pio.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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. /* The status meta data. */
  56. struct ieee80211_tx_status txstat;
  57. /* Index in the (struct b43_pio_txqueue)->packets array. */
  58. u8 index;
  59. struct list_head list;
  60. };
  61. struct b43_pio_txqueue {
  62. struct b43_wldev *dev;
  63. spinlock_t lock;
  64. u16 mmio_base;
  65. /* The device queue buffer size in bytes. */
  66. u16 buffer_size;
  67. /* The number of used bytes in the device queue buffer. */
  68. u16 buffer_used;
  69. /* The number of packets that can still get queued.
  70. * This is decremented on queueing a packet and incremented
  71. * after receiving the transmit status. */
  72. u16 free_packet_slots;
  73. /* True, if the mac80211 queue was stopped due to overflow at TX. */
  74. bool stopped;
  75. /* Our b43 queue index number */
  76. u8 index;
  77. /* The mac80211 QoS queue priority. */
  78. u8 queue_prio;
  79. /* Buffer for TX packet meta data. */
  80. struct b43_pio_txpacket packets[B43_PIO_MAX_NR_TXPACKETS];
  81. struct list_head packets_list;
  82. /* Total number of transmitted packets. */
  83. unsigned int nr_tx_packets;
  84. /* Shortcut to the 802.11 core revision. This is to
  85. * avoid horrible pointer dereferencing in the fastpaths. */
  86. u8 rev;
  87. };
  88. struct b43_pio_rxqueue {
  89. struct b43_wldev *dev;
  90. spinlock_t lock;
  91. u16 mmio_base;
  92. /* Work to reduce latency issues on RX. */
  93. struct work_struct rx_work;
  94. /* Shortcut to the 802.11 core revision. This is to
  95. * avoid horrible pointer dereferencing in the fastpaths. */
  96. u8 rev;
  97. };
  98. static inline u16 b43_piotx_read16(struct b43_pio_txqueue *q, u16 offset)
  99. {
  100. return b43_read16(q->dev, q->mmio_base + offset);
  101. }
  102. static inline u32 b43_piotx_read32(struct b43_pio_txqueue *q, u16 offset)
  103. {
  104. return b43_read32(q->dev, q->mmio_base + offset);
  105. }
  106. static inline void b43_piotx_write16(struct b43_pio_txqueue *q,
  107. u16 offset, u16 value)
  108. {
  109. b43_write16(q->dev, q->mmio_base + offset, value);
  110. }
  111. static inline void b43_piotx_write32(struct b43_pio_txqueue *q,
  112. u16 offset, u32 value)
  113. {
  114. b43_write32(q->dev, q->mmio_base + offset, value);
  115. }
  116. static inline u16 b43_piorx_read16(struct b43_pio_rxqueue *q, u16 offset)
  117. {
  118. return b43_read16(q->dev, q->mmio_base + offset);
  119. }
  120. static inline u32 b43_piorx_read32(struct b43_pio_rxqueue *q, u16 offset)
  121. {
  122. return b43_read32(q->dev, q->mmio_base + offset);
  123. }
  124. static inline void b43_piorx_write16(struct b43_pio_rxqueue *q,
  125. u16 offset, u16 value)
  126. {
  127. b43_write16(q->dev, q->mmio_base + offset, value);
  128. }
  129. static inline void b43_piorx_write32(struct b43_pio_rxqueue *q,
  130. u16 offset, u32 value)
  131. {
  132. b43_write32(q->dev, q->mmio_base + offset, value);
  133. }
  134. int b43_pio_init(struct b43_wldev *dev);
  135. void b43_pio_stop(struct b43_wldev *dev);
  136. void b43_pio_free(struct b43_wldev *dev);
  137. int b43_pio_tx(struct b43_wldev *dev,
  138. struct sk_buff *skb, struct ieee80211_tx_control *ctl);
  139. void b43_pio_handle_txstatus(struct b43_wldev *dev,
  140. const struct b43_txstatus *status);
  141. void b43_pio_get_tx_stats(struct b43_wldev *dev,
  142. struct ieee80211_tx_queue_stats *stats);
  143. void b43_pio_rx(struct b43_pio_rxqueue *q);
  144. void b43_pio_tx_suspend(struct b43_wldev *dev);
  145. void b43_pio_tx_resume(struct b43_wldev *dev);
  146. #else /* CONFIG_B43_PIO */
  147. static inline int b43_pio_init(struct b43_wldev *dev)
  148. {
  149. return 0;
  150. }
  151. static inline void b43_pio_free(struct b43_wldev *dev)
  152. {
  153. }
  154. static inline void b43_pio_stop(struct b43_wldev *dev)
  155. {
  156. }
  157. static inline int b43_pio_tx(struct b43_wldev *dev,
  158. struct sk_buff *skb,
  159. struct ieee80211_tx_control *ctl)
  160. {
  161. return 0;
  162. }
  163. static inline void b43_pio_handle_txstatus(struct b43_wldev *dev,
  164. const struct b43_txstatus *status)
  165. {
  166. }
  167. static inline void b43_pio_get_tx_stats(struct b43_wldev *dev,
  168. struct ieee80211_tx_queue_stats *stats)
  169. {
  170. }
  171. static inline void b43_pio_rx(struct b43_pio_rxqueue *q)
  172. {
  173. }
  174. static inline void b43_pio_tx_suspend(struct b43_wldev *dev)
  175. {
  176. }
  177. static inline void b43_pio_tx_resume(struct b43_wldev *dev)
  178. {
  179. }
  180. #endif /* CONFIG_B43_PIO */
  181. #endif /* B43_PIO_H_ */