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