blob: 9068c3ed696f25a3315bd566b9949094bfffbc45 [file] [log] [blame]
Forest Bond5449c682009-04-25 10:30:44 -04001/*
2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
3 * All rights reserved.
4 *
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.
9 *
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.
14 *
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.
18 *
19 * File: desc.h
20 *
21 * Purpose:The header file of descriptor
22 *
23 * Revision History:
24 *
25 * Author: Tevin Chen
26 *
27 * Date: May 21, 1996
28 *
29 */
30
Forest Bond5449c682009-04-25 10:30:44 -040031#ifndef __DESC_H__
32#define __DESC_H__
33
34#include <linux/types.h>
35#include <linux/mm.h>
Malcolm Priestley52c41302014-08-30 22:25:39 +010036#include "linux/ieee80211.h"
Forest Bond5449c682009-04-25 10:30:44 -040037#include "ttype.h"
Forest Bond5449c682009-04-25 10:30:44 -040038#include "tether.h"
Jim Lieb612822f2009-08-12 14:54:03 -070039
Igor Bezukh795a8f92014-07-25 19:05:31 +030040#define B_OWNED_BY_CHIP 1
41#define B_OWNED_BY_HOST 0
Forest Bond5449c682009-04-25 10:30:44 -040042
Veronika Kabatovab69c0bf2014-10-25 23:08:50 +020043/* Bits in the RSR register */
Igor Bezukh795a8f92014-07-25 19:05:31 +030044#define RSR_ADDRBROAD 0x80
45#define RSR_ADDRMULTI 0x40
46#define RSR_ADDRUNI 0x00
47#define RSR_IVLDTYP 0x20
Veronika Kabatovab69c0bf2014-10-25 23:08:50 +020048#define RSR_IVLDLEN 0x10 /* invalid len (> 2312 byte) */
Igor Bezukh795a8f92014-07-25 19:05:31 +030049#define RSR_BSSIDOK 0x08
50#define RSR_CRCOK 0x04
51#define RSR_BCNSSIDOK 0x02
52#define RSR_ADDROK 0x01
Forest Bond5449c682009-04-25 10:30:44 -040053
Veronika Kabatovab69c0bf2014-10-25 23:08:50 +020054/* Bits in the new RSR register */
Igor Bezukh795a8f92014-07-25 19:05:31 +030055#define NEWRSR_DECRYPTOK 0x10
56#define NEWRSR_CFPIND 0x08
57#define NEWRSR_HWUTSF 0x04
58#define NEWRSR_BCNHITAID 0x02
59#define NEWRSR_BCNHITAID0 0x01
Forest Bond5449c682009-04-25 10:30:44 -040060
Veronika Kabatovab69c0bf2014-10-25 23:08:50 +020061/* Bits in the TSR0 register */
Igor Bezukh795a8f92014-07-25 19:05:31 +030062#define TSR0_PWRSTS1_2 0xC0
63#define TSR0_PWRSTS7 0x20
64#define TSR0_NCR 0x1F
Forest Bond5449c682009-04-25 10:30:44 -040065
Veronika Kabatovab69c0bf2014-10-25 23:08:50 +020066/* Bits in the TSR1 register */
Igor Bezukh795a8f92014-07-25 19:05:31 +030067#define TSR1_TERR 0x80
68#define TSR1_PWRSTS4_6 0x70
69#define TSR1_RETRYTMO 0x08
70#define TSR1_TMO 0x04
71#define TSR1_PWRSTS3 0x02
72#define ACK_DATA 0x01
Forest Bond5449c682009-04-25 10:30:44 -040073
Veronika Kabatovab69c0bf2014-10-25 23:08:50 +020074/* Bits in the TCR register */
75#define EDMSDU 0x04 /* end of sdu */
76#define TCR_EDP 0x02 /* end of packet */
77#define TCR_STP 0x01 /* start of packet */
Forest Bond5449c682009-04-25 10:30:44 -040078
Veronika Kabatovab69c0bf2014-10-25 23:08:50 +020079/* max transmit or receive buffer size */
Igor Bezukh795a8f92014-07-25 19:05:31 +030080#define CB_MAX_BUF_SIZE 2900U
Veronika Kabatovab69c0bf2014-10-25 23:08:50 +020081 /* NOTE: must be multiple of 4 */
Igor Bezukh795a8f92014-07-25 19:05:31 +030082#define CB_MAX_TX_BUF_SIZE CB_MAX_BUF_SIZE
83#define CB_MAX_RX_BUF_SIZE_NORMAL CB_MAX_BUF_SIZE
Forest Bond5449c682009-04-25 10:30:44 -040084
Igor Bezukh795a8f92014-07-25 19:05:31 +030085#define CB_BEACON_BUF_SIZE 512U
Forest Bond5449c682009-04-25 10:30:44 -040086
Igor Bezukh795a8f92014-07-25 19:05:31 +030087#define CB_MAX_RX_DESC 128
88#define CB_MIN_RX_DESC 16
89#define CB_MAX_TX_DESC 64
90#define CB_MIN_TX_DESC 16
Forest Bond5449c682009-04-25 10:30:44 -040091
Igor Bezukh795a8f92014-07-25 19:05:31 +030092#define CB_MAX_RECEIVED_PACKETS 16
Veronika Kabatovab69c0bf2014-10-25 23:08:50 +020093 /*
94 * limit our receive routine to indicating
95 * this many at a time for 2 reasons:
96 * 1. driver flow control to protocol layer
97 * 2. limit the time used in ISR routine
98 */
Forest Bond5449c682009-04-25 10:30:44 -040099
Igor Bezukh795a8f92014-07-25 19:05:31 +0300100#define CB_EXTRA_RD_NUM 32
101#define CB_RD_NUM 32
102#define CB_TD_NUM 32
Forest Bond5449c682009-04-25 10:30:44 -0400103
Veronika Kabatovab69c0bf2014-10-25 23:08:50 +0200104/*
105 * max number of physical segments in a single NDIS packet. Above this
106 * threshold, the packet is copied into a single physically contiguous buffer
107 */
Forest Bond5449c682009-04-25 10:30:44 -0400108#define CB_MAX_SEGMENT 4
109
110#define CB_MIN_MAP_REG_NUM 4
111#define CB_MAX_MAP_REG_NUM CB_MAX_TX_DESC
112
113#define CB_PROTOCOL_RESERVED_SECTION 16
114
Veronika Kabatovab69c0bf2014-10-25 23:08:50 +0200115/*
116 * if retrys excess 15 times , tx will abort, and if tx fifo underflow,
117 * tx will fail, we should try to resend it
118 */
Forest Bond5449c682009-04-25 10:30:44 -0400119#define CB_MAX_TX_ABORT_RETRY 3
120
121#ifdef __BIG_ENDIAN
122
Veronika Kabatovab69c0bf2014-10-25 23:08:50 +0200123/* WMAC definition FIFO Control */
Igor Bezukh795a8f92014-07-25 19:05:31 +0300124#define FIFOCTL_AUTO_FB_1 0x0010
125#define FIFOCTL_AUTO_FB_0 0x0008
126#define FIFOCTL_GRPACK 0x0004
127#define FIFOCTL_11GA 0x0003
128#define FIFOCTL_11GB 0x0002
129#define FIFOCTL_11B 0x0001
130#define FIFOCTL_11A 0x0000
131#define FIFOCTL_RTS 0x8000
132#define FIFOCTL_ISDMA0 0x4000
133#define FIFOCTL_GENINT 0x2000
134#define FIFOCTL_TMOEN 0x1000
135#define FIFOCTL_LRETRY 0x0800
136#define FIFOCTL_CRCDIS 0x0400
137#define FIFOCTL_NEEDACK 0x0200
138#define FIFOCTL_LHEAD 0x0100
Forest Bond5449c682009-04-25 10:30:44 -0400139
Veronika Kabatovab69c0bf2014-10-25 23:08:50 +0200140/* WMAC definition Frag Control */
Igor Bezukh795a8f92014-07-25 19:05:31 +0300141#define FRAGCTL_AES 0x0003
142#define FRAGCTL_TKIP 0x0002
143#define FRAGCTL_LEGACY 0x0001
144#define FRAGCTL_NONENCRYPT 0x0000
145#define FRAGCTL_ENDFRAG 0x0300
146#define FRAGCTL_MIDFRAG 0x0200
147#define FRAGCTL_STAFRAG 0x0100
148#define FRAGCTL_NONFRAG 0x0000
Forest Bond5449c682009-04-25 10:30:44 -0400149
150#else
151
Igor Bezukh795a8f92014-07-25 19:05:31 +0300152#define FIFOCTL_AUTO_FB_1 0x1000
153#define FIFOCTL_AUTO_FB_0 0x0800
154#define FIFOCTL_GRPACK 0x0400
155#define FIFOCTL_11GA 0x0300
156#define FIFOCTL_11GB 0x0200
157#define FIFOCTL_11B 0x0100
158#define FIFOCTL_11A 0x0000
159#define FIFOCTL_RTS 0x0080
160#define FIFOCTL_ISDMA0 0x0040
161#define FIFOCTL_GENINT 0x0020
162#define FIFOCTL_TMOEN 0x0010
163#define FIFOCTL_LRETRY 0x0008
164#define FIFOCTL_CRCDIS 0x0004
165#define FIFOCTL_NEEDACK 0x0002
166#define FIFOCTL_LHEAD 0x0001
Forest Bond5449c682009-04-25 10:30:44 -0400167
Veronika Kabatovab69c0bf2014-10-25 23:08:50 +0200168/* WMAC definition Frag Control */
Igor Bezukh795a8f92014-07-25 19:05:31 +0300169#define FRAGCTL_AES 0x0300
170#define FRAGCTL_TKIP 0x0200
171#define FRAGCTL_LEGACY 0x0100
172#define FRAGCTL_NONENCRYPT 0x0000
173#define FRAGCTL_ENDFRAG 0x0003
174#define FRAGCTL_MIDFRAG 0x0002
175#define FRAGCTL_STAFRAG 0x0001
176#define FRAGCTL_NONFRAG 0x0000
Forest Bond5449c682009-04-25 10:30:44 -0400177
Igor Bezukh795a8f92014-07-25 19:05:31 +0300178#endif
Forest Bond5449c682009-04-25 10:30:44 -0400179
Forest Bond5449c682009-04-25 10:30:44 -0400180#define TYPE_TXDMA0 0
181#define TYPE_AC0DMA 1
182#define TYPE_ATIMDMA 2
183#define TYPE_SYNCDMA 3
184#define TYPE_MAXTD 2
185
186#define TYPE_BEACONDMA 4
187
188#define TYPE_RXDMA0 0
189#define TYPE_RXDMA1 1
190#define TYPE_MAXRD 2
191
Veronika Kabatovab69c0bf2014-10-25 23:08:50 +0200192/* TD_INFO flags control bit */
193#define TD_FLAGS_NETIF_SKB 0x01 /* check if need release skb */
194#define TD_FLAGS_PRIV_SKB 0x02 /* check if called from private skb (hostap) */
195#define TD_FLAGS_PS_RETRY 0x04 /* check if PS STA frame re-transmit */
Forest Bond5449c682009-04-25 10:30:44 -0400196
Veronika Kabatovab69c0bf2014-10-25 23:08:50 +0200197/*
198 * ref_sk_buff is used for mapping the skb structure between pre-built
199 * driver-obj & running kernel. Since different kernel version (2.4x) may
200 * change skb structure, i.e. pre-built driver-obj may link to older skb that
201 * leads error.
202 */
Forest Bond5449c682009-04-25 10:30:44 -0400203
204typedef struct tagDEVICE_RD_INFO {
Joe Perches78a717d2013-03-18 10:44:44 -0700205 struct sk_buff *skb;
206 dma_addr_t skb_dma;
207 dma_addr_t curr_desc;
Forest Bond5449c682009-04-25 10:30:44 -0400208} DEVICE_RD_INFO, *PDEVICE_RD_INFO;
209
Forest Bond5449c682009-04-25 10:30:44 -0400210#ifdef __BIG_ENDIAN
211
212typedef struct tagRDES0 {
Joe Perches78a717d2013-03-18 10:44:44 -0700213 volatile unsigned short wResCount;
Forest Bond5449c682009-04-25 10:30:44 -0400214 union {
Charles Clémentc17ce8c2010-05-28 12:34:20 -0700215 volatile u16 f15Reserved;
Forest Bond5449c682009-04-25 10:30:44 -0400216 struct {
Joe Perches78a717d2013-03-18 10:44:44 -0700217 volatile u8 f8Reserved1;
Charles Clément737c3d72010-05-28 12:34:19 -0700218 volatile u8 f1Owner:1;
219 volatile u8 f7Reserved:7;
Forest Bond5449c682009-04-25 10:30:44 -0400220 } __attribute__ ((__packed__));
221 } __attribute__ ((__packed__));
222} __attribute__ ((__packed__))
223SRDES0, *PSRDES0;
224
225#else
226
227typedef struct tagRDES0 {
Joe Perches78a717d2013-03-18 10:44:44 -0700228 unsigned short wResCount;
229 unsigned short f15Reserved:15;
230 unsigned short f1Owner:1;
Forest Bond5449c682009-04-25 10:30:44 -0400231} __attribute__ ((__packed__))
232SRDES0;
233
Forest Bond5449c682009-04-25 10:30:44 -0400234#endif
235
236typedef struct tagRDES1 {
Joe Perches78a717d2013-03-18 10:44:44 -0700237 unsigned short wReqCount;
238 unsigned short wReserved;
Forest Bond5449c682009-04-25 10:30:44 -0400239} __attribute__ ((__packed__))
240SRDES1;
241
Veronika Kabatovab69c0bf2014-10-25 23:08:50 +0200242/* Rx descriptor*/
Forest Bond5449c682009-04-25 10:30:44 -0400243typedef struct tagSRxDesc {
Joe Perches78a717d2013-03-18 10:44:44 -0700244 volatile SRDES0 m_rd0RD0;
245 volatile SRDES1 m_rd1RD1;
246 volatile u32 buff_addr;
247 volatile u32 next_desc;
Malcolm Priestley829127b2014-03-06 22:44:21 +0000248 struct tagSRxDesc *next __aligned(8);
249 volatile PDEVICE_RD_INFO pRDInfo __aligned(8);
Forest Bond5449c682009-04-25 10:30:44 -0400250} __attribute__ ((__packed__))
Jim Lieba8848472009-08-12 14:54:07 -0700251SRxDesc, *PSRxDesc;
252typedef const SRxDesc *PCSRxDesc;
Forest Bond5449c682009-04-25 10:30:44 -0400253
254#ifdef __BIG_ENDIAN
255
Forest Bond5449c682009-04-25 10:30:44 -0400256typedef struct tagTDES0 {
Joe Perches78a717d2013-03-18 10:44:44 -0700257 volatile unsigned char byTSR0;
258 volatile unsigned char byTSR1;
Forest Bond5449c682009-04-25 10:30:44 -0400259 union {
Charles Clémentc17ce8c2010-05-28 12:34:20 -0700260 volatile u16 f15Txtime;
Forest Bond5449c682009-04-25 10:30:44 -0400261 struct {
Joe Perches78a717d2013-03-18 10:44:44 -0700262 volatile u8 f8Reserved1;
Charles Clément737c3d72010-05-28 12:34:19 -0700263 volatile u8 f1Owner:1;
264 volatile u8 f7Reserved:7;
Forest Bond5449c682009-04-25 10:30:44 -0400265 } __attribute__ ((__packed__));
266 } __attribute__ ((__packed__));
267} __attribute__ ((__packed__))
268STDES0, PSTDES0;
269
270#else
271
272typedef struct tagTDES0 {
Joe Perches78a717d2013-03-18 10:44:44 -0700273 volatile unsigned char byTSR0;
274 volatile unsigned char byTSR1;
275 volatile unsigned short f15Txtime:15;
276 volatile unsigned short f1Owner:1;
Forest Bond5449c682009-04-25 10:30:44 -0400277} __attribute__ ((__packed__))
278STDES0;
279
280#endif
281
Forest Bond5449c682009-04-25 10:30:44 -0400282typedef struct tagTDES1 {
Joe Perches78a717d2013-03-18 10:44:44 -0700283 volatile unsigned short wReqCount;
284 volatile unsigned char byTCR;
285 volatile unsigned char byReserved;
Forest Bond5449c682009-04-25 10:30:44 -0400286} __attribute__ ((__packed__))
287STDES1;
288
Joe Perches78a717d2013-03-18 10:44:44 -0700289typedef struct tagDEVICE_TD_INFO {
Malcolm Priestley01eec152014-10-29 17:43:38 +0000290 void *mic_hdr;
Joe Perches78a717d2013-03-18 10:44:44 -0700291 struct sk_buff *skb;
292 unsigned char *buf;
293 dma_addr_t skb_dma;
294 dma_addr_t buf_dma;
295 dma_addr_t curr_desc;
296 unsigned long dwReqCount;
297 unsigned long dwHeaderLength;
298 unsigned char byFlags;
Forest Bond5449c682009-04-25 10:30:44 -0400299} DEVICE_TD_INFO, *PDEVICE_TD_INFO;
300
Veronika Kabatovab69c0bf2014-10-25 23:08:50 +0200301/* transmit descriptor */
Forest Bond5449c682009-04-25 10:30:44 -0400302typedef struct tagSTxDesc {
Joe Perches78a717d2013-03-18 10:44:44 -0700303 volatile STDES0 m_td0TD0;
304 volatile STDES1 m_td1TD1;
305 volatile u32 buff_addr;
306 volatile u32 next_desc;
Malcolm Priestley829127b2014-03-06 22:44:21 +0000307 struct tagSTxDesc *next __aligned(8);
308 volatile PDEVICE_TD_INFO pTDInfo __aligned(8);
Forest Bond5449c682009-04-25 10:30:44 -0400309} __attribute__ ((__packed__))
Jim Lieba8848472009-08-12 14:54:07 -0700310STxDesc, *PSTxDesc;
311typedef const STxDesc *PCSTxDesc;
Forest Bond5449c682009-04-25 10:30:44 -0400312
Forest Bond5449c682009-04-25 10:30:44 -0400313typedef struct tagSTxSyncDesc {
Joe Perches78a717d2013-03-18 10:44:44 -0700314 volatile STDES0 m_td0TD0;
315 volatile STDES1 m_td1TD1;
Veronika Kabatovab69c0bf2014-10-25 23:08:50 +0200316 volatile u32 buff_addr; /* pointer to logical buffer */
317 volatile u32 next_desc; /* pointer to next logical descriptor */
Joe Perches78a717d2013-03-18 10:44:44 -0700318 volatile unsigned short m_wFIFOCtl;
319 volatile unsigned short m_wTimeStamp;
Malcolm Priestley829127b2014-03-06 22:44:21 +0000320 struct tagSTxSyncDesc *next __aligned(8);
321 volatile PDEVICE_TD_INFO pTDInfo __aligned(8);
Forest Bond5449c682009-04-25 10:30:44 -0400322} __attribute__ ((__packed__))
Jim Lieba8848472009-08-12 14:54:07 -0700323STxSyncDesc, *PSTxSyncDesc;
324typedef const STxSyncDesc *PCSTxSyncDesc;
Forest Bond5449c682009-04-25 10:30:44 -0400325
Veronika Kabatovab69c0bf2014-10-25 23:08:50 +0200326/* RsvTime buffer header */
Forest Bond5449c682009-04-25 10:30:44 -0400327typedef struct tagSRrvTime_atim {
Joe Perches78a717d2013-03-18 10:44:44 -0700328 unsigned short wCTSTxRrvTime_ba;
329 unsigned short wTxRrvTime_a;
330} __attribute__ ((__packed__))
Jim Lieba8848472009-08-12 14:54:07 -0700331SRrvTime_atim, *PSRrvTime_atim;
332typedef const SRrvTime_atim *PCSRrvTime_atim;
Forest Bond5449c682009-04-25 10:30:44 -0400333
Malcolm Priestleyedbae992014-08-20 22:30:27 +0100334/* Length, Service, and Signal fields of Phy for Tx */
335struct vnt_phy_field {
336 u8 signal;
337 u8 service;
338 __le16 len;
339} __packed;
340
Malcolm Priestley864a5a32014-08-20 22:30:30 +0100341union vnt_phy_field_swap {
342 struct vnt_phy_field field_read;
343 u16 swap[2];
344 u32 field_write;
345};
346
Veronika Kabatovab69c0bf2014-10-25 23:08:50 +0200347/* Tx FIFO header */
Forest Bond5449c682009-04-25 10:30:44 -0400348typedef struct tagSTxBufHead {
Joe Perches78a717d2013-03-18 10:44:44 -0700349 u32 adwTxKey[4];
350 unsigned short wFIFOCtl;
351 unsigned short wTimeStamp;
352 unsigned short wFragCtl;
353 unsigned char byTxPower;
354 unsigned char wReserved;
355} __attribute__ ((__packed__))
Jim Lieba8848472009-08-12 14:54:07 -0700356STxBufHead, *PSTxBufHead;
357typedef const STxBufHead *PCSTxBufHead;
Forest Bond5449c682009-04-25 10:30:44 -0400358
Forest Bond5449c682009-04-25 10:30:44 -0400359typedef struct tagSBEACONCtl {
Joe Perches78a717d2013-03-18 10:44:44 -0700360 u32 BufReady:1;
361 u32 TSF:15;
362 u32 BufLen:11;
363 u32 Reserved:5;
364} __attribute__ ((__packed__))
Forest Bond5449c682009-04-25 10:30:44 -0400365SBEACONCtl;
366
Forest Bond5449c682009-04-25 10:30:44 -0400367typedef struct tagSSecretKey {
Joe Perches78a717d2013-03-18 10:44:44 -0700368 u32 dwLowDword;
369 unsigned char byHighByte;
370} __attribute__ ((__packed__))
Forest Bond5449c682009-04-25 10:30:44 -0400371SSecretKey;
372
373typedef struct tagSKeyEntry {
Joe Perches78a717d2013-03-18 10:44:44 -0700374 unsigned char abyAddrHi[2];
375 unsigned short wKCTL;
376 unsigned char abyAddrLo[4];
377 u32 dwKey0[4];
378 u32 dwKey1[4];
379 u32 dwKey2[4];
380 u32 dwKey3[4];
381 u32 dwKey4[4];
382} __attribute__ ((__packed__))
Forest Bond5449c682009-04-25 10:30:44 -0400383SKeyEntry;
Forest Bond5449c682009-04-25 10:30:44 -0400384
Veronika Kabatovab69c0bf2014-10-25 23:08:50 +0200385#endif /* __DESC_H__ */