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