device.h 24 KB

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