xref: /wlan-driver/qcacld-3.0/core/sme/src/csr/csr_util.c (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2011-2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2021-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 
20 /*
21  * DOC: csr_util.c
22  *
23  * Implementation supporting routines for CSR.
24  */
25 
26 #include "ani_global.h"
27 
28 #include "csr_support.h"
29 #include "csr_inside_api.h"
30 #include "sme_qos_internal.h"
31 #include "wma_types.h"
32 #include "cds_utils.h"
33 #include "wlan_policy_mgr_api.h"
34 #include "wlan_serialization_legacy_api.h"
35 #include "wlan_reg_services_api.h"
36 #include "wlan_crypto_global_api.h"
37 #include "wlan_cm_roam_api.h"
38 #include <../../core/src/wlan_cm_vdev_api.h>
39 #include <wlan_mlo_mgr_public_structs.h>
40 #include "wlan_objmgr_vdev_obj.h"
41 #include "wlan_policy_mgr_ll_sap.h"
42 
43 #define CASE_RETURN_STR(n) {\
44 	case (n): return (# n);\
45 }
46 
get_e_roam_cmd_status_str(eRoamCmdStatus val)47 const char *get_e_roam_cmd_status_str(eRoamCmdStatus val)
48 {
49 	switch (val) {
50 		CASE_RETURN_STR(eCSR_ROAM_LOSTLINK);
51 		CASE_RETURN_STR(eCSR_ROAM_MIC_ERROR_IND);
52 		CASE_RETURN_STR(eCSR_ROAM_SET_KEY_COMPLETE);
53 		CASE_RETURN_STR(eCSR_ROAM_INFRA_IND);
54 		CASE_RETURN_STR(eCSR_ROAM_WPS_PBC_PROBE_REQ_IND);
55 		CASE_RETURN_STR(eCSR_ROAM_DISCONNECT_ALL_P2P_CLIENTS);
56 		CASE_RETURN_STR(eCSR_ROAM_SEND_P2P_STOP_BSS);
57 		CASE_RETURN_STR(eCSR_ROAM_UNPROT_MGMT_FRAME_IND);
58 #ifdef FEATURE_WLAN_ESE
59 		CASE_RETURN_STR(eCSR_ROAM_TSM_IE_IND);
60 		CASE_RETURN_STR(eCSR_ROAM_ESE_ADJ_AP_REPORT_IND);
61 		CASE_RETURN_STR(eCSR_ROAM_ESE_BCN_REPORT_IND);
62 #endif /* FEATURE_WLAN_ESE */
63 		CASE_RETURN_STR(eCSR_ROAM_DFS_RADAR_IND);
64 		CASE_RETURN_STR(eCSR_ROAM_SET_CHANNEL_RSP);
65 		CASE_RETURN_STR(eCSR_ROAM_DFS_CHAN_SW_NOTIFY);
66 		CASE_RETURN_STR(eCSR_ROAM_EXT_CHG_CHNL_IND);
67 		CASE_RETURN_STR(eCSR_ROAM_STA_CHANNEL_SWITCH);
68 		CASE_RETURN_STR(eCSR_ROAM_NDP_STATUS_UPDATE);
69 		CASE_RETURN_STR(eCSR_ROAM_CHANNEL_COMPLETE_IND);
70 		CASE_RETURN_STR(eCSR_ROAM_SAE_COMPUTE);
71 		CASE_RETURN_STR(eCSR_ROAM_CHANNEL_INFO_EVENT_IND);
72 	default:
73 		return "unknown";
74 	}
75 }
76 
get_e_csr_roam_result_str(eCsrRoamResult val)77 const char *get_e_csr_roam_result_str(eCsrRoamResult val)
78 {
79 	switch (val) {
80 		CASE_RETURN_STR(eCSR_ROAM_RESULT_NONE);
81 		CASE_RETURN_STR(eCSR_ROAM_RESULT_FAILURE);
82 		CASE_RETURN_STR(eCSR_ROAM_RESULT_ASSOCIATED);
83 		CASE_RETURN_STR(eCSR_ROAM_RESULT_NOT_ASSOCIATED);
84 		CASE_RETURN_STR(eCSR_ROAM_RESULT_MIC_FAILURE);
85 		CASE_RETURN_STR(eCSR_ROAM_RESULT_FORCED);
86 		CASE_RETURN_STR(eCSR_ROAM_RESULT_DISASSOC_IND);
87 		CASE_RETURN_STR(eCSR_ROAM_RESULT_DEAUTH_IND);
88 		CASE_RETURN_STR(eCSR_ROAM_RESULT_CAP_CHANGED);
89 		CASE_RETURN_STR(eCSR_ROAM_RESULT_LOSTLINK);
90 		CASE_RETURN_STR(eCSR_ROAM_RESULT_MIC_ERROR_UNICAST);
91 		CASE_RETURN_STR(eCSR_ROAM_RESULT_MIC_ERROR_GROUP);
92 		CASE_RETURN_STR(eCSR_ROAM_RESULT_AUTHENTICATED);
93 		CASE_RETURN_STR(eCSR_ROAM_RESULT_NEW_RSN_BSS);
94  #ifdef FEATURE_WLAN_WAPI
95 		CASE_RETURN_STR(eCSR_ROAM_RESULT_NEW_WAPI_BSS);
96  #endif /* FEATURE_WLAN_WAPI */
97 		CASE_RETURN_STR(eCSR_ROAM_RESULT_INFRA_STARTED);
98 		CASE_RETURN_STR(eCSR_ROAM_RESULT_INFRA_START_FAILED);
99 		CASE_RETURN_STR(eCSR_ROAM_RESULT_INFRA_STOPPED);
100 		CASE_RETURN_STR(eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
101 		CASE_RETURN_STR(eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
102 		CASE_RETURN_STR(eCSR_ROAM_RESULT_INFRA_DISASSOCIATED);
103 		CASE_RETURN_STR(eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
104 		CASE_RETURN_STR(eCSR_ROAM_RESULT_SEND_ACTION_FAIL);
105 		CASE_RETURN_STR(eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
106 		CASE_RETURN_STR(eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL);
107 		CASE_RETURN_STR(eCSR_ROAM_RESULT_ADD_TDLS_PEER);
108 		CASE_RETURN_STR(eCSR_ROAM_RESULT_UPDATE_TDLS_PEER);
109 		CASE_RETURN_STR(eCSR_ROAM_RESULT_DELETE_TDLS_PEER);
110 		CASE_RETURN_STR(eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND);
111 		CASE_RETURN_STR(eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND);
112 		CASE_RETURN_STR(eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP);
113 		CASE_RETURN_STR(eCSR_ROAM_RESULT_TDLS_SHOULD_DISCOVER);
114 		CASE_RETURN_STR(eCSR_ROAM_RESULT_TDLS_SHOULD_TEARDOWN);
115 		CASE_RETURN_STR(eCSR_ROAM_RESULT_TDLS_SHOULD_PEER_DISCONNECTED);
116 		CASE_RETURN_STR
117 			(eCSR_ROAM_RESULT_TDLS_CONNECTION_TRACKER_NOTIFICATION);
118 		CASE_RETURN_STR(eCSR_ROAM_RESULT_DFS_RADAR_FOUND_IND);
119 		CASE_RETURN_STR(eCSR_ROAM_RESULT_CHANNEL_CHANGE_SUCCESS);
120 		CASE_RETURN_STR(eCSR_ROAM_RESULT_CHANNEL_CHANGE_FAILURE);
121 		CASE_RETURN_STR(eCSR_ROAM_RESULT_CSA_RESTART_RSP);
122 		CASE_RETURN_STR(eCSR_ROAM_RESULT_DFS_CHANSW_UPDATE_SUCCESS);
123 		CASE_RETURN_STR(eCSR_ROAM_EXT_CHG_CHNL_UPDATE_IND);
124 		CASE_RETURN_STR(eCSR_ROAM_RESULT_NDI_CREATE_RSP);
125 		CASE_RETURN_STR(eCSR_ROAM_RESULT_NDI_DELETE_RSP);
126 		CASE_RETURN_STR(eCSR_ROAM_RESULT_NDP_INITIATOR_RSP);
127 		CASE_RETURN_STR(eCSR_ROAM_RESULT_NDP_NEW_PEER_IND);
128 		CASE_RETURN_STR(eCSR_ROAM_RESULT_NDP_CONFIRM_IND);
129 		CASE_RETURN_STR(eCSR_ROAM_RESULT_NDP_INDICATION);
130 		CASE_RETURN_STR(eCSR_ROAM_RESULT_NDP_SCHED_UPDATE_RSP);
131 		CASE_RETURN_STR(eCSR_ROAM_RESULT_NDP_RESPONDER_RSP);
132 		CASE_RETURN_STR(eCSR_ROAM_RESULT_NDP_END_RSP);
133 		CASE_RETURN_STR(eCSR_ROAM_RESULT_NDP_PEER_DEPARTED_IND);
134 		CASE_RETURN_STR(eCSR_ROAM_RESULT_NDP_END_IND);
135 		CASE_RETURN_STR(eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE);
136 	default:
137 		return "unknown";
138 	}
139 }
140 
csr_phy_mode_str(eCsrPhyMode phy_mode)141 const char *csr_phy_mode_str(eCsrPhyMode phy_mode)
142 {
143 	switch (phy_mode) {
144 	case eCSR_DOT11_MODE_abg:
145 		return "abg";
146 	case eCSR_DOT11_MODE_11a:
147 		return "11a";
148 	case eCSR_DOT11_MODE_11b:
149 		return "11b";
150 	case eCSR_DOT11_MODE_11g:
151 		return "11g";
152 	case eCSR_DOT11_MODE_11n:
153 		return "11n";
154 	case eCSR_DOT11_MODE_11g_ONLY:
155 		return "11g_only";
156 	case eCSR_DOT11_MODE_11n_ONLY:
157 		return "11n_only";
158 	case eCSR_DOT11_MODE_11b_ONLY:
159 		return "11b_only";
160 	case eCSR_DOT11_MODE_11ac:
161 		return "11ac";
162 	case eCSR_DOT11_MODE_11ac_ONLY:
163 		return "11ac_only";
164 	case eCSR_DOT11_MODE_AUTO:
165 		return "auto";
166 	case eCSR_DOT11_MODE_11ax:
167 		return "11ax";
168 	case eCSR_DOT11_MODE_11ax_ONLY:
169 		return "11ax_only";
170 	case eCSR_DOT11_MODE_11be:
171 		return "11be";
172 	case eCSR_DOT11_MODE_11be_ONLY:
173 		return "11be_only";
174 	default:
175 		return "unknown";
176 	}
177 }
178 
csr_purge_pdev_all_ser_cmd_list(struct mac_context * mac_ctx)179 void csr_purge_pdev_all_ser_cmd_list(struct mac_context *mac_ctx)
180 {
181 	wlan_serialization_purge_all_pdev_cmd(mac_ctx->pdev);
182 }
183 
csr_nonscan_active_ll_peek_head(struct mac_context * mac_ctx,bool inter_locked)184 tListElem *csr_nonscan_active_ll_peek_head(struct mac_context *mac_ctx,
185 					   bool inter_locked)
186 {
187 	struct wlan_serialization_command *cmd;
188 	tSmeCmd *sme_cmd;
189 
190 	cmd = wlan_serialization_peek_head_active_cmd_using_psoc(mac_ctx->psoc,
191 								 false);
192 	if (!cmd || cmd->source != WLAN_UMAC_COMP_MLME)
193 		return NULL;
194 
195 	sme_cmd = cmd->umac_cmd;
196 
197 	return &sme_cmd->Link;
198 }
199 
csr_nonscan_pending_ll_peek_head(struct mac_context * mac_ctx,bool inter_locked)200 tListElem *csr_nonscan_pending_ll_peek_head(struct mac_context *mac_ctx,
201 					    bool inter_locked)
202 {
203 	struct wlan_serialization_command *cmd;
204 	tSmeCmd *sme_cmd;
205 
206 	cmd = wlan_serialization_peek_head_pending_cmd_using_psoc(mac_ctx->psoc,
207 								  false);
208 	while (cmd) {
209 		if (cmd->source == WLAN_UMAC_COMP_MLME) {
210 			sme_cmd = cmd->umac_cmd;
211 			return &sme_cmd->Link;
212 		}
213 		cmd = wlan_serialization_get_pending_list_next_node_using_psoc(
214 						mac_ctx->psoc, cmd, false);
215 	}
216 
217 	return NULL;
218 }
219 
csr_nonscan_active_ll_remove_entry(struct mac_context * mac_ctx,tListElem * entry,bool inter_locked)220 bool csr_nonscan_active_ll_remove_entry(struct mac_context *mac_ctx,
221 					tListElem *entry, bool inter_locked)
222 {
223 	tListElem *head;
224 
225 	head = csr_nonscan_active_ll_peek_head(mac_ctx, inter_locked);
226 	if (head == entry)
227 	return true;
228 
229 	return false;
230 }
231 
csr_nonscan_pending_ll_next(struct mac_context * mac_ctx,tListElem * entry,bool inter_locked)232 tListElem *csr_nonscan_pending_ll_next(struct mac_context *mac_ctx,
233 				       tListElem *entry, bool inter_locked)
234 {
235 	tSmeCmd *sme_cmd;
236 	struct wlan_serialization_command cmd, *tcmd;
237 
238 	if (!entry)
239 		return NULL;
240 	sme_cmd = GET_BASE_ADDR(entry, tSmeCmd, Link);
241 	cmd.cmd_id = sme_cmd->cmd_id;
242 	cmd.cmd_type = csr_get_cmd_type(sme_cmd);
243 	cmd.vdev = wlan_objmgr_get_vdev_by_id_from_psoc_no_state(
244 				mac_ctx->psoc,
245 				sme_cmd->vdev_id, WLAN_LEGACY_SME_ID);
246 	tcmd = wlan_serialization_get_pending_list_next_node_using_psoc(
247 				mac_ctx->psoc, &cmd, false);
248 	if (cmd.vdev)
249 		wlan_objmgr_vdev_release_ref(cmd.vdev, WLAN_LEGACY_SME_ID);
250 	while (tcmd) {
251 		if (tcmd->source == WLAN_UMAC_COMP_MLME) {
252 			sme_cmd = tcmd->umac_cmd;
253 			return &sme_cmd->Link;
254 		}
255 		tcmd = wlan_serialization_get_pending_list_next_node_using_psoc(
256 						mac_ctx->psoc, tcmd, false);
257 	}
258 
259 	return NULL;
260 }
261 
csr_is_conn_state(struct mac_context * mac_ctx,uint32_t session_id,eCsrConnectState state)262 static bool csr_is_conn_state(struct mac_context *mac_ctx, uint32_t session_id,
263 			      eCsrConnectState state)
264 {
265 	QDF_BUG(session_id < WLAN_MAX_VDEVS);
266 	if (session_id >= WLAN_MAX_VDEVS)
267 		return false;
268 
269 	return mac_ctx->roam.roamSession[session_id].connectState == state;
270 }
271 
csr_is_conn_state_connected(struct mac_context * mac,uint32_t sessionId)272 bool csr_is_conn_state_connected(struct mac_context *mac, uint32_t sessionId)
273 {
274 	return cm_is_vdevid_connected(mac->pdev, sessionId) ||
275 	       csr_is_conn_state_connected_wds(mac, sessionId);
276 }
277 
csr_is_conn_state_connected_wds(struct mac_context * mac_ctx,uint32_t session_id)278 bool csr_is_conn_state_connected_wds(struct mac_context *mac_ctx,
279 				     uint32_t session_id)
280 {
281 	return csr_is_conn_state(mac_ctx, session_id,
282 				 eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED);
283 }
284 
csr_is_conn_state_connected_infra_ap(struct mac_context * mac_ctx,uint32_t session_id)285 bool csr_is_conn_state_connected_infra_ap(struct mac_context *mac_ctx,
286 					  uint32_t session_id)
287 {
288 	return csr_is_conn_state(mac_ctx, session_id,
289 				 eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED) ||
290 		csr_is_conn_state(mac_ctx, session_id,
291 				  eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED);
292 }
293 
csr_is_conn_state_disconnected_wds(struct mac_context * mac_ctx,uint32_t session_id)294 bool csr_is_conn_state_disconnected_wds(struct mac_context *mac_ctx,
295 					uint32_t session_id)
296 {
297 	return csr_is_conn_state(mac_ctx, session_id,
298 				 eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED);
299 }
300 
csr_is_conn_state_wds(struct mac_context * mac,uint32_t sessionId)301 bool csr_is_conn_state_wds(struct mac_context *mac, uint32_t sessionId)
302 {
303 	return csr_is_conn_state_connected_wds(mac, sessionId) ||
304 	       csr_is_conn_state_disconnected_wds(mac, sessionId);
305 }
306 
cm_csr_get_vdev_dot11_mode(uint8_t vdev_id)307 uint16_t cm_csr_get_vdev_dot11_mode(uint8_t vdev_id)
308 {
309 	mac_handle_t mac_handle;
310 	struct mac_context *mac_ctx;
311 	enum csr_cfgdot11mode curr_dot11_mode;
312 
313 	mac_handle = cds_get_context(QDF_MODULE_ID_SME);
314 	mac_ctx = MAC_CONTEXT(mac_handle);
315 	if (!mac_ctx)
316 		return eCSR_CFG_DOT11_MODE_AUTO;
317 
318 	curr_dot11_mode = mac_ctx->roam.configParam.uCfgDot11Mode;
319 
320 	return csr_get_vdev_dot11_mode(mac_ctx, vdev_id, curr_dot11_mode);
321 }
322 
323 enum csr_cfgdot11mode
csr_get_vdev_dot11_mode(struct mac_context * mac,uint8_t vdev_id,enum csr_cfgdot11mode curr_dot11_mode)324 csr_get_vdev_dot11_mode(struct mac_context *mac,
325 			uint8_t vdev_id,
326 			enum csr_cfgdot11mode curr_dot11_mode)
327 {
328 	struct wlan_objmgr_vdev *vdev;
329 	struct vdev_mlme_obj *vdev_mlme;
330 	enum mlme_vdev_dot11_mode vdev_dot11_mode;
331 	enum csr_cfgdot11mode dot11_mode = curr_dot11_mode;
332 
333 	vdev = wlan_objmgr_get_vdev_by_id_from_pdev(mac->pdev, vdev_id,
334 						    WLAN_MLME_OBJMGR_ID);
335 	if (!vdev)
336 		return curr_dot11_mode;
337 
338 	vdev_mlme = wlan_vdev_mlme_get_cmpt_obj(vdev);
339 	if (!vdev_mlme) {
340 		wlan_objmgr_vdev_release_ref(vdev, WLAN_MLME_OBJMGR_ID);
341 		return curr_dot11_mode;
342 	}
343 
344 	vdev_dot11_mode = vdev_mlme->proto.vdev_dot11_mode;
345 	wlan_objmgr_vdev_release_ref(vdev, WLAN_MLME_OBJMGR_ID);
346 
347 	if (vdev_dot11_mode == MLME_VDEV_DOT11_MODE_AUTO)
348 		dot11_mode = curr_dot11_mode;
349 
350 	if (CSR_IS_DOT11_MODE_11N(curr_dot11_mode) &&
351 	    vdev_dot11_mode == MLME_VDEV_DOT11_MODE_11N)
352 		dot11_mode = eCSR_CFG_DOT11_MODE_11N;
353 
354 	if (CSR_IS_DOT11_MODE_11AC(curr_dot11_mode) &&
355 	    vdev_dot11_mode == MLME_VDEV_DOT11_MODE_11AC)
356 		dot11_mode = eCSR_CFG_DOT11_MODE_11AC;
357 
358 	if (CSR_IS_DOT11_MODE_11AX(curr_dot11_mode) &&
359 	    vdev_dot11_mode == MLME_VDEV_DOT11_MODE_11AX)
360 		dot11_mode = eCSR_CFG_DOT11_MODE_11AX;
361 #ifdef WLAN_FEATURE_11BE
362 	if (CSR_IS_DOT11_MODE_11BE(curr_dot11_mode) &&
363 	    vdev_dot11_mode == MLME_VDEV_DOT11_MODE_11BE)
364 		dot11_mode = eCSR_CFG_DOT11_MODE_11BE;
365 #endif
366 	sme_debug("INI vdev_dot11_mode %d new dot11_mode %d",
367 		  vdev_dot11_mode, dot11_mode);
368 
369 	return dot11_mode;
370 }
371 
csr_is_conn_state_ap(struct mac_context * mac,uint32_t sessionId)372 static bool csr_is_conn_state_ap(struct mac_context *mac, uint32_t sessionId)
373 {
374 	enum QDF_OPMODE opmode;
375 
376 	opmode = wlan_get_opmode_from_vdev_id(mac->pdev, sessionId);
377 	if (opmode == QDF_SAP_MODE || opmode == QDF_P2P_GO_MODE)
378 		return true;
379 
380 	return false;
381 }
382 
csr_is_any_session_in_connect_state(struct mac_context * mac)383 bool csr_is_any_session_in_connect_state(struct mac_context *mac)
384 {
385 	uint32_t i;
386 
387 	for (i = 0; i < WLAN_MAX_VDEVS; i++) {
388 		if (CSR_IS_SESSION_VALID(mac, i) &&
389 		    (cm_is_vdevid_connected(mac->pdev, i) ||
390 		     csr_is_conn_state_ap(mac, i))) {
391 			return true;
392 		}
393 	}
394 
395 	return false;
396 }
397 
csr_get_concurrent_operation_freq(struct mac_context * mac_ctx)398 qdf_freq_t csr_get_concurrent_operation_freq(struct mac_context *mac_ctx)
399 {
400 	uint8_t i = 0;
401 	qdf_freq_t freq;
402 	enum QDF_OPMODE op_mode;
403 
404 	for (i = 0; i < WLAN_MAX_VDEVS; i++) {
405 		op_mode = wlan_get_opmode_from_vdev_id(mac_ctx->pdev, i);
406 		/* check only for STA, CLI, GO and SAP */
407 		if (op_mode != QDF_STA_MODE && op_mode != QDF_P2P_CLIENT_MODE &&
408 		    op_mode != QDF_P2P_GO_MODE && op_mode != QDF_SAP_MODE)
409 			continue;
410 
411 		freq = wlan_get_operation_chan_freq_vdev_id(mac_ctx->pdev, i);
412 		if (!freq)
413 			continue;
414 
415 		return freq;
416 	}
417 
418 	return 0;
419 }
420 
csr_get_beaconing_concurrent_channel(struct mac_context * mac_ctx,uint8_t vdev_id_to_skip)421 uint32_t csr_get_beaconing_concurrent_channel(struct mac_context *mac_ctx,
422 					     uint8_t vdev_id_to_skip)
423 {
424 	struct csr_roam_session *session = NULL;
425 	uint8_t i = 0;
426 	enum QDF_OPMODE persona;
427 
428 	for (i = 0; i < WLAN_MAX_VDEVS; i++) {
429 		if (i == vdev_id_to_skip)
430 			continue;
431 		if (!CSR_IS_SESSION_VALID(mac_ctx, i))
432 			continue;
433 		session = CSR_GET_SESSION(mac_ctx, i);
434 		persona = wlan_get_opmode_from_vdev_id(mac_ctx->pdev, i);
435 		if (((persona == QDF_P2P_GO_MODE) ||
436 		     (persona == QDF_SAP_MODE)) &&
437 		     (session->connectState !=
438 		      eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED))
439 			return wlan_get_operation_chan_freq_vdev_id(mac_ctx->pdev, i);
440 	}
441 
442 	return 0;
443 }
444 
445 #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
446 
447 #define HALF_BW_OF(eCSR_bw_val) ((eCSR_bw_val)/2)
448 
449 /* calculation of center channel based on V/HT BW and WIFI channel bw=5MHz) */
450 
451 #define CSR_GET_HT40_PLUS_CCH(och) ((och) + 10)
452 #define CSR_GET_HT40_MINUS_CCH(och) ((och) - 10)
453 
454 #define CSR_GET_HT80_PLUS_LL_CCH(och) ((och) + 30)
455 #define CSR_GET_HT80_PLUS_HL_CCH(och) ((och) + 30)
456 #define CSR_GET_HT80_MINUS_LH_CCH(och) ((och) - 10)
457 #define CSR_GET_HT80_MINUS_HH_CCH(och) ((och) - 30)
458 
459 /**
460  * csr_calc_chb_for_sap_phymode() - to calc channel bandwidth for sap phymode
461  * @mac_ctx: pointer to mac context
462  * @sap_ch: SAP operating channel
463  * @sap_phymode: SAP physical mode
464  * @sap_cch: concurrency channel
465  * @sap_hbw: SAP half bw
466  * @chb: channel bandwidth
467  *
468  * This routine is called to calculate channel bandwidth
469  *
470  * Return: none
471  */
csr_calc_chb_for_sap_phymode(struct mac_context * mac_ctx,uint32_t * sap_ch,eCsrPhyMode * sap_phymode,uint32_t * sap_cch,uint32_t * sap_hbw,uint8_t * chb)472 static void csr_calc_chb_for_sap_phymode(struct mac_context *mac_ctx,
473 		uint32_t *sap_ch, eCsrPhyMode *sap_phymode,
474 		uint32_t *sap_cch, uint32_t *sap_hbw, uint8_t *chb)
475 {
476 	if (*sap_phymode == eCSR_DOT11_MODE_11n ||
477 			*sap_phymode == eCSR_DOT11_MODE_11n_ONLY) {
478 
479 		*sap_hbw = HALF_BW_OF(eCSR_BW_40MHz_VAL);
480 		if (*chb == PHY_DOUBLE_CHANNEL_LOW_PRIMARY)
481 			*sap_cch = CSR_GET_HT40_PLUS_CCH(*sap_ch);
482 		else if (*chb == PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
483 			*sap_cch = CSR_GET_HT40_MINUS_CCH(*sap_ch);
484 
485 	} else if (*sap_phymode == eCSR_DOT11_MODE_11ac ||
486 		   *sap_phymode == eCSR_DOT11_MODE_11ac_ONLY ||
487 		   *sap_phymode == eCSR_DOT11_MODE_11ax ||
488 		   *sap_phymode == eCSR_DOT11_MODE_11ax_ONLY ||
489 		   CSR_IS_DOT11_PHY_MODE_11BE(*sap_phymode) ||
490 		   CSR_IS_DOT11_PHY_MODE_11BE_ONLY(*sap_phymode)) {
491 		/*11AC only 80/40/20 Mhz supported in Rome */
492 		if (mac_ctx->roam.configParam.nVhtChannelWidth ==
493 				(WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ + 1)) {
494 			*sap_hbw = HALF_BW_OF(eCSR_BW_80MHz_VAL);
495 			if (*chb ==
496 				(PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW - 1))
497 				*sap_cch = CSR_GET_HT80_PLUS_LL_CCH(*sap_ch);
498 			else if (*chb ==
499 				(PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW
500 				     - 1))
501 				*sap_cch = CSR_GET_HT80_PLUS_HL_CCH(*sap_ch);
502 			else if (*chb ==
503 				 (PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH
504 				     - 1))
505 				*sap_cch = CSR_GET_HT80_MINUS_LH_CCH(*sap_ch);
506 			else if (*chb ==
507 				(PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH
508 				     - 1))
509 				*sap_cch = CSR_GET_HT80_MINUS_HH_CCH(*sap_ch);
510 		} else {
511 			*sap_hbw = HALF_BW_OF(eCSR_BW_40MHz_VAL);
512 			if (*chb == (PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW
513 					- 1))
514 				*sap_cch = CSR_GET_HT40_PLUS_CCH(*sap_ch);
515 			else if (*chb ==
516 				(PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW
517 				     - 1))
518 				*sap_cch = CSR_GET_HT40_MINUS_CCH(*sap_ch);
519 			else if (*chb ==
520 				(PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH
521 				     - 1))
522 				*sap_cch = CSR_GET_HT40_PLUS_CCH(*sap_ch);
523 			else if (*chb ==
524 				(PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH
525 				     - 1))
526 				*sap_cch = CSR_GET_HT40_MINUS_CCH(*sap_ch);
527 		}
528 	}
529 }
530 
csr_get_half_bw(enum phy_ch_width ch_width)531 static eCSR_BW_Val csr_get_half_bw(enum phy_ch_width ch_width)
532 {
533 	eCSR_BW_Val hw_bw = HALF_BW_OF(eCSR_BW_20MHz_VAL);
534 
535 	switch (ch_width) {
536 	case CH_WIDTH_40MHZ:
537 		hw_bw = HALF_BW_OF(eCSR_BW_40MHz_VAL);
538 		break;
539 	case CH_WIDTH_80MHZ:
540 		hw_bw = HALF_BW_OF(eCSR_BW_80MHz_VAL);
541 		break;
542 	case CH_WIDTH_160MHZ:
543 	case CH_WIDTH_80P80MHZ:
544 		hw_bw = HALF_BW_OF(eCSR_BW_160MHz_VAL);
545 		break;
546 	default:
547 		break;
548 	}
549 
550 	return hw_bw;
551 }
552 
553 /**
554  * csr_handle_conc_chnl_overlap_for_sap_go - To handle overlap for AP+AP
555  * @mac_ctx: pointer to mac context
556  * @session: Current session
557  * @sap_ch_freq: SAP/GO operating channel frequency
558  * @sap_hbw: SAP/GO half bw
559  * @sap_cfreq: SAP/GO channel frequency
560  * @intf_ch_freq: concurrent SAP/GO operating channel frequency
561  * @intf_hbw: concurrent SAP/GO half bw
562  * @intf_cfreq: concurrent SAP/GO channel frequency
563  * @op_mode: opmode
564  *
565  * This routine is called to check if one SAP/GO channel is overlapping with
566  * other SAP/GO channel
567  *
568  * Return: none
569  */
csr_handle_conc_chnl_overlap_for_sap_go(struct mac_context * mac_ctx,struct csr_roam_session * session,uint32_t * sap_ch_freq,uint32_t * sap_hbw,uint32_t * sap_cfreq,uint32_t * intf_ch_freq,uint32_t * intf_hbw,uint32_t * intf_cfreq,enum QDF_OPMODE op_mode,uint8_t cc_switch_mode)570 static void csr_handle_conc_chnl_overlap_for_sap_go(
571 		struct mac_context *mac_ctx,
572 		struct csr_roam_session *session,
573 		uint32_t *sap_ch_freq, uint32_t *sap_hbw, uint32_t *sap_cfreq,
574 		uint32_t *intf_ch_freq, uint32_t *intf_hbw,
575 		uint32_t *intf_cfreq, enum QDF_OPMODE op_mode,
576 		uint8_t cc_switch_mode)
577 {
578 	qdf_freq_t op_chan_freq;
579 	qdf_freq_t freq_seg_0;
580 	enum phy_ch_width ch_width;
581 
582 	wlan_get_op_chan_freq_info_vdev_id(mac_ctx->pdev, session->vdev_id,
583 					   &op_chan_freq, &freq_seg_0,
584 					   &ch_width);
585 	sme_debug("op_chan_freq:%d freq_seg_0:%d ch_width:%d",
586 		  op_chan_freq, freq_seg_0, ch_width);
587 	/*
588 	 * if conc_custom_rule1 is defined then we don't
589 	 * want p2pgo to follow SAP's channel or SAP to
590 	 * follow P2PGO's channel.
591 	 */
592 	if (0 == mac_ctx->roam.configParam.conc_custom_rule1 &&
593 		0 == mac_ctx->roam.configParam.conc_custom_rule2) {
594 		if (*sap_ch_freq == 0) {
595 			*sap_ch_freq = op_chan_freq;
596 			*sap_cfreq = freq_seg_0;
597 			*sap_hbw = csr_get_half_bw(ch_width);
598 		} else if (*sap_ch_freq != op_chan_freq ||
599 			   (cc_switch_mode ==
600 				QDF_MCC_TO_SCC_SWITCH_WITH_FAVORITE_CHANNEL &&
601 			    op_mode == QDF_P2P_GO_MODE)) {
602 			*intf_ch_freq = op_chan_freq;
603 			*intf_cfreq = freq_seg_0;
604 			*intf_hbw = csr_get_half_bw(ch_width);
605 		}
606 	} else if (*sap_ch_freq == 0 && op_mode == QDF_SAP_MODE) {
607 		*sap_ch_freq = op_chan_freq;
608 		*sap_cfreq = freq_seg_0;
609 		*sap_hbw = csr_get_half_bw(ch_width);
610 	}
611 }
612 
csr_check_concurrent_channel_overlap(struct mac_context * mac_ctx,uint32_t sap_ch_freq,eCsrPhyMode sap_phymode,uint8_t cc_switch_mode,uint8_t vdev_id)613 uint16_t csr_check_concurrent_channel_overlap(struct mac_context *mac_ctx,
614 			uint32_t sap_ch_freq, eCsrPhyMode sap_phymode,
615 			uint8_t cc_switch_mode, uint8_t vdev_id)
616 {
617 	struct csr_roam_session *session = NULL;
618 	uint8_t i = 0, chb = PHY_SINGLE_CHANNEL_CENTERED;
619 	uint32_t intf_ch_freq = 0, sap_hbw = 0, intf_hbw = 0, intf_cfreq = 0;
620 	uint32_t sap_cfreq = 0;
621 	uint32_t sap_lfreq, sap_hfreq, intf_lfreq, intf_hfreq;
622 	QDF_STATUS status;
623 	enum QDF_OPMODE op_mode;
624 	enum phy_ch_width ch_width;
625 	enum channel_state state;
626 
627 #ifdef WLAN_FEATURE_LL_LT_SAP
628 	qdf_freq_t new_sap_freq = 0;
629 	bool is_ll_lt_sap_present = false;
630 #endif
631 
632 	if (mac_ctx->roam.configParam.cc_switch_mode ==
633 			QDF_MCC_TO_SCC_SWITCH_DISABLE)
634 		return 0;
635 
636 	/*
637 	 * This is temporary code and will be removed once this feature flag
638 	 * is enabled
639 	 */
640 #ifndef WLAN_FEATURE_LL_LT_SAP
641 		if (policy_mgr_is_vdev_ll_lt_sap(mac_ctx->psoc, vdev_id))
642 			return 0;
643 #else
644 	policy_mgr_ll_lt_sap_get_valid_freq(
645 				mac_ctx->psoc, mac_ctx->pdev,
646 				vdev_id, sap_ch_freq,
647 				mac_ctx->roam.configParam.cc_switch_mode,
648 				&new_sap_freq,
649 				&is_ll_lt_sap_present);
650 	/*
651 	 * If ll_lt_sap is present, then it has already updated the frequency
652 	 * according to current concurrency, so, return from here
653 	 */
654 	if (is_ll_lt_sap_present) {
655 		if (new_sap_freq == sap_ch_freq)
656 			return 0;
657 
658 		sme_debug("LL_LT_SAP concurrency updated freq %d for vdev %d",
659 			  new_sap_freq, vdev_id);
660 		return new_sap_freq;
661 	}
662 #endif
663 
664 	if (sap_ch_freq != 0) {
665 		sap_cfreq = sap_ch_freq;
666 		sap_hbw = HALF_BW_OF(eCSR_BW_20MHz_VAL);
667 
668 		if (!WLAN_REG_IS_24GHZ_CH_FREQ(sap_ch_freq))
669 			chb = mac_ctx->roam.configParam.channelBondingMode5GHz;
670 		else
671 			chb = mac_ctx->roam.configParam.channelBondingMode24GHz;
672 
673 		if (chb)
674 			csr_calc_chb_for_sap_phymode(mac_ctx, &sap_ch_freq,
675 						     &sap_phymode, &sap_cfreq,
676 						     &sap_hbw, &chb);
677 	}
678 
679 	sme_debug("sap_ch:%d sap_phymode:%d sap_cch:%d sap_hbw:%d chb:%d",
680 		  sap_ch_freq, sap_phymode, sap_cfreq, sap_hbw, chb);
681 
682 	for (i = 0; i < WLAN_MAX_VDEVS; i++) {
683 		if (!CSR_IS_SESSION_VALID(mac_ctx, i))
684 			continue;
685 
686 		session = CSR_GET_SESSION(mac_ctx, i);
687 		op_mode = wlan_get_opmode_from_vdev_id(mac_ctx->pdev, i);
688 		if ((op_mode == QDF_STA_MODE ||
689 		     op_mode == QDF_P2P_CLIENT_MODE) &&
690 		    cm_is_vdevid_connected(mac_ctx->pdev, i)) {
691 			if (op_mode == QDF_STA_MODE &&
692 			    policy_mgr_is_ml_vdev_id(mac_ctx->psoc,
693 						     session->vdev_id) &&
694 			    policy_mgr_vdev_is_force_inactive(
695 							mac_ctx->psoc,
696 							session->vdev_id)) {
697 				sme_debug("skip inactive ml sta vdev %d",
698 					  session->vdev_id);
699 				continue;
700 			}
701 			wlan_get_op_chan_freq_info_vdev_id(mac_ctx->pdev,
702 					   session->vdev_id,
703 					   &intf_ch_freq, &intf_cfreq,
704 					   &ch_width);
705 			intf_hbw = csr_get_half_bw(ch_width);
706 			sme_debug("%d: intf_ch:%d intf_cfreq:%d intf_hbw:%d ch_width %d",
707 				  i, intf_ch_freq, intf_cfreq, intf_hbw,
708 				  ch_width);
709 		} else if ((op_mode == QDF_P2P_GO_MODE ||
710 			    op_mode == QDF_SAP_MODE) &&
711 			   (session->connectState !=
712 			     eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED)) {
713 
714 			if (session->ch_switch_in_progress)
715 				continue;
716 
717 			csr_handle_conc_chnl_overlap_for_sap_go(mac_ctx,
718 					session, &sap_ch_freq, &sap_hbw,
719 					&sap_cfreq, &intf_ch_freq, &intf_hbw,
720 					&intf_cfreq, op_mode,
721 					cc_switch_mode);
722 		}
723 
724 		if (intf_ch_freq) {
725 			state = wlan_reg_get_channel_state_for_pwrmode(
726 					mac_ctx->pdev, intf_ch_freq,
727 					REG_CURRENT_PWR_MODE);
728 			if (state == CHANNEL_STATE_DISABLE ||
729 			    state == CHANNEL_STATE_INVALID) {
730 				sme_debug("skip vdev %d for intf_ch:%d",
731 					  i, intf_ch_freq);
732 				intf_ch_freq = 0;
733 				continue;
734 			}
735 		}
736 
737 		if (intf_ch_freq &&
738 		    ((intf_ch_freq <= wlan_reg_ch_to_freq(CHAN_ENUM_2484) &&
739 		     sap_ch_freq <= wlan_reg_ch_to_freq(CHAN_ENUM_2484)) ||
740 		    (intf_ch_freq > wlan_reg_ch_to_freq(CHAN_ENUM_2484) &&
741 		     sap_ch_freq > wlan_reg_ch_to_freq(CHAN_ENUM_2484))))
742 			break;
743 	}
744 
745 	sme_debug("intf_ch:%d sap_ch:%d cc_switch_mode:%d, dbs:%d",
746 		  intf_ch_freq, sap_ch_freq, cc_switch_mode,
747 		  policy_mgr_is_hw_dbs_capable(mac_ctx->psoc));
748 
749 	if (intf_ch_freq && sap_ch_freq != intf_ch_freq &&
750 	    !policy_mgr_is_force_scc(mac_ctx->psoc)) {
751 		sap_lfreq = sap_cfreq - sap_hbw;
752 		sap_hfreq = sap_cfreq + sap_hbw;
753 		intf_lfreq = intf_cfreq - intf_hbw;
754 		intf_hfreq = intf_cfreq + intf_hbw;
755 
756 		sme_debug("SAP:  OCH: %03d CCH: %03d BW: %d LF: %d HF: %d INTF: OCH: %03d CF: %d BW: %d LF: %d HF: %d",
757 			sap_ch_freq, sap_cfreq, sap_hbw * 2,
758 			sap_lfreq, sap_hfreq, intf_ch_freq,
759 			intf_cfreq, intf_hbw * 2, intf_lfreq, intf_hfreq);
760 
761 		if (!(((sap_lfreq > intf_lfreq && sap_lfreq < intf_hfreq) ||
762 			(sap_hfreq > intf_lfreq && sap_hfreq < intf_hfreq)) ||
763 			((intf_lfreq > sap_lfreq && intf_lfreq < sap_hfreq) ||
764 			(intf_hfreq > sap_lfreq && intf_hfreq < sap_hfreq))))
765 			intf_ch_freq = 0;
766 	} else if (intf_ch_freq && sap_ch_freq != intf_ch_freq &&
767 		   (policy_mgr_is_force_scc(mac_ctx->psoc))) {
768 		policy_mgr_check_scc_channel(mac_ctx->psoc, &intf_ch_freq,
769 					     sap_ch_freq, vdev_id,
770 					     cc_switch_mode);
771 	} else if ((intf_ch_freq == sap_ch_freq) && (cc_switch_mode ==
772 				QDF_MCC_TO_SCC_SWITCH_WITH_FAVORITE_CHANNEL)) {
773 		status = policy_mgr_handle_go_sap_fav_channel(
774 					mac_ctx->psoc, vdev_id,
775 					sap_ch_freq, &intf_ch_freq);
776 		if (QDF_IS_STATUS_SUCCESS(status) &&
777 		    intf_ch_freq && intf_ch_freq != sap_ch_freq)
778 			goto end;
779 
780 		if (WLAN_REG_IS_24GHZ_CH_FREQ(intf_ch_freq) ||
781 		    WLAN_REG_IS_6GHZ_CHAN_FREQ(sap_ch_freq)) {
782 			status =
783 				policy_mgr_get_sap_mandatory_channel(
784 					mac_ctx->psoc, sap_ch_freq,
785 					&intf_ch_freq, vdev_id);
786 			if (QDF_IS_STATUS_ERROR(status))
787 				sme_err("no mandatory channel");
788 		}
789 	}
790 end:
791 	if (intf_ch_freq == sap_ch_freq)
792 		intf_ch_freq = 0;
793 
794 	sme_debug("##Concurrent Channels (%d, %d) %s Interfering", sap_ch_freq,
795 		  intf_ch_freq,
796 		  intf_ch_freq == 0 ? "Not" : "Are");
797 
798 	return intf_ch_freq;
799 }
800 #endif
801 
csr_is_all_session_disconnected(struct mac_context * mac)802 bool csr_is_all_session_disconnected(struct mac_context *mac)
803 {
804 	uint32_t i;
805 	bool fRc = true;
806 
807 	for (i = 0; i < WLAN_MAX_VDEVS; i++) {
808 		if (CSR_IS_SESSION_VALID(mac, i)
809 		    && !csr_is_conn_state_disconnected(mac, i)) {
810 			fRc = false;
811 			break;
812 		}
813 	}
814 
815 	return fRc;
816 }
817 
csr_is_infra_ap_started(struct mac_context * mac)818 bool csr_is_infra_ap_started(struct mac_context *mac)
819 {
820 	uint32_t sessionId;
821 	bool fRc = false;
822 
823 	for (sessionId = 0; sessionId < WLAN_MAX_VDEVS; sessionId++) {
824 		if (CSR_IS_SESSION_VALID(mac, sessionId) &&
825 				(csr_is_conn_state_connected_infra_ap(mac,
826 					sessionId))) {
827 			fRc = true;
828 			break;
829 		}
830 	}
831 
832 	return fRc;
833 
834 }
835 
csr_is_conn_state_disconnected(struct mac_context * mac,uint8_t vdev_id)836 bool csr_is_conn_state_disconnected(struct mac_context *mac, uint8_t vdev_id)
837 {
838 	enum QDF_OPMODE opmode;
839 
840 	opmode = wlan_get_opmode_from_vdev_id(mac->pdev, vdev_id);
841 
842 	if (opmode == QDF_STA_MODE || opmode == QDF_P2P_CLIENT_MODE)
843 		return !cm_is_vdevid_connected(mac->pdev, vdev_id);
844 
845 	return eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED ==
846 	       mac->roam.roamSession[vdev_id].connectState;
847 }
848 
csr_is11h_supported(struct mac_context * mac)849 bool csr_is11h_supported(struct mac_context *mac)
850 {
851 	return mac->mlme_cfg->gen.enabled_11h;
852 }
853 
csr_is_wmm_supported(struct mac_context * mac)854 bool csr_is_wmm_supported(struct mac_context *mac)
855 {
856 	if (WMM_USER_MODE_NO_QOS == mac->roam.configParam.WMMSupportMode)
857 		return false;
858 	else
859 		return true;
860 }
861 
862 /* This function will allocate memory for the parsed IEs to the caller.
863  * Caller must free the memory after it is done with the data only if
864  * this function succeeds
865  */
csr_get_parsed_bss_description_ies(struct mac_context * mac_ctx,struct bss_description * bss_desc,tDot11fBeaconIEs ** ppIEStruct)866 QDF_STATUS csr_get_parsed_bss_description_ies(struct mac_context *mac_ctx,
867 					      struct bss_description *bss_desc,
868 					      tDot11fBeaconIEs **ppIEStruct)
869 {
870 	return wlan_get_parsed_bss_description_ies(mac_ctx, bss_desc,
871 						   ppIEStruct);
872 }
873 
csr_get_frag_thresh(struct mac_context * mac_ctx)874 uint32_t csr_get_frag_thresh(struct mac_context *mac_ctx)
875 {
876 	return mac_ctx->mlme_cfg->threshold.frag_threshold;
877 }
878 
csr_get_rts_thresh(struct mac_context * mac_ctx)879 uint32_t csr_get_rts_thresh(struct mac_context *mac_ctx)
880 {
881 	return mac_ctx->mlme_cfg->threshold.rts_threshold;
882 }
883 
csr_translate_to_wni_cfg_dot11_mode(struct mac_context * mac,enum csr_cfgdot11mode csrDot11Mode)884 uint32_t csr_translate_to_wni_cfg_dot11_mode(struct mac_context *mac,
885 					     enum csr_cfgdot11mode csrDot11Mode)
886 {
887 	uint32_t ret;
888 
889 	switch (csrDot11Mode) {
890 	case eCSR_CFG_DOT11_MODE_AUTO:
891 #ifdef WLAN_FEATURE_11BE
892 		if (IS_FEATURE_11BE_SUPPORTED_BY_FW)
893 			ret = MLME_DOT11_MODE_11BE;
894 		else
895 #endif
896 		if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AX))
897 			ret = MLME_DOT11_MODE_11AX;
898 		else if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
899 			ret = MLME_DOT11_MODE_11AC;
900 		else
901 			ret = MLME_DOT11_MODE_11N;
902 		break;
903 	case eCSR_CFG_DOT11_MODE_11A:
904 		ret = MLME_DOT11_MODE_11A;
905 		break;
906 	case eCSR_CFG_DOT11_MODE_11B:
907 		ret = MLME_DOT11_MODE_11B;
908 		break;
909 	case eCSR_CFG_DOT11_MODE_11G:
910 		ret = MLME_DOT11_MODE_11G;
911 		break;
912 	case eCSR_CFG_DOT11_MODE_11N:
913 		ret = MLME_DOT11_MODE_11N;
914 		break;
915 	case eCSR_CFG_DOT11_MODE_11G_ONLY:
916 		ret = MLME_DOT11_MODE_11G_ONLY;
917 		break;
918 	case eCSR_CFG_DOT11_MODE_11N_ONLY:
919 		ret = MLME_DOT11_MODE_11N_ONLY;
920 		break;
921 	case eCSR_CFG_DOT11_MODE_11AC_ONLY:
922 		if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
923 			ret = MLME_DOT11_MODE_11AC_ONLY;
924 		else
925 			ret = MLME_DOT11_MODE_11N;
926 		break;
927 	case eCSR_CFG_DOT11_MODE_11AC:
928 		if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
929 			ret = MLME_DOT11_MODE_11AC;
930 		else
931 			ret = MLME_DOT11_MODE_11N;
932 		break;
933 	case eCSR_CFG_DOT11_MODE_11AX_ONLY:
934 		if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AX))
935 			ret = MLME_DOT11_MODE_11AX_ONLY;
936 		else if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
937 			ret = MLME_DOT11_MODE_11AC;
938 		else
939 			ret = MLME_DOT11_MODE_11N;
940 		break;
941 	case eCSR_CFG_DOT11_MODE_11AX:
942 		if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AX))
943 			ret = MLME_DOT11_MODE_11AX;
944 		else if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
945 			ret = MLME_DOT11_MODE_11AC;
946 		else
947 			ret = MLME_DOT11_MODE_11N;
948 		break;
949 #ifdef WLAN_FEATURE_11BE
950 	case eCSR_CFG_DOT11_MODE_11BE_ONLY:
951 		if (IS_FEATURE_11BE_SUPPORTED_BY_FW)
952 			ret = MLME_DOT11_MODE_11BE_ONLY;
953 		else if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AX))
954 			ret = MLME_DOT11_MODE_11AX_ONLY;
955 		else if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
956 			ret = MLME_DOT11_MODE_11AC;
957 		else
958 			ret = MLME_DOT11_MODE_11N;
959 		break;
960 	case eCSR_CFG_DOT11_MODE_11BE:
961 		if (IS_FEATURE_11BE_SUPPORTED_BY_FW)
962 			ret = MLME_DOT11_MODE_11BE;
963 		else if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AX))
964 			ret = MLME_DOT11_MODE_11AX;
965 		else if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
966 			ret = MLME_DOT11_MODE_11AC;
967 		else
968 			ret = MLME_DOT11_MODE_11N;
969 		break;
970 #endif
971 	case eCSR_CFG_DOT11_MODE_ABG:
972 		ret = MLME_DOT11_MODE_ABG;
973 		break;
974 	default:
975 		sme_warn("doesn't expect %d as csrDo11Mode", csrDot11Mode);
976 		ret = MLME_DOT11_MODE_ALL;
977 		break;
978 	}
979 
980 	return ret;
981 }
982 
csr_convert_to_reg_phy_mode(eCsrPhyMode csr_phy_mode,qdf_freq_t freq)983 enum reg_phymode csr_convert_to_reg_phy_mode(eCsrPhyMode csr_phy_mode,
984 				       qdf_freq_t freq)
985 {
986 	if (csr_phy_mode == eCSR_DOT11_MODE_AUTO)
987 		return REG_PHYMODE_MAX - 1;
988 #ifdef WLAN_FEATURE_11BE
989 	else if (CSR_IS_DOT11_PHY_MODE_11BE(csr_phy_mode) ||
990 		 CSR_IS_DOT11_PHY_MODE_11BE_ONLY(csr_phy_mode))
991 		return REG_PHYMODE_11BE;
992 #endif
993 	else if (csr_phy_mode == eCSR_DOT11_MODE_11ax ||
994 		 csr_phy_mode == eCSR_DOT11_MODE_11ax_ONLY)
995 		return REG_PHYMODE_11AX;
996 	else if (csr_phy_mode == eCSR_DOT11_MODE_11ac ||
997 		 csr_phy_mode == eCSR_DOT11_MODE_11ac_ONLY)
998 		return REG_PHYMODE_11AC;
999 	else if (csr_phy_mode == eCSR_DOT11_MODE_11n ||
1000 		 csr_phy_mode == eCSR_DOT11_MODE_11n_ONLY)
1001 		return REG_PHYMODE_11N;
1002 	else if (csr_phy_mode == eCSR_DOT11_MODE_11a)
1003 		return REG_PHYMODE_11A;
1004 	else if (csr_phy_mode == eCSR_DOT11_MODE_11g ||
1005 		 csr_phy_mode == eCSR_DOT11_MODE_11g_ONLY)
1006 		return REG_PHYMODE_11G;
1007 	else if (csr_phy_mode == eCSR_DOT11_MODE_11b ||
1008 		 csr_phy_mode == eCSR_DOT11_MODE_11b_ONLY)
1009 		return REG_PHYMODE_11B;
1010 	else if (csr_phy_mode == eCSR_DOT11_MODE_abg) {
1011 		if (WLAN_REG_IS_24GHZ_CH_FREQ(freq))
1012 			return REG_PHYMODE_11G;
1013 		else
1014 			return REG_PHYMODE_11A;
1015 	} else {
1016 		sme_err("Invalid eCsrPhyMode");
1017 		return REG_PHYMODE_INVALID;
1018 	}
1019 }
1020 
csr_convert_from_reg_phy_mode(enum reg_phymode phymode)1021 eCsrPhyMode csr_convert_from_reg_phy_mode(enum reg_phymode phymode)
1022 {
1023 	switch (phymode) {
1024 	case REG_PHYMODE_INVALID:
1025 		return eCSR_DOT11_MODE_AUTO;
1026 	case REG_PHYMODE_11B:
1027 		return eCSR_DOT11_MODE_11b;
1028 	case REG_PHYMODE_11G:
1029 		return eCSR_DOT11_MODE_11g;
1030 	case REG_PHYMODE_11A:
1031 		return eCSR_DOT11_MODE_11a;
1032 	case REG_PHYMODE_11N:
1033 		return eCSR_DOT11_MODE_11n;
1034 	case REG_PHYMODE_11AC:
1035 		return eCSR_DOT11_MODE_11ac;
1036 	case REG_PHYMODE_11AX:
1037 		return eCSR_DOT11_MODE_11ax;
1038 #ifdef WLAN_FEATURE_11BE
1039 	case REG_PHYMODE_11BE:
1040 		return eCSR_DOT11_MODE_11be;
1041 #endif
1042 	case REG_PHYMODE_MAX:
1043 		return eCSR_DOT11_MODE_AUTO;
1044 	default:
1045 		return eCSR_DOT11_MODE_AUTO;
1046 	}
1047 }
1048 
csr_is_auth_type_ese(enum csr_akm_type AuthType)1049 bool csr_is_auth_type_ese(enum csr_akm_type AuthType)
1050 {
1051 	switch (AuthType) {
1052 	case eCSR_AUTH_TYPE_CCKM_WPA:
1053 	case eCSR_AUTH_TYPE_CCKM_RSN:
1054 		return true;
1055 	default:
1056 		break;
1057 	}
1058 	return false;
1059 }
1060 
csr_is_pmkid_found_for_peer(struct mac_context * mac,struct csr_roam_session * session,tSirMacAddr peer_mac_addr,uint8_t * pmkid,uint16_t pmkid_count)1061 bool csr_is_pmkid_found_for_peer(struct mac_context *mac,
1062 				 struct csr_roam_session *session,
1063 				 tSirMacAddr peer_mac_addr,
1064 				 uint8_t *pmkid,
1065 				 uint16_t pmkid_count)
1066 {
1067 	uint32_t i;
1068 	uint8_t *session_pmkid;
1069 	struct wlan_crypto_pmksa *pmkid_cache;
1070 
1071 	pmkid_cache = qdf_mem_malloc(sizeof(*pmkid_cache));
1072 	if (!pmkid_cache)
1073 		return false;
1074 
1075 	qdf_mem_copy(pmkid_cache->bssid.bytes, peer_mac_addr,
1076 		     QDF_MAC_ADDR_SIZE);
1077 
1078 	if (!cm_lookup_pmkid_using_bssid(mac->psoc, session->vdev_id,
1079 					 pmkid_cache)) {
1080 		qdf_mem_free(pmkid_cache);
1081 		return false;
1082 	}
1083 
1084 	session_pmkid = pmkid_cache->pmkid;
1085 	for (i = 0; i < pmkid_count; i++) {
1086 		if (!qdf_mem_cmp(pmkid + (i * PMKID_LEN),
1087 				 session_pmkid, PMKID_LEN)) {
1088 			qdf_mem_free(pmkid_cache);
1089 			return true;
1090 		}
1091 	}
1092 
1093 	sme_debug("PMKID in PmkidCacheInfo doesn't match with PMKIDs of peer");
1094 	qdf_mem_free(pmkid_cache);
1095 
1096 	return false;
1097 }
1098 
csr_is_bssid_match(struct qdf_mac_addr * pProfBssid,struct qdf_mac_addr * BssBssid)1099 bool csr_is_bssid_match(struct qdf_mac_addr *pProfBssid,
1100 			struct qdf_mac_addr *BssBssid)
1101 {
1102 	bool fMatch = false;
1103 	struct qdf_mac_addr ProfileBssid;
1104 
1105 	/* for efficiency of the MAC_ADDRESS functions, move the */
1106 	/* Bssid's into MAC_ADDRESS structs. */
1107 	qdf_mem_copy(&ProfileBssid, pProfBssid, sizeof(struct qdf_mac_addr));
1108 
1109 	do {
1110 		/* Give the profile the benefit of the doubt... accept
1111 		 * either all 0 or the real broadcast Bssid (all 0xff)
1112 		 * as broadcast Bssids (meaning to match any Bssids).
1113 		 */
1114 		if (qdf_is_macaddr_zero(&ProfileBssid) ||
1115 		    qdf_is_macaddr_broadcast(&ProfileBssid)) {
1116 			fMatch = true;
1117 			break;
1118 		}
1119 
1120 		if (qdf_is_macaddr_equal(BssBssid, &ProfileBssid)) {
1121 			fMatch = true;
1122 			break;
1123 		}
1124 
1125 	} while (0);
1126 
1127 	return fMatch;
1128 }
1129 
1130 /* This function use the parameters to decide the CFG value. */
1131 /* CSR never sets MLME_DOT11_MODE_ALL to the CFG */
1132 /* So PE should not see MLME_DOT11_MODE_ALL when it gets the CFG value */
1133 enum csr_cfgdot11mode
csr_get_cfg_dot11_mode_from_csr_phy_mode(bool is_ap,eCsrPhyMode phyMode)1134 csr_get_cfg_dot11_mode_from_csr_phy_mode(bool is_ap, eCsrPhyMode phyMode)
1135 {
1136 	uint32_t cfgDot11Mode = eCSR_CFG_DOT11_MODE_ABG;
1137 
1138 	switch (phyMode) {
1139 	case eCSR_DOT11_MODE_11a:
1140 		cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
1141 		break;
1142 	case eCSR_DOT11_MODE_11b:
1143 	case eCSR_DOT11_MODE_11b_ONLY:
1144 		cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
1145 		break;
1146 	case eCSR_DOT11_MODE_11g:
1147 	case eCSR_DOT11_MODE_11g_ONLY:
1148 		if (is_ap && (phyMode == eCSR_DOT11_MODE_11g_ONLY))
1149 			cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G_ONLY;
1150 		else
1151 			cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
1152 		break;
1153 	case eCSR_DOT11_MODE_11n:
1154 			cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
1155 		break;
1156 	case eCSR_DOT11_MODE_11n_ONLY:
1157 		if (is_ap)
1158 			cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N_ONLY;
1159 		else
1160 			cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
1161 		break;
1162 	case eCSR_DOT11_MODE_abg:
1163 		cfgDot11Mode = eCSR_CFG_DOT11_MODE_ABG;
1164 		break;
1165 	case eCSR_DOT11_MODE_AUTO:
1166 		cfgDot11Mode = eCSR_CFG_DOT11_MODE_AUTO;
1167 		break;
1168 
1169 	case eCSR_DOT11_MODE_11ac:
1170 		if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
1171 			cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
1172 		else
1173 			cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
1174 		break;
1175 	case eCSR_DOT11_MODE_11ac_ONLY:
1176 		if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
1177 			cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
1178 		else
1179 			cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
1180 		break;
1181 	case eCSR_DOT11_MODE_11ax:
1182 		if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AX))
1183 			cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AX;
1184 		else if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
1185 			cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
1186 		else
1187 			cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
1188 		break;
1189 	case eCSR_DOT11_MODE_11ax_ONLY:
1190 		if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AX))
1191 			cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AX_ONLY;
1192 		else if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
1193 			cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
1194 		else
1195 			cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
1196 		break;
1197 #ifdef WLAN_FEATURE_11BE
1198 	case eCSR_DOT11_MODE_11be:
1199 		if (IS_FEATURE_11BE_SUPPORTED_BY_FW)
1200 			cfgDot11Mode = eCSR_CFG_DOT11_MODE_11BE;
1201 		else if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AX))
1202 			cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AX;
1203 		else if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
1204 			cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
1205 		else
1206 			cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
1207 		break;
1208 	case eCSR_DOT11_MODE_11be_ONLY:
1209 		if (IS_FEATURE_11BE_SUPPORTED_BY_FW)
1210 			cfgDot11Mode = eCSR_CFG_DOT11_MODE_11BE_ONLY;
1211 		else if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AX))
1212 			cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AX_ONLY;
1213 		else if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
1214 			cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
1215 		else
1216 			cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
1217 		break;
1218 #endif
1219 	default:
1220 		/* No need to assign anything here */
1221 		break;
1222 	}
1223 
1224 	return cfgDot11Mode;
1225 }
1226 
csr_get_modify_profile_fields(struct mac_context * mac,uint32_t sessionId,tCsrRoamModifyProfileFields * pModifyProfileFields)1227 QDF_STATUS csr_get_modify_profile_fields(struct mac_context *mac,
1228 					uint32_t sessionId,
1229 					 tCsrRoamModifyProfileFields *
1230 					 pModifyProfileFields)
1231 {
1232 	if (!pModifyProfileFields)
1233 		return QDF_STATUS_E_FAILURE;
1234 
1235 	qdf_mem_copy(pModifyProfileFields,
1236 		     &mac->roam.roamSession[sessionId].modifyProfileFields,
1237 		     sizeof(tCsrRoamModifyProfileFields));
1238 
1239 	return QDF_STATUS_SUCCESS;
1240 }
1241 
csr_set_modify_profile_fields(struct mac_context * mac,uint32_t sessionId,tCsrRoamModifyProfileFields * pModifyProfileFields)1242 QDF_STATUS csr_set_modify_profile_fields(struct mac_context *mac,
1243 					uint32_t sessionId,
1244 					 tCsrRoamModifyProfileFields *
1245 					 pModifyProfileFields)
1246 {
1247 	struct csr_roam_session *pSession = CSR_GET_SESSION(mac, sessionId);
1248 
1249 	if (!pSession) {
1250 		sme_err("Session_id invalid %d", sessionId);
1251 		return QDF_STATUS_E_INVAL;
1252 	}
1253 
1254 	qdf_mem_copy(&pSession->modifyProfileFields,
1255 		     pModifyProfileFields, sizeof(tCsrRoamModifyProfileFields));
1256 
1257 	return QDF_STATUS_SUCCESS;
1258 }
1259 
1260 /* no need to acquire lock for this basic function */
sme_chn_to_freq(uint8_t chanNum)1261 uint16_t sme_chn_to_freq(uint8_t chanNum)
1262 {
1263 	int i;
1264 
1265 	for (i = 0; i < NUM_CHANNELS; i++) {
1266 		if (WLAN_REG_CH_NUM(i) == chanNum)
1267 			return WLAN_REG_CH_TO_FREQ(i);
1268 	}
1269 
1270 	return 0;
1271 }
1272 
sme_bss_type_to_string(const uint8_t bss_type)1273 const char *sme_bss_type_to_string(const uint8_t bss_type)
1274 {
1275 	switch (bss_type) {
1276 	CASE_RETURN_STRING(eCSR_BSS_TYPE_INFRASTRUCTURE);
1277 	CASE_RETURN_STRING(eCSR_BSS_TYPE_INFRA_AP);
1278 	CASE_RETURN_STRING(eCSR_BSS_TYPE_ANY);
1279 	default:
1280 		return "unknown bss type";
1281 	}
1282 }
1283 
1284 /**
1285  * csr_is_ndi_started() - function to check if NDI is started
1286  * @mac_ctx: handle to mac context
1287  * @session_id: session identifier
1288  *
1289  * returns: true if NDI is started, false otherwise
1290  */
csr_is_ndi_started(struct mac_context * mac_ctx,uint32_t session_id)1291 bool csr_is_ndi_started(struct mac_context *mac_ctx, uint32_t session_id)
1292 {
1293 	struct csr_roam_session *session = CSR_GET_SESSION(mac_ctx, session_id);
1294 
1295 	if (!session)
1296 		return false;
1297 
1298 	return eCSR_CONNECT_STATE_TYPE_NDI_STARTED == session->connectState;
1299 }
1300 
csr_is_mcc_channel(struct mac_context * mac_ctx,uint32_t chan_freq)1301 bool csr_is_mcc_channel(struct mac_context *mac_ctx, uint32_t chan_freq)
1302 {
1303 	struct csr_roam_session *session;
1304 	enum QDF_OPMODE oper_mode;
1305 	uint32_t oper_chan_freq = 0;
1306 	uint8_t vdev_id;
1307 	bool hw_dbs_capable, same_band_freqs;
1308 
1309 	if (chan_freq == 0)
1310 		return false;
1311 
1312 	hw_dbs_capable = policy_mgr_is_hw_dbs_capable(mac_ctx->psoc);
1313 	for (vdev_id = 0; vdev_id < WLAN_MAX_VDEVS; vdev_id++) {
1314 		if (!CSR_IS_SESSION_VALID(mac_ctx, vdev_id))
1315 			continue;
1316 
1317 		session = CSR_GET_SESSION(mac_ctx, vdev_id);
1318 		oper_mode =
1319 			wlan_get_opmode_from_vdev_id(mac_ctx->pdev, vdev_id);
1320 		if ((((oper_mode == QDF_STA_MODE) ||
1321 		     (oper_mode == QDF_P2P_CLIENT_MODE)) &&
1322 		    cm_is_vdevid_connected(mac_ctx->pdev, vdev_id)) ||
1323 		    (((oper_mode == QDF_P2P_GO_MODE) ||
1324 		      (oper_mode == QDF_SAP_MODE)) &&
1325 		     (session->connectState !=
1326 		      eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED)))
1327 			oper_chan_freq =
1328 			    wlan_get_operation_chan_freq_vdev_id(mac_ctx->pdev,
1329 								 vdev_id);
1330 
1331 		if (!oper_chan_freq)
1332 			continue;
1333 		same_band_freqs = WLAN_REG_IS_SAME_BAND_FREQS(
1334 			chan_freq, oper_chan_freq);
1335 
1336 		if (oper_chan_freq && chan_freq != oper_chan_freq &&
1337 		    (!hw_dbs_capable || same_band_freqs))
1338 			return true;
1339 	}
1340 
1341 	return false;
1342 }
1343 
csr_phy_mode_to_dot11mode(enum wlan_phymode phy_mode)1344 enum csr_cfgdot11mode csr_phy_mode_to_dot11mode(enum wlan_phymode phy_mode)
1345 {
1346 	switch (phy_mode) {
1347 	case WLAN_PHYMODE_AUTO:
1348 		return eCSR_CFG_DOT11_MODE_AUTO;
1349 	case WLAN_PHYMODE_11A:
1350 		return eCSR_CFG_DOT11_MODE_11A;
1351 	case WLAN_PHYMODE_11B:
1352 		return eCSR_CFG_DOT11_MODE_11B;
1353 	case WLAN_PHYMODE_11G:
1354 		return eCSR_CFG_DOT11_MODE_11G;
1355 	case WLAN_PHYMODE_11G_ONLY:
1356 		return eCSR_CFG_DOT11_MODE_11G_ONLY;
1357 	case WLAN_PHYMODE_11NA_HT20:
1358 	case WLAN_PHYMODE_11NG_HT20:
1359 	case WLAN_PHYMODE_11NA_HT40:
1360 	case WLAN_PHYMODE_11NG_HT40PLUS:
1361 	case WLAN_PHYMODE_11NG_HT40MINUS:
1362 	case WLAN_PHYMODE_11NG_HT40:
1363 		return eCSR_CFG_DOT11_MODE_11N;
1364 	case WLAN_PHYMODE_11AC_VHT20:
1365 	case WLAN_PHYMODE_11AC_VHT20_2G:
1366 	case WLAN_PHYMODE_11AC_VHT40:
1367 	case WLAN_PHYMODE_11AC_VHT40PLUS_2G:
1368 	case WLAN_PHYMODE_11AC_VHT40MINUS_2G:
1369 	case WLAN_PHYMODE_11AC_VHT40_2G:
1370 	case WLAN_PHYMODE_11AC_VHT80:
1371 	case WLAN_PHYMODE_11AC_VHT80_2G:
1372 	case WLAN_PHYMODE_11AC_VHT160:
1373 	case WLAN_PHYMODE_11AC_VHT80_80:
1374 		return eCSR_CFG_DOT11_MODE_11AC;
1375 	case WLAN_PHYMODE_11AXA_HE20:
1376 	case WLAN_PHYMODE_11AXG_HE20:
1377 	case WLAN_PHYMODE_11AXA_HE40:
1378 	case WLAN_PHYMODE_11AXG_HE40PLUS:
1379 	case WLAN_PHYMODE_11AXG_HE40MINUS:
1380 	case WLAN_PHYMODE_11AXG_HE40:
1381 	case WLAN_PHYMODE_11AXA_HE80:
1382 	case WLAN_PHYMODE_11AXG_HE80:
1383 	case WLAN_PHYMODE_11AXA_HE160:
1384 	case WLAN_PHYMODE_11AXA_HE80_80:
1385 		return eCSR_CFG_DOT11_MODE_11AX;
1386 #ifdef WLAN_FEATURE_11BE
1387 	case WLAN_PHYMODE_11BEA_EHT20:
1388 	case WLAN_PHYMODE_11BEG_EHT20:
1389 	case WLAN_PHYMODE_11BEA_EHT40:
1390 	case WLAN_PHYMODE_11BEG_EHT40PLUS:
1391 	case WLAN_PHYMODE_11BEG_EHT40MINUS:
1392 	case WLAN_PHYMODE_11BEG_EHT40:
1393 	case WLAN_PHYMODE_11BEA_EHT80:
1394 	case WLAN_PHYMODE_11BEG_EHT80:
1395 	case WLAN_PHYMODE_11BEA_EHT160:
1396 	case WLAN_PHYMODE_11BEA_EHT320:
1397 		return eCSR_CFG_DOT11_MODE_11BE;
1398 #endif
1399 	default:
1400 		sme_err("invalid phy mode %d", phy_mode);
1401 		return eCSR_CFG_DOT11_MODE_MAX;
1402 	}
1403 }
1404 
csr_mlme_vdev_disconnect_all_p2p_client_event(uint8_t vdev_id)1405 QDF_STATUS csr_mlme_vdev_disconnect_all_p2p_client_event(uint8_t vdev_id)
1406 {
1407 	struct mac_context *mac_ctx = cds_get_context(QDF_MODULE_ID_SME);
1408 
1409 	if (!mac_ctx)
1410 		return QDF_STATUS_E_FAILURE;
1411 
1412 	return csr_roam_call_callback(mac_ctx, vdev_id, NULL,
1413 				      eCSR_ROAM_DISCONNECT_ALL_P2P_CLIENTS,
1414 				      eCSR_ROAM_RESULT_NONE);
1415 }
1416 
csr_mlme_vdev_stop_bss(uint8_t vdev_id)1417 QDF_STATUS csr_mlme_vdev_stop_bss(uint8_t vdev_id)
1418 {
1419 	struct mac_context *mac_ctx = cds_get_context(QDF_MODULE_ID_SME);
1420 
1421 	if (!mac_ctx)
1422 		return QDF_STATUS_E_FAILURE;
1423 
1424 	return csr_roam_call_callback(mac_ctx, vdev_id, NULL,
1425 				      eCSR_ROAM_SEND_P2P_STOP_BSS,
1426 				      eCSR_ROAM_RESULT_NONE);
1427 }
1428 
csr_mlme_get_concurrent_operation_freq(void)1429 qdf_freq_t csr_mlme_get_concurrent_operation_freq(void)
1430 {
1431 	struct mac_context *mac_ctx = cds_get_context(QDF_MODULE_ID_SME);
1432 
1433 	if (!mac_ctx)
1434 		return QDF_STATUS_E_FAILURE;
1435 
1436 	return csr_get_concurrent_operation_freq(mac_ctx);
1437 }
1438