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