xref: /wlan-dirver/qca-wifi-host-cmn/target_if/init_deinit/src/init_event_handler.c (revision 11f5a63a6cbdda84849a730de22f0a71e635d58c)
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 	target_if_debug(" TT support %d, Wide BW Scan %d, SW cal %d",
130 		wlan_psoc_nif_fw_ext_cap_get(psoc, WLAN_SOC_CEXT_TT_SUPPORT),
131 		wlan_psoc_nif_fw_ext_cap_get(psoc, WLAN_SOC_CEXT_WIDEBAND_SCAN),
132 		wlan_psoc_nif_fw_ext_cap_get(psoc, WLAN_SOC_CEXT_SW_CAL));
133 
134 	target_if_mesh_support_enable(psoc, tgt_hdl, event);
135 
136 	target_if_eapol_minrate_enable(psoc, tgt_hdl, event);
137 
138 	target_if_smart_antenna_enable(psoc, tgt_hdl, event);
139 
140 	target_if_cfr_support_enable(psoc, tgt_hdl, event);
141 
142 	target_if_peer_cfg_enable(psoc, tgt_hdl, event);
143 
144 	target_if_atf_cfg_enable(psoc, tgt_hdl, event);
145 
146 	if (!wmi_service_enabled(wmi_handle, wmi_service_ext_msg))
147 		target_if_qwrap_cfg_enable(psoc, tgt_hdl, event);
148 
149 	target_if_lteu_cfg_enable(psoc, tgt_hdl, event);
150 
151 	if (wmi_service_enabled(wmi_handle, wmi_service_rx_fse_support))
152 		wlan_psoc_nif_fw_ext_cap_set(psoc,
153 					     WLAN_SOC_CEXT_RX_FSE_SUPPORT);
154 
155 	/* override derived value, if it exceeds max peer count */
156 	if ((wlan_psoc_get_max_peer_count(psoc) >
157 		tgt_hdl->info.wlan_res_cfg.num_active_peers) &&
158 		(wlan_psoc_get_max_peer_count(psoc) <
159 			(tgt_hdl->info.wlan_res_cfg.num_peers -
160 				tgt_hdl->info.wlan_res_cfg.num_vdevs))) {
161 		tgt_hdl->info.wlan_res_cfg.num_peers =
162 				wlan_psoc_get_max_peer_count(psoc) +
163 					tgt_hdl->info.wlan_res_cfg.num_vdevs;
164 	}
165 	legacy_callback = target_if_get_psoc_legacy_service_ready_cb();
166 	if (!legacy_callback) {
167 		err_code = -EINVAL;
168 		goto exit;
169 	}
170 
171 	err_code = legacy_callback(wmi_service_ready_event_id,
172 				  scn_handle, event, data_len);
173 	init_deinit_chainmask_config(psoc, tgt_hdl);
174 
175 	if (wmi_service_enabled(wmi_handle, wmi_service_mgmt_tx_wmi)) {
176 		wlan_psoc_nif_fw_ext_cap_set(psoc, WLAN_SOC_CEXT_WMI_MGMT_REF);
177 		target_if_debug("WMI mgmt service enabled");
178 	} else {
179 		wlan_psoc_nif_fw_ext_cap_clear(psoc,
180 					       WLAN_SOC_CEXT_WMI_MGMT_REF);
181 		target_if_debug("WMI mgmt service disabled");
182 	}
183 
184 	err_code = init_deinit_handle_host_mem_req(psoc, tgt_hdl, event);
185 	if (err_code != QDF_STATUS_SUCCESS)
186 		goto exit;
187 
188 	target_if_reg_set_offloaded_info(psoc);
189 	if (wmi_service_enabled(wmi_handle, wmi_service_ext_msg)) {
190 		target_if_debug("Wait for EXT message");
191 	} else {
192 		target_if_debug("No EXT message, send init command");
193 		target_psoc_set_num_radios(tgt_hdl, 1);
194 		init_deinit_set_send_init_cmd(psoc, tgt_hdl);
195 	}
196 
197 exit:
198 	return err_code;
199 }
200 
201 static int init_deinit_service_ext2_ready_event_handler(ol_scn_t scn_handle,
202 							uint8_t *event,
203 							uint32_t data_len)
204 {
205 	int err_code = 0;
206 	struct wlan_objmgr_psoc *psoc;
207 	struct target_psoc_info *tgt_hdl;
208 	struct wmi_unified *wmi_handle;
209 	struct tgt_info *info;
210 
211 	if (!scn_handle) {
212 		target_if_err("scn handle NULL in service ready handler");
213 		return -EINVAL;
214 	}
215 
216 	psoc = target_if_get_psoc_from_scn_hdl(scn_handle);
217 	if (!psoc) {
218 		target_if_err("psoc is null in service ready handler");
219 		return -EINVAL;
220 	}
221 
222 	tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc);
223 	if (!tgt_hdl) {
224 		target_if_err("target_psoc_info is null in service ready ev");
225 		return -EINVAL;
226 	}
227 
228 	wmi_handle = target_psoc_get_wmi_hdl(tgt_hdl);
229 	info = (&tgt_hdl->info);
230 
231 	err_code = init_deinit_populate_service_ready_ext2_param(wmi_handle,
232 								 event, info);
233 	if (err_code)
234 		goto exit;
235 
236 	/* dbr_ring_caps could have already come as part of EXT event */
237 	if (info->service_ext2_param.num_dbr_ring_caps) {
238 		err_code = init_deinit_populate_dbr_ring_cap_ext2(psoc,
239 								  wmi_handle,
240 								  event, info);
241 		if (err_code)
242 			goto exit;
243 	}
244 
245 	/* send init command */
246 	init_deinit_set_send_init_cmd(psoc, tgt_hdl);
247 
248 exit:
249 	return err_code;
250 }
251 
252 static int init_deinit_service_ext_ready_event_handler(ol_scn_t scn_handle,
253 						uint8_t *event,
254 						uint32_t data_len)
255 {
256 	int err_code;
257 	uint8_t num_radios;
258 	struct wlan_objmgr_psoc *psoc;
259 	struct target_psoc_info *tgt_hdl;
260 	struct wmi_unified *wmi_handle;
261 	struct tgt_info *info;
262 	wmi_legacy_service_ready_callback legacy_callback;
263 
264 	if (!scn_handle) {
265 		target_if_err("scn handle NULL in service ready handler");
266 		return -EINVAL;
267 	}
268 
269 	psoc = target_if_get_psoc_from_scn_hdl(scn_handle);
270 	if (!psoc) {
271 		target_if_err("psoc is null in service ready handler");
272 		return -EINVAL;
273 	}
274 
275 	tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc);
276 	if (!tgt_hdl) {
277 		target_if_err("target_psoc_info is null in service ready ev");
278 		return -EINVAL;
279 	}
280 
281 	wmi_handle = target_psoc_get_wmi_hdl(tgt_hdl);
282 	info = (&tgt_hdl->info);
283 
284 	err_code = init_deinit_populate_service_ready_ext_param(wmi_handle,
285 				event, &(info->service_ext_param));
286 	if (err_code)
287 		goto exit;
288 
289 	target_psoc_set_num_radios(tgt_hdl, 0);
290 	err_code =  init_deinit_populate_hw_mode_capability(wmi_handle,
291 					    event, tgt_hdl);
292 	if (err_code)
293 		goto exit;
294 
295 	if (init_deinit_is_preferred_hw_mode_supported(psoc, tgt_hdl)
296 			== FALSE) {
297 		target_if_err("Preferred mode %d not supported",
298 			      info->preferred_hw_mode);
299 		return -EINVAL;
300 	}
301 
302 	num_radios = target_psoc_get_num_radios_for_mode(tgt_hdl,
303 							 info->preferred_hw_mode);
304 
305 	/* set number of radios based on current mode */
306 	target_psoc_set_num_radios(tgt_hdl, num_radios);
307 
308 	target_if_print_service_ready_ext_param(psoc, tgt_hdl);
309 
310 	err_code = init_deinit_populate_phy_reg_cap(psoc, wmi_handle,
311 					   event, info, false);
312 	if (err_code)
313 		goto exit;
314 
315 	target_if_add_11ax_modes(psoc, tgt_hdl);
316 
317 	if (init_deinit_chainmask_table_alloc(
318 				&(info->service_ext_param)) ==
319 							QDF_STATUS_SUCCESS) {
320 		err_code = init_deinit_populate_chainmask_tables(wmi_handle,
321 				event,
322 				&(info->service_ext_param.chainmask_table[0]));
323 		if (err_code)
324 			goto exit;
325 	}
326 
327 	/* dbr_ring_caps can be absent if enough space is not available */
328 	if (info->service_ext_param.num_dbr_ring_caps) {
329 		err_code = init_deinit_populate_dbr_ring_cap(psoc, wmi_handle,
330 							     event, info);
331 		if (err_code)
332 			goto exit;
333 	}
334 
335 	err_code = init_deinit_populate_spectral_bin_scale_params(psoc,
336 								  wmi_handle,
337 								  event, info);
338 	if (err_code)
339 		goto exit;
340 
341 	legacy_callback = target_if_get_psoc_legacy_service_ready_cb();
342 	if (legacy_callback)
343 		legacy_callback(wmi_service_ready_ext_event_id,
344 				scn_handle, event, data_len);
345 
346 	target_if_qwrap_cfg_enable(psoc, tgt_hdl, event);
347 
348 	target_if_set_twt_ap_pdev_count(info, tgt_hdl);
349 
350 	info->wlan_res_cfg.num_vdevs = (target_psoc_get_num_radios(tgt_hdl) *
351 					info->wlan_res_cfg.num_vdevs);
352 	info->wlan_res_cfg.beacon_tx_offload_max_vdev =
353 				(target_psoc_get_num_radios(tgt_hdl) *
354 				info->wlan_res_cfg.beacon_tx_offload_max_vdev);
355 	info->wlan_res_cfg.max_bssid_indicator =
356 				info->service_ext_param.max_bssid_indicator;
357 
358 	if (wmi_service_enabled(wmi_handle, wmi_service_ext2_msg)) {
359 		target_if_debug("Wait for EXT2 message");
360 	} else {
361 		target_if_debug("No EXT2 message, send init command");
362 		init_deinit_set_send_init_cmd(psoc, tgt_hdl);
363 	}
364 
365 exit:
366 	return err_code;
367 }
368 
369 static int init_deinit_service_available_handler(ol_scn_t scn_handle,
370 						uint8_t *event,
371 						uint32_t data_len)
372 {
373 	struct wlan_objmgr_psoc *psoc;
374 	struct target_psoc_info *tgt_hdl;
375 	struct wmi_unified *wmi_handle;
376 
377 	if (!scn_handle) {
378 		target_if_err("scn handle NULL");
379 		return -EINVAL;
380 	}
381 
382 	psoc = target_if_get_psoc_from_scn_hdl(scn_handle);
383 	if (!psoc) {
384 		target_if_err("psoc is null");
385 		return -EINVAL;
386 	}
387 
388 	tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc);
389 	if (!tgt_hdl) {
390 		target_if_err("target_psoc_info is null");
391 		return -EINVAL;
392 	}
393 
394 	wmi_handle = target_psoc_get_wmi_hdl(tgt_hdl);
395 
396 	if (wmi_save_ext_service_bitmap(wmi_handle, event, NULL) !=
397 					QDF_STATUS_SUCCESS) {
398 		target_if_err("Failed to save ext service bitmap");
399 		return -EINVAL;
400 	}
401 
402 	return 0;
403 }
404 
405 /* MAC address fourth byte index */
406 #define MAC_BYTE_4 4
407 
408 static int init_deinit_ready_event_handler(ol_scn_t scn_handle,
409 						uint8_t *event,
410 						uint32_t data_len)
411 {
412 	struct wlan_objmgr_psoc *psoc;
413 	struct wlan_objmgr_pdev *pdev;
414 	struct target_psoc_info *tgt_hdl;
415 	struct wmi_unified *wmi_handle;
416 	struct wmi_host_fw_abi_ver fw_ver;
417 	uint8_t myaddr[QDF_MAC_ADDR_SIZE];
418 	struct tgt_info *info;
419 	struct wmi_host_ready_ev_param ready_ev;
420 	wmi_legacy_service_ready_callback legacy_callback;
421 	uint8_t num_radios, i;
422 	uint32_t max_peers;
423 	uint32_t max_ast_index;
424 	target_resource_config *tgt_cfg;
425 
426 	if (!scn_handle) {
427 		target_if_err("scn handle NULL");
428 		return -EINVAL;
429 	}
430 
431 	psoc = target_if_get_psoc_from_scn_hdl(scn_handle);
432 	if (!psoc) {
433 		target_if_err("psoc is null");
434 		return -EINVAL;
435 	}
436 
437 	tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc);
438 	if (!tgt_hdl) {
439 		target_if_err("target_psoc_info is null");
440 		return -EINVAL;
441 	}
442 
443 	wmi_handle = target_psoc_get_wmi_hdl(tgt_hdl);
444 	info = (&tgt_hdl->info);
445 
446 	if (wmi_extract_fw_abi_version(wmi_handle, event, &fw_ver) ==
447 				QDF_STATUS_SUCCESS) {
448 		info->version.wlan_ver = fw_ver.sw_version;
449 		info->version.wlan_ver = fw_ver.abi_version;
450 	}
451 
452 	if (wmi_check_and_update_fw_version(wmi_handle, event) < 0) {
453 		target_if_err("Version mismatch with FW");
454 		return -EINVAL;
455 	}
456 
457 	if (wmi_extract_ready_event_params(wmi_handle, event, &ready_ev) !=
458 				QDF_STATUS_SUCCESS) {
459 		target_if_err("Failed to extract ready event");
460 		return -EINVAL;
461 	}
462 
463 	if (!ready_ev.agile_capability)
464 		target_if_err("agile capability disabled in HW");
465 	else
466 		info->wlan_res_cfg.agile_capability = ready_ev.agile_capability;
467 
468 	if ((ready_ev.num_total_peer != 0) &&
469 	    (info->wlan_res_cfg.num_peers != ready_ev.num_total_peer)) {
470 		/* FW allocated number of peers is different than host
471 		 * requested. Update host max with FW reported value.
472 		 */
473 		target_if_err("Host Requested %d peers. FW Supports %d peers",
474 			       info->wlan_res_cfg.num_peers,
475 			       ready_ev.num_total_peer);
476 		info->wlan_res_cfg.num_peers = ready_ev.num_total_peer;
477 	}
478 
479 	/* for non legacy  num_total_peer will be non zero
480 	 * allocate peer memory in this case
481 	 */
482 	if (ready_ev.num_total_peer != 0) {
483 		tgt_cfg = &info->wlan_res_cfg;
484 		max_peers = tgt_cfg->num_peers + ready_ev.num_extra_peer + 1;
485 		max_ast_index = ready_ev.max_ast_index + 1;
486 
487 		if (cdp_peer_map_attach(wlan_psoc_get_dp_handle(psoc),
488 					max_peers, max_ast_index,
489 					tgt_cfg->peer_map_unmap_v2) !=
490 				QDF_STATUS_SUCCESS) {
491 			target_if_err("DP peer map attach failed");
492 			return -EINVAL;
493 		}
494 	}
495 
496 	/* Indicate to the waiting thread that the ready
497 	 * event was received
498 	 */
499 	info->wlan_init_status = wmi_ready_extract_init_status(
500 						wmi_handle, event);
501 
502 	legacy_callback = target_if_get_psoc_legacy_service_ready_cb();
503 	if (legacy_callback)
504 		if (legacy_callback(wmi_ready_event_id,
505 				    scn_handle, event, data_len)) {
506 			target_if_err("Legacy callback returned error!");
507 			tgt_hdl->info.wmi_ready = FALSE;
508 			goto exit;
509 		}
510 
511 	num_radios = target_psoc_get_num_radios(tgt_hdl);
512 
513 	if (ready_ev.pktlog_defs_checksum) {
514 		for (i = 0; i < num_radios; i++) {
515 			pdev = wlan_objmgr_get_pdev_by_id(psoc, i,
516 							  WLAN_INIT_DEINIT_ID);
517 			if (!pdev) {
518 				target_if_err(" PDEV %d is NULL", i);
519 				return -EINVAL;
520 			}
521 			target_if_set_pktlog_checksum(pdev, tgt_hdl,
522 						      ready_ev.
523 						      pktlog_defs_checksum);
524 			wlan_objmgr_pdev_release_ref(pdev, WLAN_INIT_DEINIT_ID);
525 		}
526 	}
527 
528 	/*
529 	 * For non-legacy HW, MAC addr list is extracted.
530 	 */
531 	if (num_radios > 1) {
532 		uint8_t num_mac_addr;
533 		wmi_host_mac_addr *addr_list;
534 		int i;
535 
536 		addr_list = wmi_ready_extract_mac_addr_list(wmi_handle, event,
537 							    &num_mac_addr);
538 		if ((num_mac_addr >= num_radios) && (addr_list)) {
539 			for (i = 0; i < num_radios; i++) {
540 				WMI_HOST_MAC_ADDR_TO_CHAR_ARRAY(&addr_list[i],
541 								myaddr);
542 				pdev = wlan_objmgr_get_pdev_by_id(psoc, i,
543 								  WLAN_INIT_DEINIT_ID);
544 				if (!pdev) {
545 					target_if_err(" PDEV %d is NULL", i);
546 					return -EINVAL;
547 				}
548 				wlan_pdev_set_hw_macaddr(pdev, myaddr);
549 				wlan_objmgr_pdev_release_ref(pdev,
550 							WLAN_INIT_DEINIT_ID);
551 
552 				/* assign 1st radio addr to psoc */
553 				if (i == 0)
554 					wlan_psoc_set_hw_macaddr(psoc, myaddr);
555 			}
556 			goto out;
557 		} else {
558 			target_if_err("Using default MAC addr for all radios..");
559 		}
560 	}
561 
562 	/*
563 	 * We extract single MAC address in two scenarios:
564 	 * 1. In non-legacy case, if addr list is NULL or num_mac_addr < num_radios
565 	 * 2. In all legacy cases
566 	 */
567 	for (i = 0; i < num_radios; i++) {
568 		wmi_ready_extract_mac_addr(wmi_handle, event, myaddr);
569 		myaddr[MAC_BYTE_4] += i;
570 		pdev = wlan_objmgr_get_pdev_by_id(psoc, i, WLAN_INIT_DEINIT_ID);
571 		if (!pdev) {
572 			target_if_err(" PDEV %d is NULL", i);
573 			return -EINVAL;
574 		}
575 		wlan_pdev_set_hw_macaddr(pdev, myaddr);
576 		wlan_objmgr_pdev_release_ref(pdev, WLAN_INIT_DEINIT_ID);
577 		/* assign 1st radio addr to psoc */
578 		if (i == 0)
579 			wlan_psoc_set_hw_macaddr(psoc, myaddr);
580 	}
581 
582 out:
583 	target_if_btcoex_cfg_enable(psoc, tgt_hdl, event);
584 	tgt_hdl->info.wmi_ready = TRUE;
585 exit:
586 	init_deinit_wakeup_host_wait(psoc, tgt_hdl);
587 
588 	return 0;
589 }
590 
591 
592 QDF_STATUS init_deinit_register_tgt_psoc_ev_handlers(
593 				struct wlan_objmgr_psoc *psoc)
594 {
595 	struct target_psoc_info *tgt_hdl;
596 	wmi_unified_t wmi_handle;
597 	QDF_STATUS retval = QDF_STATUS_SUCCESS;
598 
599 	if (!psoc) {
600 		target_if_err("psoc is null in register wmi handler");
601 		return QDF_STATUS_E_FAILURE;
602 	}
603 
604 	tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc);
605 	if (!tgt_hdl) {
606 		target_if_err("target_psoc_info null in register wmi hadler");
607 		return QDF_STATUS_E_FAILURE;
608 	}
609 
610 	wmi_handle = (wmi_unified_t)target_psoc_get_wmi_hdl(tgt_hdl);
611 
612 	retval = wmi_unified_register_event_handler(wmi_handle,
613 				wmi_service_ready_event_id,
614 				init_deinit_service_ready_event_handler,
615 				WMI_RX_WORK_CTX);
616 	retval = wmi_unified_register_event_handler(wmi_handle,
617 				wmi_service_ready_ext_event_id,
618 				init_deinit_service_ext_ready_event_handler,
619 				WMI_RX_WORK_CTX);
620 	retval = wmi_unified_register_event_handler(wmi_handle,
621 				wmi_service_available_event_id,
622 				init_deinit_service_available_handler,
623 				WMI_RX_UMAC_CTX);
624 	retval = wmi_unified_register_event_handler(wmi_handle,
625 				wmi_ready_event_id,
626 				init_deinit_ready_event_handler,
627 				WMI_RX_WORK_CTX);
628 	retval = wmi_unified_register_event_handler(
629 				wmi_handle,
630 				wmi_service_ready_ext2_event_id,
631 				init_deinit_service_ext2_ready_event_handler,
632 				WMI_RX_WORK_CTX);
633 
634 
635 	return retval;
636 }
637 
638