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