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