xref: /wlan-driver/qcacld-3.0/components/mlme/core/src/wlan_mlme_main.c (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2018-2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2021-2024 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  * DOC: define internal APIs related to the mlme component
21  */
22 
23 #include "wlan_mlme_main.h"
24 #include "include/wlan_vdev_mlme.h"
25 #include "cfg_ucfg_api.h"
26 #include "wmi_unified.h"
27 #include "wlan_scan_public_structs.h"
28 #include "wlan_psoc_mlme_api.h"
29 #include "wlan_vdev_mlme_api.h"
30 #include "wlan_mlme_api.h"
31 #include <wlan_crypto_global_api.h>
32 #include <wlan_mlo_mgr_cmn.h>
33 #include "wlan_mlme_ucfg_api.h"
34 #include "wifi_pos_ucfg_i.h"
35 #include "wlan_mlo_mgr_sta.h"
36 #include "twt/core/src/wlan_twt_cfg.h"
37 #include "wlan_scan_api.h"
38 #include "wlan_mlme_vdev_mgr_interface.h"
39 #include "wlan_vdev_mgr_utils_api.h"
40 #include <wmi_unified_priv.h>
41 #include <target_if.h>
42 
43 #define NUM_OF_SOUNDING_DIMENSIONS     1 /*Nss - 1, (Nss = 2 for 2x2)*/
44 
45 /* Time to passive scan dwell for scan to get channel stats, in milliseconds */
46 #define MLME_GET_CHAN_STATS_PASSIVE_SCAN_TIME 40
47 #define MLME_GET_CHAN_STATS_WIDE_BAND_PASSIVE_SCAN_TIME 110
48 
49 struct wlan_mlme_rx_ops *
mlme_get_rx_ops(struct wlan_objmgr_psoc * psoc)50 mlme_get_rx_ops(struct wlan_objmgr_psoc *psoc)
51 {
52 	struct wlan_mlme_psoc_ext_obj *psoc_ext_priv;
53 
54 	if (!psoc) {
55 		mlme_err("psoc object is NULL");
56 		return NULL;
57 	}
58 	psoc_ext_priv = wlan_psoc_mlme_get_ext_hdl(psoc);
59 	if (!psoc_ext_priv) {
60 		mlme_err("psoc legacy private object is NULL");
61 		return NULL;
62 	}
63 
64 	return &psoc_ext_priv->mlme_rx_ops;
65 }
66 
wlan_mlme_register_rx_ops(struct wlan_mlme_rx_ops * rx_ops)67 void wlan_mlme_register_rx_ops(struct wlan_mlme_rx_ops *rx_ops)
68 {
69 	rx_ops->peer_oper_mode_eventid = wlan_mlme_set_peer_indicated_ch_width;
70 }
71 
mlme_get_psoc_ext_obj_fl(struct wlan_objmgr_psoc * psoc,const char * func,uint32_t line)72 struct wlan_mlme_psoc_ext_obj *mlme_get_psoc_ext_obj_fl(
73 			       struct wlan_objmgr_psoc *psoc,
74 			       const char *func, uint32_t line)
75 {
76 
77 	return wlan_psoc_mlme_get_ext_hdl(psoc);
78 }
79 
mlme_get_dynamic_vdev_config(struct wlan_objmgr_vdev * vdev)80 struct wlan_mlme_nss_chains *mlme_get_dynamic_vdev_config(
81 				struct wlan_objmgr_vdev *vdev)
82 {
83 	struct mlme_legacy_priv *mlme_priv;
84 
85 	mlme_priv = wlan_vdev_mlme_get_ext_hdl(vdev);
86 	if (!mlme_priv) {
87 		mlme_legacy_err("vdev legacy private object is NULL");
88 		return NULL;
89 	}
90 
91 	return &mlme_priv->dynamic_cfg;
92 }
93 
94 /* Buffer len size to consider the 4 char freq, and a space, Total 5 */
95 #define MLME_CHAN_WEIGHT_CHAR_LEN 5
96 #define MLME_MAX_CHAN_TO_PRINT 39
97 
98 /**
99  * mlme_fill_freq_in_scan_start_request() - Fill frequencies in scan req
100  * @vdev: vdev common object
101  * @req: pointer to scan request
102  *
103  * Return: QDF_STATUS
104  */
105 static QDF_STATUS
mlme_fill_freq_in_scan_start_request(struct wlan_objmgr_vdev * vdev,struct scan_start_request * req)106 mlme_fill_freq_in_scan_start_request(struct wlan_objmgr_vdev *vdev,
107 				     struct scan_start_request *req)
108 {
109 	const struct bonded_channel_freq *range;
110 	struct mlme_legacy_priv *mlme_priv;
111 	enum phy_ch_width associated_ch_width;
112 	uint8_t i;
113 	struct chan_list *scan_chan_list;
114 	qdf_freq_t first_freq, operation_chan_freq, sec_2g_freq;
115 	char *chan_buff = NULL;
116 	uint32_t buff_len, buff_num = 0, chan_count = 0;
117 
118 	mlme_priv = wlan_vdev_mlme_get_ext_hdl(vdev);
119 	if (!mlme_priv)
120 		return QDF_STATUS_E_FAILURE;
121 
122 	operation_chan_freq = wlan_get_operation_chan_freq(vdev);
123 	associated_ch_width =
124 			mlme_priv->connect_info.assoc_chan_info.assoc_ch_width;
125 	if (associated_ch_width == CH_WIDTH_INVALID) {
126 		mlme_debug("vdev %d : Invalid associated ch width for freq %d",
127 			   req->scan_req.vdev_id, operation_chan_freq);
128 		return QDF_STATUS_E_FAILURE;
129 	}
130 
131 	req->scan_req.dwell_time_passive =
132 			MLME_GET_CHAN_STATS_PASSIVE_SCAN_TIME;
133 	req->scan_req.dwell_time_passive_6g =
134 			MLME_GET_CHAN_STATS_PASSIVE_SCAN_TIME;
135 
136 	if (associated_ch_width == CH_WIDTH_20MHZ) {
137 		mlme_debug("vdev %d :Trigger scan for associated freq %d bw %d",
138 			   req->scan_req.vdev_id, operation_chan_freq,
139 			   associated_ch_width);
140 		req->scan_req.chan_list.num_chan = 1;
141 		req->scan_req.chan_list.chan[0].freq = operation_chan_freq;
142 		return QDF_STATUS_SUCCESS;
143 	}
144 
145 	if (wlan_reg_is_24ghz_ch_freq(operation_chan_freq) &&
146 	    associated_ch_width == CH_WIDTH_40MHZ) {
147 		sec_2g_freq =
148 			mlme_priv->connect_info.assoc_chan_info.sec_2g_freq;
149 		if (!sec_2g_freq) {
150 			mlme_debug("vdev %d : Invalid sec 2g freq for freq: %d",
151 				   req->scan_req.vdev_id, operation_chan_freq);
152 			return QDF_STATUS_E_FAILURE;
153 		}
154 
155 		if (operation_chan_freq > sec_2g_freq) {
156 			req->scan_req.chan_list.chan[0].freq = sec_2g_freq;
157 			req->scan_req.chan_list.chan[1].freq =
158 							operation_chan_freq;
159 		} else {
160 			req->scan_req.chan_list.chan[0].freq =
161 							operation_chan_freq;
162 			req->scan_req.chan_list.chan[1].freq = sec_2g_freq;
163 		}
164 
165 		req->scan_req.chan_list.num_chan = 2;
166 		return QDF_STATUS_SUCCESS;
167 	}
168 
169 	range = wlan_reg_get_bonded_chan_entry(operation_chan_freq,
170 					       associated_ch_width, 0);
171 	if (!range) {
172 		mlme_debug("vdev %d: Invalid freq range for freq: %d bw: %d",
173 			   req->scan_req.vdev_id, operation_chan_freq,
174 			   associated_ch_width);
175 		return QDF_STATUS_E_FAILURE;
176 	}
177 
178 	scan_chan_list = qdf_mem_malloc(sizeof(*scan_chan_list));
179 	if (!scan_chan_list)
180 		return QDF_STATUS_E_NOMEM;
181 
182 	scan_chan_list->num_chan = 0;
183 	first_freq  = range->start_freq;
184 	for (; first_freq <= range->end_freq; first_freq += BW_20_MHZ) {
185 		scan_chan_list->chan[scan_chan_list->num_chan].freq =
186 								first_freq;
187 		scan_chan_list->num_chan++;
188 	}
189 
190 	req->scan_req.chan_list.num_chan = scan_chan_list->num_chan;
191 
192 	mlme_debug("vdev %d : freq %d bw %d, range [%d-%d], Total freq %d",
193 		   req->scan_req.vdev_id, operation_chan_freq,
194 		   associated_ch_width, range->start_freq,
195 		   range->end_freq, req->scan_req.chan_list.num_chan);
196 
197 	buff_len = (QDF_MIN(req->scan_req.chan_list.num_chan,
198 		    MLME_MAX_CHAN_TO_PRINT) * MLME_CHAN_WEIGHT_CHAR_LEN) + 1;
199 
200 	chan_buff = qdf_mem_malloc(buff_len);
201 	if (!chan_buff) {
202 		qdf_mem_free(scan_chan_list);
203 		return QDF_STATUS_E_NOMEM;
204 	}
205 	for (i = 0; i < req->scan_req.chan_list.num_chan; i++) {
206 		req->scan_req.chan_list.chan[i].freq =
207 					scan_chan_list->chan[i].freq;
208 		buff_num += qdf_scnprintf(chan_buff + buff_num,
209 					  buff_len - buff_num, " %d",
210 					  req->scan_req.chan_list.chan[i].freq);
211 		chan_count++;
212 		if (chan_count >= MLME_MAX_CHAN_TO_PRINT) {
213 			mlme_debug("Freq list: %s", chan_buff);
214 			buff_num = 0;
215 			chan_count = 0;
216 		}
217 	}
218 
219 	if (buff_num)
220 		mlme_debug("Freq list: %s", chan_buff);
221 
222 	qdf_mem_free(chan_buff);
223 	qdf_mem_free(scan_chan_list);
224 
225 	return QDF_STATUS_SUCCESS;
226 }
227 
228 #ifdef WLAN_FEATURE_11BE
mlme_get_scan_phy_mode(void)229 static enum scan_phy_mode mlme_get_scan_phy_mode(void)
230 {
231 	return SCAN_PHY_MODE_11BE_EHT160;
232 }
233 
234 static enum scan_phy_mode
wlan_scan_get_11be_scan_phy_mode(enum wlan_phymode ch_phymode)235 wlan_scan_get_11be_scan_phy_mode(enum wlan_phymode ch_phymode)
236 {
237 	enum scan_phy_mode scan_phymode;
238 
239 	switch (ch_phymode) {
240 	case WLAN_PHYMODE_11BEA_EHT20:
241 		scan_phymode = SCAN_PHY_MODE_11BE_EHT20;
242 		break;
243 	case WLAN_PHYMODE_11BEG_EHT20:
244 		scan_phymode = SCAN_PHY_MODE_11BE_EHT20_2G;
245 		break;
246 	case WLAN_PHYMODE_11BEA_EHT40:
247 		scan_phymode = SCAN_PHY_MODE_11BE_EHT40;
248 		break;
249 	case WLAN_PHYMODE_11BEG_EHT40:
250 		scan_phymode = SCAN_PHY_MODE_11BE_EHT40_2G;
251 		break;
252 	case WLAN_PHYMODE_11BEA_EHT80:
253 		scan_phymode = SCAN_PHY_MODE_11BE_EHT80;
254 		break;
255 	case WLAN_PHYMODE_11BEG_EHT80:
256 		scan_phymode = SCAN_PHY_MODE_11BE_EHT80_2G;
257 		break;
258 	case WLAN_PHYMODE_11BEA_EHT160:
259 		scan_phymode = SCAN_PHY_MODE_11BE_EHT160;
260 		break;
261 	case WLAN_PHYMODE_11BEA_EHT320:
262 		scan_phymode = SCAN_PHY_MODE_11BE_EHT320;
263 		break;
264 	default:
265 		scan_phymode = SCAN_PHY_MODE_UNKNOWN;
266 		break;
267 	}
268 
269 	return scan_phymode;
270 }
271 #else
mlme_get_scan_phy_mode(void)272 static inline enum scan_phy_mode mlme_get_scan_phy_mode(void)
273 {
274 	return SCAN_PHY_MODE_UNKNOWN;
275 }
276 
277 static inline enum scan_phy_mode
wlan_scan_get_11be_scan_phy_mode(enum wlan_phymode ch_phymode)278 wlan_scan_get_11be_scan_phy_mode(enum wlan_phymode ch_phymode)
279 {
280 	return SCAN_PHY_MODE_UNKNOWN;
281 }
282 #endif
283 
284 /**
285  * wlan_scan_get_scan_phy_mode() - get scan phymode from channel phy mode
286  * @vdev: vdev common object
287  * @op_freq: operational frequency
288  * @vdev_id: vdev id
289  *
290  * Return: enum scan_phy_mode
291  */
292 static enum scan_phy_mode
wlan_scan_get_scan_phy_mode(struct wlan_objmgr_vdev * vdev,qdf_freq_t op_freq,uint32_t vdev_id)293 wlan_scan_get_scan_phy_mode(struct wlan_objmgr_vdev *vdev, qdf_freq_t op_freq,
294 			    uint32_t vdev_id)
295 {
296 	struct wlan_channel *des_chan;
297 	enum scan_phy_mode scan_phymode = SCAN_PHY_MODE_UNKNOWN;
298 
299 	des_chan = wlan_vdev_mlme_get_des_chan(vdev);
300 	if (!des_chan) {
301 		mlme_debug("vdev %d : des_chan is null", vdev_id);
302 		return scan_phymode;
303 	}
304 
305 	switch (des_chan->ch_phymode) {
306 	case WLAN_PHYMODE_11A:
307 		scan_phymode = SCAN_PHY_MODE_11A;
308 		break;
309 	case WLAN_PHYMODE_11B:
310 		scan_phymode = SCAN_PHY_MODE_11B;
311 		break;
312 	case WLAN_PHYMODE_11G:
313 		scan_phymode = SCAN_PHY_MODE_11G;
314 		break;
315 	case WLAN_PHYMODE_11G_ONLY:
316 		scan_phymode = SCAN_PHY_MODE_11GONLY;
317 		break;
318 	case WLAN_PHYMODE_11NA_HT20:
319 		scan_phymode = SCAN_PHY_MODE_11NA_HT20;
320 		break;
321 	case WLAN_PHYMODE_11NG_HT20:
322 		scan_phymode = SCAN_PHY_MODE_11NG_HT20;
323 		break;
324 	case WLAN_PHYMODE_11NA_HT40:
325 		scan_phymode = SCAN_PHY_MODE_11NA_HT40;
326 		break;
327 	case WLAN_PHYMODE_11NG_HT40:
328 		scan_phymode = SCAN_PHY_MODE_11NG_HT40;
329 		break;
330 	case WLAN_PHYMODE_11AC_VHT20:
331 		scan_phymode = SCAN_PHY_MODE_11AC_VHT20;
332 		break;
333 	case WLAN_PHYMODE_11AC_VHT40:
334 		scan_phymode = SCAN_PHY_MODE_11AC_VHT40;
335 		break;
336 	case WLAN_PHYMODE_11AC_VHT80:
337 		scan_phymode = SCAN_PHY_MODE_11AC_VHT80;
338 		break;
339 	case WLAN_PHYMODE_11AC_VHT20_2G:
340 		scan_phymode = SCAN_PHY_MODE_11AC_VHT20_2G;
341 		break;
342 	case WLAN_PHYMODE_11AC_VHT40_2G:
343 		scan_phymode = SCAN_PHY_MODE_11AC_VHT40_2G;
344 		break;
345 	case WLAN_PHYMODE_11AC_VHT80_2G:
346 		scan_phymode = SCAN_PHY_MODE_11AC_VHT80_2G;
347 		break;
348 	case WLAN_PHYMODE_11AC_VHT80_80:
349 		scan_phymode = SCAN_PHY_MODE_11AC_VHT80_80;
350 		break;
351 	case WLAN_PHYMODE_11AC_VHT160:
352 		scan_phymode = SCAN_PHY_MODE_11AC_VHT160;
353 		break;
354 	case WLAN_PHYMODE_11AXA_HE20:
355 		scan_phymode = SCAN_PHY_MODE_11AX_HE20;
356 		break;
357 	case WLAN_PHYMODE_11AXG_HE20:
358 		scan_phymode = SCAN_PHY_MODE_11AX_HE20_2G;
359 		break;
360 	case WLAN_PHYMODE_11AXA_HE40:
361 		scan_phymode = SCAN_PHY_MODE_11AX_HE40;
362 		break;
363 	case WLAN_PHYMODE_11AXG_HE40:
364 		scan_phymode = SCAN_PHY_MODE_11AX_HE40_2G;
365 		break;
366 	case WLAN_PHYMODE_11AXA_HE80:
367 		scan_phymode = SCAN_PHY_MODE_11AX_HE80;
368 		break;
369 	case WLAN_PHYMODE_11AXG_HE80:
370 		scan_phymode = SCAN_PHY_MODE_11AX_HE80_2G;
371 		break;
372 	case WLAN_PHYMODE_11AXA_HE80_80:
373 		scan_phymode = SCAN_PHY_MODE_11AX_HE80_80;
374 		break;
375 	case WLAN_PHYMODE_11AXA_HE160:
376 		scan_phymode = SCAN_PHY_MODE_11AX_HE160;
377 		break;
378 	default:
379 		scan_phymode = SCAN_PHY_MODE_UNKNOWN;
380 		break;
381 	}
382 
383 	if (scan_phymode != SCAN_PHY_MODE_UNKNOWN)
384 		return scan_phymode;
385 
386 	scan_phymode = wlan_scan_get_11be_scan_phy_mode(des_chan->ch_phymode);
387 
388 	return scan_phymode;
389 }
390 
391 #ifdef WLAN_FEATURE_11BE
392 /**
393  * mlme_get_scan_phy_mode_for_chan_load() - get scan phymode from ch width
394  * @scan_ch_width: channel width
395  *
396  * Return: enum scan_phy_mode
397  */
398 static enum scan_phy_mode
mlme_get_scan_phy_mode_for_chan_load(enum phy_ch_width scan_ch_width)399 mlme_get_scan_phy_mode_for_chan_load(enum phy_ch_width scan_ch_width)
400 {
401 	enum scan_phy_mode scan_phymode = SCAN_PHY_MODE_UNKNOWN;
402 
403 	switch (scan_ch_width) {
404 	case CH_WIDTH_20MHZ:
405 		scan_phymode = SCAN_PHY_MODE_11BE_EHT20;
406 		break;
407 	case CH_WIDTH_40MHZ:
408 		scan_phymode = SCAN_PHY_MODE_11BE_EHT40;
409 		break;
410 	case CH_WIDTH_80MHZ:
411 		scan_phymode = SCAN_PHY_MODE_11BE_EHT80;
412 		break;
413 	case CH_WIDTH_160MHZ:
414 		scan_phymode = SCAN_PHY_MODE_11BE_EHT160;
415 		break;
416 	default:
417 		mlme_debug("Invalid scan_ch_width:%d", scan_ch_width);
418 		break;
419 	}
420 
421 	return scan_phymode;
422 }
423 #else
424 static inline enum scan_phy_mode
mlme_get_scan_phy_mode_for_chan_load(enum phy_ch_width scan_ch_width)425 mlme_get_scan_phy_mode_for_chan_load(enum phy_ch_width scan_ch_width)
426 {
427 	return SCAN_PHY_MODE_UNKNOWN;
428 }
429 #endif
430 
431 QDF_STATUS
mlme_update_freq_in_scan_start_req(struct wlan_objmgr_vdev * vdev,struct scan_start_request * req,enum phy_ch_width scan_ch_width,qdf_freq_t scan_freq,qdf_freq_t cen320_freq)432 mlme_update_freq_in_scan_start_req(struct wlan_objmgr_vdev *vdev,
433 				   struct scan_start_request *req,
434 				   enum phy_ch_width scan_ch_width,
435 				   qdf_freq_t scan_freq,
436 				   qdf_freq_t cen320_freq)
437 {
438 	const struct bonded_channel_freq *range;
439 	uint8_t num_chan;
440 	qdf_freq_t op_freq, center_20_freq, start_freq, end_freq;
441 	enum scan_phy_mode phymode = SCAN_PHY_MODE_UNKNOWN;
442 	uint8_t vdev_id = vdev->vdev_objmgr.vdev_id;
443 
444 	if (scan_freq != INVALID_CHANNEL)
445 		op_freq = scan_freq;
446 	else
447 		op_freq = wlan_get_operation_chan_freq(vdev);
448 
449 	mlme_debug("vdev %d :op_freq:%d, cen320_freq:%d, scan_ch_width: %d",
450 		   vdev_id, op_freq, cen320_freq, scan_ch_width);
451 
452 	if (scan_ch_width == CH_WIDTH_320MHZ) {
453 		if (!cen320_freq)
454 			return QDF_STATUS_E_FAILURE;
455 		range = wlan_reg_get_bonded_chan_entry(op_freq,
456 						       scan_ch_width,
457 						       cen320_freq);
458 		if (!range) {
459 			mlme_debug("vdev %d : range is null for freq %d",
460 				   vdev_id, op_freq);
461 			return QDF_STATUS_E_FAILURE;
462 		}
463 
464 		phymode = mlme_get_scan_phy_mode();
465 		if (phymode == SCAN_PHY_MODE_UNKNOWN) {
466 			mlme_debug("vdev %d : invalid scan phymode for freq %d",
467 				   vdev_id, op_freq);
468 			return QDF_STATUS_E_FAILURE;
469 		}
470 
471 		start_freq = range->start_freq;
472 		end_freq = range->end_freq;
473 
474 		/* fill connected 6 GHz ML link freq in wide band scan list */
475 		center_20_freq = start_freq + (7 * BW_20_MHZ);
476 		if (op_freq > center_20_freq)
477 			end_freq = op_freq;
478 		else
479 			start_freq = op_freq;
480 
481 		num_chan = req->scan_req.chan_list.num_chan;
482 		req->scan_req.chan_list.chan[num_chan].freq = start_freq;
483 		req->scan_req.chan_list.chan[num_chan].phymode = phymode;
484 		num_chan += 1;
485 		req->scan_req.chan_list.chan[num_chan].freq = end_freq;
486 		req->scan_req.chan_list.chan[num_chan].phymode = phymode;
487 		num_chan += 1;
488 		req->scan_req.chan_list.num_chan = num_chan;
489 	} else {
490 		if (scan_freq != INVALID_CHANNEL)
491 			phymode = mlme_get_scan_phy_mode_for_chan_load(scan_ch_width);
492 		else
493 			phymode = wlan_scan_get_scan_phy_mode(vdev, op_freq, vdev_id);
494 
495 		if (phymode == SCAN_PHY_MODE_UNKNOWN) {
496 			mlme_debug("vdev %d : invalid scan phymode for freq %d",
497 				   vdev_id, op_freq);
498 			return QDF_STATUS_E_FAILURE;
499 		}
500 
501 		num_chan = req->scan_req.chan_list.num_chan;
502 		req->scan_req.chan_list.chan[num_chan].freq = op_freq;
503 		req->scan_req.chan_list.chan[num_chan].phymode = phymode;
504 		req->scan_req.chan_list.num_chan += 1;
505 	}
506 
507 	return QDF_STATUS_SUCCESS;
508 }
509 
510 #ifdef WLAN_FEATURE_11BE_MLO
511 /**
512  * mlme_update_freq_from_link_ctx() - This API updates scan request from
513  * link context
514  * @links_info: pointer to MLO link info
515  * @req: pointer to scan request
516  *
517  * Return: QDF_STATUS
518  */
519 static QDF_STATUS
mlme_update_freq_from_link_ctx(struct mlo_link_info * links_info,struct scan_start_request * req)520 mlme_update_freq_from_link_ctx(struct mlo_link_info *links_info,
521 			       struct scan_start_request *req)
522 {
523 	const struct bonded_channel_freq *range;
524 	uint8_t num_chan;
525 	qdf_freq_t op_freq, center_20_freq, start_freq, end_freq;
526 	enum scan_phy_mode phymode;
527 	enum phy_ch_width scan_ch_width;
528 	struct wlan_channel *link_chan_info = links_info->link_chan_info;
529 
530 	if (!link_chan_info) {
531 		mlme_err("link chan info is null");
532 		return QDF_STATUS_E_NULL_VALUE;
533 	}
534 
535 	op_freq = link_chan_info->ch_freq;
536 	phymode = wlan_scan_get_11be_scan_phy_mode(link_chan_info->ch_phymode);
537 	if (phymode == SCAN_PHY_MODE_UNKNOWN) {
538 		mlme_err("invalid scan phymode for freq %d", op_freq);
539 		return QDF_STATUS_E_INVAL;
540 	}
541 
542 	scan_ch_width = wlan_mlme_get_ch_width_from_phymode(
543 						link_chan_info->ch_phymode);
544 
545 	if (scan_ch_width == CH_WIDTH_320MHZ) {
546 		range = wlan_reg_get_bonded_chan_entry(op_freq, scan_ch_width,
547 						link_chan_info->ch_cfreq2);
548 		if (!range) {
549 			mlme_err("range is null for freq %d center freq %d",
550 				 op_freq, link_chan_info->ch_cfreq2);
551 			return QDF_STATUS_E_NULL_VALUE;
552 		}
553 
554 		start_freq = range->start_freq;
555 		end_freq = range->end_freq;
556 
557 		/* fill connected 6 GHz ML link freq in wide band scan list */
558 		center_20_freq = start_freq + (7 * BW_20_MHZ);
559 		if (op_freq > center_20_freq)
560 			end_freq = op_freq;
561 		else
562 			start_freq = op_freq;
563 
564 		mlme_debug("op_freq:%d, c_freq:%d, start_freq:%d, end_freq:%d",
565 			   op_freq, center_20_freq, start_freq, end_freq);
566 
567 		num_chan = req->scan_req.chan_list.num_chan;
568 		req->scan_req.chan_list.chan[num_chan].freq = start_freq;
569 		req->scan_req.chan_list.chan[num_chan].phymode = phymode;
570 		num_chan += 1;
571 		req->scan_req.chan_list.chan[num_chan].freq = end_freq;
572 		req->scan_req.chan_list.chan[num_chan].phymode = phymode;
573 		num_chan += 1;
574 		req->scan_req.chan_list.num_chan = num_chan;
575 	} else {
576 		num_chan = req->scan_req.chan_list.num_chan;
577 		req->scan_req.chan_list.chan[num_chan].freq = op_freq;
578 		req->scan_req.chan_list.chan[num_chan].phymode = phymode;
579 		req->scan_req.chan_list.num_chan += 1;
580 	}
581 
582 	return QDF_STATUS_SUCCESS;
583 }
584 
585 /**
586  * mlme_fill_freq_in_mlo_wide_band_scan_start_req() - Fill frequencies in wide
587  * band scan req for mlo connection
588  * @vdev: vdev common object
589  * @req: pointer to scan request
590  *
591  * Return: QDF_STATUS
592  */
593 static QDF_STATUS
mlme_fill_freq_in_mlo_wide_band_scan_start_req(struct wlan_objmgr_vdev * vdev,struct scan_start_request * req)594 mlme_fill_freq_in_mlo_wide_band_scan_start_req(struct wlan_objmgr_vdev *vdev,
595 					struct scan_start_request *req)
596 {
597 	struct wlan_mlo_dev_context *mlo_dev_ctx;
598 	uint8_t i;
599 	QDF_STATUS status;
600 	struct mlo_link_switch_context *link_ctx;
601 
602 	mlo_dev_ctx = vdev->mlo_dev_ctx;
603 	if (!mlo_dev_ctx) {
604 		mlme_err("vdev %d :mlo_dev_ctx is NULL", req->scan_req.vdev_id);
605 		return QDF_STATUS_E_NULL_VALUE;
606 	}
607 
608 	link_ctx = mlo_dev_ctx->link_ctx;
609 	if (!link_ctx) {
610 		mlme_err("vdev %d :mlo_link_ctx is NULL",
611 			 req->scan_req.vdev_id);
612 		return QDF_STATUS_E_NULL_VALUE;
613 	}
614 
615 	for (i = 0; i < WLAN_MAX_ML_BSS_LINKS  &&
616 	     link_ctx->links_info[i].link_id != WLAN_INVALID_LINK_ID; i++) {
617 		status = mlme_update_freq_from_link_ctx(
618 						&link_ctx->links_info[i], req);
619 		if (QDF_IS_STATUS_ERROR(status)) {
620 			mlme_debug("freq update fails for link id %d",
621 				   link_ctx->links_info[i].link_id);
622 			return status;
623 		}
624 	}
625 
626 	mlme_debug("vdev %d :trigger wide band scan for mlo conn, num freq %d",
627 		   req->scan_req.vdev_id, req->scan_req.chan_list.num_chan);
628 	return QDF_STATUS_SUCCESS;
629 }
630 #else
631 static inline QDF_STATUS
mlme_fill_freq_in_mlo_wide_band_scan_start_req(struct wlan_objmgr_vdev * vdev,struct scan_start_request * req)632 mlme_fill_freq_in_mlo_wide_band_scan_start_req(struct wlan_objmgr_vdev *vdev,
633 					struct scan_start_request *req)
634 {
635 	return QDF_STATUS_E_FAILURE;
636 }
637 #endif
638 
639 /**
640  * mlme_fill_freq_in_wide_scan_start_request() - Fill frequencies in wide band
641  * scan req
642  * @vdev: vdev common object
643  * @req: pointer to scan request
644  *
645  * Return: QDF_STATUS
646  */
647 static QDF_STATUS
mlme_fill_freq_in_wide_scan_start_request(struct wlan_objmgr_vdev * vdev,struct scan_start_request * req)648 mlme_fill_freq_in_wide_scan_start_request(struct wlan_objmgr_vdev *vdev,
649 					  struct scan_start_request *req)
650 {
651 	struct mlme_legacy_priv *mlme_priv;
652 	enum phy_ch_width associated_ch_width;
653 	QDF_STATUS status;
654 	qdf_freq_t assoc_cen320_freq = 0;
655 
656 	req->scan_req.chan_list.num_chan = 0;
657 
658 	if (wlan_vdev_mlme_is_mlo_vdev(vdev)) {
659 		status = mlme_fill_freq_in_mlo_wide_band_scan_start_req(vdev,
660 						req);
661 		if (QDF_IS_STATUS_ERROR(status))
662 			return QDF_STATUS_E_FAILURE;
663 		goto update_param;
664 	}
665 
666 	mlme_priv = wlan_vdev_mlme_get_ext_hdl(vdev);
667 	if (!mlme_priv)
668 		return QDF_STATUS_E_FAILURE;
669 
670 	associated_ch_width =
671 		mlme_priv->connect_info.assoc_chan_info.assoc_ch_width;
672 	if (associated_ch_width == CH_WIDTH_INVALID) {
673 		mlme_debug("vdev %d :Invalid associated ch_width",
674 			   req->scan_req.vdev_id);
675 		return QDF_STATUS_E_FAILURE;
676 	}
677 
678 	/* Set center frequency of complete 320MHz */
679 	assoc_cen320_freq = mlme_priv->connect_info.assoc_chan_info.cen320_freq;
680 
681 	status = mlme_update_freq_in_scan_start_req(vdev, req,
682 						    associated_ch_width,
683 						    INVALID_CHANNEL,
684 						    assoc_cen320_freq);
685 	if (QDF_IS_STATUS_ERROR(status))
686 		return QDF_STATUS_E_FAILURE;
687 
688 	mlme_debug("vdev %d :trigger wide band scan, num freq %d",
689 		   req->scan_req.vdev_id, req->scan_req.chan_list.num_chan);
690 
691 update_param:
692 	req->scan_req.dwell_time_passive =
693 			MLME_GET_CHAN_STATS_WIDE_BAND_PASSIVE_SCAN_TIME;
694 	req->scan_req.dwell_time_passive_6g =
695 			MLME_GET_CHAN_STATS_WIDE_BAND_PASSIVE_SCAN_TIME;
696 
697 	req->scan_req.scan_f_wide_band = true;
698 	/*
699 	 * FW report CCA busy for each possible 20Mhz subbands of the
700 	 * wideband scan channel if below flag is true
701 	 */
702 	req->scan_req.scan_f_report_cca_busy_for_each_20mhz = true;
703 
704 	return QDF_STATUS_SUCCESS;
705 }
706 
mlme_connected_chan_stats_request(struct wlan_objmgr_psoc * psoc,uint8_t vdev_id)707 QDF_STATUS mlme_connected_chan_stats_request(struct wlan_objmgr_psoc *psoc,
708 					     uint8_t vdev_id)
709 {
710 	struct wlan_mlme_psoc_ext_obj *mlme_obj;
711 	QDF_STATUS status;
712 	struct wlan_objmgr_vdev *vdev;
713 	struct scan_start_request *req;
714 
715 	mlme_obj = mlme_get_psoc_ext_obj(psoc);
716 	if (!mlme_obj) {
717 		mlme_debug("vdev %d : NULL mlme psoc object", vdev_id);
718 		return QDF_STATUS_E_FAILURE;
719 	}
720 
721 	vdev = wlan_objmgr_get_vdev_by_id_from_psoc(psoc, vdev_id,
722 						    WLAN_MLME_NB_ID);
723 	if (!vdev) {
724 		mlme_debug("vdev %d : NULL vdev object", vdev_id);
725 		return QDF_STATUS_E_FAILURE;
726 	}
727 
728 	req = qdf_mem_malloc(sizeof(*req));
729 	if (!req) {
730 		wlan_objmgr_vdev_release_ref(vdev, WLAN_MLME_NB_ID);
731 		return QDF_STATUS_E_NOMEM;
732 	}
733 
734 	status = wlan_scan_init_default_params(vdev, req);
735 	if (QDF_IS_STATUS_ERROR(status))
736 		goto release;
737 
738 	req->scan_req.scan_id = wlan_scan_get_scan_id(psoc);
739 	req->scan_req.scan_req_id = mlme_obj->scan_requester_id;
740 	req->scan_req.vdev_id = vdev_id;
741 
742 	req->scan_req.scan_type = SCAN_TYPE_DEFAULT;
743 
744 	/* Fill channel list as per fw capability */
745 	if (wlan_psoc_nif_fw_ext2_cap_get(psoc,
746 			WLAN_CCA_BUSY_INFO_FOREACH_20MHZ)) {
747 		status = mlme_fill_freq_in_wide_scan_start_request(vdev, req);
748 		if (QDF_IS_STATUS_ERROR(status))
749 			goto release;
750 	} else {
751 		status = mlme_fill_freq_in_scan_start_request(vdev, req);
752 		if (QDF_IS_STATUS_ERROR(status))
753 			goto release;
754 	}
755 
756 	/* disable adatptive dwell time */
757 	req->scan_req.adaptive_dwell_time_mode = SCAN_DWELL_MODE_STATIC;
758 	/* to disable early 6Ghz scan bail out */
759 	req->scan_req.min_dwell_time_6g = 0;
760 	/* passive scan for CCA measurement */
761 	req->scan_req.scan_f_passive = true;
762 	/* Fw pause home channel when scan channel is same as home channel */
763 	req->scan_req.scan_f_pause_home_channel = true;
764 
765 	status = wlan_scan_start(req);
766 	if (QDF_IS_STATUS_ERROR(status)) {
767 		mlme_debug("vdev %d :Failed to send scan req, status %d",
768 			   vdev_id, status);
769 		goto release;
770 	}
771 
772 	wlan_objmgr_vdev_release_ref(vdev, WLAN_MLME_NB_ID);
773 	return status;
774 release:
775 	qdf_mem_free(req);
776 	wlan_objmgr_vdev_release_ref(vdev, WLAN_MLME_NB_ID);
777 	return status;
778 }
779 
mlme_get_vdev_he_ops(struct wlan_objmgr_psoc * psoc,uint8_t vdev_id)780 uint32_t mlme_get_vdev_he_ops(struct wlan_objmgr_psoc *psoc, uint8_t vdev_id)
781 {
782 	struct vdev_mlme_obj *mlme_obj;
783 	uint32_t he_ops = 0;
784 	struct wlan_objmgr_vdev *vdev;
785 
786 	vdev = wlan_objmgr_get_vdev_by_id_from_psoc(psoc, vdev_id,
787 						    WLAN_MLME_NB_ID);
788 	if (!vdev)
789 		return he_ops;
790 
791 	mlme_obj = wlan_vdev_mlme_get_cmpt_obj(vdev);
792 	if (!mlme_obj) {
793 		wlan_objmgr_vdev_release_ref(vdev, WLAN_MLME_NB_ID);
794 		mlme_legacy_err("Failed to get vdev MLME Obj");
795 		return he_ops;
796 	}
797 
798 	he_ops = mlme_obj->proto.he_ops_info.he_ops;
799 	wlan_objmgr_vdev_release_ref(vdev, WLAN_MLME_NB_ID);
800 
801 	return he_ops;
802 }
803 
mlme_get_ini_vdev_config(struct wlan_objmgr_vdev * vdev)804 struct wlan_mlme_nss_chains *mlme_get_ini_vdev_config(
805 				struct wlan_objmgr_vdev *vdev)
806 {
807 	struct mlme_legacy_priv *mlme_priv;
808 
809 	mlme_priv = wlan_vdev_mlme_get_ext_hdl(vdev);
810 	if (!mlme_priv) {
811 		mlme_legacy_err("vdev legacy private object is NULL");
812 		return NULL;
813 	}
814 
815 	return &mlme_priv->ini_cfg;
816 }
817 
mlme_get_dynamic_oce_flags(struct wlan_objmgr_vdev * vdev)818 uint8_t *mlme_get_dynamic_oce_flags(struct wlan_objmgr_vdev *vdev)
819 {
820 	struct mlme_legacy_priv *mlme_priv;
821 
822 	mlme_priv = wlan_vdev_mlme_get_ext_hdl(vdev);
823 	if (!mlme_priv) {
824 		mlme_legacy_err("vdev legacy private object is NULL");
825 		return NULL;
826 	}
827 
828 	return &mlme_priv->sta_dynamic_oce_value;
829 }
830 
mlme_init_rate_config(struct vdev_mlme_obj * vdev_mlme)831 QDF_STATUS mlme_init_rate_config(struct vdev_mlme_obj *vdev_mlme)
832 {
833 	struct mlme_legacy_priv *mlme_priv;
834 
835 	mlme_priv = vdev_mlme->ext_vdev_ptr;
836 	if (!mlme_priv) {
837 		mlme_legacy_err("vdev legacy private object is NULL");
838 		return QDF_STATUS_E_FAILURE;
839 	}
840 
841 	mlme_priv->opr_rate_set.max_len =
842 		QDF_MIN(CFG_OPERATIONAL_RATE_SET_LEN, CFG_STR_DATA_LEN);
843 	mlme_priv->opr_rate_set.len = 0;
844 	mlme_priv->ext_opr_rate_set.max_len =
845 		QDF_MIN(CFG_EXTENDED_OPERATIONAL_RATE_SET_LEN,
846 			CFG_STR_DATA_LEN);
847 	mlme_priv->ext_opr_rate_set.len = 0;
848 	mlme_priv->mcs_rate_set.max_len =
849 		QDF_MIN(CFG_SUPPORTED_MCS_SET_LEN, CFG_STR_DATA_LEN);
850 	mlme_priv->mcs_rate_set.len = 0;
851 
852 	return QDF_STATUS_SUCCESS;
853 }
854 
mlme_init_connect_chan_info_config(struct vdev_mlme_obj * vdev_mlme)855 QDF_STATUS mlme_init_connect_chan_info_config(struct vdev_mlme_obj *vdev_mlme)
856 {
857 	struct mlme_legacy_priv *mlme_priv;
858 
859 	mlme_priv = vdev_mlme->ext_vdev_ptr;
860 	if (!mlme_priv) {
861 		mlme_legacy_err("vdev legacy private object is NULL");
862 		return QDF_STATUS_E_FAILURE;
863 	}
864 
865 	mlme_priv->connect_info.assoc_chan_info.assoc_ch_width =
866 							CH_WIDTH_INVALID;
867 	mlme_priv->connect_info.assoc_chan_info.omn_ie_ch_width =
868 							CH_WIDTH_INVALID;
869 	mlme_priv->connect_info.assoc_chan_info.sec_2g_freq = 0;
870 	mlme_priv->connect_info.assoc_chan_info.cen320_freq = 0;
871 
872 	return QDF_STATUS_SUCCESS;
873 }
874 
mlme_get_peer_mic_len(struct wlan_objmgr_psoc * psoc,uint8_t pdev_id,uint8_t * peer_mac,uint8_t * mic_len,uint8_t * mic_hdr_len)875 QDF_STATUS mlme_get_peer_mic_len(struct wlan_objmgr_psoc *psoc, uint8_t pdev_id,
876 				 uint8_t *peer_mac, uint8_t *mic_len,
877 				 uint8_t *mic_hdr_len)
878 {
879 	struct wlan_objmgr_peer *peer;
880 	int32_t key_cipher;
881 
882 	if (!psoc || !mic_len || !mic_hdr_len || !peer_mac) {
883 		mlme_legacy_debug("psoc/mic_len/mic_hdr_len/peer_mac null");
884 		return QDF_STATUS_E_NULL_VALUE;
885 	}
886 
887 	peer = wlan_objmgr_get_peer(psoc, pdev_id,
888 				    peer_mac, WLAN_LEGACY_MAC_ID);
889 	if (!peer) {
890 		mlme_legacy_debug("Peer of peer_mac "QDF_MAC_ADDR_FMT" not found",
891 				  QDF_MAC_ADDR_REF(peer_mac));
892 		return QDF_STATUS_E_INVAL;
893 	}
894 
895 	key_cipher =
896 		wlan_crypto_get_peer_param(peer,
897 					   WLAN_CRYPTO_PARAM_UCAST_CIPHER);
898 
899 	wlan_objmgr_peer_release_ref(peer, WLAN_LEGACY_MAC_ID);
900 
901 	if (key_cipher < 0) {
902 		mlme_legacy_err("Invalid mgmt cipher");
903 		return QDF_STATUS_E_INVAL;
904 	}
905 
906 	if (key_cipher & (1 << WLAN_CRYPTO_CIPHER_AES_GCM) ||
907 	    key_cipher & (1 << WLAN_CRYPTO_CIPHER_AES_GCM_256)) {
908 		*mic_hdr_len = WLAN_IEEE80211_GCMP_HEADERLEN;
909 		*mic_len = WLAN_IEEE80211_GCMP_MICLEN;
910 	} else {
911 		*mic_hdr_len = IEEE80211_CCMP_HEADERLEN;
912 		*mic_len = IEEE80211_CCMP_MICLEN;
913 	}
914 	mlme_legacy_debug("peer "QDF_MAC_ADDR_FMT" hdr_len %d mic_len %d key_cipher 0x%x",
915 			  QDF_MAC_ADDR_REF(peer_mac),
916 			  *mic_hdr_len, *mic_len, key_cipher);
917 
918 	return QDF_STATUS_SUCCESS;
919 }
920 
921 void
wlan_acquire_peer_key_wakelock(struct wlan_objmgr_pdev * pdev,uint8_t * mac_addr)922 wlan_acquire_peer_key_wakelock(struct wlan_objmgr_pdev *pdev, uint8_t *mac_addr)
923 {
924 	uint8_t pdev_id;
925 	struct wlan_objmgr_peer *peer;
926 	struct peer_mlme_priv_obj *peer_priv;
927 	struct wlan_objmgr_psoc *psoc;
928 
929 	psoc = wlan_pdev_get_psoc(pdev);
930 	if (!psoc)
931 		return;
932 
933 	pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev);
934 	peer = wlan_objmgr_get_peer(psoc, pdev_id, mac_addr,
935 				    WLAN_LEGACY_MAC_ID);
936 	if (!peer)
937 		return;
938 
939 	peer_priv = wlan_objmgr_peer_get_comp_private_obj(peer,
940 							  WLAN_UMAC_COMP_MLME);
941 	if (!peer_priv) {
942 		wlan_objmgr_peer_release_ref(peer, WLAN_LEGACY_MAC_ID);
943 		return;
944 	}
945 
946 	if (peer_priv->is_key_wakelock_set) {
947 		wlan_objmgr_peer_release_ref(peer, WLAN_LEGACY_MAC_ID);
948 		return;
949 	}
950 
951 	mlme_debug(QDF_MAC_ADDR_FMT ": Acquire set key wake lock for %d ms",
952 		   QDF_MAC_ADDR_REF(mac_addr),
953 		   MLME_PEER_SET_KEY_WAKELOCK_TIMEOUT);
954 	qdf_wake_lock_timeout_acquire(&peer_priv->peer_set_key_wakelock,
955 				      MLME_PEER_SET_KEY_WAKELOCK_TIMEOUT);
956 	qdf_runtime_pm_prevent_suspend(
957 			&peer_priv->peer_set_key_runtime_wakelock);
958 	peer_priv->is_key_wakelock_set = true;
959 
960 	wlan_objmgr_peer_release_ref(peer, WLAN_LEGACY_MAC_ID);
961 }
962 
963 void
wlan_release_peer_key_wakelock(struct wlan_objmgr_pdev * pdev,uint8_t * mac_addr)964 wlan_release_peer_key_wakelock(struct wlan_objmgr_pdev *pdev, uint8_t *mac_addr)
965 {
966 	uint8_t pdev_id;
967 	struct wlan_objmgr_peer *peer;
968 	struct peer_mlme_priv_obj *peer_priv;
969 	struct wlan_objmgr_psoc *psoc;
970 
971 	psoc = wlan_pdev_get_psoc(pdev);
972 	if (!psoc)
973 		return;
974 
975 	pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev);
976 	peer = wlan_objmgr_get_peer(psoc, pdev_id, mac_addr,
977 				    WLAN_LEGACY_MAC_ID);
978 	if (!peer)
979 		return;
980 
981 	peer_priv = wlan_objmgr_peer_get_comp_private_obj(peer,
982 							  WLAN_UMAC_COMP_MLME);
983 	if (!peer_priv) {
984 		wlan_objmgr_peer_release_ref(peer, WLAN_LEGACY_MAC_ID);
985 		return;
986 	}
987 
988 	if (!peer_priv->is_key_wakelock_set) {
989 		wlan_objmgr_peer_release_ref(peer, WLAN_LEGACY_MAC_ID);
990 		return;
991 	}
992 
993 	peer_priv->is_key_wakelock_set = false;
994 	mlme_debug(QDF_MAC_ADDR_FMT ": Release set key wake lock",
995 		   QDF_MAC_ADDR_REF(mac_addr));
996 	qdf_wake_lock_release(&peer_priv->peer_set_key_wakelock,
997 			      WIFI_POWER_EVENT_WAKELOCK_WMI_CMD_RSP);
998 	qdf_runtime_pm_allow_suspend(
999 			&peer_priv->peer_set_key_runtime_wakelock);
1000 
1001 	wlan_objmgr_peer_release_ref(peer, WLAN_LEGACY_MAC_ID);
1002 }
1003 
1004 QDF_STATUS
mlme_peer_object_created_notification(struct wlan_objmgr_peer * peer,void * arg)1005 mlme_peer_object_created_notification(struct wlan_objmgr_peer *peer,
1006 				      void *arg)
1007 {
1008 	struct peer_mlme_priv_obj *peer_priv;
1009 	QDF_STATUS status;
1010 
1011 	if (!peer) {
1012 		mlme_legacy_err(" peer is NULL");
1013 		return QDF_STATUS_E_FAILURE;
1014 	}
1015 
1016 	peer_priv = qdf_mem_malloc(sizeof(*peer_priv));
1017 	if (!peer_priv)
1018 		return QDF_STATUS_E_NOMEM;
1019 
1020 	status = wlan_objmgr_peer_component_obj_attach(peer,
1021 						       WLAN_UMAC_COMP_MLME,
1022 						       (void *)peer_priv,
1023 						       QDF_STATUS_SUCCESS);
1024 
1025 	if (QDF_IS_STATUS_ERROR(status)) {
1026 		mlme_legacy_err("unable to attach peer_priv obj to peer obj");
1027 		qdf_mem_free(peer_priv);
1028 		return status;
1029 	}
1030 
1031 	qdf_wake_lock_create(&peer_priv->peer_set_key_wakelock, "peer_set_key");
1032 	qdf_runtime_lock_init(&peer_priv->peer_set_key_runtime_wakelock);
1033 	peer_priv->is_key_wakelock_set = false;
1034 	peer_priv->peer_ind_bw = CH_WIDTH_INVALID;
1035 
1036 	return status;
1037 }
1038 
1039 QDF_STATUS
mlme_peer_object_destroyed_notification(struct wlan_objmgr_peer * peer,void * arg)1040 mlme_peer_object_destroyed_notification(struct wlan_objmgr_peer *peer,
1041 					void *arg)
1042 {
1043 	struct peer_mlme_priv_obj *peer_priv;
1044 	QDF_STATUS status;
1045 
1046 	if (!peer) {
1047 		mlme_legacy_err(" peer is NULL");
1048 		return QDF_STATUS_E_FAILURE;
1049 	}
1050 
1051 	peer_priv = wlan_objmgr_peer_get_comp_private_obj(peer,
1052 							  WLAN_UMAC_COMP_MLME);
1053 	if (!peer_priv) {
1054 		mlme_legacy_err(" peer MLME component object is NULL");
1055 		return QDF_STATUS_E_FAILURE;
1056 	}
1057 
1058 	peer_priv->is_key_wakelock_set = false;
1059 	qdf_runtime_lock_deinit(&peer_priv->peer_set_key_runtime_wakelock);
1060 	qdf_wake_lock_destroy(&peer_priv->peer_set_key_wakelock);
1061 
1062 	status = wlan_objmgr_peer_component_obj_detach(peer,
1063 						       WLAN_UMAC_COMP_MLME,
1064 						       peer_priv);
1065 
1066 	if (QDF_IS_STATUS_ERROR(status))
1067 		mlme_legacy_err("unable to detach peer_priv obj to peer obj");
1068 
1069 	mlme_free_peer_assoc_rsp_ie(peer_priv);
1070 	qdf_mem_free(peer_priv);
1071 
1072 	return status;
1073 }
1074 
mlme_init_chainmask_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_chainmask * chainmask_info)1075 static void mlme_init_chainmask_cfg(struct wlan_objmgr_psoc *psoc,
1076 				    struct wlan_mlme_chainmask *chainmask_info)
1077 {
1078 	chainmask_info->txchainmask1x1 =
1079 		cfg_get(psoc, CFG_VHT_ENABLE_1x1_TX_CHAINMASK);
1080 
1081 	chainmask_info->rxchainmask1x1 =
1082 		cfg_get(psoc, CFG_VHT_ENABLE_1x1_RX_CHAINMASK);
1083 
1084 	chainmask_info->tx_chain_mask_cck =
1085 		cfg_get(psoc, CFG_TX_CHAIN_MASK_CCK);
1086 
1087 	chainmask_info->tx_chain_mask_1ss =
1088 		cfg_get(psoc, CFG_TX_CHAIN_MASK_1SS);
1089 
1090 	chainmask_info->num_11b_tx_chains =
1091 		cfg_get(psoc, CFG_11B_NUM_TX_CHAIN);
1092 
1093 	chainmask_info->num_11ag_tx_chains =
1094 		cfg_get(psoc, CFG_11AG_NUM_TX_CHAIN);
1095 
1096 	chainmask_info->tx_chain_mask_2g =
1097 		cfg_get(psoc, CFG_TX_CHAIN_MASK_2G);
1098 
1099 	chainmask_info->rx_chain_mask_2g =
1100 		cfg_get(psoc, CFG_RX_CHAIN_MASK_2G);
1101 
1102 	chainmask_info->tx_chain_mask_5g =
1103 		cfg_get(psoc, CFG_TX_CHAIN_MASK_5G);
1104 
1105 	chainmask_info->rx_chain_mask_5g =
1106 		cfg_get(psoc, CFG_RX_CHAIN_MASK_5G);
1107 
1108 	chainmask_info->enable_bt_chain_separation =
1109 		cfg_get(psoc, CFG_ENABLE_BT_CHAIN_SEPARATION);
1110 }
1111 
mlme_init_ratemask_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_ratemask * ratemask_cfg)1112 static void mlme_init_ratemask_cfg(struct wlan_objmgr_psoc *psoc,
1113 				   struct wlan_mlme_ratemask *ratemask_cfg)
1114 {
1115 	uint32_t masks[CFG_MLME_RATE_MASK_LEN] = { 0 };
1116 	qdf_size_t len = 0;
1117 	QDF_STATUS status;
1118 
1119 	ratemask_cfg->type = cfg_get(psoc, CFG_RATEMASK_TYPE);
1120 	if ((ratemask_cfg->type <= WLAN_MLME_RATEMASK_TYPE_NO_MASK) ||
1121 	    (ratemask_cfg->type >= WLAN_MLME_RATEMASK_TYPE_MAX)) {
1122 		mlme_legacy_debug("Ratemask disabled");
1123 		return;
1124 	}
1125 
1126 	status = qdf_uint32_array_parse(cfg_get(psoc, CFG_RATEMASK_SET),
1127 					masks,
1128 					CFG_MLME_RATE_MASK_LEN,
1129 					&len);
1130 
1131 	if (status != QDF_STATUS_SUCCESS || len != CFG_MLME_RATE_MASK_LEN) {
1132 		/* Do not enable ratemask if config is invalid */
1133 		ratemask_cfg->type = WLAN_MLME_RATEMASK_TYPE_NO_MASK;
1134 		mlme_legacy_err("Failed to parse ratemask");
1135 		return;
1136 	}
1137 
1138 	ratemask_cfg->lower32 = masks[0];
1139 	ratemask_cfg->higher32 = masks[1];
1140 	ratemask_cfg->lower32_2 = masks[2];
1141 	ratemask_cfg->higher32_2 = masks[3];
1142 	mlme_legacy_debug("Ratemask type: %d, masks:0x%x, 0x%x, 0x%x, 0x%x",
1143 			  ratemask_cfg->type, ratemask_cfg->lower32,
1144 			  ratemask_cfg->higher32, ratemask_cfg->lower32_2,
1145 			  ratemask_cfg->higher32_2);
1146 }
1147 
mlme_init_pmf_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_generic * gen)1148 static void mlme_init_pmf_cfg(struct wlan_objmgr_psoc *psoc,
1149 			      struct wlan_mlme_generic *gen)
1150 {
1151 	gen->pmf_sa_query_max_retries =
1152 		cfg_get(psoc, CFG_PMF_SA_QUERY_MAX_RETRIES);
1153 	gen->pmf_sa_query_retry_interval =
1154 		cfg_get(psoc, CFG_PMF_SA_QUERY_RETRY_INTERVAL);
1155 }
1156 
1157 #ifdef WLAN_FEATURE_11BE
mlme_init_oem_eht_mlo_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_generic * gen)1158 static inline void mlme_init_oem_eht_mlo_cfg(struct wlan_objmgr_psoc *psoc,
1159 					     struct wlan_mlme_generic *gen)
1160 {
1161 	gen->oem_eht_mlo_crypto_bitmap =
1162 				cfg_get(psoc, CFG_OEM_EHT_MLO_CRYPTO_BITMAP);
1163 }
1164 #else
mlme_init_oem_eht_mlo_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_generic * gen)1165 static inline void mlme_init_oem_eht_mlo_cfg(struct wlan_objmgr_psoc *psoc,
1166 					     struct wlan_mlme_generic *gen)
1167 {
1168 }
1169 #endif /* WLAN_FEATURE_11BE */
1170 
1171 #ifdef WLAN_FEATURE_LPSS
1172 static inline void
mlme_init_lpass_support_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_generic * gen)1173 mlme_init_lpass_support_cfg(struct wlan_objmgr_psoc *psoc,
1174 			    struct wlan_mlme_generic *gen)
1175 {
1176 	gen->lpass_support = cfg_get(psoc, CFG_ENABLE_LPASS_SUPPORT);
1177 }
1178 #else
1179 static inline void
mlme_init_lpass_support_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_generic * gen)1180 mlme_init_lpass_support_cfg(struct wlan_objmgr_psoc *psoc,
1181 			    struct wlan_mlme_generic *gen)
1182 {
1183 	gen->lpass_support = cfg_default(CFG_ENABLE_LPASS_SUPPORT);
1184 }
1185 #endif
1186 
1187 #ifdef FEATURE_WDS
1188 /**
1189  * mlme_init_wds_config_cfg() - initialize wds_mode flag
1190  * @psoc: Pointer to PSOC
1191  * @gen: pointer to generic CFG items
1192  *
1193  * Return: None
1194  */
mlme_init_wds_config_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_generic * gen)1195 static void mlme_init_wds_config_cfg(struct wlan_objmgr_psoc *psoc,
1196 				     struct wlan_mlme_generic *gen)
1197 {
1198 	gen->wds_mode = cfg_get(psoc, CFG_WDS_MODE);
1199 }
1200 #else
mlme_init_wds_config_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_generic * gen)1201 static void mlme_init_wds_config_cfg(struct wlan_objmgr_psoc *psoc,
1202 				     struct wlan_mlme_generic *gen)
1203 {
1204 }
1205 #endif
1206 
1207 #ifdef CONFIG_BAND_6GHZ
1208 /**
1209  * mlme_init_disable_vlp_sta_conn_to_sp_ap() - initialize disable vlp STA
1210  *                                             connection to sp AP flag
1211  * @psoc: Pointer to PSOC
1212  * @gen: pointer to generic CFG items
1213  *
1214  * Return: None
1215  */
mlme_init_disable_vlp_sta_conn_to_sp_ap(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_generic * gen)1216 static void mlme_init_disable_vlp_sta_conn_to_sp_ap(
1217 						struct wlan_objmgr_psoc *psoc,
1218 						struct wlan_mlme_generic *gen)
1219 {
1220 	gen->disable_vlp_sta_conn_to_sp_ap =
1221 		cfg_default(CFG_DISABLE_VLP_STA_CONN_TO_SP_AP);
1222 }
1223 #else
mlme_init_disable_vlp_sta_conn_to_sp_ap(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_generic * gen)1224 static void mlme_init_disable_vlp_sta_conn_to_sp_ap(
1225 						struct wlan_objmgr_psoc *psoc,
1226 						struct wlan_mlme_generic *gen)
1227 {
1228 }
1229 #endif
1230 
1231 #ifdef CONFIG_BAND_6GHZ
1232 /**
1233  * mlme_init_standard_6ghz_conn_policy() - initialize standard 6GHz
1234  *                                         policy connection flag
1235  * @psoc: Pointer to PSOC
1236  * @gen: pointer to generic CFG items
1237  *
1238  * Return: None
1239  */
mlme_init_standard_6ghz_conn_policy(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_generic * gen)1240 static void mlme_init_standard_6ghz_conn_policy(struct wlan_objmgr_psoc *psoc,
1241 						struct wlan_mlme_generic *gen)
1242 {
1243 	gen->std_6ghz_conn_policy =
1244 		cfg_get(psoc, CFG_6GHZ_STANDARD_CONNECTION_POLICY);
1245 }
1246 #else
mlme_init_standard_6ghz_conn_policy(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_generic * gen)1247 static void mlme_init_standard_6ghz_conn_policy(struct wlan_objmgr_psoc *psoc,
1248 						struct wlan_mlme_generic *gen)
1249 {
1250 }
1251 #endif
1252 
1253 /**
1254  * mlme_init_mgmt_hw_tx_retry_count_cfg() - initialize mgmt hw tx retry count
1255  * @psoc: Pointer to PSOC
1256  * @gen: pointer to generic CFG items
1257  *
1258  * Return: None
1259  */
mlme_init_mgmt_hw_tx_retry_count_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_generic * gen)1260 static void mlme_init_mgmt_hw_tx_retry_count_cfg(
1261 			struct wlan_objmgr_psoc *psoc,
1262 			struct wlan_mlme_generic *gen)
1263 {
1264 	uint32_t i;
1265 	qdf_size_t out_size = 0;
1266 	uint8_t count_array[MGMT_FRM_HW_TX_RETRY_COUNT_STR_LEN];
1267 
1268 	qdf_uint8_array_parse(cfg_get(psoc, CFG_MGMT_FRAME_HW_TX_RETRY_COUNT),
1269 			      count_array,
1270 			      MGMT_FRM_HW_TX_RETRY_COUNT_STR_LEN,
1271 			      &out_size);
1272 
1273 	for (i = 0; i + 1 < out_size; i += 2) {
1274 		if (count_array[i] >= CFG_FRAME_TYPE_MAX) {
1275 			mlme_legacy_debug("invalid frm type %d",
1276 					  count_array[i]);
1277 			continue;
1278 		}
1279 		if (count_array[i + 1] >= MAX_MGMT_HW_TX_RETRY_COUNT) {
1280 			mlme_legacy_debug("mgmt hw tx retry count %d for frm %d, limit to %d",
1281 					  count_array[i + 1],
1282 					  count_array[i],
1283 					  MAX_MGMT_HW_TX_RETRY_COUNT);
1284 			gen->mgmt_hw_tx_retry_count[count_array[i]] =
1285 						MAX_MGMT_HW_TX_RETRY_COUNT;
1286 		} else {
1287 			mlme_legacy_debug("mgmt hw tx retry count %d for frm %d",
1288 					  count_array[i + 1],
1289 					  count_array[i]);
1290 			gen->mgmt_hw_tx_retry_count[count_array[i]] =
1291 							count_array[i + 1];
1292 		}
1293 	}
1294 }
1295 
1296 #ifdef WLAN_FEATURE_11BE_MLO
1297 /**
1298  * mlme_init_emlsr_mode() - initialize emlsr mode enable flag
1299  * @psoc: Pointer to PSOC
1300  * @gen: pointer to generic CFG items
1301  *
1302  * Return: None
1303  */
mlme_init_emlsr_mode(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_generic * gen)1304 static void mlme_init_emlsr_mode(struct wlan_objmgr_psoc *psoc,
1305 				 struct wlan_mlme_generic *gen)
1306 {
1307 	gen->enable_emlsr_mode = cfg_default(CFG_EMLSR_MODE_ENABLE);
1308 }
1309 
1310 /**
1311  * mlme_init_tl2m_negotiation_support() - initialize t2lm support
1312  * @psoc: Pointer to PSOC
1313  * @gen: pointer to generic CFG items
1314  *
1315  * Return: None
1316  */
mlme_init_tl2m_negotiation_support(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_generic * gen)1317 static void mlme_init_tl2m_negotiation_support(struct wlan_objmgr_psoc *psoc,
1318 						 struct wlan_mlme_generic *gen)
1319 {
1320 	gen->t2lm_negotiation_support = cfg_get(psoc,
1321 						CFG_T2LM_NEGOTIATION_SUPPORT);
1322 }
1323 #else
mlme_init_emlsr_mode(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_generic * gen)1324 static void mlme_init_emlsr_mode(struct wlan_objmgr_psoc *psoc,
1325 				 struct wlan_mlme_generic *gen)
1326 {
1327 }
1328 
mlme_init_tl2m_negotiation_support(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_generic * gen)1329 static void mlme_init_tl2m_negotiation_support(struct wlan_objmgr_psoc *psoc,
1330 						 struct wlan_mlme_generic *gen)
1331 {
1332 }
1333 #endif
1334 
1335 #if defined(WLAN_FEATURE_SR)
1336 /**
1337  * mlme_init_sr_ini_cfg() - initialize SR(Spatial Reuse) ini
1338  * @psoc: Pointer to PSOC
1339  * @gen: pointer to generic CFG items
1340  *
1341  * Return: None
1342  */
mlme_init_sr_ini_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_generic * gen)1343 static void mlme_init_sr_ini_cfg(struct wlan_objmgr_psoc *psoc,
1344 				 struct wlan_mlme_generic *gen)
1345 {
1346 	gen->sr_enable_modes = cfg_get(psoc, CFG_SR_ENABLE_MODES);
1347 }
1348 #else
mlme_init_sr_ini_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_generic * gen)1349 static void mlme_init_sr_ini_cfg(struct wlan_objmgr_psoc *psoc,
1350 				 struct wlan_mlme_generic *gen)
1351 {}
1352 #endif
1353 
mlme_init_generic_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_generic * gen)1354 static void mlme_init_generic_cfg(struct wlan_objmgr_psoc *psoc,
1355 				  struct wlan_mlme_generic *gen)
1356 {
1357 	gen->rtt3_enabled = cfg_default(CFG_RTT3_ENABLE);
1358 	gen->rtt_mac_randomization =
1359 		cfg_get(psoc, CFG_ENABLE_RTT_MAC_RANDOMIZATION);
1360 	gen->band_capability =
1361 		cfg_get(psoc, CFG_BAND_CAPABILITY);
1362 	if (!gen->band_capability)
1363 		gen->band_capability = REG_BAND_MASK_ALL;
1364 	gen->band = gen->band_capability;
1365 	gen->select_5ghz_margin =
1366 		cfg_get(psoc, CFG_SELECT_5GHZ_MARGIN);
1367 	gen->sub_20_chan_width =
1368 		cfg_get(psoc, CFG_SUB_20_CHANNEL_WIDTH);
1369 	gen->ito_repeat_count =
1370 		cfg_get(psoc, CFG_ITO_REPEAT_COUNT);
1371 	gen->dropped_pkt_disconnect_thresh =
1372 		cfg_get(psoc, CFG_DROPPED_PKT_DISCONNECT_THRESHOLD);
1373 	gen->prevent_link_down =
1374 		cfg_get(psoc, CFG_PREVENT_LINK_DOWN);
1375 	gen->memory_deep_sleep =
1376 		cfg_get(psoc, CFG_ENABLE_MEM_DEEP_SLEEP);
1377 	gen->cck_tx_fir_override =
1378 		cfg_get(psoc, CFG_ENABLE_CCK_TX_FIR_OVERRIDE);
1379 	gen->crash_inject =
1380 		cfg_get(psoc, CFG_ENABLE_CRASH_INJECT);
1381 	gen->self_recovery =
1382 		cfg_get(psoc, CFG_ENABLE_SELF_RECOVERY);
1383 	gen->sap_dot11mc =
1384 		cfg_get(psoc, CFG_SAP_DOT11MC);
1385 	gen->fatal_event_trigger =
1386 		cfg_get(psoc, CFG_ENABLE_FATAL_EVENT_TRIGGER);
1387 	gen->optimize_ca_event =
1388 		cfg_get(psoc, CFG_OPTIMIZE_CA_EVENT);
1389 	gen->fw_timeout_crash =
1390 		cfg_get(psoc, CFG_CRASH_FW_TIMEOUT);
1391 	gen->debug_packet_log = cfg_get(psoc, CFG_ENABLE_DEBUG_PACKET_LOG);
1392 	gen->enable_deauth_to_disassoc_map =
1393 		cfg_get(psoc, CFG_ENABLE_DEAUTH_TO_DISASSOC_MAP);
1394 	gen->wls_6ghz_capable = cfg_get(psoc, CFG_WLS_6GHZ_CAPABLE);
1395 	mlme_init_pmf_cfg(psoc, gen);
1396 	mlme_init_oem_eht_mlo_cfg(psoc, gen);
1397 	mlme_init_lpass_support_cfg(psoc, gen);
1398 	gen->enabled_rf_test_mode = cfg_default(CFG_RF_TEST_MODE_SUPP_ENABLED);
1399 	gen->enabled_11h = cfg_get(psoc, CFG_11H_SUPPORT_ENABLED);
1400 	gen->enabled_11d = cfg_get(psoc, CFG_11D_SUPPORT_ENABLED);
1401 	gen->enable_beacon_reception_stats =
1402 		cfg_get(psoc, CFG_ENABLE_BEACON_RECEPTION_STATS);
1403 	gen->disable_4way_hs_offload =
1404 		cfg_get(psoc, CFG_DISABLE_4WAY_HS_OFFLOAD);
1405 	gen->mgmt_retry_max = cfg_get(psoc, CFG_MGMT_RETRY_MAX);
1406 	gen->bmiss_skip_full_scan = cfg_get(psoc, CFG_BMISS_SKIP_FULL_SCAN);
1407 	gen->enable_ring_buffer = cfg_get(psoc, CFG_ENABLE_RING_BUFFER);
1408 	gen->enable_peer_unmap_conf_support =
1409 		cfg_get(psoc, CFG_DP_ENABLE_PEER_UMAP_CONF_SUPPORT);
1410 	gen->dfs_chan_ageout_time =
1411 		cfg_get(psoc, CFG_DFS_CHAN_AGEOUT_TIME);
1412 	gen->sae_connect_retries =
1413 		cfg_get(psoc, CFG_SAE_CONNECION_RETRIES);
1414 	gen->monitor_mode_concurrency =
1415 		cfg_get(psoc, CFG_MONITOR_MODE_CONCURRENCY);
1416 	gen->tx_retry_multiplier = cfg_get(psoc, CFG_TX_RETRY_MULTIPLIER);
1417 	gen->enable_he_mcs0_for_6ghz_mgmt =
1418 		cfg_get(psoc, CFG_ENABLE_HE_MCS0_MGMT_6GHZ);
1419 	mlme_init_sr_ini_cfg(psoc, gen);
1420 	mlme_init_wds_config_cfg(psoc, gen);
1421 	mlme_init_mgmt_hw_tx_retry_count_cfg(psoc, gen);
1422 	mlme_init_emlsr_mode(psoc, gen);
1423 	mlme_init_tl2m_negotiation_support(psoc, gen);
1424 	mlme_init_standard_6ghz_conn_policy(psoc, gen);
1425 	mlme_init_disable_vlp_sta_conn_to_sp_ap(psoc, gen);
1426 }
1427 
mlme_init_edca_ani_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_edca_params * edca_params)1428 static void mlme_init_edca_ani_cfg(struct wlan_objmgr_psoc *psoc,
1429 				   struct wlan_mlme_edca_params *edca_params)
1430 {
1431 	/* initialize the max allowed array length for read/write */
1432 	edca_params->ani_acbe_l.max_len = CFG_EDCA_DATA_LEN;
1433 	edca_params->ani_acbk_l.max_len = CFG_EDCA_DATA_LEN;
1434 	edca_params->ani_acvi_l.max_len = CFG_EDCA_DATA_LEN;
1435 	edca_params->ani_acvo_l.max_len = CFG_EDCA_DATA_LEN;
1436 
1437 	edca_params->ani_acbe_b.max_len = CFG_EDCA_DATA_LEN;
1438 	edca_params->ani_acbk_b.max_len = CFG_EDCA_DATA_LEN;
1439 	edca_params->ani_acvi_b.max_len = CFG_EDCA_DATA_LEN;
1440 	edca_params->ani_acvo_b.max_len = CFG_EDCA_DATA_LEN;
1441 
1442 	/* parse the ETSI edca parameters from cfg string for BK,BE,VI,VO ac */
1443 	qdf_uint8_array_parse(cfg_get(psoc, CFG_EDCA_ANI_ACBK_LOCAL),
1444 			      edca_params->ani_acbk_l.data,
1445 			      CFG_EDCA_DATA_LEN,
1446 			      &edca_params->ani_acbk_l.len);
1447 
1448 	qdf_uint8_array_parse(cfg_get(psoc, CFG_EDCA_ANI_ACBE_LOCAL),
1449 			      edca_params->ani_acbe_l.data,
1450 			      CFG_EDCA_DATA_LEN,
1451 			      &edca_params->ani_acbe_l.len);
1452 
1453 	qdf_uint8_array_parse(cfg_get(psoc, CFG_EDCA_ANI_ACVI_LOCAL),
1454 			      edca_params->ani_acvi_l.data,
1455 			      CFG_EDCA_DATA_LEN,
1456 			      &edca_params->ani_acvi_l.len);
1457 
1458 	qdf_uint8_array_parse(cfg_get(psoc, CFG_EDCA_ANI_ACVO_LOCAL),
1459 			      edca_params->ani_acvo_l.data,
1460 			      CFG_EDCA_DATA_LEN,
1461 			      &edca_params->ani_acvo_l.len);
1462 
1463 	qdf_uint8_array_parse(cfg_get(psoc, CFG_EDCA_ANI_ACBK),
1464 			      edca_params->ani_acbk_b.data,
1465 			      CFG_EDCA_DATA_LEN,
1466 			      &edca_params->ani_acbk_b.len);
1467 
1468 	qdf_uint8_array_parse(cfg_get(psoc, CFG_EDCA_ANI_ACBE),
1469 			      edca_params->ani_acbe_b.data,
1470 			      CFG_EDCA_DATA_LEN,
1471 			      &edca_params->ani_acbe_b.len);
1472 
1473 	qdf_uint8_array_parse(cfg_get(psoc, CFG_EDCA_ANI_ACVI),
1474 			      edca_params->ani_acvi_b.data,
1475 			      CFG_EDCA_DATA_LEN,
1476 			      &edca_params->ani_acvi_b.len);
1477 
1478 	qdf_uint8_array_parse(cfg_get(psoc, CFG_EDCA_ANI_ACVO),
1479 			      edca_params->ani_acvo_b.data,
1480 			      CFG_EDCA_DATA_LEN,
1481 			      &edca_params->ani_acvo_b.len);
1482 }
1483 
mlme_init_edca_wme_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_edca_params * edca_params)1484 static void mlme_init_edca_wme_cfg(struct wlan_objmgr_psoc *psoc,
1485 				   struct wlan_mlme_edca_params *edca_params)
1486 {
1487 	/* initialize the max allowed array length for read/write */
1488 	edca_params->wme_acbk_l.max_len = CFG_EDCA_DATA_LEN;
1489 	edca_params->wme_acbe_l.max_len = CFG_EDCA_DATA_LEN;
1490 	edca_params->wme_acvi_l.max_len = CFG_EDCA_DATA_LEN;
1491 	edca_params->wme_acvo_l.max_len = CFG_EDCA_DATA_LEN;
1492 
1493 	edca_params->wme_acbk_b.max_len = CFG_EDCA_DATA_LEN;
1494 	edca_params->wme_acbe_b.max_len = CFG_EDCA_DATA_LEN;
1495 	edca_params->wme_acvi_b.max_len = CFG_EDCA_DATA_LEN;
1496 	edca_params->wme_acvo_b.max_len = CFG_EDCA_DATA_LEN;
1497 
1498 	/* parse the WME edca parameters from cfg string for BK,BE,VI,VO ac */
1499 	qdf_uint8_array_parse(cfg_get(psoc, CFG_EDCA_WME_ACBK_LOCAL),
1500 			      edca_params->wme_acbk_l.data,
1501 			      CFG_EDCA_DATA_LEN,
1502 			      &edca_params->wme_acbk_l.len);
1503 
1504 	qdf_uint8_array_parse(cfg_get(psoc, CFG_EDCA_WME_ACBE_LOCAL),
1505 			      edca_params->wme_acbe_l.data,
1506 			      CFG_EDCA_DATA_LEN,
1507 			      &edca_params->wme_acbe_l.len);
1508 
1509 	qdf_uint8_array_parse(cfg_get(psoc, CFG_EDCA_WME_ACVI_LOCAL),
1510 			      edca_params->wme_acvi_l.data,
1511 			      CFG_EDCA_DATA_LEN,
1512 			      &edca_params->wme_acvi_l.len);
1513 
1514 	qdf_uint8_array_parse(cfg_get(psoc, CFG_EDCA_WME_ACVO_LOCAL),
1515 			      edca_params->wme_acvo_l.data,
1516 			      CFG_EDCA_DATA_LEN,
1517 			      &edca_params->wme_acvo_l.len);
1518 
1519 	qdf_uint8_array_parse(cfg_get(psoc, CFG_EDCA_WME_ACBK),
1520 			      edca_params->wme_acbk_b.data,
1521 			      CFG_EDCA_DATA_LEN,
1522 			      &edca_params->wme_acbk_b.len);
1523 
1524 	qdf_uint8_array_parse(cfg_get(psoc, CFG_EDCA_WME_ACBE),
1525 			      edca_params->wme_acbe_b.data,
1526 			      CFG_EDCA_DATA_LEN,
1527 			      &edca_params->wme_acbe_b.len);
1528 
1529 	qdf_uint8_array_parse(cfg_get(psoc, CFG_EDCA_WME_ACVI),
1530 			      edca_params->wme_acvi_b.data,
1531 			      CFG_EDCA_DATA_LEN,
1532 			      &edca_params->wme_acvi_b.len);
1533 
1534 	qdf_uint8_array_parse(cfg_get(psoc, CFG_EDCA_WME_ACVO),
1535 			      edca_params->wme_acvo_b.data,
1536 			      CFG_EDCA_DATA_LEN,
1537 			      &edca_params->wme_acvo_b.len);
1538 }
1539 
mlme_init_edca_etsi_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_edca_params * edca_params)1540 static void mlme_init_edca_etsi_cfg(struct wlan_objmgr_psoc *psoc,
1541 				    struct wlan_mlme_edca_params *edca_params)
1542 {
1543 	/* initialize the max allowed array length for read/write */
1544 	edca_params->etsi_acbe_l.max_len = CFG_EDCA_DATA_LEN;
1545 	edca_params->etsi_acbk_l.max_len = CFG_EDCA_DATA_LEN;
1546 	edca_params->etsi_acvi_l.max_len = CFG_EDCA_DATA_LEN;
1547 	edca_params->etsi_acvo_l.max_len = CFG_EDCA_DATA_LEN;
1548 
1549 	edca_params->etsi_acbe_b.max_len = CFG_EDCA_DATA_LEN;
1550 	edca_params->etsi_acbk_b.max_len = CFG_EDCA_DATA_LEN;
1551 	edca_params->etsi_acvi_b.max_len = CFG_EDCA_DATA_LEN;
1552 	edca_params->etsi_acvo_b.max_len = CFG_EDCA_DATA_LEN;
1553 
1554 	/* parse the ETSI edca parameters from cfg string for BK,BE,VI,VO ac */
1555 	qdf_uint8_array_parse(cfg_get(psoc, CFG_EDCA_ETSI_ACBK_LOCAL),
1556 			      edca_params->etsi_acbk_l.data,
1557 			      CFG_EDCA_DATA_LEN,
1558 			      &edca_params->etsi_acbk_l.len);
1559 
1560 	qdf_uint8_array_parse(cfg_get(psoc, CFG_EDCA_ETSI_ACBE_LOCAL),
1561 			      edca_params->etsi_acbe_l.data,
1562 			      CFG_EDCA_DATA_LEN,
1563 			      &edca_params->etsi_acbe_l.len);
1564 
1565 	qdf_uint8_array_parse(cfg_get(psoc, CFG_EDCA_ETSI_ACVI_LOCAL),
1566 			      edca_params->etsi_acvi_l.data,
1567 			      CFG_EDCA_DATA_LEN,
1568 			      &edca_params->etsi_acvi_l.len);
1569 
1570 	qdf_uint8_array_parse(cfg_get(psoc, CFG_EDCA_ETSI_ACVO_LOCAL),
1571 			      edca_params->etsi_acvo_l.data,
1572 			      CFG_EDCA_DATA_LEN,
1573 			      &edca_params->etsi_acvo_l.len);
1574 
1575 	qdf_uint8_array_parse(cfg_get(psoc, CFG_EDCA_ETSI_ACBK),
1576 			      edca_params->etsi_acbk_b.data,
1577 			      CFG_EDCA_DATA_LEN,
1578 			      &edca_params->etsi_acbk_b.len);
1579 
1580 	qdf_uint8_array_parse(cfg_get(psoc, CFG_EDCA_ETSI_ACBE),
1581 			      edca_params->etsi_acbe_b.data,
1582 			      CFG_EDCA_DATA_LEN,
1583 			      &edca_params->etsi_acbe_b.len);
1584 
1585 	qdf_uint8_array_parse(cfg_get(psoc, CFG_EDCA_ETSI_ACVI),
1586 			      edca_params->etsi_acvi_b.data,
1587 			      CFG_EDCA_DATA_LEN,
1588 			      &edca_params->etsi_acvi_b.len);
1589 
1590 	qdf_uint8_array_parse(cfg_get(psoc, CFG_EDCA_ETSI_ACVO),
1591 			      edca_params->etsi_acvo_b.data,
1592 			      CFG_EDCA_DATA_LEN,
1593 			      &edca_params->etsi_acvo_b.len);
1594 }
1595 
1596 static void
mlme_init_qos_edca_params(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_edca_params * edca_params)1597 mlme_init_qos_edca_params(struct wlan_objmgr_psoc *psoc,
1598 			  struct wlan_mlme_edca_params *edca_params)
1599 {
1600 	edca_params->enable_edca_params =
1601 			cfg_get(psoc, CFG_EDCA_ENABLE_PARAM);
1602 
1603 	edca_params->enable_wmm_txop =
1604 			cfg_get(psoc, CFG_ENABLE_WMM_TXOP);
1605 	edca_params->edca_ac_vo.vo_cwmin =
1606 			cfg_get(psoc, CFG_EDCA_VO_CWMIN);
1607 	edca_params->edca_ac_vo.vo_cwmax =
1608 			cfg_get(psoc, CFG_EDCA_VO_CWMAX);
1609 	edca_params->edca_ac_vo.vo_aifs =
1610 			cfg_get(psoc, CFG_EDCA_VO_AIFS);
1611 
1612 	edca_params->edca_ac_vi.vi_cwmin =
1613 			cfg_get(psoc, CFG_EDCA_VI_CWMIN);
1614 	edca_params->edca_ac_vi.vi_cwmax =
1615 			cfg_get(psoc, CFG_EDCA_VI_CWMAX);
1616 	edca_params->edca_ac_vi.vi_aifs =
1617 			cfg_get(psoc, CFG_EDCA_VI_AIFS);
1618 
1619 	edca_params->edca_ac_bk.bk_cwmin =
1620 			cfg_get(psoc, CFG_EDCA_BK_CWMIN);
1621 	edca_params->edca_ac_bk.bk_cwmax =
1622 			cfg_get(psoc, CFG_EDCA_BK_CWMAX);
1623 	edca_params->edca_ac_bk.bk_aifs =
1624 			cfg_get(psoc, CFG_EDCA_BK_AIFS);
1625 
1626 	edca_params->edca_ac_be.be_cwmin =
1627 			cfg_get(psoc, CFG_EDCA_BE_CWMIN);
1628 	edca_params->edca_ac_be.be_cwmax =
1629 			cfg_get(psoc, CFG_EDCA_BE_CWMAX);
1630 	edca_params->edca_ac_be.be_aifs =
1631 			cfg_get(psoc, CFG_EDCA_BE_AIFS);
1632 
1633 	edca_params->edca_param_type =
1634 			cfg_get(psoc, CFG_EDCA_PIFS_PARAM_TYPE);
1635 }
1636 
mlme_init_edca_params(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_edca_params * edca_params)1637 static void mlme_init_edca_params(struct wlan_objmgr_psoc *psoc,
1638 				  struct wlan_mlme_edca_params *edca_params)
1639 {
1640 	mlme_init_edca_ani_cfg(psoc, edca_params);
1641 	mlme_init_edca_wme_cfg(psoc, edca_params);
1642 	mlme_init_edca_etsi_cfg(psoc, edca_params);
1643 	mlme_init_qos_edca_params(psoc, edca_params);
1644 }
1645 
mlme_init_timeout_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_timeout * timeouts)1646 static void mlme_init_timeout_cfg(struct wlan_objmgr_psoc *psoc,
1647 				  struct wlan_mlme_timeout *timeouts)
1648 {
1649 	timeouts->join_failure_timeout =
1650 			cfg_get(psoc, CFG_JOIN_FAILURE_TIMEOUT);
1651 	timeouts->join_failure_timeout_ori = timeouts->join_failure_timeout;
1652 	timeouts->probe_req_retry_timeout = JOIN_PROBE_REQ_TIMER_MS;
1653 	timeouts->auth_failure_timeout =
1654 			cfg_get(psoc, CFG_AUTH_FAILURE_TIMEOUT);
1655 	timeouts->auth_rsp_timeout =
1656 			cfg_get(psoc, CFG_AUTH_RSP_TIMEOUT);
1657 	timeouts->assoc_failure_timeout =
1658 			cfg_get(psoc, CFG_ASSOC_FAILURE_TIMEOUT);
1659 	timeouts->reassoc_failure_timeout =
1660 			cfg_get(psoc, CFG_REASSOC_FAILURE_TIMEOUT);
1661 	timeouts->olbc_detect_timeout =
1662 			cfg_get(psoc, CFG_OLBC_DETECT_TIMEOUT);
1663 	timeouts->addts_rsp_timeout =
1664 			cfg_get(psoc, CFG_ADDTS_RSP_TIMEOUT);
1665 	timeouts->heart_beat_threshold =
1666 			cfg_get(psoc, CFG_HEART_BEAT_THRESHOLD);
1667 	timeouts->ap_keep_alive_timeout =
1668 			cfg_get(psoc, CFG_AP_KEEP_ALIVE_TIMEOUT);
1669 	timeouts->ap_link_monitor_timeout =
1670 			cfg_get(psoc, CFG_AP_LINK_MONITOR_TIMEOUT);
1671 	timeouts->wmi_wq_watchdog_timeout =
1672 			cfg_get(psoc, CFG_WMI_WQ_WATCHDOG);
1673 	timeouts->sae_auth_failure_timeout =
1674 			cfg_get(psoc, CFG_SAE_AUTH_FAILURE_TIMEOUT);
1675 }
1676 
mlme_init_ht_cap_in_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_ht_caps * ht_caps)1677 static void mlme_init_ht_cap_in_cfg(struct wlan_objmgr_psoc *psoc,
1678 				    struct wlan_mlme_ht_caps *ht_caps)
1679 {
1680 	union {
1681 		uint16_t val_16;
1682 		struct mlme_ht_capabilities_info ht_cap_info;
1683 	} u1;
1684 
1685 	union {
1686 		uint16_t val_16;
1687 		struct mlme_ht_ext_cap_info ext_cap_info;
1688 	} u2;
1689 
1690 	union {
1691 		uint8_t val_8;
1692 		struct mlme_ht_info_field_1 info_field_1;
1693 	} u3;
1694 
1695 	union {
1696 		uint16_t val_16;
1697 		struct mlme_ht_info_field_2 info_field_2;
1698 	} u4;
1699 
1700 	union {
1701 		uint16_t val_16;
1702 		struct mlme_ht_info_field_3 info_field_3;
1703 	} u5;
1704 
1705 	/* HT Capabilities - HT Caps Info Field */
1706 	u1.val_16 = (uint16_t)cfg_default(CFG_HT_CAP_INFO);
1707 	u1.ht_cap_info.adv_coding_cap =
1708 				cfg_get(psoc, CFG_RX_LDPC_ENABLE);
1709 	u1.ht_cap_info.rx_stbc = cfg_get(psoc, CFG_RX_STBC_ENABLE);
1710 	u1.ht_cap_info.tx_stbc = cfg_get(psoc, CFG_TX_STBC_ENABLE);
1711 	u1.ht_cap_info.short_gi_20_mhz =
1712 				cfg_get(psoc, CFG_SHORT_GI_20MHZ);
1713 	u1.ht_cap_info.short_gi_40_mhz =
1714 				cfg_get(psoc, CFG_SHORT_GI_40MHZ);
1715 	u1.ht_cap_info.mimo_power_save = cfg_get(psoc, CFG_HT_SMPS_MODE);
1716 	ht_caps->ht_cap_info = u1.ht_cap_info;
1717 
1718 	/* HT Capapabilties - AMPDU Params */
1719 	ht_caps->ampdu_params.max_rx_ampdu_factor =
1720 		cfg_get(psoc, CFG_MAX_RX_AMPDU_FACTOR);
1721 	ht_caps->ampdu_params.mpdu_density =
1722 		cfg_get(psoc, CFG_MPDU_DENSITY);
1723 	ht_caps->ampdu_params.reserved = 0;
1724 
1725 	/* HT Capabilities - Extended Capabilities field */
1726 	u2.val_16 = (uint16_t)cfg_default(CFG_EXT_HT_CAP_INFO);
1727 	ht_caps->ext_cap_info = u2.ext_cap_info;
1728 
1729 	/* HT Operation - Information subset 1 of 3 */
1730 	u3.val_8 = (uint8_t)cfg_default(CFG_HT_INFO_FIELD_1);
1731 	ht_caps->info_field_1 = u3.info_field_1;
1732 
1733 	/* HT Operation - Information subset 2 of 3 */
1734 	u4.val_16 = (uint16_t)cfg_default(CFG_HT_INFO_FIELD_2);
1735 	ht_caps->info_field_2 = u4.info_field_2;
1736 
1737 	/* HT Operation - Information subset 3 of 3 */
1738 	u5.val_16 = (uint16_t)cfg_default(CFG_HT_INFO_FIELD_3);
1739 	ht_caps->info_field_3 = u5.info_field_3;
1740 
1741 	ht_caps->short_preamble = cfg_get(psoc, CFG_SHORT_PREAMBLE);
1742 	ht_caps->enable_ampdu_ps = cfg_get(psoc, CFG_ENABLE_AMPDUPS);
1743 	ht_caps->enable_smps = cfg_get(psoc, CFG_ENABLE_HT_SMPS);
1744 	ht_caps->smps = cfg_get(psoc, CFG_HT_SMPS_MODE);
1745 	ht_caps->max_num_amsdu = cfg_get(psoc, CFG_MAX_AMSDU_NUM);
1746 	ht_caps->tx_ldpc_enable = cfg_get(psoc, CFG_TX_LDPC_ENABLE);
1747 	ht_caps->short_slot_time_enabled =
1748 		cfg_get(psoc, CFG_SHORT_SLOT_TIME_ENABLED);
1749 }
1750 
mlme_init_qos_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_qos * qos_aggr_params)1751 static void mlme_init_qos_cfg(struct wlan_objmgr_psoc *psoc,
1752 			      struct wlan_mlme_qos *qos_aggr_params)
1753 {
1754 	qos_aggr_params->tx_aggregation_size =
1755 				cfg_get(psoc, CFG_TX_AGGREGATION_SIZE);
1756 	qos_aggr_params->tx_aggregation_size_be =
1757 				cfg_get(psoc, CFG_TX_AGGREGATION_SIZEBE);
1758 	qos_aggr_params->tx_aggregation_size_bk =
1759 				cfg_get(psoc, CFG_TX_AGGREGATION_SIZEBK);
1760 	qos_aggr_params->tx_aggregation_size_vi =
1761 				cfg_get(psoc, CFG_TX_AGGREGATION_SIZEVI);
1762 	qos_aggr_params->tx_aggregation_size_vo =
1763 				cfg_get(psoc, CFG_TX_AGGREGATION_SIZEVO);
1764 	qos_aggr_params->rx_aggregation_size =
1765 				cfg_get(psoc, CFG_RX_AGGREGATION_SIZE);
1766 	qos_aggr_params->tx_aggr_sw_retry_threshold_be =
1767 				cfg_get(psoc, CFG_TX_AGGR_SW_RETRY_BE);
1768 	qos_aggr_params->tx_aggr_sw_retry_threshold_bk =
1769 				cfg_get(psoc, CFG_TX_AGGR_SW_RETRY_BK);
1770 	qos_aggr_params->tx_aggr_sw_retry_threshold_vi =
1771 				cfg_get(psoc, CFG_TX_AGGR_SW_RETRY_VI);
1772 	qos_aggr_params->tx_aggr_sw_retry_threshold_vo =
1773 				cfg_get(psoc, CFG_TX_AGGR_SW_RETRY_VO);
1774 	qos_aggr_params->tx_aggr_sw_retry_threshold =
1775 				cfg_get(psoc, CFG_TX_AGGR_SW_RETRY);
1776 	qos_aggr_params->tx_non_aggr_sw_retry_threshold_be =
1777 				cfg_get(psoc, CFG_TX_NON_AGGR_SW_RETRY_BE);
1778 	qos_aggr_params->tx_non_aggr_sw_retry_threshold_bk =
1779 				cfg_get(psoc, CFG_TX_NON_AGGR_SW_RETRY_BK);
1780 	qos_aggr_params->tx_non_aggr_sw_retry_threshold_vi =
1781 				cfg_get(psoc, CFG_TX_NON_AGGR_SW_RETRY_VI);
1782 	qos_aggr_params->tx_non_aggr_sw_retry_threshold_vo =
1783 				cfg_get(psoc, CFG_TX_NON_AGGR_SW_RETRY_VO);
1784 	qos_aggr_params->tx_non_aggr_sw_retry_threshold =
1785 				cfg_get(psoc, CFG_TX_NON_AGGR_SW_RETRY);
1786 	qos_aggr_params->sap_max_inactivity_override =
1787 				cfg_get(psoc, CFG_SAP_MAX_INACTIVITY_OVERRIDE);
1788 	qos_aggr_params->sap_uapsd_enabled =
1789 				cfg_get(psoc, CFG_SAP_QOS_UAPSD);
1790 }
1791 
mlme_init_mbo_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_mbo * mbo_params)1792 static void mlme_init_mbo_cfg(struct wlan_objmgr_psoc *psoc,
1793 			      struct wlan_mlme_mbo *mbo_params)
1794 {
1795 	mbo_params->mbo_candidate_rssi_thres =
1796 			cfg_get(psoc, CFG_MBO_CANDIDATE_RSSI_THRESHOLD);
1797 	mbo_params->mbo_current_rssi_thres =
1798 			cfg_get(psoc, CFG_MBO_CURRENT_RSSI_THRESHOLD);
1799 	mbo_params->mbo_current_rssi_mcc_thres =
1800 			cfg_get(psoc, CFG_MBO_CUR_RSSI_MCC_THRESHOLD);
1801 	mbo_params->mbo_candidate_rssi_btc_thres =
1802 			cfg_get(psoc, CFG_MBO_CAND_RSSI_BTC_THRESHOLD);
1803 }
1804 
mlme_init_vht_cap_cfg(struct wlan_objmgr_psoc * psoc,struct mlme_vht_capabilities_info * vht_cap_info)1805 static void mlme_init_vht_cap_cfg(struct wlan_objmgr_psoc *psoc,
1806 				  struct mlme_vht_capabilities_info
1807 				  *vht_cap_info)
1808 {
1809 	vht_cap_info->supp_chan_width =
1810 			cfg_default(CFG_VHT_SUPP_CHAN_WIDTH);
1811 	vht_cap_info->num_soundingdim =
1812 			cfg_default(CFG_VHT_NUM_SOUNDING_DIMENSIONS);
1813 	vht_cap_info->htc_vhtc =
1814 			cfg_default(CFG_VHT_HTC_VHTC);
1815 	vht_cap_info->link_adap_cap =
1816 			cfg_default(CFG_VHT_LINK_ADAPTATION_CAP);
1817 	vht_cap_info->rx_antpattern =
1818 			cfg_default(CFG_VHT_RX_ANT_PATTERN);
1819 	vht_cap_info->tx_antpattern =
1820 			cfg_default(CFG_VHT_TX_ANT_PATTERN);
1821 	vht_cap_info->rx_supp_data_rate =
1822 			cfg_default(CFG_VHT_RX_SUPP_DATA_RATE);
1823 	vht_cap_info->tx_supp_data_rate =
1824 			cfg_default(CFG_VHT_TX_SUPP_DATA_RATE);
1825 	vht_cap_info->txop_ps =
1826 			cfg_default(CFG_VHT_TXOP_PS);
1827 	vht_cap_info->rx_mcs_map =
1828 			CFG_VHT_RX_MCS_MAP_STADEF;
1829 	vht_cap_info->tx_mcs_map =
1830 			CFG_VHT_TX_MCS_MAP_STADEF;
1831 	vht_cap_info->basic_mcs_set =
1832 			CFG_VHT_BASIC_MCS_SET_STADEF;
1833 
1834 	vht_cap_info->tx_bfee_ant_supp =
1835 			cfg_get(psoc, CFG_VHT_BEAMFORMEE_ANT_SUPP);
1836 
1837 	vht_cap_info->enable_txbf_20mhz =
1838 			cfg_get(psoc, CFG_VHT_ENABLE_TXBF_IN_20MHZ);
1839 	vht_cap_info->ampdu_len =
1840 			cfg_get(psoc, CFG_VHT_MPDU_LEN);
1841 
1842 	vht_cap_info->ldpc_coding_cap =
1843 			cfg_get(psoc, CFG_RX_LDPC_ENABLE);
1844 	vht_cap_info->short_gi_80mhz =
1845 			cfg_get(psoc, CFG_SHORT_GI_40MHZ);
1846 	vht_cap_info->short_gi_160mhz =
1847 			cfg_get(psoc, CFG_SHORT_GI_40MHZ);
1848 	vht_cap_info->tx_stbc =
1849 			cfg_get(psoc, CFG_TX_STBC_ENABLE);
1850 	vht_cap_info->rx_stbc =
1851 			cfg_get(psoc, CFG_RX_STBC_ENABLE);
1852 
1853 	vht_cap_info->su_bformee =
1854 		cfg_get(psoc, CFG_VHT_SU_BEAMFORMEE_CAP);
1855 
1856 	vht_cap_info->mu_bformer =
1857 			cfg_default(CFG_VHT_MU_BEAMFORMER_CAP);
1858 
1859 	vht_cap_info->enable_mu_bformee =
1860 			cfg_get(psoc, CFG_VHT_ENABLE_MU_BFORMEE_CAP_FEATURE);
1861 	vht_cap_info->ampdu_len_exponent =
1862 			cfg_get(psoc, CFG_VHT_AMPDU_LEN_EXPONENT);
1863 	vht_cap_info->channel_width =
1864 			cfg_get(psoc, CFG_VHT_CHANNEL_WIDTH);
1865 	vht_cap_info->rx_mcs =
1866 			cfg_get(psoc, CFG_VHT_ENABLE_RX_MCS_8_9);
1867 	vht_cap_info->tx_mcs =
1868 			cfg_get(psoc, CFG_VHT_ENABLE_TX_MCS_8_9);
1869 	vht_cap_info->rx_mcs2x2 =
1870 			cfg_get(psoc, CFG_VHT_ENABLE_RX_MCS2x2_8_9);
1871 	vht_cap_info->tx_mcs2x2 =
1872 			cfg_get(psoc, CFG_VHT_ENABLE_TX_MCS2x2_8_9);
1873 	vht_cap_info->enable_vht20_mcs9 =
1874 			cfg_get(psoc, CFG_ENABLE_VHT20_MCS9);
1875 	vht_cap_info->enable2x2 =
1876 			cfg_get(psoc, CFG_VHT_ENABLE_2x2_CAP_FEATURE);
1877 	vht_cap_info->enable_paid =
1878 			cfg_get(psoc, CFG_VHT_ENABLE_PAID_FEATURE);
1879 	vht_cap_info->enable_gid =
1880 			cfg_get(psoc, CFG_VHT_ENABLE_GID_FEATURE);
1881 	vht_cap_info->b24ghz_band =
1882 			cfg_get(psoc, CFG_ENABLE_VHT_FOR_24GHZ);
1883 	vht_cap_info->vendor_24ghz_band =
1884 			cfg_get(psoc, CFG_ENABLE_VENDOR_VHT_FOR_24GHZ);
1885 	vht_cap_info->tx_bfee_sap =
1886 			cfg_get(psoc, CFG_VHT_ENABLE_TXBF_SAP_MODE);
1887 	vht_cap_info->vendor_vhtie =
1888 			cfg_get(psoc, CFG_ENABLE_SUBFEE_IN_VENDOR_VHTIE);
1889 
1890 	if (vht_cap_info->enable2x2)
1891 		vht_cap_info->su_bformer =
1892 			cfg_get(psoc, CFG_VHT_ENABLE_TX_SU_BEAM_FORMER);
1893 
1894 	if (vht_cap_info->enable2x2 && vht_cap_info->su_bformer)
1895 		vht_cap_info->num_soundingdim = NUM_OF_SOUNDING_DIMENSIONS;
1896 
1897 	vht_cap_info->tx_bf_cap = cfg_default(CFG_TX_BF_CAP);
1898 	vht_cap_info->as_cap = cfg_default(CFG_AS_CAP);
1899 	vht_cap_info->disable_ldpc_with_txbf_ap =
1900 			cfg_get(psoc, CFG_DISABLE_LDPC_WITH_TXBF_AP);
1901 }
1902 
mlme_init_rates_in_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_rates * rates)1903 static void mlme_init_rates_in_cfg(struct wlan_objmgr_psoc *psoc,
1904 				   struct wlan_mlme_rates *rates)
1905 {
1906 	rates->cfp_period = cfg_default(CFG_CFP_PERIOD);
1907 	rates->cfp_max_duration = cfg_default(CFG_CFP_MAX_DURATION);
1908 	rates->max_htmcs_txdata = cfg_get(psoc, CFG_MAX_HT_MCS_FOR_TX_DATA);
1909 	rates->disable_abg_rate_txdata = cfg_get(psoc,
1910 					CFG_DISABLE_ABG_RATE_FOR_TX_DATA);
1911 	rates->sap_max_mcs_txdata = cfg_get(psoc,
1912 					CFG_SAP_MAX_MCS_FOR_TX_DATA);
1913 	rates->disable_high_ht_mcs_2x2 = cfg_get(psoc,
1914 					 CFG_DISABLE_HIGH_HT_RX_MCS_2x2);
1915 
1916 	rates->supported_11b.max_len = CFG_SUPPORTED_RATES_11B_LEN;
1917 	qdf_uint8_array_parse(cfg_default(CFG_SUPPORTED_RATES_11B),
1918 			      rates->supported_11b.data,
1919 			      sizeof(rates->supported_11b.data),
1920 			      &rates->supported_11b.len);
1921 	rates->supported_11a.max_len = CFG_SUPPORTED_RATES_11A_LEN;
1922 	qdf_uint8_array_parse(cfg_default(CFG_SUPPORTED_RATES_11A),
1923 			      rates->supported_11a.data,
1924 			      sizeof(rates->supported_11a.data),
1925 			      &rates->supported_11a.len);
1926 	rates->supported_mcs_set.max_len = CFG_SUPPORTED_MCS_SET_LEN;
1927 	qdf_uint8_array_parse(cfg_default(CFG_SUPPORTED_MCS_SET),
1928 			      rates->supported_mcs_set.data,
1929 			      sizeof(rates->supported_mcs_set.data),
1930 			      &rates->supported_mcs_set.len);
1931 	rates->basic_mcs_set.max_len = CFG_BASIC_MCS_SET_LEN;
1932 	qdf_uint8_array_parse(cfg_default(CFG_BASIC_MCS_SET),
1933 			      rates->basic_mcs_set.data,
1934 			      sizeof(rates->basic_mcs_set.data),
1935 			      &rates->basic_mcs_set.len);
1936 	rates->current_mcs_set.max_len = CFG_CURRENT_MCS_SET_LEN;
1937 	qdf_uint8_array_parse(cfg_default(CFG_CURRENT_MCS_SET),
1938 			      rates->current_mcs_set.data,
1939 			      sizeof(rates->current_mcs_set.data),
1940 			      &rates->current_mcs_set.len);
1941 }
1942 
mlme_init_dfs_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_dfs_cfg * dfs_cfg)1943 static void mlme_init_dfs_cfg(struct wlan_objmgr_psoc *psoc,
1944 			      struct wlan_mlme_dfs_cfg *dfs_cfg)
1945 {
1946 	dfs_cfg->dfs_ignore_cac = cfg_get(psoc, CFG_IGNORE_CAC);
1947 	dfs_cfg->dfs_master_capable =
1948 		cfg_get(psoc, CFG_ENABLE_DFS_MASTER_CAPABILITY);
1949 	dfs_cfg->dfs_disable_channel_switch =
1950 		cfg_get(psoc, CFG_DISABLE_DFS_CH_SWITCH);
1951 	dfs_cfg->dfs_filter_offload =
1952 		cfg_get(psoc, CFG_ENABLE_DFS_PHYERR_FILTEROFFLOAD);
1953 	dfs_cfg->dfs_prefer_non_dfs =
1954 		cfg_get(psoc, CFG_ENABLE_NON_DFS_CHAN_ON_RADAR);
1955 	dfs_cfg->dfs_beacon_tx_enhanced =
1956 		cfg_get(psoc, CFG_DFS_BEACON_TX_ENHANCED);
1957 	dfs_cfg->dfs_disable_japan_w53 =
1958 		cfg_get(psoc, CFG_DISABLE_DFS_JAPAN_W53);
1959 	dfs_cfg->sap_tx_leakage_threshold =
1960 		cfg_get(psoc, CFG_SAP_TX_LEAKAGE_THRESHOLD);
1961 	dfs_cfg->dfs_pri_multiplier =
1962 		cfg_get(psoc, CFG_DFS_RADAR_PRI_MULTIPLIER);
1963 }
1964 
mlme_init_feature_flag_in_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_feature_flag * feature_flags)1965 static void mlme_init_feature_flag_in_cfg(
1966 				struct wlan_objmgr_psoc *psoc,
1967 				struct wlan_mlme_feature_flag *feature_flags)
1968 {
1969 	feature_flags->accept_short_slot_assoc =
1970 				cfg_default(CFG_ACCEPT_SHORT_SLOT_ASSOC_ONLY);
1971 	feature_flags->enable_hcf = cfg_default(CFG_HCF_ENABLED);
1972 	feature_flags->enable_rsn = cfg_default(CFG_RSN_ENABLED);
1973 	feature_flags->enable_short_preamble_11g =
1974 				cfg_default(CFG_11G_SHORT_PREAMBLE_ENABLED);
1975 	feature_flags->enable_short_slot_time_11g =
1976 				cfg_default(CFG_11G_SHORT_SLOT_TIME_ENABLED);
1977 	feature_flags->channel_bonding_mode =
1978 				cfg_default(CFG_CHANNEL_BONDING_MODE);
1979 	feature_flags->enable_block_ack = cfg_default(CFG_BLOCK_ACK_ENABLED);
1980 	feature_flags->enable_ampdu = cfg_get(psoc, CFG_ENABLE_AMPDUPS);
1981 	feature_flags->mcc_rts_cts_prot = cfg_get(psoc,
1982 						  CFG_FW_MCC_RTS_CTS_PROT);
1983 	feature_flags->mcc_bcast_prob_rsp = cfg_get(psoc,
1984 						    CFG_FW_MCC_BCAST_PROB_RESP);
1985 	feature_flags->enable_mcc = cfg_get(psoc, CFG_MCC_FEATURE);
1986 	feature_flags->channel_bonding_mode_24ghz =
1987 			cfg_get(psoc, CFG_CHANNEL_BONDING_MODE_24GHZ);
1988 	feature_flags->channel_bonding_mode_5ghz =
1989 			cfg_get(psoc, CFG_CHANNEL_BONDING_MODE_5GHZ);
1990 	feature_flags->update_cw_allowed =
1991 			cfg_get(psoc, CFG_ALLOW_UPDATE_CHANNEL_WIDTH);
1992 }
1993 
mlme_init_sap_protection_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_sap_protection * sap_protection_params)1994 static void mlme_init_sap_protection_cfg(struct wlan_objmgr_psoc *psoc,
1995 					 struct wlan_mlme_sap_protection
1996 					 *sap_protection_params)
1997 {
1998 	sap_protection_params->protection_enabled =
1999 				cfg_default(CFG_PROTECTION_ENABLED);
2000 	sap_protection_params->protection_force_policy =
2001 				cfg_default(CFG_FORCE_POLICY_PROTECTION);
2002 	sap_protection_params->ignore_peer_ht_opmode =
2003 				cfg_get(psoc, CFG_IGNORE_PEER_HT_MODE);
2004 	sap_protection_params->enable_ap_obss_protection =
2005 				cfg_get(psoc, CFG_AP_OBSS_PROTECTION_ENABLE);
2006 	sap_protection_params->is_ap_prot_enabled =
2007 				cfg_get(psoc, CFG_AP_ENABLE_PROTECTION_MODE);
2008 	sap_protection_params->ap_protection_mode =
2009 				cfg_get(psoc, CFG_AP_PROTECTION_MODE);
2010 }
2011 
2012 #ifdef WLAN_FEATURE_11AX
2013 
2014 #define HE_MCS12_13_24G_INDEX 0
2015 #define HE_MCS12_13_5G_INDEX 1
2016 #define HE_MCS12_13_BITS 16
2017 
mlme_init_he_cap_in_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_cfg * mlme_cfg)2018 static void mlme_init_he_cap_in_cfg(struct wlan_objmgr_psoc *psoc,
2019 				    struct wlan_mlme_cfg *mlme_cfg)
2020 {
2021 	uint32_t chan_width, mcs_12_13;
2022 	uint16_t value = 0;
2023 	struct wlan_mlme_he_caps *he_caps = &mlme_cfg->he_caps;
2024 	bool is_twt_enabled = false;
2025 
2026 	he_caps->dot11_he_cap.htc_he = cfg_default(CFG_HE_CONTROL);
2027 	he_caps->dot11_he_cap.twt_request =
2028 			cfg_get(psoc, CFG_TWT_REQUESTOR);
2029 	he_caps->dot11_he_cap.twt_responder =
2030 			cfg_get(psoc, CFG_TWT_RESPONDER);
2031 	/*
2032 	 * Broadcast TWT capability will be filled in
2033 	 * populate_dot11f_he_caps() based on STA/SAP
2034 	 * role and "twt_bcast_req_resp_config" ini
2035 	 */
2036 	he_caps->dot11_he_cap.broadcast_twt = 0;
2037 
2038 	is_twt_enabled = wlan_twt_cfg_is_twt_enabled(psoc);
2039 
2040 	if (is_twt_enabled)
2041 		he_caps->dot11_he_cap.flex_twt_sched =
2042 			cfg_default(CFG_HE_FLEX_TWT_SCHED);
2043 	he_caps->dot11_he_cap.fragmentation =
2044 			cfg_default(CFG_HE_FRAGMENTATION);
2045 	he_caps->dot11_he_cap.max_num_frag_msdu_amsdu_exp =
2046 			cfg_default(CFG_HE_MAX_FRAG_MSDU);
2047 	he_caps->dot11_he_cap.min_frag_size = cfg_default(CFG_HE_MIN_FRAG_SIZE);
2048 	he_caps->dot11_he_cap.trigger_frm_mac_pad =
2049 		cfg_default(CFG_HE_TRIG_PAD);
2050 	he_caps->dot11_he_cap.multi_tid_aggr_rx_supp =
2051 		cfg_default(CFG_HE_MTID_AGGR_RX);
2052 	he_caps->dot11_he_cap.he_link_adaptation =
2053 		cfg_default(CFG_HE_LINK_ADAPTATION);
2054 	he_caps->dot11_he_cap.all_ack = cfg_default(CFG_HE_ALL_ACK);
2055 	he_caps->dot11_he_cap.trigd_rsp_sched =
2056 			cfg_default(CFG_HE_TRIGD_RSP_SCHEDULING);
2057 	he_caps->dot11_he_cap.a_bsr = cfg_default(CFG_HE_BUFFER_STATUS_RPT);
2058 	he_caps->dot11_he_cap.ba_32bit_bitmap = cfg_default(CFG_HE_BA_32BIT);
2059 	he_caps->dot11_he_cap.mu_cascade = cfg_default(CFG_HE_MU_CASCADING);
2060 	he_caps->dot11_he_cap.ack_enabled_multitid =
2061 			cfg_default(CFG_HE_MULTI_TID);
2062 	he_caps->dot11_he_cap.omi_a_ctrl = cfg_default(CFG_HE_OMI);
2063 	he_caps->dot11_he_cap.ofdma_ra = cfg_default(CFG_HE_OFDMA_RA);
2064 	he_caps->dot11_he_cap.max_ampdu_len_exp_ext =
2065 			cfg_default(CFG_HE_MAX_AMPDU_LEN);
2066 	he_caps->dot11_he_cap.amsdu_frag = cfg_default(CFG_HE_AMSDU_FRAG);
2067 
2068 	he_caps->dot11_he_cap.rx_ctrl_frame = cfg_default(CFG_HE_RX_CTRL);
2069 	he_caps->dot11_he_cap.bsrp_ampdu_aggr =
2070 			cfg_default(CFG_HE_BSRP_AMPDU_AGGR);
2071 	he_caps->dot11_he_cap.qtp = cfg_default(CFG_HE_QTP);
2072 	he_caps->dot11_he_cap.a_bqr = cfg_default(CFG_HE_A_BQR);
2073 	he_caps->dot11_he_cap.spatial_reuse_param_rspder =
2074 			cfg_default(CFG_HE_SR_RESPONDER);
2075 	he_caps->dot11_he_cap.ndp_feedback_supp =
2076 			cfg_default(CFG_HE_NDP_FEEDBACK_SUPP);
2077 	he_caps->dot11_he_cap.ops_supp = cfg_default(CFG_HE_OPS_SUPP);
2078 	he_caps->dot11_he_cap.amsdu_in_ampdu =
2079 			cfg_default(CFG_HE_AMSDU_IN_AMPDU);
2080 
2081 	chan_width = cfg_default(CFG_HE_CHAN_WIDTH);
2082 	he_caps->dot11_he_cap.chan_width_0 = HE_CH_WIDTH_GET_BIT(chan_width, 0);
2083 	he_caps->dot11_he_cap.chan_width_1 = HE_CH_WIDTH_GET_BIT(chan_width, 1);
2084 	he_caps->dot11_he_cap.chan_width_2 = HE_CH_WIDTH_GET_BIT(chan_width, 2);
2085 	he_caps->dot11_he_cap.chan_width_3 = HE_CH_WIDTH_GET_BIT(chan_width, 3);
2086 	he_caps->dot11_he_cap.chan_width_4 = HE_CH_WIDTH_GET_BIT(chan_width, 4);
2087 	he_caps->dot11_he_cap.chan_width_5 = HE_CH_WIDTH_GET_BIT(chan_width, 5);
2088 	he_caps->dot11_he_cap.chan_width_6 = HE_CH_WIDTH_GET_BIT(chan_width, 6);
2089 
2090 	he_caps->dot11_he_cap.multi_tid_aggr_tx_supp =
2091 			cfg_default(CFG_HE_MTID_AGGR_TX);
2092 	he_caps->dot11_he_cap.he_sub_ch_sel_tx_supp =
2093 			cfg_default(CFG_HE_SUB_CH_SEL_TX);
2094 	he_caps->dot11_he_cap.ul_2x996_tone_ru_supp =
2095 			cfg_default(CFG_HE_UL_2X996_RU);
2096 	he_caps->dot11_he_cap.om_ctrl_ul_mu_data_dis_rx =
2097 			cfg_default(CFG_HE_OM_CTRL_UL_MU_DIS_RX);
2098 	he_caps->dot11_he_cap.he_dynamic_smps =
2099 			cfg_default(CFG_HE_DYNAMIC_SMPS);
2100 	he_caps->dot11_he_cap.punctured_sounding_supp =
2101 			cfg_default(CFG_HE_PUNCTURED_SOUNDING);
2102 	he_caps->dot11_he_cap.ht_vht_trg_frm_rx_supp =
2103 			cfg_default(CFG_HE_HT_VHT_TRG_FRM_RX);
2104 	he_caps->dot11_he_cap.rx_pream_puncturing =
2105 			cfg_get(psoc, CFG_HE_RX_PREAM_PUNC);
2106 	he_caps->dot11_he_cap.device_class =
2107 			cfg_default(CFG_HE_CLASS_OF_DEVICE);
2108 	he_caps->dot11_he_cap.ldpc_coding = cfg_default(CFG_HE_LDPC);
2109 	he_caps->dot11_he_cap.he_1x_ltf_800_gi_ppdu =
2110 			cfg_default(CFG_HE_LTF_PPDU);
2111 	he_caps->dot11_he_cap.midamble_tx_rx_max_nsts =
2112 			cfg_default(CFG_HE_MIDAMBLE_RX_MAX_NSTS);
2113 	he_caps->dot11_he_cap.he_4x_ltf_3200_gi_ndp =
2114 			cfg_default(CFG_HE_LTF_NDP);
2115 	he_caps->dot11_he_cap.tb_ppdu_tx_stbc_lt_80mhz =
2116 			cfg_default(CFG_HE_TX_STBC_LT80);
2117 	he_caps->dot11_he_cap.rx_stbc_lt_80mhz =
2118 			cfg_default(CFG_HE_RX_STBC_LT80);
2119 	he_caps->dot11_he_cap.doppler = cfg_default(CFG_HE_DOPPLER);
2120 	he_caps->dot11_he_cap.ul_mu =
2121 			cfg_get(psoc, CFG_HE_UL_MUMIMO);
2122 	he_caps->dot11_he_cap.dcm_enc_tx = cfg_default(CFG_HE_DCM_TX);
2123 	he_caps->dot11_he_cap.dcm_enc_rx = cfg_default(CFG_HE_DCM_RX);
2124 	he_caps->dot11_he_cap.ul_he_mu = cfg_default(CFG_HE_MU_PPDU);
2125 	he_caps->dot11_he_cap.su_beamformer = cfg_default(CFG_HE_SU_BEAMFORMER);
2126 	he_caps->dot11_he_cap.su_beamformee = cfg_default(CFG_HE_SU_BEAMFORMEE);
2127 	he_caps->dot11_he_cap.mu_beamformer = cfg_default(CFG_HE_MU_BEAMFORMER);
2128 	he_caps->dot11_he_cap.bfee_sts_lt_80 =
2129 			cfg_default(CFG_HE_BFEE_STS_LT80);
2130 	he_caps->dot11_he_cap.bfee_sts_gt_80 =
2131 			cfg_default(CFG_HE_BFEE_STS_GT80);
2132 	he_caps->dot11_he_cap.num_sounding_lt_80 =
2133 			cfg_default(CFG_HE_NUM_SOUND_LT80);
2134 	he_caps->dot11_he_cap.num_sounding_gt_80 =
2135 			cfg_default(CFG_HE_NUM_SOUND_GT80);
2136 	he_caps->dot11_he_cap.su_feedback_tone16 =
2137 			cfg_default(CFG_HE_SU_FEED_TONE16);
2138 	he_caps->dot11_he_cap.mu_feedback_tone16 =
2139 			cfg_default(CFG_HE_MU_FEED_TONE16);
2140 	he_caps->dot11_he_cap.codebook_su = cfg_default(CFG_HE_CODEBOOK_SU);
2141 	he_caps->dot11_he_cap.codebook_mu = cfg_default(CFG_HE_CODEBOOK_MU);
2142 	he_caps->dot11_he_cap.beamforming_feedback =
2143 			cfg_default(CFG_HE_BFRM_FEED);
2144 	he_caps->dot11_he_cap.he_er_su_ppdu = cfg_default(CFG_HE_ER_SU_PPDU);
2145 	he_caps->dot11_he_cap.dl_mu_mimo_part_bw =
2146 			cfg_default(CFG_HE_DL_PART_BW);
2147 	he_caps->dot11_he_cap.ppet_present = cfg_default(CFG_HE_PPET_PRESENT);
2148 	he_caps->dot11_he_cap.srp = cfg_default(CFG_HE_SRP);
2149 	he_caps->dot11_he_cap.power_boost = cfg_default(CFG_HE_POWER_BOOST);
2150 	he_caps->dot11_he_cap.he_ltf_800_gi_4x = cfg_default(CFG_HE_4x_LTF_GI);
2151 	he_caps->dot11_he_cap.max_nc = cfg_default(CFG_HE_MAX_NC);
2152 	he_caps->dot11_he_cap.tb_ppdu_tx_stbc_gt_80mhz =
2153 			cfg_default(CFG_HE_TX_STBC_GT80);
2154 	he_caps->dot11_he_cap.rx_stbc_gt_80mhz =
2155 			cfg_default(CFG_HE_RX_STBC_GT80);
2156 	he_caps->dot11_he_cap.er_he_ltf_800_gi_4x =
2157 			cfg_default(CFG_HE_ER_4x_LTF_GI);
2158 	he_caps->dot11_he_cap.he_ppdu_20_in_40Mhz_2G =
2159 			cfg_default(CFG_HE_PPDU_20_IN_40MHZ_2G);
2160 	he_caps->dot11_he_cap.he_ppdu_20_in_160_80p80Mhz =
2161 			cfg_default(CFG_HE_PPDU_20_IN_160_80P80MHZ);
2162 	he_caps->dot11_he_cap.he_ppdu_80_in_160_80p80Mhz =
2163 			cfg_default(CFG_HE_PPDU_80_IN_160_80P80MHZ);
2164 		he_caps->dot11_he_cap.er_1x_he_ltf_gi =
2165 			cfg_default(CFG_HE_ER_1X_HE_LTF_GI);
2166 	he_caps->dot11_he_cap.midamble_tx_rx_1x_he_ltf =
2167 			cfg_default(CFG_HE_MIDAMBLE_TXRX_1X_HE_LTF);
2168 	he_caps->dot11_he_cap.dcm_max_bw = cfg_default(CFG_HE_DCM_MAX_BW);
2169 	he_caps->dot11_he_cap.longer_than_16_he_sigb_ofdm_sym =
2170 			cfg_default(CFG_HE_LONGER_16_SIGB_OFDM_SYM);
2171 	he_caps->dot11_he_cap.non_trig_cqi_feedback =
2172 			cfg_default(CFG_HE_NON_TRIG_CQI_FEEDBACK);
2173 	he_caps->dot11_he_cap.tx_1024_qam_lt_242_tone_ru =
2174 			cfg_default(CFG_HE_TX_1024_QAM_LT_242_RU);
2175 	he_caps->dot11_he_cap.rx_1024_qam_lt_242_tone_ru =
2176 			cfg_default(CFG_HE_RX_1024_QAM_LT_242_RU);
2177 	he_caps->dot11_he_cap.rx_full_bw_su_he_mu_compress_sigb =
2178 			cfg_default(CFG_HE_RX_FULL_BW_MU_CMPR_SIGB);
2179 	he_caps->dot11_he_cap.rx_full_bw_su_he_mu_non_cmpr_sigb =
2180 			cfg_default(CFG_HE_RX_FULL_BW_MU_NON_CMPR_SIGB);
2181 	he_caps->dot11_he_cap.rx_he_mcs_map_lt_80 =
2182 			cfg_get(psoc, CFG_HE_RX_MCS_MAP_LT_80);
2183 	he_caps->dot11_he_cap.tx_he_mcs_map_lt_80 =
2184 			cfg_get(psoc, CFG_HE_TX_MCS_MAP_LT_80);
2185 	value = cfg_get(psoc, CFG_HE_RX_MCS_MAP_160);
2186 	qdf_mem_copy(he_caps->dot11_he_cap.rx_he_mcs_map_160, &value,
2187 		     sizeof(uint16_t));
2188 	value = cfg_get(psoc, CFG_HE_TX_MCS_MAP_160);
2189 	qdf_mem_copy(he_caps->dot11_he_cap.tx_he_mcs_map_160, &value,
2190 		     sizeof(uint16_t));
2191 	value = cfg_default(CFG_HE_RX_MCS_MAP_80_80);
2192 	qdf_mem_copy(he_caps->dot11_he_cap.rx_he_mcs_map_80_80, &value,
2193 		     sizeof(uint16_t));
2194 	value = cfg_default(CFG_HE_TX_MCS_MAP_80_80);
2195 	qdf_mem_copy(he_caps->dot11_he_cap.tx_he_mcs_map_80_80, &value,
2196 		     sizeof(uint16_t));
2197 	he_caps->he_ops_basic_mcs_nss = cfg_default(CFG_HE_OPS_BASIC_MCS_NSS);
2198 	he_caps->he_dynamic_fragmentation =
2199 			cfg_get(psoc, CFG_HE_DYNAMIC_FRAGMENTATION);
2200 	he_caps->enable_ul_mimo =
2201 			cfg_get(psoc, CFG_ENABLE_UL_MIMO);
2202 	he_caps->enable_ul_ofdm =
2203 			cfg_get(psoc, CFG_ENABLE_UL_OFDMA);
2204 	he_caps->he_sta_obsspd =
2205 			cfg_get(psoc, CFG_HE_STA_OBSSPD);
2206 	qdf_mem_zero(he_caps->he_ppet_2g, MLME_HE_PPET_LEN);
2207 	qdf_mem_zero(he_caps->he_ppet_5g, MLME_HE_PPET_LEN);
2208 
2209 	mcs_12_13 = cfg_get(psoc, CFG_HE_MCS_12_13_SUPPORT);
2210 	/* Get 2.4Ghz and 5Ghz value */
2211 	mlme_cfg->he_caps.he_mcs_12_13_supp_2g =
2212 		QDF_GET_BITS(mcs_12_13,
2213 			     HE_MCS12_13_24G_INDEX * HE_MCS12_13_BITS,
2214 			     HE_MCS12_13_BITS);
2215 	mlme_cfg->he_caps.he_mcs_12_13_supp_5g =
2216 		QDF_GET_BITS(mcs_12_13,
2217 			     HE_MCS12_13_5G_INDEX * HE_MCS12_13_BITS,
2218 			     HE_MCS12_13_BITS);
2219 
2220 	mlme_cfg->he_caps.disable_sap_mcs_12_13 = cfg_get(psoc,
2221 						CFG_DISABLE_MCS_12_13_SAP);
2222 }
2223 #else
mlme_init_he_cap_in_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_cfg * mlme_cfg)2224 static void mlme_init_he_cap_in_cfg(struct wlan_objmgr_psoc *psoc,
2225 				    struct wlan_mlme_cfg *mlme_cfg)
2226 {
2227 }
2228 #endif
2229 
2230 #if defined(WLAN_SUPPORT_TWT) && defined(WLAN_TWT_CONV_SUPPORTED)
2231 /**
2232  * mlme_init_disable_twt_info() - initialize disable twt info
2233  * @psoc: Pointer to PSOC
2234  * @twt_cfg: Pointer to twt_cfg
2235  *
2236  * Return: None
2237  */
mlme_init_disable_twt_info(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_cfg_twt * twt_cfg)2238 static void mlme_init_disable_twt_info(struct wlan_objmgr_psoc *psoc,
2239 				       struct wlan_mlme_cfg_twt *twt_cfg)
2240 {
2241 	twt_cfg->disable_twt_info_frame = cfg_get(psoc,
2242 						  CFG_DISABLE_TWT_INFO_FRAME);
2243 }
2244 #elif defined(WLAN_SUPPORT_TWT)
mlme_init_disable_twt_info(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_cfg_twt * twt_cfg)2245 static void mlme_init_disable_twt_info(struct wlan_objmgr_psoc *psoc,
2246 				       struct wlan_mlme_cfg_twt *twt_cfg)
2247 {
2248 }
2249 
2250 #endif
2251 
2252 #ifdef WLAN_SUPPORT_TWT
mlme_init_twt_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_cfg_twt * twt_cfg)2253 static void mlme_init_twt_cfg(struct wlan_objmgr_psoc *psoc,
2254 			      struct wlan_mlme_cfg_twt *twt_cfg)
2255 {
2256 	uint32_t bcast_conf = cfg_get(psoc, CFG_BCAST_TWT_REQ_RESP);
2257 
2258 	twt_cfg->is_twt_enabled = cfg_get(psoc, CFG_ENABLE_TWT);
2259 	twt_cfg->twt_congestion_timeout = cfg_get(psoc, CFG_TWT_CONGESTION_TIMEOUT);
2260 	twt_cfg->enable_twt_24ghz = cfg_get(psoc, CFG_ENABLE_TWT_24GHZ);
2261 	twt_cfg->is_bcast_requestor_enabled = CFG_TWT_GET_BCAST_REQ(bcast_conf);
2262 	twt_cfg->is_bcast_responder_enabled = CFG_TWT_GET_BCAST_RES(bcast_conf);
2263 	mlme_init_disable_twt_info(psoc, twt_cfg);
2264 }
2265 #else
mlme_init_twt_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_cfg_twt * twt_cfg)2266 static void mlme_init_twt_cfg(struct wlan_objmgr_psoc *psoc,
2267 			      struct wlan_mlme_cfg_twt *twt_cfg)
2268 {
2269 }
2270 #endif
2271 
2272 #ifdef WLAN_FEATURE_11BE
mlme_init_eht_cap_in_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_cfg * mlme_cfg)2273 static void mlme_init_eht_cap_in_cfg(struct wlan_objmgr_psoc *psoc,
2274 				     struct wlan_mlme_cfg *mlme_cfg)
2275 {
2276 	struct wlan_mlme_eht_caps *eht_caps = &mlme_cfg->eht_caps;
2277 
2278 	eht_caps->dot11_eht_cap.su_beamformer =
2279 			cfg_default(CFG_EHT_SU_BEAMFORMER);
2280 	eht_caps->dot11_eht_cap.su_beamformee =
2281 			cfg_default(CFG_EHT_SU_BEAMFORMEE);
2282 	eht_caps->dot11_eht_cap.mu_bformer_le_80mhz =
2283 			cfg_default(CFG_EHT_MU_BFORMER_LE_80MHZ);
2284 	eht_caps->dot11_eht_cap.mu_bformer_160mhz =
2285 			cfg_default(CFG_EHT_MU_BFORMER_160MHZ);
2286 	eht_caps->dot11_eht_cap.mu_bformer_320mhz =
2287 			cfg_default(CFG_EHT_MU_BFORMER_320MHZ);
2288 	eht_caps->dot11_eht_cap.bfee_ss_le_80mhz =
2289 			cfg_default(CFG_EHT_BFEE_SS_LE_80MHZ);
2290 	eht_caps->dot11_eht_cap.bfee_ss_160mhz =
2291 			cfg_default(CFG_EHT_BFEE_SS_160MHZ);
2292 	eht_caps->dot11_eht_cap.bfee_ss_320mhz =
2293 			cfg_default(CFG_EHT_BFEE_SS_320MHZ);
2294 	eht_caps->dot11_eht_cap.num_sounding_dim_le_80mhz =
2295 			cfg_default(CFG_EHT_NUM_SOUNDING_DIM_LE_80MHZ);
2296 	eht_caps->dot11_eht_cap.num_sounding_dim_160mhz =
2297 			cfg_default(CFG_EHT_NUM_SOUNDING_DIM_160MHZ);
2298 	eht_caps->dot11_eht_cap.num_sounding_dim_320mhz =
2299 			cfg_default(CFG_EHT_NUM_SOUNDING_DIM_320MHZ);
2300 }
2301 #else
mlme_init_eht_cap_in_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_cfg * mlme_cfg)2302 static void mlme_init_eht_cap_in_cfg(struct wlan_objmgr_psoc *psoc,
2303 				     struct wlan_mlme_cfg *mlme_cfg)
2304 {
2305 }
2306 #endif
2307 
2308 #ifdef WLAN_FEATURE_SAE
is_sae_sap_enabled(struct wlan_objmgr_psoc * psoc)2309 static bool is_sae_sap_enabled(struct wlan_objmgr_psoc *psoc)
2310 {
2311 	return cfg_get(psoc, CFG_IS_SAP_SAE_ENABLED);
2312 }
2313 
wlan_vdev_is_sae_auth_type(struct wlan_objmgr_vdev * vdev)2314 bool wlan_vdev_is_sae_auth_type(struct wlan_objmgr_vdev *vdev)
2315 {
2316 	int32_t auth_mode;
2317 
2318 	auth_mode = wlan_crypto_get_param(vdev, WLAN_CRYPTO_PARAM_AUTH_MODE);
2319 
2320 	if (auth_mode == -1)
2321 		return false;
2322 
2323 	if (QDF_HAS_PARAM(auth_mode, WLAN_CRYPTO_AUTH_SAE))
2324 		return true;
2325 
2326 	return false;
2327 }
2328 #else
is_sae_sap_enabled(struct wlan_objmgr_psoc * psoc)2329 static bool is_sae_sap_enabled(struct wlan_objmgr_psoc *psoc)
2330 {
2331 	return false;
2332 }
2333 #endif
wlan_get_rand_from_lst_for_freq(uint16_t * freq_lst,uint8_t num_chan)2334 uint16_t wlan_get_rand_from_lst_for_freq(uint16_t *freq_lst,
2335 					 uint8_t num_chan)
2336 {
2337 	uint8_t i;
2338 	uint32_t rand_byte = 0;
2339 
2340 	if (!num_chan || !freq_lst) {
2341 		mlme_legacy_debug("invalid param freq_lst %pK, num_chan = %d",
2342 				  freq_lst, num_chan);
2343 		return 0;
2344 	}
2345 
2346 	get_random_bytes((uint8_t *)&rand_byte, 1);
2347 	i = (rand_byte + qdf_mc_timer_get_system_ticks()) % num_chan;
2348 
2349 	return freq_lst[i];
2350 }
2351 
mlme_init_sap_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_cfg_sap * sap_cfg)2352 static void mlme_init_sap_cfg(struct wlan_objmgr_psoc *psoc,
2353 			      struct wlan_mlme_cfg_sap *sap_cfg)
2354 {
2355 	sap_cfg->beacon_interval = cfg_get(psoc, CFG_BEACON_INTERVAL);
2356 	sap_cfg->dtim_interval = cfg_default(CFG_DTIM_PERIOD);
2357 	sap_cfg->listen_interval = cfg_default(CFG_LISTEN_INTERVAL);
2358 	sap_cfg->sap_11g_policy = cfg_default(CFG_11G_ONLY_POLICY);
2359 	sap_cfg->assoc_sta_limit = cfg_default(CFG_ASSOC_STA_LIMIT);
2360 	sap_cfg->enable_lte_coex = cfg_get(psoc, CFG_ENABLE_LTE_COEX);
2361 	sap_cfg->rate_tx_mgmt = cfg_get(psoc, CFG_RATE_FOR_TX_MGMT);
2362 	sap_cfg->rate_tx_mgmt_2g = cfg_get(psoc, CFG_RATE_FOR_TX_MGMT_2G);
2363 	sap_cfg->rate_tx_mgmt_5g = cfg_get(psoc, CFG_RATE_FOR_TX_MGMT_5G);
2364 	sap_cfg->tele_bcn_wakeup_en = cfg_get(psoc, CFG_TELE_BCN_WAKEUP_EN);
2365 	sap_cfg->tele_bcn_max_li = cfg_get(psoc, CFG_TELE_BCN_MAX_LI);
2366 	sap_cfg->sap_get_peer_info = cfg_get(psoc, CFG_SAP_GET_PEER_INFO);
2367 	sap_cfg->sap_allow_all_chan_param_name =
2368 			cfg_get(psoc, CFG_SAP_ALLOW_ALL_CHANNEL_PARAM);
2369 	sap_cfg->sap_max_no_peers = cfg_get(psoc, CFG_SAP_MAX_NO_PEERS);
2370 	sap_cfg->sap_max_offload_peers =
2371 			cfg_get(psoc, CFG_SAP_MAX_OFFLOAD_PEERS);
2372 	sap_cfg->sap_max_offload_reorder_buffs =
2373 			cfg_get(psoc, CFG_SAP_MAX_OFFLOAD_REORDER_BUFFS);
2374 	sap_cfg->sap_ch_switch_beacon_cnt =
2375 			cfg_get(psoc, CFG_SAP_CH_SWITCH_BEACON_CNT);
2376 	sap_cfg->sap_ch_switch_mode = cfg_get(psoc, CFG_SAP_CH_SWITCH_MODE);
2377 	sap_cfg->sap_internal_restart =
2378 			cfg_get(psoc, CFG_SAP_INTERNAL_RESTART);
2379 	sap_cfg->chan_switch_hostapd_rate_enabled_name =
2380 		cfg_get(psoc, CFG_CHAN_SWITCH_HOSTAPD_RATE_ENABLED_NAME);
2381 	sap_cfg->reduced_beacon_interval =
2382 		cfg_get(psoc, CFG_REDUCED_BEACON_INTERVAL);
2383 	sap_cfg->max_li_modulated_dtim_time =
2384 		cfg_get(psoc, CFG_MAX_LI_MODULATED_DTIM);
2385 	sap_cfg->country_code_priority =
2386 		cfg_get(psoc, CFG_COUNTRY_CODE_PRIORITY);
2387 	sap_cfg->sap_pref_chan_location =
2388 		cfg_get(psoc, CFG_SAP_PREF_CHANNEL_LOCATION);
2389 	sap_cfg->sap_force_11n_for_11ac =
2390 		cfg_get(psoc, CFG_SAP_FORCE_11N_FOR_11AC);
2391 	sap_cfg->go_force_11n_for_11ac =
2392 		cfg_get(psoc, CFG_GO_FORCE_11N_FOR_11AC);
2393 	sap_cfg->ap_random_bssid_enable =
2394 		cfg_get(psoc, CFG_AP_ENABLE_RANDOM_BSSID);
2395 	sap_cfg->sap_mcc_chnl_avoid =
2396 		cfg_get(psoc, CFG_SAP_MCC_CHANNEL_AVOIDANCE);
2397 	sap_cfg->sap_11ac_override =
2398 		cfg_get(psoc, CFG_SAP_11AC_OVERRIDE);
2399 	sap_cfg->go_11ac_override =
2400 		cfg_get(psoc, CFG_GO_11AC_OVERRIDE);
2401 	sap_cfg->sap_sae_enabled = is_sae_sap_enabled(psoc);
2402 	sap_cfg->is_sap_bcast_deauth_enabled =
2403 		cfg_get(psoc, CFG_IS_SAP_BCAST_DEAUTH_ENABLED);
2404 	sap_cfg->is_6g_sap_fd_enabled =
2405 		cfg_get(psoc, CFG_6G_SAP_FILS_DISCOVERY_ENABLED);
2406 	sap_cfg->disable_bcn_prot =
2407 		cfg_get(psoc, CFG_DISABLE_SAP_BCN_PROT);
2408 	sap_cfg->sap_ps_with_twt_enable =
2409 		cfg_get(psoc, CFG_SAP_PS_WITH_TWT);
2410 }
2411 
mlme_init_obss_ht40_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_obss_ht40 * obss_ht40)2412 static void mlme_init_obss_ht40_cfg(struct wlan_objmgr_psoc *psoc,
2413 				    struct wlan_mlme_obss_ht40 *obss_ht40)
2414 {
2415 	obss_ht40->active_dwelltime =
2416 		cfg_get(psoc, CFG_OBSS_HT40_SCAN_ACTIVE_DWELL_TIME);
2417 	obss_ht40->passive_dwelltime =
2418 		cfg_get(psoc, CFG_OBSS_HT40_SCAN_PASSIVE_DWELL_TIME);
2419 	obss_ht40->width_trigger_interval =
2420 		cfg_get(psoc, CFG_OBSS_HT40_SCAN_WIDTH_TRIGGER_INTERVAL);
2421 	obss_ht40->passive_per_channel = (uint32_t)
2422 		cfg_default(CFG_OBSS_HT40_SCAN_PASSIVE_TOTAL_PER_CHANNEL);
2423 	obss_ht40->active_per_channel = (uint32_t)
2424 		cfg_default(CFG_OBSS_HT40_SCAN_ACTIVE_TOTAL_PER_CHANNEL);
2425 	obss_ht40->width_trans_delay = (uint32_t)
2426 		cfg_default(CFG_OBSS_HT40_WIDTH_CH_TRANSITION_DELAY);
2427 	obss_ht40->scan_activity_threshold = (uint32_t)
2428 		cfg_default(CFG_OBSS_HT40_SCAN_ACTIVITY_THRESHOLD);
2429 	obss_ht40->is_override_ht20_40_24g =
2430 		cfg_get(psoc, CFG_OBSS_HT40_OVERRIDE_HT40_20_24GHZ);
2431 	obss_ht40->obss_detection_offload_enabled =
2432 		(bool)cfg_default(CFG_OBSS_DETECTION_OFFLOAD);
2433 	obss_ht40->obss_color_collision_offload_enabled =
2434 		(bool)cfg_default(CFG_OBSS_COLOR_COLLISION_OFFLOAD);
2435 	obss_ht40->bss_color_collision_det_sta =
2436 		cfg_get(psoc, CFG_BSS_CLR_COLLISION_DETCN_STA);
2437 }
2438 
mlme_init_threshold_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_threshold * threshold)2439 static void mlme_init_threshold_cfg(struct wlan_objmgr_psoc *psoc,
2440 				    struct wlan_mlme_threshold *threshold)
2441 {
2442 	threshold->rts_threshold = cfg_get(psoc, CFG_RTS_THRESHOLD);
2443 	threshold->frag_threshold = cfg_get(psoc, CFG_FRAG_THRESHOLD);
2444 }
2445 
2446 static bool
mlme_is_freq_present_in_list(struct acs_weight * normalize_weight_chan_list,uint8_t num_freq,uint32_t freq,uint8_t * index)2447 mlme_is_freq_present_in_list(struct acs_weight *normalize_weight_chan_list,
2448 			     uint8_t num_freq, uint32_t freq, uint8_t *index)
2449 {
2450 	uint8_t i;
2451 
2452 	for (i = 0; i < num_freq && i < NUM_CHANNELS; i++) {
2453 		if (normalize_weight_chan_list[i].chan_freq == freq) {
2454 			*index = i;
2455 			return true;
2456 		}
2457 	}
2458 
2459 	return false;
2460 }
2461 
2462 static void
mlme_acs_parse_weight_list(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_acs * acs)2463 mlme_acs_parse_weight_list(struct wlan_objmgr_psoc *psoc,
2464 			   struct wlan_mlme_acs *acs)
2465 {
2466 	char *acs_weight, *str1, *str2 = NULL, *acs_weight_temp, is_range = '-';
2467 	int freq1, freq2, normalize_factor;
2468 	uint8_t num_acs_weight = 0, num_acs_weight_range = 0, index = 0;
2469 	struct acs_weight *weight_list = acs->normalize_weight_chan;
2470 	struct acs_weight_range *range_list = acs->normalize_weight_range;
2471 
2472 	if (!qdf_str_len(cfg_get(psoc, CFG_NORMALIZE_ACS_WEIGHT)))
2473 		return;
2474 
2475 	acs_weight = qdf_mem_malloc(ACS_WEIGHT_MAX_STR_LEN);
2476 	if (!acs_weight)
2477 		return;
2478 
2479 	qdf_mem_copy(acs_weight, cfg_get(psoc, CFG_NORMALIZE_ACS_WEIGHT),
2480 		     ACS_WEIGHT_MAX_STR_LEN);
2481 	acs_weight_temp = acs_weight;
2482 
2483 	while(acs_weight_temp) {
2484 		str1 = strsep(&acs_weight_temp, ",");
2485 		if (!str1)
2486 			goto end;
2487 		freq1 = 0;
2488 		freq2 = 0;
2489 		if (strchr(str1, is_range)) {
2490 			str2 = strsep(&str1, "-");
2491 			sscanf(str2, "%d", &freq1);
2492 			sscanf(str1, "%d", &freq2);
2493 			strsep(&str1, "=");
2494 			if (!str1)
2495 				goto end;
2496 			sscanf(str1, "%d", &normalize_factor);
2497 
2498 			if (num_acs_weight_range == MAX_ACS_WEIGHT_RANGE)
2499 				continue;
2500 			range_list[num_acs_weight_range].normalize_weight =
2501 							normalize_factor;
2502 			range_list[num_acs_weight_range].start_freq = freq1;
2503 			range_list[num_acs_weight_range++].end_freq = freq2;
2504 		} else {
2505 			sscanf(str1, "%d", &freq1);
2506 			strsep(&str1, "=");
2507 			if (!str1 || !weight_list)
2508 				goto end;
2509 			sscanf(str1, "%d", &normalize_factor);
2510 			if (mlme_is_freq_present_in_list(weight_list,
2511 							 num_acs_weight, freq1,
2512 							 &index)) {
2513 				weight_list[index].normalize_weight =
2514 							normalize_factor;
2515 			} else {
2516 				if (num_acs_weight == NUM_CHANNELS)
2517 					continue;
2518 
2519 				weight_list[num_acs_weight].chan_freq = freq1;
2520 				weight_list[num_acs_weight++].normalize_weight =
2521 							normalize_factor;
2522 			}
2523 		}
2524 	}
2525 
2526 	acs->normalize_weight_num_chan = num_acs_weight;
2527 	acs->num_weight_range = num_acs_weight_range;
2528 
2529 end:
2530 	qdf_mem_free(acs_weight);
2531 }
2532 
mlme_init_acs_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_acs * acs)2533 static void mlme_init_acs_cfg(struct wlan_objmgr_psoc *psoc,
2534 			      struct wlan_mlme_acs *acs)
2535 {
2536 	acs->is_acs_with_more_param =
2537 		cfg_get(psoc, CFG_ACS_WITH_MORE_PARAM);
2538 	acs->auto_channel_select_weight =
2539 		cfg_get(psoc, CFG_AUTO_CHANNEL_SELECT_WEIGHT);
2540 	acs->is_vendor_acs_support =
2541 		cfg_get(psoc, CFG_USER_AUTO_CHANNEL_SELECTION);
2542 	acs->force_sap_start =
2543 		cfg_get(psoc, CFG_ACS_FORCE_START_SAP);
2544 	acs->is_acs_support_for_dfs_ltecoex =
2545 		cfg_get(psoc, CFG_USER_ACS_DFS_LTE);
2546 	acs->is_external_acs_policy =
2547 		cfg_get(psoc, CFG_EXTERNAL_ACS_POLICY);
2548 	acs->np_chan_weightage = cfg_get(psoc, CFG_ACS_NP_CHAN_WEIGHT);
2549 	acs->acs_prefer_6ghz_psc = cfg_default(CFG_ACS_PREFER_6GHZ_PSC);
2550 	mlme_acs_parse_weight_list(psoc, acs);
2551 }
2552 
2553 static void
mlme_init_product_details_cfg(struct wlan_mlme_product_details_cfg * product_details)2554 mlme_init_product_details_cfg(struct wlan_mlme_product_details_cfg
2555 			      *product_details)
2556 {
2557 	qdf_str_lcopy(product_details->manufacturer_name,
2558 		      cfg_default(CFG_MFR_NAME),
2559 		      sizeof(product_details->manufacturer_name));
2560 	qdf_str_lcopy(product_details->manufacture_product_name,
2561 		      cfg_default(CFG_MFR_PRODUCT_NAME),
2562 		      sizeof(product_details->manufacture_product_name));
2563 	qdf_str_lcopy(product_details->manufacture_product_version,
2564 		      cfg_default(CFG_MFR_PRODUCT_VERSION),
2565 		      sizeof(product_details->manufacture_product_version));
2566 	qdf_str_lcopy(product_details->model_name,
2567 		      cfg_default(CFG_MODEL_NAME),
2568 		      sizeof(product_details->model_name));
2569 	qdf_str_lcopy(product_details->model_number,
2570 		      cfg_default(CFG_MODEL_NUMBER),
2571 		      sizeof(product_details->model_number));
2572 }
2573 
2574 #ifdef WLAN_FEATURE_11BE_MLO
mlme_init_sta_mlo_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_sta_cfg * sta)2575 static void mlme_init_sta_mlo_cfg(struct wlan_objmgr_psoc *psoc,
2576 				  struct wlan_mlme_sta_cfg *sta)
2577 {
2578 	sta->mlo_support_link_num =
2579 		cfg_get(psoc, CFG_MLO_SUPPORT_LINK_NUM);
2580 	sta->mlo_support_link_band =
2581 		cfg_get(psoc, CFG_MLO_SUPPORT_LINK_BAND);
2582 	sta->mlo_max_simultaneous_links =
2583 		cfg_default(CFG_MLO_MAX_SIMULTANEOUS_LINKS);
2584 	sta->mlo_prefer_percentage =
2585 		cfg_get(psoc, CFG_MLO_PREFER_PERCENTAGE);
2586 	sta->mlo_same_link_mld_address =
2587 		cfg_default(CFG_MLO_SAME_LINK_MLD_ADDR);
2588 	sta->mlo_5gl_5gh_mlsr =
2589 		cfg_get(psoc, CFG_MLO_MLO_5GL_5GH_MLSR);
2590 	sta->epcs_capability =
2591 		cfg_get(psoc, CFG_MLO_EPCS_SUPPORT_ENABLE);
2592 
2593 	mlme_debug("mlo_support_link_num: %d, mlo_support_link_band: 0x%x",
2594 		   sta->mlo_support_link_num, sta->mlo_support_link_band);
2595 }
2596 
2597 static bool
wlan_get_vdev_link_removed_flag(struct wlan_objmgr_vdev * vdev)2598 wlan_get_vdev_link_removed_flag(struct wlan_objmgr_vdev *vdev)
2599 {
2600 	bool is_mlo_link_removed = false;
2601 	uint8_t link_id;
2602 	struct mlo_link_info *link_info;
2603 
2604 	if (!mlo_is_mld_sta(vdev))
2605 		return false;
2606 
2607 	link_id = wlan_vdev_get_link_id(vdev);
2608 	link_info = mlo_mgr_get_ap_link_by_link_id(vdev->mlo_dev_ctx, link_id);
2609 	if (link_info)
2610 		is_mlo_link_removed =
2611 			!!qdf_atomic_test_bit(LS_F_AP_REMOVAL_BIT,
2612 					      &link_info->link_status_flags);
2613 	else
2614 		mlme_legacy_err("link info null, id %d", link_id);
2615 
2616 	return is_mlo_link_removed;
2617 }
2618 
wlan_get_vdev_link_removed_flag_by_vdev_id(struct wlan_objmgr_psoc * psoc,uint8_t vdev_id)2619 bool wlan_get_vdev_link_removed_flag_by_vdev_id(struct wlan_objmgr_psoc *psoc,
2620 						uint8_t vdev_id)
2621 {
2622 	struct wlan_objmgr_vdev *vdev;
2623 	bool is_mlo_link_removed;
2624 
2625 	vdev = wlan_objmgr_get_vdev_by_id_from_psoc(psoc, vdev_id,
2626 						    WLAN_MLME_OBJMGR_ID);
2627 	if (!vdev) {
2628 		mlme_legacy_err("get vdev failed for id %d", vdev_id);
2629 		return false;
2630 	}
2631 
2632 	is_mlo_link_removed = wlan_get_vdev_link_removed_flag(vdev);
2633 	wlan_objmgr_vdev_release_ref(vdev, WLAN_MLME_OBJMGR_ID);
2634 
2635 	return is_mlo_link_removed;
2636 }
2637 
2638 static QDF_STATUS
wlan_set_vdev_link_removed_flag(struct wlan_objmgr_vdev * vdev,bool removed)2639 wlan_set_vdev_link_removed_flag(struct wlan_objmgr_vdev *vdev, bool removed)
2640 {
2641 	uint8_t link_id;
2642 	struct mlo_link_info *link_info;
2643 	bool is_mlo_link_removed;
2644 
2645 	if (!vdev) {
2646 		mlme_legacy_err("vdev NULL");
2647 		return QDF_STATUS_E_INVAL;
2648 	}
2649 
2650 	if (!mlo_is_mld_sta(vdev)) {
2651 		mlme_legacy_debug("vdev not mld sta");
2652 		return QDF_STATUS_E_INVAL;
2653 	}
2654 
2655 	link_id = wlan_vdev_get_link_id(vdev);
2656 	link_info = mlo_mgr_get_ap_link_by_link_id(vdev->mlo_dev_ctx, link_id);
2657 	if (!link_info) {
2658 		mlme_legacy_err("link info null, id %d", link_id);
2659 		return QDF_STATUS_E_INVAL;
2660 	}
2661 	is_mlo_link_removed =
2662 		!!qdf_atomic_test_bit(LS_F_AP_REMOVAL_BIT,
2663 				      &link_info->link_status_flags);
2664 	if (removed == is_mlo_link_removed)
2665 		return QDF_STATUS_SUCCESS;
2666 
2667 	mlme_legacy_debug("mlo sta vdev %d link %d link removed flag %d",
2668 			  wlan_vdev_get_id(vdev), link_id, removed);
2669 	if (removed)
2670 		qdf_atomic_set_bit(LS_F_AP_REMOVAL_BIT,
2671 				   &link_info->link_status_flags);
2672 	else
2673 		qdf_atomic_clear_bit(LS_F_AP_REMOVAL_BIT,
2674 				     &link_info->link_status_flags);
2675 
2676 	return QDF_STATUS_SUCCESS;
2677 }
2678 
2679 QDF_STATUS
wlan_set_vdev_link_removed_flag_by_vdev_id(struct wlan_objmgr_psoc * psoc,uint8_t vdev_id,bool removed)2680 wlan_set_vdev_link_removed_flag_by_vdev_id(struct wlan_objmgr_psoc *psoc,
2681 					   uint8_t vdev_id, bool removed)
2682 {
2683 	struct wlan_objmgr_vdev *vdev;
2684 	QDF_STATUS status;
2685 
2686 	vdev = wlan_objmgr_get_vdev_by_id_from_psoc(psoc, vdev_id,
2687 						    WLAN_MLME_OBJMGR_ID);
2688 	if (!vdev) {
2689 		mlme_legacy_err("vdev null for id %d", vdev_id);
2690 		return QDF_STATUS_E_INVAL;
2691 	}
2692 
2693 	if (!mlo_is_mld_sta(vdev)) {
2694 		mlme_legacy_debug("vdev %d not mld sta", vdev_id);
2695 		wlan_objmgr_vdev_release_ref(vdev, WLAN_MLME_OBJMGR_ID);
2696 		return QDF_STATUS_E_INVAL;
2697 	}
2698 
2699 	status = wlan_set_vdev_link_removed_flag(vdev, removed);
2700 
2701 	wlan_objmgr_vdev_release_ref(vdev, WLAN_MLME_OBJMGR_ID);
2702 
2703 	return status;
2704 }
2705 
wlan_clear_mlo_sta_link_removed_flag(struct wlan_objmgr_vdev * vdev)2706 void wlan_clear_mlo_sta_link_removed_flag(struct wlan_objmgr_vdev *vdev)
2707 {
2708 	uint8_t i;
2709 	struct mlo_link_info *link_info;
2710 
2711 	if (!vdev || !mlo_is_mld_sta(vdev))
2712 		return;
2713 
2714 	link_info = mlo_mgr_get_ap_link(vdev);
2715 	if (!link_info)
2716 		return;
2717 
2718 	for (i = 0; i < WLAN_MAX_ML_BSS_LINKS; i++)
2719 		qdf_atomic_clear_bit(LS_F_AP_REMOVAL_BIT,
2720 				     &link_info[i].link_status_flags);
2721 }
2722 
wlan_get_mlo_link_agnostic_flag(struct wlan_objmgr_vdev * vdev,uint8_t * dest_addr)2723 bool wlan_get_mlo_link_agnostic_flag(struct wlan_objmgr_vdev *vdev,
2724 				     uint8_t *dest_addr)
2725 {
2726 	struct wlan_objmgr_peer *bss_peer = NULL;
2727 	bool mlo_link_agnostic = false;
2728 	uint8_t *peer_mld_addr = NULL;
2729 
2730 	if (!wlan_vdev_mlme_is_mlo_vdev(vdev))
2731 		return mlo_link_agnostic;
2732 
2733 	bss_peer = wlan_objmgr_vdev_try_get_bsspeer(vdev, WLAN_MLME_OBJMGR_ID);
2734 	if (bss_peer) {
2735 		peer_mld_addr = wlan_peer_mlme_get_mldaddr(bss_peer);
2736 		if (!qdf_mem_cmp(bss_peer->macaddr, dest_addr,
2737 				 QDF_MAC_ADDR_SIZE) ||
2738 		    (peer_mld_addr && !qdf_mem_cmp(peer_mld_addr, dest_addr,
2739 						   QDF_MAC_ADDR_SIZE))) {
2740 			mlme_legacy_debug("dest address" QDF_MAC_ADDR_FMT "bss peer address"
2741 					  QDF_MAC_ADDR_FMT "mld addr" QDF_MAC_ADDR_FMT,
2742 					  QDF_MAC_ADDR_REF(dest_addr),
2743 					  QDF_MAC_ADDR_REF(bss_peer->macaddr),
2744 					  QDF_MAC_ADDR_REF(peer_mld_addr));
2745 			mlo_link_agnostic = true;
2746 		}
2747 		wlan_objmgr_peer_release_ref(bss_peer, WLAN_MLME_OBJMGR_ID);
2748 	}
2749 	return mlo_link_agnostic;
2750 }
2751 
wlan_drop_mgmt_frame_on_link_removal(struct wlan_objmgr_vdev * vdev)2752 bool wlan_drop_mgmt_frame_on_link_removal(struct wlan_objmgr_vdev *vdev)
2753 {
2754 	if (!vdev || !mlo_is_mld_sta(vdev))
2755 		return false;
2756 
2757 	return wlan_get_vdev_link_removed_flag(vdev);
2758 }
2759 #else
mlme_init_sta_mlo_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_sta_cfg * sta)2760 static void mlme_init_sta_mlo_cfg(struct wlan_objmgr_psoc *psoc,
2761 				  struct wlan_mlme_sta_cfg *sta)
2762 {
2763 }
2764 #endif
2765 
mlme_init_sta_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_sta_cfg * sta)2766 static void mlme_init_sta_cfg(struct wlan_objmgr_psoc *psoc,
2767 			      struct wlan_mlme_sta_cfg *sta)
2768 {
2769 	sta->sta_keep_alive_period =
2770 		cfg_get(psoc, CFG_INFRA_STA_KEEP_ALIVE_PERIOD);
2771 	sta->bss_max_idle_period =
2772 		cfg_get(psoc, CFG_STA_BSS_MAX_IDLE_PERIOD);
2773 	sta->tgt_gtx_usr_cfg =
2774 		cfg_get(psoc, CFG_TGT_GTX_USR_CFG);
2775 	sta->pmkid_modes =
2776 		cfg_get(psoc, CFG_PMKID_MODES);
2777 	sta->ignore_peer_erp_info =
2778 		cfg_get(psoc, CFG_IGNORE_PEER_ERP_INFO);
2779 	sta->sta_prefer_80mhz_over_160mhz =
2780 		cfg_get(psoc, CFG_STA_PREFER_80MHZ_OVER_160MHZ);
2781 	sta->enable_5g_ebt =
2782 		cfg_get(psoc, CFG_PPS_ENABLE_5G_EBT);
2783 	sta->deauth_before_connection =
2784 		cfg_get(psoc, CFG_ENABLE_DEAUTH_BEFORE_CONNECTION);
2785 	sta->dot11p_mode =
2786 		cfg_get(psoc, CFG_DOT11P_MODE);
2787 	sta->enable_go_cts2self_for_sta =
2788 		cfg_get(psoc, CFG_ENABLE_GO_CTS2SELF_FOR_STA);
2789 	sta->qcn_ie_support =
2790 		cfg_get(psoc, CFG_QCN_IE_SUPPORT);
2791 	sta->fils_max_chan_guard_time =
2792 		cfg_get(psoc, CFG_FILS_MAX_CHAN_GUARD_TIME);
2793 	sta->deauth_retry_cnt = cfg_get(psoc, CFG_DEAUTH_RETRY_CNT);
2794 	sta->single_tid =
2795 		cfg_get(psoc, CFG_SINGLE_TID_RC);
2796 	sta->sta_miracast_mcc_rest_time =
2797 		cfg_get(psoc, CFG_STA_MCAST_MCC_REST_TIME);
2798 	sta->wait_cnf_timeout =
2799 		(uint32_t)cfg_default(CFG_WT_CNF_TIMEOUT);
2800 	sta->current_rssi =
2801 		(uint32_t)cfg_default(CFG_CURRENT_RSSI);
2802 	sta->allow_tpc_from_ap = cfg_get(psoc, CFG_TX_POWER_CTRL);
2803 	sta->sta_keepalive_method =
2804 		cfg_get(psoc, CFG_STA_KEEPALIVE_METHOD);
2805 	sta->max_li_modulated_dtim_time_ms =
2806 		cfg_get(psoc, CFG_MAX_LI_MODULATED_DTIM_MS);
2807 
2808 	mlme_init_sta_mlo_cfg(psoc, sta);
2809 	wlan_mlme_set_epcs_capability(psoc,
2810 				      wlan_mlme_get_epcs_capability(psoc));
2811 	wlan_mlme_set_usr_disable_sta_eht(psoc, false);
2812 	wlan_mlme_set_eht_disable_punct_in_us_lpi(psoc,
2813 						  cfg_default(CFG_EHT_DISABLE_PUNCT_IN_US_LPI));
2814 }
2815 
mlme_init_stats_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_stats_cfg * stats)2816 static void mlme_init_stats_cfg(struct wlan_objmgr_psoc *psoc,
2817 				struct wlan_mlme_stats_cfg *stats)
2818 {
2819 	stats->stats_periodic_display_time =
2820 		cfg_get(psoc, CFG_PERIODIC_STATS_DISPLAY_TIME);
2821 	stats->stats_link_speed_rssi_high =
2822 		cfg_get(psoc, CFG_LINK_SPEED_RSSI_HIGH);
2823 	stats->stats_link_speed_rssi_med =
2824 		cfg_get(psoc, CFG_LINK_SPEED_RSSI_MID);
2825 	stats->stats_link_speed_rssi_low =
2826 		cfg_get(psoc, CFG_LINK_SPEED_RSSI_LOW);
2827 	stats->stats_report_max_link_speed_rssi =
2828 		cfg_get(psoc, CFG_REPORT_MAX_LINK_SPEED);
2829 }
2830 
2831 #ifdef WLAN_ADAPTIVE_11R
2832 /**
2833  * mlme_init_adaptive_11r_cfg() - initialize enable_adaptive_11r
2834  * flag
2835  * @psoc: Pointer to PSOC
2836  * @lfr:  pointer to mlme lfr config
2837  *
2838  * Return: None
2839  */
2840 static void
mlme_init_adaptive_11r_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_lfr_cfg * lfr)2841 mlme_init_adaptive_11r_cfg(struct wlan_objmgr_psoc *psoc,
2842 			   struct wlan_mlme_lfr_cfg *lfr)
2843 {
2844 	lfr->enable_adaptive_11r = cfg_get(psoc, CFG_ADAPTIVE_11R);
2845 }
2846 
2847 #else
2848 static inline void
mlme_init_adaptive_11r_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_lfr_cfg * lfr)2849 mlme_init_adaptive_11r_cfg(struct wlan_objmgr_psoc *psoc,
2850 			   struct wlan_mlme_lfr_cfg *lfr)
2851 {
2852 }
2853 #endif
2854 
2855 #if defined(WLAN_SAE_SINGLE_PMK) && defined(WLAN_FEATURE_ROAM_OFFLOAD)
2856 /**
2857  * mlme_init_sae_single_pmk_cfg() - initialize sae_same_pmk_config
2858  * flag
2859  * @psoc: Pointer to PSOC
2860  * @lfr:  pointer to mlme lfr config
2861  *
2862  * Return: None
2863  */
2864 static void
mlme_init_sae_single_pmk_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_lfr_cfg * lfr)2865 mlme_init_sae_single_pmk_cfg(struct wlan_objmgr_psoc *psoc,
2866 			     struct wlan_mlme_lfr_cfg *lfr)
2867 {
2868 	lfr->sae_single_pmk_feature_enabled = cfg_get(psoc, CFG_SAE_SINGLE_PMK);
2869 }
2870 
2871 #else
2872 static inline void
mlme_init_sae_single_pmk_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_lfr_cfg * lfr)2873 mlme_init_sae_single_pmk_cfg(struct wlan_objmgr_psoc *psoc,
2874 			     struct wlan_mlme_lfr_cfg *lfr)
2875 {
2876 }
2877 #endif
2878 
2879 #ifdef WLAN_FEATURE_ROAM_OFFLOAD
mlme_init_roam_offload_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_lfr_cfg * lfr)2880 static void mlme_init_roam_offload_cfg(struct wlan_objmgr_psoc *psoc,
2881 				       struct wlan_mlme_lfr_cfg *lfr)
2882 {
2883 	bool val = false;
2884 
2885 	lfr->lfr3_roaming_offload =
2886 		cfg_get(psoc, CFG_LFR3_ROAMING_OFFLOAD);
2887 	lfr->lfr3_dual_sta_roaming_enabled =
2888 		cfg_get(psoc, CFG_ENABLE_DUAL_STA_ROAM_OFFLOAD);
2889 	lfr->enable_self_bss_roam = cfg_get(psoc, CFG_LFR3_ENABLE_SELF_BSS_ROAM);
2890 	lfr->enable_roam_reason_vsie =
2891 		cfg_get(psoc, CFG_ENABLE_ROAM_REASON_VSIE);
2892 	lfr->enable_disconnect_roam_offload =
2893 		cfg_get(psoc, CFG_LFR_ENABLE_DISCONNECT_ROAM);
2894 	lfr->enable_idle_roam =
2895 		cfg_get(psoc, CFG_LFR_ENABLE_IDLE_ROAM);
2896 	lfr->idle_roam_rssi_delta =
2897 		cfg_get(psoc, CFG_LFR_IDLE_ROAM_RSSI_DELTA);
2898 	lfr->roam_info_stats_num =
2899 		cfg_get(psoc, CFG_LFR3_ROAM_INFO_STATS_NUM);
2900 
2901 	ucfg_mlme_get_connection_roaming_ini_present(psoc, &val);
2902 	if (val) {
2903 		lfr->idle_roam_inactive_time =
2904 			cfg_get(psoc, CFG_ROAM_IDLE_INACTIVE_TIME) * 1000;
2905 	} else {
2906 		lfr->idle_roam_inactive_time =
2907 			cfg_get(psoc, CFG_LFR_IDLE_ROAM_INACTIVE_TIME);
2908 	}
2909 
2910 	lfr->idle_data_packet_count =
2911 		cfg_get(psoc, CFG_LFR_IDLE_ROAM_PACKET_COUNT);
2912 	lfr->idle_roam_min_rssi = cfg_get(psoc, CFG_LFR_IDLE_ROAM_MIN_RSSI);
2913 	lfr->roam_trigger_bitmap =
2914 		cfg_get(psoc, CFG_ROAM_TRIGGER_BITMAP);
2915 	lfr->vendor_btm_param.user_roam_reason = DISABLE_VENDOR_BTM_CONFIG;
2916 
2917 	lfr->idle_roam_band = cfg_get(psoc, CFG_LFR_IDLE_ROAM_BAND);
2918 	lfr->sta_roam_disable = cfg_get(psoc, CFG_STA_DISABLE_ROAM);
2919 	mlme_init_sae_single_pmk_cfg(psoc, lfr);
2920 	qdf_mem_zero(&lfr->roam_rt_stats, sizeof(lfr->roam_rt_stats));
2921 }
2922 
2923 void
wlan_mlme_defer_pmk_set_in_roaming(struct wlan_objmgr_psoc * psoc,uint8_t vdev_id,bool set_pmk_pending)2924 wlan_mlme_defer_pmk_set_in_roaming(struct wlan_objmgr_psoc *psoc,
2925 				   uint8_t vdev_id, bool set_pmk_pending)
2926 {
2927 	struct wlan_objmgr_vdev *vdev;
2928 	struct mlme_legacy_priv *mlme_priv;
2929 
2930 	if (set_pmk_pending && !MLME_IS_ROAM_SYNCH_IN_PROGRESS(psoc, vdev_id))
2931 		return;
2932 
2933 	vdev = wlan_objmgr_get_vdev_by_id_from_psoc(psoc, vdev_id,
2934 						    WLAN_MLME_OBJMGR_ID);
2935 
2936 	if (!vdev) {
2937 		mlme_err("get vdev failed");
2938 		return;
2939 	}
2940 
2941 	mlme_priv = wlan_vdev_mlme_get_ext_hdl(vdev);
2942 
2943 	if (!mlme_priv) {
2944 		wlan_objmgr_vdev_release_ref(vdev, WLAN_MLME_OBJMGR_ID);
2945 		mlme_legacy_err("vdev legacy private object is NULL");
2946 		return;
2947 	}
2948 
2949 	mlme_priv->mlme_roam.set_pmk_pending = set_pmk_pending;
2950 	wlan_objmgr_vdev_release_ref(vdev, WLAN_MLME_OBJMGR_ID);
2951 }
2952 
2953 bool
wlan_mlme_is_pmk_set_deferred(struct wlan_objmgr_psoc * psoc,uint8_t vdev_id)2954 wlan_mlme_is_pmk_set_deferred(struct wlan_objmgr_psoc *psoc,
2955 			      uint8_t vdev_id)
2956 {
2957 	struct wlan_objmgr_vdev *vdev;
2958 	struct mlme_legacy_priv *mlme_priv;
2959 	bool set_pmk_pending;
2960 
2961 	vdev = wlan_objmgr_get_vdev_by_id_from_psoc(psoc, vdev_id,
2962 						    WLAN_MLME_OBJMGR_ID);
2963 
2964 	if (!vdev) {
2965 		mlme_err("get vdev failed");
2966 		return false;
2967 	}
2968 
2969 	mlme_priv = wlan_vdev_mlme_get_ext_hdl(vdev);
2970 
2971 	if (!mlme_priv) {
2972 		wlan_objmgr_vdev_release_ref(vdev, WLAN_MLME_OBJMGR_ID);
2973 		mlme_legacy_err("vdev legacy private object is NULL");
2974 		return false;
2975 	}
2976 
2977 	set_pmk_pending = mlme_priv->mlme_roam.set_pmk_pending;
2978 	wlan_objmgr_vdev_release_ref(vdev, WLAN_MLME_OBJMGR_ID);
2979 
2980 	return set_pmk_pending;
2981 }
2982 #else
mlme_init_roam_offload_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_lfr_cfg * lfr)2983 static void mlme_init_roam_offload_cfg(struct wlan_objmgr_psoc *psoc,
2984 				       struct wlan_mlme_lfr_cfg *lfr)
2985 {
2986 }
2987 
2988 #endif
2989 
2990 #ifdef FEATURE_WLAN_ESE
mlme_init_ese_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_lfr_cfg * lfr)2991 static void mlme_init_ese_cfg(struct wlan_objmgr_psoc *psoc,
2992 			      struct wlan_mlme_lfr_cfg *lfr)
2993 {
2994 	lfr->ese_enabled = cfg_get(psoc, CFG_LFR_ESE_FEATURE_ENABLED);
2995 }
2996 #else
mlme_init_ese_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_lfr_cfg * lfr)2997 static void mlme_init_ese_cfg(struct wlan_objmgr_psoc *psoc,
2998 			      struct wlan_mlme_lfr_cfg *lfr)
2999 {
3000 }
3001 #endif
3002 
3003 #ifdef FEATURE_LFR_SUBNET_DETECTION
mlme_init_subnet_detection(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_lfr_cfg * lfr)3004 static void mlme_init_subnet_detection(struct wlan_objmgr_psoc *psoc,
3005 				       struct wlan_mlme_lfr_cfg *lfr)
3006 {
3007 	lfr->enable_lfr_subnet_detection =
3008 		cfg_get(psoc, CFG_LFR3_ENABLE_SUBNET_DETECTION);
3009 }
3010 #else
mlme_init_subnet_detection(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_lfr_cfg * lfr)3011 static void mlme_init_subnet_detection(struct wlan_objmgr_psoc *psoc,
3012 				       struct wlan_mlme_lfr_cfg *lfr)
3013 {
3014 }
3015 #endif
3016 
3017 static void
mlme_init_bss_load_trigger_params(struct wlan_objmgr_psoc * psoc,struct bss_load_trigger * bss_load_trig)3018 mlme_init_bss_load_trigger_params(struct wlan_objmgr_psoc *psoc,
3019 				  struct bss_load_trigger *bss_load_trig)
3020 {
3021 	bool val = false;
3022 
3023 	bss_load_trig->enabled =
3024 		cfg_get(psoc, CFG_ENABLE_BSS_LOAD_TRIGGERED_ROAM);
3025 	bss_load_trig->threshold = cfg_get(psoc, CFG_BSS_LOAD_THRESHOLD);
3026 
3027 	ucfg_mlme_get_connection_roaming_ini_present(psoc, &val);
3028 	if (val)
3029 		bss_load_trig->sample_time =
3030 				cfg_get(psoc, CFG_ROAM_CU_MONITOR_TIME) * 1000;
3031 	else
3032 		bss_load_trig->sample_time = cfg_get(psoc,
3033 						     CFG_BSS_LOAD_SAMPLE_TIME);
3034 
3035 	bss_load_trig->rssi_threshold_6ghz =
3036 			cfg_get(psoc, CFG_BSS_LOAD_TRIG_6G_RSSI_THRES);
3037 	bss_load_trig->rssi_threshold_5ghz =
3038 			cfg_get(psoc, CFG_BSS_LOAD_TRIG_5G_RSSI_THRES);
3039 	bss_load_trig->rssi_threshold_24ghz =
3040 			cfg_get(psoc, CFG_BSS_LOAD_TRIG_2G_RSSI_THRES);
3041 }
3042 
mlme_reinit_control_config_lfr_params(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_lfr_cfg * lfr)3043 void mlme_reinit_control_config_lfr_params(struct wlan_objmgr_psoc *psoc,
3044 					   struct wlan_mlme_lfr_cfg *lfr)
3045 {
3046 	/* Restore the params set through SETDFSSCANMODE */
3047 	lfr->roaming_dfs_channel =
3048 		cfg_get(psoc, CFG_LFR_ROAMING_DFS_CHANNEL);
3049 
3050 	/* Restore the params set through SETWESMODE */
3051 	lfr->wes_mode_enabled = cfg_get(psoc, CFG_LFR_ENABLE_WES_MODE);
3052 }
3053 
3054 #ifdef CONNECTION_ROAMING_CFG
3055 /**
3056  * mlme_init_bmiss_timeout() - Init bmiss timeout
3057  * @psoc: Pointer to psoc
3058  * @lfr: Pointer to lfr config
3059  *
3060  * Return: None
3061  */
mlme_init_bmiss_timeout(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_lfr_cfg * lfr)3062 static void mlme_init_bmiss_timeout(struct wlan_objmgr_psoc *psoc,
3063 				    struct wlan_mlme_lfr_cfg *lfr)
3064 {
3065 	lfr->beaconloss_timeout_onwakeup =
3066 		cfg_get(psoc, CFG_LFR_BEACONLOSS_TIMEOUT_ON_WAKEUP) / 2;
3067 	lfr->beaconloss_timeout_onsleep =
3068 		cfg_get(psoc, CFG_LFR_BEACONLOSS_TIMEOUT_ON_SLEEP) / 2;
3069 }
3070 #else
mlme_init_bmiss_timeout(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_lfr_cfg * lfr)3071 static void mlme_init_bmiss_timeout(struct wlan_objmgr_psoc *psoc,
3072 				    struct wlan_mlme_lfr_cfg *lfr)
3073 {
3074 	lfr->beaconloss_timeout_onwakeup =
3075 		cfg_get(psoc, CFG_LFR_BEACONLOSS_TIMEOUT_ON_WAKEUP);
3076 	lfr->beaconloss_timeout_onsleep =
3077 		cfg_get(psoc, CFG_LFR_BEACONLOSS_TIMEOUT_ON_SLEEP);
3078 }
3079 #endif
3080 
mlme_init_lfr_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_lfr_cfg * lfr)3081 static void mlme_init_lfr_cfg(struct wlan_objmgr_psoc *psoc,
3082 			      struct wlan_mlme_lfr_cfg *lfr)
3083 {
3084 	qdf_size_t neighbor_scan_chan_list_num = 0;
3085 	bool val = false;
3086 
3087 	lfr->mawc_roam_enabled =
3088 		cfg_get(psoc, CFG_LFR_MAWC_ROAM_ENABLED);
3089 	lfr->enable_fast_roam_in_concurrency =
3090 		cfg_get(psoc, CFG_LFR_ENABLE_FAST_ROAM_IN_CONCURRENCY);
3091 	lfr->early_stop_scan_enable =
3092 		cfg_get(psoc, CFG_LFR_EARLY_STOP_SCAN_ENABLE);
3093 	lfr->enable_5g_band_pref =
3094 		cfg_get(psoc, CFG_LFR_ENABLE_5G_BAND_PREF);
3095 	lfr->lfr_enabled = cfg_get(psoc, CFG_LFR_FEATURE_ENABLED);
3096 	lfr->mawc_enabled = cfg_get(psoc, CFG_LFR_MAWC_FEATURE_ENABLED);
3097 	lfr->fast_transition_enabled =
3098 		cfg_get(psoc, CFG_LFR_FAST_TRANSITION_ENABLED);
3099 	lfr->wes_mode_enabled = cfg_get(psoc, CFG_LFR_ENABLE_WES_MODE);
3100 	lfr->mawc_roam_traffic_threshold =
3101 		cfg_get(psoc, CFG_LFR_MAWC_ROAM_TRAFFIC_THRESHOLD);
3102 	lfr->mawc_roam_ap_rssi_threshold =
3103 		cfg_get(psoc, CFG_LFR_MAWC_ROAM_AP_RSSI_THRESHOLD);
3104 	lfr->mawc_roam_rssi_high_adjust =
3105 		cfg_get(psoc, CFG_LFR_MAWC_ROAM_RSSI_HIGH_ADJUST);
3106 	lfr->mawc_roam_rssi_low_adjust =
3107 		cfg_get(psoc, CFG_LFR_MAWC_ROAM_RSSI_LOW_ADJUST);
3108 	lfr->roam_rssi_abs_threshold =
3109 		cfg_get(psoc, CFG_LFR_ROAM_RSSI_ABS_THRESHOLD);
3110 	lfr->rssi_threshold_offset_5g =
3111 		cfg_get(psoc, CFG_LFR_5G_RSSI_THRESHOLD_OFFSET);
3112 	lfr->early_stop_scan_min_threshold =
3113 		cfg_get(psoc, CFG_LFR_EARLY_STOP_SCAN_MIN_THRESHOLD);
3114 	lfr->early_stop_scan_max_threshold =
3115 		cfg_get(psoc, CFG_LFR_EARLY_STOP_SCAN_MAX_THRESHOLD);
3116 	lfr->roam_dense_traffic_threshold =
3117 		cfg_get(psoc, CFG_LFR_ROAM_DENSE_TRAFFIC_THRESHOLD);
3118 	lfr->roam_dense_rssi_thre_offset =
3119 		cfg_get(psoc, CFG_LFR_ROAM_DENSE_RSSI_THRE_OFFSET);
3120 	lfr->roam_dense_min_aps =
3121 		cfg_get(psoc, CFG_LFR_ROAM_DENSE_MIN_APS);
3122 	lfr->roam_bg_scan_bad_rssi_threshold =
3123 		cfg_get(psoc, CFG_LFR_ROAM_BG_SCAN_BAD_RSSI_THRESHOLD);
3124 	lfr->roam_bg_scan_client_bitmap =
3125 		cfg_get(psoc, CFG_LFR_ROAM_BG_SCAN_CLIENT_BITMAP);
3126 	lfr->roam_bg_scan_bad_rssi_offset_2g =
3127 		cfg_get(psoc, CFG_LFR_ROAM_BG_SCAN_BAD_RSSI_OFFSET_2G);
3128 	lfr->roam_data_rssi_threshold_triggers =
3129 		cfg_get(psoc, CFG_ROAM_DATA_RSSI_THRESHOLD_TRIGGERS);
3130 	lfr->roam_data_rssi_threshold =
3131 		cfg_get(psoc, CFG_ROAM_DATA_RSSI_THRESHOLD);
3132 	lfr->rx_data_inactivity_time =
3133 		cfg_get(psoc, CFG_RX_DATA_INACTIVITY_TIME);
3134 	lfr->adaptive_roamscan_dwell_mode =
3135 		cfg_get(psoc, CFG_LFR_ADAPTIVE_ROAMSCAN_DWELL_MODE);
3136 	lfr->per_roam_enable =
3137 		cfg_get(psoc, CFG_LFR_PER_ROAM_ENABLE);
3138 	lfr->per_roam_config_high_rate_th =
3139 		cfg_get(psoc, CFG_LFR_PER_ROAM_CONFIG_HIGH_RATE_TH);
3140 	lfr->per_roam_config_low_rate_th =
3141 		cfg_get(psoc, CFG_LFR_PER_ROAM_CONFIG_LOW_RATE_TH);
3142 	lfr->per_roam_config_rate_th_percent =
3143 		cfg_get(psoc, CFG_LFR_PER_ROAM_CONFIG_RATE_TH_PERCENT);
3144 	lfr->per_roam_rest_time =
3145 		cfg_get(psoc, CFG_LFR_PER_ROAM_REST_TIME);
3146 	lfr->per_roam_monitor_time =
3147 		cfg_get(psoc, CFG_LFR_PER_ROAM_MONITOR_TIME);
3148 	lfr->per_roam_min_candidate_rssi =
3149 		cfg_get(psoc, CFG_LFR_PER_ROAM_MIN_CANDIDATE_RSSI);
3150 	lfr->lfr3_disallow_duration =
3151 		cfg_get(psoc, CFG_LFR3_ROAM_DISALLOW_DURATION);
3152 	lfr->lfr3_rssi_channel_penalization =
3153 		cfg_get(psoc, CFG_LFR3_ROAM_RSSI_CHANNEL_PENALIZATION);
3154 	lfr->lfr3_num_disallowed_aps =
3155 		cfg_get(psoc, CFG_LFR3_ROAM_NUM_DISALLOWED_APS);
3156 
3157 	if (lfr->enable_5g_band_pref) {
3158 		lfr->rssi_boost_threshold_5g =
3159 			cfg_get(psoc, CFG_LFR_5G_RSSI_BOOST_THRESHOLD);
3160 		lfr->rssi_boost_factor_5g =
3161 			cfg_get(psoc, CFG_LFR_5G_RSSI_BOOST_FACTOR);
3162 		lfr->max_rssi_boost_5g =
3163 			cfg_get(psoc, CFG_LFR_5G_MAX_RSSI_BOOST);
3164 		lfr->rssi_penalize_threshold_5g =
3165 			cfg_get(psoc, CFG_LFR_5G_RSSI_PENALIZE_THRESHOLD);
3166 		lfr->rssi_penalize_factor_5g =
3167 			cfg_get(psoc, CFG_LFR_5G_RSSI_PENALIZE_FACTOR);
3168 		lfr->max_rssi_penalize_5g =
3169 			cfg_get(psoc, CFG_LFR_5G_MAX_RSSI_PENALIZE);
3170 	}
3171 
3172 	lfr->max_num_pre_auth = (uint32_t)
3173 		cfg_default(CFG_LFR_MAX_NUM_PRE_AUTH);
3174 	lfr->roam_preauth_no_ack_timeout =
3175 		cfg_get(psoc, CFG_LFR3_ROAM_PREAUTH_NO_ACK_TIMEOUT);
3176 	lfr->roam_preauth_retry_count =
3177 		cfg_get(psoc, CFG_LFR3_ROAM_PREAUTH_RETRY_COUNT);
3178 	lfr->roam_rssi_diff = cfg_get(psoc, CFG_LFR_ROAM_RSSI_DIFF);
3179 	lfr->roam_rssi_diff_6ghz = cfg_get(psoc, CFG_LFR_ROAM_RSSI_DIFF_6GHZ);
3180 	lfr->bg_rssi_threshold = cfg_get(psoc, CFG_LFR_ROAM_BG_RSSI_TH);
3181 	lfr->roam_scan_offload_enabled =
3182 		cfg_get(psoc, CFG_LFR_ROAM_SCAN_OFFLOAD_ENABLED);
3183 	lfr->neighbor_scan_timer_period =
3184 		cfg_get(psoc, CFG_LFR_NEIGHBOR_SCAN_TIMER_PERIOD);
3185 	lfr->neighbor_scan_min_timer_period =
3186 		cfg_get(psoc, CFG_LFR_NEIGHBOR_SCAN_MIN_TIMER_PERIOD);
3187 	lfr->neighbor_lookup_rssi_threshold =
3188 		abs(cfg_get(psoc, CFG_LFR_NEIGHBOR_LOOKUP_RSSI_THRESHOLD));
3189 	lfr->opportunistic_scan_threshold_diff =
3190 		cfg_get(psoc, CFG_LFR_OPPORTUNISTIC_SCAN_THRESHOLD_DIFF);
3191 	lfr->roam_rescan_rssi_diff =
3192 		cfg_get(psoc, CFG_LFR_ROAM_RESCAN_RSSI_DIFF);
3193 	lfr->neighbor_scan_min_chan_time =
3194 		cfg_get(psoc, CFG_LFR_NEIGHBOR_SCAN_MIN_CHAN_TIME);
3195 	lfr->neighbor_scan_max_chan_time =
3196 		cfg_get(psoc, CFG_LFR_NEIGHBOR_SCAN_MAX_CHAN_TIME);
3197 	lfr->passive_max_channel_time =
3198 		cfg_get(psoc, CFG_ROAM_PASSIVE_MAX_CHANNEL_TIME);
3199 	lfr->neighbor_scan_results_refresh_period =
3200 		cfg_get(psoc, CFG_LFR_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD);
3201 
3202 	ucfg_mlme_get_connection_roaming_ini_present(psoc, &val);
3203 	if (val)
3204 		lfr->empty_scan_refresh_period =
3205 			cfg_get(psoc, CFG_ROAM_SCAN_FIRST_TIMER) * 1000;
3206 	else
3207 		lfr->empty_scan_refresh_period =
3208 			cfg_get(psoc, CFG_LFR_EMPTY_SCAN_REFRESH_PERIOD);
3209 	lfr->roam_bmiss_first_bcnt =
3210 		cfg_get(psoc, CFG_LFR_ROAM_BMISS_FIRST_BCNT);
3211 	lfr->roam_bmiss_final_bcnt =
3212 		cfg_get(psoc, CFG_LFR_ROAM_BMISS_FINAL_BCNT);
3213 	lfr->roaming_dfs_channel =
3214 		cfg_get(psoc, CFG_LFR_ROAMING_DFS_CHANNEL);
3215 	lfr->roam_scan_hi_rssi_maxcount =
3216 		cfg_get(psoc, CFG_LFR_ROAM_SCAN_HI_RSSI_MAXCOUNT);
3217 	lfr->roam_scan_hi_rssi_delta =
3218 		cfg_get(psoc, CFG_LFR_ROAM_SCAN_HI_RSSI_DELTA);
3219 	lfr->roam_scan_hi_rssi_delay =
3220 		cfg_get(psoc, CFG_LFR_ROAM_SCAN_HI_RSSI_DELAY);
3221 	lfr->roam_scan_hi_rssi_ub =
3222 		cfg_get(psoc, CFG_LFR_ROAM_SCAN_HI_RSSI_UB);
3223 	lfr->roam_prefer_5ghz =
3224 		cfg_get(psoc, CFG_LFR_ROAM_PREFER_5GHZ);
3225 	lfr->roam_intra_band =
3226 		cfg_get(psoc, CFG_LFR_ROAM_INTRA_BAND);
3227 	lfr->roam_scan_home_away_time =
3228 		cfg_get(psoc, CFG_LFR_ROAM_SCAN_HOME_AWAY_TIME);
3229 	lfr->roam_scan_n_probes =
3230 		cfg_get(psoc, CFG_LFR_ROAM_SCAN_N_PROBES);
3231 	lfr->delay_before_vdev_stop =
3232 		cfg_get(psoc, CFG_LFR_DELAY_BEFORE_VDEV_STOP);
3233 	qdf_uint8_array_parse(cfg_get(psoc, CFG_LFR_NEIGHBOR_SCAN_CHANNEL_LIST),
3234 			      lfr->neighbor_scan_channel_list,
3235 			      CFG_VALID_CHANNEL_LIST_LEN,
3236 			      &neighbor_scan_chan_list_num);
3237 	lfr->neighbor_scan_channel_list_num =
3238 				(uint8_t)neighbor_scan_chan_list_num;
3239 	lfr->ho_delay_for_rx =
3240 		cfg_get(psoc, CFG_LFR3_ROAM_HO_DELAY_FOR_RX);
3241 	lfr->min_delay_btw_roam_scans =
3242 		cfg_get(psoc, CFG_LFR_MIN_DELAY_BTW_ROAM_SCAN);
3243 	lfr->roam_trigger_reason_bitmask =
3244 		cfg_get(psoc, CFG_LFR_ROAM_SCAN_TRIGGER_REASON_BITMASK);
3245 	lfr->enable_ftopen =
3246 		cfg_get(psoc, CFG_LFR_ROAM_FT_OPEN_ENABLE);
3247 	lfr->roam_force_rssi_trigger =
3248 		cfg_get(psoc, CFG_LFR_ROAM_FORCE_RSSI_TRIGGER);
3249 	lfr->roaming_scan_policy =
3250 		cfg_get(psoc, CFG_ROAM_SCAN_SCAN_POLICY);
3251 
3252 	if (val)
3253 		lfr->roam_scan_inactivity_time =
3254 			cfg_get(psoc, CFG_ROAM_SCAN_INACTIVE_TIMER) * 1000;
3255 	else
3256 		lfr->roam_scan_inactivity_time =
3257 			cfg_get(psoc, CFG_ROAM_SCAN_INACTIVITY_TIME);
3258 
3259 	lfr->roam_inactive_data_packet_count =
3260 		cfg_get(psoc, CFG_ROAM_INACTIVE_COUNT);
3261 
3262 	lfr->fw_akm_bitmap = 0;
3263 	lfr->enable_ft_im_roaming = cfg_get(psoc, CFG_FT_IM_ROAMING);
3264 	lfr->enable_ft_over_ds = !ENABLE_FT_OVER_DS;
3265 
3266 	mlme_init_roam_offload_cfg(psoc, lfr);
3267 	mlme_init_ese_cfg(psoc, lfr);
3268 	mlme_init_bss_load_trigger_params(psoc, &lfr->bss_load_trig);
3269 	mlme_init_adaptive_11r_cfg(psoc, lfr);
3270 	mlme_init_subnet_detection(psoc, lfr);
3271 	lfr->rso_user_config.cat_rssi_offset = DEFAULT_RSSI_DB_GAP;
3272 	mlme_init_bmiss_timeout(psoc, lfr);
3273 	lfr->hs20_btm_offload_disable = cfg_get(psoc,
3274 						CFG_HS_20_BTM_OFFLOAD_DISABLE);
3275 }
3276 
mlme_init_power_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_power * power)3277 static void mlme_init_power_cfg(struct wlan_objmgr_psoc *psoc,
3278 				struct wlan_mlme_power *power)
3279 {
3280 	power->tx_power_2g = cfg_get(psoc, CFG_SET_TXPOWER_LIMIT2G);
3281 	power->tx_power_5g = cfg_get(psoc, CFG_SET_TXPOWER_LIMIT5G);
3282 
3283 	power->max_tx_power_24_chan.max_len = CFG_MAX_TX_POWER_2_4_LEN;
3284 	qdf_uint8_array_parse(cfg_default(CFG_MAX_TX_POWER_2_4),
3285 			      power->max_tx_power_24_chan.data,
3286 			      sizeof(power->max_tx_power_24_chan.data),
3287 			      &power->max_tx_power_24_chan.len);
3288 
3289 	power->max_tx_power_5_chan.max_len = CFG_MAX_TX_POWER_5_LEN;
3290 	qdf_uint8_array_parse(cfg_default(CFG_MAX_TX_POWER_5),
3291 			      power->max_tx_power_5_chan.data,
3292 			      sizeof(power->max_tx_power_5_chan.data),
3293 			      &power->max_tx_power_5_chan.len);
3294 
3295 	power->power_usage.max_len = CFG_POWER_USAGE_MAX_LEN;
3296 	power->power_usage.len = CFG_POWER_USAGE_MAX_LEN;
3297 	qdf_mem_copy(power->power_usage.data, cfg_get(psoc, CFG_POWER_USAGE),
3298 		     power->power_usage.len);
3299 	power->current_tx_power_level =
3300 			(uint8_t)cfg_default(CFG_CURRENT_TX_POWER_LEVEL);
3301 	power->local_power_constraint =
3302 			(uint8_t)cfg_default(CFG_LOCAL_POWER_CONSTRAINT);
3303 	power->skip_tpe = cfg_get(psoc, CFG_SKIP_TPE_CONSIDERATION);
3304 }
3305 
mlme_init_roam_scoring_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_roam_scoring_cfg * scoring_cfg)3306 static void mlme_init_roam_scoring_cfg(struct wlan_objmgr_psoc *psoc,
3307 				struct wlan_mlme_roam_scoring_cfg *scoring_cfg)
3308 {
3309 	bool val = false;
3310 
3311 	scoring_cfg->enable_scoring_for_roam =
3312 		cfg_get(psoc, CFG_ENABLE_SCORING_FOR_ROAM);
3313 	scoring_cfg->roam_trigger_bitmap =
3314 			cfg_get(psoc, CFG_ROAM_SCORE_DELTA_TRIGGER_BITMAP);
3315 	scoring_cfg->roam_score_delta = cfg_get(psoc, CFG_ROAM_SCORE_DELTA);
3316 	scoring_cfg->apsd_enabled = (bool)cfg_default(CFG_APSD_ENABLED);
3317 
3318 	ucfg_mlme_get_connection_roaming_ini_present(psoc, &val);
3319 	if (val) {
3320 		scoring_cfg->min_roam_score_delta =
3321 			cfg_get(psoc, CFG_ROAM_COMMON_MIN_ROAM_DELTA) * 100;
3322 	} else {
3323 		scoring_cfg->min_roam_score_delta =
3324 			cfg_get(psoc, CFG_CAND_MIN_ROAM_SCORE_DELTA);
3325 	}
3326 }
3327 
mlme_init_oce_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_oce * oce)3328 static void mlme_init_oce_cfg(struct wlan_objmgr_psoc *psoc,
3329 			      struct wlan_mlme_oce *oce)
3330 {
3331 	uint8_t val;
3332 	bool rssi_assoc_reject_enabled;
3333 	bool probe_req_rate_enabled;
3334 	bool probe_resp_rate_enabled;
3335 	bool beacon_rate_enabled;
3336 	bool probe_req_deferral_enabled;
3337 	bool fils_discovery_sap_enabled;
3338 	bool esp_for_roam_enabled;
3339 
3340 	oce->enable_bcast_probe_rsp =
3341 		cfg_get(psoc, CFG_ENABLE_BCAST_PROBE_RESP);
3342 	oce->oce_sta_enabled = cfg_get(psoc, CFG_OCE_ENABLE_STA);
3343 	oce->oce_sap_enabled = cfg_get(psoc, CFG_OCE_ENABLE_SAP);
3344 	oce->fils_enabled = cfg_get(psoc, CFG_IS_FILS_ENABLED);
3345 
3346 	rssi_assoc_reject_enabled =
3347 		cfg_get(psoc, CFG_OCE_ENABLE_RSSI_BASED_ASSOC_REJECT);
3348 	probe_req_rate_enabled = cfg_get(psoc, CFG_OCE_PROBE_REQ_RATE);
3349 	probe_resp_rate_enabled = cfg_get(psoc, CFG_OCE_PROBE_RSP_RATE);
3350 	beacon_rate_enabled = cfg_get(psoc, CFG_OCE_BEACON_RATE);
3351 	probe_req_deferral_enabled =
3352 		cfg_get(psoc, CFG_ENABLE_PROBE_REQ_DEFERRAL);
3353 	fils_discovery_sap_enabled =
3354 		cfg_get(psoc, CFG_ENABLE_FILS_DISCOVERY_SAP);
3355 	esp_for_roam_enabled = cfg_get(psoc, CFG_ENABLE_ESP_FEATURE);
3356 
3357 	if (!rssi_assoc_reject_enabled ||
3358 	    !oce->enable_bcast_probe_rsp) {
3359 		oce->oce_sta_enabled = 0;
3360 	}
3361 
3362 	val = (probe_req_rate_enabled *
3363 	WMI_VDEV_OCE_PROBE_REQUEST_RATE_FEATURE_BITMAP) +
3364 	(probe_resp_rate_enabled *
3365 	WMI_VDEV_OCE_PROBE_RESPONSE_RATE_FEATURE_BITMAP) +
3366 	(beacon_rate_enabled *
3367 	WMI_VDEV_OCE_BEACON_RATE_FEATURE_BITMAP) +
3368 	(probe_req_deferral_enabled *
3369 	 WMI_VDEV_OCE_PROBE_REQUEST_DEFERRAL_FEATURE_BITMAP) +
3370 	(fils_discovery_sap_enabled *
3371 	 WMI_VDEV_OCE_FILS_DISCOVERY_FRAME_FEATURE_BITMAP) +
3372 	(esp_for_roam_enabled *
3373 	 WMI_VDEV_OCE_ESP_FEATURE_BITMAP) +
3374 	(rssi_assoc_reject_enabled *
3375 	 WMI_VDEV_OCE_REASSOC_REJECT_FEATURE_BITMAP);
3376 	oce->feature_bitmap = val;
3377 }
3378 
mlme_init_nss_chains(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_nss_chains * nss_chains)3379 static void mlme_init_nss_chains(struct wlan_objmgr_psoc *psoc,
3380 				 struct wlan_mlme_nss_chains *nss_chains)
3381 {
3382 	nss_chains->num_rx_chains[NSS_CHAINS_BAND_2GHZ] =
3383 					    cfg_get(psoc, CFG_NUM_RX_CHAINS_2G);
3384 	nss_chains->num_rx_chains[NSS_CHAINS_BAND_5GHZ] =
3385 					    cfg_get(psoc, CFG_NUM_RX_CHAINS_5G);
3386 	nss_chains->num_tx_chains[NSS_CHAINS_BAND_2GHZ] =
3387 					    cfg_get(psoc, CFG_NUM_TX_CHAINS_2G);
3388 	nss_chains->num_tx_chains[NSS_CHAINS_BAND_5GHZ] =
3389 					    cfg_get(psoc, CFG_NUM_TX_CHAINS_5G);
3390 
3391 	nss_chains->tx_nss[NSS_CHAINS_BAND_2GHZ] = cfg_get(psoc, CFG_TX_NSS_2G);
3392 	nss_chains->tx_nss[NSS_CHAINS_BAND_5GHZ] = cfg_get(psoc, CFG_TX_NSS_5G);
3393 	nss_chains->rx_nss[NSS_CHAINS_BAND_2GHZ] = cfg_get(psoc, CFG_RX_NSS_2G);
3394 	nss_chains->rx_nss[NSS_CHAINS_BAND_5GHZ] = cfg_get(psoc, CFG_RX_NSS_5G);
3395 
3396 	nss_chains->num_tx_chains_11b = cfg_get(psoc, CFG_NUM_TX_CHAINS_11b);
3397 	nss_chains->num_tx_chains_11g = cfg_get(psoc, CFG_NUM_TX_CHAINS_11g);
3398 	nss_chains->num_tx_chains_11a = cfg_get(psoc, CFG_NUM_TX_CHAINS_11a);
3399 
3400 	nss_chains->disable_rx_mrc[NSS_CHAINS_BAND_2GHZ] =
3401 					   cfg_get(psoc, CFG_DISABLE_RX_MRC_2G);
3402 	nss_chains->disable_rx_mrc[NSS_CHAINS_BAND_5GHZ] =
3403 					   cfg_get(psoc, CFG_DISABLE_RX_MRC_5G);
3404 	nss_chains->disable_tx_mrc[NSS_CHAINS_BAND_2GHZ] =
3405 					   cfg_get(psoc, CFG_DISABLE_TX_MRC_2G);
3406 	nss_chains->disable_tx_mrc[NSS_CHAINS_BAND_5GHZ] =
3407 					   cfg_get(psoc, CFG_DISABLE_TX_MRC_5G);
3408 	nss_chains->enable_dynamic_nss_chains_cfg =
3409 			cfg_get(psoc, CFG_ENABLE_DYNAMIC_NSS_CHAIN_CONFIG);
3410 	nss_chains->restart_sap_on_dyn_nss_chains_cfg =
3411 			cfg_get(psoc,
3412 				CFG_RESTART_SAP_ON_DYNAMIC_NSS_CHAINS_CONFIG);
3413 }
3414 
mlme_init_wep_cfg(struct wlan_mlme_wep_cfg * wep_params)3415 static void mlme_init_wep_cfg(struct wlan_mlme_wep_cfg *wep_params)
3416 {
3417 	wep_params->is_privacy_enabled = cfg_default(CFG_PRIVACY_ENABLED);
3418 	wep_params->auth_type = cfg_default(CFG_AUTHENTICATION_TYPE);
3419 	wep_params->is_shared_key_auth =
3420 			cfg_default(CFG_SHARED_KEY_AUTH_ENABLE);
3421 	wep_params->is_auth_open_system =
3422 			cfg_default(CFG_OPEN_SYSTEM_AUTH_ENABLE);
3423 
3424 	wep_params->wep_default_key_id = cfg_default(CFG_WEP_DEFAULT_KEYID);
3425 }
3426 
3427 #if defined(WIFI_POS_CONVERGED) && defined(WLAN_FEATURE_RTT_11AZ_SUPPORT)
3428 static void
mlme_init_wifi_pos_11az_config(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_wifi_pos_cfg * wifi_pos_cfg)3429 mlme_init_wifi_pos_11az_config(struct wlan_objmgr_psoc *psoc,
3430 			       struct wlan_mlme_wifi_pos_cfg *wifi_pos_cfg)
3431 {
3432 	bool rsta_sec_ltf_enabled =
3433 			cfg_get(psoc, CFG_RESPONDER_SECURE_LTF_SUPPORT);
3434 	uint32_t rsta_11az_ranging_enabled =
3435 				cfg_get(psoc, CFG_RESPONDER_11AZ_SUPPORT);
3436 
3437 	wifi_pos_set_rsta_11az_ranging_cap(rsta_11az_ranging_enabled);
3438 	wifi_pos_set_rsta_sec_ltf_cap(rsta_sec_ltf_enabled);
3439 }
3440 #else
3441 static inline void
mlme_init_wifi_pos_11az_config(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_wifi_pos_cfg * wifi_pos_cfg)3442 mlme_init_wifi_pos_11az_config(struct wlan_objmgr_psoc *psoc,
3443 			       struct wlan_mlme_wifi_pos_cfg *wifi_pos_cfg)
3444 {}
3445 #endif
3446 
mlme_init_wifi_pos_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_wifi_pos_cfg * wifi_pos_cfg)3447 static void mlme_init_wifi_pos_cfg(struct wlan_objmgr_psoc *psoc,
3448 				   struct wlan_mlme_wifi_pos_cfg *wifi_pos_cfg)
3449 {
3450 	wifi_pos_cfg->fine_time_meas_cap =
3451 		cfg_get(psoc, CFG_FINE_TIME_MEAS_CAPABILITY);
3452 	wifi_pos_cfg->oem_6g_support_disable =
3453 		cfg_get(psoc, CFG_OEM_SIXG_SUPPORT_DISABLE);
3454 
3455 	mlme_init_wifi_pos_11az_config(psoc, wifi_pos_cfg);
3456 }
3457 
3458 #ifdef FEATURE_WLAN_ESE
mlme_init_inactivity_intv(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_wmm_params * wmm_params)3459 static void mlme_init_inactivity_intv(struct wlan_objmgr_psoc *psoc,
3460 				      struct wlan_mlme_wmm_params *wmm_params)
3461 {
3462 	wmm_params->wmm_tspec_element.inactivity_intv =
3463 		cfg_get(psoc, CFG_QOS_WMM_INACTIVITY_INTERVAL);
3464 }
3465 #else
3466 static inline void
mlme_init_inactivity_intv(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_wmm_params * wmm_params)3467 mlme_init_inactivity_intv(struct wlan_objmgr_psoc *psoc,
3468 			  struct wlan_mlme_wmm_params *wmm_params)
3469 {
3470 }
3471 #endif /* FEATURE_WLAN_ESE */
3472 
mlme_init_wmm_in_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_wmm_params * wmm_params)3473 static void mlme_init_wmm_in_cfg(struct wlan_objmgr_psoc *psoc,
3474 				 struct wlan_mlme_wmm_params *wmm_params)
3475 {
3476 	wmm_params->qos_enabled = cfg_default(CFG_QOS_ENABLED);
3477 	wmm_params->wme_enabled = cfg_default(CFG_WME_ENABLED);
3478 	wmm_params->max_sp_length = cfg_default(CFG_MAX_SP_LENGTH);
3479 	wmm_params->wsm_enabled = cfg_default(CFG_WSM_ENABLED);
3480 	wmm_params->edca_profile = cfg_default(CFG_EDCA_PROFILE);
3481 
3482 	wmm_params->ac_vo.dir_ac_vo = cfg_get(psoc, CFG_QOS_WMM_DIR_AC_VO);
3483 	wmm_params->ac_vo.nom_msdu_size_ac_vo =
3484 			cfg_get(psoc, CFG_QOS_WMM_NOM_MSDU_SIZE_AC_VO);
3485 	wmm_params->ac_vo.mean_data_rate_ac_vo =
3486 			cfg_get(psoc, CFG_QOS_WMM_MEAN_DATA_RATE_AC_VO);
3487 	wmm_params->ac_vo.min_phy_rate_ac_vo =
3488 			cfg_get(psoc, CFG_QOS_WMM_MIN_PHY_RATE_AC_VO);
3489 	wmm_params->ac_vo.sba_ac_vo = cfg_get(psoc, CFG_QOS_WMM_SBA_AC_VO);
3490 	wmm_params->ac_vo.uapsd_vo_srv_intv =
3491 			cfg_get(psoc, CFG_QOS_WMM_UAPSD_VO_SRV_INTV);
3492 	wmm_params->ac_vo.uapsd_vo_sus_intv =
3493 			cfg_get(psoc, CFG_QOS_WMM_UAPSD_VO_SUS_INTV);
3494 
3495 	wmm_params->ac_vi.dir_ac_vi =
3496 		cfg_get(psoc, CFG_QOS_WMM_DIR_AC_VI);
3497 	wmm_params->ac_vi.nom_msdu_size_ac_vi =
3498 		cfg_get(psoc, CFG_QOS_WMM_NOM_MSDU_SIZE_AC_VI);
3499 	wmm_params->ac_vi.mean_data_rate_ac_vi =
3500 		cfg_get(psoc, CFG_QOS_WMM_MEAN_DATA_RATE_AC_VI);
3501 	wmm_params->ac_vi.min_phy_rate_ac_vi =
3502 		cfg_get(psoc, CFG_QOS_WMM_MIN_PHY_RATE_AC_VI);
3503 	wmm_params->ac_vi.sba_ac_vi =
3504 		cfg_get(psoc, CFG_QOS_WMM_SBA_AC_VI);
3505 	wmm_params->ac_vi.uapsd_vi_srv_intv =
3506 		cfg_get(psoc, CFG_QOS_WMM_UAPSD_VI_SRV_INTV);
3507 	wmm_params->ac_vi.uapsd_vi_sus_intv =
3508 		cfg_get(psoc, CFG_QOS_WMM_UAPSD_VI_SUS_INTV);
3509 
3510 	wmm_params->ac_be.dir_ac_be =
3511 		cfg_get(psoc, CFG_QOS_WMM_DIR_AC_BE);
3512 	wmm_params->ac_be.nom_msdu_size_ac_be =
3513 		cfg_get(psoc, CFG_QOS_WMM_NOM_MSDU_SIZE_AC_BE);
3514 	wmm_params->ac_be.mean_data_rate_ac_be =
3515 		cfg_get(psoc, CFG_QOS_WMM_MEAN_DATA_RATE_AC_BE);
3516 	wmm_params->ac_be.min_phy_rate_ac_be =
3517 		cfg_get(psoc, CFG_QOS_WMM_MIN_PHY_RATE_AC_BE);
3518 	wmm_params->ac_be.sba_ac_be =
3519 		cfg_get(psoc, CFG_QOS_WMM_SBA_AC_BE);
3520 	wmm_params->ac_be.uapsd_be_srv_intv =
3521 		cfg_get(psoc, CFG_QOS_WMM_UAPSD_BE_SRV_INTV);
3522 	wmm_params->ac_be.uapsd_be_sus_intv =
3523 		cfg_get(psoc, CFG_QOS_WMM_UAPSD_BE_SUS_INTV);
3524 
3525 	wmm_params->ac_bk.dir_ac_bk =
3526 		cfg_get(psoc, CFG_QOS_WMM_DIR_AC_BK);
3527 	wmm_params->ac_bk.nom_msdu_size_ac_bk =
3528 		cfg_get(psoc, CFG_QOS_WMM_NOM_MSDU_SIZE_AC_BK);
3529 	wmm_params->ac_bk.mean_data_rate_ac_bk =
3530 		cfg_get(psoc, CFG_QOS_WMM_MEAN_DATA_RATE_AC_BK);
3531 	wmm_params->ac_bk.min_phy_rate_ac_bk =
3532 		cfg_get(psoc, CFG_QOS_WMM_MIN_PHY_RATE_AC_BK);
3533 	wmm_params->ac_bk.sba_ac_bk =
3534 		cfg_get(psoc, CFG_QOS_WMM_SBA_AC_BK);
3535 	wmm_params->ac_bk.uapsd_bk_srv_intv =
3536 		cfg_get(psoc, CFG_QOS_WMM_UAPSD_BK_SRV_INTV);
3537 	wmm_params->ac_bk.uapsd_bk_sus_intv =
3538 		cfg_get(psoc, CFG_QOS_WMM_UAPSD_BK_SUS_INTV);
3539 
3540 	wmm_params->wmm_config.wmm_mode =
3541 		cfg_get(psoc, CFG_QOS_WMM_MODE);
3542 	wmm_params->wmm_config.b80211e_is_enabled =
3543 		cfg_get(psoc, CFG_QOS_WMM_80211E_ENABLED);
3544 	wmm_params->wmm_config.uapsd_mask =
3545 		cfg_get(psoc, CFG_QOS_WMM_UAPSD_MASK);
3546 
3547 	mlme_init_inactivity_intv(psoc, wmm_params);
3548 	wmm_params->wmm_tspec_element.burst_size_def =
3549 		cfg_get(psoc, CFG_QOS_WMM_BURST_SIZE_DEFN);
3550 	wmm_params->wmm_tspec_element.ts_ack_policy =
3551 		cfg_get(psoc, CFG_QOS_WMM_TS_INFO_ACK_POLICY);
3552 	wmm_params->wmm_tspec_element.ts_acm_is_off =
3553 		cfg_get(psoc, CFG_QOS_ADDTS_WHEN_ACM_IS_OFF);
3554 	wmm_params->delayed_trigger_frm_int =
3555 		cfg_get(psoc, CFG_TL_DELAYED_TRGR_FRM_INTERVAL);
3556 
3557 }
3558 
mlme_init_wps_params_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_wps_params * wps_params)3559 static void mlme_init_wps_params_cfg(struct wlan_objmgr_psoc *psoc,
3560 				     struct wlan_mlme_wps_params *wps_params)
3561 {
3562 	wps_params->enable_wps = cfg_default(CFG_WPS_ENABLE);
3563 	wps_params->wps_cfg_method = cfg_default(CFG_WPS_CFG_METHOD);
3564 	wps_params->wps_device_password_id =
3565 				cfg_default(CFG_WPS_DEVICE_PASSWORD_ID);
3566 	wps_params->wps_device_sub_category =
3567 				cfg_default(CFG_WPS_DEVICE_SUB_CATEGORY);
3568 	wps_params->wps_primary_device_category =
3569 				cfg_default(CFG_WPS_PRIMARY_DEVICE_CATEGORY);
3570 	wps_params->wps_primary_device_oui =
3571 				cfg_default(CFG_WPS_PIMARY_DEVICE_OUI);
3572 	wps_params->wps_state = cfg_default(CFG_WPS_STATE);
3573 	wps_params->wps_version = cfg_default(CFG_WPS_VERSION);
3574 	wps_params->wps_uuid.max_len = MLME_CFG_WPS_UUID_MAX_LEN;
3575 	qdf_uint8_array_parse(cfg_default(CFG_WPS_UUID),
3576 			      wps_params->wps_uuid.data,
3577 			      MLME_CFG_WPS_UUID_MAX_LEN,
3578 			      &wps_params->wps_uuid.len);
3579 }
3580 
mlme_init_btm_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_btm * btm)3581 static void mlme_init_btm_cfg(struct wlan_objmgr_psoc *psoc,
3582 			      struct wlan_mlme_btm *btm)
3583 {
3584 	btm->btm_offload_config = cfg_get(psoc, CFG_BTM_ENABLE);
3585 	btm->prefer_btm_query = cfg_get(psoc, CFG_PREFER_BTM_QUERY);
3586 	if (btm->prefer_btm_query)
3587 		MLME_SET_BIT(btm->btm_offload_config, BTM_OFFLOAD_CONFIG_BIT_8);
3588 
3589 	btm->abridge_flag = cfg_get(psoc, CFG_ENABLE_BTM_ABRIDGE);
3590 	if (btm->abridge_flag)
3591 		MLME_SET_BIT(btm->btm_offload_config, BTM_OFFLOAD_CONFIG_BIT_7);
3592 	wlan_mlme_set_btm_abridge_flag(psoc, btm->abridge_flag);
3593 
3594 	btm->btm_solicited_timeout = cfg_get(psoc, CFG_BTM_SOLICITED_TIMEOUT);
3595 	btm->btm_max_attempt_cnt = cfg_get(psoc, CFG_BTM_MAX_ATTEMPT_CNT);
3596 	btm->btm_sticky_time = cfg_get(psoc, CFG_BTM_STICKY_TIME);
3597 	btm->rct_validity_timer = cfg_get(psoc, CFG_BTM_VALIDITY_TIMER);
3598 	btm->disassoc_timer_threshold =
3599 			cfg_get(psoc, CFG_BTM_DISASSOC_TIMER_THRESHOLD);
3600 	btm->btm_query_bitmask = cfg_get(psoc, CFG_BTM_QUERY_BITMASK);
3601 	btm->btm_trig_min_candidate_score =
3602 			cfg_get(psoc, CFG_MIN_BTM_CANDIDATE_SCORE);
3603 }
3604 
3605 static void
mlme_init_roam_score_config(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_cfg * mlme_cfg)3606 mlme_init_roam_score_config(struct wlan_objmgr_psoc *psoc,
3607 			    struct wlan_mlme_cfg *mlme_cfg)
3608 {
3609 	struct roam_trigger_score_delta *score_delta_param;
3610 	struct roam_trigger_min_rssi *min_rssi_param;
3611 
3612 	score_delta_param = &mlme_cfg->trig_score_delta[IDLE_ROAM_TRIGGER];
3613 	score_delta_param->roam_score_delta =
3614 			cfg_get(psoc, CFG_IDLE_ROAM_SCORE_DELTA);
3615 	score_delta_param->trigger_reason = ROAM_TRIGGER_REASON_IDLE;
3616 
3617 	score_delta_param = &mlme_cfg->trig_score_delta[BTM_ROAM_TRIGGER];
3618 	score_delta_param->roam_score_delta =
3619 			cfg_get(psoc, CFG_BTM_ROAM_SCORE_DELTA);
3620 	score_delta_param->trigger_reason = ROAM_TRIGGER_REASON_BTM;
3621 
3622 	min_rssi_param = &mlme_cfg->trig_min_rssi[DEAUTH_MIN_RSSI];
3623 	min_rssi_param->min_rssi =
3624 		cfg_get(psoc, CFG_DISCONNECT_ROAM_TRIGGER_MIN_RSSI);
3625 	min_rssi_param->trigger_reason = ROAM_TRIGGER_REASON_DEAUTH;
3626 
3627 	min_rssi_param = &mlme_cfg->trig_min_rssi[BMISS_MIN_RSSI];
3628 	min_rssi_param->min_rssi =
3629 		cfg_get(psoc, CFG_BMISS_ROAM_MIN_RSSI);
3630 	min_rssi_param->trigger_reason = ROAM_TRIGGER_REASON_BMISS;
3631 
3632 	min_rssi_param = &mlme_cfg->trig_min_rssi[MIN_RSSI_2G_TO_5G_ROAM];
3633 	min_rssi_param->min_rssi =
3634 		cfg_get(psoc, CFG_2G_TO_5G_ROAM_MIN_RSSI);
3635 	min_rssi_param->trigger_reason = ROAM_TRIGGER_REASON_HIGH_RSSI;
3636 
3637 }
3638 
3639 #ifdef MULTI_CLIENT_LL_SUPPORT
3640 static void
mlme_init_wlm_multi_client_ll_support(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_fe_wlm * wlm_config)3641 mlme_init_wlm_multi_client_ll_support(struct wlan_objmgr_psoc *psoc,
3642 				      struct wlan_mlme_fe_wlm *wlm_config)
3643 {
3644 	wlm_config->multi_client_ll_support =
3645 			cfg_get(psoc, CFG_WLM_MULTI_CLIENT_LL_SUPPORT);
3646 }
3647 
3648 QDF_STATUS
mlme_get_cfg_multi_client_ll_ini_support(struct wlan_objmgr_psoc * psoc,bool * multi_client_ll_support)3649 mlme_get_cfg_multi_client_ll_ini_support(struct wlan_objmgr_psoc *psoc,
3650 					 bool *multi_client_ll_support)
3651 {
3652 	struct wlan_mlme_psoc_ext_obj *mlme_obj;
3653 
3654 	mlme_obj = mlme_get_psoc_ext_obj(psoc);
3655 	if (!mlme_obj)
3656 		return QDF_STATUS_E_FAILURE;
3657 
3658 	*multi_client_ll_support =
3659 			mlme_obj->cfg.wlm_config.multi_client_ll_support;
3660 
3661 	return QDF_STATUS_SUCCESS;
3662 }
3663 #else
3664 static inline void
mlme_init_wlm_multi_client_ll_support(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_fe_wlm * wlm_config)3665 mlme_init_wlm_multi_client_ll_support(struct wlan_objmgr_psoc *psoc,
3666 				      struct wlan_mlme_fe_wlm *wlm_config)
3667 {
3668 }
3669 #endif
3670 
3671 /**
3672  * mlme_init_fe_wlm_in_cfg() - Populate WLM INI in MLME cfg
3673  * @psoc: pointer to the psoc object
3674  * @wlm_config: pointer to the MLME WLM cfg
3675  *
3676  * Return: None
3677  */
mlme_init_fe_wlm_in_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_fe_wlm * wlm_config)3678 static void mlme_init_fe_wlm_in_cfg(struct wlan_objmgr_psoc *psoc,
3679 				    struct wlan_mlme_fe_wlm *wlm_config)
3680 {
3681 	uint64_t flags = 0;
3682 	QDF_STATUS status;
3683 
3684 	wlm_config->latency_enable = cfg_get(psoc, CFG_LATENCY_ENABLE);
3685 	wlm_config->latency_reset = cfg_get(psoc, CFG_LATENCY_RESET);
3686 	wlm_config->latency_level = cfg_get(psoc, CFG_LATENCY_LEVEL);
3687 	mlme_init_wlm_multi_client_ll_support(psoc, wlm_config);
3688 
3689 	status = qdf_uint64_parse(cfg_get(psoc, CFG_LATENCY_FLAGS_NORMAL),
3690 				  &flags);
3691 	if (status != QDF_STATUS_SUCCESS) {
3692 		flags = 0;
3693 		mlme_legacy_err("normal latency flags parsing failed");
3694 	}
3695 
3696 	wlm_config->latency_flags[0] = flags & 0xFFFFFFFF;
3697 	wlm_config->latency_host_flags[0] = flags >> 32;
3698 	mlme_legacy_debug("normal latency flags 0x%x host flags 0x%x",
3699 			  wlm_config->latency_flags[0],
3700 			  wlm_config->latency_host_flags[0]);
3701 
3702 	status = qdf_uint64_parse(cfg_get(psoc, CFG_LATENCY_FLAGS_XR),
3703 				  &flags);
3704 	if (status != QDF_STATUS_SUCCESS) {
3705 		flags = 0;
3706 		mlme_legacy_err("xr latency flags parsing failed");
3707 	}
3708 
3709 	wlm_config->latency_flags[1] = flags & 0xFFFFFFFF;
3710 	wlm_config->latency_host_flags[1] = flags >> 32;
3711 	mlme_legacy_debug("xr latency flags 0x%x host flags 0x%x",
3712 			  wlm_config->latency_flags[1],
3713 			  wlm_config->latency_host_flags[1]);
3714 
3715 	status = qdf_uint64_parse(cfg_get(psoc, CFG_LATENCY_FLAGS_LOW),
3716 				  &flags);
3717 	if (status != QDF_STATUS_SUCCESS) {
3718 		flags = 0;
3719 		mlme_legacy_err("low latency flags parsing failed");
3720 	}
3721 
3722 	wlm_config->latency_flags[2] = flags & 0xFFFFFFFF;
3723 	wlm_config->latency_host_flags[2] = flags >> 32;
3724 	mlme_legacy_debug("low latency flags 0x%x host flags 0x%x",
3725 			  wlm_config->latency_flags[2],
3726 			  wlm_config->latency_host_flags[2]);
3727 
3728 	status = qdf_uint64_parse(cfg_get(psoc, CFG_LATENCY_FLAGS_ULTLOW),
3729 				  &flags);
3730 	if (status != QDF_STATUS_SUCCESS) {
3731 		flags = 0;
3732 		mlme_legacy_err("ultra-low latency flags parsing failed");
3733 	}
3734 
3735 	wlm_config->latency_flags[3] = flags & 0xFFFFFFFF;
3736 	wlm_config->latency_host_flags[3] = flags >> 32;
3737 	mlme_legacy_debug("ultra-low latency flags 0x%x host flags 0x%x",
3738 			  wlm_config->latency_flags[3],
3739 			  wlm_config->latency_host_flags[3]);
3740 }
3741 
3742 /**
3743  * mlme_init_fe_rrm_in_cfg() - Populate RRM INI in MLME cfg
3744  * @psoc: pointer to the psoc object
3745  * @rrm_config: pointer to the MLME RRM cfg
3746  *
3747  * Return: None
3748  */
mlme_init_fe_rrm_in_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_fe_rrm * rrm_config)3749 static void mlme_init_fe_rrm_in_cfg(struct wlan_objmgr_psoc *psoc,
3750 				    struct wlan_mlme_fe_rrm *rrm_config)
3751 {
3752 	qdf_size_t len;
3753 
3754 	rrm_config->rrm_enabled = cfg_get(psoc, CFG_RRM_ENABLE);
3755 	rrm_config->sap_rrm_enabled = cfg_get(psoc, CFG_SAP_RRM_ENABLE);
3756 	rrm_config->rrm_rand_interval = cfg_get(psoc, CFG_RRM_MEAS_RAND_INTVL);
3757 
3758 	qdf_uint8_array_parse(cfg_get(psoc, CFG_RM_CAPABILITY),
3759 			      rrm_config->rm_capability,
3760 			      sizeof(rrm_config->rm_capability), &len);
3761 
3762 	if (len < MLME_RMENABLEDCAP_MAX_LEN) {
3763 		mlme_legacy_debug("Incorrect RM capability, using default");
3764 		qdf_uint8_array_parse(cfg_default(CFG_RM_CAPABILITY),
3765 				      rrm_config->rm_capability,
3766 				      sizeof(rrm_config->rm_capability), &len);
3767 	}
3768 }
3769 
mlme_init_powersave_params(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_powersave * ps_cfg)3770 static void mlme_init_powersave_params(struct wlan_objmgr_psoc *psoc,
3771 				       struct wlan_mlme_powersave *ps_cfg)
3772 {
3773 	ps_cfg->is_imps_enabled = cfg_get(psoc, CFG_ENABLE_IMPS);
3774 	ps_cfg->is_bmps_enabled = cfg_get(psoc, CFG_ENABLE_PS);
3775 	ps_cfg->auto_bmps_timer_val = cfg_get(psoc, CFG_AUTO_BMPS_ENABLE_TIMER);
3776 	ps_cfg->bmps_min_listen_interval = cfg_get(psoc, CFG_BMPS_MINIMUM_LI);
3777 	ps_cfg->bmps_max_listen_interval = cfg_get(psoc, CFG_BMPS_MAXIMUM_LI);
3778 	ps_cfg->dtim_selection_diversity =
3779 				cfg_get(psoc, CFG_DTIM_SELECTION_DIVERSITY);
3780 }
3781 
3782 #if defined(CONFIG_AFC_SUPPORT) && defined(CONFIG_BAND_6GHZ)
mlme_init_afc_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_reg * reg)3783 static void mlme_init_afc_cfg(struct wlan_objmgr_psoc *psoc,
3784 			      struct wlan_mlme_reg *reg)
3785 {
3786 	reg->enable_6ghz_sp_pwrmode_supp =
3787 		cfg_get(psoc, CFG_6GHZ_SP_POWER_MODE_SUPP);
3788 	reg->afc_disable_timer_check =
3789 		cfg_default(CFG_AFC_TIMER_CHECK_DIS);
3790 	reg->afc_disable_request_id_check =
3791 		cfg_default(CFG_AFC_REQ_ID_CHECK_DIS);
3792 	reg->is_afc_reg_noaction =
3793 		cfg_default(CFG_AFC_REG_NO_ACTION);
3794 }
3795 #else
mlme_init_afc_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_reg * reg)3796 static inline void mlme_init_afc_cfg(struct wlan_objmgr_psoc *psoc,
3797 				     struct wlan_mlme_reg *reg)
3798 {
3799 }
3800 #endif
3801 
3802 #ifdef MWS_COEX
mlme_init_mwc_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_mwc * mwc)3803 static void mlme_init_mwc_cfg(struct wlan_objmgr_psoc *psoc,
3804 			      struct wlan_mlme_mwc *mwc)
3805 {
3806 	mwc->mws_coex_4g_quick_tdm =
3807 		cfg_get(psoc, CFG_MWS_COEX_4G_QUICK_FTDM);
3808 	mwc->mws_coex_5g_nr_pwr_limit =
3809 		cfg_get(psoc, CFG_MWS_COEX_5G_NR_PWR_LIMIT);
3810 	mwc->mws_coex_pcc_channel_avoid_delay =
3811 		cfg_get(psoc, CFG_MWS_COEX_PCC_CHANNEL_AVOID_DELAY);
3812 	mwc->mws_coex_scc_channel_avoid_delay =
3813 		cfg_get(psoc, CFG_MWS_COEX_SCC_CHANNEL_AVOID_DELAY);
3814 }
3815 #else
mlme_init_mwc_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_mwc * mwc)3816 static void mlme_init_mwc_cfg(struct wlan_objmgr_psoc *psoc,
3817 			      struct wlan_mlme_mwc *mwc)
3818 {
3819 }
3820 #endif
3821 
3822 #ifdef SAP_AVOID_ACS_FREQ_LIST
mlme_init_acs_avoid_freq_list(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_reg * reg)3823 static void mlme_init_acs_avoid_freq_list(struct wlan_objmgr_psoc *psoc,
3824 					  struct wlan_mlme_reg *reg)
3825 {
3826 	qdf_size_t avoid_acs_freq_list_num = 0;
3827 	uint8_t i;
3828 
3829 	qdf_uint16_array_parse(cfg_get(psoc, CFG_SAP_AVOID_ACS_FREQ_LIST),
3830 			       reg->avoid_acs_freq_list,
3831 			       CFG_VALID_CHANNEL_LIST_LEN,
3832 			       &avoid_acs_freq_list_num);
3833 	reg->avoid_acs_freq_list_num = avoid_acs_freq_list_num;
3834 
3835 	for (i = 0; i < avoid_acs_freq_list_num; i++)
3836 		mlme_legacy_debug("avoid_acs_freq %d",
3837 				  reg->avoid_acs_freq_list[i]);
3838 }
3839 #else
mlme_init_acs_avoid_freq_list(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_reg * reg)3840 static void mlme_init_acs_avoid_freq_list(struct wlan_objmgr_psoc *psoc,
3841 					  struct wlan_mlme_reg *reg)
3842 {
3843 }
3844 #endif
3845 
3846 #ifdef FEATURE_WLAN_CH_AVOID_EXT
mlme_init_coex_unsafe_chan_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_reg * reg)3847 static void mlme_init_coex_unsafe_chan_cfg(struct wlan_objmgr_psoc *psoc,
3848 					   struct wlan_mlme_reg *reg)
3849 {
3850 	reg->coex_unsafe_chan_nb_user_prefer =
3851 		cfg_get(psoc, CFG_COEX_UNSAFE_CHAN_NB_USER_PREFER);
3852 }
3853 
mlme_init_coex_unsafe_chan_reg_disable_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_reg * reg)3854 static void mlme_init_coex_unsafe_chan_reg_disable_cfg(
3855 		struct wlan_objmgr_psoc *psoc, struct wlan_mlme_reg *reg)
3856 {
3857 	reg->coex_unsafe_chan_reg_disable =
3858 		cfg_get(psoc, CFG_COEX_UNSAFE_CHAN_REG_DISABLE);
3859 }
3860 #else
mlme_init_coex_unsafe_chan_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_reg * reg)3861 static void mlme_init_coex_unsafe_chan_cfg(struct wlan_objmgr_psoc *psoc,
3862 					   struct wlan_mlme_reg *reg)
3863 {
3864 }
3865 
mlme_init_coex_unsafe_chan_reg_disable_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_reg * reg)3866 static void mlme_init_coex_unsafe_chan_reg_disable_cfg(
3867 		struct wlan_objmgr_psoc *psoc, struct wlan_mlme_reg *reg)
3868 {
3869 }
3870 #endif
3871 
mlme_init_reg_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_reg * reg)3872 static void mlme_init_reg_cfg(struct wlan_objmgr_psoc *psoc,
3873 			      struct wlan_mlme_reg *reg)
3874 {
3875 	reg->self_gen_frm_pwr = cfg_get(psoc, CFG_SELF_GEN_FRM_PWR);
3876 	reg->etsi_srd_chan_in_master_mode =
3877 			cfg_get(psoc, CFG_ETSI_SRD_CHAN_IN_MASTER_MODE);
3878 	reg->fcc_5dot9_ghz_chan_in_master_mode =
3879 			cfg_get(psoc, CFG_FCC_5DOT9_GHZ_CHAN_IN_MASTER_MODE);
3880 	reg->restart_beaconing_on_ch_avoid =
3881 			cfg_get(psoc, CFG_RESTART_BEACONING_ON_CH_AVOID);
3882 	reg->indoor_channel_support = cfg_get(psoc, CFG_INDOOR_CHANNEL_SUPPORT);
3883 	reg->enable_11d_in_world_mode = cfg_get(psoc,
3884 						CFG_ENABLE_11D_IN_WORLD_MODE);
3885 	reg->scan_11d_interval = cfg_get(psoc, CFG_SCAN_11D_INTERVAL);
3886 	reg->enable_pending_chan_list_req = cfg_get(psoc,
3887 					CFG_ENABLE_PENDING_CHAN_LIST_REQ);
3888 	reg->ignore_fw_reg_offload_ind = cfg_get(
3889 						psoc,
3890 						CFG_IGNORE_FW_REG_OFFLOAD_IND);
3891 	reg->retain_nol_across_regdmn_update =
3892 		cfg_get(psoc, CFG_RETAIN_NOL_ACROSS_REG_DOMAIN);
3893 
3894 	reg->enable_nan_on_indoor_channels =
3895 		cfg_get(psoc, CFG_INDOOR_CHANNEL_SUPPORT_FOR_NAN);
3896 
3897 	mlme_init_afc_cfg(psoc, reg);
3898 	mlme_init_acs_avoid_freq_list(psoc, reg);
3899 	mlme_init_coex_unsafe_chan_cfg(psoc, reg);
3900 	mlme_init_coex_unsafe_chan_reg_disable_cfg(psoc, reg);
3901 }
3902 
3903 static void
mlme_init_dot11_mode_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_dot11_mode * dot11_mode)3904 mlme_init_dot11_mode_cfg(struct wlan_objmgr_psoc *psoc,
3905 			 struct wlan_mlme_dot11_mode *dot11_mode)
3906 {
3907 	dot11_mode->dot11_mode = cfg_default(CFG_DOT11_MODE);
3908 	dot11_mode->vdev_type_dot11_mode = cfg_get(psoc, CFG_VDEV_DOT11_MODE);
3909 }
3910 
3911 /**
3912  * mlme_iot_parse_aggr_info - parse aggr related items in ini
3913  * @psoc: PSOC pointer
3914  * @iot: IOT related CFG items
3915  *
3916  * Return: None
3917  */
3918 static void
mlme_iot_parse_aggr_info(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_iot * iot)3919 mlme_iot_parse_aggr_info(struct wlan_objmgr_psoc *psoc,
3920 			 struct wlan_mlme_iot *iot)
3921 {
3922 	char *aggr_info, *oui, *msdu, *mpdu, *aggr_info_temp;
3923 	uint32_t ampdu_sz, amsdu_sz, index = 0, oui_len, cfg_str_len;
3924 	struct wlan_iot_aggr *aggr_info_list;
3925 	const char *cfg_str;
3926 	int ret;
3927 
3928 	cfg_str = cfg_get(psoc, CFG_TX_IOT_AGGR);
3929 	if (!cfg_str)
3930 		return;
3931 
3932 	cfg_str_len = qdf_str_len(cfg_str);
3933 	if (!cfg_str_len)
3934 		return;
3935 
3936 	aggr_info = qdf_mem_malloc(cfg_str_len + 1);
3937 	if (!aggr_info)
3938 		return;
3939 
3940 	aggr_info_list = iot->aggr;
3941 	qdf_mem_copy(aggr_info, cfg_str, cfg_str_len);
3942 	mlme_legacy_debug("aggr_info=[%s]", aggr_info);
3943 
3944 	aggr_info_temp = aggr_info;
3945 	while (aggr_info_temp) {
3946 		/* skip possible spaces before oui string */
3947 		while (*aggr_info_temp == ' ')
3948 			aggr_info_temp++;
3949 
3950 		oui = strsep(&aggr_info_temp, ",");
3951 		if (!oui) {
3952 			mlme_legacy_err("oui error");
3953 			goto end;
3954 		}
3955 
3956 		oui_len = qdf_str_len(oui) / 2;
3957 		if (oui_len > sizeof(aggr_info_list[index].oui)) {
3958 			mlme_legacy_err("size error");
3959 			goto end;
3960 		}
3961 
3962 		amsdu_sz = 0;
3963 		msdu = strsep(&aggr_info_temp, ",");
3964 		if (!msdu) {
3965 			mlme_legacy_err("msdu error");
3966 			goto end;
3967 		}
3968 
3969 		ret = kstrtou32(msdu, 10, &amsdu_sz);
3970 		if (ret || amsdu_sz > IOT_AGGR_MSDU_MAX_NUM) {
3971 			mlme_legacy_err("invalid msdu no. %s [%u]",
3972 					msdu, amsdu_sz);
3973 			goto end;
3974 		}
3975 
3976 		ampdu_sz = 0;
3977 		mpdu = strsep(&aggr_info_temp, ",");
3978 		if (!mpdu) {
3979 			mlme_legacy_err("mpdu error");
3980 			goto end;
3981 		}
3982 
3983 		ret = kstrtou32(mpdu, 10, &ampdu_sz);
3984 		if (ret || ampdu_sz > IOT_AGGR_MPDU_MAX_NUM) {
3985 			mlme_legacy_err("invalid mpdu no. %s [%u]",
3986 					mpdu, ampdu_sz);
3987 			goto end;
3988 		}
3989 
3990 		mlme_legacy_debug("id %u oui[%s] len %u msdu %u mpdu %u",
3991 				  index, oui, oui_len, amsdu_sz, ampdu_sz);
3992 
3993 		ret = qdf_hex_str_to_binary(aggr_info_list[index].oui,
3994 					    oui, oui_len);
3995 		if (ret) {
3996 			mlme_legacy_err("oui error: %d", ret);
3997 			goto end;
3998 		}
3999 
4000 		aggr_info_list[index].amsdu_sz = amsdu_sz;
4001 		aggr_info_list[index].ampdu_sz = ampdu_sz;
4002 		aggr_info_list[index].oui_len = oui_len;
4003 		index++;
4004 		if (index >= IOT_AGGR_INFO_MAX_NUM) {
4005 			mlme_legacy_err("exceed max num, index = %d", index);
4006 			break;
4007 		}
4008 	}
4009 	iot->aggr_num = index;
4010 
4011 end:
4012 	mlme_legacy_debug("configured aggr num %d", iot->aggr_num);
4013 	qdf_mem_free(aggr_info);
4014 }
4015 
4016 /**
4017  * mlme_init_iot_cfg() - parse IOT related items in ini
4018  * @psoc: PSOC pointer
4019  * @iot: IOT related CFG items
4020  *
4021  * Return: None
4022  */
4023 static void
mlme_init_iot_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_mlme_iot * iot)4024 mlme_init_iot_cfg(struct wlan_objmgr_psoc *psoc,
4025 		  struct wlan_mlme_iot *iot)
4026 {
4027 	mlme_iot_parse_aggr_info(psoc, iot);
4028 }
4029 
4030 /**
4031  * mlme_init_dual_sta_config - Initialize dual sta configurations
4032  * @gen: Generic CFG config items
4033  *
4034  * Return: None
4035  */
4036 static void
mlme_init_dual_sta_config(struct wlan_mlme_generic * gen)4037 mlme_init_dual_sta_config(struct wlan_mlme_generic *gen)
4038 {
4039 	gen->dual_sta_policy.primary_vdev_id = WLAN_UMAC_VDEV_ID_MAX;
4040 	gen->dual_sta_policy.concurrent_sta_policy =
4041 				QCA_WLAN_CONCURRENT_STA_POLICY_UNBIASED;
4042 }
4043 
4044 #ifdef WLAN_FEATURE_MCC_QUOTA
4045 /**
4046  * mlme_init_user_mcc_quota_config - Initialize mcc quota
4047  * @gen: Generic CFG config items
4048  *
4049  * Return: None
4050  */
4051 static void
mlme_init_user_mcc_quota_config(struct wlan_mlme_generic * gen)4052 mlme_init_user_mcc_quota_config(struct wlan_mlme_generic *gen)
4053 {
4054 	gen->user_mcc_quota.quota = 0;
4055 	gen->user_mcc_quota.op_mode = QDF_MAX_NO_OF_MODE;
4056 	gen->user_mcc_quota.vdev_id = WLAN_UMAC_VDEV_ID_MAX;
4057 }
4058 #else
4059 static void
mlme_init_user_mcc_quota_config(struct wlan_mlme_generic * gen)4060 mlme_init_user_mcc_quota_config(struct wlan_mlme_generic *gen)
4061 {
4062 }
4063 #endif
mlme_cfg_on_psoc_enable(struct wlan_objmgr_psoc * psoc)4064 QDF_STATUS mlme_cfg_on_psoc_enable(struct wlan_objmgr_psoc *psoc)
4065 {
4066 	struct wlan_mlme_psoc_ext_obj *mlme_obj;
4067 	struct wlan_mlme_cfg *mlme_cfg;
4068 	QDF_STATUS status = QDF_STATUS_SUCCESS;
4069 
4070 	mlme_obj = mlme_get_psoc_ext_obj(psoc);
4071 	if (!mlme_obj) {
4072 		mlme_legacy_err("Failed to get MLME Obj");
4073 		return QDF_STATUS_E_FAILURE;
4074 	}
4075 
4076 	mlme_cfg = &mlme_obj->cfg;
4077 	mlme_init_generic_cfg(psoc, &mlme_cfg->gen);
4078 	mlme_init_timeout_cfg(psoc, &mlme_cfg->timeouts);
4079 	mlme_init_edca_params(psoc, &mlme_cfg->edca_params);
4080 	mlme_init_ht_cap_in_cfg(psoc, &mlme_cfg->ht_caps);
4081 	mlme_init_wmm_in_cfg(psoc, &mlme_cfg->wmm_params);
4082 	mlme_init_mbo_cfg(psoc, &mlme_cfg->mbo_cfg);
4083 	mlme_init_qos_cfg(psoc, &mlme_cfg->qos_mlme_params);
4084 	mlme_init_rates_in_cfg(psoc, &mlme_cfg->rates);
4085 	mlme_init_dfs_cfg(psoc, &mlme_cfg->dfs_cfg);
4086 	mlme_init_sap_protection_cfg(psoc, &mlme_cfg->sap_protection_cfg);
4087 	mlme_init_vht_cap_cfg(psoc, &mlme_cfg->vht_caps.vht_cap_info);
4088 	mlme_init_chainmask_cfg(psoc, &mlme_cfg->chainmask_cfg);
4089 	mlme_init_sap_cfg(psoc, &mlme_cfg->sap_cfg);
4090 	mlme_init_nss_chains(psoc, &mlme_cfg->nss_chains_ini_cfg);
4091 	mlme_init_twt_cfg(psoc, &mlme_cfg->twt_cfg);
4092 	mlme_init_he_cap_in_cfg(psoc, mlme_cfg);
4093 	mlme_init_eht_cap_in_cfg(psoc, mlme_cfg);
4094 	mlme_init_obss_ht40_cfg(psoc, &mlme_cfg->obss_ht40);
4095 	mlme_init_product_details_cfg(&mlme_cfg->product_details);
4096 	mlme_init_powersave_params(psoc, &mlme_cfg->ps_params);
4097 	mlme_init_sta_cfg(psoc, &mlme_cfg->sta);
4098 	mlme_init_stats_cfg(psoc, &mlme_cfg->stats);
4099 	mlme_init_lfr_cfg(psoc, &mlme_cfg->lfr);
4100 	mlme_init_feature_flag_in_cfg(psoc, &mlme_cfg->feature_flags);
4101 	mlme_init_roam_scoring_cfg(psoc, &mlme_cfg->roam_scoring);
4102 	mlme_init_dot11_mode_cfg(psoc, &mlme_cfg->dot11_mode);
4103 	mlme_init_threshold_cfg(psoc, &mlme_cfg->threshold);
4104 	mlme_init_acs_cfg(psoc, &mlme_cfg->acs);
4105 	mlme_init_power_cfg(psoc, &mlme_cfg->power);
4106 	mlme_init_oce_cfg(psoc, &mlme_cfg->oce);
4107 	mlme_init_wep_cfg(&mlme_cfg->wep_params);
4108 	mlme_init_wifi_pos_cfg(psoc, &mlme_cfg->wifi_pos_cfg);
4109 	mlme_init_wps_params_cfg(psoc, &mlme_cfg->wps_params);
4110 	mlme_init_fe_wlm_in_cfg(psoc, &mlme_cfg->wlm_config);
4111 	mlme_init_fe_rrm_in_cfg(psoc, &mlme_cfg->rrm_config);
4112 	mlme_init_mwc_cfg(psoc, &mlme_cfg->mwc);
4113 	mlme_init_reg_cfg(psoc, &mlme_cfg->reg);
4114 	mlme_init_btm_cfg(psoc, &mlme_cfg->btm);
4115 	mlme_init_roam_score_config(psoc, mlme_cfg);
4116 	mlme_init_ratemask_cfg(psoc, &mlme_cfg->ratemask_cfg);
4117 	mlme_init_iot_cfg(psoc, &mlme_cfg->iot);
4118 	mlme_init_dual_sta_config(&mlme_cfg->gen);
4119 	mlme_init_user_mcc_quota_config(&mlme_cfg->gen);
4120 
4121 	return status;
4122 }
4123 
mlme_get_sae_auth_retry(struct wlan_objmgr_vdev * vdev)4124 struct sae_auth_retry *mlme_get_sae_auth_retry(struct wlan_objmgr_vdev *vdev)
4125 {
4126 	struct mlme_legacy_priv *mlme_priv;
4127 
4128 	mlme_priv = wlan_vdev_mlme_get_ext_hdl(vdev);
4129 	if (!mlme_priv) {
4130 		mlme_legacy_err("vdev legacy private object is NULL");
4131 		return NULL;
4132 	}
4133 
4134 	return &mlme_priv->sae_retry;
4135 }
4136 
mlme_free_sae_auth_retry(struct wlan_objmgr_vdev * vdev)4137 void mlme_free_sae_auth_retry(struct wlan_objmgr_vdev *vdev)
4138 {
4139 	struct mlme_legacy_priv *mlme_priv;
4140 
4141 	mlme_priv = wlan_vdev_mlme_get_ext_hdl(vdev);
4142 	if (!mlme_priv) {
4143 		mlme_legacy_err("vdev legacy private object is NULL");
4144 		return;
4145 	}
4146 
4147 	mlme_priv->sae_retry.sae_auth_max_retry = 0;
4148 	if (mlme_priv->sae_retry.sae_auth.ptr)
4149 		qdf_mem_free(mlme_priv->sae_retry.sae_auth.ptr);
4150 	mlme_priv->sae_retry.sae_auth.ptr = NULL;
4151 	mlme_priv->sae_retry.sae_auth.len = 0;
4152 }
4153 
mlme_set_self_disconnect_ies(struct wlan_objmgr_vdev * vdev,struct element_info * ie)4154 void mlme_set_self_disconnect_ies(struct wlan_objmgr_vdev *vdev,
4155 				  struct element_info *ie)
4156 {
4157 	struct mlme_legacy_priv *mlme_priv;
4158 
4159 	if (!ie || !ie->len || !ie->ptr) {
4160 		mlme_legacy_debug("disocnnect IEs are NULL");
4161 		return;
4162 	}
4163 
4164 	mlme_priv = wlan_vdev_mlme_get_ext_hdl(vdev);
4165 	if (!mlme_priv) {
4166 		mlme_legacy_err("vdev legacy private object is NULL");
4167 		return;
4168 	}
4169 
4170 	if (mlme_priv->disconnect_info.self_discon_ies.ptr) {
4171 		qdf_mem_free(mlme_priv->disconnect_info.self_discon_ies.ptr);
4172 		mlme_priv->disconnect_info.self_discon_ies.len = 0;
4173 	}
4174 
4175 	mlme_priv->disconnect_info.self_discon_ies.ptr =
4176 				qdf_mem_malloc(ie->len);
4177 	if (!mlme_priv->disconnect_info.self_discon_ies.ptr)
4178 		return;
4179 
4180 	qdf_mem_copy(mlme_priv->disconnect_info.self_discon_ies.ptr,
4181 		     ie->ptr, ie->len);
4182 	mlme_priv->disconnect_info.self_discon_ies.len = ie->len;
4183 
4184 	mlme_legacy_debug("Self disconnect IEs");
4185 	QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_MLME, QDF_TRACE_LEVEL_DEBUG,
4186 			   mlme_priv->disconnect_info.self_discon_ies.ptr,
4187 			   mlme_priv->disconnect_info.self_discon_ies.len);
4188 }
4189 
mlme_free_self_disconnect_ies(struct wlan_objmgr_vdev * vdev)4190 void mlme_free_self_disconnect_ies(struct wlan_objmgr_vdev *vdev)
4191 {
4192 	struct mlme_legacy_priv *mlme_priv;
4193 
4194 	mlme_priv = wlan_vdev_mlme_get_ext_hdl(vdev);
4195 	if (!mlme_priv) {
4196 		mlme_legacy_err("vdev legacy private object is NULL");
4197 		return;
4198 	}
4199 
4200 	if (mlme_priv->disconnect_info.self_discon_ies.ptr) {
4201 		qdf_mem_free(mlme_priv->disconnect_info.self_discon_ies.ptr);
4202 		mlme_priv->disconnect_info.self_discon_ies.ptr = NULL;
4203 		mlme_priv->disconnect_info.self_discon_ies.len = 0;
4204 	}
4205 }
4206 
mlme_get_self_disconnect_ies(struct wlan_objmgr_vdev * vdev)4207 struct element_info *mlme_get_self_disconnect_ies(struct wlan_objmgr_vdev *vdev)
4208 {
4209 	struct mlme_legacy_priv *mlme_priv;
4210 
4211 	mlme_priv = wlan_vdev_mlme_get_ext_hdl(vdev);
4212 	if (!mlme_priv) {
4213 		mlme_legacy_err("vdev legacy private object is NULL");
4214 		return NULL;
4215 	}
4216 
4217 	return &mlme_priv->disconnect_info.self_discon_ies;
4218 }
4219 
mlme_set_peer_disconnect_ies(struct wlan_objmgr_vdev * vdev,struct element_info * ie)4220 void mlme_set_peer_disconnect_ies(struct wlan_objmgr_vdev *vdev,
4221 				  struct element_info *ie)
4222 {
4223 	struct mlme_legacy_priv *mlme_priv;
4224 
4225 	if (!ie || !ie->len || !ie->ptr) {
4226 		mlme_legacy_debug("disocnnect IEs are NULL");
4227 		return;
4228 	}
4229 
4230 	mlme_priv = wlan_vdev_mlme_get_ext_hdl(vdev);
4231 	if (!mlme_priv) {
4232 		mlme_legacy_err("vdev legacy private object is NULL");
4233 		return;
4234 	}
4235 
4236 	if (mlme_priv->disconnect_info.peer_discon_ies.ptr) {
4237 		qdf_mem_free(mlme_priv->disconnect_info.peer_discon_ies.ptr);
4238 		mlme_priv->disconnect_info.peer_discon_ies.len = 0;
4239 	}
4240 
4241 	mlme_priv->disconnect_info.peer_discon_ies.ptr =
4242 					qdf_mem_malloc(ie->len);
4243 	if (!mlme_priv->disconnect_info.peer_discon_ies.ptr)
4244 		return;
4245 
4246 	qdf_mem_copy(mlme_priv->disconnect_info.peer_discon_ies.ptr,
4247 		     ie->ptr, ie->len);
4248 	mlme_priv->disconnect_info.peer_discon_ies.len = ie->len;
4249 
4250 	mlme_legacy_debug("peer disconnect IEs");
4251 	QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_MLME, QDF_TRACE_LEVEL_DEBUG,
4252 			   mlme_priv->disconnect_info.peer_discon_ies.ptr,
4253 			   mlme_priv->disconnect_info.peer_discon_ies.len);
4254 }
4255 
mlme_free_peer_disconnect_ies(struct wlan_objmgr_vdev * vdev)4256 void mlme_free_peer_disconnect_ies(struct wlan_objmgr_vdev *vdev)
4257 {
4258 	struct mlme_legacy_priv *mlme_priv;
4259 
4260 	mlme_priv = wlan_vdev_mlme_get_ext_hdl(vdev);
4261 	if (!mlme_priv) {
4262 		mlme_legacy_err("vdev legacy private object is NULL");
4263 		return;
4264 	}
4265 
4266 	if (mlme_priv->disconnect_info.peer_discon_ies.ptr) {
4267 		qdf_mem_free(mlme_priv->disconnect_info.peer_discon_ies.ptr);
4268 		mlme_priv->disconnect_info.peer_discon_ies.ptr = NULL;
4269 		mlme_priv->disconnect_info.peer_discon_ies.len = 0;
4270 	}
4271 }
4272 
mlme_get_peer_disconnect_ies(struct wlan_objmgr_vdev * vdev)4273 struct element_info *mlme_get_peer_disconnect_ies(struct wlan_objmgr_vdev *vdev)
4274 {
4275 	struct mlme_legacy_priv *mlme_priv;
4276 
4277 	mlme_priv = wlan_vdev_mlme_get_ext_hdl(vdev);
4278 	if (!mlme_priv) {
4279 		mlme_legacy_err("vdev legacy private object is NULL");
4280 		return NULL;
4281 	}
4282 
4283 	return &mlme_priv->disconnect_info.peer_discon_ies;
4284 }
4285 
mlme_free_peer_assoc_rsp_ie(struct peer_mlme_priv_obj * peer_priv)4286 void mlme_free_peer_assoc_rsp_ie(struct peer_mlme_priv_obj *peer_priv)
4287 {
4288 	if (!peer_priv) {
4289 		mlme_legacy_debug("peer priv is NULL");
4290 		return;
4291 	}
4292 
4293 	if (peer_priv->assoc_rsp.ptr) {
4294 		qdf_mem_free(peer_priv->assoc_rsp.ptr);
4295 		peer_priv->assoc_rsp.ptr = NULL;
4296 		peer_priv->assoc_rsp.len = 0;
4297 	}
4298 }
4299 
mlme_set_peer_assoc_rsp_ie(struct wlan_objmgr_psoc * psoc,uint8_t * peer_addr,struct element_info * ie)4300 void mlme_set_peer_assoc_rsp_ie(struct wlan_objmgr_psoc *psoc,
4301 				uint8_t *peer_addr, struct element_info *ie)
4302 {
4303 	struct wlan_objmgr_peer *peer;
4304 	struct peer_mlme_priv_obj *peer_priv;
4305 
4306 	if (!ie || !ie->len || !ie->ptr || !peer_addr) {
4307 		mlme_legacy_debug("Assoc IE is NULL");
4308 		return;
4309 	}
4310 
4311 	peer = wlan_objmgr_get_peer_by_mac(psoc, peer_addr, WLAN_LEGACY_MAC_ID);
4312 	if (!peer)
4313 		return;
4314 
4315 	peer_priv = wlan_objmgr_peer_get_comp_private_obj(peer,
4316 							  WLAN_UMAC_COMP_MLME);
4317 
4318 	if (!peer_priv)
4319 		goto end;
4320 
4321 	/* Free existing assoc_rsp */
4322 	mlme_free_peer_assoc_rsp_ie(peer_priv);
4323 
4324 	peer_priv->assoc_rsp.ptr = qdf_mem_malloc(ie->len);
4325 	if (!peer_priv->assoc_rsp.ptr)
4326 		goto end;
4327 
4328 	qdf_mem_copy(peer_priv->assoc_rsp.ptr, ie->ptr, ie->len);
4329 	peer_priv->assoc_rsp.len = ie->len;
4330 end:
4331 	wlan_objmgr_peer_release_ref(peer, WLAN_LEGACY_MAC_ID);
4332 }
4333 
mlme_set_follow_ap_edca_flag(struct wlan_objmgr_vdev * vdev,bool flag)4334 void mlme_set_follow_ap_edca_flag(struct wlan_objmgr_vdev *vdev, bool flag)
4335 {
4336 	struct mlme_legacy_priv *mlme_priv;
4337 
4338 	mlme_priv = wlan_vdev_mlme_get_ext_hdl(vdev);
4339 	if (!mlme_priv) {
4340 		mlme_legacy_err("vdev legacy private object is NULL");
4341 		return;
4342 	}
4343 
4344 	mlme_priv->follow_ap_edca = flag;
4345 }
4346 
mlme_get_follow_ap_edca_flag(struct wlan_objmgr_vdev * vdev)4347 bool mlme_get_follow_ap_edca_flag(struct wlan_objmgr_vdev *vdev)
4348 {
4349 	struct mlme_legacy_priv *mlme_priv;
4350 
4351 	mlme_priv = wlan_vdev_mlme_get_ext_hdl(vdev);
4352 	if (!mlme_priv) {
4353 		mlme_legacy_err("vdev legacy private object is NULL");
4354 		return false;
4355 	}
4356 
4357 	return mlme_priv->follow_ap_edca;
4358 }
4359 
mlme_set_best_6g_power_type(struct wlan_objmgr_vdev * vdev,enum reg_6g_ap_type best_6g_power_type)4360 void mlme_set_best_6g_power_type(struct wlan_objmgr_vdev *vdev,
4361 				 enum reg_6g_ap_type best_6g_power_type)
4362 {
4363 	struct mlme_legacy_priv *mlme_priv;
4364 
4365 	mlme_priv = wlan_vdev_mlme_get_ext_hdl(vdev);
4366 	if (!mlme_priv) {
4367 		mlme_legacy_err("vdev legacy private object is NULL");
4368 		return;
4369 	}
4370 
4371 	mlme_priv->best_6g_power_type = best_6g_power_type;
4372 }
4373 
mlme_get_best_6g_power_type(struct wlan_objmgr_vdev * vdev)4374 enum reg_6g_ap_type mlme_get_best_6g_power_type(struct wlan_objmgr_vdev *vdev)
4375 {
4376 	struct mlme_legacy_priv *mlme_priv;
4377 
4378 	mlme_priv = wlan_vdev_mlme_get_ext_hdl(vdev);
4379 	if (!mlme_priv) {
4380 		mlme_legacy_err("vdev legacy private object is NULL");
4381 		return REG_VERY_LOW_POWER_AP;
4382 	}
4383 
4384 	return mlme_priv->best_6g_power_type;
4385 }
4386 
mlme_set_reconn_after_assoc_timeout_flag(struct wlan_objmgr_psoc * psoc,uint8_t vdev_id,bool flag)4387 void mlme_set_reconn_after_assoc_timeout_flag(struct wlan_objmgr_psoc *psoc,
4388 					      uint8_t vdev_id, bool flag)
4389 {
4390 	struct wlan_objmgr_vdev *vdev;
4391 	struct mlme_legacy_priv *mlme_priv;
4392 
4393 	if (!psoc)
4394 		return;
4395 
4396 	vdev = wlan_objmgr_get_vdev_by_id_from_psoc(psoc, vdev_id,
4397 						    WLAN_LEGACY_MAC_ID);
4398 	if (!vdev)
4399 		return;
4400 	mlme_priv = wlan_vdev_mlme_get_ext_hdl(vdev);
4401 	if (!mlme_priv) {
4402 		mlme_legacy_err("vdev legacy private object is NULL");
4403 		wlan_objmgr_vdev_release_ref(vdev, WLAN_LEGACY_MAC_ID);
4404 		return;
4405 	}
4406 
4407 	mlme_priv->reconn_after_assoc_timeout = flag;
4408 	wlan_objmgr_vdev_release_ref(vdev, WLAN_LEGACY_MAC_ID);
4409 }
4410 
mlme_get_reconn_after_assoc_timeout_flag(struct wlan_objmgr_psoc * psoc,uint8_t vdev_id)4411 bool mlme_get_reconn_after_assoc_timeout_flag(struct wlan_objmgr_psoc *psoc,
4412 					      uint8_t vdev_id)
4413 {
4414 	struct wlan_objmgr_vdev *vdev;
4415 	struct mlme_legacy_priv *mlme_priv;
4416 	bool reconn_after_assoc_timeout;
4417 
4418 	if (!psoc)
4419 		return false;
4420 
4421 	vdev = wlan_objmgr_get_vdev_by_id_from_psoc(psoc, vdev_id,
4422 						    WLAN_LEGACY_MAC_ID);
4423 	if (!vdev)
4424 		return false;
4425 	mlme_priv = wlan_vdev_mlme_get_ext_hdl(vdev);
4426 	if (!mlme_priv) {
4427 		mlme_legacy_err("vdev legacy private object is NULL");
4428 		wlan_objmgr_vdev_release_ref(vdev, WLAN_LEGACY_MAC_ID);
4429 		return false;
4430 	}
4431 
4432 	reconn_after_assoc_timeout = mlme_priv->reconn_after_assoc_timeout;
4433 	wlan_objmgr_vdev_release_ref(vdev, WLAN_LEGACY_MAC_ID);
4434 
4435 	return reconn_after_assoc_timeout;
4436 }
4437 
mlme_set_peer_pmf_status(struct wlan_objmgr_peer * peer,bool is_pmf_enabled)4438 void mlme_set_peer_pmf_status(struct wlan_objmgr_peer *peer,
4439 			      bool is_pmf_enabled)
4440 {
4441 	struct peer_mlme_priv_obj *peer_priv;
4442 
4443 	peer_priv = wlan_objmgr_peer_get_comp_private_obj(peer,
4444 							  WLAN_UMAC_COMP_MLME);
4445 	if (!peer_priv) {
4446 		mlme_legacy_err(" peer mlme component object is NULL");
4447 		return;
4448 	}
4449 	peer_priv->is_pmf_enabled = is_pmf_enabled;
4450 }
4451 
mlme_get_peer_pmf_status(struct wlan_objmgr_peer * peer)4452 bool mlme_get_peer_pmf_status(struct wlan_objmgr_peer *peer)
4453 {
4454 	struct peer_mlme_priv_obj *peer_priv;
4455 
4456 	peer_priv = wlan_objmgr_peer_get_comp_private_obj(peer,
4457 							  WLAN_UMAC_COMP_MLME);
4458 	if (!peer_priv) {
4459 		mlme_legacy_err("peer mlme component object is NULL");
4460 		return false;
4461 	}
4462 
4463 	return peer_priv->is_pmf_enabled;
4464 }
4465 
wlan_get_opmode_from_vdev_id(struct wlan_objmgr_pdev * pdev,uint8_t vdev_id)4466 enum QDF_OPMODE wlan_get_opmode_from_vdev_id(struct wlan_objmgr_pdev *pdev,
4467 					     uint8_t vdev_id)
4468 {
4469 	struct wlan_objmgr_vdev *vdev;
4470 	enum QDF_OPMODE opmode = QDF_MAX_NO_OF_MODE;
4471 
4472 	if (!pdev)
4473 		return opmode;
4474 
4475 	vdev = wlan_objmgr_get_vdev_by_id_from_pdev(pdev, vdev_id,
4476 						    WLAN_LEGACY_MAC_ID);
4477 	if (!vdev)
4478 		return opmode;
4479 
4480 	opmode = wlan_vdev_mlme_get_opmode(vdev);
4481 	wlan_objmgr_vdev_release_ref(vdev, WLAN_LEGACY_MAC_ID);
4482 
4483 	return opmode;
4484 }
4485 
wlan_mlme_get_bssid_vdev_id(struct wlan_objmgr_pdev * pdev,uint8_t vdev_id,struct qdf_mac_addr * bss_peer_mac)4486 QDF_STATUS wlan_mlme_get_bssid_vdev_id(struct wlan_objmgr_pdev *pdev,
4487 				       uint8_t vdev_id,
4488 				       struct qdf_mac_addr *bss_peer_mac)
4489 {
4490 	struct wlan_objmgr_vdev *vdev;
4491 	QDF_STATUS status;
4492 
4493 	if (!pdev)
4494 		return QDF_STATUS_E_INVAL;
4495 
4496 	vdev = wlan_objmgr_get_vdev_by_id_from_pdev(pdev, vdev_id,
4497 						    WLAN_LEGACY_MAC_ID);
4498 	if (!vdev)
4499 		return QDF_STATUS_E_INVAL;
4500 
4501 	status = wlan_vdev_get_bss_peer_mac(vdev, bss_peer_mac);
4502 	wlan_objmgr_vdev_release_ref(vdev, WLAN_LEGACY_MAC_ID);
4503 
4504 	return status;
4505 }
4506 
wlan_get_operation_chan_freq(struct wlan_objmgr_vdev * vdev)4507 qdf_freq_t wlan_get_operation_chan_freq(struct wlan_objmgr_vdev *vdev)
4508 {
4509 	qdf_freq_t chan_freq = 0;
4510 	struct wlan_channel *chan;
4511 
4512 	if (!vdev)
4513 		return chan_freq;
4514 
4515 	chan = wlan_vdev_get_active_channel(vdev);
4516 	if (chan)
4517 		chan_freq = chan->ch_freq;
4518 
4519 	return chan_freq;
4520 }
4521 
wlan_get_operation_chan_freq_vdev_id(struct wlan_objmgr_pdev * pdev,uint8_t vdev_id)4522 qdf_freq_t wlan_get_operation_chan_freq_vdev_id(struct wlan_objmgr_pdev *pdev,
4523 						uint8_t vdev_id)
4524 {
4525 	qdf_freq_t chan_freq = 0;
4526 	struct wlan_objmgr_vdev *vdev;
4527 
4528 	if (!pdev)
4529 		return chan_freq;
4530 
4531 	vdev = wlan_objmgr_get_vdev_by_id_from_pdev(pdev, vdev_id,
4532 						    WLAN_LEGACY_MAC_ID);
4533 	if (!vdev)
4534 		return chan_freq;
4535 	chan_freq = wlan_get_operation_chan_freq(vdev);
4536 	wlan_objmgr_vdev_release_ref(vdev, WLAN_LEGACY_MAC_ID);
4537 
4538 	return chan_freq;
4539 }
4540 
wlan_vdev_set_dot11mode(struct wlan_mlme_cfg * mac_mlme_cfg,enum QDF_OPMODE device_mode,struct vdev_mlme_obj * vdev_mlme)4541 void wlan_vdev_set_dot11mode(struct wlan_mlme_cfg *mac_mlme_cfg,
4542 			     enum QDF_OPMODE device_mode,
4543 			     struct vdev_mlme_obj *vdev_mlme)
4544 {
4545 	uint8_t dot11_mode_indx;
4546 	uint8_t *mld_addr;
4547 	enum mlme_vdev_dot11_mode vdev_dot11_mode;
4548 	uint32_t mac_dot11_mode =
4549 			mac_mlme_cfg->dot11_mode.vdev_type_dot11_mode;
4550 
4551 	switch (device_mode) {
4552 	default:
4553 	case QDF_STA_MODE:
4554 		dot11_mode_indx = STA_DOT11_MODE_INDX;
4555 		break;
4556 	case QDF_P2P_CLIENT_MODE:
4557 	case QDF_P2P_DEVICE_MODE:
4558 		dot11_mode_indx = P2P_DEV_DOT11_MODE_INDX;
4559 		break;
4560 	case QDF_TDLS_MODE:
4561 		dot11_mode_indx = TDLS_DOT11_MODE_INDX;
4562 		break;
4563 	case QDF_NAN_DISC_MODE:
4564 		dot11_mode_indx = NAN_DISC_DOT11_MODE_INDX;
4565 		break;
4566 	case QDF_NDI_MODE:
4567 		dot11_mode_indx = NDI_DOT11_MODE_INDX;
4568 		break;
4569 	case QDF_OCB_MODE:
4570 		dot11_mode_indx = OCB_DOT11_MODE_INDX;
4571 		break;
4572 	}
4573 
4574 	vdev_dot11_mode = QDF_GET_BITS(mac_dot11_mode, dot11_mode_indx, 4);
4575 	if ((device_mode != QDF_NAN_DISC_MODE && device_mode != QDF_NDI_MODE) &&
4576 	    (vdev_dot11_mode == MLME_VDEV_DOT11_MODE_AUTO ||
4577 	     vdev_dot11_mode == MLME_VDEV_DOT11_MODE_11BE)) {
4578 		mld_addr = wlan_vdev_mlme_get_mldaddr(vdev_mlme->vdev);
4579 		if (qdf_is_macaddr_zero((struct qdf_mac_addr *)mld_addr)) {
4580 			vdev_dot11_mode = MLME_VDEV_DOT11_MODE_11AX;
4581 			vdev_mlme->proto.vdev_dot11_mode = vdev_dot11_mode;
4582 		}
4583 	}
4584 	mlme_debug("vdev%d: dot11_mode %d", wlan_vdev_get_id(vdev_mlme->vdev),
4585 		   vdev_dot11_mode);
4586 }
4587 
wlan_is_open_wep_cipher(struct wlan_objmgr_pdev * pdev,uint8_t vdev_id)4588 bool wlan_is_open_wep_cipher(struct wlan_objmgr_pdev *pdev, uint8_t vdev_id)
4589 {
4590 	struct wlan_objmgr_vdev *vdev;
4591 	int32_t ucast_cipher;
4592 	bool is_open_wep = false;
4593 
4594 	if (!pdev)
4595 		return is_open_wep;
4596 
4597 	vdev = wlan_objmgr_get_vdev_by_id_from_pdev(pdev, vdev_id,
4598 						    WLAN_LEGACY_MAC_ID);
4599 	if (!vdev)
4600 		return is_open_wep;
4601 	ucast_cipher = wlan_crypto_get_param(vdev,
4602 					     WLAN_CRYPTO_PARAM_UCAST_CIPHER);
4603 	if (!ucast_cipher ||
4604 	    ((QDF_HAS_PARAM(ucast_cipher, WLAN_CRYPTO_CIPHER_NONE) ==
4605 	      ucast_cipher)) ||
4606 	      QDF_HAS_PARAM(ucast_cipher, WLAN_CRYPTO_CIPHER_WEP) ||
4607 	      QDF_HAS_PARAM(ucast_cipher, WLAN_CRYPTO_CIPHER_WEP_40) ||
4608 	      QDF_HAS_PARAM(ucast_cipher,  WLAN_CRYPTO_CIPHER_WEP_104))
4609 		is_open_wep = true;
4610 	wlan_objmgr_vdev_release_ref(vdev, WLAN_LEGACY_MAC_ID);
4611 
4612 	return is_open_wep;
4613 }
4614 
wlan_vdev_is_open_mode(struct wlan_objmgr_vdev * vdev)4615 bool wlan_vdev_is_open_mode(struct wlan_objmgr_vdev *vdev)
4616 {
4617 	int32_t ucast_cipher;
4618 
4619 	ucast_cipher = wlan_crypto_get_param(vdev,
4620 					     WLAN_CRYPTO_PARAM_UCAST_CIPHER);
4621 	if (!ucast_cipher ||
4622 	    ((QDF_HAS_PARAM(ucast_cipher, WLAN_CRYPTO_CIPHER_NONE) ==
4623 	      ucast_cipher)))
4624 		return true;
4625 
4626 	return false;
4627 }
4628 
wlan_vdev_id_is_open_cipher(struct wlan_objmgr_pdev * pdev,uint8_t vdev_id)4629 bool wlan_vdev_id_is_open_cipher(struct wlan_objmgr_pdev *pdev, uint8_t vdev_id)
4630 {
4631 	struct wlan_objmgr_vdev *vdev;
4632 	bool is_open = false;
4633 
4634 	if (!pdev)
4635 		return is_open;
4636 
4637 	vdev = wlan_objmgr_get_vdev_by_id_from_pdev(pdev, vdev_id,
4638 						    WLAN_LEGACY_MAC_ID);
4639 	if (!vdev)
4640 		return is_open;
4641 	is_open = wlan_vdev_is_open_mode(vdev);
4642 	wlan_objmgr_vdev_release_ref(vdev, WLAN_LEGACY_MAC_ID);
4643 
4644 	return is_open;
4645 }
4646 
wlan_vdev_id_is_11n_allowed(struct wlan_objmgr_pdev * pdev,uint8_t vdev_id)4647 bool wlan_vdev_id_is_11n_allowed(struct wlan_objmgr_pdev *pdev, uint8_t vdev_id)
4648 {
4649 	struct wlan_objmgr_vdev *vdev;
4650 	bool is_11n_allowed = true;
4651 	int32_t ucast_cipher;
4652 
4653 	if (!pdev)
4654 		return is_11n_allowed;
4655 
4656 	vdev = wlan_objmgr_get_vdev_by_id_from_pdev(pdev, vdev_id,
4657 						    WLAN_LEGACY_MAC_ID);
4658 	if (!vdev)
4659 		return is_11n_allowed;
4660 	ucast_cipher = wlan_crypto_get_param(vdev,
4661 					     WLAN_CRYPTO_PARAM_UCAST_CIPHER);
4662 
4663 	if (ucast_cipher == -1)
4664 		goto err;
4665 	if (QDF_HAS_PARAM(ucast_cipher, WLAN_CRYPTO_CIPHER_TKIP) ||
4666 	    QDF_HAS_PARAM(ucast_cipher, WLAN_CRYPTO_CIPHER_WEP) ||
4667 	    QDF_HAS_PARAM(ucast_cipher, WLAN_CRYPTO_CIPHER_WEP_40) ||
4668 	    QDF_HAS_PARAM(ucast_cipher, WLAN_CRYPTO_CIPHER_WEP_104)) {
4669 		QDF_CLEAR_PARAM(ucast_cipher, WLAN_CRYPTO_CIPHER_TKIP);
4670 		QDF_CLEAR_PARAM(ucast_cipher, WLAN_CRYPTO_CIPHER_WEP);
4671 		QDF_CLEAR_PARAM(ucast_cipher, WLAN_CRYPTO_CIPHER_WEP_40);
4672 		QDF_CLEAR_PARAM(ucast_cipher, WLAN_CRYPTO_CIPHER_WEP_104);
4673 		if (!ucast_cipher)
4674 			is_11n_allowed = false;
4675 	}
4676 err:
4677 	wlan_objmgr_vdev_release_ref(vdev, WLAN_LEGACY_MAC_ID);
4678 
4679 	return is_11n_allowed;
4680 }
4681 
4682 
wlan_is_vdev_id_up(struct wlan_objmgr_pdev * pdev,uint8_t vdev_id)4683 bool wlan_is_vdev_id_up(struct wlan_objmgr_pdev *pdev, uint8_t vdev_id)
4684 {
4685 	struct wlan_objmgr_vdev *vdev;
4686 	bool is_up = false;
4687 
4688 	if (!pdev)
4689 		return is_up;
4690 
4691 	vdev = wlan_objmgr_get_vdev_by_id_from_pdev(pdev, vdev_id,
4692 						    WLAN_LEGACY_MAC_ID);
4693 	if (vdev) {
4694 		is_up = QDF_IS_STATUS_SUCCESS(wlan_vdev_is_up(vdev));
4695 		wlan_objmgr_vdev_release_ref(vdev, WLAN_LEGACY_MAC_ID);
4696 	}
4697 
4698 	return is_up;
4699 }
4700 
4701 
4702 QDF_STATUS
wlan_get_op_chan_freq_info_vdev_id(struct wlan_objmgr_pdev * pdev,uint8_t vdev_id,qdf_freq_t * op_freq,qdf_freq_t * freq_seg_0,enum phy_ch_width * ch_width)4703 wlan_get_op_chan_freq_info_vdev_id(struct wlan_objmgr_pdev *pdev,
4704 				   uint8_t vdev_id, qdf_freq_t *op_freq,
4705 				   qdf_freq_t *freq_seg_0,
4706 				   enum phy_ch_width *ch_width)
4707 {
4708 	struct wlan_objmgr_vdev *vdev;
4709 	struct wlan_channel *chan;
4710 	QDF_STATUS status = QDF_STATUS_E_INVAL;
4711 
4712 	*op_freq = 0;
4713 	*freq_seg_0 = 0;
4714 	*ch_width = 0;
4715 
4716 	if (!pdev)
4717 		return QDF_STATUS_E_INVAL;
4718 
4719 	vdev = wlan_objmgr_get_vdev_by_id_from_pdev(pdev, vdev_id,
4720 						    WLAN_LEGACY_MAC_ID);
4721 	if (!vdev)
4722 		goto rel_ref;
4723 	if (wlan_vdev_mlme_is_active(vdev) != QDF_STATUS_SUCCESS)
4724 		goto rel_ref;
4725 	chan = wlan_vdev_get_active_channel(vdev);
4726 	if (!chan)
4727 		goto rel_ref;
4728 
4729 	/* If operating mode is STA / P2P-CLI then get the channel width
4730 	 * from phymode. This is due the reason where actual operating
4731 	 * channel width is configured as part of WMI_PEER_ASSOC_CMDID
4732 	 * which could be downgraded while the peer associated.
4733 	 * If there is a failure or operating mode is not STA / P2P-CLI
4734 	 * then get channel width from wlan_channel.
4735 	 */
4736 	status = wlan_mlme_get_sta_ch_width(vdev, ch_width);
4737 	if (QDF_IS_STATUS_ERROR(status))
4738 		*ch_width = chan->ch_width;
4739 
4740 	*op_freq = chan->ch_freq;
4741 	*freq_seg_0 = chan->ch_cfreq1;
4742 	status = QDF_STATUS_SUCCESS;
4743 
4744 rel_ref:
4745 	wlan_objmgr_vdev_release_ref(vdev, WLAN_LEGACY_MAC_ID);
4746 
4747 	return status;
4748 }
4749 
wlan_strip_ie(uint8_t * addn_ie,uint16_t * addn_ielen,uint8_t eid,enum size_of_len_field size_of_len_field,uint8_t * oui,uint8_t oui_length,uint8_t * extracted_ie,uint32_t eid_max_len)4750 QDF_STATUS wlan_strip_ie(uint8_t *addn_ie, uint16_t *addn_ielen,
4751 			 uint8_t eid, enum size_of_len_field size_of_len_field,
4752 			 uint8_t *oui, uint8_t oui_length,
4753 			 uint8_t *extracted_ie, uint32_t eid_max_len)
4754 {
4755 	uint8_t *tmp_buf = NULL;
4756 	uint16_t tmp_len = 0;
4757 	int left = *addn_ielen;
4758 	uint8_t *ptr = addn_ie;
4759 	uint8_t elem_id;
4760 	uint16_t elem_len, ie_len, extracted_ie_len = 0;
4761 
4762 	if (!addn_ie) {
4763 		mlme_debug("NULL addn_ie pointer");
4764 		return QDF_STATUS_E_INVAL;
4765 	}
4766 	if (!left)
4767 		return QDF_STATUS_E_INVAL;
4768 
4769 	tmp_buf = qdf_mem_malloc(left);
4770 	if (!tmp_buf)
4771 		return QDF_STATUS_E_NOMEM;
4772 
4773 	if (extracted_ie)
4774 		qdf_mem_zero(extracted_ie, eid_max_len + size_of_len_field + 1);
4775 
4776 	while (left >= 2) {
4777 		elem_id  = ptr[0];
4778 		left -= 1;
4779 		if (size_of_len_field == TWO_BYTE) {
4780 			elem_len = *((uint16_t *)&ptr[1]);
4781 			left -= 2;
4782 		} else {
4783 			elem_len = ptr[1];
4784 			left -= 1;
4785 		}
4786 		if (elem_len > left) {
4787 			mlme_err("Invalid IEs eid: %d elem_len: %d left: %d",
4788 				 elem_id, elem_len, left);
4789 			qdf_mem_free(tmp_buf);
4790 			return QDF_STATUS_E_FAILURE;
4791 		}
4792 
4793 		if (eid != elem_id ||
4794 				(oui && qdf_mem_cmp(oui,
4795 						&ptr[size_of_len_field + 1],
4796 						oui_length))) {
4797 			qdf_mem_copy(tmp_buf + tmp_len, &ptr[0],
4798 				     elem_len + size_of_len_field + 1);
4799 			tmp_len += (elem_len + size_of_len_field + 1);
4800 		} else {
4801 			/*
4802 			 * eid matched and if provided OUI also matched
4803 			 * take oui IE and store in provided buffer.
4804 			 */
4805 			if (extracted_ie) {
4806 				ie_len = elem_len + size_of_len_field + 1;
4807 				if (ie_len <= eid_max_len - extracted_ie_len) {
4808 					qdf_mem_copy(
4809 					extracted_ie + extracted_ie_len,
4810 					&ptr[0], ie_len);
4811 					extracted_ie_len += ie_len;
4812 				}
4813 			}
4814 		}
4815 		left -= elem_len;
4816 		ptr += (elem_len + size_of_len_field + 1);
4817 	}
4818 	qdf_mem_copy(addn_ie, tmp_buf, tmp_len);
4819 
4820 	*addn_ielen = tmp_len;
4821 	qdf_mem_free(tmp_buf);
4822 
4823 	return QDF_STATUS_SUCCESS;
4824 }
4825 
wlan_is_channel_present_in_list(qdf_freq_t * freq_lst,uint32_t num_chan,qdf_freq_t chan_freq)4826 bool wlan_is_channel_present_in_list(qdf_freq_t *freq_lst,
4827 				     uint32_t num_chan, qdf_freq_t chan_freq)
4828 {
4829 	int i = 0;
4830 
4831 	/* Check for NULL pointer */
4832 	if (!freq_lst || (num_chan == 0))
4833 		return false;
4834 
4835 	/* Look for the channel in the list */
4836 	for (i = 0; (i < num_chan) && (i < CFG_VALID_CHANNEL_LIST_LEN); i++) {
4837 		if (freq_lst[i] == chan_freq)
4838 			return true;
4839 	}
4840 
4841 	return false;
4842 }
4843 
wlan_roam_is_channel_valid(struct wlan_mlme_reg * reg,qdf_freq_t chan_freq)4844 bool wlan_roam_is_channel_valid(struct wlan_mlme_reg *reg, qdf_freq_t chan_freq)
4845 {
4846 	bool valid = false;
4847 	uint32_t i;
4848 	uint32_t len = reg->valid_channel_list_num;
4849 
4850 	for (i = 0; (i < len); i++) {
4851 		if (wlan_reg_is_dsrc_freq(
4852 			reg->valid_channel_freq_list[i]))
4853 			continue;
4854 
4855 		if (chan_freq == reg->valid_channel_freq_list[i]) {
4856 			valid = true;
4857 			break;
4858 		}
4859 	}
4860 
4861 	return valid;
4862 }
4863 
wlan_get_cfg_max_tx_power(struct wlan_objmgr_psoc * psoc,struct wlan_objmgr_pdev * pdev,uint32_t ch_freq)4864 int8_t wlan_get_cfg_max_tx_power(struct wlan_objmgr_psoc *psoc,
4865 				 struct wlan_objmgr_pdev *pdev,
4866 				 uint32_t ch_freq)
4867 {
4868 	uint32_t cfg_length = 0;
4869 	int8_t max_tx_pwr = 0;
4870 	struct pwr_channel_info *country_info = NULL;
4871 	uint8_t count = 0;
4872 	uint8_t maxChannels;
4873 	int32_t rem_length = 0;
4874 	struct wlan_mlme_psoc_ext_obj *mlme_obj;
4875 
4876 	mlme_obj = mlme_get_psoc_ext_obj(psoc);
4877 	if (!mlme_obj)
4878 		return max_tx_pwr;
4879 
4880 	if (WLAN_REG_IS_5GHZ_CH_FREQ(ch_freq)) {
4881 		cfg_length = mlme_obj->cfg.power.max_tx_power_5.len;
4882 	} else if (WLAN_REG_IS_24GHZ_CH_FREQ(ch_freq)) {
4883 		cfg_length = mlme_obj->cfg.power.max_tx_power_24.len;
4884 
4885 	} else if (wlan_reg_is_6ghz_chan_freq(ch_freq)) {
4886 		return wlan_reg_get_channel_reg_power_for_freq(pdev,
4887 							       ch_freq);
4888 	} else {
4889 		return max_tx_pwr;
4890 	}
4891 
4892 	if (!cfg_length)
4893 		goto error;
4894 
4895 	country_info = qdf_mem_malloc(cfg_length);
4896 	if (!country_info)
4897 		goto error;
4898 
4899 	if (WLAN_REG_IS_5GHZ_CH_FREQ(ch_freq)) {
4900 		if (cfg_length > CFG_MAX_TX_POWER_5_LEN)
4901 			goto error;
4902 		qdf_mem_copy(country_info,
4903 			     mlme_obj->cfg.power.max_tx_power_5.data,
4904 			     cfg_length);
4905 	} else if (WLAN_REG_IS_24GHZ_CH_FREQ(ch_freq)) {
4906 		if (cfg_length > CFG_MAX_TX_POWER_2_4_LEN)
4907 			goto error;
4908 		qdf_mem_copy(country_info,
4909 			     mlme_obj->cfg.power.max_tx_power_24.data,
4910 			     cfg_length);
4911 	}
4912 
4913 	/* Identify the channel and maxtxpower */
4914 	rem_length = cfg_length;
4915 	while (rem_length >= (sizeof(struct pwr_channel_info))) {
4916 		maxChannels = country_info[count].num_chan;
4917 		max_tx_pwr = country_info[count].max_tx_pwr;
4918 		count++;
4919 		rem_length -= (sizeof(struct pwr_channel_info));
4920 
4921 		if (ch_freq >= country_info[count].first_freq &&
4922 		    ch_freq < (country_info[count].first_freq + maxChannels)) {
4923 			break;
4924 		}
4925 	}
4926 
4927 error:
4928 	if (country_info)
4929 		qdf_mem_free(country_info);
4930 
4931 	return max_tx_pwr;
4932 }
4933 
4934 #if defined(WLAN_FEATURE_HOST_ROAM) || defined(WLAN_FEATURE_ROAM_OFFLOAD)
4935 static
mlme_roam_state_to_string(enum roam_offload_state state)4936 const char *mlme_roam_state_to_string(enum roam_offload_state state)
4937 {
4938 	switch (state) {
4939 	case WLAN_ROAM_INIT:
4940 		return "ROAM_INIT";
4941 	case WLAN_ROAM_DEINIT:
4942 		return "ROAM_DEINIT";
4943 	case WLAN_ROAM_RSO_ENABLED:
4944 		return "ROAM_RSO_ENABLED";
4945 	case WLAN_ROAM_RSO_STOPPED:
4946 		return "ROAM_RSO_STOPPED";
4947 	case WLAN_ROAMING_IN_PROG:
4948 		return "ROAMING_IN_PROG";
4949 	case WLAN_ROAM_SYNCH_IN_PROG:
4950 		return "ROAM_SYNCH_IN_PROG";
4951 	case WLAN_MLO_ROAM_SYNCH_IN_PROG:
4952 		return "MLO_ROAM_SYNCH_IN_PROG";
4953 	default:
4954 		return "";
4955 	}
4956 }
4957 
4958 static void
mlme_print_roaming_state(uint8_t vdev_id,enum roam_offload_state cur_state,enum roam_offload_state new_state)4959 mlme_print_roaming_state(uint8_t vdev_id, enum roam_offload_state cur_state,
4960 			 enum roam_offload_state new_state)
4961 {
4962 	mlme_nofl_debug("CM_RSO: vdev%d: [%s(%d)] --> [%s(%d)]",
4963 			vdev_id, mlme_roam_state_to_string(cur_state),
4964 			cur_state,
4965 			mlme_roam_state_to_string(new_state), new_state);
4966 
4967 	/* TODO: Try to print the state change requestor also */
4968 }
4969 
4970 bool
mlme_get_supplicant_disabled_roaming(struct wlan_objmgr_psoc * psoc,uint8_t vdev_id)4971 mlme_get_supplicant_disabled_roaming(struct wlan_objmgr_psoc *psoc,
4972 				     uint8_t vdev_id)
4973 {
4974 	struct wlan_objmgr_vdev *vdev;
4975 	struct mlme_legacy_priv *mlme_priv;
4976 	bool value;
4977 
4978 	vdev = wlan_objmgr_get_vdev_by_id_from_psoc(psoc, vdev_id,
4979 						    WLAN_MLME_OBJMGR_ID);
4980 
4981 	if (!vdev) {
4982 		mlme_legacy_err("vdev object is NULL");
4983 		return 0;
4984 	}
4985 
4986 	mlme_priv = wlan_vdev_mlme_get_ext_hdl(vdev);
4987 	if (!mlme_priv) {
4988 		mlme_legacy_err("vdev legacy private object is NULL");
4989 		wlan_objmgr_vdev_release_ref(vdev, WLAN_MLME_OBJMGR_ID);
4990 		return 0;
4991 	}
4992 
4993 	value = mlme_priv->mlme_roam.roam_cfg.supplicant_disabled_roaming;
4994 	wlan_objmgr_vdev_release_ref(vdev, WLAN_MLME_OBJMGR_ID);
4995 
4996 	return value;
4997 }
4998 
mlme_set_supplicant_disabled_roaming(struct wlan_objmgr_psoc * psoc,uint8_t vdev_id,bool val)4999 void mlme_set_supplicant_disabled_roaming(struct wlan_objmgr_psoc *psoc,
5000 					  uint8_t vdev_id, bool val)
5001 {
5002 	struct wlan_objmgr_vdev *vdev;
5003 	struct mlme_legacy_priv *mlme_priv;
5004 
5005 	vdev = wlan_objmgr_get_vdev_by_id_from_psoc(psoc, vdev_id,
5006 						    WLAN_MLME_OBJMGR_ID);
5007 
5008 	if (!vdev) {
5009 		mlme_legacy_err("vdev object is NULL");
5010 		return;
5011 	}
5012 
5013 	mlme_priv = wlan_vdev_mlme_get_ext_hdl(vdev);
5014 	if (!mlme_priv) {
5015 		mlme_legacy_err("vdev legacy private object is NULL");
5016 		wlan_objmgr_vdev_release_ref(vdev, WLAN_MLME_OBJMGR_ID);
5017 		return;
5018 	}
5019 
5020 	mlme_priv->mlme_roam.roam_cfg.supplicant_disabled_roaming = val;
5021 	wlan_objmgr_vdev_release_ref(vdev, WLAN_MLME_OBJMGR_ID);
5022 }
5023 
5024 uint32_t
mlme_get_roam_trigger_bitmap(struct wlan_objmgr_psoc * psoc,uint8_t vdev_id)5025 mlme_get_roam_trigger_bitmap(struct wlan_objmgr_psoc *psoc, uint8_t vdev_id)
5026 {
5027 	struct wlan_objmgr_vdev *vdev;
5028 	struct mlme_legacy_priv *mlme_priv;
5029 	uint32_t roam_bitmap;
5030 
5031 	vdev = wlan_objmgr_get_vdev_by_id_from_psoc(psoc, vdev_id,
5032 						    WLAN_MLME_OBJMGR_ID);
5033 
5034 	if (!vdev) {
5035 		mlme_legacy_err("vdev object is NULL");
5036 		return 0;
5037 	}
5038 
5039 	mlme_priv = wlan_vdev_mlme_get_ext_hdl(vdev);
5040 	if (!mlme_priv) {
5041 		mlme_legacy_err("vdev legacy private object is NULL");
5042 		wlan_objmgr_vdev_release_ref(vdev, WLAN_MLME_OBJMGR_ID);
5043 		return 0;
5044 	}
5045 
5046 	roam_bitmap = mlme_priv->mlme_roam.roam_cfg.roam_trigger_bitmap;
5047 	wlan_objmgr_vdev_release_ref(vdev, WLAN_MLME_OBJMGR_ID);
5048 
5049 	return roam_bitmap;
5050 }
5051 
mlme_set_roam_trigger_bitmap(struct wlan_objmgr_psoc * psoc,uint8_t vdev_id,uint32_t val)5052 void mlme_set_roam_trigger_bitmap(struct wlan_objmgr_psoc *psoc,
5053 				  uint8_t vdev_id, uint32_t val)
5054 {
5055 	struct wlan_objmgr_vdev *vdev;
5056 	struct mlme_legacy_priv *mlme_priv;
5057 
5058 	vdev = wlan_objmgr_get_vdev_by_id_from_psoc(psoc, vdev_id,
5059 						    WLAN_MLME_OBJMGR_ID);
5060 	if (!vdev) {
5061 		mlme_legacy_err("vdev object is NULL");
5062 		return;
5063 	}
5064 
5065 	mlme_priv = wlan_vdev_mlme_get_ext_hdl(vdev);
5066 	if (!mlme_priv) {
5067 		mlme_legacy_err("vdev legacy private object is NULL");
5068 		wlan_objmgr_vdev_release_ref(vdev, WLAN_MLME_OBJMGR_ID);
5069 		return;
5070 	}
5071 
5072 	mlme_priv->mlme_roam.roam_cfg.roam_trigger_bitmap = val;
5073 	wlan_objmgr_vdev_release_ref(vdev, WLAN_MLME_OBJMGR_ID);
5074 }
5075 
5076 uint8_t
mlme_get_operations_bitmap(struct wlan_objmgr_psoc * psoc,uint8_t vdev_id)5077 mlme_get_operations_bitmap(struct wlan_objmgr_psoc *psoc, uint8_t vdev_id)
5078 {
5079 	struct wlan_objmgr_vdev *vdev;
5080 	struct mlme_legacy_priv *mlme_priv;
5081 	uint8_t bitmap;
5082 
5083 	vdev = wlan_objmgr_get_vdev_by_id_from_psoc(psoc, vdev_id,
5084 						    WLAN_MLME_OBJMGR_ID);
5085 
5086 	if (!vdev) {
5087 		mlme_legacy_err("vdev object is NULL");
5088 		return 0xFF;
5089 	}
5090 
5091 	mlme_priv = wlan_vdev_mlme_get_ext_hdl(vdev);
5092 	if (!mlme_priv) {
5093 		mlme_legacy_err("vdev legacy private object is NULL");
5094 		wlan_objmgr_vdev_release_ref(vdev, WLAN_MLME_OBJMGR_ID);
5095 		return 0xFF;
5096 	}
5097 
5098 	bitmap = mlme_priv->mlme_roam.roam_sm.mlme_operations_bitmap;
5099 	mlme_legacy_debug("vdev[%d] bitmap[0x%x]", vdev_id,
5100 			  mlme_priv->mlme_roam.roam_sm.mlme_operations_bitmap);
5101 	wlan_objmgr_vdev_release_ref(vdev, WLAN_MLME_OBJMGR_ID);
5102 
5103 	return bitmap;
5104 }
5105 
5106 void
mlme_set_operations_bitmap(struct wlan_objmgr_psoc * psoc,uint8_t vdev_id,enum wlan_cm_rso_control_requestor reqs,bool clear)5107 mlme_set_operations_bitmap(struct wlan_objmgr_psoc *psoc, uint8_t vdev_id,
5108 			   enum wlan_cm_rso_control_requestor reqs, bool clear)
5109 {
5110 	struct wlan_objmgr_vdev *vdev;
5111 	struct mlme_legacy_priv *mlme_priv;
5112 
5113 	vdev = wlan_objmgr_get_vdev_by_id_from_psoc(psoc, vdev_id,
5114 						    WLAN_MLME_OBJMGR_ID);
5115 	if (!vdev) {
5116 		mlme_legacy_err("vdev object is NULL");
5117 		return;
5118 	}
5119 
5120 	mlme_priv = wlan_vdev_mlme_get_ext_hdl(vdev);
5121 	if (!mlme_priv) {
5122 		mlme_legacy_err("vdev legacy private object is NULL");
5123 		wlan_objmgr_vdev_release_ref(vdev, WLAN_MLME_OBJMGR_ID);
5124 		return;
5125 	}
5126 
5127 	if (clear)
5128 		mlme_priv->mlme_roam.roam_sm.mlme_operations_bitmap &= ~reqs;
5129 	else
5130 		mlme_priv->mlme_roam.roam_sm.mlme_operations_bitmap |= reqs;
5131 
5132 	mlme_legacy_debug("vdev[%d] bitmap[0x%x], reqs: %d, clear: %d", vdev_id,
5133 			  mlme_priv->mlme_roam.roam_sm.mlme_operations_bitmap,
5134 			  reqs, clear);
5135 	wlan_objmgr_vdev_release_ref(vdev, WLAN_MLME_OBJMGR_ID);
5136 }
5137 
5138 void
mlme_clear_operations_bitmap(struct wlan_objmgr_psoc * psoc,uint8_t vdev_id)5139 mlme_clear_operations_bitmap(struct wlan_objmgr_psoc *psoc, uint8_t vdev_id)
5140 {
5141 	struct wlan_objmgr_vdev *vdev;
5142 	struct mlme_legacy_priv *mlme_priv;
5143 
5144 	vdev = wlan_objmgr_get_vdev_by_id_from_psoc(psoc, vdev_id,
5145 						    WLAN_MLME_OBJMGR_ID);
5146 	if (!vdev) {
5147 		mlme_legacy_err("vdev object is NULL");
5148 		return;
5149 	}
5150 
5151 	mlme_priv = wlan_vdev_mlme_get_ext_hdl(vdev);
5152 	if (!mlme_priv) {
5153 		mlme_legacy_err("vdev legacy private object is NULL");
5154 		wlan_objmgr_vdev_release_ref(vdev, WLAN_MLME_OBJMGR_ID);
5155 		return;
5156 	}
5157 
5158 	mlme_priv->mlme_roam.roam_sm.mlme_operations_bitmap = 0;
5159 	wlan_objmgr_vdev_release_ref(vdev, WLAN_MLME_OBJMGR_ID);
5160 }
5161 
mlme_get_cfg_wlm_level(struct wlan_objmgr_psoc * psoc,uint8_t * level)5162 QDF_STATUS mlme_get_cfg_wlm_level(struct wlan_objmgr_psoc *psoc,
5163 				  uint8_t *level)
5164 {
5165 	struct wlan_mlme_psoc_ext_obj *mlme_obj;
5166 
5167 	mlme_obj = mlme_get_psoc_ext_obj(psoc);
5168 	if (!mlme_obj)
5169 		return QDF_STATUS_E_FAILURE;
5170 
5171 	*level = mlme_obj->cfg.wlm_config.latency_level;
5172 
5173 	return QDF_STATUS_SUCCESS;
5174 }
5175 
mlme_get_cfg_wlm_reset(struct wlan_objmgr_psoc * psoc,bool * reset)5176 QDF_STATUS mlme_get_cfg_wlm_reset(struct wlan_objmgr_psoc *psoc,
5177 				  bool *reset)
5178 {
5179 	struct wlan_mlme_psoc_ext_obj *mlme_obj;
5180 
5181 	mlme_obj = mlme_get_psoc_ext_obj(psoc);
5182 	if (!mlme_obj)
5183 		return QDF_STATUS_E_FAILURE;
5184 
5185 	*reset = mlme_obj->cfg.wlm_config.latency_reset;
5186 
5187 	return QDF_STATUS_SUCCESS;
5188 }
5189 
5190 enum roam_offload_state
mlme_get_roam_state(struct wlan_objmgr_psoc * psoc,uint8_t vdev_id)5191 mlme_get_roam_state(struct wlan_objmgr_psoc *psoc, uint8_t vdev_id)
5192 {
5193 	struct wlan_objmgr_vdev *vdev;
5194 	struct mlme_legacy_priv *mlme_priv;
5195 	enum roam_offload_state roam_state;
5196 
5197 	vdev = wlan_objmgr_get_vdev_by_id_from_psoc(psoc, vdev_id,
5198 						    WLAN_MLME_OBJMGR_ID);
5199 
5200 	if (!vdev)
5201 		return WLAN_ROAM_DEINIT;
5202 
5203 	mlme_priv = wlan_vdev_mlme_get_ext_hdl(vdev);
5204 	if (!mlme_priv) {
5205 		mlme_legacy_err("vdev legacy private object is NULL");
5206 		wlan_objmgr_vdev_release_ref(vdev, WLAN_MLME_OBJMGR_ID);
5207 		return WLAN_ROAM_DEINIT;
5208 	}
5209 
5210 	roam_state = mlme_priv->mlme_roam.roam_sm.state;
5211 	wlan_objmgr_vdev_release_ref(vdev, WLAN_MLME_OBJMGR_ID);
5212 
5213 	return roam_state;
5214 }
5215 
mlme_set_roam_state(struct wlan_objmgr_psoc * psoc,uint8_t vdev_id,enum roam_offload_state new_state)5216 void mlme_set_roam_state(struct wlan_objmgr_psoc *psoc, uint8_t vdev_id,
5217 			 enum roam_offload_state new_state)
5218 {
5219 	struct wlan_objmgr_vdev *vdev;
5220 	struct mlme_legacy_priv *mlme_priv;
5221 
5222 	vdev = wlan_objmgr_get_vdev_by_id_from_psoc(psoc, vdev_id,
5223 						    WLAN_MLME_OBJMGR_ID);
5224 
5225 	if (!vdev) {
5226 		mlme_err("vdev%d: vdev object is NULL", vdev_id);
5227 		return;
5228 	}
5229 
5230 	mlme_priv = wlan_vdev_mlme_get_ext_hdl(vdev);
5231 	if (!mlme_priv) {
5232 		mlme_err("vdev%d: vdev legacy private object is NULL", vdev_id);
5233 		wlan_objmgr_vdev_release_ref(vdev, WLAN_MLME_OBJMGR_ID);
5234 		return;
5235 	}
5236 
5237 	mlme_print_roaming_state(vdev_id, mlme_priv->mlme_roam.roam_sm.state,
5238 				 new_state);
5239 	mlme_priv->mlme_roam.roam_sm.state = new_state;
5240 	wlan_objmgr_vdev_release_ref(vdev, WLAN_MLME_OBJMGR_ID);
5241 }
5242 
5243 QDF_STATUS
mlme_store_fw_scan_channels(struct wlan_objmgr_psoc * psoc,tSirUpdateChanList * chan_list)5244 mlme_store_fw_scan_channels(struct wlan_objmgr_psoc *psoc,
5245 			    tSirUpdateChanList *chan_list)
5246 {
5247 	struct wlan_mlme_psoc_ext_obj *mlme_obj;
5248 	struct wlan_mlme_lfr_cfg *lfr;
5249 	uint16_t i;
5250 
5251 	mlme_obj = mlme_get_psoc_ext_obj(psoc);
5252 	if (!mlme_obj) {
5253 		mlme_legacy_err("Failed to get MLME Obj");
5254 		return QDF_STATUS_E_FAILURE;
5255 	}
5256 
5257 	lfr = &mlme_obj->cfg.lfr;
5258 	qdf_mem_zero(&lfr->saved_freq_list, sizeof(lfr->saved_freq_list));
5259 	lfr->saved_freq_list.num_channels = chan_list->numChan;
5260 	for (i = 0; i < chan_list->numChan; i++)
5261 		lfr->saved_freq_list.freq[i] = chan_list->chanParam[i].freq;
5262 
5263 	mlme_legacy_debug("ROAM: save %d channels",
5264 			  chan_list->numChan);
5265 
5266 	return QDF_STATUS_SUCCESS;
5267 }
5268 
mlme_get_fw_scan_channels(struct wlan_objmgr_psoc * psoc,uint32_t * freq_list,uint8_t * saved_num_chan)5269 QDF_STATUS mlme_get_fw_scan_channels(struct wlan_objmgr_psoc *psoc,
5270 				     uint32_t *freq_list,
5271 				     uint8_t *saved_num_chan)
5272 {
5273 	struct wlan_mlme_psoc_ext_obj *mlme_obj;
5274 	struct wlan_mlme_lfr_cfg *lfr;
5275 	uint16_t i;
5276 
5277 	if (!freq_list) {
5278 		mlme_legacy_err("ROAM: Freq list is NULL");
5279 		*saved_num_chan = 0;
5280 		return QDF_STATUS_E_FAILURE;
5281 	}
5282 
5283 	mlme_obj = mlme_get_psoc_ext_obj(psoc);
5284 	if (!mlme_obj) {
5285 		mlme_legacy_err("Failed to get MLME Obj");
5286 		*saved_num_chan = 0;
5287 		return QDF_STATUS_E_FAILURE;
5288 	}
5289 
5290 	lfr = &mlme_obj->cfg.lfr;
5291 	*saved_num_chan = lfr->saved_freq_list.num_channels;
5292 
5293 	for (i = 0; i < lfr->saved_freq_list.num_channels; i++)
5294 		freq_list[i] = lfr->saved_freq_list.freq[i];
5295 
5296 	return QDF_STATUS_SUCCESS;
5297 }
5298 #endif
5299 
wlan_mlme_get_mac_vdev_id(struct wlan_objmgr_pdev * pdev,uint8_t vdev_id,struct qdf_mac_addr * self_mac)5300 QDF_STATUS wlan_mlme_get_mac_vdev_id(struct wlan_objmgr_pdev *pdev,
5301 				     uint8_t vdev_id,
5302 				     struct qdf_mac_addr *self_mac)
5303 {
5304 	struct wlan_objmgr_vdev *vdev;
5305 
5306 	if (!pdev)
5307 		return QDF_STATUS_E_INVAL;
5308 
5309 	vdev = wlan_objmgr_get_vdev_by_id_from_pdev(pdev, vdev_id,
5310 						    WLAN_LEGACY_MAC_ID);
5311 	if (!vdev)
5312 		return QDF_STATUS_E_INVAL;
5313 
5314 	qdf_mem_copy(self_mac->bytes,
5315 		     wlan_vdev_mlme_get_macaddr(vdev), QDF_MAC_ADDR_SIZE);
5316 	wlan_objmgr_vdev_release_ref(vdev, WLAN_LEGACY_MAC_ID);
5317 
5318 	return QDF_STATUS_SUCCESS;
5319 }
5320 
5321 qdf_freq_t
wlan_get_sap_user_config_freq(struct wlan_objmgr_vdev * vdev)5322 wlan_get_sap_user_config_freq(struct wlan_objmgr_vdev *vdev)
5323 {
5324 	struct mlme_legacy_priv *mlme_priv;
5325 	enum QDF_OPMODE opmode = QDF_MAX_NO_OF_MODE;
5326 
5327 	mlme_priv = wlan_vdev_mlme_get_ext_hdl(vdev);
5328 	if (!mlme_priv) {
5329 		mlme_legacy_err("vdev legacy private object is NULL");
5330 		return 0;
5331 	}
5332 
5333 	opmode = wlan_vdev_mlme_get_opmode(vdev);
5334 	if (opmode != QDF_SAP_MODE && opmode != QDF_P2P_GO_MODE) {
5335 		mlme_debug("Cannot get user config freq for mode %d", opmode);
5336 		return 0;
5337 	}
5338 
5339 	return mlme_priv->mlme_ap.user_config_sap_ch_freq;
5340 }
5341 
5342 QDF_STATUS
wlan_set_sap_user_config_freq(struct wlan_objmgr_vdev * vdev,qdf_freq_t freq)5343 wlan_set_sap_user_config_freq(struct wlan_objmgr_vdev *vdev,
5344 			      qdf_freq_t freq)
5345 {
5346 	struct mlme_legacy_priv *mlme_priv;
5347 	enum QDF_OPMODE opmode = QDF_MAX_NO_OF_MODE;
5348 
5349 	mlme_priv = wlan_vdev_mlme_get_ext_hdl(vdev);
5350 	if (!mlme_priv) {
5351 		mlme_legacy_err("vdev legacy private object is NULL");
5352 		return QDF_STATUS_E_INVAL;
5353 	}
5354 
5355 	opmode = wlan_vdev_mlme_get_opmode(vdev);
5356 	if (opmode != QDF_SAP_MODE && opmode != QDF_P2P_GO_MODE) {
5357 		mlme_debug("Cannot set user config freq for mode %d", opmode);
5358 		return QDF_STATUS_E_FAILURE;
5359 	}
5360 
5361 	mlme_priv->mlme_ap.user_config_sap_ch_freq = freq;
5362 	return QDF_STATUS_SUCCESS;
5363 }
5364 
5365 #ifdef CONFIG_BAND_6GHZ
5366 bool
wlan_get_tpc_update_required_for_sta(struct wlan_objmgr_vdev * vdev)5367 wlan_get_tpc_update_required_for_sta(struct wlan_objmgr_vdev *vdev)
5368 {
5369 	struct mlme_legacy_priv *mlme_priv;
5370 	enum QDF_OPMODE opmode;
5371 
5372 	mlme_priv = wlan_vdev_mlme_get_ext_hdl(vdev);
5373 	if (!mlme_priv) {
5374 		mlme_legacy_err("vdev legacy private object is NULL");
5375 		return false;
5376 	}
5377 
5378 	opmode = wlan_vdev_mlme_get_opmode(vdev);
5379 	if (opmode != QDF_SAP_MODE && opmode != QDF_P2P_GO_MODE) {
5380 		mlme_debug("Invalid opmode %d", opmode);
5381 		return false;
5382 	}
5383 
5384 	return mlme_priv->mlme_ap.update_required_scc_sta_power;
5385 }
5386 
5387 QDF_STATUS
wlan_set_tpc_update_required_for_sta(struct wlan_objmgr_vdev * vdev,bool value)5388 wlan_set_tpc_update_required_for_sta(struct wlan_objmgr_vdev *vdev, bool value)
5389 {
5390 	struct mlme_legacy_priv *mlme_priv;
5391 	enum QDF_OPMODE opmode;
5392 
5393 	mlme_priv = wlan_vdev_mlme_get_ext_hdl(vdev);
5394 	if (!mlme_priv) {
5395 		mlme_legacy_err("vdev legacy private object is NULL");
5396 		return QDF_STATUS_E_INVAL;
5397 	}
5398 
5399 	opmode = wlan_vdev_mlme_get_opmode(vdev);
5400 	if (opmode != QDF_SAP_MODE && opmode != QDF_P2P_GO_MODE) {
5401 		mlme_debug("Invalid mode %d", opmode);
5402 		QDF_ASSERT(0);
5403 		return QDF_STATUS_E_FAILURE;
5404 	}
5405 
5406 	mlme_priv->mlme_ap.update_required_scc_sta_power = value;
5407 	mlme_debug("Set change scc power as %d", value);
5408 	return QDF_STATUS_SUCCESS;
5409 }
5410 #endif
5411 
wlan_mlme_get_sta_num_tx_chains(struct wlan_objmgr_psoc * psoc,struct wlan_objmgr_vdev * vdev,uint8_t * tx_chains)5412 QDF_STATUS wlan_mlme_get_sta_num_tx_chains(struct wlan_objmgr_psoc *psoc,
5413 					   struct wlan_objmgr_vdev *vdev,
5414 					   uint8_t *tx_chains)
5415 {
5416 	bool dynamic_nss_chains_support;
5417 	struct wlan_mlme_nss_chains *dynamic_cfg;
5418 	enum band_info operating_band;
5419 	QDF_STATUS status;
5420 	struct vdev_mlme_obj *vdev_mlme;
5421 
5422 	status = wlan_mlme_cfg_get_dynamic_nss_chains_support
5423 					(psoc, &dynamic_nss_chains_support);
5424 	if (QDF_IS_STATUS_ERROR(status)) {
5425 		mlme_err("Failed to get dynamic_nss_chains_support");
5426 		return QDF_STATUS_E_INVAL;
5427 	}
5428 
5429 	vdev_mlme =
5430 		wlan_objmgr_vdev_get_comp_private_obj(vdev,
5431 						      WLAN_UMAC_COMP_MLME);
5432 	if (!vdev_mlme) {
5433 		QDF_ASSERT(0);
5434 		return false;
5435 	}
5436 
5437 	if (dynamic_nss_chains_support) {
5438 		dynamic_cfg = mlme_get_dynamic_vdev_config(vdev);
5439 		if (!dynamic_cfg) {
5440 			mlme_err("nss chain dynamic config NULL");
5441 			return QDF_STATUS_E_INVAL;
5442 		}
5443 
5444 		operating_band = ucfg_cm_get_connected_band(vdev);
5445 		switch (operating_band) {
5446 		case BAND_2G:
5447 			*tx_chains =
5448 			dynamic_cfg->num_tx_chains[NSS_CHAINS_BAND_2GHZ];
5449 			break;
5450 		case BAND_5G:
5451 			*tx_chains =
5452 			dynamic_cfg->num_tx_chains[NSS_CHAINS_BAND_5GHZ];
5453 			break;
5454 		default:
5455 			mlme_err("Band %d Not 2G or 5G", operating_band);
5456 			return QDF_STATUS_E_INVAL;
5457 		}
5458 	}
5459 
5460 	return QDF_STATUS_SUCCESS;
5461 }
5462 
wlan_mlme_get_sta_tx_nss(struct wlan_objmgr_psoc * psoc,struct wlan_objmgr_vdev * vdev,uint8_t * tx_nss)5463 QDF_STATUS wlan_mlme_get_sta_tx_nss(struct wlan_objmgr_psoc *psoc,
5464 				    struct wlan_objmgr_vdev *vdev,
5465 				    uint8_t *tx_nss)
5466 {
5467 	uint8_t proto_generic_nss;
5468 	bool dynamic_nss_chains_support;
5469 	struct wlan_mlme_nss_chains *dynamic_cfg;
5470 	enum band_info operating_band;
5471 	QDF_STATUS status;
5472 
5473 	status = wlan_mlme_cfg_get_dynamic_nss_chains_support
5474 					(psoc, &dynamic_nss_chains_support);
5475 	if (QDF_IS_STATUS_ERROR(status)) {
5476 		mlme_err("Failed to get dynamic_nss_chains_support");
5477 		return QDF_STATUS_E_INVAL;
5478 	}
5479 
5480 	proto_generic_nss = wlan_vdev_mlme_get_nss(vdev);
5481 	if (dynamic_nss_chains_support) {
5482 		dynamic_cfg = mlme_get_dynamic_vdev_config(vdev);
5483 		if (!dynamic_cfg) {
5484 			mlme_err("nss chain dynamic config NULL");
5485 			return QDF_STATUS_E_INVAL;
5486 		}
5487 
5488 		operating_band = ucfg_cm_get_connected_band(vdev);
5489 		switch (operating_band) {
5490 		case BAND_2G:
5491 			*tx_nss = dynamic_cfg->tx_nss[NSS_CHAINS_BAND_2GHZ];
5492 			break;
5493 		case BAND_5G:
5494 			*tx_nss = dynamic_cfg->tx_nss[NSS_CHAINS_BAND_5GHZ];
5495 			break;
5496 		default:
5497 			mlme_err("Band %d Not 2G or 5G", operating_band);
5498 			return QDF_STATUS_E_INVAL;
5499 		}
5500 
5501 		if (*tx_nss > proto_generic_nss)
5502 			*tx_nss = proto_generic_nss;
5503 	} else {
5504 		*tx_nss = proto_generic_nss;
5505 	}
5506 
5507 	return QDF_STATUS_SUCCESS;
5508 }
5509 
wlan_mlme_get_sta_num_rx_chains(struct wlan_objmgr_psoc * psoc,struct wlan_objmgr_vdev * vdev,uint8_t * rx_chains)5510 QDF_STATUS wlan_mlme_get_sta_num_rx_chains(struct wlan_objmgr_psoc *psoc,
5511 					   struct wlan_objmgr_vdev *vdev,
5512 					   uint8_t *rx_chains)
5513 {
5514 	bool dynamic_nss_chains_support;
5515 	struct wlan_mlme_nss_chains *dynamic_cfg;
5516 	enum band_info operating_band;
5517 	QDF_STATUS status;
5518 	struct vdev_mlme_obj *vdev_mlme;
5519 
5520 	status = wlan_mlme_cfg_get_dynamic_nss_chains_support
5521 					(psoc, &dynamic_nss_chains_support);
5522 	if (QDF_IS_STATUS_ERROR(status)) {
5523 		mlme_err("Failed to get dynamic_nss_chains_support");
5524 		return QDF_STATUS_E_INVAL;
5525 	}
5526 	vdev_mlme =
5527 		wlan_objmgr_vdev_get_comp_private_obj(vdev,
5528 						      WLAN_UMAC_COMP_MLME);
5529 	if (!vdev_mlme) {
5530 		QDF_ASSERT(0);
5531 		return false;
5532 	}
5533 
5534 	if (dynamic_nss_chains_support) {
5535 		dynamic_cfg = mlme_get_dynamic_vdev_config(vdev);
5536 		if (!dynamic_cfg) {
5537 			mlme_err("nss chain dynamic config NULL");
5538 			return QDF_STATUS_E_INVAL;
5539 		}
5540 
5541 		operating_band = ucfg_cm_get_connected_band(vdev);
5542 		switch (operating_band) {
5543 		case BAND_2G:
5544 			*rx_chains =
5545 			dynamic_cfg->num_rx_chains[NSS_CHAINS_BAND_2GHZ];
5546 			break;
5547 		case BAND_5G:
5548 			*rx_chains =
5549 			dynamic_cfg->num_rx_chains[NSS_CHAINS_BAND_5GHZ];
5550 			break;
5551 		default:
5552 			mlme_err("Band %d Not 2G or 5G", operating_band);
5553 			return QDF_STATUS_E_INVAL;
5554 		}
5555 	}
5556 
5557 	return QDF_STATUS_SUCCESS;
5558 }
5559 
wlan_mlme_get_sta_rx_nss(struct wlan_objmgr_psoc * psoc,struct wlan_objmgr_vdev * vdev,uint8_t * rx_nss)5560 QDF_STATUS wlan_mlme_get_sta_rx_nss(struct wlan_objmgr_psoc *psoc,
5561 				    struct wlan_objmgr_vdev *vdev,
5562 				    uint8_t *rx_nss)
5563 {
5564 	uint8_t proto_generic_nss;
5565 	bool dynamic_nss_chains_support;
5566 	struct wlan_mlme_nss_chains *dynamic_cfg;
5567 	enum band_info operating_band;
5568 	QDF_STATUS status;
5569 
5570 	status = wlan_mlme_cfg_get_dynamic_nss_chains_support
5571 					(psoc, &dynamic_nss_chains_support);
5572 	if (QDF_IS_STATUS_ERROR(status)) {
5573 		mlme_err("Failed to get dynamic_nss_chains_support");
5574 		return QDF_STATUS_E_INVAL;
5575 	}
5576 
5577 	proto_generic_nss = wlan_vdev_mlme_get_nss(vdev);
5578 	if (dynamic_nss_chains_support) {
5579 		dynamic_cfg = mlme_get_dynamic_vdev_config(vdev);
5580 		if (!dynamic_cfg) {
5581 			mlme_err("nss chain dynamic config NULL");
5582 			return QDF_STATUS_E_INVAL;
5583 		}
5584 
5585 		operating_band = ucfg_cm_get_connected_band(vdev);
5586 		switch (operating_band) {
5587 		case BAND_2G:
5588 			*rx_nss = dynamic_cfg->rx_nss[NSS_CHAINS_BAND_2GHZ];
5589 			break;
5590 		case BAND_5G:
5591 			*rx_nss = dynamic_cfg->rx_nss[NSS_CHAINS_BAND_5GHZ];
5592 			break;
5593 		default:
5594 			mlme_err("Band %d Not 2G or 5G", operating_band);
5595 			return QDF_STATUS_E_INVAL;
5596 		}
5597 
5598 		if (*rx_nss > proto_generic_nss)
5599 			*rx_nss = proto_generic_nss;
5600 	} else {
5601 		*rx_nss = proto_generic_nss;
5602 	}
5603 
5604 	return QDF_STATUS_SUCCESS;
5605 }
5606 
5607 #ifdef WLAN_FEATURE_ROAM_OFFLOAD
5608 QDF_STATUS
wmi_extract_peer_oper_mode_event(wmi_unified_t wmi_handle,uint8_t * event,uint32_t len,struct peer_oper_mode_event * data)5609 wmi_extract_peer_oper_mode_event(wmi_unified_t wmi_handle,
5610 				 uint8_t *event,
5611 				 uint32_t len,
5612 				 struct peer_oper_mode_event *data)
5613 {
5614 	if (wmi_handle->ops->extract_peer_oper_mode_event)
5615 		return wmi_handle->ops->extract_peer_oper_mode_event(wmi_handle,
5616 								     event,
5617 								     len, data);
5618 	return QDF_STATUS_E_FAILURE;
5619 }
5620 
mlme_peer_oper_mode_change_event_handler(ol_scn_t scn,uint8_t * event,uint32_t len)5621 int mlme_peer_oper_mode_change_event_handler(ol_scn_t scn,
5622 					      uint8_t *event,
5623 					      uint32_t len)
5624 {
5625 	struct wlan_objmgr_psoc *psoc;
5626 	struct wmi_unified *wmi_handle;
5627 	struct peer_oper_mode_event data = {0};
5628 	struct wlan_mlme_rx_ops *mlme_rx_ops;
5629 	QDF_STATUS qdf_status;
5630 
5631 	psoc = target_if_get_psoc_from_scn_hdl(scn);
5632 	if (!psoc) {
5633 		target_if_err("psoc is null");
5634 		return -EINVAL;
5635 	}
5636 
5637 	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
5638 	if (!wmi_handle) {
5639 		mlme_err("wmi_handle is null");
5640 		return -EINVAL;
5641 	}
5642 
5643 	qdf_status = wmi_extract_peer_oper_mode_event(wmi_handle, event,
5644 						      len, &data);
5645 	if (QDF_IS_STATUS_ERROR(qdf_status)) {
5646 		mlme_err("parsing of event failed, %d", qdf_status);
5647 		return -EINVAL;
5648 	}
5649 
5650 	mlme_rx_ops = mlme_get_rx_ops(psoc);
5651 	if (!mlme_rx_ops || !mlme_rx_ops->peer_oper_mode_eventid) {
5652 		mlme_err("No valid roam rx ops");
5653 		return -EINVAL;
5654 	}
5655 
5656 	qdf_status = mlme_rx_ops->peer_oper_mode_eventid(psoc, &data);
5657 	if (QDF_IS_STATUS_ERROR(qdf_status)) {
5658 		mlme_err("peer_oper_mode_change_event Failed");
5659 		return -EINVAL;
5660 	}
5661 
5662 	return QDF_STATUS_SUCCESS;
5663 }
5664 
wlan_mlme_register_common_events(struct wlan_objmgr_psoc * psoc)5665 QDF_STATUS wlan_mlme_register_common_events(struct wlan_objmgr_psoc *psoc)
5666 {
5667 	QDF_STATUS ret;
5668 	wmi_unified_t handle = get_wmi_unified_hdl_from_psoc(psoc);
5669 
5670 	if (!handle) {
5671 		mlme_err("handle is NULL");
5672 		return QDF_STATUS_E_FAILURE;
5673 	}
5674 
5675 	/* Register for peer operating mode change devent */
5676 	ret = wmi_unified_register_event_handler(handle,
5677 				wmi_peer_oper_mode_change_event_id,
5678 				mlme_peer_oper_mode_change_event_handler,
5679 				WMI_RX_SERIALIZER_CTX);
5680 	if (QDF_IS_STATUS_ERROR(ret)) {
5681 		mlme_err("wmi event(%u) registration failed, ret: %d",
5682 			      wmi_peer_oper_mode_change_event_id, ret);
5683 		return QDF_STATUS_E_FAILURE;
5684 	}
5685 	return QDF_STATUS_SUCCESS;
5686 }
5687 #endif
5688 
5689 QDF_STATUS
wlan_mlme_send_csa_event_status_ind_cmd(struct wlan_objmgr_vdev * vdev,uint8_t csa_status)5690 wlan_mlme_send_csa_event_status_ind_cmd(struct wlan_objmgr_vdev *vdev,
5691 					uint8_t csa_status)
5692 {
5693 	struct wlan_objmgr_psoc *psoc;
5694 	struct  wlan_mlme_tx_ops *tx_ops;
5695 	mlme_psoc_ext_t *mlme_priv;
5696 
5697 	psoc = wlan_vdev_get_psoc(vdev);
5698 	if (!psoc) {
5699 		mlme_err("vdev_id %d psoc object is NULL",
5700 			 wlan_vdev_get_id(vdev));
5701 		return QDF_STATUS_E_FAILURE;
5702 	}
5703 
5704 	mlme_priv = wlan_psoc_mlme_get_ext_hdl(psoc);
5705 	if (!mlme_priv)
5706 		return QDF_STATUS_E_FAILURE;
5707 
5708 	tx_ops = &mlme_priv->mlme_tx_ops;
5709 
5710 	if (!tx_ops || !tx_ops->send_csa_event_status_ind) {
5711 		mlme_err("CSA no op defined");
5712 		return QDF_STATUS_E_FAILURE;
5713 	}
5714 
5715 	return tx_ops->send_csa_event_status_ind(vdev, csa_status);
5716 }
5717 
5718 uint8_t
wlan_mlme_get_sap_psd_for_20mhz(struct wlan_objmgr_vdev * vdev)5719 wlan_mlme_get_sap_psd_for_20mhz(struct wlan_objmgr_vdev *vdev)
5720 {
5721 	struct mlme_legacy_priv *mlme_priv;
5722 	enum QDF_OPMODE opmode = QDF_MAX_NO_OF_MODE;
5723 
5724 	mlme_priv = wlan_vdev_mlme_get_ext_hdl(vdev);
5725 	if (!mlme_priv) {
5726 		mlme_legacy_err("vdev legacy private object is NULL");
5727 		return 0;
5728 	}
5729 
5730 	opmode = wlan_vdev_mlme_get_opmode(vdev);
5731 	if (opmode != QDF_SAP_MODE) {
5732 		mlme_debug("Invalid opmode %d", opmode);
5733 		return 0;
5734 	}
5735 
5736 	return mlme_priv->mlme_ap.psd_20mhz;
5737 }
5738 
5739 QDF_STATUS
wlan_mlme_set_sap_psd_for_20mhz(struct wlan_objmgr_vdev * vdev,uint8_t psd_power)5740 wlan_mlme_set_sap_psd_for_20mhz(struct wlan_objmgr_vdev *vdev,
5741 				uint8_t psd_power)
5742 {
5743 	struct mlme_legacy_priv *mlme_priv;
5744 	enum QDF_OPMODE opmode = QDF_MAX_NO_OF_MODE;
5745 
5746 	mlme_priv = wlan_vdev_mlme_get_ext_hdl(vdev);
5747 	if (!mlme_priv) {
5748 		mlme_legacy_err("vdev legacy private object is NULL");
5749 		return QDF_STATUS_E_INVAL;
5750 	}
5751 
5752 	opmode = wlan_vdev_mlme_get_opmode(vdev);
5753 	if (opmode != QDF_SAP_MODE) {
5754 		mlme_debug("Invalid opmode %d", opmode);
5755 		return QDF_STATUS_E_INVAL;
5756 	}
5757 
5758 	mlme_priv->mlme_ap.psd_20mhz = psd_power;
5759 	return QDF_STATUS_SUCCESS;
5760 }
5761 
5762 /**
5763  * wlan_peer_find_mld_peer_n_get_mac_info() - This API will find MLD peer from
5764  * peer list.
5765  * @psoc: Pointer to psoc object
5766  * @obj: Pointer to peer object
5767  * @args: Pointer to void * argument
5768  *
5769  * Return: void
5770  */
5771 static void
wlan_peer_find_mld_peer_n_get_mac_info(struct wlan_objmgr_psoc * psoc,void * obj,void * args)5772 wlan_peer_find_mld_peer_n_get_mac_info(struct wlan_objmgr_psoc *psoc,
5773 				       void *obj, void *args)
5774 {
5775 	struct wlan_objmgr_peer *peer = (struct wlan_objmgr_peer *)obj;
5776 	struct peer_mac_addresses *peer_mac_info =
5777 				(struct peer_mac_addresses *)args;
5778 	uint8_t *mld_mac, *peer_mac, *given_mac;
5779 
5780 	mld_mac = wlan_peer_mlme_get_mldaddr(peer);
5781 	peer_mac = wlan_peer_get_macaddr(peer);
5782 	given_mac = peer_mac_info->mac.bytes;
5783 
5784 	if (!mld_mac || WLAN_ADDR_EQ(mld_mac, given_mac) != QDF_STATUS_SUCCESS)
5785 		return;
5786 	qdf_copy_macaddr(&peer_mac_info->peer_mac,
5787 			 (struct qdf_mac_addr *)peer_mac);
5788 	qdf_copy_macaddr(&peer_mac_info->peer_mld,
5789 			 (struct qdf_mac_addr *)mld_mac);
5790 }
5791 
wlan_find_peer_and_get_mac_and_mld_addr(struct wlan_objmgr_psoc * psoc,struct peer_mac_addresses * peer_mac_info)5792 QDF_STATUS wlan_find_peer_and_get_mac_and_mld_addr(
5793 				struct wlan_objmgr_psoc *psoc,
5794 				struct peer_mac_addresses *peer_mac_info)
5795 {
5796 	struct wlan_objmgr_peer *peer;
5797 	QDF_STATUS status = QDF_STATUS_SUCCESS;
5798 
5799 	peer = wlan_objmgr_get_peer_by_mac(psoc, peer_mac_info->mac.bytes,
5800 					   WLAN_LEGACY_MAC_ID);
5801 	if (peer) {
5802 		qdf_copy_macaddr(
5803 			&peer_mac_info->peer_mac,
5804 			(struct qdf_mac_addr *)wlan_peer_get_macaddr(peer));
5805 		if (wlan_peer_mlme_get_mldaddr(peer))
5806 			qdf_copy_macaddr(
5807 				&peer_mac_info->peer_mld,
5808 				(struct qdf_mac_addr *)
5809 				wlan_peer_mlme_get_mldaddr(peer));
5810 		wlan_objmgr_peer_release_ref(peer, WLAN_LEGACY_MAC_ID);
5811 		return status;
5812 	}
5813 
5814 	/* if not found with mac address try finding using MLD address */
5815 	wlan_objmgr_iterate_obj_list(psoc, WLAN_PEER_OP,
5816 				     wlan_peer_find_mld_peer_n_get_mac_info,
5817 				     peer_mac_info, 0, WLAN_LEGACY_MAC_ID);
5818 	if (qdf_is_macaddr_zero(&peer_mac_info->peer_mac)) {
5819 		mlme_err("peer is null for mac:" QDF_MAC_ADDR_FMT,
5820 			 QDF_MAC_ADDR_REF(peer_mac_info->mac.bytes));
5821 		return QDF_STATUS_E_EXISTS;
5822 	}
5823 
5824 	return status;
5825 }
5826