Merge tag 'v3.3.7' into 3.3/master
[zen-stable.git] / drivers / net / wireless / b43legacy / pio.h
blob8e6773ea6e754d922c482449563dc8d164d1bd1d
1 #ifndef B43legacy_PIO_H_
2 #define B43legacy_PIO_H_
4 #include "b43legacy.h"
6 #include <linux/interrupt.h>
7 #include <linux/list.h>
8 #include <linux/skbuff.h>
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
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)
23 #define B43legacy_PIO_RXCTL_DATAAVAILABLE (1 << 0)
24 #define B43legacy_PIO_RXCTL_READY (1 << 1)
26 /* PIO constants */
27 #define B43legacy_PIO_MAXTXDEVQPACKETS 31
28 #define B43legacy_PIO_TXQADJUST 80
30 /* PIO tuning knobs */
31 #define B43legacy_PIO_MAXTXPACKETS 256
35 #ifdef CONFIG_B43LEGACY_PIO
38 struct b43legacy_pioqueue;
39 struct b43legacy_xmitstatus;
41 struct b43legacy_pio_txpacket {
42 struct b43legacy_pioqueue *queue;
43 struct sk_buff *skb;
44 struct list_head list;
47 #define pio_txpacket_getindex(packet) ((int)((packet) - \
48 (packet)->queue->tx_packets_cache))
50 struct b43legacy_pioqueue {
51 struct b43legacy_wldev *dev;
52 u16 mmio_base;
54 bool tx_suspended;
55 bool tx_frozen;
56 bool need_workarounds; /* Workarounds needed for core.rev < 3 */
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.
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 struct tasklet_struct txtask;
78 struct b43legacy_pio_txpacket
79 tx_packets_cache[B43legacy_PIO_MAXTXPACKETS];
82 static inline
83 u16 b43legacy_pio_read(struct b43legacy_pioqueue *queue,
84 u16 offset)
86 return b43legacy_read16(queue->dev, queue->mmio_base + offset);
89 static inline
90 void b43legacy_pio_write(struct b43legacy_pioqueue *queue,
91 u16 offset, u16 value)
93 b43legacy_write16(queue->dev, queue->mmio_base + offset, value);
94 mmiowb();
98 int b43legacy_pio_init(struct b43legacy_wldev *dev);
99 void b43legacy_pio_free(struct b43legacy_wldev *dev);
101 int b43legacy_pio_tx(struct b43legacy_wldev *dev,
102 struct sk_buff *skb);
103 void b43legacy_pio_handle_txstatus(struct b43legacy_wldev *dev,
104 const struct b43legacy_txstatus *status);
105 void b43legacy_pio_rx(struct b43legacy_pioqueue *queue);
107 /* Suspend TX queue in hardware. */
108 void b43legacy_pio_tx_suspend(struct b43legacy_pioqueue *queue);
109 void b43legacy_pio_tx_resume(struct b43legacy_pioqueue *queue);
110 /* Suspend (freeze) the TX tasklet (software level). */
111 void b43legacy_pio_freeze_txqueues(struct b43legacy_wldev *dev);
112 void b43legacy_pio_thaw_txqueues(struct b43legacy_wldev *dev);
114 #else /* CONFIG_B43LEGACY_PIO */
116 static inline
117 int b43legacy_pio_init(struct b43legacy_wldev *dev)
119 return 0;
121 static inline
122 void b43legacy_pio_free(struct b43legacy_wldev *dev)
125 static inline
126 int b43legacy_pio_tx(struct b43legacy_wldev *dev,
127 struct sk_buff *skb)
129 return 0;
131 static inline
132 void b43legacy_pio_handle_txstatus(struct b43legacy_wldev *dev,
133 const struct b43legacy_txstatus *status)
136 static inline
137 void b43legacy_pio_rx(struct b43legacy_pioqueue *queue)
140 static inline
141 void b43legacy_pio_tx_suspend(struct b43legacy_pioqueue *queue)
144 static inline
145 void b43legacy_pio_tx_resume(struct b43legacy_pioqueue *queue)
148 static inline
149 void b43legacy_pio_freeze_txqueues(struct b43legacy_wldev *dev)
152 static inline
153 void b43legacy_pio_thaw_txqueues(struct b43legacy_wldev *dev)
157 #endif /* CONFIG_B43LEGACY_PIO */
158 #endif /* B43legacy_PIO_H_ */