Commit | Line | Data |
---|---|---|
92b96797 FB |
1 | /* |
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 | ||
92b96797 | 32 | #include <linux/module.h> |
92b96797 | 33 | #include <linux/kernel.h> |
92b96797 | 34 | #include <linux/slab.h> |
11d404cb MP |
35 | #include <linux/delay.h> |
36 | #include <linux/device.h> | |
37 | #include <linux/firmware.h> | |
38 | #include <linux/etherdevice.h> | |
39 | #include <linux/suspend.h> | |
92b96797 | 40 | #include <linux/if_arp.h> |
11d404cb MP |
41 | #include <linux/wireless.h> |
42 | #include <net/iw_handler.h> | |
43 | #include <net/cfg80211.h> | |
44 | #include <linux/timer.h> | |
92b96797 | 45 | #include <linux/usb.h> |
f0fde117 | 46 | #include <linux/crc32.h> |
11d404cb | 47 | |
92b96797 FB |
48 | #ifdef SIOCETHTOOL |
49 | #define DEVICE_ETHTOOL_IOCTL_SUPPORT | |
50 | #include <linux/ethtool.h> | |
51 | #else | |
52 | #undef DEVICE_ETHTOOL_IOCTL_SUPPORT | |
53 | #endif | |
92b96797 | 54 | |
d3e23951 | 55 | /* please copy below macro to driver_event.c for API */ |
92b96797 FB |
56 | #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 | |
92b96797 | 62 | |
d3e23951 AM |
63 | /* |
64 | * device specific | |
65 | */ | |
92b96797 | 66 | |
92b96797 | 67 | #include "device_cfg.h" |
92b96797 | 68 | #include "80211hdr.h" |
92b96797 | 69 | #include "tether.h" |
92b96797 | 70 | #include "wmgr.h" |
92b96797 | 71 | #include "wcmd.h" |
92b96797 | 72 | #include "mib.h" |
92b96797 | 73 | #include "srom.h" |
92b96797 | 74 | #include "rc4.h" |
92b96797 | 75 | #include "desc.h" |
92b96797 | 76 | #include "key.h" |
92b96797 | 77 | #include "card.h" |
748bf69c | 78 | #include "rndis.h" |
92b96797 | 79 | |
5008c456 | 80 | #define VNT_USB_VENDOR_ID 0x160a |
92b96797 FB |
81 | #define VNT_USB_PRODUCT_ID 0x3184 |
82 | ||
83 | #define MAC_MAX_CONTEXT_REG (256+128) | |
84 | ||
85 | #define MAX_MULTICAST_ADDRESS_NUM 32 | |
9a0e756c | 86 | #define MULTICAST_ADDRESS_LIST_SIZE (MAX_MULTICAST_ADDRESS_NUM * ETH_ALEN) |
92b96797 | 87 | |
92b96797 FB |
88 | #define DUPLICATE_RX_CACHE_LENGTH 5 |
89 | ||
90 | #define NUM_KEY_ENTRY 11 | |
91 | ||
92 | #define TX_WEP_NONE 0 | |
93 | #define TX_WEP_OTF 1 | |
94 | #define TX_WEP_SW 2 | |
95 | #define TX_WEP_SWOTP 3 | |
96 | #define TX_WEP_OTPSW 4 | |
97 | #define TX_WEP_SW232 5 | |
98 | ||
99 | #define KEYSEL_WEP40 0 | |
100 | #define KEYSEL_WEP104 1 | |
101 | #define KEYSEL_TKIP 2 | |
102 | #define KEYSEL_CCMP 3 | |
103 | ||
92b96797 FB |
104 | #define AUTO_FB_NONE 0 |
105 | #define AUTO_FB_0 1 | |
106 | #define AUTO_FB_1 2 | |
107 | ||
108 | #define FB_RATE0 0 | |
109 | #define FB_RATE1 1 | |
110 | ||
d3e23951 | 111 | /* Antenna Mode */ |
92b96797 FB |
112 | #define ANT_A 0 |
113 | #define ANT_B 1 | |
114 | #define ANT_DIVERSITY 2 | |
115 | #define ANT_RXD_TXA 3 | |
116 | #define ANT_RXD_TXB 4 | |
117 | #define ANT_UNKNOWN 0xFF | |
118 | #define ANT_TXA 0 | |
119 | #define ANT_TXB 1 | |
120 | #define ANT_RXA 2 | |
121 | #define ANT_RXB 3 | |
122 | ||
92b96797 FB |
123 | #define MAXCHECKHANGCNT 4 |
124 | ||
d3e23951 | 125 | /* Packet type */ |
92b96797 FB |
126 | #define TX_PKT_UNI 0x00 |
127 | #define TX_PKT_MULTI 0x01 | |
128 | #define TX_PKT_BROAD 0x02 | |
129 | ||
130 | #define BB_VGA_LEVEL 4 | |
131 | #define BB_VGA_CHANGE_THRESHOLD 3 | |
132 | ||
92b96797 FB |
133 | #ifndef RUN_AT |
134 | #define RUN_AT(x) (jiffies+(x)) | |
135 | #endif | |
136 | ||
d3e23951 | 137 | /* DMA related */ |
92b96797 FB |
138 | #define RESERV_AC0DMA 4 |
139 | ||
140 | #define PRIVATE_Message 0 | |
141 | ||
d9d1ccb5 AM |
142 | #define DBG_PRT(l, p, args...) { if (l <= msglevel) printk(p, ##args); } |
143 | #define PRINT_K(p, args...) { if (PRIVATE_Message) printk(p, ##args); } | |
92b96797 FB |
144 | |
145 | typedef enum __device_msg_level { | |
d9d1ccb5 AM |
146 | MSG_LEVEL_ERR = 0, /* Errors causing abnormal operation */ |
147 | MSG_LEVEL_NOTICE = 1, /* Errors needing user notification */ | |
148 | MSG_LEVEL_INFO = 2, /* Normal message. */ | |
149 | MSG_LEVEL_VERBOSE = 3, /* Will report all trival errors. */ | |
150 | MSG_LEVEL_DEBUG = 4 /* Only for debug purpose. */ | |
92b96797 FB |
151 | } DEVICE_MSG_LEVEL, *PDEVICE_MSG_LEVEL; |
152 | ||
302433da MP |
153 | #define DEVICE_INIT_COLD 0x0 /* cold init */ |
154 | #define DEVICE_INIT_RESET 0x1 /* reset init or Dx to D0 power remain */ | |
155 | #define DEVICE_INIT_DXPL 0x2 /* Dx to D0 power lost init */ | |
92b96797 | 156 | |
d3e23951 | 157 | /* USB */ |
92b96797 | 158 | |
d3e23951 AM |
159 | /* |
160 | * Enum of context types for SendPacket | |
161 | */ | |
92b96797 FB |
162 | typedef enum _CONTEXT_TYPE { |
163 | CONTEXT_DATA_PACKET = 1, | |
164 | CONTEXT_MGMT_PACKET | |
165 | } CONTEXT_TYPE; | |
166 | ||
d3e23951 | 167 | /* RCB (Receive Control Block) */ |
115cac2e | 168 | struct vnt_rcb { |
dd0a774f MP |
169 | void *Next; |
170 | signed long Ref; | |
171 | void *pDevice; | |
172 | struct urb *pUrb; | |
173 | struct vnt_rx_mgmt sMngPacket; | |
174 | struct sk_buff *skb; | |
175 | int bBoolInUse; | |
115cac2e | 176 | }; |
92b96797 | 177 | |
d3e23951 | 178 | /* used to track bulk out irps */ |
dcdf1d03 MP |
179 | struct vnt_usb_send_context { |
180 | void *pDevice; | |
181 | struct sk_buff *pPacket; | |
182 | struct urb *pUrb; | |
183 | unsigned int uBufLen; | |
184 | CONTEXT_TYPE Type; | |
185 | struct ethhdr sEthHeader; | |
186 | void *Next; | |
187 | bool bBoolInUse; | |
188 | unsigned char Data[MAX_TOTAL_SIZE_WITH_ALL_HEADERS]; | |
189 | }; | |
92b96797 | 190 | |
51934e7f MP |
191 | /* tx packet info for rxtx */ |
192 | struct vnt_tx_pkt_info { | |
193 | u16 fifo_ctl; | |
194 | u8 dest_addr[ETH_ALEN]; | |
195 | }; | |
196 | ||
213d2e93 AM |
197 | /* structure got from configuration file as user-desired default settings */ |
198 | typedef struct _DEFAULT_CONFIG { | |
199 | signed int ZoneType; | |
200 | signed int eConfigMode; | |
201 | signed int eAuthenMode; /* open/wep/wpa */ | |
202 | signed int bShareKeyAlgorithm; /* open-open/{open,wep}-sharekey */ | |
203 | signed int keyidx; /* wepkey index */ | |
204 | signed int eEncryptionStatus; | |
205 | } DEFAULT_CONFIG, *PDEFAULT_CONFIG; | |
92b96797 | 206 | |
d3e23951 AM |
207 | /* |
208 | * Structure to keep track of USB interrupt packets | |
209 | */ | |
92b96797 | 210 | typedef struct { |
cc856e61 | 211 | unsigned int uDataLen; |
b902fbfe | 212 | u8 * pDataBuf; |
d3e23951 | 213 | /* struct urb *pUrb; */ |
dfdcc425 | 214 | bool bInUse; |
92b96797 FB |
215 | } INT_BUFFER, *PINT_BUFFER; |
216 | ||
d3e23951 | 217 | /* 0:11A 1:11B 2:11G */ |
92b96797 FB |
218 | typedef enum _VIA_BB_TYPE |
219 | { | |
d9d1ccb5 | 220 | BB_TYPE_11A = 0, |
92b96797 FB |
221 | BB_TYPE_11B, |
222 | BB_TYPE_11G | |
223 | } VIA_BB_TYPE, *PVIA_BB_TYPE; | |
224 | ||
d3e23951 | 225 | /* 0:11a, 1:11b, 2:11gb (only CCK in BasicRate), 3:11ga(OFDM in BasicRate) */ |
92b96797 FB |
226 | typedef enum _VIA_PKT_TYPE |
227 | { | |
d9d1ccb5 | 228 | PK_TYPE_11A = 0, |
92b96797 FB |
229 | PK_TYPE_11B, |
230 | PK_TYPE_11GB, | |
231 | PK_TYPE_11GA | |
232 | } VIA_PKT_TYPE, *PVIA_PKT_TYPE; | |
233 | ||
d3e23951 | 234 | /*++ NDIS related */ |
92b96797 | 235 | |
92b96797 | 236 | typedef enum __DEVICE_NDIS_STATUS { |
d9d1ccb5 | 237 | STATUS_SUCCESS = 0, |
92b96797 FB |
238 | STATUS_FAILURE, |
239 | STATUS_RESOURCES, | |
240 | STATUS_PENDING, | |
241 | } DEVICE_NDIS_STATUS, *PDEVICE_NDIS_STATUS; | |
242 | ||
92b96797 FB |
243 | #define MAX_BSSIDINFO_4_PMKID 16 |
244 | #define MAX_PMKIDLIST 5 | |
d3e23951 | 245 | /* flags for PMKID Candidate list structure */ |
92b96797 FB |
246 | #define NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED 0x01 |
247 | ||
d3e23951 | 248 | /* PMKID Structures */ |
cc856e61 | 249 | typedef unsigned char NDIS_802_11_PMKID_VALUE[16]; |
92b96797 | 250 | |
92b96797 FB |
251 | typedef enum _NDIS_802_11_WEP_STATUS |
252 | { | |
253 | Ndis802_11WEPEnabled, | |
254 | Ndis802_11Encryption1Enabled = Ndis802_11WEPEnabled, | |
255 | Ndis802_11WEPDisabled, | |
256 | Ndis802_11EncryptionDisabled = Ndis802_11WEPDisabled, | |
257 | Ndis802_11WEPKeyAbsent, | |
258 | Ndis802_11Encryption1KeyAbsent = Ndis802_11WEPKeyAbsent, | |
259 | Ndis802_11WEPNotSupported, | |
260 | Ndis802_11EncryptionNotSupported = Ndis802_11WEPNotSupported, | |
261 | Ndis802_11Encryption2Enabled, | |
262 | Ndis802_11Encryption2KeyAbsent, | |
263 | Ndis802_11Encryption3Enabled, | |
264 | Ndis802_11Encryption3KeyAbsent | |
265 | } NDIS_802_11_WEP_STATUS, *PNDIS_802_11_WEP_STATUS, | |
266 | NDIS_802_11_ENCRYPTION_STATUS, *PNDIS_802_11_ENCRYPTION_STATUS; | |
267 | ||
92b96797 FB |
268 | typedef enum _NDIS_802_11_STATUS_TYPE |
269 | { | |
d3e23951 AM |
270 | Ndis802_11StatusType_Authentication, |
271 | Ndis802_11StatusType_MediaStreamMode, | |
272 | Ndis802_11StatusType_PMKID_CandidateList, | |
273 | Ndis802_11StatusTypeMax, /* not a real type, defined as upper bound */ | |
92b96797 FB |
274 | } NDIS_802_11_STATUS_TYPE, *PNDIS_802_11_STATUS_TYPE; |
275 | ||
d3e23951 | 276 | /* added new types for PMKID Candidate lists */ |
92b96797 FB |
277 | typedef struct _PMKID_CANDIDATE { |
278 | NDIS_802_11_MAC_ADDRESS BSSID; | |
cc856e61 | 279 | unsigned long Flags; |
92b96797 FB |
280 | } PMKID_CANDIDATE, *PPMKID_CANDIDATE; |
281 | ||
92b96797 FB |
282 | typedef struct _BSSID_INFO |
283 | { | |
284 | NDIS_802_11_MAC_ADDRESS BSSID; | |
285 | NDIS_802_11_PMKID_VALUE PMKID; | |
286 | } BSSID_INFO, *PBSSID_INFO; | |
287 | ||
288 | typedef struct tagSPMKID { | |
cc856e61 AM |
289 | unsigned long Length; |
290 | unsigned long BSSIDInfoCount; | |
92b96797 FB |
291 | BSSID_INFO BSSIDInfo[MAX_BSSIDINFO_4_PMKID]; |
292 | } SPMKID, *PSPMKID; | |
293 | ||
294 | typedef struct tagSPMKIDCandidateEvent { | |
295 | NDIS_802_11_STATUS_TYPE StatusType; | |
cc856e61 AM |
296 | unsigned long Version; /* Version of the structure */ |
297 | unsigned long NumCandidates; /* No. of pmkid candidates */ | |
92b96797 | 298 | PMKID_CANDIDATE CandidateList[MAX_PMKIDLIST]; |
193a823c | 299 | } SPMKIDCandidateEvent, *PSPMKIDCandidateEvent; |
92b96797 | 300 | |
d3e23951 | 301 | /*++ 802.11h related */ |
92b96797 FB |
302 | #define MAX_QUIET_COUNT 8 |
303 | ||
304 | typedef struct tagSQuietControl { | |
dfdcc425 | 305 | bool bEnable; |
52a7e64b | 306 | u32 dwStartTime; |
b902fbfe | 307 | u8 byPeriod; |
3eaca0d2 | 308 | u16 wDuration; |
193a823c | 309 | } SQuietControl, *PSQuietControl; |
92b96797 | 310 | |
d3e23951 | 311 | /* The receive duplicate detection cache entry */ |
92b96797 | 312 | typedef struct tagSCacheEntry{ |
3eaca0d2 | 313 | u16 wFmSequence; |
b902fbfe | 314 | u8 abyAddr2[ETH_ALEN]; |
3eaca0d2 | 315 | u16 wFrameCtl; |
92b96797 FB |
316 | } SCacheEntry, *PSCacheEntry; |
317 | ||
318 | typedef struct tagSCache{ | |
319 | /* The receive cache is updated circularly. The next entry to be written is | |
320 | * indexed by the "InPtr". | |
d3e23951 | 321 | */ |
cc856e61 | 322 | unsigned int uInPtr; /* Place to use next */ |
92b96797 FB |
323 | SCacheEntry asCacheEntry[DUPLICATE_RX_CACHE_LENGTH]; |
324 | } SCache, *PSCache; | |
325 | ||
326 | #define CB_MAX_RX_FRAG 64 | |
d3e23951 AM |
327 | /* |
328 | * DeFragment Control Block, used for collecting fragments prior to reassembly | |
329 | */ | |
92b96797 FB |
330 | typedef struct tagSDeFragControlBlock |
331 | { | |
3eaca0d2 AM |
332 | u16 wSequence; |
333 | u16 wFragNum; | |
b902fbfe | 334 | u8 abyAddr2[ETH_ALEN]; |
cc856e61 | 335 | unsigned int uLifetime; |
92b96797 | 336 | struct sk_buff* skb; |
b902fbfe | 337 | u8 * pbyRxBuffer; |
cc856e61 | 338 | unsigned int cbFrameLength; |
dfdcc425 | 339 | bool bInUse; |
193a823c | 340 | } SDeFragControlBlock, *PSDeFragControlBlock; |
92b96797 | 341 | |
d3e23951 | 342 | /* flags for options */ |
92b96797 FB |
343 | #define DEVICE_FLAGS_UNPLUG 0x00000001UL |
344 | #define DEVICE_FLAGS_PREAMBLE_TYPE 0x00000002UL | |
345 | #define DEVICE_FLAGS_OP_MODE 0x00000004UL | |
346 | #define DEVICE_FLAGS_PS_MODE 0x00000008UL | |
347 | #define DEVICE_FLAGS_80211h_MODE 0x00000010UL | |
348 | ||
d3e23951 | 349 | /* flags for driver status */ |
92b96797 FB |
350 | #define DEVICE_FLAGS_OPENED 0x00010000UL |
351 | #define DEVICE_FLAGS_WOL_ENABLED 0x00080000UL | |
d3e23951 | 352 | /* flags for capabilities */ |
92b96797 FB |
353 | #define DEVICE_FLAGS_TX_ALIGN 0x01000000UL |
354 | #define DEVICE_FLAGS_HAVE_CAM 0x02000000UL | |
355 | #define DEVICE_FLAGS_FLOW_CTRL 0x04000000UL | |
356 | ||
d3e23951 | 357 | /* flags for MII status */ |
92b96797 FB |
358 | #define DEVICE_LINK_FAIL 0x00000001UL |
359 | #define DEVICE_SPEED_10 0x00000002UL | |
360 | #define DEVICE_SPEED_100 0x00000004UL | |
361 | #define DEVICE_SPEED_1000 0x00000008UL | |
362 | #define DEVICE_DUPLEX_FULL 0x00000010UL | |
363 | #define DEVICE_AUTONEG_ENABLE 0x00000020UL | |
364 | #define DEVICE_FORCED_BY_EEPROM 0x00000040UL | |
d3e23951 | 365 | /* for device_set_media_duplex */ |
92b96797 FB |
366 | #define DEVICE_LINK_CHANGE 0x00000001UL |
367 | ||
92b96797 | 368 | typedef struct __device_opt { |
d3e23951 AM |
369 | int nRxDescs0; /* number of RX descriptors 0 */ |
370 | int nTxDescs0; /* number of TX descriptors 0, 1, 2, 3 */ | |
371 | int rts_thresh; /* RTS threshold */ | |
92b96797 FB |
372 | int frag_thresh; |
373 | int OpMode; | |
374 | int data_rate; | |
375 | int channel_num; | |
376 | int short_retry; | |
377 | int long_retry; | |
378 | int bbp_type; | |
659770d4 | 379 | u32 flags; |
92b96797 FB |
380 | } OPTIONS, *POPTIONS; |
381 | ||
14c5ef57 | 382 | struct vnt_private { |
61462ab3 MP |
383 | /* netdev */ |
384 | struct usb_device *usb; | |
385 | struct net_device *dev; | |
386 | struct net_device_stats stats; | |
92b96797 | 387 | |
61462ab3 | 388 | OPTIONS sOpts; |
92b96797 | 389 | |
61462ab3 MP |
390 | struct tasklet_struct CmdWorkItem; |
391 | struct tasklet_struct EventWorkItem; | |
81d720d3 | 392 | struct work_struct read_work_item; |
a21fc2f5 | 393 | struct work_struct rx_mng_work_item; |
31d5bbf3 | 394 | |
61462ab3 MP |
395 | u32 rx_buf_sz; |
396 | int multicast_limit; | |
397 | u8 byRxMode; | |
92b96797 | 398 | |
61462ab3 | 399 | spinlock_t lock; |
92b96797 | 400 | |
61462ab3 | 401 | u32 rx_bytes; |
92b96797 | 402 | |
61462ab3 | 403 | u8 byRevId; |
92b96797 | 404 | |
61462ab3 MP |
405 | u32 flags; |
406 | unsigned long Flags; | |
92b96797 | 407 | |
61462ab3 | 408 | SCache sDupRxCache; |
92b96797 | 409 | |
61462ab3 MP |
410 | SDeFragControlBlock sRxDFCB[CB_MAX_RX_FRAG]; |
411 | u32 cbDFCB; | |
412 | u32 cbFreeDFCB; | |
413 | u32 uCurrentDFCBIdx; | |
92b96797 | 414 | |
61462ab3 MP |
415 | /* USB */ |
416 | struct urb *pControlURB; | |
417 | struct urb *pInterruptURB; | |
418 | struct usb_ctrlrequest sUsbCtlRequest; | |
419 | u32 int_interval; | |
92b96797 | 420 | |
61462ab3 | 421 | /* Variables to track resources for the BULK In Pipe */ |
115cac2e MP |
422 | struct vnt_rcb *pRCBMem; |
423 | struct vnt_rcb *apRCB[CB_MAX_RX_DESC]; | |
61462ab3 | 424 | u32 cbRD; |
115cac2e MP |
425 | struct vnt_rcb *FirstRecvFreeList; |
426 | struct vnt_rcb *LastRecvFreeList; | |
61462ab3 | 427 | u32 NumRecvFreeList; |
115cac2e MP |
428 | struct vnt_rcb *FirstRecvMngList; |
429 | struct vnt_rcb *LastRecvMngList; | |
61462ab3 MP |
430 | u32 NumRecvMngList; |
431 | int bIsRxWorkItemQueued; | |
432 | int bIsRxMngWorkItemQueued; | |
cc856e61 | 433 | unsigned long ulRcvRefCount; /* packets that have not returned back */ |
92b96797 | 434 | |
61462ab3 | 435 | /* Variables to track resources for the BULK Out Pipe */ |
dcdf1d03 | 436 | struct vnt_usb_send_context *apTD[CB_MAX_TX_DESC]; |
61462ab3 | 437 | u32 cbTD; |
51934e7f | 438 | struct vnt_tx_pkt_info pkt_info[16]; |
92b96797 | 439 | |
61462ab3 MP |
440 | /* Variables to track resources for the Interrupt In Pipe */ |
441 | INT_BUFFER intBuf; | |
442 | int fKillEventPollingThread; | |
443 | int bEventAvailable; | |
92b96797 | 444 | |
61462ab3 MP |
445 | /* default config from file by user setting */ |
446 | DEFAULT_CONFIG config_file; | |
92b96797 | 447 | |
61462ab3 MP |
448 | /* Statistic for USB */ |
449 | unsigned long ulBulkInPosted; | |
450 | unsigned long ulBulkInError; | |
451 | unsigned long ulBulkInContCRCError; | |
452 | unsigned long ulBulkInBytesRead; | |
92b96797 | 453 | |
61462ab3 MP |
454 | unsigned long ulBulkOutPosted; |
455 | unsigned long ulBulkOutError; | |
456 | unsigned long ulBulkOutContCRCError; | |
457 | unsigned long ulBulkOutBytesWrite; | |
92b96797 | 458 | |
61462ab3 MP |
459 | unsigned long ulIntInPosted; |
460 | unsigned long ulIntInError; | |
461 | unsigned long ulIntInContCRCError; | |
462 | unsigned long ulIntInBytesRead; | |
92b96797 | 463 | |
61462ab3 MP |
464 | /* Version control */ |
465 | u16 wFirmwareVersion; | |
466 | u8 byLocalID; | |
467 | u8 byRFType; | |
468 | u8 byBBRxConf; | |
92b96797 | 469 | |
61462ab3 MP |
470 | u8 byZoneType; |
471 | int bZoneRegExist; | |
92b96797 | 472 | |
61462ab3 | 473 | u8 byOriginalZonetype; |
92b96797 | 474 | |
61462ab3 | 475 | int bLinkPass; /* link status: OK or fail */ |
748bf69c MP |
476 | struct vnt_cmd_card_init init_command; |
477 | struct vnt_rsp_card_init init_response; | |
61462ab3 MP |
478 | u8 abyCurrentNetAddr[ETH_ALEN]; |
479 | u8 abyPermanentNetAddr[ETH_ALEN]; | |
92b96797 | 480 | |
61462ab3 | 481 | int bExistSWNetAddr; |
92b96797 | 482 | |
61462ab3 MP |
483 | /* Adapter statistics */ |
484 | SStatCounter scStatistic; | |
485 | /* 802.11 counter */ | |
486 | SDot11Counters s802_11Counter; | |
92b96797 | 487 | |
61462ab3 MP |
488 | /* Maintain statistical debug info. */ |
489 | unsigned long packetsReceived; | |
490 | unsigned long packetsReceivedDropped; | |
491 | unsigned long packetsReceivedOverflow; | |
492 | unsigned long packetsSent; | |
493 | unsigned long packetsSentDropped; | |
494 | unsigned long SendContextsInUse; | |
495 | unsigned long RcvBuffersInUse; | |
92b96797 | 496 | |
14c5ef57 | 497 | /* 802.11 management */ |
4f4a89c9 | 498 | struct vnt_manager vnt_mgmt; |
92b96797 | 499 | |
7c65fa2a | 500 | u64 qwCurrTSF; |
61462ab3 MP |
501 | u32 cbBulkInMax; |
502 | int bPSRxBeacon; | |
503 | ||
504 | /* 802.11 MAC specific */ | |
505 | u32 uCurrRSSI; | |
506 | u8 byCurrSQ; | |
507 | ||
508 | /* Antenna Diversity */ | |
509 | int bTxRxAntInv; | |
510 | u32 dwRxAntennaSel; | |
511 | u32 dwTxAntennaSel; | |
512 | u8 byAntennaCount; | |
513 | u8 byRxAntennaMode; | |
514 | u8 byTxAntennaMode; | |
515 | u8 byRadioCtl; | |
516 | u8 bHWRadioOff; | |
517 | ||
518 | /* SQ3 functions for antenna diversity */ | |
519 | struct timer_list TimerSQ3Tmax1; | |
520 | struct timer_list TimerSQ3Tmax2; | |
521 | struct timer_list TimerSQ3Tmax3; | |
522 | ||
523 | int bDiversityRegCtlON; | |
524 | int bDiversityEnable; | |
525 | unsigned long ulDiversityNValue; | |
526 | unsigned long ulDiversityMValue; | |
527 | u8 byTMax; | |
528 | u8 byTMax2; | |
529 | u8 byTMax3; | |
530 | unsigned long ulSQ3TH; | |
531 | ||
532 | unsigned long uDiversityCnt; | |
533 | u8 byAntennaState; | |
534 | unsigned long ulRatio_State0; | |
535 | unsigned long ulRatio_State1; | |
536 | unsigned long ulSQ3_State0; | |
537 | unsigned long ulSQ3_State1; | |
538 | ||
539 | unsigned long aulSQ3Val[MAX_RATE]; | |
540 | unsigned long aulPktNum[MAX_RATE]; | |
cc856e61 AM |
541 | |
542 | /* IFS & Cw */ | |
61462ab3 MP |
543 | u32 uSIFS; /* Current SIFS */ |
544 | u32 uDIFS; /* Current DIFS */ | |
545 | u32 uEIFS; /* Current EIFS */ | |
546 | u32 uSlot; /* Current SlotTime */ | |
547 | u32 uCwMin; /* Current CwMin */ | |
548 | u32 uCwMax; /* CwMax is fixed on 1023 */ | |
549 | ||
550 | /* PHY parameter */ | |
551 | u8 bySIFS; | |
552 | u8 byDIFS; | |
553 | u8 byEIFS; | |
554 | u8 bySlot; | |
555 | u8 byCWMaxMin; | |
556 | ||
557 | /* Rate */ | |
558 | VIA_BB_TYPE byBBType; /* 0: 11A, 1:11B, 2:11G */ | |
559 | VIA_PKT_TYPE byPacketType; /* 0:11a 1:11b 2:11gb 3:11ga */ | |
560 | u16 wBasicRate; | |
561 | u8 byACKRate; | |
562 | u8 byTopOFDMBasicRate; | |
563 | u8 byTopCCKBasicRate; | |
564 | ||
61462ab3 MP |
565 | u32 dwAotoRateTxOkCnt; |
566 | u32 dwAotoRateTxFailCnt; | |
567 | u32 dwErrorRateThreshold[13]; | |
568 | u32 dwTPTable[MAX_RATE]; | |
569 | u8 abyEEPROM[EEP_MAX_CONTEXT_SIZE]; /*u32 alignment */ | |
570 | ||
571 | u8 byMinChannel; | |
572 | u8 byMaxChannel; | |
573 | u32 uConnectionRate; | |
574 | ||
575 | u8 byPreambleType; | |
576 | u8 byShortPreamble; | |
577 | /* CARD_PHY_TYPE */ | |
578 | u8 eConfigPHYMode; | |
579 | ||
580 | /* For RF Power table */ | |
581 | u8 byCCKPwr; | |
582 | u8 byOFDMPwrG; | |
583 | u8 byOFDMPwrA; | |
584 | u8 byCurPwr; | |
585 | u8 abyCCKPwrTbl[14]; | |
586 | u8 abyOFDMPwrTbl[14]; | |
587 | u8 abyOFDMAPwrTbl[42]; | |
588 | ||
589 | u16 wCurrentRate; | |
f84cdf65 MP |
590 | u16 tx_rate_fb0; |
591 | u16 tx_rate_fb1; | |
592 | ||
61462ab3 MP |
593 | u16 wRTSThreshold; |
594 | u16 wFragmentationThreshold; | |
595 | u8 byShortRetryLimit; | |
596 | u8 byLongRetryLimit; | |
597 | CARD_OP_MODE eOPMode; | |
598 | int bBSSIDFilter; | |
599 | u16 wMaxTransmitMSDULifetime; | |
600 | u8 abyBSSID[ETH_ALEN]; | |
601 | u8 abyDesireBSSID[ETH_ALEN]; | |
602 | ||
61462ab3 MP |
603 | u32 dwMaxReceiveLifetime; /* dot11MaxReceiveLifetime */ |
604 | ||
605 | int bCCK; | |
606 | int bEncryptionEnable; | |
61462ab3 MP |
607 | int bShortSlotTime; |
608 | int bProtectMode; | |
609 | int bNonERPPresent; | |
610 | int bBarkerPreambleMd; | |
611 | ||
612 | u8 byERPFlag; | |
613 | u16 wUseProtectCntDown; | |
614 | ||
615 | int bRadioControlOff; | |
616 | int bRadioOff; | |
617 | ||
618 | /* Power save */ | |
619 | int bEnablePSMode; | |
620 | u16 wListenInterval; | |
621 | int bPWBitOn; | |
622 | WMAC_POWER_MODE ePSMode; | |
623 | unsigned long ulPSModeWaitTx; | |
624 | int bPSModeTxBurst; | |
625 | ||
626 | /* Beacon releated */ | |
627 | u16 wSeqCounter; | |
628 | int bBeaconBufReady; | |
629 | int bBeaconSent; | |
630 | int bFixRate; | |
631 | u8 byCurrentCh; | |
632 | u32 uScanTime; | |
633 | ||
634 | CMD_STATE eCommandState; | |
635 | ||
636 | CMD_CODE eCommand; | |
637 | int bBeaconTx; | |
638 | u8 byScanBBType; | |
639 | ||
640 | int bStopBeacon; | |
641 | int bStopDataPkt; | |
642 | int bStopTx0Pkt; | |
643 | u32 uAutoReConnectTime; | |
644 | u32 uIsroamingTime; | |
645 | ||
646 | /* 802.11 counter */ | |
647 | ||
648 | CMD_ITEM eCmdQueue[CMD_Q_SIZE]; | |
649 | u32 uCmdDequeueIdx; | |
650 | u32 uCmdEnqueueIdx; | |
651 | u32 cbFreeCmdQueue; | |
652 | int bCmdRunning; | |
653 | int bCmdClear; | |
654 | int bNeedRadioOFF; | |
655 | ||
656 | int bEnableRoaming; | |
657 | int bIsRoaming; | |
658 | int bFastRoaming; | |
659 | u8 bSameBSSMaxNum; | |
660 | u8 bSameBSSCurNum; | |
661 | int bRoaming; | |
662 | int b11hEable; | |
663 | unsigned long ulTxPower; | |
664 | ||
665 | /* Encryption */ | |
666 | NDIS_802_11_WEP_STATUS eEncryptionStatus; | |
667 | int bTransmitKey; | |
668 | NDIS_802_11_WEP_STATUS eOldEncryptionStatus; | |
669 | SKeyManagement sKey; | |
670 | u32 dwIVCounter; | |
671 | ||
61462ab3 MP |
672 | RC4Ext SBox; |
673 | u8 abyPRNG[WLAN_WEPMAX_KEYLEN+3]; | |
674 | u8 byKeyIndex; | |
675 | ||
61462ab3 MP |
676 | u32 uKeyLength; |
677 | u8 abyKey[WLAN_WEP232_KEYLEN]; | |
678 | ||
679 | /* for AP mode */ | |
680 | u32 uAssocCount; | |
681 | int bMoreData; | |
682 | ||
683 | /* QoS */ | |
684 | int bGrpAckPolicy; | |
685 | ||
61462ab3 MP |
686 | u8 byAutoFBCtrl; |
687 | ||
688 | int bTxMICFail; | |
689 | int bRxMICFail; | |
690 | ||
61462ab3 MP |
691 | /* For Update BaseBand VGA Gain Offset */ |
692 | int bUpdateBBVGA; | |
693 | u32 uBBVGADiffCount; | |
694 | u8 byBBVGANew; | |
695 | u8 byBBVGACurrent; | |
696 | u8 abyBBVGA[BB_VGA_LEVEL]; | |
697 | signed long ldBmThreshold[BB_VGA_LEVEL]; | |
698 | ||
699 | u8 byBBPreEDRSSI; | |
700 | u8 byBBPreEDIndex; | |
701 | ||
61462ab3 | 702 | int bRadioCmd; |
61462ab3 MP |
703 | |
704 | /* For FOE Tuning */ | |
705 | u8 byFOETuning; | |
706 | ||
707 | /* For Auto Power Tunning */ | |
708 | u8 byAutoPwrTunning; | |
709 | ||
710 | /* BaseBand Loopback Use */ | |
711 | u8 byBBCR4d; | |
712 | u8 byBBCRc9; | |
713 | u8 byBBCR88; | |
714 | u8 byBBCR09; | |
715 | ||
716 | /* command timer */ | |
94488a7e | 717 | struct delayed_work run_command_work; |
bd9a6dba MP |
718 | /* One second callback */ |
719 | struct delayed_work second_callback_work; | |
92b96797 | 720 | |
60cc2747 MP |
721 | u8 tx_data_time_out; |
722 | bool tx_trigger; | |
61462ab3 MP |
723 | int fWPA_Authened; /*is WPA/WPA-PSK or WPA2/WPA2-PSK authen?? */ |
724 | u8 byReAssocCount; | |
725 | u8 byLinkWaitCount; | |
92b96797 | 726 | |
ceb8c5da AM |
727 | struct ethhdr sTxEthHeader; |
728 | struct ethhdr sRxEthHeader; | |
61462ab3 MP |
729 | u8 abyBroadcastAddr[ETH_ALEN]; |
730 | u8 abySNAP_RFC1042[ETH_ALEN]; | |
731 | u8 abySNAP_Bridgetunnel[ETH_ALEN]; | |
92b96797 | 732 | |
61462ab3 MP |
733 | /* Pre-Authentication & PMK cache */ |
734 | SPMKID gsPMKID; | |
735 | SPMKIDCandidateEvent gsPMKIDCandidate; | |
92b96797 | 736 | |
61462ab3 MP |
737 | /* for 802.11h */ |
738 | int b11hEnable; | |
92b96797 | 739 | |
61462ab3 MP |
740 | int bChannelSwitch; |
741 | u8 byNewChannel; | |
742 | u8 byChannelSwitchCount; | |
92b96797 | 743 | |
61462ab3 MP |
744 | /* WPA supplicant daemon */ |
745 | int bWPADEVUp; | |
746 | int bwextstep0; | |
747 | int bwextstep1; | |
748 | int bwextstep2; | |
749 | int bwextstep3; | |
750 | int bWPASuppWextEnabled; | |
92b96797 | 751 | |
61462ab3 MP |
752 | /* user space daemon: hostapd, is used for HOSTAP */ |
753 | int bEnableHostapd; | |
754 | int bEnable8021x; | |
755 | int bEnableHostWEP; | |
756 | struct net_device *apdev; | |
757 | int (*tx_80211)(struct sk_buff *skb, struct net_device *dev); | |
92b96797 | 758 | |
61462ab3 | 759 | u32 uChannel; |
92b96797 | 760 | |
61462ab3 | 761 | struct iw_statistics wstats; /* wireless stats */ |
92b96797 | 762 | |
61462ab3 | 763 | int bCommit; |
92b96797 | 764 | |
14c5ef57 | 765 | }; |
92b96797 | 766 | |
92b96797 FB |
767 | #define EnqueueRCB(_Head, _Tail, _RCB) \ |
768 | { \ | |
769 | if (!_Head) { \ | |
770 | _Head = _RCB; \ | |
771 | } \ | |
772 | else { \ | |
773 | _Tail->Next = _RCB; \ | |
774 | } \ | |
775 | _RCB->Next = NULL; \ | |
776 | _Tail = _RCB; \ | |
777 | } | |
778 | ||
779 | #define DequeueRCB(Head, Tail) \ | |
780 | { \ | |
115cac2e | 781 | struct vnt_rcb *RCB = Head; \ |
92b96797 FB |
782 | if (!RCB->Next) { \ |
783 | Tail = NULL; \ | |
784 | } \ | |
785 | Head = RCB->Next; \ | |
786 | } | |
787 | ||
92b96797 FB |
788 | #define ADD_ONE_WITH_WRAP_AROUND(uVar, uModulo) { \ |
789 | if ((uVar) >= ((uModulo) - 1)) \ | |
790 | (uVar) = 0; \ | |
791 | else \ | |
792 | (uVar)++; \ | |
793 | } | |
794 | ||
92b96797 FB |
795 | #define fMP_RESET_IN_PROGRESS 0x00000001 |
796 | #define fMP_DISCONNECTED 0x00000002 | |
797 | #define fMP_HALT_IN_PROGRESS 0x00000004 | |
798 | #define fMP_SURPRISE_REMOVED 0x00000008 | |
799 | #define fMP_RECV_LOOKASIDE 0x00000010 | |
800 | #define fMP_INIT_IN_PROGRESS 0x00000020 | |
801 | #define fMP_SEND_SIDE_RESOURCE_ALLOCATED 0x00000040 | |
802 | #define fMP_RECV_SIDE_RESOURCE_ALLOCATED 0x00000080 | |
803 | #define fMP_POST_READS 0x00000100 | |
804 | #define fMP_POST_WRITES 0x00000200 | |
805 | #define fMP_CONTROL_READS 0x00000400 | |
806 | #define fMP_CONTROL_WRITES 0x00000800 | |
807 | ||
92b96797 FB |
808 | #define MP_SET_FLAG(_M, _F) ((_M)->Flags |= (_F)) |
809 | #define MP_CLEAR_FLAG(_M, _F) ((_M)->Flags &= ~(_F)) | |
92b96797 FB |
810 | #define MP_TEST_FLAGS(_M, _F) (((_M)->Flags & (_F)) == (_F)) |
811 | ||
812 | #define MP_IS_READY(_M) (((_M)->Flags & \ | |
813 | (fMP_DISCONNECTED | fMP_RESET_IN_PROGRESS | fMP_HALT_IN_PROGRESS | fMP_INIT_IN_PROGRESS | fMP_SURPRISE_REMOVED)) == 0) | |
814 | ||
dd0a774f | 815 | int device_alloc_frag_buf(struct vnt_private *, PSDeFragControlBlock pDeF); |
92b96797 FB |
816 | |
817 | #endif |