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