xref: /wlan-driver/qca-wifi-host-cmn/umac/mlme/vdev_mgr/dispatcher/src/wlan_vdev_mgr_utils_api.c (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2019-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: wlan_vdev_mgr_utils_api.c
22  *
23  * This file provide definition for APIs to enable Tx Ops and Rx Ops registered
24  * through LMAC
25  */
26 #include <wlan_vdev_mgr_utils_api.h>
27 #include <wlan_vdev_mgr_tgt_if_tx_api.h>
28 #include <cdp_txrx_cmn_struct.h>
29 #include <wlan_mlme_dbg.h>
30 #include <qdf_module.h>
31 #include <wlan_vdev_mgr_tgt_if_tx_api.h>
32 #include <wlan_dfs_mlme_api.h>
33 #ifndef MOBILE_DFS_SUPPORT
34 #include <wlan_dfs_utils_api.h>
35 #endif /* MOBILE_DFS_SUPPORT */
36 #ifdef WLAN_FEATURE_11BE_MLO
37 #include <wlan_utility.h>
38 #include <wlan_mlo_mgr_sta.h>
39 #endif
40 
vdev_mgr_config_ratemask_update(uint8_t vdev_id,struct vdev_ratemask_params * rate_params,struct config_ratemask_params * param,uint8_t index)41 static QDF_STATUS vdev_mgr_config_ratemask_update(
42 				uint8_t vdev_id,
43 				struct vdev_ratemask_params *rate_params,
44 				struct config_ratemask_params *param,
45 				uint8_t index)
46 {
47 	param->vdev_id = vdev_id;
48 	param->type = index;
49 	param->lower32 = rate_params->lower32;
50 	param->lower32_2 = rate_params->lower32_2;
51 	param->higher32 = rate_params->higher32;
52 	param->higher32_2 = rate_params->higher32_2;
53 
54 	return QDF_STATUS_SUCCESS;
55 }
56 
57 enum wlan_op_subtype
wlan_util_vdev_get_cdp_txrx_subtype(struct wlan_objmgr_vdev * vdev)58 wlan_util_vdev_get_cdp_txrx_subtype(struct wlan_objmgr_vdev *vdev)
59 {
60 	enum QDF_OPMODE qdf_opmode;
61 	enum wlan_op_subtype cdp_txrx_subtype;
62 
63 	qdf_opmode = wlan_vdev_mlme_get_opmode(vdev);
64 	switch (qdf_opmode) {
65 	case QDF_P2P_DEVICE_MODE:
66 		cdp_txrx_subtype = wlan_op_subtype_p2p_device;
67 		break;
68 	case QDF_P2P_CLIENT_MODE:
69 		cdp_txrx_subtype = wlan_op_subtype_p2p_cli;
70 		break;
71 	case QDF_P2P_GO_MODE:
72 		cdp_txrx_subtype = wlan_op_subtype_p2p_go;
73 		break;
74 	default:
75 		cdp_txrx_subtype = wlan_op_subtype_none;
76 	};
77 
78 	return cdp_txrx_subtype;
79 }
80 
81 enum wlan_op_mode
wlan_util_vdev_get_cdp_txrx_opmode(struct wlan_objmgr_vdev * vdev)82 wlan_util_vdev_get_cdp_txrx_opmode(struct wlan_objmgr_vdev *vdev)
83 {
84 	enum QDF_OPMODE qdf_opmode;
85 	enum wlan_op_mode cdp_txrx_opmode;
86 
87 	qdf_opmode = wlan_vdev_mlme_get_opmode(vdev);
88 	switch (qdf_opmode) {
89 	case QDF_STA_MODE:
90 		cdp_txrx_opmode = wlan_op_mode_sta;
91 		break;
92 	case QDF_SAP_MODE:
93 		cdp_txrx_opmode = wlan_op_mode_ap;
94 		break;
95 	case QDF_MONITOR_MODE:
96 		cdp_txrx_opmode = wlan_op_mode_monitor;
97 		break;
98 	case QDF_P2P_DEVICE_MODE:
99 		cdp_txrx_opmode = wlan_op_mode_ap;
100 		break;
101 	case QDF_P2P_CLIENT_MODE:
102 		cdp_txrx_opmode = wlan_op_mode_sta;
103 		break;
104 	case QDF_P2P_GO_MODE:
105 		cdp_txrx_opmode = wlan_op_mode_ap;
106 		break;
107 	case QDF_OCB_MODE:
108 		cdp_txrx_opmode = wlan_op_mode_ocb;
109 		break;
110 	case QDF_IBSS_MODE:
111 		cdp_txrx_opmode = wlan_op_mode_ibss;
112 		break;
113 	case QDF_NDI_MODE:
114 		cdp_txrx_opmode = wlan_op_mode_ndi;
115 		break;
116 	default:
117 		cdp_txrx_opmode = wlan_op_mode_unknown;
118 	};
119 
120 	return cdp_txrx_opmode;
121 }
122 
123 /**
124  * wlan_util_vdev_mlme_set_ratemask_config() - common MLME API to fill
125  * ratemask parameters of vdev_mlme object
126  * @vdev_mlme: pointer to vdev_mlme object
127  * @index: array index of ratemask_params
128  */
129 QDF_STATUS
wlan_util_vdev_mlme_set_ratemask_config(struct vdev_mlme_obj * vdev_mlme,uint8_t index)130 wlan_util_vdev_mlme_set_ratemask_config(struct vdev_mlme_obj *vdev_mlme,
131 					uint8_t index)
132 {
133 	struct config_ratemask_params rm_param = {0};
134 	uint8_t vdev_id;
135 	struct vdev_mlme_rate_info *rate_info;
136 	struct vdev_ratemask_params *rate_params;
137 
138 	if (!vdev_mlme) {
139 		mlme_err("VDEV MLME is NULL");
140 		return QDF_STATUS_E_FAILURE;
141 	}
142 
143 	vdev_id = wlan_vdev_get_id(vdev_mlme->vdev);
144 	rate_info = &vdev_mlme->mgmt.rate_info;
145 	rate_params = &rate_info->ratemask_params[index];
146 	vdev_mgr_config_ratemask_update(vdev_id,
147 					rate_params,
148 					&rm_param, index);
149 
150 	return tgt_vdev_mgr_config_ratemask_cmd_send(vdev_mlme,
151 						    &rm_param);
152 }
153 
154 qdf_export_symbol(wlan_util_vdev_mlme_set_ratemask_config);
155 
156 static QDF_STATUS
tgt_vdev_mgr_vdev_set_param_wrapper(struct vdev_mlme_obj * vdev_mlme,enum wlan_mlme_cfg_id param_id,struct wlan_vdev_mgr_cfg mlme_cfg)157 tgt_vdev_mgr_vdev_set_param_wrapper(struct vdev_mlme_obj *vdev_mlme,
158 				    enum wlan_mlme_cfg_id param_id,
159 				    struct wlan_vdev_mgr_cfg mlme_cfg)
160 {
161 	uint8_t id, count = 0;
162 	bool is_mbss_enabled, is_cmn_param = 0;
163 	unsigned long vdev_bmap = 0;
164 	struct wlan_objmgr_pdev *pdev;
165 	struct vdev_mlme_mbss_11ax *mbss;
166 	struct vdev_set_params param1 = {0};
167 	struct multiple_vdev_set_param param2 = {0};
168 	QDF_STATUS status = QDF_STATUS_SUCCESS;
169 
170 	mbss = &vdev_mlme->mgmt.mbss_11ax;
171 	is_mbss_enabled = (mbss->mbssid_flags
172 				& WLAN_VDEV_MLME_FLAGS_NON_MBSSID_AP) ? 0 : 1;
173 
174 	if (is_mbss_enabled) {
175 		vdev_bmap = mbss->vdev_bmap;
176 		is_cmn_param = mbss->is_cmn_param;
177 	}
178 
179 	/* 1. if non tx vap and cmn param, dont send any WMI
180 	 * 2. if tx vap and cmn param, send multi vdev set WMI
181 	 * 3. if non tx vap and non cmn param, send vdev set WMI
182 	 * 4. if tx vap and non cmn param, send vdev set WMI
183 	 * 5. if non mbss vap, send vdev set WMI
184 	 */
185 	if (!is_mbss_enabled || !is_cmn_param) {
186 		param1.param_id = param_id;
187 		param1.vdev_id = wlan_vdev_get_id(vdev_mlme->vdev);
188 		param1.param_value = mlme_cfg.value;
189 		return tgt_vdev_mgr_set_param_send(vdev_mlme, &param1);
190 	}
191 
192 	if (is_cmn_param && vdev_bmap) {
193 		pdev = wlan_vdev_get_pdev(vdev_mlme->vdev);
194 		param2.pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev);
195 		param2.param_id = param_id;
196 		param2.param_value = mlme_cfg.value;
197 
198 		for (id = 0; id < WLAN_UMAC_PDEV_MAX_VDEVS; id++) {
199 			if (qdf_test_bit(id, &vdev_bmap)) {
200 				param2.vdev_ids[count] = id;
201 				count++;
202 			}
203 		}
204 		param2.num_vdevs = count;
205 		status = tgt_vdev_mgr_multiple_vdev_set_param(pdev, &param2);
206 		mbss->vdev_bmap = 0;
207 	}
208 
209 	/* Reset the is_cmn_param for this vap */
210 	mbss->is_cmn_param = 0;
211 
212 	return status;
213 }
214 
215 QDF_STATUS
wlan_util_vdev_mlme_set_param(struct vdev_mlme_obj * vdev_mlme,enum wlan_mlme_cfg_id param_id,struct wlan_vdev_mgr_cfg mlme_cfg)216 wlan_util_vdev_mlme_set_param(struct vdev_mlme_obj *vdev_mlme,
217 			      enum wlan_mlme_cfg_id param_id,
218 			      struct wlan_vdev_mgr_cfg mlme_cfg)
219 {
220 	struct wlan_objmgr_vdev *vdev;
221 	struct vdev_mlme_proto *mlme_proto;
222 	struct vdev_mlme_mgmt *mlme_mgmt;
223 	struct vdev_mlme_inactivity_params *inactivity_params;
224 	bool is_wmi_cmd = false;
225 	int ret = QDF_STATUS_SUCCESS;
226 
227 	if (!vdev_mlme) {
228 		mlme_err("VDEV MLME is NULL");
229 		return QDF_STATUS_E_FAILURE;
230 	}
231 	vdev = vdev_mlme->vdev;
232 	mlme_proto = &vdev_mlme->proto;
233 	mlme_mgmt = &vdev_mlme->mgmt;
234 	inactivity_params = &mlme_mgmt->inactivity_params;
235 
236 	switch (param_id) {
237 	case WLAN_MLME_CFG_DTIM_PERIOD:
238 		mlme_proto->generic.dtim_period = mlme_cfg.value;
239 		is_wmi_cmd = true;
240 		break;
241 	case WLAN_MLME_CFG_SLOT_TIME:
242 		mlme_proto->generic.slot_time = mlme_cfg.value;
243 		is_wmi_cmd = true;
244 		break;
245 	case WLAN_MLME_CFG_PROTECTION_MODE:
246 		mlme_proto->generic.protection_mode = mlme_cfg.value;
247 		is_wmi_cmd = true;
248 		break;
249 	case WLAN_MLME_CFG_BEACON_INTERVAL:
250 		mlme_proto->generic.beacon_interval = mlme_cfg.value;
251 		is_wmi_cmd = true;
252 		break;
253 	case WLAN_MLME_CFG_LDPC:
254 		mlme_proto->generic.ldpc = mlme_cfg.value;
255 		is_wmi_cmd = true;
256 		break;
257 	case WLAN_MLME_CFG_NSS:
258 		mlme_proto->generic.nss = mlme_cfg.value;
259 		is_wmi_cmd = true;
260 		break;
261 	case WLAN_MLME_CFG_TSF_ADJUST:
262 		mlme_proto->generic.tsfadjust = mlme_cfg.tsf;
263 		break;
264 	case WLAN_MLME_CFG_ASSOC_ID:
265 		mlme_proto->sta.assoc_id = mlme_cfg.value;
266 		break;
267 	case WLAN_MLME_CFG_VHT_CAPS:
268 		mlme_proto->vht_info.caps = mlme_cfg.value;
269 		break;
270 	case WLAN_MLME_CFG_SUBFER:
271 		mlme_proto->vht_info.subfer = mlme_cfg.value;
272 		break;
273 	case WLAN_MLME_CFG_MUBFER:
274 		mlme_proto->vht_info.mubfer = mlme_cfg.value;
275 		break;
276 	case WLAN_MLME_CFG_SUBFEE:
277 		mlme_proto->vht_info.subfee = mlme_cfg.value;
278 		break;
279 	case WLAN_MLME_CFG_MUBFEE:
280 		mlme_proto->vht_info.mubfee = mlme_cfg.value;
281 		break;
282 	case WLAN_MLME_CFG_IMLICIT_BF:
283 		mlme_proto->vht_info.implicit_bf = mlme_cfg.value;
284 		break;
285 	case WLAN_MLME_CFG_SOUNDING_DIM:
286 		mlme_proto->vht_info.sounding_dimension = mlme_cfg.value;
287 		break;
288 	case WLAN_MLME_CFG_BFEE_STS_CAP:
289 		mlme_proto->vht_info.bfee_sts_cap = mlme_cfg.value;
290 		break;
291 	case WLAN_MLME_CFG_TXBF_CAPS:
292 		is_wmi_cmd = true;
293 		break;
294 	case WLAN_MLME_CFG_HT_CAPS:
295 		mlme_proto->ht_info.ht_caps = mlme_cfg.value;
296 		break;
297 	case WLAN_MLME_CFG_HE_OPS:
298 		mlme_proto->he_ops_info.he_ops = mlme_cfg.value;
299 		is_wmi_cmd = true;
300 		break;
301 #ifdef WLAN_FEATURE_11BE
302 	case WLAN_MLME_CFG_EHT_OPS:
303 		mlme_proto->eht_ops_info.eht_ops = mlme_cfg.value;
304 		is_wmi_cmd = true;
305 		break;
306 #endif
307 	case WLAN_MLME_CFG_RTS_THRESHOLD:
308 		mlme_mgmt->generic.rts_threshold = mlme_cfg.value;
309 		is_wmi_cmd = true;
310 		break;
311 	case WLAN_MLME_CFG_FRAG_THRESHOLD:
312 		mlme_mgmt->generic.frag_threshold = mlme_cfg.value;
313 		is_wmi_cmd = true;
314 		break;
315 	case WLAN_MLME_CFG_PROBE_DELAY:
316 		mlme_mgmt->generic.probe_delay = mlme_cfg.value;
317 		break;
318 	case WLAN_MLME_CFG_REPEAT_PROBE_TIME:
319 		mlme_mgmt->generic.repeat_probe_time = mlme_cfg.value;
320 		break;
321 	case WLAN_MLME_CFG_DROP_UNENCRY:
322 		mlme_mgmt->generic.drop_unencry = mlme_cfg.value;
323 		is_wmi_cmd = true;
324 		break;
325 	case WLAN_MLME_CFG_TX_PWR_LIMIT:
326 		mlme_mgmt->generic.tx_pwrlimit = mlme_cfg.value;
327 		break;
328 	case WLAN_MLME_CFG_TX_POWER:
329 		mlme_mgmt->generic.tx_power = mlme_cfg.value;
330 		is_wmi_cmd = true;
331 		break;
332 	case WLAN_MLME_CFG_AMPDU:
333 		mlme_mgmt->generic.ampdu = mlme_cfg.value;
334 		mlme_cfg.value = (mlme_cfg.value << 8) + 0xFF;
335 		is_wmi_cmd = true;
336 		break;
337 	case WLAN_MLME_CFG_AMPDU_SIZE:
338 		mlme_mgmt->generic.ampdu = mlme_cfg.value;
339 		break;
340 	case WLAN_MLME_CFG_AMSDU:
341 		mlme_mgmt->generic.amsdu = mlme_cfg.value;
342 		mlme_cfg.value = (mlme_cfg.value << 8) + 0xFF;
343 		is_wmi_cmd = true;
344 		break;
345 	case WLAN_MLME_CFG_AMSDU_SIZE:
346 		mlme_mgmt->generic.amsdu = mlme_cfg.value;
347 		break;
348 	case WLAN_MLME_CFG_BMISS_FIRST_BCNT:
349 		inactivity_params->bmiss_first_bcnt = mlme_cfg.value;
350 		break;
351 	case WLAN_MLME_CFG_BMISS_FINAL_BCNT:
352 		inactivity_params->bmiss_final_bcnt = mlme_cfg.value;
353 		break;
354 	case WLAN_MLME_CFG_MIN_IDLE_INACTIVE_TIME:
355 		inactivity_params->keepalive_min_idle_inactive_time_secs =
356 							mlme_cfg.value;
357 		is_wmi_cmd = true;
358 		break;
359 	case WLAN_MLME_CFG_MAX_IDLE_INACTIVE_TIME:
360 		inactivity_params->keepalive_max_idle_inactive_time_secs =
361 							mlme_cfg.value;
362 		is_wmi_cmd = true;
363 		break;
364 	case WLAN_MLME_CFG_MAX_UNRESPONSIVE_INACTIVE_TIME:
365 		inactivity_params->keepalive_max_unresponsive_time_secs =
366 							mlme_cfg.value;
367 		is_wmi_cmd = true;
368 		break;
369 	case WLAN_MLME_CFG_RATE_FLAGS:
370 		mlme_mgmt->rate_info.rate_flags = mlme_cfg.value;
371 		break;
372 	case WLAN_MLME_CFG_PER_BAND_TX_MGMT_RATE:
373 		mlme_mgmt->rate_info.per_band_tx_mgmt_rate = mlme_cfg.value;
374 		break;
375 	case WLAN_MLME_CFG_MAX_RATE:
376 		mlme_mgmt->rate_info.max_rate = mlme_cfg.value;
377 		break;
378 	case WLAN_MLME_CFG_TX_MGMT_RATE:
379 		mlme_mgmt->rate_info.tx_mgmt_rate = mlme_cfg.value;
380 		break;
381 	case WLAN_MLME_CFG_TX_RTSCTS_RATE:
382 		mlme_mgmt->rate_info.rtscts_tx_rate = mlme_cfg.value;
383 		break;
384 	case WLAN_MLME_CFG_TX_CHAINMASK:
385 		mlme_mgmt->chainmask_info.tx_chainmask = mlme_cfg.value;
386 		break;
387 	case WLAN_MLME_CFG_RX_CHAINMASK:
388 		mlme_mgmt->chainmask_info.rx_chainmask = mlme_cfg.value;
389 		break;
390 	case WLAN_MLME_CFG_PKT_POWERSAVE:
391 		mlme_mgmt->powersave_info.packet_powersave = mlme_cfg.value;
392 		break;
393 	case WLAN_MLME_CFG_MAX_LI_OF_MODDTIM:
394 		mlme_mgmt->powersave_info.max_li_of_moddtim = mlme_cfg.value;
395 		break;
396 	case WLAN_MLME_CFG_DYNDTIM_CNT:
397 		mlme_mgmt->powersave_info.dyndtim_cnt = mlme_cfg.value;
398 		break;
399 	case WLAN_MLME_CFG_LISTEN_INTERVAL:
400 		mlme_mgmt->powersave_info.listen_interval = mlme_cfg.value;
401 		is_wmi_cmd = true;
402 		break;
403 	case WLAN_MLME_CFG_MODDTIM_CNT:
404 		mlme_mgmt->powersave_info.moddtim_cnt = mlme_cfg.value;
405 		break;
406 	case WLAN_MLME_CFG_PROFILE_IDX:
407 		mlme_mgmt->mbss_11ax.profile_idx = mlme_cfg.value;
408 		break;
409 	case WLAN_MLME_CFG_PROFILE_NUM:
410 		mlme_mgmt->mbss_11ax.profile_num = mlme_cfg.value;
411 		break;
412 	case WLAN_MLME_CFG_MBSSID_FLAGS:
413 		mlme_mgmt->mbss_11ax.mbssid_flags = mlme_cfg.value;
414 		break;
415 	case WLAN_MLME_CFG_VDEVID_TRANS:
416 		mlme_mgmt->mbss_11ax.vdevid_trans = mlme_cfg.value;
417 		break;
418 	case WLAN_MLME_CFG_SSID:
419 		if (mlme_cfg.ssid_cfg.length <= WLAN_SSID_MAX_LEN) {
420 			qdf_mem_copy(mlme_mgmt->generic.ssid,
421 				     mlme_cfg.ssid_cfg.ssid,
422 				     mlme_cfg.ssid_cfg.length);
423 			mlme_mgmt->generic.ssid_len =
424 						mlme_cfg.ssid_cfg.length;
425 		} else {
426 			mlme_mgmt->generic.ssid_len = 0;
427 		}
428 
429 		break;
430 	case WLAN_MLME_CFG_TRANS_BSSID:
431 		qdf_mem_copy(mlme_mgmt->mbss_11ax.trans_bssid,
432 			     mlme_cfg.trans_bssid, QDF_MAC_ADDR_SIZE);
433 		break;
434 	case WLAN_MLME_CFG_TYPE:
435 		mlme_mgmt->generic.type = mlme_cfg.value;
436 		break;
437 	case WLAN_MLME_CFG_SUBTYPE:
438 		mlme_mgmt->generic.subtype = mlme_cfg.value;
439 		break;
440 	case WLAN_MLME_CFG_UAPSD:
441 		mlme_proto->sta.uapsd_cfg = mlme_cfg.value;
442 		break;
443 	case WLAN_MLME_CFG_TX_ENCAP_TYPE:
444 		is_wmi_cmd = true;
445 		mlme_mgmt->generic.tx_encap_type = mlme_cfg.value;
446 		tgt_vdev_mgr_set_tx_rx_decap_type(vdev_mlme,
447 						  WLAN_MLME_CFG_TX_ENCAP_TYPE,
448 						  mlme_cfg.value);
449 		break;
450 	case WLAN_MLME_CFG_RX_DECAP_TYPE:
451 		is_wmi_cmd = true;
452 		mlme_mgmt->generic.rx_decap_type = mlme_cfg.value;
453 		tgt_vdev_mgr_set_tx_rx_decap_type(vdev_mlme,
454 						  WLAN_MLME_CFG_RX_DECAP_TYPE,
455 						  mlme_cfg.value);
456 		break;
457 	case WLAN_MLME_CFG_RATEMASK_LOWER32:
458 		if (mlme_cfg.ratemask.index < WLAN_VDEV_RATEMASK_TYPE_MAX)
459 			mlme_mgmt->rate_info.ratemask_params[
460 					mlme_cfg.ratemask.index].lower32 =
461 							mlme_cfg.ratemask.value;
462 		break;
463 	case WLAN_MLME_CFG_RATEMASK_HIGHER32:
464 		if (mlme_cfg.ratemask.index < WLAN_VDEV_RATEMASK_TYPE_MAX)
465 			mlme_mgmt->rate_info.ratemask_params[
466 					mlme_cfg.ratemask.index].higher32 =
467 							mlme_cfg.ratemask.value;
468 		break;
469 	case WLAN_MLME_CFG_RATEMASK_LOWER32_2:
470 		if (mlme_cfg.ratemask.index < WLAN_VDEV_RATEMASK_TYPE_MAX)
471 			mlme_mgmt->rate_info.ratemask_params[
472 					mlme_cfg.ratemask.index].lower32_2 =
473 							mlme_cfg.ratemask.value;
474 		break;
475 	case WLAN_MLME_CFG_BCN_TX_RATE:
476 		mlme_mgmt->rate_info.bcn_tx_rate = mlme_cfg.value;
477 		break;
478 	case WLAN_MLME_CFG_BCN_TX_RATE_CODE:
479 		is_wmi_cmd = true;
480 		break;
481 	case WLAN_MLME_CFG_TX_MGMT_RATE_CODE:
482 		is_wmi_cmd = true;
483 		break;
484 	case WLAN_MLME_CFG_ENABLE_MULTI_GROUP_KEY:
485 		is_wmi_cmd = true;
486 		break;
487 	case WLAN_MLME_CFG_MAX_GROUP_KEYS:
488 		is_wmi_cmd = true;
489 		break;
490 	case WLAN_MLME_CFG_TX_STREAMS:
491 		mlme_mgmt->chainmask_info.num_tx_chain = mlme_cfg.value;
492 		break;
493 	case WLAN_MLME_CFG_RX_STREAMS:
494 		mlme_mgmt->chainmask_info.num_rx_chain = mlme_cfg.value;
495 		break;
496 	case WLAN_MLME_CFG_ENABLE_DISABLE_RTT_RESPONDER_ROLE:
497 		is_wmi_cmd = true;
498 		break;
499 	case WLAN_MLME_CFG_ENABLE_DISABLE_RTT_INITIATOR_ROLE:
500 		is_wmi_cmd = true;
501 		break;
502 	default:
503 		break;
504 	}
505 
506 	if (is_wmi_cmd)
507 		ret = tgt_vdev_mgr_vdev_set_param_wrapper(vdev_mlme, param_id,
508 							  mlme_cfg);
509 
510 	return ret;
511 }
512 
513 qdf_export_symbol(wlan_util_vdev_mlme_set_param);
514 
wlan_util_vdev_mlme_get_param(struct vdev_mlme_obj * vdev_mlme,enum wlan_mlme_cfg_id param_id,uint32_t * value)515 void wlan_util_vdev_mlme_get_param(struct vdev_mlme_obj *vdev_mlme,
516 				   enum wlan_mlme_cfg_id param_id,
517 				   uint32_t *value)
518 {
519 	struct vdev_mlme_proto *mlme_proto;
520 	struct vdev_mlme_mgmt *mlme_mgmt;
521 	struct vdev_mlme_inactivity_params *inactivity_params;
522 
523 	if (!vdev_mlme) {
524 		mlme_err("VDEV MLME is NULL");
525 		return;
526 	}
527 	mlme_proto = &vdev_mlme->proto;
528 	mlme_mgmt = &vdev_mlme->mgmt;
529 	inactivity_params = &mlme_mgmt->inactivity_params;
530 
531 	switch (param_id) {
532 	case WLAN_MLME_CFG_DTIM_PERIOD:
533 		*value = mlme_proto->generic.dtim_period;
534 		break;
535 	case WLAN_MLME_CFG_SLOT_TIME:
536 		*value = mlme_proto->generic.slot_time;
537 		break;
538 	case WLAN_MLME_CFG_PROTECTION_MODE:
539 		*value = mlme_proto->generic.protection_mode;
540 		break;
541 	case WLAN_MLME_CFG_BEACON_INTERVAL:
542 		*value = mlme_proto->generic.beacon_interval;
543 		break;
544 	case WLAN_MLME_CFG_LDPC:
545 		*value = mlme_proto->generic.ldpc;
546 		break;
547 	case WLAN_MLME_CFG_NSS:
548 		*value = mlme_proto->generic.nss;
549 		break;
550 	case WLAN_MLME_CFG_ASSOC_ID:
551 		*value = mlme_proto->sta.assoc_id;
552 		break;
553 	case WLAN_MLME_CFG_VHT_CAPS:
554 		*value = mlme_proto->vht_info.caps;
555 		break;
556 	case WLAN_MLME_CFG_SUBFER:
557 		*value = mlme_proto->vht_info.subfer;
558 		break;
559 	case WLAN_MLME_CFG_MUBFER:
560 		*value = mlme_proto->vht_info.mubfer;
561 		break;
562 	case WLAN_MLME_CFG_SUBFEE:
563 		*value = mlme_proto->vht_info.subfee;
564 		break;
565 	case WLAN_MLME_CFG_MUBFEE:
566 		*value = mlme_proto->vht_info.mubfee;
567 		break;
568 	case WLAN_MLME_CFG_IMLICIT_BF:
569 		*value = mlme_proto->vht_info.implicit_bf;
570 		break;
571 	case WLAN_MLME_CFG_SOUNDING_DIM:
572 		*value = mlme_proto->vht_info.sounding_dimension;
573 		break;
574 	case WLAN_MLME_CFG_BFEE_STS_CAP:
575 		*value = mlme_proto->vht_info.bfee_sts_cap;
576 		break;
577 	case WLAN_MLME_CFG_HT_CAPS:
578 		*value = mlme_proto->ht_info.ht_caps;
579 		break;
580 	case WLAN_MLME_CFG_HE_OPS:
581 		*value = mlme_proto->he_ops_info.he_ops;
582 		break;
583 #ifdef WLAN_FEATURE_11BE
584 	case WLAN_MLME_CFG_EHT_OPS:
585 		*value = mlme_proto->eht_ops_info.eht_ops;
586 		break;
587 #endif
588 	case WLAN_MLME_CFG_RTS_THRESHOLD:
589 		*value = mlme_mgmt->generic.rts_threshold;
590 		break;
591 	case WLAN_MLME_CFG_FRAG_THRESHOLD:
592 		*value = mlme_mgmt->generic.frag_threshold;
593 		break;
594 	case WLAN_MLME_CFG_PROBE_DELAY:
595 		*value = mlme_mgmt->generic.probe_delay;
596 		break;
597 	case WLAN_MLME_CFG_REPEAT_PROBE_TIME:
598 		*value = mlme_mgmt->generic.repeat_probe_time;
599 		break;
600 	case WLAN_MLME_CFG_DROP_UNENCRY:
601 		*value = mlme_mgmt->generic.drop_unencry;
602 		break;
603 	case WLAN_MLME_CFG_TX_PWR_LIMIT:
604 		*value = mlme_mgmt->generic.tx_pwrlimit;
605 		break;
606 	case WLAN_MLME_CFG_TX_POWER:
607 		*value = mlme_mgmt->generic.tx_power;
608 		break;
609 	case WLAN_MLME_CFG_AMPDU:
610 		*value = mlme_mgmt->generic.ampdu;
611 		break;
612 	case WLAN_MLME_CFG_AMSDU:
613 		*value = mlme_mgmt->generic.amsdu;
614 		break;
615 	case WLAN_MLME_CFG_SSID_LEN:
616 		*value = mlme_mgmt->generic.ssid_len;
617 		break;
618 	case WLAN_MLME_CFG_BMISS_FIRST_BCNT:
619 		*value = inactivity_params->bmiss_first_bcnt;
620 		break;
621 	case WLAN_MLME_CFG_BMISS_FINAL_BCNT:
622 		*value = inactivity_params->bmiss_final_bcnt;
623 		break;
624 	case WLAN_MLME_CFG_MIN_IDLE_INACTIVE_TIME:
625 		*value =
626 		      inactivity_params->keepalive_min_idle_inactive_time_secs;
627 		break;
628 	case WLAN_MLME_CFG_MAX_IDLE_INACTIVE_TIME:
629 		*value =
630 		      inactivity_params->keepalive_max_idle_inactive_time_secs;
631 		break;
632 	case WLAN_MLME_CFG_MAX_UNRESPONSIVE_INACTIVE_TIME:
633 		*value =
634 		      inactivity_params->keepalive_max_unresponsive_time_secs;
635 		break;
636 	case WLAN_MLME_CFG_RATE_FLAGS:
637 		*value = mlme_mgmt->rate_info.rate_flags;
638 		break;
639 	case WLAN_MLME_CFG_PER_BAND_TX_MGMT_RATE:
640 		*value = mlme_mgmt->rate_info.per_band_tx_mgmt_rate;
641 		break;
642 	case WLAN_MLME_CFG_MAX_RATE:
643 		*value = mlme_mgmt->rate_info.max_rate;
644 		break;
645 	case WLAN_MLME_CFG_TX_MGMT_RATE:
646 		*value = mlme_mgmt->rate_info.tx_mgmt_rate;
647 		break;
648 	case WLAN_MLME_CFG_TX_RTSCTS_RATE:
649 		*value = mlme_mgmt->rate_info.rtscts_tx_rate;
650 		break;
651 	case WLAN_MLME_CFG_TX_CHAINMASK:
652 		*value = mlme_mgmt->chainmask_info.tx_chainmask;
653 		break;
654 	case WLAN_MLME_CFG_RX_CHAINMASK:
655 		*value = mlme_mgmt->chainmask_info.rx_chainmask;
656 		break;
657 	case WLAN_MLME_CFG_PKT_POWERSAVE:
658 		*value = mlme_mgmt->powersave_info.packet_powersave;
659 		break;
660 	case WLAN_MLME_CFG_MAX_LI_OF_MODDTIM:
661 		*value = mlme_mgmt->powersave_info.max_li_of_moddtim;
662 		break;
663 	case WLAN_MLME_CFG_DYNDTIM_CNT:
664 		*value = mlme_mgmt->powersave_info.dyndtim_cnt;
665 		break;
666 	case WLAN_MLME_CFG_LISTEN_INTERVAL:
667 		*value = mlme_mgmt->powersave_info.listen_interval;
668 		break;
669 	case WLAN_MLME_CFG_MODDTIM_CNT:
670 		*value = mlme_mgmt->powersave_info.moddtim_cnt;
671 		break;
672 	case WLAN_MLME_CFG_PROFILE_IDX:
673 		*value = mlme_mgmt->mbss_11ax.profile_idx;
674 		break;
675 	case WLAN_MLME_CFG_PROFILE_NUM:
676 		*value = mlme_mgmt->mbss_11ax.profile_num;
677 		break;
678 	case WLAN_MLME_CFG_MBSSID_FLAGS:
679 		*value = mlme_mgmt->mbss_11ax.mbssid_flags;
680 		break;
681 	case WLAN_MLME_CFG_VDEVID_TRANS:
682 		*value = mlme_mgmt->mbss_11ax.vdevid_trans;
683 		break;
684 	case WLAN_MLME_CFG_BCN_TX_RATE:
685 		*value = mlme_mgmt->rate_info.bcn_tx_rate;
686 		break;
687 	case WLAN_MLME_CFG_TX_STREAMS:
688 		*value = mlme_mgmt->chainmask_info.num_tx_chain;
689 		break;
690 	case WLAN_MLME_CFG_RX_STREAMS:
691 		*value = mlme_mgmt->chainmask_info.num_rx_chain;
692 		break;
693 	default:
694 		break;
695 	}
696 }
697 
698 qdf_export_symbol(wlan_util_vdev_mlme_get_param);
699 
wlan_util_vdev_get_param(struct wlan_objmgr_vdev * vdev,enum wlan_mlme_cfg_id param_id,uint32_t * value)700 void wlan_util_vdev_get_param(struct wlan_objmgr_vdev *vdev,
701 			      enum wlan_mlme_cfg_id param_id,
702 			      uint32_t *value)
703 {
704 	ucfg_wlan_vdev_mgr_get_param(vdev, param_id, value);
705 }
706 
707 qdf_export_symbol(wlan_util_vdev_get_param);
708 
709 #ifndef MOBILE_DFS_SUPPORT
wlan_util_vdev_mgr_get_cac_timeout_for_vdev(struct wlan_objmgr_vdev * vdev)710 int wlan_util_vdev_mgr_get_cac_timeout_for_vdev(struct wlan_objmgr_vdev *vdev)
711 {
712 	struct wlan_channel *des_chan = NULL;
713 	struct wlan_channel *bss_chan = NULL;
714 	bool continue_current_cac = 0;
715 	int dfs_cac_timeout = 0;
716 
717 	des_chan = wlan_vdev_mlme_get_des_chan(vdev);
718 	if (!des_chan)
719 		return 0;
720 
721 	bss_chan = wlan_vdev_mlme_get_bss_chan(vdev);
722 	if (!bss_chan)
723 		return 0;
724 
725 	if (!utils_dfs_is_cac_required(wlan_vdev_get_pdev(vdev), des_chan,
726 				       bss_chan, &continue_current_cac))
727 		return 0;
728 
729 	dfs_cac_timeout = dfs_mlme_get_cac_timeout_for_freq(
730 				wlan_vdev_get_pdev(vdev), des_chan->ch_freq,
731 				des_chan->ch_cfreq2, des_chan->ch_flags);
732 	/* Seconds to milliseconds */
733 	return SECONDS_TO_MS(dfs_cac_timeout);
734 }
735 #else
wlan_util_vdev_mgr_get_cac_timeout_for_vdev(struct wlan_objmgr_vdev * vdev)736 int wlan_util_vdev_mgr_get_cac_timeout_for_vdev(struct wlan_objmgr_vdev *vdev)
737 {
738 	struct vdev_mlme_obj *vdev_mlme;
739 
740 	vdev_mlme = wlan_vdev_mlme_get_cmpt_obj(vdev);
741 	if (!vdev_mlme) {
742 		mlme_err("vdev_mlme is null");
743 		return 0;
744 	}
745 
746 	return vdev_mlme->mgmt.ap.cac_duration_ms;
747 }
748 
wlan_util_vdev_mgr_set_cac_timeout_for_vdev(struct wlan_objmgr_vdev * vdev,uint32_t new_chan_cac_ms)749 void wlan_util_vdev_mgr_set_cac_timeout_for_vdev(struct wlan_objmgr_vdev *vdev,
750 						 uint32_t new_chan_cac_ms)
751 {
752 	struct vdev_mlme_obj *vdev_mlme;
753 
754 	vdev_mlme = wlan_vdev_mlme_get_cmpt_obj(vdev);
755 	if (!vdev_mlme) {
756 		mlme_err("vdev_mlme is null");
757 		return;
758 	}
759 
760 	vdev_mlme->mgmt.ap.cac_duration_ms = new_chan_cac_ms;
761 }
762 #endif /* MOBILE_DFS_SUPPORT */
763 
wlan_util_vdev_mgr_set_acs_mode_for_vdev(struct wlan_objmgr_vdev * vdev,bool is_acs_mode)764 void wlan_util_vdev_mgr_set_acs_mode_for_vdev(struct wlan_objmgr_vdev *vdev,
765 					      bool is_acs_mode)
766 {
767 	struct vdev_mlme_obj *vdev_mlme;
768 
769 	vdev_mlme = wlan_vdev_mlme_get_cmpt_obj(vdev);
770 	if (!vdev_mlme) {
771 		mlme_err("vdev_mlme is null");
772 		return;
773 	}
774 
775 	vdev_mlme->mgmt.ap.is_acs_mode = is_acs_mode;
776 }
777 
wlan_util_vdev_mgr_get_acs_mode_for_vdev(struct wlan_objmgr_vdev * vdev)778 bool wlan_util_vdev_mgr_get_acs_mode_for_vdev(struct wlan_objmgr_vdev *vdev)
779 {
780 	struct vdev_mlme_obj *vdev_mlme;
781 
782 	vdev_mlme = wlan_vdev_mlme_get_cmpt_obj(vdev);
783 	if (!vdev_mlme) {
784 		mlme_err("vdev_mlme is null");
785 		return false;
786 	}
787 
788 	return vdev_mlme->mgmt.ap.is_acs_mode;
789 }
790 
wlan_util_vdev_mgr_get_csa_channel_switch_time(struct wlan_objmgr_vdev * vdev,uint32_t * chan_switch_time)791 QDF_STATUS wlan_util_vdev_mgr_get_csa_channel_switch_time(
792 		struct wlan_objmgr_vdev *vdev,
793 		uint32_t *chan_switch_time)
794 {
795 	struct vdev_mlme_obj *vdev_mlme = NULL;
796 
797 	*chan_switch_time = 0;
798 
799 	vdev_mlme = wlan_vdev_mlme_get_cmpt_obj(vdev);
800 	if (!vdev_mlme) {
801 		mlme_err("vdev_mlme is null");
802 		return QDF_STATUS_E_FAILURE;
803 	}
804 
805 	/* Time between CSA count 1 and CSA count 0 is one beacon interval. */
806 	*chan_switch_time = vdev_mlme->proto.generic.beacon_interval;
807 
808 	/* Vdev restart time */
809 	*chan_switch_time += SECONDS_TO_MS(VDEV_RESTART_TIME);
810 
811 	/* Add one beacon interval time required to send beacon on the
812 	 * new channel after switching to the new channel.
813 	 */
814 	*chan_switch_time += vdev_mlme->proto.generic.beacon_interval;
815 
816 	return QDF_STATUS_SUCCESS;
817 }
818 
wlan_util_vdev_mgr_compute_max_channel_switch_time(struct wlan_objmgr_vdev * vdev,uint32_t * max_chan_switch_time)819 QDF_STATUS wlan_util_vdev_mgr_compute_max_channel_switch_time(
820 		struct wlan_objmgr_vdev *vdev, uint32_t *max_chan_switch_time)
821 {
822 	QDF_STATUS status;
823 
824 	status = wlan_util_vdev_mgr_get_csa_channel_switch_time(
825 			vdev, max_chan_switch_time);
826 	if (QDF_IS_STATUS_ERROR(status)) {
827 		mlme_err("Failed to get the CSA channel switch time");
828 		return status;
829 	}
830 
831 	/* Plus the CAC time */
832 	*max_chan_switch_time +=
833 			wlan_util_vdev_mgr_get_cac_timeout_for_vdev(vdev);
834 
835 	return QDF_STATUS_SUCCESS;
836 }
837 
838 uint32_t
wlan_utils_get_vdev_remaining_channel_switch_time(struct wlan_objmgr_vdev * vdev)839 wlan_utils_get_vdev_remaining_channel_switch_time(struct wlan_objmgr_vdev *vdev)
840 {
841 	struct vdev_mlme_obj *vdev_mlme = NULL;
842 	int32_t remaining_chan_switch_time;
843 
844 	vdev_mlme = wlan_vdev_mlme_get_cmpt_obj(vdev);
845 	if (!vdev_mlme)
846 		return 0;
847 
848 	if (!vdev_mlme->mgmt.ap.last_bcn_ts_ms)
849 		return 0;
850 
851 	/* Remaining channel switch time is equal to the time when last beacon
852 	 * sent on the CSA triggered vap plus max channel switch time minus
853 	 * current time.
854 	 */
855 	remaining_chan_switch_time =
856 	    ((vdev_mlme->mgmt.ap.last_bcn_ts_ms +
857 	      vdev_mlme->mgmt.ap.max_chan_switch_time) -
858 	     qdf_mc_timer_get_system_time());
859 
860 	return (remaining_chan_switch_time > 0) ?
861 		remaining_chan_switch_time : 0;
862 }
863 
864 #ifdef WLAN_FEATURE_11BE_MLO
wlan_util_vdev_mgr_quiet_offload(struct wlan_objmgr_psoc * psoc,struct vdev_sta_quiet_event * quiet_event)865 QDF_STATUS wlan_util_vdev_mgr_quiet_offload(
866 				struct wlan_objmgr_psoc *psoc,
867 				struct vdev_sta_quiet_event *quiet_event)
868 {
869 	uint8_t vdev_id;
870 	bool connected;
871 	struct wlan_objmgr_vdev *vdev;
872 
873 	if (qdf_is_macaddr_zero(&quiet_event->mld_mac) &&
874 	    qdf_is_macaddr_zero(&quiet_event->link_mac)) {
875 		mlme_err("mld_mac and link mac are invalid");
876 		return QDF_STATUS_E_INVAL;
877 	}
878 
879 	if (!qdf_is_macaddr_zero(&quiet_event->mld_mac)) {
880 		connected = wlan_get_connected_vdev_by_mld_addr(
881 				psoc, quiet_event->mld_mac.bytes, &vdev_id);
882 		if (!connected) {
883 			mlme_err("Can't find vdev with mld " QDF_MAC_ADDR_FMT,
884 				 QDF_MAC_ADDR_REF(quiet_event->mld_mac.bytes));
885 			return QDF_STATUS_E_INVAL;
886 		}
887 		vdev = wlan_objmgr_get_vdev_by_id_from_psoc(
888 				psoc, vdev_id, WLAN_MLME_OBJMGR_ID);
889 		if (!vdev) {
890 			mlme_err("Null vdev");
891 			return QDF_STATUS_E_INVAL;
892 		}
893 		if (wlan_vdev_mlme_is_mlo_vdev(vdev))
894 			mlo_sta_save_quiet_status(vdev->mlo_dev_ctx,
895 						  quiet_event->link_id,
896 						  quiet_event->quiet_status);
897 		wlan_objmgr_vdev_release_ref(vdev, WLAN_MLME_OBJMGR_ID);
898 	} else if (!qdf_is_macaddr_zero(&quiet_event->link_mac)) {
899 		connected = wlan_get_connected_vdev_from_psoc_by_bssid(
900 				psoc, quiet_event->link_mac.bytes, &vdev_id);
901 		if (!connected) {
902 			mlme_err("Can't find vdev with BSSID" QDF_MAC_ADDR_FMT,
903 				 QDF_MAC_ADDR_REF(quiet_event->link_mac.bytes));
904 			return QDF_STATUS_E_INVAL;
905 		}
906 		vdev = wlan_objmgr_get_vdev_by_id_from_psoc(
907 				psoc, vdev_id, WLAN_MLME_OBJMGR_ID);
908 		if (!vdev) {
909 			mlme_err("Null vdev");
910 			return QDF_STATUS_E_INVAL;
911 		}
912 		if (wlan_vdev_mlme_is_mlo_vdev(vdev))
913 			mlo_sta_save_quiet_status(vdev->mlo_dev_ctx,
914 						  wlan_vdev_get_link_id(vdev),
915 						  quiet_event->quiet_status);
916 		wlan_objmgr_vdev_release_ref(vdev, WLAN_MLME_OBJMGR_ID);
917 	}
918 
919 	return QDF_STATUS_SUCCESS;
920 }
921 #endif /* WLAN_FEATURE_11BE_MLO */
922 
wlan_util_vdev_peer_set_param_send(struct wlan_objmgr_vdev * vdev,uint8_t * peer_mac_addr,uint32_t param_id,uint32_t param_value)923 QDF_STATUS wlan_util_vdev_peer_set_param_send(struct wlan_objmgr_vdev *vdev,
924 					      uint8_t *peer_mac_addr,
925 					      uint32_t param_id,
926 					      uint32_t param_value)
927 {
928 	return tgt_vdev_peer_set_param_send(vdev, peer_mac_addr,
929 					    param_id, param_value);
930 }
931 
932 qdf_export_symbol(wlan_util_vdev_peer_set_param_send);
933