pio.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. #ifndef B43_PIO_H_
  2. #define B43_PIO_H_
  3. #include "b43.h"
  4. #include <linux/interrupt.h>
  5. #include <linux/io.h>
  6. #include <linux/list.h>
  7. #include <linux/skbuff.h>
  8. /*** Registers for PIO queues up to revision 7. ***/
  9. /* TX queue. */
  10. #define B43_PIO_TXCTL 0x00
  11. #define B43_PIO_TXCTL_WRITELO 0x0001
  12. #define B43_PIO_TXCTL_WRITEHI 0x0002
  13. #define B43_PIO_TXCTL_EOF 0x0004
  14. #define B43_PIO_TXCTL_FREADY 0x0008
  15. #define B43_PIO_TXCTL_FLUSHREQ 0x0020
  16. #define B43_PIO_TXCTL_FLUSHPEND 0x0040
  17. #define B43_PIO_TXCTL_SUSPREQ 0x0080
  18. #define B43_PIO_TXCTL_QSUSP 0x0100
  19. #define B43_PIO_TXCTL_COMMCNT 0xFC00
  20. #define B43_PIO_TXCTL_COMMCNT_SHIFT 10
  21. #define B43_PIO_TXDATA 0x02
  22. #define B43_PIO_TXQBUFSIZE 0x04
  23. /* RX queue. */
  24. #define B43_PIO_RXCTL 0x00
  25. #define B43_PIO_RXCTL_FRAMERDY 0x0001
  26. #define B43_PIO_RXCTL_DATARDY 0x0002
  27. #define B43_PIO_RXDATA 0x02
  28. /*** Registers for PIO queues revision 8 and later. ***/
  29. /* TX queue */
  30. #define B43_PIO8_TXCTL 0x00
  31. #define B43_PIO8_TXCTL_0_7 0x00000001
  32. #define B43_PIO8_TXCTL_8_15 0x00000002
  33. #define B43_PIO8_TXCTL_16_23 0x00000004
  34. #define B43_PIO8_TXCTL_24_31 0x00000008
  35. #define B43_PIO8_TXCTL_EOF 0x00000010
  36. #define B43_PIO8_TXCTL_FREADY 0x00000080
  37. #define B43_PIO8_TXCTL_SUSPREQ 0x00000100
  38. #define B43_PIO8_TXCTL_QSUSP 0x00000200
  39. #define B43_PIO8_TXCTL_FLUSHREQ 0x00000400
  40. #define B43_PIO8_TXCTL_FLUSHPEND 0x00000800
  41. #define B43_PIO8_TXDATA 0x04
  42. /* RX queue */
  43. #define B43_PIO8_RXCTL 0x00
  44. #define B43_PIO8_RXCTL_FRAMERDY 0x00000001
  45. #define B43_PIO8_RXCTL_DATARDY 0x00000002
  46. #define B43_PIO8_RXDATA 0x04
  47. /* The maximum number of TX-packets the HW can handle. */
  48. #define B43_PIO_MAX_NR_TXPACKETS 32
  49. #ifdef CONFIG_B43_PIO
  50. struct b43_pio_txpacket {
  51. /* Pointer to the TX queue we belong to. */
  52. struct b43_pio_txqueue *queue;
  53. /* The TX data packet. */
  54. struct sk_buff *skb;
  55. /* Index in the (struct b43_pio_txqueue)->packets array. */
  56. u8 index;
  57. struct list_head list;
  58. };
  59. struct b43_pio_txqueue {
  60. struct b43_wldev *dev;
  61. u16 mmio_base;
  62. /* The device queue buffer size in bytes. */
  63. u16 buffer_size;
  64. /* The number of used bytes in the device queue buffer. */
  65. u16 buffer_used;
  66. /* The number of packets that can still get queued.
  67. * This is decremented on queueing a packet and incremented
  68. * after receiving the transmit status. */
  69. u16 free_packet_slots;
  70. /* True, if the mac80211 queue was stopped due to overflow at TX. */
  71. bool stopped;
  72. /* Our b43 queue index number */
  73. u8 index;
  74. /* The mac80211 QoS queue priority. */
  75. u8 queue_prio;
  76. /* Buffer for TX packet meta data. */
  77. struct b43_pio_txpacket packets[B43_PIO_MAX_NR_TXPACKETS];
  78. struct list_head packets_list;
  79. /* Total number of transmitted packets. */
  80. unsigned int nr_tx_packets;
  81. /* Shortcut to the 802.11 core revision. This is to
  82. * avoid horrible pointer dereferencing in the fastpaths. */
  83. u8 rev;
  84. };
  85. struct b43_pio_rxqueue {
  86. struct b43_wldev *dev;
  87. u16 mmio_base;
  88. /* Shortcut to the 802.11 core revision. This is to
  89. * avoid horrible pointer dereferencing in the fastpaths. */
  90. u8 rev;
  91. };
  92. static inline u16 b43_piotx_read16(struct b43_pio_txqueue *q, u16 offset)
  93. {
  94. return b43_read16(q->dev, q->mmio_base + offset);
  95. }
  96. static inline u32 b43_piotx_read32(struct b43_pio_txqueue *q, u16 offset)
  97. {
  98. return b43_read32(q->dev, q->mmio_base + offset);
  99. }
  100. static inline void b43_piotx_write16(struct b43_pio_txqueue *q,
  101. u16 offset, u16 value)
  102. {
  103. b43_write16(q->dev, q->mmio_base + offset, value);
  104. }
  105. static inline void b43_piotx_write32(struct b43_pio_txqueue *q,
  106. u16 offset, u32 value)
  107. {
  108. b43_write32(q->dev, q->mmio_base + offset, value);
  109. }
  110. static inline u16 b43_piorx_read16(struct b43_pio_rxqueue *q, u16 offset)
  111. {
  112. return b43_read16(q->dev, q->mmio_base + offset);
  113. }
  114. static inline u32 b43_piorx_read32(struct b43_pio_rxqueue *q, u16 offset)
  115. {
  116. return b43_read32(q->dev, q->mmio_base + offset);
  117. }
  118. static inline void b43_piorx_write16(struct b43_pio_rxqueue *q,
  119. u16 offset, u16 value)
  120. {
  121. b43_write16(q->dev, q->mmio_base + offset, value);
  122. }
  123. static inline void b43_piorx_write32(struct b43_pio_rxqueue *q,
  124. u16 offset, u32 value)
  125. {
  126. b43_write32(q->dev, q->mmio_base + offset, value);
  127. }
  128. int b43_pio_init(struct b43_wldev *dev);
  129. void b43_pio_free(struct b43_wldev *dev);
  130. int b43_pio_tx(struct b43_wldev *dev, struct sk_buff *skb);
  131. void b43_pio_handle_txstatus(struct b43_wldev *dev,
  132. const struct b43_txstatus *status);
  133. void b43_pio_get_tx_stats(struct b43_wldev *dev,
  134. struct ieee80211_tx_queue_stats *stats);
  135. void b43_pio_rx(struct b43_pio_rxqueue *q);
  136. void b43_pio_tx_suspend(struct b43_wldev *dev);
  137. void b43_pio_tx_resume(struct b43_wldev *dev);
  138. #else /* CONFIG_B43_PIO */
  139. static inline int b43_pio_init(struct b43_wldev *dev)
  140. {
  141. return 0;
  142. }
  143. static inline void b43_pio_free(struct b43_wldev *dev)
  144. {
  145. }
  146. static inline void b43_pio_stop(struct b43_wldev *dev)
  147. {
  148. }
  149. static inline int b43_pio_tx(struct b43_wldev *dev,
  150. struct sk_buff *skb)
  151. {
  152. return 0;
  153. }
  154. static inline void b43_pio_handle_txstatus(struct b43_wldev *dev,
  155. const struct b43_txstatus *status)
  156. {
  157. }
  158. static inline void b43_pio_get_tx_stats(struct b43_wldev *dev,
  159. struct ieee80211_tx_queue_stats *stats)
  160. {
  161. }
  162. static inline void b43_pio_rx(struct b43_pio_rxqueue *q)
  163. {
  164. }
  165. static inline void b43_pio_tx_suspend(struct b43_wldev *dev)
  166. {
  167. }
  168. static inline void b43_pio_tx_resume(struct b43_wldev *dev)
  169. {
  170. }
  171. #endif /* CONFIG_B43_PIO */
  172. #endif /* B43_PIO_H_ */