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