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>
36 #include "linux/ieee80211.h"
40 #define B_OWNED_BY_CHIP 1
41 #define B_OWNED_BY_HOST 0
44 // Bits in the RSR register
46 #define RSR_ADDRBROAD 0x80
47 #define RSR_ADDRMULTI 0x40
48 #define RSR_ADDRUNI 0x00
49 #define RSR_IVLDTYP 0x20
50 #define RSR_IVLDLEN 0x10 // invalid len (> 2312 byte)
51 #define RSR_BSSIDOK 0x08
52 #define RSR_CRCOK 0x04
53 #define RSR_BCNSSIDOK 0x02
54 #define RSR_ADDROK 0x01
57 // Bits in the new RSR register
59 #define NEWRSR_DECRYPTOK 0x10
60 #define NEWRSR_CFPIND 0x08
61 #define NEWRSR_HWUTSF 0x04
62 #define NEWRSR_BCNHITAID 0x02
63 #define NEWRSR_BCNHITAID0 0x01
66 // Bits in the TSR0 register
68 #define TSR0_PWRSTS1_2 0xC0
69 #define TSR0_PWRSTS7 0x20
73 // Bits in the TSR1 register
75 #define TSR1_TERR 0x80
76 #define TSR1_PWRSTS4_6 0x70
77 #define TSR1_RETRYTMO 0x08
79 #define TSR1_PWRSTS3 0x02
83 // Bits in the TCR register
85 #define EDMSDU 0x04 // end of sdu
86 #define TCR_EDP 0x02 // end of packet
87 #define TCR_STP 0x01 // start of packet
89 // max transmit or receive buffer size
90 #define CB_MAX_BUF_SIZE 2900U
91 // NOTE: must be multiple of 4
92 #define CB_MAX_TX_BUF_SIZE CB_MAX_BUF_SIZE
93 #define CB_MAX_RX_BUF_SIZE_NORMAL CB_MAX_BUF_SIZE
95 #define CB_BEACON_BUF_SIZE 512U
97 #define CB_MAX_RX_DESC 128
98 #define CB_MIN_RX_DESC 16
99 #define CB_MAX_TX_DESC 64
100 #define CB_MIN_TX_DESC 16
102 #define CB_MAX_RECEIVED_PACKETS 16
103 // limit our receive routine to indicating
104 // this many at a time for 2 reasons:
105 // 1. driver flow control to protocol layer
106 // 2. limit the time used in ISR routine
108 #define CB_EXTRA_RD_NUM 32
112 // max number of physical segments
113 // in a single NDIS packet. Above this threshold, the packet
114 // is copied into a single physically contiguous buffer
115 #define CB_MAX_SEGMENT 4
117 #define CB_MIN_MAP_REG_NUM 4
118 #define CB_MAX_MAP_REG_NUM CB_MAX_TX_DESC
120 #define CB_PROTOCOL_RESERVED_SECTION 16
122 // if retrys excess 15 times , tx will abort, and
123 // if tx fifo underflow, tx will fail
124 // we should try to resend it
125 #define CB_MAX_TX_ABORT_RETRY 3
129 // WMAC definition FIFO Control
130 #define FIFOCTL_AUTO_FB_1 0x0010
131 #define FIFOCTL_AUTO_FB_0 0x0008
132 #define FIFOCTL_GRPACK 0x0004
133 #define FIFOCTL_11GA 0x0003
134 #define FIFOCTL_11GB 0x0002
135 #define FIFOCTL_11B 0x0001
136 #define FIFOCTL_11A 0x0000
137 #define FIFOCTL_RTS 0x8000
138 #define FIFOCTL_ISDMA0 0x4000
139 #define FIFOCTL_GENINT 0x2000
140 #define FIFOCTL_TMOEN 0x1000
141 #define FIFOCTL_LRETRY 0x0800
142 #define FIFOCTL_CRCDIS 0x0400
143 #define FIFOCTL_NEEDACK 0x0200
144 #define FIFOCTL_LHEAD 0x0100
146 //WMAC definition Frag Control
147 #define FRAGCTL_AES 0x0003
148 #define FRAGCTL_TKIP 0x0002
149 #define FRAGCTL_LEGACY 0x0001
150 #define FRAGCTL_NONENCRYPT 0x0000
151 #define FRAGCTL_ENDFRAG 0x0300
152 #define FRAGCTL_MIDFRAG 0x0200
153 #define FRAGCTL_STAFRAG 0x0100
154 #define FRAGCTL_NONFRAG 0x0000
158 #define FIFOCTL_AUTO_FB_1 0x1000
159 #define FIFOCTL_AUTO_FB_0 0x0800
160 #define FIFOCTL_GRPACK 0x0400
161 #define FIFOCTL_11GA 0x0300
162 #define FIFOCTL_11GB 0x0200
163 #define FIFOCTL_11B 0x0100
164 #define FIFOCTL_11A 0x0000
165 #define FIFOCTL_RTS 0x0080
166 #define FIFOCTL_ISDMA0 0x0040
167 #define FIFOCTL_GENINT 0x0020
168 #define FIFOCTL_TMOEN 0x0010
169 #define FIFOCTL_LRETRY 0x0008
170 #define FIFOCTL_CRCDIS 0x0004
171 #define FIFOCTL_NEEDACK 0x0002
172 #define FIFOCTL_LHEAD 0x0001
174 //WMAC definition Frag Control
175 #define FRAGCTL_AES 0x0300
176 #define FRAGCTL_TKIP 0x0200
177 #define FRAGCTL_LEGACY 0x0100
178 #define FRAGCTL_NONENCRYPT 0x0000
179 #define FRAGCTL_ENDFRAG 0x0003
180 #define FRAGCTL_MIDFRAG 0x0002
181 #define FRAGCTL_STAFRAG 0x0001
182 #define FRAGCTL_NONFRAG 0x0000
186 #define TYPE_TXDMA0 0
187 #define TYPE_AC0DMA 1
188 #define TYPE_ATIMDMA 2
189 #define TYPE_SYNCDMA 3
192 #define TYPE_BEACONDMA 4
194 #define TYPE_RXDMA0 0
195 #define TYPE_RXDMA1 1
198 // TD_INFO flags control bit
199 #define TD_FLAGS_NETIF_SKB 0x01 // check if need release skb
200 #define TD_FLAGS_PRIV_SKB 0x02 // check if called from private skb(hostap)
201 #define TD_FLAGS_PS_RETRY 0x04 // check if PS STA frame re-transmit
203 // ref_sk_buff is used for mapping the skb structure between pre-built driver-obj & running kernel.
204 // Since different kernel version (2.4x) may change skb structure, i.e. pre-built driver-obj
205 // may link to older skb that leads error.
207 typedef struct tagDEVICE_RD_INFO {
210 dma_addr_t curr_desc;
211 } DEVICE_RD_INFO, *PDEVICE_RD_INFO;
215 typedef struct tagRDES0 {
216 volatile unsigned short wResCount;
218 volatile u16 f15Reserved;
220 volatile u8 f8Reserved1;
221 volatile u8 f1Owner:1;
222 volatile u8 f7Reserved:7;
223 } __attribute__ ((__packed__));
224 } __attribute__ ((__packed__));
225 } __attribute__ ((__packed__))
230 typedef struct tagRDES0 {
231 unsigned short wResCount;
232 unsigned short f15Reserved:15;
233 unsigned short f1Owner:1;
234 } __attribute__ ((__packed__))
239 typedef struct tagRDES1 {
240 unsigned short wReqCount;
241 unsigned short wReserved;
242 } __attribute__ ((__packed__))
248 typedef struct tagSRxDesc {
249 volatile SRDES0 m_rd0RD0;
250 volatile SRDES1 m_rd1RD1;
251 volatile u32 buff_addr;
252 volatile u32 next_desc;
253 struct tagSRxDesc *next __aligned(8);
254 volatile PDEVICE_RD_INFO pRDInfo __aligned(8);
255 } __attribute__ ((__packed__))
257 typedef const SRxDesc *PCSRxDesc;
261 typedef struct tagTDES0 {
262 volatile unsigned char byTSR0;
263 volatile unsigned char byTSR1;
265 volatile u16 f15Txtime;
267 volatile u8 f8Reserved1;
268 volatile u8 f1Owner:1;
269 volatile u8 f7Reserved:7;
270 } __attribute__ ((__packed__));
271 } __attribute__ ((__packed__));
272 } __attribute__ ((__packed__))
277 typedef struct tagTDES0 {
278 volatile unsigned char byTSR0;
279 volatile unsigned char byTSR1;
280 volatile unsigned short f15Txtime:15;
281 volatile unsigned short f1Owner:1;
282 } __attribute__ ((__packed__))
287 typedef struct tagTDES1 {
288 volatile unsigned short wReqCount;
289 volatile unsigned char byTCR;
290 volatile unsigned char byReserved;
291 } __attribute__ ((__packed__))
294 typedef struct tagDEVICE_TD_INFO {
299 dma_addr_t curr_desc;
300 unsigned long dwReqCount;
301 unsigned long dwHeaderLength;
302 unsigned char byFlags;
303 } DEVICE_TD_INFO, *PDEVICE_TD_INFO;
306 // transmit descriptor
308 typedef struct tagSTxDesc {
309 volatile STDES0 m_td0TD0;
310 volatile STDES1 m_td1TD1;
311 volatile u32 buff_addr;
312 volatile u32 next_desc;
313 struct tagSTxDesc *next __aligned(8);
314 volatile PDEVICE_TD_INFO pTDInfo __aligned(8);
315 } __attribute__ ((__packed__))
317 typedef const STxDesc *PCSTxDesc;
319 typedef struct tagSTxSyncDesc {
320 volatile STDES0 m_td0TD0;
321 volatile STDES1 m_td1TD1;
322 volatile u32 buff_addr; // pointer to logical buffer
323 volatile u32 next_desc; // pointer to next logical descriptor
324 volatile unsigned short m_wFIFOCtl;
325 volatile unsigned short m_wTimeStamp;
326 struct tagSTxSyncDesc *next __aligned(8);
327 volatile PDEVICE_TD_INFO pTDInfo __aligned(8);
328 } __attribute__ ((__packed__))
329 STxSyncDesc, *PSTxSyncDesc;
330 typedef const STxSyncDesc *PCSTxSyncDesc;
333 // RsvTime buffer header
335 typedef struct tagSRrvTime_atim {
336 unsigned short wCTSTxRrvTime_ba;
337 unsigned short wTxRrvTime_a;
338 } __attribute__ ((__packed__))
339 SRrvTime_atim, *PSRrvTime_atim;
340 typedef const SRrvTime_atim *PCSRrvTime_atim;
342 /* Length, Service, and Signal fields of Phy for Tx */
343 struct vnt_phy_field {
349 union vnt_phy_field_swap {
350 struct vnt_phy_field field_read;
358 typedef struct tagSTxBufHead {
360 unsigned short wFIFOCtl;
361 unsigned short wTimeStamp;
362 unsigned short wFragCtl;
363 unsigned char byTxPower;
364 unsigned char wReserved;
365 } __attribute__ ((__packed__))
366 STxBufHead, *PSTxBufHead;
367 typedef const STxBufHead *PCSTxBufHead;
369 typedef struct tagSBEACONCtl {
374 } __attribute__ ((__packed__))
377 typedef struct tagSSecretKey {
379 unsigned char byHighByte;
380 } __attribute__ ((__packed__))
383 typedef struct tagSKeyEntry {
384 unsigned char abyAddrHi[2];
385 unsigned short wKCTL;
386 unsigned char abyAddrLo[4];
392 } __attribute__ ((__packed__))