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