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 #define B_OWNED_BY_CHIP 1
40 #define B_OWNED_BY_HOST 0
43 // Bits in the RSR register
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
56 // Bits in the new RSR register
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
65 // Bits in the TSR0 register
67 #define TSR0_PWRSTS1_2 0xC0
68 #define TSR0_PWRSTS7 0x20
72 // Bits in the TSR1 register
74 #define TSR1_TERR 0x80
75 #define TSR1_PWRSTS4_6 0x70
76 #define TSR1_RETRYTMO 0x08
78 #define TSR1_PWRSTS3 0x02
82 // Bits in the TCR register
84 #define EDMSDU 0x04 // end of sdu
85 #define TCR_EDP 0x02 // end of packet
86 #define TCR_STP 0x01 // start of packet
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
94 #define CB_BEACON_BUF_SIZE 512U
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
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
107 #define CB_EXTRA_RD_NUM 32
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
116 #define CB_MIN_MAP_REG_NUM 4
117 #define CB_MAX_MAP_REG_NUM CB_MAX_TX_DESC
119 #define CB_PROTOCOL_RESERVED_SECTION 16
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
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
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
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
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
185 #define TYPE_TXDMA0 0
186 #define TYPE_AC0DMA 1
187 #define TYPE_ATIMDMA 2
188 #define TYPE_SYNCDMA 3
191 #define TYPE_BEACONDMA 4
193 #define TYPE_RXDMA0 0
194 #define TYPE_RXDMA1 1
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
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.
206 typedef struct tagDEVICE_RD_INFO {
209 dma_addr_t curr_desc;
210 } DEVICE_RD_INFO, *PDEVICE_RD_INFO;
214 typedef struct tagRDES0 {
215 volatile unsigned short wResCount;
217 volatile u16 f15Reserved;
219 volatile u8 f8Reserved1;
220 volatile u8 f1Owner:1;
221 volatile u8 f7Reserved:7;
222 } __attribute__ ((__packed__));
223 } __attribute__ ((__packed__));
224 } __attribute__ ((__packed__))
229 typedef struct tagRDES0 {
230 unsigned short wResCount;
231 unsigned short f15Reserved:15;
232 unsigned short f1Owner:1;
233 } __attribute__ ((__packed__))
238 typedef struct tagRDES1 {
239 unsigned short wReqCount;
240 unsigned short wReserved;
241 } __attribute__ ((__packed__))
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__))
256 typedef const SRxDesc *PCSRxDesc;
260 typedef struct tagTDES0 {
261 volatile unsigned char byTSR0;
262 volatile unsigned char byTSR1;
264 volatile u16 f15Txtime;
266 volatile u8 f8Reserved1;
267 volatile u8 f1Owner:1;
268 volatile u8 f7Reserved:7;
269 } __attribute__ ((__packed__));
270 } __attribute__ ((__packed__));
271 } __attribute__ ((__packed__))
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__))
286 typedef struct tagTDES1 {
287 volatile unsigned short wReqCount;
288 volatile unsigned char byTCR;
289 volatile unsigned char byReserved;
290 } __attribute__ ((__packed__))
293 typedef struct tagDEVICE_TD_INFO {
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;
305 // transmit descriptor
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__))
316 typedef const STxDesc *PCSTxDesc;
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;
332 // RsvTime buffer header
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;
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;
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;
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;
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;
380 /* Length, Service, and Signal fields of Phy for Tx */
381 struct vnt_phy_field {
387 union vnt_phy_field_swap {
388 struct vnt_phy_field field_read;
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;
401 } __attribute__ ((__packed__))
403 typedef const SRTS_g *PCSRTS_g;
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;
417 } __attribute__ ((__packed__))
418 SRTS_g_FB, *PSRTS_g_FB;
419 typedef const SRTS_g_FB *PCSRTS_g_FB;
421 typedef struct tagSRTS_ab {
422 struct vnt_phy_field ab;
423 unsigned short wDuration;
424 unsigned short wReserved;
426 } __attribute__ ((__packed__))
428 typedef const SRTS_ab *PCSRTS_ab;
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;
437 } __attribute__ ((__packed__))
438 SRTS_a_FB, *PSRTS_a_FB;
439 typedef const SRTS_a_FB *PCSRTS_a_FB;
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;
452 typedef struct tagSCTS {
453 struct vnt_phy_field b;
454 unsigned short wDuration_ba;
455 unsigned short wReserved;
457 } __attribute__ ((__packed__))
459 typedef const SCTS *PCSCTS;
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;
468 } __attribute__ ((__packed__))
470 typedef const SCTS_FB *PCSCTS_FB;
475 typedef struct tagSTxBufHead {
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;
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;
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;
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;
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;
531 typedef struct tagSBEACONCtl {
536 } __attribute__ ((__packed__))
539 typedef struct tagSSecretKey {
541 unsigned char byHighByte;
542 } __attribute__ ((__packed__))
545 typedef struct tagSKeyEntry {
546 unsigned char abyAddrHi[2];
547 unsigned short wKCTL;
548 unsigned char abyAddrLo[4];
554 } __attribute__ ((__packed__))