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