• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  * Copyright(c) 2007 - 2017 Realtek Corporation.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of version 2 of the GNU General Public License as
7  * published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  *****************************************************************************/
15 #ifndef __COMMON_H2C_H__
16 #define __COMMON_H2C_H__
17 
18 /* ---------------------------------------------------------------------------------------------------------
19  * ----------------------------------    H2C CMD DEFINITION    ------------------------------------------------
20  * ---------------------------------------------------------------------------------------------------------
21  * 88e, 8723b, 8812, 8821, 92e use the same FW code base */
22 enum h2c_cmd {
23 	/* Common Class: 000 */
24 	H2C_RSVD_PAGE = 0x00,
25 	H2C_MEDIA_STATUS_RPT = 0x01,
26 	H2C_SCAN_ENABLE = 0x02,
27 	H2C_KEEP_ALIVE = 0x03,
28 	H2C_DISCON_DECISION = 0x04,
29 	H2C_PSD_OFFLOAD = 0x05,
30 	H2C_CUSTOMER_STR_REQ = 0x06,
31 	H2C_TXPWR_IDX_OFFLOAD = 0x07,
32 	H2C_AP_OFFLOAD = 0x08,
33 	H2C_BCN_RSVDPAGE = 0x09,
34 	H2C_PROBERSP_RSVDPAGE = 0x0A,
35 	H2C_FCS_RSVDPAGE = 0x10,
36 	H2C_FCS_INFO = 0x11,
37 	H2C_AP_WOW_GPIO_CTRL = 0x13,
38 #ifdef CONFIG_MCC_MODE
39 	H2C_MCC_RQT_TSF = 0x15,
40 	H2C_MCC_MACID_BITMAP = 0x16,
41 	H2C_MCC_LOCATION = 0x10,
42 	H2C_MCC_CTRL_V2 = 0x17,
43 	H2C_MCC_CTRL = 0x18,
44 	H2C_MCC_TIME_SETTING = 0x19,
45 	H2C_MCC_IQK_PARAM = 0x1A,
46 #endif /* CONFIG_MCC_MODE */
47 	H2C_CHNL_SWITCH_OPER_OFFLOAD = 0x1C,
48 	H2C_SINGLE_CHANNELSWITCH_V2 = 0x1D,
49 
50 	/* PoweSave Class: 001 */
51 	H2C_SET_PWR_MODE = 0x20,
52 	H2C_PS_TUNING_PARA = 0x21,
53 	H2C_PS_TUNING_PARA2 = 0x22,
54 	H2C_P2P_LPS_PARAM = 0x23,
55 	H2C_P2P_PS_OFFLOAD = 0x24,
56 	H2C_PS_SCAN_ENABLE = 0x25,
57 	H2C_SAP_PS_ = 0x26,
58 	H2C_INACTIVE_PS_ = 0x27, /* Inactive_PS */
59 	H2C_FWLPS_IN_IPS_ = 0x28,
60 #ifdef CONFIG_LPS_POFF
61 	H2C_LPS_POFF_CTRL = 0x29,
62 	H2C_LPS_POFF_PARAM = 0x2A,
63 #endif
64 #ifdef CONFIG_LPS_PG
65 	H2C_LPS_PG_INFO = 0x2B,
66 #endif
67 
68 #ifdef CONFIG_FW_MULTI_PORT_SUPPORT
69 	H2C_DEFAULT_PORT_ID = 0x2C,
70 #endif
71 	/* Dynamic Mechanism Class: 010 */
72 	H2C_MACID_CFG = 0x40,
73 	H2C_TXBF = 0x41,
74 	H2C_RSSI_SETTING = 0x42,
75 	H2C_AP_REQ_TXRPT = 0x43,
76 	H2C_INIT_RATE_COLLECT = 0x44,
77 	H2C_IQ_CALIBRATION	= 0x45,
78 
79 	H2C_RA_MASK_3SS = 0x46,/* for 8814A */
80 	H2C_RA_PARA_ADJUST = 0x47,/* CONFIG_RA_DBG_CMD */
81 	H2C_DYNAMIC_TX_PATH = 0x48,/* for 8814A */
82 
83 	H2C_FW_TRACE_EN = 0x49,
84 #ifdef RTW_PER_CMD_SUPPORT_FW
85 	H2C_REQ_PER_RPT = 0x4e,
86 #endif
87 	/* BT Class: 011 */
88 	H2C_B_TYPE_TDMA = 0x60,
89 	H2C_BT_INFO = 0x61,
90 	H2C_FORCE_BT_TXPWR = 0x62,
91 	H2C_BT_IGNORE_WLANACT = 0x63,
92 	H2C_DAC_SWING_VALUE = 0x64,
93 	H2C_ANT_SEL_RSV = 0x65,
94 	H2C_WL_OPMODE = 0x66,
95 	H2C_BT_MP_OPER = 0x67,
96 	H2C_BT_CONTROL = 0x68,
97 	H2C_BT_WIFI_CTRL = 0x69,
98 	H2C_BT_FW_PATCH = 0x6A,
99 #if defined(CONFIG_BT_COEXIST) && defined(CONFIG_FW_MULTI_PORT_SUPPORT)
100 	H2C_BTC_WL_PORT_ID = 0x71,
101 #endif
102 	/* WOWLAN Class: 100 */
103 	H2C_WOWLAN = 0x80,
104 	H2C_REMOTE_WAKE_CTRL = 0x81,
105 	H2C_AOAC_GLOBAL_INFO = 0x82,
106 	H2C_AOAC_RSVD_PAGE = 0x83,
107 	H2C_AOAC_RSVD_PAGE2 = 0x84,
108 	H2C_D0_SCAN_OFFLOAD_CTRL = 0x85,
109 	H2C_D0_SCAN_OFFLOAD_INFO = 0x86,
110 	H2C_CHNL_SWITCH_OFFLOAD = 0x87,
111 	H2C_AOAC_RSVDPAGE3 = 0x88,
112 	H2C_GPIO_CUSTOM = 0x89,
113 	H2C_P2P_OFFLOAD_RSVD_PAGE = 0x8A,
114 	H2C_P2P_OFFLOAD = 0x8B,
115 #ifdef CONFIG_PNO_SUPPORT
116 	H2C_NLO_INFO = 0x8C, /* for ICs that have HAMMAC */
117 #endif
118 	H2C_WAR_OFFLOAD = 0x8D,
119 	H2C_WAROFLD_RSVDPAGE1 = 0x8E,
120 #ifdef CONFIG_WOW_KEEP_ALIVE_PATTERN
121 	H2C_UDP_KEEPALIVE = 0x90,
122 #endif /*CONFIG_WOW_KEEP_ALIVE_PATTERN*/
123 #ifdef CONFIG_FW_HANDLE_TXBCN
124 	H2C_FW_BCN_OFFLOAD = 0xBA,
125 #endif
126 #ifdef CONFIG_SUPPORT_DYNAMIC_TXPWR
127 	H2C_FW_CRC5_SEARCH = 0xBB,
128 #endif
129 	H2C_RESET_TSF = 0xC0,
130 #ifdef CONFIG_FW_CORRECT_BCN
131 	H2C_BCNHWSEQ = 0xC5,
132 #endif
133 	H2C_CUSTOMER_STR_W1 = 0xC6,
134 	H2C_CUSTOMER_STR_W2 = 0xC7,
135 	H2C_CUSTOMER_STR_W3 = 0xC8,
136 	H2C_BT_UNKNOWN_DEVICE_WA = 0xD1,
137 	H2C_SET_AP_BCN_IMR = 0xD8,
138 #ifdef DBG_FW_DEBUG_MSG_PKT
139 	H2C_FW_DBG_MSG_PKT = 0xE1,
140 #endif /*DBG_FW_DEBUG_MSG_PKT*/
141 	H2C_MAXID,
142 };
143 
144 #define H2C_INACTIVE_PS_LEN		4
145 #define H2C_RSVDPAGE_LOC_LEN		5
146 #ifdef CONFIG_FW_MULTI_PORT_SUPPORT
147 #define H2C_DEFAULT_PORT_ID_LEN		2
148 #define H2C_MEDIA_STATUS_RPT_LEN		4
149 #else
150 #define H2C_MEDIA_STATUS_RPT_LEN		3
151 #endif
152 #define H2C_GPIO_CUSTOM_LEN		3
153 #define H2C_KEEP_ALIVE_CTRL_LEN	2
154 #ifdef CONFIG_WOW_KEEP_ALIVE_PATTERN
155 #define H2C_KEEP_ALIVE_PATTERN_LEN	7
156 #endif /*CONFIG_WOW_KEEP_ALIVE_PATTERN*/
157 #define H2C_DISCON_DECISION_LEN		3
158 #define H2C_AP_OFFLOAD_LEN		3
159 #define H2C_AP_WOW_GPIO_CTRL_LEN	4
160 #define H2C_AP_PS_LEN			2
161 #define H2C_PWRMODE_LEN			7
162 #define H2C_AP_BCN_MIR_LEN 1
163 #define H2C_PSTUNEPARAM_LEN			4
164 #define H2C_MACID_CFG_LEN		7
165 #define H2C_BTMP_OPER_LEN			5
166 #define H2C_WOWLAN_LEN			7
167 #define H2C_REMOTE_WAKE_CTRL_LEN	3
168 #define H2C_AOAC_GLOBAL_INFO_LEN	2
169 #define H2C_AOAC_RSVDPAGE_LOC_LEN	7
170 #define H2C_SCAN_OFFLOAD_CTRL_LEN	4
171 #define H2C_BT_FW_PATCH_LEN			6
172 #define H2C_RSSI_SETTING_LEN		4
173 #define H2C_AP_REQ_TXRPT_LEN		3
174 #define H2C_FORCE_BT_TXPWR_LEN		3
175 #define H2C_BCN_RSVDPAGE_LEN		5
176 #define H2C_PROBERSP_RSVDPAGE_LEN	5
177 #define H2C_P2PRSVDPAGE_LOC_LEN	5
178 #define H2C_P2P_OFFLOAD_LEN	3
179 #ifdef CONFIG_PNO_SUPPORT
180 #define H2C_NLO_INFO_LEN	2
181 #endif
182 #ifdef CONFIG_MCC_MODE
183 	#define H2C_MCC_CTRL_LEN			7
184 #ifdef CONFIG_MCC_MODE_V2
185 	#define H2C_MCC_LOCATION_LEN		7
186 #else
187 	#define H2C_MCC_LOCATION_LEN		3
188 #endif
189 	#define H2C_MCC_MACID_BITMAP_LEN	6
190 	#define H2C_MCC_RQT_TSF_LEN		1
191 	#define H2C_MCC_TIME_SETTING_LEN		6
192 	#define H2C_MCC_IQK_PARAM_LEN		7
193 #endif /* CONFIG_MCC_MODE */
194 #ifdef CONFIG_LPS_PG
195 #ifdef CONFIG_RTL8822C
196 	#define H2C_LPS_PG_INFO_LEN		4
197 #else
198 	#define H2C_LPS_PG_INFO_LEN		2
199 #endif
200 	#define H2C_LPSPG_LEN			16
201 #endif
202 #ifdef CONFIG_LPS_POFF
203 	#define H2C_LPS_POFF_CTRL_LEN		1
204 	#define H2C_LPS_POFF_PARAM_LEN		5
205 #endif
206 
207 #if defined(CONFIG_BT_COEXIST) && defined(CONFIG_FW_MULTI_PORT_SUPPORT)
208 #define H2C_BTC_WL_PORT_ID_LEN	1
209 #endif
210 
211 #ifdef DBG_FW_DEBUG_MSG_PKT
212 	#define H2C_FW_DBG_MSG_PKT_LEN	2
213 #endif /*DBG_FW_DEBUG_MSG_PKT*/
214 
215 #define H2C_SINGLE_CHANNELSWITCH_V2_LEN 3
216 #define H2C_BT_UNKNOWN_DEVICE_WA_LEN 1
217 
218 #ifdef CONFIG_SUPPORT_DYNAMIC_TXPWR
219 #define H2C_FW_CRC5_SEARCH_LEN	7
220 #endif
221 
222 #ifdef CONFIG_WAR_OFFLOAD
223 #define	H2C_WAR_OFFLOAD_LEN			3
224 #define	H2C_WAROFLD_RSVDPAGE1_LEN	6
225 #endif /* CONFIG_WAR_OFFLOAD */
226 
227 
228 #define eq_mac_addr(a, b)						(((a)[0] == (b)[0] && (a)[1] == (b)[1] && (a)[2] == (b)[2] && (a)[3] == (b)[3] && (a)[4] == (b)[4] && (a)[5] == (b)[5]) ? 1 : 0)
229 #define cp_mac_addr(des, src)					((des)[0] = (src)[0], (des)[1] = (src)[1], (des)[2] = (src)[2], (des)[3] = (src)[3], (des)[4] = (src)[4], (des)[5] = (src)[5])
230 #define cpIpAddr(des, src)					((des)[0] = (src)[0], (des)[1] = (src)[1], (des)[2] = (src)[2], (des)[3] = (src)[3])
231 #define cpIpv6Addr(des, src)                                   ((des)[0] = (src)[0], (des)[1] = (src)[1], (des)[2] = (src)[2], (des)[3] = (src)[3], (des)[4] = (src)[4], (des)[5] = (src)[5], (des)[6] = (src)[6], (des)[7] = (src)[7], (des)[8] = (src)[8], (des)[9] = (src)[9], (des)[10] = (src)[10], (des)[11] = (src)[11], (des)[12] = (src)[12], (des)[13] = (src)[13], (des)[14] = (src)[14], (des)[15] = (src)[15])
232 
233 
234 #if defined(CONFIG_WOWLAN) || defined(CONFIG_AP_WOWLAN)
235 #define FW_WOWLAN_FUN_EN				BIT(0)
236 #define FW_WOWLAN_PATTERN_MATCH			BIT(1)
237 #define FW_WOWLAN_MAGIC_PKT				BIT(2)
238 #define FW_WOWLAN_UNICAST				BIT(3)
239 #define FW_WOWLAN_ALL_PKT_DROP			BIT(4)
240 #define FW_WOWLAN_GPIO_ACTIVE			BIT(5)
241 #define FW_WOWLAN_REKEY_WAKEUP			BIT(6)
242 #define FW_WOWLAN_DEAUTH_WAKEUP			BIT(7)
243 
244 #define FW_WOWLAN_GPIO_WAKEUP_EN		BIT(0)
245 #define FW_FW_PARSE_MAGIC_PKT			BIT(1)
246 
247 #define FW_REMOTE_WAKE_CTRL_EN			BIT(0)
248 #define FW_REALWOWLAN_EN				BIT(5)
249 
250 #define FW_WOWLAN_KEEP_ALIVE_EN			BIT(0)
251 #define FW_ADOPT_USER					BIT(1)
252 #define FW_WOWLAN_KEEP_ALIVE_PKT_TYPE	BIT(2)
253 
254 #define FW_REMOTE_WAKE_CTRL_EN			BIT(0)
255 #define FW_ARP_EN						BIT(1)
256 #define FW_REALWOWLAN_EN				BIT(5)
257 #define FW_WOW_FW_UNICAST_EN			BIT(7)
258 
259 #define FW_IPS_DISABLE_BBRF		BIT(0)
260 #define FW_IPS_WRC				BIT(1)
261 
262 #endif /* CONFIG_WOWLAN */
263 
264 /* _RSVDPAGE_LOC_CMD_0x00 */
265 #define SET_H2CCMD_RSVDPAGE_LOC_PROBE_RSP(__pH2CCmd, __Value)		SET_BITS_TO_LE_1BYTE(__pH2CCmd, 0, 8, __Value)
266 #define SET_H2CCMD_RSVDPAGE_LOC_PSPOLL(__pH2CCmd, __Value)			SET_BITS_TO_LE_1BYTE((__pH2CCmd)+1, 0, 8, __Value)
267 #define SET_H2CCMD_RSVDPAGE_LOC_NULL_DATA(__pH2CCmd, __Value)		SET_BITS_TO_LE_1BYTE((__pH2CCmd)+2, 0, 8, __Value)
268 #define SET_H2CCMD_RSVDPAGE_LOC_QOS_NULL_DATA(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd)+3, 0, 8, __Value)
269 #define SET_H2CCMD_RSVDPAGE_LOC_BT_QOS_NULL_DATA(__pH2CCmd, __Value)SET_BITS_TO_LE_1BYTE((__pH2CCmd)+4, 0, 8, __Value)
270 
271 /* _MEDIA_STATUS_RPT_PARM_CMD_0x01 */
272 #define SET_H2CCMD_MSRRPT_PARM_OPMODE(__pH2CCmd, __Value)			SET_BITS_TO_LE_1BYTE(((u8 *)(__pH2CCmd)), 0, 1, (__Value))
273 #define SET_H2CCMD_MSRRPT_PARM_MACID_IND(__pH2CCmd, __Value)		SET_BITS_TO_LE_1BYTE(((u8 *)(__pH2CCmd)), 1, 1, (__Value))
274 #define SET_H2CCMD_MSRRPT_PARM_MIRACAST(__pH2CCmd, __Value)			SET_BITS_TO_LE_1BYTE(((u8 *)(__pH2CCmd)), 2, 1, (__Value))
275 #define SET_H2CCMD_MSRRPT_PARM_MIRACAST_SINK(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE(((u8 *)(__pH2CCmd)), 3, 1, (__Value))
276 #define SET_H2CCMD_MSRRPT_PARM_ROLE(__pH2CCmd, __Value)				SET_BITS_TO_LE_1BYTE(((u8 *)(__pH2CCmd)), 4, 4, (__Value))
277 #define SET_H2CCMD_MSRRPT_PARM_MACID(__pH2CCmd, __Value)			SET_BITS_TO_LE_1BYTE(((u8 *)(__pH2CCmd)) + 1, 0, 8, (__Value))
278 #define SET_H2CCMD_MSRRPT_PARM_MACID_END(__pH2CCmd, __Value)		SET_BITS_TO_LE_1BYTE(((u8 *)(__pH2CCmd)) + 2, 0, 8, (__Value))
279 #define SET_H2CCMD_MSRRPT_PARM_PORT_NUM(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE(((u8 *)(__pH2CCmd)) + 3, 0, 3, (__Value))
280 
281 #define GET_H2CCMD_MSRRPT_PARM_OPMODE(__pH2CCmd)		LE_BITS_TO_1BYTE(((u8 *)(__pH2CCmd)), 0, 1)
282 #define GET_H2CCMD_MSRRPT_PARM_MIRACAST(__pH2CCmd)		LE_BITS_TO_1BYTE(((u8 *)(__pH2CCmd)), 2, 1)
283 #define GET_H2CCMD_MSRRPT_PARM_MIRACAST_SINK(__pH2CCmd)	LE_BITS_TO_1BYTE(((u8 *)(__pH2CCmd)), 3, 1)
284 #define GET_H2CCMD_MSRRPT_PARM_ROLE(__pH2CCmd)			LE_BITS_TO_1BYTE(((u8 *)(__pH2CCmd)), 4, 4)
285 
286 #ifdef CONFIG_WAR_OFFLOAD
287 #define SET_IPHDR_VERSION(__pHeader, __Value)				WriteLE1Byte(((u8 *)(__pHeader)) + 0, __Value)
288 #define SET_IPHDR_DSCP(__pHeader, __Value)					WriteLE1Byte(((u8 *)(__pHeader)) + 1, __Value)
289 #define SET_IPHDR_TOTAL_LEN(__pHeader, __Value)			WriteLE2Byte(((u8 *)(__pHeader)) + 2, __Value)
290 #define SET_IPHDR_IDENTIFIER(__pHeader, __Value)			WriteLE2Byte(((u8 *)(__pHeader)) + 4, __Value)
291 #define SET_IPHDR_FLAGS(__pHeader, __Value)				WriteLE1Byte(((u8 *)(__pHeader)) + 6, __Value)
292 #define SET_IPHDR_FRAG_OFFSET(__pHeader, __Value)			WriteLE1Byte(((u8 *)(__pHeader)) + 7, __Value)
293 #define SET_IPHDR_TTL(__pHeader, __Value)					WriteLE1Byte(((u8 *)(__pHeader)) + 8, __Value)
294 #define SET_IPHDR_PROTOCOL(__pHeader, __Value)			WriteLE1Byte(((u8 *)(__pHeader)) + 9, __Value)
295 #define SET_IPHDR_HDR_CHECKSUM(__pHeader, __Value)		WriteLE2Byte(((u8 *)(__pHeader)) + 10, __Value)
296 #define SET_IPHDR_SRC_IP_ADDR(__pHeader, __Value)			cpIpAddr(((u8 *)(__pHeader))+12, (u8 *)(__Value))
297 #define SET_IPHDR_DST_IP_ADDR(__pHeader, __Value)			cpIpAddr(((u8 *)(__pHeader))+16, (u8 *)(__Value))
298 #define SET_UDP_SRC_PORT(__pHeader, __Value)	WriteLE2Byte(((u8 *)(__pHeader)) + 0, __Value)
299 #define SET_UDP_DST_PORT(__pHeader, __Value)	WriteLE2Byte(((u8 *)(__pHeader)) + 2, __Value)
300 #define SET_UDP_LEN(__pHeader, __Value)			WriteLE2Byte(((u8 *)(__pHeader)) + 4, __Value)
301 #define SET_UDP_CHECKSUM(__pHeader, __Value)			WriteLE2Byte(((u8 *)(__pHeader)) + 6, __Value)
302 
303 #define SET_MDNS_HDR_FLAG(__pHeader, __Value)		WriteLE1Byte(((u8 *)(__pHeader)) + 2, __Value)
304 
305 #endif /* CONFIG_WAR_OFFLOAD */
306 
307 #ifdef CONFIG_OFFLOAD_MDNS_V6
308 #define SET_IPHDRV6_VERSION(__pHeader, __Value)                     SET_BITS_TO_LE_1BYTE(__pHeader, 4, 4, __Value)
309 #define SET_IPHDRV6_TRAFFIC_CLASS(__pHeader, __Value)               SET_BITS_TO_LE_2BYTE(__pHeader, 4, 8, __Value)
310 #define SET_IPHDRV6_FLOW_LABEL(__pHeader, __Value)                  SET_BITS_TO_LE_4BYTE(__pHeader, 12, 20, __Value)
311 #define SET_IPHDRV6_PAYLOAD_LENGTH(__pHeader, __Value)              SET_BITS_TO_LE_2BYTE(((u8 *)(__pHeader)) + 4, 0, 16, __Value)
312 #define SET_IPHDRV6_NEXT_HEADER(__pHeader, __Value)                 SET_BITS_TO_LE_1BYTE((__pHeader) + 6, 0, 8, __Value)
313 #define SET_IPHDRV6_HOP_LIMIT(__pHeader, __Value)                   SET_BITS_TO_LE_1BYTE((__pHeader) + 7, 0, 8, __Value)
314 #define SET_IPHDRV6_SRC_IP_ADDR(__pHeader, __Value)                 cpIpv6Addr((u8 *)(__pHeader) + 8, (u8 *)(__Value))
315 #define SET_IPHDRV6_DST_IP_ADDR(__pHeader, __Value)                 cpIpv6Addr((u8 *)(__pHeader) + 24, (u8 *)(__Value))
316 #endif
317 
318 
319 
320 #define H2C_MSR_ROLE_RSVD	0
321 #define H2C_MSR_ROLE_STA	1
322 #define H2C_MSR_ROLE_AP		2
323 #define H2C_MSR_ROLE_GC		3
324 #define H2C_MSR_ROLE_GO		4
325 #define H2C_MSR_ROLE_TDLS	5
326 #define H2C_MSR_ROLE_ADHOC	6
327 #define H2C_MSR_ROLE_MESH	7
328 #define H2C_MSR_ROLE_MAX	8
329 
330 extern const char *const _h2c_msr_role_str[];
331 #define h2c_msr_role_str(role) (((role) >= H2C_MSR_ROLE_MAX) ? _h2c_msr_role_str[H2C_MSR_ROLE_MAX] : _h2c_msr_role_str[(role)])
332 
333 #define H2C_MSR_FMT "%s %s%s"
334 #define H2C_MSR_ARG(h2c_msr) \
335 	GET_H2CCMD_MSRRPT_PARM_OPMODE((h2c_msr)) ? " C" : "", \
336 	h2c_msr_role_str(GET_H2CCMD_MSRRPT_PARM_ROLE((h2c_msr))), \
337 	GET_H2CCMD_MSRRPT_PARM_MIRACAST((h2c_msr)) ? (GET_H2CCMD_MSRRPT_PARM_MIRACAST_SINK((h2c_msr)) ? " MSINK" : " MSRC") : ""
338 
339 s32 rtw_hal_set_FwMediaStatusRpt_cmd(_adapter *adapter, bool opmode, bool miracast, bool miracast_sink, u8 role, u8 macid, bool macid_ind, u8 macid_end);
340 s32 rtw_hal_set_FwMediaStatusRpt_single_cmd(_adapter *adapter, bool opmode, bool miracast, bool miracast_sink, u8 role, u8 macid);
341 s32 rtw_hal_set_FwMediaStatusRpt_range_cmd(_adapter *adapter, bool opmode, bool miracast, bool miracast_sink, u8 role, u8 macid, u8 macid_end);
342 
343 /* _KEEP_ALIVE_CMD_0x03 */
344 #define SET_H2CCMD_KEEPALIVE_PARM_ENABLE(__pH2CCmd, __Value)		SET_BITS_TO_LE_1BYTE(__pH2CCmd, 0, 1, __Value)
345 #define SET_H2CCMD_KEEPALIVE_PARM_ADOPT(__pH2CCmd, __Value)		SET_BITS_TO_LE_1BYTE(__pH2CCmd, 1, 1, __Value)
346 #define SET_H2CCMD_KEEPALIVE_PARM_PKT_TYPE(__pH2CCmd, __Value)		SET_BITS_TO_LE_1BYTE(__pH2CCmd, 2, 1, __Value)
347 #define SET_H2CCMD_KEEPALIVE_PARM_PORT_NUM(__pH2CCmd, __Value)		SET_BITS_TO_LE_1BYTE(__pH2CCmd, 3, 3, __Value)
348 #define SET_H2CCMD_KEEPALIVE_PARM_CHECK_PERIOD(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE(__pH2CCmd+1, 0, 8, __Value)
349 
350 /* _DISCONNECT_DECISION_CMD_0x04 */
351 #define SET_H2CCMD_DISCONDECISION_PARM_ENABLE(__pH2CCmd, __Value)		SET_BITS_TO_LE_1BYTE(__pH2CCmd, 0, 1, __Value)
352 #define SET_H2CCMD_DISCONDECISION_PARM_ADOPT(__pH2CCmd, __Value)		SET_BITS_TO_LE_1BYTE(__pH2CCmd, 1, 1, __Value)
353 #define SET_H2CCMD_DISCONDECISION_PARM_TRY_BCN_FAIL_EN(__pH2CCmd, __Value)		SET_BITS_TO_LE_1BYTE(__pH2CCmd, 2, 1, __Value)
354 #define SET_H2CCMD_DISCONDECISION_PARM_DISCONNECT_EN(__pH2CCmd, __Value)		SET_BITS_TO_LE_1BYTE(__pH2CCmd, 3, 1, __Value)
355 #define SET_H2CCMD_DISCONDECISION_PORT_NUM(__pH2CCmd, __Value)			SET_BITS_TO_LE_1BYTE(__pH2CCmd, 4, 3, __Value)
356 #define SET_H2CCMD_DISCONDECISION_PARM_CHECK_PERIOD(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE(__pH2CCmd+1, 0, 8, __Value)
357 #define SET_H2CCMD_DISCONDECISION_PARM_TRY_PKT_NUM(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE(__pH2CCmd+2, 0, 8, __Value)
358 #define SET_H2CCMD_DISCONDECISION_PARM_TRY_OK_BCN(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE(__pH2CCmd+3, 0, 8, __Value)
359 
360 /*UDP_KEEP_ALIVE 0x90*/
361 #ifdef CONFIG_WOW_KEEP_ALIVE_PATTERN
362 /*data 0*/
363 #define SET_H2CCMD_UDP_KEEP_ALIVE_EN(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE(__pH2CCmd, 0, 1, __Value);
364 #define SET_H2CCMD_UDP_KEEP_ALIVE_PACKET_LOC(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE(__pH2CCmd, 1, 7, __Value);
365 /*data 1*/
366 #define SET_H2CCMD_UDP_KEEP_ALIVE_ACK_PATTERN_EN(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE(__pH2CCmd+1, 7, 1, __Value);
367 #define SET_H2CCMD_UDP_KEEP_ALIVE_ACK_PATTERN_idx(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE(__pH2CCmd+1, 0, 7, __Value);
368 /*data 2*/
369 #define SET_H2CCMD_UDP_KEEP_ALIVE_WAKE_EN(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE(__pH2CCmd+2, 7, 1, __Value);
370 #define SET_H2CCMD_UDP_KEEP_ALIVE_WAKE_PATTERN_idx(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE(__pH2CCmd+2, 0, 7, __Value);
371 /*data3*/
372 #define SET_H2CCMD_UDP_KEEP_ALIVE_PERIOD_LOW_BIT(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE(__pH2CCmd+3, 0, 8, __Value);
373 /*data4*/
374 #define SET_H2CCMD_UDP_KEEP_ALIVE_PERIOD_HI_BIT(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE(__pH2CCmd+4, 0, 8, __Value);
375 /*data5*/
376 #define SET_H2CCMD_UDP_KEEP_ALIVE_RETRY_INTERVAL(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE(__pH2CCmd+5, 0, 8, __Value);
377 /*data6*/
378 #define SET_H2CCMD_UDP_KEEP_ALIVE_RETRY_LIMIT(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE(__pH2CCmd+6, 0, 8, __Value);
379 #endif /*CONFIG_WOW_KEEP_ALIVE_PATTERN*/
380 #ifdef CONFIG_RTW_CUSTOMER_STR
381 #define RTW_CUSTOMER_STR_LEN 16
382 #define RTW_CUSTOMER_STR_FMT "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x"
383 #define RTW_CUSTOMER_STR_ARG(x) ((u8 *)(x))[0], ((u8 *)(x))[1], ((u8 *)(x))[2], ((u8 *)(x))[3], ((u8 *)(x))[4], ((u8 *)(x))[5], \
384 	((u8 *)(x))[6], ((u8 *)(x))[7], ((u8 *)(x))[8], ((u8 *)(x))[9], ((u8 *)(x))[10], ((u8 *)(x))[11], \
385 	((u8 *)(x))[12], ((u8 *)(x))[13], ((u8 *)(x))[14], ((u8 *)(x))[15]
386 
387 /* H2C_CUSTOMER_STR_REQ  0x06 */
388 #define H2C_CUSTOMER_STR_REQ_LEN 1
389 #define SET_H2CCMD_CUSTOMER_STR_REQ_EN(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE(((u8 *)(__pH2CCmd)), 0, 1, (__Value))
390 s32 rtw_hal_h2c_customer_str_req(_adapter *adapter);
391 s32 rtw_hal_customer_str_read(_adapter *adapter, u8 *cs);
392 
393 /* H2C_CUSTOMER_STR_W1 0xC6 */
394 #define H2C_CUSTOMER_STR_W1_LEN 7
395 #define SET_H2CCMD_CUSTOMER_STR_W1_EN(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE(((u8 *)(__pH2CCmd)), 0, 1, (__Value))
396 #define H2CCMD_CUSTOMER_STR_W1_BYTE0(__pH2CCmd)				(((u8 *)(__pH2CCmd)) + 1)
397 
398 /* H2C_CUSTOMER_STR_W2 0xC7 */
399 #define H2C_CUSTOMER_STR_W2_LEN 7
400 #define SET_H2CCMD_CUSTOMER_STR_W2_EN(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE(((u8 *)(__pH2CCmd)), 0, 1, (__Value))
401 #define H2CCMD_CUSTOMER_STR_W2_BYTE6(__pH2CCmd)				(((u8 *)(__pH2CCmd)) + 1)
402 
403 /* H2C_CUSTOMER_STR_W3 0xC8 */
404 #define H2C_CUSTOMER_STR_W3_LEN 5
405 #define SET_H2CCMD_CUSTOMER_STR_W3_EN(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE(((u8 *)(__pH2CCmd)), 0, 1, (__Value))
406 #define H2CCMD_CUSTOMER_STR_W3_BYTE12(__pH2CCmd)			(((u8 *)(__pH2CCmd)) + 1)
407 s32 rtw_hal_h2c_customer_str_write(_adapter *adapter, const u8 *cs);
408 s32 rtw_hal_customer_str_write(_adapter *adapter, const u8 *cs);
409 #endif /* CONFIG_RTW_CUSTOMER_STR */
410 
411 #ifdef CONFIG_FW_OFFLOAD_SET_TXPWR_IDX
412 #define H2C_TXPWR_IDX_OFFLOAD_LEN 4
413 #define SET_H2CCMD_TXPWR_IDX_CCK(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE(__pH2CCmd, 0, 8, __Value)
414 #define SET_H2CCMD_TXPWR_IDX_OFDM(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE(__pH2CCmd + 1, 0, 8, __Value)
415 #define SET_H2CCMD_TXPWR_IDX_HT1SS(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE(__pH2CCmd + 2, 0, 8, __Value)
416 #define SET_H2CCMD_TXPWR_IDX_EN(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE(__pH2CCmd + 3, 0, 1, __Value)
417 #endif
418 
419 /* _AP_Offload 0x08 */
420 #define SET_H2CCMD_AP_WOWLAN_EN(__pH2CCmd, __Value)			SET_BITS_TO_LE_1BYTE(__pH2CCmd, 0, 8, __Value)
421 /* _BCN_RsvdPage	0x09 */
422 #define SET_H2CCMD_AP_WOWLAN_RSVDPAGE_LOC_BCN(__pH2CCmd, __Value)		SET_BITS_TO_LE_1BYTE(__pH2CCmd, 0, 8, __Value)
423 /* _Probersp_RsvdPage 0x0a */
424 #define SET_H2CCMD_AP_WOWLAN_RSVDPAGE_LOC_ProbeRsp(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE(__pH2CCmd, 0, 8, __Value)
425 /* _Probersp_RsvdPage 0x13 */
426 
427 #define SET_H2CCMD_PWRMODE_PARM_MODE(__pH2CCmd, __Value)				SET_BITS_TO_LE_1BYTE(__pH2CCmd, 0, 8, __Value)
428 #define SET_H2CCMD_PWRMODE_PARM_RLBM(__pH2CCmd, __Value)				SET_BITS_TO_LE_1BYTE((__pH2CCmd)+1, 0, 4, __Value)
429 #define SET_H2CCMD_PWRMODE_PARM_SMART_PS(__pH2CCmd, __Value)			SET_BITS_TO_LE_1BYTE((__pH2CCmd)+1, 4, 4, __Value)
430 #define SET_H2CCMD_PWRMODE_PARM_BCN_PASS_TIME(__pH2CCmd, __Value)		SET_BITS_TO_LE_1BYTE((__pH2CCmd)+2, 0, 8, __Value)
431 #define SET_H2CCMD_PWRMODE_PARM_ALL_QUEUE_UAPSD(__pH2CCmd, __Value)		SET_BITS_TO_LE_1BYTE((__pH2CCmd)+3, 0, 8, __Value)
432 #define SET_H2CCMD_PWRMODE_PARM_BCN_EARLY_C2H_RPT(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd)+3, 2, 1, __Value)
433 #define SET_H2CCMD_PWRMODE_PARM_PWR_STATE(__pH2CCmd, __Value)			SET_BITS_TO_LE_1BYTE((__pH2CCmd)+4, 0, 8, __Value)
434 
435 #define GET_H2CCMD_PWRMODE_PARM_MODE(__pH2CCmd)							LE_BITS_TO_1BYTE(__pH2CCmd, 0, 8)
436 /* _PWR_MOD_CMD_0x20 */
437 
438 #define SET_H2CCMD_AP_WOW_GPIO_CTRL_INDEX(__pH2CCmd, __Value)		SET_BITS_TO_LE_1BYTE(__pH2CCmd, 0, 4, __Value)
439 #define SET_H2CCMD_AP_WOW_GPIO_CTRL_C2H_EN(__pH2CCmd, __Value)		SET_BITS_TO_LE_1BYTE(__pH2CCmd, 4, 1, __Value)
440 #define SET_H2CCMD_AP_WOW_GPIO_CTRL_PLUS(__pH2CCmd, __Value)		SET_BITS_TO_LE_1BYTE(__pH2CCmd, 5, 1, __Value)
441 #define SET_H2CCMD_AP_WOW_GPIO_CTRL_HIGH_ACTIVE(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE(__pH2CCmd, 6, 1, __Value)
442 #define SET_H2CCMD_AP_WOW_GPIO_CTRL_EN(__pH2CCmd, __Value)		SET_BITS_TO_LE_1BYTE(__pH2CCmd, 7, 1, __Value)
443 #define SET_H2CCMD_AP_WOW_GPIO_CTRL_DURATION(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd)+1, 0, 8, __Value)
444 #define SET_H2CCMD_AP_WOW_GPIO_CTRL_C2H_DURATION(__pH2CCmd, __Value)SET_BITS_TO_LE_1BYTE((__pH2CCmd)+2, 0, 8, __Value)
445 /* _AP_PS 0x26 */
446 #define SET_H2CCMD_AP_WOW_PS_EN(__pH2CCmd, __Value)			SET_BITS_TO_LE_1BYTE(__pH2CCmd, 0, 1, __Value)
447 #define SET_H2CCMD_AP_WOW_PS_32K_EN(__pH2CCmd, __Value)		SET_BITS_TO_LE_1BYTE(__pH2CCmd, 1, 1, __Value)
448 #define SET_H2CCMD_AP_WOW_PS_RF(__pH2CCmd, __Value)			SET_BITS_TO_LE_1BYTE(__pH2CCmd, 2, 1, __Value)
449 #define SET_H2CCMD_AP_WOW_PS_DURATION(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd)+1, 0, 8, __Value)
450 
451 /* INACTIVE_PS 0x27, duration unit is TBTT */
452 #define SET_H2CCMD_INACTIVE_PS_EN(__pH2CCmd, __Value) \
453 	SET_BITS_TO_LE_1BYTE(__pH2CCmd, 0, 1, __Value)
454 #define SET_H2CCMD_INACTIVE_IGNORE_PS(__pH2CCmd, __Value) \
455 	SET_BITS_TO_LE_1BYTE(__pH2CCmd, 1, 1, __Value)
456 #define SET_H2CCMD_INACTIVE_PERIOD_SCAN_EN(__pH2CCmd, __Value) \
457 	SET_BITS_TO_LE_1BYTE(__pH2CCmd, 2, 1, __Value)
458 #define SET_H2CCMD_INACTIVE_DISBBRF(__pH2CCmd, __Value) \
459 	SET_BITS_TO_LE_1BYTE(__pH2CCmd, 3, 1, __Value)
460 #define SET_H2CCMD_INACTIVE_PORT_NUM(__pH2CCmd, __Value) \
461 	SET_BITS_TO_LE_1BYTE(__pH2CCmd, 5, 3, __Value)
462 #define SET_H2CCMD_INACTIVE_PS_FREQ(__pH2CCmd, __Value) \
463 	SET_BITS_TO_LE_1BYTE(__pH2CCmd + 1, 0, 8, __Value)
464 #define SET_H2CCMD_INACTIVE_PS_DURATION(__pH2CCmd, __Value) \
465 	SET_BITS_TO_LE_1BYTE(__pH2CCmd + 2, 0, 8, __Value)
466 #define SET_H2CCMD_INACTIVE_PS_PERIOD_SCAN_TIME(__pH2CCmd, __Value) \
467 	SET_BITS_TO_LE_1BYTE(__pH2CCmd + 3, 0, 8, __Value)
468 
469 #ifdef CONFIG_LPS_POFF
470 /*PARTIAL OFF Control 0x29*/
471 #define SET_H2CCMD_LPS_POFF_CTRL_EN(__pH2CCmd, __Value) \
472 	SET_BITS_TO_LE_1BYTE(__pH2CCmd, 0, 1, __Value)
473 /*PARTIAL OFF PARAM   0x2A*/
474 #define SET_H2CCMD_LPS_POFF_PARAM_RDVLD(__pH2CCmd, __Value) \
475 	SET_BITS_TO_LE_1BYTE(__pH2CCmd, 0, 1, __Value)
476 #define SET_H2CCMD_LPS_POFF_PARAM_WRVLD(__pH2CCmd, __Value) \
477 	SET_BITS_TO_LE_1BYTE(__pH2CCmd, 1, 1, __Value)
478 #define SET_H2CCMD_LPS_POFF_PARAM_STARTADDL(__pH2CCmd, __Value) \
479 	SET_BITS_TO_LE_1BYTE(__pH2CCmd+1, 0, 8, __Value)
480 #define SET_H2CCMD_LPS_POFF_PARAM_STARTADDH(__pH2CCmd, __Value) \
481 	SET_BITS_TO_LE_1BYTE(__pH2CCmd+2, 0, 8, __Value)
482 #define SET_H2CCMD_LPS_POFF_PARAM_ENDADDL(__pH2CCmd, __Value) \
483 	SET_BITS_TO_LE_1BYTE(__pH2CCmd+3, 0, 8, __Value)
484 #define SET_H2CCMD_LPS_POFF_PARAM_ENDADDH(__pH2CCmd, __Value) \
485 	SET_BITS_TO_LE_1BYTE(__pH2CCmd+4, 0, 8, __Value)
486 #endif
487 
488 #ifdef CONFIG_FW_MULTI_PORT_SUPPORT
489 /* DEFAULT PORT ID 0x2C*/
490 #define SET_H2CCMD_DFTPID_PORT_ID(__pH2CCmd, __Value)			SET_BITS_TO_LE_1BYTE(((u8 *)(__pH2CCmd)), 0, 8, (__Value))
491 #define SET_H2CCMD_DFTPID_MAC_ID(__pH2CCmd, __Value)			SET_BITS_TO_LE_1BYTE(((u8 *)(__pH2CCmd)) + 1, 0, 8, (__Value))
492 #endif
493 
494 #ifdef CONFIG_MCC_MODE
495 /* MCC LOC CMD 0x10 */
496 #define SET_H2CCMD_MCC_RSVDPAGE_LOC(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE(__pH2CCmd, 0, 8, __Value)
497 #define SET_H2CCMD_MCC_PWRIDX_OFFLOAD_EN(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd) + 3, 0, 1, __Value)
498 #define SET_H2CCMD_MCC_PWRIDX_OFFLOAD_RFNUM(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd) + 3, 4, 4, __Value)
499 #define SET_H2CCMD_MCC_PWRIDX_RSVDPAGE_LOC(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd) + 4, 0, 8, __Value)
500 
501 /* MCC RQT TSF 0x15 */
502 #define SET_H2CCMD_MCC_RQT_TSFX(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE(__pH2CCmd, 0, 4, __Value)
503 #define SET_H2CCMD_MCC_RQT_TSFY(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE(__pH2CCmd, 4, 4, __Value)
504 
505 /* MCC MAC ID CMD 0x16 */
506 #define SET_H2CCMD_MCC_MACID_BITMAP_L(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE(__pH2CCmd, 0, 8, __Value)
507 #define SET_H2CCMD_MCC_MACID_BITMAP_H(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd)+1, 0, 8, __Value)
508 
509 /* NEW MCC CTRL CMD 0x17 */
510 #define SET_H2CCMD_MCC_CTRL_V2_ORDER(__pH2CCmd, __Value)		SET_BITS_TO_LE_1BYTE(__pH2CCmd, 0, 4, __Value)
511 #define SET_H2CCMD_MCC_CTRL_V2_TOTALNUM(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE(__pH2CCmd, 4, 4, __Value)
512 #define SET_H2CCMD_MCC_CTRL_V2_CENTRAL_CH(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd)+1, 0, 8, __Value)
513 #define SET_H2CCMD_MCC_CTRL_V2_PRIMARY_CH(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd)+2, 0, 4, __Value)
514 #define SET_H2CCMD_MCC_CTRL_V2_BW(__pH2CCmd, __Value)			SET_BITS_TO_LE_1BYTE((__pH2CCmd)+2, 4, 4, __Value)
515 #define SET_H2CCMD_MCC_CTRL_V2_DURATION(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd)+3, 0, 8, __Value)
516 #define SET_H2CCMD_MCC_CTRL_V2_ROLE(__pH2CCmd, __Value)			SET_BITS_TO_LE_1BYTE((__pH2CCmd)+4, 0, 3, __Value)
517 #define SET_H2CCMD_MCC_CTRL_V2_INCURCH(__pH2CCmd, __Value)		SET_BITS_TO_LE_1BYTE((__pH2CCmd)+4, 3, 1, __Value)
518 #define SET_H2CCMD_MCC_CTRL_V2_DIS_SW_RETRY(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd)+4, 4, 1, __Value)
519 #define SET_H2CCMD_MCC_CTRL_V2_DISTXNULL(__pH2CCmd, __Value)		SET_BITS_TO_LE_1BYTE((__pH2CCmd)+4, 5, 1, __Value)
520 #define SET_H2CCMD_MCC_CTRL_V2_C2HRPT(__pH2CCmd, __Value)			SET_BITS_TO_LE_1BYTE((__pH2CCmd)+4, 6, 2, __Value)
521 #define SET_H2CCMD_MCC_CTRL_V2_TSFX(__pH2CCmd, __Value)				SET_BITS_TO_LE_1BYTE((__pH2CCmd)+5, 0, 4, __Value)
522 #define SET_H2CCMD_MCC_CTRL_V2_NULL_EARLY(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd)+5, 4, 4, __Value)
523 #define SET_H2CCMD_MCC_CTRL_V2_UPDATE_PARM(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd)+6, 7, 1, __Value)
524 
525 
526 /* MCC CTRL CMD 0x18 */
527 #define SET_H2CCMD_MCC_CTRL_ORDER(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE(__pH2CCmd, 0, 4, __Value)
528 #define SET_H2CCMD_MCC_CTRL_TOTALNUM(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE(__pH2CCmd, 4, 4, __Value)
529 #define SET_H2CCMD_MCC_CTRL_CHIDX(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd)+1, 0, 8, __Value)
530 #define SET_H2CCMD_MCC_CTRL_BW(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd)+2, 0, 2, __Value)
531 #define SET_H2CCMD_MCC_CTRL_BW40SC(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd)+2, 2, 3, __Value)
532 #define SET_H2CCMD_MCC_CTRL_BW80SC(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd)+2, 5, 3, __Value)
533 #define SET_H2CCMD_MCC_CTRL_DURATION(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd)+3, 0, 8, __Value)
534 #define SET_H2CCMD_MCC_CTRL_ROLE(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd)+4, 0, 3, __Value)
535 #define SET_H2CCMD_MCC_CTRL_INCURCH(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd)+4, 3, 1, __Value)
536 #define SET_H2CCMD_MCC_CTRL_RSVD0(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd)+4, 4, 4, __Value)
537 #define SET_H2CCMD_MCC_CTRL_RSVD1(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd)+5, 0, 8, __Value)
538 #define SET_H2CCMD_MCC_CTRL_RFETYPE(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd)+6, 0, 4, __Value)
539 #define SET_H2CCMD_MCC_CTRL_DISTXNULL(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd)+6, 4, 1, __Value)
540 #define SET_H2CCMD_MCC_CTRL_C2HRPT(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd)+6, 5, 2, __Value)
541 #define SET_H2CCMD_MCC_CTRL_CHSCAN(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd)+6, 7, 1, __Value)
542 
543 /* MCC Time CMD 0x19 */
544 #define SET_H2CCMD_MCC_TIME_SETTING_FW_EN(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE(__pH2CCmd, 0, 1, __Value)
545 #define SET_H2CCMD_MCC_TIME_SETTING_TSF_SYNC_OFFSET(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE(__pH2CCmd, 1, 7, __Value)
546 #define SET_H2CCMD_MCC_TIME_SETTING_START_TIME(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd)+1, 0, 8, __Value)
547 #define SET_H2CCMD_MCC_TIME_SETTING_INTERVAL(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd)+2, 0, 8, __Value)
548 #define SET_H2CCMD_MCC_TIME_SETTING_EARLY_SWITCH_RPT(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd)+3, 0, 8, __Value)
549 #define  SET_H2CCMD_MCC_TIME_SETTING_ORDER_BASE(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE((__pH2CCmd)+4, 0, 4, __Value)
550 #define  SET_H2CCMD_MCC_TIME_SETTING_ORDER_SYNC(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE((__pH2CCmd)+4, 4, 4, __Value)
551 #define  SET_H2CCMD_MCC_TIME_SETTING_UPDATE(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE((__pH2CCmd)+5, 0, 1, __Value)
552 #define  SET_H2CCMD_MCC_TIME_SETTING_ORDER0_DURATION(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE((__pH2CCmd)+5, 1, 7, __Value)
553 
554 /* MCC IQK CMD 0x1A */
555 #define SET_H2CCMD_MCC_IQK_READY(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE(__pH2CCmd, 0, 1, __Value)
556 #define SET_H2CCMD_MCC_IQK_ORDER(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE(__pH2CCmd, 1, 4, __Value)
557 #define SET_H2CCMD_MCC_IQK_PATH(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE(__pH2CCmd, 5, 2, __Value)
558 #define SET_H2CCMD_MCC_IQK_RX_L(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd)+1, 0, 8, __Value)
559 #define SET_H2CCMD_MCC_IQK_RX_M1(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd)+2, 0, 2, __Value)
560 #define SET_H2CCMD_MCC_IQK_RX_M2(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd)+2, 2, 6, __Value)
561 #define SET_H2CCMD_MCC_IQK_RX_H(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd)+3, 0, 4, __Value)
562 #define SET_H2CCMD_MCC_IQK_TX_L(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd)+4, 0, 8, __Value)
563 #define SET_H2CCMD_MCC_IQK_TX_M1(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd)+5, 0, 3, __Value)
564 #define SET_H2CCMD_MCC_IQK_TX_M2(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd)+5, 3, 5, __Value)
565 #define SET_H2CCMD_MCC_IQK_TX_H(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd)+6, 0, 6, __Value)
566 #endif /* CONFIG_MCC_MODE */
567 
568 /* CHNL SWITCH OPER OFFLOAD 0x1C */
569 #define SET_H2CCMD_CH_SW_OPER_OFFLOAD_CH_NUM(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE(__pH2CCmd, 0, 8, __Value)
570 #define SET_H2CCMD_CH_SW_OPER_OFFLOAD_BW_MODE(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd) + 1, 0, 2, __Value)
571 #define SET_H2CCMD_CH_SW_OPER_OFFLOAD_BW_40M_SC(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd) + 1, 2, 3, __Value)
572 #define SET_H2CCMD_CH_SW_OPER_OFFLOAD_BW_80M_SC(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd) + 1, 5, 3, __Value)
573 #define SET_H2CCMD_CH_SW_OPER_OFFLOAD_RFE_TYPE(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd) + 2, 0, 4, __Value)
574 
575 /* H2C_SINGLE_CHANNELSWITCH_V2 = 0x1D */
576 #define SET_H2CCMD_SINGLE_CH_SWITCH_V2_CENTRAL_CH_NUM(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE(__pH2CCmd, 0, 8, __Value)
577 #define SET_H2CCMD_SINGLE_CH_SWITCH_V2_PRIMARY_CH_IDX(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd) + 1, 0, 4, __Value)
578 #define SET_H2CCMD_SINGLE_CH_SWITCH_V2_BW(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd) + 1, 4, 4, __Value)
579 #define SET_H2CCMD_SINGLE_CH_SWITCH_V2_PWR_IDX_UPDATE_EN(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd) + 2, 0, 1, __Value)
580 #define SET_H2CCMD_SINGLE_CH_SWITCH_V2_IQK_UPDATE_EN(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd) + 2, 1, 1, __Value)
581 #define SET_H2CCMD_SINGLE_CH_SWITCH_V2_CH_IDX(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd) + 2, 4, 4, __Value)
582 
583 #if defined(CONFIG_BT_COEXIST) && defined(CONFIG_FW_MULTI_PORT_SUPPORT)
584 #define SET_H2CCMD_BTC_WL_PORT_ID(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE(__pH2CCmd, 0, 4, __Value)
585 #endif
586 
587 /* _WoWLAN PARAM_CMD_0x80 */
588 #define SET_H2CCMD_WOWLAN_FUNC_ENABLE(__pH2CCmd, __Value)			SET_BITS_TO_LE_1BYTE(__pH2CCmd, 0, 1, __Value)
589 #define SET_H2CCMD_WOWLAN_PATTERN_MATCH_ENABLE(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE(__pH2CCmd, 1, 1, __Value)
590 #define SET_H2CCMD_WOWLAN_MAGIC_PKT_ENABLE(__pH2CCmd, __Value)		SET_BITS_TO_LE_1BYTE(__pH2CCmd, 2, 1, __Value)
591 #define SET_H2CCMD_WOWLAN_UNICAST_PKT_ENABLE(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE(__pH2CCmd, 3, 1, __Value)
592 #define SET_H2CCMD_WOWLAN_ALL_PKT_DROP(__pH2CCmd, __Value)			SET_BITS_TO_LE_1BYTE(__pH2CCmd, 4, 1, __Value)
593 #define SET_H2CCMD_WOWLAN_GPIO_ACTIVE(__pH2CCmd, __Value)			SET_BITS_TO_LE_1BYTE(__pH2CCmd, 5, 1, __Value)
594 #define SET_H2CCMD_WOWLAN_REKEY_WAKE_UP(__pH2CCmd, __Value)			SET_BITS_TO_LE_1BYTE(__pH2CCmd, 6, 1, __Value)
595 #define SET_H2CCMD_WOWLAN_DISCONNECT_WAKE_UP(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE(__pH2CCmd, 7, 1, __Value)
596 #define SET_H2CCMD_WOWLAN_GPIONUM(__pH2CCmd, __Value)				SET_BITS_TO_LE_1BYTE((__pH2CCmd)+1, 0, 7, __Value)
597 #define SET_H2CCMD_WOWLAN_DATAPIN_WAKE_UP(__pH2CCmd, __Value)		SET_BITS_TO_LE_1BYTE((__pH2CCmd)+1, 7, 1, __Value)
598 #define SET_H2CCMD_WOWLAN_GPIO_DURATION(__pH2CCmd, __Value)			SET_BITS_TO_LE_1BYTE((__pH2CCmd)+2, 0, 8, __Value)
599 #define SET_H2CCMD_WOWLAN_GPIO_PULSE_EN(__pH2CCmd, __Value)		SET_BITS_TO_LE_1BYTE((__pH2CCmd)+3, 0, 1, __Value)
600 #define SET_H2CCMD_WOWLAN_GPIO_PULSE_COUNT(__pH2CCmd, __Value)		SET_BITS_TO_LE_1BYTE((__pH2CCmd)+3, 1, 7, __Value)
601 #define SET_H2CCMD_WOWLAN_DISABLE_UPHY(__pH2CCmd, __Value)				SET_BITS_TO_LE_1BYTE((__pH2CCmd)+4, 0, 1, __Value)
602 #define SET_H2CCMD_WOWLAN_HST2DEV_EN(__pH2CCmd, __Value)				SET_BITS_TO_LE_1BYTE((__pH2CCmd)+4, 1, 1, __Value)
603 #define SET_H2CCMD_WOWLAN_GPIO_DURATION_MS(__pH2CCmd, __Value)		SET_BITS_TO_LE_1BYTE((__pH2CCmd)+4, 2, 1, __Value)
604 #define SET_H2CCMD_WOWLAN_CHANGE_UNIT(__pH2CCmd, __Value)		SET_BITS_TO_LE_1BYTE((__pH2CCmd)+4, 2, 1, __Value)
605 #define SET_H2CCMD_WOWLAN_UNIT_FOR_UPHY_DISABLE(__pH2CCmd, __Value)		SET_BITS_TO_LE_1BYTE((__pH2CCmd)+4, 3, 1, __Value)
606 #define SET_H2CCMD_WOWLAN_TAKE_PDN_UPHY_DIS_EN(__pH2CCmd, __Value)		SET_BITS_TO_LE_1BYTE((__pH2CCmd)+4, 4, 1, __Value)
607 #define SET_H2CCMD_WOWLAN_GPIO_INPUT_EN(__pH2CCmd, __Value)		SET_BITS_TO_LE_1BYTE((__pH2CCmd)+4, 5, 1, __Value)
608 #define SET_H2CCMD_WOWLAN_DEV2HST_EN(__pH2CCmd, __Value) 	SET_BITS_TO_LE_1BYTE((__pH2CCmd)+4, 7, 1, __Value)
609 #define SET_H2CCMD_WOWLAN_TIME_FOR_UPHY_DISABLE(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE((__pH2CCmd)+5, 0, 8, __Value)
610 #define SET_H2CCMD_WOWLAN_RISE_HST2DEV(__pH2CCmd, __Value) 	SET_BITS_TO_LE_1BYTE((__pH2CCmd)+6, 2, 1, __Value)
611 
612 /* _REMOTE_WAKEUP_CMD_0x81 */
613 #define SET_H2CCMD_REMOTE_WAKECTRL_ENABLE(__pH2CCmd, __Value)		SET_BITS_TO_LE_1BYTE(__pH2CCmd, 0, 1, __Value)
614 #define SET_H2CCMD_REMOTE_WAKE_CTRL_ARP_OFFLOAD_EN(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE(__pH2CCmd, 1, 1, __Value)
615 #define SET_H2CCMD_REMOTE_WAKE_CTRL_NDP_OFFLOAD_EN(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE(__pH2CCmd, 2, 1, __Value)
616 #define SET_H2CCMD_REMOTE_WAKE_CTRL_GTK_OFFLOAD_EN(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE(__pH2CCmd, 3, 1, __Value)
617 #define SET_H2CCMD_REMOTE_WAKE_CTRL_NLO_OFFLOAD_EN(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE(__pH2CCmd, 4, 1, __Value)
618 #define SET_H2CCMD_REMOTE_WAKE_CTRL_FW_UNICAST_EN(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE(__pH2CCmd, 7, 1, __Value)
619 #define SET_H2CCMD_REMOTE_WAKE_CTRL_P2P_OFFLAD_EN(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd)+1, 0, 1, __Value)
620 #define SET_H2CCMD_REMOTE_WAKE_CTRL_NBNS_FILTER_EN(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd)+1, 2, 1, __Value)
621 #define SET_H2CCMD_REMOTE_WAKE_CTRL_TKIP_OFFLOAD_EN(__pH2CCmd, __Value) \
622 	SET_BITS_TO_LE_1BYTE((__pH2CCmd)+1, 3, 1, __Value)
623 
624 #define SET_H2CCMD_REMOTE_WAKE_CTRL_ARP_ACTION(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd)+2, 0, 1, __Value)
625 #define SET_H2CCMD_REMOTE_WAKE_CTRL_FW_PARSING_UNTIL_WAKEUP(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd)+2, 4, 1, __Value)
626 
627 /* AOAC_GLOBAL_INFO_0x82 */
628 #define SET_H2CCMD_AOAC_GLOBAL_INFO_PAIRWISE_ENC_ALG(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE(__pH2CCmd, 0, 8, __Value)
629 #define SET_H2CCMD_AOAC_GLOBAL_INFO_GROUP_ENC_ALG(__pH2CCmd, __Value)		SET_BITS_TO_LE_1BYTE((__pH2CCmd)+1, 0, 8, __Value)
630 
631 /* AOAC_RSVDPAGE_LOC_0x83 */
632 #define SET_H2CCMD_AOAC_RSVDPAGE_LOC_REMOTE_WAKE_CTRL_INFO(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd), 0, 8, __Value)
633 #define SET_H2CCMD_AOAC_RSVDPAGE_LOC_ARP_RSP(__pH2CCmd, __Value)		SET_BITS_TO_LE_1BYTE((__pH2CCmd)+1, 0, 8, __Value)
634 #define SET_H2CCMD_AOAC_RSVDPAGE_LOC_NEIGHBOR_ADV(__pH2CCmd, __Value)		SET_BITS_TO_LE_1BYTE((__pH2CCmd)+2, 0, 8, __Value)
635 #define SET_H2CCMD_AOAC_RSVDPAGE_LOC_GTK_RSP(__pH2CCmd, __Value)		SET_BITS_TO_LE_1BYTE((__pH2CCmd)+3, 0, 8, __Value)
636 #define SET_H2CCMD_AOAC_RSVDPAGE_LOC_GTK_INFO(__pH2CCmd, __Value)		SET_BITS_TO_LE_1BYTE((__pH2CCmd)+4, 0, 8, __Value)
637 #ifdef CONFIG_GTK_OL
638 #define SET_H2CCMD_AOAC_RSVDPAGE_LOC_GTK_EXT_MEM(__pH2CCmd, __Value)		SET_BITS_TO_LE_1BYTE((__pH2CCmd)+5, 0, 8, __Value)
639 #endif /* CONFIG_GTK_OL */
640 #define SET_H2CCMD_AOAC_RSVDPAGE_LOC_NDP_INFO(__pH2CCmd, __Value) \
641 	SET_BITS_TO_LE_1BYTE((__pH2CCmd)+6, 0, 8, __Value)
642 
643 /* AOAC_RSVDPAGE_2_0x84 */
644 
645 /* AOAC_RSVDPAGE_3_0x88 */
646 #ifdef CONFIG_PNO_SUPPORT
647 #define SET_H2CCMD_AOAC_RSVDPAGE_LOC_NLO_INFO(__pH2CCmd, __Value)		SET_BITS_TO_LE_1BYTE((__pH2CCmd), 0, 8, __Value)
648 #endif
649 #define SET_H2CCMD_AOAC_RSVDPAGE_LOC_AOAC_REPORT(__pH2CCmd, __Value) \
650 	SET_BITS_TO_LE_1BYTE((__pH2CCmd) + 1, 0, 8, __Value)
651 
652 #ifdef CONFIG_PNO_SUPPORT
653 /* D0_Scan_Offload_Info_0x86 */
654 #define SET_H2CCMD_AOAC_NLO_FUN_EN(__pH2CCmd, __Value)			SET_BITS_TO_LE_1BYTE((__pH2CCmd), 3, 1, __Value)
655 #define SET_H2CCMD_AOAC_NLO_IPS_EN(__pH2CCmd, __Value)			SET_BITS_TO_LE_1BYTE((__pH2CCmd), 4, 1, __Value)
656 #define SET_H2CCMD_AOAC_RSVDPAGE_LOC_PROBE_PACKET(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd)+1, 0, 8, __Value)
657 #define SET_H2CCMD_AOAC_RSVDPAGE_LOC_SCAN_INFO(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd)+2, 0, 8, __Value)
658 #define SET_H2CCMD_AOAC_RSVDPAGE_LOC_SSID_INFO(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd)+3, 0, 8, __Value)
659 
660 /* NLO SCAN offload for ICs that have HALMAC */
661 #define SET_H2CCMD_NLO_FUN_EN(__pH2CCmd, __Value)                      SET_BITS_TO_LE_1BYTE((__pH2CCmd), 0, 1, __Value)
662 #define SET_H2CCMD_NLO_PS_32K(__pH2CCmd, __Value)                      SET_BITS_TO_LE_1BYTE((__pH2CCmd), 1, 1, __Value)
663 #define SET_H2CCMD_NLO_LOC_NLO_INFO(__pH2CCmd, __Value)        SET_BITS_TO_LE_1BYTE((__pH2CCmd)+1, 0, 8, __Value)
664 #endif /* CONFIG_PNO_SUPPORT */
665 
666 /* _GPIO_CUSTOM_CMD_0x89 */
667 #define SET_H2CCMD_CUSTOMERID(__pH2CCmd, __Value)		SET_BITS_TO_LE_1BYTE(__pH2CCmd, 0, 8, __Value)
668 #define SET_H2CCMD_SPECIAL_WAKE_REASON(__pH2CCmd, __Value)		SET_BITS_TO_LE_1BYTE((__pH2CCmd)+1, 0, 8, __Value)
669 #define SET_H2CCMD_CUSTOM_WAKE_REASON(__pH2CCmd, __Value)		SET_BITS_TO_LE_1BYTE((__pH2CCmd)+2, 0, 1, __Value)
670 
671 #ifdef CONFIG_P2P_WOWLAN
672 /* P2P_RsvdPage_0x8a */
673 #define SET_H2CCMD_RSVDPAGE_LOC_P2P_BCN(__pH2CCmd, __Value)			SET_BITS_TO_LE_1BYTE(__pH2CCmd, 0, 8, __Value)
674 #define SET_H2CCMD_RSVDPAGE_LOC_P2P_PROBE_RSP(__pH2CCmd, __Value)				SET_BITS_TO_LE_1BYTE((__pH2CCmd)+1, 0, 8, __Value)
675 #define SET_H2CCMD_RSVDPAGE_LOC_P2P_NEGO_RSP(__pH2CCmd, __Value)			SET_BITS_TO_LE_1BYTE((__pH2CCmd)+2, 0, 8, __Value)
676 #define SET_H2CCMD_RSVDPAGE_LOC_P2P_INVITE_RSP(__pH2CCmd, __Value)		SET_BITS_TO_LE_1BYTE((__pH2CCmd)+3, 0, 8, __Value)
677 #define SET_H2CCMD_RSVDPAGE_LOC_P2P_PD_RSP(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd)+4, 0, 8, __Value)
678 #endif /* CONFIG_P2P_WOWLAN */
679 
680 #ifdef CONFIG_LPS_PG
681 #define SET_H2CCMD_LPSPG_SEC_CAM_EN(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE(__pH2CCmd, 0, 1, __Value)/*SecurityCAM_En*/
682 #define SET_H2CCMD_LPSPG_MBID_CAM_EN(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE(__pH2CCmd, 1, 1, __Value)/*BSSIDCAM_En*/
683 #define SET_H2CCMD_LPSPG_PMC_CAM_EN(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE(__pH2CCmd, 2, 1, __Value)/*PatternMatchCAM_En*/
684 #define SET_H2CCMD_LPSPG_MACID_SEARCH_EN(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE(__pH2CCmd, 3, 1, __Value)/*MACIDSearch_En*/
685 #define SET_H2CCMD_LPSPG_TXSC_EN(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE(__pH2CCmd, 4, 1, __Value)/*TXSC_En*/
686 #define SET_H2CCMD_LPSPG_MU_RATE_TB_EN(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE(__pH2CCmd, 5, 1, __Value)/*MURateTable_En*/
687 #define SET_H2CCMD_LPSPG_LOC(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd)+1, 0, 8, __Value)/*Loc_LPS_PG*/
688 #define SET_H2CCMD_LPSPG_DPK_INFO_LOC(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd)+2, 0, 8, __Value)/*Loc_LPS_PG_DPK_info*/
689 #define SET_H2CCMD_LPSPG_IQK_INFO_LOC(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd) + 3, 0, 8, __Value)/*Loc_IQK_result*/
690 #endif
691 
692 #if defined(CONFIG_RTL8822C) && defined(CONFIG_SUPPORT_DYNAMIC_TXPWR)
693 #define SET_H2CCMD_FW_CRC5_SEARCH_EN(cmd, v)	\
694 	SET_BITS_TO_LE_1BYTE((cmd), 0, 1, (v));
695 #define SET_H2CCMD_FW_CRC5_SEARCH_MACID(cmd, v)	\
696 	SET_BITS_TO_LE_1BYTE((cmd), 1, 7, (v));
697 #define SET_H2CCMD_FW_CRC5_SEARCH_MAC(cmd, mac)	\
698 	do {		\
699 		int __offset = 0;	\
700 		for (__offset = 0; __offset < ETH_ALEN; __offset++)	\
701 			SET_BITS_TO_LE_1BYTE((u8 *)(cmd + __offset), 0, 8, *((u8 *)(mac + __offset)));	\
702 	} while(0)
703 #endif
704 
705 #ifdef CONFIG_WAR_OFFLOAD
706 /* WarOffload_Info_0x8D */
707 #define SET_H2CCMD_WAR_CFG_EN(__pH2CCmd, __Value)               SET_BITS_TO_LE_1BYTE(__pH2CCmd, 0, 1, __Value)
708 #define SET_H2CCMD_WAR_CFG_ARP_RSP_EN(__pH2CCmd, __Value)       SET_BITS_TO_LE_1BYTE(__pH2CCmd, 1, 1, __Value)
709 #define SET_H2CCMD_WAR_CFG_MDNSV4_RSP_EN(__pH2CCmd, __Value)   SET_BITS_TO_LE_1BYTE((__pH2CCmd)+2, 2, 1, __Value)
710 #define SET_H2CCMD_WAR_CFG_MDNSV6_RSP_EN(__pH2CCmd, __Value)   SET_BITS_TO_LE_1BYTE((__pH2CCmd)+2, 3, 1, __Value)
711 #define SET_H2CCMD_WAR_CFG_MDNSV4_WAKE_EN(__pH2CCmd, __Value)   SET_BITS_TO_LE_1BYTE((__pH2CCmd)+2, 6, 1, __Value)
712 #define SET_H2CCMD_WAR_CFG_MDNSV6_WAKE_EN(__pH2CCmd, __Value)   SET_BITS_TO_LE_1BYTE((__pH2CCmd)+2, 7, 1, __Value)
713 
714 /* H2C_WAROFLD_RSVDPAGE1 */
715 #define SET_H2CCMD_WAROFLD_RSVDPAGE1_LOC_PARM(__pH2CCmd, __Value)  SET_BITS_TO_LE_1BYTE((__pH2CCmd), 0, 8, __Value)
716 #endif /* CONFIG_WAR_OFFLOAD */
717 
718 
719 /* BT_UNKNOWN_DEVICE_WA_0xD1 */
720 #define SET_H2CCMD_BT_UNKNOWN_DEVICE_WA_HANG_CHK_EN(__pH2CCmd, __Value) \
721 	SET_BITS_TO_LE_1BYTE(__pH2CCmd, 0, 1, __Value)
722 #define SET_H2CCMD_BT_UNKNOWN_DEVICE_WA_FORCE_IB_EN(__pH2CCmd, __Value) \
723 	SET_BITS_TO_LE_1BYTE(__pH2CCmd, 1, 1, __Value)
724 #define SET_H2CCMD_BT_UNKNOWN_DEVICE_WA_HWID_CHK_EN(__pH2CCmd, __Value) \
725 	SET_BITS_TO_LE_1BYTE(__pH2CCmd, 2, 1, __Value)
726 #define SET_H2CCMD_BT_UNKNOWN_DEVICE_WA_ONE_TIME_CHK(__pH2CCmd, __Value) \
727 	SET_BITS_TO_LE_1BYTE(__pH2CCmd, 3, 1, __Value)
728 
729 #ifdef DBG_FW_DEBUG_MSG_PKT
730 #define SET_H2CCMD_FW_DBG_MSG_PKT_EN(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE(__pH2CCmd, 0, 1, __Value)/*sniffer_dbg_en*/
731 #define SET_H2CCMD_RSVDPAGE_LOC_FW_DBG_MSG_PKT(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd)+1, 0, 8, __Value) /*loc_debug_packet*/
732 #endif /*DBG_FW_DEBUG_MSG_PKT*/
733 
734 #ifdef DBG_RSVD_PAGE_CFG
735 #define RSVD_PAGE_CFG(ops, v1, v2, v3)	\
736 	RTW_INFO("=== [RSVD][%s]-NeedPage:%d, TotalPageNum:%d TotalPacketLen:%d ===\n",	\
737 		ops, v1, v2, v3)
738 #else
739 #define RSVD_PAGE_CFG(ops, v1, v2, v3) do {} while (0)
740 #endif
741 
742 /* ---------------------------------------------------------------------------------------------------------
743  * -------------------------------------------    Structure    --------------------------------------------------
744  * --------------------------------------------------------------------------------------------------------- */
745 typedef struct _RSVDPAGE_LOC {
746 	u8 LocProbeRsp;
747 	u8 LocPsPoll;
748 	u8 LocNullData;
749 	u8 LocQosNull;
750 	u8 LocBTQosNull;
751 #ifdef CONFIG_WOWLAN
752 	u8 LocRemoteCtrlInfo;
753 	u8 LocArpRsp;
754 	u8 LocNbrAdv;
755 	u8 LocGTKRsp;
756 	u8 LocGTKInfo;
757 	u8 LocProbeReq;
758 	u8 LocNetList;
759 #ifdef CONFIG_GTK_OL
760 	u8 LocGTKEXTMEM;
761 #endif /* CONFIG_GTK_OL */
762 	u8 LocNDPInfo;
763 	u8 LocAOACReport;
764 #ifdef CONFIG_PNO_SUPPORT
765 	u8 LocPNOInfo;
766 	u8 LocScanInfo;
767 	u8 LocSSIDInfo;
768 	u8 LocProbePacket;
769 #endif /* CONFIG_PNO_SUPPORT */
770 #ifdef CONFIG_WOW_KEEP_ALIVE_PATTERN
771 	u8 LocKeepAlive;
772 #endif /*CONFIG_WOW_KEEP_ALIVE_PATTERN*/
773 #ifdef CONFIG_WAR_OFFLOAD
774 	u8 LocIpParm;
775 #if defined(CONFIG_OFFLOAD_MDNS_V4) || defined(CONFIG_OFFLOAD_MDNS_V6)
776 	u8 LocMdnsPara;
777 	u8 LocMdnsv4;
778 	u8 LocMdnsv6;
779 #endif /* defined(CONFIG_OFFLOAD_MDNS_V4) || defined(CONFIG_OFFLOAD_MDNS_V6) */
780 #endif /* CONFIG_WAR_OFFLOAD */
781 
782 #endif /* CONFIG_WOWLAN	 */
783 	u8 LocApOffloadBCN;
784 #ifdef CONFIG_P2P_WOWLAN
785 	u8 LocP2PBeacon;
786 	u8 LocP2PProbeRsp;
787 	u8 LocNegoRsp;
788 	u8 LocInviteRsp;
789 	u8 LocPDRsp;
790 #endif /* CONFIG_P2P_WOWLAN */
791 #ifdef DBG_FW_DEBUG_MSG_PKT
792 	u8 loc_fw_dbg_msg_pkt;
793 #endif /*DBG_FW_DEBUG_MSG_PKT*/
794 } RSVDPAGE_LOC, *PRSVDPAGE_LOC;
795 
796 struct rsvd_page_cache_t {
797 	char *name;
798 	u8 loc;
799 	u8 page_num;
800 	u8 *data;
801 	u32 size;
802 };
803 
804 bool rsvd_page_cache_update_all(struct rsvd_page_cache_t *cache, u8 loc
805 	, u8 txdesc_len, u32 page_size, u8 *info, u32 info_len);
806 bool rsvd_page_cache_update_data(struct rsvd_page_cache_t *cache, u8 *info
807 	, u32 info_len);
808 void rsvd_page_cache_free_data(struct rsvd_page_cache_t *cache);
809 void rsvd_page_cache_free(struct rsvd_page_cache_t *cache);
810 
811 #endif
812 #ifdef CONFIG_WOWLAN
813 void dump_TX_FIFO(PADAPTER padapter, u8 page_num, u16 page_size);
814 #endif
815 u8 rtw_hal_set_fw_media_status_cmd(_adapter *adapter, u8 mstatus, u8 macid);
816 #if defined(CONFIG_WOWLAN) || defined(CONFIG_AP_WOWLAN)
817 	/* WOW command function */
818 	void rtw_hal_set_fw_wow_related_cmd(_adapter *padapter, u8 enable);
819 	#ifdef CONFIG_P2P_WOWLAN
820 		/* H2C 0x8A */
821 		u8 rtw_hal_set_FwP2PRsvdPage_cmd(_adapter *adapter, PRSVDPAGE_LOC rsvdpageloc);
822 		/* H2C 0x8B */
823 		u8 rtw_hal_set_p2p_wowlan_offload_cmd(_adapter *adapter);
824 	#endif /* CONFIG_P2P_WOWLAN */
825 #endif
826 
827 #ifdef RTW_PER_CMD_SUPPORT_FW
828 u8 rtw_hal_set_req_per_rpt_cmd(_adapter *adapter, u8 group_macid,
829 			       u8 rpt_type, u32 macid_bitmap);
830 #endif
831