blob: 34a44c1b6314126f1929bb2feaf6acf912428de4 [file] [log] [blame]
Michael Buesche4d6b792007-09-18 15:39:42 -04001#ifndef B43_PIO_H_
2#define B43_PIO_H_
3
4#include "b43.h"
5
6#include <linux/interrupt.h>
7#include <linux/list.h>
8#include <linux/skbuff.h>
9
10#define B43_PIO_TXCTL 0x00
11#define B43_PIO_TXDATA 0x02
12#define B43_PIO_TXQBUFSIZE 0x04
13#define B43_PIO_RXCTL 0x08
14#define B43_PIO_RXDATA 0x0A
15
16#define B43_PIO_TXCTL_WRITELO (1 << 0)
17#define B43_PIO_TXCTL_WRITEHI (1 << 1)
18#define B43_PIO_TXCTL_COMPLETE (1 << 2)
19#define B43_PIO_TXCTL_INIT (1 << 3)
20#define B43_PIO_TXCTL_SUSPEND (1 << 7)
21
22#define B43_PIO_RXCTL_DATAAVAILABLE (1 << 0)
23#define B43_PIO_RXCTL_READY (1 << 1)
24
25/* PIO constants */
26#define B43_PIO_MAXTXDEVQPACKETS 31
27#define B43_PIO_TXQADJUST 80
28
29/* PIO tuning knobs */
30#define B43_PIO_MAXTXPACKETS 256
31
32#ifdef CONFIG_B43_PIO
33
34struct b43_pioqueue;
35struct b43_xmitstatus;
36
37struct b43_pio_txpacket {
38 struct b43_pioqueue *queue;
39 struct sk_buff *skb;
40 struct ieee80211_tx_status txstat;
41 struct list_head list;
Michael Buesch1a094042007-09-20 11:13:40 -070042 u16 index; /* Index in the tx_packets_cache */
Michael Buesche4d6b792007-09-18 15:39:42 -040043};
44
Michael Buesche4d6b792007-09-18 15:39:42 -040045struct b43_pioqueue {
46 struct b43_wldev *dev;
47 u16 mmio_base;
48
49 bool tx_suspended;
50 bool tx_frozen;
51 bool need_workarounds; /* Workarounds needed for core.rev < 3 */
52
53 /* Adjusted size of the device internal TX buffer. */
54 u16 tx_devq_size;
55 /* Used octets of the device internal TX buffer. */
56 u16 tx_devq_used;
57 /* Used packet slots in the device internal TX buffer. */
58 u8 tx_devq_packets;
59 /* Packets from the txfree list can
60 * be taken on incoming TX requests.
61 */
62 struct list_head txfree;
63 unsigned int nr_txfree;
64 /* Packets on the txqueue are queued,
65 * but not completely written to the chip, yet.
66 */
67 struct list_head txqueue;
68 /* Packets on the txrunning queue are completely
69 * posted to the device. We are waiting for the txstatus.
70 */
71 struct list_head txrunning;
72 /* Total number or packets sent.
73 * (This counter can obviously wrap).
74 */
75 unsigned int nr_tx_packets;
76 struct tasklet_struct txtask;
77 struct b43_pio_txpacket tx_packets_cache[B43_PIO_MAXTXPACKETS];
78};
79
80static inline u16 b43_pio_read(struct b43_pioqueue *queue, u16 offset)
81{
82 return b43_read16(queue->dev, queue->mmio_base + offset);
83}
84
85static inline
86 void b43_pio_write(struct b43_pioqueue *queue, u16 offset, u16 value)
87{
88 b43_write16(queue->dev, queue->mmio_base + offset, value);
89 mmiowb();
90}
91
92int b43_pio_init(struct b43_wldev *dev);
93void b43_pio_free(struct b43_wldev *dev);
94
95int b43_pio_tx(struct b43_wldev *dev,
96 struct sk_buff *skb, struct ieee80211_tx_control *ctl);
97void b43_pio_handle_txstatus(struct b43_wldev *dev,
98 const struct b43_txstatus *status);
99void b43_pio_get_tx_stats(struct b43_wldev *dev,
100 struct ieee80211_tx_queue_stats *stats);
101void b43_pio_rx(struct b43_pioqueue *queue);
102
103/* Suspend TX queue in hardware. */
104void b43_pio_tx_suspend(struct b43_pioqueue *queue);
105void b43_pio_tx_resume(struct b43_pioqueue *queue);
106/* Suspend (freeze) the TX tasklet (software level). */
107void b43_pio_freeze_txqueues(struct b43_wldev *dev);
108void b43_pio_thaw_txqueues(struct b43_wldev *dev);
109
110#else /* CONFIG_B43_PIO */
111
112static inline int b43_pio_init(struct b43_wldev *dev)
113{
114 return 0;
115}
116static inline void b43_pio_free(struct b43_wldev *dev)
117{
118}
119static inline
120 int b43_pio_tx(struct b43_wldev *dev,
121 struct sk_buff *skb, struct ieee80211_tx_control *ctl)
122{
123 return 0;
124}
125static inline
126 void b43_pio_handle_txstatus(struct b43_wldev *dev,
127 const struct b43_txstatus *status)
128{
129}
130static inline
131 void b43_pio_get_tx_stats(struct b43_wldev *dev,
132 struct ieee80211_tx_queue_stats *stats)
133{
134}
135static inline void b43_pio_rx(struct b43_pioqueue *queue)
136{
137}
138static inline void b43_pio_tx_suspend(struct b43_pioqueue *queue)
139{
140}
141static inline void b43_pio_tx_resume(struct b43_pioqueue *queue)
142{
143}
144static inline void b43_pio_freeze_txqueues(struct b43_wldev *dev)
145{
146}
147static inline void b43_pio_thaw_txqueues(struct b43_wldev *dev)
148{
149}
150
151#endif /* CONFIG_B43_PIO */
152#endif /* B43_PIO_H_ */