device.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755
  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. #ifndef __DEVICE_H__
  29. #define __DEVICE_H__
  30. #include <linux/module.h>
  31. #include <linux/types.h>
  32. #include <linux/mm.h>
  33. #include <linux/errno.h>
  34. #include <linux/ioport.h>
  35. #include <linux/pci.h>
  36. #include <linux/kernel.h>
  37. #include <linux/netdevice.h>
  38. #include <linux/etherdevice.h>
  39. #include <linux/skbuff.h>
  40. #include <linux/delay.h>
  41. #include <linux/timer.h>
  42. #include <linux/slab.h>
  43. #include <linux/interrupt.h>
  44. #include <linux/string.h>
  45. #include <linux/wait.h>
  46. #include <linux/if_arp.h>
  47. #include <linux/sched.h>
  48. #include <linux/io.h>
  49. #include <linux/if.h>
  50. #include <linux/crc32.h>
  51. //#include <linux/config.h>
  52. #include <linux/uaccess.h>
  53. #include <linux/proc_fs.h>
  54. #include <linux/inetdevice.h>
  55. #include <linux/reboot.h>
  56. #include <linux/ethtool.h>
  57. /* Include Wireless Extension definition and check version - Jean II */
  58. #include <linux/wireless.h>
  59. #include <net/iw_handler.h> // New driver API
  60. //2008-0409-07, <Add> by Einsn Liu
  61. #ifndef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
  62. #define WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
  63. #endif
  64. //
  65. // device specific
  66. //
  67. #include "device_cfg.h"
  68. #include "ttype.h"
  69. #include "80211hdr.h"
  70. #include "tether.h"
  71. #include "wmgr.h"
  72. #include "wcmd.h"
  73. #include "mib.h"
  74. #include "srom.h"
  75. #include "rc4.h"
  76. #include "desc.h"
  77. #include "key.h"
  78. #include "mac.h"
  79. /*--------------------- Export Definitions -------------------------*/
  80. #define MAC_MAX_CONTEXT_REG (256+128)
  81. #define MAX_MULTICAST_ADDRESS_NUM 32
  82. #define MULTICAST_ADDRESS_LIST_SIZE (MAX_MULTICAST_ADDRESS_NUM * ETH_ALEN)
  83. #define DUPLICATE_RX_CACHE_LENGTH 5
  84. #define NUM_KEY_ENTRY 11
  85. #define TX_WEP_NONE 0
  86. #define TX_WEP_OTF 1
  87. #define TX_WEP_SW 2
  88. #define TX_WEP_SWOTP 3
  89. #define TX_WEP_OTPSW 4
  90. #define TX_WEP_SW232 5
  91. #define KEYSEL_WEP40 0
  92. #define KEYSEL_WEP104 1
  93. #define KEYSEL_TKIP 2
  94. #define KEYSEL_CCMP 3
  95. #define AUTO_FB_NONE 0
  96. #define AUTO_FB_0 1
  97. #define AUTO_FB_1 2
  98. #define FB_RATE0 0
  99. #define FB_RATE1 1
  100. // Antenna Mode
  101. #define ANT_A 0
  102. #define ANT_B 1
  103. #define ANT_DIVERSITY 2
  104. #define ANT_RXD_TXA 3
  105. #define ANT_RXD_TXB 4
  106. #define ANT_UNKNOWN 0xFF
  107. #define MAXCHECKHANGCNT 4
  108. #define BB_VGA_LEVEL 4
  109. #define BB_VGA_CHANGE_THRESHOLD 16
  110. #ifndef RUN_AT
  111. #define RUN_AT(x) (jiffies+(x))
  112. #endif
  113. // DMA related
  114. #define RESERV_AC0DMA 4
  115. // BUILD OBJ mode
  116. #define AVAIL_TD(p, q) ((p)->sOpts.nTxDescs[(q)] - ((p)->iTDUsed[(q)]))
  117. #define NUM 64
  118. #define PRIVATE_Message 0
  119. /*--------------------- Export Types ------------------------------*/
  120. #define PRINT_K(p, args...) \
  121. do { \
  122. if (PRIVATE_Message) \
  123. printk(p, ##args); \
  124. } while (0)
  125. //0:11A 1:11B 2:11G
  126. typedef enum _VIA_BB_TYPE
  127. {
  128. BB_TYPE_11A = 0,
  129. BB_TYPE_11B,
  130. BB_TYPE_11G
  131. } VIA_BB_TYPE, *PVIA_BB_TYPE;
  132. //0:11a,1:11b,2:11gb(only CCK in BasicRate),3:11ga(OFDM in Basic Rate)
  133. typedef enum _VIA_PKT_TYPE
  134. {
  135. PK_TYPE_11A = 0,
  136. PK_TYPE_11B,
  137. PK_TYPE_11GB,
  138. PK_TYPE_11GA
  139. } VIA_PKT_TYPE, *PVIA_PKT_TYPE;
  140. typedef enum __device_msg_level {
  141. MSG_LEVEL_ERR = 0, //Errors that will cause abnormal operation.
  142. MSG_LEVEL_NOTICE = 1, //Some errors need users to be notified.
  143. MSG_LEVEL_INFO = 2, //Normal message.
  144. MSG_LEVEL_VERBOSE = 3, //Will report all trival errors.
  145. MSG_LEVEL_DEBUG = 4 //Only for debug purpose.
  146. } DEVICE_MSG_LEVEL, *PDEVICE_MSG_LEVEL;
  147. //++ NDIS related
  148. #define MAX_BSSIDINFO_4_PMKID 16
  149. #define MAX_PMKIDLIST 5
  150. //Flags for PMKID Candidate list structure
  151. #define NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED 0x01
  152. // PMKID Structures
  153. typedef unsigned char NDIS_802_11_PMKID_VALUE[16];
  154. typedef enum _NDIS_802_11_WEP_STATUS {
  155. Ndis802_11WEPEnabled,
  156. Ndis802_11Encryption1Enabled = Ndis802_11WEPEnabled,
  157. Ndis802_11WEPDisabled,
  158. Ndis802_11EncryptionDisabled = Ndis802_11WEPDisabled,
  159. Ndis802_11WEPKeyAbsent,
  160. Ndis802_11Encryption1KeyAbsent = Ndis802_11WEPKeyAbsent,
  161. Ndis802_11WEPNotSupported,
  162. Ndis802_11EncryptionNotSupported = Ndis802_11WEPNotSupported,
  163. Ndis802_11Encryption2Enabled,
  164. Ndis802_11Encryption2KeyAbsent,
  165. Ndis802_11Encryption3Enabled,
  166. Ndis802_11Encryption3KeyAbsent
  167. } NDIS_802_11_WEP_STATUS, *PNDIS_802_11_WEP_STATUS,
  168. NDIS_802_11_ENCRYPTION_STATUS, *PNDIS_802_11_ENCRYPTION_STATUS;
  169. typedef enum _NDIS_802_11_STATUS_TYPE {
  170. Ndis802_11StatusType_Authentication,
  171. Ndis802_11StatusType_MediaStreamMode,
  172. Ndis802_11StatusType_PMKID_CandidateList,
  173. Ndis802_11StatusTypeMax // not a real type, defined as an upper bound
  174. } NDIS_802_11_STATUS_TYPE, *PNDIS_802_11_STATUS_TYPE;
  175. //Added new types for PMKID Candidate lists.
  176. struct pmkid_candidate {
  177. NDIS_802_11_MAC_ADDRESS BSSID;
  178. unsigned long Flags;
  179. };
  180. typedef struct _BSSID_INFO {
  181. NDIS_802_11_MAC_ADDRESS BSSID;
  182. NDIS_802_11_PMKID_VALUE PMKID;
  183. } BSSID_INFO, *PBSSID_INFO;
  184. typedef struct tagSPMKID {
  185. unsigned long Length;
  186. unsigned long BSSIDInfoCount;
  187. BSSID_INFO BSSIDInfo[MAX_BSSIDINFO_4_PMKID];
  188. } SPMKID, *PSPMKID;
  189. typedef struct tagSPMKIDCandidateEvent {
  190. NDIS_802_11_STATUS_TYPE StatusType;
  191. unsigned long Version; // Version of the structure
  192. unsigned long NumCandidates; // No. of pmkid candidates
  193. struct pmkid_candidate CandidateList[MAX_PMKIDLIST];
  194. } SPMKIDCandidateEvent, *PSPMKIDCandidateEvent;
  195. //--
  196. //++ 802.11h related
  197. #define MAX_QUIET_COUNT 8
  198. typedef struct tagSQuietControl {
  199. bool bEnable;
  200. unsigned long dwStartTime;
  201. unsigned char byPeriod;
  202. unsigned short wDuration;
  203. } SQuietControl, *PSQuietControl;
  204. //--
  205. typedef struct __chip_info_tbl {
  206. CHIP_TYPE chip_id;
  207. char *name;
  208. int io_size;
  209. int nTxQueue;
  210. u32 flags;
  211. } CHIP_INFO, *PCHIP_INFO;
  212. typedef enum {
  213. OWNED_BY_HOST = 0,
  214. OWNED_BY_NIC = 1
  215. } DEVICE_OWNER_TYPE, *PDEVICE_OWNER_TYPE;
  216. // The receive duplicate detection cache entry
  217. typedef struct tagSCacheEntry {
  218. unsigned short wFmSequence;
  219. unsigned char abyAddr2[ETH_ALEN];
  220. } SCacheEntry, *PSCacheEntry;
  221. typedef struct tagSCache {
  222. /* The receive cache is updated circularly. The next entry to be written is
  223. * indexed by the "InPtr".
  224. */
  225. unsigned int uInPtr; // Place to use next
  226. SCacheEntry asCacheEntry[DUPLICATE_RX_CACHE_LENGTH];
  227. } SCache, *PSCache;
  228. #define CB_MAX_RX_FRAG 64
  229. // DeFragment Control Block, used for collecting fragments prior to reassembly
  230. typedef struct tagSDeFragControlBlock {
  231. unsigned short wSequence;
  232. unsigned short wFragNum;
  233. unsigned char abyAddr2[ETH_ALEN];
  234. unsigned int uLifetime;
  235. struct sk_buff *skb;
  236. unsigned char *pbyRxBuffer;
  237. unsigned int cbFrameLength;
  238. bool bInUse;
  239. } SDeFragControlBlock, *PSDeFragControlBlock;
  240. //flags for options
  241. #define DEVICE_FLAGS_IP_ALIGN 0x00000001UL
  242. #define DEVICE_FLAGS_PREAMBLE_TYPE 0x00000002UL
  243. #define DEVICE_FLAGS_OP_MODE 0x00000004UL
  244. #define DEVICE_FLAGS_PS_MODE 0x00000008UL
  245. #define DEVICE_FLAGS_80211h_MODE 0x00000010UL
  246. #define DEVICE_FLAGS_DiversityANT 0x00000020UL
  247. //flags for driver status
  248. #define DEVICE_FLAGS_OPENED 0x00010000UL
  249. #define DEVICE_FLAGS_WOL_ENABLED 0x00080000UL
  250. //flags for capabilities
  251. #define DEVICE_FLAGS_TX_ALIGN 0x01000000UL
  252. #define DEVICE_FLAGS_HAVE_CAM 0x02000000UL
  253. #define DEVICE_FLAGS_FLOW_CTRL 0x04000000UL
  254. //flags for MII status
  255. #define DEVICE_LINK_FAIL 0x00000001UL
  256. #define DEVICE_SPEED_10 0x00000002UL
  257. #define DEVICE_SPEED_100 0x00000004UL
  258. #define DEVICE_SPEED_1000 0x00000008UL
  259. #define DEVICE_DUPLEX_FULL 0x00000010UL
  260. #define DEVICE_AUTONEG_ENABLE 0x00000020UL
  261. #define DEVICE_FORCED_BY_EEPROM 0x00000040UL
  262. //for device_set_media_duplex
  263. #define DEVICE_LINK_CHANGE 0x00000001UL
  264. typedef struct __device_opt {
  265. int nRxDescs0; //Number of RX descriptors0
  266. int nRxDescs1; //Number of RX descriptors1
  267. int nTxDescs[2]; //Number of TX descriptors 0, 1
  268. int int_works; //interrupt limits
  269. int rts_thresh; //rts threshold
  270. int frag_thresh;
  271. int data_rate;
  272. int channel_num;
  273. int short_retry;
  274. int long_retry;
  275. int bbp_type;
  276. u32 flags;
  277. } OPTIONS, *POPTIONS;
  278. struct vnt_private {
  279. struct pci_dev *pcid;
  280. // netdev
  281. struct net_device *dev;
  282. //dma addr, rx/tx pool
  283. dma_addr_t pool_dma;
  284. dma_addr_t rd0_pool_dma;
  285. dma_addr_t rd1_pool_dma;
  286. dma_addr_t td0_pool_dma;
  287. dma_addr_t td1_pool_dma;
  288. dma_addr_t tx_bufs_dma0;
  289. dma_addr_t tx_bufs_dma1;
  290. dma_addr_t tx_beacon_dma;
  291. unsigned char *tx0_bufs;
  292. unsigned char *tx1_bufs;
  293. unsigned char *tx_beacon_bufs;
  294. CHIP_TYPE chip_id;
  295. void __iomem *PortOffset;
  296. unsigned long dwIsr;
  297. u32 memaddr;
  298. u32 ioaddr;
  299. u32 io_size;
  300. unsigned char byRevId;
  301. unsigned short SubSystemID;
  302. unsigned short SubVendorID;
  303. int nTxQueues;
  304. volatile int iTDUsed[TYPE_MAXTD];
  305. volatile PSTxDesc apCurrTD[TYPE_MAXTD];
  306. volatile PSTxDesc apTailTD[TYPE_MAXTD];
  307. volatile PSTxDesc apTD0Rings;
  308. volatile PSTxDesc apTD1Rings;
  309. volatile PSRxDesc aRD0Ring;
  310. volatile PSRxDesc aRD1Ring;
  311. volatile PSRxDesc pCurrRD[TYPE_MAXRD];
  312. SCache sDupRxCache;
  313. SDeFragControlBlock sRxDFCB[CB_MAX_RX_FRAG];
  314. unsigned int cbDFCB;
  315. unsigned int cbFreeDFCB;
  316. unsigned int uCurrentDFCBIdx;
  317. OPTIONS sOpts;
  318. u32 flags;
  319. u32 rx_buf_sz;
  320. int multicast_limit;
  321. unsigned char byRxMode;
  322. spinlock_t lock;
  323. pid_t MLMEThr_pid;
  324. struct completion notify;
  325. struct semaphore mlme_semaphore;
  326. u32 rx_bytes;
  327. // Version control
  328. unsigned char byLocalID;
  329. unsigned char byRFType;
  330. unsigned char byMaxPwrLevel;
  331. unsigned char byZoneType;
  332. bool bZoneRegExist;
  333. unsigned char byOriginalZonetype;
  334. unsigned char abyMacContext[MAC_MAX_CONTEXT_REG];
  335. bool bLinkPass; // link status: OK or fail
  336. unsigned char abyCurrentNetAddr[ETH_ALEN];
  337. // Adapter statistics
  338. SStatCounter scStatistic;
  339. // 802.11 counter
  340. SDot11Counters s802_11Counter;
  341. // 802.11 management
  342. PSMgmtObject pMgmt;
  343. SMgmtObject sMgmtObj;
  344. // 802.11 MAC specific
  345. unsigned int uCurrRSSI;
  346. unsigned char byCurrSQ;
  347. unsigned long dwTxAntennaSel;
  348. unsigned long dwRxAntennaSel;
  349. unsigned char byAntennaCount;
  350. unsigned char byRxAntennaMode;
  351. unsigned char byTxAntennaMode;
  352. bool bTxRxAntInv;
  353. unsigned char *pbyTmpBuff;
  354. unsigned int uSIFS; //Current SIFS
  355. unsigned int uDIFS; //Current DIFS
  356. unsigned int uEIFS; //Current EIFS
  357. unsigned int uSlot; //Current SlotTime
  358. unsigned int uCwMin; //Current CwMin
  359. unsigned int uCwMax; //CwMax is fixed on 1023.
  360. // PHY parameter
  361. unsigned char bySIFS;
  362. unsigned char byDIFS;
  363. unsigned char byEIFS;
  364. unsigned char bySlot;
  365. unsigned char byCWMaxMin;
  366. CARD_PHY_TYPE eCurrentPHYType;
  367. VIA_BB_TYPE byBBType; //0: 11A, 1:11B, 2:11G
  368. VIA_PKT_TYPE byPacketType; //0:11a,1:11b,2:11gb(only CCK in BasicRate),3:11ga(OFDM in Basic Rate)
  369. unsigned short wBasicRate;
  370. unsigned char byACKRate;
  371. unsigned char byTopOFDMBasicRate;
  372. unsigned char byTopCCKBasicRate;
  373. unsigned char byMinChannel;
  374. unsigned char byMaxChannel;
  375. unsigned int uConnectionRate;
  376. unsigned char byPreambleType;
  377. unsigned char byShortPreamble;
  378. unsigned short wCurrentRate;
  379. unsigned short wRTSThreshold;
  380. unsigned short wFragmentationThreshold;
  381. unsigned char byShortRetryLimit;
  382. unsigned char byLongRetryLimit;
  383. enum nl80211_iftype op_mode;
  384. unsigned char byOpMode;
  385. bool bBSSIDFilter;
  386. unsigned short wMaxTransmitMSDULifetime;
  387. unsigned char abyBSSID[ETH_ALEN];
  388. unsigned char abyDesireBSSID[ETH_ALEN];
  389. unsigned short wACKDuration; // update while speed change
  390. unsigned short wRTSTransmitLen; // update while speed change
  391. unsigned char byRTSServiceField; // update while speed change
  392. unsigned char byRTSSignalField; // update while speed change
  393. unsigned long dwMaxReceiveLifetime; // dot11MaxReceiveLifetime
  394. bool bEncryptionEnable;
  395. bool bLongHeader;
  396. bool bShortSlotTime;
  397. bool bProtectMode;
  398. bool bNonERPPresent;
  399. bool bBarkerPreambleMd;
  400. unsigned char byERPFlag;
  401. unsigned short wUseProtectCntDown;
  402. bool bRadioControlOff;
  403. bool bRadioOff;
  404. bool bEnablePSMode;
  405. unsigned short wListenInterval;
  406. bool bPWBitOn;
  407. WMAC_POWER_MODE ePSMode;
  408. // GPIO Radio Control
  409. unsigned char byRadioCtl;
  410. unsigned char byGPIO;
  411. bool bHWRadioOff;
  412. bool bPrvActive4RadioOFF;
  413. bool bGPIOBlockRead;
  414. // Beacon related
  415. unsigned short wSeqCounter;
  416. unsigned short wBCNBufLen;
  417. bool bBeaconBufReady;
  418. bool bBeaconSent;
  419. bool bIsBeaconBufReadySet;
  420. unsigned int cbBeaconBufReadySetCnt;
  421. bool bFixRate;
  422. unsigned char byCurrentCh;
  423. unsigned int uScanTime;
  424. CMD_STATE eCommandState;
  425. CMD_CODE eCommand;
  426. bool bBeaconTx;
  427. bool bStopBeacon;
  428. bool bStopDataPkt;
  429. bool bStopTx0Pkt;
  430. unsigned int uAutoReConnectTime;
  431. // 802.11 counter
  432. CMD_ITEM eCmdQueue[CMD_Q_SIZE];
  433. unsigned int uCmdDequeueIdx;
  434. unsigned int uCmdEnqueueIdx;
  435. unsigned int cbFreeCmdQueue;
  436. bool bCmdRunning;
  437. bool bCmdClear;
  438. bool bRoaming;
  439. //WOW
  440. unsigned char abyIPAddr[4];
  441. unsigned long ulTxPower;
  442. NDIS_802_11_WEP_STATUS eEncryptionStatus;
  443. bool bTransmitKey;
  444. //2007-0925-01<Add>by MikeLiu
  445. //mike add :save old Encryption
  446. NDIS_802_11_WEP_STATUS eOldEncryptionStatus;
  447. SKeyManagement sKey;
  448. unsigned long dwIVCounter;
  449. u64 qwPacketNumber; /* For CCMP and TKIP as TSC(6 bytes) */
  450. unsigned int uCurrentWEPMode;
  451. RC4Ext SBox;
  452. unsigned char abyPRNG[WLAN_WEPMAX_KEYLEN+3];
  453. unsigned char byKeyIndex;
  454. unsigned int uKeyLength;
  455. unsigned char abyKey[WLAN_WEP232_KEYLEN];
  456. bool bAES;
  457. unsigned char byCntMeasure;
  458. // for AP mode
  459. unsigned int uAssocCount;
  460. bool bMoreData;
  461. // QoS
  462. bool bGrpAckPolicy;
  463. // for OID_802_11_ASSOCIATION_INFORMATION
  464. bool bAssocInfoSet;
  465. unsigned char byAutoFBCtrl;
  466. bool bTxMICFail;
  467. bool bRxMICFail;
  468. unsigned int uRATEIdx;
  469. // For Update BaseBand VGA Gain Offset
  470. bool bUpdateBBVGA;
  471. unsigned int uBBVGADiffCount;
  472. unsigned char byBBVGANew;
  473. unsigned char byBBVGACurrent;
  474. unsigned char abyBBVGA[BB_VGA_LEVEL];
  475. long ldBmThreshold[BB_VGA_LEVEL];
  476. unsigned char byBBPreEDRSSI;
  477. unsigned char byBBPreEDIndex;
  478. bool bRadioCmd;
  479. unsigned long dwDiagRefCount;
  480. // For FOE Tuning
  481. unsigned char byFOETuning;
  482. // For Auto Power Tunning
  483. unsigned char byAutoPwrTunning;
  484. short sPSetPointCCK;
  485. short sPSetPointOFDMG;
  486. short sPSetPointOFDMA;
  487. long lPFormulaOffset;
  488. short sPThreshold;
  489. char cAdjustStep;
  490. char cMinTxAGC;
  491. // For RF Power table
  492. unsigned char byCCKPwr;
  493. unsigned char byOFDMPwrG;
  494. unsigned char byCurPwr;
  495. char byCurPwrdBm;
  496. unsigned char abyCCKPwrTbl[CB_MAX_CHANNEL_24G+1];
  497. unsigned char abyOFDMPwrTbl[CB_MAX_CHANNEL+1];
  498. char abyCCKDefaultPwr[CB_MAX_CHANNEL_24G+1];
  499. char abyOFDMDefaultPwr[CB_MAX_CHANNEL+1];
  500. char abyRegPwr[CB_MAX_CHANNEL+1];
  501. char abyLocalPwr[CB_MAX_CHANNEL+1];
  502. // BaseBand Loopback Use
  503. unsigned char byBBCR4d;
  504. unsigned char byBBCRc9;
  505. unsigned char byBBCR88;
  506. unsigned char byBBCR09;
  507. // command timer
  508. struct timer_list sTimerCommand;
  509. struct timer_list sTimerTxData;
  510. unsigned long nTxDataTimeCout;
  511. bool fTxDataInSleep;
  512. bool IsTxDataTrigger;
  513. #ifdef WPA_SM_Transtatus
  514. bool fWPA_Authened; //is WPA/WPA-PSK or WPA2/WPA2-PSK authen??
  515. #endif
  516. unsigned char byReAssocCount; //mike add:re-association retry times!
  517. unsigned char byLinkWaitCount;
  518. unsigned char abyNodeName[17];
  519. bool bDiversityRegCtlON;
  520. bool bDiversityEnable;
  521. unsigned long ulDiversityNValue;
  522. unsigned long ulDiversityMValue;
  523. unsigned char byTMax;
  524. unsigned char byTMax2;
  525. unsigned char byTMax3;
  526. unsigned long ulSQ3TH;
  527. // ANT diversity
  528. unsigned long uDiversityCnt;
  529. unsigned char byAntennaState;
  530. unsigned long ulRatio_State0;
  531. unsigned long ulRatio_State1;
  532. //SQ3 functions for antenna diversity
  533. struct timer_list TimerSQ3Tmax1;
  534. struct timer_list TimerSQ3Tmax2;
  535. struct timer_list TimerSQ3Tmax3;
  536. unsigned long uNumSQ3[MAX_RATE];
  537. unsigned short wAntDiversityMaxRate;
  538. SEthernetHeader sTxEthHeader;
  539. SEthernetHeader sRxEthHeader;
  540. unsigned char abyBroadcastAddr[ETH_ALEN];
  541. unsigned char abySNAP_RFC1042[ETH_ALEN];
  542. unsigned char abySNAP_Bridgetunnel[ETH_ALEN];
  543. unsigned char abyEEPROM[EEP_MAX_CONTEXT_SIZE]; //unsigned long alignment
  544. // Pre-Authentication & PMK cache
  545. SPMKID gsPMKID;
  546. SPMKIDCandidateEvent gsPMKIDCandidate;
  547. // for 802.11h
  548. bool b11hEnable;
  549. unsigned char abyCountryCode[3];
  550. // for 802.11h DFS
  551. unsigned int uNumOfMeasureEIDs;
  552. PWLAN_IE_MEASURE_REQ pCurrMeasureEID;
  553. bool bMeasureInProgress;
  554. unsigned char byOrgChannel;
  555. unsigned char byOrgRCR;
  556. unsigned long dwOrgMAR0;
  557. unsigned long dwOrgMAR4;
  558. unsigned char byBasicMap;
  559. unsigned char byCCAFraction;
  560. unsigned char abyRPIs[8];
  561. unsigned long dwRPIs[8];
  562. bool bChannelSwitch;
  563. unsigned char byNewChannel;
  564. unsigned char byChannelSwitchCount;
  565. bool bQuietEnable;
  566. bool bEnableFirstQuiet;
  567. unsigned char byQuietStartCount;
  568. unsigned int uQuietEnqueue;
  569. unsigned long dwCurrentQuietEndTime;
  570. SQuietControl sQuiet[MAX_QUIET_COUNT];
  571. // for 802.11h TPC
  572. bool bCountryInfo5G;
  573. bool bCountryInfo24G;
  574. unsigned short wBeaconInterval;
  575. //WPA supplicant deamon
  576. struct net_device *wpadev;
  577. bool bWPADEVUp;
  578. struct sk_buff *skb;
  579. #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
  580. unsigned int bwextcount;
  581. bool bWPASuppWextEnabled;
  582. #endif
  583. //--
  584. #ifdef HOSTAP
  585. // user space daemon: hostapd, is used for HOSTAP
  586. bool bEnableHostapd;
  587. bool bEnable8021x;
  588. bool bEnableHostWEP;
  589. struct net_device *apdev;
  590. int (*tx_80211)(struct sk_buff *skb, struct net_device *dev);
  591. #endif
  592. unsigned int uChannel;
  593. bool bMACSuspend;
  594. struct iw_statistics wstats; // wireless stats
  595. bool bCommit;
  596. };
  597. static inline bool device_get_ip(struct vnt_private *pInfo)
  598. {
  599. struct in_device *in_dev = (struct in_device *)pInfo->dev->ip_ptr;
  600. struct in_ifaddr *ifa;
  601. if (in_dev != NULL) {
  602. ifa = (struct in_ifaddr *)in_dev->ifa_list;
  603. if (ifa != NULL) {
  604. memcpy(pInfo->abyIPAddr, &ifa->ifa_address, 4);
  605. return true;
  606. }
  607. }
  608. return false;
  609. }
  610. static inline PDEVICE_RD_INFO alloc_rd_info(void)
  611. {
  612. return kzalloc(sizeof(DEVICE_RD_INFO), GFP_ATOMIC);
  613. }
  614. static inline PDEVICE_TD_INFO alloc_td_info(void)
  615. {
  616. return kzalloc(sizeof(DEVICE_TD_INFO), GFP_ATOMIC);
  617. }
  618. /*--------------------- Export Functions --------------------------*/
  619. bool device_dma0_xmit(struct vnt_private *pDevice,
  620. struct sk_buff *skb, unsigned int uNodeIndex);
  621. bool device_alloc_frag_buf(struct vnt_private *pDevice,
  622. PSDeFragControlBlock pDeF);
  623. int Config_FileOperation(struct vnt_private *pDevice,
  624. bool fwrite, unsigned char *Parameter);
  625. #endif