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