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
34 #include <linux/types.h>
39 /*--------------------- Export Definitions -------------------------*/
41 #define B_OWNED_BY_CHIP 1 //
42 #define B_OWNED_BY_HOST 0 //
45 // Bits in the RSR register
47 #define RSR_ADDRBROAD 0x80 // 1000 0000
48 #define RSR_ADDRMULTI 0x40 // 0100 0000
49 #define RSR_ADDRUNI 0x00 // 0000 0000
50 #define RSR_IVLDTYP 0x20 // 0010 0000 , invalid packet type
51 #define RSR_IVLDLEN 0x10 // 0001 0000 , invalid len (> 2312 byte)
52 #define RSR_BSSIDOK 0x08 // 0000 1000
53 #define RSR_CRCOK 0x04 // 0000 0100
54 #define RSR_BCNSSIDOK 0x02 // 0000 0010
55 #define RSR_ADDROK 0x01 // 0000 0001
58 // Bits in the new RSR register
60 #define NEWRSR_DECRYPTOK 0x10 // 0001 0000
61 #define NEWRSR_CFPIND 0x08 // 0000 1000
62 #define NEWRSR_HWUTSF 0x04 // 0000 0100
63 #define NEWRSR_BCNHITAID 0x02 // 0000 0010
64 #define NEWRSR_BCNHITAID0 0x01 // 0000 0001
67 // Bits in the TSR0 register
69 #define TSR0_PWRSTS1_2 0xC0 // 1100 0000
70 #define TSR0_PWRSTS7 0x20 // 0010 0000
71 #define TSR0_NCR 0x1F // 0001 1111
74 // Bits in the TSR1 register
76 #define TSR1_TERR 0x80 // 1000 0000
77 #define TSR1_PWRSTS4_6 0x70 // 0111 0000
78 #define TSR1_RETRYTMO 0x08 // 0000 1000
79 #define TSR1_TMO 0x04 // 0000 0100
80 #define TSR1_PWRSTS3 0x02 // 0000 0010
81 #define ACK_DATA 0x01 // 0000 0000
84 // Bits in the TCR register
86 #define EDMSDU 0x04 // 0000 0100 end of sdu
87 #define TCR_EDP 0x02 // 0000 0010 end of packet
88 #define TCR_STP 0x01 // 0000 0001 start of packet
90 // max transmit or receive buffer size
91 #define CB_MAX_BUF_SIZE 2900U // max buffer size
92 // NOTE: must be multiple of 4
93 #define CB_MAX_TX_BUF_SIZE CB_MAX_BUF_SIZE // max Tx buffer size
94 #define CB_MAX_RX_BUF_SIZE_NORMAL CB_MAX_BUF_SIZE // max Rx buffer size when not use Multi-RD
96 #define CB_BEACON_BUF_SIZE 512U // default beacon buffer size
98 #define CB_MAX_RX_DESC 128 // max # of descriptor
99 #define CB_MIN_RX_DESC 16 // min # of rx descriptor
100 #define CB_MAX_TX_DESC 64 // max # of descriptor
101 #define CB_MIN_TX_DESC 16 // min # of tx descriptor
103 #define CB_MAX_RECEIVED_PACKETS 16 // max # of received packets at one time
104 // limit our receive routine to indicating
105 // this many at a time for 2 reasons:
106 // 1. driver flow control to protocol layer
107 // 2. limit the time used in ISR routine
109 #define CB_EXTRA_RD_NUM 32 // default # of Extra RD
110 #define CB_RD_NUM 32 // default # of RD
111 #define CB_TD_NUM 32 // default # of TD
113 // max number of physical segments
114 // in a single NDIS packet. Above this threshold, the packet
115 // is copied into a single physically contiguous buffer
116 #define CB_MAX_SEGMENT 4
118 #define CB_MIN_MAP_REG_NUM 4
119 #define CB_MAX_MAP_REG_NUM CB_MAX_TX_DESC
121 #define CB_PROTOCOL_RESERVED_SECTION 16
123 // if retrys excess 15 times , tx will abort, and
124 // if tx fifo underflow, tx will fail
125 // we should try to resend it
126 #define CB_MAX_TX_ABORT_RETRY 3
130 // WMAC definition FIFO Control
131 #define FIFOCTL_AUTO_FB_1 0x0010 // 0001 0000 0000 0000
132 #define FIFOCTL_AUTO_FB_0 0x0008 // 0000 1000 0000 0000
133 #define FIFOCTL_GRPACK 0x0004 // 0000 0100 0000 0000
134 #define FIFOCTL_11GA 0x0003 // 0000 0011 0000 0000
135 #define FIFOCTL_11GB 0x0002 // 0000 0010 0000 0000
136 #define FIFOCTL_11B 0x0001 // 0000 0001 0000 0000
137 #define FIFOCTL_11A 0x0000 // 0000 0000 0000 0000
138 #define FIFOCTL_RTS 0x8000 // 0000 0000 1000 0000
139 #define FIFOCTL_ISDMA0 0x4000 // 0000 0000 0100 0000
140 #define FIFOCTL_GENINT 0x2000 // 0000 0000 0010 0000
141 #define FIFOCTL_TMOEN 0x1000 // 0000 0000 0001 0000
142 #define FIFOCTL_LRETRY 0x0800 // 0000 0000 0000 1000
143 #define FIFOCTL_CRCDIS 0x0400 // 0000 0000 0000 0100
144 #define FIFOCTL_NEEDACK 0x0200 // 0000 0000 0000 0010
145 #define FIFOCTL_LHEAD 0x0100 // 0000 0000 0000 0001
147 //WMAC definition Frag Control
148 #define FRAGCTL_AES 0x0003 // 0000 0011 0000 0000
149 #define FRAGCTL_TKIP 0x0002 // 0000 0010 0000 0000
150 #define FRAGCTL_LEGACY 0x0001 // 0000 0001 0000 0000
151 #define FRAGCTL_NONENCRYPT 0x0000 // 0000 0000 0000 0000
152 #define FRAGCTL_ENDFRAG 0x0300 // 0000 0000 0000 0011
153 #define FRAGCTL_MIDFRAG 0x0200 // 0000 0000 0000 0010
154 #define FRAGCTL_STAFRAG 0x0100 // 0000 0000 0000 0001
155 #define FRAGCTL_NONFRAG 0x0000 // 0000 0000 0000 0000
159 #define FIFOCTL_AUTO_FB_1 0x1000 // 0001 0000 0000 0000
160 #define FIFOCTL_AUTO_FB_0 0x0800 // 0000 1000 0000 0000
161 #define FIFOCTL_GRPACK 0x0400 // 0000 0100 0000 0000
162 #define FIFOCTL_11GA 0x0300 // 0000 0011 0000 0000
163 #define FIFOCTL_11GB 0x0200 // 0000 0010 0000 0000
164 #define FIFOCTL_11B 0x0100 // 0000 0001 0000 0000
165 #define FIFOCTL_11A 0x0000 // 0000 0000 0000 0000
166 #define FIFOCTL_RTS 0x0080 // 0000 0000 1000 0000
167 #define FIFOCTL_ISDMA0 0x0040 // 0000 0000 0100 0000
168 #define FIFOCTL_GENINT 0x0020 // 0000 0000 0010 0000
169 #define FIFOCTL_TMOEN 0x0010 // 0000 0000 0001 0000
170 #define FIFOCTL_LRETRY 0x0008 // 0000 0000 0000 1000
171 #define FIFOCTL_CRCDIS 0x0004 // 0000 0000 0000 0100
172 #define FIFOCTL_NEEDACK 0x0002 // 0000 0000 0000 0010
173 #define FIFOCTL_LHEAD 0x0001 // 0000 0000 0000 0001
175 //WMAC definition Frag Control
176 #define FRAGCTL_AES 0x0300 // 0000 0011 0000 0000
177 #define FRAGCTL_TKIP 0x0200 // 0000 0010 0000 0000
178 #define FRAGCTL_LEGACY 0x0100 // 0000 0001 0000 0000
179 #define FRAGCTL_NONENCRYPT 0x0000 // 0000 0000 0000 0000
180 #define FRAGCTL_ENDFRAG 0x0003 // 0000 0000 0000 0011
181 #define FRAGCTL_MIDFRAG 0x0002 // 0000 0000 0000 0010
182 #define FRAGCTL_STAFRAG 0x0001 // 0000 0000 0000 0001
183 #define FRAGCTL_NONFRAG 0x0000 // 0000 0000 0000 0000
185 #endif // #ifdef __BIG_ENDIAN
187 #define TYPE_TXDMA0 0
188 #define TYPE_AC0DMA 1
189 #define TYPE_ATIMDMA 2
190 #define TYPE_SYNCDMA 3
193 #define TYPE_BEACONDMA 4
195 #define TYPE_RXDMA0 0
196 #define TYPE_RXDMA1 1
199 // TD_INFO flags control bit
200 #define TD_FLAGS_NETIF_SKB 0x01 // check if need release skb
201 #define TD_FLAGS_PRIV_SKB 0x02 // check if called from private skb(hostap)
202 #define TD_FLAGS_PS_RETRY 0x04 // check if PS STA frame re-transmit
204 /*--------------------- Export Types ------------------------------*/
206 // ref_sk_buff is used for mapping the skb structure between pre-built driver-obj & running kernel.
207 // Since different kernel version (2.4x) may change skb structure, i.e. pre-built driver-obj
208 // may link to older skb that leads error.
210 typedef struct tagDEVICE_RD_INFO
{
213 dma_addr_t curr_desc
;
214 } DEVICE_RD_INFO
, *PDEVICE_RD_INFO
;
217 static inline PDEVICE_RD_INFO alloc_rd_info(void) {
219 ptr = kmalloc(sizeof(DEVICE_RD_INFO), GFP_ATOMIC);
223 memset(ptr,0,sizeof(DEVICE_RD_INFO));
230 typedef struct tagRDES0 {
231 unsigned short wResCount;
232 unsigned short wf1Owner;
233 // unsigned short f15Reserved : 15;
234 // unsigned short f1Owner : 1;
235 } __attribute__ ((__packed__))
241 typedef struct tagRDES0
{
242 volatile unsigned short wResCount
;
244 volatile u16 f15Reserved
;
246 volatile u8 f8Reserved1
;
247 volatile u8 f1Owner
:1;
248 volatile u8 f7Reserved
:7;
249 } __attribute__ ((__packed__
));
250 } __attribute__ ((__packed__
));
251 } __attribute__ ((__packed__
))
256 typedef struct tagRDES0
{
257 unsigned short wResCount
;
258 unsigned short f15Reserved
:15;
259 unsigned short f1Owner
:1;
260 } __attribute__ ((__packed__
))
265 typedef struct tagRDES1
{
266 unsigned short wReqCount
;
267 unsigned short wReserved
;
268 } __attribute__ ((__packed__
))
274 typedef struct tagSRxDesc
{
275 volatile SRDES0 m_rd0RD0
;
276 volatile SRDES1 m_rd1RD1
;
277 volatile u32 buff_addr
;
278 volatile u32 next_desc
;
279 struct tagSRxDesc
*next
;//4 bytes
280 volatile PDEVICE_RD_INFO pRDInfo
;//4 bytes
281 volatile u32 Reserved
[2];//8 bytes
282 } __attribute__ ((__packed__
))
284 typedef const SRxDesc
*PCSRxDesc
;
289 typedef struct tagTDES0 {
290 volatile unsigned char byTSR0;
291 volatile unsigned char byTSR1;
292 volatile unsigned short wOwner_Txtime;
293 // volatile unsigned short f15Txtime : 15;
294 // volatile unsigned short f1Owner:1;
295 } __attribute__ ((__packed__))
299 typedef struct tagTDES0
{
300 volatile unsigned char byTSR0
;
301 volatile unsigned char byTSR1
;
303 volatile u16 f15Txtime
;
305 volatile u8 f8Reserved1
;
306 volatile u8 f1Owner
:1;
307 volatile u8 f7Reserved
:7;
308 } __attribute__ ((__packed__
));
309 } __attribute__ ((__packed__
));
310 } __attribute__ ((__packed__
))
315 typedef struct tagTDES0
{
316 volatile unsigned char byTSR0
;
317 volatile unsigned char byTSR1
;
318 volatile unsigned short f15Txtime
:15;
319 volatile unsigned short f1Owner
:1;
320 } __attribute__ ((__packed__
))
325 typedef struct tagTDES1
{
326 volatile unsigned short wReqCount
;
327 volatile unsigned char byTCR
;
328 volatile unsigned char byReserved
;
329 } __attribute__ ((__packed__
))
332 typedef struct tagDEVICE_TD_INFO
{
337 dma_addr_t curr_desc
;
338 unsigned long dwReqCount
;
339 unsigned long dwHeaderLength
;
340 unsigned char byFlags
;
341 } DEVICE_TD_INFO
, *PDEVICE_TD_INFO
;
344 static inline PDEVICE_TD_INFO alloc_td_info(void) {
346 ptr = kmalloc(sizeof(DEVICE_TD_INFO),GFP_ATOMIC);
350 memset(ptr,0,sizeof(DEVICE_TD_INFO));
357 // transmit descriptor
359 typedef struct tagSTxDesc
{
360 volatile STDES0 m_td0TD0
;
361 volatile STDES1 m_td1TD1
;
362 volatile u32 buff_addr
;
363 volatile u32 next_desc
;
364 struct tagSTxDesc
*next
; //4 bytes
365 volatile PDEVICE_TD_INFO pTDInfo
;//4 bytes
366 volatile u32 Reserved
[2];//8 bytes
367 } __attribute__ ((__packed__
))
369 typedef const STxDesc
*PCSTxDesc
;
371 typedef struct tagSTxSyncDesc
{
372 volatile STDES0 m_td0TD0
;
373 volatile STDES1 m_td1TD1
;
374 volatile u32 buff_addr
; // pointer to logical buffer
375 volatile u32 next_desc
; // pointer to next logical descriptor
376 volatile unsigned short m_wFIFOCtl
;
377 volatile unsigned short m_wTimeStamp
;
378 struct tagSTxSyncDesc
*next
; //4 bytes
379 volatile PDEVICE_TD_INFO pTDInfo
;//4 bytes
380 volatile u32 m_dwReserved2
;
381 } __attribute__ ((__packed__
))
382 STxSyncDesc
, *PSTxSyncDesc
;
383 typedef const STxSyncDesc
*PCSTxSyncDesc
;
386 // RsvTime buffer header
388 typedef struct tagSRrvTime_gRTS
{
389 unsigned short wRTSTxRrvTime_ba
;
390 unsigned short wRTSTxRrvTime_aa
;
391 unsigned short wRTSTxRrvTime_bb
;
392 unsigned short wReserved
;
393 unsigned short wTxRrvTime_b
;
394 unsigned short wTxRrvTime_a
;
395 } __attribute__ ((__packed__
))
396 SRrvTime_gRTS
, *PSRrvTime_gRTS
;
397 typedef const SRrvTime_gRTS
*PCSRrvTime_gRTS
;
399 typedef struct tagSRrvTime_gCTS
{
400 unsigned short wCTSTxRrvTime_ba
;
401 unsigned short wReserved
;
402 unsigned short wTxRrvTime_b
;
403 unsigned short wTxRrvTime_a
;
404 } __attribute__ ((__packed__
))
405 SRrvTime_gCTS
, *PSRrvTime_gCTS
;
406 typedef const SRrvTime_gCTS
*PCSRrvTime_gCTS
;
408 typedef struct tagSRrvTime_ab
{
409 unsigned short wRTSTxRrvTime
;
410 unsigned short wTxRrvTime
;
411 } __attribute__ ((__packed__
))
412 SRrvTime_ab
, *PSRrvTime_ab
;
413 typedef const SRrvTime_ab
*PCSRrvTime_ab
;
415 typedef struct tagSRrvTime_atim
{
416 unsigned short wCTSTxRrvTime_ba
;
417 unsigned short wTxRrvTime_a
;
418 } __attribute__ ((__packed__
))
419 SRrvTime_atim
, *PSRrvTime_atim
;
420 typedef const SRrvTime_atim
*PCSRrvTime_atim
;
425 typedef struct tagSRTSData
{
426 unsigned short wFrameControl
;
427 unsigned short wDurationID
;
428 unsigned char abyRA
[ETH_ALEN
];
429 unsigned char abyTA
[ETH_ALEN
];
430 } __attribute__ ((__packed__
))
431 SRTSData
, *PSRTSData
;
432 typedef const SRTSData
*PCSRTSData
;
434 typedef struct tagSRTS_g
{
435 unsigned char bySignalField_b
;
436 unsigned char byServiceField_b
;
437 unsigned short wTransmitLength_b
;
438 unsigned char bySignalField_a
;
439 unsigned char byServiceField_a
;
440 unsigned short wTransmitLength_a
;
441 unsigned short wDuration_ba
;
442 unsigned short wDuration_aa
;
443 unsigned short wDuration_bb
;
444 unsigned short wReserved
;
446 } __attribute__ ((__packed__
))
448 typedef const SRTS_g
*PCSRTS_g
;
450 typedef struct tagSRTS_g_FB
{
451 unsigned char bySignalField_b
;
452 unsigned char byServiceField_b
;
453 unsigned short wTransmitLength_b
;
454 unsigned char bySignalField_a
;
455 unsigned char byServiceField_a
;
456 unsigned short wTransmitLength_a
;
457 unsigned short wDuration_ba
;
458 unsigned short wDuration_aa
;
459 unsigned short wDuration_bb
;
460 unsigned short wReserved
;
461 unsigned short wRTSDuration_ba_f0
;
462 unsigned short wRTSDuration_aa_f0
;
463 unsigned short wRTSDuration_ba_f1
;
464 unsigned short wRTSDuration_aa_f1
;
466 } __attribute__ ((__packed__
))
467 SRTS_g_FB
, *PSRTS_g_FB
;
468 typedef const SRTS_g_FB
*PCSRTS_g_FB
;
470 typedef struct tagSRTS_ab
{
471 unsigned char bySignalField
;
472 unsigned char byServiceField
;
473 unsigned short wTransmitLength
;
474 unsigned short wDuration
;
475 unsigned short wReserved
;
477 } __attribute__ ((__packed__
))
479 typedef const SRTS_ab
*PCSRTS_ab
;
481 typedef struct tagSRTS_a_FB
{
482 unsigned char bySignalField
;
483 unsigned char byServiceField
;
484 unsigned short wTransmitLength
;
485 unsigned short wDuration
;
486 unsigned short wReserved
;
487 unsigned short wRTSDuration_f0
;
488 unsigned short wRTSDuration_f1
;
490 } __attribute__ ((__packed__
))
491 SRTS_a_FB
, *PSRTS_a_FB
;
492 typedef const SRTS_a_FB
*PCSRTS_a_FB
;
497 typedef struct tagSCTSData
{
498 unsigned short wFrameControl
;
499 unsigned short wDurationID
;
500 unsigned char abyRA
[ETH_ALEN
];
501 unsigned short wReserved
;
502 } __attribute__ ((__packed__
))
503 SCTSData
, *PSCTSData
;
505 typedef struct tagSCTS
{
506 unsigned char bySignalField_b
;
507 unsigned char byServiceField_b
;
508 unsigned short wTransmitLength_b
;
509 unsigned short wDuration_ba
;
510 unsigned short wReserved
;
512 } __attribute__ ((__packed__
))
514 typedef const SCTS
*PCSCTS
;
516 typedef struct tagSCTS_FB
{
517 unsigned char bySignalField_b
;
518 unsigned char byServiceField_b
;
519 unsigned short wTransmitLength_b
;
520 unsigned short wDuration_ba
;
521 unsigned short wReserved
;
522 unsigned short wCTSDuration_ba_f0
;
523 unsigned short wCTSDuration_ba_f1
;
525 } __attribute__ ((__packed__
))
527 typedef const SCTS_FB
*PCSCTS_FB
;
532 typedef struct tagSTxBufHead
{
534 unsigned short wFIFOCtl
;
535 unsigned short wTimeStamp
;
536 unsigned short wFragCtl
;
537 unsigned char byTxPower
;
538 unsigned char wReserved
;
539 } __attribute__ ((__packed__
))
540 STxBufHead
, *PSTxBufHead
;
541 typedef const STxBufHead
*PCSTxBufHead
;
543 typedef struct tagSTxShortBufHead
{
544 unsigned short wFIFOCtl
;
545 unsigned short wTimeStamp
;
546 } __attribute__ ((__packed__
))
547 STxShortBufHead
, *PSTxShortBufHead
;
548 typedef const STxShortBufHead
*PCSTxShortBufHead
;
553 typedef struct tagSTxDataHead_g
{
554 unsigned char bySignalField_b
;
555 unsigned char byServiceField_b
;
556 unsigned short wTransmitLength_b
;
557 unsigned char bySignalField_a
;
558 unsigned char byServiceField_a
;
559 unsigned short wTransmitLength_a
;
560 unsigned short wDuration_b
;
561 unsigned short wDuration_a
;
562 unsigned short wTimeStampOff_b
;
563 unsigned short wTimeStampOff_a
;
564 } __attribute__ ((__packed__
))
565 STxDataHead_g
, *PSTxDataHead_g
;
566 typedef const STxDataHead_g
*PCSTxDataHead_g
;
568 typedef struct tagSTxDataHead_g_FB
{
569 unsigned char bySignalField_b
;
570 unsigned char byServiceField_b
;
571 unsigned short wTransmitLength_b
;
572 unsigned char bySignalField_a
;
573 unsigned char byServiceField_a
;
574 unsigned short wTransmitLength_a
;
575 unsigned short wDuration_b
;
576 unsigned short wDuration_a
;
577 unsigned short wDuration_a_f0
;
578 unsigned short wDuration_a_f1
;
579 unsigned short wTimeStampOff_b
;
580 unsigned short wTimeStampOff_a
;
581 } __attribute__ ((__packed__
))
582 STxDataHead_g_FB
, *PSTxDataHead_g_FB
;
583 typedef const STxDataHead_g_FB
*PCSTxDataHead_g_FB
;
585 typedef struct tagSTxDataHead_ab
{
586 unsigned char bySignalField
;
587 unsigned char byServiceField
;
588 unsigned short wTransmitLength
;
589 unsigned short wDuration
;
590 unsigned short wTimeStampOff
;
591 } __attribute__ ((__packed__
))
592 STxDataHead_ab
, *PSTxDataHead_ab
;
593 typedef const STxDataHead_ab
*PCSTxDataHead_ab
;
595 typedef struct tagSTxDataHead_a_FB
{
596 unsigned char bySignalField
;
597 unsigned char byServiceField
;
598 unsigned short wTransmitLength
;
599 unsigned short wDuration
;
600 unsigned short wTimeStampOff
;
601 unsigned short wDuration_f0
;
602 unsigned short wDuration_f1
;
603 } __attribute__ ((__packed__
))
604 STxDataHead_a_FB
, *PSTxDataHead_a_FB
;
605 typedef const STxDataHead_a_FB
*PCSTxDataHead_a_FB
;
608 // MICHDR data header
610 typedef struct tagSMICHDRHead
{
614 } __attribute__ ((__packed__
))
615 SMICHDRHead
, *PSMICHDRHead
;
616 typedef const SMICHDRHead
*PCSMICHDRHead
;
618 typedef struct tagSBEACONCtl
{
623 } __attribute__ ((__packed__
))
626 typedef struct tagSSecretKey
{
628 unsigned char byHighByte
;
629 } __attribute__ ((__packed__
))
632 typedef struct tagSKeyEntry
{
633 unsigned char abyAddrHi
[2];
634 unsigned short wKCTL
;
635 unsigned char abyAddrLo
[4];
641 } __attribute__ ((__packed__
))
643 /*--------------------- Export Macros ------------------------------*/
645 /*--------------------- Export Classes ----------------------------*/
647 /*--------------------- Export Variables --------------------------*/
649 /*--------------------- Export Functions --------------------------*/