bcm43xx_pio.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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_WRITEHI (1 << 0)
  13. #define BCM43xx_PIO_TXCTL_WRITELO (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. need_workarounds:1; /* 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 bcm43xx_pio_txpacket tx_packets_cache[BCM43xx_PIO_MAXTXPACKETS];
  65. };
  66. static inline
  67. u16 bcm43xx_pio_read(struct bcm43xx_pioqueue *queue,
  68. u16 offset)
  69. {
  70. return bcm43xx_read16(queue->bcm, queue->mmio_base + offset);
  71. }
  72. static inline
  73. void bcm43xx_pio_write(struct bcm43xx_pioqueue *queue,
  74. u16 offset, u16 value)
  75. {
  76. bcm43xx_write16(queue->bcm, queue->mmio_base + offset, value);
  77. }
  78. int bcm43xx_pio_init(struct bcm43xx_private *bcm);
  79. void bcm43xx_pio_free(struct bcm43xx_private *bcm);
  80. int bcm43xx_pio_tx(struct bcm43xx_private *bcm,
  81. struct ieee80211_txb *txb);
  82. void bcm43xx_pio_handle_xmitstatus(struct bcm43xx_private *bcm,
  83. struct bcm43xx_xmitstatus *status);
  84. void bcm43xx_pio_rx(struct bcm43xx_pioqueue *queue);
  85. #else /* CONFIG_BCM43XX_PIO */
  86. static inline
  87. int bcm43xx_pio_init(struct bcm43xx_private *bcm)
  88. {
  89. return 0;
  90. }
  91. static inline
  92. void bcm43xx_pio_free(struct bcm43xx_private *bcm)
  93. {
  94. }
  95. static inline
  96. int bcm43xx_pio_tx(struct bcm43xx_private *bcm,
  97. struct ieee80211_txb *txb)
  98. {
  99. return 0;
  100. }
  101. static inline
  102. void bcm43xx_pio_handle_xmitstatus(struct bcm43xx_private *bcm,
  103. struct bcm43xx_xmitstatus *status)
  104. {
  105. }
  106. static inline
  107. void bcm43xx_pio_rx(struct bcm43xx_pioqueue *queue)
  108. {
  109. }
  110. #endif /* CONFIG_BCM43XX_PIO */
  111. #endif /* BCM43xx_PIO_H_ */