xref: /wlan-dirver/qca-wifi-host-cmn/target_if/init_deinit/src/init_event_handler.c (revision 70a19e16789e308182f63b15c75decec7bf0b342)
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_event_handler.c
22  *
23  * WMI common event handler implementation source file
24  */
25 
26 #include <qdf_status.h>
27 #include <wlan_objmgr_psoc_obj.h>
28 #include <wlan_objmgr_pdev_obj.h>
29 #include <target_if.h>
30 #include <target_if_reg.h>
31 #include <init_event_handler.h>
32 #include <service_ready_util.h>
33 #include <service_ready_param.h>
34 #include <init_cmd_api.h>
35 #include <cdp_txrx_cmn.h>
36 #include <wlan_reg_ucfg_api.h>
37 #if defined(WLAN_FEATURE_11BE_MLO) && defined(WLAN_MLO_MULTI_CHIP)
38 #include <wlan_mlo_mgr_cmn.h>
39 #include <wlan_mlo_mgr_setup.h>
40 #endif
41 #include <target_if_twt.h>
42 
43 static void init_deinit_set_send_init_cmd(struct wlan_objmgr_psoc *psoc,
44 					  struct target_psoc_info *tgt_hdl)
45 {
46 	tgt_hdl->info.wmi_service_ready = TRUE;
47 	/* send init command */
48 	init_deinit_prepare_send_init_cmd(psoc, tgt_hdl);
49 }
50 
51 #ifdef WLAN_FEATURE_P2P_P2P_STA
52 static void
53 init_deinit_update_p2p_p2p_conc_support(struct wmi_unified *wmi_handle,
54 					struct wlan_objmgr_psoc *psoc)
55 {
56 	if (wmi_service_enabled(wmi_handle, wmi_service_p2p_p2p_cc_support))
57 		wlan_psoc_nif_fw_ext_cap_set(psoc,
58 					     WLAN_SOC_EXT_P2P_P2P_CONC_SUPPORT);
59 	else
60 		target_if_debug("P2P + P2P conc disabled");
61 }
62 #else
63 static inline void
64 init_deinit_update_p2p_p2p_conc_support(struct wmi_unified *wmi_handle,
65 					struct wlan_objmgr_psoc *psoc)
66 {}
67 #endif
68 
69 #ifdef QCA_RSSI_DB2DBM
70 static void
71 init_deinit_update_rssi_dbm_conv_support(struct wmi_unified *wmi_handle,
72 					 struct wlan_objmgr_psoc *psoc)
73 {
74 	/* Send RSSI_DBM_CONV to DP layer */
75 	if (wmi_service_enabled(wmi_handle,
76 				wmi_service_pdev_rssi_dbm_conv_event_support))
77 		cdp_soc_set_param(wlan_psoc_get_dp_handle(psoc),
78 				  DP_SOC_PARAM_RSSI_DBM_CONV_SUPPORT, 1);
79 }
80 #else
81 static inline void
82 init_deinit_update_rssi_dbm_conv_support(struct wmi_unified *wmi_handle,
83 					 struct wlan_objmgr_psoc *psoc)
84 {}
85 #endif
86 
87 #ifdef WIFI_POS_CONVERGED
88 static inline void
89 init_deinit_update_wifi_pos_caps(struct wmi_unified *wmi_handle,
90 				 struct wlan_objmgr_psoc *psoc)
91 {
92 	if (wmi_service_enabled(wmi_handle, wmi_service_rtt_11az_ntb_support))
93 		wlan_psoc_nif_fw_ext_cap_set(psoc,
94 					     WLAN_RTT_11AZ_NTB_SUPPORT);
95 
96 	if (wmi_service_enabled(wmi_handle, wmi_service_rtt_11az_tb_support))
97 		wlan_psoc_nif_fw_ext2_cap_set(psoc,
98 					      WLAN_RTT_11AZ_TB_SUPPORT);
99 
100 	if (wmi_service_enabled(wmi_handle,
101 				wmi_service_rtt_11az_mac_sec_support))
102 		wlan_psoc_nif_fw_ext2_cap_set(psoc,
103 					      WLAN_RTT_11AZ_MAC_SEC_SUPPORT);
104 
105 	if (wmi_service_enabled(wmi_handle,
106 				wmi_service_rtt_11az_mac_phy_sec_support))
107 		wlan_psoc_nif_fw_ext2_cap_set(
108 				psoc, WLAN_RTT_11AZ_MAC_PHY_SEC_SUPPORT);
109 }
110 #else
111 static inline void
112 init_deinit_update_wifi_pos_caps(struct wmi_unified *wmi_handle,
113 				 struct wlan_objmgr_psoc *psoc)
114 {}
115 #endif
116 
117 #ifdef WLAN_FEATURE_ROAM_OFFLOAD
118 static void
119 init_deinit_update_roam_stats_cap(struct wmi_unified *wmi_handle,
120 				  struct wlan_objmgr_psoc *psoc)
121 {
122 	if (wmi_service_enabled(wmi_handle,
123 				wmi_service_roam_stats_per_candidate_frame_info))
124 		wlan_psoc_nif_fw_ext2_cap_set(
125 			psoc, WLAN_ROAM_STATS_FRAME_INFO_PER_CANDIDATE);
126 }
127 #else
128 static inline void
129 init_deinit_update_roam_stats_cap(struct wmi_unified *wmi_handle,
130 				  struct wlan_objmgr_psoc *psoc)
131 {}
132 #endif
133 
134 #ifdef MULTI_CLIENT_LL_SUPPORT
135 /**
136  * init_deinit_update_multi_client_ll_caps() - Update multi client service
137  * capability bit
138  * @wmi_handle: wmi handle
139  * @psoc: psoc common object
140  *
141  * Return: none
142  */
143 static void
144 init_deinit_update_multi_client_ll_caps(struct wmi_unified *wmi_handle,
145 					struct wlan_objmgr_psoc *psoc)
146 {
147 	if (wmi_service_enabled(wmi_handle,
148 				wmi_service_configure_multi_client_ll_support))
149 		wlan_psoc_nif_fw_ext2_cap_set(psoc,
150 					WLAN_SOC_WLM_MULTI_CLIENT_LL_SUPPORT);
151 }
152 #else
153 static inline void
154 init_deinit_update_multi_client_ll_caps(struct wmi_unified *wmi_handle,
155 					struct wlan_objmgr_psoc *psoc)
156 {}
157 #endif
158 
159 #ifdef WLAN_VENDOR_HANDOFF_CONTROL
160 /**
161  * init_deinit_update_vendor_handoff_control_caps() - Update vendor handoff
162  * control service capability bit
163  * @wmi_handle: wmi handle
164  * @psoc: psoc common object
165  *
166  * Return: none
167  */
168 static void
169 init_deinit_update_vendor_handoff_control_caps(struct wmi_unified *wmi_handle,
170 					       struct wlan_objmgr_psoc *psoc)
171 {
172 	if (wmi_service_enabled(wmi_handle,
173 			wmi_service_configure_vendor_handoff_control_support))
174 		wlan_psoc_nif_fw_ext2_cap_set(psoc,
175 					      WLAN_SOC_VENDOR_HANDOFF_CONTROL);
176 }
177 #else
178 static inline void
179 init_deinit_update_vendor_handoff_control_caps(struct wmi_unified *wmi_handle,
180 					       struct wlan_objmgr_psoc *psoc)
181 {}
182 #endif
183 
184 static int init_deinit_service_ready_event_handler(ol_scn_t scn_handle,
185 							uint8_t *event,
186 							uint32_t data_len)
187 {
188 	int err_code;
189 	struct wlan_objmgr_psoc *psoc;
190 	struct target_psoc_info *tgt_hdl;
191 	wmi_legacy_service_ready_callback legacy_callback;
192 	struct wmi_unified *wmi_handle;
193 	QDF_STATUS ret_val;
194 
195 	if (!scn_handle) {
196 		target_if_err("scn handle NULL in service ready handler");
197 		return -EINVAL;
198 	}
199 
200 	psoc = target_if_get_psoc_from_scn_hdl(scn_handle);
201 	if (!psoc) {
202 		target_if_err("psoc is null in service ready handler");
203 		return -EINVAL;
204 	}
205 
206 	tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc);
207 	if (!tgt_hdl) {
208 		target_if_err("target_psoc_info is null in service ready ev");
209 		return -EINVAL;
210 	}
211 
212 	ret_val = target_if_sw_version_check(psoc, tgt_hdl, event);
213 
214 	wmi_handle = target_psoc_get_wmi_hdl(tgt_hdl);
215 
216 	err_code = init_deinit_populate_service_bitmap(wmi_handle, event,
217 			tgt_hdl->info.service_bitmap);
218 	if (err_code)
219 		goto exit;
220 
221 	err_code = init_deinit_populate_fw_version_cmd(wmi_handle, event);
222 	if (err_code)
223 		goto exit;
224 
225 	err_code = init_deinit_populate_target_cap(wmi_handle, event,
226 				   &(tgt_hdl->info.target_caps));
227 	if (err_code)
228 		goto exit;
229 
230 	err_code = init_deinit_populate_phy_reg_cap(psoc, wmi_handle, event,
231 				    &(tgt_hdl->info), true);
232 	if (err_code)
233 		goto exit;
234 
235 	if (init_deinit_validate_160_80p80_fw_caps(psoc, tgt_hdl) !=
236 			QDF_STATUS_SUCCESS) {
237 		wlan_psoc_nif_op_flag_set(psoc, WLAN_SOC_OP_VHT_INVALID_CAP);
238 	}
239 
240 	if (wmi_service_enabled(wmi_handle, wmi_service_tt))
241 		wlan_psoc_nif_fw_ext_cap_set(psoc, WLAN_SOC_CEXT_TT_SUPPORT);
242 
243 	if (wmi_service_enabled(wmi_handle, wmi_service_widebw_scan))
244 		wlan_psoc_nif_fw_ext_cap_set(psoc, WLAN_SOC_CEXT_WIDEBAND_SCAN);
245 
246 	if (wmi_service_enabled(wmi_handle, wmi_service_check_cal_version))
247 		wlan_psoc_nif_fw_ext_cap_set(psoc, WLAN_SOC_CEXT_SW_CAL);
248 
249 	if (wmi_service_enabled(wmi_handle, wmi_service_twt_requestor))
250 		wlan_psoc_nif_fw_ext_cap_set(psoc, WLAN_SOC_CEXT_TWT_REQUESTER);
251 
252 	if (wmi_service_enabled(wmi_handle, wmi_service_twt_responder))
253 		wlan_psoc_nif_fw_ext_cap_set(psoc, WLAN_SOC_CEXT_TWT_RESPONDER);
254 
255 	if (wmi_service_enabled(wmi_handle, wmi_service_bss_color_offload))
256 		target_if_debug(" BSS COLOR OFFLOAD supported");
257 
258 	if (wmi_service_enabled(wmi_handle, wmi_service_ul_ru26_allowed))
259 		wlan_psoc_nif_fw_ext_cap_set(psoc, WLAN_SOC_CEXT_OBSS_NBW_RU);
260 
261 	if (wmi_service_enabled(wmi_handle, wmi_service_infra_mbssid))
262 		wlan_psoc_nif_fw_ext_cap_set(psoc, WLAN_SOC_CEXT_MBSS_IE);
263 
264 	if (wmi_service_enabled(wmi_handle,
265 				wmi_service_mbss_param_in_vdev_start_support))
266 		wlan_psoc_nif_fw_ext_cap_set(psoc,
267 					     WLAN_SOC_CEXT_MBSS_PARAM_IN_START);
268 
269 	if (wmi_service_enabled(wmi_handle, wmi_service_dynamic_hw_mode))
270 		wlan_psoc_nif_fw_ext_cap_set(psoc, WLAN_SOC_CEXT_DYNAMIC_HW_MODE);
271 
272 	if (wmi_service_enabled(wmi_handle,
273 				wmi_service_bw_restricted_80p80_support))
274 		wlan_psoc_nif_fw_ext_cap_set(psoc,
275 					     WLAN_SOC_RESTRICTED_80P80_SUPPORT);
276 
277 	if (wmi_service_enabled(wmi_handle,
278 				wmi_service_nss_ratio_to_host_support))
279 		wlan_psoc_nif_fw_ext_cap_set(
280 				psoc, WLAN_SOC_NSS_RATIO_TO_HOST_SUPPORT);
281 
282 	if (wmi_service_enabled(wmi_handle,
283 				wmi_service_rtt_ap_initiator_staggered_mode_supported))
284 		wlan_psoc_nif_fw_ext_cap_set(
285 				psoc, WLAN_SOC_RTT_AP_INITIATOR_STAGGERED_MODE_SUPPORTED);
286 
287 	if (wmi_service_enabled(wmi_handle,
288 				wmi_service_rtt_ap_initiator_bursted_mode_supported))
289 		wlan_psoc_nif_fw_ext_cap_set(
290 				psoc, WLAN_SOC_RTT_AP_INITIATOR_BURSTED_MODE_SUPPORTED);
291 
292 	target_if_debug(" TT support %d, Wide BW Scan %d, SW cal %d",
293 		wlan_psoc_nif_fw_ext_cap_get(psoc, WLAN_SOC_CEXT_TT_SUPPORT),
294 		wlan_psoc_nif_fw_ext_cap_get(psoc, WLAN_SOC_CEXT_WIDEBAND_SCAN),
295 		wlan_psoc_nif_fw_ext_cap_get(psoc, WLAN_SOC_CEXT_SW_CAL));
296 
297 	target_if_mesh_support_enable(psoc, tgt_hdl, event);
298 
299 	target_if_eapol_minrate_enable(psoc, tgt_hdl, event);
300 
301 	target_if_smart_antenna_enable(psoc, tgt_hdl, event);
302 
303 	target_if_cfr_support_enable(psoc, tgt_hdl, event);
304 
305 	target_if_peer_cfg_enable(psoc, tgt_hdl, event);
306 
307 	target_if_atf_cfg_enable(psoc, tgt_hdl, event);
308 
309 	if (wmi_service_enabled(wmi_handle,
310 				wmi_service_mgmt_rx_reo_supported))
311 		wlan_psoc_nif_feat_cap_set(psoc,
312 					   WLAN_SOC_F_MGMT_RX_REO_CAPABLE);
313 
314 	target_if_lteu_cfg_enable(psoc, tgt_hdl, event);
315 
316 	if (wmi_service_enabled(wmi_handle, wmi_service_rx_fse_support))
317 		wlan_psoc_nif_fw_ext_cap_set(psoc,
318 					     WLAN_SOC_CEXT_RX_FSE_SUPPORT);
319 
320 	if (wmi_service_enabled(wmi_handle,
321 				wmi_service_scan_conf_per_ch_support))
322 		wlan_psoc_nif_fw_ext_cap_set(psoc,
323 					     WLAN_SOC_CEXT_SCAN_PER_CH_CONFIG);
324 
325 	if (wmi_service_enabled(wmi_handle,
326 				wmi_service_pno_scan_conf_per_ch_support))
327 		wlan_psoc_nif_fw_ext_cap_set(psoc,
328 					WLAN_SOC_PNO_SCAN_CONFIG_PER_CHANNEL);
329 
330 	if (wmi_service_enabled(wmi_handle, wmi_service_csa_beacon_template))
331 		wlan_psoc_nif_fw_ext_cap_set(psoc,
332 					     WLAN_SOC_CEXT_CSA_TX_OFFLOAD);
333 
334 	init_deinit_update_roam_stats_cap(wmi_handle, psoc);
335 
336 	init_deinit_update_wifi_pos_caps(wmi_handle, psoc);
337 
338 	/* override derived value, if it exceeds max peer count */
339 	if ((wlan_psoc_get_max_peer_count(psoc) >
340 		tgt_hdl->info.wlan_res_cfg.num_active_peers) &&
341 		(wlan_psoc_get_max_peer_count(psoc) <
342 			(tgt_hdl->info.wlan_res_cfg.num_peers -
343 				tgt_hdl->info.wlan_res_cfg.num_vdevs))) {
344 		tgt_hdl->info.wlan_res_cfg.num_peers =
345 				wlan_psoc_get_max_peer_count(psoc) +
346 					tgt_hdl->info.wlan_res_cfg.num_vdevs;
347 	}
348 	legacy_callback = target_if_get_psoc_legacy_service_ready_cb();
349 	if (!legacy_callback) {
350 		err_code = -EINVAL;
351 		goto exit;
352 	}
353 
354 	err_code = legacy_callback(wmi_service_ready_event_id,
355 				  scn_handle, event, data_len);
356 	init_deinit_chainmask_config(psoc, tgt_hdl);
357 
358 	if (wmi_service_enabled(wmi_handle, wmi_service_mgmt_tx_wmi)) {
359 		wlan_psoc_nif_fw_ext_cap_set(psoc, WLAN_SOC_CEXT_WMI_MGMT_REF);
360 		target_if_debug("WMI mgmt service enabled");
361 	} else {
362 		wlan_psoc_nif_fw_ext_cap_clear(psoc,
363 					       WLAN_SOC_CEXT_WMI_MGMT_REF);
364 		target_if_debug("WMI mgmt service disabled");
365 	}
366 	init_deinit_update_p2p_p2p_conc_support(wmi_handle, psoc);
367 
368 	err_code = init_deinit_handle_host_mem_req(psoc, tgt_hdl, event);
369 	if (err_code != QDF_STATUS_SUCCESS)
370 		goto exit;
371 
372 	target_if_reg_set_offloaded_info(psoc);
373 	target_if_reg_set_6ghz_info(psoc);
374 	target_if_reg_set_5dot9_ghz_info(psoc);
375 	target_if_twt_fill_tgt_caps(psoc, wmi_handle);
376 
377 	/* Send num_msdu_desc to DP layer */
378 	cdp_soc_set_param(wlan_psoc_get_dp_handle(psoc),
379 			  DP_SOC_PARAM_MSDU_EXCEPTION_DESC,
380 			  tgt_hdl->info.target_caps.num_msdu_desc);
381 
382 	/* Send CMEM FSE support to DP layer */
383 	if (wmi_service_enabled(wmi_handle, wmi_service_fse_cmem_alloc_support))
384 		cdp_soc_set_param(wlan_psoc_get_dp_handle(psoc),
385 				  DP_SOC_PARAM_CMEM_FSE_SUPPORT, 1);
386 
387 	/* Send multi_peer_group support to DP layer */
388 	if (wmi_service_enabled(wmi_handle,
389 				wmi_service_multi_peer_group_cmd_support))
390 		cdp_soc_set_param(wlan_psoc_get_dp_handle(psoc),
391 				  DP_SOC_PARAM_MULTI_PEER_GRP_CMD_SUPPORT, 1);
392 
393 	/* Send UMAC HW reset support to DP layer */
394 	if (wmi_service_enabled(wmi_handle,
395 				wmi_service_umac_hang_recovery_support))
396 		cdp_soc_set_param(wlan_psoc_get_dp_handle(psoc),
397 				  DP_SOC_PARAM_UMAC_HW_RESET_SUPPORT, 1);
398 
399 	if (wmi_service_enabled(wmi_handle, wmi_service_vdev_delete_all_peer))
400 		wlan_psoc_nif_fw_ext2_cap_set(psoc,
401 					      WLAN_VDEV_DELETE_ALL_PEER_SUPPORT);
402 
403 	init_deinit_update_rssi_dbm_conv_support(wmi_handle, psoc);
404 
405 	init_deinit_update_multi_client_ll_caps(wmi_handle, psoc);
406 
407 	init_deinit_update_vendor_handoff_control_caps(wmi_handle, psoc);
408 
409 	if (wmi_service_enabled(wmi_handle, wmi_service_ext_msg)) {
410 		target_if_debug("Wait for EXT message");
411 	} else {
412 		target_if_debug("No EXT message, send init command");
413 		target_psoc_set_num_radios(tgt_hdl, 1);
414 		init_deinit_set_send_init_cmd(psoc, tgt_hdl);
415 	}
416 
417 exit:
418 	return err_code;
419 }
420 
421 static int init_deinit_service_ext2_ready_event_handler(ol_scn_t scn_handle,
422 							uint8_t *event,
423 							uint32_t data_len)
424 {
425 	int err_code = 0;
426 	struct wlan_objmgr_psoc *psoc;
427 	struct target_psoc_info *tgt_hdl;
428 	struct wmi_unified *wmi_handle;
429 	struct tgt_info *info;
430 	wmi_legacy_service_ready_callback legacy_callback;
431 
432 	if (!scn_handle) {
433 		target_if_err("scn handle NULL in service ready ext2 handler");
434 		return -EINVAL;
435 	}
436 
437 	psoc = target_if_get_psoc_from_scn_hdl(scn_handle);
438 	if (!psoc) {
439 		target_if_err("psoc is null in service ready ext2 handler");
440 		return -EINVAL;
441 	}
442 
443 	tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc);
444 	if (!tgt_hdl) {
445 		target_if_err("target_psoc_info is null in service ready ext2 handler");
446 		return -EINVAL;
447 	}
448 
449 	wmi_handle = target_psoc_get_wmi_hdl(tgt_hdl);
450 	if (!wmi_handle) {
451 		target_if_err("wmi_handle is null in service ready ext2 handler");
452 		return -EINVAL;
453 	}
454 
455 	info = (&tgt_hdl->info);
456 	if (info->wmi_service_status ==
457 			wmi_init_ext_processing_failed)
458 		return -EINVAL;
459 
460 	err_code = init_deinit_populate_service_ready_ext2_param(wmi_handle,
461 								 event, info);
462 	if (err_code)
463 		goto exit;
464 
465 	if (wmi_service_enabled(wmi_handle,
466 				wmi_service_reg_cc_ext_event_support)) {
467 		target_if_set_reg_cc_ext_supp(tgt_hdl, psoc);
468 		wlan_psoc_nif_fw_ext_cap_set(psoc,
469 					     WLAN_SOC_EXT_EVENT_SUPPORTED);
470 	}
471 
472 	if (wmi_service_enabled(wmi_handle,
473 				wmi_service_bang_radar_320_support)) {
474 		info->wlan_res_cfg.is_host_dfs_320mhz_bangradar_supported =
475 									   true;
476 	}
477 
478 	/* dbr_ring_caps could have already come as part of EXT event */
479 	if (info->service_ext2_param.num_dbr_ring_caps) {
480 		err_code = init_deinit_populate_dbr_ring_cap_ext2(psoc,
481 								  wmi_handle,
482 								  event, info);
483 		if (err_code)
484 			goto exit;
485 	}
486 
487 	err_code = init_deinit_populate_hal_reg_cap_ext2(wmi_handle, event,
488 							 info);
489 	if (err_code) {
490 		target_if_err("failed to populate hal reg cap ext2");
491 		goto exit;
492 	}
493 
494 	err_code = init_deinit_populate_mac_phy_cap_ext2(wmi_handle, event,
495 							 info);
496 	if (err_code) {
497 		target_if_err("failed to populate mac phy cap ext2");
498 		goto exit;
499 	}
500 
501 	target_if_add_11ax_modes(psoc, tgt_hdl);
502 
503 	err_code = init_deinit_populate_scan_radio_cap_ext2(wmi_handle, event,
504 							    info);
505 	if (err_code) {
506 		target_if_err("failed to populate scan radio cap ext2");
507 		goto exit;
508 	}
509 
510 	err_code = init_deinit_populate_twt_cap_ext2(psoc, wmi_handle, event,
511 						     info);
512 
513 	if (err_code)
514 		target_if_debug("failed to populate twt cap ext2");
515 
516 	err_code = init_deinit_populate_dbs_or_sbs_cap_ext2(psoc, wmi_handle,
517 							    event, info);
518 	if (err_code)
519 		target_if_debug("failed to populate dbs_or_sbs cap ext2");
520 
521 	err_code = init_deinit_populate_sap_coex_capability(psoc, wmi_handle,
522 							    event);
523 	if (err_code)
524 		target_if_debug("failed to populate sap_coex_capability ext2");
525 
526 	legacy_callback = target_if_get_psoc_legacy_service_ready_cb();
527 	if (legacy_callback)
528 		if (legacy_callback(wmi_service_ready_ext2_event_id,
529 				    scn_handle, event, data_len)) {
530 			target_if_err("Legacy callback return error!");
531 			goto exit;
532 		}
533 	target_if_regulatory_set_ext_tpc(psoc);
534 
535 	target_if_reg_set_lower_6g_edge_ch_info(psoc);
536 
537 	target_if_reg_set_disable_upper_6g_edge_ch_info(psoc);
538 
539 	target_if_reg_set_afc_dev_type(psoc, tgt_hdl);
540 
541 	target_if_set_regulatory_eirp_preferred_support(psoc);
542 
543 	tgt_if_set_reg_afc_configure(tgt_hdl, psoc);
544 
545 	/* send init command */
546 	init_deinit_set_send_init_cmd(psoc, tgt_hdl);
547 
548 	return 0;
549 exit:
550 	info->wmi_ready = false;
551 	info->wmi_service_status = wmi_init_ext2_processing_failed;
552 	return err_code;
553 }
554 
555 static int init_deinit_service_ext_ready_event_handler(ol_scn_t scn_handle,
556 						uint8_t *event,
557 						uint32_t data_len)
558 {
559 	int err_code;
560 	uint8_t num_radios;
561 	struct wlan_objmgr_psoc *psoc;
562 	struct target_psoc_info *tgt_hdl;
563 	struct wmi_unified *wmi_handle;
564 	struct tgt_info *info;
565 	wmi_legacy_service_ready_callback legacy_callback;
566 
567 	if (!scn_handle) {
568 		target_if_err("scn handle NULL in service ready handler");
569 		return -EINVAL;
570 	}
571 
572 	psoc = target_if_get_psoc_from_scn_hdl(scn_handle);
573 	if (!psoc) {
574 		target_if_err("psoc is null in service ready handler");
575 		return -EINVAL;
576 	}
577 
578 	tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc);
579 	if (!tgt_hdl) {
580 		target_if_err("target_psoc_info is null in service ready ev");
581 		return -EINVAL;
582 	}
583 
584 	wmi_handle = target_psoc_get_wmi_hdl(tgt_hdl);
585 	info = (&tgt_hdl->info);
586 
587 	err_code = init_deinit_populate_service_ready_ext_param(wmi_handle,
588 				event, &(info->service_ext_param));
589 	if (err_code)
590 		goto exit;
591 
592 	target_psoc_set_num_radios(tgt_hdl, 0);
593 	err_code =  init_deinit_populate_hw_mode_capability(wmi_handle,
594 					    event, tgt_hdl);
595 	if (err_code)
596 		goto exit;
597 
598 	if (init_deinit_is_preferred_hw_mode_supported(psoc, tgt_hdl)
599 			== FALSE) {
600 		target_if_err("Preferred mode %d not supported",
601 			      info->preferred_hw_mode);
602 		goto exit;
603 	}
604 
605 	num_radios = target_psoc_get_num_radios_for_mode(tgt_hdl,
606 							 info->preferred_hw_mode);
607 
608 	/* set number of radios based on current mode */
609 	target_psoc_set_num_radios(tgt_hdl, num_radios);
610 
611 	target_if_print_service_ready_ext_param(psoc, tgt_hdl);
612 
613 	err_code = init_deinit_populate_phy_reg_cap(psoc, wmi_handle,
614 					   event, info, false);
615 	if (err_code)
616 		goto exit;
617 
618 	/* Host receives 11AX wireless modes from target in service ext2
619 	 * message. Therefore, call target_if_add_11ax_modes() from service ext2
620 	 * event handler as well.
621 	 */
622 	if (!wmi_service_enabled(wmi_handle, wmi_service_ext2_msg))
623 		target_if_add_11ax_modes(psoc, tgt_hdl);
624 
625 	if (init_deinit_chainmask_table_alloc(
626 				&(info->service_ext_param)) ==
627 							QDF_STATUS_SUCCESS) {
628 		err_code = init_deinit_populate_chainmask_tables(wmi_handle,
629 				event,
630 				&(info->service_ext_param.chainmask_table[0]));
631 		if (err_code)
632 			goto exit;
633 	}
634 
635 	/* dbr_ring_caps can be absent if enough space is not available */
636 	if (info->service_ext_param.num_dbr_ring_caps) {
637 		err_code = init_deinit_populate_dbr_ring_cap(psoc, wmi_handle,
638 							     event, info);
639 		if (err_code)
640 			goto exit;
641 	}
642 
643 	err_code = init_deinit_populate_spectral_bin_scale_params(psoc,
644 								  wmi_handle,
645 								  event, info);
646 	if (err_code)
647 		goto exit;
648 
649 	legacy_callback = target_if_get_psoc_legacy_service_ready_cb();
650 	if (legacy_callback) {
651 		if (legacy_callback(wmi_service_ready_ext_event_id,
652 				    scn_handle, event, data_len)) {
653 			target_if_err("Error Code %d", err_code);
654 			goto exit;
655 		}
656 	}
657 
658 	target_if_set_twt_ap_pdev_count(info, tgt_hdl);
659 
660 	info->wlan_res_cfg.max_bssid_indicator =
661 				info->service_ext_param.max_bssid_indicator;
662 
663 	if (wmi_service_enabled(wmi_handle, wmi_service_ext2_msg)) {
664 		target_if_debug("Wait for EXT2 message");
665 	} else {
666 		target_if_debug("No EXT2 message, send init command");
667 		init_deinit_set_send_init_cmd(psoc, tgt_hdl);
668 	}
669 
670 	return 0;
671 exit:
672 	info->wmi_ready = false;
673 	info->wmi_service_status = wmi_init_ext_processing_failed;
674 	init_deinit_wakeup_host_wait(psoc, tgt_hdl);
675 	return err_code;
676 }
677 
678 static int init_deinit_service_available_handler(ol_scn_t scn_handle,
679 						uint8_t *event,
680 						uint32_t data_len)
681 {
682 	struct wlan_objmgr_psoc *psoc;
683 	struct target_psoc_info *tgt_hdl;
684 	struct wmi_unified *wmi_handle;
685 
686 	if (!scn_handle) {
687 		target_if_err("scn handle NULL");
688 		return -EINVAL;
689 	}
690 
691 	psoc = target_if_get_psoc_from_scn_hdl(scn_handle);
692 	if (!psoc) {
693 		target_if_err("psoc is null");
694 		return -EINVAL;
695 	}
696 
697 	tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc);
698 	if (!tgt_hdl) {
699 		target_if_err("target_psoc_info is null");
700 		return -EINVAL;
701 	}
702 
703 	wmi_handle = target_psoc_get_wmi_hdl(tgt_hdl);
704 
705 	if (wmi_save_ext_service_bitmap(wmi_handle, event, NULL) !=
706 					QDF_STATUS_SUCCESS) {
707 		target_if_err("Failed to save ext service bitmap");
708 		return -EINVAL;
709 	}
710 
711 	return 0;
712 }
713 
714 #if defined(WLAN_FEATURE_11BE_MLO) && defined(WLAN_MLO_MULTI_CHIP)
715 static bool init_deinit_mlo_capable(struct wlan_objmgr_psoc *psoc)
716 {
717 	struct target_psoc_info *tgt_hdl;
718 
719 	tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc);
720 	if (!tgt_hdl) {
721 		target_if_err("target_psoc_info is null");
722 		return false;
723 	}
724 
725 	if ((tgt_hdl->tif_ops) &&
726 	    (tgt_hdl->tif_ops->mlo_capable))
727 		return tgt_hdl->tif_ops->mlo_capable(psoc);
728 
729 	return false;
730 }
731 
732 static bool init_deinit_mlo_get_group_id(struct wlan_objmgr_psoc *psoc,
733 					 uint8_t *grp_id)
734 {
735 	struct target_psoc_info *tgt_hdl;
736 
737 	tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc);
738 	if (!tgt_hdl) {
739 		target_if_err("target_psoc_info is null");
740 		return false;
741 	}
742 
743 	if ((tgt_hdl->tif_ops) &&
744 	    (tgt_hdl->tif_ops->mlo_get_group_id)) {
745 		*grp_id = tgt_hdl->tif_ops->mlo_get_group_id(psoc);
746 		return true;
747 	}
748 
749 	return false;
750 }
751 
752 static void init_deinit_mlo_update_soc_ready(struct wlan_objmgr_psoc *psoc)
753 {
754 	uint8_t grp_id = 0;
755 
756 	if (init_deinit_mlo_capable(psoc)) {
757 		if (!init_deinit_mlo_get_group_id(psoc, &grp_id)) {
758 			target_if_err("Invalid MLD group id");
759 			return;
760 		}
761 		mlo_setup_update_soc_ready(psoc, grp_id);
762 	}
763 }
764 
765 static void init_deinit_send_ml_link_ready(struct wlan_objmgr_psoc *psoc,
766 					   void *object, void *arg)
767 {
768 	struct wlan_objmgr_pdev *pdev = object;
769 	uint8_t grp_id = 0;
770 
771 	if (!init_deinit_mlo_capable(psoc))
772 		return;
773 
774 	qdf_assert_always(psoc);
775 	qdf_assert_always(pdev);
776 
777 	if (!init_deinit_mlo_get_group_id(psoc, &grp_id))
778 		qdf_assert_always(grp_id);
779 
780 	mlo_setup_link_ready(pdev, grp_id);
781 }
782 
783 static void init_deinit_mlo_update_pdev_ready(struct wlan_objmgr_psoc *psoc,
784 					      uint8_t num_radios)
785 {
786 	if (!init_deinit_mlo_capable(psoc))
787 		return;
788 
789 	wlan_objmgr_iterate_obj_list(psoc, WLAN_PDEV_OP,
790 				     init_deinit_send_ml_link_ready,
791 				     NULL, 0, WLAN_INIT_DEINIT_ID);
792 }
793 #else
794 static void init_deinit_mlo_update_soc_ready(struct wlan_objmgr_psoc *psoc)
795 {}
796 static void init_deinit_mlo_update_pdev_ready(struct wlan_objmgr_psoc *psoc,
797 					      uint8_t num_radios)
798 {}
799 #endif /*WLAN_FEATURE_11BE_MLO && WLAN_MLO_MULTI_CHIP*/
800 
801 /* MAC address fourth byte index */
802 #define MAC_BYTE_4 4
803 
804 static int init_deinit_ready_event_handler(ol_scn_t scn_handle,
805 						uint8_t *event,
806 						uint32_t data_len)
807 {
808 	struct wlan_objmgr_psoc *psoc;
809 	struct wlan_objmgr_pdev *pdev;
810 	struct target_psoc_info *tgt_hdl;
811 	struct wmi_unified *wmi_handle;
812 	struct wmi_host_fw_abi_ver fw_ver;
813 	uint8_t myaddr[QDF_MAC_ADDR_SIZE];
814 	struct tgt_info *info;
815 	struct wmi_host_ready_ev_param ready_ev;
816 	wmi_legacy_service_ready_callback legacy_callback;
817 	uint8_t num_radios, i;
818 	uint32_t max_peers;
819 	uint32_t max_ast_index;
820 	target_resource_config *tgt_cfg;
821 
822 	if (!scn_handle) {
823 		target_if_err("scn handle NULL");
824 		return -EINVAL;
825 	}
826 
827 	psoc = target_if_get_psoc_from_scn_hdl(scn_handle);
828 	if (!psoc) {
829 		target_if_err("psoc is null");
830 		return -EINVAL;
831 	}
832 
833 	tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc);
834 	if (!tgt_hdl) {
835 		target_if_err("target_psoc_info is null");
836 		return -EINVAL;
837 	}
838 
839 	wmi_handle = target_psoc_get_wmi_hdl(tgt_hdl);
840 	info = (&tgt_hdl->info);
841 
842 	if (wmi_extract_fw_abi_version(wmi_handle, event, &fw_ver) ==
843 				QDF_STATUS_SUCCESS) {
844 		info->version.wlan_ver = fw_ver.sw_version;
845 		info->version.wlan_ver = fw_ver.abi_version;
846 	}
847 
848 	if (wmi_check_and_update_fw_version(wmi_handle, event) < 0) {
849 		target_if_err("Version mismatch with FW");
850 		return -EINVAL;
851 	}
852 
853 	if (wmi_extract_ready_event_params(wmi_handle, event, &ready_ev) !=
854 				QDF_STATUS_SUCCESS) {
855 		target_if_err("Failed to extract ready event");
856 		return -EINVAL;
857 	}
858 
859 	if (!ready_ev.agile_capability)
860 		target_if_err("agile capability disabled in HW");
861 	else
862 		info->wlan_res_cfg.agile_capability = ready_ev.agile_capability;
863 
864 	if (ready_ev.num_max_active_vdevs) {
865 		if (ready_ev.num_max_active_vdevs <
866 		    info->wlan_res_cfg.num_max_active_vdevs) {
867 			target_if_err("unexpected num_max_active_vdevs fw %d host %d",
868 				      ready_ev.num_max_active_vdevs,
869 				      info->wlan_res_cfg.num_max_active_vdevs);
870 			info->wlan_res_cfg.num_max_active_vdevs =
871 					ready_ev.num_max_active_vdevs;
872 		}
873 	}
874 
875 	/* Indicate to the waiting thread that the ready
876 	 * event was received
877 	 */
878 	info->wlan_init_status = wmi_ready_extract_init_status(
879 						wmi_handle, event);
880 
881 	legacy_callback = target_if_get_psoc_legacy_service_ready_cb();
882 	if (legacy_callback)
883 		if (legacy_callback(wmi_ready_event_id,
884 				    scn_handle, event, data_len)) {
885 			target_if_err("Legacy callback returned error!");
886 			tgt_hdl->info.wmi_ready = false;
887 			goto exit;
888 		}
889 
890 	init_deinit_mlo_update_soc_ready(psoc);
891 
892 	num_radios = target_psoc_get_num_radios(tgt_hdl);
893 
894 	if ((ready_ev.num_total_peer != 0) &&
895 	    (info->wlan_res_cfg.num_peers != ready_ev.num_total_peer)) {
896 		uint16_t num_peers = 0;
897 		/* FW allocated number of peers is different than host
898 		 * requested. Update host max with FW reported value.
899 		 */
900 		target_if_err("Host Requested %d peers. FW Supports %d peers",
901 			       info->wlan_res_cfg.num_peers,
902 			       ready_ev.num_total_peer);
903 		info->wlan_res_cfg.num_peers = ready_ev.num_total_peer;
904 		num_peers = info->wlan_res_cfg.num_peers / num_radios;
905 
906 		for (i = 0; i < num_radios; i++) {
907 			pdev = wlan_objmgr_get_pdev_by_id(psoc, i,
908 							  WLAN_INIT_DEINIT_ID);
909 			if (!pdev) {
910 				target_if_err(" PDEV %d is NULL", i);
911 				return -EINVAL;
912 			}
913 
914 			wlan_pdev_set_max_peer_count(pdev, num_peers);
915 			wlan_objmgr_pdev_release_ref(pdev, WLAN_INIT_DEINIT_ID);
916 		}
917 
918 		wlan_psoc_set_max_peer_count(psoc,
919 					     info->wlan_res_cfg.num_peers);
920 	}
921 
922 	/* for non legacy  num_total_peer will be non zero
923 	 * allocate peer memory in this case
924 	 */
925 	if (ready_ev.num_total_peer != 0) {
926 		tgt_cfg = &info->wlan_res_cfg;
927 		max_peers = tgt_cfg->num_peers + ready_ev.num_extra_peer + 1;
928 		max_ast_index = ready_ev.max_ast_index + 1;
929 
930 		if (cdp_peer_map_attach(wlan_psoc_get_dp_handle(psoc),
931 					max_peers, max_ast_index,
932 					tgt_cfg->peer_map_unmap_version) !=
933 				QDF_STATUS_SUCCESS) {
934 			target_if_err("DP peer map attach failed");
935 			return -EINVAL;
936 		}
937 	}
938 
939 
940 	if (ready_ev.pktlog_defs_checksum) {
941 		for (i = 0; i < num_radios; i++) {
942 			pdev = wlan_objmgr_get_pdev_by_id(psoc, i,
943 							  WLAN_INIT_DEINIT_ID);
944 			if (!pdev) {
945 				target_if_err(" PDEV %d is NULL", i);
946 				return -EINVAL;
947 			}
948 			target_if_set_pktlog_checksum(pdev, tgt_hdl,
949 						      ready_ev.
950 						      pktlog_defs_checksum);
951 			wlan_objmgr_pdev_release_ref(pdev, WLAN_INIT_DEINIT_ID);
952 		}
953 	}
954 
955 	/*
956 	 * For non-legacy HW, MAC addr list is extracted.
957 	 */
958 	if (num_radios > 1) {
959 		uint8_t num_mac_addr;
960 		wmi_host_mac_addr *addr_list;
961 		int i;
962 
963 		addr_list = wmi_ready_extract_mac_addr_list(wmi_handle, event,
964 							    &num_mac_addr);
965 		if ((num_mac_addr >= num_radios) && (addr_list)) {
966 			for (i = 0; i < num_radios; i++) {
967 				WMI_HOST_MAC_ADDR_TO_CHAR_ARRAY(&addr_list[i],
968 								myaddr);
969 				pdev = wlan_objmgr_get_pdev_by_id(psoc, i,
970 								  WLAN_INIT_DEINIT_ID);
971 				if (!pdev) {
972 					target_if_err(" PDEV %d is NULL", i);
973 					return -EINVAL;
974 				}
975 				wlan_pdev_set_hw_macaddr(pdev, myaddr);
976 				wlan_objmgr_pdev_release_ref(pdev,
977 							WLAN_INIT_DEINIT_ID);
978 
979 				/* assign 1st radio addr to psoc */
980 				if (i == 0)
981 					wlan_psoc_set_hw_macaddr(psoc, myaddr);
982 			}
983 			goto out;
984 		} else {
985 			target_if_err("Using default MAC addr for all radios..");
986 		}
987 	}
988 
989 	/*
990 	 * We extract single MAC address in two scenarios:
991 	 * 1. In non-legacy case, if addr list is NULL or num_mac_addr < num_radios
992 	 * 2. In all legacy cases
993 	 */
994 	for (i = 0; i < num_radios; i++) {
995 		wmi_ready_extract_mac_addr(wmi_handle, event, myaddr);
996 		myaddr[MAC_BYTE_4] += i;
997 		pdev = wlan_objmgr_get_pdev_by_id(psoc, i, WLAN_INIT_DEINIT_ID);
998 		if (!pdev) {
999 			target_if_err(" PDEV %d is NULL", i);
1000 			return -EINVAL;
1001 		}
1002 		wlan_pdev_set_hw_macaddr(pdev, myaddr);
1003 		wlan_objmgr_pdev_release_ref(pdev, WLAN_INIT_DEINIT_ID);
1004 		/* assign 1st radio addr to psoc */
1005 		if (i == 0)
1006 			wlan_psoc_set_hw_macaddr(psoc, myaddr);
1007 	}
1008 
1009 out:
1010 	target_if_btcoex_cfg_enable(psoc, tgt_hdl, event);
1011 	tgt_hdl->info.wmi_ready = true;
1012 	init_deinit_mlo_update_pdev_ready(psoc, num_radios);
1013 exit:
1014 	init_deinit_wakeup_host_wait(psoc, tgt_hdl);
1015 
1016 	return 0;
1017 }
1018 
1019 #ifdef HEALTH_MON_SUPPORT
1020 static int init_deinit_health_mon_event_handler(ol_scn_t scn_handle,
1021 						uint8_t *event,
1022 						uint32_t data_len)
1023 {
1024 	struct wlan_objmgr_psoc *psoc;
1025 	struct target_psoc_info *tgt_hdl;
1026 	struct wmi_unified *wmi_handle;
1027 	struct tgt_info *info;
1028 	struct wmi_health_mon_params *param;
1029 
1030 	if (!scn_handle) {
1031 		target_if_err("scn handle NULL");
1032 		return -EINVAL;
1033 	}
1034 
1035 	psoc = target_if_get_psoc_from_scn_hdl(scn_handle);
1036 	if (!psoc) {
1037 		target_if_err("psoc is null");
1038 		return -EINVAL;
1039 	}
1040 
1041 	tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc);
1042 	if (!tgt_hdl) {
1043 		target_if_err("target_psoc_info is null");
1044 		return -EINVAL;
1045 	}
1046 
1047 	wmi_handle = target_psoc_get_wmi_hdl(tgt_hdl);
1048 	info = (&tgt_hdl->info);
1049 
1050 	param = (&info->health_mon_param);
1051 	wmi_extract_health_mon_event(wmi_handle, event, param);
1052 
1053 	return 0;
1054 }
1055 #endif /* HEALTH_MON_SUPPORT */
1056 
1057 #if defined(WLAN_FEATURE_11BE_MLO) && defined(WLAN_MLO_MULTI_CHIP)
1058 static void init_deinit_mlo_setup_done_event(struct wlan_objmgr_psoc *psoc)
1059 {
1060 	struct target_psoc_info *tgt_hdl;
1061 
1062 	tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc);
1063 	if (!tgt_hdl) {
1064 		target_if_err("target_psoc_info is null");
1065 		return;
1066 	}
1067 
1068 	if ((tgt_hdl->tif_ops) &&
1069 	    (tgt_hdl->tif_ops->mlo_setup_done_event))
1070 		tgt_hdl->tif_ops->mlo_setup_done_event(psoc);
1071 }
1072 
1073 static int init_deinit_mlo_setup_comp_event_handler(ol_scn_t scn_handle,
1074 						    uint8_t *event,
1075 						    uint32_t data_len)
1076 {
1077 	struct wlan_objmgr_psoc *psoc;
1078 	struct wlan_objmgr_pdev *pdev;
1079 	struct target_psoc_info *tgt_hdl;
1080 	struct wmi_unified *wmi_handle;
1081 	struct wmi_mlo_setup_complete_params params;
1082 	uint8_t grp_id = 0;
1083 
1084 	if (!scn_handle) {
1085 		target_if_err("scn handle NULL");
1086 		return -EINVAL;
1087 	}
1088 
1089 	psoc = target_if_get_psoc_from_scn_hdl(scn_handle);
1090 
1091 	if (!psoc) {
1092 		target_if_err("psoc is null");
1093 		return -EINVAL;
1094 	}
1095 
1096 	if (!init_deinit_mlo_get_group_id(psoc, &grp_id)) {
1097 		target_if_err("Invalid MLD group id");
1098 		return -EINVAL;
1099 	}
1100 
1101 	tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc);
1102 
1103 	if (!tgt_hdl) {
1104 		target_if_err("target_psoc_info is null");
1105 		return -EINVAL;
1106 	}
1107 
1108 	wmi_handle = target_psoc_get_wmi_hdl(tgt_hdl);
1109 
1110 	if (wmi_extract_mlo_setup_cmpl_event(wmi_handle, event, &params) !=
1111 			QDF_STATUS_SUCCESS)
1112 		return -EINVAL;
1113 
1114 	pdev = wlan_objmgr_get_pdev_by_id(psoc, params.pdev_id,
1115 					  WLAN_INIT_DEINIT_ID);
1116 
1117 	if (pdev) {
1118 		mlo_link_setup_complete(pdev, grp_id);
1119 		wlan_objmgr_pdev_release_ref(pdev, WLAN_INIT_DEINIT_ID);
1120 	}
1121 
1122 	init_deinit_mlo_setup_done_event(psoc);
1123 
1124 	return 0;
1125 }
1126 
1127 static int init_deinit_mlo_teardown_comp_event_handler(ol_scn_t scn_handle,
1128 						       uint8_t *event,
1129 						       uint32_t data_len)
1130 {
1131 	struct wlan_objmgr_psoc *psoc;
1132 	struct wlan_objmgr_pdev *pdev;
1133 	struct target_psoc_info *tgt_hdl;
1134 	struct wmi_unified *wmi_handle;
1135 	struct wmi_mlo_teardown_cmpl_params params;
1136 	uint8_t grp_id = 0;
1137 
1138 	if (!scn_handle) {
1139 		target_if_err("scn handle NULL");
1140 		return -EINVAL;
1141 	}
1142 
1143 	psoc = target_if_get_psoc_from_scn_hdl(scn_handle);
1144 	if (!psoc) {
1145 		target_if_err("psoc is null");
1146 		return -EINVAL;
1147 	}
1148 
1149 	if (!init_deinit_mlo_get_group_id(psoc, &grp_id)) {
1150 		target_if_err("Invalid MLD group id");
1151 		return -EINVAL;
1152 	}
1153 
1154 	tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc);
1155 	if (!tgt_hdl) {
1156 		target_if_err("target_psoc_info is null");
1157 		return -EINVAL;
1158 	}
1159 	wmi_handle = target_psoc_get_wmi_hdl(tgt_hdl);
1160 
1161 	if (wmi_extract_mlo_teardown_cmpl_event(wmi_handle, event, &params) !=
1162 			QDF_STATUS_SUCCESS)
1163 		return -EINVAL;
1164 
1165 	pdev = wlan_objmgr_get_pdev_by_id(psoc, params.pdev_id,
1166 					  WLAN_INIT_DEINIT_ID);
1167 	if (pdev) {
1168 		mlo_link_teardown_complete(pdev, grp_id);
1169 		wlan_objmgr_pdev_release_ref(pdev, WLAN_INIT_DEINIT_ID);
1170 	}
1171 
1172 	return 0;
1173 }
1174 
1175 static QDF_STATUS init_deinit_register_mlo_ev_handlers(wmi_unified_t wmi_handle)
1176 {
1177 	wmi_unified_register_event(wmi_handle,
1178 				   wmi_mlo_setup_complete_event_id,
1179 				   init_deinit_mlo_setup_comp_event_handler);
1180 	wmi_unified_register_event(wmi_handle,
1181 				   wmi_mlo_teardown_complete_event_id,
1182 				   init_deinit_mlo_teardown_comp_event_handler);
1183 
1184 	return QDF_STATUS_SUCCESS;
1185 }
1186 #else
1187 static QDF_STATUS init_deinit_register_mlo_ev_handlers(wmi_unified_t wmi_handle)
1188 {
1189 	return QDF_STATUS_SUCCESS;
1190 }
1191 #endif /*WLAN_FEATURE_11BE_MLO && WLAN_MLO_MULTI_CHIP*/
1192 
1193 QDF_STATUS init_deinit_register_tgt_psoc_ev_handlers(
1194 				struct wlan_objmgr_psoc *psoc)
1195 {
1196 	struct target_psoc_info *tgt_hdl;
1197 	wmi_unified_t wmi_handle;
1198 	QDF_STATUS retval = QDF_STATUS_SUCCESS;
1199 
1200 	if (!psoc) {
1201 		target_if_err("psoc is null in register wmi handler");
1202 		return QDF_STATUS_E_FAILURE;
1203 	}
1204 
1205 	tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc);
1206 	if (!tgt_hdl) {
1207 		target_if_err("target_psoc_info null in register wmi hadler");
1208 		return QDF_STATUS_E_FAILURE;
1209 	}
1210 
1211 	wmi_handle = (wmi_unified_t)target_psoc_get_wmi_hdl(tgt_hdl);
1212 
1213 	retval = wmi_unified_register_event_handler(wmi_handle,
1214 				wmi_service_ready_event_id,
1215 				init_deinit_service_ready_event_handler,
1216 				WMI_RX_WORK_CTX);
1217 	retval = wmi_unified_register_event_handler(wmi_handle,
1218 				wmi_service_ready_ext_event_id,
1219 				init_deinit_service_ext_ready_event_handler,
1220 				WMI_RX_WORK_CTX);
1221 	retval = wmi_unified_register_event_handler(wmi_handle,
1222 				wmi_service_available_event_id,
1223 				init_deinit_service_available_handler,
1224 				WMI_RX_UMAC_CTX);
1225 	retval = wmi_unified_register_event_handler(wmi_handle,
1226 				wmi_ready_event_id,
1227 				init_deinit_ready_event_handler,
1228 				WMI_RX_WORK_CTX);
1229 	retval = wmi_unified_register_event_handler(
1230 				wmi_handle,
1231 				wmi_service_ready_ext2_event_id,
1232 				init_deinit_service_ext2_ready_event_handler,
1233 				WMI_RX_WORK_CTX);
1234 	retval = init_deinit_register_mlo_ev_handlers(wmi_handle);
1235 
1236 #ifdef HEALTH_MON_SUPPORT
1237 	retval = wmi_unified_register_event_handler(
1238 				wmi_handle,
1239 				wmi_extract_health_mon_init_done_info_eventid,
1240 				init_deinit_health_mon_event_handler,
1241 				WMI_RX_WORK_CTX);
1242 #endif /* HEALTH_MON_SUPPORT */
1243 
1244 	return retval;
1245 }
1246 
1247