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