device.h 29 KB

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