xref: /wlan-driver/qcacld-3.0/components/cmn_services/policy_mgr/src/wlan_policy_mgr_ucfg.c (revision 5113495b16420b49004c444715d2daae2066e7dc) !
1 /*
2  * Copyright (c) 2018-2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for
6  * any purpose with or without fee is hereby granted, provided that the
7  * above copyright notice and this permission notice appear in all
8  * copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17  * PERFORMANCE OF THIS SOFTWARE.
18  */
19 #include "wlan_policy_mgr_ucfg.h"
20 #include "wlan_policy_mgr_i.h"
21 #include "cfg_ucfg_api.h"
22 #include "wlan_policy_mgr_api.h"
23 #include "wlan_nan_api.h"
24 
25 #ifdef WLAN_FEATURE_SR
26 /**
27  * policy_mgr_init_same_mac_conc_sr_status() - Function initializes default
28  * value to sr_in_same_mac_conc based on INI g_enable_sr_in_same_mac_conc
29  *
30  * @psoc: Pointer to PSOC
31  *
32  * Return: void
33  */
34 static void
policy_mgr_init_same_mac_conc_sr_status(struct wlan_objmgr_psoc * psoc)35 policy_mgr_init_same_mac_conc_sr_status(struct wlan_objmgr_psoc *psoc)
36 {
37 	struct policy_mgr_psoc_priv_obj *pm_ctx;
38 
39 	pm_ctx = policy_mgr_get_context(psoc);
40 	if (!pm_ctx) {
41 		policy_mgr_err("Invalid Context");
42 		return;
43 	}
44 
45 	pm_ctx->cfg.sr_in_same_mac_conc =
46 		cfg_get(psoc, CFG_ENABLE_SR_IN_SAME_MAC_CONC);
47 }
48 #else
49 static void
policy_mgr_init_same_mac_conc_sr_status(struct wlan_objmgr_psoc * psoc)50 policy_mgr_init_same_mac_conc_sr_status(struct wlan_objmgr_psoc *psoc)
51 {}
52 #endif
53 
policy_mgr_init_cfg(struct wlan_objmgr_psoc * psoc)54 static QDF_STATUS policy_mgr_init_cfg(struct wlan_objmgr_psoc *psoc)
55 {
56 	struct policy_mgr_psoc_priv_obj *pm_ctx;
57 	struct policy_mgr_cfg *cfg;
58 
59 	pm_ctx = policy_mgr_get_context(psoc);
60 	if (!pm_ctx) {
61 		policy_mgr_err("pm_ctx is NULL");
62 		return QDF_STATUS_E_FAILURE;
63 	}
64 	cfg = &pm_ctx->cfg;
65 
66 	cfg->mcc_to_scc_switch = cfg_get(psoc, CFG_MCC_TO_SCC_SWITCH);
67 	if (cfg->mcc_to_scc_switch != QDF_MCC_TO_SCC_SWITCH_DISABLE &&
68 	    cfg->mcc_to_scc_switch <
69 			QDF_MCC_TO_SCC_SWITCH_FORCE_WITHOUT_DISCONNECTION) {
70 		policy_mgr_info("User configured mcc_to_scc_switch: %d, overwrite it to: %d",
71 			cfg->mcc_to_scc_switch,
72 			QDF_MCC_TO_SCC_SWITCH_FORCE_WITHOUT_DISCONNECTION);
73 		cfg->mcc_to_scc_switch =
74 			QDF_MCC_TO_SCC_SWITCH_FORCE_WITHOUT_DISCONNECTION;
75 	}
76 
77 	cfg->sys_pref = cfg_get(psoc, CFG_CONC_SYS_PREF);
78 
79 	if (wlan_is_mlo_sta_nan_ndi_allowed(psoc)) {
80 		cfg->max_conc_cxns = cfg_get(psoc, CFG_MAX_CONC_CXNS) + 1;
81 		 policy_mgr_err("max_conc_cxns %d nan", cfg->max_conc_cxns);
82 	} else {
83 		cfg->max_conc_cxns = cfg_get(psoc, CFG_MAX_CONC_CXNS);
84 		policy_mgr_err("max_conc_cxns %d non-nan", cfg->max_conc_cxns);
85 	}
86 	cfg->max_conc_cxns = QDF_MIN(cfg->max_conc_cxns,
87 				     MAX_NUMBER_OF_CONC_CONNECTIONS);
88 	cfg->conc_rule1 = cfg_get(psoc, CFG_ENABLE_CONC_RULE1);
89 	cfg->conc_rule2 = cfg_get(psoc, CFG_ENABLE_CONC_RULE2);
90 	cfg->pcl_band_priority = cfg_get(psoc, CFG_PCL_BAND_PRIORITY);
91 	cfg->dbs_selection_plcy = cfg_get(psoc, CFG_DBS_SELECTION_PLCY);
92 	cfg->vdev_priority_list = cfg_get(psoc, CFG_VDEV_CUSTOM_PRIORITY_LIST);
93 	cfg->chnl_select_plcy = cfg_get(psoc, CFG_CHNL_SELECT_LOGIC_CONC);
94 	cfg->enable_mcc_adaptive_sch =
95 		cfg_get(psoc, CFG_ENABLE_MCC_ADAPTIVE_SCH_ENABLED_NAME);
96 	cfg->enable_sta_cxn_5g_band =
97 		cfg_get(psoc, CFG_ENABLE_STA_CONNECTION_IN_5GHZ);
98 	cfg->allow_mcc_go_diff_bi =
99 		cfg_get(psoc, CFG_ALLOW_MCC_GO_DIFF_BI);
100 	cfg->dual_mac_feature =
101 		cfg_get(psoc, CFG_DUAL_MAC_FEATURE_DISABLE);
102 	cfg->sbs_enable =
103 		cfg_get(psoc, CFG_ENABLE_SBS);
104 	cfg->is_force_1x1_enable =
105 		cfg_get(psoc, CFG_FORCE_1X1_FEATURE);
106 	cfg->sta_sap_scc_on_dfs_chnl =
107 		cfg_get(psoc, CFG_STA_SAP_SCC_ON_DFS_CHAN);
108 
109 	/*
110 	 * Override concurrency sta+sap indoor flag to true if global indoor
111 	 * flag is true
112 	 */
113 	cfg->sta_sap_scc_on_indoor_channel =
114 		cfg_get(psoc, CFG_STA_SAP_SCC_ON_INDOOR_CHAN);
115 	if (cfg_get(psoc, CFG_INDOOR_CHANNEL_SUPPORT))
116 		cfg->sta_sap_scc_on_indoor_channel = true;
117 
118 	/*
119 	 * Force set sta_sap_scc_on_dfs_chnl on Non-DBS HW so that standalone
120 	 * SAP is not allowed on DFS channel on non-DBS HW, Also, force SCC in
121 	 * case of STA+SAP
122 	 */
123 	if (cfg->sta_sap_scc_on_dfs_chnl == 2 &&
124 	    !cfg_get(psoc, CFG_ENABLE_DFS_MASTER_CAPABILITY))
125 		cfg->sta_sap_scc_on_dfs_chnl = 0;
126 	cfg->nan_sap_scc_on_lte_coex_chnl =
127 		cfg_get(psoc, CFG_NAN_SAP_SCC_ON_LTE_COEX_CHAN);
128 	cfg->sta_sap_scc_on_lte_coex_chnl =
129 		cfg_get(psoc, CFG_STA_SAP_SCC_ON_LTE_COEX_CHAN);
130 	cfg->sap_mandatory_chnl_enable =
131 		cfg_get(psoc, CFG_ENABLE_SAP_MANDATORY_CHAN_LIST);
132 	cfg->mark_indoor_chnl_disable =
133 		cfg_get(psoc, CFG_MARK_INDOOR_AS_DISABLE_FEATURE);
134 	cfg->go_force_scc = cfg_get(psoc, CFG_P2P_GO_ENABLE_FORCE_SCC);
135 	cfg->multi_sap_allowed_on_same_band =
136 		cfg_get(psoc, CFG_MULTI_SAP_ALLOWED_ON_SAME_BAND);
137 	policy_mgr_init_same_mac_conc_sr_status(psoc);
138 	cfg->use_sap_original_bw =
139 		cfg_get(psoc, CFG_SAP_DEFAULT_BW_FOR_RESTART);
140 	cfg->move_sap_go_1st_on_dfs_sta_csa =
141 		cfg_get(psoc, CFG_MOVE_SAP_GO_1ST_ON_DFS_STA_CSA);
142 
143 	return QDF_STATUS_SUCCESS;
144 }
145 
policy_mgr_deinit_cfg(struct wlan_objmgr_psoc * psoc)146 static void policy_mgr_deinit_cfg(struct wlan_objmgr_psoc *psoc)
147 {
148 	struct policy_mgr_psoc_priv_obj *pm_ctx;
149 
150 	pm_ctx = policy_mgr_get_context(psoc);
151 	if (!pm_ctx) {
152 		policy_mgr_err("pm_ctx is NULL");
153 		return;
154 	}
155 
156 	qdf_mem_zero(&pm_ctx->cfg, sizeof(pm_ctx->cfg));
157 }
158 
ucfg_policy_mgr_psoc_open(struct wlan_objmgr_psoc * psoc)159 QDF_STATUS ucfg_policy_mgr_psoc_open(struct wlan_objmgr_psoc *psoc)
160 {
161 	QDF_STATUS status;
162 
163 	status = policy_mgr_init_cfg(psoc);
164 	if (QDF_IS_STATUS_ERROR(status)) {
165 		policy_mgr_err("pm_ctx is NULL");
166 		return status;
167 	}
168 
169 	status = policy_mgr_psoc_open(psoc);
170 	if (QDF_IS_STATUS_ERROR(status)) {
171 		policy_mgr_err("psoc open fail");
172 		policy_mgr_psoc_close(psoc);
173 		return status;
174 	}
175 
176 	return QDF_STATUS_SUCCESS;
177 }
178 
ucfg_policy_mgr_psoc_close(struct wlan_objmgr_psoc * psoc)179 void ucfg_policy_mgr_psoc_close(struct wlan_objmgr_psoc *psoc)
180 {
181 	policy_mgr_psoc_close(psoc);
182 	policy_mgr_deinit_cfg(psoc);
183 }
184 
ucfg_policy_mgr_get_mcc_scc_switch(struct wlan_objmgr_psoc * psoc,uint8_t * mcc_scc_switch)185 QDF_STATUS ucfg_policy_mgr_get_mcc_scc_switch(struct wlan_objmgr_psoc *psoc,
186 					      uint8_t *mcc_scc_switch)
187 {
188 	return policy_mgr_get_mcc_scc_switch(psoc, mcc_scc_switch);
189 }
190 
ucfg_policy_mgr_get_sys_pref(struct wlan_objmgr_psoc * psoc,uint8_t * sys_pref)191 QDF_STATUS ucfg_policy_mgr_get_sys_pref(struct wlan_objmgr_psoc *psoc,
192 					uint8_t *sys_pref)
193 {
194 	return policy_mgr_get_sys_pref(psoc, sys_pref);
195 }
196 
ucfg_policy_mgr_set_sys_pref(struct wlan_objmgr_psoc * psoc,uint8_t sys_pref)197 QDF_STATUS ucfg_policy_mgr_set_sys_pref(struct wlan_objmgr_psoc *psoc,
198 					uint8_t sys_pref)
199 {
200 	return policy_mgr_set_sys_pref(psoc, sys_pref);
201 }
202 
ucfg_policy_mgr_get_conc_rule1(struct wlan_objmgr_psoc * psoc,uint8_t * conc_rule1)203 QDF_STATUS ucfg_policy_mgr_get_conc_rule1(struct wlan_objmgr_psoc *psoc,
204 						uint8_t *conc_rule1)
205 {
206 	return policy_mgr_get_conc_rule1(psoc, conc_rule1);
207 }
208 
ucfg_policy_mgr_get_conc_rule2(struct wlan_objmgr_psoc * psoc,uint8_t * conc_rule2)209 QDF_STATUS ucfg_policy_mgr_get_conc_rule2(struct wlan_objmgr_psoc *psoc,
210 						uint8_t *conc_rule2)
211 {
212 	return policy_mgr_get_conc_rule2(psoc, conc_rule2);
213 }
214 
ucfg_policy_mgr_get_chnl_select_plcy(struct wlan_objmgr_psoc * psoc,uint32_t * chnl_select_plcy)215 QDF_STATUS ucfg_policy_mgr_get_chnl_select_plcy(struct wlan_objmgr_psoc *psoc,
216 						uint32_t *chnl_select_plcy)
217 {
218 	return policy_mgr_get_chnl_select_plcy(psoc, chnl_select_plcy);
219 }
220 
221 
ucfg_policy_mgr_set_dynamic_mcc_adaptive_sch(struct wlan_objmgr_psoc * psoc,bool dynamic_mcc_adaptive_sch)222 QDF_STATUS ucfg_policy_mgr_set_dynamic_mcc_adaptive_sch(
223 					struct wlan_objmgr_psoc *psoc,
224 					bool dynamic_mcc_adaptive_sch)
225 {
226 	return policy_mgr_set_dynamic_mcc_adaptive_sch(
227 					psoc, dynamic_mcc_adaptive_sch);
228 }
229 
ucfg_policy_mgr_get_dynamic_mcc_adaptive_sch(struct wlan_objmgr_psoc * psoc,bool * dynamic_mcc_adaptive_sch)230 QDF_STATUS ucfg_policy_mgr_get_dynamic_mcc_adaptive_sch(
231 					struct wlan_objmgr_psoc *psoc,
232 					bool *dynamic_mcc_adaptive_sch)
233 {
234 	return policy_mgr_get_dynamic_mcc_adaptive_sch(
235 					psoc, dynamic_mcc_adaptive_sch);
236 }
237 
ucfg_policy_mgr_get_mcc_adaptive_sch(struct wlan_objmgr_psoc * psoc,bool * mcc_adaptive_sch)238 QDF_STATUS ucfg_policy_mgr_get_mcc_adaptive_sch(struct wlan_objmgr_psoc *psoc,
239 						bool *mcc_adaptive_sch)
240 {
241 	return policy_mgr_get_mcc_adaptive_sch(psoc, mcc_adaptive_sch);
242 }
243 
ucfg_policy_mgr_get_sta_cxn_5g_band(struct wlan_objmgr_psoc * psoc,uint8_t * enable_sta_cxn_5g_band)244 QDF_STATUS ucfg_policy_mgr_get_sta_cxn_5g_band(struct wlan_objmgr_psoc *psoc,
245 					       uint8_t *enable_sta_cxn_5g_band)
246 {
247 	return policy_mgr_get_sta_cxn_5g_band(psoc, enable_sta_cxn_5g_band);
248 }
249 
250 QDF_STATUS
ucfg_policy_mgr_get_allow_mcc_go_diff_bi(struct wlan_objmgr_psoc * psoc,uint8_t * allow_mcc_go_diff_bi)251 ucfg_policy_mgr_get_allow_mcc_go_diff_bi(struct wlan_objmgr_psoc *psoc,
252 					 uint8_t *allow_mcc_go_diff_bi)
253 {
254 	return policy_mgr_get_allow_mcc_go_diff_bi(psoc, allow_mcc_go_diff_bi);
255 }
256 
ucfg_policy_mgr_get_dual_mac_feature(struct wlan_objmgr_psoc * psoc,uint8_t * dual_mac_feature)257 QDF_STATUS ucfg_policy_mgr_get_dual_mac_feature(struct wlan_objmgr_psoc *psoc,
258 						uint8_t *dual_mac_feature)
259 {
260 	return policy_mgr_get_dual_mac_feature(psoc, dual_mac_feature);
261 }
262 
ucfg_policy_mgr_get_dual_sta_feature(struct wlan_objmgr_psoc * psoc)263 bool ucfg_policy_mgr_get_dual_sta_feature(struct wlan_objmgr_psoc *psoc)
264 {
265 	return policy_mgr_allow_multiple_sta_connections(psoc);
266 }
267 
ucfg_policy_mgr_get_force_1x1(struct wlan_objmgr_psoc * psoc,uint8_t * force_1x1)268 QDF_STATUS ucfg_policy_mgr_get_force_1x1(struct wlan_objmgr_psoc *psoc,
269 					 uint8_t *force_1x1)
270 {
271 	return policy_mgr_get_force_1x1(psoc, force_1x1);
272 }
273 
ucfg_policy_mgr_get_max_conc_cxns(struct wlan_objmgr_psoc * psoc)274 uint32_t ucfg_policy_mgr_get_max_conc_cxns(struct wlan_objmgr_psoc *psoc)
275 {
276 	return policy_mgr_get_max_conc_cxns(psoc);
277 }
278 
ucfg_policy_mgr_set_max_conc_cxns(struct wlan_objmgr_psoc * psoc,uint32_t max_conc_cxns)279 QDF_STATUS ucfg_policy_mgr_set_max_conc_cxns(struct wlan_objmgr_psoc *psoc,
280 					     uint32_t max_conc_cxns)
281 {
282 	return policy_mgr_set_max_conc_cxns(psoc, max_conc_cxns);
283 }
284 
285 QDF_STATUS
ucfg_policy_mgr_get_radio_combinations(struct wlan_objmgr_psoc * psoc,struct radio_combination * comb,uint32_t comb_max,uint32_t * comb_num)286 ucfg_policy_mgr_get_radio_combinations(struct wlan_objmgr_psoc *psoc,
287 				       struct radio_combination *comb,
288 				       uint32_t comb_max,
289 				       uint32_t *comb_num)
290 {
291 	return policy_mgr_get_radio_combinations(psoc, comb,
292 						 comb_max, comb_num);
293 }
294 
295 QDF_STATUS
ucfg_policy_mgr_get_sta_sap_scc_on_dfs_chnl(struct wlan_objmgr_psoc * psoc,uint8_t * sta_sap_scc_on_dfs_chnl)296 ucfg_policy_mgr_get_sta_sap_scc_on_dfs_chnl(struct wlan_objmgr_psoc *psoc,
297 					    uint8_t *sta_sap_scc_on_dfs_chnl)
298 {
299 	return policy_mgr_get_sta_sap_scc_on_dfs_chnl(psoc,
300 						      sta_sap_scc_on_dfs_chnl);
301 }
302 
303 bool
ucfg_policy_mgr_get_dfs_master_dynamic_enabled(struct wlan_objmgr_psoc * psoc,uint8_t vdev_id)304 ucfg_policy_mgr_get_dfs_master_dynamic_enabled(struct wlan_objmgr_psoc *psoc,
305 					       uint8_t vdev_id)
306 {
307 	return policy_mgr_get_dfs_master_dynamic_enabled(psoc, vdev_id);
308 }
309 
310 QDF_STATUS
ucfg_policy_mgr_get_sta_sap_scc_lte_coex_chnl(struct wlan_objmgr_psoc * psoc,uint8_t * sta_sap_scc_lte_coex)311 ucfg_policy_mgr_get_sta_sap_scc_lte_coex_chnl(struct wlan_objmgr_psoc *psoc,
312 					      uint8_t *sta_sap_scc_lte_coex)
313 {
314 	return policy_mgr_get_sta_sap_scc_lte_coex_chnl(psoc,
315 							sta_sap_scc_lte_coex);
316 }
317 
318 QDF_STATUS
ucfg_policy_mgr_init_chan_avoidance(struct wlan_objmgr_psoc * psoc,qdf_freq_t * chan_freq_list,uint16_t chan_cnt)319 ucfg_policy_mgr_init_chan_avoidance(struct wlan_objmgr_psoc *psoc,
320 				    qdf_freq_t *chan_freq_list,
321 				    uint16_t chan_cnt)
322 {
323 	return policy_mgr_init_chan_avoidance(psoc, chan_freq_list, chan_cnt);
324 }
325 
ucfg_policy_mgr_get_sap_mandt_chnl(struct wlan_objmgr_psoc * psoc,uint8_t * sap_mandt_chnl)326 QDF_STATUS ucfg_policy_mgr_get_sap_mandt_chnl(struct wlan_objmgr_psoc *psoc,
327 					      uint8_t *sap_mandt_chnl)
328 {
329 	return policy_mgr_get_sap_mandt_chnl(psoc, sap_mandt_chnl);
330 }
331 
332 QDF_STATUS
ucfg_policy_mgr_get_indoor_chnl_marking(struct wlan_objmgr_psoc * psoc,uint8_t * indoor_chnl_marking)333 ucfg_policy_mgr_get_indoor_chnl_marking(struct wlan_objmgr_psoc *psoc,
334 					uint8_t *indoor_chnl_marking)
335 {
336 	return policy_mgr_get_indoor_chnl_marking(psoc, indoor_chnl_marking);
337 }
338 
339 bool
ucfg_policy_mgr_get_sta_sap_scc_on_indoor_chnl(struct wlan_objmgr_psoc * psoc)340 ucfg_policy_mgr_get_sta_sap_scc_on_indoor_chnl(struct wlan_objmgr_psoc *psoc)
341 {
342 	return policy_mgr_get_sta_sap_scc_allowed_on_indoor_chnl(psoc) ?
343 								true : false;
344 }
345 
ucfg_policy_mgr_is_fw_supports_dbs(struct wlan_objmgr_psoc * psoc)346 bool ucfg_policy_mgr_is_fw_supports_dbs(struct wlan_objmgr_psoc *psoc)
347 {
348 	return policy_mgr_find_if_fw_supports_dbs(psoc);
349 }
350 
ucfg_policy_mgr_get_connection_count(struct wlan_objmgr_psoc * psoc)351 uint32_t ucfg_policy_mgr_get_connection_count(struct wlan_objmgr_psoc *psoc)
352 {
353 	return policy_mgr_get_connection_count(psoc);
354 }
355 
ucfg_policy_mgr_is_hw_sbs_capable(struct wlan_objmgr_psoc * psoc)356 bool ucfg_policy_mgr_is_hw_sbs_capable(struct wlan_objmgr_psoc *psoc)
357 {
358 	return policy_mgr_is_hw_dbs_capable(psoc);
359 }
360 
ucfg_policy_mgr_get_vdev_same_freq_new_conn(struct wlan_objmgr_psoc * psoc,uint32_t new_freq,uint8_t * vdev_id)361 bool ucfg_policy_mgr_get_vdev_same_freq_new_conn(struct wlan_objmgr_psoc *psoc,
362 						 uint32_t new_freq,
363 						 uint8_t *vdev_id)
364 {
365 	return policy_mgr_get_vdev_same_freq_new_conn(psoc, new_freq, vdev_id);
366 }
367 
ucfg_policy_mgr_get_vdev_diff_freq_new_conn(struct wlan_objmgr_psoc * psoc,uint32_t new_freq,uint8_t * vdev_id)368 bool ucfg_policy_mgr_get_vdev_diff_freq_new_conn(struct wlan_objmgr_psoc *psoc,
369 						 uint32_t new_freq,
370 						 uint8_t *vdev_id)
371 {
372 	return policy_mgr_get_vdev_diff_freq_new_conn(psoc, new_freq, vdev_id);
373 }
374 
ucfg_policy_mgr_get_dbs_hw_modes(struct wlan_objmgr_psoc * psoc,bool * one_by_one_dbs,bool * two_by_two_dbs)375 QDF_STATUS ucfg_policy_mgr_get_dbs_hw_modes(struct wlan_objmgr_psoc *psoc,
376 					    bool *one_by_one_dbs,
377 					    bool *two_by_two_dbs)
378 {
379 	return policy_mgr_get_dbs_hw_modes(psoc, one_by_one_dbs,
380 					   two_by_two_dbs);
381 }
382