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__)
49 /*--------------------- Export Definitions -------------------------*/
51 #define B_OWNED_BY_CHIP 1 //
52 #define B_OWNED_BY_HOST 0 //
55 // Bits in the RSR register
57 #define RSR_ADDRBROAD 0x80 // 1000 0000
58 #define RSR_ADDRMULTI 0x40 // 0100 0000
59 #define RSR_ADDRUNI 0x00 // 0000 0000
60 #define RSR_IVLDTYP 0x20 // 0010 0000 , invalid packet type
61 #define RSR_IVLDLEN 0x10 // 0001 0000 , invalid len (> 2312 byte)
62 #define RSR_BSSIDOK 0x08 // 0000 1000
63 #define RSR_CRCOK 0x04 // 0000 0100
64 #define RSR_BCNSSIDOK 0x02 // 0000 0010
65 #define RSR_ADDROK 0x01 // 0000 0001
68 // Bits in the new RSR register
70 #define NEWRSR_DECRYPTOK 0x10 // 0001 0000
71 #define NEWRSR_CFPIND 0x08 // 0000 1000
72 #define NEWRSR_HWUTSF 0x04 // 0000 0100
73 #define NEWRSR_BCNHITAID 0x02 // 0000 0010
74 #define NEWRSR_BCNHITAID0 0x01 // 0000 0001
77 // Bits in the TSR0 register
79 #define TSR0_PWRSTS1_2 0xC0 // 1100 0000
80 #define TSR0_PWRSTS7 0x20 // 0010 0000
81 #define TSR0_NCR 0x1F // 0001 1111
84 // Bits in the TSR1 register
86 #define TSR1_TERR 0x80 // 1000 0000
87 #define TSR1_PWRSTS4_6 0x70 // 0111 0000
88 #define TSR1_RETRYTMO 0x08 // 0000 1000
89 #define TSR1_TMO 0x04 // 0000 0100
90 #define TSR1_PWRSTS3 0x02 // 0000 0010
91 #define ACK_DATA 0x01 // 0000 0000
94 // Bits in the TCR register
96 #define EDMSDU 0x04 // 0000 0100 end of sdu
97 #define TCR_EDP 0x02 // 0000 0010 end of packet
98 #define TCR_STP 0x01 // 0000 0001 start of packet
100 // max transmit or receive buffer size
101 #define CB_MAX_BUF_SIZE 2900U // max buffer size
102 // NOTE: must be multiple of 4
103 #define CB_MAX_TX_BUF_SIZE CB_MAX_BUF_SIZE // max Tx buffer size
104 #define CB_MAX_RX_BUF_SIZE_NORMAL CB_MAX_BUF_SIZE // max Rx buffer size when not use Multi-RD
106 #define CB_BEACON_BUF_SIZE 512U // default beacon buffer size
108 #define CB_MAX_RX_DESC 128 // max # of descriptor
109 #define CB_MIN_RX_DESC 16 // min # of rx descriptor
110 #define CB_MAX_TX_DESC 64 // max # of descriptor
111 #define CB_MIN_TX_DESC 16 // min # of tx descriptor
113 #define CB_MAX_RECEIVED_PACKETS 16 // max # of received packets at one time
114 // limit our receive routine to indicating
115 // this many at a time for 2 reasons:
116 // 1. driver flow control to protocol layer
117 // 2. limit the time used in ISR routine
119 #define CB_EXTRA_RD_NUM 32 // default # of Extra RD
120 #define CB_RD_NUM 32 // default # of RD
121 #define CB_TD_NUM 32 // default # of TD
124 // max number of physical segments
125 // in a single NDIS packet. Above this threshold, the packet
126 // is copied into a single physically contiguous buffer
127 #define CB_MAX_SEGMENT 4
129 #define CB_MIN_MAP_REG_NUM 4
130 #define CB_MAX_MAP_REG_NUM CB_MAX_TX_DESC
132 #define CB_PROTOCOL_RESERVED_SECTION 16
136 // if retrys excess 15 times , tx will abort, and
137 // if tx fifo underflow, tx will fail
138 // we should try to resend it
139 #define CB_MAX_TX_ABORT_RETRY 3
143 // WMAC definition FIFO Control
144 #define FIFOCTL_AUTO_FB_1 0x0010 // 0001 0000 0000 0000
145 #define FIFOCTL_AUTO_FB_0 0x0008 // 0000 1000 0000 0000
146 #define FIFOCTL_GRPACK 0x0004 // 0000 0100 0000 0000
147 #define FIFOCTL_11GA 0x0003 // 0000 0011 0000 0000
148 #define FIFOCTL_11GB 0x0002 // 0000 0010 0000 0000
149 #define FIFOCTL_11B 0x0001 // 0000 0001 0000 0000
150 #define FIFOCTL_11A 0x0000 // 0000 0000 0000 0000
151 #define FIFOCTL_RTS 0x8000 // 0000 0000 1000 0000
152 #define FIFOCTL_ISDMA0 0x4000 // 0000 0000 0100 0000
153 #define FIFOCTL_GENINT 0x2000 // 0000 0000 0010 0000
154 #define FIFOCTL_TMOEN 0x1000 // 0000 0000 0001 0000
155 #define FIFOCTL_LRETRY 0x0800 // 0000 0000 0000 1000
156 #define FIFOCTL_CRCDIS 0x0400 // 0000 0000 0000 0100
157 #define FIFOCTL_NEEDACK 0x0200 // 0000 0000 0000 0010
158 #define FIFOCTL_LHEAD 0x0100 // 0000 0000 0000 0001
160 //WMAC definition Frag Control
161 #define FRAGCTL_AES 0x0003 // 0000 0011 0000 0000
162 #define FRAGCTL_TKIP 0x0002 // 0000 0010 0000 0000
163 #define FRAGCTL_LEGACY 0x0001 // 0000 0001 0000 0000
164 #define FRAGCTL_NONENCRYPT 0x0000 // 0000 0000 0000 0000
165 //#define FRAGCTL_AC3 0x0C00 // 0000 0000 0000 1100
166 //#define FRAGCTL_AC2 0x0800 // 0000 0000 0000 1000
167 //#define FRAGCTL_AC1 0x0400 // 0000 0000 0000 0100
168 //#define FRAGCTL_AC0 0x0000 // 0000 0000 0000 0000
169 #define FRAGCTL_ENDFRAG 0x0300 // 0000 0000 0000 0011
170 #define FRAGCTL_MIDFRAG 0x0200 // 0000 0000 0000 0010
171 #define FRAGCTL_STAFRAG 0x0100 // 0000 0000 0000 0001
172 #define FRAGCTL_NONFRAG 0x0000 // 0000 0000 0000 0000
176 #define FIFOCTL_AUTO_FB_1 0x1000 // 0001 0000 0000 0000
177 #define FIFOCTL_AUTO_FB_0 0x0800 // 0000 1000 0000 0000
178 #define FIFOCTL_GRPACK 0x0400 // 0000 0100 0000 0000
179 #define FIFOCTL_11GA 0x0300 // 0000 0011 0000 0000
180 #define FIFOCTL_11GB 0x0200 // 0000 0010 0000 0000
181 #define FIFOCTL_11B 0x0100 // 0000 0001 0000 0000
182 #define FIFOCTL_11A 0x0000 // 0000 0000 0000 0000
183 #define FIFOCTL_RTS 0x0080 // 0000 0000 1000 0000
184 #define FIFOCTL_ISDMA0 0x0040 // 0000 0000 0100 0000
185 #define FIFOCTL_GENINT 0x0020 // 0000 0000 0010 0000
186 #define FIFOCTL_TMOEN 0x0010 // 0000 0000 0001 0000
187 #define FIFOCTL_LRETRY 0x0008 // 0000 0000 0000 1000
188 #define FIFOCTL_CRCDIS 0x0004 // 0000 0000 0000 0100
189 #define FIFOCTL_NEEDACK 0x0002 // 0000 0000 0000 0010
190 #define FIFOCTL_LHEAD 0x0001 // 0000 0000 0000 0001
192 //WMAC definition Frag Control
193 #define FRAGCTL_AES 0x0300 // 0000 0011 0000 0000
194 #define FRAGCTL_TKIP 0x0200 // 0000 0010 0000 0000
195 #define FRAGCTL_LEGACY 0x0100 // 0000 0001 0000 0000
196 #define FRAGCTL_NONENCRYPT 0x0000 // 0000 0000 0000 0000
197 //#define FRAGCTL_AC3 0x000C // 0000 0000 0000 1100
198 //#define FRAGCTL_AC2 0x0008 // 0000 0000 0000 1000
199 //#define FRAGCTL_AC1 0x0004 // 0000 0000 0000 0100
200 //#define FRAGCTL_AC0 0x0000 // 0000 0000 0000 0000
201 #define FRAGCTL_ENDFRAG 0x0003 // 0000 0000 0000 0011
202 #define FRAGCTL_MIDFRAG 0x0002 // 0000 0000 0000 0010
203 #define FRAGCTL_STAFRAG 0x0001 // 0000 0000 0000 0001
204 #define FRAGCTL_NONFRAG 0x0000 // 0000 0000 0000 0000
206 #endif // #ifdef __BIG_ENDIAN
208 //#define TYPE_AC0DMA 0
209 //#define TYPE_TXDMA0 1
210 #define TYPE_TXDMA0 0
211 #define TYPE_AC0DMA 1
212 #define TYPE_ATIMDMA 2
213 #define TYPE_SYNCDMA 3
216 #define TYPE_BEACONDMA 4
218 #define TYPE_RXDMA0 0
219 #define TYPE_RXDMA1 1
224 // TD_INFO flags control bit
225 #define TD_FLAGS_NETIF_SKB 0x01 // check if need release skb
226 #define TD_FLAGS_PRIV_SKB 0x02 // check if called from private skb(hostap)
227 #define TD_FLAGS_PS_RETRY 0x04 // check if PS STA frame re-transmit
228 //#define TD_FLAGS_NETIF_SKB 0x04
230 /*--------------------- Export Types ------------------------------*/
232 // ref_sk_buff is used for mapping the skb structure between pre-built driver-obj & running kernel.
233 // Since different kernel version (2.4x) may change skb structure, i.e. pre-built driver-obj
234 // may link to older skb that leads error.
236 typedef struct tagDEVICE_RD_INFO
{
239 dma_addr_t curr_desc
;
240 } DEVICE_RD_INFO
, *PDEVICE_RD_INFO
;
243 static inline PDEVICE_RD_INFO alloc_rd_info(void) {
245 if ((ptr = kmalloc(sizeof(DEVICE_RD_INFO), GFP_ATOMIC)) == NULL)
248 memset(ptr,0,sizeof(DEVICE_RD_INFO));
255 typedef struct tagRDES0 {
258 // WORD f15Reserved : 15;
260 } __attribute__ ((__packed__))
266 typedef struct tagRDES0
{
267 volatile WORD wResCount
;
269 volatile U16 f15Reserved
;
271 volatile U8 f8Reserved1
;
272 volatile U8 f1Owner
:1;
273 volatile U8 f7Reserved
:7;
274 } __attribute__ ((__packed__
));
275 } __attribute__ ((__packed__
));
276 } __attribute__ ((__packed__
))
281 typedef struct tagRDES0
{
283 WORD f15Reserved
: 15;
285 } __attribute__ ((__packed__
))
291 typedef struct tagRDES1
{
294 } __attribute__ ((__packed__
))
300 typedef struct tagSRxDesc
{
301 volatile SRDES0 m_rd0RD0
;
302 volatile SRDES1 m_rd1RD1
;
303 volatile U32 buff_addr
;
304 volatile U32 next_desc
;
305 struct tagSRxDesc
*next
;//4 bytes
306 volatile PDEVICE_RD_INFO pRDInfo
;//4 bytes
307 volatile U32 Reserved
[2];//8 bytes
308 } __attribute__ ((__packed__
))
309 SRxDesc
, DEF
* PSRxDesc
;
310 typedef const SRxDesc DEF
* PCSRxDesc
;
315 typedef struct tagTDES0 {
316 volatile BYTE byTSR0;
317 volatile BYTE byTSR1;
318 volatile WORD wOwner_Txtime;
319 // volatile WORD f15Txtime : 15;
320 // volatile WORD f1Owner:1;
321 } __attribute__ ((__packed__))
325 typedef struct tagTDES0
{
326 volatile BYTE byTSR0
;
327 volatile BYTE byTSR1
;
329 volatile U16 f15Txtime
;
331 volatile U8 f8Reserved1
;
332 volatile U8 f1Owner
:1;
333 volatile U8 f7Reserved
:7;
334 } __attribute__ ((__packed__
));
335 } __attribute__ ((__packed__
));
336 } __attribute__ ((__packed__
))
341 typedef struct tagTDES0
{
342 volatile BYTE byTSR0
;
343 volatile BYTE byTSR1
;
344 volatile WORD f15Txtime
: 15;
345 volatile WORD f1Owner
:1;
346 } __attribute__ ((__packed__
))
352 typedef struct tagTDES1
{
353 volatile WORD wReqCount
;
355 volatile BYTE byReserved
;
356 } __attribute__ ((__packed__
))
360 typedef struct tagDEVICE_TD_INFO
{
365 dma_addr_t curr_desc
;
367 DWORD dwHeaderLength
;
369 } DEVICE_TD_INFO
, *PDEVICE_TD_INFO
;
372 static inline PDEVICE_TD_INFO alloc_td_info(void) {
374 if ((ptr = kmalloc(sizeof(DEVICE_TD_INFO),GFP_ATOMIC))==NULL)
377 memset(ptr,0,sizeof(DEVICE_TD_INFO));
384 // transmit descriptor
386 typedef struct tagSTxDesc
{
387 volatile STDES0 m_td0TD0
;
388 volatile STDES1 m_td1TD1
;
389 volatile U32 buff_addr
;
390 volatile U32 next_desc
;
391 struct tagSTxDesc
* next
; //4 bytes
392 volatile PDEVICE_TD_INFO pTDInfo
;//4 bytes
393 volatile U32 Reserved
[2];//8 bytes
394 } __attribute__ ((__packed__
))
395 STxDesc
, DEF
* PSTxDesc
;
396 typedef const STxDesc DEF
* PCSTxDesc
;
399 typedef struct tagSTxSyncDesc
{
400 volatile STDES0 m_td0TD0
;
401 volatile STDES1 m_td1TD1
;
402 volatile DWORD buff_addr
; // pointer to logical buffer
403 volatile DWORD next_desc
; // pointer to next logical descriptor
404 volatile WORD m_wFIFOCtl
;
405 volatile WORD m_wTimeStamp
;
406 struct tagSTxSyncDesc
* next
; //4 bytes
407 volatile PDEVICE_TD_INFO pTDInfo
;//4 bytes
408 volatile DWORD m_dwReserved2
;
409 } __attribute__ ((__packed__
))
410 STxSyncDesc
, DEF
* PSTxSyncDesc
;
411 typedef const STxSyncDesc DEF
* PCSTxSyncDesc
;
415 // RsvTime buffer header
417 typedef struct tagSRrvTime_gRTS
{
418 WORD wRTSTxRrvTime_ba
;
419 WORD wRTSTxRrvTime_aa
;
420 WORD wRTSTxRrvTime_bb
;
424 }__attribute__ ((__packed__
))
425 SRrvTime_gRTS
, DEF
* PSRrvTime_gRTS
;
426 typedef const SRrvTime_gRTS DEF
* PCSRrvTime_gRTS
;
428 typedef struct tagSRrvTime_gCTS
{
429 WORD wCTSTxRrvTime_ba
;
433 }__attribute__ ((__packed__
))
434 SRrvTime_gCTS
, DEF
* PSRrvTime_gCTS
;
435 typedef const SRrvTime_gCTS DEF
* PCSRrvTime_gCTS
;
437 typedef struct tagSRrvTime_ab
{
440 }__attribute__ ((__packed__
))
441 SRrvTime_ab
, DEF
* PSRrvTime_ab
;
442 typedef const SRrvTime_ab DEF
* PCSRrvTime_ab
;
444 typedef struct tagSRrvTime_atim
{
445 WORD wCTSTxRrvTime_ba
;
447 }__attribute__ ((__packed__
))
448 SRrvTime_atim
, DEF
* PSRrvTime_atim
;
449 typedef const SRrvTime_atim DEF
* PCSRrvTime_atim
;
454 typedef struct tagSRTSData
{
457 BYTE abyRA
[U_ETHER_ADDR_LEN
];
458 BYTE abyTA
[U_ETHER_ADDR_LEN
];
459 }__attribute__ ((__packed__
))
460 SRTSData
, DEF
* PSRTSData
;
461 typedef const SRTSData DEF
* PCSRTSData
;
463 typedef struct tagSRTS_g
{
464 BYTE bySignalField_b
;
465 BYTE byServiceField_b
;
466 WORD wTransmitLength_b
;
467 BYTE bySignalField_a
;
468 BYTE byServiceField_a
;
469 WORD wTransmitLength_a
;
475 }__attribute__ ((__packed__
))
476 SRTS_g
, DEF
* PSRTS_g
;
477 typedef const SRTS_g DEF
* PCSRTS_g
;
480 typedef struct tagSRTS_g_FB
{
481 BYTE bySignalField_b
;
482 BYTE byServiceField_b
;
483 WORD wTransmitLength_b
;
484 BYTE bySignalField_a
;
485 BYTE byServiceField_a
;
486 WORD wTransmitLength_a
;
491 WORD wRTSDuration_ba_f0
;
492 WORD wRTSDuration_aa_f0
;
493 WORD wRTSDuration_ba_f1
;
494 WORD wRTSDuration_aa_f1
;
496 }__attribute__ ((__packed__
))
497 SRTS_g_FB
, DEF
* PSRTS_g_FB
;
498 typedef const SRTS_g_FB DEF
* PCSRTS_g_FB
;
501 typedef struct tagSRTS_ab
{
504 WORD wTransmitLength
;
508 }__attribute__ ((__packed__
))
509 SRTS_ab
, DEF
* PSRTS_ab
;
510 typedef const SRTS_ab DEF
* PCSRTS_ab
;
513 typedef struct tagSRTS_a_FB
{
516 WORD wTransmitLength
;
519 WORD wRTSDuration_f0
;
520 WORD wRTSDuration_f1
;
522 }__attribute__ ((__packed__
))
523 SRTS_a_FB
, DEF
* PSRTS_a_FB
;
524 typedef const SRTS_a_FB DEF
* PCSRTS_a_FB
;
530 typedef struct tagSCTSData
{
533 BYTE abyRA
[U_ETHER_ADDR_LEN
];
535 }__attribute__ ((__packed__
))
536 SCTSData
, DEF
* PSCTSData
;
538 typedef struct tagSCTS
{
539 BYTE bySignalField_b
;
540 BYTE byServiceField_b
;
541 WORD wTransmitLength_b
;
545 }__attribute__ ((__packed__
))
547 typedef const SCTS DEF
* PCSCTS
;
549 typedef struct tagSCTS_FB
{
550 BYTE bySignalField_b
;
551 BYTE byServiceField_b
;
552 WORD wTransmitLength_b
;
555 WORD wCTSDuration_ba_f0
;
556 WORD wCTSDuration_ba_f1
;
558 }__attribute__ ((__packed__
))
559 SCTS_FB
, DEF
* PSCTS_FB
;
560 typedef const SCTS_FB DEF
* PCSCTS_FB
;
566 typedef struct tagSTxBufHead
{
573 }__attribute__ ((__packed__
))
574 STxBufHead
, DEF
* PSTxBufHead
;
575 typedef const STxBufHead DEF
* PCSTxBufHead
;
577 typedef struct tagSTxShortBufHead
{
580 }__attribute__ ((__packed__
))
581 STxShortBufHead
, DEF
* PSTxShortBufHead
;
582 typedef const STxShortBufHead DEF
* PCSTxShortBufHead
;
587 typedef struct tagSTxDataHead_g
{
588 BYTE bySignalField_b
;
589 BYTE byServiceField_b
;
590 WORD wTransmitLength_b
;
591 BYTE bySignalField_a
;
592 BYTE byServiceField_a
;
593 WORD wTransmitLength_a
;
596 WORD wTimeStampOff_b
;
597 WORD wTimeStampOff_a
;
598 }__attribute__ ((__packed__
))
599 STxDataHead_g
, DEF
* PSTxDataHead_g
;
600 typedef const STxDataHead_g DEF
* PCSTxDataHead_g
;
602 typedef struct tagSTxDataHead_g_FB
{
603 BYTE bySignalField_b
;
604 BYTE byServiceField_b
;
605 WORD wTransmitLength_b
;
606 BYTE bySignalField_a
;
607 BYTE byServiceField_a
;
608 WORD wTransmitLength_a
;
613 WORD wTimeStampOff_b
;
614 WORD wTimeStampOff_a
;
615 }__attribute__ ((__packed__
))
616 STxDataHead_g_FB
, DEF
* PSTxDataHead_g_FB
;
617 typedef const STxDataHead_g_FB DEF
* PCSTxDataHead_g_FB
;
620 typedef struct tagSTxDataHead_ab
{
623 WORD wTransmitLength
;
626 }__attribute__ ((__packed__
))
627 STxDataHead_ab
, DEF
* PSTxDataHead_ab
;
628 typedef const STxDataHead_ab DEF
* PCSTxDataHead_ab
;
631 typedef struct tagSTxDataHead_a_FB
{
634 WORD wTransmitLength
;
639 }__attribute__ ((__packed__
))
640 STxDataHead_a_FB
, DEF
* PSTxDataHead_a_FB
;
641 typedef const STxDataHead_a_FB DEF
* PCSTxDataHead_a_FB
;
644 // MICHDR data header
646 typedef struct tagSMICHDRHead
{
650 }__attribute__ ((__packed__
))
651 SMICHDRHead
, DEF
* PSMICHDRHead
;
652 typedef const SMICHDRHead DEF
* PCSMICHDRHead
;
654 typedef struct tagSBEACONCtl
{
659 }__attribute__ ((__packed__
))
663 typedef struct tagSSecretKey
{
666 }__attribute__ ((__packed__
))
669 typedef struct tagSKeyEntry
{
678 }__attribute__ ((__packed__
))
680 /*--------------------- Export Macros ------------------------------*/
682 /*--------------------- Export Classes ----------------------------*/
684 /*--------------------- Export Variables --------------------------*/
686 /*--------------------- Export Functions --------------------------*/