7d18d05039d23d3d8be4ceac51f0ab40ef7b3851
[pandora-kernel.git] / drivers / staging / rtl8192e / rtl8192e / rtl_core.h
1 /******************************************************************************
2  * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved.
3  *
4  * Based on the r8180 driver, which is:
5  * Copyright 2004-2005 Andrea Merello <andrea.merello@gmail.com>, et al.
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms of version 2 of the GNU General Public License as
8  * published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU General Public License along with
16  * this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
18  *
19  * The full GNU General Public License is included in this distribution in the
20  * file called LICENSE.
21  *
22  * Contact Information:
23  * wlanfae <wlanfae@realtek.com>
24 ******************************************************************************/
25
26 #ifndef _RTL_CORE_H
27 #define _RTL_CORE_H
28
29 #include <linux/module.h>
30 #include <linux/kernel.h>
31 #include <linux/ioport.h>
32 #include <linux/sched.h>
33 #include <linux/types.h>
34 #include <linux/interrupt.h>
35 #include <linux/slab.h>
36 #include <linux/netdevice.h>
37 #include <linux/pci.h>
38 #include <linux/etherdevice.h>
39 #include <linux/delay.h>
40 #include <linux/rtnetlink.h>
41 #include <linux/wireless.h>
42 #include <linux/timer.h>
43 #include <linux/proc_fs.h>
44 #include <linux/if_arp.h>
45 #include <linux/random.h>
46 #include <linux/io.h>
47
48 /* Need this defined before including local include files */
49 #define DRV_NAME "rtl819xE"
50
51 #include "../rtllib.h"
52
53 #include "../dot11d.h"
54
55 #include "r8192E_firmware.h"
56 #include "r8192E_hw.h"
57
58 #include "r8190P_def.h"
59 #include "r8192E_dev.h"
60
61 #include "rtl_eeprom.h"
62 #include "rtl_ps.h"
63 #include "rtl_pci.h"
64 #include "rtl_cam.h"
65
66 #define DRV_COPYRIGHT           \
67         "Copyright(c) 2008 - 2010 Realsil Semiconductor Corporation"
68 #define DRV_AUTHOR  "<wlanfae@realtek.com>"
69 #define DRV_VERSION  "0014.0401.2010"
70
71 #define IS_HARDWARE_TYPE_8192SE(_priv)          \
72         (((struct r8192_priv *)rtllib_priv(dev))->card_8192 == NIC_8192SE)
73
74 #define RTL_PCI_DEVICE(vend, dev, cfg) \
75         .vendor = (vend), .device = (dev), \
76         .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, \
77         .driver_data = (kernel_ulong_t)&(cfg)
78
79 #define TOTAL_CAM_ENTRY         32
80 #define CAM_CONTENT_COUNT       8
81
82 #define HAL_HW_PCI_REVISION_ID_8192PCIE         0x01
83 #define HAL_HW_PCI_REVISION_ID_8192SE   0x10
84
85 #define RTL819X_DEFAULT_RF_TYPE         RF_1T2R
86
87 #define RTLLIB_WATCH_DOG_TIME           2000
88
89 #define MAX_DEV_ADDR_SIZE               8  /*support till 64 bit bus width OS*/
90 #define MAX_FIRMWARE_INFORMATION_SIZE   32
91 #define MAX_802_11_HEADER_LENGTH        (40 + MAX_FIRMWARE_INFORMATION_SIZE)
92 #define ENCRYPTION_MAX_OVERHEAD         128
93 #define MAX_FRAGMENT_COUNT              8
94 #define MAX_TRANSMIT_BUFFER_SIZE        \
95         (1600 + (MAX_802_11_HEADER_LENGTH + ENCRYPTION_MAX_OVERHEAD) *  \
96          MAX_FRAGMENT_COUNT)
97
98 #define DEFAULT_FRAG_THRESHOLD  2342U
99 #define MIN_FRAG_THRESHOLD      256U
100 #define DEFAULT_BEACONINTERVAL  0x64U
101
102 #define DEFAULT_RETRY_RTS       7
103 #define DEFAULT_RETRY_DATA      7
104
105 #define PHY_RSSI_SLID_WIN_MAX                   100
106
107 #define RTL_IOCTL_WPA_SUPPLICANT                (SIOCIWFIRSTPRIV + 30)
108
109 #define TxBBGainTableLength                     37
110 #define CCKTxBBGainTableLength                  23
111
112 #define CHANNEL_PLAN_LEN                        10
113 #define sCrcLng                                 4
114
115 #define NIC_SEND_HANG_THRESHOLD_NORMAL          4
116 #define NIC_SEND_HANG_THRESHOLD_POWERSAVE       8
117
118 #define MAX_TX_QUEUE                            9
119
120 #define MAX_RX_QUEUE                            1
121
122 #define MAX_RX_COUNT                            64
123 #define MAX_TX_QUEUE_COUNT                      9
124
125 extern int hwwep;
126
127 enum nic_t {
128         NIC_UNKNOWN     = 0,
129         NIC_8192E       = 1,
130         NIC_8190P       = 2,
131         NIC_8192SE      = 4,
132         NIC_8192CE      = 5,
133         NIC_8192CU      = 6,
134         NIC_8192DE      = 7,
135         NIC_8192DU      = 8,
136 };
137
138 enum rt_eeprom_type {
139         EEPROM_93C46,
140         EEPROM_93C56,
141 };
142
143 enum dcmg_txcmd_op {
144         TXCMD_TXRA_HISTORY_CTRL         = 0xFF900000,
145         TXCMD_RESET_TX_PKT_BUFF         = 0xFF900001,
146         TXCMD_RESET_RX_PKT_BUFF         = 0xFF900002,
147         TXCMD_SET_TX_DURATION           = 0xFF900003,
148         TXCMD_SET_RX_RSSI               = 0xFF900004,
149         TXCMD_SET_TX_PWR_TRACKING       = 0xFF900005,
150         TXCMD_XXXX_CTRL,
151 };
152
153 enum rt_rf_type_819xu {
154         RF_TYPE_MIN = 0,
155         RF_8225,
156         RF_8256,
157         RF_8258,
158         RF_6052 = 4,
159         RF_PSEUDO_11N = 5,
160 };
161
162 enum rt_customer_id {
163         RT_CID_DEFAULT    = 0,
164         RT_CID_8187_ALPHA0      = 1,
165         RT_CID_8187_SERCOMM_PS  = 2,
166         RT_CID_8187_HW_LED      = 3,
167         RT_CID_8187_NETGEAR     = 4,
168         RT_CID_WHQL          = 5,
169         RT_CID_819x_CAMEO       = 6,
170         RT_CID_819x_RUNTOP      = 7,
171         RT_CID_819x_Senao       = 8,
172         RT_CID_TOSHIBA    = 9,
173         RT_CID_819x_Netcore     = 10,
174         RT_CID_Nettronix        = 11,
175         RT_CID_DLINK        = 12,
176         RT_CID_PRONET      = 13,
177         RT_CID_COREGA      = 14,
178         RT_CID_819x_ALPHA       = 15,
179         RT_CID_819x_Sitecom     = 16,
180         RT_CID_CCX            = 17,
181         RT_CID_819x_Lenovo      = 18,
182         RT_CID_819x_QMI  = 19,
183         RT_CID_819x_Edimax_Belkin = 20,
184         RT_CID_819x_Sercomm_Belkin = 21,
185         RT_CID_819x_CAMEO1 = 22,
186         RT_CID_819x_MSI = 23,
187         RT_CID_819x_Acer = 24,
188         RT_CID_819x_HP  = 27,
189         RT_CID_819x_CLEVO = 28,
190         RT_CID_819x_Arcadyan_Belkin = 29,
191         RT_CID_819x_SAMSUNG = 30,
192         RT_CID_819x_WNC_COREGA = 31,
193 };
194
195 enum reset_type {
196         RESET_TYPE_NORESET = 0x00,
197         RESET_TYPE_NORMAL = 0x01,
198         RESET_TYPE_SILENT = 0x02
199 };
200
201 struct rt_stats {
202         unsigned long txrdu;
203         unsigned long rxrdu;
204         unsigned long rxok;
205         unsigned long rxframgment;
206         unsigned long rxurberr;
207         unsigned long rxstaterr;
208         unsigned long rxdatacrcerr;
209         unsigned long rxmgmtcrcerr;
210         unsigned long rxcrcerrmin;
211         unsigned long rxcrcerrmid;
212         unsigned long rxcrcerrmax;
213         unsigned long received_rate_histogram[4][32];
214         unsigned long received_preamble_GI[2][32];
215         unsigned long   rx_AMPDUsize_histogram[5];
216         unsigned long rx_AMPDUnum_histogram[5];
217         unsigned long numpacket_matchbssid;
218         unsigned long numpacket_toself;
219         unsigned long num_process_phyinfo;
220         unsigned long numqry_phystatus;
221         unsigned long numqry_phystatusCCK;
222         unsigned long numqry_phystatusHT;
223         unsigned long received_bwtype[5];
224         unsigned long txnperr;
225         unsigned long txnpdrop;
226         unsigned long txresumed;
227         unsigned long rxoverflow;
228         unsigned long rxint;
229         unsigned long txnpokint;
230         unsigned long ints;
231         unsigned long shints;
232         unsigned long txoverflow;
233         unsigned long txlpokint;
234         unsigned long txlpdrop;
235         unsigned long txlperr;
236         unsigned long txbeokint;
237         unsigned long txbedrop;
238         unsigned long txbeerr;
239         unsigned long txbkokint;
240         unsigned long txbkdrop;
241         unsigned long txbkerr;
242         unsigned long txviokint;
243         unsigned long txvidrop;
244         unsigned long txvierr;
245         unsigned long txvookint;
246         unsigned long txvodrop;
247         unsigned long txvoerr;
248         unsigned long txbeaconokint;
249         unsigned long txbeacondrop;
250         unsigned long txbeaconerr;
251         unsigned long txmanageokint;
252         unsigned long txmanagedrop;
253         unsigned long txmanageerr;
254         unsigned long txcmdpktokint;
255         unsigned long txdatapkt;
256         unsigned long txfeedback;
257         unsigned long txfeedbackok;
258         unsigned long txoktotal;
259         unsigned long txokbytestotal;
260         unsigned long txokinperiod;
261         unsigned long txmulticast;
262         unsigned long txbytesmulticast;
263         unsigned long txbroadcast;
264         unsigned long txbytesbroadcast;
265         unsigned long txunicast;
266         unsigned long txbytesunicast;
267         unsigned long rxbytesunicast;
268         unsigned long txfeedbackfail;
269         unsigned long txerrtotal;
270         unsigned long txerrbytestotal;
271         unsigned long txerrmulticast;
272         unsigned long txerrbroadcast;
273         unsigned long txerrunicast;
274         unsigned long txretrycount;
275         unsigned long txfeedbackretry;
276         u8      last_packet_rate;
277         unsigned long slide_signal_strength[100];
278         unsigned long slide_evm[100];
279         unsigned long   slide_rssi_total;
280         unsigned long slide_evm_total;
281         long signal_strength;
282         long signal_quality;
283         long last_signal_strength_inpercent;
284         long    recv_signal_power;
285         u8 rx_rssi_percentage[4];
286         u8 rx_evm_percentage[2];
287         long rxSNRdB[4];
288         u32 Slide_Beacon_pwdb[100];
289         u32 Slide_Beacon_Total;
290         u32     CurrentShowTxate;
291 };
292
293 struct channel_access_setting {
294         u16 SIFS_Timer;
295         u16 DIFS_Timer;
296         u16 SlotTimeTimer;
297         u16 EIFS_Timer;
298         u16 CWminIndex;
299         u16 CWmaxIndex;
300 };
301
302 struct init_gain {
303         u8      xaagccore1;
304         u8      xbagccore1;
305         u8      xcagccore1;
306         u8      xdagccore1;
307         u8      cca;
308
309 };
310
311 struct tx_ring {
312         u32 *desc;
313         u8 nStuckCount;
314         struct tx_ring *next;
315 } __packed;
316
317 struct rtl8192_tx_ring {
318         struct tx_desc *desc;
319         dma_addr_t dma;
320         unsigned int idx;
321         unsigned int entries;
322         struct sk_buff_head queue;
323 };
324
325
326
327 struct rtl819x_ops {
328         enum nic_t nic_type;
329         void (*get_eeprom_size)(struct net_device *dev);
330         void (*init_adapter_variable)(struct net_device *dev);
331         void (*init_before_adapter_start)(struct net_device *dev);
332         bool (*initialize_adapter)(struct net_device *dev);
333         void (*link_change)(struct net_device *dev);
334         void (*tx_fill_descriptor)(struct net_device *dev,
335                                    struct tx_desc *tx_desc,
336                                    struct cb_desc *cb_desc,
337                                    struct sk_buff *skb);
338         void (*tx_fill_cmd_descriptor)(struct net_device *dev,
339                                        struct tx_desc_cmd *entry,
340                                        struct cb_desc *cb_desc,
341                                        struct sk_buff *skb);
342         bool (*rx_query_status_descriptor)(struct net_device *dev,
343                                            struct rtllib_rx_stats *stats,
344                                            struct rx_desc *pdesc,
345                                            struct sk_buff *skb);
346         bool (*rx_command_packet_handler)(struct net_device *dev,
347                                           struct sk_buff *skb,
348                                           struct rx_desc *pdesc);
349         void (*stop_adapter)(struct net_device *dev, bool reset);
350         void (*update_ratr_table)(struct net_device *dev);
351         void (*irq_enable)(struct net_device *dev);
352         void (*irq_disable)(struct net_device *dev);
353         void (*irq_clear)(struct net_device *dev);
354         void (*rx_enable)(struct net_device *dev);
355         void (*tx_enable)(struct net_device *dev);
356         void (*interrupt_recognized)(struct net_device *dev,
357                                      u32 *p_inta, u32 *p_intb);
358         bool (*TxCheckStuckHandler)(struct net_device *dev);
359         bool (*RxCheckStuckHandler)(struct net_device *dev);
360 };
361
362 struct r8192_priv {
363         struct pci_dev *pdev;
364         struct pci_dev *bridge_pdev;
365
366         bool            bfirst_init;
367         bool            bfirst_after_down;
368         bool            initialized_at_probe;
369         bool            being_init_adapter;
370         bool            bDriverIsGoingToUnload;
371
372         int             irq;
373         short   irq_enabled;
374
375         short   up;
376         short   up_first_time;
377         struct delayed_work             update_beacon_wq;
378         struct delayed_work             watch_dog_wq;
379         struct delayed_work             txpower_tracking_wq;
380         struct delayed_work             rfpath_check_wq;
381         struct delayed_work             gpio_change_rf_wq;
382         struct delayed_work             initialgain_operate_wq;
383         struct delayed_work             check_hw_scan_wq;
384         struct delayed_work             hw_scan_simu_wq;
385         struct delayed_work             start_hw_scan_wq;
386
387         struct workqueue_struct         *priv_wq;
388
389         struct channel_access_setting ChannelAccessSetting;
390
391         struct mp_adapter NdisAdapter;
392
393         struct rtl819x_ops                      *ops;
394         struct rtllib_device                    *rtllib;
395
396         struct work_struct                              reset_wq;
397
398         struct log_int_8190 InterruptLog;
399
400         enum rt_customer_id CustomerID;
401
402
403         enum rt_rf_type_819xu rf_chip;
404         enum ht_channel_width CurrentChannelBW;
405         struct bb_reg_definition PHYRegDef[4];
406         struct rate_adaptive rate_adaptive;
407
408         enum acm_method AcmMethod;
409
410         struct rt_firmware                      *pFirmware;
411         enum rtl819x_loopback LoopbackMode;
412
413         struct timer_list                       watch_dog_timer;
414         struct timer_list                       fsync_timer;
415         struct timer_list                       gpio_polling_timer;
416
417         spinlock_t                              fw_scan_lock;
418         spinlock_t                              irq_lock;
419         spinlock_t                              irq_th_lock;
420         spinlock_t                              tx_lock;
421         spinlock_t                              rf_ps_lock;
422         spinlock_t                              rw_lock;
423         spinlock_t                              rt_h2c_lock;
424         spinlock_t                              rf_lock;
425         spinlock_t                              ps_lock;
426
427         struct sk_buff_head             rx_queue;
428         struct sk_buff_head             skb_queue;
429
430         struct tasklet_struct           irq_rx_tasklet;
431         struct tasklet_struct           irq_tx_tasklet;
432         struct tasklet_struct           irq_prepare_beacon_tasklet;
433
434         struct semaphore                        wx_sem;
435         struct semaphore                        rf_sem;
436         struct mutex                            mutex;
437
438         struct rt_stats stats;
439         struct iw_statistics                    wstats;
440         struct proc_dir_entry           *dir_dev;
441
442         short (*rf_set_sens)(struct net_device *dev, short sens);
443         u8 (*rf_set_chan)(struct net_device *dev, u8 ch);
444         void (*rf_close)(struct net_device *dev);
445         void (*rf_init)(struct net_device *dev);
446
447         struct rx_desc *rx_ring[MAX_RX_QUEUE];
448         struct sk_buff  *rx_buf[MAX_RX_QUEUE][MAX_RX_COUNT];
449         dma_addr_t      rx_ring_dma[MAX_RX_QUEUE];
450         unsigned int    rx_idx[MAX_RX_QUEUE];
451         int             rxringcount;
452         u16             rxbuffersize;
453
454         u64             LastRxDescTSF;
455
456         u16             EarlyRxThreshold;
457         u32             ReceiveConfig;
458         u8              AcmControl;
459         u8              RFProgType;
460         u8              retry_data;
461         u8              retry_rts;
462         u16             rts;
463
464         struct rtl8192_tx_ring tx_ring[MAX_TX_QUEUE_COUNT];
465         int              txringcount;
466         int             txbuffsize;
467         int             txfwbuffersize;
468         atomic_t        tx_pending[0x10];
469
470         u16             ShortRetryLimit;
471         u16             LongRetryLimit;
472         u32             TransmitConfig;
473         u8              RegCWinMin;
474         u8              keepAliveLevel;
475
476         bool            bHwRadioOff;
477         bool            pwrdown;
478         bool            blinked_ingpio;
479         u8              polling_timer_on;
480
481         /**********************************************************/
482
483         enum card_type {
484                 PCI, MINIPCI,
485                 CARDBUS, USB
486         } card_type;
487
488         struct work_struct qos_activate;
489
490         u8 bIbssCoordinator;
491
492         short   promisc;
493         short   crcmon;
494
495         int txbeaconcount;
496
497         short   chan;
498         short   sens;
499         short   max_sens;
500         u32 rx_prevlen;
501
502         u8 ScanDelay;
503         bool ps_force;
504
505         u32 irq_mask[2];
506
507         u8 Rf_Mode;
508         enum nic_t card_8192;
509         u8 card_8192_version;
510
511         short   enable_gpio0;
512
513         u8 rf_type;
514         u8 IC_Cut;
515         char nick[IW_ESSID_MAX_SIZE + 1];
516
517         u8 RegBcnCtrlVal;
518         bool bHwAntDiv;
519
520         bool bTKIPinNmodeFromReg;
521         bool bWEPinNmodeFromReg;
522
523         bool bLedOpenDrain;
524
525         u8 check_roaming_cnt;
526
527         bool bIgnoreSilentReset;
528         u32 SilentResetRxSoltNum;
529         u32 SilentResetRxSlotIndex;
530         u32 SilentResetRxStuckEvent[MAX_SILENT_RESET_RX_SLOT_NUM];
531
532         void *scan_cmd;
533         u8 hwscan_bw_40;
534
535         u16 nrxAMPDU_size;
536         u8 nrxAMPDU_aggr_num;
537
538         u32 last_rxdesc_tsf_high;
539         u32 last_rxdesc_tsf_low;
540
541         u16 basic_rate;
542         u8 short_preamble;
543         u8 dot11CurrentPreambleMode;
544         u8 slot_time;
545         u16 SifsTime;
546
547         u8 RegWirelessMode;
548
549         u8 firmware_version;
550         u16 FirmwareSubVersion;
551         u16 rf_pathmap;
552         bool AutoloadFailFlag;
553
554         u8 RegPciASPM;
555         u8 RegAMDPciASPM;
556         u8 RegHwSwRfOffD3;
557         u8 RegSupportPciASPM;
558         bool bSupportASPM;
559
560         u32 RfRegChnlVal[2];
561
562         u8 ShowRateMode;
563         u8 RATRTableBitmap;
564
565         u8 EfuseMap[2][HWSET_MAX_SIZE_92S];
566         u16 EfuseUsedBytes;
567         u8 EfuseUsedPercentage;
568
569         short   epromtype;
570         u16 eeprom_vid;
571         u16 eeprom_did;
572         u16 eeprom_svid;
573         u16 eeprom_smid;
574         u8 eeprom_CustomerID;
575         u16 eeprom_ChannelPlan;
576         u8 eeprom_version;
577
578         u8 EEPROMRegulatory;
579         u8 EEPROMPwrGroup[2][3];
580         u8 EEPROMOptional;
581
582         u8 EEPROMTxPowerLevelCCK[14];
583         u8 EEPROMTxPowerLevelOFDM24G[14];
584         u8 EEPROMTxPowerLevelOFDM5G[24];
585         u8 EEPROMRfACCKChnl1TxPwLevel[3];
586         u8 EEPROMRfAOfdmChnlTxPwLevel[3];
587         u8 EEPROMRfCCCKChnl1TxPwLevel[3];
588         u8 EEPROMRfCOfdmChnlTxPwLevel[3];
589         u16 EEPROMTxPowerDiff;
590         u16 EEPROMAntPwDiff;
591         u8 EEPROMThermalMeter;
592         u8 EEPROMPwDiff;
593         u8 EEPROMCrystalCap;
594
595         u8 EEPROMBluetoothCoexist;
596         u8 EEPROMBluetoothType;
597         u8 EEPROMBluetoothAntNum;
598         u8 EEPROMBluetoothAntIsolation;
599         u8 EEPROMBluetoothRadioShared;
600
601
602         u8 EEPROMSupportWoWLAN;
603         u8 EEPROMBoardType;
604         u8 EEPROM_Def_Ver;
605         u8 EEPROMHT2T_TxPwr[6];
606         u8 EEPROMTSSI_A;
607         u8 EEPROMTSSI_B;
608         u8 EEPROMTxPowerLevelCCK_V1[3];
609         u8 EEPROMLegacyHTTxPowerDiff;
610
611         u8 BluetoothCoexist;
612
613         u8 CrystalCap;
614         u8 ThermalMeter[2];
615
616         u16 FwCmdIOMap;
617         u32 FwCmdIOParam;
618
619         u8 SwChnlInProgress;
620         u8 SwChnlStage;
621         u8 SwChnlStep;
622         u8 SetBWModeInProgress;
623
624         u8 nCur40MhzPrimeSC;
625
626         u32 RfReg0Value[4];
627         u8 NumTotalRFPath;
628         bool brfpath_rxenable[4];
629
630         bool bTXPowerDataReadFromEEPORM;
631
632         u16 RegChannelPlan;
633         u16 ChannelPlan;
634         bool bChnlPlanFromHW;
635
636         bool RegRfOff;
637         bool isRFOff;
638         bool bInPowerSaveMode;
639         u8 bHwRfOffAction;
640
641         bool aspm_clkreq_enable;
642         u8 RegHostPciASPMSetting;
643         u8 RegDevicePciASPMSetting;
644
645         bool RFChangeInProgress;
646         bool SetRFPowerStateInProgress;
647         bool bdisable_nic;
648
649         u8 pwrGroupCnt;
650
651         u8 ThermalValue_LCK;
652         u8 ThermalValue_IQK;
653         bool bRfPiEnable;
654
655         u32 APKoutput[2][2];
656         bool bAPKdone;
657
658         long RegE94;
659         long RegE9C;
660         long RegEB4;
661         long RegEBC;
662
663         u32 RegC04;
664         u32 Reg874;
665         u32 RegC08;
666         u32 ADDA_backup[16];
667         u32 IQK_MAC_backup[3];
668
669         bool SetFwCmdInProgress;
670         u8 CurrentFwCmdIO;
671
672         u8 rssi_level;
673
674         bool bInformFWDriverControlDM;
675         u8 PwrGroupHT20[2][14];
676         u8 PwrGroupHT40[2][14];
677
678         u8 ThermalValue;
679         long EntryMinUndecoratedSmoothedPWDB;
680         long EntryMaxUndecoratedSmoothedPWDB;
681         u8 DynamicTxHighPowerLvl;
682         u8 LastDTPLvl;
683         u32 CurrentRATR0;
684         struct false_alarm_stats FalseAlmCnt;
685
686         u8 DMFlag;
687         u8 DM_Type;
688
689         u8 CckPwEnl;
690         u16 TSSI_13dBm;
691         u32 Pwr_Track;
692         u8 CCKPresentAttentuation_20Mdefault;
693         u8 CCKPresentAttentuation_40Mdefault;
694         char CCKPresentAttentuation_difference;
695         char CCKPresentAttentuation;
696         u8 bCckHighPower;
697         long undecorated_smoothed_pwdb;
698         long undecorated_smoothed_cck_adc_pwdb[4];
699
700         u32 MCSTxPowerLevelOriginalOffset[6];
701         u32 CCKTxPowerLevelOriginalOffset;
702         u8 TxPowerLevelCCK[14];
703         u8 TxPowerLevelCCK_A[14];
704         u8 TxPowerLevelCCK_C[14];
705         u8              TxPowerLevelOFDM24G[14];
706         u8              TxPowerLevelOFDM5G[14];
707         u8              TxPowerLevelOFDM24G_A[14];
708         u8              TxPowerLevelOFDM24G_C[14];
709         u8              LegacyHTTxPowerDiff;
710         u8              TxPowerDiff;
711         s8              RF_C_TxPwDiff;
712         s8              RF_B_TxPwDiff;
713         u8              RfTxPwrLevelCck[2][14];
714         u8              RfTxPwrLevelOfdm1T[2][14];
715         u8              RfTxPwrLevelOfdm2T[2][14];
716         u8              AntennaTxPwDiff[3];
717         u8              TxPwrHt20Diff[2][14];
718         u8              TxPwrLegacyHtDiff[2][14];
719         u8              TxPwrSafetyFlag;
720         u8              HT2T_TxPwr_A[14];
721         u8              HT2T_TxPwr_B[14];
722         u8              CurrentCckTxPwrIdx;
723         u8              CurrentOfdm24GTxPwrIdx;
724
725         bool            bdynamic_txpower;
726         bool            bDynamicTxHighPower;
727         bool            bDynamicTxLowPower;
728         bool            bLastDTPFlag_High;
729         bool            bLastDTPFlag_Low;
730
731         bool            bstore_last_dtpflag;
732         bool            bstart_txctrl_bydtp;
733
734         u8              rfa_txpowertrackingindex;
735         u8              rfa_txpowertrackingindex_real;
736         u8              rfa_txpowertracking_default;
737         u8              rfc_txpowertrackingindex;
738         u8              rfc_txpowertrackingindex_real;
739         u8              rfc_txpowertracking_default;
740         bool            btxpower_tracking;
741         bool            bcck_in_ch14;
742
743         u8              TxPowerTrackControl;
744         u8              txpower_count;
745         bool            btxpower_trackingInit;
746
747         u8              OFDM_index[2];
748         u8              CCK_index;
749
750         u8              Record_CCK_20Mindex;
751         u8              Record_CCK_40Mindex;
752
753         struct init_gain initgain_backup;
754         u8              DefaultInitialGain[4];
755         bool            bis_any_nonbepkts;
756         bool            bcurrent_turbo_EDCA;
757         bool            bis_cur_rdlstate;
758
759         bool            bCCKinCH14;
760
761         u8              MidHighPwrTHR_L1;
762         u8              MidHighPwrTHR_L2;
763
764         bool            bfsync_processing;
765         u32             rate_record;
766         u32             rateCountDiffRecord;
767         u32             ContinueDiffCount;
768         bool            bswitch_fsync;
769         u8              framesync;
770         u32             framesyncC34;
771         u8              framesyncMonitor;
772
773         bool            bDMInitialGainEnable;
774         bool            MutualAuthenticationFail;
775
776         bool            bDisableFrameBursting;
777
778         u32             reset_count;
779         bool            bpbc_pressed;
780
781         u32             txpower_checkcnt;
782         u32             txpower_tracking_callback_cnt;
783         u8              thermal_read_val[40];
784         u8              thermal_readback_index;
785         u32             ccktxpower_adjustcnt_not_ch14;
786         u32             ccktxpower_adjustcnt_ch14;
787
788         enum reset_type ResetProgress;
789         bool            bForcedSilentReset;
790         bool            bDisableNormalResetCheck;
791         u16             TxCounter;
792         u16             RxCounter;
793         int             IrpPendingCount;
794         bool            bResetInProgress;
795         bool            force_reset;
796         bool            force_lps;
797         u8              InitialGainOperateType;
798
799         bool            chan_forced;
800         bool            bSingleCarrier;
801         bool            RegBoard;
802         bool            bCckContTx;
803         bool            bOfdmContTx;
804         bool            bStartContTx;
805         u8              RegPaModel;
806         u8              btMpCckTxPower;
807         u8              btMpOfdmTxPower;
808
809         u32             MptActType;
810         u32             MptIoOffset;
811         u32             MptIoValue;
812         u32             MptRfPath;
813
814         u32             MptBandWidth;
815         u32             MptRateIndex;
816         u8              MptChannelToSw;
817         u32     MptRCR;
818
819         u8              PwrDomainProtect;
820         u8              H2CTxCmdSeq;
821
822
823 };
824
825 extern const struct ethtool_ops rtl819x_ethtool_ops;
826
827 void rtl8192_tx_cmd(struct net_device *dev, struct sk_buff *skb);
828 short rtl8192_tx(struct net_device *dev, struct sk_buff *skb);
829
830 u8 read_nic_io_byte(struct net_device *dev, int x);
831 u32 read_nic_io_dword(struct net_device *dev, int x);
832 u16 read_nic_io_word(struct net_device *dev, int x);
833 void write_nic_io_byte(struct net_device *dev, int x, u8 y);
834 void write_nic_io_word(struct net_device *dev, int x, u16 y);
835 void write_nic_io_dword(struct net_device *dev, int x, u32 y);
836
837 u8 read_nic_byte(struct net_device *dev, int x);
838 u32 read_nic_dword(struct net_device *dev, int x);
839 u16 read_nic_word(struct net_device *dev, int x);
840 void write_nic_byte(struct net_device *dev, int x, u8 y);
841 void write_nic_word(struct net_device *dev, int x, u16 y);
842 void write_nic_dword(struct net_device *dev, int x, u32 y);
843
844 void force_pci_posting(struct net_device *dev);
845
846 void rtl8192_rx_enable(struct net_device *);
847 void rtl8192_tx_enable(struct net_device *);
848
849 int rtl8192_hard_start_xmit(struct sk_buff *skb, struct net_device *dev);
850 void rtl8192_hard_data_xmit(struct sk_buff *skb, struct net_device *dev,
851                             int rate);
852 void rtl8192_data_hard_stop(struct net_device *dev);
853 void rtl8192_data_hard_resume(struct net_device *dev);
854 void rtl8192_restart(void *data);
855 void rtl819x_watchdog_wqcallback(void *data);
856 void rtl8192_hw_sleep_wq(void *data);
857 void watch_dog_timer_callback(unsigned long data);
858 void rtl8192_irq_rx_tasklet(struct r8192_priv *priv);
859 void rtl8192_irq_tx_tasklet(struct r8192_priv *priv);
860 int rtl8192_down(struct net_device *dev, bool shutdownrf);
861 int rtl8192_up(struct net_device *dev);
862 void rtl8192_commit(struct net_device *dev);
863 void rtl8192_set_chan(struct net_device *dev, short ch);
864
865 void check_rfctrl_gpio_timer(unsigned long data);
866
867 void rtl8192_hw_wakeup_wq(void *data);
868 short rtl8192_pci_initdescring(struct net_device *dev);
869
870 void rtl8192_cancel_deferred_work(struct r8192_priv *priv);
871
872 int _rtl8192_up(struct net_device *dev, bool is_silent_reset);
873
874 short rtl8192_is_tx_queue_empty(struct net_device *dev);
875 void rtl8192_irq_disable(struct net_device *dev);
876
877 void rtl8192_tx_timeout(struct net_device *dev);
878 void rtl8192_pci_resetdescring(struct net_device *dev);
879 void rtl8192_SetWirelessMode(struct net_device *dev, u8 wireless_mode);
880 void rtl8192_irq_enable(struct net_device *dev);
881 void rtl8192_config_rate(struct net_device *dev, u16 *rate_config);
882 void rtl8192_update_cap(struct net_device *dev, u16 cap);
883 void rtl8192_irq_disable(struct net_device *dev);
884
885 void rtl819x_UpdateRxPktTimeStamp(struct net_device *dev,
886                                   struct rtllib_rx_stats *stats);
887 long rtl819x_translate_todbm(struct r8192_priv *priv, u8 signal_strength_index);
888 void rtl819x_update_rxsignalstatistics8190pci(struct r8192_priv *priv,
889                                       struct rtllib_rx_stats *pprevious_stats);
890 u8 rtl819x_evm_dbtopercentage(char value);
891 void rtl819x_process_cck_rxpathsel(struct r8192_priv *priv,
892                                    struct rtllib_rx_stats *pprevious_stats);
893 u8 rtl819x_query_rxpwrpercentage(char antpower);
894 void rtl8192_record_rxdesc_forlateruse(struct rtllib_rx_stats *psrc_stats,
895                                        struct rtllib_rx_stats *ptarget_stats);
896 bool NicIFEnableNIC(struct net_device *dev);
897 bool NicIFDisableNIC(struct net_device *dev);
898
899 bool MgntActSet_RF_State(struct net_device *dev,
900                          enum rt_rf_power_state StateToSet,
901                          RT_RF_CHANGE_SOURCE ChangeSource,
902                          bool   ProtectOrNot);
903 void ActUpdateChannelAccessSetting(struct net_device *dev,
904                            enum wireless_mode WirelessMode,
905                            struct channel_access_setting *ChnlAccessSetting);
906
907 #endif