]> git.kernelconcepts.de Git - karo-tx-linux.git/blob - drivers/staging/vt6655/desc.h
staging: vt6655: rxtx create new structure vnt_tx_short_buf_head for csBeacon_xmit
[karo-tx-linux.git] / drivers / staging / vt6655 / 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 #define B_OWNED_BY_CHIP     1
40 #define B_OWNED_BY_HOST     0
41
42 //
43 // Bits in the RSR register
44 //
45 #define RSR_ADDRBROAD       0x80
46 #define RSR_ADDRMULTI       0x40
47 #define RSR_ADDRUNI         0x00
48 #define RSR_IVLDTYP         0x20
49 #define RSR_IVLDLEN         0x10        // invalid len (> 2312 byte)
50 #define RSR_BSSIDOK         0x08
51 #define RSR_CRCOK           0x04
52 #define RSR_BCNSSIDOK       0x02
53 #define RSR_ADDROK          0x01
54
55 //
56 // Bits in the new RSR register
57 //
58 #define NEWRSR_DECRYPTOK    0x10
59 #define NEWRSR_CFPIND       0x08
60 #define NEWRSR_HWUTSF       0x04
61 #define NEWRSR_BCNHITAID    0x02
62 #define NEWRSR_BCNHITAID0   0x01
63
64 //
65 // Bits in the TSR0 register
66 //
67 #define TSR0_PWRSTS1_2      0xC0
68 #define TSR0_PWRSTS7        0x20
69 #define TSR0_NCR            0x1F
70
71 //
72 // Bits in the TSR1 register
73 //
74 #define TSR1_TERR           0x80
75 #define TSR1_PWRSTS4_6      0x70
76 #define TSR1_RETRYTMO       0x08
77 #define TSR1_TMO            0x04
78 #define TSR1_PWRSTS3        0x02
79 #define ACK_DATA            0x01
80
81 //
82 // Bits in the TCR register
83 //
84 #define EDMSDU              0x04        // end of sdu
85 #define TCR_EDP             0x02        // end of packet
86 #define TCR_STP             0x01        // start of packet
87
88 // max transmit or receive buffer size
89 #define CB_MAX_BUF_SIZE     2900U
90                                         // NOTE: must be multiple of 4
91 #define CB_MAX_TX_BUF_SIZE          CB_MAX_BUF_SIZE
92 #define CB_MAX_RX_BUF_SIZE_NORMAL   CB_MAX_BUF_SIZE
93
94 #define CB_BEACON_BUF_SIZE  512U
95
96 #define CB_MAX_RX_DESC      128
97 #define CB_MIN_RX_DESC      16
98 #define CB_MAX_TX_DESC      64
99 #define CB_MIN_TX_DESC      16
100
101 #define CB_MAX_RECEIVED_PACKETS     16
102                                         // limit our receive routine to indicating
103                                         // this many at a time for 2 reasons:
104                                         // 1. driver flow control to protocol layer
105                                         // 2. limit the time used in ISR routine
106
107 #define CB_EXTRA_RD_NUM     32
108 #define CB_RD_NUM           32
109 #define CB_TD_NUM           32
110
111 // max number of physical segments
112 // in a single NDIS packet. Above this threshold, the packet
113 // is copied into a single physically contiguous buffer
114 #define CB_MAX_SEGMENT      4
115
116 #define CB_MIN_MAP_REG_NUM  4
117 #define CB_MAX_MAP_REG_NUM  CB_MAX_TX_DESC
118
119 #define CB_PROTOCOL_RESERVED_SECTION    16
120
121 // if retrys excess 15 times , tx will abort, and
122 // if tx fifo underflow, tx will fail
123 // we should try to resend it
124 #define CB_MAX_TX_ABORT_RETRY   3
125
126 #ifdef __BIG_ENDIAN
127
128 // WMAC definition FIFO Control
129 #define FIFOCTL_AUTO_FB_1   0x0010
130 #define FIFOCTL_AUTO_FB_0   0x0008
131 #define FIFOCTL_GRPACK      0x0004
132 #define FIFOCTL_11GA        0x0003
133 #define FIFOCTL_11GB        0x0002
134 #define FIFOCTL_11B         0x0001
135 #define FIFOCTL_11A         0x0000
136 #define FIFOCTL_RTS         0x8000
137 #define FIFOCTL_ISDMA0      0x4000
138 #define FIFOCTL_GENINT      0x2000
139 #define FIFOCTL_TMOEN       0x1000
140 #define FIFOCTL_LRETRY      0x0800
141 #define FIFOCTL_CRCDIS      0x0400
142 #define FIFOCTL_NEEDACK     0x0200
143 #define FIFOCTL_LHEAD       0x0100
144
145 //WMAC definition Frag Control
146 #define FRAGCTL_AES         0x0003
147 #define FRAGCTL_TKIP        0x0002
148 #define FRAGCTL_LEGACY      0x0001
149 #define FRAGCTL_NONENCRYPT  0x0000
150 #define FRAGCTL_ENDFRAG     0x0300
151 #define FRAGCTL_MIDFRAG     0x0200
152 #define FRAGCTL_STAFRAG     0x0100
153 #define FRAGCTL_NONFRAG     0x0000
154
155 #else
156
157 #define FIFOCTL_AUTO_FB_1   0x1000
158 #define FIFOCTL_AUTO_FB_0   0x0800
159 #define FIFOCTL_GRPACK      0x0400
160 #define FIFOCTL_11GA        0x0300
161 #define FIFOCTL_11GB        0x0200
162 #define FIFOCTL_11B         0x0100
163 #define FIFOCTL_11A         0x0000
164 #define FIFOCTL_RTS         0x0080
165 #define FIFOCTL_ISDMA0      0x0040
166 #define FIFOCTL_GENINT      0x0020
167 #define FIFOCTL_TMOEN       0x0010
168 #define FIFOCTL_LRETRY      0x0008
169 #define FIFOCTL_CRCDIS      0x0004
170 #define FIFOCTL_NEEDACK     0x0002
171 #define FIFOCTL_LHEAD       0x0001
172
173 //WMAC definition Frag Control
174 #define FRAGCTL_AES         0x0300
175 #define FRAGCTL_TKIP        0x0200
176 #define FRAGCTL_LEGACY      0x0100
177 #define FRAGCTL_NONENCRYPT  0x0000
178 #define FRAGCTL_ENDFRAG     0x0003
179 #define FRAGCTL_MIDFRAG     0x0002
180 #define FRAGCTL_STAFRAG     0x0001
181 #define FRAGCTL_NONFRAG     0x0000
182
183 #endif
184
185 #define TYPE_TXDMA0     0
186 #define TYPE_AC0DMA     1
187 #define TYPE_ATIMDMA    2
188 #define TYPE_SYNCDMA    3
189 #define TYPE_MAXTD      2
190
191 #define TYPE_BEACONDMA  4
192
193 #define TYPE_RXDMA0     0
194 #define TYPE_RXDMA1     1
195 #define TYPE_MAXRD      2
196
197 // TD_INFO flags control bit
198 #define TD_FLAGS_NETIF_SKB               0x01       // check if need release skb
199 #define TD_FLAGS_PRIV_SKB                0x02       // check if called from private skb(hostap)
200 #define TD_FLAGS_PS_RETRY                0x04       // check if PS STA frame re-transmit
201
202 // ref_sk_buff is used for mapping the skb structure between pre-built driver-obj & running kernel.
203 // Since different kernel version (2.4x) may change skb structure, i.e. pre-built driver-obj
204 // may link to older skb that leads error.
205
206 typedef struct tagDEVICE_RD_INFO {
207         struct sk_buff *skb;
208         dma_addr_t  skb_dma;
209         dma_addr_t  curr_desc;
210 } DEVICE_RD_INFO,   *PDEVICE_RD_INFO;
211
212 #ifdef __BIG_ENDIAN
213
214 typedef struct tagRDES0 {
215         volatile unsigned short wResCount;
216         union {
217                 volatile u16    f15Reserved;
218                 struct {
219                         volatile u8 f8Reserved1;
220                         volatile u8 f1Owner:1;
221                         volatile u8 f7Reserved:7;
222                 } __attribute__ ((__packed__));
223         } __attribute__ ((__packed__));
224 } __attribute__ ((__packed__))
225 SRDES0, *PSRDES0;
226
227 #else
228
229 typedef struct tagRDES0 {
230         unsigned short wResCount;
231         unsigned short f15Reserved:15;
232         unsigned short f1Owner:1;
233 } __attribute__ ((__packed__))
234 SRDES0;
235
236 #endif
237
238 typedef struct tagRDES1 {
239         unsigned short wReqCount;
240         unsigned short wReserved;
241 } __attribute__ ((__packed__))
242 SRDES1;
243
244 //
245 // Rx descriptor
246 //
247 typedef struct tagSRxDesc {
248         volatile SRDES0 m_rd0RD0;
249         volatile SRDES1 m_rd1RD1;
250         volatile u32    buff_addr;
251         volatile u32    next_desc;
252         struct tagSRxDesc *next __aligned(8);
253         volatile PDEVICE_RD_INFO pRDInfo __aligned(8);
254 } __attribute__ ((__packed__))
255 SRxDesc, *PSRxDesc;
256 typedef const SRxDesc *PCSRxDesc;
257
258 #ifdef __BIG_ENDIAN
259
260 typedef struct tagTDES0 {
261         volatile    unsigned char byTSR0;
262         volatile    unsigned char byTSR1;
263         union {
264                 volatile u16    f15Txtime;
265                 struct {
266                         volatile u8 f8Reserved1;
267                         volatile u8 f1Owner:1;
268                         volatile u8 f7Reserved:7;
269                 } __attribute__ ((__packed__));
270         } __attribute__ ((__packed__));
271 } __attribute__ ((__packed__))
272 STDES0, PSTDES0;
273
274 #else
275
276 typedef struct tagTDES0 {
277         volatile    unsigned char byTSR0;
278         volatile    unsigned char byTSR1;
279         volatile    unsigned short f15Txtime:15;
280         volatile    unsigned short f1Owner:1;
281 } __attribute__ ((__packed__))
282 STDES0;
283
284 #endif
285
286 typedef struct tagTDES1 {
287         volatile    unsigned short wReqCount;
288         volatile    unsigned char byTCR;
289         volatile    unsigned char byReserved;
290 } __attribute__ ((__packed__))
291 STDES1;
292
293 typedef struct tagDEVICE_TD_INFO {
294         struct sk_buff *skb;
295         unsigned char *buf;
296         dma_addr_t          skb_dma;
297         dma_addr_t          buf_dma;
298         dma_addr_t          curr_desc;
299         unsigned long dwReqCount;
300         unsigned long dwHeaderLength;
301         unsigned char byFlags;
302 } DEVICE_TD_INFO,    *PDEVICE_TD_INFO;
303
304 //
305 // transmit descriptor
306 //
307 typedef struct tagSTxDesc {
308         volatile    STDES0  m_td0TD0;
309         volatile    STDES1  m_td1TD1;
310         volatile    u32    buff_addr;
311         volatile    u32    next_desc;
312         struct tagSTxDesc *next __aligned(8);
313         volatile    PDEVICE_TD_INFO pTDInfo __aligned(8);
314 } __attribute__ ((__packed__))
315 STxDesc, *PSTxDesc;
316 typedef const STxDesc *PCSTxDesc;
317
318 typedef struct tagSTxSyncDesc {
319         volatile    STDES0  m_td0TD0;
320         volatile    STDES1  m_td1TD1;
321         volatile    u32 buff_addr; // pointer to logical buffer
322         volatile    u32 next_desc; // pointer to next logical descriptor
323         volatile    unsigned short m_wFIFOCtl;
324         volatile    unsigned short m_wTimeStamp;
325         struct tagSTxSyncDesc *next __aligned(8);
326         volatile    PDEVICE_TD_INFO pTDInfo __aligned(8);
327 } __attribute__ ((__packed__))
328 STxSyncDesc, *PSTxSyncDesc;
329 typedef const STxSyncDesc *PCSTxSyncDesc;
330
331 //
332 // RsvTime buffer header
333 //
334 typedef struct tagSRrvTime_gRTS {
335         unsigned short wRTSTxRrvTime_ba;
336         unsigned short wRTSTxRrvTime_aa;
337         unsigned short wRTSTxRrvTime_bb;
338         unsigned short wReserved;
339         unsigned short wTxRrvTime_b;
340         unsigned short wTxRrvTime_a;
341 } __attribute__ ((__packed__))
342 SRrvTime_gRTS, *PSRrvTime_gRTS;
343 typedef const SRrvTime_gRTS *PCSRrvTime_gRTS;
344
345 typedef struct tagSRrvTime_gCTS {
346         unsigned short wCTSTxRrvTime_ba;
347         unsigned short wReserved;
348         unsigned short wTxRrvTime_b;
349         unsigned short wTxRrvTime_a;
350 } __attribute__ ((__packed__))
351 SRrvTime_gCTS, *PSRrvTime_gCTS;
352 typedef const SRrvTime_gCTS *PCSRrvTime_gCTS;
353
354 typedef struct tagSRrvTime_ab {
355         unsigned short wRTSTxRrvTime;
356         unsigned short wTxRrvTime;
357 } __attribute__ ((__packed__))
358 SRrvTime_ab, *PSRrvTime_ab;
359 typedef const SRrvTime_ab *PCSRrvTime_ab;
360
361 typedef struct tagSRrvTime_atim {
362         unsigned short wCTSTxRrvTime_ba;
363         unsigned short wTxRrvTime_a;
364 } __attribute__ ((__packed__))
365 SRrvTime_atim, *PSRrvTime_atim;
366 typedef const SRrvTime_atim *PCSRrvTime_atim;
367
368 //
369 // RTS buffer header
370 //
371 typedef struct tagSRTSData {
372         unsigned short wFrameControl;
373         unsigned short wDurationID;
374         unsigned char abyRA[ETH_ALEN];
375         unsigned char abyTA[ETH_ALEN];
376 } __attribute__ ((__packed__))
377 SRTSData, *PSRTSData;
378 typedef const SRTSData *PCSRTSData;
379
380 /* Length, Service, and Signal fields of Phy for Tx */
381 struct vnt_phy_field {
382         u8 signal;
383         u8 service;
384         __le16 len;
385 } __packed;
386
387 union vnt_phy_field_swap {
388         struct vnt_phy_field field_read;
389         u16 swap[2];
390         u32 field_write;
391 };
392
393 typedef struct tagSRTS_g {
394         struct vnt_phy_field b;
395         struct vnt_phy_field a;
396         unsigned short wDuration_ba;
397         unsigned short wDuration_aa;
398         unsigned short wDuration_bb;
399         unsigned short wReserved;
400         SRTSData    Data;
401 } __attribute__ ((__packed__))
402 SRTS_g, *PSRTS_g;
403 typedef const SRTS_g *PCSRTS_g;
404
405 typedef struct tagSRTS_g_FB {
406         struct vnt_phy_field b;
407         struct vnt_phy_field a;
408         unsigned short wDuration_ba;
409         unsigned short wDuration_aa;
410         unsigned short wDuration_bb;
411         unsigned short wReserved;
412         unsigned short wRTSDuration_ba_f0;
413         unsigned short wRTSDuration_aa_f0;
414         unsigned short wRTSDuration_ba_f1;
415         unsigned short wRTSDuration_aa_f1;
416         SRTSData    Data;
417 } __attribute__ ((__packed__))
418 SRTS_g_FB, *PSRTS_g_FB;
419 typedef const SRTS_g_FB *PCSRTS_g_FB;
420
421 typedef struct tagSRTS_ab {
422         struct vnt_phy_field ab;
423         unsigned short wDuration;
424         unsigned short wReserved;
425         SRTSData    Data;
426 } __attribute__ ((__packed__))
427 SRTS_ab, *PSRTS_ab;
428 typedef const SRTS_ab *PCSRTS_ab;
429
430 typedef struct tagSRTS_a_FB {
431         struct vnt_phy_field a;
432         unsigned short wDuration;
433         unsigned short wReserved;
434         unsigned short wRTSDuration_f0;
435         unsigned short wRTSDuration_f1;
436         SRTSData    Data;
437 } __attribute__ ((__packed__))
438 SRTS_a_FB, *PSRTS_a_FB;
439 typedef const SRTS_a_FB *PCSRTS_a_FB;
440
441 //
442 // CTS buffer header
443 //
444 typedef struct tagSCTSData {
445         unsigned short wFrameControl;
446         unsigned short wDurationID;
447         unsigned char abyRA[ETH_ALEN];
448         unsigned short wReserved;
449 } __attribute__ ((__packed__))
450 SCTSData, *PSCTSData;
451
452 typedef struct tagSCTS {
453         struct vnt_phy_field b;
454         unsigned short wDuration_ba;
455         unsigned short wReserved;
456         SCTSData    Data;
457 } __attribute__ ((__packed__))
458 SCTS, *PSCTS;
459 typedef const SCTS *PCSCTS;
460
461 typedef struct tagSCTS_FB {
462         struct vnt_phy_field b;
463         unsigned short wDuration_ba;
464         unsigned short wReserved;
465         unsigned short wCTSDuration_ba_f0;
466         unsigned short wCTSDuration_ba_f1;
467         SCTSData    Data;
468 } __attribute__ ((__packed__))
469 SCTS_FB, *PSCTS_FB;
470 typedef const SCTS_FB *PCSCTS_FB;
471
472 //
473 // Tx FIFO header
474 //
475 typedef struct tagSTxBufHead {
476         u32 adwTxKey[4];
477         unsigned short wFIFOCtl;
478         unsigned short wTimeStamp;
479         unsigned short wFragCtl;
480         unsigned char byTxPower;
481         unsigned char wReserved;
482 } __attribute__ ((__packed__))
483 STxBufHead, *PSTxBufHead;
484 typedef const STxBufHead *PCSTxBufHead;
485
486 //
487 // Tx data header
488 //
489 typedef struct tagSTxDataHead_g {
490         struct vnt_phy_field b;
491         struct vnt_phy_field a;
492         unsigned short wDuration_b;
493         unsigned short wDuration_a;
494         unsigned short wTimeStampOff_b;
495         unsigned short wTimeStampOff_a;
496 } __attribute__ ((__packed__))
497 STxDataHead_g, *PSTxDataHead_g;
498 typedef const STxDataHead_g *PCSTxDataHead_g;
499
500 typedef struct tagSTxDataHead_g_FB {
501         struct vnt_phy_field b;
502         struct vnt_phy_field a;
503         unsigned short wDuration_b;
504         unsigned short wDuration_a;
505         unsigned short wDuration_a_f0;
506         unsigned short wDuration_a_f1;
507         unsigned short wTimeStampOff_b;
508         unsigned short wTimeStampOff_a;
509 } __attribute__ ((__packed__))
510 STxDataHead_g_FB, *PSTxDataHead_g_FB;
511 typedef const STxDataHead_g_FB *PCSTxDataHead_g_FB;
512
513 typedef struct tagSTxDataHead_ab {
514         struct vnt_phy_field ab;
515         unsigned short wDuration;
516         unsigned short wTimeStampOff;
517 } __attribute__ ((__packed__))
518 STxDataHead_ab, *PSTxDataHead_ab;
519 typedef const STxDataHead_ab *PCSTxDataHead_ab;
520
521 typedef struct tagSTxDataHead_a_FB {
522         struct vnt_phy_field a;
523         unsigned short wDuration;
524         unsigned short wTimeStampOff;
525         unsigned short wDuration_f0;
526         unsigned short wDuration_f1;
527 } __attribute__ ((__packed__))
528 STxDataHead_a_FB, *PSTxDataHead_a_FB;
529 typedef const STxDataHead_a_FB *PCSTxDataHead_a_FB;
530
531 typedef struct tagSBEACONCtl {
532         u32 BufReady:1;
533         u32 TSF:15;
534         u32 BufLen:11;
535         u32 Reserved:5;
536 } __attribute__ ((__packed__))
537 SBEACONCtl;
538
539 typedef struct tagSSecretKey {
540         u32 dwLowDword;
541         unsigned char byHighByte;
542 } __attribute__ ((__packed__))
543 SSecretKey;
544
545 typedef struct tagSKeyEntry {
546         unsigned char abyAddrHi[2];
547         unsigned short wKCTL;
548         unsigned char abyAddrLo[4];
549         u32 dwKey0[4];
550         u32 dwKey1[4];
551         u32 dwKey2[4];
552         u32 dwKey3[4];
553         u32 dwKey4[4];
554 } __attribute__ ((__packed__))
555 SKeyEntry;
556
557 #endif // __DESC_H__