blob: c195a9c8f1f1b22ade66ee30116348a95a45939f [file] [log] [blame]
Forest Bond92b96792009-06-13 07:38:31 -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: device.h
20 *
21 * Purpose: MAC Data structure
22 *
23 * Author: Tevin Chen
24 *
25 * Date: Mar 17, 1997
26 *
27 */
28
29#ifndef __DEVICE_H__
30#define __DEVICE_H__
31
Forest Bond92b96792009-06-13 07:38:31 -040032#include <linux/module.h>
Forest Bond92b96792009-06-13 07:38:31 -040033#include <linux/kernel.h>
Forest Bond92b96792009-06-13 07:38:31 -040034#include <linux/slab.h>
Malcolm Priestley11d404c2012-11-24 14:19:34 +000035#include <linux/delay.h>
36#include <linux/device.h>
Ben Hutchings31d5bbf2011-01-09 04:16:48 +000037#include <linux/firmware.h>
Malcolm Priestley11d404c2012-11-24 14:19:34 +000038#include <linux/etherdevice.h>
39#include <linux/suspend.h>
40#include <linux/if_arp.h>
41#include <linux/wireless.h>
42#include <net/iw_handler.h>
43#include <net/cfg80211.h>
44#include <linux/timer.h>
45#include <linux/usb.h>
Malcolm Priestleyf0fde112013-11-03 19:02:41 +000046#include <linux/crc32.h>
Malcolm Priestley11d404c2012-11-24 14:19:34 +000047
Forest Bond92b96792009-06-13 07:38:31 -040048#ifdef SIOCETHTOOL
49#define DEVICE_ETHTOOL_IOCTL_SUPPORT
50#include <linux/ethtool.h>
51#else
52#undef DEVICE_ETHTOOL_IOCTL_SUPPORT
53#endif
Forest Bond92b96792009-06-13 07:38:31 -040054
Andres Mored3e23952013-01-31 15:57:19 -050055/* please copy below macro to driver_event.c for API */
Forest Bond92b96792009-06-13 07:38:31 -040056#define RT_INSMOD_EVENT_FLAG 0x0101
57#define RT_UPDEV_EVENT_FLAG 0x0102
58#define RT_DISCONNECTED_EVENT_FLAG 0x0103
59#define RT_WPACONNECTED_EVENT_FLAG 0x0104
60#define RT_DOWNDEV_EVENT_FLAG 0x0105
61#define RT_RMMOD_EVENT_FLAG 0x0106
Forest Bond92b96792009-06-13 07:38:31 -040062
Andres Mored3e23952013-01-31 15:57:19 -050063/*
64 * device specific
65 */
Forest Bond92b96792009-06-13 07:38:31 -040066
Forest Bond92b96792009-06-13 07:38:31 -040067#include "device_cfg.h"
Forest Bond92b96792009-06-13 07:38:31 -040068#include "80211hdr.h"
Forest Bond92b96792009-06-13 07:38:31 -040069#include "tether.h"
Forest Bond92b96792009-06-13 07:38:31 -040070#include "wmgr.h"
Forest Bond92b96792009-06-13 07:38:31 -040071#include "wcmd.h"
Forest Bond92b96792009-06-13 07:38:31 -040072#include "srom.h"
Forest Bond92b96792009-06-13 07:38:31 -040073#include "rc4.h"
Forest Bond92b96792009-06-13 07:38:31 -040074#include "desc.h"
Forest Bond92b96792009-06-13 07:38:31 -040075#include "key.h"
Forest Bond92b96792009-06-13 07:38:31 -040076#include "card.h"
Malcolm Priestley748bf692013-11-03 17:49:32 +000077#include "rndis.h"
Forest Bond92b96792009-06-13 07:38:31 -040078
Otavio Salvador5008c452009-10-12 23:47:36 -030079#define VNT_USB_VENDOR_ID 0x160a
Forest Bond92b96792009-06-13 07:38:31 -040080#define VNT_USB_PRODUCT_ID 0x3184
81
82#define MAC_MAX_CONTEXT_REG (256+128)
83
84#define MAX_MULTICAST_ADDRESS_NUM 32
Andres More9a0e7562010-04-13 21:54:48 -030085#define MULTICAST_ADDRESS_LIST_SIZE (MAX_MULTICAST_ADDRESS_NUM * ETH_ALEN)
Forest Bond92b96792009-06-13 07:38:31 -040086
Forest Bond92b96792009-06-13 07:38:31 -040087#define DUPLICATE_RX_CACHE_LENGTH 5
88
89#define NUM_KEY_ENTRY 11
90
91#define TX_WEP_NONE 0
92#define TX_WEP_OTF 1
93#define TX_WEP_SW 2
94#define TX_WEP_SWOTP 3
95#define TX_WEP_OTPSW 4
96#define TX_WEP_SW232 5
97
98#define KEYSEL_WEP40 0
99#define KEYSEL_WEP104 1
100#define KEYSEL_TKIP 2
101#define KEYSEL_CCMP 3
102
Forest Bond92b96792009-06-13 07:38:31 -0400103#define AUTO_FB_NONE 0
104#define AUTO_FB_0 1
105#define AUTO_FB_1 2
106
107#define FB_RATE0 0
108#define FB_RATE1 1
109
Andres Mored3e23952013-01-31 15:57:19 -0500110/* Antenna Mode */
Forest Bond92b96792009-06-13 07:38:31 -0400111#define ANT_A 0
112#define ANT_B 1
113#define ANT_DIVERSITY 2
114#define ANT_RXD_TXA 3
115#define ANT_RXD_TXB 4
116#define ANT_UNKNOWN 0xFF
117#define ANT_TXA 0
118#define ANT_TXB 1
119#define ANT_RXA 2
120#define ANT_RXB 3
121
Forest Bond92b96792009-06-13 07:38:31 -0400122#define MAXCHECKHANGCNT 4
123
Andres Mored3e23952013-01-31 15:57:19 -0500124/* Packet type */
Forest Bond92b96792009-06-13 07:38:31 -0400125#define TX_PKT_UNI 0x00
126#define TX_PKT_MULTI 0x01
127#define TX_PKT_BROAD 0x02
128
129#define BB_VGA_LEVEL 4
130#define BB_VGA_CHANGE_THRESHOLD 3
131
Forest Bond92b96792009-06-13 07:38:31 -0400132#ifndef RUN_AT
133#define RUN_AT(x) (jiffies+(x))
134#endif
135
Andres Mored3e23952013-01-31 15:57:19 -0500136/* DMA related */
Forest Bond92b96792009-06-13 07:38:31 -0400137#define RESERV_AC0DMA 4
138
139#define PRIVATE_Message 0
140
Andres Mored9d1ccb2010-05-26 20:00:36 -0300141#define DBG_PRT(l, p, args...) { if (l <= msglevel) printk(p, ##args); }
142#define PRINT_K(p, args...) { if (PRIVATE_Message) printk(p, ##args); }
Forest Bond92b96792009-06-13 07:38:31 -0400143
144typedef enum __device_msg_level {
Andres Mored9d1ccb2010-05-26 20:00:36 -0300145 MSG_LEVEL_ERR = 0, /* Errors causing abnormal operation */
146 MSG_LEVEL_NOTICE = 1, /* Errors needing user notification */
147 MSG_LEVEL_INFO = 2, /* Normal message. */
148 MSG_LEVEL_VERBOSE = 3, /* Will report all trival errors. */
149 MSG_LEVEL_DEBUG = 4 /* Only for debug purpose. */
Forest Bond92b96792009-06-13 07:38:31 -0400150} DEVICE_MSG_LEVEL, *PDEVICE_MSG_LEVEL;
151
Malcolm Priestley302433d2013-11-03 17:40:51 +0000152#define DEVICE_INIT_COLD 0x0 /* cold init */
153#define DEVICE_INIT_RESET 0x1 /* reset init or Dx to D0 power remain */
154#define DEVICE_INIT_DXPL 0x2 /* Dx to D0 power lost init */
Forest Bond92b96792009-06-13 07:38:31 -0400155
Andres Mored3e23952013-01-31 15:57:19 -0500156/* USB */
Forest Bond92b96792009-06-13 07:38:31 -0400157
Andres Mored3e23952013-01-31 15:57:19 -0500158/*
159 * Enum of context types for SendPacket
160 */
Forest Bond92b96792009-06-13 07:38:31 -0400161typedef enum _CONTEXT_TYPE {
162 CONTEXT_DATA_PACKET = 1,
163 CONTEXT_MGMT_PACKET
164} CONTEXT_TYPE;
165
Andres Mored3e23952013-01-31 15:57:19 -0500166/* RCB (Receive Control Block) */
Malcolm Priestley115cac22013-08-28 21:12:35 +0100167struct vnt_rcb {
Malcolm Priestleydd0a7742012-12-10 21:59:10 +0000168 void *Next;
169 signed long Ref;
170 void *pDevice;
171 struct urb *pUrb;
172 struct vnt_rx_mgmt sMngPacket;
173 struct sk_buff *skb;
174 int bBoolInUse;
Malcolm Priestley115cac22013-08-28 21:12:35 +0100175};
Forest Bond92b96792009-06-13 07:38:31 -0400176
Andres Mored3e23952013-01-31 15:57:19 -0500177/* used to track bulk out irps */
Malcolm Priestleydcdf1d02013-08-27 12:41:50 +0100178struct vnt_usb_send_context {
179 void *pDevice;
180 struct sk_buff *pPacket;
181 struct urb *pUrb;
182 unsigned int uBufLen;
183 CONTEXT_TYPE Type;
184 struct ethhdr sEthHeader;
185 void *Next;
186 bool bBoolInUse;
187 unsigned char Data[MAX_TOTAL_SIZE_WITH_ALL_HEADERS];
188};
Forest Bond92b96792009-06-13 07:38:31 -0400189
Malcolm Priestley51934e72013-12-09 22:30:14 +0000190/* tx packet info for rxtx */
191struct vnt_tx_pkt_info {
192 u16 fifo_ctl;
193 u8 dest_addr[ETH_ALEN];
194};
195
Andres More213d2e92010-05-17 21:34:00 -0300196/* structure got from configuration file as user-desired default settings */
197typedef struct _DEFAULT_CONFIG {
198 signed int ZoneType;
199 signed int eConfigMode;
200 signed int eAuthenMode; /* open/wep/wpa */
201 signed int bShareKeyAlgorithm; /* open-open/{open,wep}-sharekey */
202 signed int keyidx; /* wepkey index */
203 signed int eEncryptionStatus;
204} DEFAULT_CONFIG, *PDEFAULT_CONFIG;
Forest Bond92b96792009-06-13 07:38:31 -0400205
Andres Mored3e23952013-01-31 15:57:19 -0500206/*
207 * Structure to keep track of USB interrupt packets
208 */
Forest Bond92b96792009-06-13 07:38:31 -0400209typedef struct {
Andres Morecc856e62010-05-17 21:34:01 -0300210 unsigned int uDataLen;
Andres Moreb902fbf2013-02-25 20:32:51 -0500211 u8 * pDataBuf;
Andres Mored3e23952013-01-31 15:57:19 -0500212 /* struct urb *pUrb; */
Andres Moredfdcc422013-02-12 20:36:28 -0500213 bool bInUse;
Forest Bond92b96792009-06-13 07:38:31 -0400214} INT_BUFFER, *PINT_BUFFER;
215
Andres Mored3e23952013-01-31 15:57:19 -0500216/* 0:11A 1:11B 2:11G */
Forest Bond92b96792009-06-13 07:38:31 -0400217typedef enum _VIA_BB_TYPE
218{
Andres Mored9d1ccb2010-05-26 20:00:36 -0300219 BB_TYPE_11A = 0,
Forest Bond92b96792009-06-13 07:38:31 -0400220 BB_TYPE_11B,
221 BB_TYPE_11G
222} VIA_BB_TYPE, *PVIA_BB_TYPE;
223
Andres Mored3e23952013-01-31 15:57:19 -0500224/*++ NDIS related */
Forest Bond92b96792009-06-13 07:38:31 -0400225
Forest Bond92b96792009-06-13 07:38:31 -0400226typedef enum __DEVICE_NDIS_STATUS {
Andres Mored9d1ccb2010-05-26 20:00:36 -0300227 STATUS_SUCCESS = 0,
Forest Bond92b96792009-06-13 07:38:31 -0400228 STATUS_FAILURE,
229 STATUS_RESOURCES,
230 STATUS_PENDING,
231} DEVICE_NDIS_STATUS, *PDEVICE_NDIS_STATUS;
232
Forest Bond92b96792009-06-13 07:38:31 -0400233#define MAX_BSSIDINFO_4_PMKID 16
234#define MAX_PMKIDLIST 5
Andres Mored3e23952013-01-31 15:57:19 -0500235/* flags for PMKID Candidate list structure */
Forest Bond92b96792009-06-13 07:38:31 -0400236#define NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED 0x01
237
Andres Mored3e23952013-01-31 15:57:19 -0500238/* PMKID Structures */
Andres Morecc856e62010-05-17 21:34:01 -0300239typedef unsigned char NDIS_802_11_PMKID_VALUE[16];
Forest Bond92b96792009-06-13 07:38:31 -0400240
Forest Bond92b96792009-06-13 07:38:31 -0400241typedef enum _NDIS_802_11_WEP_STATUS
242{
243 Ndis802_11WEPEnabled,
244 Ndis802_11Encryption1Enabled = Ndis802_11WEPEnabled,
245 Ndis802_11WEPDisabled,
246 Ndis802_11EncryptionDisabled = Ndis802_11WEPDisabled,
247 Ndis802_11WEPKeyAbsent,
248 Ndis802_11Encryption1KeyAbsent = Ndis802_11WEPKeyAbsent,
249 Ndis802_11WEPNotSupported,
250 Ndis802_11EncryptionNotSupported = Ndis802_11WEPNotSupported,
251 Ndis802_11Encryption2Enabled,
252 Ndis802_11Encryption2KeyAbsent,
253 Ndis802_11Encryption3Enabled,
254 Ndis802_11Encryption3KeyAbsent
255} NDIS_802_11_WEP_STATUS, *PNDIS_802_11_WEP_STATUS,
256 NDIS_802_11_ENCRYPTION_STATUS, *PNDIS_802_11_ENCRYPTION_STATUS;
257
Forest Bond92b96792009-06-13 07:38:31 -0400258typedef enum _NDIS_802_11_STATUS_TYPE
259{
Andres Mored3e23952013-01-31 15:57:19 -0500260 Ndis802_11StatusType_Authentication,
261 Ndis802_11StatusType_MediaStreamMode,
262 Ndis802_11StatusType_PMKID_CandidateList,
263 Ndis802_11StatusTypeMax, /* not a real type, defined as upper bound */
Forest Bond92b96792009-06-13 07:38:31 -0400264} NDIS_802_11_STATUS_TYPE, *PNDIS_802_11_STATUS_TYPE;
265
Andres Mored3e23952013-01-31 15:57:19 -0500266/* added new types for PMKID Candidate lists */
Forest Bond92b96792009-06-13 07:38:31 -0400267typedef struct _PMKID_CANDIDATE {
268 NDIS_802_11_MAC_ADDRESS BSSID;
Andres Morecc856e62010-05-17 21:34:01 -0300269 unsigned long Flags;
Forest Bond92b96792009-06-13 07:38:31 -0400270} PMKID_CANDIDATE, *PPMKID_CANDIDATE;
271
Forest Bond92b96792009-06-13 07:38:31 -0400272typedef struct _BSSID_INFO
273{
274 NDIS_802_11_MAC_ADDRESS BSSID;
275 NDIS_802_11_PMKID_VALUE PMKID;
276} BSSID_INFO, *PBSSID_INFO;
277
278typedef struct tagSPMKID {
Andres Morecc856e62010-05-17 21:34:01 -0300279 unsigned long Length;
280 unsigned long BSSIDInfoCount;
Forest Bond92b96792009-06-13 07:38:31 -0400281 BSSID_INFO BSSIDInfo[MAX_BSSIDINFO_4_PMKID];
282} SPMKID, *PSPMKID;
283
284typedef struct tagSPMKIDCandidateEvent {
285 NDIS_802_11_STATUS_TYPE StatusType;
Andres Morecc856e62010-05-17 21:34:01 -0300286 unsigned long Version; /* Version of the structure */
287 unsigned long NumCandidates; /* No. of pmkid candidates */
Forest Bond92b96792009-06-13 07:38:31 -0400288 PMKID_CANDIDATE CandidateList[MAX_PMKIDLIST];
Jim Lieb193a8232009-08-12 14:54:06 -0700289} SPMKIDCandidateEvent, *PSPMKIDCandidateEvent;
Forest Bond92b96792009-06-13 07:38:31 -0400290
Andres Mored3e23952013-01-31 15:57:19 -0500291/*++ 802.11h related */
Forest Bond92b96792009-06-13 07:38:31 -0400292#define MAX_QUIET_COUNT 8
293
294typedef struct tagSQuietControl {
Andres Moredfdcc422013-02-12 20:36:28 -0500295 bool bEnable;
Andres More52a7e642013-02-25 20:32:53 -0500296 u32 dwStartTime;
Andres Moreb902fbf2013-02-25 20:32:51 -0500297 u8 byPeriod;
Andres More3eaca0d2013-02-25 20:32:52 -0500298 u16 wDuration;
Jim Lieb193a8232009-08-12 14:54:06 -0700299} SQuietControl, *PSQuietControl;
Forest Bond92b96792009-06-13 07:38:31 -0400300
Andres Mored3e23952013-01-31 15:57:19 -0500301/* The receive duplicate detection cache entry */
Forest Bond92b96792009-06-13 07:38:31 -0400302typedef struct tagSCacheEntry{
Andres More3eaca0d2013-02-25 20:32:52 -0500303 u16 wFmSequence;
Andres Moreb902fbf2013-02-25 20:32:51 -0500304 u8 abyAddr2[ETH_ALEN];
Andres More3eaca0d2013-02-25 20:32:52 -0500305 u16 wFrameCtl;
Forest Bond92b96792009-06-13 07:38:31 -0400306} SCacheEntry, *PSCacheEntry;
307
308typedef struct tagSCache{
309/* The receive cache is updated circularly. The next entry to be written is
310 * indexed by the "InPtr".
Andres Mored3e23952013-01-31 15:57:19 -0500311 */
Andres Morecc856e62010-05-17 21:34:01 -0300312 unsigned int uInPtr; /* Place to use next */
Forest Bond92b96792009-06-13 07:38:31 -0400313 SCacheEntry asCacheEntry[DUPLICATE_RX_CACHE_LENGTH];
314} SCache, *PSCache;
315
316#define CB_MAX_RX_FRAG 64
Andres Mored3e23952013-01-31 15:57:19 -0500317/*
318 * DeFragment Control Block, used for collecting fragments prior to reassembly
319 */
Forest Bond92b96792009-06-13 07:38:31 -0400320typedef struct tagSDeFragControlBlock
321{
Andres More3eaca0d2013-02-25 20:32:52 -0500322 u16 wSequence;
323 u16 wFragNum;
Andres Moreb902fbf2013-02-25 20:32:51 -0500324 u8 abyAddr2[ETH_ALEN];
Andres Morecc856e62010-05-17 21:34:01 -0300325 unsigned int uLifetime;
Forest Bond92b96792009-06-13 07:38:31 -0400326 struct sk_buff* skb;
Andres Moreb902fbf2013-02-25 20:32:51 -0500327 u8 * pbyRxBuffer;
Andres Morecc856e62010-05-17 21:34:01 -0300328 unsigned int cbFrameLength;
Andres Moredfdcc422013-02-12 20:36:28 -0500329 bool bInUse;
Jim Lieb193a8232009-08-12 14:54:06 -0700330} SDeFragControlBlock, *PSDeFragControlBlock;
Forest Bond92b96792009-06-13 07:38:31 -0400331
Andres Mored3e23952013-01-31 15:57:19 -0500332/* flags for options */
Forest Bond92b96792009-06-13 07:38:31 -0400333#define DEVICE_FLAGS_UNPLUG 0x00000001UL
334#define DEVICE_FLAGS_PREAMBLE_TYPE 0x00000002UL
335#define DEVICE_FLAGS_OP_MODE 0x00000004UL
336#define DEVICE_FLAGS_PS_MODE 0x00000008UL
337#define DEVICE_FLAGS_80211h_MODE 0x00000010UL
338
Andres Mored3e23952013-01-31 15:57:19 -0500339/* flags for driver status */
Forest Bond92b96792009-06-13 07:38:31 -0400340#define DEVICE_FLAGS_OPENED 0x00010000UL
341#define DEVICE_FLAGS_WOL_ENABLED 0x00080000UL
Andres Mored3e23952013-01-31 15:57:19 -0500342/* flags for capabilities */
Forest Bond92b96792009-06-13 07:38:31 -0400343#define DEVICE_FLAGS_TX_ALIGN 0x01000000UL
344#define DEVICE_FLAGS_HAVE_CAM 0x02000000UL
345#define DEVICE_FLAGS_FLOW_CTRL 0x04000000UL
346
Andres Mored3e23952013-01-31 15:57:19 -0500347/* flags for MII status */
Forest Bond92b96792009-06-13 07:38:31 -0400348#define DEVICE_LINK_FAIL 0x00000001UL
349#define DEVICE_SPEED_10 0x00000002UL
350#define DEVICE_SPEED_100 0x00000004UL
351#define DEVICE_SPEED_1000 0x00000008UL
352#define DEVICE_DUPLEX_FULL 0x00000010UL
353#define DEVICE_AUTONEG_ENABLE 0x00000020UL
354#define DEVICE_FORCED_BY_EEPROM 0x00000040UL
Andres Mored3e23952013-01-31 15:57:19 -0500355/* for device_set_media_duplex */
Forest Bond92b96792009-06-13 07:38:31 -0400356#define DEVICE_LINK_CHANGE 0x00000001UL
357
Forest Bond92b96792009-06-13 07:38:31 -0400358typedef struct __device_opt {
Andres Mored3e23952013-01-31 15:57:19 -0500359 int nRxDescs0; /* number of RX descriptors 0 */
360 int nTxDescs0; /* number of TX descriptors 0, 1, 2, 3 */
361 int rts_thresh; /* RTS threshold */
Forest Bond92b96792009-06-13 07:38:31 -0400362 int frag_thresh;
363 int OpMode;
364 int data_rate;
365 int channel_num;
366 int short_retry;
367 int long_retry;
368 int bbp_type;
Andres More659770d2010-05-12 18:59:46 -0300369 u32 flags;
Forest Bond92b96792009-06-13 07:38:31 -0400370} OPTIONS, *POPTIONS;
371
Malcolm Priestley14c5ef52013-01-17 23:19:37 +0000372struct vnt_private {
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000373 /* netdev */
374 struct usb_device *usb;
375 struct net_device *dev;
376 struct net_device_stats stats;
Forest Bond92b96792009-06-13 07:38:31 -0400377
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000378 OPTIONS sOpts;
379
380 struct tasklet_struct CmdWorkItem;
381 struct tasklet_struct EventWorkItem;
Malcolm Priestley81d720d2013-09-27 16:53:55 +0100382 struct work_struct read_work_item;
Malcolm Priestleya21fc2f2013-09-27 16:55:45 +0100383 struct work_struct rx_mng_work_item;
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000384
385 u32 rx_buf_sz;
386 int multicast_limit;
387 u8 byRxMode;
388
389 spinlock_t lock;
390
391 u32 rx_bytes;
392
393 u8 byRevId;
394
395 u32 flags;
396 unsigned long Flags;
397
398 SCache sDupRxCache;
399
400 SDeFragControlBlock sRxDFCB[CB_MAX_RX_FRAG];
401 u32 cbDFCB;
402 u32 cbFreeDFCB;
403 u32 uCurrentDFCBIdx;
Forest Bond92b96792009-06-13 07:38:31 -0400404
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000405 /* USB */
406 struct urb *pControlURB;
407 struct urb *pInterruptURB;
408 struct usb_ctrlrequest sUsbCtlRequest;
409 u32 int_interval;
Forest Bond92b96792009-06-13 07:38:31 -0400410
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000411 /* Variables to track resources for the BULK In Pipe */
Malcolm Priestley115cac22013-08-28 21:12:35 +0100412 struct vnt_rcb *pRCBMem;
413 struct vnt_rcb *apRCB[CB_MAX_RX_DESC];
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000414 u32 cbRD;
Malcolm Priestley115cac22013-08-28 21:12:35 +0100415 struct vnt_rcb *FirstRecvFreeList;
416 struct vnt_rcb *LastRecvFreeList;
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000417 u32 NumRecvFreeList;
Malcolm Priestley115cac22013-08-28 21:12:35 +0100418 struct vnt_rcb *FirstRecvMngList;
419 struct vnt_rcb *LastRecvMngList;
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000420 u32 NumRecvMngList;
421 int bIsRxWorkItemQueued;
422 int bIsRxMngWorkItemQueued;
Andres Morecc856e62010-05-17 21:34:01 -0300423 unsigned long ulRcvRefCount; /* packets that have not returned back */
Forest Bond92b96792009-06-13 07:38:31 -0400424
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000425 /* Variables to track resources for the BULK Out Pipe */
Malcolm Priestleydcdf1d02013-08-27 12:41:50 +0100426 struct vnt_usb_send_context *apTD[CB_MAX_TX_DESC];
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000427 u32 cbTD;
Malcolm Priestley51934e72013-12-09 22:30:14 +0000428 struct vnt_tx_pkt_info pkt_info[16];
Forest Bond92b96792009-06-13 07:38:31 -0400429
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000430 /* Variables to track resources for the Interrupt In Pipe */
431 INT_BUFFER intBuf;
432 int fKillEventPollingThread;
433 int bEventAvailable;
Forest Bond92b96792009-06-13 07:38:31 -0400434
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000435 /* default config from file by user setting */
436 DEFAULT_CONFIG config_file;
Forest Bond92b96792009-06-13 07:38:31 -0400437
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000438 /* Statistic for USB */
439 unsigned long ulBulkInPosted;
440 unsigned long ulBulkInError;
441 unsigned long ulBulkInContCRCError;
442 unsigned long ulBulkInBytesRead;
443
444 unsigned long ulBulkOutPosted;
445 unsigned long ulBulkOutError;
446 unsigned long ulBulkOutContCRCError;
447 unsigned long ulBulkOutBytesWrite;
448
449 unsigned long ulIntInPosted;
450 unsigned long ulIntInError;
451 unsigned long ulIntInContCRCError;
452 unsigned long ulIntInBytesRead;
Forest Bond92b96792009-06-13 07:38:31 -0400453
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000454 /* Version control */
455 u16 wFirmwareVersion;
456 u8 byLocalID;
457 u8 byRFType;
458 u8 byBBRxConf;
Forest Bond92b96792009-06-13 07:38:31 -0400459
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000460 u8 byZoneType;
461 int bZoneRegExist;
Forest Bond92b96792009-06-13 07:38:31 -0400462
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000463 u8 byOriginalZonetype;
Forest Bond92b96792009-06-13 07:38:31 -0400464
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000465 int bLinkPass; /* link status: OK or fail */
Malcolm Priestley748bf692013-11-03 17:49:32 +0000466 struct vnt_cmd_card_init init_command;
467 struct vnt_rsp_card_init init_response;
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000468 u8 abyCurrentNetAddr[ETH_ALEN];
469 u8 abyPermanentNetAddr[ETH_ALEN];
Forest Bond92b96792009-06-13 07:38:31 -0400470
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000471 int bExistSWNetAddr;
Forest Bond92b96792009-06-13 07:38:31 -0400472
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000473 /* Maintain statistical debug info. */
474 unsigned long packetsReceived;
475 unsigned long packetsReceivedDropped;
476 unsigned long packetsReceivedOverflow;
477 unsigned long packetsSent;
478 unsigned long packetsSentDropped;
479 unsigned long SendContextsInUse;
480 unsigned long RcvBuffersInUse;
Forest Bond92b96792009-06-13 07:38:31 -0400481
Malcolm Priestley14c5ef52013-01-17 23:19:37 +0000482 /* 802.11 management */
Malcolm Priestley4f4a89c2012-12-10 21:55:59 +0000483 struct vnt_manager vnt_mgmt;
Forest Bond92b96792009-06-13 07:38:31 -0400484
Malcolm Priestley7c65fa22012-11-28 21:11:02 +0000485 u64 qwCurrTSF;
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000486 u32 cbBulkInMax;
487 int bPSRxBeacon;
Forest Bond92b96792009-06-13 07:38:31 -0400488
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000489 /* 802.11 MAC specific */
490 u32 uCurrRSSI;
491 u8 byCurrSQ;
Forest Bond92b96792009-06-13 07:38:31 -0400492
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000493 /* Antenna Diversity */
494 int bTxRxAntInv;
495 u32 dwRxAntennaSel;
496 u32 dwTxAntennaSel;
497 u8 byAntennaCount;
498 u8 byRxAntennaMode;
499 u8 byTxAntennaMode;
500 u8 byRadioCtl;
501 u8 bHWRadioOff;
Forest Bond92b96792009-06-13 07:38:31 -0400502
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000503 /* SQ3 functions for antenna diversity */
504 struct timer_list TimerSQ3Tmax1;
505 struct timer_list TimerSQ3Tmax2;
506 struct timer_list TimerSQ3Tmax3;
Forest Bond92b96792009-06-13 07:38:31 -0400507
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000508 int bDiversityRegCtlON;
509 int bDiversityEnable;
510 unsigned long ulDiversityNValue;
511 unsigned long ulDiversityMValue;
512 u8 byTMax;
513 u8 byTMax2;
514 u8 byTMax3;
515 unsigned long ulSQ3TH;
Forest Bond92b96792009-06-13 07:38:31 -0400516
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000517 unsigned long uDiversityCnt;
518 u8 byAntennaState;
519 unsigned long ulRatio_State0;
520 unsigned long ulRatio_State1;
521 unsigned long ulSQ3_State0;
522 unsigned long ulSQ3_State1;
Forest Bond92b96792009-06-13 07:38:31 -0400523
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000524 unsigned long aulSQ3Val[MAX_RATE];
525 unsigned long aulPktNum[MAX_RATE];
Forest Bond92b96792009-06-13 07:38:31 -0400526
Andres Morecc856e62010-05-17 21:34:01 -0300527 /* IFS & Cw */
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000528 u32 uSIFS; /* Current SIFS */
529 u32 uDIFS; /* Current DIFS */
530 u32 uEIFS; /* Current EIFS */
531 u32 uSlot; /* Current SlotTime */
532 u32 uCwMin; /* Current CwMin */
533 u32 uCwMax; /* CwMax is fixed on 1023 */
Andres Morecc856e62010-05-17 21:34:01 -0300534
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000535 /* PHY parameter */
536 u8 bySIFS;
537 u8 byDIFS;
538 u8 byEIFS;
539 u8 bySlot;
540 u8 byCWMaxMin;
Forest Bond92b96792009-06-13 07:38:31 -0400541
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000542 /* Rate */
543 VIA_BB_TYPE byBBType; /* 0: 11A, 1:11B, 2:11G */
Malcolm Priestleybf1c8202014-02-15 21:58:55 +0000544 u8 byPacketType; /* 0:11a 1:11b 2:11gb 3:11ga */
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000545 u16 wBasicRate;
546 u8 byACKRate;
547 u8 byTopOFDMBasicRate;
548 u8 byTopCCKBasicRate;
Forest Bond92b96792009-06-13 07:38:31 -0400549
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000550 u32 dwAotoRateTxOkCnt;
551 u32 dwAotoRateTxFailCnt;
552 u32 dwErrorRateThreshold[13];
553 u32 dwTPTable[MAX_RATE];
554 u8 abyEEPROM[EEP_MAX_CONTEXT_SIZE]; /*u32 alignment */
Forest Bond92b96792009-06-13 07:38:31 -0400555
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000556 u8 byMinChannel;
557 u8 byMaxChannel;
558 u32 uConnectionRate;
Forest Bond92b96792009-06-13 07:38:31 -0400559
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000560 u8 byPreambleType;
561 u8 byShortPreamble;
562 /* CARD_PHY_TYPE */
563 u8 eConfigPHYMode;
Forest Bond92b96792009-06-13 07:38:31 -0400564
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000565 /* For RF Power table */
566 u8 byCCKPwr;
567 u8 byOFDMPwrG;
568 u8 byOFDMPwrA;
569 u8 byCurPwr;
570 u8 abyCCKPwrTbl[14];
571 u8 abyOFDMPwrTbl[14];
572 u8 abyOFDMAPwrTbl[42];
Forest Bond92b96792009-06-13 07:38:31 -0400573
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000574 u16 wCurrentRate;
Malcolm Priestleyf84cdf62013-10-15 21:00:09 +0100575 u16 tx_rate_fb0;
576 u16 tx_rate_fb1;
577
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000578 u16 wRTSThreshold;
579 u16 wFragmentationThreshold;
580 u8 byShortRetryLimit;
581 u8 byLongRetryLimit;
Malcolm Priestleya0ad2772014-02-15 21:56:20 +0000582
583 enum nl80211_iftype op_mode;
584
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000585 int bBSSIDFilter;
586 u16 wMaxTransmitMSDULifetime;
587 u8 abyBSSID[ETH_ALEN];
588 u8 abyDesireBSSID[ETH_ALEN];
Forest Bond92b96792009-06-13 07:38:31 -0400589
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000590 u32 dwMaxReceiveLifetime; /* dot11MaxReceiveLifetime */
Forest Bond92b96792009-06-13 07:38:31 -0400591
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000592 int bCCK;
593 int bEncryptionEnable;
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000594 int bShortSlotTime;
595 int bProtectMode;
596 int bNonERPPresent;
597 int bBarkerPreambleMd;
Forest Bond92b96792009-06-13 07:38:31 -0400598
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000599 u8 byERPFlag;
600 u16 wUseProtectCntDown;
Forest Bond92b96792009-06-13 07:38:31 -0400601
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000602 int bRadioControlOff;
603 int bRadioOff;
Forest Bond92b96792009-06-13 07:38:31 -0400604
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000605 /* Power save */
606 int bEnablePSMode;
607 u16 wListenInterval;
608 int bPWBitOn;
609 WMAC_POWER_MODE ePSMode;
610 unsigned long ulPSModeWaitTx;
611 int bPSModeTxBurst;
Forest Bond92b96792009-06-13 07:38:31 -0400612
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000613 /* Beacon releated */
614 u16 wSeqCounter;
615 int bBeaconBufReady;
616 int bBeaconSent;
617 int bFixRate;
618 u8 byCurrentCh;
619 u32 uScanTime;
Forest Bond92b96792009-06-13 07:38:31 -0400620
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000621 CMD_STATE eCommandState;
Forest Bond92b96792009-06-13 07:38:31 -0400622
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000623 CMD_CODE eCommand;
624 int bBeaconTx;
625 u8 byScanBBType;
Forest Bond92b96792009-06-13 07:38:31 -0400626
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000627 int bStopBeacon;
628 int bStopDataPkt;
629 int bStopTx0Pkt;
630 u32 uAutoReConnectTime;
631 u32 uIsroamingTime;
Forest Bond92b96792009-06-13 07:38:31 -0400632
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000633 /* 802.11 counter */
Forest Bond92b96792009-06-13 07:38:31 -0400634
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000635 CMD_ITEM eCmdQueue[CMD_Q_SIZE];
636 u32 uCmdDequeueIdx;
637 u32 uCmdEnqueueIdx;
638 u32 cbFreeCmdQueue;
639 int bCmdRunning;
640 int bCmdClear;
641 int bNeedRadioOFF;
Forest Bond92b96792009-06-13 07:38:31 -0400642
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000643 int bEnableRoaming;
644 int bIsRoaming;
645 int bFastRoaming;
646 u8 bSameBSSMaxNum;
647 u8 bSameBSSCurNum;
648 int bRoaming;
649 int b11hEable;
650 unsigned long ulTxPower;
Forest Bond92b96792009-06-13 07:38:31 -0400651
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000652 /* Encryption */
653 NDIS_802_11_WEP_STATUS eEncryptionStatus;
654 int bTransmitKey;
655 NDIS_802_11_WEP_STATUS eOldEncryptionStatus;
656 SKeyManagement sKey;
657 u32 dwIVCounter;
Forest Bond92b96792009-06-13 07:38:31 -0400658
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000659 RC4Ext SBox;
660 u8 abyPRNG[WLAN_WEPMAX_KEYLEN+3];
661 u8 byKeyIndex;
Forest Bond92b96792009-06-13 07:38:31 -0400662
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000663 u32 uKeyLength;
664 u8 abyKey[WLAN_WEP232_KEYLEN];
Forest Bond92b96792009-06-13 07:38:31 -0400665
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000666 /* for AP mode */
667 u32 uAssocCount;
668 int bMoreData;
Forest Bond92b96792009-06-13 07:38:31 -0400669
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000670 /* QoS */
671 int bGrpAckPolicy;
Forest Bond92b96792009-06-13 07:38:31 -0400672
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000673 u8 byAutoFBCtrl;
Forest Bond92b96792009-06-13 07:38:31 -0400674
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000675 int bTxMICFail;
676 int bRxMICFail;
Forest Bond92b96792009-06-13 07:38:31 -0400677
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000678 /* For Update BaseBand VGA Gain Offset */
679 int bUpdateBBVGA;
680 u32 uBBVGADiffCount;
681 u8 byBBVGANew;
682 u8 byBBVGACurrent;
683 u8 abyBBVGA[BB_VGA_LEVEL];
684 signed long ldBmThreshold[BB_VGA_LEVEL];
Forest Bond92b96792009-06-13 07:38:31 -0400685
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000686 u8 byBBPreEDRSSI;
687 u8 byBBPreEDIndex;
Forest Bond92b96792009-06-13 07:38:31 -0400688
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000689 int bRadioCmd;
Forest Bond92b96792009-06-13 07:38:31 -0400690
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000691 /* For FOE Tuning */
692 u8 byFOETuning;
Forest Bond92b96792009-06-13 07:38:31 -0400693
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000694 /* For Auto Power Tunning */
695 u8 byAutoPwrTunning;
Forest Bond92b96792009-06-13 07:38:31 -0400696
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000697 /* BaseBand Loopback Use */
698 u8 byBBCR4d;
699 u8 byBBCRc9;
700 u8 byBBCR88;
701 u8 byBBCR09;
Forest Bond92b96792009-06-13 07:38:31 -0400702
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000703 /* command timer */
Malcolm Priestley94488a72013-09-27 16:48:14 +0100704 struct delayed_work run_command_work;
Malcolm Priestleybd9a6db2013-09-27 16:51:13 +0100705 /* One second callback */
706 struct delayed_work second_callback_work;
Forest Bond92b96792009-06-13 07:38:31 -0400707
Malcolm Priestley60cc2742013-10-14 19:46:52 +0100708 u8 tx_data_time_out;
709 bool tx_trigger;
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000710 int fWPA_Authened; /*is WPA/WPA-PSK or WPA2/WPA2-PSK authen?? */
711 u8 byReAssocCount;
712 u8 byLinkWaitCount;
Forest Bond92b96792009-06-13 07:38:31 -0400713
Andres Moreceb8c5d2013-03-18 20:33:49 -0500714 struct ethhdr sTxEthHeader;
715 struct ethhdr sRxEthHeader;
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000716 u8 abyBroadcastAddr[ETH_ALEN];
717 u8 abySNAP_RFC1042[ETH_ALEN];
718 u8 abySNAP_Bridgetunnel[ETH_ALEN];
Forest Bond92b96792009-06-13 07:38:31 -0400719
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000720 /* Pre-Authentication & PMK cache */
721 SPMKID gsPMKID;
722 SPMKIDCandidateEvent gsPMKIDCandidate;
Forest Bond92b96792009-06-13 07:38:31 -0400723
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000724 /* for 802.11h */
725 int b11hEnable;
Forest Bond92b96792009-06-13 07:38:31 -0400726
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000727 int bChannelSwitch;
728 u8 byNewChannel;
729 u8 byChannelSwitchCount;
Forest Bond92b96792009-06-13 07:38:31 -0400730
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000731 /* WPA supplicant daemon */
732 int bWPADEVUp;
733 int bwextstep0;
734 int bwextstep1;
735 int bwextstep2;
736 int bwextstep3;
737 int bWPASuppWextEnabled;
Forest Bond92b96792009-06-13 07:38:31 -0400738
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000739 /* user space daemon: hostapd, is used for HOSTAP */
740 int bEnableHostapd;
741 int bEnable8021x;
742 int bEnableHostWEP;
743 struct net_device *apdev;
Forest Bond92b96792009-06-13 07:38:31 -0400744 int (*tx_80211)(struct sk_buff *skb, struct net_device *dev);
Forest Bond92b96792009-06-13 07:38:31 -0400745
Malcolm Priestley61462ab2013-01-17 23:21:50 +0000746 u32 uChannel;
747
748 struct iw_statistics wstats; /* wireless stats */
749
750 int bCommit;
Forest Bond92b96792009-06-13 07:38:31 -0400751
Malcolm Priestley14c5ef52013-01-17 23:19:37 +0000752};
Forest Bond92b96792009-06-13 07:38:31 -0400753
Forest Bond92b96792009-06-13 07:38:31 -0400754#define EnqueueRCB(_Head, _Tail, _RCB) \
755{ \
756 if (!_Head) { \
757 _Head = _RCB; \
758 } \
759 else { \
760 _Tail->Next = _RCB; \
761 } \
762 _RCB->Next = NULL; \
763 _Tail = _RCB; \
764}
765
766#define DequeueRCB(Head, Tail) \
767{ \
Malcolm Priestley115cac22013-08-28 21:12:35 +0100768 struct vnt_rcb *RCB = Head; \
Forest Bond92b96792009-06-13 07:38:31 -0400769 if (!RCB->Next) { \
770 Tail = NULL; \
771 } \
772 Head = RCB->Next; \
773}
774
Forest Bond92b96792009-06-13 07:38:31 -0400775#define ADD_ONE_WITH_WRAP_AROUND(uVar, uModulo) { \
776 if ((uVar) >= ((uModulo) - 1)) \
777 (uVar) = 0; \
778 else \
779 (uVar)++; \
780}
781
Forest Bond92b96792009-06-13 07:38:31 -0400782#define fMP_RESET_IN_PROGRESS 0x00000001
783#define fMP_DISCONNECTED 0x00000002
784#define fMP_HALT_IN_PROGRESS 0x00000004
785#define fMP_SURPRISE_REMOVED 0x00000008
786#define fMP_RECV_LOOKASIDE 0x00000010
787#define fMP_INIT_IN_PROGRESS 0x00000020
788#define fMP_SEND_SIDE_RESOURCE_ALLOCATED 0x00000040
789#define fMP_RECV_SIDE_RESOURCE_ALLOCATED 0x00000080
790#define fMP_POST_READS 0x00000100
791#define fMP_POST_WRITES 0x00000200
792#define fMP_CONTROL_READS 0x00000400
793#define fMP_CONTROL_WRITES 0x00000800
794
Forest Bond92b96792009-06-13 07:38:31 -0400795#define MP_SET_FLAG(_M, _F) ((_M)->Flags |= (_F))
796#define MP_CLEAR_FLAG(_M, _F) ((_M)->Flags &= ~(_F))
Forest Bond92b96792009-06-13 07:38:31 -0400797#define MP_TEST_FLAGS(_M, _F) (((_M)->Flags & (_F)) == (_F))
798
799#define MP_IS_READY(_M) (((_M)->Flags & \
800 (fMP_DISCONNECTED | fMP_RESET_IN_PROGRESS | fMP_HALT_IN_PROGRESS | fMP_INIT_IN_PROGRESS | fMP_SURPRISE_REMOVED)) == 0)
801
Malcolm Priestleydd0a7742012-12-10 21:59:10 +0000802int device_alloc_frag_buf(struct vnt_private *, PSDeFragControlBlock pDeF);
Forest Bond92b96792009-06-13 07:38:31 -0400803
804#endif