bcm43xx_pio.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. #ifndef BCM43xx_PIO_H_
  2. #define BCM43xx_PIO_H_
  3. #include "bcm43xx.h"
  4. #include <linux/interrupt.h>
  5. #include <linux/list.h>
  6. #include <linux/skbuff.h>
  7. #define BCM43xx_PIO_TXCTL 0x00
  8. #define BCM43xx_PIO_TXDATA 0x02
  9. #define BCM43xx_PIO_TXQBUFSIZE 0x04
  10. #define BCM43xx_PIO_RXCTL 0x08
  11. #define BCM43xx_PIO_RXDATA 0x0A
  12. #define BCM43xx_PIO_TXCTL_WRITELO (1 << 0)
  13. #define BCM43xx_PIO_TXCTL_WRITEHI (1 << 1)
  14. #define BCM43xx_PIO_TXCTL_COMPLETE (1 << 2)
  15. #define BCM43xx_PIO_TXCTL_INIT (1 << 3)
  16. #define BCM43xx_PIO_TXCTL_SUSPEND (1 << 7)
  17. #define BCM43xx_PIO_RXCTL_DATAAVAILABLE (1 << 0)
  18. #define BCM43xx_PIO_RXCTL_READY (1 << 1)
  19. /* PIO constants */
  20. #define BCM43xx_PIO_MAXTXDEVQPACKETS 31
  21. #define BCM43xx_PIO_TXQADJUST 80
  22. /* PIO tuning knobs */
  23. #define BCM43xx_PIO_MAXTXPACKETS 256
  24. #ifdef CONFIG_BCM43XX_PIO
  25. struct bcm43xx_pioqueue;
  26. struct bcm43xx_xmitstatus;
  27. struct bcm43xx_pio_txpacket {
  28. struct bcm43xx_pioqueue *queue;
  29. struct ieee80211_txb *txb;
  30. struct list_head list;
  31. u8 xmitted_frags;
  32. u16 xmitted_octets;
  33. };
  34. #define pio_txpacket_getindex(packet) ((int)((packet) - (packet)->queue->tx_packets_cache))
  35. struct bcm43xx_pioqueue {
  36. struct bcm43xx_private *bcm;
  37. u16 mmio_base;
  38. u8 tx_suspended:1,
  39. tx_frozen:1,
  40. need_workarounds:1; /* 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 bcm43xx_pio_txpacket tx_packets_cache[BCM43xx_PIO_MAXTXPACKETS];
  66. };
  67. static inline
  68. u16 bcm43xx_pio_read(struct bcm43xx_pioqueue *queue,
  69. u16 offset)
  70. {
  71. return bcm43xx_read16(queue->bcm, queue->mmio_base + offset);
  72. }
  73. static inline
  74. void bcm43xx_pio_write(struct bcm43xx_pioqueue *queue,
  75. u16 offset, u16 value)
  76. {
  77. bcm43xx_write16(queue->bcm, queue->mmio_base + offset, value);
  78. mmiowb();
  79. }
  80. int bcm43xx_pio_init(struct bcm43xx_private *bcm);
  81. void bcm43xx_pio_free(struct bcm43xx_private *bcm);
  82. int bcm43xx_pio_tx(struct bcm43xx_private *bcm,
  83. struct ieee80211_txb *txb);
  84. void bcm43xx_pio_handle_xmitstatus(struct bcm43xx_private *bcm,
  85. struct bcm43xx_xmitstatus *status);
  86. void bcm43xx_pio_rx(struct bcm43xx_pioqueue *queue);
  87. /* Suspend a TX queue on hardware level. */
  88. void bcm43xx_pio_tx_suspend(struct bcm43xx_pioqueue *queue);
  89. void bcm43xx_pio_tx_resume(struct bcm43xx_pioqueue *queue);
  90. /* Suspend (freeze) the TX tasklet (software level). */
  91. void bcm43xx_pio_freeze_txqueues(struct bcm43xx_private *bcm);
  92. void bcm43xx_pio_thaw_txqueues(struct bcm43xx_private *bcm);
  93. #else /* CONFIG_BCM43XX_PIO */
  94. static inline
  95. int bcm43xx_pio_init(struct bcm43xx_private *bcm)
  96. {
  97. return 0;
  98. }
  99. static inline
  100. void bcm43xx_pio_free(struct bcm43xx_private *bcm)
  101. {
  102. }
  103. static inline
  104. int bcm43xx_pio_tx(struct bcm43xx_private *bcm,
  105. struct ieee80211_txb *txb)
  106. {
  107. return 0;
  108. }
  109. static inline
  110. void bcm43xx_pio_handle_xmitstatus(struct bcm43xx_private *bcm,
  111. struct bcm43xx_xmitstatus *status)
  112. {
  113. }
  114. static inline
  115. void bcm43xx_pio_rx(struct bcm43xx_pioqueue *queue)
  116. {
  117. }
  118. static inline
  119. void bcm43xx_pio_tx_suspend(struct bcm43xx_pioqueue *queue)
  120. {
  121. }
  122. static inline
  123. void bcm43xx_pio_tx_resume(struct bcm43xx_pioqueue *queue)
  124. {
  125. }
  126. static inline
  127. void bcm43xx_pio_freeze_txqueues(struct bcm43xx_private *bcm)
  128. {
  129. }
  130. static inline
  131. void bcm43xx_pio_thaw_txqueues(struct bcm43xx_private *bcm)
  132. {
  133. }
  134. #endif /* CONFIG_BCM43XX_PIO */
  135. #endif /* BCM43xx_PIO_H_ */