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