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