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