6 #include <linux/interrupt.h>
7 #include <linux/list.h>
8 #include <linux/skbuff.h>
11 #define BCM43xx_PIO_TXCTL 0x00
12 #define BCM43xx_PIO_TXDATA 0x02
13 #define BCM43xx_PIO_TXQBUFSIZE 0x04
14 #define BCM43xx_PIO_RXCTL 0x08
15 #define BCM43xx_PIO_RXDATA 0x0A
17 #define BCM43xx_PIO_TXCTL_WRITELO (1 << 0)
18 #define BCM43xx_PIO_TXCTL_WRITEHI (1 << 1)
19 #define BCM43xx_PIO_TXCTL_COMPLETE (1 << 2)
20 #define BCM43xx_PIO_TXCTL_INIT (1 << 3)
21 #define BCM43xx_PIO_TXCTL_SUSPEND (1 << 7)
23 #define BCM43xx_PIO_RXCTL_DATAAVAILABLE (1 << 0)
24 #define BCM43xx_PIO_RXCTL_READY (1 << 1)
27 #define BCM43xx_PIO_MAXTXDEVQPACKETS 31
28 #define BCM43xx_PIO_TXQADJUST 80
30 /* PIO tuning knobs */
31 #define BCM43xx_PIO_MAXTXPACKETS 256
35 #ifdef CONFIG_BCM43XX_MAC80211_PIO
38 struct bcm43xx_pioqueue
;
39 struct bcm43xx_xmitstatus
;
41 struct bcm43xx_pio_txpacket
{
42 struct bcm43xx_pioqueue
*queue
;
44 struct ieee80211_tx_status txstat
;
45 struct list_head list
;
48 #define pio_txpacket_getindex(packet) ((int)((packet) - (packet)->queue->tx_packets_cache))
50 struct bcm43xx_pioqueue
{
51 struct bcm43xx_wldev
*dev
;
56 need_workarounds
:1; /* Workarounds needed for core.rev < 3 */
58 /* Adjusted size of the device internal TX buffer. */
60 /* Used octets of the device internal TX buffer. */
62 /* Used packet slots in the device internal TX buffer. */
64 /* Packets from the txfree list can
65 * be taken on incoming TX requests.
67 struct list_head txfree
;
68 unsigned int nr_txfree
;
69 /* Packets on the txqueue are queued,
70 * but not completely written to the chip, yet.
72 struct list_head txqueue
;
73 /* Packets on the txrunning queue are completely
74 * posted to the device. We are waiting for the txstatus.
76 struct list_head txrunning
;
77 /* Total number or packets sent.
78 * (This counter can obviously wrap).
80 unsigned int nr_tx_packets
;
81 struct tasklet_struct txtask
;
82 struct bcm43xx_pio_txpacket tx_packets_cache
[BCM43xx_PIO_MAXTXPACKETS
];
86 u16
bcm43xx_pio_read(struct bcm43xx_pioqueue
*queue
,
89 return bcm43xx_read16(queue
->dev
, queue
->mmio_base
+ offset
);
93 void bcm43xx_pio_write(struct bcm43xx_pioqueue
*queue
,
94 u16 offset
, u16 value
)
96 bcm43xx_write16(queue
->dev
, queue
->mmio_base
+ offset
, value
);
101 int bcm43xx_pio_init(struct bcm43xx_wldev
*dev
);
102 void bcm43xx_pio_free(struct bcm43xx_wldev
*dev
);
104 int bcm43xx_pio_tx(struct bcm43xx_wldev
*dev
,
106 struct ieee80211_tx_control
*ctl
);
107 void bcm43xx_pio_handle_txstatus(struct bcm43xx_wldev
*dev
,
108 const struct bcm43xx_txstatus
*status
);
109 void bcm43xx_pio_get_tx_stats(struct bcm43xx_wldev
*dev
,
110 struct ieee80211_tx_queue_stats
*stats
);
111 void bcm43xx_pio_rx(struct bcm43xx_pioqueue
*queue
);
113 /* Suspend TX queue in hardware. */
114 void bcm43xx_pio_tx_suspend(struct bcm43xx_pioqueue
*queue
);
115 void bcm43xx_pio_tx_resume(struct bcm43xx_pioqueue
*queue
);
116 /* Suspend (freeze) the TX tasklet (software level). */
117 void bcm43xx_pio_freeze_txqueues(struct bcm43xx_wldev
*dev
);
118 void bcm43xx_pio_thaw_txqueues(struct bcm43xx_wldev
*dev
);
120 #else /* CONFIG_BCM43XX_MAC80211_PIO */
123 int bcm43xx_pio_init(struct bcm43xx_wldev
*dev
)
128 void bcm43xx_pio_free(struct bcm43xx_wldev
*dev
)
132 int bcm43xx_pio_tx(struct bcm43xx_wldev
*dev
,
134 struct ieee80211_tx_control
*ctl
)
139 void bcm43xx_pio_handle_txstatus(struct bcm43xx_wldev
*dev
,
140 const struct bcm43xx_txstatus
*status
)
144 void bcm43xx_pio_get_tx_stats(struct bcm43xx_wldev
*dev
,
145 struct ieee80211_tx_queue_stats
*stats
)
149 void bcm43xx_pio_rx(struct bcm43xx_pioqueue
*queue
)
153 void bcm43xx_pio_tx_suspend(struct bcm43xx_pioqueue
*queue
)
157 void bcm43xx_pio_tx_resume(struct bcm43xx_pioqueue
*queue
)
161 void bcm43xx_pio_freeze_txqueues(struct bcm43xx_wldev
*dev
)
165 void bcm43xx_pio_thaw_txqueues(struct bcm43xx_wldev
*dev
)
169 #endif /* CONFIG_BCM43XX_MAC80211_PIO */
170 #endif /* BCM43xx_PIO_H_ */