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