]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blame - drivers/net/wireless/rt2x00/rt2x00ring.h
rt2x00: Only set the TBCN flag when the interface is configured to send beacons.
[mirror_ubuntu-zesty-kernel.git] / drivers / net / wireless / rt2x00 / rt2x00ring.h
CommitLineData
95ea3627
ID
1/*
2 Copyright (C) 2004 - 2007 rt2x00 SourceForge Project
3 <http://rt2x00.serialmonkey.com>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the
17 Free Software Foundation, Inc.,
18 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 */
20
21/*
22 Module: rt2x00
23 Abstract: rt2x00 ring datastructures and routines
24 */
25
26#ifndef RT2X00RING_H
27#define RT2X00RING_H
28
08992f7f
ID
29/*
30 * skb_desc
31 * Descriptor information for the skb buffer
32 */
33struct skb_desc {
34 unsigned int frame_type;
35
36 unsigned int desc_len;
37 unsigned int data_len;
38
39 void *desc;
40 void *data;
41
42 struct data_ring *ring;
43 struct data_entry *entry;
44};
45
46static inline struct skb_desc* get_skb_desc(struct sk_buff *skb)
47{
48 return (struct skb_desc*)&skb->cb[0];
49}
50
95ea3627 51/*
4150c572
JB
52 * rxdata_entry_desc
53 * Summary of information that has been read from the
54 * RX frame descriptor.
55 */
56struct rxdata_entry_desc {
57 int signal;
58 int rssi;
59 int ofdm;
60 int size;
61 int flags;
62};
63
64/*
65 * txdata_entry_desc
95ea3627
ID
66 * Summary of information that should be written into the
67 * descriptor for sending a TX frame.
68 */
4150c572 69struct txdata_entry_desc {
95ea3627
ID
70 unsigned long flags;
71#define ENTRY_TXDONE 1
72#define ENTRY_TXD_RTS_FRAME 2
73#define ENTRY_TXD_OFDM_RATE 3
74#define ENTRY_TXD_MORE_FRAG 4
75#define ENTRY_TXD_REQ_TIMESTAMP 5
76#define ENTRY_TXD_BURST 6
2700f8b0 77#define ENTRY_TXD_ACK 7
95ea3627
ID
78
79/*
80 * Queue ID. ID's 0-4 are data TX rings
81 */
82 int queue;
83#define QUEUE_MGMT 13
84#define QUEUE_RX 14
85#define QUEUE_OTHER 15
86
87 /*
88 * PLCP values.
89 */
90 u16 length_high;
91 u16 length_low;
92 u16 signal;
93 u16 service;
94
95 /*
96 * Timing information
97 */
98 int aifs;
99 int ifs;
100 int cw_min;
101 int cw_max;
102};
103
104/*
105 * data_entry
106 * The data ring is a list of data entries.
107 * Each entry holds a reference to the descriptor
108 * and the data buffer. For TX rings the reference to the
109 * sk_buff of the packet being transmitted is also stored here.
110 */
111struct data_entry {
112 /*
113 * Status flags
114 */
115 unsigned long flags;
116#define ENTRY_OWNER_NIC 1
117
118 /*
119 * Ring we belong to.
120 */
121 struct data_ring *ring;
122
123 /*
124 * sk_buff for the packet which is being transmitted
125 * in this entry (Only used with TX related rings).
126 */
127 struct sk_buff *skb;
128
129 /*
130 * Store a ieee80211_tx_status structure in each
131 * ring entry, this will optimize the txdone
132 * handler.
133 */
134 struct ieee80211_tx_status tx_status;
135
136 /*
137 * private pointer specific to driver.
138 */
139 void *priv;
140
141 /*
142 * Data address for this entry.
143 */
144 void *data_addr;
145 dma_addr_t data_dma;
146};
147
148/*
149 * data_ring
150 * Data rings are used by the device to send and receive packets.
151 * The data_addr is the base address of the data memory.
152 * To determine at which point in the ring we are,
153 * have to use the rt2x00_ring_index_*() functions.
154 */
155struct data_ring {
156 /*
157 * Pointer to main rt2x00dev structure where this
158 * ring belongs to.
159 */
160 struct rt2x00_dev *rt2x00dev;
161
162 /*
163 * Base address for the device specific data entries.
164 */
165 struct data_entry *entry;
166
167 /*
168 * TX queue statistic info.
169 */
170 struct ieee80211_tx_queue_stats_data stats;
171
172 /*
173 * TX Queue parameters.
174 */
175 struct ieee80211_tx_queue_params tx_params;
176
177 /*
178 * Base address for data ring.
179 */
180 dma_addr_t data_dma;
181 void *data_addr;
182
183 /*
184 * Index variables.
185 */
186 u16 index;
187 u16 index_done;
188
189 /*
190 * Size of packet and descriptor in bytes.
191 */
192 u16 data_size;
193 u16 desc_size;
194};
195
196/*
197 * Handlers to determine the address of the current device specific
198 * data entry, where either index or index_done points to.
199 */
200static inline struct data_entry *rt2x00_get_data_entry(struct data_ring *ring)
201{
202 return &ring->entry[ring->index];
203}
204
205static inline struct data_entry *rt2x00_get_data_entry_done(struct data_ring
206 *ring)
207{
208 return &ring->entry[ring->index_done];
209}
210
211/*
212 * Total ring memory
213 */
214static inline int rt2x00_get_ring_size(struct data_ring *ring)
215{
216 return ring->stats.limit * (ring->desc_size + ring->data_size);
217}
218
219/*
220 * Ring index manipulation functions.
221 */
222static inline void rt2x00_ring_index_inc(struct data_ring *ring)
223{
224 ring->index++;
225 if (ring->index >= ring->stats.limit)
226 ring->index = 0;
227 ring->stats.len++;
228}
229
230static inline void rt2x00_ring_index_done_inc(struct data_ring *ring)
231{
232 ring->index_done++;
233 if (ring->index_done >= ring->stats.limit)
234 ring->index_done = 0;
235 ring->stats.len--;
236 ring->stats.count++;
237}
238
239static inline void rt2x00_ring_index_clear(struct data_ring *ring)
240{
241 ring->index = 0;
242 ring->index_done = 0;
243 ring->stats.len = 0;
244 ring->stats.count = 0;
245}
246
247static inline int rt2x00_ring_empty(struct data_ring *ring)
248{
249 return ring->stats.len == 0;
250}
251
252static inline int rt2x00_ring_full(struct data_ring *ring)
253{
254 return ring->stats.len == ring->stats.limit;
255}
256
257static inline int rt2x00_ring_free(struct data_ring *ring)
258{
259 return ring->stats.limit - ring->stats.len;
260}
261
262/*
263 * TX/RX Descriptor access functions.
264 */
4bd7c452 265static inline void rt2x00_desc_read(__le32 *desc,
95ea3627
ID
266 const u8 word, u32 *value)
267{
4bd7c452 268 *value = le32_to_cpu(desc[word]);
95ea3627
ID
269}
270
4bd7c452 271static inline void rt2x00_desc_write(__le32 *desc,
95ea3627
ID
272 const u8 word, const u32 value)
273{
4bd7c452 274 desc[word] = cpu_to_le32(value);
95ea3627
ID
275}
276
277#endif /* RT2X00RING_H */