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