1 /* 2 * Copyright (c) 2017-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: API for interacting with target interface. 22 * 23 */ 24 25 #include "target_if.h" 26 #include "target_type.h" 27 #ifdef WLAN_ATF_ENABLE 28 #include "target_if_atf.h" 29 #endif 30 #ifdef WLAN_SA_API_ENABLE 31 #include "target_if_sa_api.h" 32 #endif 33 #ifdef WLAN_CFR_ENABLE 34 #include "target_if_cfr.h" 35 #endif 36 #ifdef WLAN_CONV_SPECTRAL_ENABLE 37 #include "target_if_spectral.h" 38 #endif 39 40 #ifdef WLAN_IOT_SIM_SUPPORT 41 #include <target_if_iot_sim.h> 42 #endif 43 #include <target_if_reg.h> 44 #include <target_if_scan.h> 45 #include <target_if_ftm.h> 46 #ifdef DFS_COMPONENT_ENABLE 47 #include <target_if_dfs.h> 48 #endif 49 50 #ifdef CONVERGED_P2P_ENABLE 51 #include "target_if_p2p.h" 52 #endif 53 54 #ifdef WIFI_POS_CONVERGED 55 #include "target_if_wifi_pos.h" 56 #include "target_if_wifi_pos_rx_ops.h" 57 #include "target_if_wifi_pos_tx_ops.h" 58 #endif 59 60 #ifdef FEATURE_WLAN_TDLS 61 #include "target_if_tdls.h" 62 #endif 63 #if defined(QCA_SUPPORT_SON) || defined(WLAN_FEATURE_SON) 64 #include <target_if_son.h> 65 #endif 66 #if defined WLAN_FEATURE_11AX 67 #include <target_if_spatial_reuse.h> 68 #endif 69 #ifdef WLAN_OFFCHAN_TXRX_ENABLE 70 #include <target_if_offchan_txrx_api.h> 71 #endif 72 #ifdef WLAN_SUPPORT_GREEN_AP 73 #include <target_if_green_ap.h> 74 #endif 75 #include <init_deinit_lmac.h> 76 #include <service_ready_util.h> 77 78 #ifdef DIRECT_BUF_RX_ENABLE 79 #include <target_if_direct_buf_rx_api.h> 80 #endif 81 82 #ifdef WLAN_SUPPORT_FILS 83 #include <target_if_fd.h> 84 #endif 85 #include "qdf_module.h" 86 87 #include <target_if_cp_stats.h> 88 #ifdef CRYPTO_SET_KEY_CONVERGED 89 #include <target_if_crypto.h> 90 #endif 91 #include <target_if_vdev_mgr_tx_ops.h> 92 93 #ifdef FEATURE_COEX 94 #include <target_if_coex.h> 95 #endif 96 #include <wlan_utility.h> 97 98 #ifdef DCS_INTERFERENCE_DETECTION 99 #include <target_if_dcs.h> 100 #endif 101 102 #include <target_if_gpio.h> 103 #ifdef IPA_OFFLOAD 104 #include <target_if_ipa.h> 105 #endif 106 107 #ifdef WLAN_MGMT_RX_REO_SUPPORT 108 #include <target_if_mgmt_txrx.h> 109 #endif /* WLAN_MGMT_RX_REO_SUPPORT */ 110 111 #include "wmi_unified_api.h" 112 #include <target_if_twt.h> 113 114 #ifdef WLAN_FEATURE_11BE_MLO 115 #include <target_if_mlo_mgr.h> 116 #endif 117 118 #ifdef WLAN_FEATURE_COAP 119 #include <target_if_coap.h> 120 #endif 121 122 static struct target_if_ctx *g_target_if_ctx; 123 124 struct target_if_ctx *target_if_get_ctx() 125 { 126 return g_target_if_ctx; 127 } 128 129 struct wlan_objmgr_psoc *target_if_get_psoc_from_scn_hdl(void *scn_handle) 130 { 131 struct wlan_objmgr_psoc *psoc; 132 133 qdf_spin_lock_bh(&g_target_if_ctx->lock); 134 if (scn_handle && g_target_if_ctx->get_psoc_hdl_cb) 135 psoc = g_target_if_ctx->get_psoc_hdl_cb(scn_handle); 136 else 137 psoc = NULL; 138 qdf_spin_unlock_bh(&g_target_if_ctx->lock); 139 140 return psoc; 141 } 142 143 struct wlan_objmgr_pdev *target_if_get_pdev_from_scn_hdl(void *scn_handle) 144 { 145 struct wlan_objmgr_pdev *pdev; 146 147 qdf_spin_lock_bh(&g_target_if_ctx->lock); 148 if (scn_handle && g_target_if_ctx->get_pdev_hdl_cb) 149 pdev = g_target_if_ctx->get_pdev_hdl_cb(scn_handle); 150 else 151 pdev = NULL; 152 qdf_spin_unlock_bh(&g_target_if_ctx->lock); 153 154 return pdev; 155 } 156 157 #ifdef DIRECT_BUF_RX_ENABLE 158 static QDF_STATUS target_if_direct_buf_rx_init(void) 159 { 160 return direct_buf_rx_init(); 161 } 162 163 static QDF_STATUS target_if_direct_buf_rx_deinit(void) 164 { 165 return direct_buf_rx_deinit(); 166 } 167 #else 168 static QDF_STATUS target_if_direct_buf_rx_init(void) 169 { 170 return QDF_STATUS_SUCCESS; 171 } 172 173 static QDF_STATUS target_if_direct_buf_rx_deinit(void) 174 { 175 return QDF_STATUS_SUCCESS; 176 } 177 #endif /* DIRECT_BUF_RX_ENABLE */ 178 179 QDF_STATUS target_if_init(get_psoc_handle_callback psoc_hdl_cb) 180 { 181 g_target_if_ctx = qdf_mem_malloc(sizeof(*g_target_if_ctx)); 182 if (!g_target_if_ctx) { 183 QDF_ASSERT(0); 184 return QDF_STATUS_E_NOMEM; 185 } 186 187 qdf_spinlock_create(&g_target_if_ctx->lock); 188 189 qdf_spin_lock_bh(&g_target_if_ctx->lock); 190 g_target_if_ctx->magic = TGT_MAGIC; 191 g_target_if_ctx->get_psoc_hdl_cb = psoc_hdl_cb; 192 qdf_spin_unlock_bh(&g_target_if_ctx->lock); 193 194 target_if_direct_buf_rx_init(); 195 196 return QDF_STATUS_SUCCESS; 197 } 198 199 QDF_STATUS target_if_deinit(void) 200 { 201 if (!g_target_if_ctx) { 202 QDF_ASSERT(0); 203 target_if_err("target if ctx is null"); 204 return QDF_STATUS_E_INVAL; 205 } 206 207 qdf_spin_lock_bh(&g_target_if_ctx->lock); 208 g_target_if_ctx->magic = 0; 209 g_target_if_ctx->get_psoc_hdl_cb = NULL; 210 g_target_if_ctx->get_pdev_hdl_cb = NULL; 211 g_target_if_ctx->service_ready_cb = NULL; 212 qdf_spin_unlock_bh(&g_target_if_ctx->lock); 213 214 qdf_spinlock_destroy(&g_target_if_ctx->lock); 215 qdf_mem_free(g_target_if_ctx); 216 g_target_if_ctx = NULL; 217 218 target_if_direct_buf_rx_deinit(); 219 220 return QDF_STATUS_SUCCESS; 221 } 222 223 qdf_export_symbol(target_if_deinit); 224 225 QDF_STATUS target_if_store_pdev_target_if_ctx( 226 get_pdev_handle_callback pdev_hdl_cb) 227 { 228 if (!g_target_if_ctx) { 229 QDF_ASSERT(0); 230 target_if_err("target if ctx is null"); 231 return QDF_STATUS_E_INVAL; 232 } 233 234 qdf_spin_lock_bh(&g_target_if_ctx->lock); 235 g_target_if_ctx->get_pdev_hdl_cb = pdev_hdl_cb; 236 qdf_spin_unlock_bh(&g_target_if_ctx->lock); 237 238 return QDF_STATUS_SUCCESS; 239 } 240 241 #ifndef WLAN_OFFCHAN_TXRX_ENABLE 242 static void target_if_offchan_txrx_ops_register( 243 struct wlan_lmac_if_tx_ops *tx_ops) 244 { 245 } 246 #endif /* WLAN_OFFCHAN_TXRX_ENABLE */ 247 248 #ifndef WLAN_ATF_ENABLE 249 static void target_if_atf_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops) 250 { 251 } 252 #endif /* WLAN_ATF_ENABLE */ 253 254 #ifndef WLAN_SA_API_ENABLE 255 static void target_if_sa_api_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops) 256 { 257 } 258 #endif /* WLAN_SA_API_ENABLE */ 259 260 #ifndef WLAN_CFR_ENABLE 261 static void target_if_cfr_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops) 262 { 263 } 264 #endif 265 266 #ifdef WLAN_SUPPORT_FILS 267 static void target_if_fd_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops) 268 { 269 target_if_fd_register_tx_ops(tx_ops); 270 } 271 #else 272 static void target_if_fd_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops) 273 { 274 } 275 #endif 276 277 #ifdef WIFI_POS_CONVERGED 278 static void 279 target_if_wifi_pos_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops) 280 { 281 target_if_wifi_pos_register_tx_ops(tx_ops); 282 } 283 #else 284 static void 285 target_if_wifi_pos_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops) 286 { 287 } 288 #endif 289 290 #if defined(QCA_SUPPORT_SON) || defined(WLAN_FEATURE_SON) 291 static void target_if_son_tx_ops_register( 292 struct wlan_lmac_if_tx_ops *tx_ops) 293 { 294 target_if_son_register_tx_ops(tx_ops); 295 return; 296 } 297 #else 298 static void target_if_son_tx_ops_register( 299 struct wlan_lmac_if_tx_ops *tx_ops) 300 { 301 return; 302 } 303 #endif 304 305 #if defined WLAN_FEATURE_11AX 306 static void target_if_spatial_reuse_tx_ops_register( 307 struct wlan_lmac_if_tx_ops *tx_ops) 308 { 309 target_if_spatial_reuse_register_tx_ops(tx_ops); 310 } 311 312 #else 313 static void target_if_spatial_reuse_tx_ops_register( 314 struct wlan_lmac_if_tx_ops *tx_ops) 315 { 316 } 317 318 #endif 319 320 #ifdef FEATURE_WLAN_TDLS 321 static void target_if_tdls_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops) 322 { 323 target_if_tdls_register_tx_ops(tx_ops); 324 } 325 #else 326 static void target_if_tdls_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops) 327 { 328 } 329 #endif /* FEATURE_WLAN_TDLS */ 330 331 #ifdef DFS_COMPONENT_ENABLE 332 static void target_if_dfs_tx_ops_register( 333 struct wlan_lmac_if_tx_ops *tx_ops) 334 { 335 target_if_register_dfs_tx_ops(tx_ops); 336 } 337 #else 338 static void target_if_dfs_tx_ops_register( 339 struct wlan_lmac_if_tx_ops *tx_ops) 340 { 341 } 342 #endif /* DFS_COMPONENT_ENABLE */ 343 344 #ifdef WLAN_CONV_SPECTRAL_ENABLE 345 static void target_if_sptrl_tx_ops_register( 346 struct wlan_lmac_if_tx_ops *tx_ops) 347 { 348 target_if_sptrl_register_tx_ops(tx_ops); 349 } 350 #else 351 static void target_if_sptrl_tx_ops_register( 352 struct wlan_lmac_if_tx_ops *tx_ops) 353 { 354 } 355 #endif /* WLAN_CONV_SPECTRAL_ENABLE */ 356 357 #ifdef WLAN_IOT_SIM_SUPPORT 358 static void target_if_iot_sim_tx_ops_register( 359 struct wlan_lmac_if_tx_ops *tx_ops) 360 { 361 target_if_iot_sim_register_tx_ops(tx_ops); 362 } 363 #else 364 static void target_if_iot_sim_tx_ops_register( 365 struct wlan_lmac_if_tx_ops *tx_ops) 366 { 367 } 368 #endif 369 370 #ifdef DIRECT_BUF_RX_ENABLE 371 static void target_if_direct_buf_rx_tx_ops_register( 372 struct wlan_lmac_if_tx_ops *tx_ops) 373 { 374 target_if_direct_buf_rx_register_tx_ops(tx_ops); 375 } 376 #else 377 static void target_if_direct_buf_rx_tx_ops_register( 378 struct wlan_lmac_if_tx_ops *tx_ops) 379 { 380 } 381 #endif /* DIRECT_BUF_RX_ENABLE */ 382 383 #ifdef WLAN_SUPPORT_GREEN_AP 384 static QDF_STATUS target_if_green_ap_tx_ops_register( 385 struct wlan_lmac_if_tx_ops *tx_ops) 386 { 387 return target_if_register_green_ap_tx_ops(tx_ops); 388 } 389 #else 390 static QDF_STATUS target_if_green_ap_tx_ops_register( 391 struct wlan_lmac_if_tx_ops *tx_ops) 392 { 393 return QDF_STATUS_SUCCESS; 394 } 395 #endif /* WLAN_SUPPORT_GREEN_AP */ 396 #if defined(CRYPTO_SET_KEY_CONVERGED) 397 static void target_if_crypto_tx_ops_register( 398 struct wlan_lmac_if_tx_ops *tx_ops) 399 { 400 target_if_crypto_register_tx_ops(tx_ops); 401 } 402 #else 403 static inline void target_if_crypto_tx_ops_register( 404 struct wlan_lmac_if_tx_ops *tx_ops) 405 { 406 } 407 #endif 408 409 #ifdef FEATURE_COEX 410 static QDF_STATUS 411 target_if_coex_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops) 412 { 413 return target_if_coex_register_tx_ops(tx_ops); 414 } 415 #else 416 static inline QDF_STATUS 417 target_if_coex_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops) 418 { 419 return QDF_STATUS_SUCCESS; 420 } 421 #endif 422 423 #ifdef WLAN_FEATURE_DBAM_CONFIG 424 static QDF_STATUS 425 target_if_dbam_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops) 426 { 427 return target_if_dbam_register_tx_ops(tx_ops); 428 } 429 #else 430 static inline QDF_STATUS 431 target_if_dbam_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops) 432 { 433 return QDF_STATUS_SUCCESS; 434 } 435 #endif 436 437 #ifdef WLAN_FEATURE_COAP 438 static QDF_STATUS 439 target_if_coap_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops) 440 { 441 return target_if_coap_register_tx_ops(tx_ops); 442 } 443 #else 444 static inline QDF_STATUS 445 target_if_coap_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops) 446 { 447 return QDF_STATUS_SUCCESS; 448 } 449 #endif 450 451 static void target_if_target_tx_ops_register( 452 struct wlan_lmac_if_tx_ops *tx_ops) 453 { 454 struct wlan_lmac_if_target_tx_ops *target_tx_ops; 455 456 if (!tx_ops) { 457 target_if_err("invalid tx_ops"); 458 return; 459 } 460 461 target_tx_ops = &tx_ops->target_tx_ops; 462 463 target_tx_ops->tgt_is_tgt_type_ar900b = 464 target_is_tgt_type_ar900b; 465 466 target_tx_ops->tgt_is_tgt_type_qca9984 = 467 target_is_tgt_type_qca9984; 468 469 target_tx_ops->tgt_is_tgt_type_qca9888 = 470 target_is_tgt_type_qca9888; 471 472 target_tx_ops->tgt_is_tgt_type_adrastea = 473 target_is_tgt_type_adrastea; 474 475 target_tx_ops->tgt_is_tgt_type_qcn9000 = 476 target_is_tgt_type_qcn9000; 477 478 target_tx_ops->tgt_is_tgt_type_qcn6122 = 479 target_is_tgt_type_qcn6122; 480 481 target_tx_ops->tgt_is_tgt_type_qcn7605 = 482 target_is_tgt_type_qcn7605; 483 484 target_tx_ops->tgt_get_tgt_type = 485 lmac_get_tgt_type; 486 487 target_tx_ops->tgt_get_tgt_version = 488 lmac_get_tgt_version; 489 490 target_tx_ops->tgt_get_tgt_revision = 491 lmac_get_tgt_revision; 492 } 493 494 static QDF_STATUS 495 target_if_cp_stats_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops) 496 { 497 return target_if_cp_stats_register_tx_ops(tx_ops); 498 } 499 500 #ifdef DCS_INTERFERENCE_DETECTION 501 static QDF_STATUS 502 target_if_dcs_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops) 503 { 504 return target_if_dcs_register_tx_ops(tx_ops); 505 } 506 #else 507 static QDF_STATUS 508 target_if_dcs_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops) 509 { 510 return QDF_STATUS_SUCCESS; 511 } 512 #endif 513 514 static QDF_STATUS 515 target_if_vdev_mgr_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops) 516 { 517 return target_if_vdev_mgr_register_tx_ops(tx_ops); 518 } 519 520 #ifdef QCA_WIFI_FTM 521 static 522 void target_if_ftm_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops) 523 { 524 target_if_ftm_register_tx_ops(tx_ops); 525 } 526 #else 527 static 528 void target_if_ftm_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops) 529 { 530 } 531 #endif 532 533 #ifdef WLAN_FEATURE_GPIO_CFG 534 static 535 void target_if_gpio_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops) 536 { 537 target_if_gpio_register_tx_ops(tx_ops); 538 } 539 #else 540 static 541 void target_if_gpio_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops) 542 { 543 } 544 #endif 545 546 #ifdef WLAN_MGMT_RX_REO_SUPPORT 547 static 548 void target_if_mgmt_txrx_register_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops) 549 { 550 target_if_mgmt_txrx_tx_ops_register(tx_ops); 551 } 552 #else 553 static 554 void target_if_mgmt_txrx_register_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops) 555 { 556 } 557 #endif /* WLAN_MGMT_RX_REO_SUPPORT */ 558 559 #ifdef WLAN_FEATURE_11BE_MLO 560 static QDF_STATUS 561 target_if_mlo_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops) 562 { 563 return target_if_mlo_register_tx_ops(tx_ops); 564 } 565 #else 566 static QDF_STATUS 567 target_if_mlo_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops) 568 { 569 return QDF_STATUS_SUCCESS; 570 } 571 #endif 572 573 #ifdef IPA_OFFLOAD 574 static void target_if_ipa_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops) 575 { 576 target_if_ipa_register_tx_ops(tx_ops); 577 } 578 #else 579 static void target_if_ipa_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops) 580 { } 581 #endif 582 583 #if defined(WLAN_SUPPORT_TWT) && defined(WLAN_TWT_CONV_SUPPORTED) 584 static 585 void target_if_twt_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops) 586 { 587 target_if_twt_register_tx_ops(tx_ops); 588 } 589 #else 590 static 591 void target_if_twt_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops) 592 { 593 } 594 #endif /* WLAN_SUPPORT_TWT && WLAN_TWT_CONV_SUPPORTED */ 595 596 static 597 QDF_STATUS target_if_register_umac_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops) 598 { 599 /* call regulatory callback to register tx ops */ 600 target_if_register_regulatory_tx_ops(tx_ops); 601 602 /* call umac callback to register legacy tx ops */ 603 wlan_lmac_if_umac_tx_ops_register(tx_ops); 604 605 /* Register scan tx ops */ 606 target_if_scan_tx_ops_register(tx_ops); 607 608 target_if_atf_tx_ops_register(tx_ops); 609 610 target_if_sa_api_tx_ops_register(tx_ops); 611 612 target_if_cfr_tx_ops_register(tx_ops); 613 614 target_if_wifi_pos_tx_ops_register(tx_ops); 615 616 target_if_dfs_tx_ops_register(tx_ops); 617 618 target_if_son_tx_ops_register(tx_ops); 619 620 target_if_spatial_reuse_tx_ops_register(tx_ops); 621 622 target_if_tdls_tx_ops_register(tx_ops); 623 624 target_if_fd_tx_ops_register(tx_ops); 625 626 target_if_target_tx_ops_register(tx_ops); 627 628 target_if_offchan_txrx_ops_register(tx_ops); 629 630 target_if_green_ap_tx_ops_register(tx_ops); 631 632 target_if_ftm_tx_ops_register(tx_ops); 633 634 target_if_cp_stats_tx_ops_register(tx_ops); 635 636 target_if_dcs_tx_ops_register(tx_ops); 637 638 target_if_crypto_tx_ops_register(tx_ops); 639 640 target_if_vdev_mgr_tx_ops_register(tx_ops); 641 642 target_if_coex_tx_ops_register(tx_ops); 643 644 target_if_gpio_tx_ops_register(tx_ops); 645 646 target_if_mgmt_txrx_register_tx_ops(tx_ops); 647 648 target_if_mlo_tx_ops_register(tx_ops); 649 650 target_if_ipa_tx_ops_register(tx_ops); 651 652 target_if_twt_tx_ops_register(tx_ops); 653 654 target_if_dbam_tx_ops_register(tx_ops); 655 656 target_if_coap_tx_ops_register(tx_ops); 657 658 /* Converged UMAC components to register their TX-ops here */ 659 return QDF_STATUS_SUCCESS; 660 } 661 662 QDF_STATUS target_if_register_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops) 663 { 664 /* Converged UMAC components to register their TX-ops */ 665 target_if_register_umac_tx_ops(tx_ops); 666 667 /* Components parallel to UMAC to register their TX-ops here */ 668 target_if_sptrl_tx_ops_register(tx_ops); 669 670 target_if_iot_sim_tx_ops_register(tx_ops); 671 672 /* Register direct buffer rx component tx ops here */ 673 target_if_direct_buf_rx_tx_ops_register(tx_ops); 674 675 #ifdef CONVERGED_P2P_ENABLE 676 /* Converged UMAC components to register P2P TX-ops */ 677 target_if_p2p_register_tx_ops(tx_ops); 678 #endif 679 680 return QDF_STATUS_SUCCESS; 681 } 682 qdf_export_symbol(target_if_register_tx_ops); 683 684 wmi_legacy_service_ready_callback 685 target_if_get_psoc_legacy_service_ready_cb(void) 686 { 687 wmi_legacy_service_ready_callback service_ready_cb; 688 689 qdf_spin_lock_bh(&g_target_if_ctx->lock); 690 if (g_target_if_ctx->service_ready_cb) 691 service_ready_cb = g_target_if_ctx->service_ready_cb; 692 else 693 service_ready_cb = NULL; 694 qdf_spin_unlock_bh(&g_target_if_ctx->lock); 695 696 return service_ready_cb; 697 } 698 qdf_export_symbol(target_if_get_psoc_legacy_service_ready_cb); 699 700 QDF_STATUS target_if_register_legacy_service_ready_cb( 701 wmi_legacy_service_ready_callback service_ready_cb) 702 { 703 qdf_spin_lock_bh(&g_target_if_ctx->lock); 704 g_target_if_ctx->service_ready_cb = service_ready_cb; 705 qdf_spin_unlock_bh(&g_target_if_ctx->lock); 706 707 return QDF_STATUS_SUCCESS; 708 } 709 qdf_export_symbol(target_if_register_legacy_service_ready_cb); 710 711 QDF_STATUS target_if_alloc_pdev_tgt_info(struct wlan_objmgr_pdev *pdev) 712 { 713 struct target_pdev_info *tgt_pdev_info; 714 715 if (!pdev) { 716 target_if_err("pdev is null"); 717 return QDF_STATUS_E_INVAL; 718 } 719 720 tgt_pdev_info = qdf_mem_malloc(sizeof(*tgt_pdev_info)); 721 722 if (!tgt_pdev_info) 723 return QDF_STATUS_E_NOMEM; 724 725 wlan_pdev_set_tgt_if_handle(pdev, tgt_pdev_info); 726 727 return QDF_STATUS_SUCCESS; 728 } 729 730 QDF_STATUS target_if_free_pdev_tgt_info(struct wlan_objmgr_pdev *pdev) 731 { 732 struct target_pdev_info *tgt_pdev_info; 733 734 if (!pdev) { 735 target_if_err("pdev is null"); 736 return QDF_STATUS_E_INVAL; 737 } 738 739 tgt_pdev_info = wlan_pdev_get_tgt_if_handle(pdev); 740 741 wlan_pdev_set_tgt_if_handle(pdev, NULL); 742 743 qdf_mem_free(tgt_pdev_info); 744 745 return QDF_STATUS_SUCCESS; 746 } 747 748 QDF_STATUS target_if_alloc_psoc_tgt_info(struct wlan_objmgr_psoc *psoc) 749 { 750 struct target_psoc_info *tgt_psoc_info; 751 752 if (!psoc) { 753 target_if_err("psoc is null"); 754 return QDF_STATUS_E_INVAL; 755 } 756 757 tgt_psoc_info = qdf_mem_malloc(sizeof(*tgt_psoc_info)); 758 759 if (!tgt_psoc_info) 760 return QDF_STATUS_E_NOMEM; 761 762 wlan_psoc_set_tgt_if_handle(psoc, tgt_psoc_info); 763 target_psoc_set_preferred_hw_mode(tgt_psoc_info, WMI_HOST_HW_MODE_MAX); 764 wlan_minidump_log(tgt_psoc_info, 765 sizeof(*tgt_psoc_info), psoc, 766 WLAN_MD_OBJMGR_PSOC_TGT_INFO, "target_psoc_info"); 767 768 qdf_event_create(&tgt_psoc_info->info.event); 769 770 return QDF_STATUS_SUCCESS; 771 } 772 773 QDF_STATUS target_if_free_psoc_tgt_info(struct wlan_objmgr_psoc *psoc) 774 { 775 struct target_psoc_info *tgt_psoc_info; 776 struct wlan_psoc_host_service_ext_param *ext_param; 777 778 if (!psoc) { 779 target_if_err("psoc is null"); 780 return QDF_STATUS_E_INVAL; 781 } 782 783 tgt_psoc_info = wlan_psoc_get_tgt_if_handle(psoc); 784 785 ext_param = target_psoc_get_service_ext_param(tgt_psoc_info); 786 if (!ext_param) { 787 target_if_err("tgt_psoc_info is NULL"); 788 return QDF_STATUS_E_INVAL; 789 } 790 init_deinit_chainmask_table_free(ext_param); 791 init_deinit_dbr_ring_cap_free(tgt_psoc_info); 792 init_deinit_spectral_scaling_params_free(tgt_psoc_info); 793 init_deinit_scan_radio_cap_free(tgt_psoc_info); 794 795 qdf_event_destroy(&tgt_psoc_info->info.event); 796 797 wlan_psoc_set_tgt_if_handle(psoc, NULL); 798 799 wlan_minidump_remove(tgt_psoc_info, 800 sizeof(*tgt_psoc_info), psoc, 801 WLAN_MD_OBJMGR_PSOC_TGT_INFO, "target_psoc_info"); 802 qdf_mem_free(tgt_psoc_info); 803 804 return QDF_STATUS_SUCCESS; 805 } 806 807 bool target_is_tgt_type_ar900b(uint32_t target_type) 808 { 809 return target_type == TARGET_TYPE_AR900B; 810 } 811 812 bool target_is_tgt_type_qca9984(uint32_t target_type) 813 { 814 return target_type == TARGET_TYPE_QCA9984; 815 } 816 817 bool target_is_tgt_type_qca9888(uint32_t target_type) 818 { 819 return target_type == TARGET_TYPE_QCA9888; 820 } 821 822 bool target_is_tgt_type_adrastea(uint32_t target_type) 823 { 824 return target_type == TARGET_TYPE_ADRASTEA; 825 } 826 827 bool target_is_tgt_type_qcn9000(uint32_t target_type) 828 { 829 return target_type == TARGET_TYPE_QCN9000; 830 } 831 832 bool target_is_tgt_type_qcn6122(uint32_t target_type) 833 { 834 return target_type == TARGET_TYPE_QCN6122; 835 } 836 837 bool target_is_tgt_type_qcn7605(uint32_t target_type) 838 { 839 return target_type == TARGET_TYPE_QCN7605; 840 } 841 842 QDF_STATUS 843 target_pdev_is_scan_radio_supported(struct wlan_objmgr_pdev *pdev, 844 bool *is_scan_radio_supported) 845 { 846 struct wlan_objmgr_psoc *psoc; 847 struct wlan_psoc_host_scan_radio_caps *scan_radio_caps; 848 uint8_t cap_idx; 849 uint32_t num_scan_radio_caps; 850 int32_t phy_id; 851 struct target_psoc_info *tgt_psoc_info; 852 struct target_pdev_info *tgt_pdev; 853 854 if (!is_scan_radio_supported) { 855 target_if_err("input argument is null"); 856 return QDF_STATUS_E_INVAL; 857 } 858 *is_scan_radio_supported = false; 859 860 if (!pdev) { 861 target_if_err("pdev is null"); 862 return QDF_STATUS_E_INVAL; 863 } 864 865 psoc = wlan_pdev_get_psoc(pdev); 866 if (!psoc) { 867 target_if_err("psoc is null"); 868 return QDF_STATUS_E_INVAL; 869 } 870 871 tgt_psoc_info = wlan_psoc_get_tgt_if_handle(psoc); 872 if (!tgt_psoc_info) { 873 target_if_err("target_psoc_info is null"); 874 return QDF_STATUS_E_INVAL; 875 } 876 877 num_scan_radio_caps = 878 target_psoc_get_num_scan_radio_caps(tgt_psoc_info); 879 if (!num_scan_radio_caps) 880 return QDF_STATUS_SUCCESS; 881 882 scan_radio_caps = target_psoc_get_scan_radio_caps(tgt_psoc_info); 883 if (!scan_radio_caps) { 884 target_if_err("scan radio capabilities is null"); 885 return QDF_STATUS_E_INVAL; 886 } 887 888 tgt_pdev = (struct target_pdev_info *)wlan_pdev_get_tgt_if_handle(pdev); 889 if (!tgt_pdev) { 890 target_if_err("target_pdev_info is null"); 891 return QDF_STATUS_E_INVAL; 892 } 893 894 phy_id = target_pdev_get_phy_idx(tgt_pdev); 895 if (phy_id < 0) { 896 target_if_err("phy_id is invalid"); 897 return QDF_STATUS_E_INVAL; 898 } 899 900 for (cap_idx = 0; cap_idx < num_scan_radio_caps; cap_idx++) 901 if (scan_radio_caps[cap_idx].phy_id == phy_id) 902 *is_scan_radio_supported = 903 scan_radio_caps[cap_idx].scan_radio_supported; 904 905 return QDF_STATUS_SUCCESS; 906 } 907 908 QDF_STATUS 909 target_pdev_scan_radio_is_dfs_enabled(struct wlan_objmgr_pdev *pdev, 910 bool *is_dfs_en) 911 { 912 struct wlan_objmgr_psoc *psoc; 913 struct wlan_psoc_host_scan_radio_caps *scan_radio_caps; 914 uint8_t cap_idx; 915 uint32_t num_scan_radio_caps, pdev_id; 916 int32_t phy_id; 917 struct target_psoc_info *tgt_psoc_info; 918 struct target_pdev_info *tgt_pdev; 919 920 if (!is_dfs_en) { 921 target_if_err("input argument is null"); 922 return QDF_STATUS_E_INVAL; 923 } 924 *is_dfs_en = true; 925 926 if (!pdev) { 927 target_if_err("pdev is null"); 928 return QDF_STATUS_E_INVAL; 929 } 930 931 psoc = wlan_pdev_get_psoc(pdev); 932 if (!psoc) { 933 target_if_err("psoc is null"); 934 return QDF_STATUS_E_INVAL; 935 } 936 937 tgt_psoc_info = wlan_psoc_get_tgt_if_handle(psoc); 938 if (!tgt_psoc_info) { 939 target_if_err("target_psoc_info is null"); 940 return QDF_STATUS_E_INVAL; 941 } 942 943 num_scan_radio_caps = 944 target_psoc_get_num_scan_radio_caps(tgt_psoc_info); 945 if (!num_scan_radio_caps) { 946 target_if_err("scan radio not supported for psoc"); 947 return QDF_STATUS_E_INVAL; 948 } 949 950 scan_radio_caps = target_psoc_get_scan_radio_caps(tgt_psoc_info); 951 if (!scan_radio_caps) { 952 target_if_err("scan radio capabilities is null"); 953 return QDF_STATUS_E_INVAL; 954 } 955 956 tgt_pdev = (struct target_pdev_info *)wlan_pdev_get_tgt_if_handle(pdev); 957 if (!tgt_pdev) { 958 target_if_err("target_pdev_info is null"); 959 return QDF_STATUS_E_INVAL; 960 } 961 962 pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev); 963 phy_id = target_pdev_get_phy_idx(tgt_pdev); 964 if (phy_id < 0) { 965 target_if_err("phy_id is invalid"); 966 return QDF_STATUS_E_INVAL; 967 } 968 969 for (cap_idx = 0; cap_idx < num_scan_radio_caps; cap_idx++) 970 if (scan_radio_caps[cap_idx].phy_id == phy_id) { 971 *is_dfs_en = scan_radio_caps[cap_idx].dfs_en; 972 return QDF_STATUS_SUCCESS; 973 } 974 975 target_if_err("No scan radio cap found in pdev %d", pdev_id); 976 977 return QDF_STATUS_E_INVAL; 978 } 979 980 void target_if_set_reg_cc_ext_supp(struct target_psoc_info *tgt_hdl, 981 struct wlan_objmgr_psoc *psoc) 982 { 983 struct tgt_info *info; 984 985 if (!tgt_hdl) 986 return; 987 988 info = (&tgt_hdl->info); 989 990 info->wlan_res_cfg.is_reg_cc_ext_event_supported = 991 target_if_reg_is_reg_cc_ext_event_host_supported(psoc); 992 } 993 994 #if defined(WLAN_FEATURE_11BE_MLO) && defined(WLAN_MLO_MULTI_CHIP) 995 uint16_t target_if_pdev_get_hw_link_id(struct wlan_objmgr_pdev *pdev) 996 { 997 struct target_pdev_info *tgt_pdev_info; 998 999 if (!pdev) 1000 return PDEV_INVALID_HW_LINK_ID; 1001 1002 tgt_pdev_info = wlan_pdev_get_tgt_if_handle(pdev); 1003 if (!tgt_pdev_info) 1004 return PDEV_INVALID_HW_LINK_ID; 1005 1006 return tgt_pdev_info->hw_link_id; 1007 } 1008 1009 void target_pdev_set_hw_link_id(struct wlan_objmgr_pdev *pdev, 1010 uint16_t hw_link_id) 1011 { 1012 struct target_pdev_info *tgt_pdev_info; 1013 1014 if (!pdev) 1015 return; 1016 1017 tgt_pdev_info = wlan_pdev_get_tgt_if_handle(pdev); 1018 if (!tgt_pdev_info) 1019 return; 1020 1021 tgt_pdev_info->hw_link_id = hw_link_id; 1022 } 1023 1024 static QDF_STATUS target_if_mlo_setup_send(struct wlan_objmgr_pdev *pdev, 1025 struct wlan_objmgr_pdev **pdev_list, 1026 uint8_t num_links, uint8_t grp_id) 1027 { 1028 wmi_unified_t wmi_handle; 1029 struct wmi_mlo_setup_params params = {0}; 1030 uint8_t idx, num_valid_links = 0; 1031 1032 wmi_handle = lmac_get_pdev_wmi_handle(pdev); 1033 if (!wmi_handle) 1034 return QDF_STATUS_E_INVAL; 1035 1036 params.mld_grp_id = grp_id; 1037 params.pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev); 1038 1039 for (idx = 0; idx < num_links; idx++) { 1040 if (pdev == pdev_list[idx]) 1041 continue; 1042 1043 params.partner_links[num_valid_links] = 1044 target_if_pdev_get_hw_link_id(pdev_list[idx]); 1045 num_valid_links++; 1046 } 1047 params.num_valid_hw_links = num_valid_links; 1048 1049 return wmi_mlo_setup_cmd_send(wmi_handle, ¶ms); 1050 } 1051 1052 QDF_STATUS target_if_mlo_setup_req(struct wlan_objmgr_pdev **pdev, 1053 uint8_t num_pdevs, uint8_t grp_id) 1054 { 1055 uint8_t idx; 1056 1057 for (idx = 0; idx < num_pdevs; idx++) 1058 target_if_mlo_setup_send(pdev[idx], pdev, num_pdevs, grp_id); 1059 1060 return QDF_STATUS_SUCCESS; 1061 } 1062 1063 static QDF_STATUS target_if_mlo_ready_send(struct wlan_objmgr_pdev *pdev) 1064 { 1065 wmi_unified_t wmi_handle; 1066 struct wmi_mlo_ready_params params = {0}; 1067 1068 wmi_handle = lmac_get_pdev_wmi_handle(pdev); 1069 if (!wmi_handle) 1070 return QDF_STATUS_E_INVAL; 1071 1072 params.pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev); 1073 1074 return wmi_mlo_ready_cmd_send(wmi_handle, ¶ms); 1075 } 1076 1077 QDF_STATUS target_if_mlo_ready(struct wlan_objmgr_pdev **pdev, 1078 uint8_t num_pdevs) 1079 { 1080 uint8_t idx; 1081 1082 for (idx = 0; idx < num_pdevs; idx++) 1083 target_if_mlo_ready_send(pdev[idx]); 1084 1085 return QDF_STATUS_SUCCESS; 1086 } 1087 1088 static QDF_STATUS 1089 target_if_mlo_teardown_send(struct wlan_objmgr_pdev *pdev, 1090 enum wmi_mlo_teardown_reason reason) 1091 { 1092 wmi_unified_t wmi_handle; 1093 struct wmi_mlo_teardown_params params = {0}; 1094 1095 wmi_handle = lmac_get_pdev_wmi_handle(pdev); 1096 if (!wmi_handle) 1097 return QDF_STATUS_E_INVAL; 1098 1099 params.pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev); 1100 params.reason = reason; 1101 1102 return wmi_mlo_teardown_cmd_send(wmi_handle, ¶ms); 1103 } 1104 1105 QDF_STATUS target_if_mlo_teardown_req(struct wlan_objmgr_pdev **pdev, 1106 uint8_t num_pdevs, 1107 enum wmi_mlo_teardown_reason reason) 1108 { 1109 uint8_t idx; 1110 1111 for (idx = 0; idx < num_pdevs; idx++) 1112 target_if_mlo_teardown_send(pdev[idx], reason); 1113 1114 return QDF_STATUS_SUCCESS; 1115 } 1116 #endif /*WLAN_FEATURE_11BE_MLO && WLAN_MLO_MULTI_CHIP*/ 1117