pio.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef B43_PIO_H_
  3. #define B43_PIO_H_
  4. #include "b43.h"
  5. #include <linux/interrupt.h>
  6. #include <linux/io.h>
  7. #include <linux/list.h>
  8. #include <linux/skbuff.h>
  9. /*** Registers for PIO queues up to revision 7. ***/
  10. /* TX queue. */
  11. #define B43_PIO_TXCTL 0x00
  12. #define B43_PIO_TXCTL_WRITELO 0x0001
  13. #define B43_PIO_TXCTL_WRITEHI 0x0002
  14. #define B43_PIO_TXCTL_EOF 0x0004
  15. #define B43_PIO_TXCTL_FREADY 0x0008
  16. #define B43_PIO_TXCTL_FLUSHREQ 0x0020
  17. #define B43_PIO_TXCTL_FLUSHPEND 0x0040
  18. #define B43_PIO_TXCTL_SUSPREQ 0x0080
  19. #define B43_PIO_TXCTL_QSUSP 0x0100
  20. #define B43_PIO_TXCTL_COMMCNT 0xFC00
  21. #define B43_PIO_TXCTL_COMMCNT_SHIFT 10
  22. #define B43_PIO_TXDATA 0x02
  23. #define B43_PIO_TXQBUFSIZE 0x04
  24. /* RX queue. */
  25. #define B43_PIO_RXCTL 0x00
  26. #define B43_PIO_RXCTL_FRAMERDY 0x0001
  27. #define B43_PIO_RXCTL_DATARDY 0x0002
  28. #define B43_PIO_RXDATA 0x02
  29. /*** Registers for PIO queues revision 8 and later. ***/
  30. /* TX queue */
  31. #define B43_PIO8_TXCTL 0x00
  32. #define B43_PIO8_TXCTL_0_7 0x00000001
  33. #define B43_PIO8_TXCTL_8_15 0x00000002
  34. #define B43_PIO8_TXCTL_16_23 0x00000004
  35. #define B43_PIO8_TXCTL_24_31 0x00000008
  36. #define B43_PIO8_TXCTL_EOF 0x00000010
  37. #define B43_PIO8_TXCTL_FREADY 0x00000080
  38. #define B43_PIO8_TXCTL_SUSPREQ 0x00000100
  39. #define B43_PIO8_TXCTL_QSUSP 0x00000200
  40. #define B43_PIO8_TXCTL_FLUSHREQ 0x00000400
  41. #define B43_PIO8_TXCTL_FLUSHPEND 0x00000800
  42. #define B43_PIO8_TXDATA 0x04
  43. /* RX queue */
  44. #define B43_PIO8_RXCTL 0x00
  45. #define B43_PIO8_RXCTL_FRAMERDY 0x00000001
  46. #define B43_PIO8_RXCTL_DATARDY 0x00000002
  47. #define B43_PIO8_RXDATA 0x04
  48. /* The maximum number of TX-packets the HW can handle. */
  49. #define B43_PIO_MAX_NR_TXPACKETS 32
  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. /* Shortcut to the 802.11 core revision. This is to
  80. * avoid horrible pointer dereferencing in the fastpaths. */
  81. u8 rev;
  82. };
  83. struct b43_pio_rxqueue {
  84. struct b43_wldev *dev;
  85. u16 mmio_base;
  86. /* Shortcut to the 802.11 core revision. This is to
  87. * avoid horrible pointer dereferencing in the fastpaths. */
  88. u8 rev;
  89. };
  90. static inline u16 b43_piotx_read16(struct b43_pio_txqueue *q, u16 offset)
  91. {
  92. return b43_read16(q->dev, q->mmio_base + offset);
  93. }
  94. static inline u32 b43_piotx_read32(struct b43_pio_txqueue *q, u16 offset)
  95. {
  96. return b43_read32(q->dev, q->mmio_base + offset);
  97. }
  98. static inline void b43_piotx_write16(struct b43_pio_txqueue *q,
  99. u16 offset, u16 value)
  100. {
  101. b43_write16(q->dev, q->mmio_base + offset, value);
  102. }
  103. static inline void b43_piotx_write32(struct b43_pio_txqueue *q,
  104. u16 offset, u32 value)
  105. {
  106. b43_write32(q->dev, q->mmio_base + offset, value);
  107. }
  108. static inline u16 b43_piorx_read16(struct b43_pio_rxqueue *q, u16 offset)
  109. {
  110. return b43_read16(q->dev, q->mmio_base + offset);
  111. }
  112. static inline u32 b43_piorx_read32(struct b43_pio_rxqueue *q, u16 offset)
  113. {
  114. return b43_read32(q->dev, q->mmio_base + offset);
  115. }
  116. static inline void b43_piorx_write16(struct b43_pio_rxqueue *q,
  117. u16 offset, u16 value)
  118. {
  119. b43_write16(q->dev, q->mmio_base + offset, value);
  120. }
  121. static inline void b43_piorx_write32(struct b43_pio_rxqueue *q,
  122. u16 offset, u32 value)
  123. {
  124. b43_write32(q->dev, q->mmio_base + offset, value);
  125. }
  126. int b43_pio_init(struct b43_wldev *dev);
  127. void b43_pio_free(struct b43_wldev *dev);
  128. int b43_pio_tx(struct b43_wldev *dev, struct sk_buff *skb);
  129. void b43_pio_handle_txstatus(struct b43_wldev *dev,
  130. const struct b43_txstatus *status);
  131. void b43_pio_rx(struct b43_pio_rxqueue *q);
  132. void b43_pio_tx_suspend(struct b43_wldev *dev);
  133. void b43_pio_tx_resume(struct b43_wldev *dev);
  134. #endif /* B43_PIO_H_ */