1 /*
2  * Copyright (c) 2018-2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for
6  * any purpose with or without fee is hereby granted, provided that the
7  * above copyright notice and this permission notice appear in all
8  * copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17  * PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 /**
21  * DOC: init_cmd_api.c
22  *
23  * WMI Init command prepare & send APIs
24  */
25 #include <qdf_status.h>
26 #include <qdf_types.h>
27 #include <wlan_objmgr_psoc_obj.h>
28 #include <wlan_objmgr_pdev_obj.h>
29 #include <target_if.h>
30 #include <service_ready_util.h>
31 #include <wlan_tgt_def_config.h>
32 #include <wlan_reg_ucfg_api.h>
33 #include <init_cmd_api.h>
34 #include <target_if_scan.h>
35 #include <target_if_reg.h>
36 #include <target_if_twt.h>
37 #include <cdp_txrx_ctrl.h>
38 
39 /**
40  *  init_deinit_alloc_host_mem_chunk() - allocates chunk of memory requested
41  *                                       by FW.
42  *  @psoc: PSOC object
43  *  @tgt_hdl: Target PSOC info
44  *  @req_id: request id
45  *  @idx: chunk id
46  *  @num_units: Number of units
47  *  @unit_len: Unit length
48  *  @num_unit_info: Num unit info
49  *
50  *  API to allocate host memory chunk requested by FW
51  *
52  *  Return: num_units on successful allocation
53  *          0 on failure
54  */
init_deinit_alloc_host_mem_chunk(struct wlan_objmgr_psoc * psoc,struct target_psoc_info * tgt_hdl,u_int32_t req_id,u_int32_t idx,u_int32_t num_units,u_int32_t unit_len,u_int32_t num_unit_info)55 static uint32_t init_deinit_alloc_host_mem_chunk(struct wlan_objmgr_psoc *psoc,
56 			struct target_psoc_info *tgt_hdl,
57 			u_int32_t req_id, u_int32_t idx, u_int32_t num_units,
58 			u_int32_t unit_len, u_int32_t num_unit_info)
59 {
60 	qdf_dma_addr_t paddr;
61 	uint32_t ichunk = 0;
62 	struct tgt_info *info;
63 	qdf_device_t qdf_dev;
64 
65 	info = (&tgt_hdl->info);
66 
67 	if (!num_units  || !unit_len)
68 		return 0;
69 
70 	qdf_dev = wlan_psoc_get_qdf_dev(psoc);
71 	if (!qdf_dev)
72 		return 0;
73 
74 	/*
75 	 * We have skip smaller chunks memory allocation for TXBF_CV and
76 	 * CFR_CAPTURE buffer as Firmware is expecting continuous memory
77 	 */
78 	if (!((num_unit_info & HOST_CONTIGUOUS_MEM_CHUNK_REQUIRED) &&
79 	      (req_id == TXBF_CV_POOL0 || req_id == TXBF_CV_POOL1 ||
80 	      req_id == TXBF_CV_POOL2 ||
81 	      req_id == CFR_CAPTURE_HOST_MEM_REQ_ID))) {
82 		ichunk = ((num_units * unit_len) >>
83 			HOST_MEM_CHUNK_MAX_SIZE_POWER2);
84 		if (ichunk)
85 			num_units = num_units / (ichunk + 1);
86 	}
87 
88 	info->mem_chunks[idx].vaddr = NULL;
89 	/* reduce the requested allocation by half until allocation succeeds */
90 	while (!info->mem_chunks[idx].vaddr && num_units) {
91 		info->mem_chunks[idx].vaddr = qdf_mem_alloc_consistent(qdf_dev,
92 				qdf_dev->dev, num_units * unit_len, &paddr);
93 		if (!info->mem_chunks[idx].vaddr) {
94 			if (num_unit_info &
95 					HOST_CONTIGUOUS_MEM_CHUNK_REQUIRED) {
96 				num_units = 0;
97 				target_if_err("mem chink alloc failed for %d",
98 					      idx);
99 				break;
100 			}
101 			/* reduce length by half */
102 			num_units = (num_units >> 1);
103 		} else {
104 			info->mem_chunks[idx].paddr = paddr;
105 			info->mem_chunks[idx].len = num_units*unit_len;
106 			info->mem_chunks[idx].req_id =  req_id;
107 		}
108 	}
109 	target_if_debug("req_id %d idx %d num_units %d unit_len %d",
110 			req_id, idx, num_units, unit_len);
111 
112 	return num_units;
113 }
114 
115 /* Host mem size units, it is used for round-off */
116 #define HOST_MEM_SIZE_UNIT 4
117 
118 /**
119  *  init_deinit_alloc_host_mem() - allocates amount of memory requested by FW.
120  *  @psoc: PSOC object
121  *  @tgt_hdl: Target PSOC info
122  *  @req_id: request id
123  *  @num_units: Number of units
124  *  @unit_len: Unit length
125  *  @num_unit_info: Num unit info
126  *
127  *  API to allocate host memory requested by FW
128  *
129  *  Return: QDF_STATUS_SUCCESS on successful allocation
130  *          QDF_STATUS_E_FAILURE on failure
131  */
init_deinit_alloc_host_mem(struct wlan_objmgr_psoc * psoc,struct target_psoc_info * tgt_hdl,u_int32_t req_id,u_int32_t num_units,u_int32_t unit_len,u_int32_t num_unit_info)132 static QDF_STATUS init_deinit_alloc_host_mem(struct wlan_objmgr_psoc *psoc,
133 		struct target_psoc_info *tgt_hdl, u_int32_t req_id,
134 		u_int32_t num_units, u_int32_t unit_len,
135 		u_int32_t num_unit_info)
136 {
137 	struct tgt_info *info;
138 	uint32_t remaining_units;
139 	uint32_t allocated_units = 0;
140 	uint32_t idx;
141 
142 	info = (&tgt_hdl->info);
143 	/* adjust the length to nearest multiple of unit size */
144 	unit_len = (unit_len + (HOST_MEM_SIZE_UNIT - 1)) &
145 				(~(HOST_MEM_SIZE_UNIT - 1));
146 	idx = info->num_mem_chunks;
147 	remaining_units = num_units;
148 
149 	while (remaining_units) {
150 		if (idx == MAX_MEM_CHUNKS) {
151 			target_if_err(
152 				"REACHED MAX CHUNK LIMIT for mem units %d",
153 					num_units);
154 			target_if_err(
155 			"unit len %d requested by FW, only allocated %d",
156 				unit_len, (num_units - remaining_units));
157 			info->num_mem_chunks = idx;
158 			return QDF_STATUS_E_FAILURE;
159 		}
160 
161 		if ((tgt_hdl->tif_ops) &&
162 		    (tgt_hdl->tif_ops->mem_mgr_alloc_chunk))
163 			allocated_units = tgt_hdl->tif_ops->mem_mgr_alloc_chunk(
164 						psoc, tgt_hdl, req_id, idx,
165 						remaining_units,
166 						unit_len, num_unit_info);
167 		else
168 			allocated_units = init_deinit_alloc_host_mem_chunk(
169 						psoc, tgt_hdl, req_id, idx,
170 						remaining_units,
171 						unit_len, num_unit_info);
172 		if (allocated_units == 0) {
173 			target_if_err("FAILED TO ALLOC mem unit len %d",
174 				      unit_len);
175 			target_if_err("units requested %d units allocated %d",
176 				      num_units, (num_units - remaining_units));
177 			info->num_mem_chunks = idx;
178 			return QDF_STATUS_E_NOMEM;
179 		}
180 		remaining_units -= allocated_units;
181 		++idx;
182 	}
183 	info->num_mem_chunks = idx;
184 
185 	return QDF_STATUS_SUCCESS;
186 }
187 
init_deinit_free_num_units(struct wlan_objmgr_psoc * psoc,struct target_psoc_info * tgt_hdl)188 QDF_STATUS init_deinit_free_num_units(struct wlan_objmgr_psoc *psoc,
189 			struct target_psoc_info *tgt_hdl)
190 {
191 	struct tgt_info *info;
192 	qdf_device_t qdf_dev;
193 	uint32_t idx;
194 	QDF_STATUS status;
195 
196 	if (!tgt_hdl) {
197 		target_if_err("target_psoc_info is null");
198 		return QDF_STATUS_E_INVAL;
199 	}
200 
201 	if ((tgt_hdl->tif_ops) &&
202 	    (tgt_hdl->tif_ops->mem_mgr_free_chunks)) {
203 		status = tgt_hdl->tif_ops->mem_mgr_free_chunks(psoc, tgt_hdl);
204 	} else {
205 		qdf_dev = wlan_psoc_get_qdf_dev(psoc);
206 		if (!qdf_dev) {
207 			target_if_err("qdf_dev is null");
208 			QDF_BUG(0);
209 			return QDF_STATUS_E_INVAL;
210 		}
211 		info = (&tgt_hdl->info);
212 		for (idx = 0; idx < info->num_mem_chunks; idx++) {
213 			qdf_mem_free_consistent(
214 					qdf_dev, qdf_dev->dev,
215 					info->mem_chunks[idx].len,
216 					info->mem_chunks[idx].vaddr,
217 					info->mem_chunks[idx].paddr,
218 					qdf_get_dma_mem_context(
219 					(&info->mem_chunks[idx]), memctx));
220 
221 			info->mem_chunks[idx].vaddr = NULL;
222 			info->mem_chunks[idx].paddr = 0;
223 			info->mem_chunks[idx].len = 0;
224 		}
225 		info->num_mem_chunks = 0;
226 		status = QDF_STATUS_SUCCESS;
227 	}
228 
229 	return status;
230 }
231 
init_deinit_handle_host_mem_req(struct wlan_objmgr_psoc * psoc,struct target_psoc_info * tgt_hdl,uint8_t * event)232 QDF_STATUS init_deinit_handle_host_mem_req(
233 		struct wlan_objmgr_psoc *psoc,
234 		struct target_psoc_info *tgt_hdl, uint8_t *event)
235 {
236 	uint32_t num_mem_reqs;
237 	host_mem_req mem_reqs;
238 	uint32_t i;
239 	uint32_t idx;
240 	QDF_STATUS status = QDF_STATUS_SUCCESS;
241 	struct wmi_unified *wmi_handle;
242 	struct tgt_info *info;
243 
244 	if (!tgt_hdl) {
245 		target_if_err("target_psoc_info is null");
246 		return QDF_STATUS_E_INVAL;
247 	}
248 
249 	wmi_handle = target_psoc_get_wmi_hdl(tgt_hdl);
250 	info = (&tgt_hdl->info);
251 
252 	num_mem_reqs = wmi_extract_num_mem_reqs_from_service_ready(
253 							wmi_handle, event);
254 	if (!num_mem_reqs)
255 		return QDF_STATUS_SUCCESS;
256 
257 	if (num_mem_reqs > MAX_MEM_CHUNKS) {
258 		target_if_err_rl("num_mem_reqs:%u is out of bounds",
259 				num_mem_reqs);
260 		return QDF_STATUS_E_FAILURE;
261 	}
262 
263 	for (i = 0; i < WMI_FW_PRIORITY_MAX; i++) {
264 		for (idx = 0; idx < num_mem_reqs; idx++) {
265 			status = wmi_extract_host_mem_req_from_service_ready(
266 					wmi_handle, event, &mem_reqs,
267 					info->wlan_res_cfg.num_active_peers,
268 					info->wlan_res_cfg.num_peers, i, idx);
269 			if (mem_reqs.tgt_num_units) {
270 				status = init_deinit_alloc_host_mem(
271 						psoc,
272 						tgt_hdl,
273 						mem_reqs.req_id,
274 						mem_reqs.tgt_num_units,
275 						mem_reqs.unit_size,
276 						mem_reqs.num_unit_info);
277 				if (status == QDF_STATUS_E_FAILURE) {
278 					target_if_err("num_mem_chunk exceeds supp number");
279 				} else if (status == QDF_STATUS_E_NOMEM) {
280 					target_if_err("mem alloc failure");
281 				}
282 			}
283 
284 			if (status != QDF_STATUS_SUCCESS)
285 				return status;
286 		}
287 	}
288 
289 	return status;
290 }
291 
292 #ifdef FEATURE_NO_DBS_INTRABAND_MCC_SUPPORT
293 /**
294  * is_num_band_to_mac_required() - host needs to configure MACs or not.
295  * @tgt_hdl: Pointer to target handle
296  *
297  * if num of mac per band is sent by host then FW will not initialize
298  * its data structure with its default value. Host either have to set
299  * these value as per current HW mode or else these variable should be
300  * initialized to 0.
301  * Ex - If host is sending default HW mode as DBS in INIT_CMDID and FW
302  * doesn't advertise wmi_service_dual_band_simultaneous_support then host
303  * must not configure MACs and FW should configure with default values.
304  *
305  * @return: true if host needs to configure MACs else false
306  */
is_num_band_to_mac_required(struct target_psoc_info * tgt_hdl)307 static bool is_num_band_to_mac_required(struct target_psoc_info *tgt_hdl)
308 {
309 	struct tgt_info *info;
310 	struct wmi_unified *wmi_handle;
311 
312 	if (!tgt_hdl)
313 		return true;
314 
315 	wmi_handle = target_psoc_get_wmi_hdl(tgt_hdl);
316 	info = (&tgt_hdl->info);
317 
318 	if ((info->hw_modes.num_modes == 1) &&
319 	    (info->hw_modes.hw_mode_ids[0] == WMI_HOST_HW_MODE_DBS) &&
320 	    !wmi_service_enabled(wmi_handle,
321 				 wmi_service_dual_band_simultaneous_support))
322 		return false;
323 
324 	return true;
325 }
326 #else
is_num_band_to_mac_required(struct target_psoc_info * tgt_hdl)327 static bool is_num_band_to_mac_required(struct target_psoc_info *tgt_hdl)
328 {
329 	return true;
330 }
331 #endif
332 
init_deinit_derive_band_to_mac_param(struct wlan_objmgr_psoc * psoc,struct target_psoc_info * tgt_hdl,struct wmi_init_cmd_param * init_param)333 void init_deinit_derive_band_to_mac_param(
334 		struct wlan_objmgr_psoc *psoc,
335 		struct target_psoc_info *tgt_hdl,
336 		struct wmi_init_cmd_param *init_param)
337 {
338 	uint8_t i;
339 	struct wlan_psoc_host_mac_phy_caps *mac_phy_cap;
340 	struct wlan_psoc_host_hal_reg_capabilities_ext *reg_cap;
341 	struct wmi_host_pdev_band_to_mac *band_to_mac = init_param->band_to_mac;
342 
343 	if (!tgt_hdl) {
344 		target_if_err("target_psoc_info is null ");
345 		return;
346 	}
347 
348 	reg_cap = ucfg_reg_get_hal_reg_cap(psoc);
349 	if (!reg_cap) {
350 		target_if_err("reg cap is NULL");
351 		return;
352 	}
353 
354 	mac_phy_cap = target_psoc_get_mac_phy_cap(tgt_hdl);
355 	if (!mac_phy_cap) {
356 		target_if_err("mac_phy_cap is NULL");
357 		return;
358 	}
359 	if (is_num_band_to_mac_required(tgt_hdl))
360 		init_param->num_band_to_mac =
361 			target_psoc_get_num_radios(tgt_hdl);
362 
363 	for (i = 0; i < target_psoc_get_num_radios(tgt_hdl); i++) {
364 		if (mac_phy_cap->supported_bands ==
365 			(WMI_HOST_WLAN_5G_CAPABILITY |
366 					WMI_HOST_WLAN_2G_CAPABILITY)) {
367 			/*Supports both 5G and 2G. Use freq from both radios*/
368 			target_if_debug("Supports both 2G and 5G");
369 			band_to_mac[i].pdev_id = mac_phy_cap->pdev_id;
370 			band_to_mac[i].start_freq =
371 					reg_cap[i].low_2ghz_chan;
372 			band_to_mac[i].end_freq =
373 					reg_cap[i].high_5ghz_chan;
374 
375 		} else if (mac_phy_cap->supported_bands ==
376 				WMI_HOST_WLAN_2G_CAPABILITY) {
377 			reg_cap[mac_phy_cap->phy_id].low_5ghz_chan = 0;
378 			reg_cap[mac_phy_cap->phy_id].high_5ghz_chan = 0;
379 
380 			if (!init_param->num_band_to_mac)
381 				goto next_mac_phy_cap;
382 
383 			band_to_mac[i].pdev_id = mac_phy_cap->pdev_id;
384 			band_to_mac[i].start_freq =
385 					reg_cap[i].low_2ghz_chan;
386 			band_to_mac[i].end_freq =
387 					reg_cap[i].high_2ghz_chan;
388 			target_if_debug("2G radio - pdev_id = %d start_freq = %d end_freq= %d",
389 				       band_to_mac[i].pdev_id,
390 				       band_to_mac[i].start_freq,
391 				       band_to_mac[i].end_freq);
392 
393 		} else if (mac_phy_cap->supported_bands ==
394 					WMI_HOST_WLAN_5G_CAPABILITY) {
395 			reg_cap[mac_phy_cap->phy_id].low_2ghz_chan = 0;
396 			reg_cap[mac_phy_cap->phy_id].high_2ghz_chan = 0;
397 
398 			if (!init_param->num_band_to_mac)
399 				goto next_mac_phy_cap;
400 
401 			band_to_mac[i].pdev_id = mac_phy_cap->pdev_id;
402 			band_to_mac[i].start_freq =
403 						reg_cap[i].low_5ghz_chan;
404 			band_to_mac[i].end_freq =
405 						reg_cap[i].high_5ghz_chan;
406 
407 			target_if_debug("5G radio -pdev_id = %d start_freq = %d end_freq =%d\n",
408 				       band_to_mac[i].pdev_id,
409 				       band_to_mac[i].start_freq,
410 				       band_to_mac[i].end_freq);
411 		}
412 
413 next_mac_phy_cap:
414 		mac_phy_cap++;
415 	}
416 }
417 
418 #if defined(CONFIG_AFC_SUPPORT)
419 /**
420  * init_deinit_derive_afc_dev_type_param() - Derive AFC init deployment param
421  *
422  * @psoc: PSOC object
423  * @init_param: Pointer to init param
424  *
425  * Return: void
426  */
init_deinit_derive_afc_dev_type_param(struct wlan_objmgr_psoc * psoc,struct wmi_init_cmd_param * init_param)427 static void init_deinit_derive_afc_dev_type_param(
428 		struct wlan_objmgr_psoc *psoc,
429 		struct wmi_init_cmd_param *init_param)
430 {
431 	enum reg_afc_dev_deploy_type reg_afc_dev_type;
432 	target_resource_config *tgt_cfg;
433 	QDF_STATUS ret_val;
434 
435 	tgt_cfg = init_param->res_cfg;
436 
437 	ret_val = target_if_reg_get_afc_dev_type(psoc,
438 						 &reg_afc_dev_type);
439 
440 	if (QDF_IS_STATUS_ERROR(ret_val)) {
441 		target_if_err("get afc dev type failed");
442 		return;
443 	}
444 	tgt_cfg->afc_indoor_support = false;
445 	tgt_cfg->afc_outdoor_support = false;
446 	if (reg_afc_dev_type == AFC_DEPLOYMENT_INDOOR)
447 		tgt_cfg->afc_indoor_support = true;
448 	else if (reg_afc_dev_type == AFC_DEPLOYMENT_OUTDOOR)
449 		tgt_cfg->afc_outdoor_support = true;
450 }
451 #else
init_deinit_derive_afc_dev_type_param(struct wlan_objmgr_psoc * psoc,struct wmi_init_cmd_param * init_param)452 static inline void init_deinit_derive_afc_dev_type_param(
453 		struct wlan_objmgr_psoc *psoc,
454 		struct wmi_init_cmd_param *init_param)
455 {
456 }
457 #endif
458 
459 #ifdef WLAN_FEATURE_11BE_MLO
460 #ifdef FEATURE_WLAN_TDLS
461 static void
init_deinit_set_tdls_mlo_vdev(struct wmi_init_cmd_param * init_param,struct wmi_unified * wmi_handle)462 init_deinit_set_tdls_mlo_vdev(struct wmi_init_cmd_param *init_param,
463 			      struct wmi_unified *wmi_handle)
464 {
465 	if (wmi_service_enabled(wmi_handle, wmi_service_tdls_mlo_support))
466 		init_param->res_cfg->num_tdls_vdevs = WLAN_UMAC_MLO_MAX_VDEVS;
467 }
468 #else
469 static void
init_deinit_set_tdls_mlo_vdev(struct wmi_init_cmd_param * init_param,struct wmi_unified * wmi_handle)470 init_deinit_set_tdls_mlo_vdev(struct wmi_init_cmd_param *init_param,
471 			      struct wmi_unified *wmi_handle)
472 {}
473 #endif
474 #else
475 static void
init_deinit_set_tdls_mlo_vdev(struct wmi_init_cmd_param * init_param,struct wmi_unified * wmi_handle)476 init_deinit_set_tdls_mlo_vdev(struct wmi_init_cmd_param *init_param,
477 			      struct wmi_unified *wmi_handle)
478 {}
479 #endif
480 
481 /**
482  * init_deinit_set_dp_rx_peer_metadata_ver() - update RX peer metadata
483  *                                             version to DP
484  * @psoc: PSOC object
485  * @peer_md_ver: peer metadata version value
486  *
487  * Return: None
488  */
489 static void
init_deinit_set_dp_rx_peer_metadata_ver(struct wlan_objmgr_psoc * psoc,uint8_t peer_md_ver)490 init_deinit_set_dp_rx_peer_metadata_ver(struct wlan_objmgr_psoc *psoc,
491 					uint8_t peer_md_ver)
492 {
493 	ol_txrx_soc_handle soc;
494 	cdp_config_param_type val = {0};
495 
496 	val.cdp_peer_metadata_ver = peer_md_ver;
497 	soc = wlan_psoc_get_dp_handle(psoc);
498 
499 	cdp_txrx_set_psoc_param(soc, CDP_CFG_RX_PEER_METADATA_VER,
500 				val);
501 }
502 
init_deinit_prepare_send_init_cmd(struct wlan_objmgr_psoc * psoc,struct target_psoc_info * tgt_hdl)503 void init_deinit_prepare_send_init_cmd(
504 		 struct wlan_objmgr_psoc *psoc,
505 		 struct target_psoc_info *tgt_hdl)
506 {
507 	struct wmi_init_cmd_param init_param = {0};
508 	struct tgt_info *info;
509 	struct wmi_unified *wmi_handle;
510 	QDF_STATUS ret_val;
511 	uint32_t fw_build_vers_ext;
512 
513 	if (!tgt_hdl) {
514 		target_if_err("target_psoc_info is null");
515 		return;
516 	}
517 
518 	wmi_handle = target_psoc_get_wmi_hdl(tgt_hdl);
519 	info = (&tgt_hdl->info);
520 
521 	init_param.res_cfg = &info->wlan_res_cfg;
522 	init_param.num_mem_chunks = info->num_mem_chunks;
523 	init_param.mem_chunks = info->mem_chunks;
524 
525 	if (init_deinit_is_service_ext_msg(psoc, tgt_hdl) ==
526 			QDF_STATUS_SUCCESS) {
527 		init_param.hw_mode_id = info->preferred_hw_mode;
528 		/* Temp change, until FW submits support for handling this TLV
529 		 * For single mode, skip sending hw_mode
530 		 */
531 		if (info->preferred_hw_mode == WMI_HOST_HW_MODE_SINGLE)
532 			init_param.hw_mode_id = WMI_HOST_HW_MODE_MAX;
533 
534 		init_deinit_derive_band_to_mac_param(psoc, tgt_hdl,
535 						     &init_param);
536 	} else {
537 		ret_val = tgt_if_regulatory_modify_freq_range(psoc);
538 		if (QDF_IS_STATUS_ERROR(ret_val)) {
539 			target_if_err("Modify freq range is failed");
540 			return;
541 		}
542 	}
543 
544 	ret_val = target_if_alloc_pdevs(psoc, tgt_hdl);
545 	if (ret_val != QDF_STATUS_SUCCESS)
546 		return;
547 
548 	ret_val = target_if_update_pdev_tgt_info(psoc, tgt_hdl);
549 	if (ret_val != QDF_STATUS_SUCCESS)
550 		return;
551 
552 	info->wlan_res_cfg.max_ndp_sessions =
553 		QDF_MIN(info->wlan_res_cfg.max_ndp_sessions,
554 			info->service_ext2_param.max_ndp_sessions);
555 
556 	if (info->service_ext2_param.twt_ack_support_cap) {
557 		info->wlan_res_cfg.twt_ack_support_cap = true;
558 		target_if_twt_set_twt_ack_support(psoc, true);
559 	}
560 
561 	info->wlan_res_cfg.target_cap_flags =
562 		target_psoc_get_target_cap_flags(tgt_hdl);
563 
564 	target_if_debug("FW version 0x%x ", info->target_caps.fw_version);
565 	if (init_deinit_is_service_ext_msg(psoc, tgt_hdl) ==
566 							QDF_STATUS_SUCCESS) {
567 		fw_build_vers_ext = info->service_ext_param.fw_build_vers_ext;
568 		target_if_debug("fw_build_vers_ext:0x%x HDL version info:0x%0x, CRM sub ID:0x%x\n",
569 				fw_build_vers_ext, fw_build_vers_ext & 0x3FF,
570 				(fw_build_vers_ext >> 25) & 0x7F);
571 	} else {
572 		target_if_debug("0x%x\n", info->target_caps.fw_version_1);
573 	}
574 
575 	if (wmi_service_enabled(wmi_handle, wmi_service_ext2_msg))
576 		init_deinit_derive_afc_dev_type_param(psoc, &init_param);
577 
578 	if (wmi_service_enabled(wmi_handle, wmi_service_v1a_v1b_supported))
579 		info->wlan_res_cfg.dp_peer_meta_data_ver =
580 					CDP_RX_PEER_METADATA_V1_A_B;
581 	else
582 		info->wlan_res_cfg.dp_peer_meta_data_ver =
583 			target_psoc_get_target_dp_peer_meta_data_ver(tgt_hdl);
584 
585 	/* notify DP rx peer metadata version */
586 	init_deinit_set_dp_rx_peer_metadata_ver(
587 			psoc, info->wlan_res_cfg.dp_peer_meta_data_ver);
588 
589 	init_deinit_set_tdls_mlo_vdev(&init_param, wmi_handle);
590 
591 	target_if_ext_res_cfg_enable(psoc, tgt_hdl, NULL);
592 
593 	target_if_set_reo_shared_qref_feature(psoc, info);
594 
595 	target_if_set_num_max_mlo_link(psoc, info);
596 
597 	wmi_unified_init_cmd_send(wmi_handle, &init_param);
598 
599 	/* Set Max scans allowed */
600 	target_if_scan_set_max_active_scans(psoc,
601 					    WLAN_MAX_ACTIVE_SCANS_ALLOWED);
602 
603 	if (wmi_service_enabled(wmi_handle, wmi_service_hw_db2dbm_support))
604 		wlan_psoc_nif_fw_ext_cap_set(psoc, WLAN_SOC_CEXT_HW_DB2DBM);
605 }
606