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