xref: /OK3568_Linux_fs/external/rkwifibt/drivers/rtl8852be/include/rtw_csa.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 __RTW_CSA_H_
16 #define __RTW_CSA_H_
17 
18 #if CONFIG_DFS
19 #define CSA_IE_LEN 3 /* Length of Channel Switch element */
20 #define CSA_SWITCH_MODE 0
21 #define CSA_NEW_CH 1
22 #define CSA_SWITCH_COUNT 2
23 #define MAX_CSA_CNT 10
24 
25 #define CS_WR_DATA_LEN 5 /* Length of Channel Switch Wrapper element */
26 
27 void reset_csa_param(struct rf_ctl_t *rfctl);
28 bool rtw_get_csa_setting(struct dvobj_priv *d, s16 *req_ch, u8 *req_bw, u8 *req_offset);
29 
30 #ifdef CONFIG_ECSA_PHL
31 #define MCC_ECSA_DELAY_START_TIME 30000 /* ms */
32 
33 enum ecsa_state_t {
34 	ECSA_ST_NONE,
35 	ECSA_ST_SW_START, /* ready to switch */
36 	ECSA_ST_SW_DONE /* switch done */
37 };
38 
39 struct core_ecsa_info {
40 	enum ecsa_state_t state;
41 	u32 ecsa_allow_case;
42 	u32 ecsa_delay_time;
43 
44 	/* @channel_width defined in 802.11-2016, Table 9-252 VHT operation information subfields
45 	* 0 for 20 MHz or 40 MHz
46 	* 1 for 80 MHz, 160 MHz or 80+80 MHz
47 	* 2 for 160 MHz (deprecated)
48 	* 3 for non-contiguous 80+80 MHz (deprecated)
49 	*/
50 	u8 channel_width;
51 	struct createbss_parm *bss_param;
52 	struct rtw_phl_ecsa_param phl_ecsa_param;
53 };
54 
set_ecsa_state(struct core_ecsa_info * ecsa_info,enum ecsa_state_t state)55 __inline static void set_ecsa_state(struct core_ecsa_info *ecsa_info, enum ecsa_state_t state)
56 {
57 	ecsa_info->state = state;
58 }
59 
check_ecsa_state(struct core_ecsa_info * ecsa_info,enum ecsa_state_t state)60 __inline static bool check_ecsa_state(struct core_ecsa_info *ecsa_info, enum ecsa_state_t state)
61 {
62 	if (ecsa_info->state == state)
63 		return _TRUE;
64 	return _FALSE;
65 }
66 
67 #define SET_ECSA_STATE(adapter, state) set_ecsa_state(&((adapter)->ecsa_info), (state))
68 #define CHK_ECSA_STATE(adapter, state) check_ecsa_state(&((adapter)->ecsa_info), (state))
69 
70 bool rtw_mr_is_ecsa_running(struct _ADAPTER *a);
71 void rtw_ecsa_update_probe_resp(struct xmit_frame *xframe);
72 void rtw_ecsa_update_beacon(void *priv, struct rtw_wifi_role_t *role);
73 bool rtw_ap_check_ecsa_allow(
74 	void *priv,
75 	struct rtw_wifi_role_t *role,
76 	struct rtw_chan_def chan_def,
77 	enum phl_ecsa_start_reason reason,
78 	u32 *delay_start_ms
79 );
80 void rtw_ecsa_mr_update_chan_info_by_role(
81 	void *priv,
82 	struct rtw_wifi_role_t *role,
83 	struct rtw_chan_def new_chan_def
84 );
85 bool rtw_ecsa_check_tx_resume_allow(void *priv, struct rtw_wifi_role_t *role);
86 void rtw_ecsa_complete(void *priv, struct rtw_wifi_role_t *role);
87 void rtw_trigger_phl_ecsa_start(struct _ADAPTER *a);
88 #endif /* CONFIG_ECSA_PHL */
89 #endif /* CONFIG_DFS */
90 
91 #endif
92