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
;
218 typedef struct tagRDES0
{
219 volatile unsigned short wResCount
;
221 volatile u16 f15Reserved
;
223 volatile u8 f8Reserved1
;
224 volatile u8 f1Owner
:1;
225 volatile u8 f7Reserved
:7;
226 } __attribute__ ((__packed__
));
227 } __attribute__ ((__packed__
));
228 } __attribute__ ((__packed__
))
233 typedef struct tagRDES0
{
234 unsigned short wResCount
;
235 unsigned short f15Reserved
:15;
236 unsigned short f1Owner
:1;
237 } __attribute__ ((__packed__
))
242 typedef struct tagRDES1
{
243 unsigned short wReqCount
;
244 unsigned short wReserved
;
245 } __attribute__ ((__packed__
))
251 typedef struct tagSRxDesc
{
252 volatile SRDES0 m_rd0RD0
;
253 volatile SRDES1 m_rd1RD1
;
254 volatile u32 buff_addr
;
255 volatile u32 next_desc
;
256 struct tagSRxDesc
*next
__aligned(8);
257 volatile PDEVICE_RD_INFO pRDInfo
__aligned(8);
258 } __attribute__ ((__packed__
))
260 typedef const SRxDesc
*PCSRxDesc
;
264 typedef struct tagTDES0
{
265 volatile unsigned char byTSR0
;
266 volatile unsigned char byTSR1
;
268 volatile u16 f15Txtime
;
270 volatile u8 f8Reserved1
;
271 volatile u8 f1Owner
:1;
272 volatile u8 f7Reserved
:7;
273 } __attribute__ ((__packed__
));
274 } __attribute__ ((__packed__
));
275 } __attribute__ ((__packed__
))
280 typedef struct tagTDES0
{
281 volatile unsigned char byTSR0
;
282 volatile unsigned char byTSR1
;
283 volatile unsigned short f15Txtime
:15;
284 volatile unsigned short f1Owner
:1;
285 } __attribute__ ((__packed__
))
290 typedef struct tagTDES1
{
291 volatile unsigned short wReqCount
;
292 volatile unsigned char byTCR
;
293 volatile unsigned char byReserved
;
294 } __attribute__ ((__packed__
))
297 typedef struct tagDEVICE_TD_INFO
{
302 dma_addr_t curr_desc
;
303 unsigned long dwReqCount
;
304 unsigned long dwHeaderLength
;
305 unsigned char byFlags
;
306 } DEVICE_TD_INFO
, *PDEVICE_TD_INFO
;
309 // transmit descriptor
311 typedef struct tagSTxDesc
{
312 volatile STDES0 m_td0TD0
;
313 volatile STDES1 m_td1TD1
;
314 volatile u32 buff_addr
;
315 volatile u32 next_desc
;
316 struct tagSTxDesc
*next
__aligned(8);
317 volatile PDEVICE_TD_INFO pTDInfo
__aligned(8);
318 } __attribute__ ((__packed__
))
320 typedef const STxDesc
*PCSTxDesc
;
322 typedef struct tagSTxSyncDesc
{
323 volatile STDES0 m_td0TD0
;
324 volatile STDES1 m_td1TD1
;
325 volatile u32 buff_addr
; // pointer to logical buffer
326 volatile u32 next_desc
; // pointer to next logical descriptor
327 volatile unsigned short m_wFIFOCtl
;
328 volatile unsigned short m_wTimeStamp
;
329 struct tagSTxSyncDesc
*next
__aligned(8);
330 volatile PDEVICE_TD_INFO pTDInfo
__aligned(8);
331 } __attribute__ ((__packed__
))
332 STxSyncDesc
, *PSTxSyncDesc
;
333 typedef const STxSyncDesc
*PCSTxSyncDesc
;
336 // RsvTime buffer header
338 typedef struct tagSRrvTime_gRTS
{
339 unsigned short wRTSTxRrvTime_ba
;
340 unsigned short wRTSTxRrvTime_aa
;
341 unsigned short wRTSTxRrvTime_bb
;
342 unsigned short wReserved
;
343 unsigned short wTxRrvTime_b
;
344 unsigned short wTxRrvTime_a
;
345 } __attribute__ ((__packed__
))
346 SRrvTime_gRTS
, *PSRrvTime_gRTS
;
347 typedef const SRrvTime_gRTS
*PCSRrvTime_gRTS
;
349 typedef struct tagSRrvTime_gCTS
{
350 unsigned short wCTSTxRrvTime_ba
;
351 unsigned short wReserved
;
352 unsigned short wTxRrvTime_b
;
353 unsigned short wTxRrvTime_a
;
354 } __attribute__ ((__packed__
))
355 SRrvTime_gCTS
, *PSRrvTime_gCTS
;
356 typedef const SRrvTime_gCTS
*PCSRrvTime_gCTS
;
358 typedef struct tagSRrvTime_ab
{
359 unsigned short wRTSTxRrvTime
;
360 unsigned short wTxRrvTime
;
361 } __attribute__ ((__packed__
))
362 SRrvTime_ab
, *PSRrvTime_ab
;
363 typedef const SRrvTime_ab
*PCSRrvTime_ab
;
365 typedef struct tagSRrvTime_atim
{
366 unsigned short wCTSTxRrvTime_ba
;
367 unsigned short wTxRrvTime_a
;
368 } __attribute__ ((__packed__
))
369 SRrvTime_atim
, *PSRrvTime_atim
;
370 typedef const SRrvTime_atim
*PCSRrvTime_atim
;
375 typedef struct tagSRTSData
{
376 unsigned short wFrameControl
;
377 unsigned short wDurationID
;
378 unsigned char abyRA
[ETH_ALEN
];
379 unsigned char abyTA
[ETH_ALEN
];
380 } __attribute__ ((__packed__
))
381 SRTSData
, *PSRTSData
;
382 typedef const SRTSData
*PCSRTSData
;
384 typedef struct tagSRTS_g
{
385 unsigned char bySignalField_b
;
386 unsigned char byServiceField_b
;
387 unsigned short wTransmitLength_b
;
388 unsigned char bySignalField_a
;
389 unsigned char byServiceField_a
;
390 unsigned short wTransmitLength_a
;
391 unsigned short wDuration_ba
;
392 unsigned short wDuration_aa
;
393 unsigned short wDuration_bb
;
394 unsigned short wReserved
;
396 } __attribute__ ((__packed__
))
398 typedef const SRTS_g
*PCSRTS_g
;
400 typedef struct tagSRTS_g_FB
{
401 unsigned char bySignalField_b
;
402 unsigned char byServiceField_b
;
403 unsigned short wTransmitLength_b
;
404 unsigned char bySignalField_a
;
405 unsigned char byServiceField_a
;
406 unsigned short wTransmitLength_a
;
407 unsigned short wDuration_ba
;
408 unsigned short wDuration_aa
;
409 unsigned short wDuration_bb
;
410 unsigned short wReserved
;
411 unsigned short wRTSDuration_ba_f0
;
412 unsigned short wRTSDuration_aa_f0
;
413 unsigned short wRTSDuration_ba_f1
;
414 unsigned short wRTSDuration_aa_f1
;
416 } __attribute__ ((__packed__
))
417 SRTS_g_FB
, *PSRTS_g_FB
;
418 typedef const SRTS_g_FB
*PCSRTS_g_FB
;
420 typedef struct tagSRTS_ab
{
421 unsigned char bySignalField
;
422 unsigned char byServiceField
;
423 unsigned short wTransmitLength
;
424 unsigned short wDuration
;
425 unsigned short wReserved
;
427 } __attribute__ ((__packed__
))
429 typedef const SRTS_ab
*PCSRTS_ab
;
431 typedef struct tagSRTS_a_FB
{
432 unsigned char bySignalField
;
433 unsigned char byServiceField
;
434 unsigned short wTransmitLength
;
435 unsigned short wDuration
;
436 unsigned short wReserved
;
437 unsigned short wRTSDuration_f0
;
438 unsigned short wRTSDuration_f1
;
440 } __attribute__ ((__packed__
))
441 SRTS_a_FB
, *PSRTS_a_FB
;
442 typedef const SRTS_a_FB
*PCSRTS_a_FB
;
447 typedef struct tagSCTSData
{
448 unsigned short wFrameControl
;
449 unsigned short wDurationID
;
450 unsigned char abyRA
[ETH_ALEN
];
451 unsigned short wReserved
;
452 } __attribute__ ((__packed__
))
453 SCTSData
, *PSCTSData
;
455 typedef struct tagSCTS
{
456 unsigned char bySignalField_b
;
457 unsigned char byServiceField_b
;
458 unsigned short wTransmitLength_b
;
459 unsigned short wDuration_ba
;
460 unsigned short wReserved
;
462 } __attribute__ ((__packed__
))
464 typedef const SCTS
*PCSCTS
;
466 typedef struct tagSCTS_FB
{
467 unsigned char bySignalField_b
;
468 unsigned char byServiceField_b
;
469 unsigned short wTransmitLength_b
;
470 unsigned short wDuration_ba
;
471 unsigned short wReserved
;
472 unsigned short wCTSDuration_ba_f0
;
473 unsigned short wCTSDuration_ba_f1
;
475 } __attribute__ ((__packed__
))
477 typedef const SCTS_FB
*PCSCTS_FB
;
482 typedef struct tagSTxBufHead
{
484 unsigned short wFIFOCtl
;
485 unsigned short wTimeStamp
;
486 unsigned short wFragCtl
;
487 unsigned char byTxPower
;
488 unsigned char wReserved
;
489 } __attribute__ ((__packed__
))
490 STxBufHead
, *PSTxBufHead
;
491 typedef const STxBufHead
*PCSTxBufHead
;
493 typedef struct tagSTxShortBufHead
{
494 unsigned short wFIFOCtl
;
495 unsigned short wTimeStamp
;
496 } __attribute__ ((__packed__
))
497 STxShortBufHead
, *PSTxShortBufHead
;
498 typedef const STxShortBufHead
*PCSTxShortBufHead
;
503 typedef struct tagSTxDataHead_g
{
504 unsigned char bySignalField_b
;
505 unsigned char byServiceField_b
;
506 unsigned short wTransmitLength_b
;
507 unsigned char bySignalField_a
;
508 unsigned char byServiceField_a
;
509 unsigned short wTransmitLength_a
;
510 unsigned short wDuration_b
;
511 unsigned short wDuration_a
;
512 unsigned short wTimeStampOff_b
;
513 unsigned short wTimeStampOff_a
;
514 } __attribute__ ((__packed__
))
515 STxDataHead_g
, *PSTxDataHead_g
;
516 typedef const STxDataHead_g
*PCSTxDataHead_g
;
518 typedef struct tagSTxDataHead_g_FB
{
519 unsigned char bySignalField_b
;
520 unsigned char byServiceField_b
;
521 unsigned short wTransmitLength_b
;
522 unsigned char bySignalField_a
;
523 unsigned char byServiceField_a
;
524 unsigned short wTransmitLength_a
;
525 unsigned short wDuration_b
;
526 unsigned short wDuration_a
;
527 unsigned short wDuration_a_f0
;
528 unsigned short wDuration_a_f1
;
529 unsigned short wTimeStampOff_b
;
530 unsigned short wTimeStampOff_a
;
531 } __attribute__ ((__packed__
))
532 STxDataHead_g_FB
, *PSTxDataHead_g_FB
;
533 typedef const STxDataHead_g_FB
*PCSTxDataHead_g_FB
;
535 typedef struct tagSTxDataHead_ab
{
536 unsigned char bySignalField
;
537 unsigned char byServiceField
;
538 unsigned short wTransmitLength
;
539 unsigned short wDuration
;
540 unsigned short wTimeStampOff
;
541 } __attribute__ ((__packed__
))
542 STxDataHead_ab
, *PSTxDataHead_ab
;
543 typedef const STxDataHead_ab
*PCSTxDataHead_ab
;
545 typedef struct tagSTxDataHead_a_FB
{
546 unsigned char bySignalField
;
547 unsigned char byServiceField
;
548 unsigned short wTransmitLength
;
549 unsigned short wDuration
;
550 unsigned short wTimeStampOff
;
551 unsigned short wDuration_f0
;
552 unsigned short wDuration_f1
;
553 } __attribute__ ((__packed__
))
554 STxDataHead_a_FB
, *PSTxDataHead_a_FB
;
555 typedef const STxDataHead_a_FB
*PCSTxDataHead_a_FB
;
558 // MICHDR data header
560 typedef struct tagSMICHDRHead
{
564 } __attribute__ ((__packed__
))
565 SMICHDRHead
, *PSMICHDRHead
;
566 typedef const SMICHDRHead
*PCSMICHDRHead
;
568 typedef struct tagSBEACONCtl
{
573 } __attribute__ ((__packed__
))
576 typedef struct tagSSecretKey
{
578 unsigned char byHighByte
;
579 } __attribute__ ((__packed__
))
582 typedef struct tagSKeyEntry
{
583 unsigned char abyAddrHi
[2];
584 unsigned short wKCTL
;
585 unsigned char abyAddrLo
[4];
591 } __attribute__ ((__packed__
))
593 /*--------------------- Export Macros ------------------------------*/
595 /*--------------------- Export Classes ----------------------------*/
597 /*--------------------- Export Variables --------------------------*/
599 /*--------------------- Export Functions --------------------------*/