• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include <linux/module.h>
33 #include <linux/types.h>
34 #include <linux/mm.h>
35 #include <linux/errno.h>
36 #include <linux/ioport.h>
37 #include <linux/pci.h>
38 #include <linux/kernel.h>
39 #include <linux/netdevice.h>
40 #include <linux/etherdevice.h>
41 #include <linux/skbuff.h>
42 #include <linux/delay.h>
43 #include <linux/timer.h>
44 #include <linux/slab.h>
45 #include <linux/interrupt.h>
46 #include <linux/string.h>
47 #include <linux/wait.h>
48 #include <linux/if_arp.h>
49 #include <linux/sched.h>
50 #include <linux/io.h>
51 #include <linux/if.h>
52 #include <linux/crc32.h>
53 //#include <linux/config.h>
54 #include <linux/uaccess.h>
55 #include <linux/proc_fs.h>
56 #include <linux/inetdevice.h>
57 #include <linux/reboot.h>
58 #include <linux/ethtool.h>
59 /* Include Wireless Extension definition and check version - Jean II */
60 #include <linux/wireless.h>
61 #include <net/iw_handler.h>	// New driver API
62 
63 //2008-0409-07, <Add> by Einsn Liu
64 #ifndef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
65 #define WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
66 #endif
67 
68 //
69 // device specific
70 //
71 
72 #include "device_cfg.h"
73 #include "ttype.h"
74 #include "80211hdr.h"
75 #include "tether.h"
76 #include "wmgr.h"
77 #include "wcmd.h"
78 #include "mib.h"
79 #include "srom.h"
80 #include "rc4.h"
81 #include "desc.h"
82 #include "key.h"
83 #include "mac.h"
84 
85 /*---------------------  Export Definitions -------------------------*/
86 
87 #define MAC_MAX_CONTEXT_REG     (256+128)
88 
89 #define MAX_MULTICAST_ADDRESS_NUM       32
90 #define MULTICAST_ADDRESS_LIST_SIZE     (MAX_MULTICAST_ADDRESS_NUM * ETH_ALEN)
91 
92 #define DUPLICATE_RX_CACHE_LENGTH       5
93 
94 #define NUM_KEY_ENTRY                   11
95 
96 #define TX_WEP_NONE                     0
97 #define TX_WEP_OTF                      1
98 #define TX_WEP_SW                       2
99 #define TX_WEP_SWOTP                    3
100 #define TX_WEP_OTPSW                    4
101 #define TX_WEP_SW232                    5
102 
103 #define KEYSEL_WEP40                    0
104 #define KEYSEL_WEP104                   1
105 #define KEYSEL_TKIP                     2
106 #define KEYSEL_CCMP                     3
107 
108 #define AUTO_FB_NONE            0
109 #define AUTO_FB_0               1
110 #define AUTO_FB_1               2
111 
112 #define FB_RATE0                0
113 #define FB_RATE1                1
114 
115 // Antenna Mode
116 #define ANT_A                   0
117 #define ANT_B                   1
118 #define ANT_DIVERSITY           2
119 #define ANT_RXD_TXA             3
120 #define ANT_RXD_TXB             4
121 #define ANT_UNKNOWN             0xFF
122 
123 #define MAXCHECKHANGCNT         4
124 
125 #define BB_VGA_LEVEL            4
126 #define BB_VGA_CHANGE_THRESHOLD 16
127 
128 #ifndef RUN_AT
129 #define RUN_AT(x)                       (jiffies+(x))
130 #endif
131 
132 // DMA related
133 #define RESERV_AC0DMA                   4
134 
135 // BUILD OBJ mode
136 
137 #define	AVAIL_TD(p, q)	((p)->sOpts.nTxDescs[(q)] - ((p)->iTDUsed[(q)]))
138 
139 #define	NUM				64
140 
141 #define PRIVATE_Message                 0
142 
143 /*---------------------  Export Types  ------------------------------*/
144 
145 #define PRINT_K(p, args...)		\
146 do {					\
147 	if (PRIVATE_Message)		\
148 		printk(p, ##args);	\
149 } while (0)
150 
151 //0:11A 1:11B 2:11G
152 typedef enum _VIA_BB_TYPE
153 {
154 	BB_TYPE_11A = 0,
155 	BB_TYPE_11B,
156 	BB_TYPE_11G
157 } VIA_BB_TYPE, *PVIA_BB_TYPE;
158 
159 //0:11a,1:11b,2:11gb(only CCK in BasicRate),3:11ga(OFDM in Basic Rate)
160 typedef enum _VIA_PKT_TYPE
161 {
162 	PK_TYPE_11A = 0,
163 	PK_TYPE_11B,
164 	PK_TYPE_11GB,
165 	PK_TYPE_11GA
166 } VIA_PKT_TYPE, *PVIA_PKT_TYPE;
167 
168 typedef enum __device_msg_level {
169 	MSG_LEVEL_ERR = 0,            //Errors that will cause abnormal operation.
170 	MSG_LEVEL_NOTICE = 1,         //Some errors need users to be notified.
171 	MSG_LEVEL_INFO = 2,           //Normal message.
172 	MSG_LEVEL_VERBOSE = 3,        //Will report all trival errors.
173 	MSG_LEVEL_DEBUG = 4           //Only for debug purpose.
174 } DEVICE_MSG_LEVEL, *PDEVICE_MSG_LEVEL;
175 
176 //++ NDIS related
177 
178 #define MAX_BSSIDINFO_4_PMKID   16
179 #define MAX_PMKIDLIST           5
180 //Flags for PMKID Candidate list structure
181 #define NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED	0x01
182 
183 // PMKID Structures
184 typedef unsigned char NDIS_802_11_PMKID_VALUE[16];
185 
186 typedef enum _NDIS_802_11_WEP_STATUS {
187 	Ndis802_11WEPEnabled,
188 	Ndis802_11Encryption1Enabled = Ndis802_11WEPEnabled,
189 	Ndis802_11WEPDisabled,
190 	Ndis802_11EncryptionDisabled = Ndis802_11WEPDisabled,
191 	Ndis802_11WEPKeyAbsent,
192 	Ndis802_11Encryption1KeyAbsent = Ndis802_11WEPKeyAbsent,
193 	Ndis802_11WEPNotSupported,
194 	Ndis802_11EncryptionNotSupported = Ndis802_11WEPNotSupported,
195 	Ndis802_11Encryption2Enabled,
196 	Ndis802_11Encryption2KeyAbsent,
197 	Ndis802_11Encryption3Enabled,
198 	Ndis802_11Encryption3KeyAbsent
199 } NDIS_802_11_WEP_STATUS, *PNDIS_802_11_WEP_STATUS,
200 	NDIS_802_11_ENCRYPTION_STATUS, *PNDIS_802_11_ENCRYPTION_STATUS;
201 
202 typedef enum _NDIS_802_11_STATUS_TYPE {
203 	Ndis802_11StatusType_Authentication,
204 	Ndis802_11StatusType_MediaStreamMode,
205 	Ndis802_11StatusType_PMKID_CandidateList,
206 	Ndis802_11StatusTypeMax    // not a real type, defined as an upper bound
207 } NDIS_802_11_STATUS_TYPE, *PNDIS_802_11_STATUS_TYPE;
208 
209 //Added new types for PMKID Candidate lists.
210 struct pmkid_candidate {
211 	NDIS_802_11_MAC_ADDRESS BSSID;
212 	unsigned long Flags;
213 };
214 
215 typedef struct _BSSID_INFO {
216 	NDIS_802_11_MAC_ADDRESS BSSID;
217 	NDIS_802_11_PMKID_VALUE PMKID;
218 } BSSID_INFO, *PBSSID_INFO;
219 
220 typedef struct tagSPMKID {
221 	unsigned long Length;
222 	unsigned long BSSIDInfoCount;
223 	BSSID_INFO BSSIDInfo[MAX_BSSIDINFO_4_PMKID];
224 } SPMKID, *PSPMKID;
225 
226 typedef struct tagSPMKIDCandidateEvent {
227 	NDIS_802_11_STATUS_TYPE     StatusType;
228 	unsigned long Version;       // Version of the structure
229 	unsigned long NumCandidates; // No. of pmkid candidates
230 	struct pmkid_candidate CandidateList[MAX_PMKIDLIST];
231 } SPMKIDCandidateEvent, *PSPMKIDCandidateEvent;
232 
233 //--
234 
235 //++ 802.11h related
236 #define MAX_QUIET_COUNT     8
237 
238 typedef struct tagSQuietControl {
239 	bool bEnable;
240 	unsigned long dwStartTime;
241 	unsigned char byPeriod;
242 	unsigned short wDuration;
243 } SQuietControl, *PSQuietControl;
244 
245 //--
246 typedef struct __chip_info_tbl {
247 	CHIP_TYPE   chip_id;
248 	char *name;
249 	int         io_size;
250 	int         nTxQueue;
251 	u32         flags;
252 } CHIP_INFO, *PCHIP_INFO;
253 
254 typedef enum {
255 	OWNED_BY_HOST = 0,
256 	OWNED_BY_NIC = 1
257 } DEVICE_OWNER_TYPE, *PDEVICE_OWNER_TYPE;
258 
259 // The receive duplicate detection cache entry
260 typedef struct tagSCacheEntry {
261 	unsigned short wFmSequence;
262 	unsigned char abyAddr2[ETH_ALEN];
263 } SCacheEntry, *PSCacheEntry;
264 
265 typedef struct tagSCache {
266 /* The receive cache is updated circularly.  The next entry to be written is
267  * indexed by the "InPtr".
268  */
269 	unsigned int uInPtr;         // Place to use next
270 	SCacheEntry     asCacheEntry[DUPLICATE_RX_CACHE_LENGTH];
271 } SCache, *PSCache;
272 
273 #define CB_MAX_RX_FRAG                 64
274 // DeFragment Control Block, used for collecting fragments prior to reassembly
275 typedef struct tagSDeFragControlBlock {
276 	unsigned short wSequence;
277 	unsigned short wFragNum;
278 	unsigned char abyAddr2[ETH_ALEN];
279 	unsigned int uLifetime;
280 	struct sk_buff *skb;
281 	unsigned char *pbyRxBuffer;
282 	unsigned int cbFrameLength;
283 	bool bInUse;
284 } SDeFragControlBlock, *PSDeFragControlBlock;
285 
286 //flags for options
287 #define     DEVICE_FLAGS_IP_ALIGN        0x00000001UL
288 #define     DEVICE_FLAGS_PREAMBLE_TYPE   0x00000002UL
289 #define     DEVICE_FLAGS_OP_MODE         0x00000004UL
290 #define     DEVICE_FLAGS_PS_MODE         0x00000008UL
291 #define		DEVICE_FLAGS_80211h_MODE	 0x00000010UL
292 #define		DEVICE_FLAGS_DiversityANT	 0x00000020UL
293 
294 //flags for driver status
295 #define     DEVICE_FLAGS_OPENED          0x00010000UL
296 #define     DEVICE_FLAGS_WOL_ENABLED     0x00080000UL
297 //flags for capabilities
298 #define     DEVICE_FLAGS_TX_ALIGN        0x01000000UL
299 #define     DEVICE_FLAGS_HAVE_CAM        0x02000000UL
300 #define     DEVICE_FLAGS_FLOW_CTRL       0x04000000UL
301 
302 //flags for MII status
303 #define     DEVICE_LINK_FAIL             0x00000001UL
304 #define     DEVICE_SPEED_10              0x00000002UL
305 #define     DEVICE_SPEED_100             0x00000004UL
306 #define     DEVICE_SPEED_1000            0x00000008UL
307 #define     DEVICE_DUPLEX_FULL           0x00000010UL
308 #define     DEVICE_AUTONEG_ENABLE        0x00000020UL
309 #define     DEVICE_FORCED_BY_EEPROM      0x00000040UL
310 //for device_set_media_duplex
311 #define     DEVICE_LINK_CHANGE           0x00000001UL
312 
313 typedef struct __device_opt {
314 	int         nRxDescs0;    //Number of RX descriptors0
315 	int         nRxDescs1;    //Number of RX descriptors1
316 	int         nTxDescs[2];  //Number of TX descriptors 0, 1
317 	int         int_works;    //interrupt limits
318 	int         rts_thresh;   //rts threshold
319 	int         frag_thresh;
320 	int         data_rate;
321 	int         channel_num;
322 	int         short_retry;
323 	int         long_retry;
324 	int         bbp_type;
325 	u32         flags;
326 } OPTIONS, *POPTIONS;
327 
328 struct vnt_private {
329 	struct pci_dev *pcid;
330 
331 // netdev
332 	struct net_device *dev;
333 
334 //dma addr, rx/tx pool
335 	dma_addr_t                  pool_dma;
336 	dma_addr_t                  rd0_pool_dma;
337 	dma_addr_t                  rd1_pool_dma;
338 
339 	dma_addr_t                  td0_pool_dma;
340 	dma_addr_t                  td1_pool_dma;
341 
342 	dma_addr_t                  tx_bufs_dma0;
343 	dma_addr_t                  tx_bufs_dma1;
344 	dma_addr_t                  tx_beacon_dma;
345 
346 	unsigned char *tx0_bufs;
347 	unsigned char *tx1_bufs;
348 	unsigned char *tx_beacon_bufs;
349 
350 	CHIP_TYPE                   chip_id;
351 
352 	void __iomem                *PortOffset;
353 	unsigned long dwIsr;
354 	u32                         memaddr;
355 	u32                         ioaddr;
356 	u32                         io_size;
357 
358 	unsigned char byRevId;
359 	unsigned short SubSystemID;
360 	unsigned short SubVendorID;
361 
362 	int                         nTxQueues;
363 	volatile int                iTDUsed[TYPE_MAXTD];
364 
365 	volatile PSTxDesc           apCurrTD[TYPE_MAXTD];
366 	volatile PSTxDesc           apTailTD[TYPE_MAXTD];
367 
368 	volatile PSTxDesc           apTD0Rings;
369 	volatile PSTxDesc           apTD1Rings;
370 
371 	volatile PSRxDesc           aRD0Ring;
372 	volatile PSRxDesc           aRD1Ring;
373 	volatile PSRxDesc           pCurrRD[TYPE_MAXRD];
374 	SCache                      sDupRxCache;
375 
376 	SDeFragControlBlock         sRxDFCB[CB_MAX_RX_FRAG];
377 	unsigned int	cbDFCB;
378 	unsigned int	cbFreeDFCB;
379 	unsigned int	uCurrentDFCBIdx;
380 
381 	OPTIONS                     sOpts;
382 
383 	u32                         flags;
384 
385 	u32                         rx_buf_sz;
386 	int                         multicast_limit;
387 	unsigned char byRxMode;
388 
389 	spinlock_t                  lock;
390 
391 	pid_t			MLMEThr_pid;
392 	struct completion	notify;
393 	struct semaphore	mlme_semaphore;
394 
395 	u32                         rx_bytes;
396 
397 	// Version control
398 	unsigned char byLocalID;
399 	unsigned char byRFType;
400 
401 	unsigned char byMaxPwrLevel;
402 	unsigned char byZoneType;
403 	bool bZoneRegExist;
404 	unsigned char byOriginalZonetype;
405 	unsigned char abyMacContext[MAC_MAX_CONTEXT_REG];
406 	bool bLinkPass;          // link status: OK or fail
407 	unsigned char abyCurrentNetAddr[ETH_ALEN];
408 
409 	// Adapter statistics
410 	SStatCounter                scStatistic;
411 	// 802.11 counter
412 	SDot11Counters              s802_11Counter;
413 
414 	// 802.11 management
415 	PSMgmtObject                pMgmt;
416 	SMgmtObject                 sMgmtObj;
417 
418 	// 802.11 MAC specific
419 	unsigned int	uCurrRSSI;
420 	unsigned char byCurrSQ;
421 
422 	unsigned long dwTxAntennaSel;
423 	unsigned long dwRxAntennaSel;
424 	unsigned char byAntennaCount;
425 	unsigned char byRxAntennaMode;
426 	unsigned char byTxAntennaMode;
427 	bool bTxRxAntInv;
428 
429 	unsigned char *pbyTmpBuff;
430 	unsigned int	uSIFS;    //Current SIFS
431 	unsigned int	uDIFS;    //Current DIFS
432 	unsigned int	uEIFS;    //Current EIFS
433 	unsigned int	uSlot;    //Current SlotTime
434 	unsigned int	uCwMin;   //Current CwMin
435 	unsigned int	uCwMax;   //CwMax is fixed on 1023.
436 	// PHY parameter
437 	unsigned char bySIFS;
438 	unsigned char byDIFS;
439 	unsigned char byEIFS;
440 	unsigned char bySlot;
441 	unsigned char byCWMaxMin;
442 	CARD_PHY_TYPE               eCurrentPHYType;
443 
444 	VIA_BB_TYPE                 byBBType; //0: 11A, 1:11B, 2:11G
445 	VIA_PKT_TYPE                byPacketType; //0:11a,1:11b,2:11gb(only CCK in BasicRate),3:11ga(OFDM in Basic Rate)
446 	unsigned short wBasicRate;
447 	unsigned char byACKRate;
448 	unsigned char byTopOFDMBasicRate;
449 	unsigned char byTopCCKBasicRate;
450 
451 	unsigned char byMinChannel;
452 	unsigned char byMaxChannel;
453 	unsigned int	uConnectionRate;
454 
455 	unsigned char byPreambleType;
456 	unsigned char byShortPreamble;
457 
458 	unsigned short wCurrentRate;
459 	unsigned short wRTSThreshold;
460 	unsigned short wFragmentationThreshold;
461 	unsigned char byShortRetryLimit;
462 	unsigned char byLongRetryLimit;
463 	enum nl80211_iftype op_mode;
464 	unsigned char byOpMode;
465 	bool bBSSIDFilter;
466 	unsigned short wMaxTransmitMSDULifetime;
467 	unsigned char abyBSSID[ETH_ALEN];
468 	unsigned char abyDesireBSSID[ETH_ALEN];
469 	unsigned short wACKDuration;       // update while speed change
470 	unsigned short wRTSTransmitLen;    // update while speed change
471 	unsigned char byRTSServiceField;  // update while speed change
472 	unsigned char byRTSSignalField;   // update while speed change
473 
474 	unsigned long dwMaxReceiveLifetime;       // dot11MaxReceiveLifetime
475 
476 	bool bEncryptionEnable;
477 	bool bLongHeader;
478 	bool bShortSlotTime;
479 	bool bProtectMode;
480 	bool bNonERPPresent;
481 	bool bBarkerPreambleMd;
482 
483 	unsigned char byERPFlag;
484 	unsigned short wUseProtectCntDown;
485 
486 	bool bRadioControlOff;
487 	bool bRadioOff;
488 	bool bEnablePSMode;
489 	unsigned short wListenInterval;
490 	bool bPWBitOn;
491 	WMAC_POWER_MODE         ePSMode;
492 
493 	// GPIO Radio Control
494 	unsigned char byRadioCtl;
495 	unsigned char byGPIO;
496 	bool bHWRadioOff;
497 	bool bPrvActive4RadioOFF;
498 	bool bGPIOBlockRead;
499 
500 	// Beacon related
501 	unsigned short wSeqCounter;
502 	unsigned short wBCNBufLen;
503 	bool bBeaconBufReady;
504 	bool bBeaconSent;
505 	bool bIsBeaconBufReadySet;
506 	unsigned int	cbBeaconBufReadySetCnt;
507 	bool bFixRate;
508 	unsigned char byCurrentCh;
509 	unsigned int	uScanTime;
510 
511 	CMD_STATE               eCommandState;
512 
513 	CMD_CODE                eCommand;
514 	bool bBeaconTx;
515 
516 	bool bStopBeacon;
517 	bool bStopDataPkt;
518 	bool bStopTx0Pkt;
519 	unsigned int	uAutoReConnectTime;
520 
521 	// 802.11 counter
522 
523 	CMD_ITEM                eCmdQueue[CMD_Q_SIZE];
524 	unsigned int	uCmdDequeueIdx;
525 	unsigned int	uCmdEnqueueIdx;
526 	unsigned int	cbFreeCmdQueue;
527 	bool bCmdRunning;
528 	bool bCmdClear;
529 
530 	bool bRoaming;
531 	//WOW
532 	unsigned char abyIPAddr[4];
533 
534 	unsigned long ulTxPower;
535 	NDIS_802_11_WEP_STATUS  eEncryptionStatus;
536 	bool bTransmitKey;
537 //2007-0925-01<Add>by MikeLiu
538 //mike add :save old Encryption
539 	NDIS_802_11_WEP_STATUS  eOldEncryptionStatus;
540 
541 	SKeyManagement          sKey;
542 	unsigned long dwIVCounter;
543 
544 	u64 qwPacketNumber; /* For CCMP and TKIP as TSC(6 bytes) */
545 	unsigned int	uCurrentWEPMode;
546 
547 	RC4Ext                  SBox;
548 	unsigned char abyPRNG[WLAN_WEPMAX_KEYLEN+3];
549 	unsigned char byKeyIndex;
550 	unsigned int	uKeyLength;
551 	unsigned char abyKey[WLAN_WEP232_KEYLEN];
552 
553 	bool bAES;
554 	unsigned char byCntMeasure;
555 
556 	// for AP mode
557 	unsigned int	uAssocCount;
558 	bool bMoreData;
559 
560 	// QoS
561 	bool bGrpAckPolicy;
562 
563 	// for OID_802_11_ASSOCIATION_INFORMATION
564 	bool bAssocInfoSet;
565 
566 	unsigned char byAutoFBCtrl;
567 
568 	bool bTxMICFail;
569 	bool bRxMICFail;
570 
571 	unsigned int	uRATEIdx;
572 
573 	// For Update BaseBand VGA Gain Offset
574 	bool bUpdateBBVGA;
575 	unsigned int	uBBVGADiffCount;
576 	unsigned char byBBVGANew;
577 	unsigned char byBBVGACurrent;
578 	unsigned char abyBBVGA[BB_VGA_LEVEL];
579 	long                    ldBmThreshold[BB_VGA_LEVEL];
580 
581 	unsigned char byBBPreEDRSSI;
582 	unsigned char byBBPreEDIndex;
583 
584 	bool bRadioCmd;
585 	unsigned long dwDiagRefCount;
586 
587 	// For FOE Tuning
588 	unsigned char byFOETuning;
589 
590 	// For Auto Power Tunning
591 
592 	unsigned char byAutoPwrTunning;
593 	short                   sPSetPointCCK;
594 	short                   sPSetPointOFDMG;
595 	short                   sPSetPointOFDMA;
596 	long                    lPFormulaOffset;
597 	short                   sPThreshold;
598 	char                    cAdjustStep;
599 	char                    cMinTxAGC;
600 
601 	// For RF Power table
602 	unsigned char byCCKPwr;
603 	unsigned char byOFDMPwrG;
604 	unsigned char byCurPwr;
605 	char	 byCurPwrdBm;
606 	unsigned char abyCCKPwrTbl[CB_MAX_CHANNEL_24G+1];
607 	unsigned char abyOFDMPwrTbl[CB_MAX_CHANNEL+1];
608 	char	abyCCKDefaultPwr[CB_MAX_CHANNEL_24G+1];
609 	char	abyOFDMDefaultPwr[CB_MAX_CHANNEL+1];
610 	char	abyRegPwr[CB_MAX_CHANNEL+1];
611 	char	abyLocalPwr[CB_MAX_CHANNEL+1];
612 
613 	// BaseBand Loopback Use
614 	unsigned char byBBCR4d;
615 	unsigned char byBBCRc9;
616 	unsigned char byBBCR88;
617 	unsigned char byBBCR09;
618 
619 	// command timer
620 	struct timer_list       sTimerCommand;
621 	struct timer_list       sTimerTxData;
622 	unsigned long nTxDataTimeCout;
623 	bool fTxDataInSleep;
624 	bool IsTxDataTrigger;
625 
626 #ifdef WPA_SM_Transtatus
627 	bool fWPA_Authened;           //is WPA/WPA-PSK or WPA2/WPA2-PSK authen??
628 #endif
629 	unsigned char byReAssocCount;   //mike add:re-association retry times!
630 	unsigned char byLinkWaitCount;
631 
632 	unsigned char abyNodeName[17];
633 
634 	bool bDiversityRegCtlON;
635 	bool bDiversityEnable;
636 	unsigned long ulDiversityNValue;
637 	unsigned long ulDiversityMValue;
638 	unsigned char byTMax;
639 	unsigned char byTMax2;
640 	unsigned char byTMax3;
641 	unsigned long ulSQ3TH;
642 
643 // ANT diversity
644 	unsigned long uDiversityCnt;
645 	unsigned char byAntennaState;
646 	unsigned long ulRatio_State0;
647 	unsigned long ulRatio_State1;
648 
649 	//SQ3 functions for antenna diversity
650 	struct timer_list           TimerSQ3Tmax1;
651 	struct timer_list           TimerSQ3Tmax2;
652 	struct timer_list           TimerSQ3Tmax3;
653 
654 	unsigned long uNumSQ3[MAX_RATE];
655 	unsigned short wAntDiversityMaxRate;
656 
657 	SEthernetHeader         sTxEthHeader;
658 	SEthernetHeader         sRxEthHeader;
659 	unsigned char abyBroadcastAddr[ETH_ALEN];
660 	unsigned char abySNAP_RFC1042[ETH_ALEN];
661 	unsigned char abySNAP_Bridgetunnel[ETH_ALEN];
662 	unsigned char abyEEPROM[EEP_MAX_CONTEXT_SIZE];  //unsigned long alignment
663 	// Pre-Authentication & PMK cache
664 	SPMKID                  gsPMKID;
665 	SPMKIDCandidateEvent    gsPMKIDCandidate;
666 
667 	// for 802.11h
668 	bool b11hEnable;
669 	unsigned char abyCountryCode[3];
670 	// for 802.11h DFS
671 	unsigned int	uNumOfMeasureEIDs;
672 	PWLAN_IE_MEASURE_REQ    pCurrMeasureEID;
673 	bool bMeasureInProgress;
674 	unsigned char byOrgChannel;
675 	unsigned char byOrgRCR;
676 	unsigned long dwOrgMAR0;
677 	unsigned long dwOrgMAR4;
678 	unsigned char byBasicMap;
679 	unsigned char byCCAFraction;
680 	unsigned char abyRPIs[8];
681 	unsigned long dwRPIs[8];
682 	bool bChannelSwitch;
683 	unsigned char byNewChannel;
684 	unsigned char byChannelSwitchCount;
685 	bool bQuietEnable;
686 	bool bEnableFirstQuiet;
687 	unsigned char byQuietStartCount;
688 	unsigned int	uQuietEnqueue;
689 	unsigned long dwCurrentQuietEndTime;
690 	SQuietControl           sQuiet[MAX_QUIET_COUNT];
691 	// for 802.11h TPC
692 	bool bCountryInfo5G;
693 	bool bCountryInfo24G;
694 
695 	unsigned short wBeaconInterval;
696 
697 	//WPA supplicant deamon
698 	struct net_device       *wpadev;
699 	bool bWPADEVUp;
700 	struct sk_buff          *skb;
701 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
702 	unsigned int	bwextcount;
703 	bool bWPASuppWextEnabled;
704 #endif
705 
706 	//--
707 #ifdef HOSTAP
708 	// user space daemon: hostapd, is used for HOSTAP
709 	bool bEnableHostapd;
710 	bool bEnable8021x;
711 	bool bEnableHostWEP;
712 	struct net_device       *apdev;
713 	int (*tx_80211)(struct sk_buff *skb, struct net_device *dev);
714 #endif
715 	unsigned int	uChannel;
716 	bool bMACSuspend;
717 
718 	struct iw_statistics	wstats;		// wireless stats
719 	bool bCommit;
720 };
721 
device_get_ip(struct vnt_private * pInfo)722 static inline bool device_get_ip(struct vnt_private *pInfo)
723 {
724 	struct in_device *in_dev = (struct in_device *)pInfo->dev->ip_ptr;
725 	struct in_ifaddr *ifa;
726 
727 	if (in_dev != NULL) {
728 		ifa = (struct in_ifaddr *)in_dev->ifa_list;
729 		if (ifa != NULL) {
730 			memcpy(pInfo->abyIPAddr, &ifa->ifa_address, 4);
731 			return true;
732 		}
733 	}
734 	return false;
735 }
736 
alloc_rd_info(void)737 static inline PDEVICE_RD_INFO alloc_rd_info(void)
738 {
739 	return kzalloc(sizeof(DEVICE_RD_INFO), GFP_ATOMIC);
740 }
741 
alloc_td_info(void)742 static inline PDEVICE_TD_INFO alloc_td_info(void)
743 {
744 	return kzalloc(sizeof(DEVICE_TD_INFO), GFP_ATOMIC);
745 }
746 
747 /*---------------------  Export Functions  --------------------------*/
748 
749 bool device_dma0_xmit(struct vnt_private *pDevice,
750 		      struct sk_buff *skb, unsigned int uNodeIndex);
751 bool device_alloc_frag_buf(struct vnt_private *pDevice,
752 			   PSDeFragControlBlock pDeF);
753 int Config_FileOperation(struct vnt_private *pDevice,
754 			 bool fwrite, unsigned char *Parameter);
755 #endif
756