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