Committer: Michael Beasley <mike@snafu.setup>
[mikesnafu-overlay.git] / drivers / net / wireless / rt2x00 / rt2x00ring.h
blob1caa6d688c402f74f4244a1ec0365d3f7096880f
1 /*
2 Copyright (C) 2004 - 2007 rt2x00 SourceForge Project
3 <http://rt2x00.serialmonkey.com>
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.
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.
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.
22 Module: rt2x00
23 Abstract: rt2x00 ring datastructures and routines
26 #ifndef RT2X00RING_H
27 #define RT2X00RING_H
30 * skb_desc
31 * Descriptor information for the skb buffer
33 struct skb_desc {
34 unsigned int frame_type;
36 unsigned int desc_len;
37 unsigned int data_len;
39 void *desc;
40 void *data;
42 struct data_ring *ring;
43 struct data_entry *entry;
46 static inline struct skb_desc* get_skb_desc(struct sk_buff *skb)
48 return (struct skb_desc*)&skb->cb[0];
52 * rxdata_entry_desc
53 * Summary of information that has been read from the
54 * RX frame descriptor.
56 struct rxdata_entry_desc {
57 int signal;
58 int rssi;
59 int ofdm;
60 int size;
61 int flags;
62 int my_bss;
66 * txdata_entry_desc
67 * Summary of information that should be written into the
68 * descriptor for sending a TX frame.
70 struct txdata_entry_desc {
71 unsigned long flags;
72 #define ENTRY_TXDONE 1
73 #define ENTRY_TXD_RTS_FRAME 2
74 #define ENTRY_TXD_OFDM_RATE 3
75 #define ENTRY_TXD_MORE_FRAG 4
76 #define ENTRY_TXD_REQ_TIMESTAMP 5
77 #define ENTRY_TXD_BURST 6
78 #define ENTRY_TXD_ACK 7
81 * Queue ID. ID's 0-4 are data TX rings
83 int queue;
84 #define QUEUE_MGMT 13
85 #define QUEUE_RX 14
86 #define QUEUE_OTHER 15
89 * PLCP values.
91 u16 length_high;
92 u16 length_low;
93 u16 signal;
94 u16 service;
97 * Timing information
99 int aifs;
100 int ifs;
101 int cw_min;
102 int cw_max;
106 * data_entry
107 * The data ring is a list of data entries.
108 * Each entry holds a reference to the descriptor
109 * and the data buffer. For TX rings the reference to the
110 * sk_buff of the packet being transmitted is also stored here.
112 struct data_entry {
114 * Status flags
116 unsigned long flags;
117 #define ENTRY_OWNER_NIC 1
120 * Ring we belong to.
122 struct data_ring *ring;
125 * sk_buff for the packet which is being transmitted
126 * in this entry (Only used with TX related rings).
128 struct sk_buff *skb;
131 * Store a ieee80211_tx_status structure in each
132 * ring entry, this will optimize the txdone
133 * handler.
135 struct ieee80211_tx_status tx_status;
138 * private pointer specific to driver.
140 void *priv;
143 * Data address for this entry.
145 void *data_addr;
146 dma_addr_t data_dma;
149 * Entry identification number (index).
151 unsigned int entry_idx;
155 * data_ring
156 * Data rings are used by the device to send and receive packets.
157 * The data_addr is the base address of the data memory.
158 * To determine at which point in the ring we are,
159 * have to use the rt2x00_ring_index_*() functions.
161 struct data_ring {
163 * Pointer to main rt2x00dev structure where this
164 * ring belongs to.
166 struct rt2x00_dev *rt2x00dev;
169 * Base address for the device specific data entries.
171 struct data_entry *entry;
174 * TX queue statistic info.
176 struct ieee80211_tx_queue_stats_data stats;
179 * TX Queue parameters.
181 struct ieee80211_tx_queue_params tx_params;
184 * Base address for data ring.
186 dma_addr_t data_dma;
187 void *data_addr;
190 * Queue identification number:
191 * RX: 0
192 * TX: IEEE80211_TX_*
194 unsigned int queue_idx;
197 * Index variables.
199 u16 index;
200 u16 index_done;
203 * Size of packet and descriptor in bytes.
205 u16 data_size;
206 u16 desc_size;
210 * Handlers to determine the address of the current device specific
211 * data entry, where either index or index_done points to.
213 static inline struct data_entry *rt2x00_get_data_entry(struct data_ring *ring)
215 return &ring->entry[ring->index];
218 static inline struct data_entry *rt2x00_get_data_entry_done(struct data_ring
219 *ring)
221 return &ring->entry[ring->index_done];
225 * Total ring memory
227 static inline int rt2x00_get_ring_size(struct data_ring *ring)
229 return ring->stats.limit * (ring->desc_size + ring->data_size);
233 * Ring index manipulation functions.
235 static inline void rt2x00_ring_index_inc(struct data_ring *ring)
237 ring->index++;
238 if (ring->index >= ring->stats.limit)
239 ring->index = 0;
240 ring->stats.len++;
243 static inline void rt2x00_ring_index_done_inc(struct data_ring *ring)
245 ring->index_done++;
246 if (ring->index_done >= ring->stats.limit)
247 ring->index_done = 0;
248 ring->stats.len--;
249 ring->stats.count++;
252 static inline void rt2x00_ring_index_clear(struct data_ring *ring)
254 ring->index = 0;
255 ring->index_done = 0;
256 ring->stats.len = 0;
257 ring->stats.count = 0;
260 static inline int rt2x00_ring_empty(struct data_ring *ring)
262 return ring->stats.len == 0;
265 static inline int rt2x00_ring_full(struct data_ring *ring)
267 return ring->stats.len == ring->stats.limit;
270 static inline int rt2x00_ring_free(struct data_ring *ring)
272 return ring->stats.limit - ring->stats.len;
276 * TX/RX Descriptor access functions.
278 static inline void rt2x00_desc_read(__le32 *desc,
279 const u8 word, u32 *value)
281 *value = le32_to_cpu(desc[word]);
284 static inline void rt2x00_desc_write(__le32 *desc,
285 const u8 word, const u32 value)
287 desc[word] = cpu_to_le32(value);
290 #endif /* RT2X00RING_H */