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