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.
23 Abstract: rt2x00 ring datastructures and routines
31 * Each data entry also contains a descriptor which is used by the
32 * device to determine what should be done with the packet and
33 * what the current status is.
34 * This structure is greatly simplified, but the descriptors
35 * are basically a list of little endian 32 bit values.
36 * Make the array by default 1 word big, this will allow us
37 * to use sizeof() correctly.
45 * Summary of information that has been read from the
46 * RX frame descriptor.
48 struct rxdata_entry_desc
{
58 * Summary of information that should be written into the
59 * descriptor for sending a TX frame.
61 struct txdata_entry_desc
{
63 #define ENTRY_TXDONE 1
64 #define ENTRY_TXD_RTS_FRAME 2
65 #define ENTRY_TXD_OFDM_RATE 3
66 #define ENTRY_TXD_MORE_FRAG 4
67 #define ENTRY_TXD_REQ_TIMESTAMP 5
68 #define ENTRY_TXD_BURST 6
71 * Queue ID. ID's 0-4 are data TX rings
76 #define QUEUE_OTHER 15
97 * The data ring is a list of data entries.
98 * Each entry holds a reference to the descriptor
99 * and the data buffer. For TX rings the reference to the
100 * sk_buff of the packet being transmitted is also stored here.
107 #define ENTRY_OWNER_NIC 1
112 struct data_ring
*ring
;
115 * sk_buff for the packet which is being transmitted
116 * in this entry (Only used with TX related rings).
121 * Store a ieee80211_tx_status structure in each
122 * ring entry, this will optimize the txdone
125 struct ieee80211_tx_status tx_status
;
128 * private pointer specific to driver.
133 * Data address for this entry.
141 * Data rings are used by the device to send and receive packets.
142 * The data_addr is the base address of the data memory.
143 * To determine at which point in the ring we are,
144 * have to use the rt2x00_ring_index_*() functions.
148 * Pointer to main rt2x00dev structure where this
151 struct rt2x00_dev
*rt2x00dev
;
154 * Base address for the device specific data entries.
156 struct data_entry
*entry
;
159 * TX queue statistic info.
161 struct ieee80211_tx_queue_stats_data stats
;
164 * TX Queue parameters.
166 struct ieee80211_tx_queue_params tx_params
;
169 * Base address for data ring.
181 * Size of packet and descriptor in bytes.
188 * Handlers to determine the address of the current device specific
189 * data entry, where either index or index_done points to.
191 static inline struct data_entry
*rt2x00_get_data_entry(struct data_ring
*ring
)
193 return &ring
->entry
[ring
->index
];
196 static inline struct data_entry
*rt2x00_get_data_entry_done(struct data_ring
199 return &ring
->entry
[ring
->index_done
];
205 static inline int rt2x00_get_ring_size(struct data_ring
*ring
)
207 return ring
->stats
.limit
* (ring
->desc_size
+ ring
->data_size
);
211 * Ring index manipulation functions.
213 static inline void rt2x00_ring_index_inc(struct data_ring
*ring
)
216 if (ring
->index
>= ring
->stats
.limit
)
221 static inline void rt2x00_ring_index_done_inc(struct data_ring
*ring
)
224 if (ring
->index_done
>= ring
->stats
.limit
)
225 ring
->index_done
= 0;
230 static inline void rt2x00_ring_index_clear(struct data_ring
*ring
)
233 ring
->index_done
= 0;
235 ring
->stats
.count
= 0;
238 static inline int rt2x00_ring_empty(struct data_ring
*ring
)
240 return ring
->stats
.len
== 0;
243 static inline int rt2x00_ring_full(struct data_ring
*ring
)
245 return ring
->stats
.len
== ring
->stats
.limit
;
248 static inline int rt2x00_ring_free(struct data_ring
*ring
)
250 return ring
->stats
.limit
- ring
->stats
.len
;
254 * TX/RX Descriptor access functions.
256 static inline void rt2x00_desc_read(struct data_desc
*desc
,
257 const u8 word
, u32
*value
)
259 *value
= le32_to_cpu(desc
->word
[word
]);
262 static inline void rt2x00_desc_write(struct data_desc
*desc
,
263 const u8 word
, const u32 value
)
265 desc
->word
[word
] = cpu_to_le32(value
);
268 #endif /* RT2X00RING_H */