xref: /wlan-dirver/qca-wifi-host-cmn/target_if/init_deinit/src/init_event_handler.c (revision 901120c066e139c7f8a2c8e4820561fdd83c67ef)
1 /*
2  * Copyright (c) 2018-2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2021-2022 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 	legacy_callback = target_if_get_psoc_legacy_service_ready_cb();
522 	if (legacy_callback)
523 		if (legacy_callback(wmi_service_ready_ext2_event_id,
524 				    scn_handle, event, data_len)) {
525 			target_if_err("Legacy callback return error!");
526 			goto exit;
527 		}
528 	target_if_regulatory_set_ext_tpc(psoc);
529 
530 	target_if_reg_set_lower_6g_edge_ch_info(psoc);
531 
532 	target_if_reg_set_disable_upper_6g_edge_ch_info(psoc);
533 
534 	target_if_reg_set_afc_dev_type(psoc, tgt_hdl);
535 
536 	target_if_set_regulatory_eirp_preferred_support(psoc);
537 
538 	/* send init command */
539 	init_deinit_set_send_init_cmd(psoc, tgt_hdl);
540 
541 	return 0;
542 exit:
543 	info->wmi_ready = false;
544 	info->wmi_service_status = wmi_init_ext2_processing_failed;
545 	return err_code;
546 }
547 
548 static int init_deinit_service_ext_ready_event_handler(ol_scn_t scn_handle,
549 						uint8_t *event,
550 						uint32_t data_len)
551 {
552 	int err_code;
553 	uint8_t num_radios;
554 	struct wlan_objmgr_psoc *psoc;
555 	struct target_psoc_info *tgt_hdl;
556 	struct wmi_unified *wmi_handle;
557 	struct tgt_info *info;
558 	wmi_legacy_service_ready_callback legacy_callback;
559 
560 	if (!scn_handle) {
561 		target_if_err("scn handle NULL in service ready handler");
562 		return -EINVAL;
563 	}
564 
565 	psoc = target_if_get_psoc_from_scn_hdl(scn_handle);
566 	if (!psoc) {
567 		target_if_err("psoc is null in service ready handler");
568 		return -EINVAL;
569 	}
570 
571 	tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc);
572 	if (!tgt_hdl) {
573 		target_if_err("target_psoc_info is null in service ready ev");
574 		return -EINVAL;
575 	}
576 
577 	wmi_handle = target_psoc_get_wmi_hdl(tgt_hdl);
578 	info = (&tgt_hdl->info);
579 
580 	err_code = init_deinit_populate_service_ready_ext_param(wmi_handle,
581 				event, &(info->service_ext_param));
582 	if (err_code)
583 		goto exit;
584 
585 	target_psoc_set_num_radios(tgt_hdl, 0);
586 	err_code =  init_deinit_populate_hw_mode_capability(wmi_handle,
587 					    event, tgt_hdl);
588 	if (err_code)
589 		goto exit;
590 
591 	if (init_deinit_is_preferred_hw_mode_supported(psoc, tgt_hdl)
592 			== FALSE) {
593 		target_if_err("Preferred mode %d not supported",
594 			      info->preferred_hw_mode);
595 		goto exit;
596 	}
597 
598 	num_radios = target_psoc_get_num_radios_for_mode(tgt_hdl,
599 							 info->preferred_hw_mode);
600 
601 	/* set number of radios based on current mode */
602 	target_psoc_set_num_radios(tgt_hdl, num_radios);
603 
604 	target_if_print_service_ready_ext_param(psoc, tgt_hdl);
605 
606 	err_code = init_deinit_populate_phy_reg_cap(psoc, wmi_handle,
607 					   event, info, false);
608 	if (err_code)
609 		goto exit;
610 
611 	/* Host receives 11AX wireless modes from target in service ext2
612 	 * message. Therefore, call target_if_add_11ax_modes() from service ext2
613 	 * event handler as well.
614 	 */
615 	if (!wmi_service_enabled(wmi_handle, wmi_service_ext2_msg))
616 		target_if_add_11ax_modes(psoc, tgt_hdl);
617 
618 	if (init_deinit_chainmask_table_alloc(
619 				&(info->service_ext_param)) ==
620 							QDF_STATUS_SUCCESS) {
621 		err_code = init_deinit_populate_chainmask_tables(wmi_handle,
622 				event,
623 				&(info->service_ext_param.chainmask_table[0]));
624 		if (err_code)
625 			goto exit;
626 	}
627 
628 	/* dbr_ring_caps can be absent if enough space is not available */
629 	if (info->service_ext_param.num_dbr_ring_caps) {
630 		err_code = init_deinit_populate_dbr_ring_cap(psoc, wmi_handle,
631 							     event, info);
632 		if (err_code)
633 			goto exit;
634 	}
635 
636 	err_code = init_deinit_populate_spectral_bin_scale_params(psoc,
637 								  wmi_handle,
638 								  event, info);
639 	if (err_code)
640 		goto exit;
641 
642 	legacy_callback = target_if_get_psoc_legacy_service_ready_cb();
643 	if (legacy_callback) {
644 		if (legacy_callback(wmi_service_ready_ext_event_id,
645 				    scn_handle, event, data_len)) {
646 			target_if_err("Error Code %d", err_code);
647 			goto exit;
648 		}
649 	}
650 
651 	target_if_set_twt_ap_pdev_count(info, tgt_hdl);
652 
653 	info->wlan_res_cfg.max_bssid_indicator =
654 				info->service_ext_param.max_bssid_indicator;
655 
656 	if (wmi_service_enabled(wmi_handle, wmi_service_ext2_msg)) {
657 		target_if_debug("Wait for EXT2 message");
658 	} else {
659 		target_if_debug("No EXT2 message, send init command");
660 		init_deinit_set_send_init_cmd(psoc, tgt_hdl);
661 	}
662 
663 	return 0;
664 exit:
665 	info->wmi_ready = false;
666 	info->wmi_service_status = wmi_init_ext_processing_failed;
667 	init_deinit_wakeup_host_wait(psoc, tgt_hdl);
668 	return err_code;
669 }
670 
671 static int init_deinit_service_available_handler(ol_scn_t scn_handle,
672 						uint8_t *event,
673 						uint32_t data_len)
674 {
675 	struct wlan_objmgr_psoc *psoc;
676 	struct target_psoc_info *tgt_hdl;
677 	struct wmi_unified *wmi_handle;
678 
679 	if (!scn_handle) {
680 		target_if_err("scn handle NULL");
681 		return -EINVAL;
682 	}
683 
684 	psoc = target_if_get_psoc_from_scn_hdl(scn_handle);
685 	if (!psoc) {
686 		target_if_err("psoc is null");
687 		return -EINVAL;
688 	}
689 
690 	tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc);
691 	if (!tgt_hdl) {
692 		target_if_err("target_psoc_info is null");
693 		return -EINVAL;
694 	}
695 
696 	wmi_handle = target_psoc_get_wmi_hdl(tgt_hdl);
697 
698 	if (wmi_save_ext_service_bitmap(wmi_handle, event, NULL) !=
699 					QDF_STATUS_SUCCESS) {
700 		target_if_err("Failed to save ext service bitmap");
701 		return -EINVAL;
702 	}
703 
704 	return 0;
705 }
706 
707 #if defined(WLAN_FEATURE_11BE_MLO) && defined(WLAN_MLO_MULTI_CHIP)
708 static bool init_deinit_mlo_capable(struct wlan_objmgr_psoc *psoc)
709 {
710 	struct target_psoc_info *tgt_hdl;
711 
712 	tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc);
713 	if (!tgt_hdl) {
714 		target_if_err("target_psoc_info is null");
715 		return false;
716 	}
717 
718 	if ((tgt_hdl->tif_ops) &&
719 	    (tgt_hdl->tif_ops->mlo_capable))
720 		return tgt_hdl->tif_ops->mlo_capable(psoc);
721 
722 	return false;
723 }
724 
725 static void init_deinit_mlo_update_soc_ready(struct wlan_objmgr_psoc *psoc)
726 {
727 	if (init_deinit_mlo_capable(psoc))
728 		mlo_setup_update_soc_ready(psoc);
729 }
730 
731 static void init_deinit_send_ml_link_ready(struct wlan_objmgr_psoc *psoc,
732 					   void *object, void *arg)
733 {
734 	struct wlan_objmgr_pdev *pdev = object;
735 
736 	if (!init_deinit_mlo_capable(psoc))
737 		return;
738 
739 	qdf_assert_always(psoc);
740 	qdf_assert_always(pdev);
741 
742 	mlo_setup_link_ready(pdev);
743 }
744 
745 static void init_deinit_mlo_update_pdev_ready(struct wlan_objmgr_psoc *psoc,
746 					      uint8_t num_radios)
747 {
748 	if (!init_deinit_mlo_capable(psoc))
749 		return;
750 
751 	wlan_objmgr_iterate_obj_list(psoc, WLAN_PDEV_OP,
752 				     init_deinit_send_ml_link_ready,
753 				     NULL, 0, WLAN_INIT_DEINIT_ID);
754 }
755 #else
756 static void init_deinit_mlo_update_soc_ready(struct wlan_objmgr_psoc *psoc)
757 {}
758 static void init_deinit_mlo_update_pdev_ready(struct wlan_objmgr_psoc *psoc,
759 					      uint8_t num_radios)
760 {}
761 #endif /*WLAN_FEATURE_11BE_MLO && WLAN_MLO_MULTI_CHIP*/
762 
763 /* MAC address fourth byte index */
764 #define MAC_BYTE_4 4
765 
766 static int init_deinit_ready_event_handler(ol_scn_t scn_handle,
767 						uint8_t *event,
768 						uint32_t data_len)
769 {
770 	struct wlan_objmgr_psoc *psoc;
771 	struct wlan_objmgr_pdev *pdev;
772 	struct target_psoc_info *tgt_hdl;
773 	struct wmi_unified *wmi_handle;
774 	struct wmi_host_fw_abi_ver fw_ver;
775 	uint8_t myaddr[QDF_MAC_ADDR_SIZE];
776 	struct tgt_info *info;
777 	struct wmi_host_ready_ev_param ready_ev;
778 	wmi_legacy_service_ready_callback legacy_callback;
779 	uint8_t num_radios, i;
780 	uint32_t max_peers;
781 	uint32_t max_ast_index;
782 	target_resource_config *tgt_cfg;
783 
784 	if (!scn_handle) {
785 		target_if_err("scn handle NULL");
786 		return -EINVAL;
787 	}
788 
789 	psoc = target_if_get_psoc_from_scn_hdl(scn_handle);
790 	if (!psoc) {
791 		target_if_err("psoc is null");
792 		return -EINVAL;
793 	}
794 
795 	tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc);
796 	if (!tgt_hdl) {
797 		target_if_err("target_psoc_info is null");
798 		return -EINVAL;
799 	}
800 
801 	wmi_handle = target_psoc_get_wmi_hdl(tgt_hdl);
802 	info = (&tgt_hdl->info);
803 
804 	if (wmi_extract_fw_abi_version(wmi_handle, event, &fw_ver) ==
805 				QDF_STATUS_SUCCESS) {
806 		info->version.wlan_ver = fw_ver.sw_version;
807 		info->version.wlan_ver = fw_ver.abi_version;
808 	}
809 
810 	if (wmi_check_and_update_fw_version(wmi_handle, event) < 0) {
811 		target_if_err("Version mismatch with FW");
812 		return -EINVAL;
813 	}
814 
815 	if (wmi_extract_ready_event_params(wmi_handle, event, &ready_ev) !=
816 				QDF_STATUS_SUCCESS) {
817 		target_if_err("Failed to extract ready event");
818 		return -EINVAL;
819 	}
820 
821 	if (!ready_ev.agile_capability)
822 		target_if_err("agile capability disabled in HW");
823 	else
824 		info->wlan_res_cfg.agile_capability = ready_ev.agile_capability;
825 
826 	if (ready_ev.num_max_active_vdevs) {
827 		if (ready_ev.num_max_active_vdevs <
828 		    info->wlan_res_cfg.num_max_active_vdevs) {
829 			target_if_err("unexpected num_max_active_vdevs fw %d host %d",
830 				      ready_ev.num_max_active_vdevs,
831 				      info->wlan_res_cfg.num_max_active_vdevs);
832 			info->wlan_res_cfg.num_max_active_vdevs =
833 					ready_ev.num_max_active_vdevs;
834 		}
835 	}
836 
837 	/* Indicate to the waiting thread that the ready
838 	 * event was received
839 	 */
840 	info->wlan_init_status = wmi_ready_extract_init_status(
841 						wmi_handle, event);
842 
843 	legacy_callback = target_if_get_psoc_legacy_service_ready_cb();
844 	if (legacy_callback)
845 		if (legacy_callback(wmi_ready_event_id,
846 				    scn_handle, event, data_len)) {
847 			target_if_err("Legacy callback returned error!");
848 			tgt_hdl->info.wmi_ready = false;
849 			goto exit;
850 		}
851 
852 	init_deinit_mlo_update_soc_ready(psoc);
853 
854 	num_radios = target_psoc_get_num_radios(tgt_hdl);
855 
856 	if ((ready_ev.num_total_peer != 0) &&
857 	    (info->wlan_res_cfg.num_peers != ready_ev.num_total_peer)) {
858 		uint16_t num_peers = 0;
859 		/* FW allocated number of peers is different than host
860 		 * requested. Update host max with FW reported value.
861 		 */
862 		target_if_err("Host Requested %d peers. FW Supports %d peers",
863 			       info->wlan_res_cfg.num_peers,
864 			       ready_ev.num_total_peer);
865 		info->wlan_res_cfg.num_peers = ready_ev.num_total_peer;
866 		num_peers = info->wlan_res_cfg.num_peers / num_radios;
867 
868 		for (i = 0; i < num_radios; i++) {
869 			pdev = wlan_objmgr_get_pdev_by_id(psoc, i,
870 							  WLAN_INIT_DEINIT_ID);
871 			if (!pdev) {
872 				target_if_err(" PDEV %d is NULL", i);
873 				return -EINVAL;
874 			}
875 
876 			wlan_pdev_set_max_peer_count(pdev, num_peers);
877 			wlan_objmgr_pdev_release_ref(pdev, WLAN_INIT_DEINIT_ID);
878 		}
879 
880 		wlan_psoc_set_max_peer_count(psoc,
881 					     info->wlan_res_cfg.num_peers);
882 	}
883 
884 	/* for non legacy  num_total_peer will be non zero
885 	 * allocate peer memory in this case
886 	 */
887 	if (ready_ev.num_total_peer != 0) {
888 		tgt_cfg = &info->wlan_res_cfg;
889 		max_peers = tgt_cfg->num_peers + ready_ev.num_extra_peer + 1;
890 		max_ast_index = ready_ev.max_ast_index + 1;
891 
892 		if (cdp_peer_map_attach(wlan_psoc_get_dp_handle(psoc),
893 					max_peers, max_ast_index,
894 					tgt_cfg->peer_map_unmap_version) !=
895 				QDF_STATUS_SUCCESS) {
896 			target_if_err("DP peer map attach failed");
897 			return -EINVAL;
898 		}
899 	}
900 
901 
902 	if (ready_ev.pktlog_defs_checksum) {
903 		for (i = 0; i < num_radios; i++) {
904 			pdev = wlan_objmgr_get_pdev_by_id(psoc, i,
905 							  WLAN_INIT_DEINIT_ID);
906 			if (!pdev) {
907 				target_if_err(" PDEV %d is NULL", i);
908 				return -EINVAL;
909 			}
910 			target_if_set_pktlog_checksum(pdev, tgt_hdl,
911 						      ready_ev.
912 						      pktlog_defs_checksum);
913 			wlan_objmgr_pdev_release_ref(pdev, WLAN_INIT_DEINIT_ID);
914 		}
915 	}
916 
917 	/*
918 	 * For non-legacy HW, MAC addr list is extracted.
919 	 */
920 	if (num_radios > 1) {
921 		uint8_t num_mac_addr;
922 		wmi_host_mac_addr *addr_list;
923 		int i;
924 
925 		addr_list = wmi_ready_extract_mac_addr_list(wmi_handle, event,
926 							    &num_mac_addr);
927 		if ((num_mac_addr >= num_radios) && (addr_list)) {
928 			for (i = 0; i < num_radios; i++) {
929 				WMI_HOST_MAC_ADDR_TO_CHAR_ARRAY(&addr_list[i],
930 								myaddr);
931 				pdev = wlan_objmgr_get_pdev_by_id(psoc, i,
932 								  WLAN_INIT_DEINIT_ID);
933 				if (!pdev) {
934 					target_if_err(" PDEV %d is NULL", i);
935 					return -EINVAL;
936 				}
937 				wlan_pdev_set_hw_macaddr(pdev, myaddr);
938 				wlan_objmgr_pdev_release_ref(pdev,
939 							WLAN_INIT_DEINIT_ID);
940 
941 				/* assign 1st radio addr to psoc */
942 				if (i == 0)
943 					wlan_psoc_set_hw_macaddr(psoc, myaddr);
944 			}
945 			goto out;
946 		} else {
947 			target_if_err("Using default MAC addr for all radios..");
948 		}
949 	}
950 
951 	/*
952 	 * We extract single MAC address in two scenarios:
953 	 * 1. In non-legacy case, if addr list is NULL or num_mac_addr < num_radios
954 	 * 2. In all legacy cases
955 	 */
956 	for (i = 0; i < num_radios; i++) {
957 		wmi_ready_extract_mac_addr(wmi_handle, event, myaddr);
958 		myaddr[MAC_BYTE_4] += i;
959 		pdev = wlan_objmgr_get_pdev_by_id(psoc, i, WLAN_INIT_DEINIT_ID);
960 		if (!pdev) {
961 			target_if_err(" PDEV %d is NULL", i);
962 			return -EINVAL;
963 		}
964 		wlan_pdev_set_hw_macaddr(pdev, myaddr);
965 		wlan_objmgr_pdev_release_ref(pdev, WLAN_INIT_DEINIT_ID);
966 		/* assign 1st radio addr to psoc */
967 		if (i == 0)
968 			wlan_psoc_set_hw_macaddr(psoc, myaddr);
969 	}
970 
971 out:
972 	target_if_btcoex_cfg_enable(psoc, tgt_hdl, event);
973 	tgt_hdl->info.wmi_ready = true;
974 	init_deinit_mlo_update_pdev_ready(psoc, num_radios);
975 exit:
976 	init_deinit_wakeup_host_wait(psoc, tgt_hdl);
977 
978 	return 0;
979 }
980 
981 #ifdef HEALTH_MON_SUPPORT
982 static int init_deinit_health_mon_event_handler(ol_scn_t scn_handle,
983 						uint8_t *event,
984 						uint32_t data_len)
985 {
986 	struct wlan_objmgr_psoc *psoc;
987 	struct target_psoc_info *tgt_hdl;
988 	struct wmi_unified *wmi_handle;
989 	struct tgt_info *info;
990 	struct wmi_health_mon_params *param;
991 
992 	if (!scn_handle) {
993 		target_if_err("scn handle NULL");
994 		return -EINVAL;
995 	}
996 
997 	psoc = target_if_get_psoc_from_scn_hdl(scn_handle);
998 	if (!psoc) {
999 		target_if_err("psoc is null");
1000 		return -EINVAL;
1001 	}
1002 
1003 	tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc);
1004 	if (!tgt_hdl) {
1005 		target_if_err("target_psoc_info is null");
1006 		return -EINVAL;
1007 	}
1008 
1009 	wmi_handle = target_psoc_get_wmi_hdl(tgt_hdl);
1010 	info = (&tgt_hdl->info);
1011 
1012 	param = (&info->health_mon_param);
1013 	wmi_extract_health_mon_event(wmi_handle, event, param);
1014 
1015 	return 0;
1016 }
1017 #endif /* HEALTH_MON_SUPPORT */
1018 
1019 #if defined(WLAN_FEATURE_11BE_MLO) && defined(WLAN_MLO_MULTI_CHIP)
1020 static void init_deinit_mlo_setup_done_event(struct wlan_objmgr_psoc *psoc)
1021 {
1022 	struct target_psoc_info *tgt_hdl;
1023 
1024 	tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc);
1025 	if (!tgt_hdl) {
1026 		target_if_err("target_psoc_info is null");
1027 		return;
1028 	}
1029 
1030 	if ((tgt_hdl->tif_ops) &&
1031 	    (tgt_hdl->tif_ops->mlo_setup_done_event))
1032 		tgt_hdl->tif_ops->mlo_setup_done_event(psoc);
1033 }
1034 
1035 static int init_deinit_mlo_setup_comp_event_handler(ol_scn_t scn_handle,
1036 						    uint8_t *event,
1037 						    uint32_t data_len)
1038 {
1039 	struct wlan_objmgr_psoc *psoc;
1040 	struct wlan_objmgr_pdev *pdev;
1041 	struct target_psoc_info *tgt_hdl;
1042 	struct wmi_unified *wmi_handle;
1043 	struct wmi_mlo_setup_complete_params params;
1044 
1045 	if (!scn_handle) {
1046 		target_if_err("scn handle NULL");
1047 		return -EINVAL;
1048 	}
1049 
1050 	psoc = target_if_get_psoc_from_scn_hdl(scn_handle);
1051 	if (!psoc) {
1052 		target_if_err("psoc is null");
1053 		return -EINVAL;
1054 	}
1055 
1056 	tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc);
1057 	if (!tgt_hdl) {
1058 		target_if_err("target_psoc_info is null");
1059 		return -EINVAL;
1060 	}
1061 	wmi_handle = target_psoc_get_wmi_hdl(tgt_hdl);
1062 
1063 	if (wmi_extract_mlo_setup_cmpl_event(wmi_handle, event, &params) !=
1064 			QDF_STATUS_SUCCESS)
1065 		return -EINVAL;
1066 
1067 	pdev = wlan_objmgr_get_pdev_by_id(psoc, params.pdev_id,
1068 					  WLAN_INIT_DEINIT_ID);
1069 	if (pdev) {
1070 		mlo_link_setup_complete(pdev);
1071 		wlan_objmgr_pdev_release_ref(pdev, WLAN_INIT_DEINIT_ID);
1072 	}
1073 
1074 	init_deinit_mlo_setup_done_event(psoc);
1075 
1076 	return 0;
1077 }
1078 
1079 static int init_deinit_mlo_teardown_comp_event_handler(ol_scn_t scn_handle,
1080 						       uint8_t *event,
1081 						       uint32_t data_len)
1082 {
1083 	struct wlan_objmgr_psoc *psoc;
1084 	struct wlan_objmgr_pdev *pdev;
1085 	struct target_psoc_info *tgt_hdl;
1086 	struct wmi_unified *wmi_handle;
1087 	struct wmi_mlo_teardown_cmpl_params params;
1088 
1089 	if (!scn_handle) {
1090 		target_if_err("scn handle NULL");
1091 		return -EINVAL;
1092 	}
1093 
1094 	psoc = target_if_get_psoc_from_scn_hdl(scn_handle);
1095 	if (!psoc) {
1096 		target_if_err("psoc is null");
1097 		return -EINVAL;
1098 	}
1099 
1100 	tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc);
1101 	if (!tgt_hdl) {
1102 		target_if_err("target_psoc_info is null");
1103 		return -EINVAL;
1104 	}
1105 	wmi_handle = target_psoc_get_wmi_hdl(tgt_hdl);
1106 
1107 	if (wmi_extract_mlo_teardown_cmpl_event(wmi_handle, event, &params) !=
1108 			QDF_STATUS_SUCCESS)
1109 		return -EINVAL;
1110 
1111 	pdev = wlan_objmgr_get_pdev_by_id(psoc, params.pdev_id,
1112 					  WLAN_INIT_DEINIT_ID);
1113 	if (pdev) {
1114 		mlo_link_teardown_complete(pdev);
1115 		wlan_objmgr_pdev_release_ref(pdev, WLAN_INIT_DEINIT_ID);
1116 	}
1117 
1118 	return 0;
1119 }
1120 
1121 static QDF_STATUS init_deinit_register_mlo_ev_handlers(wmi_unified_t wmi_handle)
1122 {
1123 	wmi_unified_register_event(wmi_handle,
1124 				   wmi_mlo_setup_complete_event_id,
1125 				   init_deinit_mlo_setup_comp_event_handler);
1126 	wmi_unified_register_event(wmi_handle,
1127 				   wmi_mlo_teardown_complete_event_id,
1128 				   init_deinit_mlo_teardown_comp_event_handler);
1129 
1130 	return QDF_STATUS_SUCCESS;
1131 }
1132 #else
1133 static QDF_STATUS init_deinit_register_mlo_ev_handlers(wmi_unified_t wmi_handle)
1134 {
1135 	return QDF_STATUS_SUCCESS;
1136 }
1137 #endif /*WLAN_FEATURE_11BE_MLO && WLAN_MLO_MULTI_CHIP*/
1138 
1139 QDF_STATUS init_deinit_register_tgt_psoc_ev_handlers(
1140 				struct wlan_objmgr_psoc *psoc)
1141 {
1142 	struct target_psoc_info *tgt_hdl;
1143 	wmi_unified_t wmi_handle;
1144 	QDF_STATUS retval = QDF_STATUS_SUCCESS;
1145 
1146 	if (!psoc) {
1147 		target_if_err("psoc is null in register wmi handler");
1148 		return QDF_STATUS_E_FAILURE;
1149 	}
1150 
1151 	tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc);
1152 	if (!tgt_hdl) {
1153 		target_if_err("target_psoc_info null in register wmi hadler");
1154 		return QDF_STATUS_E_FAILURE;
1155 	}
1156 
1157 	wmi_handle = (wmi_unified_t)target_psoc_get_wmi_hdl(tgt_hdl);
1158 
1159 	retval = wmi_unified_register_event_handler(wmi_handle,
1160 				wmi_service_ready_event_id,
1161 				init_deinit_service_ready_event_handler,
1162 				WMI_RX_WORK_CTX);
1163 	retval = wmi_unified_register_event_handler(wmi_handle,
1164 				wmi_service_ready_ext_event_id,
1165 				init_deinit_service_ext_ready_event_handler,
1166 				WMI_RX_WORK_CTX);
1167 	retval = wmi_unified_register_event_handler(wmi_handle,
1168 				wmi_service_available_event_id,
1169 				init_deinit_service_available_handler,
1170 				WMI_RX_UMAC_CTX);
1171 	retval = wmi_unified_register_event_handler(wmi_handle,
1172 				wmi_ready_event_id,
1173 				init_deinit_ready_event_handler,
1174 				WMI_RX_WORK_CTX);
1175 	retval = wmi_unified_register_event_handler(
1176 				wmi_handle,
1177 				wmi_service_ready_ext2_event_id,
1178 				init_deinit_service_ext2_ready_event_handler,
1179 				WMI_RX_WORK_CTX);
1180 	retval = init_deinit_register_mlo_ev_handlers(wmi_handle);
1181 
1182 #ifdef HEALTH_MON_SUPPORT
1183 	retval = wmi_unified_register_event_handler(
1184 				wmi_handle,
1185 				wmi_extract_health_mon_init_done_info_eventid,
1186 				init_deinit_health_mon_event_handler,
1187 				WMI_RX_WORK_CTX);
1188 #endif /* HEALTH_MON_SUPPORT */
1189 
1190 	return retval;
1191 }
1192 
1193