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