1 /* 2 * Copyright (c) 2017-2020 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 * DOC: wifi_pos_api.c 21 * This file defines the APIs wifi_pos component. 22 */ 23 24 #include <wlan_lmac_if_def.h> 25 #include "wifi_pos_api.h" 26 #include "wifi_pos_utils_i.h" 27 #include "wifi_pos_main_i.h" 28 #include "os_if_wifi_pos.h" 29 #include "target_if_wifi_pos.h" 30 #include "wlan_objmgr_cmn.h" 31 #include "wlan_objmgr_global_obj.h" 32 #include "wlan_objmgr_psoc_obj.h" 33 #include "wlan_objmgr_peer_obj.h" 34 #include "wlan_lmac_if_def.h" 35 36 struct wlan_lmac_if_wifi_pos_rx_ops * 37 wifi_pos_get_rx_ops(struct wlan_objmgr_psoc *psoc) 38 { 39 struct wlan_lmac_if_rx_ops *rx_ops; 40 41 if (!psoc) { 42 wifi_pos_err("psoc is null"); 43 return NULL; 44 } 45 46 rx_ops = wlan_psoc_get_lmac_if_rxops(psoc); 47 if (!rx_ops) { 48 wifi_pos_err("rx_ops is NULL"); 49 return NULL; 50 } 51 52 return &rx_ops->wifi_pos_rx_ops; 53 } 54 55 struct wifi_pos_legacy_ops *wifi_pos_get_legacy_ops(void) 56 { 57 struct wifi_pos_psoc_priv_obj *wifi_pos_obj = 58 wifi_pos_get_psoc_priv_obj(wifi_pos_get_psoc()); 59 60 if (!wifi_pos_obj) 61 return NULL; 62 63 return wifi_pos_obj->legacy_ops; 64 } 65 66 QDF_STATUS 67 wifi_pos_set_legacy_ops(struct wlan_objmgr_psoc *psoc, 68 struct wifi_pos_legacy_ops *legacy_ops) 69 { 70 struct wifi_pos_psoc_priv_obj *wifi_pos_obj = 71 wifi_pos_get_psoc_priv_obj(wifi_pos_get_psoc()); 72 73 if (!wifi_pos_obj) 74 return QDF_STATUS_E_FAILURE; 75 76 wifi_pos_obj->legacy_ops = legacy_ops; 77 78 return QDF_STATUS_SUCCESS; 79 } 80 81 struct wlan_lmac_if_wifi_pos_tx_ops * 82 wifi_pos_get_tx_ops(struct wlan_objmgr_psoc *psoc) 83 { 84 struct wlan_lmac_if_tx_ops *tx_ops; 85 86 if (!psoc) { 87 wifi_pos_err("psoc is null"); 88 return NULL; 89 } 90 91 tx_ops = wlan_psoc_get_lmac_if_txops(psoc); 92 if (!tx_ops) { 93 wifi_pos_err("tx_ops is NULL"); 94 return NULL; 95 } 96 97 return &tx_ops->wifi_pos_tx_ops; 98 } 99 100 QDF_STATUS wifi_pos_init(void) 101 { 102 QDF_STATUS status; 103 104 wifi_pos_lock_init(); 105 106 /* register psoc create handler functions. */ 107 status = wlan_objmgr_register_psoc_create_handler( 108 WLAN_UMAC_COMP_WIFI_POS, 109 wifi_pos_psoc_obj_created_notification, 110 NULL); 111 if (QDF_IS_STATUS_ERROR(status)) { 112 wifi_pos_err("register_psoc_create_handler failed, status: %d", 113 status); 114 return status; 115 } 116 117 /* register psoc delete handler functions. */ 118 status = wlan_objmgr_register_psoc_destroy_handler( 119 WLAN_UMAC_COMP_WIFI_POS, 120 wifi_pos_psoc_obj_destroyed_notification, 121 NULL); 122 if (QDF_IS_STATUS_ERROR(status)) { 123 wifi_pos_err("register_psoc_destroy_handler failed, status: %d", 124 status); 125 goto fail_psoc_destroy_handler; 126 } 127 128 status = wlan_objmgr_register_vdev_create_handler( 129 WLAN_UMAC_COMP_WIFI_POS, 130 wifi_pos_vdev_created_notification, NULL); 131 if (QDF_IS_STATUS_ERROR(status)) { 132 wifi_pos_err("register_vdev_create_handler failed, status: %d", 133 status); 134 goto fail_vdev_create_handler; 135 } 136 137 status = wlan_objmgr_register_vdev_destroy_handler( 138 WLAN_UMAC_COMP_WIFI_POS, 139 wifi_pos_vdev_destroyed_notification, NULL); 140 if (QDF_IS_STATUS_ERROR(status)) { 141 wifi_pos_err("register_vdev_destroy_handler failed, status: %d", 142 status); 143 goto fail_vdev_destroy_handler; 144 } 145 146 status = wlan_objmgr_register_peer_create_handler( 147 WLAN_UMAC_COMP_WIFI_POS, 148 wifi_pos_peer_object_created_notification, 149 NULL); 150 if (QDF_IS_STATUS_ERROR(status)) { 151 wifi_pos_err("peer create register notification failed"); 152 goto fail_peer_create_handler; 153 } 154 155 status = wlan_objmgr_register_peer_destroy_handler( 156 WLAN_UMAC_COMP_WIFI_POS, 157 wifi_pos_peer_object_destroyed_notification, 158 NULL); 159 if (QDF_IS_STATUS_ERROR(status)) { 160 wifi_pos_err("peer destroy register notification failed"); 161 goto fail_peer_destroy_handler; 162 } 163 164 return status; 165 166 fail_peer_destroy_handler: 167 wlan_objmgr_unregister_peer_create_handler( 168 WLAN_UMAC_COMP_WIFI_POS, 169 wifi_pos_peer_object_created_notification, 170 NULL); 171 fail_peer_create_handler: 172 wlan_objmgr_unregister_vdev_destroy_handler( 173 WLAN_UMAC_COMP_WIFI_POS, 174 wifi_pos_vdev_destroyed_notification, NULL); 175 176 fail_vdev_destroy_handler: 177 wlan_objmgr_unregister_vdev_create_handler( 178 WLAN_UMAC_COMP_WIFI_POS, 179 wifi_pos_vdev_created_notification, NULL); 180 181 fail_vdev_create_handler: 182 wlan_objmgr_unregister_psoc_destroy_handler( 183 WLAN_UMAC_COMP_WIFI_POS, 184 wifi_pos_psoc_obj_destroyed_notification, NULL); 185 186 fail_psoc_destroy_handler: 187 wlan_objmgr_unregister_psoc_create_handler( 188 WLAN_UMAC_COMP_WIFI_POS, 189 wifi_pos_psoc_obj_created_notification, NULL); 190 191 return status; 192 } 193 194 QDF_STATUS wifi_pos_deinit(void) 195 { 196 QDF_STATUS status; 197 198 status = wlan_objmgr_unregister_peer_destroy_handler( 199 WLAN_UMAC_COMP_WIFI_POS, 200 wifi_pos_peer_object_destroyed_notification, 201 NULL); 202 if (QDF_IS_STATUS_ERROR(status)) 203 wifi_pos_err("unable to unregister peer destroy handle"); 204 205 status = wlan_objmgr_unregister_peer_create_handler( 206 WLAN_UMAC_COMP_WIFI_POS, 207 wifi_pos_peer_object_created_notification, 208 NULL); 209 if (QDF_IS_STATUS_ERROR(status)) 210 wifi_pos_err("unable to unregister peer create handle"); 211 212 status = wlan_objmgr_unregister_vdev_destroy_handler( 213 WLAN_UMAC_COMP_WIFI_POS, 214 wifi_pos_vdev_destroyed_notification, NULL); 215 if (QDF_IS_STATUS_ERROR(status)) 216 wifi_pos_err("unregister_vdev_destroy_handler failed, status: %d", 217 status); 218 219 status = wlan_objmgr_unregister_vdev_create_handler( 220 WLAN_UMAC_COMP_WIFI_POS, 221 wifi_pos_vdev_created_notification, NULL); 222 if (QDF_IS_STATUS_ERROR(status)) 223 wifi_pos_err("unregister_vdev_create_handler failed, status: %d", 224 status); 225 226 /* deregister psoc create handler functions. */ 227 status = wlan_objmgr_unregister_psoc_create_handler( 228 WLAN_UMAC_COMP_WIFI_POS, 229 wifi_pos_psoc_obj_created_notification, 230 NULL); 231 if (QDF_IS_STATUS_ERROR(status)) { 232 wifi_pos_err("unregister_psoc_create_handler failed, status: %d", 233 status); 234 return status; 235 } 236 237 /* deregister psoc delete handler functions. */ 238 status = wlan_objmgr_unregister_psoc_destroy_handler( 239 WLAN_UMAC_COMP_WIFI_POS, 240 wifi_pos_psoc_obj_destroyed_notification, 241 NULL); 242 if (QDF_IS_STATUS_ERROR(status)) { 243 wifi_pos_err("unregister_psoc_destroy_handler failed, status: %d", 244 status); 245 } 246 247 wifi_pos_lock_deinit(); 248 249 return QDF_STATUS_SUCCESS; 250 } 251 252 QDF_STATUS wifi_pos_psoc_enable(struct wlan_objmgr_psoc *psoc) 253 { 254 QDF_STATUS status; 255 struct wlan_lmac_if_wifi_pos_tx_ops *tx_ops; 256 257 tx_ops = wifi_pos_get_tx_ops(psoc); 258 if (!tx_ops) { 259 wifi_pos_err("tx_ops is null"); 260 return QDF_STATUS_E_NULL_VALUE; 261 } 262 263 status = tx_ops->wifi_pos_register_events(psoc); 264 265 if (QDF_IS_STATUS_ERROR(status)) 266 wifi_pos_err("target_if_wifi_pos_register_events failed"); 267 268 return status; 269 } 270 271 QDF_STATUS wifi_pos_psoc_disable(struct wlan_objmgr_psoc *psoc) 272 { 273 QDF_STATUS status; 274 struct wlan_lmac_if_wifi_pos_tx_ops *tx_ops; 275 276 tx_ops = wifi_pos_get_tx_ops(psoc); 277 if (!tx_ops) { 278 wifi_pos_err("tx_ops is null"); 279 return QDF_STATUS_E_NULL_VALUE; 280 } 281 282 status = tx_ops->wifi_pos_deregister_events(psoc); 283 284 if (QDF_IS_STATUS_ERROR(status)) 285 wifi_pos_err("target_if_wifi_pos_deregister_events failed"); 286 287 return QDF_STATUS_SUCCESS; 288 } 289 290 struct wlan_wifi_pos_peer_priv_obj * 291 wifi_pos_get_peer_private_object(struct wlan_objmgr_peer *peer) 292 { 293 struct wlan_wifi_pos_peer_priv_obj *peer_priv; 294 295 if (!peer) { 296 wifi_pos_err("Peer is NULL"); 297 return NULL; 298 } 299 300 peer_priv = 301 wlan_objmgr_peer_get_comp_private_obj(peer, 302 WLAN_UMAC_COMP_WIFI_POS); 303 304 return peer_priv; 305 } 306 307 void wifi_pos_set_oem_target_type(struct wlan_objmgr_psoc *psoc, uint32_t val) 308 { 309 struct wifi_pos_psoc_priv_obj *wifi_pos_psoc = 310 wifi_pos_get_psoc_priv_obj(psoc); 311 312 if (!wifi_pos_psoc) { 313 wifi_pos_err("wifi_pos priv obj is null"); 314 return; 315 } 316 317 qdf_spin_lock_bh(&wifi_pos_psoc->wifi_pos_lock); 318 wifi_pos_psoc->oem_target_type = val; 319 qdf_spin_unlock_bh(&wifi_pos_psoc->wifi_pos_lock); 320 } 321 322 void wifi_pos_set_oem_fw_version(struct wlan_objmgr_psoc *psoc, uint32_t val) 323 { 324 struct wifi_pos_psoc_priv_obj *wifi_pos_psoc = 325 wifi_pos_get_psoc_priv_obj(psoc); 326 327 if (!wifi_pos_psoc) { 328 wifi_pos_err("wifi_pos priv obj is null"); 329 return; 330 } 331 332 qdf_spin_lock_bh(&wifi_pos_psoc->wifi_pos_lock); 333 wifi_pos_psoc->oem_fw_version = val; 334 qdf_spin_unlock_bh(&wifi_pos_psoc->wifi_pos_lock); 335 } 336 337 void wifi_pos_set_drv_ver_major(struct wlan_objmgr_psoc *psoc, uint8_t val) 338 { 339 struct wifi_pos_psoc_priv_obj *wifi_pos_psoc = 340 wifi_pos_get_psoc_priv_obj(psoc); 341 342 if (!wifi_pos_psoc) { 343 wifi_pos_err("wifi_pos priv obj is null"); 344 return; 345 } 346 347 qdf_spin_lock_bh(&wifi_pos_psoc->wifi_pos_lock); 348 wifi_pos_psoc->driver_version.major = val; 349 qdf_spin_unlock_bh(&wifi_pos_psoc->wifi_pos_lock); 350 } 351 352 void wifi_pos_set_drv_ver_minor(struct wlan_objmgr_psoc *psoc, uint8_t val) 353 { 354 struct wifi_pos_psoc_priv_obj *wifi_pos_psoc = 355 wifi_pos_get_psoc_priv_obj(psoc); 356 357 if (!wifi_pos_psoc) { 358 wifi_pos_err("wifi_pos priv obj is null"); 359 return; 360 } 361 362 qdf_spin_lock_bh(&wifi_pos_psoc->wifi_pos_lock); 363 wifi_pos_psoc->driver_version.minor = val; 364 qdf_spin_unlock_bh(&wifi_pos_psoc->wifi_pos_lock); 365 } 366 367 void wifi_pos_set_drv_ver_patch(struct wlan_objmgr_psoc *psoc, uint8_t val) 368 { 369 struct wifi_pos_psoc_priv_obj *wifi_pos_psoc = 370 wifi_pos_get_psoc_priv_obj(psoc); 371 372 if (!wifi_pos_psoc) { 373 wifi_pos_err("wifi_pos priv obj is null"); 374 return; 375 } 376 377 qdf_spin_lock_bh(&wifi_pos_psoc->wifi_pos_lock); 378 wifi_pos_psoc->driver_version.patch = val; 379 qdf_spin_unlock_bh(&wifi_pos_psoc->wifi_pos_lock); 380 } 381 382 void wifi_pos_set_drv_ver_build(struct wlan_objmgr_psoc *psoc, uint8_t val) 383 { 384 struct wifi_pos_psoc_priv_obj *wifi_pos_psoc = 385 wifi_pos_get_psoc_priv_obj(psoc); 386 387 if (!wifi_pos_psoc) { 388 wifi_pos_err("wifi_pos priv obj is null"); 389 return; 390 } 391 392 qdf_spin_lock_bh(&wifi_pos_psoc->wifi_pos_lock); 393 wifi_pos_psoc->driver_version.build = val; 394 qdf_spin_unlock_bh(&wifi_pos_psoc->wifi_pos_lock); 395 } 396 397 void wifi_pos_set_dwell_time_min(struct wlan_objmgr_psoc *psoc, uint16_t val) 398 { 399 struct wifi_pos_psoc_priv_obj *wifi_pos_psoc = 400 wifi_pos_get_psoc_priv_obj(psoc); 401 402 if (!wifi_pos_psoc) { 403 wifi_pos_err("wifi_pos priv obj is null"); 404 return; 405 } 406 407 qdf_spin_lock_bh(&wifi_pos_psoc->wifi_pos_lock); 408 wifi_pos_psoc->allowed_dwell_time_min = val; 409 qdf_spin_unlock_bh(&wifi_pos_psoc->wifi_pos_lock); 410 } 411 void wifi_pos_set_dwell_time_max(struct wlan_objmgr_psoc *psoc, uint16_t val) 412 { 413 struct wifi_pos_psoc_priv_obj *wifi_pos_psoc = 414 wifi_pos_get_psoc_priv_obj(psoc); 415 416 if (!wifi_pos_psoc) { 417 wifi_pos_err("wifi_pos priv obj is null"); 418 return; 419 } 420 421 qdf_spin_lock_bh(&wifi_pos_psoc->wifi_pos_lock); 422 wifi_pos_psoc->allowed_dwell_time_max = val; 423 qdf_spin_unlock_bh(&wifi_pos_psoc->wifi_pos_lock); 424 } 425 426 void wifi_pos_set_current_dwell_time_max(struct wlan_objmgr_psoc *psoc, 427 uint16_t val) 428 { 429 struct wifi_pos_psoc_priv_obj *wifi_pos_psoc = 430 wifi_pos_get_psoc_priv_obj(psoc); 431 432 if (!wifi_pos_psoc) { 433 wifi_pos_err("wifi_pos priv obj is null"); 434 return; 435 } 436 437 qdf_spin_lock_bh(&wifi_pos_psoc->wifi_pos_lock); 438 wifi_pos_psoc->current_dwell_time_max = val; 439 qdf_spin_unlock_bh(&wifi_pos_psoc->wifi_pos_lock); 440 } 441 442 void wifi_pos_set_current_dwell_time_min(struct wlan_objmgr_psoc *psoc, 443 uint16_t val) 444 { 445 struct wifi_pos_psoc_priv_obj *wifi_pos_psoc = 446 wifi_pos_get_psoc_priv_obj(psoc); 447 448 if (!wifi_pos_psoc) { 449 wifi_pos_err("wifi_pos priv obj is null"); 450 return; 451 } 452 453 qdf_spin_lock_bh(&wifi_pos_psoc->wifi_pos_lock); 454 wifi_pos_psoc->current_dwell_time_max = val; 455 qdf_spin_unlock_bh(&wifi_pos_psoc->wifi_pos_lock); 456 } 457 458 uint32_t wifi_pos_get_app_pid(struct wlan_objmgr_psoc *psoc) 459 { 460 uint32_t app_pid; 461 struct wifi_pos_psoc_priv_obj *wifi_pos_psoc = 462 wifi_pos_get_psoc_priv_obj(psoc); 463 464 if (!wifi_pos_psoc) { 465 wifi_pos_err("wifi_pos priv obj is null"); 466 return 0; 467 } 468 469 qdf_spin_lock_bh(&wifi_pos_psoc->wifi_pos_lock); 470 app_pid = wifi_pos_psoc->app_pid; 471 qdf_spin_unlock_bh(&wifi_pos_psoc->wifi_pos_lock); 472 473 return app_pid; 474 475 } 476 477 bool wifi_pos_is_app_registered(struct wlan_objmgr_psoc *psoc) 478 { 479 bool is_app_registered; 480 struct wifi_pos_psoc_priv_obj *wifi_pos_psoc = 481 wifi_pos_get_psoc_priv_obj(psoc); 482 483 if (!wifi_pos_psoc) { 484 wifi_pos_err("wifi_pos priv obj is null"); 485 return false; 486 } 487 488 qdf_spin_lock_bh(&wifi_pos_psoc->wifi_pos_lock); 489 is_app_registered = wifi_pos_psoc->is_app_registered; 490 qdf_spin_unlock_bh(&wifi_pos_psoc->wifi_pos_lock); 491 492 return is_app_registered; 493 } 494 495 #ifdef WLAN_FEATURE_CIF_CFR 496 QDF_STATUS wifi_pos_init_cir_cfr_rings(struct wlan_objmgr_psoc *psoc, 497 void *hal_soc, uint8_t num_mac, void *buf) 498 { 499 return target_if_wifi_pos_init_cir_cfr_rings(psoc, hal_soc, 500 num_mac, buf); 501 } 502 #endif 503 504 QDF_STATUS 505 wifi_pos_register_get_phy_mode_cb(struct wlan_objmgr_psoc *psoc, 506 void (*handler)(qdf_freq_t, uint32_t, 507 uint32_t *)) 508 { 509 struct wifi_pos_psoc_priv_obj *wifi_pos_psoc; 510 511 if (!psoc) { 512 wifi_pos_err("psoc is null"); 513 return QDF_STATUS_E_NULL_VALUE; 514 } 515 516 if (!handler) { 517 wifi_pos_err("Null callback"); 518 return QDF_STATUS_E_NULL_VALUE; 519 } 520 wifi_pos_psoc = wifi_pos_get_psoc_priv_obj(psoc); 521 if (!wifi_pos_psoc) { 522 wifi_pos_err("wifi_pos priv obj is null"); 523 return QDF_STATUS_E_NULL_VALUE; 524 } 525 526 wifi_pos_psoc->wifi_pos_get_phy_mode = handler; 527 528 return QDF_STATUS_SUCCESS; 529 } 530 531 QDF_STATUS wifi_pos_register_get_fw_phy_mode_for_freq_cb( 532 struct wlan_objmgr_psoc *psoc, 533 void (*handler)(uint32_t, uint32_t, uint32_t *)) 534 { 535 struct wifi_pos_psoc_priv_obj *wifi_pos_psoc; 536 537 if (!psoc) { 538 wifi_pos_err("psoc is null"); 539 return QDF_STATUS_E_NULL_VALUE; 540 } 541 542 if (!handler) { 543 wifi_pos_err("Null callback"); 544 return QDF_STATUS_E_NULL_VALUE; 545 } 546 wifi_pos_psoc = wifi_pos_get_psoc_priv_obj(psoc); 547 if (!wifi_pos_psoc) { 548 wifi_pos_err("wifi_pos priv obj is null"); 549 return QDF_STATUS_E_NULL_VALUE; 550 } 551 552 wifi_pos_psoc->wifi_pos_get_fw_phy_mode_for_freq = handler; 553 554 return QDF_STATUS_SUCCESS; 555 } 556 557 #ifndef CNSS_GENL 558 QDF_STATUS wifi_pos_register_get_pdev_id_by_dev_name( 559 struct wlan_objmgr_psoc *psoc, 560 QDF_STATUS (*handler)(char *dev_name, uint8_t *pdev_id, 561 struct wlan_objmgr_psoc **psoc)) 562 { 563 struct wifi_pos_psoc_priv_obj *wifi_pos_psoc; 564 565 if (!psoc) { 566 wifi_pos_err("psoc is null"); 567 return QDF_STATUS_E_NULL_VALUE; 568 } 569 570 if (!handler) { 571 wifi_pos_err("Null callback"); 572 return QDF_STATUS_E_NULL_VALUE; 573 } 574 575 wifi_pos_psoc = wifi_pos_get_psoc_priv_obj(psoc); 576 if (!wifi_pos_psoc) { 577 wifi_pos_err("wifi_pos priv obj is null"); 578 return QDF_STATUS_E_NULL_VALUE; 579 } 580 581 wifi_pos_psoc->wifi_pos_get_pdev_id_by_dev_name = handler; 582 583 return QDF_STATUS_SUCCESS; 584 } 585 586 #ifdef WLAN_RTT_MEASUREMENT_NOTIFICATION 587 QDF_STATUS wifi_pos_register_measurement_request_notification( 588 struct wlan_objmgr_psoc *psoc, 589 QDF_STATUS (*handler)(struct wlan_objmgr_pdev *pdev, 590 struct rtt_channel_info *chinfo)) 591 { 592 struct wifi_pos_psoc_priv_obj *wifi_pos_psoc; 593 594 if (!psoc) { 595 wifi_pos_err("psoc is null"); 596 return QDF_STATUS_E_NULL_VALUE; 597 } 598 599 if (!handler) { 600 wifi_pos_err("Null callback"); 601 return QDF_STATUS_E_NULL_VALUE; 602 } 603 604 wifi_pos_psoc = wifi_pos_get_psoc_priv_obj(psoc); 605 if (!wifi_pos_psoc) { 606 wifi_pos_err("wifi_pos priv obj is null"); 607 return QDF_STATUS_E_NULL_VALUE; 608 } 609 610 wifi_pos_psoc->wifi_pos_measurement_request_notification = handler; 611 612 return QDF_STATUS_SUCCESS; 613 } 614 #endif /* WLAN_RTT_MEASUREMENT_NOTIFICATION */ 615 616 QDF_STATUS wifi_pos_register_get_max_fw_phymode_for_channels( 617 struct wlan_objmgr_psoc *psoc, 618 QDF_STATUS (*handler)(struct wlan_objmgr_pdev *pdev, 619 struct wifi_pos_channel_power *chan_list, 620 uint16_t wifi_pos_num_chans)) 621 { 622 struct wifi_pos_psoc_priv_obj *wifi_pos_psoc; 623 624 if (!psoc) { 625 wifi_pos_err("psoc is null"); 626 return QDF_STATUS_E_NULL_VALUE; 627 } 628 629 if (!handler) { 630 wifi_pos_err("Null callback"); 631 return QDF_STATUS_E_NULL_VALUE; 632 } 633 634 wifi_pos_psoc = wifi_pos_get_psoc_priv_obj(psoc); 635 if (!wifi_pos_psoc) { 636 wifi_pos_err("wifi_pos priv obj is null"); 637 return QDF_STATUS_E_NULL_VALUE; 638 } 639 640 wifi_pos_psoc->wifi_pos_get_max_fw_phymode_for_channels = handler; 641 642 return QDF_STATUS_SUCCESS; 643 } 644 #endif /* CNSS_GENL */ 645 646 QDF_STATUS wifi_pos_register_send_action( 647 struct wlan_objmgr_psoc *psoc, 648 void (*handler)(struct wlan_objmgr_psoc *psoc, 649 uint32_t sub_type, 650 uint8_t *buf, 651 uint32_t buf_len)) 652 { 653 struct wifi_pos_psoc_priv_obj *wifi_pos_psoc; 654 655 if (!psoc) { 656 wifi_pos_err("psoc is null"); 657 return QDF_STATUS_E_NULL_VALUE; 658 } 659 660 if (!handler) { 661 wifi_pos_err("Null callback"); 662 return QDF_STATUS_E_NULL_VALUE; 663 } 664 wifi_pos_psoc = wifi_pos_get_psoc_priv_obj(psoc); 665 if (!wifi_pos_psoc) { 666 wifi_pos_err("wifi_pos priv obj is null"); 667 return QDF_STATUS_E_NULL_VALUE; 668 } 669 670 wifi_pos_psoc->wifi_pos_send_action = handler; 671 672 return QDF_STATUS_SUCCESS; 673 } 674 675 QDF_STATUS wifi_pos_register_osif_callbacks(struct wifi_pos_osif_ops *ops) 676 { 677 struct wifi_pos_psoc_priv_obj *wifi_pos_obj = 678 wifi_pos_get_psoc_priv_obj(wifi_pos_get_psoc()); 679 680 if (!wifi_pos_obj) { 681 wifi_pos_err("wifi_pos priv obj is null"); 682 return QDF_STATUS_E_NULL_VALUE; 683 } 684 685 wifi_pos_obj->osif_cb = ops; 686 687 return QDF_STATUS_SUCCESS; 688 } 689 690 struct wifi_pos_osif_ops *wifi_pos_get_osif_callbacks(void) 691 { 692 struct wifi_pos_psoc_priv_obj *wifi_pos_obj = 693 wifi_pos_get_psoc_priv_obj(wifi_pos_get_psoc()); 694 695 if (!wifi_pos_obj) { 696 wifi_pos_err("wifi_pos priv obj is null"); 697 return NULL; 698 } 699 700 return wifi_pos_obj->osif_cb; 701 } 702 703 #if defined(WIFI_POS_CONVERGED) && defined(WLAN_FEATURE_RTT_11AZ_SUPPORT) 704 void wifi_pos_set_rsta_sec_ltf_cap(bool val) 705 { 706 struct wifi_pos_psoc_priv_obj *wifi_pos_psoc = 707 wifi_pos_get_psoc_priv_obj(wifi_pos_get_psoc()); 708 709 if (!wifi_pos_psoc) { 710 wifi_pos_alert("unable to get wifi_pos psoc obj"); 711 return; 712 } 713 714 qdf_spin_lock_bh(&wifi_pos_psoc->wifi_pos_lock); 715 wifi_pos_psoc->enable_rsta_secure_ltf_support = val; 716 qdf_spin_unlock_bh(&wifi_pos_psoc->wifi_pos_lock); 717 } 718 719 bool wifi_pos_get_rsta_sec_ltf_cap(void) 720 { 721 bool value; 722 struct wifi_pos_psoc_priv_obj *wifi_pos_psoc = 723 wifi_pos_get_psoc_priv_obj(wifi_pos_get_psoc()); 724 725 if (!wifi_pos_psoc) { 726 wifi_pos_alert("unable to get wifi_pos psoc obj"); 727 return false; 728 } 729 730 qdf_spin_lock_bh(&wifi_pos_psoc->wifi_pos_lock); 731 value = wifi_pos_psoc->enable_rsta_secure_ltf_support; 732 qdf_spin_unlock_bh(&wifi_pos_psoc->wifi_pos_lock); 733 734 return value; 735 } 736 737 void wifi_pos_set_rsta_11az_ranging_cap(bool val) 738 { 739 struct wifi_pos_psoc_priv_obj *wifi_pos_psoc = 740 wifi_pos_get_psoc_priv_obj(wifi_pos_get_psoc()); 741 742 if (!wifi_pos_psoc) { 743 wifi_pos_alert("unable to get wifi_pos psoc obj"); 744 return; 745 } 746 747 qdf_spin_lock_bh(&wifi_pos_psoc->wifi_pos_lock); 748 wifi_pos_psoc->enable_rsta_11az_ranging = val; 749 qdf_spin_unlock_bh(&wifi_pos_psoc->wifi_pos_lock); 750 } 751 752 bool wifi_pos_get_rsta_11az_ranging_cap(void) 753 { 754 bool value; 755 struct wifi_pos_psoc_priv_obj *wifi_pos_psoc = 756 wifi_pos_get_psoc_priv_obj(wifi_pos_get_psoc()); 757 758 if (!wifi_pos_psoc) { 759 wifi_pos_alert("unable to get wifi_pos psoc obj"); 760 return false; 761 } 762 763 qdf_spin_lock_bh(&wifi_pos_psoc->wifi_pos_lock); 764 value = wifi_pos_psoc->enable_rsta_11az_ranging; 765 qdf_spin_unlock_bh(&wifi_pos_psoc->wifi_pos_lock); 766 767 return value; 768 } 769 #endif 770