r8180.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718
  1. /*
  2. This is part of rtl8180 OpenSource driver.
  3. Copyright (C) Andrea Merello 2004-2005 <andreamrl@tiscali.it>
  4. Released under the terms of GPL (General Public Licence)
  5. Parts of this driver are based on the GPL part of the
  6. official realtek driver
  7. Parts of this driver are based on the rtl8180 driver skeleton
  8. from Patric Schenke & Andres Salomon
  9. Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver
  10. We want to tanks the Authors of those projects and the Ndiswrapper
  11. project Authors.
  12. */
  13. #ifndef R8180H
  14. #define R8180H
  15. #define RTL8180_MODULE_NAME "r8180"
  16. #define DMESG(x,a...) printk(KERN_INFO RTL8180_MODULE_NAME ": " x "\n", ## a)
  17. #define DMESGW(x,a...) printk(KERN_WARNING RTL8180_MODULE_NAME ": WW:" x "\n", ## a)
  18. #define DMESGE(x,a...) printk(KERN_WARNING RTL8180_MODULE_NAME ": EE:" x "\n", ## a)
  19. #include <linux/module.h>
  20. #include <linux/kernel.h>
  21. //#include <linux/config.h>
  22. #include <linux/init.h>
  23. #include <linux/ioport.h>
  24. #include <linux/sched.h>
  25. #include <linux/types.h>
  26. #include <linux/slab.h>
  27. #include <linux/netdevice.h>
  28. #include <linux/pci.h>
  29. #include <linux/etherdevice.h>
  30. #include <linux/delay.h>
  31. #include <linux/rtnetlink.h> //for rtnl_lock()
  32. #include <linux/wireless.h>
  33. #include <linux/timer.h>
  34. #include <linux/proc_fs.h> // Necessary because we use the proc fs
  35. #include <linux/if_arp.h>
  36. #include "ieee80211/ieee80211.h"
  37. #include <asm/io.h>
  38. //#include <asm/semaphore.h>
  39. #define EPROM_93c46 0
  40. #define EPROM_93c56 1
  41. #define RTL_IOCTL_WPA_SUPPLICANT SIOCIWFIRSTPRIV+30
  42. #define DEFAULT_FRAG_THRESHOLD 2342U
  43. #define MIN_FRAG_THRESHOLD 256U
  44. #define DEFAULT_RTS_THRESHOLD 2342U
  45. #define MIN_RTS_THRESHOLD 0U
  46. #define MAX_RTS_THRESHOLD 2342U
  47. #define DEFAULT_BEACONINTERVAL 0x64U
  48. #define DEFAULT_RETRY_RTS 7
  49. #define DEFAULT_RETRY_DATA 7
  50. #define BEACON_QUEUE 6
  51. #define aSifsTime 10
  52. #define sCrcLng 4
  53. #define sAckCtsLng 112 // bits in ACK and CTS frames
  54. //+by amy 080312
  55. #define RATE_ADAPTIVE_TIMER_PERIOD 300
  56. typedef enum _WIRELESS_MODE {
  57. WIRELESS_MODE_UNKNOWN = 0x00,
  58. WIRELESS_MODE_A = 0x01,
  59. WIRELESS_MODE_B = 0x02,
  60. WIRELESS_MODE_G = 0x04,
  61. WIRELESS_MODE_AUTO = 0x08,
  62. } WIRELESS_MODE;
  63. typedef struct ChnlAccessSetting {
  64. u16 SIFS_Timer;
  65. u16 DIFS_Timer;
  66. u16 SlotTimeTimer;
  67. u16 EIFS_Timer;
  68. u16 CWminIndex;
  69. u16 CWmaxIndex;
  70. }*PCHANNEL_ACCESS_SETTING,CHANNEL_ACCESS_SETTING;
  71. typedef enum{
  72. NIC_8185 = 1,
  73. NIC_8185B
  74. } nic_t;
  75. typedef u32 AC_CODING;
  76. #define AC0_BE 0 // ACI: 0x00 // Best Effort
  77. #define AC1_BK 1 // ACI: 0x01 // Background
  78. #define AC2_VI 2 // ACI: 0x10 // Video
  79. #define AC3_VO 3 // ACI: 0x11 // Voice
  80. #define AC_MAX 4 // Max: define total number; Should not to be used as a real enum.
  81. //
  82. // ECWmin/ECWmax field.
  83. // Ref: WMM spec 2.2.2: WME Parameter Element, p.13.
  84. //
  85. typedef union _ECW{
  86. u8 charData;
  87. struct
  88. {
  89. u8 ECWmin:4;
  90. u8 ECWmax:4;
  91. }f; // Field
  92. }ECW, *PECW;
  93. //
  94. // ACI/AIFSN Field.
  95. // Ref: WMM spec 2.2.2: WME Parameter Element, p.12.
  96. //
  97. typedef union _ACI_AIFSN{
  98. u8 charData;
  99. struct
  100. {
  101. u8 AIFSN:4;
  102. u8 ACM:1;
  103. u8 ACI:2;
  104. u8 Reserved:1;
  105. }f; // Field
  106. }ACI_AIFSN, *PACI_AIFSN;
  107. //
  108. // AC Parameters Record Format.
  109. // Ref: WMM spec 2.2.2: WME Parameter Element, p.12.
  110. //
  111. typedef union _AC_PARAM{
  112. u32 longData;
  113. u8 charData[4];
  114. struct
  115. {
  116. ACI_AIFSN AciAifsn;
  117. ECW Ecw;
  118. u16 TXOPLimit;
  119. }f; // Field
  120. }AC_PARAM, *PAC_PARAM;
  121. /* it is a wrong definition. -xiong-2006-11-17
  122. typedef struct ThreeWireReg {
  123. u16 longData;
  124. struct {
  125. u8 enableB;
  126. u8 data;
  127. u8 clk;
  128. u8 read_write;
  129. } struc;
  130. } ThreeWireReg;
  131. */
  132. typedef union _ThreeWire{
  133. struct _ThreeWireStruc{
  134. u16 data:1;
  135. u16 clk:1;
  136. u16 enableB:1;
  137. u16 read_write:1;
  138. u16 resv1:12;
  139. // u2Byte resv2:14;
  140. // u2Byte ThreeWireEnable:1;
  141. // u2Byte resv3:1;
  142. }struc;
  143. u16 longData;
  144. }ThreeWireReg;
  145. typedef struct buffer
  146. {
  147. struct buffer *next;
  148. u32 *buf;
  149. dma_addr_t dma;
  150. } buffer;
  151. //YJ,modified,080828
  152. typedef struct Stats
  153. {
  154. unsigned long txrdu;
  155. unsigned long rxrdu;
  156. unsigned long rxnolast;
  157. unsigned long rxnodata;
  158. // unsigned long rxreset;
  159. // unsigned long rxwrkaround;
  160. unsigned long rxnopointer;
  161. unsigned long txnperr;
  162. unsigned long txresumed;
  163. unsigned long rxerr;
  164. unsigned long rxoverflow;
  165. unsigned long rxint;
  166. unsigned long txbkpokint;
  167. unsigned long txbepoking;
  168. unsigned long txbkperr;
  169. unsigned long txbeperr;
  170. unsigned long txnpokint;
  171. unsigned long txhpokint;
  172. unsigned long txhperr;
  173. unsigned long ints;
  174. unsigned long shints;
  175. unsigned long txoverflow;
  176. unsigned long rxdmafail;
  177. unsigned long txbeacon;
  178. unsigned long txbeaconerr;
  179. unsigned long txlpokint;
  180. unsigned long txlperr;
  181. unsigned long txretry;//retry number tony 20060601
  182. unsigned long rxcrcerrmin;//crc error (0-500)
  183. unsigned long rxcrcerrmid;//crc error (500-1000)
  184. unsigned long rxcrcerrmax;//crc error (>1000)
  185. unsigned long rxicverr;//ICV error
  186. } Stats;
  187. #define MAX_LD_SLOT_NUM 10
  188. #define KEEP_ALIVE_INTERVAL 20 // in seconds.
  189. #define CHECK_FOR_HANG_PERIOD 2 //be equal to watchdog check time
  190. #define DEFAULT_KEEP_ALIVE_LEVEL 1
  191. #define DEFAULT_SLOT_NUM 2
  192. #define POWER_PROFILE_AC 0
  193. #define POWER_PROFILE_BATTERY 1
  194. typedef struct _link_detect_t
  195. {
  196. u32 RxFrameNum[MAX_LD_SLOT_NUM]; // number of Rx Frame / CheckForHang_period to determine link status
  197. u16 SlotNum; // number of CheckForHang period to determine link status, default is 2
  198. u16 SlotIndex;
  199. u32 NumTxOkInPeriod; //number of packet transmitted during CheckForHang
  200. u32 NumRxOkInPeriod; //number of packet received during CheckForHang
  201. u8 IdleCount; // (KEEP_ALIVE_INTERVAL / CHECK_FOR_HANG_PERIOD)
  202. u32 LastNumTxUnicast;
  203. u32 LastNumRxUnicast;
  204. bool bBusyTraffic; //when it is set to 1, UI cann't scan at will.
  205. }link_detect_t, *plink_detect_t;
  206. //YJ,modified,080828,end
  207. //by amy for led
  208. //================================================================================
  209. // LED customization.
  210. //================================================================================
  211. typedef enum _LED_STRATEGY_8185{
  212. SW_LED_MODE0, //
  213. SW_LED_MODE1, //
  214. HW_LED, // HW control 2 LEDs, LED0 and LED1 (there are 4 different control modes)
  215. }LED_STRATEGY_8185, *PLED_STRATEGY_8185;
  216. //by amy for led
  217. //by amy for power save
  218. typedef enum _LED_CTL_MODE{
  219. LED_CTL_POWER_ON = 1,
  220. LED_CTL_LINK = 2,
  221. LED_CTL_NO_LINK = 3,
  222. LED_CTL_TX = 4,
  223. LED_CTL_RX = 5,
  224. LED_CTL_SITE_SURVEY = 6,
  225. LED_CTL_POWER_OFF = 7
  226. }LED_CTL_MODE;
  227. typedef enum _RT_RF_POWER_STATE
  228. {
  229. eRfOn,
  230. eRfSleep,
  231. eRfOff
  232. }RT_RF_POWER_STATE;
  233. enum _ReasonCode{
  234. unspec_reason = 0x1,
  235. auth_not_valid = 0x2,
  236. deauth_lv_ss = 0x3,
  237. inactivity = 0x4,
  238. ap_overload = 0x5,
  239. class2_err = 0x6,
  240. class3_err = 0x7,
  241. disas_lv_ss = 0x8,
  242. asoc_not_auth = 0x9,
  243. //----MIC_CHECK
  244. mic_failure = 0xe,
  245. //----END MIC_CHECK
  246. // Reason code defined in 802.11i D10.0 p.28.
  247. invalid_IE = 0x0d,
  248. four_way_tmout = 0x0f,
  249. two_way_tmout = 0x10,
  250. IE_dismatch = 0x11,
  251. invalid_Gcipher = 0x12,
  252. invalid_Pcipher = 0x13,
  253. invalid_AKMP = 0x14,
  254. unsup_RSNIEver = 0x15,
  255. invalid_RSNIE = 0x16,
  256. auth_802_1x_fail= 0x17,
  257. ciper_reject = 0x18,
  258. // Reason code defined in 7.3.1.7, 802.1e D13.0, p.42. Added by Annie, 2005-11-15.
  259. QoS_unspec = 0x20, // 32
  260. QAP_bandwidth = 0x21, // 33
  261. poor_condition = 0x22, // 34
  262. no_facility = 0x23, // 35
  263. // Where is 36???
  264. req_declined = 0x25, // 37
  265. invalid_param = 0x26, // 38
  266. req_not_honored= 0x27, // 39
  267. TS_not_created = 0x2F, // 47
  268. DL_not_allowed = 0x30, // 48
  269. dest_not_exist = 0x31, // 49
  270. dest_not_QSTA = 0x32, // 50
  271. };
  272. typedef enum _RT_PS_MODE
  273. {
  274. eActive, // Active/Continuous access.
  275. eMaxPs, // Max power save mode.
  276. eFastPs // Fast power save mode.
  277. }RT_PS_MODE;
  278. //by amy for power save
  279. typedef struct r8180_priv
  280. {
  281. struct pci_dev *pdev;
  282. short epromtype;
  283. int irq;
  284. struct ieee80211_device *ieee80211;
  285. short phy_ver; /* meaningful for rtl8225 1:A 2:B 3:C */
  286. short enable_gpio0;
  287. short hw_plcp_len;
  288. short plcp_preamble_mode; // 0:auto 1:short 2:long
  289. spinlock_t irq_lock;
  290. spinlock_t irq_th_lock;
  291. spinlock_t tx_lock;
  292. spinlock_t ps_lock;
  293. spinlock_t rf_ps_lock;
  294. u16 irq_mask;
  295. short irq_enabled;
  296. struct net_device *dev;
  297. short chan;
  298. short sens;
  299. short max_sens;
  300. u8 chtxpwr[15]; //channels from 1 to 14, 0 not used
  301. u8 chtxpwr_ofdm[15]; //channels from 1 to 14, 0 not used
  302. //u8 challow[15]; //channels from 1 to 14, 0 not used
  303. u8 channel_plan; // it's the channel plan index
  304. short up;
  305. short crcmon; //if 1 allow bad crc frame reception in monitor mode
  306. short prism_hdr;
  307. struct timer_list scan_timer;
  308. /*short scanpending;
  309. short stopscan;*/
  310. spinlock_t scan_lock;
  311. u8 active_probe;
  312. //u8 active_scan_num;
  313. struct semaphore wx_sem;
  314. struct semaphore rf_state;
  315. short hw_wep;
  316. short digphy;
  317. short antb;
  318. short diversity;
  319. u8 cs_treshold;
  320. short rcr_csense;
  321. u32 key0[4];
  322. short (*rf_set_sens)(struct net_device *dev,short sens);
  323. void (*rf_set_chan)(struct net_device *dev,short ch);
  324. void (*rf_close)(struct net_device *dev);
  325. void (*rf_init)(struct net_device *dev);
  326. void (*rf_sleep)(struct net_device *dev);
  327. void (*rf_wakeup)(struct net_device *dev);
  328. //short rate;
  329. short promisc;
  330. /*stats*/
  331. struct Stats stats;
  332. struct _link_detect_t link_detect; //YJ,add,080828
  333. struct iw_statistics wstats;
  334. struct proc_dir_entry *dir_dev;
  335. /*RX stuff*/
  336. u32 *rxring;
  337. u32 *rxringtail;
  338. dma_addr_t rxringdma;
  339. struct buffer *rxbuffer;
  340. struct buffer *rxbufferhead;
  341. int rxringcount;
  342. u16 rxbuffersize;
  343. struct sk_buff *rx_skb;
  344. short rx_skb_complete;
  345. u32 rx_prevlen;
  346. /*TX stuff*/
  347. /*
  348. u32 *txlpring;
  349. u32 *txhpring;
  350. u32 *txnpring;
  351. dma_addr_t txlpringdma;
  352. dma_addr_t txhpringdma;
  353. dma_addr_t txnpringdma;
  354. u32 *txlpringtail;
  355. u32 *txhpringtail;
  356. u32 *txnpringtail;
  357. u32 *txlpringhead;
  358. u32 *txhpringhead;
  359. u32 *txnpringhead;
  360. struct buffer *txlpbufs;
  361. struct buffer *txhpbufs;
  362. struct buffer *txnpbufs;
  363. struct buffer *txlpbufstail;
  364. struct buffer *txhpbufstail;
  365. struct buffer *txnpbufstail;
  366. */
  367. u32 *txmapring;
  368. u32 *txbkpring;
  369. u32 *txbepring;
  370. u32 *txvipring;
  371. u32 *txvopring;
  372. u32 *txhpring;
  373. dma_addr_t txmapringdma;
  374. dma_addr_t txbkpringdma;
  375. dma_addr_t txbepringdma;
  376. dma_addr_t txvipringdma;
  377. dma_addr_t txvopringdma;
  378. dma_addr_t txhpringdma;
  379. u32 *txmapringtail;
  380. u32 *txbkpringtail;
  381. u32 *txbepringtail;
  382. u32 *txvipringtail;
  383. u32 *txvopringtail;
  384. u32 *txhpringtail;
  385. u32 *txmapringhead;
  386. u32 *txbkpringhead;
  387. u32 *txbepringhead;
  388. u32 *txvipringhead;
  389. u32 *txvopringhead;
  390. u32 *txhpringhead;
  391. struct buffer *txmapbufs;
  392. struct buffer *txbkpbufs;
  393. struct buffer *txbepbufs;
  394. struct buffer *txvipbufs;
  395. struct buffer *txvopbufs;
  396. struct buffer *txhpbufs;
  397. struct buffer *txmapbufstail;
  398. struct buffer *txbkpbufstail;
  399. struct buffer *txbepbufstail;
  400. struct buffer *txvipbufstail;
  401. struct buffer *txvopbufstail;
  402. struct buffer *txhpbufstail;
  403. int txringcount;
  404. int txbuffsize;
  405. //struct tx_pendingbuf txnp_pending;
  406. //struct tasklet_struct irq_tx_tasklet;
  407. struct tasklet_struct irq_rx_tasklet;
  408. u8 dma_poll_mask;
  409. //short tx_suspend;
  410. /* adhoc/master mode stuff */
  411. u32 *txbeaconringtail;
  412. dma_addr_t txbeaconringdma;
  413. u32 *txbeaconring;
  414. int txbeaconcount;
  415. struct buffer *txbeaconbufs;
  416. struct buffer *txbeaconbufstail;
  417. //char *master_essid;
  418. //u16 master_beaconinterval;
  419. //u32 master_beaconsize;
  420. //u16 beacon_interval;
  421. u8 retry_data;
  422. u8 retry_rts;
  423. u16 rts;
  424. //by amy for led
  425. LED_STRATEGY_8185 LedStrategy;
  426. //by amy for led
  427. //by amy for power save
  428. struct timer_list watch_dog_timer;
  429. bool bInactivePs;
  430. bool bSwRfProcessing;
  431. RT_RF_POWER_STATE eInactivePowerState;
  432. RT_RF_POWER_STATE eRFPowerState;
  433. u32 RfOffReason;
  434. bool RFChangeInProgress;
  435. bool bInHctTest;
  436. bool SetRFPowerStateInProgress;
  437. u8 RFProgType;
  438. bool bLeisurePs;
  439. RT_PS_MODE dot11PowerSaveMode;
  440. //u32 NumRxOkInPeriod; //YJ,del,080828
  441. //u32 NumTxOkInPeriod; //YJ,del,080828
  442. u8 TxPollingTimes;
  443. bool bApBufOurFrame;// TRUE if AP buffer our unicast data , we will keep eAwake until receive data or timeout.
  444. u8 WaitBufDataBcnCount;
  445. u8 WaitBufDataTimeOut;
  446. //by amy for power save
  447. //by amy for antenna
  448. u8 EEPROMSwAntennaDiversity;
  449. bool EEPROMDefaultAntenna1;
  450. u8 RegSwAntennaDiversityMechanism;
  451. bool bSwAntennaDiverity;
  452. u8 RegDefaultAntenna;
  453. bool bDefaultAntenna1;
  454. u8 SignalStrength;
  455. long Stats_SignalStrength;
  456. long LastSignalStrengthInPercent; // In percentange, used for smoothing, e.g. Moving Average.
  457. u8 SignalQuality; // in 0-100 index.
  458. long Stats_SignalQuality;
  459. long RecvSignalPower; // in dBm.
  460. long Stats_RecvSignalPower;
  461. u8 LastRxPktAntenna; // +by amy 080312 Antenn which received the lasted packet. 0: Aux, 1:Main. Added by Roger, 2008.01.25.
  462. u32 AdRxOkCnt;
  463. long AdRxSignalStrength;
  464. u8 CurrAntennaIndex; // Index to current Antenna (both Tx and Rx).
  465. u8 AdTickCount; // Times of SwAntennaDiversityTimer happened.
  466. u8 AdCheckPeriod; // # of period SwAntennaDiversityTimer to check Rx signal strength for SW Antenna Diversity.
  467. u8 AdMinCheckPeriod; // Min value of AdCheckPeriod.
  468. u8 AdMaxCheckPeriod; // Max value of AdCheckPeriod.
  469. long AdRxSsThreshold; // Signal strength threshold to switch antenna.
  470. long AdMaxRxSsThreshold; // Max value of AdRxSsThreshold.
  471. bool bAdSwitchedChecking; // TRUE if we shall shall check Rx signal strength for last time switching antenna.
  472. long AdRxSsBeforeSwitched; // Rx signal strength before we swithed antenna.
  473. struct timer_list SwAntennaDiversityTimer;
  474. //by amy for antenna
  475. //{by amy 080312
  476. //
  477. // Crystal calibration.
  478. // Added by Roger, 2007.12.11.
  479. //
  480. bool bXtalCalibration; // Crystal calibration.
  481. u8 XtalCal_Xin; // Crystal calibration for Xin. 0~7.5pF
  482. u8 XtalCal_Xout; // Crystal calibration for Xout. 0~7.5pF
  483. //
  484. // Tx power tracking with thermal meter indication.
  485. // Added by Roger, 2007.12.11.
  486. //
  487. bool bTxPowerTrack; // Tx Power tracking.
  488. u8 ThermalMeter; // Thermal meter reference indication.
  489. //
  490. // Dynamic Initial Gain Adjustment Mechanism. Added by Bruce, 2007-02-14.
  491. //
  492. bool bDigMechanism; // TRUE if DIG is enabled, FALSE ow.
  493. bool bRegHighPowerMechanism; // For High Power Mechanism. 061010, by rcnjko.
  494. u32 FalseAlarmRegValue;
  495. u8 RegDigOfdmFaUpTh; // Upper threhold of OFDM false alarm, which is used in DIG.
  496. u8 DIG_NumberFallbackVote;
  497. u8 DIG_NumberUpgradeVote;
  498. // For HW antenna diversity, added by Roger, 2008.01.30.
  499. u32 AdMainAntennaRxOkCnt; // Main antenna Rx OK count.
  500. u32 AdAuxAntennaRxOkCnt; // Aux antenna Rx OK count.
  501. bool bHWAdSwitched; // TRUE if we has switched default antenna by HW evaluation.
  502. // RF High Power upper/lower threshold.
  503. u8 RegHiPwrUpperTh;
  504. u8 RegHiPwrLowerTh;
  505. // RF RSSI High Power upper/lower Threshold.
  506. u8 RegRSSIHiPwrUpperTh;
  507. u8 RegRSSIHiPwrLowerTh;
  508. // Current CCK RSSI value to determine CCK high power, asked by SD3 DZ, by Bruce, 2007-04-12.
  509. u8 CurCCKRSSI;
  510. bool bCurCCKPkt;
  511. //
  512. // High Power Mechanism. Added by amy, 080312.
  513. //
  514. bool bToUpdateTxPwr;
  515. long UndecoratedSmoothedSS;
  516. long UndercorateSmoothedRxPower;
  517. u8 RSSI;
  518. char RxPower;
  519. u8 InitialGain;
  520. //For adjust Dig Threshold during Legacy/Leisure Power Save Mode
  521. u32 DozePeriodInPast2Sec;
  522. // Don't access BB/RF under disable PLL situation.
  523. u8 InitialGainBackUp;
  524. u8 RegBModeGainStage;
  525. //by amy for rate adaptive
  526. struct timer_list rateadapter_timer;
  527. u32 RateAdaptivePeriod;
  528. bool bEnhanceTxPwr;
  529. bool bUpdateARFR;
  530. int ForcedDataRate; // Force Data Rate. 0: Auto, 0x02: 1M ~ 0x6C: 54M.)
  531. u32 NumTxUnicast; //YJ,add,080828,for keep alive
  532. u8 keepAliveLevel; //YJ,add,080828,for KeepAlive
  533. unsigned long NumTxOkTotal;
  534. u16 LastRetryCnt;
  535. u16 LastRetryRate;
  536. unsigned long LastTxokCnt;
  537. unsigned long LastRxokCnt;
  538. u16 CurrRetryCnt;
  539. unsigned long LastTxOKBytes;
  540. unsigned long NumTxOkBytesTotal;
  541. u8 LastFailTxRate;
  542. long LastFailTxRateSS;
  543. u8 FailTxRateCount;
  544. u32 LastTxThroughput;
  545. //for up rate
  546. unsigned short bTryuping;
  547. u8 CurrTxRate; //the rate before up
  548. u16 CurrRetryRate;
  549. u16 TryupingCount;
  550. u8 TryDownCountLowData;
  551. u8 TryupingCountNoData;
  552. u8 CurrentOperaRate;
  553. //by amy for rate adaptive
  554. //by amy 080312}
  555. // short wq_hurryup;
  556. // struct workqueue_struct *workqueue;
  557. struct work_struct reset_wq;
  558. struct work_struct watch_dog_wq;
  559. struct work_struct tx_irq_wq;
  560. short ack_tx_to_ieee;
  561. u8 PowerProfile;
  562. u32 CSMethod;
  563. u8 cck_txpwr_base;
  564. u8 ofdm_txpwr_base;
  565. u8 dma_poll_stop_mask;
  566. //u8 RegThreeWireMode;
  567. u8 MWIEnable;
  568. u16 ShortRetryLimit;
  569. u16 LongRetryLimit;
  570. u16 EarlyRxThreshold;
  571. u32 TransmitConfig;
  572. u32 ReceiveConfig;
  573. u32 IntrMask;
  574. struct ChnlAccessSetting ChannelAccessSetting;
  575. }r8180_priv;
  576. #define MANAGE_PRIORITY 0
  577. #define BK_PRIORITY 1
  578. #define BE_PRIORITY 2
  579. #define VI_PRIORITY 3
  580. #define VO_PRIORITY 4
  581. #define HI_PRIORITY 5
  582. #define BEACON_PRIORITY 6
  583. #define LOW_PRIORITY VI_PRIORITY
  584. #define NORM_PRIORITY VO_PRIORITY
  585. //AC2Queue mapping
  586. #define AC2Q(_ac) (((_ac) == WME_AC_VO) ? VO_PRIORITY : \
  587. ((_ac) == WME_AC_VI) ? VI_PRIORITY : \
  588. ((_ac) == WME_AC_BK) ? BK_PRIORITY : \
  589. BE_PRIORITY)
  590. short rtl8180_tx(struct net_device *dev,u8* skbuf, int len,int priority,
  591. short morefrag,short fragdesc,int rate);
  592. u8 read_nic_byte(struct net_device *dev, int x);
  593. u32 read_nic_dword(struct net_device *dev, int x);
  594. u16 read_nic_word(struct net_device *dev, int x) ;
  595. void write_nic_byte(struct net_device *dev, int x,u8 y);
  596. void write_nic_word(struct net_device *dev, int x,u16 y);
  597. void write_nic_dword(struct net_device *dev, int x,u32 y);
  598. void force_pci_posting(struct net_device *dev);
  599. void rtl8180_rtx_disable(struct net_device *);
  600. void rtl8180_rx_enable(struct net_device *);
  601. void rtl8180_tx_enable(struct net_device *);
  602. void rtl8180_start_scanning(struct net_device *dev);
  603. void rtl8180_start_scanning_s(struct net_device *dev);
  604. void rtl8180_stop_scanning(struct net_device *dev);
  605. void rtl8180_disassociate(struct net_device *dev);
  606. //void fix_rx_fifo(struct net_device *dev);
  607. void rtl8180_set_anaparam(struct net_device *dev,u32 a);
  608. void rtl8185_set_anaparam2(struct net_device *dev,u32 a);
  609. void rtl8180_set_hw_wep(struct net_device *dev);
  610. void rtl8180_no_hw_wep(struct net_device *dev);
  611. void rtl8180_update_msr(struct net_device *dev);
  612. //void rtl8180_BSS_create(struct net_device *dev);
  613. void rtl8180_beacon_tx_disable(struct net_device *dev);
  614. void rtl8180_beacon_rx_disable(struct net_device *dev);
  615. void rtl8180_conttx_enable(struct net_device *dev);
  616. void rtl8180_conttx_disable(struct net_device *dev);
  617. int rtl8180_down(struct net_device *dev);
  618. int rtl8180_up(struct net_device *dev);
  619. void rtl8180_commit(struct net_device *dev);
  620. void rtl8180_set_chan(struct net_device *dev,short ch);
  621. void rtl8180_set_master_essid(struct net_device *dev,char *essid);
  622. void rtl8180_update_beacon_security(struct net_device *dev);
  623. void write_phy(struct net_device *dev, u8 adr, u8 data);
  624. void write_phy_cck(struct net_device *dev, u8 adr, u32 data);
  625. void write_phy_ofdm(struct net_device *dev, u8 adr, u32 data);
  626. void rtl8185_tx_antenna(struct net_device *dev, u8 ant);
  627. void rtl8185_rf_pins_enable(struct net_device *dev);
  628. void IBSS_randomize_cell(struct net_device *dev);
  629. void IPSEnter(struct net_device *dev);
  630. void IPSLeave(struct net_device *dev);
  631. int get_curr_tx_free_desc(struct net_device *dev, int priority);
  632. void UpdateInitialGain(struct net_device *dev);
  633. bool SetAntennaConfig87SE(struct net_device *dev, u8 DefaultAnt, bool bAntDiversity);
  634. //#ifdef CONFIG_RTL8185B
  635. void rtl8185b_adapter_start(struct net_device *dev);
  636. void rtl8185b_rx_enable(struct net_device *dev);
  637. void rtl8185b_tx_enable(struct net_device *dev);
  638. void rtl8180_reset(struct net_device *dev);
  639. void rtl8185b_irq_enable(struct net_device *dev);
  640. void fix_rx_fifo(struct net_device *dev);
  641. void fix_tx_fifo(struct net_device *dev);
  642. void rtl8225z2_SetTXPowerLevel(struct net_device *dev, short ch);
  643. void rtl8180_rate_adapter(struct work_struct * work);
  644. //#endif
  645. bool MgntActSet_RF_State(struct net_device *dev, RT_RF_POWER_STATE StateToSet, u32 ChangeSource);
  646. #endif