pio.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. #ifndef B43_PIO_H_
  2. #define B43_PIO_H_
  3. #include "b43.h"
  4. #include <linux/interrupt.h>
  5. #include <linux/list.h>
  6. #include <linux/skbuff.h>
  7. #define B43_PIO_TXCTL 0x00
  8. #define B43_PIO_TXDATA 0x02
  9. #define B43_PIO_TXQBUFSIZE 0x04
  10. #define B43_PIO_RXCTL 0x08
  11. #define B43_PIO_RXDATA 0x0A
  12. #define B43_PIO_TXCTL_WRITELO (1 << 0)
  13. #define B43_PIO_TXCTL_WRITEHI (1 << 1)
  14. #define B43_PIO_TXCTL_COMPLETE (1 << 2)
  15. #define B43_PIO_TXCTL_INIT (1 << 3)
  16. #define B43_PIO_TXCTL_SUSPEND (1 << 7)
  17. #define B43_PIO_RXCTL_DATAAVAILABLE (1 << 0)
  18. #define B43_PIO_RXCTL_READY (1 << 1)
  19. /* PIO constants */
  20. #define B43_PIO_MAXTXDEVQPACKETS 31
  21. #define B43_PIO_TXQADJUST 80
  22. /* PIO tuning knobs */
  23. #define B43_PIO_MAXTXPACKETS 256
  24. #ifdef CONFIG_B43_PIO
  25. struct b43_pioqueue;
  26. struct b43_xmitstatus;
  27. struct b43_pio_txpacket {
  28. struct b43_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) - (packet)->queue->tx_packets_cache))
  34. struct b43_pioqueue {
  35. struct b43_wldev *dev;
  36. u16 mmio_base;
  37. bool tx_suspended;
  38. bool tx_frozen;
  39. bool need_workarounds; /* Workarounds needed for core.rev < 3 */
  40. /* Adjusted size of the device internal TX buffer. */
  41. u16 tx_devq_size;
  42. /* Used octets of the device internal TX buffer. */
  43. u16 tx_devq_used;
  44. /* Used packet slots in the device internal TX buffer. */
  45. u8 tx_devq_packets;
  46. /* Packets from the txfree list can
  47. * be taken on incoming TX requests.
  48. */
  49. struct list_head txfree;
  50. unsigned int nr_txfree;
  51. /* Packets on the txqueue are queued,
  52. * but not completely written to the chip, yet.
  53. */
  54. struct list_head txqueue;
  55. /* Packets on the txrunning queue are completely
  56. * posted to the device. We are waiting for the txstatus.
  57. */
  58. struct list_head txrunning;
  59. /* Total number or packets sent.
  60. * (This counter can obviously wrap).
  61. */
  62. unsigned int nr_tx_packets;
  63. struct tasklet_struct txtask;
  64. struct b43_pio_txpacket tx_packets_cache[B43_PIO_MAXTXPACKETS];
  65. };
  66. static inline u16 b43_pio_read(struct b43_pioqueue *queue, u16 offset)
  67. {
  68. return b43_read16(queue->dev, queue->mmio_base + offset);
  69. }
  70. static inline
  71. void b43_pio_write(struct b43_pioqueue *queue, u16 offset, u16 value)
  72. {
  73. b43_write16(queue->dev, queue->mmio_base + offset, value);
  74. mmiowb();
  75. }
  76. int b43_pio_init(struct b43_wldev *dev);
  77. void b43_pio_free(struct b43_wldev *dev);
  78. int b43_pio_tx(struct b43_wldev *dev,
  79. struct sk_buff *skb, struct ieee80211_tx_control *ctl);
  80. void b43_pio_handle_txstatus(struct b43_wldev *dev,
  81. const struct b43_txstatus *status);
  82. void b43_pio_get_tx_stats(struct b43_wldev *dev,
  83. struct ieee80211_tx_queue_stats *stats);
  84. void b43_pio_rx(struct b43_pioqueue *queue);
  85. /* Suspend TX queue in hardware. */
  86. void b43_pio_tx_suspend(struct b43_pioqueue *queue);
  87. void b43_pio_tx_resume(struct b43_pioqueue *queue);
  88. /* Suspend (freeze) the TX tasklet (software level). */
  89. void b43_pio_freeze_txqueues(struct b43_wldev *dev);
  90. void b43_pio_thaw_txqueues(struct b43_wldev *dev);
  91. #else /* CONFIG_B43_PIO */
  92. static inline int b43_pio_init(struct b43_wldev *dev)
  93. {
  94. return 0;
  95. }
  96. static inline void b43_pio_free(struct b43_wldev *dev)
  97. {
  98. }
  99. static inline
  100. int b43_pio_tx(struct b43_wldev *dev,
  101. struct sk_buff *skb, struct ieee80211_tx_control *ctl)
  102. {
  103. return 0;
  104. }
  105. static inline
  106. void b43_pio_handle_txstatus(struct b43_wldev *dev,
  107. const struct b43_txstatus *status)
  108. {
  109. }
  110. static inline
  111. void b43_pio_get_tx_stats(struct b43_wldev *dev,
  112. struct ieee80211_tx_queue_stats *stats)
  113. {
  114. }
  115. static inline void b43_pio_rx(struct b43_pioqueue *queue)
  116. {
  117. }
  118. static inline void b43_pio_tx_suspend(struct b43_pioqueue *queue)
  119. {
  120. }
  121. static inline void b43_pio_tx_resume(struct b43_pioqueue *queue)
  122. {
  123. }
  124. static inline void b43_pio_freeze_txqueues(struct b43_wldev *dev)
  125. {
  126. }
  127. static inline void b43_pio_thaw_txqueues(struct b43_wldev *dev)
  128. {
  129. }
  130. #endif /* CONFIG_B43_PIO */
  131. #endif /* B43_PIO_H_ */