xref: /OK3568_Linux_fs/external/rkwifibt/drivers/rtl8852bs/phl/phl_def.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /******************************************************************************
2  *
3  * Copyright(c) 2019 - 2021 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 _PHL_DEF_H_
16 #define _PHL_DEF_H_
17 
18 enum phl_packet_type {
19 	PACKET_NORMAL,
20 	PACKET_DHCP,
21 	PACKET_ARP,
22 	PACKET_EAPOL,
23 	PACKET_EAPOL_START,
24 	PACKET_MAX
25 };
26 
27 /*HW_BAND0 - CMAC0 + PHY0 + S0*/
28 /*HW_BAND1 - CMAC1 + PHY1 + S1*/
29 /*wifi_role->hw_band*/
30 enum phl_band_idx {
31 	HW_BAND_0,
32 	HW_BAND_1,
33 	HW_BAND_MAX
34 };
35 
36 /*wifi_role->hw_port*/
37 enum phl_hw_port {
38 	HW_PORT0,
39 	HW_PORT1,
40 	HW_PORT2,
41 	HW_PORT3,
42 	HW_PORT4,
43 	HW_PORT_MAX,
44 };
45 
46 #define RTW_MAX_TID_NUM 16
47 #define RTW_MAX_AC_QUEUE_NUM 4
48 enum phl_ac_queue {
49 	PHL_BE_QUEUE_SEL		= 0,
50 	PHL_BK_QUEUE_SEL		= 1,
51 	PHL_VI_QUEUE_SEL		= 2,
52 	PHL_VO_QUEUE_SEL		= 3,
53 	PHL_AC_QUEUE_TOTAL
54 };
55 
56 enum phl_stat_info_query {
57 	STAT_INFO_FA_ALL,
58 	STAT_INFO_CCA_ALL,
59 };
60 
61 /**
62  * struct rtw_chan_def - channel defination
63  * @chan: the (control/primary) channel
64  * @center_ch: the center channel
65  * @bw: channel bandwidth
66  * @center_freq1: center frequency of first segment
67  * @center_freq2: center frequency of second segment
68  *	(only with 80+80 MHz)
69  */
70 
71 struct rtw_chan_def {
72 	enum band_type band; /* protocol -2.4G,5G,6G*/
73 	enum channel_width bw;
74 	enum chan_offset offset;
75 	u8 chan; /*primary channel*/
76 	u8 center_ch;
77 	u16 hw_value;
78 	u32 center_freq1;
79 	u32 center_freq2;
80 };
81 
82 struct chg_opch_param {
83 	struct rtw_wifi_role_t *wrole;
84 	struct rtw_chan_def new_chdef;
85 	struct rtw_chan_def ori_chdef;
86 	enum rtw_phl_status cmd_start_sts;
87 	void (*chg_opch_done)(void *priv, u8 ridx, enum rtw_phl_status status);
88 };
89 
90 /**
91  * struct rtw_chan_ctx - channel context
92  * @list:
93  * @chan_ctx_lock:
94  * @chan_def:
95  */
96 struct rtw_chan_ctx {
97 	_os_list list;
98 	struct rtw_chan_def chan_def;
99 	u8 role_map; /*used role_idx*/
100 	bool dfs_enabled;
101 };
102 
103 
104 #ifdef CONFIG_PCI_HCI
105 struct rtw_pci_info {
106 	u8 dummy;
107 };
108 #endif
109 
110 
111 #ifdef CONFIG_USB_HCI
112 struct rtw_usb_info {
113 	enum rtw_usb_speed usb_speed; /* USB 1.1, 2.0 or 3.0 */
114 	u16 usb_bulkout_size;
115 	u8 outep_num;
116 	u8 inep_num;
117 };
118 
119 enum phl_usb_rx_agg_mode {
120 	PHL_RX_AGG_DISABLE,
121 	PHL_RX_AGG_DEFAULT,
122 	PHL_RX_AGG_SMALL_PKT,
123 	PHL_RX_AGG_USER_DEFINE,
124 };
125 /*
126  * refers to _usb.h
127  * #define SWITCHMODE           0x2
128  * #define FORCEUSB3MODE        0x1
129  * #define FORCEUSB2MODE        0x0
130 */
131 enum rtw_usb_sw_ability {
132 	RTW_USB2_ONLY = 0,
133 	RTW_USB3_ONLY,
134 	RTW_USB_SUPPORT_SWITCH,
135 	RTW_USB_SUPPORT_MAX
136 };
137 #endif
138 
139 #ifdef CONFIG_SDIO_HCI
140 struct rtw_sdio_info {
141 	unsigned int clock;
142 	unsigned int timing;
143 	u8 sd3_bus_mode;
144 	u16 block_sz;
145 	u16 io_align_sz;
146 	u16 tx_align_sz;
147 	bool tx_512_by_byte_mode;	/* Send 512 bytes by cmd53 byte or */
148 					/* block mode. */
149 };
150 #endif
151 
152 enum rtw_rx_status {
153 	RTW_STATUS_RX_OK,
154 	RTW_STATUS_RXDMA_HANG,
155 	RTW_STATUS_RXFIFO_HANG
156 };
157 
158 struct rtw_ic_info {
159 	enum rtl_ic_id ic_id;
160 	enum rtw_hci_type hci_type;
161 	#ifdef CONFIG_SDIO_HCI
162 	struct rtw_sdio_info sdio_info;
163 	#endif
164 
165 	#ifdef CONFIG_USB_HCI
166 	struct rtw_usb_info usb_info;
167 	#endif
168 
169 	#ifdef CONFIG_PCI_HCI
170 	struct rtw_pci_info pci_info;
171 	#endif
172 };
173 
174 enum rtw_proc_cmd_type {
175 	RTW_PROC_CMD_UNKNOW,
176 	RTW_PROC_CMD_BB,	/* 1 */
177 	RTW_PROC_CMD_RF,	/* 2 */
178 	RTW_PROC_CMD_MAC,	/* 3 */
179 	RTW_PROC_CMD_PHL,	/* 4 */
180 	RTW_PROC_CMD_CORE,	/* 5 */
181 	RTW_PROC_CMD_BTC,	/* 6 */
182 	RTW_PROC_CMD_EFUSE,	/* 7 */
183 	RTW_PROC_CMD_MAX
184 };
185 
186 enum rtw_arg_type {
187 	RTW_ARG_TYPE_UNKNOW,
188 	RTW_ARG_TYPE_BUF,	/* 1 */
189 	RTW_ARG_TYPE_ARRAY,	/* 2 */
190 	RTW_ARG_TYPE_MAX
191 };
192 
193 #define		MAX_ARGC	20
194 #define		MAX_ARGV	16
195 
196 
197 struct rtw_proc_cmd {
198 	enum rtw_arg_type in_type;
199 	u32 in_cnt_len;
200 	union {
201 		char *buf;
202 		char vector[MAX_ARGC][MAX_ARGV];
203 	}in;
204 };
205 
206 enum rtw_para_src {
207 	RTW_PARA_SRC_INTNAL, /* 0 */
208 	RTW_PARA_SRC_EXTNAL, /* 1 */
209 	RTW_PARA_SRC_EXTNAL_BUF, /* 2 */
210 	RTW_PARA_SRC_CUSTOM, /* 3 */
211 	RTW_PARA_SRC_MAX
212 };
213 
214 struct rtw_para_info_t {
215 	enum rtw_para_src para_src;
216 	char para_path[256];
217 	char *hal_phy_folder;
218 	char postfix[33];
219 
220 	u8 *ext_para_file_buf;
221 	u32 ext_para_file_buf_len;
222 	u32 para_data_len;
223 	u32 *para_data;
224 };
225 
226 #define regd_name_max_size 32
227 
228 struct rtw_para_pwrlmt_info_t {
229 	enum rtw_para_src para_src;
230 	char para_path[256];
231 	char *hal_phy_folder;
232 	char postfix[33];
233 
234 	u8 *ext_para_file_buf;
235 	u32 ext_para_file_buf_len;
236 	u32 para_data_len;
237 	u32 *para_data;
238 
239 	char ext_regd_name[regd_name_max_size][10];
240 	u16 ext_regd_arridx;
241 	u16 ext_reg_map_num;
242 	u8 *ext_reg_codemap;
243 };
244 
245 #define RTW_PHL_HANDLER_STATUS_INITIALIZED BIT0
246 #define RTW_PHL_HANDLER_STATUS_SET BIT1
247 #define RTW_PHL_HANDLER_STATUS_RELEASED BIT2
248 
249 #define RTW_PHL_HANDLER_PRIO_HIGH 0
250 #define RTW_PHL_HANDLER_PRIO_NORMAL 1
251 #define RTW_PHL_HANDLER_PRIO_LOW 2
252 
253 #define RTW_PHL_HANDLER_CB_NAME_LEN 32
254 
255 enum rtw_phl_evt {
256 	RTW_PHL_EVT_RX = BIT0,
257 	RTW_PHL_EVT_TX_RECYCLE = BIT1,
258 
259 	RTW_PHL_EVT_MAX = BIT31
260 };
261 
262 enum rtw_phl_config_int {
263 	RTW_PHL_STOP_RX_INT,
264 	RTW_PHL_RESUME_RX_INT,
265 	RTW_PHL_SER_HANDSHAKE_MODE,
266 	RTW_PHL_EN_HCI_INT,
267 	RTW_PHL_DIS_HCI_INT,
268 	RTW_PHL_CLR_HCI_INT,
269 	RTW_PHL_CONFIG_INT_MAX
270 };
271 
272 /**
273  * phl_handler - scheduled by core layer or phl itself
274  * and the properties is assigned by different hanlder type
275  * @status: handler current status defined by RTW_PHL_HANDLER_STATUS_XXX
276  * @type: define different properties of handler - tasklet, thread, workitem
277  * @handle: store different type of handler structure
278  * @callback: handler callback function
279  * @context: context used in handler callback function
280  */
281 struct rtw_phl_handler {
282 	char status;
283 	char type;
284 	void *drv_priv;
285 	struct _os_handler os_handler;
286 	void (*callback)(void *context);
287 	char cb_name[RTW_PHL_HANDLER_CB_NAME_LEN];
288 	void *context;
289 };
290 
291 struct rtw_xmit_req;
292 struct rtw_aoac_report;
293 struct rtw_phl_evt_ops {
294 	enum rtw_phl_status (*rx_process)(void *drv_priv);
295 	enum rtw_phl_status (*tx_recycle)(void *drv_priv, struct rtw_xmit_req *txreq);
296 	enum rtw_phl_status (*tx_test_recycle)(void *phl, struct rtw_xmit_req *txreq);
297 	bool (*set_rf_state)(void *drv_priv, enum rtw_rf_state state_to_set);
298 	void (*wow_handle_sec_info_update)(void *drv_priv, struct rtw_aoac_report *aoac_info, u8 aoac_report_get_ok, u8 phase);
299 	void (*indicate_wake_rsn)(void *drv_priv, u8 rsn);
300 #ifdef CONFIG_SYNC_INTERRUPT
301 	void (*interrupt_restore)(void *drv_priv, u8 rx);
302 	void (*set_interrupt_caps)(void *drv_priv, u8 en);
303 #endif /* CONFIG_SYNC_INTERRUPT */
304 	void (*ap_ps_sta_ps_change)(void *drv_priv, u8 role_id, u8 *sta_mac,
305 	                            int power_save);
306 	u8 (*issue_null_data)(void *priv, u8 ridx, bool ps);
307 };
308 
309 /*
310  * PHL CMD support direct execution, no-wait: synchronization, wait:asynchronization
311  * PHL_CMD_CMD_DIRECTLY: call PHL API including I/O operation directly
312  * PHL_CMD_NO_WARIT: send phl cmd msg to cmd dispatcher and do not wait for completion
313  * PHL_CMD_WAIT: send phl cmd msg to cmd dispatcher and wait for completion
314  */
315 enum phl_cmd_type {
316 	PHL_CMD_DIRECTLY,
317 	PHL_CMD_NO_WAIT,
318 	PHL_CMD_WAIT,
319 	PHL_CMD_MAX,
320 };
321 
322 enum role_type {
323 	PHL_RTYPE_NONE,
324 	PHL_RTYPE_STATION,
325 	PHL_RTYPE_AP,
326 	PHL_RTYPE_VAP,
327 	PHL_RTYPE_ADHOC,
328 	PHL_RTYPE_ADHOC_MASTER,
329 	PHL_RTYPE_MESH,
330 	PHL_RTYPE_MONITOR,
331 	PHL_RTYPE_P2P_DEVICE,
332 	PHL_RTYPE_P2P_GC,
333 	PHL_RTYPE_P2P_GO,
334 	PHL_RTYPE_TDLS,
335 	PHL_RTYPE_NAN,
336 	PHL_MLME_MAX
337 };
338 
339 enum role_state {
340 	PHL_ROLE_START, /* 0 - PHL*/
341 	PHL_ROLE_STOP, /* 1 - PHL*/
342 	PHL_ROLE_CHG_TYPE, /* 2 - PHL*/
343 	PHL_ROLE_UPDATE_NOA, /* 3 - PHL*/
344 	PHL_ROLE_MSTS_STA_CONN_START, /*CORE*/
345 	PHL_ROLE_MSTS_STA_CONN_END,/*CORE*/
346 	PHL_ROLE_MSTS_STA_DIS_CONN,/*CORE*/
347 	PHL_ROLE_MSTS_AP_START,/*CORE*/
348 	PHL_ROLE_MSTS_AP_STOP,/*CORE*/
349 	PHL_ROLE_STATE_UNKNOWN,
350 };
351 
352 enum mlme_state {
353 	MLME_NO_LINK,
354 	MLME_LINKING,
355 	MLME_LINKED
356 };
357 enum wr_chg_id {
358 	WR_CHG_TYPE,
359 	WR_CHG_MADDR,
360 	WR_CHG_AP_PARAM,
361 	WR_CHG_EDCA_PARAM,
362 	WR_CHG_MU_EDCA_PARAM,
363 	WR_CHG_MU_EDCA_CFG,
364 	WR_CHG_BSS_COLOR,
365 	WR_CHG_RTS_TH,
366 	WR_CHG_DFS_HE_TB_CFG,
367 	WR_CHG_TRX_PATH,
368 	WR_CHG_MAX,
369 };
370 
371 enum wr_status{
372 	WR_STATUS_PS_ANN = BIT0,
373 	WR_STATUS_BCN_STOP = BIT1,
374 	WR_STATUS_TSF_SYNC = BIT2,
375 	WR_STATUS_MAX = BIT7
376 };
377 
378 enum rtw_cfg_type { /* sync with pcfg_type */
379 	CFG_TBTT_AGG,
380 	CFG_TBTT_SHIFT,
381 	CFG_HIQ_WIN,
382 	CFG_HIQ_DTIM,
383 	CFG_HIQ_MAX,
384 	CFG_BCN_INTERVAL,	/* Beacon Interval */
385 	CFG_BSS_CLR
386 };
387 
388 struct rtw_ap_param {
389 	u32 cfg_id;
390 	u32 value;
391 };
392 
393 struct rtw_edca_param {
394 	/* Access Category, 0:BE, 1:BK, 2:VI, 3:VO */
395 	u8 ac;
396 	/*
397 	 * EDCA parameter
398 	 * |31...16|15...12|11...8|7...0|
399 	 * |   TXOP|  CWMAX| CWMIN| AIFS|
400 	 */
401 	u32 param;
402 };
403 
404 struct rtw_mu_edca_param {
405 	u8 ac;
406 	u8 aifsn;
407 	u8 cw;
408 	u8 timer;
409 };
410 
411 struct rtw_trx_path_param {
412 	enum rf_path tx;
413 	enum rf_path rx;
414 	u8 tx_nss;
415 	u8 rx_nss;
416 };
417 
418 #define MAX_STORE_BCN_NUM 3
419 enum conf_lvl {
420 	CONF_LVL_NONE = 0,
421 	CONF_LVL_LOW,
422 	CONF_LVL_MID,
423 	CONF_LVL_HIGH
424 };
425 
426 struct rtw_bcn_offset {
427 	u16 offset; /*TU*/
428 	enum conf_lvl conf_lvl; /*confidence level*/
429 	u16 cr_tbtt_shift; /* CR current setting */
430 };
431 
432 /*
433  * Store rx bcn tsf info
434  * @num: the store noumber of "info" array
435  * @idx: store current index of "info" array
436  * @info: store array. info[0]: store tsf, info[1]: store mod(TU), info[2]: store hw rx time
437  * @offset_i: Bcn offset info. Dont't access directionly this variable for application.
438                    You can get offset_i info from phl_get_sta_bcn_offset_info.
439  */
440 struct rtw_rx_bcn_info {
441 	u8 idx;
442 	u8 num;
443 	u64 info[3][MAX_STORE_BCN_NUM];
444 	struct rtw_bcn_offset offset_i;
445 };
446 
447 struct rtw_bcn_pkt_info {
448 	struct rtw_phl_stainfo_t *sta;
449 	u64 tsf;
450 	u64 hw_tsf;
451 };
452 
453 struct rtw_rts_threshold {
454 	u16 rts_time_th;
455 	u16 rts_len_th;
456 };
457 
458 enum phl_module_id{
459 	/* 0 ~ 128 PHL background module starts from here*/
460 	/* 1,2,3 cmd controller section */
461 	PHL_BK_MDL_START = 0,
462 	PHL_MDL_PHY_MGNT = 1,
463 	PHL_MDL_TX = 2,
464 	PHL_MDL_RX = 3,
465 
466 	/* above enum is fixed, add new module id from here*/
467 	/* 10 ~ 40 protocol, wifi role section*/
468 	PHL_BK_MDL_ROLE_START = 10,
469 	PHL_MDL_MRC = 10, /* Multi-Role Controller intead of STA/P2P role /NAN/AP*/
470 	PHL_MDL_SOUND = 11,
471 
472 	PHL_BK_MDL_ROLE_END = 40,
473 
474 	/* 41 ~ 70 mandatory background module section*/
475 	PHL_BK_MDL_MDRY_START = 41,
476 	PHL_MDL_POWER_MGNT = 41,
477 	PHL_MDL_SER = 42,
478 
479 	PHL_BK_MDL_MDRY_END = 70,
480 
481 	/* 70 ~ 127 optional background module section*/
482 	PHL_BK_MDL_OPT_START = 71,
483 	PHL_MDL_BTC = 71,
484 	/*PHL_MDL_RSVD = 72,*/
485 	PHL_MDL_CUSTOM = 73,
486 	PHL_MDL_WOW = 74,
487 	PHL_MDL_PSTS = 75,
488 	PHL_MDL_LED = 76,
489 	PHL_MDL_GENERAL = 77,
490 	PHL_MDL_REGU = 78,
491 
492 	PHL_BK_MDL_OPT_END = 127,
493 
494 	/* Fixed BK MDL Max Value*/
495 	PHL_BK_MDL_END = 128,
496 
497 	/* 129 ~ 256 PHL foreground module starts from here*/
498 	PHL_FG_MDL_START = 129,
499 	PHL_FUNC_MDL_TEST_MODULE = 129,
500 	PHL_FG_MDL_SCAN = 130,
501 	PHL_FG_MDL_CONNECT = 131,
502 	PHL_FG_MDL_DISCONNECT = 132,
503 	PHL_FG_MDL_AP_START = 133,
504 	PHL_FG_MDL_AP_STOP = 134,
505 	PHL_FG_MDL_ECSA = 135,
506 	PHL_FG_MDL_END = 254,
507 
508 	/* Fixed MDL Max Value*/
509 	PHL_MDL_ID_MAX = 255
510 };
511 
512 /* General phl event id shall share this common enum definition
513  * if definition of private events for a specific module is required,
514  * please be sure to start its enum from PRIVATE_EVT_START(0x8000)
515  */
516 enum phl_msg_evt_id {
517 	MSG_EVT_NONE = 0,
518 	MSG_EVT_PHY_ON = 1,
519 	MSG_EVT_PHY_IDLE = 2,
520 	MSG_EVT_SCAN_START = 3,
521 	MSG_EVT_SCAN_END = 4,
522 	MSG_EVT_CONNECT_START = 5,
523 	MSG_EVT_CONNECT_LINKED = 6,
524 	MSG_EVT_CONNECT_END = 7,
525 	MSG_EVT_SER_L1 = 8,
526 	MSG_EVT_SER_L2 = 9,
527 	MSG_EVT_FWDL_OK = 10,
528 	MSG_EVT_FWDL_FAIL = 11,
529 	MSG_EVT_HAL_INIT_OK = 12,
530 	MSG_EVT_HAL_INIT_FAIL = 13,
531 	MSG_EVT_MP_CMD_DONE = 14,
532 	/* wow */
533 	MSG_EVT_WOW_ENTER = 15,
534 	MSG_EVT_WOW_LEAVE = 16,
535 	MSG_EVT_WOW_WAKE_RSN = 17,
536 	MSG_EVT_BCN_RESEND = 18,
537 	MSG_EVT_DUMP_PLE_BUFFER = 19,
538 	MSG_EVT_MP_RX_PHYSTS = 20,
539 	MSG_EVT_ROLE_NTFY = 21,
540 	MSG_EVT_RX_PSTS = 22,
541 	MSG_EVT_SWCH_START = 23,
542 	MSG_EVT_SWCH_DONE = 24,
543 	MSG_EVT_DISCONNECT_PREPARE = 25,
544 	MSG_EVT_DISCONNECT = 26,
545 	MSG_EVT_TSF_SYNC_DONE = 27,
546 	MSG_EVT_TX_RESUME = 28,
547 	MSG_EVT_AP_START_PREPARE =29,
548 	MSG_EVT_AP_START = 30,
549 	MSG_EVT_AP_START_END = 31,
550 	MSG_EVT_AP_STOP_PREPARE = 32,
551 	MSG_EVT_AP_STOP = 33,
552 	MSG_EVT_PCIE_TRX_MIT = 34,
553 	MSG_EVT_BTC_TMR = 35,
554 	MSG_EVT_BTC_FWEVNT = 36,
555 	MSG_EVT_BTC_REQ_BT_SLOT = 37,
556 	MSG_EVT_BTC_PKT_EVT_NTFY = 38,
557 	/* ser*/
558 	MSG_EVT_SER_L0_RESET = 39,		/* L0 notify only */
559 	MSG_EVT_SER_M1_PAUSE_TRX = 40,
560 	MSG_EVT_SER_IO_TIMER_EXPIRE = 41,
561 	MSG_EVT_SER_FW_TIMER_EXPIRE = 42,
562 	MSG_EVT_SER_M3_DO_RECOV = 43,
563 	MSG_EVT_SER_M5_READY = 44,
564 	MSG_EVT_SER_M9_L2_RESET = 45,
565 	MSG_EVT_SER_EVENT_CHK = 46,
566 	MSG_EVT_SER_POLLING_CHK = 47,
567 	MSG_EVT_ECSA_START = 48,
568 	MSG_EVT_ECSA_UPDATE_FIRST_BCN_DONE = 49,
569 	MSG_EVT_ECSA_COUNT_DOWN = 50,
570 	MSG_EVT_ECSA_SWITCH_START = 51,
571 	MSG_EVT_ECSA_SWITCH_DONE = 52,
572 	MSG_EVT_ECSA_CHECK_TX_RESUME = 53,
573 	MSG_EVT_ECSA_DONE = 54,
574 	MSG_EVT_LISTEN_STATE_EXPIRE = 55,
575 	/* beamform */
576 	MSG_EVT_SET_VHT_GID = 56,
577 	MSG_EVT_HW_WATCHDOG = 57,
578 	MSG_EVT_DEV_CANNOT_IO = 58,
579 	MSG_EVT_DEV_RESUME_IO = 59,
580 	MSG_EVT_FORCE_USB_SW = 60,
581 	MSG_EVT_GET_USB_SPEED = 61,
582 	MSG_EVT_GET_USB_SW_ABILITY = 62,
583 	MSG_EVT_CFG_AMPDU = 63,
584 	MSG_EVT_DFS_PAUSE_TX = 64,
585 	MSG_EVT_ROLE_RECOVER = 65,
586 	MSG_EVT_ROLE_SUSPEND = 66,
587 	MSG_EVT_HAL_SET_L2_LEAVE = 67,
588 	MSG_EVT_NOTIFY_HAL = 68,
589 	MSG_EVT_ISSUE_BCN = 69,
590 	MSG_EVT_FREE_BCN = 70,
591 	MSG_EVT_STOP_BCN = 71,
592 	MSG_EVT_SEC_KEY = 72,
593 	MSG_EVT_ROLE_START = 73,
594 	MSG_EVT_ROLE_CHANGE = 74,
595 	MSG_EVT_ROLE_STOP = 75,
596 	MSG_EVT_STA_INFO_CTRL = 76,
597 	MSG_EVT_STA_MEDIA_STATUS_UPT = 77,
598 	MSG_EVT_CFG_CHINFO = 78,
599 	MSG_EVT_STA_CHG_STAINFO = 79,
600 	MSG_EVT_HW_TRX_RST_RESUME = 80,
601 	MSG_EVT_HW_TRX_PAUSE = 81,
602 	MSG_EVT_SW_TX_RESUME = 82,
603 	MSG_EVT_SW_RX_RESUME = 83,
604 	MSG_EVT_SW_TX_PAUSE = 84,
605 	MSG_EVT_SW_RX_PAUSE = 85,
606 	MSG_EVT_SW_TX_RESET = 86,
607 	MSG_EVT_SW_RX_RESET = 87,
608 	MSG_EVT_TRX_SW_PAUSE = 88,
609 	MSG_EVT_TRX_SW_RESUME = 89,
610 	MSG_EVT_TRX_PAUSE_W_RST = 90,
611 	MSG_EVT_TRX_RESUME_W_RST = 91,
612 	/* Regulation*/
613 	MSG_EVT_REGU_SET_DOMAIN = 92,
614 	MSG_EVT_RF_ON = 93,
615 	MSG_EVT_RF_OFF = 94,
616 	MSG_EVT_WPS_PRESSED = 95,
617 	MSG_EVT_WPS_RELEASED = 96,
618 	MSG_EVT_SURPRISE_REMOVE = 97,
619 	MSG_EVT_DATA_PATH_START = 98,
620 	MSG_EVT_DATA_PATH_STOP = 99,
621 	MSG_EVT_TRX_PWR_REQ = 100,
622 	/* tdls */
623 	MSG_EVT_TDLS_SYNC = 101,
624 	/* beamformee */
625 	MSG_EVT_SET_BFEE_AID = 102,
626 	/* ccx */
627 	MSG_EVT_CCX_REPORT_TX_OK = 103,
628 	MSG_EVT_CCX_REPORT_TX_FAIL = 104,
629 	/* ps */
630 	MSG_EVT_PS_CAP_CHG = 105,
631 	MSG_EVT_PS_PERIOD_CHK = 106,
632 	MSG_EVT_PS_DBG_LPS_ENTER = 107,
633 	MSG_EVT_PS_DBG_LPS_LEAVE = 108,
634 	MSG_EVT_PS_DBG_IPS_ENTER = 109,
635 	MSG_EVT_PS_DBG_IPS_LEAVE = 110,
636 	/* Change operating ch def(ch / bw) */
637 	MSG_EVT_CHG_OP_CH_DEF_START = 111,
638 	MSG_EVT_CHG_OP_CH_DEF_END = 112,
639 	MSG_EVT_MDL_CHECK_STOP = 113,
640 	MSG_EVT_HW_RF_CHG = 114,
641 
642 	MSG_EVT_TX_PKT_NTFY = 115,
643 	MSG_EVT_SW_WATCHDOG = 116,
644 	/* ltr */
645 	/* dbg */
646 	MSG_EVT_DBG_SIP_REG_DUMP = 200,
647 	MSG_EVT_DBG_FULL_REG_DUMP = 201,
648 	MSG_EVT_DBG_L2_DIAGNOSE = 202,
649 	MSG_EVT_DBG_RX_DUMP = 203,
650 	MSG_EVT_DBG_TX_DUMP = 204,
651 	/* dbg end */
652 	/* p2pps */
653 	MSG_EVT_TSF32_TOG = 205,
654 	/* p2pps end */
655 	/*Add EVT-ID for linux core cmd temporality*/
656 
657 	/* sub module IO */
658 	MSG_EVT_NOTIFY_BB = 300,
659 	MSG_EVT_NOTIFY_RF = 301,
660 	MSG_EVT_NOTIFY_MAC = 302,
661 	/* sub module IO end*/
662 
663 	MSG_EVT_LINUX_CMD_WRK = 888,
664 	MSG_EVT_LINUX_CMD_WRK_TRI_PS = 889,
665 	/* LED */
666 	MSG_EVT_LED_TICK = 5000,
667 	MSG_EVT_LED_EVT_START = 5001,
668 	MSG_EVT_LED_EVT_END = 5050,
669 	MSG_EVT_MAX = 0x7fff
670 };
671 
672 
673 
674 enum phl_msg_recver_layer {
675 	MSG_RECV_PHL = 0,
676 	MSG_RECV_CORE = 1,
677 	MSG_RECV_MAX
678 };
679 
680 enum phl_msg_indicator {
681 	MSG_INDC_PRE_PHASE = BIT0,
682 	MSG_INDC_FAIL = BIT1,
683 	MSG_INDC_CANCEL = BIT2,
684 	MSG_INDC_CANNOT_IO = BIT3
685 };
686 
687 enum phl_msg_opt {
688 	MSG_OPT_SKIP_NOTIFY_OPT_MDL = BIT0,
689 	MSG_OPT_BLIST_PRESENT = BIT1,
690 	MSG_OPT_CLR_SNDR_MSG_IF_PENDING = BIT2,
691 	MSG_OPT_SEND_IN_ABORT = BIT3,
692 	MSG_OPT_PENDING_DURING_CANNOT_IO = BIT4,
693 };
694 
695 
696 /* all module share this common enum definition */
697 enum phy_bk_module_opcode {
698 	BK_MODL_OP_NONE = 0,
699 	BK_MODL_OP_CHK_NEW_MSG,
700 	BK_MODL_OP_INPUT_CMD,
701 	BK_MODL_OP_STATE,
702 	BK_MODL_OP_CUS_SET_ROLE_CAP,
703 	BK_MODL_OP_CUS_UPDATE_ROLE_CAP,
704 	BK_MODL_OP_MAX
705 };
706 
707 /* Foreground cmd token opcode */
708 enum phy_fg_cmd_req_opcode {
709 	FG_REQ_OP_NONE = 0,
710 	FG_REQ_OP_GET_ROLE,
711 	FG_REQ_OP_GET_MDL_ID,
712 #ifdef RTW_WKARD_MRC_ISSUE_NULL_WITH_SCAN_OPS
713 	FG_REQ_OP_GET_SCAN_PARAM,
714 	FG_REQ_OP_GET_ISSUE_NULL_OPS,
715 #endif
716 #ifdef RTW_WKARD_CMD_SCAN_EXTEND_ACTIVE_SCAN
717 	FG_REQ_OP_NOTIFY_BCN_RCV,
718 #endif
719 #ifdef RTW_WKARD_CMD_SCAN_EXTEND_ACTION_FRAME_TX
720 	FG_REQ_OP_NOTIFY_ACTION_FRAME_TX,
721 #endif
722 	FG_REQ_OP_MAX
723 };
724 
725 /* priority of phl background
726 module which would be considered when dispatching phl msg*/
727 enum phl_bk_module_priority {
728 	PHL_MDL_PRI_ROLE = 0,
729 	PHL_MDL_PRI_OPTIONAL,
730 	PHL_MDL_PRI_MANDATORY,
731 	PHL_MDL_PRI_MAX
732 };
733 
734 enum phl_data_ctl_cmd {
735 	PHL_DATA_CTL_HW_TRX_RST_RESUME = 1,
736 	PHL_DATA_CTL_HW_TRX_PAUSE = 2,
737 	PHL_DATA_CTL_SW_TX_RESUME = 3,
738 	PHL_DATA_CTL_SW_RX_RESUME = 4,
739 	PHL_DATA_CTL_SW_TX_PAUSE = 5,
740 	PHL_DATA_CTL_SW_RX_PAUSE = 6,
741 	PHL_DATA_CTL_SW_TX_RESET = 7,
742 	PHL_DATA_CTL_SW_RX_RESET = 8,
743 	PHL_DATA_CTL_TRX_SW_PAUSE = 9,
744 	PHL_DATA_CTL_TRX_SW_RESUME = 10,
745 	PHL_DATA_CTL_TRX_PAUSE_W_RST = 11,
746 	PHL_DATA_CTL_TRX_RESUME_W_RST = 12,
747 	PHL_DATA_CTL_MAX = 0xFF
748 };
749 
750 /**
751  * phl_msg - define a general msg format for PHL/CORE layer module to handle
752  * one can easily extend additional mgnt info by encapsulating inside a file
753  * refer to
754  *		struct phl_msg_ex 		in phl_msg_hub.c
755  *		struct phl_dispr_msg_ex		in phl_cmd_dispatcher.c
756  *
757  * @msg_id: indicate msg source & msg type
758  *	    BYTE 3: RSVD
759  *	    BYTE 2: PHL Module ID,  refer to enum phl_module_id
760  *	    BYTE 0-1: event id, refer to enum phl_msg_evt_id
761  * @inbuf: input buffer that sent along with msg
762  * @inlen: input buffer length
763  * @outbuf: output buffer that returned after all phl modules have recved msg.
764  * @outlen: output buffer length
765  * @band_idx: index of Band(PHY) which associate to this msg
766 
767  * @rsvd: feature reserved, passing object pointer.
768  *        For example,
769  *        - cmd_scan : [0]: wifi_role.
770  *        - CANNOT_IO error: [0]: mdl handle.
771  */
772 struct phl_msg{
773 	u32 msg_id;
774 	enum phl_band_idx band_idx;
775 	u8* inbuf;
776 	u8* outbuf;
777 	u32 inlen;
778 	u32 outlen;
779 	void *rsvd[4];
780 };
781 
782 struct msg_notify_map {
783 	u8* id_arr;
784 	u8 len;
785 };
786 struct msg_dispatch_seq {
787 	struct msg_notify_map map[PHL_MDL_PRI_MAX];
788 };
789 struct msg_self_def_seq {
790 	struct msg_dispatch_seq pre_prot_phase;
791 	struct msg_dispatch_seq post_prot_phase;
792 };
793 struct msg_completion_routine {
794 	void* priv;
795 	void (*completion)(void* priv, struct phl_msg* msg);
796 };
797 /**
798  * phl_msg_attribute: used in phl_disp_eng_send_msg
799  * @opt: refers to enum phl_msg_opt.
800  * @notify: input id array (refer to enum phl_module_id)
801  * 	    for indicating additional dependency
802  * @completion: completion routine
803  */
804 struct phl_msg_attribute {
805 	u8 opt;
806 	struct msg_notify_map notify;
807 	struct msg_completion_routine completion;
808 #ifdef CONFIG_CMD_DISP_SUPPORT_CUSTOM_SEQ
809 	void *dispr_attr;
810 #endif
811 };
812 
813 /**
814  * phl_module_op_info - set by core layer or phl itself,
815  * op code process is an synchronous process.
816  * which would be handled directly by module handler
817  * @op_code: refer to enum phy_module_opcode
818  * @inbuf: input buffer that sent along with msg
819  * @inlen: input buffer length
820  * @outbuf: output buffer that returned after all phy modules have recved msg.
821  * @outlen: output buffer length
822  */
823 struct phl_module_op_info{
824 	u32 op_code;
825 	u8* inbuf;
826 	u8* outbuf;
827 	u32 inlen;
828 	u32 outlen;
829 };
830 
831 /**
832  * phl_cmd_token_req - request foramt for applying token of a specific cmd
833  * dispatcher.
834  * cmd token request is regarded as foreground module, thus,
835  * need to contend for cmd token.
836  * Normally, these req would be linked to a specific wifi role
837  * and acquiring RF resource for a specific task.
838  *
839  * @module_id: starting from PHL_FG_MDL_START
840  * @priv: private context from requestor
841  * @role: designated role info associated with current request.
842  * -----------------------------------------
843  * regarding on "return code" for following ops, refer to enum phl_mdl_ret_code
844  * -----------------------------------------
845  * @acquired: notify requestor when cmd token has acquired for this cmd and
846               cannot have any I/O operation.
847  * @abort: notify requestor when cmd has been canceled
848            after calling rtw_phl_phy_cancel_token_req and
849            cannot have any I/O operation.
850  * @msg_hdlr: notify requestor about incoming msg.
851  * @set_info: notify requestor to handle specific op code.
852  * @query_info: notify requestor to handle specific op code.
853  */
854 
855 struct phl_cmd_token_req{
856 	u8 module_id;
857 	void* priv;
858 	void* role;
859 	enum phl_mdl_ret_code (*acquired)(void* dispr, void* priv);
860 	enum phl_mdl_ret_code (*abort)(void* dispr, void* priv);
861 	enum phl_mdl_ret_code (*msg_hdlr)(void* dispr, void* priv,
862 							struct phl_msg* msg);
863 	enum phl_mdl_ret_code (*set_info)(void* dispr, void* priv,
864 					struct phl_module_op_info* info);
865 	enum phl_mdl_ret_code (*query_info)(void* dispr, void* priv,
866 				struct phl_module_op_info* info);
867 };
868 /**
869  * phl_module_ops - standard interface for interacting with a cmd dispatcher.
870  * -----------------------------------------
871  * regarding on "return code" for following ops, refer to enum phl_mdl_ret_code
872  * -----------------------------------------
873  * @init: notify module for initialization.
874  * @deinit: notify module for de-initialization.
875  * @start: notify module to start.
876  * @stop: notify module to stop.
877  * @msg_hdlr: notify module about incoming msg.
878  * @set_info: notify module to handle specific op code.
879  * @query_info: notify module to handle specific op code.
880  */
881 struct phl_bk_module_ops {
882 	enum phl_mdl_ret_code (*init)(void* phl_info, void* dispr, void** priv);
883 	void (*deinit)(void* dispr, void* priv);
884 	enum phl_mdl_ret_code (*start)(void* dispr, void* priv);
885 	enum phl_mdl_ret_code (*stop)(void* dispr, void* priv);
886 	enum phl_mdl_ret_code (*msg_hdlr)(void* dispr, void* priv,
887 							struct phl_msg* msg);
888 	enum phl_mdl_ret_code (*set_info)(void* dispr, void* priv,
889 			struct phl_module_op_info* info);
890 	enum phl_mdl_ret_code (*query_info)(void* dispr, void* priv,
891 			struct phl_module_op_info* info);
892 };
893 
894 /**
895  * phl_data_ctl_t - datapath control parameters for dispatcher controller
896  * @cmd: data path control command
897  * @id: module id which request data path control
898  */
899 struct phl_data_ctl_t {
900 	enum phl_data_ctl_cmd cmd;
901 	enum phl_module_id id;
902 };
903 
904 #define MSG_MDL_ID_FIELD(_msg_id) (((_msg_id) >> 16) & 0xFF)
905 #define MSG_EVT_ID_FIELD(_msg_id) ((_msg_id) & 0xFFFF)
906 #define MSG_INDC_FIELD(_msg_id) (((_msg_id) >> 24) & 0xFF)
907 #define IS_PRIVATE_MSG(_msg_id) ((_msg_id) & PRIVATE_EVT_START)
908 #define IS_MSG_FAIL(_msg_id) ((_msg_id) & ( MSG_INDC_FAIL <<  24))
909 #define IS_MSG_IN_PRE_PHASE(_msg_id) ((_msg_id) & ( MSG_INDC_PRE_PHASE <<  24))
910 #define IS_MSG_CANCEL(_msg_id) ((_msg_id) & ( MSG_INDC_CANCEL <<  24))
911 #define IS_MSG_CANNOT_IO(_msg_id) ((_msg_id) & ( MSG_INDC_CANNOT_IO <<  24))
912 #define SET_MSG_MDL_ID_FIELD(_msg_id, _id) \
913 	((_msg_id) = (((_msg_id) & 0xFF00FFFF) | ((u32)(_id) << 16)))
914 #define SET_MSG_EVT_ID_FIELD(_msg_id, _id) \
915 	((_msg_id) = (((_msg_id) & 0xFFFF0000) | (_id)))
916 #define SET_MSG_INDC_FIELD(_msg_id, _indc) \
917 	((_msg_id) = (((_msg_id) & ~((u32)(_indc) << 24))|((u32)(_indc) << 24)))
918 #define CLEAR_MSG_INDC_FIELD(_msg_id, _indc) ((_msg_id) &= ~((_indc) << 24))
919 
920 #define RTW_MAX_FW_SIZE 0x400000
921 
922 enum rtw_fw_src {
923 	RTW_FW_SRC_INTNAL, /* 0 */
924 	RTW_FW_SRC_EXTNAL, /* 1 */
925 	RTW_FW_SRC_MAX
926 };
927 
928 enum rtw_fw_rsn {
929 	RTW_FW_RSN_INIT, /* 0 */
930 	RTW_FW_RSN_SPIC, /* 1 */
931 	RTW_FW_RSN_LPS, /* 2 */
932 	RTW_FW_RSN_MCC, /* 3 */
933 	RTW_FW_RSN_WOW, /* 4 */
934 	RTW_FW_RSN_MAX
935 };
936 
937 struct rtw_fw_cap_t {
938 	enum rtw_fw_src fw_src;
939 	u32 offload_cap;
940 	u8 dlram_en;
941 	u8 dlrom_en;
942 };
943 
944 #define INVALID_WIFI_ROLE_IDX MAX_WIFI_ROLE_NUMBER
945 #define UNSPECIFIED_ROLE_ID 0xFF
946 #define MAX_SECCAM_NUM_PER_ENTRY 7
947 
948 /* Role hw TX CAP*/
949 struct role_cap_t {
950 	enum wlan_mode wmode;
951 	enum channel_width bw;
952 	u8 rty_lmt;		/* retry limit for DATA frame, 0xFF: invalid */
953 	u8 rty_lmt_rts;		/* retry limit for RTS frame, 0xFF: invalid */
954 
955 	u8 tx_num_ampdu;
956 	u8 tx_amsdu_in_ampdu; /*from SW & HW*/
957 	u8 tx_ampdu_len_exp; /*from  SW & HW*/
958 	u8 tx_htc;
959 	u8 tx_sgi;
960 
961 	u8 tx_ht_ldpc:1;
962 	u8 tx_vht_ldpc:1;
963 	u8 tx_he_ldpc:1;
964 	u8 tx_ht_stbc:1;
965 	u8 tx_vht_stbc:1;
966 	u8 tx_he_stbc:1;
967 
968 	u8 supported_rates[12];
969 };
970 
971 struct role_sw_cap_t {
972 	u16 bf_cap; /* use define : HW_CAP_BFER_XX_XX */
973 	u16 stbc_cap;/* use define: HW_CAP_STBC_XX */
974 };
975 
976 /*
977 Protocol - RX CAP from 80211 PKT,
978 driver TX related function need to
979 reference __rx__ of rtw_phl_stainfo_t->asoc_cap
980 */
981 struct protocol_cap_t {
982 	/* MAC related */
983 	u16 bcn_interval;	/* beacon interval */
984 	u8 num_ampdu;
985 	u8 ampdu_density:3;	/* rx ampdu cap */
986 	u8 ampdu_len_exp; /* rx ampdu cap */
987 	u8 amsdu_in_ampdu:1; /* rx ampdu cap */
988 	u8 max_amsdu_len:2; /* 0: 4k, 1: 8k, 2: 11k */
989 	u8 htc_rx:1;
990 	u8 sm_ps:2;
991 	u8 trig_padding:2;
992 	u8 twt:6;
993 	u8 all_ack:1;
994 	u8 a_ctrl:4;
995 	u8 ops:1;
996 	u8 ht_vht_trig_rx:1;
997 	u8 bsscolor;
998 	u16 rts_th:10;
999 
1000 	u8 short_slot:1;	/* Short Slot Time */
1001 
1002 	u8 preamble:1;		/* Preamble, 0: long, 1: short */
1003 	u8 sgi_20:1;		/* HT Short GI for 20 MHz */
1004 	u8 sgi_40:1;		/* HT Short GI for 40 MHz */
1005 	u8 sgi_80:1;		/* VHT Short GI for 80 MHz */
1006 	u8 sgi_160:1;		/* VHT Short GI for 160/80+80 MHz */
1007 	struct rtw_edca_param edca[4]; 	/* Access Category, 0:BE, 1:BK, 2:VI, 3:VO */
1008 	u8 mu_qos_info;
1009 	struct rtw_mu_edca_param mu_edca[4];
1010 
1011 	/* BB related */
1012 	u8 ht_ldpc:1;
1013 	u8 vht_ldpc:1;
1014 	u8 he_ldpc:1;
1015 	u8 he_su_bfmr:1;
1016 	u8 he_su_bfme:1;
1017 	u8 he_mu_bfmr:1;
1018 	u8 he_mu_bfme:1;
1019 	u8 bfme_sts:3;
1020 	u8 num_snd_dim:3;
1021 
1022 	u8 ht_su_bfmr:1;
1023 	u8 ht_su_bfme:1;
1024 	u8 vht_su_bfmr:1;
1025 	u8 vht_su_bfme:1;
1026 	u8 vht_mu_bfmr:1;
1027 	u8 vht_mu_bfme:1;
1028 	u8 ht_vht_ng:2;
1029 	u8 ht_vht_cb:2;
1030 	/*
1031 	 * supported_rates: Supported data rate of CCK/OFDM.
1032 	 * The rate definition follow Wi-Fi spec, unit is 500kb/s,
1033 	 * and the MSB(bit 7) represent basic rate.
1034 	 * ex. CCK 2Mbps not basic rate is encoded as 0x04,
1035 	 *     and OFDM 6M basic rate is encoded as 0x8c.
1036 	 * Suppose rates come from Supported Rates and Extended Supported
1037 	 * Rates IE.
1038 	 * Value 0 means it is end of array, and no more valid data rate follow.
1039 	 */
1040 	u8 supported_rates[12];
1041 	u8 ht_rx_mcs[4];
1042 	u8 ht_tx_mcs[4];
1043 	u8 ht_basic_mcs[4];	/* Basic rate of HT */
1044 	u8 vht_rx_mcs[2];
1045 	u8 vht_tx_mcs[2];
1046 	u8 vht_basic_mcs[2];	/* Basic rate of VHT */
1047 	u8 he_rx_mcs[6];/*80,160,80+80*/
1048 	u8 he_tx_mcs[6];/*80,160,80+80*/
1049 	u8 he_basic_mcs[2];	/* Basic rate of HE */
1050 	u8 stbc_ht_rx:2;
1051 	u8 stbc_vht_rx:3;
1052 	u8 stbc_he_rx:1;
1053 	u8 stbc_tx:1;
1054 	u8 stbc_ht_tx:1;
1055 	u8 stbc_vht_tx:1;
1056 	u8 stbc_he_tx:1;
1057 	u8 ltf_gi;
1058 	u8 doppler_tx:1;
1059 	u8 doppler_rx:1;
1060 	u8 dcm_max_const_tx:2;
1061 	u8 dcm_max_nss_tx:1;
1062 	u8 dcm_max_const_rx:2;
1063 	u8 dcm_max_nss_rx:1;
1064 	u8 partial_bw_su_in_mu:1;
1065 	u8 bfme_sts_greater_80mhz:3;
1066 	u8 num_snd_dim_greater_80mhz:3;
1067 	u8 stbc_tx_greater_80mhz:1;
1068 	u8 stbc_rx_greater_80mhz:1;
1069 	u8 ng_16_su_fb:1;
1070 	u8 ng_16_mu_fb:1;
1071 	u8 cb_sz_su_fb:1;
1072 	u8 cb_sz_mu_fb:1;
1073 	u8 trig_su_bfm_fb:1;
1074 	u8 trig_mu_bfm_fb:1;
1075 	u8 trig_cqi_fb:1;
1076 	u8 partial_bw_su_er:1;
1077 	u8 pkt_padding:2;
1078 	u8 ppe_thr[8][4];
1079 	u8 pwr_bst_factor:1;
1080 	u8 max_nc:3;
1081 	u8 dcm_max_ru:2;
1082 	u8 long_sigb_symbol:1;
1083 	u8 non_trig_cqi_fb:1;
1084 	u8 tx_1024q_ru:1;
1085 	u8 rx_1024q_ru:1;
1086 	u8 fbw_su_using_mu_cmprs_sigb:1;
1087 	u8 fbw_su_using_mu_non_cmprs_sigb:1;
1088 	u8 er_su:1;
1089 	u8 tb_pe:3;
1090 	u16 txop_du_rts_th;
1091 	u8 he_rx_ndp_4x32:1;
1092 
1093 	/* RF related */
1094 	u8 nss_tx:3;
1095 	u8 nss_rx:3;
1096 
1097 	u8 num_ampdu_bk;
1098 };
1099 
1100 
1101 
1102 #define LOAD_MAC_REG_FILE				BIT0
1103 #define LOAD_BB_PHY_REG_FILE			BIT1
1104 #define LOAD_BB_PHY_REG_MP_FILE			BIT2
1105 #define LOAD_RF_RADIO_FILE				BIT3
1106 #define LOAD_RF_TXPWR_BY_RATE			BIT4
1107 #define LOAD_RF_TXPWR_TRACK_FILE		BIT5
1108 #define LOAD_RF_TXPWR_LMT_FILE			BIT6
1109 #define LOAD_RF_TXPWR_LMT_RU_FILE		BIT7
1110 #define LOAD_BB_PHY_REG_GAIN_FILE		BIT8
1111 
1112 #define PHL_UNDEFINED_SW_CAP 0xFF
1113 
1114 struct rtw_pcie_ltr_lat_ctrl {
1115 	enum rtw_pcie_bus_func_cap_t ctrl;
1116 	u32 val;
1117 };
1118 
1119 enum rtw_pcie_ltr_state {
1120 	RTW_PCIE_LTR_SW_ACT = 1,
1121 	RTW_PCIE_LTR_SW_IDLE = 2
1122 };
1123 
1124 struct bus_sw_cap_t {
1125 #ifdef CONFIG_PCI_HCI
1126 	enum rtw_pcie_bus_func_cap_t l0s_ctrl;
1127 	enum rtw_pcie_bus_func_cap_t l1_ctrl;
1128 	enum rtw_pcie_bus_func_cap_t l1ss_ctrl;
1129 	enum rtw_pcie_bus_func_cap_t wake_ctrl;
1130 	enum rtw_pcie_bus_func_cap_t crq_ctrl;
1131 	u32 txbd_num;
1132 	u32 rxbd_num;
1133 	u32 rpbd_num;
1134 	u32 rxbuf_num;
1135 	u32 rpbuf_num;
1136 	u8 clkdly_ctrl;
1137 	u8 l0sdly_ctrl;
1138 	u8 l1dly_ctrl;
1139 	struct rtw_pcie_ltr_lat_ctrl ltr_act;
1140 	struct rtw_pcie_ltr_lat_ctrl ltr_idle;
1141 	u8 ltr_init_state;
1142 	u16 ltr_sw_ctrl_thre; /* [15:8] tx [7:0] rx */
1143 	u8 ltr_sw_ctrl;
1144 	u8 ltr_hw_ctrl;
1145 	u32 ltr_last_trigger_time;
1146 	u32 ltr_sw_act_tri_cnt;
1147 	u32 ltr_sw_idle_tri_cnt;
1148 	u8 ltr_cur_state;
1149 #elif defined (CONFIG_USB_HCI)
1150 	u32 tx_buf_size;
1151 	u32 tx_buf_num;
1152 	u32 tx_mgnt_buf_size;
1153 	u32 tx_mgnt_buf_num;
1154 	u32 tx_h2c_buf_num;
1155 	u32 rx_buf_size;
1156 	u32 rx_buf_num;
1157 	u32 in_token_num;
1158 #elif defined(CONFIG_SDIO_HCI)
1159 	u16 tx_buf_retry_lmt;
1160 	u32 tx_buf_size;
1161 	u32 tx_buf_num;
1162 	u32 tx_mgnt_buf_size;
1163 	u32 tx_mgnt_buf_num;
1164 	u32 rx_buf_size;
1165 	u32 rx_buf_num;
1166 #else
1167 	u8 temp_for_struct_empty; /* for undefined interface */
1168 #endif
1169 };
1170 struct bus_cap_t {
1171 #ifdef CONFIG_PCI_HCI
1172 	enum rtw_pcie_bus_func_cap_t l0s_ctrl;
1173 	enum rtw_pcie_bus_func_cap_t l1_ctrl;
1174 	enum rtw_pcie_bus_func_cap_t l1ss_ctrl;
1175 	enum rtw_pcie_bus_func_cap_t wake_ctrl;
1176 	enum rtw_pcie_bus_func_cap_t crq_ctrl;
1177 	u32 txbd_num;
1178 	u32 rxbd_num;
1179 	u32 rpbd_num;
1180 	u32 rxbuf_num;
1181 	u32 rpbuf_num;
1182 	u8 clkdly_ctrl;
1183 	u8 l0sdly_ctrl;
1184 	u8 l1dly_ctrl;
1185 	struct rtw_pcie_ltr_lat_ctrl ltr_act;
1186 	struct rtw_pcie_ltr_lat_ctrl ltr_idle;
1187 	u8 ltr_init_state;
1188 	u8 ltr_sw_ctrl;
1189 	u8 ltr_hw_ctrl;
1190 #elif defined (CONFIG_USB_HCI)
1191 	u32 tx_buf_size;
1192 	u32 tx_buf_num;
1193 	u32 tx_mgnt_buf_size;
1194 	u32 tx_mgnt_buf_num;
1195 	u32 tx_h2c_buf_num;
1196 	u32 rx_buf_size;
1197 	u32 rx_buf_num;
1198 	u32 in_token_num;
1199 #elif defined(CONFIG_SDIO_HCI)
1200 	u16 tx_buf_retry_lmt;
1201 	u32 tx_buf_size;
1202 	u32 tx_buf_num;
1203 	u32 tx_mgnt_buf_size;
1204 	u32 tx_mgnt_buf_num;
1205 	u32 rx_buf_size;
1206 	u32 rx_buf_num;
1207 #else
1208 	u8 temp_for_struct_empty; /* for undefined interface */
1209 #endif
1210 };
1211 
1212 #ifdef CONFIG_PHL_TWT
1213 
1214 #define DELETE_ALL 0xFF
1215 #define IGNORE_CFG_ID 0xFF
1216 #define IGNORE_MACID 0xFF
1217 
1218 enum rtw_phl_twt_sup_cap {
1219 	RTW_PHL_TWT_REQ_SUP = BIT(0), /* REQUESTER */
1220 	RTW_PHL_TWT_RSP_SUP = BIT(1)/* RESPONDER */
1221 };
1222 
1223 enum rtw_phl_nego_type {
1224 	RTW_PHL_INDIV_TWT = 0, /*individual TWT*/
1225 	RTW_PHL_WAKE_TBTT_INR = 1, /*wake TBTT and wake interval*/
1226 	RTW_PHL_BCAST_TWT = 2, /*Broadcast TWT*/
1227 	RTW_PHL_MANAGE_BCAST_TWT = 3 /*Manage memberships in broadcast TWT schedules*/
1228 };
1229 
1230 enum rtw_phl_wake_dur_unit{ /*wake duration unit*/
1231 	RTW_PHL_WAKE_256US = 0,
1232 	RTW_PHL_WAKE_1TU = 1
1233 };
1234 
1235 enum rtw_phl_setup_cmd{
1236 	RTW_PHL_REQUEST_TWT = 0,
1237 	RTW_PHL_SUGGEST_TWT = 1,
1238 	RTW_PHL_DEMAND_TWT = 2,
1239 	RTW_PHL_TWT_GROUPING = 3,
1240 	RTW_PHL_ACCEPT_TWT = 4,
1241 	RTW_PHL_ALTERNATE_TWT = 5,
1242 	RTW_PHL_DICTATE_TWT = 6,
1243 	RTW_PHL_REJECT_TWT = 7
1244 };
1245 
1246 enum rtw_phl_flow_type{
1247 	RTW_PHL_ANNOUNCED_TWT = 0,
1248 	RTW_PHL_UNANNOUNCED_TWT = 1
1249 };
1250 
1251 enum rtw_phl_twt_sta_action {
1252 	TWT_STA_NONE = 0,
1253 	TWT_STA_ADD_MACID = 1,
1254 	TWT_STA_DEL_MACID = 2,
1255 	TWT_STA_TETMINATW_SP = 3,
1256 	TWT_STA_SUSPEND_TWT = 4,
1257 	TWT_STA_RESUME_TWT = 5
1258 };
1259 
1260 enum rtw_phl_twt_cfg_action {
1261 	TWT_CFG_ADD = 0,
1262 	TWT_CFG_DELETE = 1,
1263 	TWT_CFG_MODIFY = 2
1264 };
1265 
1266 struct rtw_phl_twt_flow_type01 {
1267 	u8 twt_flow_id;
1268 	u8 teardown_all;
1269 };
1270 
1271 struct rtw_phl_twt_flow_type2 {
1272 	u8 reserved;
1273 };
1274 
1275 struct rtw_phl_twt_flow_type3 {
1276 	u8 bcast_twt_id;
1277 	u8 teardown_all;
1278 };
1279 
1280 struct rtw_phl_twt_flow_field{
1281 	enum rtw_phl_nego_type nego_type;
1282 	union {
1283 		struct rtw_phl_twt_flow_type01 twt_flow01;
1284 		struct rtw_phl_twt_flow_type2 twt_flow2;
1285 		struct rtw_phl_twt_flow_type3 twt_flow3;
1286 	} info;
1287 };
1288 
1289 /*phl_twt_setup_info Start*/
1290 
1291 /*Broadcast TWT Parameter Set field*/
1292 struct rtw_phl_bcast_twt_para_set{
1293 	u8 reserved; /*todo*/
1294 };
1295 
1296 /*Individual TWT Parameter Set field*/
1297 struct rtw_phl_twt_group_asgmt{
1298 	u8 reserved; /*todo*/
1299 };
1300 
1301 struct rtw_phl_req_type_indiv{
1302 	enum rtw_phl_setup_cmd twt_setup_cmd; /*twt setup command*/
1303 	enum rtw_phl_flow_type flow_type;
1304 	u8 twt_request;
1305 	u8 trigger;
1306 	u8 implicit;
1307 	u8 twt_flow_id;
1308 	u8 twt_wake_int_exp;/*twt wake interval exponent*/
1309 	u8 twt_protection;
1310 };
1311 
1312 struct rtw_phl_indiv_twt_para_set{
1313 	struct rtw_phl_req_type_indiv req_type;
1314 	struct rtw_phl_twt_group_asgmt twt_group_asgmt; /* twt group assignment*/
1315 	u32 target_wake_t_h; /* if contain twt_group_assignment then don't contain target_wake_time*/
1316 	u32 target_wake_t_l;
1317 	u16 twt_wake_int_mantissa; /*twt wake interval mantissa*/
1318 	u8 nom_min_twt_wake_dur; /*nominal minimum twt wake duration*/
1319 	u8 twt_channel;
1320 };
1321 
1322 struct rtw_phl_twt_control{
1323 	enum rtw_phl_nego_type nego_type; /*negotiation type*/
1324 	enum rtw_phl_wake_dur_unit wake_dur_unit; /*wake duration unit*/
1325 	u8 ndp_paging_indic; /*ndp paging indicator*/
1326 	u8 responder_pm_mode;
1327 	u8 twt_info_frame_disable; /*twt information frame disable*/
1328 };
1329 struct rtw_phl_twt_element{
1330 /* element info*/
1331 	/*control filed*/
1332 	struct rtw_phl_twt_control twt_ctrl;
1333 	/*twt para info*/
1334 	union {
1335 		struct rtw_phl_indiv_twt_para_set i_twt_para_set;
1336 		struct rtw_phl_bcast_twt_para_set b_twt_para_set;
1337 	} info;
1338 };
1339 
1340 struct rtw_phl_twt_setup_info{
1341 	struct rtw_phl_twt_element twt_element;
1342 	//struct rtw_phl_stainfo_t *phl_sta; //sta entry
1343 	u8 dialog_token;
1344 };
1345 /*phl_twt_setup_info End*/
1346 
1347 
1348 /*phl_twt_info Start*/
1349 struct rtw_twt_sta_info{
1350 	_os_list list;
1351 	struct rtw_phl_stainfo_t *phl_sta; /*sta entry*/
1352 	u8 id; /*twt_flow_identifier or broadcast_twt_id*/
1353 };
1354 
1355 struct rtw_phl_twt_info{
1356 	enum rtw_phl_wake_dur_unit wake_dur_unit;
1357 	enum rtw_phl_nego_type nego_type;
1358 	enum rtw_phl_flow_type flow_type;
1359 	u8 twt_id; /*config id*/
1360 	u8 bcast_twt_id; /*ignore in individual TWT*/
1361 	u8 twt_action;
1362 	u8 responder_pm_mode;
1363 	u8 trigger;
1364 	u8 implicit_lastbcast; /*implicit or lastbroadcast*/
1365 	u8 twt_protection;
1366 	u8 twt_wake_int_exp;
1367 	u8 nom_min_twt_wake_dur;
1368 	u16 twt_wake_int_mantissa;
1369 	u32 target_wake_time_h;
1370 	u32 target_wake_time_l;
1371 };
1372 
1373 
1374 #endif /* CONFIG_PHL_TWT */
1375 
1376 
1377 enum rtw_lps_listen_bcn_mode {
1378 	RTW_LPS_RLBM_MIN         = 0,
1379 	RTW_LPS_RLBM_MAX         = 1,
1380 	RTW_LPS_RLBM_USERDEFINE  = 2,
1381 	RTW_LPS_LISTEN_BCN_MAX,
1382 };
1383 
1384 enum rtw_lps_smart_ps_mode {
1385 	RTW_LPS_LEGACY_PWR1      = 0,
1386 	RTW_LPS_TRX_PWR0         = 1,
1387 	RTW_LPS_SMART_PS_MAX,
1388 };
1389 
1390 struct  rtw_wow_cap_t {
1391 	u8 magic_sup;
1392 	u8 pattern_sup;
1393 	u8 ping_pattern_wake_sup;
1394 	u8 arp_ofld_sup;
1395 	u8 ns_oflod_sup;
1396 	u8 gtk_ofld_sup;
1397 	u8 nlo_sup;
1398 };
1399 
1400 /**
1401  * enum phl_ps_leave_fail_act decide the action when leave ps fail
1402  * BIT 0 : reject all subsequent power request
1403  * BIT 1 : trigger L2 reset
1404  */
1405 enum phl_ps_leave_fail_act {
1406 	PS_LEAVE_FAIL_ACT_REJ_PWR = BIT0,
1407 	PS_LEAVE_FAIL_ACT_L2 = BIT1
1408 };
1409 #define PS_LEAVE_FAIL_ACT_NONE 0
1410 
1411 enum phl_ps_operation_mode {
1412 	PS_OP_MODE_DISABLED = 0,
1413 	PS_OP_MODE_FORCE_ENABLED = 1,
1414 	PS_OP_MODE_AUTO = 2
1415 };
1416 
1417 enum phl_ps_pwr_lvl {
1418 	PS_PWR_LVL_PWROFF = 0, /* hal deinit */
1419 	PS_PWR_LVL_PWR_GATED = 1, /* FW control*/
1420 	PS_PWR_LVL_CLK_GATED = 2, /* FW control*/
1421 	PS_PWR_LVL_RF_OFF = 3, /* FW control*/
1422 	PS_PWR_LVL_PWRON = 4, /* hal init */
1423 	PS_PWR_LVL_MAX
1424 };
1425 
1426 /**
1427  * enum phl_stop_rson record the reason to stop power saving
1428  * BIT 0 : by core initialization setting
1429  * BIT 1 : by debug flow setting
1430  * BIT 2 : by battery change
1431  */
1432 enum phl_ps_rt_rson {
1433 	PS_RT_DEBUG = BIT0,
1434 	PS_RT_CORE_INIT = BIT1,
1435 	PS_RT_BATTERY_CHG = BIT2,
1436 };
1437 #define PS_RT_RSON_NONE 0
1438 
1439 #define PS_CAP_PWRON BIT0
1440 #define PS_CAP_RF_OFF BIT1
1441 #define PS_CAP_CLK_GATED BIT2
1442 #define PS_CAP_PWR_GATED BIT3
1443 #define PS_CAP_PWR_OFF BIT4
1444 
1445 /**
1446  * ips_en/lps_en
1447  * refs. structure "phl_ps_operation_mode"
1448  * 0: disable -> disable all ps mechanism
1449  * 1: force enable -> ignore all other condition, force enter ps
1450  * 2: auto -> will be affected by runtime capability set by core
1451  *
1452  * ips_cap/ips_wow_cap/lps_cap/lps_wow_cap are bit defined
1453  * corresponding bit is set if specific power level is supported
1454  * BIT0: Power on
1455  * BIT1: Rf off
1456  * BIT2: Clock gating
1457  * BIT3: Power gating
1458  * BIT4: Power off
1459  */
1460 struct rtw_ps_cap_t {
1461 	/* rf state */
1462 	enum rtw_rf_state init_rf_state;
1463 	u8 init_rt_stop_rson;
1464 	u8 leave_fail_act; /* action when leave ps fail */
1465 	/* ips */
1466 	u8 ips_en;
1467 	u8 ips_cap;
1468 	u8 ips_wow_en;
1469 	u8 ips_wow_cap;
1470 	/* lps */
1471 	u8 lps_en;
1472 	u8 lps_cap;
1473 	u8 lps_awake_interval;
1474 	enum rtw_lps_listen_bcn_mode lps_listen_bcn_mode;
1475 	enum rtw_lps_smart_ps_mode lps_smart_ps_mode;
1476 	u8 lps_rssi_enter_threshold;
1477 	u8 lps_rssi_leave_threshold;
1478 	u8 lps_rssi_diff_threshold;
1479 	bool lps_pause_tx;
1480 	/* wow lps */
1481 	u8 lps_wow_en;
1482 	u8 lps_wow_cap;
1483 	u8 lps_wow_awake_interval;
1484 	enum rtw_lps_listen_bcn_mode lps_wow_listen_bcn_mode;
1485 	enum rtw_lps_smart_ps_mode lps_wow_smart_ps_mode;
1486 };
1487 
1488 struct rtw_edcca_cap_t {
1489 	u8 edcca_adap_th_2g;
1490 	u8 edcca_adap_th_5g;
1491 
1492 	u8 edcca_carrier_sense_th;
1493 };
1494 
1495 struct phy_sw_cap_t {
1496 	struct rtw_para_info_t mac_reg_info;
1497 	struct rtw_para_info_t bb_phy_reg_info;
1498 	struct rtw_para_info_t bb_phy_reg_mp_info;
1499 	struct rtw_para_info_t bb_phy_reg_gain_info;
1500 
1501 	struct rtw_para_info_t rf_radio_a_info;
1502 	struct rtw_para_info_t rf_radio_b_info;
1503 	struct rtw_para_info_t rf_txpwr_byrate_info;
1504 	struct rtw_para_info_t rf_txpwrtrack_info;
1505 
1506 	struct rtw_para_pwrlmt_info_t rf_txpwrlmt_info;
1507 	struct rtw_para_pwrlmt_info_t rf_txpwrlmt_ru_info;
1508 
1509 	u8 proto_sup;
1510 	u8 band_sup;
1511 	u8 bw_sup;
1512 	u8 txss;
1513 	u8 rxss;
1514 	u16 hw_rts_time_th;
1515 	u16 hw_rts_len_th;
1516 	bool bfreed_para;
1517 };
1518 
1519 /* final capability of phy */
1520 struct phy_cap_t {
1521 	u8 proto_sup;
1522 	u8 band_sup;
1523 	u8 bw_sup;
1524 	u8 txss;
1525 	u8 rxss;
1526 	u16 hw_rts_time_th;
1527 	u16 hw_rts_len_th;
1528 };
1529 
1530 /* final capability of device */
1531 struct dev_cap_t {
1532 	u64 hw_sup_flags;/*hw's feature support flags*/
1533 #ifdef RTW_WKARD_LAMODE
1534 	bool la_mode;
1535 #endif
1536 	u8 pkg_type;
1537 	u8 rfe_type;
1538 	u8 bypass_rfe_chk;
1539 	u8 xcap;
1540 	struct rtw_fw_cap_t fw_cap;
1541 #ifdef CONFIG_MCC_SUPPORT
1542 	bool mcc_sup;
1543 #endif
1544 #ifdef CONFIG_DBCC_SUPPORT
1545 	bool dbcc_sup;
1546 #endif
1547 #ifdef CONFIG_PHL_TWT
1548 	u8 twt_sup;
1549 #endif /* CONFIG_PHL_TWT */
1550 
1551 	struct rtw_wow_cap_t wow_cap;
1552 	struct rtw_ps_cap_t ps_cap;
1553 	u8 hw_hdr_conv;
1554 	u8 domain;
1555 	u8 btc_mode;
1556 	u8 ap_ps;           /* support for AP mode PS in PHL */
1557 	u8 pwrbyrate_off;
1558 	u8 pwrlmt_type;
1559 	u8 rf_board_opt;
1560 	u8 sta_ulru; /* support UL OFDAM for STA mode (reply trigger frame) */
1561 #ifdef RTW_WKARD_BB_DISABLE_STA_2G40M_ULOFDMA
1562 	u8 sta_ulru_2g40mhz; /* when "sta_ulru" is enabled, support UL OFDAM on 2.4G 40MHz ? */
1563 #endif
1564 	u8 tx_mu_ru;
1565 	struct rtw_edcca_cap_t edcca_cap;
1566 #ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE
1567 	bool bfree_para_info;	/* keep load file para info buf,default 0*/
1568 #endif
1569 	u8 hw_stype_cap;
1570 	u8 wl_func_cap;
1571 	u8 rpq_agg_num; /* 0: no adjust, use mac default size: 121 */
1572 	bool quota_turbo;
1573 };
1574 
1575 #ifdef RTW_PHL_BCN //phl def
1576 
1577 #define BCN_ID_MAX		(0xFF)
1578 #define MAX_BCN_SIZE	1000
1579 
1580 enum bcn_offload_flags{
1581 	BCN_HW_SEQ = 0,
1582 	BCN_HW_TIM,
1583 
1584 	BCN_HW_MAX = 32,
1585 };
1586 
1587 struct rtw_bcn_info_cmn {
1588 	u8 role_idx;
1589 	u8 bcn_id;
1590 	u8 bcn_added;
1591 
1592 	u8 bssid[6];
1593 	u32 bcn_interval;
1594 
1595 	u8 bcn_buf[MAX_BCN_SIZE];
1596 	u32 bcn_length;
1597 	u32 bcn_rate;
1598 
1599 	u32 bcn_dtim;
1600 	u32 ie_offset_tim;
1601 
1602 	u32 bcn_offload;
1603 };
1604 
1605 struct rtw_bcn_info_hw {
1606 	u8 band;
1607 	u8 port;
1608 	u8 mbssid;
1609 	u8 mac_id;
1610 };
1611 
1612 struct rtw_bcn_entry {
1613 	_os_list list;
1614 	struct rtw_bcn_info_cmn	*bcn_cmn;	//fill by core
1615 	struct rtw_bcn_info_hw 	bcn_hw;	//fill by phl //?? void mapping ?? for 8852, 8834 ...blabla
1616 };
1617 #endif
1618 
1619 struct rtw_phl_com_t;
1620 
1621 struct phl_msg_receiver {
1622 		void* priv;
1623 		void (*incoming_evt_notify)(void* priv, struct phl_msg *msg);
1624 };
1625 
1626 #ifdef CONFIG_PHL_P2PPS
1627 
1628 #define MAX_NOA_DESC 5
1629 #define NOAID_NONE 0xFF
1630 
1631 enum p2pps_trig_tag {
1632 	P2PPS_TRIG_GO = 0,
1633 	P2PPS_TRIG_GC = 1,
1634 	P2PPS_TRIG_GC_255 = 2,
1635 	P2PPS_TRIG_MCC = 3,
1636 	P2PPS_TRIG_2G_SCC_1AP_1STA_BT = 4,
1637 	P2PPS_TRIG_MAX = MAX_NOA_DESC
1638 };
1639 
1640 struct rtw_phl_noa_desc {
1641 	u8 enable; /*false=disable, true=enable*/
1642 	struct rtw_wifi_role_t *w_role;
1643 	enum p2pps_trig_tag tag;
1644 	u32 start_t_h;
1645 	u32 start_t_l;
1646 	u32 interval;
1647 	u32 duration;
1648 	u8 count;
1649 	u8 noa_id; /*filed by phl noa module*/
1650 };
1651 
1652 struct rtw_phl_opps_desc {
1653 	u16 ctw;
1654 	u8 all_slep;
1655 };
1656 
1657 struct rtw_phl_tsf32_tog_rpt{
1658 	u8 band;
1659 	u8 port;
1660 	u8 valid;
1661 	u16 early;
1662 	u16 status;
1663 	u32 tsf_l;
1664 	u32 tsf_h;
1665 };
1666 
1667 struct rtw_phl_p2pps_ops {
1668 	void *priv; /* ops private, define by core layer*/
1669 	void (*tsf32_tog_update_noa)(void *priv, struct rtw_wifi_role_t *w_role,
1670 					struct rtw_phl_tsf32_tog_rpt *rpt);
1671 	void (*tsf32_tog_update_single_noa)(void *priv,
1672 					struct rtw_wifi_role_t *w_role,
1673 					struct rtw_phl_noa_desc *desc);
1674 };
1675 
1676 
1677 #endif
1678 
1679 struct rtw_wifi_role_t {
1680 	struct rtw_phl_com_t *phl_com;/*point to phl_com*/
1681 	#ifdef RTW_WKARD_ROLE_TYPE
1682 	enum role_type real_type;
1683 	#endif /* RTW_WKARD_ROLE_TYPE */
1684 	enum role_type type;/*will mapping to net type*/
1685 	enum role_type target_type;
1686 	#ifdef RTW_WKARD_PHL_NTFY_MEDIA_STS
1687 	bool is_gc;
1688 	#endif
1689 	enum mlme_state mstate;
1690 	bool active;
1691 	enum wr_status status;
1692 	u8 id;/* recode role_idx in phl_com */
1693 	u8 hw_wmm; /*HW EDCA - wmm0 or wmm1*/
1694 	#ifdef RTW_WKARD_HW_WMM_ALLOCATE
1695 	_os_atomic hw_wmm0_ref_cnt;
1696 	#endif
1697 	u8 mac_addr[MAC_ALEN];
1698 	u8 hw_band; /*MAC Band0 or Band1*/
1699 	u8 hw_port; /*MAC HW Port*/
1700 	/*
1701 	 * final protocol capability of role from intersection of
1702 	 * sw role cap, sw protocol cap and hw protocol cap
1703 	 */
1704 	struct protocol_cap_t proto_role_cap;
1705 
1706 	/*
1707 	 * final capability of role from intersection of
1708 	 * sw role cap, final phy cap and final dev cap
1709 	 */
1710 	struct role_cap_t cap;
1711 
1712 	/*#ifdef CONFIG_AP*/
1713 #ifdef RTW_PHL_BCN
1714 	struct rtw_bcn_info_cmn bcn_cmn; //todo: ieee mbssid case & multi-bcn (in one iface) case
1715 	u8 hw_mbssid;
1716 #endif
1717 	u8 dtim_period;
1718 	u8 mbid_num;
1719 	u32 hiq_win;
1720 	/*#endif CONFIG_AP*/
1721 
1722 	struct rtw_chan_def chandef;
1723 	struct rtw_chan_ctx *chanctx;/*point to chanctx*/
1724 
1725 	struct phl_queue assoc_sta_queue;
1726 
1727 #ifdef CONFIG_PHL_TWT
1728 	struct rtw_phl_twt_setup_info twt_setup_info;
1729 #endif /* CONFIG_PHL_TWT */
1730 
1731 #ifdef CONFIG_PHL_P2PPS
1732 	struct rtw_phl_noa_desc noa_desc[MAX_NOA_DESC];
1733 #endif
1734 
1735 	void *core_data; /* Track back to counter part in core layer */
1736 #ifdef RTW_WKARD_BFEE_SET_AID
1737 	u16 last_set_aid;
1738 #endif
1739 };
1740 
1741 #define TXTP_CALC_DIFF_MS 1000
1742 #define RXTP_CALC_DIFF_MS 1000
1743 
1744 #define	TX_ULTRA_LOW_TP_THRES_KBPS 100
1745 #define	RX_ULTRA_LOW_TP_THRES_KBPS 100
1746 #define	TX_LOW_TP_THRES_MBPS 2
1747 #define	RX_LOW_TP_THRES_MBPS 2
1748 #define	TX_MID_TP_THRES_MBPS  10
1749 #define	RX_MID_TP_THRES_MBPS  10
1750 #define	TX_HIGH_TP_THRES_MBPS  50
1751 #define	RX_HIGH_TP_THRES_MBPS  50
1752 
1753 
1754 enum rtw_tfc_lvl {
1755 	RTW_TFC_IDLE = 0,
1756 	RTW_TFC_ULTRA_LOW = 1,
1757 	RTW_TFC_LOW = 2,
1758 	RTW_TFC_MID = 3,
1759 	RTW_TFC_HIGH = 4,
1760 	RTW_TFC_LVL_MAX = 0xFF
1761 };
1762 
1763 enum rtw_tfc_sts {
1764 	TRAFFIC_CHANGED = BIT0,
1765 	TRAFFIC_INCREASE = BIT1,
1766 	TRAFFIC_DECREASE = BIT2,
1767 	TRAFFIC_STS_MAX = BIT7
1768 };
1769 
1770 struct rtw_traffic_t {
1771 	enum rtw_tfc_lvl lvl;
1772 	enum rtw_tfc_sts sts;
1773 };
1774 
1775 struct rtw_stats_tp {
1776 	u64 last_calc_bits;
1777 	u32 last_calc_time_ms;
1778 };
1779 /*statistic*/
1780 struct rtw_stats {
1781 	u64 tx_byte_uni;/*unicast tx byte*/
1782 	u64 rx_byte_uni;/*unicast rx byte*/
1783 	u64 tx_byte_total;
1784 	u64 rx_byte_total;
1785 	u32 tx_tp_kbits;
1786 	u32 rx_tp_kbits;
1787 	u16 tx_moving_average_tp; /* tx average MBps*/
1788 	u16 rx_moving_average_tp; /* rx average MBps*/
1789 	u32 last_tx_time_ms;
1790 	u32 last_rx_time_ms;
1791 	u32 txreq_num;
1792 	u32 rx_rate;
1793 	u32 rx_rate_nmr[RTW_DATA_RATE_HE_NSS4_MCS11 +1];
1794 	u64 ser_event[8]; /* RTW_PHL_SER_MAX */
1795 	struct rtw_stats_tp txtp;
1796 	struct rtw_stats_tp rxtp;
1797 	struct rtw_traffic_t tx_traffic;
1798 	struct rtw_traffic_t rx_traffic;
1799 	u32 rx_tf_cnt; /* rx trigger frame number (accumulated, only reset in disconnect) */
1800 	u32 pre_rx_tf_cnt; /* last record rx trigger frame number from BB */
1801 };
1802 enum sta_chg_id {
1803 	STA_CHG_BW,
1804 	STA_CHG_NSS,
1805 	STA_CHG_RAMASK,
1806 	STA_CHG_SEC_MODE,
1807 	STA_CHG_MBSSID,
1808 	STA_CHG_RA_GILTF,
1809 	STA_CHG_MAX
1810 };
1811 
1812 enum phl_upd_mode {
1813 	PHL_UPD_ROLE_CREATE,
1814 	PHL_UPD_ROLE_REMOVE,
1815 	PHL_UPD_ROLE_TYPE_CHANGE,
1816 	PHL_UPD_ROLE_INFO_CHANGE,
1817 	PHL_UPD_STA_INFO_CHANGE,
1818 	PHL_UPD_STA_CON_DISCONN,
1819 	PHL_UPD_ROLE_MAX
1820 };
1821 
1822 #ifdef CONFIG_PHL_TXSC
1823 #define PHL_TXSC_ENTRY_NUM 8
1824 #define MAX_WD_SIZE	128
1825 
1826 struct phl_txsc_entry {
1827 	bool txsc_wd_cached;
1828 	u8 txsc_wd_cache[MAX_WD_SIZE];
1829 	u8 txsc_wd_len;
1830 	u32 txsc_cache_hit;
1831 };
1832 #endif
1833 
1834 struct rtw_hal_stainfo_t;
1835 struct rtw_phl_stainfo_t {
1836 	_os_list list;
1837 	struct rtw_wifi_role_t *wrole;
1838 	bool active;
1839 	u16 aid;
1840 	u16 macid;
1841 	u8 mac_addr[MAC_ALEN];
1842 
1843 	struct rtw_chan_def chandef;
1844 	struct rtw_stats stats;
1845 	enum wlan_mode wmode;
1846 
1847 	/*mlme protocol or MAC related CAP*/
1848 	u8 bcn_hit_cond;
1849 	u8 hit_rule;
1850 	u8 tf_trs;
1851 	u8 tgt_ind;
1852 	u8 frm_tgt_ind;
1853 	u8 addr_sel;
1854 	u8 addr_msk;
1855 
1856 	/* rx agg */
1857 	struct phl_tid_ampdu_rx *tid_rx[RTW_MAX_TID_NUM]; /* TID_MAX_NUM */
1858 	_os_lock tid_rx_lock;               /* guarding @tid_rx */
1859 	_os_event comp_sync;     /* reorder timer completion event */
1860 	_os_timer reorder_timer; /* reorder timer for all @tid_rx of the
1861 	                          * stainfo */
1862 	/* TODO: add missing part */
1863 
1864 	/*mlme protocol or PHY related CAP*/
1865 	struct protocol_cap_t asoc_cap;
1866 	enum rtw_protect_mode protect;
1867 
1868 	/*security related*/
1869 	u8 wapi;
1870 	u8 sec_mode;
1871 
1872 	/*
1873 	 * STA powersave, those could be implemented as bit flags but there's no
1874 	 * corresponding atomic bit operations available on Windows.
1875 	 */
1876 	_os_atomic ps_sta;      /* the sta is in PS mode or not */
1877 
1878 	struct rtw_hal_stainfo_t *hal_sta;
1879 
1880 #ifdef CONFIG_PHL_TXSC
1881 	struct phl_txsc_entry phl_txsc[PHL_TXSC_ENTRY_NUM];
1882 #endif
1883 	struct rtw_rx_bcn_info bcn_i;
1884 	void *core_data; /* Track back to counter part in core layer */
1885 };
1886 
1887 
1888 
1889 
1890 #define WL_FUNC_P2P		BIT0
1891 #define WL_FUNC_MIRACAST	BIT1
1892 #define WL_FUNC_TDLS		BIT2
1893 #define WL_FUNC_FTM		BIT3
1894 #define WL_FUNC_BIT_NUM	4
1895 
1896 
1897 /* HW MAC capability*/
1898 #define HW_SUP_DBCC			BIT0
1899 #define HW_SUP_AMSDU			BIT1
1900 #define HW_SUP_TCP_TX_CHKSUM		BIT2
1901 #define HW_SUP_TCP_RX_CHKSUM		BIT3
1902 #define HW_SUP_TXPKT_CONVR		BIT4
1903 #define HW_SUP_RXPKT_CONVR		BIT5
1904 #define HW_SUP_MULTI_BSSID		BIT6
1905 #define HW_SUP_OFDMA			BIT7
1906 #define HW_SUP_CHAN_INFO		BIT8
1907 #define HW_SUP_TSSI			BIT9
1908 #define HW_SUP_TANK_K			BIT10
1909 
1910 /*BUS Section CAP */
1911 #define HW_SUP_PCIE_PLFH		BIT20	/*payload from host*/
1912 #define HW_SUP_USB_MULTI_FUN		BIT21
1913 #define HW_SUP_SDIO_MULTI_FUN		BIT22
1914 
1915 /* Beamform CAP */
1916 #define HW_CAP_BF_NON_SUPPORT 0
1917 #define HW_CAP_BFEE_HT_SU BIT(0)
1918 #define HW_CAP_BFER_HT_SU BIT(1)
1919 #define HW_CAP_BFEE_VHT_SU BIT(2)
1920 #define HW_CAP_BFER_VHT_SU BIT(3)
1921 #define HW_CAP_BFEE_VHT_MU BIT(4)
1922 #define HW_CAP_BFER_VHT_MU BIT(5)
1923 #define HW_CAP_BFEE_HE_SU BIT(6)
1924 #define HW_CAP_BFER_HE_SU BIT(7)
1925 #define HW_CAP_BFEE_HE_MU BIT(8)
1926 #define HW_CAP_BFER_HE_MU BIT(9)
1927 #define HW_CAP_HE_NON_TB_CQI BIT(10)
1928 #define HW_CAP_HE_TB_CQI BIT(11)
1929 
1930 #define RTW_HW_CAP_ULRU_AUTO 0
1931 #define RTW_HW_CAP_ULRU_DISABLE 1
1932 #define RTW_HW_CAP_ULRU_ENABLE 2
1933 
1934 /* STBC CAP */
1935 #define HW_CAP_STBC_HT_TX BIT(0)
1936 #define HW_CAP_STBC_VHT_TX BIT(1)
1937 #define HW_CAP_STBC_HE_TX BIT(2)
1938 #define HW_CAP_STBC_HE_TX_GT_80M BIT(3)
1939 #define HW_CAP_STBC_HT_RX BIT(4)
1940 #define HW_CAP_STBC_VHT_RX BIT(5)
1941 #define HW_CAP_STBC_HE_RX BIT(6)
1942 #define HW_CAP_STBC_HE_RX_GT_80M BIT(7)
1943 
1944 struct hal_spec_t {
1945 	char *ic_name;
1946 	u16 macid_num;
1947 
1948 	u8 sec_cam_ent_num;
1949 	u8 sec_cap;
1950 	u8 wow_cap;
1951 
1952 	u8 rfpath_num_2g:4;	/* used for tx power index path */
1953 	u8 rfpath_num_5g:4;	/* used for tx power index path */
1954 	u8 rf_reg_path_num;
1955 	u8 max_tx_cnt;
1956 
1957 	u8 band_cap;	/* value of BAND_CAP_XXX */
1958 	u8 bw_cap;	/* value of BW_CAP_XXX */
1959 	u8 port_num;
1960 	u8 wmm_num;
1961 	u8 proto_cap;	/* value of PROTO_CAP_XXX */
1962 	u8 wl_func;	/* value of WL_FUNC_XXX */
1963 
1964 	/********* xmit ************/
1965 
1966 
1967 	/********* recv ************/
1968 	u8 rx_bd_info_sz;
1969 
1970 	u16 rx_tag[2];
1971 	#ifdef CONFIG_USB_HCI
1972 	u8 max_bulkin_num;
1973 	u8 max_bulkout_num;
1974 	#endif
1975 	#ifdef CONFIG_PCI_HCI
1976 	u16 txbd_multi_tag;
1977 	u8 txbd_upd_lmt;
1978 	#ifdef RTW_WKARD_BUSCAP_IN_HALSPEC
1979 	u8 phyaddr_num;
1980 	#endif
1981 	#endif
1982 	u8 cts2_thres_en;
1983 	u16 cts2_thres;
1984 	/********* beamformer ************/
1985 	u8 max_csi_buf_su_nr;
1986 	u8 max_csi_buf_mu_nr;
1987 	u8 max_bf_ent_nr;
1988 	u8 max_su_sta_nr;
1989 	u8 max_mu_sta_nr;
1990 
1991 };
1992 
1993 #define phl_get_hci_type(_phlcom) (_phlcom->hci_type)
1994 #define phl_get_ic_spec(_phlcom) (&_phlcom->hal_spec)
1995 #define phl_get_fw_buf(_phlcom) (_phlcom->fw_info.ram_buff)
1996 #define phl_get_fw_size(_phlcom) (_phlcom->fw_info.ram_size)
1997 
1998 enum rtw_drv_mode {
1999 	RTW_DRV_MODE_NORMAL = 0,
2000 	RTW_DRV_MODE_EQC = 1,
2001 	RTW_DRV_MODE_HIGH_THERMAL = 2,
2002 
2003 	/* 11~20 for MP submodule section*/
2004 	RTW_DRV_MODE_MP_SMDL_START = 11,
2005 	RTW_DRV_MODE_MP = 11,
2006 	RTW_DRV_MODE_HOMOLOGATION = 12,
2007 	RTW_DRV_MODE_MP_SMDL_END = 20,
2008 
2009 	/* 21~30 for FPGA submodule section*/
2010 	RTW_DRV_MODE_FPGA_SMDL_START = 21,
2011 	RTW_DRV_MODE_FPGA_SMDL_END = 30,
2012 
2013 	/* 31~60 for VERIFY submodule section*/
2014 	RTW_DRV_MODE_VERIFY_SMDL_START = 31,
2015 	RTW_DRV_MODE_VERIFY_SMDL_END = 60,
2016 
2017 	/* 61~80 for TOOL submodule section*/
2018 	RTW_DRV_MODE_TOOL_SMDL_START = 61,
2019 	RTW_DRV_MODE_TOOL_SMDL_END = 80,
2020 
2021 	/* Fixed Max Value*/
2022 	RTW_DRV_MODE_MAX = 255
2023 };
2024 
2025 struct rtw_evt_info_t {
2026 	_os_lock evt_lock;
2027 	enum rtw_phl_evt evt_bitmap;
2028 };
2029 
2030 // WiFi FW
2031 struct rtw_fw_info_t {
2032 	u8 fw_en;
2033 	u8 fw_src;
2034 	u8 fw_type;
2035 	u8 dlram_en;
2036 	u8 dlrom_en;
2037 	u8 *rom_buff;
2038 	u32 rom_addr;
2039 	u32 rom_size;
2040 	char rom_path[256];
2041 	u8 *ram_buff;
2042 	u32 ram_size;
2043 	char ram_path[256];
2044 	u8 *buf;
2045 	u32 buf_size;
2046 	u8 *wow_buf;
2047 	u32 wow_buf_size;
2048 	u8 *sym_buf;
2049 	u32 sym_buf_size;
2050 };
2051 
2052 enum rtw_fw_status {
2053 	RTW_FW_STATUS_OK,
2054 	RTW_FW_STATUS_NOFW,
2055 	RTW_FW_STATUS_ASSERT,
2056 	RTW_FW_STATUS_EXCEP,
2057 	RTW_FW_STATUS_RXI300,
2058 	RTW_FW_STATUS_HANG
2059 };
2060 
2061 #ifdef CONFIG_PHL_DFS
2062 enum dfs_regd_t {
2063 	DFS_REGD_UNKNOWN	= 0,
2064 	DFS_REGD_FCC	= 1,
2065 	DFS_REGD_JAP	= 2,
2066 	DFS_REGD_ETSI	= 3,
2067 };
2068 struct rtw_dfs_t {
2069 	u8 region_domain;
2070 	bool dfs_enabled;
2071 };
2072 #endif
2073 
2074 #ifdef CONFIG_PHL_CHANNEL_INFO
2075 
2076 #define CHAN_INFO_MAX_SIZE 65535
2077 #define MAX_CHAN_INFO_PKT_KEEP 2
2078 #define CHAN_INFO_PKT_TOTAL MAX_CHAN_INFO_PKT_KEEP + 1
2079 
2080 struct csi_header_t {
2081 	u8 mac_addr[6];			/* mdata: u8 ta[6]? */
2082 	u32 hw_assigned_timestamp;	/* mdata: u32 freerun_cnt */
2083 	u8 channel;			/* Drv define */
2084 	u8 bandwidth;			/* mdata: u8 bw */
2085 	u16 rx_data_rate;		/* mdata: u16 rx_rate */
2086 	u8 nc;				/* ch_rpt_hdr_info */
2087 	u8 nr;				/* ch_rpt_hdr_info */
2088 	u16 num_sub_carrier;		/* Drv define*/
2089 	u8 num_bit_per_tone;		/* Drv define per I/Q */
2090 	u8 avg_idle_noise_pwr;		/* ch_rpt_hdr_info */
2091 	u8 evm[2];			/* ch_rpt_hdr_info */
2092 	u8 rssi[2];			/* phy_info_rpt */
2093 	u32 csi_data_length;		/* ch_rpt_hdr_info */
2094 	u8 rxsc;			/* phy_info_rpt */
2095 	u8 ch_matrix_report;		/* mdata: u8 get_ch_info */
2096 	u8 csi_valid;			/* ch_rpt_hdr_info */
2097 };
2098 
2099 struct chan_info_t {
2100 	_os_list list;
2101 	u8* chan_info_buffer;
2102 	u32 length;
2103 	struct csi_header_t csi_header;
2104 };
2105 
2106 struct rx_chan_info_pool {
2107 	struct chan_info_t channl_info_pkt[CHAN_INFO_PKT_TOTAL];
2108 	_os_list idle;
2109 	_os_list busy;
2110 	_os_lock idle_lock;	/* spinlock */
2111 	_os_lock busy_lock;	/* spinlock */
2112 	u32 idle_cnt;
2113 	u32 busy_cnt;
2114 };
2115 
2116 #endif /* CONFIG_PHL_CHANNEL_INFO */
2117 
2118 #ifdef CONFIG_MCC_SUPPORT
2119 #define BT_SEG_NUM 2
2120 #define SLOT_NUM 4
2121 #define MIN_TDMRA_SLOT_NUM 2
2122 #define NONSPECIFIC_SETTING 0xff
2123 
2124 /*Export to core layer. Phl get the judgement of slot mode*/
2125 enum rtw_phl_mcc_coex_mode {
2126 	RTW_PHL_MCC_COEX_MODE_NONE = 0,
2127 	RTW_PHL_MCC_COEX_MODE_BT_MASTER,
2128 	RTW_PHL_MCC_COEX_MODE_WIFI_MASTER,
2129 	RTW_PHL_MCC_COEX_MODE_BT_WIFI_BALANCE
2130 };
2131 
2132 enum rtw_phl_tdmra_wmode {
2133 	RTW_PHL_TDMRA_WMODE_NONE = 0,
2134 	RTW_PHL_TDMRA_AP_CLIENT_WMODE,
2135 	RTW_PHL_TDMRA_2CLIENTS_WMODE,
2136 	RTW_PHL_TDMRA_AP_WMODE,
2137 	RTW_PHL_TDMRA_UNKNOWN_WMODE
2138 };
2139 
2140 enum rtw_phl_mcc_dbg_type {
2141 	MCC_DBG_NONE = 0,
2142 	MCC_DBG_STATE,
2143 	MCC_DBG_OP_MODE,
2144 	MCC_DBG_COEX_MODE,
2145 	MCC_DBG_BT_INFO,
2146 	MCC_DBG_EN_INFO
2147 };
2148 
2149 enum rtw_phl_mcc_state {
2150 	MCC_NONE = 0,
2151 	MCC_CFG_EN_INFO,
2152 	MCC_TRIGGER_FW_EN,
2153 	MCC_FW_EN_FAIL,
2154 	MCC_RUNING,
2155 	MCC_TRIGGER_FW_DIS,
2156 	MCC_FW_DIS_FAIL,
2157 	MCC_STOP
2158 };
2159 
2160 enum rtw_phl_mcc_dur_lim_tag {
2161 	RTW_MCC_DUR_LIM_NONE = 0,
2162 	RTW_MCC_DUR_LIM_NOA
2163 };
2164 
2165 /*Export to core layer and hal layyer. Phl get the c2h report mode and config to halmac*/
2166 enum rtw_phl_mcc_rpt {
2167 	RTW_MCC_RPT_OFF = 0,
2168 	RTW_MCC_RPT_FAIL_ONLY,
2169 	RTW_MCC_RPT_ALL
2170 };
2171 
2172 /*Export to core layer. Phl get switch ch setting of role from core layer*/
2173 struct rtw_phl_mcc_setting_info {
2174 	struct rtw_wifi_role_t *wrole;
2175 	u8 role_map;/*the wifi role map in operating mcc */
2176 	u8 tx_null_early;
2177 	u16 dur; /*core specific duration in a period of 100 ms */
2178 	bool en_fw_mcc_log;
2179 	u8 fw_mcc_log_lv;/* fw mcc log level */
2180 };
2181 
2182 /*Export to core layer. Core get NOA info to update p2p beacon*/
2183 struct rtw_phl_mcc_noa {
2184 	struct rtw_wifi_role_t *wrole;
2185 	u32 start_t_h;
2186 	u32 start_t_l;
2187 	u16 dur;
2188 	u16 interval;
2189 	u8 cnt;
2190 };
2191 
2192 struct rtw_phl_mcc_ops {
2193 	void *priv; /* ops private, define by core layer*/
2194 	int (*mcc_update_noa)(void *priv, struct rtw_phl_mcc_noa *param);
2195 	int (*mcc_get_setting)(void *priv, struct rtw_phl_mcc_setting_info *param);
2196 };
2197 
2198 /*
2199  * Export to phl layer and hal layer.
2200  * Record the debug info.
2201 */
2202 struct rtw_phl_mcc_dbg_slot_info {
2203 	bool bt_role;
2204 	u16 dur;
2205 	u16 ch;
2206 	u16 macid;
2207 };
2208 
2209 struct rtw_phl_mcc_dbg_hal_info {
2210 	u8 slot_num;
2211 	struct rtw_phl_mcc_dbg_slot_info dbg_slot_i[SLOT_NUM];
2212 	bool btc_in_group;
2213 };
2214 
2215 struct rtw_phl_mcc_macid_bitmap {
2216 	u32 *bitmap;
2217 	u8 len;
2218 };
2219 
2220 struct rtw_phl_mcc_sync_tsf_info {
2221 	u8 sync_en;
2222 	u16 source;
2223 	u16 target;
2224 	u16 offset;
2225 };
2226 
2227 struct rtw_phl_mcc_dur_lim_info {
2228 	bool enable;
2229 	enum rtw_phl_mcc_dur_lim_tag tag;
2230 	u16 max_tob;
2231 	u16 max_toa;
2232 	u16 max_dur;
2233 };
2234 
2235 struct rtw_phl_mcc_dur_info {
2236 	u16 dur;
2237 	struct rtw_phl_mcc_dur_lim_info dur_limit;
2238 };
2239 
2240 struct rtw_phl_mcc_policy_info {
2241 	u8 c2h_rpt;
2242 	u8 tx_null_early;
2243 	u8 dis_tx_null;
2244 	u8 in_curr_ch;
2245 	u8 dis_sw_retry;
2246 	u8 sw_retry_count;
2247 	struct rtw_phl_mcc_dur_info dur_info;
2248 	u8 rfk_chk;
2249 	u8 protect_bcn;
2250 	u8 courtesy_en;
2251 	u8 courtesy_num;
2252 	u8 courtesy_target;
2253 };
2254 
2255 struct rtw_phl_mcc_role {
2256 	struct rtw_wifi_role_t *wrole;
2257 	struct rtw_phl_mcc_macid_bitmap used_macid;
2258 	struct rtw_chan_def *chandef;
2259 	struct rtw_phl_mcc_policy_info policy;
2260 	u16 macid;
2261 	u16 bcn_intvl;
2262 	bool bt_role;
2263 	u8 group;
2264 };
2265 
2266 /*
2267  * @c_en: Enable courtesy function
2268  * @c_num: the time slot of src_role replace by tgt_role
2269  */
2270 struct rtw_phl_mcc_courtesy {
2271 	bool c_en;
2272 	bool c_num;
2273 	struct rtw_phl_mcc_role *src_role;
2274 	struct rtw_phl_mcc_role *tgt_role;
2275 };
2276 
2277 /*
2278  * @slot: duration, unit: TU
2279  * @bt_role: True: bt role, False: Wifi role
2280  * @mrole: mcc role info for Wifi Role
2281  */
2282 struct rtw_phl_mcc_slot_info {
2283 	u16 slot;
2284 	bool bt_role;
2285 	struct rtw_phl_mcc_role *mrole;
2286 };
2287 
2288 /*
2289  * @slot_num: total slot num(Wifi+BT)
2290  * @bt_slot_num: total BT slot num
2291  * |      Dur1      |     Dur2      |
2292  * 	bcn              bcn
2293  * |tob_r | toa_r|tob_a | toa_a|
2294  */
2295 struct rtw_phl_mcc_pattern {
2296 	u8 slot_num;
2297 	u8 bt_slot_num;
2298 	struct rtw_phl_mcc_role *role_ref;
2299 	struct rtw_phl_mcc_role *role_ano;
2300 	s16 tob_r;
2301 	s16 toa_r;
2302 	s16 tob_a;
2303 	s16 toa_a;
2304 	u16 bcns_offset;
2305 
2306 	u16 calc_fail;
2307 	/**
2308 	* |tob_r|toa_r|
2309 	* -----------<d_r_d_a_spacing>-----------
2310 	*                                               |tob_a|toa_a|
2311 	**/
2312 	u16 d_r_d_a_spacing_max;
2313 	struct rtw_phl_mcc_courtesy courtesy_i;
2314 	/*record slot order for X wifi slot + Y bt slot*/
2315 	struct rtw_phl_mcc_slot_info slot_order[SLOT_NUM];
2316 };
2317 
2318 /*
2319  * Enable info for mcc
2320  * @ref_role_idx: the index of reference role
2321  * @mrole_map: use mcc role num
2322  * @mrole_num: use mcc role num
2323  * @group: assigned by halmac mcc, the group resource of fw feture, phl layer ignore it
2324  *	fw mcc can handle differenec slot pattern, and the group is the id of slot pattern.
2325  * @tsf_high, tsf_low: Start TSF
2326  * @tsf_high_l, tsf_low_l: Limitation of Start TSF
2327  * @dbg_hal_i: Debug info for hal mcc
2328  */
2329 struct rtw_phl_mcc_en_info {
2330 	struct rtw_phl_mcc_role mcc_role[MCC_ROLE_NUM];
2331 	struct rtw_phl_mcc_sync_tsf_info sync_tsf_info;
2332 	struct rtw_phl_mcc_pattern m_pattern;
2333 	u8 ref_role_idx;
2334 	u8 mrole_map;
2335 	u8 mrole_num;
2336 	u8 group;
2337 	u16 mcc_intvl;
2338 	u32 tsf_high;
2339 	u32 tsf_low;
2340 	u32 tsf_high_l;
2341 	u32 tsf_low_l;
2342 	struct rtw_phl_mcc_dbg_hal_info dbg_hal_i;
2343 };
2344 
2345 /*
2346  * Bt info
2347  * @bt_dur: bt slot
2348  * @bt_seg: segment bt slot
2349  * @bt_seg_num: segment num
2350  * @add_bt_role: if add_bt_role = true, we need to add bt slot to fw
2351  */
2352 struct rtw_phl_mcc_bt_info {
2353 	u16 bt_dur;
2354 	u16 bt_seg[BT_SEG_NUM];
2355 	u8 bt_seg_num;
2356 	bool add_bt_role;
2357 };
2358 
2359 enum rtw_phl_mcc_chk_inprocess_type {
2360 	RTW_PHL_MCC_CHK_INPROGRESS = 0,
2361 	RTW_PHL_MCC_CHK_INPROGRESS_SINGLE_CH,
2362 	RTW_PHL_MCC_CHK_INPROGRESS_MULTI_CH,
2363 	RTW_PHL_MCC_CHK_MAX,
2364 };
2365 
2366 enum mr_coex_trigger {
2367 	MR_COEX_TRIG_BY_BT,
2368 	MR_COEX_TRIG_BY_LINKING,
2369 	MR_COEX_TRIG_BY_DIS_LINKING,
2370 	MR_COEX_TRIG_BY_CHG_SLOT,
2371 	MR_COEX_TRIG_BY_SCAN,
2372 	MR_COEX_TRIG_BY_ECSA,
2373 	MR_COEX_TRIG_BY_CHG_OP_CHDEF,
2374 	MR_COEX_TRIG_MAX,
2375 };
2376 
2377 #endif /* CONFIG_MCC_SUPPORT */
2378 
2379 /*multi-roles control components*/
2380 enum mr_op_mode {
2381 	MR_OP_NON,
2382 	MR_OP_SCC,
2383 	MR_OP_MCC,
2384 	MR_OP_MAX,
2385 };
2386 
2387 enum mr_op_type {
2388 	MR_OP_TYPE_NONE,
2389 	MR_OP_TYPE_STATION_ONLY,
2390 	MR_OP_TYPE_AP_ONLY,
2391 	MR_OP_TYPE_STATION_AP,
2392 	MR_OP_TYPE_MAX,
2393 };
2394 
2395 struct mr_info {
2396 	u8 sta_num;
2397 	u8 ld_sta_num;
2398 	u8 lg_sta_num;		/* WIFI_STATION_STATE && WIFI_UNDER_LINKING */
2399 
2400 	u8 ap_num;
2401 	u8 ld_ap_num;	/*&& asoc_sta_count > 2*/
2402 	u8 monitor_num;
2403 
2404 	u8 p2p_device_num;
2405 	u8 p2p_gc_num;
2406 	u8 p2p_go_num;
2407 
2408 #ifdef CONFIG_PHL_TDLS
2409 	u8 ld_tdls_num;	/* phl_role->type == PHL_RTYPE_TDLS */
2410 #endif
2411 
2412 #if 0
2413 #ifdef CONFIG_AP_MODE
2414 	u8 starting_ap_num;	/*WIFI_FW_AP_STATE*/
2415 #endif
2416 	u8 adhoc_num;		/* (WIFI_ADHOC_STATE | WIFI_ADHOC_MASTER_STATE) && WIFI_ASOC_STATE */
2417 	u8 ld_adhoc_num;	/* (WIFI_ADHOC_STATE | WIFI_ADHOC_MASTER_STATE) && WIFI_ASOC_STATE && asoc_sta_count > 2 */
2418 #ifdef CONFIG_RTW_MESH
2419 	u8 mesh_num;		/* WIFI_MESH_STATE &&  WIFI_ASOC_STATE */
2420 	u8 ld_mesh_num;		/* WIFI_MESH_STATE &&  WIFI_ASOC_STATE && asoc_sta_count > 2 */
2421 #endif
2422 #endif
2423 };
2424 
2425 enum mr_coex_mode {
2426 	MR_COEX_MODE_NONE = 0,
2427 	MR_COEX_MODE_2GSCC_1AP_1STA_BTC = 1,
2428 	MR_COEX_MODE_TDMRA = 2
2429 };
2430 
2431 /*export to core layer*/
2432 struct mr_query_info {
2433 	struct mr_info cur_info;
2434 	enum mr_op_mode op_mode;
2435 	enum mr_op_type op_type;
2436 };
2437 
2438 struct hw_band_ctl_t {
2439 	_os_lock lock;
2440 	u8 id;
2441 	u8 port_map; /*used port_idx*/
2442 	u8 role_map; /*used role_idx*/
2443 	u8 wmm_map;
2444 	struct mr_info cur_info;
2445 	enum mr_op_mode op_mode;
2446 	enum mr_op_type op_type;
2447 	enum phl_hw_port tsf_sync_port;
2448 	struct phl_queue chan_ctx_queue;/*struct rtw_chan_ctx*/
2449 	enum mr_coex_mode coex_mode;
2450 #ifdef CONFIG_MCC_SUPPORT
2451 	void *mcc_info; /*struct phl_mcc_info*/
2452 #endif
2453 };
2454 
2455 #define MAX_BAND_NUM 2
2456 struct rtw_hal_com_t;
2457 
2458 #ifdef CONFIG_PHL_P2PPS
2459 struct rtw_phl_noa {
2460 	struct rtw_wifi_role_t *wrole;
2461 	enum p2pps_trig_tag tag;
2462 	u32 start_t_h;
2463 	u32 start_t_l;
2464 	u16 dur;
2465 	u8 cnt;
2466 	u16 interval;
2467 };
2468 #endif
2469 
2470 struct rtw_phl_mr_ops {
2471 	void *priv; /* ops private, define by core layer*/
2472 #ifdef CONFIG_PHL_P2PPS
2473 	int (*phl_mr_update_noa)(void *priv, struct rtw_phl_noa *param);
2474 #endif
2475 #ifdef CONFIG_MCC_SUPPORT
2476 	struct rtw_phl_mcc_ops *mcc_ops;
2477 #endif
2478 };
2479 
2480 struct mr_ctl_t {
2481 	struct rtw_hal_com_t *hal_com;
2482 	_os_lock lock;
2483 	struct hw_band_ctl_t band_ctrl[MAX_BAND_NUM];
2484 	struct phl_bk_module_ops bk_ops;
2485 	u8 role_map;
2486 	bool is_sb;
2487 	struct rtw_phl_mr_ops mr_ops;
2488 #ifdef CONFIG_MCC_SUPPORT
2489 	u8 init_mcc;
2490 	void *com_mcc;/*struct phl_com_mcc_info*/
2491 #endif
2492 };
2493 
2494 enum rtw_rssi_type {
2495 	RTW_RSSI_DATA_ACAM,
2496 	RTW_RSSI_DATA_ACAM_A1M,
2497 	RTW_RSSI_DATA_OTHER,
2498 	RTW_RSSI_CTRL_ACAM,
2499 	RTW_RSSI_CTRL_ACAM_A1M,
2500 	RTW_RSSI_CTRL_OTHER,
2501 	RTW_RSSI_MGNT_ACAM,
2502 	RTW_RSSI_MGNT_ACAM_A1M,
2503 	RTW_RSSI_MGNT_OTHER,
2504 	RTW_RSSI_UNKNOWN,
2505 	RTW_RSSI_TYPE_MAX
2506 };
2507 #define PHL_RSSI_MA_H 4 /*RSSI_MA_H*/
2508 #define PHL_MAX_RSSI 110
2509 #define PHL_RSSI_MAVG_NUM 16
2510 #define UPDATE_MA_RSSI(_RSSI, _TYPE, _VAL) \
2511 	do { \
2512 		u8 oldest_rssi = 0; \
2513 		if(_RSSI->ma_rssi_ele_idx[_TYPE] < PHL_RSSI_MAVG_NUM) { \
2514 			oldest_rssi = _RSSI->ma_rssi_ele[_TYPE][\
2515 					_RSSI->ma_rssi_ele_idx[_TYPE]]; \
2516 			_RSSI->ma_rssi_ele[_TYPE][_RSSI->ma_rssi_ele_idx[_TYPE]] = \
2517 				((_VAL > PHL_MAX_RSSI) ? PHL_MAX_RSSI : _VAL ); \
2518 		} else { \
2519 			_RSSI->ma_rssi_ele_idx[_TYPE] = 0; \
2520 			oldest_rssi = _RSSI->ma_rssi_ele[_TYPE][0]; \
2521 			_RSSI->ma_rssi_ele[_TYPE][0] = \
2522 				((_VAL > PHL_MAX_RSSI) ? PHL_MAX_RSSI : _VAL ); \
2523 		} \
2524 		_RSSI->ma_rssi_ele_sum[_TYPE] -= oldest_rssi;\
2525 		_RSSI->ma_rssi_ele_sum[_TYPE] += \
2526 			((_VAL > PHL_MAX_RSSI) ? PHL_MAX_RSSI : _VAL ); \
2527 		_RSSI->ma_rssi_ele_idx[_TYPE]++; \
2528 		if(_RSSI->ma_rssi_ele_cnt[_TYPE] < PHL_RSSI_MAVG_NUM) \
2529 			_RSSI->ma_rssi_ele_cnt[_TYPE]++; \
2530 		_RSSI->ma_rssi[_TYPE] = (u8)(_RSSI->ma_rssi_ele_sum[_TYPE] / \
2531 			_RSSI->ma_rssi_ele_cnt[_TYPE]);\
2532 	} while (0)
2533 
2534 #define PHL_TRANS_2_RSSI(X) (X >> 1)
2535 
2536 struct rtw_phl_rssi_stat {
2537 	_os_lock lock;
2538 	u8 ma_rssi_ele_idx[RTW_RSSI_TYPE_MAX];
2539 	u8 ma_rssi_ele_cnt[RTW_RSSI_TYPE_MAX]; /* maximum : PHL_RSSI_MAVG_NUM */
2540 	u8 ma_rssi_ele[RTW_RSSI_TYPE_MAX][PHL_RSSI_MAVG_NUM]; /* rssi element for moving average */
2541 	u32 ma_rssi_ele_sum[RTW_RSSI_TYPE_MAX];
2542 	u8 ma_rssi[RTW_RSSI_TYPE_MAX]; /* moving average : 0~PHL_MAX_RSSI (dBm = rssi - PHL_MAX_RSSI) */
2543 };
2544 
2545 #define PHL_MAX_PPDU_CNT 8
2546 #define PHL_MAX_PPDU_STA_NUM 4
2547 struct rtw_phl_ppdu_sts_sta_ent {
2548 	u8 vld;
2549 	/*u8 rssi;*/
2550 	u16 macid;
2551 };
2552 struct rtw_phl_ppdu_phy_info {
2553 	bool is_valid;
2554 	u8 rssi; /*signal power : 0 - PHL_MAX_RSSI, rssi dbm = PHL_MAX_RSSI - value*/
2555 	u8 rssi_path[RTW_PHL_MAX_RF_PATH];/*PATH A, PATH B ... PATH D*/
2556 	u8 ch_idx;
2557 	u8 tx_bf;
2558 	u8 frame_type; /* type + subtype */
2559 };
2560 #ifdef CONFIG_PHY_INFO_NTFY
2561 struct rtw_phl_ppdu_sts_ntfy {
2562 	bool vld;
2563 	u8 frame_type;
2564 	u8 src_mac_addr[MAC_ADDRESS_LENGTH];
2565 	struct rtw_phl_ppdu_phy_info phy_info;
2566 };
2567 #endif
2568 struct rtw_phl_ppdu_sts_ent {
2569 	/* from normal data */
2570 	u8 frame_type;
2571 	u8 addr_cam_vld;
2572 	u8 crc32;
2573 	u8 ppdu_type;
2574 	u16 rx_rate;
2575 	u8 src_mac_addr[MAC_ADDRESS_LENGTH];
2576 
2577 	/* from ppdu status */
2578 	bool valid;
2579 	bool phl_done;
2580 	u8 usr_num;
2581 	u32 freerun_cnt;
2582 	struct rtw_phl_ppdu_phy_info phy_info;
2583 	struct rtw_phl_ppdu_sts_sta_ent sta[PHL_MAX_PPDU_STA_NUM];
2584 #ifdef CONFIG_PHL_RX_PSTS_PER_PKT
2585 	/* for ppdu status per pkt */
2586 	struct phl_queue frames;
2587 #endif
2588 };
2589 struct rtw_phl_ppdu_sts_info {
2590 	struct rtw_phl_ppdu_sts_ent sts_ent[HW_BAND_MAX][PHL_MAX_PPDU_CNT];
2591 	u8 cur_rx_ppdu_cnt[HW_BAND_MAX];
2592 	bool en_ppdu_sts[HW_BAND_MAX];
2593 	bool latest_rx_is_psts[HW_BAND_MAX];
2594 #ifdef CONFIG_PHL_RX_PSTS_PER_PKT
2595 	bool en_psts_per_pkt;
2596 	bool psts_ampdu;
2597 #define RTW_PHL_PSTS_FLTR_MGNT BIT(RTW_FRAME_TYPE_MGNT)
2598 #define RTW_PHL_PSTS_FLTR_CTRL BIT(RTW_FRAME_TYPE_CTRL)
2599 #define RTW_PHL_PSTS_FLTR_DATA BIT(RTW_FRAME_TYPE_DATA)
2600 #define RTW_PHL_PSTS_FLTR_EXT_RSVD BIT(RTW_FRAME_TYPE_EXT_RSVD)
2601 	u8 ppdu_sts_filter;
2602 	u8 en_fake_psts;
2603 	u8 cur_ppdu_cnt[HW_BAND_MAX];
2604 #endif
2605 #ifdef CONFIG_PHY_INFO_NTFY
2606 #define MAX_PSTS_MSG_AGGR_NUM 10
2607 	struct rtw_phl_ppdu_sts_ntfy msg_aggr_buf[MAX_PSTS_MSG_AGGR_NUM];
2608 	u8 msg_aggr_cnt;
2609 #endif
2610 };
2611 
2612 struct rtw_phl_gid_pos_tbl {
2613 #define RTW_VHT_GID_MGNT_FRAME_GID_SZ 8
2614 #define RTW_VHT_GID_MGNT_FRAME_POS_SZ 16
2615 	u8 gid_vld[RTW_VHT_GID_MGNT_FRAME_GID_SZ]; /* from 0 - 63 */
2616 	u8 pos[RTW_VHT_GID_MGNT_FRAME_POS_SZ]; /* 0 - 63, per 2 bit*/
2617 };
2618 
2619 
2620 struct rtw_iot_t {
2621 	u32 id;
2622 };
2623 
2624 #ifdef CONFIG_PHL_THERMAL_PROTECT
2625 enum phl_thermal_protect_action{
2626 	PHL_THERMAL_PROTECT_ACTION_NONE = 0,
2627 	PHL_THERMAL_PROTECT_ACTION_LEVEL1 = 1,
2628 	PHL_THERMAL_PROTECT_ACTION_LEVEL2 = 2,
2629 };
2630 #endif
2631 
2632 struct rtw_phl_evt_ops;
2633 struct rtw_phl_com_t {
2634 	struct rtw_wifi_role_t wifi_roles[MAX_WIFI_ROLE_NUMBER];
2635 	struct mr_ctl_t mr_ctrl; /*multi wifi_role control module*/
2636 	struct rtw_phl_evt_ops evt_ops;
2637 	enum rtw_hci_type hci_type;
2638 	enum rtw_drv_mode drv_mode;/*normal or mp mode*/
2639 	enum rtw_dev_state dev_state;
2640 
2641 	struct hal_spec_t hal_spec;
2642 
2643 	struct role_sw_cap_t role_sw_cap; /* SW control capability of role for any purpose */
2644 	struct protocol_cap_t proto_sw_cap[2]; /* SW control wifi protocol capability for any purpose */
2645 	struct phy_sw_cap_t phy_sw_cap[2]; /* SW control phy capability for any purpose */
2646 	struct phy_cap_t phy_cap[2]; /* final capability of phy (intersection of sw/hw) */
2647 
2648 	struct dev_cap_t dev_sw_cap;
2649 	struct dev_cap_t dev_cap; /* final capability of device (intersection of sw/hw) */
2650 
2651 	struct bus_sw_cap_t bus_sw_cap; /* SW controlled bus capability */
2652 
2653 	struct rtw_fw_info_t fw_info;
2654 	struct rtw_evt_info_t evt_info;
2655 	struct rtw_stats phl_stats;
2656 	#ifdef CONFIG_PHL_DFS
2657 	struct rtw_dfs_t dfs_info;
2658 	#endif
2659 	struct rtw_iot_t id;
2660 	/* Flags to control/check RX packets */
2661 	bool append_fcs;
2662 	bool accept_icv_err;
2663 
2664 	u8 rf_type; /*enum rf_type , is RF_PATH - GET_HAL_RFPATH*/
2665 	u8 rf_path_num; /*GET_HAL_RFPATH_NUM*/
2666 	u8 regulation;  /*regulation*/
2667 	u8 edcca_mode;
2668 
2669 #ifdef CONFIG_PHL_CHANNEL_INFO
2670 	struct rx_chan_info_pool *chan_info_pool;
2671 	struct chan_info_t *chan_info; /* Handle channel info packet */
2672 #endif /* CONFIG_PHL_CHANNEL_INFO */
2673 	void *p2pps_info;
2674 
2675 	struct rtw_phl_ppdu_sts_info ppdu_sts_info;
2676 	struct rtw_phl_rssi_stat rssi_stat;
2677 #ifdef CONFIG_PHL_THERMAL_PROTECT
2678 	enum phl_thermal_protect_action thermal_protect_action;
2679 #endif
2680 	void *test_mgnt;
2681 
2682 	void *phl_priv; /* pointer to phl_info */
2683 	void *drv_priv;
2684 #ifdef RTW_WKARD_BFEE_SET_AID
2685 	u8 is_in_lps;
2686 #endif
2687 };
2688 
2689 struct phl_sec_param_h {
2690 	u8 keyid;
2691 	u8 enc_type;
2692 	u8 key_type;
2693 	u8 key_len;
2694 	u8 spp;
2695 };
2696 
2697 #define PHL_MAX_AGG_WSIZE 32
2698 
2699 struct mp_usr_sw_tx_gen_in {
2700 	u32 data_rate : 9;
2701 	u32 mcs : 6;
2702 	u32 mpdu_len : 14;
2703 	u32 n_mpdu : 9;
2704 	u32 fec : 1;
2705 	u32 dcm : 1;
2706 	u32 rsvd0 : 1;
2707 	u32 aid : 12;
2708 	u32 scrambler_seed : 8; // rand (1~255)
2709 	u32 random_init_seed : 8; // rand (1~255)
2710 	u32 rsvd1 : 4;
2711 	u32 apep : 22;
2712 	u32 ru_alloc : 8;
2713 	u32 rsvd2 : 2;
2714 	u32 nss : 4;
2715 	u32 txbf : 1;
2716 	u32 pwr_boost_db : 5;
2717 	u32 rsvd3 : 22;
2718 };
2719 
2720 
2721 struct mp_sw_tx_param_t {
2722 	u32 dbw : 2; //0:BW20, 1:BW40, 2:BW80, 3:BW160/BW80+80
2723 	u32 source_gen_mode : 2;
2724 	u32 locked_clk : 1;
2725 	u32 dyn_bw : 1;
2726 	u32 ndp_en : 1;
2727 	u32 long_preamble_en : 1; //bmode
2728 	u32 stbc : 1;
2729 	u32 gi : 2; //0:0.4,1:0.8,2:1.6,3:3.2
2730 	u32 tb_l_len : 12;
2731 	u32 tb_ru_tot_sts_max : 3;
2732 	u32 vht_txop_not_allowed : 1;
2733 	u32 tb_disam : 1;
2734 	u32 doppler : 2;
2735 	u32 he_ltf_type : 2;//0:1x,1:2x,2:4x
2736 
2737 	u32 ht_l_len : 12;
2738 	u32 preamble_puncture : 1;
2739 	u32 he_mcs_sigb : 3;//0~5
2740 	u32 he_dcm_sigb : 1;
2741 	u32 he_sigb_compress_en : 1;
2742 	u32 max_tx_time_0p4us : 14;
2743 
2744 
2745 	u32 ul_flag : 1;
2746 	u32 tb_ldpc_extra : 1;
2747 	u32 bss_color : 6;
2748 	u32 sr : 4;
2749 	u32 beamchange_en : 1;
2750 	u32 he_er_u106ru_en : 1;
2751 	u32 ul_srp1 : 4;
2752 	u32 ul_srp2 : 4;
2753 	u32 ul_srp3 : 4;
2754 	u32 ul_srp4 : 4;
2755 	u32 mode : 2;
2756 
2757 	u32 group_id : 6;
2758 	u32 ppdu_type : 4;//0: bmode,1:Legacy,2:HT_MF,3:HT_GF,4:VHT,5:HE_SU,6:HE_ER_SU,7:HE_MU,8:HE_TB
2759 	u32 txop : 7;
2760 	u32 tb_strt_sts : 3;
2761 	u32 tb_pre_fec_padding_factor : 2;
2762 	u32 cbw : 2;
2763 	u32 txsc : 4;
2764 	u32 tb_mumimo_mode_en : 1;
2765 	u32 rsvd1 : 3;
2766 
2767 	u8 nominal_t_pe : 2; // def = 2
2768 	u8 ness : 2; // def = 0
2769 	u8 rsvd2 : 4;
2770 
2771 	u8 n_user;
2772 	u16 tb_rsvd : 9;//def = 0
2773 	u16 rsvd3 : 7;
2774 
2775 	struct mp_usr_sw_tx_gen_in usr[4];
2776 };
2777 
2778 struct mp_usr_plcp_gen_in {
2779 	u32 mcs : 6;
2780 	u32 mpdu_len : 14;
2781 	u32 n_mpdu : 9;
2782 	u32 fec : 1;
2783 	u32 dcm : 1;
2784 	u32 rsvd0 : 1;
2785 	u32 aid : 12;
2786 	u32 scrambler_seed : 8; // rand (1~255)
2787 	u32 random_init_seed : 8; // rand (1~255)
2788 	u32 rsvd1 : 4;
2789 	u32 apep : 22;
2790 	u32 ru_alloc : 8;
2791 	u32 rsvd2 : 2;
2792 	u32 nss : 4;
2793 	u32 txbf : 1;
2794 	u32 pwr_boost_db : 5;
2795 	u32 rsvd3 : 22;
2796 };
2797 
2798 enum pkt_ofld_type {
2799 	PKT_TYPE_PROBE_RSP = 0,
2800 	PKT_TYPE_PS_POLL = 1,
2801 	PKT_TYPE_NULL_DATA = 2,
2802 	PKT_TYPE_QOS_NULL = 3,
2803 	PKT_TYPE_CTS2SELF = 4,
2804 	PKT_TYPE_ARP_RSP = 5,
2805 	PKT_TYPE_NDP = 6,
2806 	PKT_TYPE_EAPOL_KEY = 7,
2807 	PKT_TYPE_SA_QUERY = 8,
2808 	PKT_TYPE_REALWOW_KAPKT = 9, /* RealWoW Keep Alive Packet */
2809 	PKT_TYPE_REALWOW_ACK = 10, /* RealWoW Ack Patten */
2810 	PKT_TYPE_REALWOW_WP = 11, /* RealWoW Wakeup Patten */
2811 	PKT_TYPE_PROBE_REQ = 12,
2812 	PKT_OFLD_TYPE_MAX,
2813 };
2814 
2815 struct scan_ofld_ch_info {
2816 	u8 center_chan;
2817 	u8 chan; /* primary channel */
2818 	u8 bw;
2819 	u8 period;
2820 	bool tx_pkt; /* 1:probe request will be sent */
2821 	bool tx_data_pause; /* 1:no data will be sent during fw scanning */
2822 };
2823 
2824 enum SCAN_OFLD_OP {
2825 	SCAN_OFLD_OP_STOP,
2826 	SCAN_OFLD_OP_START,
2827 	SCAN_OFLD_OP_SET
2828 };
2829 
2830 enum SCAN_OFLD_MD {
2831 	/* scan once */
2832 	SCAN_OFLD_MD_ONCE,
2833 	/**
2834 	 * normal period repeatd
2835 	 * e.g., period = 2s
2836 	 * scan - 2s - scan - 2s -....
2837 	 */
2838 
2839 	SCAN_OFLD_MD_PD,
2840 	/**
2841 	 * slow period repeat
2842 	 * e.g., period = 2s, cycle = 2, slow period = 3s
2843 	 * scan - 2s - scan - 2s - scan - 3s - scan - 3s
2844 	 */
2845 	SCAN_OFLD_MD_PD_SLOW,
2846 	/**
2847 	 * seamless
2848 	 * scan - scan - scan - scan - scan  -....
2849 	 */
2850 	SCAN_OFLD_MD_SEEMLESS,
2851 };
2852 
2853 struct scan_ofld_info {
2854 	enum SCAN_OFLD_OP operation;
2855 	enum SCAN_OFLD_MD mode;
2856 	/* destinated tsf to start scanning, set 0 for both to scan immediately*/
2857 	u32 tsf_low;
2858 	u32 tsf_high;
2859 	u32 probe_req_pkt_id;
2860 	u32 period; /* SCAN_OFLD_MD_PD & SCAN_OFLD_MD_PD_SLOW */
2861 	u8 cycle; /* SCAN_OFLD_MD_PD & SCAN_OFLD_MD_PD_SLOW*/
2862 	u32 slow_period; /* SCAN_OFLD_MD_PD_SLOW */
2863 };
2864 
2865 struct mp_plcp_param_t {
2866 	u32 dbw : 2; //0:BW20, 1:BW40, 2:BW80, 3:BW160/BW80+80
2867 	u32 source_gen_mode : 2;
2868 	u32 locked_clk : 1;
2869 	u32 dyn_bw : 1;
2870 	u32 ndp_en : 1;
2871 	u32 long_preamble_en : 1; //bmode
2872 	u32 stbc : 1;
2873 	u32 gi : 2; //0:0.4,1:0.8,2:1.6,3:3.2
2874 	u32 tb_l_len : 12;
2875 	u32 tb_ru_tot_sts_max : 3;
2876 	u32 vht_txop_not_allowed : 1;
2877 	u32 tb_disam : 1;
2878 	u32 doppler : 2;
2879 	u32 he_ltf_type : 2;//0:1x,1:2x,2:4x
2880 
2881 	u32 ht_l_len : 12;
2882 	u32 preamble_puncture : 1;
2883 	u32 he_mcs_sigb : 3;//0~5
2884 	u32 he_dcm_sigb : 1;
2885 	u32 he_sigb_compress_en : 1;
2886 	u32 max_tx_time_0p4us : 14;
2887 
2888 
2889 	u32 ul_flag : 1;
2890 	u32 tb_ldpc_extra : 1;
2891 	u32 bss_color : 6;
2892 	u32 sr : 4;
2893 	u32 beamchange_en : 1;
2894 	u32 he_er_u106ru_en : 1;
2895 	u32 ul_srp1 : 4;
2896 	u32 ul_srp2 : 4;
2897 	u32 ul_srp3 : 4;
2898 	u32 ul_srp4 : 4;
2899 	u32 mode : 2;
2900 
2901 	u32 group_id : 6;
2902 	u32 ppdu_type : 4;//0: bmode,1:Legacy,2:HT_MF,3:HT_GF,4:VHT,5:HE_SU,6:HE_ER_SU,7:HE_MU,8:HE_TB
2903 	u32 txop : 7;
2904 	u32 tb_strt_sts : 3;
2905 	u32 tb_pre_fec_padding_factor : 2;
2906 	u32 cbw : 2;
2907 	u32 txsc : 4;
2908 	u32 tb_mumimo_mode_en : 1;
2909 	u32 rsvd1 : 3;
2910 
2911 	u8 nominal_t_pe : 2; // def = 2
2912 	u8 ness : 2; // def = 0
2913 	u8 rsvd2 : 4;
2914 
2915 	u8 n_user;
2916 	u16 tb_rsvd : 9;//def = 0
2917 	u16 rsvd3 : 7;
2918 
2919 	struct mp_usr_plcp_gen_in usr[4];
2920 };
2921 
2922 
2923 
2924 #define MP_MAC_AX_MAX_RU_NUM	4
2925 
2926 struct mp_mac_ax_tf_depend_user_para {
2927 	u8 pref_AC: 2;
2928 	u8 rsvd: 6;
2929 };
2930 
2931 struct mp_mac_ax_tf_user_para {
2932 	u16 aid12: 12;
2933 	u16 ul_mcs: 4;
2934 	u8 macid;
2935 	u8 ru_pos;
2936 
2937 	u8 ul_fec_code: 1;
2938 	u8 ul_dcm: 1;
2939 	u8 ss_alloc: 6;
2940 	u8 ul_tgt_rssi: 7;
2941 	u8 rsvd: 1;
2942 	u16 rsvd2;
2943 };
2944 
2945 
2946 struct mp_mac_ax_tf_pkt_para {
2947 	u8 ul_bw: 2;
2948 	u8 gi_ltf: 2;
2949 	u8 num_he_ltf: 3;
2950 	u8 ul_stbc: 1;
2951 	u8 doppler: 1;
2952 	u8 ap_tx_power: 6;
2953 	u8 rsvd0: 1;
2954 	u8 user_num: 3;
2955 	u8 pktnum: 3;
2956 	u8 rsvd1: 2;
2957 	u8 pri20_bitmap;
2958 
2959 	struct mp_mac_ax_tf_user_para user[MP_MAC_AX_MAX_RU_NUM];
2960 	struct mp_mac_ax_tf_depend_user_para dep_user[MP_MAC_AX_MAX_RU_NUM];
2961 };
2962 
2963 struct mp_mac_ax_tf_wd_para {
2964 	u16 datarate: 9;
2965 	u16 mulport_id: 3;
2966 	u16 pwr_ofset: 3;
2967 	u16 rsvd: 1;
2968 };
2969 
2970 struct mp_mac_ax_f2p_test_para {
2971 	struct mp_mac_ax_tf_pkt_para tf_pkt;
2972 	struct mp_mac_ax_tf_wd_para tf_wd;
2973 	u8 mode: 2;
2974 	u8 frexch_type: 6;
2975 	u8 sigb_len;
2976 };
2977 
2978 struct mp_mac_ax_f2p_wd {
2979 	/* dword 0 */
2980 	u32 cmd_qsel:6;
2981 	u32 rsvd0:2;
2982 	u32 rsvd1:2;
2983 	u32 ls:1;
2984 	u32 fs:1;
2985 	u32 total_number:4;
2986 	u32 seq:8;
2987 	u32 length:8;
2988 	/* dword 1 */
2989 	u32 rsvd2;
2990 };
2991 
2992 struct mp_mac_ax_f2p_tx_cmd {
2993 	/* dword 0 */
2994 	u32 cmd_type:8;
2995 	u32 cmd_sub_type:8;
2996 	u32 dl_user_num:5;
2997 	u32 bw:2;
2998 	u32 tx_power:9;
2999 	/* dword 1 */
3000 	u32 fw_define:16;
3001 	u32 ss_sel_mode:2;
3002 	u32 next_qsel:6;
3003 	u32 twt_group:4;
3004 	u32 dis_chk_slp:1;
3005 	u32 ru_mu_2_su:1;
3006 	u32 dl_t_pe:2;
3007 	/* dword 2 */
3008 	u32 sigb_ch1_len:8;
3009 	u32 sigb_ch2_len:8;
3010 	u32 sigb_sym_num:6;
3011 	u32 sigb_ch2_ofs:5;
3012 	u32 dis_htp_ack:1;
3013 	u32 tx_time_ref:2;
3014 	u32 pri_user_idx:2;
3015 	/* dword 3 */
3016 	u32 ampdu_max_txtime:14;
3017 	u32 rsvd0:2;
3018 	u32 group_id:6;
3019 	u32 rsvd1:2;
3020 	u32 rsvd2:4;
3021 	u32 twt_chk_en:1;
3022 	u32 twt_port_id:3;
3023 	/* dword 4 */
3024 	u32 twt_start_time:32;
3025 	/* dword 5 */
3026 	u32 twt_end_time:32;
3027 	/* dword 6 */
3028 	u32 apep_len:12;
3029 	u32 tri_pad:2;
3030 	u32 ul_t_pe:2;
3031 	u32 rf_gain_idx:10;
3032 	u32 fixed_gain_en:1;
3033 	u32 ul_gi_ltf:3;
3034 	u32 ul_doppler:1;
3035 	u32 ul_stbc:1;
3036 	/* dword 7 */
3037 	u32 ul_mid_per:1;
3038 	u32 ul_cqi_rrp_tri:1;
3039 	u32 rsvd3:6;
3040 	u32 rsvd4:8;
3041 	u32 sigb_dcm:1;
3042 	u32 sigb_comp:1;
3043 	u32 doppler:1;
3044 	u32 stbc:1;
3045 	u32 mid_per:1;
3046 	u32 gi_ltf_size:3;
3047 	u32 sigb_mcs:3;
3048 	u32 rsvd5:5;
3049 	/* dword 8 */
3050 	u32 macid_u0:8;
3051 	u32 ac_type_u0:2;
3052 	u32 mu_sta_pos_u0:2;
3053 	u32 dl_rate_idx_u0:9;
3054 	u32 dl_dcm_en_u0:1;
3055 	u32 rsvd6:2;
3056 	u32 ru_alo_idx_u0:8;
3057 	/* dword 9 */
3058 	u32 pwr_boost_u0:5;
3059 	u32 agg_bmp_alo_u0:3;
3060 	u32 ampdu_max_txnum_u0:8;
3061 	u32 user_define_u0:8;
3062 	u32 user_define_ext_u0:8;
3063 	/* dword 10 */
3064 	u32 ul_addr_idx_u0:8;
3065 	u32 ul_dcm_u0:1;
3066 	u32 ul_fec_cod_u0:1;
3067 	u32 ul_ru_rate_u0:7;
3068 	u32 rsvd8:7;
3069 	u32 ul_ru_alo_idx_u0:8;
3070 	/* dword 11 */
3071 	u32 rsvd9:32;
3072 	/* dword 12 */
3073 	u32 macid_u1:8;
3074 	u32 ac_type_u1:2;
3075 	u32 mu_sta_pos_u1:2;
3076 	u32 dl_rate_idx_u1:9;
3077 	u32 dl_dcm_en_u1:1;
3078 	u32 rsvd10:2;
3079 	u32 ru_alo_idx_u1:8;
3080 	/* dword 13 */
3081 	u32 pwr_boost_u1:5;
3082 	u32 agg_bmp_alo_u1:3;
3083 	u32 ampdu_max_txnum_u1:8;
3084 	u32 user_define_u1:8;
3085 	u32 user_define_ext_u1:8;
3086 	/* dword 14 */
3087 	u32 ul_addr_idx_u1:8;
3088 	u32 ul_dcm_u1:1;
3089 	u32 ul_fec_cod_u1:1;
3090 	u32 ul_ru_rate_u1:7;
3091 	u32 rsvd12:7;
3092 	u32 ul_ru_alo_idx_u1:8;
3093 	/* dword 15 */
3094 	u32 rsvd13:32;
3095 	/* dword 16 */
3096 	u32 macid_u2:8;
3097 	u32 ac_type_u2:2;
3098 	u32 mu_sta_pos_u2:2;
3099 	u32 dl_rate_idx_u2:9;
3100 	u32 dl_dcm_en_u2:1;
3101 	u32 rsvd14:2;
3102 	u32 ru_alo_idx_u2:8;
3103 	/* dword 17 */
3104 	u32 pwr_boost_u2:5;
3105 	u32 agg_bmp_alo_u2:3;
3106 	u32 ampdu_max_txnum_u2:8;
3107 	u32 user_define_u2:8;
3108 	u32 user_define_ext_u2:8;
3109 	/* dword 18 */
3110 	u32 ul_addr_idx_u2:8;
3111 	u32 ul_dcm_u2:1;
3112 	u32 ul_fec_cod_u2:1;
3113 	u32 ul_ru_rate_u2:7;
3114 	u32 rsvd16:7;
3115 	u32 ul_ru_alo_idx_u2:8;
3116 	/* dword 19 */
3117 	u32 rsvd17:32;
3118 	/* dword 20 */
3119 	u32 macid_u3:8;
3120 	u32 ac_type_u3:2;
3121 	u32 mu_sta_pos_u3:2;
3122 	u32 dl_rate_idx_u3:9;
3123 	u32 dl_dcm_en_u3:1;
3124 	u32 rsvd18:2;
3125 	u32 ru_alo_idx_u3:8;
3126 	/* dword 21 */
3127 	u32 pwr_boost_u3:5;
3128 	u32 agg_bmp_alo_u3:3;
3129 	u32 ampdu_max_txnum_u3:8;
3130 	u32 user_define_u3:8;
3131 	u32 user_define_ext_u3:8;
3132 	/* dword 22 */
3133 	u32 ul_addr_idx_u3:8;
3134 	u32 ul_dcm_u3:1;
3135 	u32 ul_fec_cod_u3:1;
3136 	u32 ul_ru_rate_u3:7;
3137 	u32 rsvd20:7;
3138 	u32 ul_ru_alo_idx_u3:8;
3139 	/* dword 23 */
3140 	u32 rsvd21:32;
3141 	/* dword 24 */
3142 	u32 pkt_id_0:12;
3143 	u32 rsvd22:3;
3144 	u32 valid_0:1;
3145 	u32 ul_user_num_0:4;
3146 	u32 rsvd23:12;
3147 	/* dword 25 */
3148 	u32 pkt_id_1:12;
3149 	u32 rsvd24:3;
3150 	u32 valid_1:1;
3151 	u32 ul_user_num_1:4;
3152 	u32 rsvd25:12;
3153 	/* dword 26 */
3154 	u32 pkt_id_2:12;
3155 	u32 rsvd26:3;
3156 	u32 valid_2:1;
3157 	u32 ul_user_num_2:4;
3158 	u32 rsvd27:12;
3159 	/* dword 27 */
3160 	u32 pkt_id_3:12;
3161 	u32 rsvd28:3;
3162 	u32 valid_3:1;
3163 	u32 ul_user_num_3:4;
3164 	u32 rsvd29:12;
3165 	/* dword 28 */
3166 	u32 pkt_id_4:12;
3167 	u32 rsvd30:3;
3168 	u32 valid_4:1;
3169 	u32 ul_user_num_4:4;
3170 	u32 rsvd31:12;
3171 	/* dword 29 */
3172 	u32 pkt_id_5:12;
3173 	u32 rsvd32:3;
3174 	u32 valid_5:1;
3175 	u32 ul_user_num_5:4;
3176 	u32 rsvd33:12;
3177 };
3178 
3179 u8 mp_start(void *priv);
3180 
3181 #ifdef CONFIG_DBCC_SUPPORT
3182 enum dbcc_test_id {
3183 	DBCC_PRE_CFG,
3184 	DBCC_CFG,
3185 	DBCC_CLEAN_TXQ,
3186 };
3187 #endif
3188 
3189 struct rtw_role_cmd {
3190 	struct rtw_wifi_role_t *wrole;
3191 	enum role_state rstate;
3192 };
3193 
3194 enum phl_btc_pkt_evt_type {
3195 	BTC_PKT_EVT_NORMAL,
3196 	BTC_PKT_EVT_DHCP,
3197 	BTC_PKT_EVT_ARP,
3198 	BTC_PKT_EVT_EAPOL,
3199 	BTC_PKT_EVT_EAPOL_START,
3200 	BTC_PKT_EVT_ADD_KEY,
3201 	BTC_PKT_EVT_MAX
3202 };
3203 
3204 struct rtw_pkt_evt_ntfy {
3205 	struct rtw_wifi_role_t *wrole;
3206 	enum phl_btc_pkt_evt_type type;
3207 };
3208 
3209 struct role_ntfy_info {
3210 	u8 role_id;
3211 	u16 macid;
3212 	enum role_state rstate;
3213 };
3214 
3215 struct battery_chg_ntfy_info {
3216 	bool ips_allow;
3217 	bool lps_allow;
3218 };
3219 
3220 struct ps_ntfy_info {
3221 	bool sync;
3222 	void *ctx;
3223 	void (*cb)(void *phl, void *hdl, void *ctx, enum rtw_phl_status stat);
3224 };
3225 
3226 struct set_rf_ntfy_info {
3227 	enum rtw_rf_state state_to_set;
3228 	_os_event done;
3229 };
3230 
3231 
3232 /**
3233  * rtw_phl_rainfo - structure use to query RA information
3234  * from hal layer to core/phl layer
3235  * @rate: current rate selected by RA, define by general definition enum rtw_data_rate
3236  * @bw: current BW, define by general definition enum channel_width
3237  * @gi_ltf: current gi_ltf, define by general definition enum rtw_gi_ltf
3238  */
3239 struct rtw_phl_rainfo {
3240 	enum rtw_data_rate rate;
3241 	enum channel_width bw;
3242 	enum rtw_gi_ltf gi_ltf;
3243 };
3244 
3245 struct rtw_pcie_trx_mit_info_t {
3246 	u32 tx_timer;
3247 	u8 tx_counter;
3248 	u32 rx_timer;
3249 	u8 rx_counter;
3250 	u8 fixed_mitigation; /*no watchdog dynamic setting*/
3251 	void *priv;
3252 };
3253 
3254 struct rtw_env_report {
3255 	bool rpt_status; /*1 means CCX_SUCCESS,0 means fail*/
3256 	u8 clm_ratio;
3257 	u8 nhm_ratio;
3258 	u8 nhm_pwr;
3259 	u8 nhm_cca_ratio;
3260 };
3261 
3262 enum rtw_phl_ser_lv1_recv_step {
3263 	RTW_PHL_SER_LV1_RCVY_STEP_1 = 0,
3264 	RTW_PHL_SER_LV1_SER_RCVY_STEP_2,
3265 
3266 	/* keep last */
3267 	RTW_PHL_SER_LV1_RCVY_STEP_LAST,
3268 	RTW_PHL_SER_LV1_RCVY_STEP_MAX = RTW_PHL_SER_LV1_RCVY_STEP_LAST,
3269 	RTW_PHL_SER_LV1_RCVY_STEP_INVALID = RTW_PHL_SER_LV1_RCVY_STEP_LAST,
3270 };
3271 
3272 #endif /*_PHL_DEF_H_*/
3273