blob: f627fdc15a58c49e6ed1e28d0f0f70af33b90360 [file] [log] [blame]
Larry Finger94a79942011-08-23 19:00:42 -05001/******************************************************************************
2 * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved.
3 *
4 * Based on the r8180 driver, which is:
Andrea Merello559a4c32013-08-26 13:53:30 +02005 * Copyright 2004-2005 Andrea Merello <andrea.merello@gmail.com>, et al.
Larry Finger94a79942011-08-23 19:00:42 -05006 * 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 *
Larry Finger94a79942011-08-23 19:00:42 -050015 * The full GNU General Public License is included in this distribution in the
16 * file called LICENSE.
17 *
18 * Contact Information:
19 * wlanfae <wlanfae@realtek.com>
20******************************************************************************/
21
22#ifndef _RTL_CORE_H
23#define _RTL_CORE_H
24
25#include <linux/module.h>
26#include <linux/kernel.h>
Larry Finger94a79942011-08-23 19:00:42 -050027#include <linux/ioport.h>
28#include <linux/sched.h>
29#include <linux/types.h>
30#include <linux/interrupt.h>
31#include <linux/slab.h>
32#include <linux/netdevice.h>
33#include <linux/pci.h>
34#include <linux/etherdevice.h>
35#include <linux/delay.h>
36#include <linux/rtnetlink.h>
37#include <linux/wireless.h>
38#include <linux/timer.h>
39#include <linux/proc_fs.h>
40#include <linux/if_arp.h>
41#include <linux/random.h>
Larry Finger1344ee22011-08-25 11:48:20 -050042#include <linux/io.h>
Sean MacLennanea74fed2011-11-28 20:19:33 -050043
44/* Need this defined before including local include files */
45#define DRV_NAME "rtl819xE"
46
Sean MacLennan3d461c92011-11-28 20:22:26 -050047#include "../rtllib.h"
Larry Finger94a79942011-08-23 19:00:42 -050048
Sean MacLennan3d461c92011-11-28 20:22:26 -050049#include "../dot11d.h"
Larry Finger94a79942011-08-23 19:00:42 -050050
51#include "r8192E_firmware.h"
52#include "r8192E_hw.h"
53
54#include "r8190P_def.h"
55#include "r8192E_dev.h"
56
Larry Finger94a79942011-08-23 19:00:42 -050057#include "rtl_eeprom.h"
58#include "rtl_ps.h"
59#include "rtl_pci.h"
60#include "rtl_cam.h"
61
Larry Finger1344ee22011-08-25 11:48:20 -050062#define DRV_COPYRIGHT \
63 "Copyright(c) 2008 - 2010 Realsil Semiconductor Corporation"
Larry Finger94a79942011-08-23 19:00:42 -050064#define DRV_AUTHOR "<wlanfae@realtek.com>"
65#define DRV_VERSION "0014.0401.2010"
66
Larry Finger1344ee22011-08-25 11:48:20 -050067#define IS_HARDWARE_TYPE_8192SE(_priv) \
68 (((struct r8192_priv *)rtllib_priv(dev))->card_8192 == NIC_8192SE)
Larry Finger94a79942011-08-23 19:00:42 -050069
70#define RTL_PCI_DEVICE(vend, dev, cfg) \
71 .vendor = (vend), .device = (dev), \
Mateusz Kulikowskif6692282015-04-13 23:47:27 +020072 .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, \
Larry Finger94a79942011-08-23 19:00:42 -050073 .driver_data = (kernel_ulong_t)&(cfg)
Larry Finger94a79942011-08-23 19:00:42 -050074
Larry Finger94a79942011-08-23 19:00:42 -050075#define TOTAL_CAM_ENTRY 32
76#define CAM_CONTENT_COUNT 8
77
Larry Finger94a79942011-08-23 19:00:42 -050078#define HAL_HW_PCI_REVISION_ID_8192PCIE 0x01
Larry Finger94a79942011-08-23 19:00:42 -050079#define HAL_HW_PCI_REVISION_ID_8192SE 0x10
Larry Finger94a79942011-08-23 19:00:42 -050080
81#define RTL819X_DEFAULT_RF_TYPE RF_1T2R
82
83#define RTLLIB_WATCH_DOG_TIME 2000
84
Larry Finger1344ee22011-08-25 11:48:20 -050085#define MAX_DEV_ADDR_SIZE 8 /*support till 64 bit bus width OS*/
Larry Finger94a79942011-08-23 19:00:42 -050086#define MAX_FIRMWARE_INFORMATION_SIZE 32
87#define MAX_802_11_HEADER_LENGTH (40 + MAX_FIRMWARE_INFORMATION_SIZE)
88#define ENCRYPTION_MAX_OVERHEAD 128
89#define MAX_FRAGMENT_COUNT 8
Larry Finger1344ee22011-08-25 11:48:20 -050090#define MAX_TRANSMIT_BUFFER_SIZE \
91 (1600 + (MAX_802_11_HEADER_LENGTH + ENCRYPTION_MAX_OVERHEAD) * \
92 MAX_FRAGMENT_COUNT)
Larry Finger94a79942011-08-23 19:00:42 -050093
Mateusz Kulikowski1e7da092015-10-19 22:00:20 +020094#define CMDPACKET_FRAG_SIZE (4 * (MAX_TRANSMIT_BUFFER_SIZE / 4) - 8)
95
Larry Finger94a79942011-08-23 19:00:42 -050096#define DEFAULT_FRAG_THRESHOLD 2342U
97#define MIN_FRAG_THRESHOLD 256U
98#define DEFAULT_BEACONINTERVAL 0x64U
99
Larry Finger94a79942011-08-23 19:00:42 -0500100#define DEFAULT_RETRY_RTS 7
101#define DEFAULT_RETRY_DATA 7
Larry Finger94a79942011-08-23 19:00:42 -0500102
103#define PHY_RSSI_SLID_WIN_MAX 100
104
Larry Finger1344ee22011-08-25 11:48:20 -0500105#define RTL_IOCTL_WPA_SUPPLICANT (SIOCIWFIRSTPRIV + 30)
Larry Finger94a79942011-08-23 19:00:42 -0500106
Larry Finger1344ee22011-08-25 11:48:20 -0500107#define TxBBGainTableLength 37
108#define CCKTxBBGainTableLength 23
Larry Finger94a79942011-08-23 19:00:42 -0500109
110#define CHANNEL_PLAN_LEN 10
Larry Finger1344ee22011-08-25 11:48:20 -0500111#define sCrcLng 4
Larry Finger94a79942011-08-23 19:00:42 -0500112
113#define NIC_SEND_HANG_THRESHOLD_NORMAL 4
114#define NIC_SEND_HANG_THRESHOLD_POWERSAVE 8
115
116#define MAX_TX_QUEUE 9
117
118#define MAX_RX_QUEUE 1
119
Larry Finger1344ee22011-08-25 11:48:20 -0500120#define MAX_RX_COUNT 64
121#define MAX_TX_QUEUE_COUNT 9
Larry Finger94a79942011-08-23 19:00:42 -0500122
Rashika Kheriafa63c9c2013-11-07 19:14:56 +0530123extern int hwwep;
124
Larry Fingerb55941a2011-07-19 19:33:00 -0500125enum nic_t {
Larry Finger94a79942011-08-23 19:00:42 -0500126 NIC_UNKNOWN = 0,
127 NIC_8192E = 1,
128 NIC_8190P = 2,
129 NIC_8192SE = 4,
Larry Finger1344ee22011-08-25 11:48:20 -0500130 NIC_8192CE = 5,
131 NIC_8192CU = 6,
132 NIC_8192DE = 7,
133 NIC_8192DU = 8,
134};
Larry Finger94a79942011-08-23 19:00:42 -0500135
Larry Fingere9463772011-07-19 19:34:33 -0500136enum rt_eeprom_type {
Larry Finger94a79942011-08-23 19:00:42 -0500137 EEPROM_93C46,
138 EEPROM_93C56,
Larry Fingere9463772011-07-19 19:34:33 -0500139};
Larry Finger94a79942011-08-23 19:00:42 -0500140
Larry Fingeraec11482011-07-19 19:36:07 -0500141enum dcmg_txcmd_op {
Larry Finger1344ee22011-08-25 11:48:20 -0500142 TXCMD_TXRA_HISTORY_CTRL = 0xFF900000,
Larry Finger94a79942011-08-23 19:00:42 -0500143 TXCMD_RESET_TX_PKT_BUFF = 0xFF900001,
144 TXCMD_RESET_RX_PKT_BUFF = 0xFF900002,
145 TXCMD_SET_TX_DURATION = 0xFF900003,
146 TXCMD_SET_RX_RSSI = 0xFF900004,
147 TXCMD_SET_TX_PWR_TRACKING = 0xFF900005,
148 TXCMD_XXXX_CTRL,
Larry Fingeraec11482011-07-19 19:36:07 -0500149};
Larry Finger94a79942011-08-23 19:00:42 -0500150
Larry Fingerfc6094f2011-07-19 19:37:46 -0500151enum rt_rf_type_819xu {
Larry Finger1344ee22011-08-25 11:48:20 -0500152 RF_TYPE_MIN = 0,
153 RF_8225,
154 RF_8256,
155 RF_8258,
156 RF_6052 = 4,
157 RF_PSEUDO_11N = 5,
Larry Fingerfc6094f2011-07-19 19:37:46 -0500158};
Larry Finger94a79942011-08-23 19:00:42 -0500159
Larry Fingered8eac22011-07-19 19:42:55 -0500160enum rt_customer_id {
Larry Finger1344ee22011-08-25 11:48:20 -0500161 RT_CID_DEFAULT = 0,
Larry Finger94a79942011-08-23 19:00:42 -0500162 RT_CID_8187_ALPHA0 = 1,
163 RT_CID_8187_SERCOMM_PS = 2,
164 RT_CID_8187_HW_LED = 3,
165 RT_CID_8187_NETGEAR = 4,
Larry Finger1344ee22011-08-25 11:48:20 -0500166 RT_CID_WHQL = 5,
Larry Finger94a79942011-08-23 19:00:42 -0500167 RT_CID_819x_CAMEO = 6,
168 RT_CID_819x_RUNTOP = 7,
169 RT_CID_819x_Senao = 8,
Larry Finger1344ee22011-08-25 11:48:20 -0500170 RT_CID_TOSHIBA = 9,
Larry Finger94a79942011-08-23 19:00:42 -0500171 RT_CID_819x_Netcore = 10,
Larry Finger1344ee22011-08-25 11:48:20 -0500172 RT_CID_Nettronix = 11,
173 RT_CID_DLINK = 12,
174 RT_CID_PRONET = 13,
175 RT_CID_COREGA = 14,
Larry Finger94a79942011-08-23 19:00:42 -0500176 RT_CID_819x_ALPHA = 15,
177 RT_CID_819x_Sitecom = 16,
Larry Finger1344ee22011-08-25 11:48:20 -0500178 RT_CID_CCX = 17,
Larry Finger94a79942011-08-23 19:00:42 -0500179 RT_CID_819x_Lenovo = 18,
Larry Finger1344ee22011-08-25 11:48:20 -0500180 RT_CID_819x_QMI = 19,
Larry Finger94a79942011-08-23 19:00:42 -0500181 RT_CID_819x_Edimax_Belkin = 20,
182 RT_CID_819x_Sercomm_Belkin = 21,
183 RT_CID_819x_CAMEO1 = 22,
184 RT_CID_819x_MSI = 23,
185 RT_CID_819x_Acer = 24,
Larry Finger1344ee22011-08-25 11:48:20 -0500186 RT_CID_819x_HP = 27,
Larry Finger94a79942011-08-23 19:00:42 -0500187 RT_CID_819x_CLEVO = 28,
188 RT_CID_819x_Arcadyan_Belkin = 29,
189 RT_CID_819x_SAMSUNG = 30,
190 RT_CID_819x_WNC_COREGA = 31,
Larry Fingered8eac22011-07-19 19:42:55 -0500191};
Larry Finger94a79942011-08-23 19:00:42 -0500192
Larry Fingerab0d7cc2011-07-19 19:49:51 -0500193enum reset_type {
Larry Finger94a79942011-08-23 19:00:42 -0500194 RESET_TYPE_NORESET = 0x00,
195 RESET_TYPE_NORMAL = 0x01,
196 RESET_TYPE_SILENT = 0x02
Larry Fingerab0d7cc2011-07-19 19:49:51 -0500197};
Larry Finger94a79942011-08-23 19:00:42 -0500198
Larry Finger2fac6fc2011-07-19 00:21:31 -0500199struct rt_stats {
Larry Finger94a79942011-08-23 19:00:42 -0500200 unsigned long rxrdu;
201 unsigned long rxok;
Larry Finger94a79942011-08-23 19:00:42 -0500202 unsigned long rxdatacrcerr;
203 unsigned long rxmgmtcrcerr;
204 unsigned long rxcrcerrmin;
205 unsigned long rxcrcerrmid;
206 unsigned long rxcrcerrmax;
207 unsigned long received_rate_histogram[4][32];
208 unsigned long received_preamble_GI[2][32];
Larry Finger94a79942011-08-23 19:00:42 -0500209 unsigned long numpacket_matchbssid;
210 unsigned long numpacket_toself;
211 unsigned long num_process_phyinfo;
212 unsigned long numqry_phystatus;
213 unsigned long numqry_phystatusCCK;
214 unsigned long numqry_phystatusHT;
215 unsigned long received_bwtype[5];
Larry Finger94a79942011-08-23 19:00:42 -0500216 unsigned long rxoverflow;
217 unsigned long rxint;
Larry Finger94a79942011-08-23 19:00:42 -0500218 unsigned long ints;
219 unsigned long shints;
220 unsigned long txoverflow;
Larry Finger94a79942011-08-23 19:00:42 -0500221 unsigned long txbeokint;
Larry Finger94a79942011-08-23 19:00:42 -0500222 unsigned long txbkokint;
Larry Finger94a79942011-08-23 19:00:42 -0500223 unsigned long txviokint;
Larry Finger94a79942011-08-23 19:00:42 -0500224 unsigned long txvookint;
Larry Finger94a79942011-08-23 19:00:42 -0500225 unsigned long txbeaconokint;
Larry Finger94a79942011-08-23 19:00:42 -0500226 unsigned long txbeaconerr;
227 unsigned long txmanageokint;
Larry Finger94a79942011-08-23 19:00:42 -0500228 unsigned long txcmdpktokint;
Larry Finger94a79942011-08-23 19:00:42 -0500229 unsigned long txbytesmulticast;
Larry Finger94a79942011-08-23 19:00:42 -0500230 unsigned long txbytesbroadcast;
Larry Finger94a79942011-08-23 19:00:42 -0500231 unsigned long txbytesunicast;
232 unsigned long rxbytesunicast;
Larry Finger94a79942011-08-23 19:00:42 -0500233 unsigned long txretrycount;
Larry Finger1344ee22011-08-25 11:48:20 -0500234 u8 last_packet_rate;
Larry Finger94a79942011-08-23 19:00:42 -0500235 unsigned long slide_signal_strength[100];
236 unsigned long slide_evm[100];
237 unsigned long slide_rssi_total;
238 unsigned long slide_evm_total;
239 long signal_strength;
240 long signal_quality;
241 long last_signal_strength_inpercent;
242 long recv_signal_power;
243 u8 rx_rssi_percentage[4];
244 u8 rx_evm_percentage[2];
245 long rxSNRdB[4];
Larry Finger94a79942011-08-23 19:00:42 -0500246 u32 Slide_Beacon_pwdb[100];
247 u32 Slide_Beacon_Total;
Larry Finger94a79942011-08-23 19:00:42 -0500248 u32 CurrentShowTxate;
Larry Finger2fac6fc2011-07-19 00:21:31 -0500249};
Larry Finger94a79942011-08-23 19:00:42 -0500250
Larry Fingere91dbf02011-07-18 22:30:34 -0500251struct channel_access_setting {
Larry Finger94a79942011-08-23 19:00:42 -0500252 u16 SIFS_Timer;
253 u16 DIFS_Timer;
254 u16 SlotTimeTimer;
255 u16 EIFS_Timer;
256 u16 CWminIndex;
257 u16 CWmaxIndex;
Larry Fingere91dbf02011-07-18 22:30:34 -0500258};
Larry Finger94a79942011-08-23 19:00:42 -0500259
Larry Finger43267fe2011-07-18 23:51:09 -0500260struct init_gain {
Larry Finger1344ee22011-08-25 11:48:20 -0500261 u8 xaagccore1;
262 u8 xbagccore1;
263 u8 xcagccore1;
264 u8 xdagccore1;
265 u8 cca;
Larry Finger94a79942011-08-23 19:00:42 -0500266
Larry Finger43267fe2011-07-18 23:51:09 -0500267};
Larry Finger94a79942011-08-23 19:00:42 -0500268
Larry Fingerb7a14042011-07-18 23:29:22 -0500269struct tx_ring {
Larry Finger1344ee22011-08-25 11:48:20 -0500270 u32 *desc;
Larry Finger94a79942011-08-23 19:00:42 -0500271 u8 nStuckCount;
Larry Finger1344ee22011-08-25 11:48:20 -0500272 struct tx_ring *next;
Larry Fingerb7a14042011-07-18 23:29:22 -0500273} __packed;
Larry Finger94a79942011-08-23 19:00:42 -0500274
275struct rtl8192_tx_ring {
Larry Finger1344ee22011-08-25 11:48:20 -0500276 struct tx_desc *desc;
277 dma_addr_t dma;
278 unsigned int idx;
279 unsigned int entries;
280 struct sk_buff_head queue;
Larry Finger94a79942011-08-23 19:00:42 -0500281};
282
283
284
Larry Finger1344ee22011-08-25 11:48:20 -0500285struct rtl819x_ops {
Larry Fingerb55941a2011-07-19 19:33:00 -0500286 enum nic_t nic_type;
Larry Finger1344ee22011-08-25 11:48:20 -0500287 void (*get_eeprom_size)(struct net_device *dev);
288 void (*init_adapter_variable)(struct net_device *dev);
289 void (*init_before_adapter_start)(struct net_device *dev);
290 bool (*initialize_adapter)(struct net_device *dev);
291 void (*link_change)(struct net_device *dev);
292 void (*tx_fill_descriptor)(struct net_device *dev,
293 struct tx_desc *tx_desc,
294 struct cb_desc *cb_desc,
295 struct sk_buff *skb);
296 void (*tx_fill_cmd_descriptor)(struct net_device *dev,
297 struct tx_desc_cmd *entry,
298 struct cb_desc *cb_desc,
299 struct sk_buff *skb);
300 bool (*rx_query_status_descriptor)(struct net_device *dev,
301 struct rtllib_rx_stats *stats,
302 struct rx_desc *pdesc,
303 struct sk_buff *skb);
304 bool (*rx_command_packet_handler)(struct net_device *dev,
305 struct sk_buff *skb,
306 struct rx_desc *pdesc);
307 void (*stop_adapter)(struct net_device *dev, bool reset);
308 void (*update_ratr_table)(struct net_device *dev);
309 void (*irq_enable)(struct net_device *dev);
310 void (*irq_disable)(struct net_device *dev);
311 void (*irq_clear)(struct net_device *dev);
312 void (*rx_enable)(struct net_device *dev);
313 void (*tx_enable)(struct net_device *dev);
314 void (*interrupt_recognized)(struct net_device *dev,
315 u32 *p_inta, u32 *p_intb);
316 bool (*TxCheckStuckHandler)(struct net_device *dev);
317 bool (*RxCheckStuckHandler)(struct net_device *dev);
Larry Finger94a79942011-08-23 19:00:42 -0500318};
319
Larry Fingere3e37622011-07-19 00:26:41 -0500320struct r8192_priv {
Larry Finger94a79942011-08-23 19:00:42 -0500321 struct pci_dev *pdev;
322 struct pci_dev *bridge_pdev;
323
Larry Finger94a79942011-08-23 19:00:42 -0500324 bool bfirst_init;
325 bool bfirst_after_down;
326 bool initialized_at_probe;
327 bool being_init_adapter;
328 bool bDriverIsGoingToUnload;
329
330 int irq;
331 short irq_enabled;
332
333 short up;
334 short up_first_time;
Larry Fingeredc4b2c2011-07-19 00:46:24 -0500335 struct delayed_work update_beacon_wq;
336 struct delayed_work watch_dog_wq;
337 struct delayed_work txpower_tracking_wq;
338 struct delayed_work rfpath_check_wq;
339 struct delayed_work gpio_change_rf_wq;
Larry Finger94a79942011-08-23 19:00:42 -0500340
Larry Fingere91dbf02011-07-18 22:30:34 -0500341 struct channel_access_setting ChannelAccessSetting;
Larry Finger94a79942011-08-23 19:00:42 -0500342
Larry Finger94a79942011-08-23 19:00:42 -0500343 struct rtl819x_ops *ops;
344 struct rtllib_device *rtllib;
345
Larry Fingeredc4b2c2011-07-19 00:46:24 -0500346 struct work_struct reset_wq;
Larry Finger94a79942011-08-23 19:00:42 -0500347
Larry Fingerc13ac632011-07-18 21:32:47 -0500348 struct log_int_8190 InterruptLog;
Larry Finger94a79942011-08-23 19:00:42 -0500349
Larry Fingered8eac22011-07-19 19:42:55 -0500350 enum rt_customer_id CustomerID;
Larry Finger94a79942011-08-23 19:00:42 -0500351
352
Larry Fingerfc6094f2011-07-19 19:37:46 -0500353 enum rt_rf_type_819xu rf_chip;
Larry Finger6e579112011-07-19 18:20:30 -0500354 enum ht_channel_width CurrentChannelBW;
Larry Finger9bf6e4c2011-07-18 21:16:51 -0500355 struct bb_reg_definition PHYRegDef[4];
Larry Finger9be6f102011-07-19 00:09:03 -0500356 struct rate_adaptive rate_adaptive;
Larry Finger94a79942011-08-23 19:00:42 -0500357
Larry Finger379a20f2011-07-19 19:30:04 -0500358 enum acm_method AcmMethod;
Larry Finger94a79942011-08-23 19:00:42 -0500359
Larry Finger5aca1142011-07-18 23:10:50 -0500360 struct rt_firmware *pFirmware;
Larry Finger70f9f792011-07-19 12:54:24 -0500361 enum rtl819x_loopback LoopbackMode;
Larry Finger94a79942011-08-23 19:00:42 -0500362
363 struct timer_list watch_dog_timer;
364 struct timer_list fsync_timer;
365 struct timer_list gpio_polling_timer;
366
Larry Finger94a79942011-08-23 19:00:42 -0500367 spinlock_t irq_th_lock;
368 spinlock_t tx_lock;
369 spinlock_t rf_ps_lock;
Larry Finger94a79942011-08-23 19:00:42 -0500370 spinlock_t ps_lock;
371
Larry Finger94a79942011-08-23 19:00:42 -0500372 struct sk_buff_head skb_queue;
373
374 struct tasklet_struct irq_rx_tasklet;
375 struct tasklet_struct irq_tx_tasklet;
376 struct tasklet_struct irq_prepare_beacon_tasklet;
377
378 struct semaphore wx_sem;
379 struct semaphore rf_sem;
Larry Finger94a79942011-08-23 19:00:42 -0500380 struct mutex mutex;
Larry Finger94a79942011-08-23 19:00:42 -0500381
Larry Finger2fac6fc2011-07-19 00:21:31 -0500382 struct rt_stats stats;
Larry Finger94a79942011-08-23 19:00:42 -0500383 struct iw_statistics wstats;
Larry Finger94a79942011-08-23 19:00:42 -0500384
Larry Finger1344ee22011-08-25 11:48:20 -0500385 short (*rf_set_sens)(struct net_device *dev, short sens);
386 u8 (*rf_set_chan)(struct net_device *dev, u8 ch);
Larry Finger94a79942011-08-23 19:00:42 -0500387
Larry Finger4f534b32011-07-18 22:52:12 -0500388 struct rx_desc *rx_ring[MAX_RX_QUEUE];
Larry Finger94a79942011-08-23 19:00:42 -0500389 struct sk_buff *rx_buf[MAX_RX_QUEUE][MAX_RX_COUNT];
390 dma_addr_t rx_ring_dma[MAX_RX_QUEUE];
391 unsigned int rx_idx[MAX_RX_QUEUE];
392 int rxringcount;
393 u16 rxbuffersize;
394
Larry Finger0dd56502011-08-25 11:48:12 -0500395 u64 LastRxDescTSF;
Larry Finger94a79942011-08-23 19:00:42 -0500396
Larry Finger94a79942011-08-23 19:00:42 -0500397 u32 ReceiveConfig;
Larry Finger94a79942011-08-23 19:00:42 -0500398 u8 retry_data;
399 u8 retry_rts;
400 u16 rts;
401
402 struct rtl8192_tx_ring tx_ring[MAX_TX_QUEUE_COUNT];
403 int txringcount;
Larry Finger94a79942011-08-23 19:00:42 -0500404 atomic_t tx_pending[0x10];
405
406 u16 ShortRetryLimit;
407 u16 LongRetryLimit;
Larry Finger94a79942011-08-23 19:00:42 -0500408
Larry Finger94a79942011-08-23 19:00:42 -0500409 bool bHwRadioOff;
Larry Finger94a79942011-08-23 19:00:42 -0500410 bool blinked_ingpio;
411 u8 polling_timer_on;
412
413 /**********************************************************/
414
Larry Finger1344ee22011-08-25 11:48:20 -0500415 enum card_type {
416 PCI, MINIPCI,
417 CARDBUS, USB
418 } card_type;
Larry Finger94a79942011-08-23 19:00:42 -0500419
Larry Fingeredc4b2c2011-07-19 00:46:24 -0500420 struct work_struct qos_activate;
Larry Finger94a79942011-08-23 19:00:42 -0500421
Larry Finger94a79942011-08-23 19:00:42 -0500422 short promisc;
Larry Finger94a79942011-08-23 19:00:42 -0500423
424 short chan;
425 short sens;
426 short max_sens;
Larry Finger94a79942011-08-23 19:00:42 -0500427
Larry Finger1344ee22011-08-25 11:48:20 -0500428 u8 ScanDelay;
429 bool ps_force;
Larry Finger94a79942011-08-23 19:00:42 -0500430
Larry Finger1344ee22011-08-25 11:48:20 -0500431 u32 irq_mask[2];
Larry Finger94a79942011-08-23 19:00:42 -0500432
Larry Finger1344ee22011-08-25 11:48:20 -0500433 u8 Rf_Mode;
Larry Fingerb55941a2011-07-19 19:33:00 -0500434 enum nic_t card_8192;
Larry Finger1344ee22011-08-25 11:48:20 -0500435 u8 card_8192_version;
Larry Finger94a79942011-08-23 19:00:42 -0500436
Larry Finger1344ee22011-08-25 11:48:20 -0500437 u8 rf_type;
438 u8 IC_Cut;
439 char nick[IW_ESSID_MAX_SIZE + 1];
Larry Finger1344ee22011-08-25 11:48:20 -0500440 u8 check_roaming_cnt;
Larry Finger94a79942011-08-23 19:00:42 -0500441
Larry Finger1344ee22011-08-25 11:48:20 -0500442 u32 SilentResetRxSlotIndex;
443 u32 SilentResetRxStuckEvent[MAX_SILENT_RESET_RX_SLOT_NUM];
Larry Finger94a79942011-08-23 19:00:42 -0500444
Larry Finger1344ee22011-08-25 11:48:20 -0500445 u16 basic_rate;
446 u8 short_preamble;
447 u8 dot11CurrentPreambleMode;
448 u8 slot_time;
449 u16 SifsTime;
Larry Finger94a79942011-08-23 19:00:42 -0500450
Larry Finger1344ee22011-08-25 11:48:20 -0500451 bool AutoloadFailFlag;
Larry Finger94a79942011-08-23 19:00:42 -0500452
Larry Finger94a79942011-08-23 19:00:42 -0500453 short epromtype;
Larry Finger1344ee22011-08-25 11:48:20 -0500454 u16 eeprom_vid;
455 u16 eeprom_did;
Larry Finger1344ee22011-08-25 11:48:20 -0500456 u8 eeprom_CustomerID;
457 u16 eeprom_ChannelPlan;
Larry Finger94a79942011-08-23 19:00:42 -0500458
Larry Finger1344ee22011-08-25 11:48:20 -0500459 u8 EEPROMTxPowerLevelCCK[14];
460 u8 EEPROMTxPowerLevelOFDM24G[14];
Larry Finger1344ee22011-08-25 11:48:20 -0500461 u8 EEPROMRfACCKChnl1TxPwLevel[3];
462 u8 EEPROMRfAOfdmChnlTxPwLevel[3];
463 u8 EEPROMRfCCCKChnl1TxPwLevel[3];
464 u8 EEPROMRfCOfdmChnlTxPwLevel[3];
Larry Finger1344ee22011-08-25 11:48:20 -0500465 u16 EEPROMAntPwDiff;
466 u8 EEPROMThermalMeter;
Larry Finger1344ee22011-08-25 11:48:20 -0500467 u8 EEPROMCrystalCap;
Larry Finger94a79942011-08-23 19:00:42 -0500468
Larry Finger1344ee22011-08-25 11:48:20 -0500469 u8 EEPROMLegacyHTTxPowerDiff;
Larry Finger94a79942011-08-23 19:00:42 -0500470
Larry Finger1344ee22011-08-25 11:48:20 -0500471 u8 CrystalCap;
472 u8 ThermalMeter[2];
Larry Finger94a79942011-08-23 19:00:42 -0500473
Larry Finger1344ee22011-08-25 11:48:20 -0500474 u8 SwChnlInProgress;
475 u8 SwChnlStage;
476 u8 SwChnlStep;
477 u8 SetBWModeInProgress;
Larry Finger94a79942011-08-23 19:00:42 -0500478
Larry Finger1344ee22011-08-25 11:48:20 -0500479 u8 nCur40MhzPrimeSC;
Larry Finger94a79942011-08-23 19:00:42 -0500480
Larry Finger1344ee22011-08-25 11:48:20 -0500481 u32 RfReg0Value[4];
482 u8 NumTotalRFPath;
483 bool brfpath_rxenable[4];
Larry Finger94a79942011-08-23 19:00:42 -0500484
Larry Finger1344ee22011-08-25 11:48:20 -0500485 bool bTXPowerDataReadFromEEPORM;
Larry Finger94a79942011-08-23 19:00:42 -0500486
Larry Finger1344ee22011-08-25 11:48:20 -0500487 u16 RegChannelPlan;
488 u16 ChannelPlan;
Larry Finger94a79942011-08-23 19:00:42 -0500489
Larry Finger1344ee22011-08-25 11:48:20 -0500490 bool RegRfOff;
491 bool isRFOff;
492 bool bInPowerSaveMode;
493 u8 bHwRfOffAction;
Larry Finger94a79942011-08-23 19:00:42 -0500494
Larry Finger1344ee22011-08-25 11:48:20 -0500495 bool RFChangeInProgress;
496 bool SetRFPowerStateInProgress;
497 bool bdisable_nic;
Larry Finger94a79942011-08-23 19:00:42 -0500498
Larry Finger1344ee22011-08-25 11:48:20 -0500499 u8 DM_Type;
Larry Finger94a79942011-08-23 19:00:42 -0500500
Larry Finger1344ee22011-08-25 11:48:20 -0500501 u8 CckPwEnl;
502 u16 TSSI_13dBm;
503 u32 Pwr_Track;
504 u8 CCKPresentAttentuation_20Mdefault;
505 u8 CCKPresentAttentuation_40Mdefault;
506 char CCKPresentAttentuation_difference;
507 char CCKPresentAttentuation;
Larry Finger1344ee22011-08-25 11:48:20 -0500508 long undecorated_smoothed_pwdb;
Larry Finger94a79942011-08-23 19:00:42 -0500509
Larry Finger1344ee22011-08-25 11:48:20 -0500510 u32 MCSTxPowerLevelOriginalOffset[6];
Larry Finger1344ee22011-08-25 11:48:20 -0500511 u8 TxPowerLevelCCK[14];
512 u8 TxPowerLevelCCK_A[14];
513 u8 TxPowerLevelCCK_C[14];
Larry Finger94a79942011-08-23 19:00:42 -0500514 u8 TxPowerLevelOFDM24G[14];
Larry Finger94a79942011-08-23 19:00:42 -0500515 u8 TxPowerLevelOFDM24G_A[14];
516 u8 TxPowerLevelOFDM24G_C[14];
517 u8 LegacyHTTxPowerDiff;
Larry Finger94a79942011-08-23 19:00:42 -0500518 s8 RF_C_TxPwDiff;
Larry Finger94a79942011-08-23 19:00:42 -0500519 u8 AntennaTxPwDiff[3];
Larry Finger94a79942011-08-23 19:00:42 -0500520
Larry Finger94a79942011-08-23 19:00:42 -0500521 bool bDynamicTxHighPower;
522 bool bDynamicTxLowPower;
523 bool bLastDTPFlag_High;
524 bool bLastDTPFlag_Low;
525
Larry Finger94a79942011-08-23 19:00:42 -0500526 u8 rfa_txpowertrackingindex;
527 u8 rfa_txpowertrackingindex_real;
528 u8 rfa_txpowertracking_default;
529 u8 rfc_txpowertrackingindex;
530 u8 rfc_txpowertrackingindex_real;
Larry Finger94a79942011-08-23 19:00:42 -0500531 bool btxpower_tracking;
532 bool bcck_in_ch14;
533
Larry Finger94a79942011-08-23 19:00:42 -0500534 u8 txpower_count;
535 bool btxpower_trackingInit;
536
537 u8 OFDM_index[2];
538 u8 CCK_index;
539
540 u8 Record_CCK_20Mindex;
541 u8 Record_CCK_40Mindex;
542
Larry Finger43267fe2011-07-18 23:51:09 -0500543 struct init_gain initgain_backup;
Larry Finger94a79942011-08-23 19:00:42 -0500544 u8 DefaultInitialGain[4];
545 bool bis_any_nonbepkts;
546 bool bcurrent_turbo_EDCA;
547 bool bis_cur_rdlstate;
548
Larry Finger94a79942011-08-23 19:00:42 -0500549 bool bfsync_processing;
550 u32 rate_record;
551 u32 rateCountDiffRecord;
Justin P. Mattock4c234eb2012-05-01 08:34:14 -0700552 u32 ContinueDiffCount;
Larry Finger94a79942011-08-23 19:00:42 -0500553 bool bswitch_fsync;
554 u8 framesync;
555 u32 framesyncC34;
556 u8 framesyncMonitor;
557
Larry Finger94a79942011-08-23 19:00:42 -0500558 u32 reset_count;
Larry Finger94a79942011-08-23 19:00:42 -0500559
Larry Fingerab0d7cc2011-07-19 19:49:51 -0500560 enum reset_type ResetProgress;
Larry Finger94a79942011-08-23 19:00:42 -0500561 bool bForcedSilentReset;
562 bool bDisableNormalResetCheck;
563 u16 TxCounter;
564 u16 RxCounter;
Larry Finger94a79942011-08-23 19:00:42 -0500565 bool bResetInProgress;
566 bool force_reset;
567 bool force_lps;
Larry Finger94a79942011-08-23 19:00:42 -0500568
569 bool chan_forced;
Larry Finger94a79942011-08-23 19:00:42 -0500570
571 u8 PwrDomainProtect;
572 u8 H2CTxCmdSeq;
Larry Fingerd3b2c172011-07-19 12:50:41 -0500573};
Larry Finger94a79942011-08-23 19:00:42 -0500574
575extern const struct ethtool_ops rtl819x_ethtool_ops;
576
Mateusz Kulikowskib59a4ca2015-07-19 19:28:09 +0200577u8 rtl92e_readb(struct net_device *dev, int x);
Mateusz Kulikowski99aa47e2015-07-19 19:28:10 +0200578u32 rtl92e_readl(struct net_device *dev, int x);
Mateusz Kulikowski1c0a7c02015-07-19 19:28:11 +0200579u16 rtl92e_readw(struct net_device *dev, int x);
Mateusz Kulikowskid8ae1962015-07-19 19:28:26 +0200580void rtl92e_writeb(struct net_device *dev, int x, u8 y);
Mateusz Kulikowski6dee0c82015-07-19 19:28:28 +0200581void rtl92e_writew(struct net_device *dev, int x, u16 y);
Mateusz Kulikowski8ea54102015-07-19 19:28:27 +0200582void rtl92e_writel(struct net_device *dev, int x, u32 y);
Larry Finger94a79942011-08-23 19:00:42 -0500583
584void force_pci_posting(struct net_device *dev);
585
Mateusz Kulikowski630268b2015-07-19 19:28:18 +0200586void rtl92e_rx_enable(struct net_device *);
Mateusz Kulikowski94199b32015-07-19 19:28:20 +0200587void rtl92e_tx_enable(struct net_device *);
Larry Finger94a79942011-08-23 19:00:42 -0500588
Mateusz Kulikowskibcdcc1e2015-07-19 19:33:51 +0200589void rtl92e_hw_sleep_wq(void *data);
Mateusz Kulikowskibc4f2cc2015-07-19 19:28:12 +0200590void rtl92e_commit(struct net_device *dev);
Larry Finger94a79942011-08-23 19:00:42 -0500591
Mateusz Kulikowskia643d922015-07-19 19:28:05 +0200592void rtl92e_check_rfctrl_gpio_timer(unsigned long data);
Larry Finger94a79942011-08-23 19:00:42 -0500593
Mateusz Kulikowskic34b29f2015-07-19 19:33:54 +0200594void rtl92e_hw_wakeup_wq(void *data);
Larry Finger94a79942011-08-23 19:00:42 -0500595
Mateusz Kulikowski36154dc2015-07-19 19:28:16 +0200596void rtl92e_reset_desc_ring(struct net_device *dev);
Mateusz Kulikowski35bf8482015-07-19 19:28:19 +0200597void rtl92e_set_wireless_mode(struct net_device *dev, u8 wireless_mode);
Mateusz Kulikowskib74299c2015-07-19 19:28:15 +0200598void rtl92e_irq_enable(struct net_device *dev);
Mateusz Kulikowski122fe9f2015-07-19 19:28:13 +0200599void rtl92e_config_rate(struct net_device *dev, u16 *rate_config);
Mateusz Kulikowskib7b50d62015-07-19 19:28:14 +0200600void rtl92e_irq_disable(struct net_device *dev);
Larry Finger94a79942011-08-23 19:00:42 -0500601
Mateusz Kulikowski7879efc2015-07-19 19:28:24 +0200602void rtl92e_update_rx_pkt_timestamp(struct net_device *dev,
603 struct rtllib_rx_stats *stats);
Mateusz Kulikowskif54f10b2015-07-19 19:28:23 +0200604long rtl92e_translate_to_dbm(struct r8192_priv *priv, u8 signal_strength_index);
Mateusz Kulikowski97ef4502015-07-19 19:28:25 +0200605void rtl92e_update_rx_statistics(struct r8192_priv *priv,
606 struct rtllib_rx_stats *pprevious_stats);
Mateusz Kulikowski6b89d0e2015-07-19 19:28:21 +0200607u8 rtl92e_evm_db_to_percent(char value);
Mateusz Kulikowskiaa804032015-07-19 19:28:22 +0200608u8 rtl92e_rx_db_to_percent(char antpower);
Mateusz Kulikowskie58701d2015-07-19 19:28:17 +0200609void rtl92e_copy_mpdu_stats(struct rtllib_rx_stats *psrc_stats,
610 struct rtllib_rx_stats *ptarget_stats);
Mateusz Kulikowski502bd1d2015-07-19 19:28:08 +0200611bool rtl92e_enable_nic(struct net_device *dev);
Mateusz Kulikowskiaf002dc2015-07-19 19:28:07 +0200612bool rtl92e_disable_nic(struct net_device *dev);
Larry Finger94a79942011-08-23 19:00:42 -0500613
Mateusz Kulikowskif434f9d2015-07-19 19:28:06 +0200614bool rtl92e_set_rf_state(struct net_device *dev,
Larry Finger1344ee22011-08-25 11:48:20 -0500615 enum rt_rf_power_state StateToSet,
Mateusz Kulikowski2937a5d2015-07-28 23:31:41 +0200616 RT_RF_CHANGE_SOURCE ChangeSource);
Larry Finger94a79942011-08-23 19:00:42 -0500617#endif