xref: /linux/drivers/net/wireless/realtek/rtlwifi/wifi.h (revision 84efbad4f867507b1067d3277c238885f182068d)
1f1d2b4d3SLarry Finger /******************************************************************************
2f1d2b4d3SLarry Finger  *
3f1d2b4d3SLarry Finger  * Copyright(c) 2009-2012  Realtek Corporation.
4f1d2b4d3SLarry Finger  *
5f1d2b4d3SLarry Finger  * This program is free software; you can redistribute it and/or modify it
6f1d2b4d3SLarry Finger  * under the terms of version 2 of the GNU General Public License as
7f1d2b4d3SLarry Finger  * published by the Free Software Foundation.
8f1d2b4d3SLarry Finger  *
9f1d2b4d3SLarry Finger  * This program is distributed in the hope that it will be useful, but WITHOUT
10f1d2b4d3SLarry Finger  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11f1d2b4d3SLarry Finger  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
12f1d2b4d3SLarry Finger  * more details.
13f1d2b4d3SLarry Finger  *
14f1d2b4d3SLarry Finger  * The full GNU General Public License is included in this distribution in the
15f1d2b4d3SLarry Finger  * file called LICENSE.
16f1d2b4d3SLarry Finger  *
17f1d2b4d3SLarry Finger  * Contact Information:
18f1d2b4d3SLarry Finger  * wlanfae <wlanfae@realtek.com>
19f1d2b4d3SLarry Finger  * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
20f1d2b4d3SLarry Finger  * Hsinchu 300, Taiwan.
21f1d2b4d3SLarry Finger  *
22f1d2b4d3SLarry Finger  * Larry Finger <Larry.Finger@lwfinger.net>
23f1d2b4d3SLarry Finger  *
24f1d2b4d3SLarry Finger  *****************************************************************************/
25f1d2b4d3SLarry Finger 
26f1d2b4d3SLarry Finger #ifndef __RTL_WIFI_H__
27f1d2b4d3SLarry Finger #define __RTL_WIFI_H__
28f1d2b4d3SLarry Finger 
29f1d2b4d3SLarry Finger #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
30f1d2b4d3SLarry Finger 
31f1d2b4d3SLarry Finger #include <linux/sched.h>
32f1d2b4d3SLarry Finger #include <linux/firmware.h>
33f1d2b4d3SLarry Finger #include <linux/etherdevice.h>
34f1d2b4d3SLarry Finger #include <linux/vmalloc.h>
35f1d2b4d3SLarry Finger #include <linux/usb.h>
36f1d2b4d3SLarry Finger #include <net/mac80211.h>
37f1d2b4d3SLarry Finger #include <linux/completion.h>
38f1d2b4d3SLarry Finger #include "debug.h"
39f1d2b4d3SLarry Finger 
40f1d2b4d3SLarry Finger #define	MASKBYTE0				0xff
41f1d2b4d3SLarry Finger #define	MASKBYTE1				0xff00
42f1d2b4d3SLarry Finger #define	MASKBYTE2				0xff0000
43f1d2b4d3SLarry Finger #define	MASKBYTE3				0xff000000
44f1d2b4d3SLarry Finger #define	MASKHWORD				0xffff0000
45f1d2b4d3SLarry Finger #define	MASKLWORD				0x0000ffff
46f1d2b4d3SLarry Finger #define	MASKDWORD				0xffffffff
47f1d2b4d3SLarry Finger #define	MASK12BITS				0xfff
48f1d2b4d3SLarry Finger #define	MASKH4BITS				0xf0000000
49f1d2b4d3SLarry Finger #define MASKOFDM_D				0xffc00000
50f1d2b4d3SLarry Finger #define	MASKCCK					0x3f3f3f3f
51f1d2b4d3SLarry Finger 
52f1d2b4d3SLarry Finger #define	MASK4BITS				0x0f
53f1d2b4d3SLarry Finger #define	MASK20BITS				0xfffff
54f1d2b4d3SLarry Finger #define RFREG_OFFSET_MASK			0xfffff
55f1d2b4d3SLarry Finger 
56f1d2b4d3SLarry Finger #define	MASKBYTE0				0xff
57f1d2b4d3SLarry Finger #define	MASKBYTE1				0xff00
58f1d2b4d3SLarry Finger #define	MASKBYTE2				0xff0000
59f1d2b4d3SLarry Finger #define	MASKBYTE3				0xff000000
60f1d2b4d3SLarry Finger #define	MASKHWORD				0xffff0000
61f1d2b4d3SLarry Finger #define	MASKLWORD				0x0000ffff
62f1d2b4d3SLarry Finger #define	MASKDWORD				0xffffffff
63f1d2b4d3SLarry Finger #define	MASK12BITS				0xfff
64f1d2b4d3SLarry Finger #define	MASKH4BITS				0xf0000000
65f1d2b4d3SLarry Finger #define MASKOFDM_D				0xffc00000
66f1d2b4d3SLarry Finger #define	MASKCCK					0x3f3f3f3f
67f1d2b4d3SLarry Finger 
68f1d2b4d3SLarry Finger #define	MASK4BITS				0x0f
69f1d2b4d3SLarry Finger #define	MASK20BITS				0xfffff
70f1d2b4d3SLarry Finger #define RFREG_OFFSET_MASK			0xfffff
71f1d2b4d3SLarry Finger 
72f1d2b4d3SLarry Finger #define RF_CHANGE_BY_INIT			0
73f1d2b4d3SLarry Finger #define RF_CHANGE_BY_IPS			BIT(28)
74f1d2b4d3SLarry Finger #define RF_CHANGE_BY_PS				BIT(29)
75f1d2b4d3SLarry Finger #define RF_CHANGE_BY_HW				BIT(30)
76f1d2b4d3SLarry Finger #define RF_CHANGE_BY_SW				BIT(31)
77f1d2b4d3SLarry Finger 
78f1d2b4d3SLarry Finger #define IQK_ADDA_REG_NUM			16
79f1d2b4d3SLarry Finger #define IQK_MAC_REG_NUM				4
80f1d2b4d3SLarry Finger #define IQK_THRESHOLD				8
81f1d2b4d3SLarry Finger 
82f1d2b4d3SLarry Finger #define MAX_KEY_LEN				61
83f1d2b4d3SLarry Finger #define KEY_BUF_SIZE				5
84f1d2b4d3SLarry Finger 
85f1d2b4d3SLarry Finger /* QoS related. */
86f1d2b4d3SLarry Finger /*aci: 0x00	Best Effort*/
87f1d2b4d3SLarry Finger /*aci: 0x01	Background*/
88f1d2b4d3SLarry Finger /*aci: 0x10	Video*/
89f1d2b4d3SLarry Finger /*aci: 0x11	Voice*/
90f1d2b4d3SLarry Finger /*Max: define total number.*/
91f1d2b4d3SLarry Finger #define AC0_BE					0
92f1d2b4d3SLarry Finger #define AC1_BK					1
93f1d2b4d3SLarry Finger #define AC2_VI					2
94f1d2b4d3SLarry Finger #define AC3_VO					3
95f1d2b4d3SLarry Finger #define AC_MAX					4
96f1d2b4d3SLarry Finger #define QOS_QUEUE_NUM				4
97f1d2b4d3SLarry Finger #define RTL_MAC80211_NUM_QUEUE			5
98f1d2b4d3SLarry Finger #define REALTEK_USB_VENQT_MAX_BUF_SIZE		254
99f1d2b4d3SLarry Finger #define RTL_USB_MAX_RX_COUNT			100
100f1d2b4d3SLarry Finger #define QBSS_LOAD_SIZE				5
101f1d2b4d3SLarry Finger #define MAX_WMMELE_LENGTH			64
102f1d2b4d3SLarry Finger 
103f1d2b4d3SLarry Finger #define TOTAL_CAM_ENTRY				32
104f1d2b4d3SLarry Finger 
105f1d2b4d3SLarry Finger /*slot time for 11g. */
106f1d2b4d3SLarry Finger #define RTL_SLOT_TIME_9				9
107f1d2b4d3SLarry Finger #define RTL_SLOT_TIME_20			20
108f1d2b4d3SLarry Finger 
109f1d2b4d3SLarry Finger /*related to tcp/ip. */
110f1d2b4d3SLarry Finger #define SNAP_SIZE		6
111f1d2b4d3SLarry Finger #define PROTOC_TYPE_SIZE	2
112f1d2b4d3SLarry Finger 
113f1d2b4d3SLarry Finger /*related with 802.11 frame*/
114f1d2b4d3SLarry Finger #define MAC80211_3ADDR_LEN			24
115f1d2b4d3SLarry Finger #define MAC80211_4ADDR_LEN			30
116f1d2b4d3SLarry Finger 
117f1d2b4d3SLarry Finger #define CHANNEL_MAX_NUMBER	(14 + 24 + 21)	/* 14 is the max channel no */
118f1d2b4d3SLarry Finger #define CHANNEL_MAX_NUMBER_2G		14
1190a44b220SLarry Finger #define CHANNEL_MAX_NUMBER_5G		49 /* Please refer to
120f1d2b4d3SLarry Finger 					    *"phy_GetChnlGroup8812A" and
121f1d2b4d3SLarry Finger 					    * "Hal_ReadTxPowerInfo8812A"
122f1d2b4d3SLarry Finger 					    */
123f1d2b4d3SLarry Finger #define CHANNEL_MAX_NUMBER_5G_80M	7
124f1d2b4d3SLarry Finger #define CHANNEL_GROUP_MAX	(3 + 9)	/*  ch1~3, 4~9, 10~14 = three groups */
125f1d2b4d3SLarry Finger #define MAX_PG_GROUP			13
126f1d2b4d3SLarry Finger #define	CHANNEL_GROUP_MAX_2G		3
127f1d2b4d3SLarry Finger #define	CHANNEL_GROUP_IDX_5GL		3
128f1d2b4d3SLarry Finger #define	CHANNEL_GROUP_IDX_5GM		6
129f1d2b4d3SLarry Finger #define	CHANNEL_GROUP_IDX_5GH		9
130f1d2b4d3SLarry Finger #define	CHANNEL_GROUP_MAX_5G		9
131f1d2b4d3SLarry Finger #define CHANNEL_MAX_NUMBER_2G		14
132f1d2b4d3SLarry Finger #define AVG_THERMAL_NUM			8
133f1d2b4d3SLarry Finger #define AVG_THERMAL_NUM_88E		4
134f1d2b4d3SLarry Finger #define AVG_THERMAL_NUM_8723BE		4
135f1d2b4d3SLarry Finger #define MAX_TID_COUNT			9
136f1d2b4d3SLarry Finger 
137f1d2b4d3SLarry Finger /* for early mode */
138f1d2b4d3SLarry Finger #define FCS_LEN				4
139f1d2b4d3SLarry Finger #define EM_HDR_LEN			8
140f1d2b4d3SLarry Finger 
141f1d2b4d3SLarry Finger enum rtl8192c_h2c_cmd {
142f1d2b4d3SLarry Finger 	H2C_AP_OFFLOAD = 0,
143f1d2b4d3SLarry Finger 	H2C_SETPWRMODE = 1,
144f1d2b4d3SLarry Finger 	H2C_JOINBSSRPT = 2,
145f1d2b4d3SLarry Finger 	H2C_RSVDPAGE = 3,
146f1d2b4d3SLarry Finger 	H2C_RSSI_REPORT = 5,
147f1d2b4d3SLarry Finger 	H2C_RA_MASK = 6,
148f1d2b4d3SLarry Finger 	H2C_MACID_PS_MODE = 7,
149f1d2b4d3SLarry Finger 	H2C_P2P_PS_OFFLOAD = 8,
150f1d2b4d3SLarry Finger 	H2C_MAC_MODE_SEL = 9,
151f1d2b4d3SLarry Finger 	H2C_PWRM = 15,
152f1d2b4d3SLarry Finger 	H2C_P2P_PS_CTW_CMD = 24,
153f1d2b4d3SLarry Finger 	MAX_H2CCMD
154f1d2b4d3SLarry Finger };
155f1d2b4d3SLarry Finger 
156f1d2b4d3SLarry Finger #define MAX_TX_COUNT			4
157f1d2b4d3SLarry Finger #define MAX_REGULATION_NUM		4
158f1d2b4d3SLarry Finger #define MAX_RF_PATH_NUM			4
159f1d2b4d3SLarry Finger #define MAX_RATE_SECTION_NUM		6
160d5e58252SLarry Finger #define MAX_2_4G_BANDWIDTH_NUM		4
161d5e58252SLarry Finger #define MAX_5G_BANDWIDTH_NUM		4
162f1d2b4d3SLarry Finger #define	MAX_RF_PATH			4
163f1d2b4d3SLarry Finger #define	MAX_CHNL_GROUP_24G		6
164f1d2b4d3SLarry Finger #define	MAX_CHNL_GROUP_5G		14
165f1d2b4d3SLarry Finger 
166f1d2b4d3SLarry Finger #define TX_PWR_BY_RATE_NUM_BAND		2
167f1d2b4d3SLarry Finger #define TX_PWR_BY_RATE_NUM_RF		4
168f1d2b4d3SLarry Finger #define TX_PWR_BY_RATE_NUM_SECTION	12
169f1d2b4d3SLarry Finger #define MAX_BASE_NUM_IN_PHY_REG_PG_24G  6
170f1d2b4d3SLarry Finger #define MAX_BASE_NUM_IN_PHY_REG_PG_5G	5
171f1d2b4d3SLarry Finger 
1720c07bd74SPing-Ke Shih #define BUFDESC_SEG_NUM		1 /* 0:2 seg, 1: 4 seg, 2: 8 seg */
173f1d2b4d3SLarry Finger 
174f1d2b4d3SLarry Finger #define DEL_SW_IDX_SZ		30
175f1d2b4d3SLarry Finger 
176f1d2b4d3SLarry Finger /* For now, it's just for 8192ee
177f1d2b4d3SLarry Finger  * but not OK yet, keep it 0
178f1d2b4d3SLarry Finger  */
1790c07bd74SPing-Ke Shih #define RTL8192EE_SEG_NUM		BUFDESC_SEG_NUM
180f1d2b4d3SLarry Finger 
181f1d2b4d3SLarry Finger enum rf_tx_num {
182f1d2b4d3SLarry Finger 	RF_1TX = 0,
183f1d2b4d3SLarry Finger 	RF_2TX,
184f1d2b4d3SLarry Finger 	RF_MAX_TX_NUM,
185f1d2b4d3SLarry Finger 	RF_TX_NUM_NONIMPLEMENT,
186f1d2b4d3SLarry Finger };
187f1d2b4d3SLarry Finger 
188f1d2b4d3SLarry Finger #define PACKET_NORMAL			0
189f1d2b4d3SLarry Finger #define PACKET_DHCP			1
190f1d2b4d3SLarry Finger #define PACKET_ARP			2
191f1d2b4d3SLarry Finger #define PACKET_EAPOL			3
192f1d2b4d3SLarry Finger 
193f1d2b4d3SLarry Finger #define	MAX_SUPPORT_WOL_PATTERN_NUM	16
194f1d2b4d3SLarry Finger #define	RSVD_WOL_PATTERN_NUM		1
195f1d2b4d3SLarry Finger #define	WKFMCAM_ADDR_NUM		6
196f1d2b4d3SLarry Finger #define	WKFMCAM_SIZE			24
197f1d2b4d3SLarry Finger 
198f1d2b4d3SLarry Finger #define	MAX_WOL_BIT_MASK_SIZE		16
199f1d2b4d3SLarry Finger /* MIN LEN keeps 13 here */
200f1d2b4d3SLarry Finger #define	MIN_WOL_PATTERN_SIZE		13
201f1d2b4d3SLarry Finger #define	MAX_WOL_PATTERN_SIZE		128
202f1d2b4d3SLarry Finger 
203f1d2b4d3SLarry Finger #define	WAKE_ON_MAGIC_PACKET		BIT(0)
204f1d2b4d3SLarry Finger #define	WAKE_ON_PATTERN_MATCH		BIT(1)
205f1d2b4d3SLarry Finger 
206f1d2b4d3SLarry Finger #define	WOL_REASON_PTK_UPDATE		BIT(0)
207f1d2b4d3SLarry Finger #define	WOL_REASON_GTK_UPDATE		BIT(1)
208f1d2b4d3SLarry Finger #define	WOL_REASON_DISASSOC		BIT(2)
209f1d2b4d3SLarry Finger #define	WOL_REASON_DEAUTH		BIT(3)
210f1d2b4d3SLarry Finger #define	WOL_REASON_AP_LOST		BIT(4)
211f1d2b4d3SLarry Finger #define	WOL_REASON_MAGIC_PKT		BIT(5)
212f1d2b4d3SLarry Finger #define	WOL_REASON_UNICAST_PKT		BIT(6)
213f1d2b4d3SLarry Finger #define	WOL_REASON_PATTERN_PKT		BIT(7)
214f1d2b4d3SLarry Finger #define	WOL_REASON_RTD3_SSID_MATCH	BIT(8)
215f1d2b4d3SLarry Finger #define	WOL_REASON_REALWOW_V2_WAKEUPPKT	BIT(9)
216f1d2b4d3SLarry Finger #define	WOL_REASON_REALWOW_V2_ACKLOST	BIT(10)
217f1d2b4d3SLarry Finger 
218f1d2b4d3SLarry Finger struct rtlwifi_firmware_header {
219f1d2b4d3SLarry Finger 	__le16 signature;
220f1d2b4d3SLarry Finger 	u8 category;
221f1d2b4d3SLarry Finger 	u8 function;
222f1d2b4d3SLarry Finger 	__le16 version;
223f1d2b4d3SLarry Finger 	u8 subversion;
224f1d2b4d3SLarry Finger 	u8 rsvd1;
225f1d2b4d3SLarry Finger 	u8 month;
226f1d2b4d3SLarry Finger 	u8 date;
227f1d2b4d3SLarry Finger 	u8 hour;
228f1d2b4d3SLarry Finger 	u8 minute;
229f1d2b4d3SLarry Finger 	__le16 ramcodeSize;
230f1d2b4d3SLarry Finger 	__le16 rsvd2;
231f1d2b4d3SLarry Finger 	__le32 svnindex;
232f1d2b4d3SLarry Finger 	__le32 rsvd3;
233f1d2b4d3SLarry Finger 	__le32 rsvd4;
234f1d2b4d3SLarry Finger 	__le32 rsvd5;
235f1d2b4d3SLarry Finger };
236f1d2b4d3SLarry Finger 
237f1d2b4d3SLarry Finger struct txpower_info_2g {
238f1d2b4d3SLarry Finger 	u8 index_cck_base[MAX_RF_PATH][MAX_CHNL_GROUP_24G];
239f1d2b4d3SLarry Finger 	u8 index_bw40_base[MAX_RF_PATH][MAX_CHNL_GROUP_24G];
240f1d2b4d3SLarry Finger 	/*If only one tx, only BW20 and OFDM are used.*/
241f1d2b4d3SLarry Finger 	u8 cck_diff[MAX_RF_PATH][MAX_TX_COUNT];
242f1d2b4d3SLarry Finger 	u8 ofdm_diff[MAX_RF_PATH][MAX_TX_COUNT];
243f1d2b4d3SLarry Finger 	u8 bw20_diff[MAX_RF_PATH][MAX_TX_COUNT];
244f1d2b4d3SLarry Finger 	u8 bw40_diff[MAX_RF_PATH][MAX_TX_COUNT];
245f1d2b4d3SLarry Finger 	u8 bw80_diff[MAX_RF_PATH][MAX_TX_COUNT];
246f1d2b4d3SLarry Finger 	u8 bw160_diff[MAX_RF_PATH][MAX_TX_COUNT];
247f1d2b4d3SLarry Finger };
248f1d2b4d3SLarry Finger 
249f1d2b4d3SLarry Finger struct txpower_info_5g {
250f1d2b4d3SLarry Finger 	u8 index_bw40_base[MAX_RF_PATH][MAX_CHNL_GROUP_5G];
251f1d2b4d3SLarry Finger 	/*If only one tx, only BW20, OFDM, BW80 and BW160 are used.*/
252f1d2b4d3SLarry Finger 	u8 ofdm_diff[MAX_RF_PATH][MAX_TX_COUNT];
253f1d2b4d3SLarry Finger 	u8 bw20_diff[MAX_RF_PATH][MAX_TX_COUNT];
254f1d2b4d3SLarry Finger 	u8 bw40_diff[MAX_RF_PATH][MAX_TX_COUNT];
255f1d2b4d3SLarry Finger 	u8 bw80_diff[MAX_RF_PATH][MAX_TX_COUNT];
256f1d2b4d3SLarry Finger 	u8 bw160_diff[MAX_RF_PATH][MAX_TX_COUNT];
257f1d2b4d3SLarry Finger };
258f1d2b4d3SLarry Finger 
259f1d2b4d3SLarry Finger enum rate_section {
260f1d2b4d3SLarry Finger 	CCK = 0,
261f1d2b4d3SLarry Finger 	OFDM,
262f1d2b4d3SLarry Finger 	HT_MCS0_MCS7,
263f1d2b4d3SLarry Finger 	HT_MCS8_MCS15,
264f1d2b4d3SLarry Finger 	VHT_1SSMCS0_1SSMCS9,
265f1d2b4d3SLarry Finger 	VHT_2SSMCS0_2SSMCS9,
266f1d2b4d3SLarry Finger };
267f1d2b4d3SLarry Finger 
268f1d2b4d3SLarry Finger enum intf_type {
269f1d2b4d3SLarry Finger 	INTF_PCI = 0,
270f1d2b4d3SLarry Finger 	INTF_USB = 1,
271f1d2b4d3SLarry Finger };
272f1d2b4d3SLarry Finger 
273f1d2b4d3SLarry Finger enum radio_path {
274f1d2b4d3SLarry Finger 	RF90_PATH_A = 0,
275f1d2b4d3SLarry Finger 	RF90_PATH_B = 1,
276f1d2b4d3SLarry Finger 	RF90_PATH_C = 2,
277f1d2b4d3SLarry Finger 	RF90_PATH_D = 3,
278f1d2b4d3SLarry Finger };
279f1d2b4d3SLarry Finger 
280f1d2b4d3SLarry Finger enum regulation_txpwr_lmt {
281f1d2b4d3SLarry Finger 	TXPWR_LMT_FCC = 0,
282f1d2b4d3SLarry Finger 	TXPWR_LMT_MKK = 1,
283f1d2b4d3SLarry Finger 	TXPWR_LMT_ETSI = 2,
284f1d2b4d3SLarry Finger 	TXPWR_LMT_WW = 3,
285f1d2b4d3SLarry Finger 
286f1d2b4d3SLarry Finger 	TXPWR_LMT_MAX_REGULATION_NUM = 4
287f1d2b4d3SLarry Finger };
288f1d2b4d3SLarry Finger 
289f1d2b4d3SLarry Finger enum rt_eeprom_type {
290f1d2b4d3SLarry Finger 	EEPROM_93C46,
291f1d2b4d3SLarry Finger 	EEPROM_93C56,
292f1d2b4d3SLarry Finger 	EEPROM_BOOT_EFUSE,
293f1d2b4d3SLarry Finger };
294f1d2b4d3SLarry Finger 
295f1d2b4d3SLarry Finger enum ttl_status {
296f1d2b4d3SLarry Finger 	RTL_STATUS_INTERFACE_START = 0,
297f1d2b4d3SLarry Finger };
298f1d2b4d3SLarry Finger 
299f1d2b4d3SLarry Finger enum hardware_type {
300f1d2b4d3SLarry Finger 	HARDWARE_TYPE_RTL8192E,
301f1d2b4d3SLarry Finger 	HARDWARE_TYPE_RTL8192U,
302f1d2b4d3SLarry Finger 	HARDWARE_TYPE_RTL8192SE,
303f1d2b4d3SLarry Finger 	HARDWARE_TYPE_RTL8192SU,
304f1d2b4d3SLarry Finger 	HARDWARE_TYPE_RTL8192CE,
305f1d2b4d3SLarry Finger 	HARDWARE_TYPE_RTL8192CU,
306f1d2b4d3SLarry Finger 	HARDWARE_TYPE_RTL8192DE,
307f1d2b4d3SLarry Finger 	HARDWARE_TYPE_RTL8192DU,
308f1d2b4d3SLarry Finger 	HARDWARE_TYPE_RTL8723AE,
309f1d2b4d3SLarry Finger 	HARDWARE_TYPE_RTL8723U,
310f1d2b4d3SLarry Finger 	HARDWARE_TYPE_RTL8188EE,
311f1d2b4d3SLarry Finger 	HARDWARE_TYPE_RTL8723BE,
312f1d2b4d3SLarry Finger 	HARDWARE_TYPE_RTL8192EE,
313f1d2b4d3SLarry Finger 	HARDWARE_TYPE_RTL8821AE,
314f1d2b4d3SLarry Finger 	HARDWARE_TYPE_RTL8812AE,
31558438d9aSPing-Ke Shih 	HARDWARE_TYPE_RTL8822BE,
316f1d2b4d3SLarry Finger 
317f1d2b4d3SLarry Finger 	/* keep it last */
318f1d2b4d3SLarry Finger 	HARDWARE_TYPE_NUM
319f1d2b4d3SLarry Finger };
320f1d2b4d3SLarry Finger 
32158438d9aSPing-Ke Shih #define RTL_HW_TYPE(rtlpriv)	(rtl_hal((struct rtl_priv *)rtlpriv)->hw_type)
32258438d9aSPing-Ke Shih #define IS_NEW_GENERATION_IC(rtlpriv)			\
32358438d9aSPing-Ke Shih 			(RTL_HW_TYPE(rtlpriv) >= HARDWARE_TYPE_RTL8192EE)
32458438d9aSPing-Ke Shih #define IS_HARDWARE_TYPE_8192CE(rtlpriv)		\
32558438d9aSPing-Ke Shih 			(RTL_HW_TYPE(rtlpriv) == HARDWARE_TYPE_RTL8192CE)
32658438d9aSPing-Ke Shih #define IS_HARDWARE_TYPE_8812(rtlpriv)			\
32758438d9aSPing-Ke Shih 			(RTL_HW_TYPE(rtlpriv) == HARDWARE_TYPE_RTL8812AE)
32858438d9aSPing-Ke Shih #define IS_HARDWARE_TYPE_8821(rtlpriv)			\
32958438d9aSPing-Ke Shih 			(RTL_HW_TYPE(rtlpriv) == HARDWARE_TYPE_RTL8821AE)
33058438d9aSPing-Ke Shih #define IS_HARDWARE_TYPE_8723A(rtlpriv)			\
33158438d9aSPing-Ke Shih 			(RTL_HW_TYPE(rtlpriv) == HARDWARE_TYPE_RTL8723AE)
33258438d9aSPing-Ke Shih #define IS_HARDWARE_TYPE_8723B(rtlpriv)			\
33358438d9aSPing-Ke Shih 			(RTL_HW_TYPE(rtlpriv) == HARDWARE_TYPE_RTL8723BE)
33458438d9aSPing-Ke Shih #define IS_HARDWARE_TYPE_8192E(rtlpriv)			\
33558438d9aSPing-Ke Shih 			(RTL_HW_TYPE(rtlpriv) == HARDWARE_TYPE_RTL8192EE)
33658438d9aSPing-Ke Shih #define IS_HARDWARE_TYPE_8822B(rtlpriv)			\
33758438d9aSPing-Ke Shih 			(RTL_HW_TYPE(rtlpriv) == HARDWARE_TYPE_RTL8822BE)
338f1d2b4d3SLarry Finger 
339f1d2b4d3SLarry Finger #define RX_HAL_IS_CCK_RATE(rxmcs)			\
340f1d2b4d3SLarry Finger 	((rxmcs) == DESC_RATE1M ||			\
341f1d2b4d3SLarry Finger 	 (rxmcs) == DESC_RATE2M ||			\
342f1d2b4d3SLarry Finger 	 (rxmcs) == DESC_RATE5_5M ||			\
343f1d2b4d3SLarry Finger 	 (rxmcs) == DESC_RATE11M)
344f1d2b4d3SLarry Finger 
345f1d2b4d3SLarry Finger enum scan_operation_backup_opt {
346f1d2b4d3SLarry Finger 	SCAN_OPT_BACKUP = 0,
347f1d2b4d3SLarry Finger 	SCAN_OPT_BACKUP_BAND0 = 0,
348f1d2b4d3SLarry Finger 	SCAN_OPT_BACKUP_BAND1,
349f1d2b4d3SLarry Finger 	SCAN_OPT_RESTORE,
350f1d2b4d3SLarry Finger 	SCAN_OPT_MAX
351f1d2b4d3SLarry Finger };
352f1d2b4d3SLarry Finger 
353f1d2b4d3SLarry Finger /*RF state.*/
354f1d2b4d3SLarry Finger enum rf_pwrstate {
355f1d2b4d3SLarry Finger 	ERFON,
356f1d2b4d3SLarry Finger 	ERFSLEEP,
357f1d2b4d3SLarry Finger 	ERFOFF
358f1d2b4d3SLarry Finger };
359f1d2b4d3SLarry Finger 
360f1d2b4d3SLarry Finger struct bb_reg_def {
361f1d2b4d3SLarry Finger 	u32 rfintfs;
362f1d2b4d3SLarry Finger 	u32 rfintfi;
363f1d2b4d3SLarry Finger 	u32 rfintfo;
364f1d2b4d3SLarry Finger 	u32 rfintfe;
365f1d2b4d3SLarry Finger 	u32 rf3wire_offset;
366f1d2b4d3SLarry Finger 	u32 rflssi_select;
367f1d2b4d3SLarry Finger 	u32 rftxgain_stage;
368f1d2b4d3SLarry Finger 	u32 rfhssi_para1;
369f1d2b4d3SLarry Finger 	u32 rfhssi_para2;
370f1d2b4d3SLarry Finger 	u32 rfsw_ctrl;
371f1d2b4d3SLarry Finger 	u32 rfagc_control1;
372f1d2b4d3SLarry Finger 	u32 rfagc_control2;
373f1d2b4d3SLarry Finger 	u32 rfrxiq_imbal;
374f1d2b4d3SLarry Finger 	u32 rfrx_afe;
375f1d2b4d3SLarry Finger 	u32 rftxiq_imbal;
376f1d2b4d3SLarry Finger 	u32 rftx_afe;
377f1d2b4d3SLarry Finger 	u32 rf_rb;		/* rflssi_readback */
378f1d2b4d3SLarry Finger 	u32 rf_rbpi;		/* rflssi_readbackpi */
379f1d2b4d3SLarry Finger };
380f1d2b4d3SLarry Finger 
381f1d2b4d3SLarry Finger enum io_type {
382f1d2b4d3SLarry Finger 	IO_CMD_PAUSE_DM_BY_SCAN = 0,
383f1d2b4d3SLarry Finger 	IO_CMD_PAUSE_BAND0_DM_BY_SCAN = 0,
384f1d2b4d3SLarry Finger 	IO_CMD_PAUSE_BAND1_DM_BY_SCAN = 1,
385f1d2b4d3SLarry Finger 	IO_CMD_RESUME_DM_BY_SCAN = 2,
386f1d2b4d3SLarry Finger };
387f1d2b4d3SLarry Finger 
388f1d2b4d3SLarry Finger enum hw_variables {
3898334ffdcSLarry Finger 	HW_VAR_ETHER_ADDR = 0x0,
3908334ffdcSLarry Finger 	HW_VAR_MULTICAST_REG = 0x1,
3918334ffdcSLarry Finger 	HW_VAR_BASIC_RATE = 0x2,
3928334ffdcSLarry Finger 	HW_VAR_BSSID = 0x3,
3938334ffdcSLarry Finger 	HW_VAR_MEDIA_STATUS= 0x4,
3948334ffdcSLarry Finger 	HW_VAR_SECURITY_CONF= 0x5,
3958334ffdcSLarry Finger 	HW_VAR_BEACON_INTERVAL = 0x6,
3968334ffdcSLarry Finger 	HW_VAR_ATIM_WINDOW = 0x7,
3978334ffdcSLarry Finger 	HW_VAR_LISTEN_INTERVAL = 0x8,
3988334ffdcSLarry Finger 	HW_VAR_CS_COUNTER = 0x9,
3998334ffdcSLarry Finger 	HW_VAR_DEFAULTKEY0 = 0xa,
4008334ffdcSLarry Finger 	HW_VAR_DEFAULTKEY1 = 0xb,
4018334ffdcSLarry Finger 	HW_VAR_DEFAULTKEY2 = 0xc,
4028334ffdcSLarry Finger 	HW_VAR_DEFAULTKEY3 = 0xd,
4038334ffdcSLarry Finger 	HW_VAR_SIFS = 0xe,
4048334ffdcSLarry Finger 	HW_VAR_R2T_SIFS = 0xf,
4058334ffdcSLarry Finger 	HW_VAR_DIFS = 0x10,
4068334ffdcSLarry Finger 	HW_VAR_EIFS = 0x11,
4078334ffdcSLarry Finger 	HW_VAR_SLOT_TIME = 0x12,
4088334ffdcSLarry Finger 	HW_VAR_ACK_PREAMBLE = 0x13,
4098334ffdcSLarry Finger 	HW_VAR_CW_CONFIG = 0x14,
4108334ffdcSLarry Finger 	HW_VAR_CW_VALUES = 0x15,
4118334ffdcSLarry Finger 	HW_VAR_RATE_FALLBACK_CONTROL= 0x16,
4128334ffdcSLarry Finger 	HW_VAR_CONTENTION_WINDOW = 0x17,
4138334ffdcSLarry Finger 	HW_VAR_RETRY_COUNT = 0x18,
4148334ffdcSLarry Finger 	HW_VAR_TR_SWITCH = 0x19,
4158334ffdcSLarry Finger 	HW_VAR_COMMAND = 0x1a,
4168334ffdcSLarry Finger 	HW_VAR_WPA_CONFIG = 0x1b,
4178334ffdcSLarry Finger 	HW_VAR_AMPDU_MIN_SPACE = 0x1c,
4188334ffdcSLarry Finger 	HW_VAR_SHORTGI_DENSITY = 0x1d,
4198334ffdcSLarry Finger 	HW_VAR_AMPDU_FACTOR = 0x1e,
4208334ffdcSLarry Finger 	HW_VAR_MCS_RATE_AVAILABLE = 0x1f,
4218334ffdcSLarry Finger 	HW_VAR_AC_PARAM = 0x20,
4228334ffdcSLarry Finger 	HW_VAR_ACM_CTRL = 0x21,
4238334ffdcSLarry Finger 	HW_VAR_DIS_Req_Qsize = 0x22,
4248334ffdcSLarry Finger 	HW_VAR_CCX_CHNL_LOAD = 0x23,
4258334ffdcSLarry Finger 	HW_VAR_CCX_NOISE_HISTOGRAM = 0x24,
4268334ffdcSLarry Finger 	HW_VAR_CCX_CLM_NHM = 0x25,
4278334ffdcSLarry Finger 	HW_VAR_TxOPLimit = 0x26,
4288334ffdcSLarry Finger 	HW_VAR_TURBO_MODE = 0x27,
4298334ffdcSLarry Finger 	HW_VAR_RF_STATE = 0x28,
4308334ffdcSLarry Finger 	HW_VAR_RF_OFF_BY_HW = 0x29,
4318334ffdcSLarry Finger 	HW_VAR_BUS_SPEED = 0x2a,
4328334ffdcSLarry Finger 	HW_VAR_SET_DEV_POWER = 0x2b,
433f1d2b4d3SLarry Finger 
4348334ffdcSLarry Finger 	HW_VAR_RCR = 0x2c,
4358334ffdcSLarry Finger 	HW_VAR_RATR_0 = 0x2d,
4368334ffdcSLarry Finger 	HW_VAR_RRSR = 0x2e,
4378334ffdcSLarry Finger 	HW_VAR_CPU_RST = 0x2f,
4388334ffdcSLarry Finger 	HW_VAR_CHECK_BSSID = 0x30,
4398334ffdcSLarry Finger 	HW_VAR_LBK_MODE = 0x31,
4408334ffdcSLarry Finger 	HW_VAR_AES_11N_FIX = 0x32,
4418334ffdcSLarry Finger 	HW_VAR_USB_RX_AGGR = 0x33,
4428334ffdcSLarry Finger 	HW_VAR_USER_CONTROL_TURBO_MODE = 0x34,
4438334ffdcSLarry Finger 	HW_VAR_RETRY_LIMIT = 0x35,
4448334ffdcSLarry Finger 	HW_VAR_INIT_TX_RATE = 0x36,
4458334ffdcSLarry Finger 	HW_VAR_TX_RATE_REG = 0x37,
4468334ffdcSLarry Finger 	HW_VAR_EFUSE_USAGE = 0x38,
4478334ffdcSLarry Finger 	HW_VAR_EFUSE_BYTES = 0x39,
4488334ffdcSLarry Finger 	HW_VAR_AUTOLOAD_STATUS = 0x3a,
4498334ffdcSLarry Finger 	HW_VAR_RF_2R_DISABLE = 0x3b,
4508334ffdcSLarry Finger 	HW_VAR_SET_RPWM = 0x3c,
4518334ffdcSLarry Finger 	HW_VAR_H2C_FW_PWRMODE = 0x3d,
4528334ffdcSLarry Finger 	HW_VAR_H2C_FW_JOINBSSRPT = 0x3e,
4538334ffdcSLarry Finger 	HW_VAR_H2C_FW_MEDIASTATUSRPT = 0x3f,
4548334ffdcSLarry Finger 	HW_VAR_H2C_FW_P2P_PS_OFFLOAD = 0x40,
4558334ffdcSLarry Finger 	HW_VAR_FW_PSMODE_STATUS = 0x41,
4568334ffdcSLarry Finger 	HW_VAR_INIT_RTS_RATE = 0x42,
4578334ffdcSLarry Finger 	HW_VAR_RESUME_CLK_ON = 0x43,
4588334ffdcSLarry Finger 	HW_VAR_FW_LPS_ACTION = 0x44,
4598334ffdcSLarry Finger 	HW_VAR_1X1_RECV_COMBINE = 0x45,
4608334ffdcSLarry Finger 	HW_VAR_STOP_SEND_BEACON = 0x46,
4618334ffdcSLarry Finger 	HW_VAR_TSF_TIMER = 0x47,
4628334ffdcSLarry Finger 	HW_VAR_IO_CMD = 0x48,
463f1d2b4d3SLarry Finger 
4648334ffdcSLarry Finger 	HW_VAR_RF_RECOVERY = 0x49,
4658334ffdcSLarry Finger 	HW_VAR_H2C_FW_UPDATE_GTK = 0x4a,
4668334ffdcSLarry Finger 	HW_VAR_WF_MASK = 0x4b,
4678334ffdcSLarry Finger 	HW_VAR_WF_CRC = 0x4c,
4688334ffdcSLarry Finger 	HW_VAR_WF_IS_MAC_ADDR = 0x4d,
4698334ffdcSLarry Finger 	HW_VAR_H2C_FW_OFFLOAD = 0x4e,
4708334ffdcSLarry Finger 	HW_VAR_RESET_WFCRC = 0x4f,
471f1d2b4d3SLarry Finger 
4728334ffdcSLarry Finger 	HW_VAR_HANDLE_FW_C2H = 0x50,
4738334ffdcSLarry Finger 	HW_VAR_DL_FW_RSVD_PAGE = 0x51,
4748334ffdcSLarry Finger 	HW_VAR_AID = 0x52,
4758334ffdcSLarry Finger 	HW_VAR_HW_SEQ_ENABLE = 0x53,
4768334ffdcSLarry Finger 	HW_VAR_CORRECT_TSF = 0x54,
4778334ffdcSLarry Finger 	HW_VAR_BCN_VALID = 0x55,
4788334ffdcSLarry Finger 	HW_VAR_FWLPS_RF_ON = 0x56,
4798334ffdcSLarry Finger 	HW_VAR_DUAL_TSF_RST = 0x57,
4808334ffdcSLarry Finger 	HW_VAR_SWITCH_EPHY_WoWLAN = 0x58,
4818334ffdcSLarry Finger 	HW_VAR_INT_MIGRATION = 0x59,
4828334ffdcSLarry Finger 	HW_VAR_INT_AC = 0x5a,
4838334ffdcSLarry Finger 	HW_VAR_RF_TIMING = 0x5b,
484f1d2b4d3SLarry Finger 
4858334ffdcSLarry Finger 	HAL_DEF_WOWLAN = 0x5c,
4868334ffdcSLarry Finger 	HW_VAR_MRC = 0x5d,
4878334ffdcSLarry Finger 	HW_VAR_KEEP_ALIVE = 0x5e,
4888334ffdcSLarry Finger 	HW_VAR_NAV_UPPER = 0x5f,
489f1d2b4d3SLarry Finger 
4908334ffdcSLarry Finger 	HW_VAR_MGT_FILTER = 0x60,
4918334ffdcSLarry Finger 	HW_VAR_CTRL_FILTER = 0x61,
4928334ffdcSLarry Finger 	HW_VAR_DATA_FILTER = 0x62,
493f1d2b4d3SLarry Finger };
494f1d2b4d3SLarry Finger 
495f1d2b4d3SLarry Finger enum rt_media_status {
496f1d2b4d3SLarry Finger 	RT_MEDIA_DISCONNECT = 0,
497f1d2b4d3SLarry Finger 	RT_MEDIA_CONNECT = 1
498f1d2b4d3SLarry Finger };
499f1d2b4d3SLarry Finger 
500f1d2b4d3SLarry Finger enum rt_oem_id {
501f1d2b4d3SLarry Finger 	RT_CID_DEFAULT = 0,
502f1d2b4d3SLarry Finger 	RT_CID_8187_ALPHA0 = 1,
503f1d2b4d3SLarry Finger 	RT_CID_8187_SERCOMM_PS = 2,
504f1d2b4d3SLarry Finger 	RT_CID_8187_HW_LED = 3,
505f1d2b4d3SLarry Finger 	RT_CID_8187_NETGEAR = 4,
506f1d2b4d3SLarry Finger 	RT_CID_WHQL = 5,
507f1d2b4d3SLarry Finger 	RT_CID_819X_CAMEO = 6,
508f1d2b4d3SLarry Finger 	RT_CID_819X_RUNTOP = 7,
509f1d2b4d3SLarry Finger 	RT_CID_819X_SENAO = 8,
510f1d2b4d3SLarry Finger 	RT_CID_TOSHIBA = 9,
511f1d2b4d3SLarry Finger 	RT_CID_819X_NETCORE = 10,
512f1d2b4d3SLarry Finger 	RT_CID_NETTRONIX = 11,
513f1d2b4d3SLarry Finger 	RT_CID_DLINK = 12,
514f1d2b4d3SLarry Finger 	RT_CID_PRONET = 13,
515f1d2b4d3SLarry Finger 	RT_CID_COREGA = 14,
516f1d2b4d3SLarry Finger 	RT_CID_819X_ALPHA = 15,
517f1d2b4d3SLarry Finger 	RT_CID_819X_SITECOM = 16,
518f1d2b4d3SLarry Finger 	RT_CID_CCX = 17,
519f1d2b4d3SLarry Finger 	RT_CID_819X_LENOVO = 18,
520f1d2b4d3SLarry Finger 	RT_CID_819X_QMI = 19,
521f1d2b4d3SLarry Finger 	RT_CID_819X_EDIMAX_BELKIN = 20,
522f1d2b4d3SLarry Finger 	RT_CID_819X_SERCOMM_BELKIN = 21,
523f1d2b4d3SLarry Finger 	RT_CID_819X_CAMEO1 = 22,
524f1d2b4d3SLarry Finger 	RT_CID_819X_MSI = 23,
525f1d2b4d3SLarry Finger 	RT_CID_819X_ACER = 24,
526f1d2b4d3SLarry Finger 	RT_CID_819X_HP = 27,
527f1d2b4d3SLarry Finger 	RT_CID_819X_CLEVO = 28,
528f1d2b4d3SLarry Finger 	RT_CID_819X_ARCADYAN_BELKIN = 29,
529f1d2b4d3SLarry Finger 	RT_CID_819X_SAMSUNG = 30,
530f1d2b4d3SLarry Finger 	RT_CID_819X_WNC_COREGA = 31,
531f1d2b4d3SLarry Finger 	RT_CID_819X_FOXCOON = 32,
532f1d2b4d3SLarry Finger 	RT_CID_819X_DELL = 33,
533f1d2b4d3SLarry Finger 	RT_CID_819X_PRONETS = 34,
534f1d2b4d3SLarry Finger 	RT_CID_819X_EDIMAX_ASUS = 35,
535f1d2b4d3SLarry Finger 	RT_CID_NETGEAR = 36,
536f1d2b4d3SLarry Finger 	RT_CID_PLANEX = 37,
537f1d2b4d3SLarry Finger 	RT_CID_CC_C = 38,
538f1d2b4d3SLarry Finger };
539f1d2b4d3SLarry Finger 
540f1d2b4d3SLarry Finger enum hw_descs {
541f1d2b4d3SLarry Finger 	HW_DESC_OWN,
542f1d2b4d3SLarry Finger 	HW_DESC_RXOWN,
543f1d2b4d3SLarry Finger 	HW_DESC_TX_NEXTDESC_ADDR,
544f1d2b4d3SLarry Finger 	HW_DESC_TXBUFF_ADDR,
545f1d2b4d3SLarry Finger 	HW_DESC_RXBUFF_ADDR,
546f1d2b4d3SLarry Finger 	HW_DESC_RXPKT_LEN,
547f1d2b4d3SLarry Finger 	HW_DESC_RXERO,
548f1d2b4d3SLarry Finger 	HW_DESC_RX_PREPARE,
549f1d2b4d3SLarry Finger };
550f1d2b4d3SLarry Finger 
551f1d2b4d3SLarry Finger enum prime_sc {
552f1d2b4d3SLarry Finger 	PRIME_CHNL_OFFSET_DONT_CARE = 0,
553f1d2b4d3SLarry Finger 	PRIME_CHNL_OFFSET_LOWER = 1,
554f1d2b4d3SLarry Finger 	PRIME_CHNL_OFFSET_UPPER = 2,
555f1d2b4d3SLarry Finger };
556f1d2b4d3SLarry Finger 
557f1d2b4d3SLarry Finger enum rf_type {
558f1d2b4d3SLarry Finger 	RF_1T1R = 0,
559f1d2b4d3SLarry Finger 	RF_1T2R = 1,
560f1d2b4d3SLarry Finger 	RF_2T2R = 2,
561f1d2b4d3SLarry Finger 	RF_2T2R_GREEN = 3,
56208ab7465SPing-Ke Shih 	RF_2T3R = 4,
56308ab7465SPing-Ke Shih 	RF_2T4R = 5,
56408ab7465SPing-Ke Shih 	RF_3T3R = 6,
56508ab7465SPing-Ke Shih 	RF_3T4R = 7,
56608ab7465SPing-Ke Shih 	RF_4T4R = 8,
567f1d2b4d3SLarry Finger };
568f1d2b4d3SLarry Finger 
569f1d2b4d3SLarry Finger enum ht_channel_width {
570f1d2b4d3SLarry Finger 	HT_CHANNEL_WIDTH_20 = 0,
571f1d2b4d3SLarry Finger 	HT_CHANNEL_WIDTH_20_40 = 1,
572f1d2b4d3SLarry Finger 	HT_CHANNEL_WIDTH_80 = 2,
573f1d2b4d3SLarry Finger };
574f1d2b4d3SLarry Finger 
575f1d2b4d3SLarry Finger /* Ref: 802.11i sepc D10.0 7.3.2.25.1
576f1d2b4d3SLarry Finger Cipher Suites Encryption Algorithms */
577f1d2b4d3SLarry Finger enum rt_enc_alg {
578f1d2b4d3SLarry Finger 	NO_ENCRYPTION = 0,
579f1d2b4d3SLarry Finger 	WEP40_ENCRYPTION = 1,
580f1d2b4d3SLarry Finger 	TKIP_ENCRYPTION = 2,
581f1d2b4d3SLarry Finger 	RSERVED_ENCRYPTION = 3,
582f1d2b4d3SLarry Finger 	AESCCMP_ENCRYPTION = 4,
583f1d2b4d3SLarry Finger 	WEP104_ENCRYPTION = 5,
584f1d2b4d3SLarry Finger 	AESCMAC_ENCRYPTION = 6,	/*IEEE802.11w */
585f1d2b4d3SLarry Finger };
586f1d2b4d3SLarry Finger 
587f1d2b4d3SLarry Finger enum rtl_hal_state {
588f1d2b4d3SLarry Finger 	_HAL_STATE_STOP = 0,
589f1d2b4d3SLarry Finger 	_HAL_STATE_START = 1,
590f1d2b4d3SLarry Finger };
591f1d2b4d3SLarry Finger 
5926ec9dfbcSPing-Ke Shih enum rtl_desc_rate {
593f1d2b4d3SLarry Finger 	DESC_RATE1M = 0x00,
594f1d2b4d3SLarry Finger 	DESC_RATE2M = 0x01,
595f1d2b4d3SLarry Finger 	DESC_RATE5_5M = 0x02,
596f1d2b4d3SLarry Finger 	DESC_RATE11M = 0x03,
597f1d2b4d3SLarry Finger 
598f1d2b4d3SLarry Finger 	DESC_RATE6M = 0x04,
599f1d2b4d3SLarry Finger 	DESC_RATE9M = 0x05,
600f1d2b4d3SLarry Finger 	DESC_RATE12M = 0x06,
601f1d2b4d3SLarry Finger 	DESC_RATE18M = 0x07,
602f1d2b4d3SLarry Finger 	DESC_RATE24M = 0x08,
603f1d2b4d3SLarry Finger 	DESC_RATE36M = 0x09,
604f1d2b4d3SLarry Finger 	DESC_RATE48M = 0x0a,
605f1d2b4d3SLarry Finger 	DESC_RATE54M = 0x0b,
606f1d2b4d3SLarry Finger 
607f1d2b4d3SLarry Finger 	DESC_RATEMCS0 = 0x0c,
608f1d2b4d3SLarry Finger 	DESC_RATEMCS1 = 0x0d,
609f1d2b4d3SLarry Finger 	DESC_RATEMCS2 = 0x0e,
610f1d2b4d3SLarry Finger 	DESC_RATEMCS3 = 0x0f,
611f1d2b4d3SLarry Finger 	DESC_RATEMCS4 = 0x10,
612f1d2b4d3SLarry Finger 	DESC_RATEMCS5 = 0x11,
613f1d2b4d3SLarry Finger 	DESC_RATEMCS6 = 0x12,
614f1d2b4d3SLarry Finger 	DESC_RATEMCS7 = 0x13,
615f1d2b4d3SLarry Finger 	DESC_RATEMCS8 = 0x14,
616f1d2b4d3SLarry Finger 	DESC_RATEMCS9 = 0x15,
617f1d2b4d3SLarry Finger 	DESC_RATEMCS10 = 0x16,
618f1d2b4d3SLarry Finger 	DESC_RATEMCS11 = 0x17,
619f1d2b4d3SLarry Finger 	DESC_RATEMCS12 = 0x18,
620f1d2b4d3SLarry Finger 	DESC_RATEMCS13 = 0x19,
621f1d2b4d3SLarry Finger 	DESC_RATEMCS14 = 0x1a,
622f1d2b4d3SLarry Finger 	DESC_RATEMCS15 = 0x1b,
623f1d2b4d3SLarry Finger 	DESC_RATEMCS15_SG = 0x1c,
624f1d2b4d3SLarry Finger 	DESC_RATEMCS32 = 0x20,
625f1d2b4d3SLarry Finger 
626f1d2b4d3SLarry Finger 	DESC_RATEVHT1SS_MCS0 = 0x2c,
627f1d2b4d3SLarry Finger 	DESC_RATEVHT1SS_MCS1 = 0x2d,
628f1d2b4d3SLarry Finger 	DESC_RATEVHT1SS_MCS2 = 0x2e,
629f1d2b4d3SLarry Finger 	DESC_RATEVHT1SS_MCS3 = 0x2f,
630f1d2b4d3SLarry Finger 	DESC_RATEVHT1SS_MCS4 = 0x30,
631f1d2b4d3SLarry Finger 	DESC_RATEVHT1SS_MCS5 = 0x31,
632f1d2b4d3SLarry Finger 	DESC_RATEVHT1SS_MCS6 = 0x32,
633f1d2b4d3SLarry Finger 	DESC_RATEVHT1SS_MCS7 = 0x33,
634f1d2b4d3SLarry Finger 	DESC_RATEVHT1SS_MCS8 = 0x34,
635f1d2b4d3SLarry Finger 	DESC_RATEVHT1SS_MCS9 = 0x35,
636f1d2b4d3SLarry Finger 	DESC_RATEVHT2SS_MCS0 = 0x36,
637f1d2b4d3SLarry Finger 	DESC_RATEVHT2SS_MCS1 = 0x37,
638f1d2b4d3SLarry Finger 	DESC_RATEVHT2SS_MCS2 = 0x38,
639f1d2b4d3SLarry Finger 	DESC_RATEVHT2SS_MCS3 = 0x39,
640f1d2b4d3SLarry Finger 	DESC_RATEVHT2SS_MCS4 = 0x3a,
641f1d2b4d3SLarry Finger 	DESC_RATEVHT2SS_MCS5 = 0x3b,
642f1d2b4d3SLarry Finger 	DESC_RATEVHT2SS_MCS6 = 0x3c,
643f1d2b4d3SLarry Finger 	DESC_RATEVHT2SS_MCS7 = 0x3d,
644f1d2b4d3SLarry Finger 	DESC_RATEVHT2SS_MCS8 = 0x3e,
645f1d2b4d3SLarry Finger 	DESC_RATEVHT2SS_MCS9 = 0x3f,
646f1d2b4d3SLarry Finger };
647f1d2b4d3SLarry Finger 
648f1d2b4d3SLarry Finger enum rtl_var_map {
649f1d2b4d3SLarry Finger 	/*reg map */
650f1d2b4d3SLarry Finger 	SYS_ISO_CTRL = 0,
651f1d2b4d3SLarry Finger 	SYS_FUNC_EN,
652f1d2b4d3SLarry Finger 	SYS_CLK,
653f1d2b4d3SLarry Finger 	MAC_RCR_AM,
654f1d2b4d3SLarry Finger 	MAC_RCR_AB,
655f1d2b4d3SLarry Finger 	MAC_RCR_ACRC32,
656f1d2b4d3SLarry Finger 	MAC_RCR_ACF,
657f1d2b4d3SLarry Finger 	MAC_RCR_AAP,
658f1d2b4d3SLarry Finger 	MAC_HIMR,
659f1d2b4d3SLarry Finger 	MAC_HIMRE,
660f1d2b4d3SLarry Finger 	MAC_HSISR,
661f1d2b4d3SLarry Finger 
662f1d2b4d3SLarry Finger 	/*efuse map */
663f1d2b4d3SLarry Finger 	EFUSE_TEST,
664f1d2b4d3SLarry Finger 	EFUSE_CTRL,
665f1d2b4d3SLarry Finger 	EFUSE_CLK,
666f1d2b4d3SLarry Finger 	EFUSE_CLK_CTRL,
667f1d2b4d3SLarry Finger 	EFUSE_PWC_EV12V,
668f1d2b4d3SLarry Finger 	EFUSE_FEN_ELDR,
669f1d2b4d3SLarry Finger 	EFUSE_LOADER_CLK_EN,
670f1d2b4d3SLarry Finger 	EFUSE_ANA8M,
671f1d2b4d3SLarry Finger 	EFUSE_HWSET_MAX_SIZE,
672f1d2b4d3SLarry Finger 	EFUSE_MAX_SECTION_MAP,
673f1d2b4d3SLarry Finger 	EFUSE_REAL_CONTENT_SIZE,
674f1d2b4d3SLarry Finger 	EFUSE_OOB_PROTECT_BYTES_LEN,
675f1d2b4d3SLarry Finger 	EFUSE_ACCESS,
676f1d2b4d3SLarry Finger 
677f1d2b4d3SLarry Finger 	/*CAM map */
678f1d2b4d3SLarry Finger 	RWCAM,
679f1d2b4d3SLarry Finger 	WCAMI,
680f1d2b4d3SLarry Finger 	RCAMO,
681f1d2b4d3SLarry Finger 	CAMDBG,
682f1d2b4d3SLarry Finger 	SECR,
683f1d2b4d3SLarry Finger 	SEC_CAM_NONE,
684f1d2b4d3SLarry Finger 	SEC_CAM_WEP40,
685f1d2b4d3SLarry Finger 	SEC_CAM_TKIP,
686f1d2b4d3SLarry Finger 	SEC_CAM_AES,
687f1d2b4d3SLarry Finger 	SEC_CAM_WEP104,
688f1d2b4d3SLarry Finger 
689f1d2b4d3SLarry Finger 	/*IMR map */
690f1d2b4d3SLarry Finger 	RTL_IMR_BCNDMAINT6,	/*Beacon DMA Interrupt 6 */
691f1d2b4d3SLarry Finger 	RTL_IMR_BCNDMAINT5,	/*Beacon DMA Interrupt 5 */
692f1d2b4d3SLarry Finger 	RTL_IMR_BCNDMAINT4,	/*Beacon DMA Interrupt 4 */
693f1d2b4d3SLarry Finger 	RTL_IMR_BCNDMAINT3,	/*Beacon DMA Interrupt 3 */
694f1d2b4d3SLarry Finger 	RTL_IMR_BCNDMAINT2,	/*Beacon DMA Interrupt 2 */
695f1d2b4d3SLarry Finger 	RTL_IMR_BCNDMAINT1,	/*Beacon DMA Interrupt 1 */
696f1d2b4d3SLarry Finger 	RTL_IMR_BCNDOK8,	/*Beacon Queue DMA OK Interrup 8 */
697f1d2b4d3SLarry Finger 	RTL_IMR_BCNDOK7,	/*Beacon Queue DMA OK Interrup 7 */
698f1d2b4d3SLarry Finger 	RTL_IMR_BCNDOK6,	/*Beacon Queue DMA OK Interrup 6 */
699f1d2b4d3SLarry Finger 	RTL_IMR_BCNDOK5,	/*Beacon Queue DMA OK Interrup 5 */
700f1d2b4d3SLarry Finger 	RTL_IMR_BCNDOK4,	/*Beacon Queue DMA OK Interrup 4 */
701f1d2b4d3SLarry Finger 	RTL_IMR_BCNDOK3,	/*Beacon Queue DMA OK Interrup 3 */
702f1d2b4d3SLarry Finger 	RTL_IMR_BCNDOK2,	/*Beacon Queue DMA OK Interrup 2 */
703f1d2b4d3SLarry Finger 	RTL_IMR_BCNDOK1,	/*Beacon Queue DMA OK Interrup 1 */
704f1d2b4d3SLarry Finger 	RTL_IMR_TIMEOUT2,	/*Timeout interrupt 2 */
705f1d2b4d3SLarry Finger 	RTL_IMR_TIMEOUT1,	/*Timeout interrupt 1 */
706f1d2b4d3SLarry Finger 	RTL_IMR_TXFOVW,		/*Transmit FIFO Overflow */
707f1d2b4d3SLarry Finger 	RTL_IMR_PSTIMEOUT,	/*Power save time out interrupt */
708f1d2b4d3SLarry Finger 	RTL_IMR_BCNINT,		/*Beacon DMA Interrupt 0 */
709f1d2b4d3SLarry Finger 	RTL_IMR_RXFOVW,		/*Receive FIFO Overflow */
710f1d2b4d3SLarry Finger 	RTL_IMR_RDU,		/*Receive Descriptor Unavailable */
711f1d2b4d3SLarry Finger 	RTL_IMR_ATIMEND,	/*For 92C,ATIM Window End Interrupt */
712f1d2b4d3SLarry Finger 	RTL_IMR_BDOK,		/*Beacon Queue DMA OK Interrup */
713f1d2b4d3SLarry Finger 	RTL_IMR_HIGHDOK,	/*High Queue DMA OK Interrupt */
714f1d2b4d3SLarry Finger 	RTL_IMR_COMDOK,		/*Command Queue DMA OK Interrupt*/
715f1d2b4d3SLarry Finger 	RTL_IMR_TBDOK,		/*Transmit Beacon OK interrup */
716f1d2b4d3SLarry Finger 	RTL_IMR_MGNTDOK,	/*Management Queue DMA OK Interrupt */
717f1d2b4d3SLarry Finger 	RTL_IMR_TBDER,		/*For 92C,Transmit Beacon Error Interrupt */
718f1d2b4d3SLarry Finger 	RTL_IMR_BKDOK,		/*AC_BK DMA OK Interrupt */
719f1d2b4d3SLarry Finger 	RTL_IMR_BEDOK,		/*AC_BE DMA OK Interrupt */
720f1d2b4d3SLarry Finger 	RTL_IMR_VIDOK,		/*AC_VI DMA OK Interrupt */
721f1d2b4d3SLarry Finger 	RTL_IMR_VODOK,		/*AC_VO DMA Interrupt */
722f1d2b4d3SLarry Finger 	RTL_IMR_ROK,		/*Receive DMA OK Interrupt */
723f1d2b4d3SLarry Finger 	RTL_IMR_HSISR_IND,	/*HSISR Interrupt*/
724f1d2b4d3SLarry Finger 	RTL_IBSS_INT_MASKS,	/*(RTL_IMR_BCNINT | RTL_IMR_TBDOK |
725f1d2b4d3SLarry Finger 				 * RTL_IMR_TBDER) */
726f1d2b4d3SLarry Finger 	RTL_IMR_C2HCMD,		/*fw interrupt*/
727f1d2b4d3SLarry Finger 
728f1d2b4d3SLarry Finger 	/*CCK Rates, TxHT = 0 */
729f1d2b4d3SLarry Finger 	RTL_RC_CCK_RATE1M,
730f1d2b4d3SLarry Finger 	RTL_RC_CCK_RATE2M,
731f1d2b4d3SLarry Finger 	RTL_RC_CCK_RATE5_5M,
732f1d2b4d3SLarry Finger 	RTL_RC_CCK_RATE11M,
733f1d2b4d3SLarry Finger 
734f1d2b4d3SLarry Finger 	/*OFDM Rates, TxHT = 0 */
735f1d2b4d3SLarry Finger 	RTL_RC_OFDM_RATE6M,
736f1d2b4d3SLarry Finger 	RTL_RC_OFDM_RATE9M,
737f1d2b4d3SLarry Finger 	RTL_RC_OFDM_RATE12M,
738f1d2b4d3SLarry Finger 	RTL_RC_OFDM_RATE18M,
739f1d2b4d3SLarry Finger 	RTL_RC_OFDM_RATE24M,
740f1d2b4d3SLarry Finger 	RTL_RC_OFDM_RATE36M,
741f1d2b4d3SLarry Finger 	RTL_RC_OFDM_RATE48M,
742f1d2b4d3SLarry Finger 	RTL_RC_OFDM_RATE54M,
743f1d2b4d3SLarry Finger 
744f1d2b4d3SLarry Finger 	RTL_RC_HT_RATEMCS7,
745f1d2b4d3SLarry Finger 	RTL_RC_HT_RATEMCS15,
746f1d2b4d3SLarry Finger 
747f1d2b4d3SLarry Finger 	RTL_RC_VHT_RATE_1SS_MCS7,
748f1d2b4d3SLarry Finger 	RTL_RC_VHT_RATE_1SS_MCS8,
749f1d2b4d3SLarry Finger 	RTL_RC_VHT_RATE_1SS_MCS9,
750f1d2b4d3SLarry Finger 	RTL_RC_VHT_RATE_2SS_MCS7,
751f1d2b4d3SLarry Finger 	RTL_RC_VHT_RATE_2SS_MCS8,
752f1d2b4d3SLarry Finger 	RTL_RC_VHT_RATE_2SS_MCS9,
753f1d2b4d3SLarry Finger 
754f1d2b4d3SLarry Finger 	/*keep it last */
755f1d2b4d3SLarry Finger 	RTL_VAR_MAP_MAX,
756f1d2b4d3SLarry Finger };
757f1d2b4d3SLarry Finger 
758f1d2b4d3SLarry Finger /*Firmware PS mode for control LPS.*/
759f1d2b4d3SLarry Finger enum _fw_ps_mode {
760f1d2b4d3SLarry Finger 	FW_PS_ACTIVE_MODE = 0,
761f1d2b4d3SLarry Finger 	FW_PS_MIN_MODE = 1,
762f1d2b4d3SLarry Finger 	FW_PS_MAX_MODE = 2,
763f1d2b4d3SLarry Finger 	FW_PS_DTIM_MODE = 3,
764f1d2b4d3SLarry Finger 	FW_PS_VOIP_MODE = 4,
765f1d2b4d3SLarry Finger 	FW_PS_UAPSD_WMM_MODE = 5,
766f1d2b4d3SLarry Finger 	FW_PS_UAPSD_MODE = 6,
767f1d2b4d3SLarry Finger 	FW_PS_IBSS_MODE = 7,
768f1d2b4d3SLarry Finger 	FW_PS_WWLAN_MODE = 8,
769f1d2b4d3SLarry Finger 	FW_PS_PM_Radio_Off = 9,
770f1d2b4d3SLarry Finger 	FW_PS_PM_Card_Disable = 10,
771f1d2b4d3SLarry Finger };
772f1d2b4d3SLarry Finger 
773f1d2b4d3SLarry Finger enum rt_psmode {
774f1d2b4d3SLarry Finger 	EACTIVE,		/*Active/Continuous access. */
775f1d2b4d3SLarry Finger 	EMAXPS,			/*Max power save mode. */
776f1d2b4d3SLarry Finger 	EFASTPS,		/*Fast power save mode. */
777f1d2b4d3SLarry Finger 	EAUTOPS,		/*Auto power save mode. */
778f1d2b4d3SLarry Finger };
779f1d2b4d3SLarry Finger 
780f1d2b4d3SLarry Finger /*LED related.*/
781f1d2b4d3SLarry Finger enum led_ctl_mode {
782f1d2b4d3SLarry Finger 	LED_CTL_POWER_ON = 1,
783f1d2b4d3SLarry Finger 	LED_CTL_LINK = 2,
784f1d2b4d3SLarry Finger 	LED_CTL_NO_LINK = 3,
785f1d2b4d3SLarry Finger 	LED_CTL_TX = 4,
786f1d2b4d3SLarry Finger 	LED_CTL_RX = 5,
787f1d2b4d3SLarry Finger 	LED_CTL_SITE_SURVEY = 6,
788f1d2b4d3SLarry Finger 	LED_CTL_POWER_OFF = 7,
789f1d2b4d3SLarry Finger 	LED_CTL_START_TO_LINK = 8,
790f1d2b4d3SLarry Finger 	LED_CTL_START_WPS = 9,
791f1d2b4d3SLarry Finger 	LED_CTL_STOP_WPS = 10,
792f1d2b4d3SLarry Finger };
793f1d2b4d3SLarry Finger 
794f1d2b4d3SLarry Finger enum rtl_led_pin {
795f1d2b4d3SLarry Finger 	LED_PIN_GPIO0,
796f1d2b4d3SLarry Finger 	LED_PIN_LED0,
797f1d2b4d3SLarry Finger 	LED_PIN_LED1,
798f1d2b4d3SLarry Finger 	LED_PIN_LED2
799f1d2b4d3SLarry Finger };
800f1d2b4d3SLarry Finger 
801f1d2b4d3SLarry Finger /*QoS related.*/
802f1d2b4d3SLarry Finger /*acm implementation method.*/
803f1d2b4d3SLarry Finger enum acm_method {
804f1d2b4d3SLarry Finger 	eAcmWay0_SwAndHw = 0,
805f1d2b4d3SLarry Finger 	eAcmWay1_HW = 1,
806f1d2b4d3SLarry Finger 	EACMWAY2_SW = 2,
807f1d2b4d3SLarry Finger };
808f1d2b4d3SLarry Finger 
809f1d2b4d3SLarry Finger enum macphy_mode {
810f1d2b4d3SLarry Finger 	SINGLEMAC_SINGLEPHY = 0,
811f1d2b4d3SLarry Finger 	DUALMAC_DUALPHY,
812f1d2b4d3SLarry Finger 	DUALMAC_SINGLEPHY,
813f1d2b4d3SLarry Finger };
814f1d2b4d3SLarry Finger 
815f1d2b4d3SLarry Finger enum band_type {
816f1d2b4d3SLarry Finger 	BAND_ON_2_4G = 0,
817f1d2b4d3SLarry Finger 	BAND_ON_5G,
818f1d2b4d3SLarry Finger 	BAND_ON_BOTH,
819f1d2b4d3SLarry Finger 	BANDMAX
820f1d2b4d3SLarry Finger };
821f1d2b4d3SLarry Finger 
822f1d2b4d3SLarry Finger /*aci/aifsn Field.
823f1d2b4d3SLarry Finger Ref: WMM spec 2.2.2: WME Parameter Element, p.12.*/
824f1d2b4d3SLarry Finger union aci_aifsn {
825f1d2b4d3SLarry Finger 	u8 char_data;
826f1d2b4d3SLarry Finger 
827f1d2b4d3SLarry Finger 	struct {
828f1d2b4d3SLarry Finger 		u8 aifsn:4;
829f1d2b4d3SLarry Finger 		u8 acm:1;
830f1d2b4d3SLarry Finger 		u8 aci:2;
831f1d2b4d3SLarry Finger 		u8 reserved:1;
832f1d2b4d3SLarry Finger 	} f;			/* Field */
833f1d2b4d3SLarry Finger };
834f1d2b4d3SLarry Finger 
835f1d2b4d3SLarry Finger /*mlme related.*/
836f1d2b4d3SLarry Finger enum wireless_mode {
837f1d2b4d3SLarry Finger 	WIRELESS_MODE_UNKNOWN = 0x00,
838f1d2b4d3SLarry Finger 	WIRELESS_MODE_A = 0x01,
839f1d2b4d3SLarry Finger 	WIRELESS_MODE_B = 0x02,
840f1d2b4d3SLarry Finger 	WIRELESS_MODE_G = 0x04,
841f1d2b4d3SLarry Finger 	WIRELESS_MODE_AUTO = 0x08,
842f1d2b4d3SLarry Finger 	WIRELESS_MODE_N_24G = 0x10,
843f1d2b4d3SLarry Finger 	WIRELESS_MODE_N_5G = 0x20,
844f1d2b4d3SLarry Finger 	WIRELESS_MODE_AC_5G = 0x40,
845f1d2b4d3SLarry Finger 	WIRELESS_MODE_AC_24G  = 0x80,
846f1d2b4d3SLarry Finger 	WIRELESS_MODE_AC_ONLY = 0x100,
847f1d2b4d3SLarry Finger 	WIRELESS_MODE_MAX = 0x800
848f1d2b4d3SLarry Finger };
849f1d2b4d3SLarry Finger 
850f1d2b4d3SLarry Finger #define IS_WIRELESS_MODE_A(wirelessmode)	\
851f1d2b4d3SLarry Finger 	(wirelessmode == WIRELESS_MODE_A)
852f1d2b4d3SLarry Finger #define IS_WIRELESS_MODE_B(wirelessmode)	\
853f1d2b4d3SLarry Finger 	(wirelessmode == WIRELESS_MODE_B)
854f1d2b4d3SLarry Finger #define IS_WIRELESS_MODE_G(wirelessmode)	\
855f1d2b4d3SLarry Finger 	(wirelessmode == WIRELESS_MODE_G)
856f1d2b4d3SLarry Finger #define IS_WIRELESS_MODE_N_24G(wirelessmode)	\
857f1d2b4d3SLarry Finger 	(wirelessmode == WIRELESS_MODE_N_24G)
858f1d2b4d3SLarry Finger #define IS_WIRELESS_MODE_N_5G(wirelessmode)	\
859f1d2b4d3SLarry Finger 	(wirelessmode == WIRELESS_MODE_N_5G)
860f1d2b4d3SLarry Finger 
861f1d2b4d3SLarry Finger enum ratr_table_mode {
862f1d2b4d3SLarry Finger 	RATR_INX_WIRELESS_NGB = 0,
863f1d2b4d3SLarry Finger 	RATR_INX_WIRELESS_NG = 1,
864f1d2b4d3SLarry Finger 	RATR_INX_WIRELESS_NB = 2,
865f1d2b4d3SLarry Finger 	RATR_INX_WIRELESS_N = 3,
866f1d2b4d3SLarry Finger 	RATR_INX_WIRELESS_GB = 4,
867f1d2b4d3SLarry Finger 	RATR_INX_WIRELESS_G = 5,
868f1d2b4d3SLarry Finger 	RATR_INX_WIRELESS_B = 6,
869f1d2b4d3SLarry Finger 	RATR_INX_WIRELESS_MC = 7,
870f1d2b4d3SLarry Finger 	RATR_INX_WIRELESS_A = 8,
871f1d2b4d3SLarry Finger 	RATR_INX_WIRELESS_AC_5N = 8,
872f1d2b4d3SLarry Finger 	RATR_INX_WIRELESS_AC_24N = 9,
873f1d2b4d3SLarry Finger };
874f1d2b4d3SLarry Finger 
875f1d2b4d3SLarry Finger enum rtl_link_state {
876f1d2b4d3SLarry Finger 	MAC80211_NOLINK = 0,
877f1d2b4d3SLarry Finger 	MAC80211_LINKING = 1,
878f1d2b4d3SLarry Finger 	MAC80211_LINKED = 2,
879f1d2b4d3SLarry Finger 	MAC80211_LINKED_SCANNING = 3,
880f1d2b4d3SLarry Finger };
881f1d2b4d3SLarry Finger 
882f1d2b4d3SLarry Finger enum act_category {
883f1d2b4d3SLarry Finger 	ACT_CAT_QOS = 1,
884f1d2b4d3SLarry Finger 	ACT_CAT_DLS = 2,
885f1d2b4d3SLarry Finger 	ACT_CAT_BA = 3,
886f1d2b4d3SLarry Finger 	ACT_CAT_HT = 7,
887f1d2b4d3SLarry Finger 	ACT_CAT_WMM = 17,
888f1d2b4d3SLarry Finger };
889f1d2b4d3SLarry Finger 
890f1d2b4d3SLarry Finger enum ba_action {
891f1d2b4d3SLarry Finger 	ACT_ADDBAREQ = 0,
892f1d2b4d3SLarry Finger 	ACT_ADDBARSP = 1,
893f1d2b4d3SLarry Finger 	ACT_DELBA = 2,
894f1d2b4d3SLarry Finger };
895f1d2b4d3SLarry Finger 
896f1d2b4d3SLarry Finger enum rt_polarity_ctl {
897f1d2b4d3SLarry Finger 	RT_POLARITY_LOW_ACT = 0,
898f1d2b4d3SLarry Finger 	RT_POLARITY_HIGH_ACT = 1,
899f1d2b4d3SLarry Finger };
900f1d2b4d3SLarry Finger 
901f1d2b4d3SLarry Finger /* After 8188E, we use V2 reason define. 88C/8723A use V1 reason. */
902f1d2b4d3SLarry Finger enum fw_wow_reason_v2 {
903f1d2b4d3SLarry Finger 	FW_WOW_V2_PTK_UPDATE_EVENT = 0x01,
904f1d2b4d3SLarry Finger 	FW_WOW_V2_GTK_UPDATE_EVENT = 0x02,
905f1d2b4d3SLarry Finger 	FW_WOW_V2_DISASSOC_EVENT = 0x04,
906f1d2b4d3SLarry Finger 	FW_WOW_V2_DEAUTH_EVENT = 0x08,
907f1d2b4d3SLarry Finger 	FW_WOW_V2_FW_DISCONNECT_EVENT = 0x10,
908f1d2b4d3SLarry Finger 	FW_WOW_V2_MAGIC_PKT_EVENT = 0x21,
909f1d2b4d3SLarry Finger 	FW_WOW_V2_UNICAST_PKT_EVENT = 0x22,
910f1d2b4d3SLarry Finger 	FW_WOW_V2_PATTERN_PKT_EVENT = 0x23,
911f1d2b4d3SLarry Finger 	FW_WOW_V2_RTD3_SSID_MATCH_EVENT = 0x24,
912f1d2b4d3SLarry Finger 	FW_WOW_V2_REALWOW_V2_WAKEUPPKT = 0x30,
913f1d2b4d3SLarry Finger 	FW_WOW_V2_REALWOW_V2_ACKLOST = 0x31,
914f1d2b4d3SLarry Finger 	FW_WOW_V2_REASON_MAX = 0xff,
915f1d2b4d3SLarry Finger };
916f1d2b4d3SLarry Finger 
917f1d2b4d3SLarry Finger enum wolpattern_type {
918f1d2b4d3SLarry Finger 	UNICAST_PATTERN = 0,
919f1d2b4d3SLarry Finger 	MULTICAST_PATTERN = 1,
920f1d2b4d3SLarry Finger 	BROADCAST_PATTERN = 2,
921f1d2b4d3SLarry Finger 	DONT_CARE_DA = 3,
922f1d2b4d3SLarry Finger 	UNKNOWN_TYPE = 4,
923f1d2b4d3SLarry Finger };
924f1d2b4d3SLarry Finger 
9257fe1fe75SPing-Ke Shih enum package_type {
9267fe1fe75SPing-Ke Shih 	PACKAGE_DEFAULT,
9277fe1fe75SPing-Ke Shih 	PACKAGE_QFN68,
9287fe1fe75SPing-Ke Shih 	PACKAGE_TFBGA90,
9297fe1fe75SPing-Ke Shih 	PACKAGE_TFBGA80,
9307fe1fe75SPing-Ke Shih 	PACKAGE_TFBGA79
9317fe1fe75SPing-Ke Shih };
9327fe1fe75SPing-Ke Shih 
933f1d2b4d3SLarry Finger struct octet_string {
934f1d2b4d3SLarry Finger 	u8 *octet;
935f1d2b4d3SLarry Finger 	u16 length;
936f1d2b4d3SLarry Finger };
937f1d2b4d3SLarry Finger 
938f1d2b4d3SLarry Finger struct rtl_hdr_3addr {
939f1d2b4d3SLarry Finger 	__le16 frame_ctl;
940f1d2b4d3SLarry Finger 	__le16 duration_id;
941f1d2b4d3SLarry Finger 	u8 addr1[ETH_ALEN];
942f1d2b4d3SLarry Finger 	u8 addr2[ETH_ALEN];
943f1d2b4d3SLarry Finger 	u8 addr3[ETH_ALEN];
944f1d2b4d3SLarry Finger 	__le16 seq_ctl;
945f1d2b4d3SLarry Finger 	u8 payload[0];
946f1d2b4d3SLarry Finger } __packed;
947f1d2b4d3SLarry Finger 
948f1d2b4d3SLarry Finger struct rtl_info_element {
949f1d2b4d3SLarry Finger 	u8 id;
950f1d2b4d3SLarry Finger 	u8 len;
951f1d2b4d3SLarry Finger 	u8 data[0];
952f1d2b4d3SLarry Finger } __packed;
953f1d2b4d3SLarry Finger 
954f1d2b4d3SLarry Finger struct rtl_probe_rsp {
955f1d2b4d3SLarry Finger 	struct rtl_hdr_3addr header;
956f1d2b4d3SLarry Finger 	u32 time_stamp[2];
957f1d2b4d3SLarry Finger 	__le16 beacon_interval;
958f1d2b4d3SLarry Finger 	__le16 capability;
959f1d2b4d3SLarry Finger 	/*SSID, supported rates, FH params, DS params,
960f1d2b4d3SLarry Finger 	   CF params, IBSS params, TIM (if beacon), RSN */
961f1d2b4d3SLarry Finger 	struct rtl_info_element info_element[0];
962f1d2b4d3SLarry Finger } __packed;
963f1d2b4d3SLarry Finger 
964f1d2b4d3SLarry Finger /*LED related.*/
965f1d2b4d3SLarry Finger /*ledpin Identify how to implement this SW led.*/
966f1d2b4d3SLarry Finger struct rtl_led {
967f1d2b4d3SLarry Finger 	void *hw;
968f1d2b4d3SLarry Finger 	enum rtl_led_pin ledpin;
969f1d2b4d3SLarry Finger 	bool ledon;
970f1d2b4d3SLarry Finger };
971f1d2b4d3SLarry Finger 
972f1d2b4d3SLarry Finger struct rtl_led_ctl {
973f1d2b4d3SLarry Finger 	bool led_opendrain;
974f1d2b4d3SLarry Finger 	struct rtl_led sw_led0;
975f1d2b4d3SLarry Finger 	struct rtl_led sw_led1;
976f1d2b4d3SLarry Finger };
977f1d2b4d3SLarry Finger 
978f1d2b4d3SLarry Finger struct rtl_qos_parameters {
979f1d2b4d3SLarry Finger 	__le16 cw_min;
980f1d2b4d3SLarry Finger 	__le16 cw_max;
981f1d2b4d3SLarry Finger 	u8 aifs;
982f1d2b4d3SLarry Finger 	u8 flag;
983f1d2b4d3SLarry Finger 	__le16 tx_op;
984f1d2b4d3SLarry Finger } __packed;
985f1d2b4d3SLarry Finger 
986f1d2b4d3SLarry Finger struct rt_smooth_data {
987f1d2b4d3SLarry Finger 	u32 elements[100];	/*array to store values */
988f1d2b4d3SLarry Finger 	u32 index;		/*index to current array to store */
989f1d2b4d3SLarry Finger 	u32 total_num;		/*num of valid elements */
990f1d2b4d3SLarry Finger 	u32 total_val;		/*sum of valid elements */
991f1d2b4d3SLarry Finger };
992f1d2b4d3SLarry Finger 
993f1d2b4d3SLarry Finger struct false_alarm_statistics {
994f1d2b4d3SLarry Finger 	u32 cnt_parity_fail;
995f1d2b4d3SLarry Finger 	u32 cnt_rate_illegal;
996f1d2b4d3SLarry Finger 	u32 cnt_crc8_fail;
997f1d2b4d3SLarry Finger 	u32 cnt_mcs_fail;
998f1d2b4d3SLarry Finger 	u32 cnt_fast_fsync_fail;
999f1d2b4d3SLarry Finger 	u32 cnt_sb_search_fail;
1000f1d2b4d3SLarry Finger 	u32 cnt_ofdm_fail;
1001f1d2b4d3SLarry Finger 	u32 cnt_cck_fail;
1002f1d2b4d3SLarry Finger 	u32 cnt_all;
1003f1d2b4d3SLarry Finger 	u32 cnt_ofdm_cca;
1004f1d2b4d3SLarry Finger 	u32 cnt_cck_cca;
1005f1d2b4d3SLarry Finger 	u32 cnt_cca_all;
1006f1d2b4d3SLarry Finger 	u32 cnt_bw_usc;
1007f1d2b4d3SLarry Finger 	u32 cnt_bw_lsc;
1008f1d2b4d3SLarry Finger };
1009f1d2b4d3SLarry Finger 
1010f1d2b4d3SLarry Finger struct init_gain {
1011f1d2b4d3SLarry Finger 	u8 xaagccore1;
1012f1d2b4d3SLarry Finger 	u8 xbagccore1;
1013f1d2b4d3SLarry Finger 	u8 xcagccore1;
1014f1d2b4d3SLarry Finger 	u8 xdagccore1;
1015f1d2b4d3SLarry Finger 	u8 cca;
1016f1d2b4d3SLarry Finger 
1017f1d2b4d3SLarry Finger };
1018f1d2b4d3SLarry Finger 
1019f1d2b4d3SLarry Finger struct wireless_stats {
102074451b93SPing-Ke Shih 	u64 txbytesunicast;
102174451b93SPing-Ke Shih 	u64 txbytesmulticast;
102274451b93SPing-Ke Shih 	u64 txbytesbroadcast;
102374451b93SPing-Ke Shih 	u64 rxbytesunicast;
102474451b93SPing-Ke Shih 
102574451b93SPing-Ke Shih 	u64 txbytesunicast_inperiod;
102674451b93SPing-Ke Shih 	u64 rxbytesunicast_inperiod;
102774451b93SPing-Ke Shih 	u32 txbytesunicast_inperiod_tp;
102874451b93SPing-Ke Shih 	u32 rxbytesunicast_inperiod_tp;
102974451b93SPing-Ke Shih 	u64 txbytesunicast_last;
103074451b93SPing-Ke Shih 	u64 rxbytesunicast_last;
1031f1d2b4d3SLarry Finger 
1032f1d2b4d3SLarry Finger 	long rx_snr_db[4];
1033f1d2b4d3SLarry Finger 	/*Correct smoothed ss in Dbm, only used
1034f1d2b4d3SLarry Finger 	   in driver to report real power now. */
1035f1d2b4d3SLarry Finger 	long recv_signal_power;
1036f1d2b4d3SLarry Finger 	long signal_quality;
1037f1d2b4d3SLarry Finger 	long last_sigstrength_inpercent;
1038f1d2b4d3SLarry Finger 
1039f1d2b4d3SLarry Finger 	u32 rssi_calculate_cnt;
1040f1d2b4d3SLarry Finger 	u32 pwdb_all_cnt;
1041f1d2b4d3SLarry Finger 
1042f1d2b4d3SLarry Finger 	/*Transformed, in dbm. Beautified signal
1043f1d2b4d3SLarry Finger 	   strength for UI, not correct. */
1044f1d2b4d3SLarry Finger 	long signal_strength;
1045f1d2b4d3SLarry Finger 
1046f1d2b4d3SLarry Finger 	u8 rx_rssi_percentage[4];
1047f1d2b4d3SLarry Finger 	u8 rx_evm_dbm[4];
1048f1d2b4d3SLarry Finger 	u8 rx_evm_percentage[2];
1049f1d2b4d3SLarry Finger 
1050f1d2b4d3SLarry Finger 	u16 rx_cfo_short[4];
1051f1d2b4d3SLarry Finger 	u16 rx_cfo_tail[4];
1052f1d2b4d3SLarry Finger 
1053f1d2b4d3SLarry Finger 	struct rt_smooth_data ui_rssi;
1054f1d2b4d3SLarry Finger 	struct rt_smooth_data ui_link_quality;
1055f1d2b4d3SLarry Finger };
1056f1d2b4d3SLarry Finger 
1057f1d2b4d3SLarry Finger struct rate_adaptive {
1058f1d2b4d3SLarry Finger 	u8 rate_adaptive_disabled;
1059f1d2b4d3SLarry Finger 	u8 ratr_state;
1060f1d2b4d3SLarry Finger 	u16 reserve;
1061f1d2b4d3SLarry Finger 
1062f1d2b4d3SLarry Finger 	u32 high_rssi_thresh_for_ra;
1063f1d2b4d3SLarry Finger 	u32 high2low_rssi_thresh_for_ra;
1064f1d2b4d3SLarry Finger 	u8 low2high_rssi_thresh_for_ra40m;
1065f1d2b4d3SLarry Finger 	u32 low_rssi_thresh_for_ra40m;
1066f1d2b4d3SLarry Finger 	u8 low2high_rssi_thresh_for_ra20m;
1067f1d2b4d3SLarry Finger 	u32 low_rssi_thresh_for_ra20m;
1068f1d2b4d3SLarry Finger 	u32 upper_rssi_threshold_ratr;
1069f1d2b4d3SLarry Finger 	u32 middleupper_rssi_threshold_ratr;
1070f1d2b4d3SLarry Finger 	u32 middle_rssi_threshold_ratr;
1071f1d2b4d3SLarry Finger 	u32 middlelow_rssi_threshold_ratr;
1072f1d2b4d3SLarry Finger 	u32 low_rssi_threshold_ratr;
1073f1d2b4d3SLarry Finger 	u32 ultralow_rssi_threshold_ratr;
1074f1d2b4d3SLarry Finger 	u32 low_rssi_threshold_ratr_40m;
1075f1d2b4d3SLarry Finger 	u32 low_rssi_threshold_ratr_20m;
1076f1d2b4d3SLarry Finger 	u8 ping_rssi_enable;
1077f1d2b4d3SLarry Finger 	u32 ping_rssi_ratr;
1078f1d2b4d3SLarry Finger 	u32 ping_rssi_thresh_for_ra;
1079f1d2b4d3SLarry Finger 	u32 last_ratr;
1080f1d2b4d3SLarry Finger 	u8 pre_ratr_state;
1081f1d2b4d3SLarry Finger 	u8 ldpc_thres;
1082f1d2b4d3SLarry Finger 	bool use_ldpc;
1083f1d2b4d3SLarry Finger 	bool lower_rts_rate;
1084f1d2b4d3SLarry Finger 	bool is_special_data;
1085f1d2b4d3SLarry Finger };
1086f1d2b4d3SLarry Finger 
1087f1d2b4d3SLarry Finger struct regd_pair_mapping {
1088f1d2b4d3SLarry Finger 	u16 reg_dmnenum;
1089f1d2b4d3SLarry Finger 	u16 reg_5ghz_ctl;
1090f1d2b4d3SLarry Finger 	u16 reg_2ghz_ctl;
1091f1d2b4d3SLarry Finger };
1092f1d2b4d3SLarry Finger 
1093f1d2b4d3SLarry Finger struct dynamic_primary_cca {
1094f1d2b4d3SLarry Finger 	u8 pricca_flag;
1095f1d2b4d3SLarry Finger 	u8 intf_flag;
1096f1d2b4d3SLarry Finger 	u8 intf_type;
1097f1d2b4d3SLarry Finger 	u8 dup_rts_flag;
1098f1d2b4d3SLarry Finger 	u8 monitor_flag;
1099f1d2b4d3SLarry Finger 	u8 ch_offset;
1100f1d2b4d3SLarry Finger 	u8 mf_state;
1101f1d2b4d3SLarry Finger };
1102f1d2b4d3SLarry Finger 
1103f1d2b4d3SLarry Finger struct rtl_regulatory {
110408aba42fSArnd Bergmann 	s8 alpha2[2];
1105f1d2b4d3SLarry Finger 	u16 country_code;
1106f1d2b4d3SLarry Finger 	u16 max_power_level;
1107f1d2b4d3SLarry Finger 	u32 tp_scale;
1108f1d2b4d3SLarry Finger 	u16 current_rd;
1109f1d2b4d3SLarry Finger 	u16 current_rd_ext;
1110f1d2b4d3SLarry Finger 	int16_t power_limit;
1111f1d2b4d3SLarry Finger 	struct regd_pair_mapping *regpair;
1112f1d2b4d3SLarry Finger };
1113f1d2b4d3SLarry Finger 
1114f1d2b4d3SLarry Finger struct rtl_rfkill {
1115f1d2b4d3SLarry Finger 	bool rfkill_state;	/*0 is off, 1 is on */
1116f1d2b4d3SLarry Finger };
1117f1d2b4d3SLarry Finger 
1118f1d2b4d3SLarry Finger /*for P2P PS**/
1119f1d2b4d3SLarry Finger #define	P2P_MAX_NOA_NUM		2
1120f1d2b4d3SLarry Finger 
1121f1d2b4d3SLarry Finger enum p2p_role {
1122f1d2b4d3SLarry Finger 	P2P_ROLE_DISABLE = 0,
1123f1d2b4d3SLarry Finger 	P2P_ROLE_DEVICE = 1,
1124f1d2b4d3SLarry Finger 	P2P_ROLE_CLIENT = 2,
1125f1d2b4d3SLarry Finger 	P2P_ROLE_GO = 3
1126f1d2b4d3SLarry Finger };
1127f1d2b4d3SLarry Finger 
1128f1d2b4d3SLarry Finger enum p2p_ps_state {
1129f1d2b4d3SLarry Finger 	P2P_PS_DISABLE = 0,
1130f1d2b4d3SLarry Finger 	P2P_PS_ENABLE = 1,
1131f1d2b4d3SLarry Finger 	P2P_PS_SCAN = 2,
1132f1d2b4d3SLarry Finger 	P2P_PS_SCAN_DONE = 3,
1133f1d2b4d3SLarry Finger 	P2P_PS_ALLSTASLEEP = 4, /* for P2P GO */
1134f1d2b4d3SLarry Finger };
1135f1d2b4d3SLarry Finger 
1136f1d2b4d3SLarry Finger enum p2p_ps_mode {
1137f1d2b4d3SLarry Finger 	P2P_PS_NONE = 0,
1138f1d2b4d3SLarry Finger 	P2P_PS_CTWINDOW = 1,
1139f1d2b4d3SLarry Finger 	P2P_PS_NOA	 = 2,
1140f1d2b4d3SLarry Finger 	P2P_PS_MIX = 3, /* CTWindow and NoA */
1141f1d2b4d3SLarry Finger };
1142f1d2b4d3SLarry Finger 
1143f1d2b4d3SLarry Finger struct rtl_p2p_ps_info {
1144f1d2b4d3SLarry Finger 	enum p2p_ps_mode p2p_ps_mode; /* indicate p2p ps mode */
1145f1d2b4d3SLarry Finger 	enum p2p_ps_state p2p_ps_state; /*  indicate p2p ps state */
1146f1d2b4d3SLarry Finger 	u8 noa_index; /*  Identifies instance of Notice of Absence timing. */
1147f1d2b4d3SLarry Finger 	/*  Client traffic window. A period of time in TU after TBTT. */
1148f1d2b4d3SLarry Finger 	u8 ctwindow;
1149f1d2b4d3SLarry Finger 	u8 opp_ps; /*  opportunistic power save. */
1150f1d2b4d3SLarry Finger 	u8 noa_num; /*  number of NoA descriptor in P2P IE. */
1151f1d2b4d3SLarry Finger 	/*  Count for owner, Type of client. */
1152f1d2b4d3SLarry Finger 	u8 noa_count_type[P2P_MAX_NOA_NUM];
1153f1d2b4d3SLarry Finger 	/*  Max duration for owner, preferred or min acceptable duration
1154f1d2b4d3SLarry Finger 	 * for client.
1155f1d2b4d3SLarry Finger 	 */
1156f1d2b4d3SLarry Finger 	u32 noa_duration[P2P_MAX_NOA_NUM];
1157f1d2b4d3SLarry Finger 	/*  Length of interval for owner, preferred or max acceptable intervali
1158f1d2b4d3SLarry Finger 	 * of client.
1159f1d2b4d3SLarry Finger 	 */
1160f1d2b4d3SLarry Finger 	u32 noa_interval[P2P_MAX_NOA_NUM];
1161f1d2b4d3SLarry Finger 	/*  schedule in terms of the lower 4 bytes of the TSF timer. */
1162f1d2b4d3SLarry Finger 	u32 noa_start_time[P2P_MAX_NOA_NUM];
1163f1d2b4d3SLarry Finger };
1164f1d2b4d3SLarry Finger 
1165f1d2b4d3SLarry Finger struct p2p_ps_offload_t {
1166f1d2b4d3SLarry Finger 	u8 offload_en:1;
1167f1d2b4d3SLarry Finger 	u8 role:1; /* 1: Owner, 0: Client */
1168f1d2b4d3SLarry Finger 	u8 ctwindow_en:1;
1169f1d2b4d3SLarry Finger 	u8 noa0_en:1;
1170f1d2b4d3SLarry Finger 	u8 noa1_en:1;
1171f1d2b4d3SLarry Finger 	u8 allstasleep:1;
1172f1d2b4d3SLarry Finger 	u8 discovery:1;
1173f1d2b4d3SLarry Finger 	u8 reserved:1;
1174f1d2b4d3SLarry Finger };
1175f1d2b4d3SLarry Finger 
1176f1d2b4d3SLarry Finger #define IQK_MATRIX_REG_NUM	8
1177f1d2b4d3SLarry Finger #define IQK_MATRIX_SETTINGS_NUM	(1 + 24 + 21)
1178f1d2b4d3SLarry Finger 
1179f1d2b4d3SLarry Finger struct iqk_matrix_regs {
1180f1d2b4d3SLarry Finger 	bool iqk_done;
1181f1d2b4d3SLarry Finger 	long value[1][IQK_MATRIX_REG_NUM];
1182f1d2b4d3SLarry Finger };
1183f1d2b4d3SLarry Finger 
1184f1d2b4d3SLarry Finger struct phy_parameters {
1185f1d2b4d3SLarry Finger 	u16 length;
1186f1d2b4d3SLarry Finger 	u32 *pdata;
1187f1d2b4d3SLarry Finger };
1188f1d2b4d3SLarry Finger 
1189f1d2b4d3SLarry Finger enum hw_param_tab_index {
1190f1d2b4d3SLarry Finger 	PHY_REG_2T,
1191f1d2b4d3SLarry Finger 	PHY_REG_1T,
1192f1d2b4d3SLarry Finger 	PHY_REG_PG,
1193f1d2b4d3SLarry Finger 	RADIOA_2T,
1194f1d2b4d3SLarry Finger 	RADIOB_2T,
1195f1d2b4d3SLarry Finger 	RADIOA_1T,
1196f1d2b4d3SLarry Finger 	RADIOB_1T,
1197f1d2b4d3SLarry Finger 	MAC_REG,
1198f1d2b4d3SLarry Finger 	AGCTAB_2T,
1199f1d2b4d3SLarry Finger 	AGCTAB_1T,
1200f1d2b4d3SLarry Finger 	MAX_TAB
1201f1d2b4d3SLarry Finger };
1202f1d2b4d3SLarry Finger 
1203f1d2b4d3SLarry Finger struct rtl_phy {
1204f1d2b4d3SLarry Finger 	struct bb_reg_def phyreg_def[4];	/*Radio A/B/C/D */
1205f1d2b4d3SLarry Finger 	struct init_gain initgain_backup;
1206f1d2b4d3SLarry Finger 	enum io_type current_io_type;
1207f1d2b4d3SLarry Finger 
1208f1d2b4d3SLarry Finger 	u8 rf_mode;
1209f1d2b4d3SLarry Finger 	u8 rf_type;
1210f1d2b4d3SLarry Finger 	u8 current_chan_bw;
1211f1d2b4d3SLarry Finger 	u8 set_bwmode_inprogress;
1212f1d2b4d3SLarry Finger 	u8 sw_chnl_inprogress;
1213f1d2b4d3SLarry Finger 	u8 sw_chnl_stage;
1214f1d2b4d3SLarry Finger 	u8 sw_chnl_step;
1215f1d2b4d3SLarry Finger 	u8 current_channel;
1216f1d2b4d3SLarry Finger 	u8 h2c_box_num;
1217f1d2b4d3SLarry Finger 	u8 set_io_inprogress;
1218f1d2b4d3SLarry Finger 	u8 lck_inprogress;
1219f1d2b4d3SLarry Finger 
1220f1d2b4d3SLarry Finger 	/* record for power tracking */
1221f1d2b4d3SLarry Finger 	s32 reg_e94;
1222f1d2b4d3SLarry Finger 	s32 reg_e9c;
1223f1d2b4d3SLarry Finger 	s32 reg_ea4;
1224f1d2b4d3SLarry Finger 	s32 reg_eac;
1225f1d2b4d3SLarry Finger 	s32 reg_eb4;
1226f1d2b4d3SLarry Finger 	s32 reg_ebc;
1227f1d2b4d3SLarry Finger 	s32 reg_ec4;
1228f1d2b4d3SLarry Finger 	s32 reg_ecc;
1229f1d2b4d3SLarry Finger 	u8 rfpienable;
1230f1d2b4d3SLarry Finger 	u8 reserve_0;
1231f1d2b4d3SLarry Finger 	u16 reserve_1;
1232f1d2b4d3SLarry Finger 	u32 reg_c04, reg_c08, reg_874;
1233f1d2b4d3SLarry Finger 	u32 adda_backup[16];
1234f1d2b4d3SLarry Finger 	u32 iqk_mac_backup[IQK_MAC_REG_NUM];
1235f1d2b4d3SLarry Finger 	u32 iqk_bb_backup[10];
1236f1d2b4d3SLarry Finger 	bool iqk_initialized;
1237f1d2b4d3SLarry Finger 
1238f1d2b4d3SLarry Finger 	bool rfpath_rx_enable[MAX_RF_PATH];
1239f1d2b4d3SLarry Finger 	u8 reg_837;
1240f1d2b4d3SLarry Finger 	/* Dual mac */
1241f1d2b4d3SLarry Finger 	bool need_iqk;
1242f1d2b4d3SLarry Finger 	struct iqk_matrix_regs iqk_matrix[IQK_MATRIX_SETTINGS_NUM];
1243f1d2b4d3SLarry Finger 
1244f1d2b4d3SLarry Finger 	bool rfpi_enable;
1245f1d2b4d3SLarry Finger 	bool iqk_in_progress;
1246f1d2b4d3SLarry Finger 
1247f1d2b4d3SLarry Finger 	u8 pwrgroup_cnt;
1248f1d2b4d3SLarry Finger 	u8 cck_high_power;
1249f1d2b4d3SLarry Finger 	/* this is for 88E & 8723A */
1250f1d2b4d3SLarry Finger 	u32 mcs_txpwrlevel_origoffset[MAX_PG_GROUP][16];
1251f1d2b4d3SLarry Finger 	/* MAX_PG_GROUP groups of pwr diff by rates */
1252f1d2b4d3SLarry Finger 	u32 mcs_offset[MAX_PG_GROUP][16];
1253f1d2b4d3SLarry Finger 	u32 tx_power_by_rate_offset[TX_PWR_BY_RATE_NUM_BAND]
1254f1d2b4d3SLarry Finger 				   [TX_PWR_BY_RATE_NUM_RF]
1255f1d2b4d3SLarry Finger 				   [TX_PWR_BY_RATE_NUM_RF]
1256f1d2b4d3SLarry Finger 				   [TX_PWR_BY_RATE_NUM_SECTION];
1257f1d2b4d3SLarry Finger 	u8 txpwr_by_rate_base_24g[TX_PWR_BY_RATE_NUM_RF]
1258f1d2b4d3SLarry Finger 				 [TX_PWR_BY_RATE_NUM_RF]
1259f1d2b4d3SLarry Finger 				 [MAX_BASE_NUM_IN_PHY_REG_PG_24G];
1260f1d2b4d3SLarry Finger 	u8 txpwr_by_rate_base_5g[TX_PWR_BY_RATE_NUM_RF]
1261f1d2b4d3SLarry Finger 				[TX_PWR_BY_RATE_NUM_RF]
1262f1d2b4d3SLarry Finger 				[MAX_BASE_NUM_IN_PHY_REG_PG_5G];
1263f1d2b4d3SLarry Finger 	u8 default_initialgain[4];
1264f1d2b4d3SLarry Finger 
1265f1d2b4d3SLarry Finger 	/* the current Tx power level */
1266f1d2b4d3SLarry Finger 	u8 cur_cck_txpwridx;
1267f1d2b4d3SLarry Finger 	u8 cur_ofdm24g_txpwridx;
1268f1d2b4d3SLarry Finger 	u8 cur_bw20_txpwridx;
1269f1d2b4d3SLarry Finger 	u8 cur_bw40_txpwridx;
1270f1d2b4d3SLarry Finger 
127108aba42fSArnd Bergmann 	s8 txpwr_limit_2_4g[MAX_REGULATION_NUM]
1272d5e58252SLarry Finger 			   [MAX_2_4G_BANDWIDTH_NUM]
1273f1d2b4d3SLarry Finger 			   [MAX_RATE_SECTION_NUM]
1274f1d2b4d3SLarry Finger 			   [CHANNEL_MAX_NUMBER_2G]
1275f1d2b4d3SLarry Finger 			   [MAX_RF_PATH_NUM];
127608aba42fSArnd Bergmann 	s8 txpwr_limit_5g[MAX_REGULATION_NUM]
1277d5e58252SLarry Finger 			 [MAX_5G_BANDWIDTH_NUM]
1278f1d2b4d3SLarry Finger 			 [MAX_RATE_SECTION_NUM]
1279f1d2b4d3SLarry Finger 			 [CHANNEL_MAX_NUMBER_5G]
1280f1d2b4d3SLarry Finger 			 [MAX_RF_PATH_NUM];
1281f1d2b4d3SLarry Finger 
1282f1d2b4d3SLarry Finger 	u32 rfreg_chnlval[2];
1283f1d2b4d3SLarry Finger 	bool apk_done;
1284f1d2b4d3SLarry Finger 	u32 reg_rf3c[2];	/* pathA / pathB  */
1285f1d2b4d3SLarry Finger 
1286f1d2b4d3SLarry Finger 	u32 backup_rf_0x1a;/*92ee*/
1287f1d2b4d3SLarry Finger 	/* bfsync */
1288f1d2b4d3SLarry Finger 	u8 framesync;
1289f1d2b4d3SLarry Finger 	u32 framesync_c34;
1290f1d2b4d3SLarry Finger 
1291f1d2b4d3SLarry Finger 	u8 num_total_rfpath;
1292f1d2b4d3SLarry Finger 	struct phy_parameters hwparam_tables[MAX_TAB];
1293f1d2b4d3SLarry Finger 	u16 rf_pathmap;
1294f1d2b4d3SLarry Finger 
1295f1d2b4d3SLarry Finger 	u8 hw_rof_enable; /*Enable GPIO[9] as WL RF HW PDn source*/
1296f1d2b4d3SLarry Finger 	enum rt_polarity_ctl polarity_ctl;
1297f1d2b4d3SLarry Finger };
1298f1d2b4d3SLarry Finger 
1299f1d2b4d3SLarry Finger #define MAX_TID_COUNT				9
1300f1d2b4d3SLarry Finger #define RTL_AGG_STOP				0
1301f1d2b4d3SLarry Finger #define RTL_AGG_PROGRESS			1
1302f1d2b4d3SLarry Finger #define RTL_AGG_START				2
1303f1d2b4d3SLarry Finger #define RTL_AGG_OPERATIONAL			3
1304f1d2b4d3SLarry Finger #define RTL_AGG_OFF				0
1305f1d2b4d3SLarry Finger #define RTL_AGG_ON				1
1306f1d2b4d3SLarry Finger #define RTL_RX_AGG_START			1
1307f1d2b4d3SLarry Finger #define RTL_RX_AGG_STOP				0
1308f1d2b4d3SLarry Finger #define RTL_AGG_EMPTYING_HW_QUEUE_ADDBA		2
1309f1d2b4d3SLarry Finger #define RTL_AGG_EMPTYING_HW_QUEUE_DELBA		3
1310f1d2b4d3SLarry Finger 
1311f1d2b4d3SLarry Finger struct rtl_ht_agg {
1312f1d2b4d3SLarry Finger 	u16 txq_id;
1313f1d2b4d3SLarry Finger 	u16 wait_for_ba;
1314f1d2b4d3SLarry Finger 	u16 start_idx;
1315f1d2b4d3SLarry Finger 	u64 bitmap;
1316f1d2b4d3SLarry Finger 	u32 rate_n_flags;
1317f1d2b4d3SLarry Finger 	u8 agg_state;
1318f1d2b4d3SLarry Finger 	u8 rx_agg_state;
1319f1d2b4d3SLarry Finger };
1320f1d2b4d3SLarry Finger 
1321f1d2b4d3SLarry Finger struct rssi_sta {
1322f1d2b4d3SLarry Finger 	long undec_sm_pwdb;
1323f1d2b4d3SLarry Finger 	long undec_sm_cck;
1324f1d2b4d3SLarry Finger };
1325f1d2b4d3SLarry Finger 
1326f1d2b4d3SLarry Finger struct rtl_tid_data {
1327f1d2b4d3SLarry Finger 	u16 seq_number;
1328f1d2b4d3SLarry Finger 	struct rtl_ht_agg agg;
1329f1d2b4d3SLarry Finger };
1330f1d2b4d3SLarry Finger 
1331f1d2b4d3SLarry Finger struct rtl_sta_info {
1332f1d2b4d3SLarry Finger 	struct list_head list;
1333f1d2b4d3SLarry Finger 	struct rtl_tid_data tids[MAX_TID_COUNT];
1334f1d2b4d3SLarry Finger 	/* just used for ap adhoc or mesh*/
1335f1d2b4d3SLarry Finger 	struct rssi_sta rssi_stat;
133608ab7465SPing-Ke Shih 	u8 rssi_level;
133773fb2705SLarry Finger 	u16 wireless_mode;
133873fb2705SLarry Finger 	u8 ratr_index;
133973fb2705SLarry Finger 	u8 mimo_ps;
134073fb2705SLarry Finger 	u8 mac_addr[ETH_ALEN];
1341f1d2b4d3SLarry Finger } __packed;
1342f1d2b4d3SLarry Finger 
1343f1d2b4d3SLarry Finger struct rtl_priv;
1344f1d2b4d3SLarry Finger struct rtl_io {
1345f1d2b4d3SLarry Finger 	struct device *dev;
1346f1d2b4d3SLarry Finger 	struct mutex bb_mutex;
1347f1d2b4d3SLarry Finger 
1348f1d2b4d3SLarry Finger 	/*PCI MEM map */
1349f1d2b4d3SLarry Finger 	unsigned long pci_mem_end;	/*shared mem end        */
1350f1d2b4d3SLarry Finger 	unsigned long pci_mem_start;	/*shared mem start */
1351f1d2b4d3SLarry Finger 
1352f1d2b4d3SLarry Finger 	/*PCI IO map */
1353f1d2b4d3SLarry Finger 	unsigned long pci_base_addr;	/*device I/O address */
1354f1d2b4d3SLarry Finger 
1355f1d2b4d3SLarry Finger 	void (*write8_async) (struct rtl_priv *rtlpriv, u32 addr, u8 val);
1356f1d2b4d3SLarry Finger 	void (*write16_async) (struct rtl_priv *rtlpriv, u32 addr, u16 val);
1357f1d2b4d3SLarry Finger 	void (*write32_async) (struct rtl_priv *rtlpriv, u32 addr, u32 val);
1358f1d2b4d3SLarry Finger 	void (*writeN_sync) (struct rtl_priv *rtlpriv, u32 addr, void *buf,
1359f1d2b4d3SLarry Finger 			     u16 len);
1360f1d2b4d3SLarry Finger 
1361f1d2b4d3SLarry Finger 	u8(*read8_sync) (struct rtl_priv *rtlpriv, u32 addr);
1362f1d2b4d3SLarry Finger 	u16(*read16_sync) (struct rtl_priv *rtlpriv, u32 addr);
1363f1d2b4d3SLarry Finger 	u32(*read32_sync) (struct rtl_priv *rtlpriv, u32 addr);
1364f1d2b4d3SLarry Finger 
1365f1d2b4d3SLarry Finger };
1366f1d2b4d3SLarry Finger 
1367f1d2b4d3SLarry Finger struct rtl_mac {
1368f1d2b4d3SLarry Finger 	u8 mac_addr[ETH_ALEN];
1369f1d2b4d3SLarry Finger 	u8 mac80211_registered;
1370f1d2b4d3SLarry Finger 	u8 beacon_enabled;
1371f1d2b4d3SLarry Finger 
1372f1d2b4d3SLarry Finger 	u32 tx_ss_num;
1373f1d2b4d3SLarry Finger 	u32 rx_ss_num;
1374f1d2b4d3SLarry Finger 
137557fbcce3SJohannes Berg 	struct ieee80211_supported_band bands[NUM_NL80211_BANDS];
1376f1d2b4d3SLarry Finger 	struct ieee80211_hw *hw;
1377f1d2b4d3SLarry Finger 	struct ieee80211_vif *vif;
1378f1d2b4d3SLarry Finger 	enum nl80211_iftype opmode;
1379f1d2b4d3SLarry Finger 
1380f1d2b4d3SLarry Finger 	/*Probe Beacon management */
1381f1d2b4d3SLarry Finger 	struct rtl_tid_data tids[MAX_TID_COUNT];
1382f1d2b4d3SLarry Finger 	enum rtl_link_state link_state;
1383f1d2b4d3SLarry Finger 
1384f1d2b4d3SLarry Finger 	int n_channels;
1385f1d2b4d3SLarry Finger 	int n_bitrates;
1386f1d2b4d3SLarry Finger 
1387f1d2b4d3SLarry Finger 	bool offchan_delay;
1388f1d2b4d3SLarry Finger 	u8 p2p;	/*using p2p role*/
1389f1d2b4d3SLarry Finger 	bool p2p_in_use;
1390f1d2b4d3SLarry Finger 
1391f1d2b4d3SLarry Finger 	/*filters */
1392f1d2b4d3SLarry Finger 	u32 rx_conf;
1393f1d2b4d3SLarry Finger 	u16 rx_mgt_filter;
1394f1d2b4d3SLarry Finger 	u16 rx_ctrl_filter;
1395f1d2b4d3SLarry Finger 	u16 rx_data_filter;
1396f1d2b4d3SLarry Finger 
1397f1d2b4d3SLarry Finger 	bool act_scanning;
1398f1d2b4d3SLarry Finger 	u8 cnt_after_linked;
1399f1d2b4d3SLarry Finger 	bool skip_scan;
1400f1d2b4d3SLarry Finger 
1401f1d2b4d3SLarry Finger 	/* early mode */
1402f1d2b4d3SLarry Finger 	/* skb wait queue */
1403f1d2b4d3SLarry Finger 	struct sk_buff_head skb_waitq[MAX_TID_COUNT];
1404f1d2b4d3SLarry Finger 
1405f1d2b4d3SLarry Finger 	u8 ht_stbc_cap;
1406f1d2b4d3SLarry Finger 	u8 ht_cur_stbc;
1407f1d2b4d3SLarry Finger 
1408f1d2b4d3SLarry Finger 	/*vht support*/
1409f1d2b4d3SLarry Finger 	u8 vht_enable;
1410f1d2b4d3SLarry Finger 	u8 bw_80;
1411f1d2b4d3SLarry Finger 	u8 vht_cur_ldpc;
1412f1d2b4d3SLarry Finger 	u8 vht_cur_stbc;
1413f1d2b4d3SLarry Finger 	u8 vht_stbc_cap;
1414f1d2b4d3SLarry Finger 	u8 vht_ldpc_cap;
1415f1d2b4d3SLarry Finger 
1416f1d2b4d3SLarry Finger 	/*RDG*/
1417f1d2b4d3SLarry Finger 	bool rdg_en;
1418f1d2b4d3SLarry Finger 
1419f1d2b4d3SLarry Finger 	/*AP*/
1420f1d2b4d3SLarry Finger 	u8 bssid[ETH_ALEN] __aligned(2);
1421f1d2b4d3SLarry Finger 	u32 vendor;
1422f1d2b4d3SLarry Finger 	u8 mcs[16];	/* 16 bytes mcs for HT rates. */
1423f1d2b4d3SLarry Finger 	u32 basic_rates; /* b/g rates */
1424f1d2b4d3SLarry Finger 	u8 ht_enable;
1425f1d2b4d3SLarry Finger 	u8 sgi_40;
1426f1d2b4d3SLarry Finger 	u8 sgi_20;
1427f1d2b4d3SLarry Finger 	u8 bw_40;
1428f1d2b4d3SLarry Finger 	u16 mode;		/* wireless mode */
1429f1d2b4d3SLarry Finger 	u8 slot_time;
1430f1d2b4d3SLarry Finger 	u8 short_preamble;
1431f1d2b4d3SLarry Finger 	u8 use_cts_protect;
1432f1d2b4d3SLarry Finger 	u8 cur_40_prime_sc;
1433f1d2b4d3SLarry Finger 	u8 cur_40_prime_sc_bk;
1434f1d2b4d3SLarry Finger 	u8 cur_80_prime_sc;
1435f1d2b4d3SLarry Finger 	u64 tsf;
1436f1d2b4d3SLarry Finger 	u8 retry_short;
1437f1d2b4d3SLarry Finger 	u8 retry_long;
1438f1d2b4d3SLarry Finger 	u16 assoc_id;
1439f1d2b4d3SLarry Finger 	bool hiddenssid;
1440f1d2b4d3SLarry Finger 
1441f1d2b4d3SLarry Finger 	/*IBSS*/
1442f1d2b4d3SLarry Finger 	int beacon_interval;
1443f1d2b4d3SLarry Finger 
1444f1d2b4d3SLarry Finger 	/*AMPDU*/
1445f1d2b4d3SLarry Finger 	u8 min_space_cfg;	/*For Min spacing configurations */
1446f1d2b4d3SLarry Finger 	u8 max_mss_density;
1447f1d2b4d3SLarry Finger 	u8 current_ampdu_factor;
1448f1d2b4d3SLarry Finger 	u8 current_ampdu_density;
1449f1d2b4d3SLarry Finger 
1450f1d2b4d3SLarry Finger 	/*QOS & EDCA */
1451f1d2b4d3SLarry Finger 	struct ieee80211_tx_queue_params edca_param[RTL_MAC80211_NUM_QUEUE];
1452f1d2b4d3SLarry Finger 	struct rtl_qos_parameters ac[AC_MAX];
1453f1d2b4d3SLarry Finger 
1454f1d2b4d3SLarry Finger 	/* counters */
1455f1d2b4d3SLarry Finger 	u64 last_txok_cnt;
1456f1d2b4d3SLarry Finger 	u64 last_rxok_cnt;
1457f1d2b4d3SLarry Finger 	u32 last_bt_edca_ul;
1458f1d2b4d3SLarry Finger 	u32 last_bt_edca_dl;
1459f1d2b4d3SLarry Finger };
1460f1d2b4d3SLarry Finger 
1461f1d2b4d3SLarry Finger struct btdm_8723 {
1462f1d2b4d3SLarry Finger 	bool all_off;
1463f1d2b4d3SLarry Finger 	bool agc_table_en;
1464f1d2b4d3SLarry Finger 	bool adc_back_off_on;
1465f1d2b4d3SLarry Finger 	bool b2_ant_hid_en;
1466f1d2b4d3SLarry Finger 	bool low_penalty_rate_adaptive;
1467f1d2b4d3SLarry Finger 	bool rf_rx_lpf_shrink;
1468f1d2b4d3SLarry Finger 	bool reject_aggre_pkt;
1469f1d2b4d3SLarry Finger 	bool tra_tdma_on;
1470f1d2b4d3SLarry Finger 	u8 tra_tdma_nav;
1471f1d2b4d3SLarry Finger 	u8 tra_tdma_ant;
1472f1d2b4d3SLarry Finger 	bool tdma_on;
1473f1d2b4d3SLarry Finger 	u8 tdma_ant;
1474f1d2b4d3SLarry Finger 	u8 tdma_nav;
1475f1d2b4d3SLarry Finger 	u8 tdma_dac_swing;
1476f1d2b4d3SLarry Finger 	u8 fw_dac_swing_lvl;
1477f1d2b4d3SLarry Finger 	bool ps_tdma_on;
1478f1d2b4d3SLarry Finger 	u8 ps_tdma_byte[5];
1479f1d2b4d3SLarry Finger 	bool pta_on;
1480f1d2b4d3SLarry Finger 	u32 val_0x6c0;
1481f1d2b4d3SLarry Finger 	u32 val_0x6c8;
1482f1d2b4d3SLarry Finger 	u32 val_0x6cc;
1483f1d2b4d3SLarry Finger 	bool sw_dac_swing_on;
1484f1d2b4d3SLarry Finger 	u32 sw_dac_swing_lvl;
1485f1d2b4d3SLarry Finger 	u32 wlan_act_hi;
1486f1d2b4d3SLarry Finger 	u32 wlan_act_lo;
1487f1d2b4d3SLarry Finger 	u32 bt_retry_index;
1488f1d2b4d3SLarry Finger 	bool dec_bt_pwr;
1489f1d2b4d3SLarry Finger 	bool ignore_wlan_act;
1490f1d2b4d3SLarry Finger };
1491f1d2b4d3SLarry Finger 
1492f1d2b4d3SLarry Finger struct bt_coexist_8723 {
1493f1d2b4d3SLarry Finger 	u32 high_priority_tx;
1494f1d2b4d3SLarry Finger 	u32 high_priority_rx;
1495f1d2b4d3SLarry Finger 	u32 low_priority_tx;
1496f1d2b4d3SLarry Finger 	u32 low_priority_rx;
1497f1d2b4d3SLarry Finger 	u8 c2h_bt_info;
1498f1d2b4d3SLarry Finger 	bool c2h_bt_info_req_sent;
1499f1d2b4d3SLarry Finger 	bool c2h_bt_inquiry_page;
1500f1d2b4d3SLarry Finger 	u32 bt_inq_page_start_time;
1501f1d2b4d3SLarry Finger 	u8 bt_retry_cnt;
1502f1d2b4d3SLarry Finger 	u8 c2h_bt_info_original;
1503f1d2b4d3SLarry Finger 	u8 bt_inquiry_page_cnt;
1504f1d2b4d3SLarry Finger 	struct btdm_8723 btdm;
1505f1d2b4d3SLarry Finger };
1506f1d2b4d3SLarry Finger 
1507f1d2b4d3SLarry Finger struct rtl_hal {
1508f1d2b4d3SLarry Finger 	struct ieee80211_hw *hw;
1509f1d2b4d3SLarry Finger 	bool driver_is_goingto_unload;
1510f1d2b4d3SLarry Finger 	bool up_first_time;
1511f1d2b4d3SLarry Finger 	bool first_init;
1512f1d2b4d3SLarry Finger 	bool being_init_adapter;
1513f1d2b4d3SLarry Finger 	bool bbrf_ready;
1514f1d2b4d3SLarry Finger 	bool mac_func_enable;
1515f1d2b4d3SLarry Finger 	bool pre_edcca_enable;
1516f1d2b4d3SLarry Finger 	struct bt_coexist_8723 hal_coex_8723;
1517f1d2b4d3SLarry Finger 
1518f1d2b4d3SLarry Finger 	enum intf_type interface;
1519f1d2b4d3SLarry Finger 	u16 hw_type;		/*92c or 92d or 92s and so on */
1520f1d2b4d3SLarry Finger 	u8 ic_class;
1521f1d2b4d3SLarry Finger 	u8 oem_id;
1522f1d2b4d3SLarry Finger 	u32 version;		/*version of chip */
1523f1d2b4d3SLarry Finger 	u8 state;		/*stop 0, start 1 */
1524f1d2b4d3SLarry Finger 	u8 board_type;
15257fe1fe75SPing-Ke Shih 	u8 package_type;
1526f1d2b4d3SLarry Finger 	u8 external_pa;
1527f1d2b4d3SLarry Finger 
1528f1d2b4d3SLarry Finger 	u8 pa_mode;
1529f1d2b4d3SLarry Finger 	u8 pa_type_2g;
1530f1d2b4d3SLarry Finger 	u8 pa_type_5g;
1531f1d2b4d3SLarry Finger 	u8 lna_type_2g;
1532f1d2b4d3SLarry Finger 	u8 lna_type_5g;
1533f1d2b4d3SLarry Finger 	u8 external_pa_2g;
1534f1d2b4d3SLarry Finger 	u8 external_lna_2g;
1535f1d2b4d3SLarry Finger 	u8 external_pa_5g;
1536f1d2b4d3SLarry Finger 	u8 external_lna_5g;
153784d26fdaSPing-Ke Shih 	u8 type_glna;
153884d26fdaSPing-Ke Shih 	u8 type_gpa;
153984d26fdaSPing-Ke Shih 	u8 type_alna;
154084d26fdaSPing-Ke Shih 	u8 type_apa;
1541f1d2b4d3SLarry Finger 	u8 rfe_type;
1542f1d2b4d3SLarry Finger 
1543f1d2b4d3SLarry Finger 	/*firmware */
1544f1d2b4d3SLarry Finger 	u32 fwsize;
1545f1d2b4d3SLarry Finger 	u8 *pfirmware;
1546f1d2b4d3SLarry Finger 	u16 fw_version;
1547f1d2b4d3SLarry Finger 	u16 fw_subversion;
1548f1d2b4d3SLarry Finger 	bool h2c_setinprogress;
1549f1d2b4d3SLarry Finger 	u8 last_hmeboxnum;
1550f1d2b4d3SLarry Finger 	bool fw_ready;
1551f1d2b4d3SLarry Finger 	/*Reserve page start offset except beacon in TxQ. */
1552f1d2b4d3SLarry Finger 	u8 fw_rsvdpage_startoffset;
1553f1d2b4d3SLarry Finger 	u8 h2c_txcmd_seq;
1554f1d2b4d3SLarry Finger 	u8 current_ra_rate;
1555f1d2b4d3SLarry Finger 
1556f1d2b4d3SLarry Finger 	/* FW Cmd IO related */
1557f1d2b4d3SLarry Finger 	u16 fwcmd_iomap;
1558f1d2b4d3SLarry Finger 	u32 fwcmd_ioparam;
1559f1d2b4d3SLarry Finger 	bool set_fwcmd_inprogress;
1560f1d2b4d3SLarry Finger 	u8 current_fwcmd_io;
1561f1d2b4d3SLarry Finger 
1562f1d2b4d3SLarry Finger 	struct p2p_ps_offload_t p2p_ps_offload;
1563f1d2b4d3SLarry Finger 	bool fw_clk_change_in_progress;
1564f1d2b4d3SLarry Finger 	bool allow_sw_to_change_hwclc;
1565f1d2b4d3SLarry Finger 	u8 fw_ps_state;
1566f1d2b4d3SLarry Finger 	/**/
1567f1d2b4d3SLarry Finger 	bool driver_going2unload;
1568f1d2b4d3SLarry Finger 
1569f1d2b4d3SLarry Finger 	/*AMPDU init min space*/
1570f1d2b4d3SLarry Finger 	u8 minspace_cfg;	/*For Min spacing configurations */
1571f1d2b4d3SLarry Finger 
1572f1d2b4d3SLarry Finger 	/* Dual mac */
1573f1d2b4d3SLarry Finger 	enum macphy_mode macphymode;
1574f1d2b4d3SLarry Finger 	enum band_type current_bandtype;	/* 0:2.4G, 1:5G */
1575f1d2b4d3SLarry Finger 	enum band_type current_bandtypebackup;
1576f1d2b4d3SLarry Finger 	enum band_type bandset;
1577f1d2b4d3SLarry Finger 	/* dual MAC 0--Mac0 1--Mac1 */
1578f1d2b4d3SLarry Finger 	u32 interfaceindex;
1579f1d2b4d3SLarry Finger 	/* just for DualMac S3S4 */
1580f1d2b4d3SLarry Finger 	u8 macphyctl_reg;
1581f1d2b4d3SLarry Finger 	bool earlymode_enable;
1582f1d2b4d3SLarry Finger 	u8 max_earlymode_num;
1583f1d2b4d3SLarry Finger 	/* Dual mac*/
1584f1d2b4d3SLarry Finger 	bool during_mac0init_radiob;
1585f1d2b4d3SLarry Finger 	bool during_mac1init_radioa;
1586f1d2b4d3SLarry Finger 	bool reloadtxpowerindex;
1587f1d2b4d3SLarry Finger 	/* True if IMR or IQK  have done
1588f1d2b4d3SLarry Finger 	for 2.4G in scan progress */
1589f1d2b4d3SLarry Finger 	bool load_imrandiqk_setting_for2g;
1590f1d2b4d3SLarry Finger 
1591f1d2b4d3SLarry Finger 	bool disable_amsdu_8k;
1592f1d2b4d3SLarry Finger 	bool master_of_dmsp;
1593f1d2b4d3SLarry Finger 	bool slave_of_dmsp;
1594f1d2b4d3SLarry Finger 
1595f1d2b4d3SLarry Finger 	u16 rx_tag;/*for 92ee*/
1596f1d2b4d3SLarry Finger 	u8 rts_en;
1597f1d2b4d3SLarry Finger 
1598f1d2b4d3SLarry Finger 	/*for wowlan*/
1599f1d2b4d3SLarry Finger 	bool wow_enable;
1600f1d2b4d3SLarry Finger 	bool enter_pnp_sleep;
1601f1d2b4d3SLarry Finger 	bool wake_from_pnp_sleep;
1602f1d2b4d3SLarry Finger 	bool wow_enabled;
1603f1d2b4d3SLarry Finger 	__kernel_time_t last_suspend_sec;
1604f1d2b4d3SLarry Finger 	u32 wowlan_fwsize;
1605f1d2b4d3SLarry Finger 	u8 *wowlan_firmware;
1606f1d2b4d3SLarry Finger 
1607f1d2b4d3SLarry Finger 	u8 hw_rof_enable; /*Enable GPIO[9] as WL RF HW PDn source*/
1608f1d2b4d3SLarry Finger 
1609f1d2b4d3SLarry Finger 	bool real_wow_v2_enable;
1610f1d2b4d3SLarry Finger 	bool re_init_llt_table;
1611f1d2b4d3SLarry Finger };
1612f1d2b4d3SLarry Finger 
1613f1d2b4d3SLarry Finger struct rtl_security {
1614f1d2b4d3SLarry Finger 	/*default 0 */
1615f1d2b4d3SLarry Finger 	bool use_sw_sec;
1616f1d2b4d3SLarry Finger 
1617f1d2b4d3SLarry Finger 	bool being_setkey;
1618f1d2b4d3SLarry Finger 	bool use_defaultkey;
1619f1d2b4d3SLarry Finger 	/*Encryption Algorithm for Unicast Packet */
1620f1d2b4d3SLarry Finger 	enum rt_enc_alg pairwise_enc_algorithm;
1621f1d2b4d3SLarry Finger 	/*Encryption Algorithm for Brocast/Multicast */
1622f1d2b4d3SLarry Finger 	enum rt_enc_alg group_enc_algorithm;
1623f1d2b4d3SLarry Finger 	/*Cam Entry Bitmap */
1624f1d2b4d3SLarry Finger 	u32 hwsec_cam_bitmap;
1625f1d2b4d3SLarry Finger 	u8 hwsec_cam_sta_addr[TOTAL_CAM_ENTRY][ETH_ALEN];
1626f1d2b4d3SLarry Finger 	/*local Key buffer, indx 0 is for
1627f1d2b4d3SLarry Finger 	   pairwise key 1-4 is for agoup key. */
1628f1d2b4d3SLarry Finger 	u8 key_buf[KEY_BUF_SIZE][MAX_KEY_LEN];
1629f1d2b4d3SLarry Finger 	u8 key_len[KEY_BUF_SIZE];
1630f1d2b4d3SLarry Finger 
1631f1d2b4d3SLarry Finger 	/*The pointer of Pairwise Key,
1632f1d2b4d3SLarry Finger 	   it always points to KeyBuf[4] */
1633f1d2b4d3SLarry Finger 	u8 *pairwise_key;
1634f1d2b4d3SLarry Finger };
1635f1d2b4d3SLarry Finger 
1636f1d2b4d3SLarry Finger #define ASSOCIATE_ENTRY_NUM	33
1637f1d2b4d3SLarry Finger 
1638f1d2b4d3SLarry Finger struct fast_ant_training {
1639f1d2b4d3SLarry Finger 	u8	bssid[6];
1640f1d2b4d3SLarry Finger 	u8	antsel_rx_keep_0;
1641f1d2b4d3SLarry Finger 	u8	antsel_rx_keep_1;
1642f1d2b4d3SLarry Finger 	u8	antsel_rx_keep_2;
1643f1d2b4d3SLarry Finger 	u32	ant_sum[7];
1644f1d2b4d3SLarry Finger 	u32	ant_cnt[7];
1645f1d2b4d3SLarry Finger 	u32	ant_ave[7];
1646f1d2b4d3SLarry Finger 	u8	fat_state;
1647f1d2b4d3SLarry Finger 	u32	train_idx;
1648f1d2b4d3SLarry Finger 	u8	antsel_a[ASSOCIATE_ENTRY_NUM];
1649f1d2b4d3SLarry Finger 	u8	antsel_b[ASSOCIATE_ENTRY_NUM];
1650f1d2b4d3SLarry Finger 	u8	antsel_c[ASSOCIATE_ENTRY_NUM];
1651f1d2b4d3SLarry Finger 	u32	main_ant_sum[ASSOCIATE_ENTRY_NUM];
1652f1d2b4d3SLarry Finger 	u32	aux_ant_sum[ASSOCIATE_ENTRY_NUM];
1653f1d2b4d3SLarry Finger 	u32	main_ant_cnt[ASSOCIATE_ENTRY_NUM];
1654f1d2b4d3SLarry Finger 	u32	aux_ant_cnt[ASSOCIATE_ENTRY_NUM];
1655f1d2b4d3SLarry Finger 	u8	rx_idle_ant;
1656f1d2b4d3SLarry Finger 	bool	becomelinked;
1657f1d2b4d3SLarry Finger };
1658f1d2b4d3SLarry Finger 
1659f1d2b4d3SLarry Finger struct dm_phy_dbg_info {
166008aba42fSArnd Bergmann 	s8 rx_snrdb[4];
1661f1d2b4d3SLarry Finger 	u64 num_qry_phy_status;
1662f1d2b4d3SLarry Finger 	u64 num_qry_phy_status_cck;
1663f1d2b4d3SLarry Finger 	u64 num_qry_phy_status_ofdm;
1664f1d2b4d3SLarry Finger 	u16 num_qry_beacon_pkt;
1665f1d2b4d3SLarry Finger 	u16 num_non_be_pkt;
1666f1d2b4d3SLarry Finger 	s32 rx_evm[4];
1667f1d2b4d3SLarry Finger };
1668f1d2b4d3SLarry Finger 
1669f1d2b4d3SLarry Finger struct rtl_dm {
1670f1d2b4d3SLarry Finger 	/*PHY status for Dynamic Management */
1671f1d2b4d3SLarry Finger 	long entry_min_undec_sm_pwdb;
1672f1d2b4d3SLarry Finger 	long undec_sm_cck;
1673f1d2b4d3SLarry Finger 	long undec_sm_pwdb;	/*out dm */
1674f1d2b4d3SLarry Finger 	long entry_max_undec_sm_pwdb;
1675f1d2b4d3SLarry Finger 	s32 ofdm_pkt_cnt;
1676f1d2b4d3SLarry Finger 	bool dm_initialgain_enable;
1677f1d2b4d3SLarry Finger 	bool dynamic_txpower_enable;
1678f1d2b4d3SLarry Finger 	bool current_turbo_edca;
1679f1d2b4d3SLarry Finger 	bool is_any_nonbepkts;	/*out dm */
1680f1d2b4d3SLarry Finger 	bool is_cur_rdlstate;
1681f1d2b4d3SLarry Finger 	bool txpower_trackinginit;
1682f1d2b4d3SLarry Finger 	bool disable_framebursting;
1683f1d2b4d3SLarry Finger 	bool cck_inch14;
1684f1d2b4d3SLarry Finger 	bool txpower_tracking;
1685f1d2b4d3SLarry Finger 	bool useramask;
1686f1d2b4d3SLarry Finger 	bool rfpath_rxenable[4];
1687f1d2b4d3SLarry Finger 	bool inform_fw_driverctrldm;
1688f1d2b4d3SLarry Finger 	bool current_mrc_switch;
1689f1d2b4d3SLarry Finger 	u8 txpowercount;
1690f1d2b4d3SLarry Finger 	u8 powerindex_backup[6];
1691f1d2b4d3SLarry Finger 
1692f1d2b4d3SLarry Finger 	u8 thermalvalue_rxgain;
1693f1d2b4d3SLarry Finger 	u8 thermalvalue_iqk;
1694f1d2b4d3SLarry Finger 	u8 thermalvalue_lck;
1695f1d2b4d3SLarry Finger 	u8 thermalvalue;
1696f1d2b4d3SLarry Finger 	u8 last_dtp_lvl;
1697f1d2b4d3SLarry Finger 	u8 thermalvalue_avg[AVG_THERMAL_NUM];
1698f1d2b4d3SLarry Finger 	u8 thermalvalue_avg_index;
1699f1d2b4d3SLarry Finger 	u8 tm_trigger;
1700f1d2b4d3SLarry Finger 	bool done_txpower;
1701f1d2b4d3SLarry Finger 	u8 dynamic_txhighpower_lvl;	/*Tx high power level */
1702f1d2b4d3SLarry Finger 	u8 dm_flag;		/*Indicate each dynamic mechanism's status. */
1703f1d2b4d3SLarry Finger 	u8 dm_flag_tmp;
1704f1d2b4d3SLarry Finger 	u8 dm_type;
1705f1d2b4d3SLarry Finger 	u8 dm_rssi_sel;
1706f1d2b4d3SLarry Finger 	u8 txpower_track_control;
1707f1d2b4d3SLarry Finger 	bool interrupt_migration;
1708f1d2b4d3SLarry Finger 	bool disable_tx_int;
170908aba42fSArnd Bergmann 	s8 ofdm_index[MAX_RF_PATH];
1710f1d2b4d3SLarry Finger 	u8 default_ofdm_index;
1711f1d2b4d3SLarry Finger 	u8 default_cck_index;
171208aba42fSArnd Bergmann 	s8 cck_index;
171308aba42fSArnd Bergmann 	s8 delta_power_index[MAX_RF_PATH];
171408aba42fSArnd Bergmann 	s8 delta_power_index_last[MAX_RF_PATH];
171508aba42fSArnd Bergmann 	s8 power_index_offset[MAX_RF_PATH];
171608aba42fSArnd Bergmann 	s8 absolute_ofdm_swing_idx[MAX_RF_PATH];
171708aba42fSArnd Bergmann 	s8 remnant_ofdm_swing_idx[MAX_RF_PATH];
171808aba42fSArnd Bergmann 	s8 remnant_cck_idx;
1719f1d2b4d3SLarry Finger 	bool modify_txagc_flag_path_a;
1720f1d2b4d3SLarry Finger 	bool modify_txagc_flag_path_b;
1721f1d2b4d3SLarry Finger 
1722f1d2b4d3SLarry Finger 	bool one_entry_only;
1723f1d2b4d3SLarry Finger 	struct dm_phy_dbg_info dbginfo;
1724f1d2b4d3SLarry Finger 
1725f1d2b4d3SLarry Finger 	/* Dynamic ATC switch */
1726f1d2b4d3SLarry Finger 	bool atc_status;
1727f1d2b4d3SLarry Finger 	bool large_cfo_hit;
1728f1d2b4d3SLarry Finger 	bool is_freeze;
1729f1d2b4d3SLarry Finger 	int cfo_tail[2];
1730f1d2b4d3SLarry Finger 	int cfo_ave_pre;
1731f1d2b4d3SLarry Finger 	int crystal_cap;
1732f1d2b4d3SLarry Finger 	u8 cfo_threshold;
1733f1d2b4d3SLarry Finger 	u32 packet_count;
1734f1d2b4d3SLarry Finger 	u32 packet_count_pre;
1735f1d2b4d3SLarry Finger 	u8 tx_rate;
1736f1d2b4d3SLarry Finger 
1737f1d2b4d3SLarry Finger 	/*88e tx power tracking*/
1738f1d2b4d3SLarry Finger 	u8	swing_idx_ofdm[MAX_RF_PATH];
1739f1d2b4d3SLarry Finger 	u8	swing_idx_ofdm_cur;
1740f1d2b4d3SLarry Finger 	u8	swing_idx_ofdm_base[MAX_RF_PATH];
1741f1d2b4d3SLarry Finger 	bool	swing_flag_ofdm;
1742f1d2b4d3SLarry Finger 	u8	swing_idx_cck;
1743f1d2b4d3SLarry Finger 	u8	swing_idx_cck_cur;
1744f1d2b4d3SLarry Finger 	u8	swing_idx_cck_base;
1745f1d2b4d3SLarry Finger 	bool	swing_flag_cck;
1746f1d2b4d3SLarry Finger 
174708aba42fSArnd Bergmann 	s8	swing_diff_2g;
174808aba42fSArnd Bergmann 	s8	swing_diff_5g;
1749f1d2b4d3SLarry Finger 
1750f1d2b4d3SLarry Finger 	/* DMSP */
1751f1d2b4d3SLarry Finger 	bool supp_phymode_switch;
1752f1d2b4d3SLarry Finger 
1753f1d2b4d3SLarry Finger 	/* DulMac */
1754f1d2b4d3SLarry Finger 	struct fast_ant_training fat_table;
1755f1d2b4d3SLarry Finger 
1756f1d2b4d3SLarry Finger 	u8	resp_tx_path;
1757f1d2b4d3SLarry Finger 	u8	path_sel;
1758f1d2b4d3SLarry Finger 	u32	patha_sum;
1759f1d2b4d3SLarry Finger 	u32	pathb_sum;
1760f1d2b4d3SLarry Finger 	u32	patha_cnt;
1761f1d2b4d3SLarry Finger 	u32	pathb_cnt;
1762f1d2b4d3SLarry Finger 
1763f1d2b4d3SLarry Finger 	u8 pre_channel;
1764f1d2b4d3SLarry Finger 	u8 *p_channel;
1765f1d2b4d3SLarry Finger 	u8 linked_interval;
1766f1d2b4d3SLarry Finger 
1767f1d2b4d3SLarry Finger 	u64 last_tx_ok_cnt;
1768f1d2b4d3SLarry Finger 	u64 last_rx_ok_cnt;
1769f1d2b4d3SLarry Finger };
1770f1d2b4d3SLarry Finger 
1771f1d2b4d3SLarry Finger #define	EFUSE_MAX_LOGICAL_SIZE			512
1772f1d2b4d3SLarry Finger 
1773f1d2b4d3SLarry Finger struct rtl_efuse {
1774f1d2b4d3SLarry Finger 	bool autoLoad_ok;
1775f1d2b4d3SLarry Finger 	bool bootfromefuse;
1776f1d2b4d3SLarry Finger 	u16 max_physical_size;
1777f1d2b4d3SLarry Finger 
1778f1d2b4d3SLarry Finger 	u8 efuse_map[2][EFUSE_MAX_LOGICAL_SIZE];
1779f1d2b4d3SLarry Finger 	u16 efuse_usedbytes;
1780f1d2b4d3SLarry Finger 	u8 efuse_usedpercentage;
1781f1d2b4d3SLarry Finger #ifdef EFUSE_REPG_WORKAROUND
1782f1d2b4d3SLarry Finger 	bool efuse_re_pg_sec1flag;
1783f1d2b4d3SLarry Finger 	u8 efuse_re_pg_data[8];
1784f1d2b4d3SLarry Finger #endif
1785f1d2b4d3SLarry Finger 
1786f1d2b4d3SLarry Finger 	u8 autoload_failflag;
1787f1d2b4d3SLarry Finger 	u8 autoload_status;
1788f1d2b4d3SLarry Finger 
1789f1d2b4d3SLarry Finger 	short epromtype;
1790f1d2b4d3SLarry Finger 	u16 eeprom_vid;
1791f1d2b4d3SLarry Finger 	u16 eeprom_did;
1792f1d2b4d3SLarry Finger 	u16 eeprom_svid;
1793f1d2b4d3SLarry Finger 	u16 eeprom_smid;
1794f1d2b4d3SLarry Finger 	u8 eeprom_oemid;
1795f1d2b4d3SLarry Finger 	u16 eeprom_channelplan;
1796f1d2b4d3SLarry Finger 	u8 eeprom_version;
1797f1d2b4d3SLarry Finger 	u8 board_type;
1798f1d2b4d3SLarry Finger 	u8 external_pa;
1799f1d2b4d3SLarry Finger 
1800f1d2b4d3SLarry Finger 	u8 dev_addr[6];
1801f1d2b4d3SLarry Finger 	u8 wowlan_enable;
1802f1d2b4d3SLarry Finger 	u8 antenna_div_cfg;
1803f1d2b4d3SLarry Finger 	u8 antenna_div_type;
1804f1d2b4d3SLarry Finger 
1805f1d2b4d3SLarry Finger 	bool txpwr_fromeprom;
1806f1d2b4d3SLarry Finger 	u8 eeprom_crystalcap;
1807f1d2b4d3SLarry Finger 	u8 eeprom_tssi[2];
1808f1d2b4d3SLarry Finger 	u8 eeprom_tssi_5g[3][2]; /* for 5GL/5GM/5GH band. */
1809f1d2b4d3SLarry Finger 	u8 eeprom_pwrlimit_ht20[CHANNEL_GROUP_MAX];
1810f1d2b4d3SLarry Finger 	u8 eeprom_pwrlimit_ht40[CHANNEL_GROUP_MAX];
1811f1d2b4d3SLarry Finger 	u8 eeprom_chnlarea_txpwr_cck[MAX_RF_PATH][CHANNEL_GROUP_MAX_2G];
1812f1d2b4d3SLarry Finger 	u8 eeprom_chnlarea_txpwr_ht40_1s[MAX_RF_PATH][CHANNEL_GROUP_MAX];
1813f1d2b4d3SLarry Finger 	u8 eprom_chnl_txpwr_ht40_2sdf[MAX_RF_PATH][CHANNEL_GROUP_MAX];
1814f1d2b4d3SLarry Finger 
1815f1d2b4d3SLarry Finger 	u8 internal_pa_5g[2];	/* pathA / pathB */
1816f1d2b4d3SLarry Finger 	u8 eeprom_c9;
1817f1d2b4d3SLarry Finger 	u8 eeprom_cc;
1818f1d2b4d3SLarry Finger 
1819f1d2b4d3SLarry Finger 	/*For power group */
1820f1d2b4d3SLarry Finger 	u8 eeprom_pwrgroup[2][3];
1821f1d2b4d3SLarry Finger 	u8 pwrgroup_ht20[2][CHANNEL_MAX_NUMBER];
1822f1d2b4d3SLarry Finger 	u8 pwrgroup_ht40[2][CHANNEL_MAX_NUMBER];
1823f1d2b4d3SLarry Finger 
1824f1d2b4d3SLarry Finger 	u8 txpwrlevel_cck[MAX_RF_PATH][CHANNEL_MAX_NUMBER_2G];
1825f1d2b4d3SLarry Finger 	/*For HT 40MHZ pwr */
1826f1d2b4d3SLarry Finger 	u8 txpwrlevel_ht40_1s[MAX_RF_PATH][CHANNEL_MAX_NUMBER];
1827f1d2b4d3SLarry Finger 	/*For HT 40MHZ pwr */
1828f1d2b4d3SLarry Finger 	u8 txpwrlevel_ht40_2s[MAX_RF_PATH][CHANNEL_MAX_NUMBER];
1829f1d2b4d3SLarry Finger 
1830f1d2b4d3SLarry Finger 	/*--------------------------------------------------------*
1831f1d2b4d3SLarry Finger 	 * 8192CE\8192SE\8192DE\8723AE use the following 4 arrays,
1832f1d2b4d3SLarry Finger 	 * other ICs (8188EE\8723BE\8192EE\8812AE...)
1833f1d2b4d3SLarry Finger 	 * define new arrays in Windows code.
1834f1d2b4d3SLarry Finger 	 * BUT, in linux code, we use the same array for all ICs.
1835f1d2b4d3SLarry Finger 	 *
1836f1d2b4d3SLarry Finger 	 * The Correspondance relation between two arrays is:
1837f1d2b4d3SLarry Finger 	 * txpwr_cckdiff[][] == CCK_24G_Diff[][]
1838f1d2b4d3SLarry Finger 	 * txpwr_ht20diff[][] == BW20_24G_Diff[][]
1839f1d2b4d3SLarry Finger 	 * txpwr_ht40diff[][] == BW40_24G_Diff[][]
1840f1d2b4d3SLarry Finger 	 * txpwr_legacyhtdiff[][] == OFDM_24G_Diff[][]
1841f1d2b4d3SLarry Finger 	 *
1842f1d2b4d3SLarry Finger 	 * Sizes of these arrays are decided by the larger ones.
1843f1d2b4d3SLarry Finger 	 */
184408aba42fSArnd Bergmann 	s8 txpwr_cckdiff[MAX_RF_PATH][CHANNEL_MAX_NUMBER];
184508aba42fSArnd Bergmann 	s8 txpwr_ht20diff[MAX_RF_PATH][CHANNEL_MAX_NUMBER];
184608aba42fSArnd Bergmann 	s8 txpwr_ht40diff[MAX_RF_PATH][CHANNEL_MAX_NUMBER];
184708aba42fSArnd Bergmann 	s8 txpwr_legacyhtdiff[MAX_RF_PATH][CHANNEL_MAX_NUMBER];
1848f1d2b4d3SLarry Finger 
1849f1d2b4d3SLarry Finger 	u8 txpwr_5g_bw40base[MAX_RF_PATH][CHANNEL_MAX_NUMBER];
1850f1d2b4d3SLarry Finger 	u8 txpwr_5g_bw80base[MAX_RF_PATH][CHANNEL_MAX_NUMBER_5G_80M];
185108aba42fSArnd Bergmann 	s8 txpwr_5g_ofdmdiff[MAX_RF_PATH][MAX_TX_COUNT];
185208aba42fSArnd Bergmann 	s8 txpwr_5g_bw20diff[MAX_RF_PATH][MAX_TX_COUNT];
185308aba42fSArnd Bergmann 	s8 txpwr_5g_bw40diff[MAX_RF_PATH][MAX_TX_COUNT];
185408aba42fSArnd Bergmann 	s8 txpwr_5g_bw80diff[MAX_RF_PATH][MAX_TX_COUNT];
1855f1d2b4d3SLarry Finger 
1856f1d2b4d3SLarry Finger 	u8 txpwr_safetyflag;			/* Band edge enable flag */
1857f1d2b4d3SLarry Finger 	u16 eeprom_txpowerdiff;
1858f1d2b4d3SLarry Finger 	u8 legacy_httxpowerdiff;	/* Legacy to HT rate power diff */
1859f1d2b4d3SLarry Finger 	u8 antenna_txpwdiff[3];
1860f1d2b4d3SLarry Finger 
1861f1d2b4d3SLarry Finger 	u8 eeprom_regulatory;
1862f1d2b4d3SLarry Finger 	u8 eeprom_thermalmeter;
1863f1d2b4d3SLarry Finger 	u8 thermalmeter[2]; /*ThermalMeter, index 0 for RFIC0, 1 for RFIC1 */
1864f1d2b4d3SLarry Finger 	u16 tssi_13dbm;
1865f1d2b4d3SLarry Finger 	u8 crystalcap;		/* CrystalCap. */
1866f1d2b4d3SLarry Finger 	u8 delta_iqk;
1867f1d2b4d3SLarry Finger 	u8 delta_lck;
1868f1d2b4d3SLarry Finger 
1869f1d2b4d3SLarry Finger 	u8 legacy_ht_txpowerdiff;	/*Legacy to HT rate power diff */
1870f1d2b4d3SLarry Finger 	bool apk_thermalmeterignore;
1871f1d2b4d3SLarry Finger 
1872f1d2b4d3SLarry Finger 	bool b1x1_recvcombine;
1873f1d2b4d3SLarry Finger 	bool b1ss_support;
1874f1d2b4d3SLarry Finger 
1875f1d2b4d3SLarry Finger 	/*channel plan */
1876f1d2b4d3SLarry Finger 	u8 channel_plan;
1877f1d2b4d3SLarry Finger };
1878f1d2b4d3SLarry Finger 
18798479580bSPing-Ke Shih struct rtl_tx_report {
18808479580bSPing-Ke Shih 	atomic_t sn;
18818479580bSPing-Ke Shih 	u16 last_sent_sn;
18828479580bSPing-Ke Shih 	unsigned long last_sent_time;
18838479580bSPing-Ke Shih 	u16 last_recv_sn;
18848479580bSPing-Ke Shih };
18858479580bSPing-Ke Shih 
1886f1d2b4d3SLarry Finger struct rtl_ps_ctl {
1887f1d2b4d3SLarry Finger 	bool pwrdomain_protect;
1888f1d2b4d3SLarry Finger 	bool in_powersavemode;
1889f1d2b4d3SLarry Finger 	bool rfchange_inprogress;
1890f1d2b4d3SLarry Finger 	bool swrf_processing;
1891f1d2b4d3SLarry Finger 	bool hwradiooff;
1892f1d2b4d3SLarry Finger 	/*
1893f1d2b4d3SLarry Finger 	 * just for PCIE ASPM
1894f1d2b4d3SLarry Finger 	 * If it supports ASPM, Offset[560h] = 0x40,
1895f1d2b4d3SLarry Finger 	 * otherwise Offset[560h] = 0x00.
1896f1d2b4d3SLarry Finger 	 * */
1897f1d2b4d3SLarry Finger 	bool support_aspm;
1898f1d2b4d3SLarry Finger 	bool support_backdoor;
1899f1d2b4d3SLarry Finger 
1900f1d2b4d3SLarry Finger 	/*for LPS */
1901f1d2b4d3SLarry Finger 	enum rt_psmode dot11_psmode;	/*Power save mode configured. */
1902f1d2b4d3SLarry Finger 	bool swctrl_lps;
1903f1d2b4d3SLarry Finger 	bool leisure_ps;
1904f1d2b4d3SLarry Finger 	bool fwctrl_lps;
1905f1d2b4d3SLarry Finger 	u8 fwctrl_psmode;
1906f1d2b4d3SLarry Finger 	/*For Fw control LPS mode */
1907f1d2b4d3SLarry Finger 	u8 reg_fwctrl_lps;
1908f1d2b4d3SLarry Finger 	/*Record Fw PS mode status. */
1909f1d2b4d3SLarry Finger 	bool fw_current_inpsmode;
1910f1d2b4d3SLarry Finger 	u8 reg_max_lps_awakeintvl;
1911f1d2b4d3SLarry Finger 	bool report_linked;
1912f1d2b4d3SLarry Finger 	bool low_power_enable;/*for 32k*/
1913f1d2b4d3SLarry Finger 
1914f1d2b4d3SLarry Finger 	/*for IPS */
1915f1d2b4d3SLarry Finger 	bool inactiveps;
1916f1d2b4d3SLarry Finger 
1917f1d2b4d3SLarry Finger 	u32 rfoff_reason;
1918f1d2b4d3SLarry Finger 
1919f1d2b4d3SLarry Finger 	/*RF OFF Level */
1920f1d2b4d3SLarry Finger 	u32 cur_ps_level;
1921f1d2b4d3SLarry Finger 	u32 reg_rfps_level;
1922f1d2b4d3SLarry Finger 
1923f1d2b4d3SLarry Finger 	/*just for PCIE ASPM */
1924f1d2b4d3SLarry Finger 	u8 const_amdpci_aspm;
1925f1d2b4d3SLarry Finger 	bool pwrdown_mode;
1926f1d2b4d3SLarry Finger 
1927f1d2b4d3SLarry Finger 	enum rf_pwrstate inactive_pwrstate;
1928f1d2b4d3SLarry Finger 	enum rf_pwrstate rfpwr_state;	/*cur power state */
1929f1d2b4d3SLarry Finger 
1930f1d2b4d3SLarry Finger 	/* for SW LPS*/
1931f1d2b4d3SLarry Finger 	bool sw_ps_enabled;
1932f1d2b4d3SLarry Finger 	bool state;
1933f1d2b4d3SLarry Finger 	bool state_inap;
1934f1d2b4d3SLarry Finger 	bool multi_buffered;
1935f1d2b4d3SLarry Finger 	u16 nullfunc_seq;
1936f1d2b4d3SLarry Finger 	unsigned int dtim_counter;
1937f1d2b4d3SLarry Finger 	unsigned int sleep_ms;
1938f1d2b4d3SLarry Finger 	unsigned long last_sleep_jiffies;
1939f1d2b4d3SLarry Finger 	unsigned long last_awake_jiffies;
1940f1d2b4d3SLarry Finger 	unsigned long last_delaylps_stamp_jiffies;
1941f1d2b4d3SLarry Finger 	unsigned long last_dtim;
1942f1d2b4d3SLarry Finger 	unsigned long last_beacon;
1943f1d2b4d3SLarry Finger 	unsigned long last_action;
1944f1d2b4d3SLarry Finger 	unsigned long last_slept;
1945f1d2b4d3SLarry Finger 
1946f1d2b4d3SLarry Finger 	/*For P2P PS */
1947f1d2b4d3SLarry Finger 	struct rtl_p2p_ps_info p2p_ps_info;
1948f1d2b4d3SLarry Finger 	u8 pwr_mode;
1949f1d2b4d3SLarry Finger 	u8 smart_ps;
1950f1d2b4d3SLarry Finger 
1951f1d2b4d3SLarry Finger 	/* wake up on line */
1952f1d2b4d3SLarry Finger 	u8 wo_wlan_mode;
1953f1d2b4d3SLarry Finger 	u8 arp_offload_enable;
1954f1d2b4d3SLarry Finger 	u8 gtk_offload_enable;
1955f1d2b4d3SLarry Finger 	/* Used for WOL, indicates the reason for waking event.*/
1956f1d2b4d3SLarry Finger 	u32 wakeup_reason;
1957f1d2b4d3SLarry Finger 	/* Record the last waking time for comparison with setting key. */
1958f1d2b4d3SLarry Finger 	u64 last_wakeup_time;
1959f1d2b4d3SLarry Finger };
1960f1d2b4d3SLarry Finger 
1961f1d2b4d3SLarry Finger struct rtl_stats {
1962f1d2b4d3SLarry Finger 	u8 psaddr[ETH_ALEN];
1963f1d2b4d3SLarry Finger 	u32 mac_time[2];
1964f1d2b4d3SLarry Finger 	s8 rssi;
1965f1d2b4d3SLarry Finger 	u8 signal;
1966f1d2b4d3SLarry Finger 	u8 noise;
1967f1d2b4d3SLarry Finger 	u8 rate;		/* hw desc rate */
1968f1d2b4d3SLarry Finger 	u8 received_channel;
1969f1d2b4d3SLarry Finger 	u8 control;
1970f1d2b4d3SLarry Finger 	u8 mask;
1971f1d2b4d3SLarry Finger 	u8 freq;
1972f1d2b4d3SLarry Finger 	u16 len;
1973f1d2b4d3SLarry Finger 	u64 tsf;
1974f1d2b4d3SLarry Finger 	u32 beacon_time;
1975f1d2b4d3SLarry Finger 	u8 nic_type;
1976f1d2b4d3SLarry Finger 	u16 length;
1977f1d2b4d3SLarry Finger 	u8 signalquality;	/*in 0-100 index. */
1978f1d2b4d3SLarry Finger 	/*
1979f1d2b4d3SLarry Finger 	 * Real power in dBm for this packet,
1980f1d2b4d3SLarry Finger 	 * no beautification and aggregation.
1981f1d2b4d3SLarry Finger 	 * */
1982f1d2b4d3SLarry Finger 	s32 recvsignalpower;
1983f1d2b4d3SLarry Finger 	s8 rxpower;		/*in dBm Translate from PWdB */
1984f1d2b4d3SLarry Finger 	u8 signalstrength;	/*in 0-100 index. */
1985f1d2b4d3SLarry Finger 	u16 hwerror:1;
1986f1d2b4d3SLarry Finger 	u16 crc:1;
1987f1d2b4d3SLarry Finger 	u16 icv:1;
1988f1d2b4d3SLarry Finger 	u16 shortpreamble:1;
1989f1d2b4d3SLarry Finger 	u16 antenna:1;
1990f1d2b4d3SLarry Finger 	u16 decrypted:1;
1991f1d2b4d3SLarry Finger 	u16 wakeup:1;
1992f1d2b4d3SLarry Finger 	u32 timestamp_low;
1993f1d2b4d3SLarry Finger 	u32 timestamp_high;
1994f1d2b4d3SLarry Finger 	bool shift;
1995f1d2b4d3SLarry Finger 
1996f1d2b4d3SLarry Finger 	u8 rx_drvinfo_size;
1997f1d2b4d3SLarry Finger 	u8 rx_bufshift;
1998f1d2b4d3SLarry Finger 	bool isampdu;
1999f1d2b4d3SLarry Finger 	bool isfirst_ampdu;
2000f1d2b4d3SLarry Finger 	bool rx_is40Mhzpacket;
2001f1d2b4d3SLarry Finger 	u8 rx_packet_bw;
2002f1d2b4d3SLarry Finger 	u32 rx_pwdb_all;
2003f1d2b4d3SLarry Finger 	u8 rx_mimo_signalstrength[4];	/*in 0~100 index */
2004f1d2b4d3SLarry Finger 	s8 rx_mimo_signalquality[4];
2005f1d2b4d3SLarry Finger 	u8 rx_mimo_evm_dbm[4];
2006f1d2b4d3SLarry Finger 	u16 cfo_short[4];		/* per-path's Cfo_short */
2007f1d2b4d3SLarry Finger 	u16 cfo_tail[4];
2008f1d2b4d3SLarry Finger 
2009f1d2b4d3SLarry Finger 	s8 rx_mimo_sig_qual[4];
2010f1d2b4d3SLarry Finger 	u8 rx_pwr[4]; /* per-path's pwdb */
2011f1d2b4d3SLarry Finger 	u8 rx_snr[4]; /* per-path's SNR */
2012f1d2b4d3SLarry Finger 	u8 bandwidth;
2013f1d2b4d3SLarry Finger 	u8 bt_coex_pwr_adjust;
2014f1d2b4d3SLarry Finger 	bool packet_matchbssid;
2015f1d2b4d3SLarry Finger 	bool is_cck;
2016f1d2b4d3SLarry Finger 	bool is_ht;
2017f1d2b4d3SLarry Finger 	bool packet_toself;
2018f1d2b4d3SLarry Finger 	bool packet_beacon;	/*for rssi */
201908aba42fSArnd Bergmann 	s8 cck_adc_pwdb[4];	/*for rx path selection */
2020f1d2b4d3SLarry Finger 
2021f1d2b4d3SLarry Finger 	bool is_vht;
2022f1d2b4d3SLarry Finger 	bool is_short_gi;
2023f1d2b4d3SLarry Finger 	u8 vht_nss;
2024f1d2b4d3SLarry Finger 
2025f1d2b4d3SLarry Finger 	u8 packet_report_type;
2026f1d2b4d3SLarry Finger 
2027f1d2b4d3SLarry Finger 	u32 macid;
2028f1d2b4d3SLarry Finger 	u8 wake_match;
2029f1d2b4d3SLarry Finger 	u32 bt_rx_rssi_percentage;
2030f1d2b4d3SLarry Finger 	u32 macid_valid_entry[2];
2031f1d2b4d3SLarry Finger };
2032f1d2b4d3SLarry Finger 
2033f1d2b4d3SLarry Finger 
2034f1d2b4d3SLarry Finger struct rt_link_detect {
2035f1d2b4d3SLarry Finger 	/* count for roaming */
2036f1d2b4d3SLarry Finger 	u32 bcn_rx_inperiod;
2037f1d2b4d3SLarry Finger 	u32 roam_times;
2038f1d2b4d3SLarry Finger 
2039f1d2b4d3SLarry Finger 	u32 num_tx_in4period[4];
2040f1d2b4d3SLarry Finger 	u32 num_rx_in4period[4];
2041f1d2b4d3SLarry Finger 
2042f1d2b4d3SLarry Finger 	u32 num_tx_inperiod;
2043f1d2b4d3SLarry Finger 	u32 num_rx_inperiod;
2044f1d2b4d3SLarry Finger 
2045f1d2b4d3SLarry Finger 	bool busytraffic;
2046f1d2b4d3SLarry Finger 	bool tx_busy_traffic;
2047f1d2b4d3SLarry Finger 	bool rx_busy_traffic;
2048f1d2b4d3SLarry Finger 	bool higher_busytraffic;
2049f1d2b4d3SLarry Finger 	bool higher_busyrxtraffic;
2050f1d2b4d3SLarry Finger 
2051f1d2b4d3SLarry Finger 	u32 tidtx_in4period[MAX_TID_COUNT][4];
2052f1d2b4d3SLarry Finger 	u32 tidtx_inperiod[MAX_TID_COUNT];
2053f1d2b4d3SLarry Finger 	bool higher_busytxtraffic[MAX_TID_COUNT];
2054f1d2b4d3SLarry Finger };
2055f1d2b4d3SLarry Finger 
2056f1d2b4d3SLarry Finger struct rtl_tcb_desc {
2057f1d2b4d3SLarry Finger 	u8 packet_bw:2;
2058f1d2b4d3SLarry Finger 	u8 multicast:1;
2059f1d2b4d3SLarry Finger 	u8 broadcast:1;
2060f1d2b4d3SLarry Finger 
2061f1d2b4d3SLarry Finger 	u8 rts_stbc:1;
2062f1d2b4d3SLarry Finger 	u8 rts_enable:1;
2063f1d2b4d3SLarry Finger 	u8 cts_enable:1;
2064f1d2b4d3SLarry Finger 	u8 rts_use_shortpreamble:1;
2065f1d2b4d3SLarry Finger 	u8 rts_use_shortgi:1;
2066f1d2b4d3SLarry Finger 	u8 rts_sc:1;
2067f1d2b4d3SLarry Finger 	u8 rts_bw:1;
2068f1d2b4d3SLarry Finger 	u8 rts_rate;
2069f1d2b4d3SLarry Finger 
2070f1d2b4d3SLarry Finger 	u8 use_shortgi:1;
2071f1d2b4d3SLarry Finger 	u8 use_shortpreamble:1;
2072f1d2b4d3SLarry Finger 	u8 use_driver_rate:1;
2073f1d2b4d3SLarry Finger 	u8 disable_ratefallback:1;
2074f1d2b4d3SLarry Finger 
20758479580bSPing-Ke Shih 	u8 use_spe_rpt:1;
20768479580bSPing-Ke Shih 
2077f1d2b4d3SLarry Finger 	u8 ratr_index;
2078f1d2b4d3SLarry Finger 	u8 mac_id;
2079f1d2b4d3SLarry Finger 	u8 hw_rate;
2080f1d2b4d3SLarry Finger 
2081f1d2b4d3SLarry Finger 	u8 last_inipkt:1;
2082f1d2b4d3SLarry Finger 	u8 cmd_or_init:1;
2083f1d2b4d3SLarry Finger 	u8 queue_index;
2084f1d2b4d3SLarry Finger 
2085f1d2b4d3SLarry Finger 	/* early mode */
2086f1d2b4d3SLarry Finger 	u8 empkt_num;
2087f1d2b4d3SLarry Finger 	/* The max value by HW */
2088f1d2b4d3SLarry Finger 	u32 empkt_len[10];
2089f1d2b4d3SLarry Finger 	bool tx_enable_sw_calc_duration;
2090f1d2b4d3SLarry Finger };
2091f1d2b4d3SLarry Finger 
2092f1d2b4d3SLarry Finger struct rtl_wow_pattern {
2093f1d2b4d3SLarry Finger 	u8 type;
2094f1d2b4d3SLarry Finger 	u16 crc;
2095f1d2b4d3SLarry Finger 	u32 mask[4];
2096f1d2b4d3SLarry Finger };
2097f1d2b4d3SLarry Finger 
2098f1d2b4d3SLarry Finger struct rtl_hal_ops {
2099f1d2b4d3SLarry Finger 	int (*init_sw_vars) (struct ieee80211_hw *hw);
2100f1d2b4d3SLarry Finger 	void (*deinit_sw_vars) (struct ieee80211_hw *hw);
2101f1d2b4d3SLarry Finger 	void (*read_chip_version)(struct ieee80211_hw *hw);
2102f1d2b4d3SLarry Finger 	void (*read_eeprom_info) (struct ieee80211_hw *hw);
2103f1d2b4d3SLarry Finger 	void (*interrupt_recognized) (struct ieee80211_hw *hw,
2104f1d2b4d3SLarry Finger 				      u32 *p_inta, u32 *p_intb);
2105f1d2b4d3SLarry Finger 	int (*hw_init) (struct ieee80211_hw *hw);
2106f1d2b4d3SLarry Finger 	void (*hw_disable) (struct ieee80211_hw *hw);
2107f1d2b4d3SLarry Finger 	void (*hw_suspend) (struct ieee80211_hw *hw);
2108f1d2b4d3SLarry Finger 	void (*hw_resume) (struct ieee80211_hw *hw);
2109f1d2b4d3SLarry Finger 	void (*enable_interrupt) (struct ieee80211_hw *hw);
2110f1d2b4d3SLarry Finger 	void (*disable_interrupt) (struct ieee80211_hw *hw);
2111f1d2b4d3SLarry Finger 	int (*set_network_type) (struct ieee80211_hw *hw,
2112f1d2b4d3SLarry Finger 				 enum nl80211_iftype type);
2113f1d2b4d3SLarry Finger 	void (*set_chk_bssid)(struct ieee80211_hw *hw,
2114f1d2b4d3SLarry Finger 				bool check_bssid);
2115f1d2b4d3SLarry Finger 	void (*set_bw_mode) (struct ieee80211_hw *hw,
2116f1d2b4d3SLarry Finger 			     enum nl80211_channel_type ch_type);
2117f1d2b4d3SLarry Finger 	 u8(*switch_channel) (struct ieee80211_hw *hw);
2118f1d2b4d3SLarry Finger 	void (*set_qos) (struct ieee80211_hw *hw, int aci);
2119f1d2b4d3SLarry Finger 	void (*set_bcn_reg) (struct ieee80211_hw *hw);
2120f1d2b4d3SLarry Finger 	void (*set_bcn_intv) (struct ieee80211_hw *hw);
2121f1d2b4d3SLarry Finger 	void (*update_interrupt_mask) (struct ieee80211_hw *hw,
2122f1d2b4d3SLarry Finger 				       u32 add_msr, u32 rm_msr);
2123f1d2b4d3SLarry Finger 	void (*get_hw_reg) (struct ieee80211_hw *hw, u8 variable, u8 *val);
2124f1d2b4d3SLarry Finger 	void (*set_hw_reg) (struct ieee80211_hw *hw, u8 variable, u8 *val);
2125f1d2b4d3SLarry Finger 	void (*update_rate_tbl) (struct ieee80211_hw *hw,
21261d22b177SPing-Ke Shih 			      struct ieee80211_sta *sta, u8 rssi_leve,
21271d22b177SPing-Ke Shih 			      bool update_bw);
2128f1d2b4d3SLarry Finger 	void (*pre_fill_tx_bd_desc)(struct ieee80211_hw *hw, u8 *tx_bd_desc,
2129f1d2b4d3SLarry Finger 				    u8 *desc, u8 queue_index,
2130f1d2b4d3SLarry Finger 				    struct sk_buff *skb, dma_addr_t addr);
2131f1d2b4d3SLarry Finger 	void (*update_rate_mask) (struct ieee80211_hw *hw, u8 rssi_level);
2132f1d2b4d3SLarry Finger 	u16 (*rx_desc_buff_remained_cnt)(struct ieee80211_hw *hw,
2133f1d2b4d3SLarry Finger 					 u8 queue_index);
2134f1d2b4d3SLarry Finger 	void (*rx_check_dma_ok)(struct ieee80211_hw *hw, u8 *header_desc,
2135f1d2b4d3SLarry Finger 				u8 queue_index);
2136f1d2b4d3SLarry Finger 	void (*fill_tx_desc) (struct ieee80211_hw *hw,
2137f1d2b4d3SLarry Finger 			      struct ieee80211_hdr *hdr, u8 *pdesc_tx,
2138f1d2b4d3SLarry Finger 			      u8 *pbd_desc_tx,
2139f1d2b4d3SLarry Finger 			      struct ieee80211_tx_info *info,
2140f1d2b4d3SLarry Finger 			      struct ieee80211_sta *sta,
2141f1d2b4d3SLarry Finger 			      struct sk_buff *skb, u8 hw_queue,
2142f1d2b4d3SLarry Finger 			      struct rtl_tcb_desc *ptcb_desc);
2143f1d2b4d3SLarry Finger 	void (*fill_fake_txdesc) (struct ieee80211_hw *hw, u8 *pDesc,
2144f1d2b4d3SLarry Finger 				  u32 buffer_len, bool bIsPsPoll);
2145f1d2b4d3SLarry Finger 	void (*fill_tx_cmddesc) (struct ieee80211_hw *hw, u8 *pdesc,
2146f1d2b4d3SLarry Finger 				 bool firstseg, bool lastseg,
2147f1d2b4d3SLarry Finger 				 struct sk_buff *skb);
2148f1d2b4d3SLarry Finger 	bool (*query_rx_desc) (struct ieee80211_hw *hw,
2149f1d2b4d3SLarry Finger 			       struct rtl_stats *stats,
2150f1d2b4d3SLarry Finger 			       struct ieee80211_rx_status *rx_status,
2151f1d2b4d3SLarry Finger 			       u8 *pdesc, struct sk_buff *skb);
2152f1d2b4d3SLarry Finger 	void (*set_channel_access) (struct ieee80211_hw *hw);
2153f1d2b4d3SLarry Finger 	bool (*radio_onoff_checking) (struct ieee80211_hw *hw, u8 *valid);
2154f1d2b4d3SLarry Finger 	void (*dm_watchdog) (struct ieee80211_hw *hw);
2155f1d2b4d3SLarry Finger 	void (*scan_operation_backup) (struct ieee80211_hw *hw, u8 operation);
2156f1d2b4d3SLarry Finger 	bool (*set_rf_power_state) (struct ieee80211_hw *hw,
2157f1d2b4d3SLarry Finger 				    enum rf_pwrstate rfpwr_state);
2158f1d2b4d3SLarry Finger 	void (*led_control) (struct ieee80211_hw *hw,
2159f1d2b4d3SLarry Finger 			     enum led_ctl_mode ledaction);
2160f1d2b4d3SLarry Finger 	void (*set_desc)(struct ieee80211_hw *hw, u8 *pdesc, bool istx,
2161f1d2b4d3SLarry Finger 			 u8 desc_name, u8 *val);
21620c07bd74SPing-Ke Shih 	u64 (*get_desc)(struct ieee80211_hw *hw, u8 *pdesc, bool istx,
21630c07bd74SPing-Ke Shih 			u8 desc_name);
2164f1d2b4d3SLarry Finger 	bool (*is_tx_desc_closed) (struct ieee80211_hw *hw,
2165f1d2b4d3SLarry Finger 				   u8 hw_queue, u16 index);
2166f1d2b4d3SLarry Finger 	void (*tx_polling) (struct ieee80211_hw *hw, u8 hw_queue);
2167f1d2b4d3SLarry Finger 	void (*enable_hw_sec) (struct ieee80211_hw *hw);
2168f1d2b4d3SLarry Finger 	void (*set_key) (struct ieee80211_hw *hw, u32 key_index,
2169f1d2b4d3SLarry Finger 			 u8 *macaddr, bool is_group, u8 enc_algo,
2170f1d2b4d3SLarry Finger 			 bool is_wepkey, bool clear_all);
2171f1d2b4d3SLarry Finger 	void (*init_sw_leds) (struct ieee80211_hw *hw);
2172f1d2b4d3SLarry Finger 	void (*deinit_sw_leds) (struct ieee80211_hw *hw);
2173f1d2b4d3SLarry Finger 	u32 (*get_bbreg) (struct ieee80211_hw *hw, u32 regaddr, u32 bitmask);
2174f1d2b4d3SLarry Finger 	void (*set_bbreg) (struct ieee80211_hw *hw, u32 regaddr, u32 bitmask,
2175f1d2b4d3SLarry Finger 			   u32 data);
2176f1d2b4d3SLarry Finger 	u32 (*get_rfreg) (struct ieee80211_hw *hw, enum radio_path rfpath,
2177f1d2b4d3SLarry Finger 			  u32 regaddr, u32 bitmask);
2178f1d2b4d3SLarry Finger 	void (*set_rfreg) (struct ieee80211_hw *hw, enum radio_path rfpath,
2179f1d2b4d3SLarry Finger 			   u32 regaddr, u32 bitmask, u32 data);
2180f1d2b4d3SLarry Finger 	void (*linked_set_reg) (struct ieee80211_hw *hw);
2181f1d2b4d3SLarry Finger 	void (*chk_switch_dmdp) (struct ieee80211_hw *hw);
2182f1d2b4d3SLarry Finger 	void (*dualmac_easy_concurrent) (struct ieee80211_hw *hw);
2183f1d2b4d3SLarry Finger 	void (*dualmac_switch_to_dmdp) (struct ieee80211_hw *hw);
2184f1d2b4d3SLarry Finger 	bool (*phy_rf6052_config) (struct ieee80211_hw *hw);
2185f1d2b4d3SLarry Finger 	void (*phy_rf6052_set_cck_txpower) (struct ieee80211_hw *hw,
2186f1d2b4d3SLarry Finger 					    u8 *powerlevel);
2187f1d2b4d3SLarry Finger 	void (*phy_rf6052_set_ofdm_txpower) (struct ieee80211_hw *hw,
2188f1d2b4d3SLarry Finger 					     u8 *ppowerlevel, u8 channel);
2189f1d2b4d3SLarry Finger 	bool (*config_bb_with_headerfile) (struct ieee80211_hw *hw,
2190f1d2b4d3SLarry Finger 					   u8 configtype);
2191f1d2b4d3SLarry Finger 	bool (*config_bb_with_pgheaderfile) (struct ieee80211_hw *hw,
2192f1d2b4d3SLarry Finger 					     u8 configtype);
2193f1d2b4d3SLarry Finger 	void (*phy_lc_calibrate) (struct ieee80211_hw *hw, bool is2t);
2194f1d2b4d3SLarry Finger 	void (*phy_set_bw_mode_callback) (struct ieee80211_hw *hw);
2195f1d2b4d3SLarry Finger 	void (*dm_dynamic_txpower) (struct ieee80211_hw *hw);
2196f1d2b4d3SLarry Finger 	void (*c2h_command_handle) (struct ieee80211_hw *hw);
2197f1d2b4d3SLarry Finger 	void (*bt_wifi_media_status_notify) (struct ieee80211_hw *hw,
2198f1d2b4d3SLarry Finger 					     bool mstate);
2199f1d2b4d3SLarry Finger 	void (*bt_coex_off_before_lps) (struct ieee80211_hw *hw);
2200f1d2b4d3SLarry Finger 	void (*fill_h2c_cmd) (struct ieee80211_hw *hw, u8 element_id,
2201f1d2b4d3SLarry Finger 			      u32 cmd_len, u8 *p_cmdbuffer);
2202f1d2b4d3SLarry Finger 	bool (*get_btc_status) (void);
2203f1d2b4d3SLarry Finger 	bool (*is_fw_header)(struct rtlwifi_firmware_header *hdr);
2204f1d2b4d3SLarry Finger 	u32 (*rx_command_packet)(struct ieee80211_hw *hw,
2205ce254243SColin Ian King 				 const struct rtl_stats *status, struct sk_buff *skb);
2206f1d2b4d3SLarry Finger 	void (*add_wowlan_pattern)(struct ieee80211_hw *hw,
2207f1d2b4d3SLarry Finger 				   struct rtl_wow_pattern *rtl_pattern,
2208f1d2b4d3SLarry Finger 				   u8 index);
2209f1d2b4d3SLarry Finger 	u16 (*get_available_desc)(struct ieee80211_hw *hw, u8 q_idx);
2210cceb0a59SPing-Ke Shih 	void (*c2h_content_parsing)(struct ieee80211_hw *hw, u8 tag, u8 len,
2211cceb0a59SPing-Ke Shih 				    u8 *val);
2212f1d2b4d3SLarry Finger };
2213f1d2b4d3SLarry Finger 
2214f1d2b4d3SLarry Finger struct rtl_intf_ops {
2215f1d2b4d3SLarry Finger 	/*com */
2216f1d2b4d3SLarry Finger 	void (*read_efuse_byte)(struct ieee80211_hw *hw, u16 _offset, u8 *pbuf);
2217f1d2b4d3SLarry Finger 	int (*adapter_start) (struct ieee80211_hw *hw);
2218f1d2b4d3SLarry Finger 	void (*adapter_stop) (struct ieee80211_hw *hw);
2219f1d2b4d3SLarry Finger 	bool (*check_buddy_priv)(struct ieee80211_hw *hw,
2220f1d2b4d3SLarry Finger 				 struct rtl_priv **buddy_priv);
2221f1d2b4d3SLarry Finger 
2222f1d2b4d3SLarry Finger 	int (*adapter_tx) (struct ieee80211_hw *hw,
2223f1d2b4d3SLarry Finger 			   struct ieee80211_sta *sta,
2224f1d2b4d3SLarry Finger 			   struct sk_buff *skb,
2225f1d2b4d3SLarry Finger 			   struct rtl_tcb_desc *ptcb_desc);
2226f1d2b4d3SLarry Finger 	void (*flush)(struct ieee80211_hw *hw, u32 queues, bool drop);
2227f1d2b4d3SLarry Finger 	int (*reset_trx_ring) (struct ieee80211_hw *hw);
2228f1d2b4d3SLarry Finger 	bool (*waitq_insert) (struct ieee80211_hw *hw,
2229f1d2b4d3SLarry Finger 			      struct ieee80211_sta *sta,
2230f1d2b4d3SLarry Finger 			      struct sk_buff *skb);
2231f1d2b4d3SLarry Finger 
2232f1d2b4d3SLarry Finger 	/*pci */
2233f1d2b4d3SLarry Finger 	void (*disable_aspm) (struct ieee80211_hw *hw);
2234f1d2b4d3SLarry Finger 	void (*enable_aspm) (struct ieee80211_hw *hw);
2235f1d2b4d3SLarry Finger 
2236f1d2b4d3SLarry Finger 	/*usb */
2237f1d2b4d3SLarry Finger };
2238f1d2b4d3SLarry Finger 
2239f1d2b4d3SLarry Finger struct rtl_mod_params {
2240c34df318SLarry Finger 	/* default: 0,0 */
2241c34df318SLarry Finger 	u64 debug_mask;
2242f1d2b4d3SLarry Finger 	/* default: 0 = using hardware encryption */
2243f1d2b4d3SLarry Finger 	bool sw_crypto;
2244f1d2b4d3SLarry Finger 
2245f1d2b4d3SLarry Finger 	/* default: 0 = DBG_EMERG (0)*/
2246c34df318SLarry Finger 	int debug_level;
2247f1d2b4d3SLarry Finger 
2248f1d2b4d3SLarry Finger 	/* default: 1 = using no linked power save */
2249f1d2b4d3SLarry Finger 	bool inactiveps;
2250f1d2b4d3SLarry Finger 
2251f1d2b4d3SLarry Finger 	/* default: 1 = using linked sw power save */
2252f1d2b4d3SLarry Finger 	bool swctrl_lps;
2253f1d2b4d3SLarry Finger 
2254f1d2b4d3SLarry Finger 	/* default: 1 = using linked fw power save */
2255f1d2b4d3SLarry Finger 	bool fwctrl_lps;
2256f1d2b4d3SLarry Finger 
2257f1d2b4d3SLarry Finger 	/* default: 0 = not using MSI interrupts mode
2258f1d2b4d3SLarry Finger 	 * submodules should set their own default value
2259f1d2b4d3SLarry Finger 	 */
2260f1d2b4d3SLarry Finger 	bool msi_support;
2261f1d2b4d3SLarry Finger 
22620c07bd74SPing-Ke Shih 	/* default: 0 = dma 32 */
22630c07bd74SPing-Ke Shih 	bool dma64;
22640c07bd74SPing-Ke Shih 
2265*84efbad4SPing-Ke Shih 	/* default: 1 = enable aspm */
2266*84efbad4SPing-Ke Shih 	int aspm_support;
2267*84efbad4SPing-Ke Shih 
2268f1d2b4d3SLarry Finger 	/* default 0: 1 means disable */
2269f1d2b4d3SLarry Finger 	bool disable_watchdog;
2270d59542ddSDavid S. Miller 
2271d59542ddSDavid S. Miller 	/* default 0: 1 means do not disable interrupts */
2272d59542ddSDavid S. Miller 	bool int_clear;
2273c18d8f50SLarry Finger 
2274c18d8f50SLarry Finger 	/* select antenna */
2275c18d8f50SLarry Finger 	int ant_sel;
2276f1d2b4d3SLarry Finger };
2277f1d2b4d3SLarry Finger 
2278f1d2b4d3SLarry Finger struct rtl_hal_usbint_cfg {
2279f1d2b4d3SLarry Finger 	/* data - rx */
2280f1d2b4d3SLarry Finger 	u32 in_ep_num;
2281f1d2b4d3SLarry Finger 	u32 rx_urb_num;
2282f1d2b4d3SLarry Finger 	u32 rx_max_size;
2283f1d2b4d3SLarry Finger 
2284f1d2b4d3SLarry Finger 	/* op - rx */
2285f1d2b4d3SLarry Finger 	void (*usb_rx_hdl)(struct ieee80211_hw *, struct sk_buff *);
2286f1d2b4d3SLarry Finger 	void (*usb_rx_segregate_hdl)(struct ieee80211_hw *, struct sk_buff *,
2287f1d2b4d3SLarry Finger 				     struct sk_buff_head *);
2288f1d2b4d3SLarry Finger 
2289f1d2b4d3SLarry Finger 	/* tx */
2290f1d2b4d3SLarry Finger 	void (*usb_tx_cleanup)(struct ieee80211_hw *, struct sk_buff *);
2291f1d2b4d3SLarry Finger 	int (*usb_tx_post_hdl)(struct ieee80211_hw *, struct urb *,
2292f1d2b4d3SLarry Finger 			       struct sk_buff *);
2293f1d2b4d3SLarry Finger 	struct sk_buff *(*usb_tx_aggregate_hdl)(struct ieee80211_hw *,
2294f1d2b4d3SLarry Finger 						struct sk_buff_head *);
2295f1d2b4d3SLarry Finger 
2296f1d2b4d3SLarry Finger 	/* endpoint mapping */
2297f1d2b4d3SLarry Finger 	int (*usb_endpoint_mapping)(struct ieee80211_hw *hw);
2298f1d2b4d3SLarry Finger 	u16 (*usb_mq_to_hwq)(__le16 fc, u16 mac80211_queue_index);
2299f1d2b4d3SLarry Finger };
2300f1d2b4d3SLarry Finger 
2301f1d2b4d3SLarry Finger struct rtl_hal_cfg {
2302f1d2b4d3SLarry Finger 	u8 bar_id;
2303f1d2b4d3SLarry Finger 	bool write_readback;
2304f1d2b4d3SLarry Finger 	char *name;
2305f1d2b4d3SLarry Finger 	char *alt_fw_name;
2306f1d2b4d3SLarry Finger 	struct rtl_hal_ops *ops;
2307f1d2b4d3SLarry Finger 	struct rtl_mod_params *mod_params;
2308f1d2b4d3SLarry Finger 	struct rtl_hal_usbint_cfg *usb_interface_cfg;
2309f1d2b4d3SLarry Finger 
2310f1d2b4d3SLarry Finger 	/*this map used for some registers or vars
2311f1d2b4d3SLarry Finger 	   defined int HAL but used in MAIN */
2312f1d2b4d3SLarry Finger 	u32 maps[RTL_VAR_MAP_MAX];
2313f1d2b4d3SLarry Finger 
2314f1d2b4d3SLarry Finger };
2315f1d2b4d3SLarry Finger 
2316f1d2b4d3SLarry Finger struct rtl_locks {
2317f1d2b4d3SLarry Finger 	/* mutex */
2318f1d2b4d3SLarry Finger 	struct mutex conf_mutex;
2319f1d2b4d3SLarry Finger 	struct mutex ps_mutex;
2320f1d2b4d3SLarry Finger 
2321f1d2b4d3SLarry Finger 	/*spin lock */
2322f1d2b4d3SLarry Finger 	spinlock_t ips_lock;
2323f1d2b4d3SLarry Finger 	spinlock_t irq_th_lock;
2324f1d2b4d3SLarry Finger 	spinlock_t irq_pci_lock;
2325f1d2b4d3SLarry Finger 	spinlock_t tx_lock;
2326f1d2b4d3SLarry Finger 	spinlock_t h2c_lock;
2327f1d2b4d3SLarry Finger 	spinlock_t rf_ps_lock;
2328f1d2b4d3SLarry Finger 	spinlock_t rf_lock;
2329f1d2b4d3SLarry Finger 	spinlock_t lps_lock;
2330f1d2b4d3SLarry Finger 	spinlock_t waitq_lock;
2331f1d2b4d3SLarry Finger 	spinlock_t entry_list_lock;
2332f1d2b4d3SLarry Finger 	spinlock_t usb_lock;
2333cceb0a59SPing-Ke Shih 	spinlock_t c2hcmd_lock;
2334c76ab8e7SPing-Ke Shih 	spinlock_t scan_list_lock; /* lock for the scan list */
2335f1d2b4d3SLarry Finger 
2336f1d2b4d3SLarry Finger 	/*FW clock change */
2337f1d2b4d3SLarry Finger 	spinlock_t fw_ps_lock;
2338f1d2b4d3SLarry Finger 
2339f1d2b4d3SLarry Finger 	/*Dual mac*/
2340f1d2b4d3SLarry Finger 	spinlock_t cck_and_rw_pagea_lock;
2341f1d2b4d3SLarry Finger 
2342f1d2b4d3SLarry Finger 	/*Easy concurrent*/
2343f1d2b4d3SLarry Finger 	spinlock_t check_sendpkt_lock;
2344f1d2b4d3SLarry Finger 
2345f1d2b4d3SLarry Finger 	spinlock_t iqk_lock;
2346f1d2b4d3SLarry Finger };
2347f1d2b4d3SLarry Finger 
2348f1d2b4d3SLarry Finger struct rtl_works {
2349f1d2b4d3SLarry Finger 	struct ieee80211_hw *hw;
2350f1d2b4d3SLarry Finger 
2351f1d2b4d3SLarry Finger 	/*timer */
2352f1d2b4d3SLarry Finger 	struct timer_list watchdog_timer;
2353f1d2b4d3SLarry Finger 	struct timer_list dualmac_easyconcurrent_retrytimer;
2354f1d2b4d3SLarry Finger 	struct timer_list fw_clockoff_timer;
2355f1d2b4d3SLarry Finger 	struct timer_list fast_antenna_training_timer;
2356f1d2b4d3SLarry Finger 	/*task */
2357f1d2b4d3SLarry Finger 	struct tasklet_struct irq_tasklet;
2358f1d2b4d3SLarry Finger 	struct tasklet_struct irq_prepare_bcn_tasklet;
2359f1d2b4d3SLarry Finger 
2360f1d2b4d3SLarry Finger 	/*work queue */
2361f1d2b4d3SLarry Finger 	struct workqueue_struct *rtl_wq;
2362f1d2b4d3SLarry Finger 	struct delayed_work watchdog_wq;
2363f1d2b4d3SLarry Finger 	struct delayed_work ips_nic_off_wq;
2364cceb0a59SPing-Ke Shih 	struct delayed_work c2hcmd_wq;
2365f1d2b4d3SLarry Finger 
2366f1d2b4d3SLarry Finger 	/* For SW LPS */
2367f1d2b4d3SLarry Finger 	struct delayed_work ps_work;
2368f1d2b4d3SLarry Finger 	struct delayed_work ps_rfon_wq;
2369f1d2b4d3SLarry Finger 	struct delayed_work fwevt_wq;
2370f1d2b4d3SLarry Finger 
2371f1d2b4d3SLarry Finger 	struct work_struct lps_change_work;
2372f1d2b4d3SLarry Finger 	struct work_struct fill_h2c_cmd;
2373f1d2b4d3SLarry Finger };
2374f1d2b4d3SLarry Finger 
2375f1d2b4d3SLarry Finger #define MIMO_PS_STATIC			0
2376f1d2b4d3SLarry Finger #define MIMO_PS_DYNAMIC			1
2377f1d2b4d3SLarry Finger #define MIMO_PS_NOLIMIT			3
2378f1d2b4d3SLarry Finger 
2379f1d2b4d3SLarry Finger struct rtl_dualmac_easy_concurrent_ctl {
2380f1d2b4d3SLarry Finger 	enum band_type currentbandtype_backfordmdp;
2381f1d2b4d3SLarry Finger 	bool close_bbandrf_for_dmsp;
2382f1d2b4d3SLarry Finger 	bool change_to_dmdp;
2383f1d2b4d3SLarry Finger 	bool change_to_dmsp;
2384f1d2b4d3SLarry Finger 	bool switch_in_process;
2385f1d2b4d3SLarry Finger };
2386f1d2b4d3SLarry Finger 
2387f1d2b4d3SLarry Finger struct rtl_dmsp_ctl {
2388f1d2b4d3SLarry Finger 	bool activescan_for_slaveofdmsp;
2389f1d2b4d3SLarry Finger 	bool scan_for_anothermac_fordmsp;
2390f1d2b4d3SLarry Finger 	bool scan_for_itself_fordmsp;
2391f1d2b4d3SLarry Finger 	bool writedig_for_anothermacofdmsp;
2392f1d2b4d3SLarry Finger 	u32 curdigvalue_for_anothermacofdmsp;
2393f1d2b4d3SLarry Finger 	bool changecckpdstate_for_anothermacofdmsp;
2394f1d2b4d3SLarry Finger 	u8 curcckpdstate_for_anothermacofdmsp;
2395f1d2b4d3SLarry Finger 	bool changetxhighpowerlvl_for_anothermacofdmsp;
2396f1d2b4d3SLarry Finger 	u8 curtxhighlvl_for_anothermacofdmsp;
2397f1d2b4d3SLarry Finger 	long rssivalmin_for_anothermacofdmsp;
2398f1d2b4d3SLarry Finger };
2399f1d2b4d3SLarry Finger 
2400f1d2b4d3SLarry Finger struct ps_t {
2401f1d2b4d3SLarry Finger 	u8 pre_ccastate;
2402f1d2b4d3SLarry Finger 	u8 cur_ccasate;
2403f1d2b4d3SLarry Finger 	u8 pre_rfstate;
2404f1d2b4d3SLarry Finger 	u8 cur_rfstate;
2405f1d2b4d3SLarry Finger 	u8 initialize;
2406f1d2b4d3SLarry Finger 	long rssi_val_min;
2407f1d2b4d3SLarry Finger };
2408f1d2b4d3SLarry Finger 
2409f1d2b4d3SLarry Finger struct dig_t {
2410f1d2b4d3SLarry Finger 	u32 rssi_lowthresh;
2411f1d2b4d3SLarry Finger 	u32 rssi_highthresh;
2412f1d2b4d3SLarry Finger 	u32 fa_lowthresh;
2413f1d2b4d3SLarry Finger 	u32 fa_highthresh;
2414f1d2b4d3SLarry Finger 	long last_min_undec_pwdb_for_dm;
2415f1d2b4d3SLarry Finger 	long rssi_highpower_lowthresh;
2416f1d2b4d3SLarry Finger 	long rssi_highpower_highthresh;
2417f1d2b4d3SLarry Finger 	u32 recover_cnt;
2418f1d2b4d3SLarry Finger 	u32 pre_igvalue;
2419f1d2b4d3SLarry Finger 	u32 cur_igvalue;
2420f1d2b4d3SLarry Finger 	long rssi_val;
2421f1d2b4d3SLarry Finger 	u8 dig_enable_flag;
2422f1d2b4d3SLarry Finger 	u8 dig_ext_port_stage;
2423f1d2b4d3SLarry Finger 	u8 dig_algorithm;
2424f1d2b4d3SLarry Finger 	u8 dig_twoport_algorithm;
2425f1d2b4d3SLarry Finger 	u8 dig_dbgmode;
2426f1d2b4d3SLarry Finger 	u8 dig_slgorithm_switch;
2427f1d2b4d3SLarry Finger 	u8 cursta_cstate;
2428f1d2b4d3SLarry Finger 	u8 presta_cstate;
2429f1d2b4d3SLarry Finger 	u8 curmultista_cstate;
2430f1d2b4d3SLarry Finger 	u8 stop_dig;
243108aba42fSArnd Bergmann 	s8 back_val;
243208aba42fSArnd Bergmann 	s8 back_range_max;
243308aba42fSArnd Bergmann 	s8 back_range_min;
2434f1d2b4d3SLarry Finger 	u8 rx_gain_max;
2435f1d2b4d3SLarry Finger 	u8 rx_gain_min;
2436f1d2b4d3SLarry Finger 	u8 min_undec_pwdb_for_dm;
2437f1d2b4d3SLarry Finger 	u8 rssi_val_min;
2438f1d2b4d3SLarry Finger 	u8 pre_cck_cca_thres;
2439f1d2b4d3SLarry Finger 	u8 cur_cck_cca_thres;
2440f1d2b4d3SLarry Finger 	u8 pre_cck_pd_state;
2441f1d2b4d3SLarry Finger 	u8 cur_cck_pd_state;
2442f1d2b4d3SLarry Finger 	u8 pre_cck_fa_state;
2443f1d2b4d3SLarry Finger 	u8 cur_cck_fa_state;
2444f1d2b4d3SLarry Finger 	u8 pre_ccastate;
2445f1d2b4d3SLarry Finger 	u8 cur_ccasate;
2446f1d2b4d3SLarry Finger 	u8 large_fa_hit;
2447f1d2b4d3SLarry Finger 	u8 forbidden_igi;
2448f1d2b4d3SLarry Finger 	u8 dig_state;
2449f1d2b4d3SLarry Finger 	u8 dig_highpwrstate;
2450f1d2b4d3SLarry Finger 	u8 cur_sta_cstate;
2451f1d2b4d3SLarry Finger 	u8 pre_sta_cstate;
2452f1d2b4d3SLarry Finger 	u8 cur_ap_cstate;
2453f1d2b4d3SLarry Finger 	u8 pre_ap_cstate;
2454f1d2b4d3SLarry Finger 	u8 cur_pd_thstate;
2455f1d2b4d3SLarry Finger 	u8 pre_pd_thstate;
2456f1d2b4d3SLarry Finger 	u8 cur_cs_ratiostate;
2457f1d2b4d3SLarry Finger 	u8 pre_cs_ratiostate;
2458f1d2b4d3SLarry Finger 	u8 backoff_enable_flag;
245908aba42fSArnd Bergmann 	s8 backoffval_range_max;
246008aba42fSArnd Bergmann 	s8 backoffval_range_min;
2461f1d2b4d3SLarry Finger 	u8 dig_min_0;
2462f1d2b4d3SLarry Finger 	u8 dig_min_1;
2463f1d2b4d3SLarry Finger 	u8 bt30_cur_igi;
2464f1d2b4d3SLarry Finger 	bool media_connect_0;
2465f1d2b4d3SLarry Finger 	bool media_connect_1;
2466f1d2b4d3SLarry Finger 
2467f1d2b4d3SLarry Finger 	u32 antdiv_rssi_max;
2468f1d2b4d3SLarry Finger 	u32 rssi_max;
2469f1d2b4d3SLarry Finger };
2470f1d2b4d3SLarry Finger 
2471f1d2b4d3SLarry Finger struct rtl_global_var {
2472f1d2b4d3SLarry Finger 	/* from this list we can get
2473f1d2b4d3SLarry Finger 	 * other adapter's rtl_priv */
2474f1d2b4d3SLarry Finger 	struct list_head glb_priv_list;
2475f1d2b4d3SLarry Finger 	spinlock_t glb_list_lock;
2476f1d2b4d3SLarry Finger };
2477f1d2b4d3SLarry Finger 
247811f35c95SPing-Ke Shih #define IN_4WAY_TIMEOUT_TIME	(30 * MSEC_PER_SEC)	/* 30 seconds */
247911f35c95SPing-Ke Shih 
2480f1d2b4d3SLarry Finger struct rtl_btc_info {
2481f1d2b4d3SLarry Finger 	u8 bt_type;
2482f1d2b4d3SLarry Finger 	u8 btcoexist;
2483f1d2b4d3SLarry Finger 	u8 ant_num;
2484db8cb009SPing-Ke Shih 	u8 single_ant_path;
2485f1cb27edSPing-Ke Shih 
2486f1cb27edSPing-Ke Shih 	u8 ap_num;
248776f146b6SPing-Ke Shih 	bool in_4way;
248811f35c95SPing-Ke Shih 	unsigned long in_4way_ts;
2489f1d2b4d3SLarry Finger };
2490f1d2b4d3SLarry Finger 
2491f1d2b4d3SLarry Finger struct bt_coexist_info {
2492f1d2b4d3SLarry Finger 	struct rtl_btc_ops *btc_ops;
2493f1d2b4d3SLarry Finger 	struct rtl_btc_info btc_info;
2494f1d2b4d3SLarry Finger 	/* EEPROM BT info. */
2495f1d2b4d3SLarry Finger 	u8 eeprom_bt_coexist;
2496f1d2b4d3SLarry Finger 	u8 eeprom_bt_type;
2497f1d2b4d3SLarry Finger 	u8 eeprom_bt_ant_num;
2498f1d2b4d3SLarry Finger 	u8 eeprom_bt_ant_isol;
2499f1d2b4d3SLarry Finger 	u8 eeprom_bt_radio_shared;
2500f1d2b4d3SLarry Finger 
2501f1d2b4d3SLarry Finger 	u8 bt_coexistence;
2502f1d2b4d3SLarry Finger 	u8 bt_ant_num;
2503f1d2b4d3SLarry Finger 	u8 bt_coexist_type;
2504f1d2b4d3SLarry Finger 	u8 bt_state;
2505f1d2b4d3SLarry Finger 	u8 bt_cur_state;	/* 0:on, 1:off */
2506f1d2b4d3SLarry Finger 	u8 bt_ant_isolation;	/* 0:good, 1:bad */
2507f1d2b4d3SLarry Finger 	u8 bt_pape_ctrl;	/* 0:SW, 1:SW/HW dynamic */
2508f1d2b4d3SLarry Finger 	u8 bt_service;
2509f1d2b4d3SLarry Finger 	u8 bt_radio_shared_type;
2510f1d2b4d3SLarry Finger 	u8 bt_rfreg_origin_1e;
2511f1d2b4d3SLarry Finger 	u8 bt_rfreg_origin_1f;
2512f1d2b4d3SLarry Finger 	u8 bt_rssi_state;
2513f1d2b4d3SLarry Finger 	u32 ratio_tx;
2514f1d2b4d3SLarry Finger 	u32 ratio_pri;
2515f1d2b4d3SLarry Finger 	u32 bt_edca_ul;
2516f1d2b4d3SLarry Finger 	u32 bt_edca_dl;
2517f1d2b4d3SLarry Finger 
2518f1d2b4d3SLarry Finger 	bool init_set;
2519f1d2b4d3SLarry Finger 	bool bt_busy_traffic;
2520f1d2b4d3SLarry Finger 	bool bt_traffic_mode_set;
2521f1d2b4d3SLarry Finger 	bool bt_non_traffic_mode_set;
2522f1d2b4d3SLarry Finger 
2523f1d2b4d3SLarry Finger 	bool fw_coexist_all_off;
2524f1d2b4d3SLarry Finger 	bool sw_coexist_all_off;
2525f1d2b4d3SLarry Finger 	bool hw_coexist_all_off;
2526f1d2b4d3SLarry Finger 	u32 cstate;
2527f1d2b4d3SLarry Finger 	u32 previous_state;
2528f1d2b4d3SLarry Finger 	u32 cstate_h;
2529f1d2b4d3SLarry Finger 	u32 previous_state_h;
2530f1d2b4d3SLarry Finger 
2531f1d2b4d3SLarry Finger 	u8 bt_pre_rssi_state;
2532f1d2b4d3SLarry Finger 	u8 bt_pre_rssi_state1;
2533f1d2b4d3SLarry Finger 
2534f1d2b4d3SLarry Finger 	u8 reg_bt_iso;
2535f1d2b4d3SLarry Finger 	u8 reg_bt_sco;
2536f1d2b4d3SLarry Finger 	bool balance_on;
2537f1d2b4d3SLarry Finger 	u8 bt_active_zero_cnt;
2538f1d2b4d3SLarry Finger 	bool cur_bt_disabled;
2539f1d2b4d3SLarry Finger 	bool pre_bt_disabled;
2540f1d2b4d3SLarry Finger 
2541f1d2b4d3SLarry Finger 	u8 bt_profile_case;
2542f1d2b4d3SLarry Finger 	u8 bt_profile_action;
2543f1d2b4d3SLarry Finger 	bool bt_busy;
2544f1d2b4d3SLarry Finger 	bool hold_for_bt_operation;
2545f1d2b4d3SLarry Finger 	u8 lps_counter;
2546f1d2b4d3SLarry Finger };
2547f1d2b4d3SLarry Finger 
2548f1d2b4d3SLarry Finger struct rtl_btc_ops {
2549f1d2b4d3SLarry Finger 	void (*btc_init_variables) (struct rtl_priv *rtlpriv);
2550f1d2b4d3SLarry Finger 	void (*btc_init_hal_vars) (struct rtl_priv *rtlpriv);
2551f1d2b4d3SLarry Finger 	void (*btc_init_hw_config) (struct rtl_priv *rtlpriv);
2552f1d2b4d3SLarry Finger 	void (*btc_ips_notify) (struct rtl_priv *rtlpriv, u8 type);
2553f1d2b4d3SLarry Finger 	void (*btc_lps_notify)(struct rtl_priv *rtlpriv, u8 type);
2554f1d2b4d3SLarry Finger 	void (*btc_scan_notify) (struct rtl_priv *rtlpriv, u8 scantype);
2555f1d2b4d3SLarry Finger 	void (*btc_connect_notify) (struct rtl_priv *rtlpriv, u8 action);
2556f1d2b4d3SLarry Finger 	void (*btc_mediastatus_notify) (struct rtl_priv *rtlpriv,
2557f1d2b4d3SLarry Finger 					enum rt_media_status mstatus);
2558f1d2b4d3SLarry Finger 	void (*btc_periodical) (struct rtl_priv *rtlpriv);
2559f1d2b4d3SLarry Finger 	void (*btc_halt_notify) (void);
2560f1d2b4d3SLarry Finger 	void (*btc_btinfo_notify) (struct rtl_priv *rtlpriv,
2561f1d2b4d3SLarry Finger 				   u8 *tmp_buf, u8 length);
25626aad6075SPing-Ke Shih 	void (*btc_btmpinfo_notify)(struct rtl_priv *rtlpriv,
25636aad6075SPing-Ke Shih 				    u8 *tmp_buf, u8 length);
2564f1d2b4d3SLarry Finger 	bool (*btc_is_limited_dig) (struct rtl_priv *rtlpriv);
2565f1d2b4d3SLarry Finger 	bool (*btc_is_disable_edca_turbo) (struct rtl_priv *rtlpriv);
2566f1d2b4d3SLarry Finger 	bool (*btc_is_bt_disabled) (struct rtl_priv *rtlpriv);
2567f1d2b4d3SLarry Finger 	void (*btc_special_packet_notify)(struct rtl_priv *rtlpriv,
2568f1d2b4d3SLarry Finger 					  u8 pkt_type);
256954685f9cSPing-Ke Shih 	void (*btc_record_pwr_mode)(struct rtl_priv *rtlpriv, u8 *buf, u8 len);
257042213f2fSPing-Ke Shih 	u8   (*btc_get_lps_val)(struct rtl_priv *rtlpriv);
257142213f2fSPing-Ke Shih 	u8   (*btc_get_rpwm_val)(struct rtl_priv *rtlpriv);
257242213f2fSPing-Ke Shih 	bool (*btc_is_bt_ctrl_lps)(struct rtl_priv *rtlpriv);
25732635664eSPing-Ke Shih 	void (*btc_get_ampdu_cfg)(struct rtl_priv *rtlpriv, u8 *reject_agg,
25742635664eSPing-Ke Shih 				  u8 *ctrl_agg_size, u8 *agg_size);
2575c692205dSPing-Ke Shih 	bool (*btc_is_bt_lps_on)(struct rtl_priv *rtlpriv);
2576f1d2b4d3SLarry Finger };
2577f1d2b4d3SLarry Finger 
2578f1d2b4d3SLarry Finger struct proxim {
2579f1d2b4d3SLarry Finger 	bool proxim_on;
2580f1d2b4d3SLarry Finger 
2581f1d2b4d3SLarry Finger 	void *proximity_priv;
2582f1d2b4d3SLarry Finger 	int (*proxim_rx)(struct ieee80211_hw *hw, struct rtl_stats *status,
2583f1d2b4d3SLarry Finger 			 struct sk_buff *skb);
2584f1d2b4d3SLarry Finger 	u8  (*proxim_get_var)(struct ieee80211_hw *hw, u8 type);
2585f1d2b4d3SLarry Finger };
2586f1d2b4d3SLarry Finger 
2587cceb0a59SPing-Ke Shih struct rtl_c2hcmd {
2588cceb0a59SPing-Ke Shih 	struct list_head list;
2589cceb0a59SPing-Ke Shih 	u8 tag;
2590cceb0a59SPing-Ke Shih 	u8 len;
2591cceb0a59SPing-Ke Shih 	u8 *val;
2592cceb0a59SPing-Ke Shih };
2593cceb0a59SPing-Ke Shih 
2594c76ab8e7SPing-Ke Shih struct rtl_bssid_entry {
2595c76ab8e7SPing-Ke Shih 	struct list_head list;
2596c76ab8e7SPing-Ke Shih 	u8 bssid[ETH_ALEN];
2597c76ab8e7SPing-Ke Shih 	u32 age;
2598c76ab8e7SPing-Ke Shih };
2599c76ab8e7SPing-Ke Shih 
2600c76ab8e7SPing-Ke Shih struct rtl_scan_list {
2601c76ab8e7SPing-Ke Shih 	int num;
2602c76ab8e7SPing-Ke Shih 	struct list_head list;	/* sort by age */
2603c76ab8e7SPing-Ke Shih };
2604c76ab8e7SPing-Ke Shih 
2605f1d2b4d3SLarry Finger struct rtl_priv {
2606f1d2b4d3SLarry Finger 	struct ieee80211_hw *hw;
2607f1d2b4d3SLarry Finger 	struct completion firmware_loading_complete;
2608f1d2b4d3SLarry Finger 	struct list_head list;
2609f1d2b4d3SLarry Finger 	struct rtl_priv *buddy_priv;
2610f1d2b4d3SLarry Finger 	struct rtl_global_var *glb_var;
2611f1d2b4d3SLarry Finger 	struct rtl_dualmac_easy_concurrent_ctl easy_concurrent_ctl;
2612f1d2b4d3SLarry Finger 	struct rtl_dmsp_ctl dmsp_ctl;
2613f1d2b4d3SLarry Finger 	struct rtl_locks locks;
2614f1d2b4d3SLarry Finger 	struct rtl_works works;
2615f1d2b4d3SLarry Finger 	struct rtl_mac mac80211;
2616f1d2b4d3SLarry Finger 	struct rtl_hal rtlhal;
2617f1d2b4d3SLarry Finger 	struct rtl_regulatory regd;
2618f1d2b4d3SLarry Finger 	struct rtl_rfkill rfkill;
2619f1d2b4d3SLarry Finger 	struct rtl_io io;
2620f1d2b4d3SLarry Finger 	struct rtl_phy phy;
2621f1d2b4d3SLarry Finger 	struct rtl_dm dm;
2622f1d2b4d3SLarry Finger 	struct rtl_security sec;
2623f1d2b4d3SLarry Finger 	struct rtl_efuse efuse;
2624d5efe153SLarry Finger 	struct rtl_led_ctl ledctl;
26258479580bSPing-Ke Shih 	struct rtl_tx_report tx_report;
2626c76ab8e7SPing-Ke Shih 	struct rtl_scan_list scan_list;
2627f1d2b4d3SLarry Finger 
2628f1d2b4d3SLarry Finger 	struct rtl_ps_ctl psc;
2629f1d2b4d3SLarry Finger 	struct rate_adaptive ra;
2630f1d2b4d3SLarry Finger 	struct dynamic_primary_cca primarycca;
2631f1d2b4d3SLarry Finger 	struct wireless_stats stats;
2632f1d2b4d3SLarry Finger 	struct rt_link_detect link_info;
2633f1d2b4d3SLarry Finger 	struct false_alarm_statistics falsealm_cnt;
2634f1d2b4d3SLarry Finger 
2635f1d2b4d3SLarry Finger 	struct rtl_rate_priv *rate_priv;
2636f1d2b4d3SLarry Finger 
2637f1d2b4d3SLarry Finger 	/* sta entry list for ap adhoc or mesh */
2638f1d2b4d3SLarry Finger 	struct list_head entry_list;
2639f1d2b4d3SLarry Finger 
2640cceb0a59SPing-Ke Shih 	/* c2hcmd list for kthread level access */
2641cceb0a59SPing-Ke Shih 	struct list_head c2hcmd_list;
2642cceb0a59SPing-Ke Shih 
2643f1d2b4d3SLarry Finger 	int max_fw_size;
2644f1d2b4d3SLarry Finger 
2645f1d2b4d3SLarry Finger 	/*
2646f1d2b4d3SLarry Finger 	 *hal_cfg : for diff cards
2647f1d2b4d3SLarry Finger 	 *intf_ops : for diff interrface usb/pcie
2648f1d2b4d3SLarry Finger 	 */
2649f1d2b4d3SLarry Finger 	struct rtl_hal_cfg *cfg;
26501bfcfdccSJulia Lawall 	const struct rtl_intf_ops *intf_ops;
2651f1d2b4d3SLarry Finger 
2652f1d2b4d3SLarry Finger 	/*this var will be set by set_bit,
2653f1d2b4d3SLarry Finger 	   and was used to indicate status of
2654f1d2b4d3SLarry Finger 	   interface or hardware */
2655f1d2b4d3SLarry Finger 	unsigned long status;
2656f1d2b4d3SLarry Finger 
2657f1d2b4d3SLarry Finger 	/* tables for dm */
2658f1d2b4d3SLarry Finger 	struct dig_t dm_digtable;
2659f1d2b4d3SLarry Finger 	struct ps_t dm_pstable;
2660f1d2b4d3SLarry Finger 
2661f1d2b4d3SLarry Finger 	u32 reg_874;
2662f1d2b4d3SLarry Finger 	u32 reg_c70;
2663f1d2b4d3SLarry Finger 	u32 reg_85c;
2664f1d2b4d3SLarry Finger 	u32 reg_a74;
2665f1d2b4d3SLarry Finger 	bool reg_init;	/* true if regs saved */
2666f1d2b4d3SLarry Finger 	bool bt_operation_on;
2667f1d2b4d3SLarry Finger 	__le32 *usb_data;
2668f1d2b4d3SLarry Finger 	int usb_data_index;
2669f1d2b4d3SLarry Finger 	bool initialized;
2670f1d2b4d3SLarry Finger 	bool enter_ps;	/* true when entering PS */
2671f1d2b4d3SLarry Finger 	u8 rate_mask[5];
2672f1d2b4d3SLarry Finger 
2673f1d2b4d3SLarry Finger 	/* intel Proximity, should be alloc mem
2674f1d2b4d3SLarry Finger 	 * in intel Proximity module and can only
2675f1d2b4d3SLarry Finger 	 * be used in intel Proximity mode
2676f1d2b4d3SLarry Finger 	 */
2677f1d2b4d3SLarry Finger 	struct proxim proximity;
2678f1d2b4d3SLarry Finger 
2679f1d2b4d3SLarry Finger 	/*for bt coexist use*/
2680f1d2b4d3SLarry Finger 	struct bt_coexist_info btcoexist;
2681f1d2b4d3SLarry Finger 
2682f1d2b4d3SLarry Finger 	/* separate 92ee from other ICs,
2683f1d2b4d3SLarry Finger 	 * 92ee use new trx flow.
2684f1d2b4d3SLarry Finger 	 */
2685f1d2b4d3SLarry Finger 	bool use_new_trx_flow;
2686f1d2b4d3SLarry Finger 
2687f1d2b4d3SLarry Finger #ifdef CONFIG_PM
2688f1d2b4d3SLarry Finger 	struct wiphy_wowlan_support wowlan;
2689f1d2b4d3SLarry Finger #endif
2690f1d2b4d3SLarry Finger 	/*This must be the last item so
2691f1d2b4d3SLarry Finger 	   that it points to the data allocated
2692f1d2b4d3SLarry Finger 	   beyond  this structure like:
2693f1d2b4d3SLarry Finger 	   rtl_pci_priv or rtl_usb_priv */
2694f1d2b4d3SLarry Finger 	u8 priv[0] __aligned(sizeof(void *));
2695f1d2b4d3SLarry Finger };
2696f1d2b4d3SLarry Finger 
2697f1d2b4d3SLarry Finger #define rtl_priv(hw)		(((struct rtl_priv *)(hw)->priv))
2698f1d2b4d3SLarry Finger #define rtl_mac(rtlpriv)	(&((rtlpriv)->mac80211))
2699f1d2b4d3SLarry Finger #define rtl_hal(rtlpriv)	(&((rtlpriv)->rtlhal))
2700f1d2b4d3SLarry Finger #define rtl_efuse(rtlpriv)	(&((rtlpriv)->efuse))
2701f1d2b4d3SLarry Finger #define rtl_psc(rtlpriv)	(&((rtlpriv)->psc))
2702f1d2b4d3SLarry Finger 
2703f1d2b4d3SLarry Finger 
2704f1d2b4d3SLarry Finger /***************************************
2705f1d2b4d3SLarry Finger     Bluetooth Co-existence Related
2706f1d2b4d3SLarry Finger ****************************************/
2707f1d2b4d3SLarry Finger 
2708f1d2b4d3SLarry Finger enum bt_ant_num {
2709f1d2b4d3SLarry Finger 	ANT_X2 = 0,
2710f1d2b4d3SLarry Finger 	ANT_X1 = 1,
2711f1d2b4d3SLarry Finger };
2712f1d2b4d3SLarry Finger 
2713f1d2b4d3SLarry Finger enum bt_co_type {
2714f1d2b4d3SLarry Finger 	BT_2WIRE = 0,
2715f1d2b4d3SLarry Finger 	BT_ISSC_3WIRE = 1,
2716f1d2b4d3SLarry Finger 	BT_ACCEL = 2,
2717f1d2b4d3SLarry Finger 	BT_CSR_BC4 = 3,
2718f1d2b4d3SLarry Finger 	BT_CSR_BC8 = 4,
2719f1d2b4d3SLarry Finger 	BT_RTL8756 = 5,
2720f1d2b4d3SLarry Finger 	BT_RTL8723A = 6,
2721f1d2b4d3SLarry Finger 	BT_RTL8821A = 7,
2722f1d2b4d3SLarry Finger 	BT_RTL8723B = 8,
2723f1d2b4d3SLarry Finger 	BT_RTL8192E = 9,
2724f1d2b4d3SLarry Finger 	BT_RTL8812A = 11,
2725f1d2b4d3SLarry Finger };
2726f1d2b4d3SLarry Finger 
2727f1d2b4d3SLarry Finger enum bt_total_ant_num {
2728f1d2b4d3SLarry Finger 	ANT_TOTAL_X2 = 0,
2729f1d2b4d3SLarry Finger 	ANT_TOTAL_X1 = 1
2730f1d2b4d3SLarry Finger };
2731f1d2b4d3SLarry Finger 
2732f1d2b4d3SLarry Finger enum bt_cur_state {
2733f1d2b4d3SLarry Finger 	BT_OFF = 0,
2734f1d2b4d3SLarry Finger 	BT_ON = 1,
2735f1d2b4d3SLarry Finger };
2736f1d2b4d3SLarry Finger 
2737f1d2b4d3SLarry Finger enum bt_service_type {
2738f1d2b4d3SLarry Finger 	BT_SCO = 0,
2739f1d2b4d3SLarry Finger 	BT_A2DP = 1,
2740f1d2b4d3SLarry Finger 	BT_HID = 2,
2741f1d2b4d3SLarry Finger 	BT_HID_IDLE = 3,
2742f1d2b4d3SLarry Finger 	BT_SCAN = 4,
2743f1d2b4d3SLarry Finger 	BT_IDLE = 5,
2744f1d2b4d3SLarry Finger 	BT_OTHER_ACTION = 6,
2745f1d2b4d3SLarry Finger 	BT_BUSY = 7,
2746f1d2b4d3SLarry Finger 	BT_OTHERBUSY = 8,
2747f1d2b4d3SLarry Finger 	BT_PAN = 9,
2748f1d2b4d3SLarry Finger };
2749f1d2b4d3SLarry Finger 
2750f1d2b4d3SLarry Finger enum bt_radio_shared {
2751f1d2b4d3SLarry Finger 	BT_RADIO_SHARED = 0,
2752f1d2b4d3SLarry Finger 	BT_RADIO_INDIVIDUAL = 1,
2753f1d2b4d3SLarry Finger };
2754f1d2b4d3SLarry Finger 
2755f1d2b4d3SLarry Finger 
2756f1d2b4d3SLarry Finger /****************************************
2757f1d2b4d3SLarry Finger 	mem access macro define start
2758f1d2b4d3SLarry Finger 	Call endian free function when
2759f1d2b4d3SLarry Finger 	1. Read/write packet content.
2760f1d2b4d3SLarry Finger 	2. Before write integer to IO.
2761f1d2b4d3SLarry Finger 	3. After read integer from IO.
2762f1d2b4d3SLarry Finger ****************************************/
2763f1d2b4d3SLarry Finger /* Convert little data endian to host ordering */
2764f1d2b4d3SLarry Finger #define EF1BYTE(_val)		\
2765f1d2b4d3SLarry Finger 	((u8)(_val))
2766f1d2b4d3SLarry Finger #define EF2BYTE(_val)		\
2767f1d2b4d3SLarry Finger 	(le16_to_cpu(_val))
2768f1d2b4d3SLarry Finger #define EF4BYTE(_val)		\
2769f1d2b4d3SLarry Finger 	(le32_to_cpu(_val))
2770f1d2b4d3SLarry Finger 
2771f1d2b4d3SLarry Finger /* Read data from memory */
2772f1d2b4d3SLarry Finger #define READEF1BYTE(_ptr)      \
2773f1d2b4d3SLarry Finger 	EF1BYTE(*((u8 *)(_ptr)))
2774f1d2b4d3SLarry Finger /* Read le16 data from memory and convert to host ordering */
2775f1d2b4d3SLarry Finger #define READEF2BYTE(_ptr)      \
2776f1d2b4d3SLarry Finger 	EF2BYTE(*(_ptr))
2777f1d2b4d3SLarry Finger #define READEF4BYTE(_ptr)      \
2778f1d2b4d3SLarry Finger 	EF4BYTE(*(_ptr))
2779f1d2b4d3SLarry Finger 
2780f1d2b4d3SLarry Finger /* Create a bit mask
2781f1d2b4d3SLarry Finger  * Examples:
2782f1d2b4d3SLarry Finger  * BIT_LEN_MASK_32(0) => 0x00000000
2783f1d2b4d3SLarry Finger  * BIT_LEN_MASK_32(1) => 0x00000001
2784f1d2b4d3SLarry Finger  * BIT_LEN_MASK_32(2) => 0x00000003
2785f1d2b4d3SLarry Finger  * BIT_LEN_MASK_32(32) => 0xFFFFFFFF
2786f1d2b4d3SLarry Finger  */
2787f1d2b4d3SLarry Finger #define BIT_LEN_MASK_32(__bitlen)	 \
2788f1d2b4d3SLarry Finger 	(0xFFFFFFFF >> (32 - (__bitlen)))
2789f1d2b4d3SLarry Finger #define BIT_LEN_MASK_16(__bitlen)	 \
2790f1d2b4d3SLarry Finger 	(0xFFFF >> (16 - (__bitlen)))
2791f1d2b4d3SLarry Finger #define BIT_LEN_MASK_8(__bitlen) \
2792f1d2b4d3SLarry Finger 	(0xFF >> (8 - (__bitlen)))
2793f1d2b4d3SLarry Finger 
2794f1d2b4d3SLarry Finger /* Create an offset bit mask
2795f1d2b4d3SLarry Finger  * Examples:
2796f1d2b4d3SLarry Finger  * BIT_OFFSET_LEN_MASK_32(0, 2) => 0x00000003
2797f1d2b4d3SLarry Finger  * BIT_OFFSET_LEN_MASK_32(16, 2) => 0x00030000
2798f1d2b4d3SLarry Finger  */
2799f1d2b4d3SLarry Finger #define BIT_OFFSET_LEN_MASK_32(__bitoffset, __bitlen) \
2800f1d2b4d3SLarry Finger 	(BIT_LEN_MASK_32(__bitlen) << (__bitoffset))
2801f1d2b4d3SLarry Finger #define BIT_OFFSET_LEN_MASK_16(__bitoffset, __bitlen) \
2802f1d2b4d3SLarry Finger 	(BIT_LEN_MASK_16(__bitlen) << (__bitoffset))
2803f1d2b4d3SLarry Finger #define BIT_OFFSET_LEN_MASK_8(__bitoffset, __bitlen) \
2804f1d2b4d3SLarry Finger 	(BIT_LEN_MASK_8(__bitlen) << (__bitoffset))
2805f1d2b4d3SLarry Finger 
2806f1d2b4d3SLarry Finger /*Description:
2807f1d2b4d3SLarry Finger  * Return 4-byte value in host byte ordering from
2808f1d2b4d3SLarry Finger  * 4-byte pointer in little-endian system.
2809f1d2b4d3SLarry Finger  */
2810f1d2b4d3SLarry Finger #define LE_P4BYTE_TO_HOST_4BYTE(__pstart) \
2811f1d2b4d3SLarry Finger 	(EF4BYTE(*((__le32 *)(__pstart))))
2812f1d2b4d3SLarry Finger #define LE_P2BYTE_TO_HOST_2BYTE(__pstart) \
2813f1d2b4d3SLarry Finger 	(EF2BYTE(*((__le16 *)(__pstart))))
2814f1d2b4d3SLarry Finger #define LE_P1BYTE_TO_HOST_1BYTE(__pstart) \
2815f1d2b4d3SLarry Finger 	(EF1BYTE(*((u8 *)(__pstart))))
2816f1d2b4d3SLarry Finger 
2817f1d2b4d3SLarry Finger /*Description:
2818f1d2b4d3SLarry Finger Translate subfield (continuous bits in little-endian) of 4-byte
2819f1d2b4d3SLarry Finger value to host byte ordering.*/
2820f1d2b4d3SLarry Finger #define LE_BITS_TO_4BYTE(__pstart, __bitoffset, __bitlen) \
2821f1d2b4d3SLarry Finger 	( \
2822f1d2b4d3SLarry Finger 		(LE_P4BYTE_TO_HOST_4BYTE(__pstart) >> (__bitoffset))  & \
2823f1d2b4d3SLarry Finger 		BIT_LEN_MASK_32(__bitlen) \
2824f1d2b4d3SLarry Finger 	)
2825f1d2b4d3SLarry Finger #define LE_BITS_TO_2BYTE(__pstart, __bitoffset, __bitlen) \
2826f1d2b4d3SLarry Finger 	( \
2827f1d2b4d3SLarry Finger 		(LE_P2BYTE_TO_HOST_2BYTE(__pstart) >> (__bitoffset)) & \
2828f1d2b4d3SLarry Finger 		BIT_LEN_MASK_16(__bitlen) \
2829f1d2b4d3SLarry Finger 	)
2830f1d2b4d3SLarry Finger #define LE_BITS_TO_1BYTE(__pstart, __bitoffset, __bitlen) \
2831f1d2b4d3SLarry Finger 	( \
2832f1d2b4d3SLarry Finger 		(LE_P1BYTE_TO_HOST_1BYTE(__pstart) >> (__bitoffset)) & \
2833f1d2b4d3SLarry Finger 		BIT_LEN_MASK_8(__bitlen) \
2834f1d2b4d3SLarry Finger 	)
2835f1d2b4d3SLarry Finger 
2836f1d2b4d3SLarry Finger /* Description:
2837f1d2b4d3SLarry Finger  * Mask subfield (continuous bits in little-endian) of 4-byte value
2838f1d2b4d3SLarry Finger  * and return the result in 4-byte value in host byte ordering.
2839f1d2b4d3SLarry Finger  */
2840f1d2b4d3SLarry Finger #define LE_BITS_CLEARED_TO_4BYTE(__pstart, __bitoffset, __bitlen) \
2841f1d2b4d3SLarry Finger 	( \
2842f1d2b4d3SLarry Finger 		LE_P4BYTE_TO_HOST_4BYTE(__pstart)  & \
2843f1d2b4d3SLarry Finger 		(~BIT_OFFSET_LEN_MASK_32(__bitoffset, __bitlen)) \
2844f1d2b4d3SLarry Finger 	)
2845f1d2b4d3SLarry Finger #define LE_BITS_CLEARED_TO_2BYTE(__pstart, __bitoffset, __bitlen) \
2846f1d2b4d3SLarry Finger 	( \
2847f1d2b4d3SLarry Finger 		LE_P2BYTE_TO_HOST_2BYTE(__pstart) & \
2848f1d2b4d3SLarry Finger 		(~BIT_OFFSET_LEN_MASK_16(__bitoffset, __bitlen)) \
2849f1d2b4d3SLarry Finger 	)
2850f1d2b4d3SLarry Finger #define LE_BITS_CLEARED_TO_1BYTE(__pstart, __bitoffset, __bitlen) \
2851f1d2b4d3SLarry Finger 	( \
2852f1d2b4d3SLarry Finger 		LE_P1BYTE_TO_HOST_1BYTE(__pstart) & \
2853f1d2b4d3SLarry Finger 		(~BIT_OFFSET_LEN_MASK_8(__bitoffset, __bitlen)) \
2854f1d2b4d3SLarry Finger 	)
2855f1d2b4d3SLarry Finger 
2856f1d2b4d3SLarry Finger /* Description:
2857f1d2b4d3SLarry Finger  * Set subfield of little-endian 4-byte value to specified value.
2858f1d2b4d3SLarry Finger  */
2859f1d2b4d3SLarry Finger #define SET_BITS_TO_LE_4BYTE(__pstart, __bitoffset, __bitlen, __val) \
2860106e0decSLarry Finger 	*((__le32 *)(__pstart)) = \
2861106e0decSLarry Finger 	cpu_to_le32( \
2862f1d2b4d3SLarry Finger 		LE_BITS_CLEARED_TO_4BYTE(__pstart, __bitoffset, __bitlen) | \
2863f1d2b4d3SLarry Finger 		((((u32)__val) & BIT_LEN_MASK_32(__bitlen)) << (__bitoffset)) \
2864ecf4000eSPing-Ke Shih 	)
2865f1d2b4d3SLarry Finger #define SET_BITS_TO_LE_2BYTE(__pstart, __bitoffset, __bitlen, __val) \
2866106e0decSLarry Finger 	*((__le16 *)(__pstart)) = \
2867106e0decSLarry Finger 	cpu_to_le16( \
2868f1d2b4d3SLarry Finger 		LE_BITS_CLEARED_TO_2BYTE(__pstart, __bitoffset, __bitlen) | \
2869f1d2b4d3SLarry Finger 		((((u16)__val) & BIT_LEN_MASK_16(__bitlen)) << (__bitoffset)) \
2870ecf4000eSPing-Ke Shih 	)
2871f1d2b4d3SLarry Finger #define SET_BITS_TO_LE_1BYTE(__pstart, __bitoffset, __bitlen, __val) \
2872f1d2b4d3SLarry Finger 	*((u8 *)(__pstart)) = EF1BYTE \
2873f1d2b4d3SLarry Finger 	( \
2874f1d2b4d3SLarry Finger 		LE_BITS_CLEARED_TO_1BYTE(__pstart, __bitoffset, __bitlen) | \
2875f1d2b4d3SLarry Finger 		((((u8)__val) & BIT_LEN_MASK_8(__bitlen)) << (__bitoffset)) \
2876ecf4000eSPing-Ke Shih 	)
2877f1d2b4d3SLarry Finger 
2878f1d2b4d3SLarry Finger #define	N_BYTE_ALIGMENT(__value, __aligment) ((__aligment == 1) ? \
2879f1d2b4d3SLarry Finger 	(__value) : (((__value + __aligment - 1) / __aligment) * __aligment))
2880f1d2b4d3SLarry Finger 
2881f1d2b4d3SLarry Finger /****************************************
2882f1d2b4d3SLarry Finger 	mem access macro define end
2883f1d2b4d3SLarry Finger ****************************************/
2884f1d2b4d3SLarry Finger 
2885f1d2b4d3SLarry Finger #define byte(x, n) ((x >> (8 * n)) & 0xff)
2886f1d2b4d3SLarry Finger 
2887f1d2b4d3SLarry Finger #define packet_get_type(_packet) (EF1BYTE((_packet).octet[0]) & 0xFC)
2888f1d2b4d3SLarry Finger #define RTL_WATCH_DOG_TIME	2000
2889f1d2b4d3SLarry Finger #define MSECS(t)		msecs_to_jiffies(t)
2890f1d2b4d3SLarry Finger #define WLAN_FC_GET_VERS(fc)	(le16_to_cpu(fc) & IEEE80211_FCTL_VERS)
2891f1d2b4d3SLarry Finger #define WLAN_FC_GET_TYPE(fc)	(le16_to_cpu(fc) & IEEE80211_FCTL_FTYPE)
2892f1d2b4d3SLarry Finger #define WLAN_FC_GET_STYPE(fc)	(le16_to_cpu(fc) & IEEE80211_FCTL_STYPE)
2893f1d2b4d3SLarry Finger #define WLAN_FC_MORE_DATA(fc)	(le16_to_cpu(fc) & IEEE80211_FCTL_MOREDATA)
2894f1d2b4d3SLarry Finger #define rtl_dm(rtlpriv)		(&((rtlpriv)->dm))
2895f1d2b4d3SLarry Finger 
2896f1d2b4d3SLarry Finger #define	RT_RF_OFF_LEVL_ASPM		BIT(0)	/*PCI ASPM */
2897f1d2b4d3SLarry Finger #define	RT_RF_OFF_LEVL_CLK_REQ		BIT(1)	/*PCI clock request */
2898f1d2b4d3SLarry Finger #define	RT_RF_OFF_LEVL_PCI_D3		BIT(2)	/*PCI D3 mode */
2899f1d2b4d3SLarry Finger /*NIC halt, re-initialize hw parameters*/
2900f1d2b4d3SLarry Finger #define	RT_RF_OFF_LEVL_HALT_NIC		BIT(3)
2901f1d2b4d3SLarry Finger #define	RT_RF_OFF_LEVL_FREE_FW		BIT(4)	/*FW free, re-download the FW */
2902f1d2b4d3SLarry Finger #define	RT_RF_OFF_LEVL_FW_32K		BIT(5)	/*FW in 32k */
2903f1d2b4d3SLarry Finger /*Always enable ASPM and Clock Req in initialization.*/
2904f1d2b4d3SLarry Finger #define	RT_RF_PS_LEVEL_ALWAYS_ASPM	BIT(6)
2905f1d2b4d3SLarry Finger /* no matter RFOFF or SLEEP we set PS_ASPM_LEVL*/
2906f1d2b4d3SLarry Finger #define	RT_PS_LEVEL_ASPM		BIT(7)
2907f1d2b4d3SLarry Finger /*When LPS is on, disable 2R if no packet is received or transmittd.*/
2908f1d2b4d3SLarry Finger #define	RT_RF_LPS_DISALBE_2R		BIT(30)
2909f1d2b4d3SLarry Finger #define	RT_RF_LPS_LEVEL_ASPM		BIT(31)	/*LPS with ASPM */
2910f1d2b4d3SLarry Finger #define	RT_IN_PS_LEVEL(ppsc, _ps_flg)		\
2911f1d2b4d3SLarry Finger 	((ppsc->cur_ps_level & _ps_flg) ? true : false)
2912f1d2b4d3SLarry Finger #define	RT_CLEAR_PS_LEVEL(ppsc, _ps_flg)	\
2913f1d2b4d3SLarry Finger 	(ppsc->cur_ps_level &= (~(_ps_flg)))
2914f1d2b4d3SLarry Finger #define	RT_SET_PS_LEVEL(ppsc, _ps_flg)		\
2915f1d2b4d3SLarry Finger 	(ppsc->cur_ps_level |= _ps_flg)
2916f1d2b4d3SLarry Finger 
2917f1d2b4d3SLarry Finger #define container_of_dwork_rtl(x, y, z) \
29184679f413SGeliang Tang 	container_of(to_delayed_work(x), y, z)
2919f1d2b4d3SLarry Finger 
2920f1d2b4d3SLarry Finger #define FILL_OCTET_STRING(_os, _octet, _len)	\
2921f1d2b4d3SLarry Finger 		(_os).octet = (u8 *)(_octet);		\
2922f1d2b4d3SLarry Finger 		(_os).length = (_len);
2923f1d2b4d3SLarry Finger 
2924f1d2b4d3SLarry Finger #define CP_MACADDR(des, src)	\
2925f1d2b4d3SLarry Finger 	((des)[0] = (src)[0], (des)[1] = (src)[1],\
2926f1d2b4d3SLarry Finger 	(des)[2] = (src)[2], (des)[3] = (src)[3],\
2927f1d2b4d3SLarry Finger 	(des)[4] = (src)[4], (des)[5] = (src)[5])
2928f1d2b4d3SLarry Finger 
2929f1d2b4d3SLarry Finger #define	LDPC_HT_ENABLE_RX			BIT(0)
2930f1d2b4d3SLarry Finger #define	LDPC_HT_ENABLE_TX			BIT(1)
2931f1d2b4d3SLarry Finger #define	LDPC_HT_TEST_TX_ENABLE			BIT(2)
2932f1d2b4d3SLarry Finger #define	LDPC_HT_CAP_TX				BIT(3)
2933f1d2b4d3SLarry Finger 
2934f1d2b4d3SLarry Finger #define	STBC_HT_ENABLE_RX			BIT(0)
2935f1d2b4d3SLarry Finger #define	STBC_HT_ENABLE_TX			BIT(1)
2936f1d2b4d3SLarry Finger #define	STBC_HT_TEST_TX_ENABLE			BIT(2)
2937f1d2b4d3SLarry Finger #define	STBC_HT_CAP_TX				BIT(3)
2938f1d2b4d3SLarry Finger 
2939f1d2b4d3SLarry Finger #define	LDPC_VHT_ENABLE_RX			BIT(0)
2940f1d2b4d3SLarry Finger #define	LDPC_VHT_ENABLE_TX			BIT(1)
2941f1d2b4d3SLarry Finger #define	LDPC_VHT_TEST_TX_ENABLE			BIT(2)
2942f1d2b4d3SLarry Finger #define	LDPC_VHT_CAP_TX				BIT(3)
2943f1d2b4d3SLarry Finger 
2944f1d2b4d3SLarry Finger #define	STBC_VHT_ENABLE_RX			BIT(0)
2945f1d2b4d3SLarry Finger #define	STBC_VHT_ENABLE_TX			BIT(1)
2946f1d2b4d3SLarry Finger #define	STBC_VHT_TEST_TX_ENABLE			BIT(2)
2947f1d2b4d3SLarry Finger #define	STBC_VHT_CAP_TX				BIT(3)
2948f1d2b4d3SLarry Finger 
29499696a159SLarry Finger extern u8 channel5g[CHANNEL_MAX_NUMBER_5G];
29509696a159SLarry Finger 
29519696a159SLarry Finger extern u8 channel5g_80m[CHANNEL_MAX_NUMBER_5G_80M];
29529696a159SLarry Finger 
2953f1d2b4d3SLarry Finger static inline u8 rtl_read_byte(struct rtl_priv *rtlpriv, u32 addr)
2954f1d2b4d3SLarry Finger {
2955f1d2b4d3SLarry Finger 	return rtlpriv->io.read8_sync(rtlpriv, addr);
2956f1d2b4d3SLarry Finger }
2957f1d2b4d3SLarry Finger 
2958f1d2b4d3SLarry Finger static inline u16 rtl_read_word(struct rtl_priv *rtlpriv, u32 addr)
2959f1d2b4d3SLarry Finger {
2960f1d2b4d3SLarry Finger 	return rtlpriv->io.read16_sync(rtlpriv, addr);
2961f1d2b4d3SLarry Finger }
2962f1d2b4d3SLarry Finger 
2963f1d2b4d3SLarry Finger static inline u32 rtl_read_dword(struct rtl_priv *rtlpriv, u32 addr)
2964f1d2b4d3SLarry Finger {
2965f1d2b4d3SLarry Finger 	return rtlpriv->io.read32_sync(rtlpriv, addr);
2966f1d2b4d3SLarry Finger }
2967f1d2b4d3SLarry Finger 
2968f1d2b4d3SLarry Finger static inline void rtl_write_byte(struct rtl_priv *rtlpriv, u32 addr, u8 val8)
2969f1d2b4d3SLarry Finger {
2970f1d2b4d3SLarry Finger 	rtlpriv->io.write8_async(rtlpriv, addr, val8);
2971f1d2b4d3SLarry Finger 
2972f1d2b4d3SLarry Finger 	if (rtlpriv->cfg->write_readback)
2973f1d2b4d3SLarry Finger 		rtlpriv->io.read8_sync(rtlpriv, addr);
2974f1d2b4d3SLarry Finger }
2975f1d2b4d3SLarry Finger 
297684d26fdaSPing-Ke Shih static inline void rtl_write_byte_with_val32(struct ieee80211_hw *hw,
297784d26fdaSPing-Ke Shih 					     u32 addr, u32 val8)
297884d26fdaSPing-Ke Shih {
297984d26fdaSPing-Ke Shih 	struct rtl_priv *rtlpriv = rtl_priv(hw);
298084d26fdaSPing-Ke Shih 
298184d26fdaSPing-Ke Shih 	rtl_write_byte(rtlpriv, addr, (u8)val8);
298284d26fdaSPing-Ke Shih }
298384d26fdaSPing-Ke Shih 
2984f1d2b4d3SLarry Finger static inline void rtl_write_word(struct rtl_priv *rtlpriv, u32 addr, u16 val16)
2985f1d2b4d3SLarry Finger {
2986f1d2b4d3SLarry Finger 	rtlpriv->io.write16_async(rtlpriv, addr, val16);
2987f1d2b4d3SLarry Finger 
2988f1d2b4d3SLarry Finger 	if (rtlpriv->cfg->write_readback)
2989f1d2b4d3SLarry Finger 		rtlpriv->io.read16_sync(rtlpriv, addr);
2990f1d2b4d3SLarry Finger }
2991f1d2b4d3SLarry Finger 
2992f1d2b4d3SLarry Finger static inline void rtl_write_dword(struct rtl_priv *rtlpriv,
2993f1d2b4d3SLarry Finger 				   u32 addr, u32 val32)
2994f1d2b4d3SLarry Finger {
2995f1d2b4d3SLarry Finger 	rtlpriv->io.write32_async(rtlpriv, addr, val32);
2996f1d2b4d3SLarry Finger 
2997f1d2b4d3SLarry Finger 	if (rtlpriv->cfg->write_readback)
2998f1d2b4d3SLarry Finger 		rtlpriv->io.read32_sync(rtlpriv, addr);
2999f1d2b4d3SLarry Finger }
3000f1d2b4d3SLarry Finger 
3001f1d2b4d3SLarry Finger static inline u32 rtl_get_bbreg(struct ieee80211_hw *hw,
3002f1d2b4d3SLarry Finger 				u32 regaddr, u32 bitmask)
3003f1d2b4d3SLarry Finger {
3004f1d2b4d3SLarry Finger 	struct rtl_priv *rtlpriv = hw->priv;
3005f1d2b4d3SLarry Finger 
3006f1d2b4d3SLarry Finger 	return rtlpriv->cfg->ops->get_bbreg(hw, regaddr, bitmask);
3007f1d2b4d3SLarry Finger }
3008f1d2b4d3SLarry Finger 
3009f1d2b4d3SLarry Finger static inline void rtl_set_bbreg(struct ieee80211_hw *hw, u32 regaddr,
3010f1d2b4d3SLarry Finger 				 u32 bitmask, u32 data)
3011f1d2b4d3SLarry Finger {
3012f1d2b4d3SLarry Finger 	struct rtl_priv *rtlpriv = hw->priv;
3013f1d2b4d3SLarry Finger 
3014f1d2b4d3SLarry Finger 	rtlpriv->cfg->ops->set_bbreg(hw, regaddr, bitmask, data);
3015f1d2b4d3SLarry Finger }
3016f1d2b4d3SLarry Finger 
301784d26fdaSPing-Ke Shih static inline void rtl_set_bbreg_with_dwmask(struct ieee80211_hw *hw,
301884d26fdaSPing-Ke Shih 				 u32 regaddr, u32 data)
301984d26fdaSPing-Ke Shih {
302084d26fdaSPing-Ke Shih 	rtl_set_bbreg(hw, regaddr, 0xffffffff, data);
302184d26fdaSPing-Ke Shih }
302284d26fdaSPing-Ke Shih 
3023f1d2b4d3SLarry Finger static inline u32 rtl_get_rfreg(struct ieee80211_hw *hw,
3024f1d2b4d3SLarry Finger 				enum radio_path rfpath, u32 regaddr,
3025f1d2b4d3SLarry Finger 				u32 bitmask)
3026f1d2b4d3SLarry Finger {
3027f1d2b4d3SLarry Finger 	struct rtl_priv *rtlpriv = hw->priv;
3028f1d2b4d3SLarry Finger 
3029f1d2b4d3SLarry Finger 	return rtlpriv->cfg->ops->get_rfreg(hw, rfpath, regaddr, bitmask);
3030f1d2b4d3SLarry Finger }
3031f1d2b4d3SLarry Finger 
3032f1d2b4d3SLarry Finger static inline void rtl_set_rfreg(struct ieee80211_hw *hw,
3033f1d2b4d3SLarry Finger 				 enum radio_path rfpath, u32 regaddr,
3034f1d2b4d3SLarry Finger 				 u32 bitmask, u32 data)
3035f1d2b4d3SLarry Finger {
3036f1d2b4d3SLarry Finger 	struct rtl_priv *rtlpriv = hw->priv;
3037f1d2b4d3SLarry Finger 
3038f1d2b4d3SLarry Finger 	rtlpriv->cfg->ops->set_rfreg(hw, rfpath, regaddr, bitmask, data);
3039f1d2b4d3SLarry Finger }
3040f1d2b4d3SLarry Finger 
3041f1d2b4d3SLarry Finger static inline bool is_hal_stop(struct rtl_hal *rtlhal)
3042f1d2b4d3SLarry Finger {
3043f1d2b4d3SLarry Finger 	return (_HAL_STATE_STOP == rtlhal->state);
3044f1d2b4d3SLarry Finger }
3045f1d2b4d3SLarry Finger 
3046f1d2b4d3SLarry Finger static inline void set_hal_start(struct rtl_hal *rtlhal)
3047f1d2b4d3SLarry Finger {
3048f1d2b4d3SLarry Finger 	rtlhal->state = _HAL_STATE_START;
3049f1d2b4d3SLarry Finger }
3050f1d2b4d3SLarry Finger 
3051f1d2b4d3SLarry Finger static inline void set_hal_stop(struct rtl_hal *rtlhal)
3052f1d2b4d3SLarry Finger {
3053f1d2b4d3SLarry Finger 	rtlhal->state = _HAL_STATE_STOP;
3054f1d2b4d3SLarry Finger }
3055f1d2b4d3SLarry Finger 
3056f1d2b4d3SLarry Finger static inline u8 get_rf_type(struct rtl_phy *rtlphy)
3057f1d2b4d3SLarry Finger {
3058f1d2b4d3SLarry Finger 	return rtlphy->rf_type;
3059f1d2b4d3SLarry Finger }
3060f1d2b4d3SLarry Finger 
3061f1d2b4d3SLarry Finger static inline struct ieee80211_hdr *rtl_get_hdr(struct sk_buff *skb)
3062f1d2b4d3SLarry Finger {
3063f1d2b4d3SLarry Finger 	return (struct ieee80211_hdr *)(skb->data);
3064f1d2b4d3SLarry Finger }
3065f1d2b4d3SLarry Finger 
3066f1d2b4d3SLarry Finger static inline __le16 rtl_get_fc(struct sk_buff *skb)
3067f1d2b4d3SLarry Finger {
3068f1d2b4d3SLarry Finger 	return rtl_get_hdr(skb)->frame_control;
3069f1d2b4d3SLarry Finger }
3070f1d2b4d3SLarry Finger 
3071f1d2b4d3SLarry Finger static inline u16 rtl_get_tid_h(struct ieee80211_hdr *hdr)
3072f1d2b4d3SLarry Finger {
3073f1d2b4d3SLarry Finger 	return (ieee80211_get_qos_ctl(hdr))[0] & IEEE80211_QOS_CTL_TID_MASK;
3074f1d2b4d3SLarry Finger }
3075f1d2b4d3SLarry Finger 
3076f1d2b4d3SLarry Finger static inline u16 rtl_get_tid(struct sk_buff *skb)
3077f1d2b4d3SLarry Finger {
3078f1d2b4d3SLarry Finger 	return rtl_get_tid_h(rtl_get_hdr(skb));
3079f1d2b4d3SLarry Finger }
3080f1d2b4d3SLarry Finger 
3081f1d2b4d3SLarry Finger static inline struct ieee80211_sta *get_sta(struct ieee80211_hw *hw,
3082f1d2b4d3SLarry Finger 					    struct ieee80211_vif *vif,
3083f1d2b4d3SLarry Finger 					    const u8 *bssid)
3084f1d2b4d3SLarry Finger {
3085f1d2b4d3SLarry Finger 	return ieee80211_find_sta(vif, bssid);
3086f1d2b4d3SLarry Finger }
3087f1d2b4d3SLarry Finger 
3088f1d2b4d3SLarry Finger static inline struct ieee80211_sta *rtl_find_sta(struct ieee80211_hw *hw,
3089f1d2b4d3SLarry Finger 		u8 *mac_addr)
3090f1d2b4d3SLarry Finger {
3091f1d2b4d3SLarry Finger 	struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
3092f1d2b4d3SLarry Finger 	return ieee80211_find_sta(mac->vif, mac_addr);
3093f1d2b4d3SLarry Finger }
3094f1d2b4d3SLarry Finger 
3095f1d2b4d3SLarry Finger #endif
3096