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