xref: /wlan-dirver/qca-wifi-host-cmn/target_if/init_deinit/src/init_event_handler.c (revision bea437e2293c3d4fb1b5704fcf633aedac996962)
1 /*
2  * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for
5  * any purpose with or without fee is hereby granted, provided that the
6  * above copyright notice and this permission notice appear in all
7  * copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16  * PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 /**
20  * DOC: init_event_handler.c
21  *
22  * WMI common event handler implementation source file
23  */
24 
25 #include <qdf_status.h>
26 #include <wlan_objmgr_psoc_obj.h>
27 #include <wlan_objmgr_pdev_obj.h>
28 #include <target_if.h>
29 #include <target_if_reg.h>
30 #include <init_event_handler.h>
31 #include <service_ready_util.h>
32 #include <service_ready_param.h>
33 #include <init_cmd_api.h>
34 #include <cdp_txrx_cmn.h>
35 
36 static void init_deinit_set_send_init_cmd(struct wlan_objmgr_psoc *psoc,
37 					  struct target_psoc_info *tgt_hdl)
38 {
39 	tgt_hdl->info.wmi_service_ready = TRUE;
40 	/* send init command */
41 	init_deinit_prepare_send_init_cmd(psoc, tgt_hdl);
42 }
43 
44 static int init_deinit_service_ready_event_handler(ol_scn_t scn_handle,
45 							uint8_t *event,
46 							uint32_t data_len)
47 {
48 	int err_code;
49 	struct wlan_objmgr_psoc *psoc;
50 	struct target_psoc_info *tgt_hdl;
51 	wmi_legacy_service_ready_callback legacy_callback;
52 	struct wmi_unified *wmi_handle;
53 	QDF_STATUS ret_val;
54 
55 	if (!scn_handle) {
56 		target_if_err("scn handle NULL in service ready handler");
57 		return -EINVAL;
58 	}
59 
60 	psoc = target_if_get_psoc_from_scn_hdl(scn_handle);
61 	if (!psoc) {
62 		target_if_err("psoc is null in service ready handler");
63 		return -EINVAL;
64 	}
65 
66 	tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc);
67 	if (!tgt_hdl) {
68 		target_if_err("target_psoc_info is null in service ready ev");
69 		return -EINVAL;
70 	}
71 
72 	ret_val = target_if_sw_version_check(psoc, tgt_hdl, event);
73 
74 	wmi_handle = target_psoc_get_wmi_hdl(tgt_hdl);
75 
76 	err_code = init_deinit_populate_service_bitmap(wmi_handle, event,
77 			tgt_hdl->info.service_bitmap);
78 	if (err_code)
79 		goto exit;
80 
81 	err_code = init_deinit_populate_fw_version_cmd(wmi_handle, event);
82 	if (err_code)
83 		goto exit;
84 
85 	err_code = init_deinit_populate_target_cap(wmi_handle, event,
86 				   &(tgt_hdl->info.target_caps));
87 	if (err_code)
88 		goto exit;
89 
90 	err_code = init_deinit_populate_phy_reg_cap(psoc, wmi_handle, event,
91 				    &(tgt_hdl->info), true);
92 	if (err_code)
93 		goto exit;
94 
95 	if (init_deinit_validate_160_80p80_fw_caps(psoc, tgt_hdl) !=
96 			QDF_STATUS_SUCCESS) {
97 		wlan_psoc_nif_op_flag_set(psoc, WLAN_SOC_OP_VHT_INVALID_CAP);
98 	}
99 
100 	target_if_ext_res_cfg_enable(psoc, tgt_hdl, event);
101 
102 	if (wmi_service_enabled(wmi_handle, wmi_service_tt))
103 		wlan_psoc_nif_fw_ext_cap_set(psoc, WLAN_SOC_CEXT_TT_SUPPORT);
104 
105 	if (wmi_service_enabled(wmi_handle, wmi_service_widebw_scan))
106 		wlan_psoc_nif_fw_ext_cap_set(psoc, WLAN_SOC_CEXT_WIDEBAND_SCAN);
107 
108 	if (wmi_service_enabled(wmi_handle, wmi_service_check_cal_version))
109 		wlan_psoc_nif_fw_ext_cap_set(psoc, WLAN_SOC_CEXT_SW_CAL);
110 
111 	if (wmi_service_enabled(wmi_handle, wmi_service_twt_requestor))
112 		wlan_psoc_nif_fw_ext_cap_set(psoc, WLAN_SOC_CEXT_TWT_REQUESTER);
113 
114 	if (wmi_service_enabled(wmi_handle, wmi_service_twt_responder))
115 		wlan_psoc_nif_fw_ext_cap_set(psoc, WLAN_SOC_CEXT_TWT_RESPONDER);
116 
117 	if (wmi_service_enabled(wmi_handle, wmi_service_bss_color_offload))
118 		target_if_debug(" BSS COLOR OFFLOAD supported");
119 
120 	if (wmi_service_enabled(wmi_handle, wmi_service_ul_ru26_allowed))
121 		wlan_psoc_nif_fw_ext_cap_set(psoc, WLAN_SOC_CEXT_OBSS_NBW_RU);
122 
123 	if (wmi_service_enabled(wmi_handle, wmi_service_infra_mbssid))
124 		wlan_psoc_nif_fw_ext_cap_set(psoc, WLAN_SOC_CEXT_MBSS_IE);
125 
126 	if (wmi_service_enabled(wmi_handle, wmi_service_dynamic_hw_mode))
127 		wlan_psoc_nif_fw_ext_cap_set(psoc, WLAN_SOC_CEXT_DYNAMIC_HW_MODE);
128 
129 	if (wmi_service_enabled(wmi_handle, wmi_service_bw_165mhz_support))
130 		wlan_psoc_nif_fw_ext_cap_set(psoc,
131 					     WLAN_SOC_RESTRICTED_80P80_SUPPORT);
132 
133 	target_if_debug(" TT support %d, Wide BW Scan %d, SW cal %d",
134 		wlan_psoc_nif_fw_ext_cap_get(psoc, WLAN_SOC_CEXT_TT_SUPPORT),
135 		wlan_psoc_nif_fw_ext_cap_get(psoc, WLAN_SOC_CEXT_WIDEBAND_SCAN),
136 		wlan_psoc_nif_fw_ext_cap_get(psoc, WLAN_SOC_CEXT_SW_CAL));
137 
138 	target_if_mesh_support_enable(psoc, tgt_hdl, event);
139 
140 	target_if_eapol_minrate_enable(psoc, tgt_hdl, event);
141 
142 	target_if_smart_antenna_enable(psoc, tgt_hdl, event);
143 
144 	target_if_cfr_support_enable(psoc, tgt_hdl, event);
145 
146 	target_if_peer_cfg_enable(psoc, tgt_hdl, event);
147 
148 	target_if_atf_cfg_enable(psoc, tgt_hdl, event);
149 
150 	if (!wmi_service_enabled(wmi_handle, wmi_service_ext_msg))
151 		target_if_qwrap_cfg_enable(psoc, tgt_hdl, event);
152 
153 	target_if_lteu_cfg_enable(psoc, tgt_hdl, event);
154 
155 	if (wmi_service_enabled(wmi_handle, wmi_service_rx_fse_support))
156 		wlan_psoc_nif_fw_ext_cap_set(psoc,
157 					     WLAN_SOC_CEXT_RX_FSE_SUPPORT);
158 
159 	/* override derived value, if it exceeds max peer count */
160 	if ((wlan_psoc_get_max_peer_count(psoc) >
161 		tgt_hdl->info.wlan_res_cfg.num_active_peers) &&
162 		(wlan_psoc_get_max_peer_count(psoc) <
163 			(tgt_hdl->info.wlan_res_cfg.num_peers -
164 				tgt_hdl->info.wlan_res_cfg.num_vdevs))) {
165 		tgt_hdl->info.wlan_res_cfg.num_peers =
166 				wlan_psoc_get_max_peer_count(psoc) +
167 					tgt_hdl->info.wlan_res_cfg.num_vdevs;
168 	}
169 	legacy_callback = target_if_get_psoc_legacy_service_ready_cb();
170 	if (!legacy_callback) {
171 		err_code = -EINVAL;
172 		goto exit;
173 	}
174 
175 	err_code = legacy_callback(wmi_service_ready_event_id,
176 				  scn_handle, event, data_len);
177 	init_deinit_chainmask_config(psoc, tgt_hdl);
178 
179 	if (wmi_service_enabled(wmi_handle, wmi_service_mgmt_tx_wmi)) {
180 		wlan_psoc_nif_fw_ext_cap_set(psoc, WLAN_SOC_CEXT_WMI_MGMT_REF);
181 		target_if_debug("WMI mgmt service enabled");
182 	} else {
183 		wlan_psoc_nif_fw_ext_cap_clear(psoc,
184 					       WLAN_SOC_CEXT_WMI_MGMT_REF);
185 		target_if_debug("WMI mgmt service disabled");
186 	}
187 
188 	err_code = init_deinit_handle_host_mem_req(psoc, tgt_hdl, event);
189 	if (err_code != QDF_STATUS_SUCCESS)
190 		goto exit;
191 
192 	target_if_reg_set_offloaded_info(psoc);
193 	target_if_reg_set_6ghz_info(psoc);
194 
195 	if (wmi_service_enabled(wmi_handle, wmi_service_ext_msg)) {
196 		target_if_debug("Wait for EXT message");
197 	} else {
198 		target_if_debug("No EXT message, send init command");
199 		target_psoc_set_num_radios(tgt_hdl, 1);
200 		init_deinit_set_send_init_cmd(psoc, tgt_hdl);
201 	}
202 
203 exit:
204 	return err_code;
205 }
206 
207 static int init_deinit_service_ext2_ready_event_handler(ol_scn_t scn_handle,
208 							uint8_t *event,
209 							uint32_t data_len)
210 {
211 	int err_code = 0;
212 	struct wlan_objmgr_psoc *psoc;
213 	struct target_psoc_info *tgt_hdl;
214 	struct wmi_unified *wmi_handle;
215 	struct tgt_info *info;
216 
217 	if (!scn_handle) {
218 		target_if_err("scn handle NULL in service ready handler");
219 		return -EINVAL;
220 	}
221 
222 	psoc = target_if_get_psoc_from_scn_hdl(scn_handle);
223 	if (!psoc) {
224 		target_if_err("psoc is null in service ready handler");
225 		return -EINVAL;
226 	}
227 
228 	tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc);
229 	if (!tgt_hdl) {
230 		target_if_err("target_psoc_info is null in service ready ev");
231 		return -EINVAL;
232 	}
233 
234 	wmi_handle = target_psoc_get_wmi_hdl(tgt_hdl);
235 	info = (&tgt_hdl->info);
236 
237 	err_code = init_deinit_populate_service_ready_ext2_param(wmi_handle,
238 								 event, info);
239 	if (err_code)
240 		goto exit;
241 
242 	/* dbr_ring_caps could have already come as part of EXT event */
243 	if (info->service_ext2_param.num_dbr_ring_caps) {
244 		err_code = init_deinit_populate_dbr_ring_cap_ext2(psoc,
245 								  wmi_handle,
246 								  event, info);
247 		if (err_code)
248 			goto exit;
249 	}
250 
251 	/* send init command */
252 	init_deinit_set_send_init_cmd(psoc, tgt_hdl);
253 
254 exit:
255 	return err_code;
256 }
257 
258 static int init_deinit_service_ext_ready_event_handler(ol_scn_t scn_handle,
259 						uint8_t *event,
260 						uint32_t data_len)
261 {
262 	int err_code;
263 	uint8_t num_radios;
264 	struct wlan_objmgr_psoc *psoc;
265 	struct target_psoc_info *tgt_hdl;
266 	struct wmi_unified *wmi_handle;
267 	struct tgt_info *info;
268 	wmi_legacy_service_ready_callback legacy_callback;
269 
270 	if (!scn_handle) {
271 		target_if_err("scn handle NULL in service ready handler");
272 		return -EINVAL;
273 	}
274 
275 	psoc = target_if_get_psoc_from_scn_hdl(scn_handle);
276 	if (!psoc) {
277 		target_if_err("psoc is null in service ready handler");
278 		return -EINVAL;
279 	}
280 
281 	tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc);
282 	if (!tgt_hdl) {
283 		target_if_err("target_psoc_info is null in service ready ev");
284 		return -EINVAL;
285 	}
286 
287 	wmi_handle = target_psoc_get_wmi_hdl(tgt_hdl);
288 	info = (&tgt_hdl->info);
289 
290 	err_code = init_deinit_populate_service_ready_ext_param(wmi_handle,
291 				event, &(info->service_ext_param));
292 	if (err_code)
293 		goto exit;
294 
295 	target_psoc_set_num_radios(tgt_hdl, 0);
296 	err_code =  init_deinit_populate_hw_mode_capability(wmi_handle,
297 					    event, tgt_hdl);
298 	if (err_code)
299 		goto exit;
300 
301 	if (init_deinit_is_preferred_hw_mode_supported(psoc, tgt_hdl)
302 			== FALSE) {
303 		target_if_err("Preferred mode %d not supported",
304 			      info->preferred_hw_mode);
305 		return -EINVAL;
306 	}
307 
308 	num_radios = target_psoc_get_num_radios_for_mode(tgt_hdl,
309 							 info->preferred_hw_mode);
310 
311 	/* set number of radios based on current mode */
312 	target_psoc_set_num_radios(tgt_hdl, num_radios);
313 
314 	target_if_print_service_ready_ext_param(psoc, tgt_hdl);
315 
316 	err_code = init_deinit_populate_phy_reg_cap(psoc, wmi_handle,
317 					   event, info, false);
318 	if (err_code)
319 		goto exit;
320 
321 	target_if_add_11ax_modes(psoc, tgt_hdl);
322 
323 	if (init_deinit_chainmask_table_alloc(
324 				&(info->service_ext_param)) ==
325 							QDF_STATUS_SUCCESS) {
326 		err_code = init_deinit_populate_chainmask_tables(wmi_handle,
327 				event,
328 				&(info->service_ext_param.chainmask_table[0]));
329 		if (err_code)
330 			goto exit;
331 	}
332 
333 	/* dbr_ring_caps can be absent if enough space is not available */
334 	if (info->service_ext_param.num_dbr_ring_caps) {
335 		err_code = init_deinit_populate_dbr_ring_cap(psoc, wmi_handle,
336 							     event, info);
337 		if (err_code)
338 			goto exit;
339 	}
340 
341 	err_code = init_deinit_populate_spectral_bin_scale_params(psoc,
342 								  wmi_handle,
343 								  event, info);
344 	if (err_code)
345 		goto exit;
346 
347 	legacy_callback = target_if_get_psoc_legacy_service_ready_cb();
348 	if (legacy_callback)
349 		legacy_callback(wmi_service_ready_ext_event_id,
350 				scn_handle, event, data_len);
351 
352 	target_if_qwrap_cfg_enable(psoc, tgt_hdl, event);
353 
354 	target_if_set_twt_ap_pdev_count(info, tgt_hdl);
355 
356 	info->wlan_res_cfg.num_vdevs = (target_psoc_get_num_radios(tgt_hdl) *
357 					info->wlan_res_cfg.num_vdevs);
358 	info->wlan_res_cfg.beacon_tx_offload_max_vdev =
359 				(target_psoc_get_num_radios(tgt_hdl) *
360 				info->wlan_res_cfg.beacon_tx_offload_max_vdev);
361 	info->wlan_res_cfg.max_bssid_indicator =
362 				info->service_ext_param.max_bssid_indicator;
363 
364 	if (wmi_service_enabled(wmi_handle, wmi_service_ext2_msg)) {
365 		target_if_debug("Wait for EXT2 message");
366 	} else {
367 		target_if_debug("No EXT2 message, send init command");
368 		init_deinit_set_send_init_cmd(psoc, tgt_hdl);
369 	}
370 
371 exit:
372 	return err_code;
373 }
374 
375 static int init_deinit_service_available_handler(ol_scn_t scn_handle,
376 						uint8_t *event,
377 						uint32_t data_len)
378 {
379 	struct wlan_objmgr_psoc *psoc;
380 	struct target_psoc_info *tgt_hdl;
381 	struct wmi_unified *wmi_handle;
382 
383 	if (!scn_handle) {
384 		target_if_err("scn handle NULL");
385 		return -EINVAL;
386 	}
387 
388 	psoc = target_if_get_psoc_from_scn_hdl(scn_handle);
389 	if (!psoc) {
390 		target_if_err("psoc is null");
391 		return -EINVAL;
392 	}
393 
394 	tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc);
395 	if (!tgt_hdl) {
396 		target_if_err("target_psoc_info is null");
397 		return -EINVAL;
398 	}
399 
400 	wmi_handle = target_psoc_get_wmi_hdl(tgt_hdl);
401 
402 	if (wmi_save_ext_service_bitmap(wmi_handle, event, NULL) !=
403 					QDF_STATUS_SUCCESS) {
404 		target_if_err("Failed to save ext service bitmap");
405 		return -EINVAL;
406 	}
407 
408 	return 0;
409 }
410 
411 /* MAC address fourth byte index */
412 #define MAC_BYTE_4 4
413 
414 static int init_deinit_ready_event_handler(ol_scn_t scn_handle,
415 						uint8_t *event,
416 						uint32_t data_len)
417 {
418 	struct wlan_objmgr_psoc *psoc;
419 	struct wlan_objmgr_pdev *pdev;
420 	struct target_psoc_info *tgt_hdl;
421 	struct wmi_unified *wmi_handle;
422 	struct wmi_host_fw_abi_ver fw_ver;
423 	uint8_t myaddr[QDF_MAC_ADDR_SIZE];
424 	struct tgt_info *info;
425 	struct wmi_host_ready_ev_param ready_ev;
426 	wmi_legacy_service_ready_callback legacy_callback;
427 	uint8_t num_radios, i;
428 	uint32_t max_peers;
429 	uint32_t max_ast_index;
430 	target_resource_config *tgt_cfg;
431 
432 	if (!scn_handle) {
433 		target_if_err("scn handle NULL");
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");
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");
446 		return -EINVAL;
447 	}
448 
449 	wmi_handle = target_psoc_get_wmi_hdl(tgt_hdl);
450 	info = (&tgt_hdl->info);
451 
452 	if (wmi_extract_fw_abi_version(wmi_handle, event, &fw_ver) ==
453 				QDF_STATUS_SUCCESS) {
454 		info->version.wlan_ver = fw_ver.sw_version;
455 		info->version.wlan_ver = fw_ver.abi_version;
456 	}
457 
458 	if (wmi_check_and_update_fw_version(wmi_handle, event) < 0) {
459 		target_if_err("Version mismatch with FW");
460 		return -EINVAL;
461 	}
462 
463 	if (wmi_extract_ready_event_params(wmi_handle, event, &ready_ev) !=
464 				QDF_STATUS_SUCCESS) {
465 		target_if_err("Failed to extract ready event");
466 		return -EINVAL;
467 	}
468 
469 	if (!ready_ev.agile_capability)
470 		target_if_err("agile capability disabled in HW");
471 	else
472 		info->wlan_res_cfg.agile_capability = ready_ev.agile_capability;
473 
474 	if ((ready_ev.num_total_peer != 0) &&
475 	    (info->wlan_res_cfg.num_peers != ready_ev.num_total_peer)) {
476 		/* FW allocated number of peers is different than host
477 		 * requested. Update host max with FW reported value.
478 		 */
479 		target_if_err("Host Requested %d peers. FW Supports %d peers",
480 			       info->wlan_res_cfg.num_peers,
481 			       ready_ev.num_total_peer);
482 		info->wlan_res_cfg.num_peers = ready_ev.num_total_peer;
483 	}
484 
485 	/* for non legacy  num_total_peer will be non zero
486 	 * allocate peer memory in this case
487 	 */
488 	if (ready_ev.num_total_peer != 0) {
489 		tgt_cfg = &info->wlan_res_cfg;
490 		max_peers = tgt_cfg->num_peers + ready_ev.num_extra_peer + 1;
491 		max_ast_index = ready_ev.max_ast_index + 1;
492 
493 		if (cdp_peer_map_attach(wlan_psoc_get_dp_handle(psoc),
494 					max_peers, max_ast_index,
495 					tgt_cfg->peer_map_unmap_v2) !=
496 				QDF_STATUS_SUCCESS) {
497 			target_if_err("DP peer map attach failed");
498 			return -EINVAL;
499 		}
500 	}
501 
502 	/* Indicate to the waiting thread that the ready
503 	 * event was received
504 	 */
505 	info->wlan_init_status = wmi_ready_extract_init_status(
506 						wmi_handle, event);
507 
508 	legacy_callback = target_if_get_psoc_legacy_service_ready_cb();
509 	if (legacy_callback)
510 		if (legacy_callback(wmi_ready_event_id,
511 				    scn_handle, event, data_len)) {
512 			target_if_err("Legacy callback returned error!");
513 			tgt_hdl->info.wmi_ready = FALSE;
514 			goto exit;
515 		}
516 
517 	num_radios = target_psoc_get_num_radios(tgt_hdl);
518 
519 	if (ready_ev.pktlog_defs_checksum) {
520 		for (i = 0; i < num_radios; i++) {
521 			pdev = wlan_objmgr_get_pdev_by_id(psoc, i,
522 							  WLAN_INIT_DEINIT_ID);
523 			if (!pdev) {
524 				target_if_err(" PDEV %d is NULL", i);
525 				return -EINVAL;
526 			}
527 			target_if_set_pktlog_checksum(pdev, tgt_hdl,
528 						      ready_ev.
529 						      pktlog_defs_checksum);
530 			wlan_objmgr_pdev_release_ref(pdev, WLAN_INIT_DEINIT_ID);
531 		}
532 	}
533 
534 	/*
535 	 * For non-legacy HW, MAC addr list is extracted.
536 	 */
537 	if (num_radios > 1) {
538 		uint8_t num_mac_addr;
539 		wmi_host_mac_addr *addr_list;
540 		int i;
541 
542 		addr_list = wmi_ready_extract_mac_addr_list(wmi_handle, event,
543 							    &num_mac_addr);
544 		if ((num_mac_addr >= num_radios) && (addr_list)) {
545 			for (i = 0; i < num_radios; i++) {
546 				WMI_HOST_MAC_ADDR_TO_CHAR_ARRAY(&addr_list[i],
547 								myaddr);
548 				pdev = wlan_objmgr_get_pdev_by_id(psoc, i,
549 								  WLAN_INIT_DEINIT_ID);
550 				if (!pdev) {
551 					target_if_err(" PDEV %d is NULL", i);
552 					return -EINVAL;
553 				}
554 				wlan_pdev_set_hw_macaddr(pdev, myaddr);
555 				wlan_objmgr_pdev_release_ref(pdev,
556 							WLAN_INIT_DEINIT_ID);
557 
558 				/* assign 1st radio addr to psoc */
559 				if (i == 0)
560 					wlan_psoc_set_hw_macaddr(psoc, myaddr);
561 			}
562 			goto out;
563 		} else {
564 			target_if_err("Using default MAC addr for all radios..");
565 		}
566 	}
567 
568 	/*
569 	 * We extract single MAC address in two scenarios:
570 	 * 1. In non-legacy case, if addr list is NULL or num_mac_addr < num_radios
571 	 * 2. In all legacy cases
572 	 */
573 	for (i = 0; i < num_radios; i++) {
574 		wmi_ready_extract_mac_addr(wmi_handle, event, myaddr);
575 		myaddr[MAC_BYTE_4] += i;
576 		pdev = wlan_objmgr_get_pdev_by_id(psoc, i, WLAN_INIT_DEINIT_ID);
577 		if (!pdev) {
578 			target_if_err(" PDEV %d is NULL", i);
579 			return -EINVAL;
580 		}
581 		wlan_pdev_set_hw_macaddr(pdev, myaddr);
582 		wlan_objmgr_pdev_release_ref(pdev, WLAN_INIT_DEINIT_ID);
583 		/* assign 1st radio addr to psoc */
584 		if (i == 0)
585 			wlan_psoc_set_hw_macaddr(psoc, myaddr);
586 	}
587 
588 out:
589 	target_if_btcoex_cfg_enable(psoc, tgt_hdl, event);
590 	tgt_hdl->info.wmi_ready = TRUE;
591 exit:
592 	init_deinit_wakeup_host_wait(psoc, tgt_hdl);
593 
594 	return 0;
595 }
596 
597 
598 QDF_STATUS init_deinit_register_tgt_psoc_ev_handlers(
599 				struct wlan_objmgr_psoc *psoc)
600 {
601 	struct target_psoc_info *tgt_hdl;
602 	wmi_unified_t wmi_handle;
603 	QDF_STATUS retval = QDF_STATUS_SUCCESS;
604 
605 	if (!psoc) {
606 		target_if_err("psoc is null in register wmi handler");
607 		return QDF_STATUS_E_FAILURE;
608 	}
609 
610 	tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc);
611 	if (!tgt_hdl) {
612 		target_if_err("target_psoc_info null in register wmi hadler");
613 		return QDF_STATUS_E_FAILURE;
614 	}
615 
616 	wmi_handle = (wmi_unified_t)target_psoc_get_wmi_hdl(tgt_hdl);
617 
618 	retval = wmi_unified_register_event_handler(wmi_handle,
619 				wmi_service_ready_event_id,
620 				init_deinit_service_ready_event_handler,
621 				WMI_RX_WORK_CTX);
622 	retval = wmi_unified_register_event_handler(wmi_handle,
623 				wmi_service_ready_ext_event_id,
624 				init_deinit_service_ext_ready_event_handler,
625 				WMI_RX_WORK_CTX);
626 	retval = wmi_unified_register_event_handler(wmi_handle,
627 				wmi_service_available_event_id,
628 				init_deinit_service_available_handler,
629 				WMI_RX_UMAC_CTX);
630 	retval = wmi_unified_register_event_handler(wmi_handle,
631 				wmi_ready_event_id,
632 				init_deinit_ready_event_handler,
633 				WMI_RX_WORK_CTX);
634 	retval = wmi_unified_register_event_handler(
635 				wmi_handle,
636 				wmi_service_ready_ext2_event_id,
637 				init_deinit_service_ext2_ready_event_handler,
638 				WMI_RX_WORK_CTX);
639 
640 
641 	return retval;
642 }
643 
644