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