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