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/io.h>
  6. #include <linux/list.h>
  7. #include <linux/skbuff.h>
  8. #define B43_PIO_TXCTL 0x00
  9. #define B43_PIO_TXDATA 0x02
  10. #define B43_PIO_TXQBUFSIZE 0x04
  11. #define B43_PIO_RXCTL 0x08
  12. #define B43_PIO_RXDATA 0x0A
  13. #define B43_PIO_TXCTL_WRITELO (1 << 0)
  14. #define B43_PIO_TXCTL_WRITEHI (1 << 1)
  15. #define B43_PIO_TXCTL_COMPLETE (1 << 2)
  16. #define B43_PIO_TXCTL_INIT (1 << 3)
  17. #define B43_PIO_TXCTL_SUSPEND (1 << 7)
  18. #define B43_PIO_RXCTL_DATAAVAILABLE (1 << 0)
  19. #define B43_PIO_RXCTL_READY (1 << 1)
  20. /* PIO constants */
  21. #define B43_PIO_MAXTXDEVQPACKETS 31
  22. #define B43_PIO_TXQADJUST 80
  23. /* PIO tuning knobs */
  24. #define B43_PIO_MAXTXPACKETS 256
  25. #ifdef CONFIG_B43_PIO
  26. struct b43_pioqueue;
  27. struct b43_xmitstatus;
  28. struct b43_pio_txpacket {
  29. struct b43_pioqueue *queue;
  30. struct sk_buff *skb;
  31. struct ieee80211_tx_status txstat;
  32. struct list_head list;
  33. u16 index; /* Index in the tx_packets_cache */
  34. };
  35. struct b43_pioqueue {
  36. struct b43_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 b43_pio_txpacket tx_packets_cache[B43_PIO_MAXTXPACKETS];
  66. };
  67. static inline u16 b43_pio_read(struct b43_pioqueue *queue, u16 offset)
  68. {
  69. return b43_read16(queue->dev, queue->mmio_base + offset);
  70. }
  71. static inline
  72. void b43_pio_write(struct b43_pioqueue *queue, u16 offset, u16 value)
  73. {
  74. b43_write16(queue->dev, queue->mmio_base + offset, value);
  75. mmiowb();
  76. }
  77. int b43_pio_init(struct b43_wldev *dev);
  78. void b43_pio_free(struct b43_wldev *dev);
  79. int b43_pio_tx(struct b43_wldev *dev,
  80. struct sk_buff *skb, struct ieee80211_tx_control *ctl);
  81. void b43_pio_handle_txstatus(struct b43_wldev *dev,
  82. const struct b43_txstatus *status);
  83. void b43_pio_get_tx_stats(struct b43_wldev *dev,
  84. struct ieee80211_tx_queue_stats *stats);
  85. void b43_pio_rx(struct b43_pioqueue *queue);
  86. /* Suspend TX queue in hardware. */
  87. void b43_pio_tx_suspend(struct b43_pioqueue *queue);
  88. void b43_pio_tx_resume(struct b43_pioqueue *queue);
  89. /* Suspend (freeze) the TX tasklet (software level). */
  90. void b43_pio_freeze_txqueues(struct b43_wldev *dev);
  91. void b43_pio_thaw_txqueues(struct b43_wldev *dev);
  92. #else /* CONFIG_B43_PIO */
  93. static inline int b43_pio_init(struct b43_wldev *dev)
  94. {
  95. return 0;
  96. }
  97. static inline void b43_pio_free(struct b43_wldev *dev)
  98. {
  99. }
  100. static inline
  101. int b43_pio_tx(struct b43_wldev *dev,
  102. struct sk_buff *skb, struct ieee80211_tx_control *ctl)
  103. {
  104. return 0;
  105. }
  106. static inline
  107. void b43_pio_handle_txstatus(struct b43_wldev *dev,
  108. const struct b43_txstatus *status)
  109. {
  110. }
  111. static inline
  112. void b43_pio_get_tx_stats(struct b43_wldev *dev,
  113. struct ieee80211_tx_queue_stats *stats)
  114. {
  115. }
  116. static inline void b43_pio_rx(struct b43_pioqueue *queue)
  117. {
  118. }
  119. static inline void b43_pio_tx_suspend(struct b43_pioqueue *queue)
  120. {
  121. }
  122. static inline void b43_pio_tx_resume(struct b43_pioqueue *queue)
  123. {
  124. }
  125. static inline void b43_pio_freeze_txqueues(struct b43_wldev *dev)
  126. {
  127. }
  128. static inline void b43_pio_thaw_txqueues(struct b43_wldev *dev)
  129. {
  130. }
  131. #endif /* CONFIG_B43_PIO */
  132. #endif /* B43_PIO_H_ */