Staging: vt665x: remove tpci.h file
[pandora-kernel.git] / drivers / staging / vt6655 / 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 #ifdef MODULE
33 #ifdef MODVERSIONS
34 #include <linux/modversions.h>
35 #endif /* MODVERSIONS */
36 #include <linux/module.h>
37 #endif /* MODULE */
38
39 #include <linux/types.h>
40 #include <linux/init.h>
41 #include <linux/mm.h>
42 #include <linux/errno.h>
43 #include <linux/ioport.h>
44 #include <linux/pci.h>
45 #include <linux/kernel.h>
46 #include <linux/netdevice.h>
47 #include <linux/etherdevice.h>
48 #include <linux/skbuff.h>
49 #include <linux/delay.h>
50 #include <linux/timer.h>
51 #include <linux/slab.h>
52 #include <linux/interrupt.h>
53 #include <linux/version.h>
54 #include <linux/string.h>
55 #include <linux/wait.h>
56 #include <linux/if_arp.h>
57 #include <linux/sched.h>
58 #include <asm/io.h>
59 #include <linux/if.h>
60 //#include <linux/config.h>
61 #include <asm/uaccess.h>
62 #include <linux/proc_fs.h>
63 #include <linux/inetdevice.h>
64 #include <linux/reboot.h>
65 #ifdef SIOCETHTOOL
66 #define DEVICE_ETHTOOL_IOCTL_SUPPORT
67 #include <linux/ethtool.h>
68 #else
69 #undef DEVICE_ETHTOOL_IOCTL_SUPPORT
70 #endif
71 /* Include Wireless Extension definition and check version - Jean II */
72 #include <linux/wireless.h>
73 #include <net/iw_handler.h>     // New driver API
74
75 //2008-0409-07, <Add> by Einsn Liu
76 #ifndef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
77 #define WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
78 #endif
79 //2008-4-14<add> by chester for led issue
80 //#define FOR_LED_ON_NOTEBOOK
81 //
82
83
84 //
85 // device specific
86 //
87
88 #include "kcompat.h"
89 #include "device_cfg.h"
90 #include "ttype.h"
91 #include "80211hdr.h"
92 #include "tether.h"
93 #include "wmgr.h"
94 #include "wcmd.h"
95 #include "mib.h"
96 #include "srom.h"
97 #include "rc4.h"
98 #include "desc.h"
99 #include "key.h"
100 #include "mac.h"
101
102 //PLICE_DEBUG->
103 //#define               THREAD
104
105 //#define       TASK_LET
106 //PLICE_DEBUG<-
107
108
109 /*---------------------  Export Definitions -------------------------*/
110
111 #define MAC_MAX_CONTEXT_REG     (256+128)
112
113 #define MAX_MULTICAST_ADDRESS_NUM       32
114 #define MULTICAST_ADDRESS_LIST_SIZE     (MAX_MULTICAST_ADDRESS_NUM * U_ETHER_ADDR_LEN)
115
116
117 //#define OP_MODE_INFRASTRUCTURE  0
118 //#define OP_MODE_ADHOC           1
119 //#define OP_MODE_AP              2
120
121 #define DUPLICATE_RX_CACHE_LENGTH       5
122
123 #define NUM_KEY_ENTRY                   11
124
125 #define TX_WEP_NONE                     0
126 #define TX_WEP_OTF                      1
127 #define TX_WEP_SW                       2
128 #define TX_WEP_SWOTP                    3
129 #define TX_WEP_OTPSW                    4
130 #define TX_WEP_SW232                    5
131
132 #define KEYSEL_WEP40                    0
133 #define KEYSEL_WEP104                   1
134 #define KEYSEL_TKIP                     2
135 #define KEYSEL_CCMP                     3
136
137
138
139 #define AUTO_FB_NONE            0
140 #define AUTO_FB_0               1
141 #define AUTO_FB_1               2
142
143 #define FB_RATE0                0
144 #define FB_RATE1                1
145
146 // Antenna Mode
147 #define ANT_A                   0
148 #define ANT_B                   1
149 #define ANT_DIVERSITY           2
150 #define ANT_RXD_TXA             3
151 #define ANT_RXD_TXB             4
152 #define ANT_UNKNOWN             0xFF
153
154 #define MAXCHECKHANGCNT         4
155
156 #define BB_VGA_LEVEL            4
157 #define BB_VGA_CHANGE_THRESHOLD 16
158
159
160
161 #ifndef RUN_AT
162 #define RUN_AT(x)                       (jiffies+(x))
163 #endif
164
165 // DMA related
166 #define RESERV_AC0DMA                   4
167
168
169 // BUILD OBJ mode
170
171
172 #define AVAIL_TD(p,q)   ((p)->sOpts.nTxDescs[(q)]-((p)->iTDUsed[(q)]))
173
174 //PLICE_DEBUG ->
175 #define NUM                             64
176 //PLICE_DEUBG <-
177
178
179
180 #define PRIVATE_Message                 0
181
182 /*---------------------  Export Types  ------------------------------*/
183
184
185 #define DBG_PRT(l, p, args...) {if (l<=msglevel) printk( p ,##args);}
186 #define PRINT_K(p, args...) {if (PRIVATE_Message) printk( p ,##args);}
187
188 //0:11A 1:11B 2:11G
189 typedef enum _VIA_BB_TYPE
190 {
191     BB_TYPE_11A=0,
192     BB_TYPE_11B,
193     BB_TYPE_11G
194 } VIA_BB_TYPE, *PVIA_BB_TYPE;
195
196 //0:11a,1:11b,2:11gb(only CCK in BasicRate),3:11ga(OFDM in Basic Rate)
197 typedef enum _VIA_PKT_TYPE
198 {
199     PK_TYPE_11A=0,
200     PK_TYPE_11B,
201     PK_TYPE_11GB,
202     PK_TYPE_11GA
203 } VIA_PKT_TYPE, *PVIA_PKT_TYPE;
204
205
206 typedef enum __device_msg_level {
207     MSG_LEVEL_ERR=0,            //Errors that will cause abnormal operation.
208     MSG_LEVEL_NOTICE=1,         //Some errors need users to be notified.
209     MSG_LEVEL_INFO=2,           //Normal message.
210     MSG_LEVEL_VERBOSE=3,        //Will report all trival errors.
211     MSG_LEVEL_DEBUG=4           //Only for debug purpose.
212 } DEVICE_MSG_LEVEL, *PDEVICE_MSG_LEVEL;
213
214 typedef enum __device_init_type {
215     DEVICE_INIT_COLD=0,         // cold init
216     DEVICE_INIT_RESET,          // reset init or Dx to D0 power remain init
217     DEVICE_INIT_DXPL            // Dx to D0 power lost init
218 } DEVICE_INIT_TYPE, *PDEVICE_INIT_TYPE;
219
220
221 //++ NDIS related
222
223 #define MAX_BSSIDINFO_4_PMKID   16
224 #define MAX_PMKIDLIST           5
225 //Flags for PMKID Candidate list structure
226 #define NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED     0x01
227
228 // PMKID Structures
229 typedef UCHAR   NDIS_802_11_PMKID_VALUE[16];
230
231
232 typedef enum _NDIS_802_11_WEP_STATUS
233 {
234     Ndis802_11WEPEnabled,
235     Ndis802_11Encryption1Enabled = Ndis802_11WEPEnabled,
236     Ndis802_11WEPDisabled,
237     Ndis802_11EncryptionDisabled = Ndis802_11WEPDisabled,
238     Ndis802_11WEPKeyAbsent,
239     Ndis802_11Encryption1KeyAbsent = Ndis802_11WEPKeyAbsent,
240     Ndis802_11WEPNotSupported,
241     Ndis802_11EncryptionNotSupported = Ndis802_11WEPNotSupported,
242     Ndis802_11Encryption2Enabled,
243     Ndis802_11Encryption2KeyAbsent,
244     Ndis802_11Encryption3Enabled,
245     Ndis802_11Encryption3KeyAbsent
246 } NDIS_802_11_WEP_STATUS, *PNDIS_802_11_WEP_STATUS,
247   NDIS_802_11_ENCRYPTION_STATUS, *PNDIS_802_11_ENCRYPTION_STATUS;
248
249
250 typedef enum _NDIS_802_11_STATUS_TYPE
251 {
252     Ndis802_11StatusType_Authentication,
253     Ndis802_11StatusType_MediaStreamMode,
254     Ndis802_11StatusType_PMKID_CandidateList,
255     Ndis802_11StatusTypeMax    // not a real type, defined as an upper bound
256 } NDIS_802_11_STATUS_TYPE, *PNDIS_802_11_STATUS_TYPE;
257
258 //Added new types for PMKID Candidate lists.
259 typedef struct _PMKID_CANDIDATE {
260     NDIS_802_11_MAC_ADDRESS BSSID;
261     ULONG Flags;
262 } PMKID_CANDIDATE, *PPMKID_CANDIDATE;
263
264
265 typedef struct _BSSID_INFO
266 {
267     NDIS_802_11_MAC_ADDRESS BSSID;
268     NDIS_802_11_PMKID_VALUE PMKID;
269 } BSSID_INFO, *PBSSID_INFO;
270
271 typedef struct tagSPMKID {
272     ULONG Length;
273     ULONG BSSIDInfoCount;
274     BSSID_INFO BSSIDInfo[MAX_BSSIDINFO_4_PMKID];
275 } SPMKID, *PSPMKID;
276
277 typedef struct tagSPMKIDCandidateEvent {
278     NDIS_802_11_STATUS_TYPE     StatusType;
279     ULONG Version;       // Version of the structure
280     ULONG NumCandidates; // No. of pmkid candidates
281     PMKID_CANDIDATE CandidateList[MAX_PMKIDLIST];
282 } SPMKIDCandidateEvent, *PSPMKIDCandidateEvent;
283
284 //--
285
286 //++ 802.11h related
287 #define MAX_QUIET_COUNT     8
288
289 typedef struct tagSQuietControl {
290     BOOL        bEnable;
291     DWORD       dwStartTime;
292     BYTE        byPeriod;
293     WORD        wDuration;
294 } SQuietControl, *PSQuietControl;
295
296 //--
297 typedef struct __chip_info_tbl{
298     CHIP_TYPE   chip_id;
299     char*       name;
300     int         io_size;
301     int         nTxQueue;
302     U32         flags;
303 } CHIP_INFO, *PCHIP_INFO;
304
305
306 typedef enum {
307     OWNED_BY_HOST=0,
308     OWNED_BY_NIC=1
309 } DEVICE_OWNER_TYPE, *PDEVICE_OWNER_TYPE;
310
311
312 // The receive duplicate detection cache entry
313 typedef struct tagSCacheEntry{
314     WORD        wFmSequence;
315     BYTE        abyAddr2[U_ETHER_ADDR_LEN];
316 } SCacheEntry, *PSCacheEntry;
317
318 typedef struct tagSCache{
319 /* The receive cache is updated circularly.  The next entry to be written is
320  * indexed by the "InPtr".
321 */
322     UINT            uInPtr;         // Place to use next
323     SCacheEntry     asCacheEntry[DUPLICATE_RX_CACHE_LENGTH];
324 } SCache, *PSCache;
325
326 #define CB_MAX_RX_FRAG                 64
327 // DeFragment Control Block, used for collecting fragments prior to reassembly
328 typedef struct tagSDeFragControlBlock
329 {
330     WORD            wSequence;
331     WORD            wFragNum;
332     BYTE            abyAddr2[U_ETHER_ADDR_LEN];
333         UINT            uLifetime;
334     struct sk_buff* skb;
335     PBYTE           pbyRxBuffer;
336     UINT            cbFrameLength;
337     BOOL            bInUse;
338 } SDeFragControlBlock, *PSDeFragControlBlock;
339
340
341
342 //flags for options
343 #define     DEVICE_FLAGS_IP_ALIGN        0x00000001UL
344 #define     DEVICE_FLAGS_PREAMBLE_TYPE   0x00000002UL
345 #define     DEVICE_FLAGS_OP_MODE         0x00000004UL
346 #define     DEVICE_FLAGS_PS_MODE         0x00000008UL
347 #define         DEVICE_FLAGS_80211h_MODE         0x00000010UL
348 #define         DEVICE_FLAGS_DiversityANT        0x00000020UL
349
350 //flags for driver status
351 #define     DEVICE_FLAGS_OPENED          0x00010000UL
352 #define     DEVICE_FLAGS_WOL_ENABLED     0x00080000UL
353 //flags for capbilities
354 #define     DEVICE_FLAGS_TX_ALIGN        0x01000000UL
355 #define     DEVICE_FLAGS_HAVE_CAM        0x02000000UL
356 #define     DEVICE_FLAGS_FLOW_CTRL       0x04000000UL
357
358 //flags for MII status
359 #define     DEVICE_LINK_FAIL             0x00000001UL
360 #define     DEVICE_SPEED_10              0x00000002UL
361 #define     DEVICE_SPEED_100             0x00000004UL
362 #define     DEVICE_SPEED_1000            0x00000008UL
363 #define     DEVICE_DUPLEX_FULL           0x00000010UL
364 #define     DEVICE_AUTONEG_ENABLE        0x00000020UL
365 #define     DEVICE_FORCED_BY_EEPROM      0x00000040UL
366 //for device_set_media_duplex
367 #define     DEVICE_LINK_CHANGE           0x00000001UL
368
369
370 //PLICE_DEBUG->
371
372
373 typedef struct _RxManagementQueue
374 {
375         int     packet_num;
376         int     head,tail;
377         PSRxMgmtPacket  Q[NUM];
378 } RxManagementQueue,*PSRxManagementQueue;
379
380
381
382 //PLICE_DEBUG<-
383
384
385 typedef struct __device_opt {
386     int         nRxDescs0;    //Number of RX descriptors0
387     int         nRxDescs1;    //Number of RX descriptors1
388     int         nTxDescs[2];  //Number of TX descriptors 0, 1
389     int         int_works;    //interrupt limits
390     int         rts_thresh;   //rts threshold
391     int         frag_thresh;
392     int         data_rate;
393     int         channel_num;
394     int         short_retry;
395     int         long_retry;
396     int         bbp_type;
397     U32         flags;
398 } OPTIONS, *POPTIONS;
399
400
401 typedef struct __device_info {
402     struct __device_info*        next;
403     struct __device_info*        prev;
404
405     struct pci_dev*             pcid;
406
407 #if CONFIG_PM
408     u32                         pci_state[16];
409 #endif
410
411 // netdev
412     struct net_device*          dev;
413     struct net_device*          next_module;
414     struct net_device_stats     stats;
415
416 //dma addr, rx/tx pool
417     dma_addr_t                  pool_dma;
418     dma_addr_t                  rd0_pool_dma;
419     dma_addr_t                  rd1_pool_dma;
420
421     dma_addr_t                  td0_pool_dma;
422     dma_addr_t                  td1_pool_dma;
423
424     dma_addr_t                  tx_bufs_dma0;
425     dma_addr_t                  tx_bufs_dma1;
426     dma_addr_t                  tx_beacon_dma;
427
428     PBYTE                       tx0_bufs;
429     PBYTE                       tx1_bufs;
430     PBYTE                       tx_beacon_bufs;
431
432     CHIP_TYPE                   chip_id;
433
434     U32                         PortOffset;
435     DWORD                       dwIsr;
436     U32                         memaddr;
437     U32                         ioaddr;
438     U32                         io_size;
439
440     BYTE                        byRevId;
441     WORD                        SubSystemID;
442     WORD                        SubVendorID;
443
444     int                         nTxQueues;
445     volatile int                iTDUsed[TYPE_MAXTD];
446
447     volatile PSTxDesc           apCurrTD[TYPE_MAXTD];
448     volatile PSTxDesc           apTailTD[TYPE_MAXTD];
449
450     volatile PSTxDesc           apTD0Rings;
451     volatile PSTxDesc           apTD1Rings;
452
453     volatile PSRxDesc           aRD0Ring;
454     volatile PSRxDesc           aRD1Ring;
455     volatile PSRxDesc           pCurrRD[TYPE_MAXRD];
456     SCache                      sDupRxCache;
457
458     SDeFragControlBlock         sRxDFCB[CB_MAX_RX_FRAG];
459     UINT                        cbDFCB;
460     UINT                        cbFreeDFCB;
461     UINT                        uCurrentDFCBIdx;
462
463     OPTIONS                     sOpts;
464
465     U32                         flags;
466
467     U32                         rx_buf_sz;
468     int                         multicast_limit;
469     BYTE                        byRxMode;
470
471     spinlock_t                  lock;
472 //PLICE_DEBUG->
473         struct  tasklet_struct          RxMngWorkItem;
474         RxManagementQueue       rxManeQueue;
475 //PLICE_DEBUG<-
476 //PLICE_DEBUG ->
477         pid_t                           MLMEThr_pid;
478         struct  completion      notify;
479         struct  semaphore       mlme_semaphore;
480 //PLICE_DEBUG <-
481
482
483     U32                         rx_bytes;
484
485     // Version control
486     BYTE                        byLocalID;
487     BYTE                        byRFType;
488
489     BYTE                        byMaxPwrLevel;
490     BYTE                        byZoneType;
491     BOOL                        bZoneRegExist;
492    BYTE                        byOriginalZonetype;
493     BYTE                        abyMacContext[MAC_MAX_CONTEXT_REG];
494     BOOL                        bLinkPass;          // link status: OK or fail
495     BYTE                        abyCurrentNetAddr[U_ETHER_ADDR_LEN];
496
497     // Adapter statistics
498     SStatCounter                scStatistic;
499     // 802.11 counter
500     SDot11Counters              s802_11Counter;
501
502
503     // 802.11 management
504     PSMgmtObject                pMgmt;
505     SMgmtObject                 sMgmtObj;
506
507     // 802.11 MAC specific
508     UINT                        uCurrRSSI;
509     BYTE                        byCurrSQ;
510
511     DWORD                       dwTxAntennaSel;
512     DWORD                       dwRxAntennaSel;
513     BYTE                        byAntennaCount;
514     BYTE                        byRxAntennaMode;
515     BYTE                        byTxAntennaMode;
516     BOOL                        bTxRxAntInv;
517
518     PBYTE                       pbyTmpBuff;
519     UINT                        uSIFS;    //Current SIFS
520     UINT                        uDIFS;    //Current DIFS
521     UINT                        uEIFS;    //Current EIFS
522     UINT                        uSlot;    //Current SlotTime
523     UINT                        uCwMin;   //Current CwMin
524     UINT                        uCwMax;   //CwMax is fixed on 1023.
525     // PHY parameter
526     BYTE                        bySIFS;
527     BYTE                        byDIFS;
528     BYTE                        byEIFS;
529     BYTE                        bySlot;
530     BYTE                        byCWMaxMin;
531     CARD_PHY_TYPE               eCurrentPHYType;
532
533
534     VIA_BB_TYPE                 byBBType; //0: 11A, 1:11B, 2:11G
535     VIA_PKT_TYPE                byPacketType; //0:11a,1:11b,2:11gb(only CCK in BasicRate),3:11ga(OFDM in Basic Rate)
536     WORD                        wBasicRate;
537     BYTE                        byACKRate;
538     BYTE                        byTopOFDMBasicRate;
539     BYTE                        byTopCCKBasicRate;
540
541     BYTE                        byMinChannel;
542     BYTE                        byMaxChannel;
543     UINT                        uConnectionRate;
544
545     BYTE                        byPreambleType;
546     BYTE                        byShortPreamble;
547
548     WORD                        wCurrentRate;
549     WORD                        wRTSThreshold;
550     WORD                        wFragmentationThreshold;
551     BYTE                        byShortRetryLimit;
552     BYTE                        byLongRetryLimit;
553     CARD_OP_MODE                eOPMode;
554     BYTE                        byOpMode;
555     BOOL                        bBSSIDFilter;
556     WORD                        wMaxTransmitMSDULifetime;
557     BYTE                        abyBSSID[U_ETHER_ADDR_LEN];
558     BYTE                        abyDesireBSSID[U_ETHER_ADDR_LEN];
559     WORD                        wCTSDuration;       // update while speed change
560     WORD                        wACKDuration;       // update while speed change
561     WORD                        wRTSTransmitLen;    // update while speed change
562     BYTE                        byRTSServiceField;  // update while speed change
563     BYTE                        byRTSSignalField;   // update while speed change
564
565     DWORD                       dwMaxReceiveLifetime;       // dot11MaxReceiveLifetime
566
567     BOOL                        bCCK;
568     BOOL                        bEncryptionEnable;
569     BOOL                        bLongHeader;
570     BOOL                        bShortSlotTime;
571     BOOL                        bProtectMode;
572     BOOL                        bNonERPPresent;
573     BOOL                        bBarkerPreambleMd;
574
575     BYTE                        byERPFlag;
576     WORD                        wUseProtectCntDown;
577
578     BOOL                        bRadioControlOff;
579     BOOL                        bRadioOff;
580     BOOL                    bEnablePSMode;
581     WORD                    wListenInterval;
582     BOOL                    bPWBitOn;
583     WMAC_POWER_MODE         ePSMode;
584
585
586     // GPIO Radio Control
587     BYTE                    byRadioCtl;
588     BYTE                    byGPIO;
589     BOOL                    bHWRadioOff;
590     BOOL                    bPrvActive4RadioOFF;
591     BOOL                    bGPIOBlockRead;
592
593     // Beacon releated
594     WORD                    wSeqCounter;
595     WORD                    wBCNBufLen;
596     BOOL                    bBeaconBufReady;
597     BOOL                    bBeaconSent;
598     BOOL                    bIsBeaconBufReadySet;
599     UINT                    cbBeaconBufReadySetCnt;
600     BOOL                    bFixRate;
601     BYTE                    byCurrentCh;
602     UINT                    uScanTime;
603
604     CMD_STATE               eCommandState;
605
606     CMD_CODE                eCommand;
607     BOOL                    bBeaconTx;
608
609     BOOL                    bStopBeacon;
610     BOOL                    bStopDataPkt;
611     BOOL                    bStopTx0Pkt;
612     UINT                    uAutoReConnectTime;
613
614     // 802.11 counter
615
616     CMD_ITEM                eCmdQueue[CMD_Q_SIZE];
617     UINT                    uCmdDequeueIdx;
618     UINT                    uCmdEnqueueIdx;
619     UINT                    cbFreeCmdQueue;
620     BOOL                    bCmdRunning;
621     BOOL                    bCmdClear;
622
623
624
625     BOOL                    bRoaming;
626     //WOW
627     BYTE                    abyIPAddr[4];
628
629     ULONG                   ulTxPower;
630     NDIS_802_11_WEP_STATUS  eEncryptionStatus;
631     BOOL                    bTransmitKey;
632 //2007-0925-01<Add>by MikeLiu
633 //mike add :save old Encryption
634     NDIS_802_11_WEP_STATUS  eOldEncryptionStatus;
635
636     SKeyManagement          sKey;
637     DWORD                   dwIVCounter;
638
639     QWORD                   qwPacketNumber; //For CCMP and TKIP as TSC(6 bytes)
640     UINT                    uCurrentWEPMode;
641
642     RC4Ext                  SBox;
643     BYTE                    abyPRNG[WLAN_WEPMAX_KEYLEN+3];
644     BYTE                    byKeyIndex;
645     UINT                    uKeyLength;
646     BYTE                    abyKey[WLAN_WEP232_KEYLEN];
647
648     BOOL                    bAES;
649     BYTE                    byCntMeasure;
650
651     // for AP mode
652     UINT                    uAssocCount;
653     BOOL                    bMoreData;
654
655     // QoS
656     BOOL                    bGrpAckPolicy;
657
658     // for OID_802_11_ASSOCIATION_INFORMATION
659     BOOL                    bAssocInfoSet;
660
661
662     BYTE                    byAutoFBCtrl;
663
664     BOOL                    bTxMICFail;
665     BOOL                    bRxMICFail;
666
667
668     UINT                    uRATEIdx;
669
670
671     // For Update BaseBand VGA Gain Offset
672     BOOL                    bUpdateBBVGA;
673     UINT                    uBBVGADiffCount;
674     BYTE                    byBBVGANew;
675     BYTE                    byBBVGACurrent;
676     BYTE                    abyBBVGA[BB_VGA_LEVEL];
677     LONG                    ldBmThreshold[BB_VGA_LEVEL];
678
679     BYTE                    byBBPreEDRSSI;
680     BYTE                    byBBPreEDIndex;
681
682
683     BOOL                    bRadioCmd;
684     DWORD                   dwDiagRefCount;
685
686     // For FOE Tuning
687     BYTE                    byFOETuning;
688
689     // For Auto Power Tunning
690
691     BYTE                    byAutoPwrTunning;
692     SHORT                   sPSetPointCCK;
693     SHORT                   sPSetPointOFDMG;
694     SHORT                   sPSetPointOFDMA;
695     LONG                    lPFormulaOffset;
696     SHORT                   sPThreshold;
697     CHAR                    cAdjustStep;
698     CHAR                    cMinTxAGC;
699
700     // For RF Power table
701     BYTE                    byCCKPwr;
702     BYTE                    byOFDMPwrG;
703     BYTE                    byCurPwr;
704     I8                      byCurPwrdBm;
705     BYTE                    abyCCKPwrTbl[CB_MAX_CHANNEL_24G+1];
706     BYTE                    abyOFDMPwrTbl[CB_MAX_CHANNEL+1];
707     I8                      abyCCKDefaultPwr[CB_MAX_CHANNEL_24G+1];
708     I8                      abyOFDMDefaultPwr[CB_MAX_CHANNEL+1];
709     I8                      abyRegPwr[CB_MAX_CHANNEL+1];
710     I8                      abyLocalPwr[CB_MAX_CHANNEL+1];
711
712
713     // BaseBand Loopback Use
714     BYTE                    byBBCR4d;
715     BYTE                    byBBCRc9;
716     BYTE                    byBBCR88;
717     BYTE                    byBBCR09;
718
719     // command timer
720     struct timer_list       sTimerCommand;
721 #ifdef TxInSleep
722      struct timer_list       sTimerTxData;
723      ULONG                       nTxDataTimeCout;
724      BOOL  fTxDataInSleep;
725      BOOL  IsTxDataTrigger;
726 #endif
727
728 #ifdef WPA_SM_Transtatus
729     BOOL  fWPA_Authened;           //is WPA/WPA-PSK or WPA2/WPA2-PSK authen??
730 #endif
731     BYTE            byReAssocCount;   //mike add:re-association retry times!
732     BYTE            byLinkWaitCount;
733
734
735     BYTE                    abyNodeName[17];
736
737     BOOL                    bDiversityRegCtlON;
738     BOOL                    bDiversityEnable;
739     ULONG                   ulDiversityNValue;
740     ULONG                   ulDiversityMValue;
741     BYTE                    byTMax;
742     BYTE                    byTMax2;
743     BYTE                    byTMax3;
744     ULONG                   ulSQ3TH;
745
746 // ANT diversity
747     ULONG                   uDiversityCnt;
748     BYTE                    byAntennaState;
749     ULONG                   ulRatio_State0;
750     ULONG                   ulRatio_State1;
751
752     //SQ3 functions for antenna diversity
753     struct timer_list           TimerSQ3Tmax1;
754     struct timer_list           TimerSQ3Tmax2;
755     struct timer_list           TimerSQ3Tmax3;
756
757
758     ULONG                   uNumSQ3[MAX_RATE];
759     WORD                    wAntDiversityMaxRate;
760
761
762     SEthernetHeader         sTxEthHeader;
763     SEthernetHeader         sRxEthHeader;
764     BYTE                    abyBroadcastAddr[U_ETHER_ADDR_LEN];
765     BYTE                    abySNAP_RFC1042[U_ETHER_ADDR_LEN];
766     BYTE                    abySNAP_Bridgetunnel[U_ETHER_ADDR_LEN];
767      BYTE                        abyEEPROM[EEP_MAX_CONTEXT_SIZE];  //DWORD alignment
768     // Pre-Authentication & PMK cache
769     SPMKID                  gsPMKID;
770     SPMKIDCandidateEvent    gsPMKIDCandidate;
771
772
773     // for 802.11h
774     BOOL                    b11hEnable;
775     BYTE                    abyCountryCode[3];
776     // for 802.11h DFS
777     UINT                    uNumOfMeasureEIDs;
778     PWLAN_IE_MEASURE_REQ    pCurrMeasureEID;
779     BOOL                    bMeasureInProgress;
780     BYTE                    byOrgChannel;
781     BYTE                    byOrgRCR;
782     DWORD                   dwOrgMAR0;
783     DWORD                   dwOrgMAR4;
784     BYTE                    byBasicMap;
785     BYTE                    byCCAFraction;
786     BYTE                    abyRPIs[8];
787     DWORD                   dwRPIs[8];
788     BOOL                    bChannelSwitch;
789     BYTE                    byNewChannel;
790     BYTE                    byChannelSwitchCount;
791     BOOL                    bQuietEnable;
792     BOOL                    bEnableFirstQuiet;
793     BYTE                    byQuietStartCount;
794     UINT                    uQuietEnqueue;
795     DWORD                   dwCurrentQuietEndTime;
796     SQuietControl           sQuiet[MAX_QUIET_COUNT];
797     // for 802.11h TPC
798     BOOL                    bCountryInfo5G;
799     BOOL                    bCountryInfo24G;
800
801     WORD                    wBeaconInterval;
802
803     //WPA supplicant deamon
804         struct net_device       *wpadev;
805         BOOL                    bWPADEVUp;
806     struct sk_buff          *skb;
807 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
808 /*
809         BOOL                 bwextstep0;
810         BOOL                 bwextstep1;
811         BOOL                 bwextstep2;
812         BOOL                 bwextstep3;
813         */
814         UINT                   bwextcount;
815         BOOL                 bWPASuppWextEnabled;
816 #endif
817
818     //--
819 #ifdef HOSTAP
820     // user space daemon: hostapd, is used for HOSTAP
821         BOOL                    bEnableHostapd;
822         BOOL                    bEnable8021x;
823         BOOL                    bEnableHostWEP;
824         struct net_device       *apdev;
825         int (*tx_80211)(struct sk_buff *skb, struct net_device *dev);
826 #endif
827     UINT                    uChannel;
828     BOOL                    bMACSuspend;
829
830         struct iw_statistics    wstats;         // wireless stats
831     BOOL                    bCommit;
832
833 } DEVICE_INFO, *PSDevice;
834
835
836 //PLICE_DEBUG->
837
838
839  inline  static VOID   EnQueue (PSDevice pDevice,PSRxMgmtPacket  pRxMgmtPacket)
840 {
841         //printk("Enter EnQueue:tail is %d\n",pDevice->rxManeQueue.tail);
842         if ((pDevice->rxManeQueue.tail+1) % NUM == pDevice->rxManeQueue.head)
843         {
844                 //printk("Queue is Full,tail is %d\n",pDevice->rxManeQueue.tail);
845                 return ;
846         }
847         else
848         {
849                 pDevice->rxManeQueue.tail = (pDevice->rxManeQueue.tail+1)% NUM;
850                 pDevice->rxManeQueue.Q[pDevice->rxManeQueue.tail] = pRxMgmtPacket;
851                 pDevice->rxManeQueue.packet_num++;
852                 //printk("packet num is %d\n",pDevice->rxManeQueue.packet_num);
853         }
854 }
855
856
857
858
859         inline  static  PSRxMgmtPacket DeQueue (PSDevice pDevice)
860 {
861         PSRxMgmtPacket  pRxMgmtPacket;
862         if (pDevice->rxManeQueue.tail == pDevice->rxManeQueue.head)
863         {
864                 printk("Queue is Empty\n");
865                 return NULL;
866         }
867         else
868         {
869                 int     x;
870                 //x=pDevice->rxManeQueue.head = (pDevice->rxManeQueue.head+1)%NUM;
871                 pDevice->rxManeQueue.head = (pDevice->rxManeQueue.head+1)%NUM;
872                 x = pDevice->rxManeQueue.head;
873                 //printk("Enter DeQueue:head is %d\n",x);
874                 pRxMgmtPacket = pDevice->rxManeQueue.Q[x];
875                 pDevice->rxManeQueue.packet_num--;
876                 return pRxMgmtPacket;
877         }
878 }
879
880 VOID    InitRxManagementQueue(PSDevice   pDevice);
881
882
883
884 //PLICE_DEBUG<-
885
886
887
888
889
890
891 inline static BOOL device_get_ip(PSDevice pInfo) {
892     struct in_device* in_dev=(struct in_device*) pInfo->dev->ip_ptr;
893     struct in_ifaddr* ifa;
894
895     if (in_dev!=NULL) {
896         ifa=(struct in_ifaddr*) in_dev->ifa_list;
897         if (ifa!=NULL) {
898             memcpy(pInfo->abyIPAddr,&ifa->ifa_address,4);
899             return TRUE;
900         }
901     }
902     return FALSE;
903 }
904
905
906
907 static inline PDEVICE_RD_INFO alloc_rd_info(void) {
908     PDEVICE_RD_INFO  ptr;
909     if ((ptr = (PDEVICE_RD_INFO)kmalloc((int)sizeof(DEVICE_RD_INFO), (int)GFP_ATOMIC)) == NULL)
910         return NULL;
911     else {
912         memset(ptr,0,sizeof(DEVICE_RD_INFO));
913         return ptr;
914     }
915 }
916
917 static inline PDEVICE_TD_INFO alloc_td_info(void) {
918     PDEVICE_TD_INFO  ptr;
919     if ((ptr = (PDEVICE_TD_INFO)kmalloc((int)sizeof(DEVICE_TD_INFO), (int)GFP_ATOMIC))==NULL)
920         return NULL;
921     else {
922         memset(ptr,0,sizeof(DEVICE_TD_INFO));
923         return ptr;
924     }
925 }
926
927 /*---------------------  Export Functions  --------------------------*/
928
929 BOOL device_dma0_xmit(PSDevice pDevice, struct sk_buff *skb, UINT uNodeIndex);
930 BOOL device_alloc_frag_buf(PSDevice pDevice, PSDeFragControlBlock pDeF);
931 int Config_FileOperation(PSDevice pDevice,BOOL fwrite,unsigned char *Parameter);
932 #endif
933
934