pio.h 5.5 KB

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