2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
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 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.
21 * Purpose:The header file of descriptor
35 #include <linux/types.h>
38 #if !defined(__TTYPE_H__)
41 #if !defined(__TETHER_H__)
45 //#if !defined(__DEVICE_MODULE_H)
46 //#include "device_module.h"
52 /*--------------------- Export Definitions -------------------------*/
54 #define B_OWNED_BY_CHIP 1 //
55 #define B_OWNED_BY_HOST 0 //
58 // Bits in the RSR register
60 #define RSR_ADDRBROAD 0x80 // 1000 0000
61 #define RSR_ADDRMULTI 0x40 // 0100 0000
62 #define RSR_ADDRUNI 0x00 // 0000 0000
63 #define RSR_IVLDTYP 0x20 // 0010 0000 , invalid packet type
64 #define RSR_IVLDLEN 0x10 // 0001 0000 , invalid len (> 2312 byte)
65 #define RSR_BSSIDOK 0x08 // 0000 1000
66 #define RSR_CRCOK 0x04 // 0000 0100
67 #define RSR_BCNSSIDOK 0x02 // 0000 0010
68 #define RSR_ADDROK 0x01 // 0000 0001
71 // Bits in the new RSR register
73 #define NEWRSR_DECRYPTOK 0x10 // 0001 0000
74 #define NEWRSR_CFPIND 0x08 // 0000 1000
75 #define NEWRSR_HWUTSF 0x04 // 0000 0100
76 #define NEWRSR_BCNHITAID 0x02 // 0000 0010
77 #define NEWRSR_BCNHITAID0 0x01 // 0000 0001
80 // Bits in the TSR0 register
82 #define TSR0_PWRSTS1_2 0xC0 // 1100 0000
83 #define TSR0_PWRSTS7 0x20 // 0010 0000
84 #define TSR0_NCR 0x1F // 0001 1111
87 // Bits in the TSR1 register
89 #define TSR1_TERR 0x80 // 1000 0000
90 #define TSR1_PWRSTS4_6 0x70 // 0111 0000
91 #define TSR1_RETRYTMO 0x08 // 0000 1000
92 #define TSR1_TMO 0x04 // 0000 0100
93 #define TSR1_PWRSTS3 0x02 // 0000 0010
94 #define ACK_DATA 0x01 // 0000 0000
97 // Bits in the TCR register
99 #define EDMSDU 0x04 // 0000 0100 end of sdu
100 #define TCR_EDP 0x02 // 0000 0010 end of packet
101 #define TCR_STP 0x01 // 0000 0001 start of packet
103 // max transmit or receive buffer size
104 #define CB_MAX_BUF_SIZE 2900U // max buffer size
105 // NOTE: must be multiple of 4
106 #define CB_MAX_TX_BUF_SIZE CB_MAX_BUF_SIZE // max Tx buffer size
107 #define CB_MAX_RX_BUF_SIZE_NORMAL CB_MAX_BUF_SIZE // max Rx buffer size when not use Multi-RD
109 #define CB_BEACON_BUF_SIZE 512U // default beacon buffer size
111 #define CB_MAX_RX_DESC 128 // max # of descriptor
112 #define CB_MIN_RX_DESC 16 // min # of rx descriptor
113 #define CB_MAX_TX_DESC 64 // max # of descriptor
114 #define CB_MIN_TX_DESC 16 // min # of tx descriptor
116 #define CB_MAX_RECEIVED_PACKETS 16 // max # of received packets at one time
117 // limit our receive routine to indicating
118 // this many at a time for 2 reasons:
119 // 1. driver flow control to protocol layer
120 // 2. limit the time used in ISR routine
122 #define CB_EXTRA_RD_NUM 32 // default # of Extra RD
123 #define CB_RD_NUM 32 // default # of RD
124 #define CB_TD_NUM 32 // default # of TD
127 // max number of physical segments
128 // in a single NDIS packet. Above this threshold, the packet
129 // is copied into a single physically contiguous buffer
130 #define CB_MAX_SEGMENT 4
132 #define CB_MIN_MAP_REG_NUM 4
133 #define CB_MAX_MAP_REG_NUM CB_MAX_TX_DESC
135 #define CB_PROTOCOL_RESERVED_SECTION 16
138 // if retrys excess 15 times , tx will abort, and
139 // if tx fifo underflow, tx will fail
140 // we should try to resend it
141 #define CB_MAX_TX_ABORT_RETRY 3
145 // WMAC definition FIFO Control
146 #define FIFOCTL_AUTO_FB_1 0x0010 // 0001 0000 0000 0000
147 #define FIFOCTL_AUTO_FB_0 0x0008 // 0000 1000 0000 0000
148 #define FIFOCTL_GRPACK 0x0004 // 0000 0100 0000 0000
149 #define FIFOCTL_11GA 0x0003 // 0000 0011 0000 0000
150 #define FIFOCTL_11GB 0x0002 // 0000 0010 0000 0000
151 #define FIFOCTL_11B 0x0001 // 0000 0001 0000 0000
152 #define FIFOCTL_11A 0x0000 // 0000 0000 0000 0000
153 #define FIFOCTL_RTS 0x8000 // 0000 0000 1000 0000
154 #define FIFOCTL_ISDMA0 0x4000 // 0000 0000 0100 0000
155 #define FIFOCTL_GENINT 0x2000 // 0000 0000 0010 0000
156 #define FIFOCTL_TMOEN 0x1000 // 0000 0000 0001 0000
157 #define FIFOCTL_LRETRY 0x0800 // 0000 0000 0000 1000
158 #define FIFOCTL_CRCDIS 0x0400 // 0000 0000 0000 0100
159 #define FIFOCTL_NEEDACK 0x0200 // 0000 0000 0000 0010
160 #define FIFOCTL_LHEAD 0x0100 // 0000 0000 0000 0001
162 //WMAC definition Frag Control
163 #define FRAGCTL_AES 0x0003 // 0000 0011 0000 0000
164 #define FRAGCTL_TKIP 0x0002 // 0000 0010 0000 0000
165 #define FRAGCTL_LEGACY 0x0001 // 0000 0001 0000 0000
166 #define FRAGCTL_NONENCRYPT 0x0000 // 0000 0000 0000 0000
167 //#define FRAGCTL_AC3 0x0C00 // 0000 0000 0000 1100
168 //#define FRAGCTL_AC2 0x0800 // 0000 0000 0000 1000
169 //#define FRAGCTL_AC1 0x0400 // 0000 0000 0000 0100
170 //#define FRAGCTL_AC0 0x0000 // 0000 0000 0000 0000
171 #define FRAGCTL_ENDFRAG 0x0300 // 0000 0000 0000 0011
172 #define FRAGCTL_MIDFRAG 0x0200 // 0000 0000 0000 0010
173 #define FRAGCTL_STAFRAG 0x0100 // 0000 0000 0000 0001
174 #define FRAGCTL_NONFRAG 0x0000 // 0000 0000 0000 0000
178 #define FIFOCTL_AUTO_FB_1 0x1000 // 0001 0000 0000 0000
179 #define FIFOCTL_AUTO_FB_0 0x0800 // 0000 1000 0000 0000
180 #define FIFOCTL_GRPACK 0x0400 // 0000 0100 0000 0000
181 #define FIFOCTL_11GA 0x0300 // 0000 0011 0000 0000
182 #define FIFOCTL_11GB 0x0200 // 0000 0010 0000 0000
183 #define FIFOCTL_11B 0x0100 // 0000 0001 0000 0000
184 #define FIFOCTL_11A 0x0000 // 0000 0000 0000 0000
185 #define FIFOCTL_RTS 0x0080 // 0000 0000 1000 0000
186 #define FIFOCTL_ISDMA0 0x0040 // 0000 0000 0100 0000
187 #define FIFOCTL_GENINT 0x0020 // 0000 0000 0010 0000
188 #define FIFOCTL_TMOEN 0x0010 // 0000 0000 0001 0000
189 #define FIFOCTL_LRETRY 0x0008 // 0000 0000 0000 1000
190 #define FIFOCTL_CRCDIS 0x0004 // 0000 0000 0000 0100
191 #define FIFOCTL_NEEDACK 0x0002 // 0000 0000 0000 0010
192 #define FIFOCTL_LHEAD 0x0001 // 0000 0000 0000 0001
194 //WMAC definition Frag Control
195 #define FRAGCTL_AES 0x0300 // 0000 0011 0000 0000
196 #define FRAGCTL_TKIP 0x0200 // 0000 0010 0000 0000
197 #define FRAGCTL_LEGACY 0x0100 // 0000 0001 0000 0000
198 #define FRAGCTL_NONENCRYPT 0x0000 // 0000 0000 0000 0000
199 //#define FRAGCTL_AC3 0x000C // 0000 0000 0000 1100
200 //#define FRAGCTL_AC2 0x0008 // 0000 0000 0000 1000
201 //#define FRAGCTL_AC1 0x0004 // 0000 0000 0000 0100
202 //#define FRAGCTL_AC0 0x0000 // 0000 0000 0000 0000
203 #define FRAGCTL_ENDFRAG 0x0003 // 0000 0000 0000 0011
204 #define FRAGCTL_MIDFRAG 0x0002 // 0000 0000 0000 0010
205 #define FRAGCTL_STAFRAG 0x0001 // 0000 0000 0000 0001
206 #define FRAGCTL_NONFRAG 0x0000 // 0000 0000 0000 0000
208 #endif // #ifdef __BIG_ENDIAN
210 //#define TYPE_AC0DMA 0
211 //#define TYPE_TXDMA0 1
212 #define TYPE_TXDMA0 0
213 #define TYPE_AC0DMA 1
214 #define TYPE_ATIMDMA 2
215 #define TYPE_SYNCDMA 3
218 #define TYPE_BEACONDMA 4
220 #define TYPE_RXDMA0 0
221 #define TYPE_RXDMA1 1
226 // TD_INFO flags control bit
227 #define TD_FLAGS_NETIF_SKB 0x01 // check if need release skb
228 #define TD_FLAGS_PRIV_SKB 0x02 // check if called from private skb(hostap)
229 #define TD_FLAGS_PS_RETRY 0x04 // check if PS STA frame re-transmit
230 //#define TD_FLAGS_NETIF_SKB 0x04
232 /*--------------------- Export Types ------------------------------*/
234 // ref_sk_buff is used for mapping the skb structure between pre-built driver-obj & running kernel.
235 // Since different kernel version (2.4x) may change skb structure, i.e. pre-built driver-obj
236 // may link to older skb that leads error.
238 typedef struct tagDEVICE_RD_INFO {
244 dma_addr_t curr_desc;
245 } DEVICE_RD_INFO, *PDEVICE_RD_INFO;
248 static inline PDEVICE_RD_INFO alloc_rd_info(void) {
250 if ((ptr = kmalloc(sizeof(DEVICE_RD_INFO), GFP_ATOMIC)) == NULL)
253 memset(ptr,0,sizeof(DEVICE_RD_INFO));
260 typedef struct tagRDES0 {
263 // WORD f15Reserved : 15;
265 } __attribute__ ((__packed__))
271 typedef struct tagRDES0 {
272 volatile WORD wResCount;
274 volatile U16 f15Reserved;
276 volatile U8 f8Reserved1;
277 volatile U8 f1Owner:1;
278 volatile U8 f7Reserved:7;
279 } __attribute__ ((__packed__));
280 } __attribute__ ((__packed__));
281 } __attribute__ ((__packed__))
286 typedef struct tagRDES0 {
288 WORD f15Reserved : 15;
290 } __attribute__ ((__packed__))
296 typedef struct tagRDES1 {
299 } __attribute__ ((__packed__))
305 typedef struct tagSRxDesc {
306 volatile SRDES0 m_rd0RD0;
307 volatile SRDES1 m_rd1RD1;
308 volatile U32 buff_addr;
309 volatile U32 next_desc;
310 struct tagSRxDesc *next;//4 bytes
311 volatile PDEVICE_RD_INFO pRDInfo;//4 bytes
312 volatile U32 Reserved[2];//8 bytes
313 } __attribute__ ((__packed__))
314 SRxDesc, DEF* PSRxDesc;
315 typedef const SRxDesc DEF* PCSRxDesc;
320 typedef struct tagTDES0 {
321 volatile BYTE byTSR0;
322 volatile BYTE byTSR1;
323 volatile WORD wOwner_Txtime;
324 // volatile WORD f15Txtime : 15;
325 // volatile WORD f1Owner:1;
326 } __attribute__ ((__packed__))
330 typedef struct tagTDES0 {
331 volatile BYTE byTSR0;
332 volatile BYTE byTSR1;
334 volatile U16 f15Txtime;
336 volatile U8 f8Reserved1;
337 volatile U8 f1Owner:1;
338 volatile U8 f7Reserved:7;
339 } __attribute__ ((__packed__));
340 } __attribute__ ((__packed__));
341 } __attribute__ ((__packed__))
346 typedef struct tagTDES0 {
347 volatile BYTE byTSR0;
348 volatile BYTE byTSR1;
349 volatile WORD f15Txtime : 15;
350 volatile WORD f1Owner:1;
351 } __attribute__ ((__packed__))
357 typedef struct tagTDES1 {
358 volatile WORD wReqCount;
360 volatile BYTE byReserved;
361 } __attribute__ ((__packed__))
365 typedef struct tagDEVICE_TD_INFO{
370 dma_addr_t curr_desc;
372 DWORD dwHeaderLength;
374 } DEVICE_TD_INFO, *PDEVICE_TD_INFO;
377 static inline PDEVICE_TD_INFO alloc_td_info(void) {
379 if ((ptr = kmalloc(sizeof(DEVICE_TD_INFO),GFP_ATOMIC))==NULL)
382 memset(ptr,0,sizeof(DEVICE_TD_INFO));
389 // transmit descriptor
391 typedef struct tagSTxDesc {
392 volatile STDES0 m_td0TD0;
393 volatile STDES1 m_td1TD1;
394 volatile U32 buff_addr;
395 volatile U32 next_desc;
396 struct tagSTxDesc* next; //4 bytes
397 volatile PDEVICE_TD_INFO pTDInfo;//4 bytes
398 volatile U32 Reserved[2];//8 bytes
399 } __attribute__ ((__packed__))
400 STxDesc, DEF* PSTxDesc;
401 typedef const STxDesc DEF* PCSTxDesc;
404 typedef struct tagSTxSyncDesc {
405 volatile STDES0 m_td0TD0;
406 volatile STDES1 m_td1TD1;
407 volatile DWORD buff_addr; // pointer to logical buffer
408 volatile DWORD next_desc; // pointer to next logical descriptor
409 volatile WORD m_wFIFOCtl;
410 volatile WORD m_wTimeStamp;
411 struct tagSTxSyncDesc* next; //4 bytes
412 volatile PDEVICE_TD_INFO pTDInfo;//4 bytes
413 volatile DWORD m_dwReserved2;
414 } __attribute__ ((__packed__))
415 STxSyncDesc, DEF* PSTxSyncDesc;
416 typedef const STxSyncDesc DEF* PCSTxSyncDesc;
420 // RsvTime buffer header
422 typedef struct tagSRrvTime_gRTS {
423 WORD wRTSTxRrvTime_ba;
424 WORD wRTSTxRrvTime_aa;
425 WORD wRTSTxRrvTime_bb;
429 }__attribute__ ((__packed__))
430 SRrvTime_gRTS, DEF* PSRrvTime_gRTS;
431 typedef const SRrvTime_gRTS DEF* PCSRrvTime_gRTS;
433 typedef struct tagSRrvTime_gCTS {
434 WORD wCTSTxRrvTime_ba;
438 }__attribute__ ((__packed__))
439 SRrvTime_gCTS, DEF* PSRrvTime_gCTS;
440 typedef const SRrvTime_gCTS DEF* PCSRrvTime_gCTS;
442 typedef struct tagSRrvTime_ab {
445 }__attribute__ ((__packed__))
446 SRrvTime_ab, DEF* PSRrvTime_ab;
447 typedef const SRrvTime_ab DEF* PCSRrvTime_ab;
449 typedef struct tagSRrvTime_atim {
450 WORD wCTSTxRrvTime_ba;
452 }__attribute__ ((__packed__))
453 SRrvTime_atim, DEF* PSRrvTime_atim;
454 typedef const SRrvTime_atim DEF* PCSRrvTime_atim;
459 typedef struct tagSRTSData {
462 BYTE abyRA[U_ETHER_ADDR_LEN];
463 BYTE abyTA[U_ETHER_ADDR_LEN];
464 }__attribute__ ((__packed__))
465 SRTSData, DEF* PSRTSData;
466 typedef const SRTSData DEF* PCSRTSData;
468 typedef struct tagSRTS_g {
469 BYTE bySignalField_b;
470 BYTE byServiceField_b;
471 WORD wTransmitLength_b;
472 BYTE bySignalField_a;
473 BYTE byServiceField_a;
474 WORD wTransmitLength_a;
480 }__attribute__ ((__packed__))
481 SRTS_g, DEF* PSRTS_g;
482 typedef const SRTS_g DEF* PCSRTS_g;
485 typedef struct tagSRTS_g_FB {
486 BYTE bySignalField_b;
487 BYTE byServiceField_b;
488 WORD wTransmitLength_b;
489 BYTE bySignalField_a;
490 BYTE byServiceField_a;
491 WORD wTransmitLength_a;
496 WORD wRTSDuration_ba_f0;
497 WORD wRTSDuration_aa_f0;
498 WORD wRTSDuration_ba_f1;
499 WORD wRTSDuration_aa_f1;
501 }__attribute__ ((__packed__))
502 SRTS_g_FB, DEF* PSRTS_g_FB;
503 typedef const SRTS_g_FB DEF* PCSRTS_g_FB;
506 typedef struct tagSRTS_ab {
509 WORD wTransmitLength;
513 }__attribute__ ((__packed__))
514 SRTS_ab, DEF* PSRTS_ab;
515 typedef const SRTS_ab DEF* PCSRTS_ab;
518 typedef struct tagSRTS_a_FB {
521 WORD wTransmitLength;
524 WORD wRTSDuration_f0;
525 WORD wRTSDuration_f1;
527 }__attribute__ ((__packed__))
528 SRTS_a_FB, DEF* PSRTS_a_FB;
529 typedef const SRTS_a_FB DEF* PCSRTS_a_FB;
535 typedef struct tagSCTSData {
538 BYTE abyRA[U_ETHER_ADDR_LEN];
540 }__attribute__ ((__packed__))
541 SCTSData, DEF* PSCTSData;
543 typedef struct tagSCTS {
544 BYTE bySignalField_b;
545 BYTE byServiceField_b;
546 WORD wTransmitLength_b;
550 }__attribute__ ((__packed__))
552 typedef const SCTS DEF* PCSCTS;
554 typedef struct tagSCTS_FB {
555 BYTE bySignalField_b;
556 BYTE byServiceField_b;
557 WORD wTransmitLength_b;
560 WORD wCTSDuration_ba_f0;
561 WORD wCTSDuration_ba_f1;
563 }__attribute__ ((__packed__))
564 SCTS_FB, DEF* PSCTS_FB;
565 typedef const SCTS_FB DEF* PCSCTS_FB;
571 typedef struct tagSTxBufHead {
578 }__attribute__ ((__packed__))
579 STxBufHead, DEF* PSTxBufHead;
580 typedef const STxBufHead DEF* PCSTxBufHead;
582 typedef struct tagSTxShortBufHead {
585 }__attribute__ ((__packed__))
586 STxShortBufHead, DEF* PSTxShortBufHead;
587 typedef const STxShortBufHead DEF* PCSTxShortBufHead;
592 typedef struct tagSTxDataHead_g {
593 BYTE bySignalField_b;
594 BYTE byServiceField_b;
595 WORD wTransmitLength_b;
596 BYTE bySignalField_a;
597 BYTE byServiceField_a;
598 WORD wTransmitLength_a;
601 WORD wTimeStampOff_b;
602 WORD wTimeStampOff_a;
603 }__attribute__ ((__packed__))
604 STxDataHead_g, DEF* PSTxDataHead_g;
605 typedef const STxDataHead_g DEF* PCSTxDataHead_g;
607 typedef struct tagSTxDataHead_g_FB {
608 BYTE bySignalField_b;
609 BYTE byServiceField_b;
610 WORD wTransmitLength_b;
611 BYTE bySignalField_a;
612 BYTE byServiceField_a;
613 WORD wTransmitLength_a;
618 WORD wTimeStampOff_b;
619 WORD wTimeStampOff_a;
620 }__attribute__ ((__packed__))
621 STxDataHead_g_FB, DEF* PSTxDataHead_g_FB;
622 typedef const STxDataHead_g_FB DEF* PCSTxDataHead_g_FB;
625 typedef struct tagSTxDataHead_ab {
628 WORD wTransmitLength;
631 }__attribute__ ((__packed__))
632 STxDataHead_ab, DEF* PSTxDataHead_ab;
633 typedef const STxDataHead_ab DEF* PCSTxDataHead_ab;
636 typedef struct tagSTxDataHead_a_FB {
639 WORD wTransmitLength;
644 }__attribute__ ((__packed__))
645 STxDataHead_a_FB, DEF* PSTxDataHead_a_FB;
646 typedef const STxDataHead_a_FB DEF* PCSTxDataHead_a_FB;
649 // MICHDR data header
651 typedef struct tagSMICHDRHead {
655 }__attribute__ ((__packed__))
656 SMICHDRHead, DEF* PSMICHDRHead;
657 typedef const SMICHDRHead DEF* PCSMICHDRHead;
659 typedef struct tagSBEACONCtl {
664 }__attribute__ ((__packed__))
668 typedef struct tagSSecretKey {
671 }__attribute__ ((__packed__))
674 typedef struct tagSKeyEntry {
683 }__attribute__ ((__packed__))
685 /*--------------------- Export Macros ------------------------------*/
687 /*--------------------- Export Classes ----------------------------*/
689 /*--------------------- Export Variables --------------------------*/
691 /*--------------------- Export Functions --------------------------*/