blob: 464fec05a06d667ba9a3575abee51da12402e9b7 [file] [log] [blame]
Larry Finger75388ac2007-09-25 16:46:54 -07001#ifndef B43legacy_PIO_H_
2#define B43legacy_PIO_H_
3
4#include "b43legacy.h"
5
6#include <linux/interrupt.h>
7#include <linux/list.h>
8#include <linux/skbuff.h>
9
10
11#define B43legacy_PIO_TXCTL 0x00
12#define B43legacy_PIO_TXDATA 0x02
13#define B43legacy_PIO_TXQBUFSIZE 0x04
14#define B43legacy_PIO_RXCTL 0x08
15#define B43legacy_PIO_RXDATA 0x0A
16
17#define B43legacy_PIO_TXCTL_WRITELO (1 << 0)
18#define B43legacy_PIO_TXCTL_WRITEHI (1 << 1)
19#define B43legacy_PIO_TXCTL_COMPLETE (1 << 2)
20#define B43legacy_PIO_TXCTL_INIT (1 << 3)
21#define B43legacy_PIO_TXCTL_SUSPEND (1 << 7)
22
23#define B43legacy_PIO_RXCTL_DATAAVAILABLE (1 << 0)
24#define B43legacy_PIO_RXCTL_READY (1 << 1)
25
26/* PIO constants */
27#define B43legacy_PIO_MAXTXDEVQPACKETS 31
28#define B43legacy_PIO_TXQADJUST 80
29
30/* PIO tuning knobs */
31#define B43legacy_PIO_MAXTXPACKETS 256
32
33
34
35#ifdef CONFIG_B43LEGACY_PIO
36
37
38struct b43legacy_pioqueue;
39struct b43legacy_xmitstatus;
40
41struct b43legacy_pio_txpacket {
42 struct b43legacy_pioqueue *queue;
43 struct sk_buff *skb;
Larry Finger75388ac2007-09-25 16:46:54 -070044 struct list_head list;
45};
46
47#define pio_txpacket_getindex(packet) ((int)((packet) - \
48 (packet)->queue->tx_packets_cache))
49
50struct b43legacy_pioqueue {
51 struct b43legacy_wldev *dev;
52 u16 mmio_base;
53
54 bool tx_suspended;
55 bool tx_frozen;
56 bool need_workarounds; /* Workarounds needed for core.rev < 3 */
57
58 /* Adjusted size of the device internal TX buffer. */
59 u16 tx_devq_size;
60 /* Used octets of the device internal TX buffer. */
61 u16 tx_devq_used;
62 /* Used packet slots in the device internal TX buffer. */
63 u8 tx_devq_packets;
64 /* Packets from the txfree list can
65 * be taken on incoming TX requests.
66 */
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.
71 */
72 struct list_head txqueue;
73 /* Packets on the txrunning queue are completely
74 * posted to the device. We are waiting for the txstatus.
75 */
76 struct list_head txrunning;
77 /* Total number or packets sent.
78 * (This counter can obviously wrap).
79 */
80 unsigned int nr_tx_packets;
81 struct tasklet_struct txtask;
82 struct b43legacy_pio_txpacket
83 tx_packets_cache[B43legacy_PIO_MAXTXPACKETS];
84};
85
86static inline
87u16 b43legacy_pio_read(struct b43legacy_pioqueue *queue,
88 u16 offset)
89{
90 return b43legacy_read16(queue->dev, queue->mmio_base + offset);
91}
92
93static inline
94void b43legacy_pio_write(struct b43legacy_pioqueue *queue,
95 u16 offset, u16 value)
96{
97 b43legacy_write16(queue->dev, queue->mmio_base + offset, value);
98 mmiowb();
99}
100
101
102int b43legacy_pio_init(struct b43legacy_wldev *dev);
103void b43legacy_pio_free(struct b43legacy_wldev *dev);
104
105int b43legacy_pio_tx(struct b43legacy_wldev *dev,
Johannes Berge039fa42008-05-15 12:55:29 +0200106 struct sk_buff *skb);
Larry Finger75388ac2007-09-25 16:46:54 -0700107void b43legacy_pio_handle_txstatus(struct b43legacy_wldev *dev,
108 const struct b43legacy_txstatus *status);
109void b43legacy_pio_get_tx_stats(struct b43legacy_wldev *dev,
110 struct ieee80211_tx_queue_stats *stats);
111void b43legacy_pio_rx(struct b43legacy_pioqueue *queue);
112
113/* Suspend TX queue in hardware. */
114void b43legacy_pio_tx_suspend(struct b43legacy_pioqueue *queue);
115void b43legacy_pio_tx_resume(struct b43legacy_pioqueue *queue);
116/* Suspend (freeze) the TX tasklet (software level). */
117void b43legacy_pio_freeze_txqueues(struct b43legacy_wldev *dev);
118void b43legacy_pio_thaw_txqueues(struct b43legacy_wldev *dev);
119
120#else /* CONFIG_B43LEGACY_PIO */
121
122static inline
123int b43legacy_pio_init(struct b43legacy_wldev *dev)
124{
125 return 0;
126}
127static inline
128void b43legacy_pio_free(struct b43legacy_wldev *dev)
129{
130}
131static inline
132int b43legacy_pio_tx(struct b43legacy_wldev *dev,
Johannes Berg553381c2008-05-24 20:07:55 +0200133 struct sk_buff *skb)
Larry Finger75388ac2007-09-25 16:46:54 -0700134{
135 return 0;
136}
137static inline
138void b43legacy_pio_handle_txstatus(struct b43legacy_wldev *dev,
139 const struct b43legacy_txstatus *status)
140{
141}
142static inline
143void b43legacy_pio_get_tx_stats(struct b43legacy_wldev *dev,
144 struct ieee80211_tx_queue_stats *stats)
145{
146}
147static inline
148void b43legacy_pio_rx(struct b43legacy_pioqueue *queue)
149{
150}
151static inline
152void b43legacy_pio_tx_suspend(struct b43legacy_pioqueue *queue)
153{
154}
155static inline
156void b43legacy_pio_tx_resume(struct b43legacy_pioqueue *queue)
157{
158}
159static inline
160void b43legacy_pio_freeze_txqueues(struct b43legacy_wldev *dev)
161{
162}
163static inline
164void b43legacy_pio_thaw_txqueues(struct b43legacy_wldev *dev)
165{
166}
167
168#endif /* CONFIG_B43LEGACY_PIO */
169#endif /* B43legacy_PIO_H_ */