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