aa5e249092a1ddc12105042ef9c7afaac63f6763
[cascardo/linux.git] / drivers / staging / vt6656 / desc.h
1 /*
2  * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
3  * All rights reserved.
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 along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  *
19  * File: desc.h
20  *
21  * Purpose:The header file of descriptor
22  *
23  * Revision History:
24  *
25  * Author: Tevin Chen
26  *
27  * Date: May 21, 1996
28  *
29  */
30
31 #ifndef __DESC_H__
32 #define __DESC_H__
33
34 #include <linux/types.h>
35 #include <linux/mm.h>
36 #include <linux/ieee80211.h>
37
38 #include "tether.h"
39
40 /* max transmit or receive buffer size */
41 #define CB_MAX_BUF_SIZE     2900U       /* NOTE: must be multiple of 4 */
42
43 /* max TX buffer size */
44 #define CB_MAX_TX_BUF_SIZE        CB_MAX_BUF_SIZE
45 /* max RX buffer size when not use Multi-RD */
46 #define CB_MAX_RX_BUF_SIZE_NORMAL CB_MAX_BUF_SIZE
47
48 #define CB_BEACON_BUF_SIZE  512U        /* default beacon buffer size */
49
50 #define MAX_TOTAL_SIZE_WITH_ALL_HEADERS CB_MAX_BUF_SIZE
51
52 #define MAX_INTERRUPT_SIZE              32
53
54 #define RX_BLOCKS           64          /* from 0x60 to 0xA0 */
55 #define TX_BLOCKS           32          /* from 0xA0 to 0xC0 */
56
57 #define CB_MAX_RX_DESC      128         /* max # of descriptors */
58 #define CB_MIN_RX_DESC      16          /* min # of RX descriptors */
59 #define CB_MAX_TX_DESC      128         /* max # of descriptors */
60 #define CB_MIN_TX_DESC      16          /* min # of TX descriptors */
61
62 #define CB_RD_NUM           64          /* default # of RD */
63 #define CB_TD_NUM           64          /* default # of TD */
64
65 /*
66  * bits in the RSR register
67  */
68 #define RSR_ADDRBROAD       0x80
69 #define RSR_ADDRMULTI       0x40
70 #define RSR_ADDRUNI         0x00
71 #define RSR_IVLDTYP         0x20        /* invalid packet type */
72 #define RSR_IVLDLEN         0x10        /* invalid len (> 2312 byte) */
73 #define RSR_BSSIDOK         0x08
74 #define RSR_CRCOK           0x04
75 #define RSR_BCNSSIDOK       0x02
76 #define RSR_ADDROK          0x01
77
78 /*
79  * bits in the new RSR register
80  */
81 #define NEWRSR_DECRYPTOK    0x10
82 #define NEWRSR_CFPIND       0x08
83 #define NEWRSR_HWUTSF       0x04
84 #define NEWRSR_BCNHITAID    0x02
85 #define NEWRSR_BCNHITAID0   0x01
86
87 /*
88  * bits in the TSR register
89  */
90 #define TSR_RETRYTMO        0x08
91 #define TSR_TMO             0x04
92 #define TSR_ACKDATA         0x02
93 #define TSR_VALID           0x01
94
95 #define CB_PROTOCOL_RESERVED_SECTION    16
96
97 /*
98  * if retries exceed 15 times, TX will abort, and
99  * if TX fifo underflow, TX will fail
100  * we should try to resend it
101  */
102 #define CB_MAX_TX_ABORT_RETRY   3
103
104 #define FIFOCTL_AUTO_FB_1   0x1000
105 #define FIFOCTL_AUTO_FB_0   0x0800
106 #define FIFOCTL_GRPACK      0x0400
107 #define FIFOCTL_11GA        0x0300
108 #define FIFOCTL_11GB        0x0200
109 #define FIFOCTL_11B         0x0100
110 #define FIFOCTL_11A         0x0000
111 #define FIFOCTL_RTS         0x0080
112 #define FIFOCTL_ISDMA0      0x0040
113 #define FIFOCTL_GENINT      0x0020
114 #define FIFOCTL_TMOEN       0x0010
115 #define FIFOCTL_LRETRY      0x0008
116 #define FIFOCTL_CRCDIS      0x0004
117 #define FIFOCTL_NEEDACK     0x0002
118 #define FIFOCTL_LHEAD       0x0001
119
120 /* WMAC definition Frag Control */
121 #define FRAGCTL_AES         0x0300
122 #define FRAGCTL_TKIP        0x0200
123 #define FRAGCTL_LEGACY      0x0100
124 #define FRAGCTL_NONENCRYPT  0x0000
125 #define FRAGCTL_ENDFRAG     0x0003
126 #define FRAGCTL_MIDFRAG     0x0002
127 #define FRAGCTL_STAFRAG     0x0001
128 #define FRAGCTL_NONFRAG     0x0000
129
130 #define TYPE_TXDMA0     0
131 #define TYPE_AC0DMA     1
132 #define TYPE_ATIMDMA    2
133 #define TYPE_SYNCDMA    3
134 #define TYPE_MAXTD      2
135
136 #define TYPE_BEACONDMA  4
137
138 #define TYPE_RXDMA0     0
139 #define TYPE_RXDMA1     1
140 #define TYPE_MAXRD      2
141
142 /* TD_INFO flags control bit */
143 #define TD_FLAGS_NETIF_SKB 0x01 /* check if need release skb */
144 #define TD_FLAGS_PRIV_SKB  0x02 /* check if called from private skb(hostap) */
145 #define TD_FLAGS_PS_RETRY  0x04 /* check if PS STA frame re-transmit */
146
147 /*
148  * RsvTime buffer header
149  */
150 typedef struct tagSRrvTime_gRTS {
151     u16        wRTSTxRrvTime_ba;
152     u16        wRTSTxRrvTime_aa;
153     u16        wRTSTxRrvTime_bb;
154     u16        wReserved;
155     u16        wTxRrvTime_b;
156     u16        wTxRrvTime_a;
157 } __attribute__ ((__packed__))
158 SRrvTime_gRTS, *PSRrvTime_gRTS;
159
160 typedef const SRrvTime_gRTS *PCSRrvTime_gRTS;
161
162 typedef struct tagSRrvTime_gCTS {
163     u16        wCTSTxRrvTime_ba;
164     u16        wReserved;
165     u16        wTxRrvTime_b;
166     u16        wTxRrvTime_a;
167 } __attribute__ ((__packed__))
168 SRrvTime_gCTS, *PSRrvTime_gCTS;
169
170 typedef const SRrvTime_gCTS *PCSRrvTime_gCTS;
171
172 typedef struct tagSRrvTime_ab {
173     u16        wRTSTxRrvTime;
174     u16        wTxRrvTime;
175 } __attribute__ ((__packed__))
176 SRrvTime_ab, *PSRrvTime_ab;
177
178 typedef const SRrvTime_ab *PCSRrvTime_ab;
179
180 typedef struct tagSRrvTime_atim {
181     u16        wCTSTxRrvTime_ba;
182     u16        wTxRrvTime_a;
183 } __attribute__ ((__packed__))
184 SRrvTime_atim, *PSRrvTime_atim;
185
186 typedef const SRrvTime_atim *PCSRrvTime_atim;
187
188 /*
189  * RTS buffer header
190  */
191 typedef struct tagSRTS_g {
192     u8        bySignalField_b;
193     u8        byServiceField_b;
194     u16        wTransmitLength_b;
195     u8        bySignalField_a;
196     u8        byServiceField_a;
197     u16        wTransmitLength_a;
198     u16        wDuration_ba;
199     u16        wDuration_aa;
200     u16        wDuration_bb;
201     u16        wReserved;
202         struct ieee80211_rts data;
203 } __attribute__ ((__packed__))
204 SRTS_g, *PSRTS_g;
205 typedef const SRTS_g *PCSRTS_g;
206
207 typedef struct tagSRTS_g_FB {
208     u8        bySignalField_b;
209     u8        byServiceField_b;
210     u16        wTransmitLength_b;
211     u8        bySignalField_a;
212     u8        byServiceField_a;
213     u16        wTransmitLength_a;
214     u16        wDuration_ba;
215     u16        wDuration_aa;
216     u16        wDuration_bb;
217     u16        wReserved;
218     u16        wRTSDuration_ba_f0;
219     u16        wRTSDuration_aa_f0;
220     u16        wRTSDuration_ba_f1;
221     u16        wRTSDuration_aa_f1;
222         struct ieee80211_rts data;
223 } __attribute__ ((__packed__))
224 SRTS_g_FB, *PSRTS_g_FB;
225
226 typedef const SRTS_g_FB *PCSRTS_g_FB;
227
228 typedef struct tagSRTS_ab {
229     u8        bySignalField;
230     u8        byServiceField;
231     u16        wTransmitLength;
232     u16        wDuration;
233     u16        wReserved;
234         struct ieee80211_rts data;
235 } __attribute__ ((__packed__))
236 SRTS_ab, *PSRTS_ab;
237
238 typedef const SRTS_ab *PCSRTS_ab;
239
240 typedef struct tagSRTS_a_FB {
241     u8        bySignalField;
242     u8        byServiceField;
243     u16        wTransmitLength;
244     u16        wDuration;
245     u16        wReserved;
246     u16        wRTSDuration_f0;
247     u16        wRTSDuration_f1;
248         struct ieee80211_rts data;
249 } __attribute__ ((__packed__))
250 SRTS_a_FB, *PSRTS_a_FB;
251
252 typedef const SRTS_a_FB *PCSRTS_a_FB;
253
254 /*
255  * CTS buffer header
256  */
257 typedef struct tagSCTSData {
258     u16    wFrameControl;
259     u16    wDurationID;
260     u8    abyRA[ETH_ALEN];
261     u16    wReserved;
262 } __attribute__ ((__packed__))
263 SCTSData, *PSCTSData;
264
265 typedef struct tagSCTS {
266     u8        bySignalField_b;
267     u8        byServiceField_b;
268     u16        wTransmitLength_b;
269     u16        wDuration_ba;
270     u16        wReserved;
271     SCTSData    Data;
272 } __attribute__ ((__packed__))
273 SCTS, *PSCTS;
274
275 typedef const SCTS *PCSCTS;
276
277 typedef struct tagSCTS_FB {
278     u8        bySignalField_b;
279     u8        byServiceField_b;
280     u16        wTransmitLength_b;
281     u16        wDuration_ba;
282     u16        wReserved;
283     u16        wCTSDuration_ba_f0;
284     u16        wCTSDuration_ba_f1;
285     SCTSData    Data;
286 } __attribute__ ((__packed__))
287 SCTS_FB, *PSCTS_FB;
288
289 typedef const SCTS_FB *PCSCTS_FB;
290
291 /*
292  * TX FIFO header
293  */
294 typedef struct tagSTxBufHead {
295         u32 adwTxKey[4];
296     u16    wFIFOCtl;
297     u16    wTimeStamp;
298     u16    wFragCtl;
299     u16    wReserved;
300 } __attribute__ ((__packed__))
301 STxBufHead, *PSTxBufHead;
302 typedef const STxBufHead *PCSTxBufHead;
303
304 typedef struct tagSTxShortBufHead {
305     u16    wFIFOCtl;
306     u16    wTimeStamp;
307 } __attribute__ ((__packed__))
308 STxShortBufHead, *PSTxShortBufHead;
309 typedef const STxShortBufHead *PCSTxShortBufHead;
310
311 /*
312  * TX data header
313  */
314 typedef struct tagSTxDataHead_g {
315     u8    bySignalField_b;
316     u8    byServiceField_b;
317     u16    wTransmitLength_b;
318     u8    bySignalField_a;
319     u8    byServiceField_a;
320     u16    wTransmitLength_a;
321     u16    wDuration_b;
322     u16    wDuration_a;
323     u16    wTimeStampOff_b;
324     u16    wTimeStampOff_a;
325 } __attribute__ ((__packed__))
326 STxDataHead_g, *PSTxDataHead_g;
327
328 typedef const STxDataHead_g *PCSTxDataHead_g;
329
330 typedef struct tagSTxDataHead_g_FB {
331     u8    bySignalField_b;
332     u8    byServiceField_b;
333     u16    wTransmitLength_b;
334     u8    bySignalField_a;
335     u8    byServiceField_a;
336     u16    wTransmitLength_a;
337     u16    wDuration_b;
338     u16    wDuration_a;
339     u16    wDuration_a_f0;
340     u16    wDuration_a_f1;
341     u16    wTimeStampOff_b;
342     u16    wTimeStampOff_a;
343 } __attribute__ ((__packed__))
344 STxDataHead_g_FB, *PSTxDataHead_g_FB;
345 typedef const STxDataHead_g_FB *PCSTxDataHead_g_FB;
346
347 typedef struct tagSTxDataHead_ab {
348     u8    bySignalField;
349     u8    byServiceField;
350     u16    wTransmitLength;
351     u16    wDuration;
352     u16    wTimeStampOff;
353 } __attribute__ ((__packed__))
354 STxDataHead_ab, *PSTxDataHead_ab;
355 typedef const STxDataHead_ab *PCSTxDataHead_ab;
356
357 typedef struct tagSTxDataHead_a_FB {
358     u8    bySignalField;
359     u8    byServiceField;
360     u16    wTransmitLength;
361     u16    wDuration;
362     u16    wTimeStampOff;
363     u16    wDuration_f0;
364     u16    wDuration_f1;
365 } __attribute__ ((__packed__))
366 STxDataHead_a_FB, *PSTxDataHead_a_FB;
367 typedef const STxDataHead_a_FB *PCSTxDataHead_a_FB;
368
369 /*
370  * MICHDR data header
371  */
372 typedef struct tagSMICHDRHead {
373         u32 adwHDR0[4];
374         u32 adwHDR1[4];
375         u32 adwHDR2[4];
376 } __attribute__ ((__packed__))
377 SMICHDRHead, *PSMICHDRHead;
378
379 typedef const SMICHDRHead *PCSMICHDRHead;
380
381 typedef struct tagSBEACONCtl {
382         u32 BufReady:1;
383         u32 TSF:15;
384         u32 BufLen:11;
385         u32 Reserved:5;
386 } __attribute__ ((__packed__))
387 SBEACONCtl;
388
389 typedef struct tagSSecretKey {
390         u32 dwLowDword;
391     u8    byHighByte;
392 } __attribute__ ((__packed__))
393 SSecretKey;
394
395 typedef struct tagSKeyEntry {
396     u8  abyAddrHi[2];
397     u16  wKCTL;
398     u8  abyAddrLo[4];
399         u32 dwKey0[4];
400         u32 dwKey1[4];
401         u32 dwKey2[4];
402         u32 dwKey3[4];
403         u32 dwKey4[4];
404 } __attribute__ ((__packed__))
405 SKeyEntry;
406
407 #endif /* __DESC_H__ */