pio.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. #ifndef B43legacy_PIO_H_
  2. #define B43legacy_PIO_H_
  3. #include "b43legacy.h"
  4. #include <linux/interrupt.h>
  5. #include <linux/list.h>
  6. #include <linux/skbuff.h>
  7. #define B43legacy_PIO_TXCTL 0x00
  8. #define B43legacy_PIO_TXDATA 0x02
  9. #define B43legacy_PIO_TXQBUFSIZE 0x04
  10. #define B43legacy_PIO_RXCTL 0x08
  11. #define B43legacy_PIO_RXDATA 0x0A
  12. #define B43legacy_PIO_TXCTL_WRITELO (1 << 0)
  13. #define B43legacy_PIO_TXCTL_WRITEHI (1 << 1)
  14. #define B43legacy_PIO_TXCTL_COMPLETE (1 << 2)
  15. #define B43legacy_PIO_TXCTL_INIT (1 << 3)
  16. #define B43legacy_PIO_TXCTL_SUSPEND (1 << 7)
  17. #define B43legacy_PIO_RXCTL_DATAAVAILABLE (1 << 0)
  18. #define B43legacy_PIO_RXCTL_READY (1 << 1)
  19. /* PIO constants */
  20. #define B43legacy_PIO_MAXTXDEVQPACKETS 31
  21. #define B43legacy_PIO_TXQADJUST 80
  22. /* PIO tuning knobs */
  23. #define B43legacy_PIO_MAXTXPACKETS 256
  24. #ifdef CONFIG_B43LEGACY_PIO
  25. struct b43legacy_pioqueue;
  26. struct b43legacy_xmitstatus;
  27. struct b43legacy_pio_txpacket {
  28. struct b43legacy_pioqueue *queue;
  29. struct sk_buff *skb;
  30. struct ieee80211_tx_status txstat;
  31. struct list_head list;
  32. };
  33. #define pio_txpacket_getindex(packet) ((int)((packet) - \
  34. (packet)->queue->tx_packets_cache))
  35. struct b43legacy_pioqueue {
  36. struct b43legacy_wldev *dev;
  37. u16 mmio_base;
  38. bool tx_suspended;
  39. bool tx_frozen;
  40. bool need_workarounds; /* Workarounds needed for core.rev < 3 */
  41. /* Adjusted size of the device internal TX buffer. */
  42. u16 tx_devq_size;
  43. /* Used octets of the device internal TX buffer. */
  44. u16 tx_devq_used;
  45. /* Used packet slots in the device internal TX buffer. */
  46. u8 tx_devq_packets;
  47. /* Packets from the txfree list can
  48. * be taken on incoming TX requests.
  49. */
  50. struct list_head txfree;
  51. unsigned int nr_txfree;
  52. /* Packets on the txqueue are queued,
  53. * but not completely written to the chip, yet.
  54. */
  55. struct list_head txqueue;
  56. /* Packets on the txrunning queue are completely
  57. * posted to the device. We are waiting for the txstatus.
  58. */
  59. struct list_head txrunning;
  60. /* Total number or packets sent.
  61. * (This counter can obviously wrap).
  62. */
  63. unsigned int nr_tx_packets;
  64. struct tasklet_struct txtask;
  65. struct b43legacy_pio_txpacket
  66. tx_packets_cache[B43legacy_PIO_MAXTXPACKETS];
  67. };
  68. static inline
  69. u16 b43legacy_pio_read(struct b43legacy_pioqueue *queue,
  70. u16 offset)
  71. {
  72. return b43legacy_read16(queue->dev, queue->mmio_base + offset);
  73. }
  74. static inline
  75. void b43legacy_pio_write(struct b43legacy_pioqueue *queue,
  76. u16 offset, u16 value)
  77. {
  78. b43legacy_write16(queue->dev, queue->mmio_base + offset, value);
  79. mmiowb();
  80. }
  81. int b43legacy_pio_init(struct b43legacy_wldev *dev);
  82. void b43legacy_pio_free(struct b43legacy_wldev *dev);
  83. int b43legacy_pio_tx(struct b43legacy_wldev *dev,
  84. struct sk_buff *skb,
  85. struct ieee80211_tx_control *ctl);
  86. void b43legacy_pio_handle_txstatus(struct b43legacy_wldev *dev,
  87. const struct b43legacy_txstatus *status);
  88. void b43legacy_pio_get_tx_stats(struct b43legacy_wldev *dev,
  89. struct ieee80211_tx_queue_stats *stats);
  90. void b43legacy_pio_rx(struct b43legacy_pioqueue *queue);
  91. /* Suspend TX queue in hardware. */
  92. void b43legacy_pio_tx_suspend(struct b43legacy_pioqueue *queue);
  93. void b43legacy_pio_tx_resume(struct b43legacy_pioqueue *queue);
  94. /* Suspend (freeze) the TX tasklet (software level). */
  95. void b43legacy_pio_freeze_txqueues(struct b43legacy_wldev *dev);
  96. void b43legacy_pio_thaw_txqueues(struct b43legacy_wldev *dev);
  97. #else /* CONFIG_B43LEGACY_PIO */
  98. static inline
  99. int b43legacy_pio_init(struct b43legacy_wldev *dev)
  100. {
  101. return 0;
  102. }
  103. static inline
  104. void b43legacy_pio_free(struct b43legacy_wldev *dev)
  105. {
  106. }
  107. static inline
  108. int b43legacy_pio_tx(struct b43legacy_wldev *dev,
  109. struct sk_buff *skb,
  110. struct ieee80211_tx_control *ctl)
  111. {
  112. return 0;
  113. }
  114. static inline
  115. void b43legacy_pio_handle_txstatus(struct b43legacy_wldev *dev,
  116. const struct b43legacy_txstatus *status)
  117. {
  118. }
  119. static inline
  120. void b43legacy_pio_get_tx_stats(struct b43legacy_wldev *dev,
  121. struct ieee80211_tx_queue_stats *stats)
  122. {
  123. }
  124. static inline
  125. void b43legacy_pio_rx(struct b43legacy_pioqueue *queue)
  126. {
  127. }
  128. static inline
  129. void b43legacy_pio_tx_suspend(struct b43legacy_pioqueue *queue)
  130. {
  131. }
  132. static inline
  133. void b43legacy_pio_tx_resume(struct b43legacy_pioqueue *queue)
  134. {
  135. }
  136. static inline
  137. void b43legacy_pio_freeze_txqueues(struct b43legacy_wldev *dev)
  138. {
  139. }
  140. static inline
  141. void b43legacy_pio_thaw_txqueues(struct b43legacy_wldev *dev)
  142. {
  143. }
  144. #endif /* CONFIG_B43LEGACY_PIO */
  145. #endif /* B43legacy_PIO_H_ */