1 /* 2 * Copyright (c) 2017-2020 The Linux Foundation. All rights reserved. 3 * 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 * @file wlan_reg_services_api.c 22 * @brief contains regulatory service functions 23 */ 24 25 26 #include <qdf_status.h> 27 #include <qdf_types.h> 28 #include <qdf_module.h> 29 #include <wlan_cmn.h> 30 #include <reg_services_public_struct.h> 31 #include <wlan_reg_services_api.h> 32 #include <wlan_objmgr_psoc_obj.h> 33 #include <wlan_objmgr_pdev_obj.h> 34 #include "../../core/src/reg_priv_objs.h" 35 #include "../../core/src/reg_utils.h" 36 #include "../../core/src/reg_services_common.h" 37 #include "../../core/src/reg_db.h" 38 #include "../../core/src/reg_db_parser.h" 39 #include <../../core/src/reg_build_chan_list.h> 40 #include <../../core/src/reg_opclass.h> 41 #include <../../core/src/reg_callbacks.h> 42 #include <../../core/src/reg_offload_11d_scan.h> 43 #include <wlan_objmgr_global_obj.h> 44 45 /** 46 * wlan_reg_read_default_country() - Read the default country for the regdomain 47 * @country: pointer to the country code. 48 * 49 * Return: None 50 */ 51 QDF_STATUS wlan_reg_read_default_country(struct wlan_objmgr_psoc *psoc, 52 uint8_t *country) 53 { 54 /* 55 * Get the default country information 56 */ 57 return reg_read_default_country(psoc, country); 58 } 59 60 QDF_STATUS wlan_reg_read_current_country(struct wlan_objmgr_psoc *psoc, 61 uint8_t *country) 62 { 63 /* 64 * Get the current country information 65 */ 66 return reg_read_current_country(psoc, country); 67 } 68 69 QDF_STATUS wlan_reg_get_max_5g_bw_from_country_code(uint16_t cc, 70 uint16_t *max_bw_5g) 71 { 72 /* 73 * Get the max 5G bandwidth from country code 74 */ 75 return reg_get_max_5g_bw_from_country_code(cc, max_bw_5g); 76 } 77 78 QDF_STATUS wlan_reg_get_max_5g_bw_from_regdomain(uint16_t regdmn, 79 uint16_t *max_bw_5g) 80 { 81 /* 82 * Get the max 5G bandwidth from regdomain pair value 83 */ 84 return reg_get_max_5g_bw_from_regdomain(regdmn, max_bw_5g); 85 } 86 87 #ifdef CONFIG_CHAN_NUM_API 88 /** 89 * wlan_reg_get_channel_state() - Get channel state from regulatory 90 * @ch: channel number. 91 * 92 * Return: channel state 93 */ 94 enum channel_state wlan_reg_get_channel_state(struct wlan_objmgr_pdev *pdev, 95 uint8_t ch) 96 { 97 /* 98 * Get channel state from regulatory 99 */ 100 return reg_get_channel_state(pdev, ch); 101 } 102 103 bool 104 wlan_reg_chan_has_dfs_attribute(struct wlan_objmgr_pdev *pdev, uint8_t ch) 105 { 106 return reg_chan_has_dfs_attribute(pdev, ch); 107 } 108 109 /** 110 * wlan_reg_get_5g_bonded_channel_state() - Get 5G bonded channel state 111 * @ch: channel number. 112 * @bw: channel band width 113 * 114 * Return: channel state 115 */ 116 enum channel_state wlan_reg_get_5g_bonded_channel_state( 117 struct wlan_objmgr_pdev *pdev, uint8_t ch, 118 enum phy_ch_width bw) 119 { 120 /* 121 * Get channel state from regulatory 122 */ 123 return reg_get_5g_bonded_channel_state(pdev, ch, bw); 124 } 125 126 /** 127 * wlan_reg_get_2g_bonded_channel_state() - Get 2G bonded channel state 128 * @ch: channel number. 129 * @bw: channel band width 130 * 131 * Return: channel state 132 */ 133 enum channel_state wlan_reg_get_2g_bonded_channel_state( 134 struct wlan_objmgr_pdev *pdev, uint8_t ch, 135 uint8_t sec_ch, enum phy_ch_width bw) 136 { 137 /* 138 * Get channel state from regulatory 139 */ 140 return reg_get_2g_bonded_channel_state(pdev, ch, sec_ch, bw); 141 } 142 143 /** 144 * wlan_reg_set_channel_params() - Sets channel parameteres for given bandwidth 145 * @ch: channel number. 146 * @ch_params: pointer to the channel parameters. 147 * 148 * Return: None 149 */ 150 void wlan_reg_set_channel_params(struct wlan_objmgr_pdev *pdev, uint8_t ch, 151 uint8_t sec_ch_2g, 152 struct ch_params *ch_params) 153 { 154 /* 155 * Set channel parameters like center frequency for a bonded channel 156 * state. Also return the maximum bandwidth supported by the channel. 157 */ 158 reg_set_channel_params(pdev, ch, sec_ch_2g, ch_params); 159 } 160 #endif /* CONFIG_CHAN_NUM_API */ 161 162 /** 163 * wlan_reg_get_dfs_region () - Get the current dfs region 164 * @dfs_reg: pointer to dfs region 165 * 166 * Return: Status 167 */ 168 QDF_STATUS wlan_reg_get_dfs_region(struct wlan_objmgr_pdev *pdev, 169 enum dfs_reg *dfs_reg) 170 { 171 /* 172 * Get the current dfs region 173 */ 174 reg_get_current_dfs_region(pdev, dfs_reg); 175 176 return QDF_STATUS_SUCCESS; 177 } 178 179 #ifdef CONFIG_CHAN_NUM_API 180 uint32_t wlan_reg_get_channel_reg_power(struct wlan_objmgr_pdev *pdev, 181 uint8_t chan_num) 182 { 183 return reg_get_channel_reg_power(pdev, chan_num); 184 } 185 186 /** 187 * wlan_reg_get_channel_freq() - get regulatory power for channel 188 * @chan_num: channel number 189 * 190 * Return: int 191 */ 192 qdf_freq_t wlan_reg_get_channel_freq(struct wlan_objmgr_pdev *pdev, 193 uint8_t chan_num) 194 { 195 return reg_get_channel_freq(pdev, chan_num); 196 } 197 #endif /* CONFIG_CHAN_NUM_API */ 198 199 QDF_STATUS wlan_reg_get_current_chan_list(struct wlan_objmgr_pdev *pdev, 200 struct regulatory_channel *chan_list) 201 { 202 return reg_get_current_chan_list(pdev, chan_list); 203 } 204 205 qdf_export_symbol(wlan_reg_get_current_chan_list); 206 207 /** 208 * wlan_reg_get_bw_value() - give bandwidth value 209 * bw: bandwidth enum 210 * 211 * Return: uint16_t 212 */ 213 uint16_t wlan_reg_get_bw_value(enum phy_ch_width bw) 214 { 215 return reg_get_bw_value(bw); 216 } 217 218 qdf_export_symbol(wlan_reg_get_bw_value); 219 220 #ifdef CONFIG_CHAN_NUM_API 221 /** 222 * wlan_reg_get_bonded_channel_state() - Get 2G bonded channel state 223 * @ch: channel number. 224 * @bw: channel band width 225 * 226 * Return: channel state 227 */ 228 enum channel_state 229 wlan_reg_get_bonded_channel_state(struct wlan_objmgr_pdev *pdev, 230 uint8_t ch, 231 enum phy_ch_width bw, uint8_t sec_ch) 232 { 233 if (WLAN_REG_IS_24GHZ_CH(ch)) 234 return reg_get_2g_bonded_channel_state(pdev, ch, 235 sec_ch, bw); 236 else 237 return reg_get_5g_bonded_channel_state(pdev, ch, 238 bw); 239 } 240 241 #endif /* CONFIG_CHAN_NUM_API */ 242 243 /** 244 * wlan_reg_set_dfs_region () - Get the current dfs region 245 * @dfs_reg: pointer to dfs region 246 * 247 * Return: None 248 */ 249 void wlan_reg_set_dfs_region(struct wlan_objmgr_pdev *pdev, 250 enum dfs_reg dfs_reg) 251 { 252 reg_set_dfs_region(pdev, dfs_reg); 253 } 254 255 QDF_STATUS wlan_reg_get_domain_from_country_code(v_REGDOMAIN_t *reg_domain_ptr, 256 const uint8_t *country_alpha2, enum country_src source) 257 { 258 259 return reg_get_domain_from_country_code(reg_domain_ptr, 260 country_alpha2, source); 261 } 262 263 264 uint16_t wlan_reg_dmn_get_opclass_from_channel(uint8_t *country, 265 uint8_t channel, 266 uint8_t offset) 267 { 268 return reg_dmn_get_opclass_from_channel(country, channel, 269 offset); 270 } 271 272 uint8_t wlan_reg_get_band_cap_from_op_class(const uint8_t *country, 273 uint8_t num_of_opclass, 274 const uint8_t *opclass) 275 { 276 return reg_get_band_cap_from_op_class(country, 277 num_of_opclass, opclass); 278 } 279 280 uint8_t wlan_reg_get_opclass_from_freq_width(uint8_t *country, 281 qdf_freq_t freq, 282 uint8_t ch_width, 283 uint16_t behav_limit) 284 { 285 return reg_dmn_get_opclass_from_freq_width(country, freq, ch_width, 286 behav_limit); 287 } 288 289 void wlan_reg_dmn_print_channels_in_opclass(uint8_t *country, 290 uint8_t opclass) 291 { 292 reg_dmn_print_channels_in_opclass(country, opclass); 293 } 294 295 uint16_t wlan_reg_dmn_get_chanwidth_from_opclass(uint8_t *country, 296 uint8_t channel, 297 uint8_t opclass) 298 { 299 return reg_dmn_get_chanwidth_from_opclass(country, channel, 300 opclass); 301 } 302 303 uint16_t wlan_reg_dmn_get_chanwidth_from_opclass_auto(uint8_t *country, 304 uint8_t channel, 305 uint8_t opclass) 306 { 307 return reg_dmn_get_chanwidth_from_opclass_auto(country, channel, 308 opclass); 309 } 310 311 uint16_t wlan_reg_dmn_set_curr_opclasses(uint8_t num_classes, 312 uint8_t *class) 313 { 314 return reg_dmn_set_curr_opclasses(num_classes, class); 315 } 316 317 uint16_t wlan_reg_dmn_get_curr_opclasses(uint8_t *num_classes, 318 uint8_t *class) 319 { 320 return reg_dmn_get_curr_opclasses(num_classes, class); 321 } 322 323 QDF_STATUS 324 wlan_reg_get_opclass_details(struct wlan_objmgr_pdev *pdev, 325 struct regdmn_ap_cap_opclass_t *reg_ap_cap, 326 uint8_t *n_opclasses, 327 uint8_t max_supp_op_class, 328 bool global_tbl_lookup) 329 { 330 return reg_get_opclass_details(pdev, reg_ap_cap, n_opclasses, 331 max_supp_op_class, 332 global_tbl_lookup); 333 } 334 335 enum country_src wlan_reg_get_cc_and_src(struct wlan_objmgr_psoc *psoc, 336 uint8_t *alpha) 337 { 338 return reg_get_cc_and_src(psoc, alpha); 339 } 340 341 QDF_STATUS wlan_regulatory_init(void) 342 { 343 QDF_STATUS status; 344 345 status = wlan_objmgr_register_psoc_create_handler( 346 WLAN_UMAC_COMP_REGULATORY, 347 wlan_regulatory_psoc_obj_created_notification, NULL); 348 if (status != QDF_STATUS_SUCCESS) { 349 reg_err("failed to register reg psoc obj create handler"); 350 return status; 351 } 352 353 status = wlan_objmgr_register_psoc_destroy_handler( 354 WLAN_UMAC_COMP_REGULATORY, 355 wlan_regulatory_psoc_obj_destroyed_notification, NULL); 356 if (status != QDF_STATUS_SUCCESS) { 357 reg_err("failed to register reg psoc obj create handler"); 358 goto unreg_psoc_create; 359 } 360 361 status = wlan_objmgr_register_pdev_create_handler( 362 WLAN_UMAC_COMP_REGULATORY, 363 wlan_regulatory_pdev_obj_created_notification, NULL); 364 if (status != QDF_STATUS_SUCCESS) { 365 reg_err("failed to register reg psoc obj create handler"); 366 goto unreg_psoc_destroy; 367 } 368 369 status = wlan_objmgr_register_pdev_destroy_handler( 370 WLAN_UMAC_COMP_REGULATORY, 371 wlan_regulatory_pdev_obj_destroyed_notification, NULL); 372 if (status != QDF_STATUS_SUCCESS) { 373 reg_err("failed to register reg psoc obj create handler"); 374 goto unreg_pdev_create; 375 } 376 channel_map = channel_map_global; 377 reg_debug("regulatory handlers registered with obj mgr"); 378 379 return status; 380 381 unreg_pdev_create: 382 status = wlan_objmgr_unregister_pdev_create_handler( 383 WLAN_UMAC_COMP_REGULATORY, 384 wlan_regulatory_pdev_obj_created_notification, 385 NULL); 386 387 unreg_psoc_destroy: 388 status = wlan_objmgr_unregister_psoc_destroy_handler( 389 WLAN_UMAC_COMP_REGULATORY, 390 wlan_regulatory_psoc_obj_destroyed_notification, 391 NULL); 392 393 unreg_psoc_create: 394 status = wlan_objmgr_unregister_psoc_create_handler( 395 WLAN_UMAC_COMP_REGULATORY, 396 wlan_regulatory_psoc_obj_created_notification, 397 NULL); 398 399 return QDF_STATUS_E_FAILURE; 400 } 401 402 QDF_STATUS wlan_regulatory_deinit(void) 403 { 404 QDF_STATUS status, ret_status = QDF_STATUS_SUCCESS; 405 406 status = wlan_objmgr_unregister_pdev_destroy_handler( 407 WLAN_UMAC_COMP_REGULATORY, 408 wlan_regulatory_pdev_obj_destroyed_notification, NULL); 409 if (status != QDF_STATUS_SUCCESS) { 410 reg_err("failed to unregister reg pdev obj destroy handler"); 411 ret_status = status; 412 } 413 414 status = wlan_objmgr_unregister_pdev_create_handler( 415 WLAN_UMAC_COMP_REGULATORY, 416 wlan_regulatory_pdev_obj_created_notification, NULL); 417 if (status != QDF_STATUS_SUCCESS) { 418 reg_err("failed to unregister reg pdev obj create handler"); 419 ret_status = status; 420 } 421 422 status = wlan_objmgr_unregister_psoc_destroy_handler( 423 WLAN_UMAC_COMP_REGULATORY, 424 wlan_regulatory_psoc_obj_destroyed_notification, NULL); 425 if (status != QDF_STATUS_SUCCESS) { 426 reg_err("failed to unregister reg psoc obj destroy handler"); 427 ret_status = status; 428 } 429 430 status = wlan_objmgr_unregister_psoc_create_handler( 431 WLAN_UMAC_COMP_REGULATORY, 432 wlan_regulatory_psoc_obj_created_notification, NULL); 433 if (status != QDF_STATUS_SUCCESS) { 434 reg_err("failed to unregister reg psoc obj create handler"); 435 ret_status = status; 436 } 437 438 reg_debug("deregistered callbacks with obj mgr"); 439 440 return ret_status; 441 } 442 443 QDF_STATUS regulatory_psoc_open(struct wlan_objmgr_psoc *psoc) 444 { 445 struct wlan_lmac_if_reg_tx_ops *tx_ops; 446 447 tx_ops = reg_get_psoc_tx_ops(psoc); 448 if (tx_ops->register_master_handler) 449 tx_ops->register_master_handler(psoc, NULL); 450 if (tx_ops->register_11d_new_cc_handler) 451 tx_ops->register_11d_new_cc_handler(psoc, NULL); 452 if (tx_ops->register_ch_avoid_event_handler) 453 tx_ops->register_ch_avoid_event_handler(psoc, NULL); 454 455 return QDF_STATUS_SUCCESS; 456 } 457 458 QDF_STATUS regulatory_psoc_close(struct wlan_objmgr_psoc *psoc) 459 { 460 struct wlan_lmac_if_reg_tx_ops *tx_ops; 461 462 tx_ops = reg_get_psoc_tx_ops(psoc); 463 if (tx_ops->unregister_11d_new_cc_handler) 464 tx_ops->unregister_11d_new_cc_handler(psoc, NULL); 465 if (tx_ops->unregister_master_handler) 466 tx_ops->unregister_master_handler(psoc, NULL); 467 if (tx_ops->unregister_ch_avoid_event_handler) 468 tx_ops->unregister_ch_avoid_event_handler(psoc, NULL); 469 470 return QDF_STATUS_SUCCESS; 471 } 472 473 QDF_STATUS regulatory_pdev_open(struct wlan_objmgr_pdev *pdev) 474 { 475 struct wlan_objmgr_psoc *parent_psoc; 476 struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj; 477 478 pdev_priv_obj = reg_get_pdev_obj(pdev); 479 480 if (!IS_VALID_PDEV_REG_OBJ(pdev_priv_obj)) { 481 reg_err("reg pdev private obj is NULL"); 482 return QDF_STATUS_E_FAILURE; 483 } 484 485 pdev_priv_obj->pdev_opened = true; 486 487 parent_psoc = wlan_pdev_get_psoc(pdev); 488 489 reg_send_scheduler_msg_nb(parent_psoc, pdev); 490 491 return QDF_STATUS_SUCCESS; 492 } 493 494 QDF_STATUS regulatory_pdev_close(struct wlan_objmgr_pdev *pdev) 495 { 496 struct wlan_objmgr_psoc *psoc; 497 struct wlan_regulatory_psoc_priv_obj *soc_reg; 498 struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj; 499 500 pdev_priv_obj = reg_get_pdev_obj(pdev); 501 if (!IS_VALID_PDEV_REG_OBJ(pdev_priv_obj)) { 502 reg_err("reg pdev private obj is NULL"); 503 return QDF_STATUS_E_FAILURE; 504 } 505 506 pdev_priv_obj->pdev_opened = false; 507 508 psoc = wlan_pdev_get_psoc(pdev); 509 soc_reg = reg_get_psoc_obj(psoc); 510 if (!soc_reg) { 511 reg_err("reg psoc private obj is NULL"); 512 return QDF_STATUS_E_FAULT; 513 } 514 515 reg_reset_ctry_pending_hints(soc_reg); 516 517 return QDF_STATUS_SUCCESS; 518 } 519 520 #ifdef CONFIG_CHAN_NUM_API 521 void wlan_reg_update_nol_ch(struct wlan_objmgr_pdev *pdev, uint8_t *ch_list, 522 uint8_t num_ch, bool nol_ch) 523 { 524 reg_update_nol_ch(pdev, ch_list, num_ch, nol_ch); 525 } 526 527 void wlan_reg_update_nol_history_ch(struct wlan_objmgr_pdev *pdev, 528 uint8_t *ch_list, uint8_t num_ch, 529 bool nol_history_ch) 530 { 531 reg_update_nol_history_ch(pdev, ch_list, num_ch, nol_history_ch); 532 } 533 534 bool wlan_reg_is_passive_or_disable_ch(struct wlan_objmgr_pdev *pdev, 535 uint8_t chan) 536 { 537 return reg_is_passive_or_disable_ch(pdev, chan); 538 } 539 540 bool wlan_reg_is_disable_ch(struct wlan_objmgr_pdev *pdev, 541 uint8_t chan) 542 { 543 return reg_is_disable_ch(pdev, chan); 544 } 545 #endif /* CONFIG_CHAN_NUM_API */ 546 547 uint8_t wlan_reg_freq_to_chan(struct wlan_objmgr_pdev *pdev, 548 qdf_freq_t freq) 549 { 550 return reg_freq_to_chan(pdev, freq); 551 } 552 553 qdf_export_symbol(wlan_reg_freq_to_chan); 554 555 qdf_freq_t wlan_reg_chan_to_freq(struct wlan_objmgr_pdev *pdev, 556 uint8_t chan_num) 557 { 558 return reg_chan_to_freq(pdev, chan_num); 559 } 560 561 qdf_export_symbol(wlan_reg_chan_to_freq); 562 563 qdf_freq_t wlan_reg_legacy_chan_to_freq(struct wlan_objmgr_pdev *pdev, 564 uint8_t chan_num) 565 { 566 return reg_legacy_chan_to_freq(pdev, chan_num); 567 } 568 569 #ifdef CONFIG_CHAN_NUM_API 570 bool wlan_reg_chan_is_49ghz(struct wlan_objmgr_pdev *pdev, 571 uint8_t chan_num) 572 { 573 return reg_chan_is_49ghz(pdev, chan_num); 574 } 575 #endif /* CONFIG_CHAN_NUM_API */ 576 577 QDF_STATUS wlan_reg_set_country(struct wlan_objmgr_pdev *pdev, 578 uint8_t *country) 579 { 580 return reg_set_country(pdev, country); 581 } 582 583 QDF_STATUS wlan_reg_set_11d_country(struct wlan_objmgr_pdev *pdev, 584 uint8_t *country) 585 { 586 return reg_set_11d_country(pdev, country); 587 } 588 589 bool wlan_reg_is_world(uint8_t *country) 590 { 591 return reg_is_world_alpha2(country); 592 } 593 594 bool wlan_reg_is_us(uint8_t *country) 595 { 596 return reg_is_us_alpha2(country); 597 } 598 599 void wlan_reg_register_chan_change_callback(struct wlan_objmgr_psoc *psoc, 600 void *cbk, void *arg) 601 { 602 reg_register_chan_change_callback(psoc, (reg_chan_change_callback)cbk, 603 arg); 604 605 } 606 607 void wlan_reg_unregister_chan_change_callback(struct wlan_objmgr_psoc *psoc, 608 void *cbk) 609 { 610 reg_unregister_chan_change_callback(psoc, 611 (reg_chan_change_callback)cbk); 612 } 613 614 bool wlan_reg_is_11d_offloaded(struct wlan_objmgr_psoc *psoc) 615 { 616 return reg_is_11d_offloaded(psoc); 617 } 618 619 bool wlan_reg_11d_enabled_on_host(struct wlan_objmgr_psoc *psoc) 620 { 621 return reg_11d_enabled_on_host(psoc); 622 } 623 624 #ifdef CONFIG_CHAN_NUM_API 625 bool wlan_reg_is_dsrc_chan(struct wlan_objmgr_pdev *pdev, uint8_t chan_num) 626 { 627 return reg_is_dsrc_chan(pdev, chan_num); 628 } 629 630 bool wlan_reg_is_etsi13_srd_chan(struct wlan_objmgr_pdev *pdev, 631 uint8_t chan_num) 632 { 633 return reg_is_etsi13_srd_chan(pdev, chan_num); 634 } 635 #endif /* CONFIG_CHAN_NUM_API */ 636 637 bool wlan_reg_is_etsi13_regdmn(struct wlan_objmgr_pdev *pdev) 638 { 639 return reg_is_etsi13_regdmn(pdev); 640 } 641 642 bool wlan_reg_is_etsi13_srd_chan_allowed_master_mode(struct wlan_objmgr_pdev 643 *pdev) 644 { 645 return reg_is_etsi13_srd_chan_allowed_master_mode(pdev); 646 } 647 648 bool wlan_reg_get_fcc_constraint(struct wlan_objmgr_pdev *pdev, uint32_t freq) 649 { 650 return reg_get_fcc_constraint(pdev, freq); 651 } 652 653 QDF_STATUS wlan_reg_get_chip_mode(struct wlan_objmgr_pdev *pdev, 654 uint32_t *chip_mode) 655 { 656 struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj; 657 658 pdev_priv_obj = wlan_objmgr_pdev_get_comp_private_obj(pdev, 659 WLAN_UMAC_COMP_REGULATORY); 660 661 if (!pdev_priv_obj) { 662 reg_err("reg pdev private obj is NULL"); 663 return QDF_STATUS_E_FAULT; 664 } 665 666 *chip_mode = pdev_priv_obj->wireless_modes; 667 668 return QDF_STATUS_SUCCESS; 669 } 670 671 QDF_STATUS wlan_reg_get_phybitmap(struct wlan_objmgr_pdev *pdev, 672 uint16_t *phybitmap) 673 { 674 return reg_get_phybitmap(pdev, phybitmap); 675 } 676 677 bool wlan_reg_is_11d_scan_inprogress(struct wlan_objmgr_psoc *psoc) 678 { 679 return reg_is_11d_scan_inprogress(psoc); 680 } 681 682 QDF_STATUS wlan_reg_get_freq_range(struct wlan_objmgr_pdev *pdev, 683 qdf_freq_t *low_2g, 684 qdf_freq_t *high_2g, 685 qdf_freq_t *low_5g, 686 qdf_freq_t *high_5g) 687 { 688 struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj; 689 690 pdev_priv_obj = wlan_objmgr_pdev_get_comp_private_obj(pdev, 691 WLAN_UMAC_COMP_REGULATORY); 692 693 if (!pdev_priv_obj) { 694 reg_err("reg pdev private obj is NULL"); 695 return QDF_STATUS_E_FAULT; 696 } 697 698 if (low_2g) 699 *low_2g = pdev_priv_obj->range_2g_low; 700 701 if (high_2g) 702 *high_2g = pdev_priv_obj->range_2g_high; 703 704 if (low_5g) 705 *low_5g = pdev_priv_obj->range_5g_low; 706 707 if (high_5g) 708 *high_5g = pdev_priv_obj->range_5g_high; 709 710 return QDF_STATUS_SUCCESS; 711 } 712 713 struct wlan_lmac_if_reg_tx_ops * 714 wlan_reg_get_tx_ops(struct wlan_objmgr_psoc *psoc) 715 { 716 return reg_get_psoc_tx_ops(psoc); 717 } 718 719 QDF_STATUS wlan_reg_get_curr_regdomain(struct wlan_objmgr_pdev *pdev, 720 struct cur_regdmn_info *cur_regdmn) 721 { 722 return reg_get_curr_regdomain(pdev, cur_regdmn); 723 } 724 725 #ifdef CONFIG_CHAN_NUM_API 726 uint8_t wlan_reg_min_24ghz_ch_num(void) 727 { 728 return reg_min_24ghz_ch_num(); 729 } 730 731 uint8_t wlan_reg_max_24ghz_ch_num(void) 732 { 733 return reg_max_24ghz_ch_num(); 734 } 735 736 uint8_t wlan_reg_min_5ghz_ch_num(void) 737 { 738 return reg_min_5ghz_ch_num(); 739 } 740 741 uint8_t wlan_reg_max_5ghz_ch_num(void) 742 { 743 return reg_max_5ghz_ch_num(); 744 } 745 #endif /* CONFIG_CHAN_NUM_API */ 746 747 #ifdef CONFIG_CHAN_FREQ_API 748 qdf_freq_t wlan_reg_min_24ghz_chan_freq(void) 749 { 750 return reg_min_24ghz_chan_freq(); 751 } 752 753 qdf_freq_t wlan_reg_max_24ghz_chan_freq(void) 754 { 755 return reg_max_24ghz_chan_freq(); 756 } 757 758 qdf_freq_t wlan_reg_min_5ghz_chan_freq(void) 759 { 760 return reg_min_5ghz_chan_freq(); 761 } 762 763 qdf_freq_t wlan_reg_max_5ghz_chan_freq(void) 764 { 765 return reg_max_5ghz_chan_freq(); 766 } 767 #endif /* CONFIG_CHAN_FREQ_API */ 768 769 #ifdef CONFIG_CHAN_NUM_API 770 bool wlan_reg_is_24ghz_ch(uint8_t chan) 771 { 772 return reg_is_24ghz_ch(chan); 773 } 774 775 bool wlan_reg_is_5ghz_ch(uint8_t chan) 776 { 777 return reg_is_5ghz_ch(chan); 778 } 779 #endif /* CONFIG_CHAN_NUM_API */ 780 781 bool wlan_reg_is_24ghz_ch_freq(qdf_freq_t freq) 782 { 783 return reg_is_24ghz_ch_freq(freq); 784 } 785 786 bool wlan_reg_is_5ghz_ch_freq(qdf_freq_t freq) 787 { 788 return reg_is_5ghz_ch_freq(freq); 789 } 790 791 bool wlan_reg_is_range_overlap_2g(qdf_freq_t low_freq, qdf_freq_t high_freq) 792 { 793 return reg_is_range_overlap_2g(low_freq, high_freq); 794 } 795 796 bool wlan_reg_is_range_overlap_5g(qdf_freq_t low_freq, qdf_freq_t high_freq) 797 { 798 return reg_is_range_overlap_5g(low_freq, high_freq); 799 } 800 801 #ifdef CONFIG_BAND_6GHZ 802 bool wlan_reg_is_6ghz_chan_freq(uint16_t freq) 803 { 804 return reg_is_6ghz_chan_freq(freq); 805 } 806 807 #ifdef CONFIG_6G_FREQ_OVERLAP 808 bool wlan_reg_is_range_only6g(qdf_freq_t low_freq, qdf_freq_t high_freq) 809 { 810 return reg_is_range_only6g(low_freq, high_freq); 811 } 812 813 bool wlan_reg_is_range_overlap_6g(qdf_freq_t low_freq, qdf_freq_t high_freq) 814 { 815 return reg_is_range_overlap_6g(low_freq, high_freq); 816 } 817 #endif 818 819 uint16_t wlan_reg_min_6ghz_chan_freq(void) 820 { 821 return reg_min_6ghz_chan_freq(); 822 } 823 824 uint16_t wlan_reg_max_6ghz_chan_freq(void) 825 { 826 return reg_max_6ghz_chan_freq(); 827 } 828 829 bool wlan_reg_is_6ghz_psc_chan_freq(uint16_t freq) 830 { 831 return reg_is_6ghz_psc_chan_freq(freq); 832 } 833 834 bool wlan_reg_is_6g_freq_indoor(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq) 835 { 836 return reg_is_6g_freq_indoor(pdev, freq); 837 } 838 839 QDF_STATUS 840 wlan_reg_get_max_txpower_for_6g_tpe(struct wlan_objmgr_pdev *pdev, 841 qdf_freq_t freq, uint8_t bw, 842 enum reg_6g_ap_type reg_ap, 843 enum reg_6g_client_type reg_client, 844 bool is_psd, 845 uint8_t *tx_power) 846 { 847 return reg_get_max_txpower_for_6g_tpe(pdev, freq, bw, 848 reg_ap, 849 reg_client, is_psd, 850 tx_power); 851 } 852 #endif /* CONFIG_BAND_6GHZ */ 853 854 uint16_t 855 wlan_reg_get_band_channel_list(struct wlan_objmgr_pdev *pdev, 856 uint8_t band_mask, 857 struct regulatory_channel *channel_list) 858 { 859 if (!pdev) { 860 reg_err("pdev object is NULL"); 861 return 0; 862 } 863 864 return reg_get_band_channel_list(pdev, band_mask, channel_list); 865 } 866 867 qdf_freq_t wlan_reg_chan_band_to_freq(struct wlan_objmgr_pdev *pdev, 868 uint8_t chan, uint8_t band_mask) 869 { 870 return reg_chan_band_to_freq(pdev, chan, band_mask); 871 } 872 873 qdf_export_symbol(wlan_reg_chan_band_to_freq); 874 875 #ifdef CONFIG_49GHZ_CHAN 876 bool wlan_reg_is_49ghz_freq(qdf_freq_t freq) 877 { 878 return reg_is_49ghz_freq(freq); 879 } 880 #endif /* CONFIG_49GHZ_CHAN */ 881 882 uint8_t wlan_reg_ch_num(uint32_t ch_enum) 883 { 884 return reg_ch_num(ch_enum); 885 } 886 887 qdf_freq_t wlan_reg_ch_to_freq(uint32_t ch_enum) 888 { 889 return reg_ch_to_freq(ch_enum); 890 } 891 892 #ifdef CONFIG_CHAN_NUM_API 893 bool wlan_reg_is_same_band_channels(uint8_t chan_num1, uint8_t chan_num2) 894 { 895 return reg_is_same_band_channels(chan_num1, chan_num2); 896 } 897 898 bool wlan_reg_is_channel_valid_5g_sbs(uint8_t curchan, uint8_t newchan) 899 { 900 return reg_is_channel_valid_5g_sbs(curchan, newchan); 901 } 902 903 enum band_info wlan_reg_chan_to_band(uint8_t chan_num) 904 { 905 return reg_chan_to_band(chan_num); 906 } 907 908 qdf_export_symbol(wlan_reg_chan_to_band); 909 910 /** 911 * wlan_reg_get_chan_enum() - Get channel enum for given channel number 912 * @chan_num: Channel number 913 * 914 * Return: Channel enum 915 */ 916 enum channel_enum wlan_reg_get_chan_enum(uint8_t chan_num) 917 { 918 return reg_get_chan_enum(chan_num); 919 } 920 #endif /* CONFIG_CHAN_NUM_API */ 921 922 bool wlan_reg_is_regdmn_en302502_applicable(struct wlan_objmgr_pdev *pdev) 923 { 924 return reg_is_regdmn_en302502_applicable(pdev); 925 } 926 927 /** 928 * wlan_reg_modify_pdev_chan_range() - Compute current channel list for the 929 * modified regcap. 930 * @pdev: pointer to struct wlan_objmgr_pdev 931 * 932 */ 933 QDF_STATUS wlan_reg_modify_pdev_chan_range(struct wlan_objmgr_pdev *pdev) 934 { 935 return reg_modify_pdev_chan_range(pdev); 936 } 937 938 QDF_STATUS wlan_reg_update_pdev_wireless_modes(struct wlan_objmgr_pdev *pdev, 939 uint32_t wireless_modes) 940 { 941 return reg_update_pdev_wireless_modes(pdev, wireless_modes); 942 } 943 #ifdef DISABLE_UNII_SHARED_BANDS 944 QDF_STATUS wlan_reg_disable_chan_coex(struct wlan_objmgr_pdev *pdev, 945 uint8_t unii_5g_bitmap) 946 { 947 return reg_disable_chan_coex(pdev, unii_5g_bitmap); 948 } 949 #endif 950 951 #ifdef CONFIG_CHAN_FREQ_API 952 bool wlan_reg_is_same_band_freqs(qdf_freq_t freq1, qdf_freq_t freq2) 953 { 954 return reg_is_same_band_freqs(freq1, freq2); 955 } 956 957 bool wlan_reg_is_frequency_valid_5g_sbs(qdf_freq_t curfreq, qdf_freq_t newfreq) 958 { 959 return reg_is_frequency_valid_5g_sbs(curfreq, newfreq); 960 } 961 962 enum channel_enum wlan_reg_get_chan_enum_for_freq(qdf_freq_t freq) 963 { 964 return reg_get_chan_enum_for_freq(freq); 965 } 966 967 bool wlan_reg_is_etsi13_srd_chan_for_freq(struct wlan_objmgr_pdev *pdev, 968 qdf_freq_t freq) 969 { 970 return reg_is_etsi13_srd_chan_for_freq(pdev, freq); 971 } 972 973 bool wlan_reg_is_dsrc_freq(qdf_freq_t freq) 974 { 975 return reg_is_dsrc_freq(freq); 976 } 977 978 void wlan_reg_update_nol_ch_for_freq(struct wlan_objmgr_pdev *pdev, 979 uint16_t *chan_freq_list, 980 uint8_t num_ch, 981 bool nol_ch) 982 { 983 reg_update_nol_ch_for_freq(pdev, chan_freq_list, num_ch, nol_ch); 984 } 985 986 void wlan_reg_update_nol_history_ch_for_freq(struct wlan_objmgr_pdev *pdev, 987 uint16_t *ch_list, 988 uint8_t num_ch, 989 bool nol_history_ch) 990 { 991 reg_update_nol_history_ch_for_freq(pdev, 992 ch_list, 993 num_ch, 994 nol_history_ch); 995 } 996 997 bool wlan_reg_is_dfs_for_freq(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq) 998 { 999 return reg_is_dfs_for_freq(pdev, freq); 1000 } 1001 1002 bool wlan_reg_is_passive_or_disable_for_freq(struct wlan_objmgr_pdev *pdev, 1003 qdf_freq_t freq) 1004 { 1005 return reg_is_passive_or_disable_for_freq(pdev, freq); 1006 } 1007 1008 bool wlan_reg_is_disable_for_freq(struct wlan_objmgr_pdev *pdev, 1009 qdf_freq_t freq) 1010 { 1011 return reg_is_disable_for_freq(pdev, freq); 1012 } 1013 1014 bool wlan_reg_is_passive_for_freq(struct wlan_objmgr_pdev *pdev, 1015 qdf_freq_t freq) 1016 { 1017 return reg_is_passive_for_freq(pdev, freq); 1018 } 1019 1020 QDF_STATUS 1021 wlan_reg_get_channel_list_with_power_for_freq(struct wlan_objmgr_pdev *pdev, 1022 struct channel_power *ch_list, 1023 uint8_t *num_chan) 1024 { 1025 return reg_get_channel_list_with_power_for_freq(pdev, 1026 ch_list, 1027 num_chan); 1028 } 1029 1030 bool 1031 wlan_reg_chan_has_dfs_attribute_for_freq(struct wlan_objmgr_pdev *pdev, 1032 qdf_freq_t freq) 1033 { 1034 return reg_chan_has_dfs_attribute_for_freq(pdev, freq); 1035 } 1036 1037 enum channel_state 1038 wlan_reg_get_5g_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, 1039 qdf_freq_t freq, 1040 enum phy_ch_width bw) 1041 { 1042 return reg_get_5g_bonded_channel_state_for_freq(pdev, freq, bw); 1043 } 1044 1045 qdf_export_symbol(wlan_reg_get_5g_bonded_channel_state_for_freq); 1046 1047 enum channel_state 1048 wlan_reg_get_2g_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, 1049 qdf_freq_t freq, 1050 qdf_freq_t sec_ch_freq, 1051 enum phy_ch_width bw) 1052 { 1053 return reg_get_2g_bonded_channel_state_for_freq(pdev, 1054 freq, 1055 sec_ch_freq, 1056 bw); 1057 } 1058 1059 void wlan_reg_set_channel_params_for_freq(struct wlan_objmgr_pdev *pdev, 1060 qdf_freq_t freq, 1061 qdf_freq_t sec_ch_2g_freq, 1062 struct ch_params *ch_params) 1063 { 1064 reg_set_channel_params_for_freq(pdev, freq, sec_ch_2g_freq, ch_params); 1065 } 1066 1067 qdf_export_symbol(wlan_reg_set_channel_params_for_freq); 1068 1069 enum channel_state 1070 wlan_reg_get_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, 1071 qdf_freq_t freq) 1072 { 1073 return reg_get_channel_state_for_freq(pdev, freq); 1074 } 1075 1076 uint8_t wlan_reg_get_channel_reg_power_for_freq(struct wlan_objmgr_pdev *pdev, 1077 qdf_freq_t freq) 1078 { 1079 return reg_get_channel_reg_power_for_freq(pdev, freq); 1080 } 1081 1082 enum reg_wifi_band wlan_reg_freq_to_band(qdf_freq_t freq) 1083 { 1084 return reg_freq_to_band(freq); 1085 } 1086 qdf_export_symbol(wlan_reg_freq_to_band); 1087 1088 qdf_freq_t wlan_reg_min_chan_freq(void) 1089 { 1090 return reg_min_chan_freq(); 1091 } 1092 1093 qdf_freq_t wlan_reg_max_chan_freq(void) 1094 { 1095 return reg_max_chan_freq(); 1096 } 1097 1098 void wlan_reg_freq_width_to_chan_op_class(struct wlan_objmgr_pdev *pdev, 1099 qdf_freq_t freq, 1100 uint16_t chan_width, 1101 bool global_tbl_lookup, 1102 uint16_t behav_limit, 1103 uint8_t *op_class, 1104 uint8_t *chan_num) 1105 { 1106 return reg_freq_width_to_chan_op_class(pdev, freq, chan_width, 1107 global_tbl_lookup, 1108 behav_limit, 1109 op_class, 1110 chan_num); 1111 } 1112 1113 void wlan_reg_freq_width_to_chan_op_class_auto(struct wlan_objmgr_pdev *pdev, 1114 qdf_freq_t freq, 1115 uint16_t chan_width, 1116 bool global_tbl_lookup, 1117 uint16_t behav_limit, 1118 uint8_t *op_class, 1119 uint8_t *chan_num) 1120 { 1121 reg_freq_width_to_chan_op_class_auto(pdev, freq, chan_width, 1122 global_tbl_lookup, 1123 behav_limit, 1124 op_class, 1125 chan_num); 1126 } 1127 1128 qdf_export_symbol(wlan_reg_freq_width_to_chan_op_class_auto); 1129 1130 void wlan_reg_freq_to_chan_op_class(struct wlan_objmgr_pdev *pdev, 1131 qdf_freq_t freq, 1132 bool global_tbl_lookup, 1133 uint16_t behav_limit, 1134 uint8_t *op_class, 1135 uint8_t *chan_num) 1136 { 1137 return reg_freq_to_chan_op_class(pdev, freq, 1138 global_tbl_lookup, 1139 behav_limit, 1140 op_class, 1141 chan_num); 1142 } 1143 1144 bool wlan_reg_is_freq_in_country_opclass(struct wlan_objmgr_pdev *pdev, 1145 const uint8_t country[3], 1146 uint8_t op_class, 1147 qdf_freq_t chan_freq) 1148 { 1149 return reg_is_freq_in_country_opclass(pdev, country, 1150 op_class, chan_freq); 1151 } 1152 1153 enum channel_state 1154 wlan_reg_get_5g_bonded_channel_and_state_for_freq(struct wlan_objmgr_pdev *pdev, 1155 uint16_t freq, 1156 enum phy_ch_width bw, 1157 const 1158 struct bonded_channel_freq 1159 **bonded_chan_ptr_ptr) 1160 { 1161 /* 1162 * Get channel frequencies and state from regulatory 1163 */ 1164 return reg_get_5g_bonded_channel_for_freq(pdev, freq, bw, 1165 bonded_chan_ptr_ptr); 1166 } 1167 1168 enum channel_state 1169 wlan_reg_get_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, 1170 qdf_freq_t freq, 1171 enum phy_ch_width bw, 1172 qdf_freq_t sec_freq) 1173 { 1174 if (WLAN_REG_IS_24GHZ_CH_FREQ(freq)) 1175 return reg_get_2g_bonded_channel_state_for_freq(pdev, freq, 1176 sec_freq, bw); 1177 else 1178 return reg_get_5g_bonded_channel_state_for_freq(pdev, freq, 1179 bw); 1180 } 1181 1182 qdf_export_symbol(wlan_reg_get_5g_bonded_channel_and_state_for_freq); 1183 1184 #endif /* CONFIG CHAN FREQ API */ 1185 1186 uint16_t wlan_reg_get_op_class_width(struct wlan_objmgr_pdev *pdev, 1187 uint8_t op_class, 1188 bool global_tbl_lookup) 1189 { 1190 return reg_get_op_class_width(pdev, op_class, 1191 global_tbl_lookup); 1192 } 1193 1194 bool wlan_reg_is_5ghz_op_class(const uint8_t *country, uint8_t op_class) 1195 { 1196 return reg_is_5ghz_op_class(country, op_class); 1197 } 1198 1199 bool wlan_reg_is_2ghz_op_class(const uint8_t *country, uint8_t op_class) 1200 { 1201 return reg_is_2ghz_op_class(country, op_class); 1202 } 1203 1204 bool wlan_reg_is_6ghz_op_class(struct wlan_objmgr_pdev *pdev, 1205 uint8_t op_class) 1206 { 1207 return reg_is_6ghz_op_class(pdev, op_class); 1208 } 1209 1210 #ifdef CONFIG_REG_CLIENT 1211 bool wlan_reg_is_6ghz_supported(struct wlan_objmgr_psoc *psoc) 1212 { 1213 return reg_is_6ghz_supported(psoc); 1214 } 1215 #endif 1216 1217 #ifdef HOST_OPCLASS_EXT 1218 qdf_freq_t 1219 wlan_reg_country_chan_opclass_to_freq(struct wlan_objmgr_pdev *pdev, 1220 const uint8_t country[3], 1221 uint8_t chan, uint8_t op_class, 1222 bool strict) 1223 { 1224 return reg_country_chan_opclass_to_freq(pdev, country, chan, op_class, 1225 strict); 1226 } 1227 #endif 1228 1229 uint16_t wlan_reg_chan_opclass_to_freq(uint8_t chan, 1230 uint8_t op_class, 1231 bool global_tbl_lookup) 1232 { 1233 if (!chan || !op_class) 1234 return 0; 1235 1236 return reg_chan_opclass_to_freq(chan, op_class, global_tbl_lookup); 1237 } 1238 1239 qdf_freq_t wlan_reg_chan_opclass_to_freq_auto(uint8_t chan, uint8_t op_class, 1240 bool global_tbl_lookup) 1241 { 1242 if (!chan || !op_class) 1243 return 0; 1244 1245 return reg_chan_opclass_to_freq_auto(chan, op_class, global_tbl_lookup); 1246 } 1247 1248 #ifdef CHECK_REG_PHYMODE 1249 enum reg_phymode wlan_reg_get_max_phymode(struct wlan_objmgr_pdev *pdev, 1250 enum reg_phymode phy_in, 1251 qdf_freq_t freq) 1252 { 1253 return reg_get_max_phymode(pdev, phy_in, freq); 1254 } 1255 #endif /* CHECK_REG_PHYMODE */ 1256 1257 #ifdef CONFIG_REG_CLIENT 1258 enum band_info wlan_reg_band_bitmap_to_band_info(uint32_t band_bitmap) 1259 { 1260 return reg_band_bitmap_to_band_info(band_bitmap); 1261 } 1262 #endif 1263 1264 #if defined(CONFIG_BAND_6GHZ) 1265 QDF_STATUS wlan_reg_get_rnr_tpe_usable(struct wlan_objmgr_pdev *pdev, 1266 bool *reg_rnr_tpe_usable) 1267 { 1268 return reg_get_rnr_tpe_usable(pdev, reg_rnr_tpe_usable); 1269 } 1270 1271 QDF_STATUS wlan_reg_get_unspecified_ap_usable(struct wlan_objmgr_pdev *pdev, 1272 bool *reg_unspecified_ap_usable) 1273 { 1274 return reg_get_unspecified_ap_usable(pdev, reg_unspecified_ap_usable); 1275 } 1276 1277 QDF_STATUS 1278 wlan_reg_get_cur_6g_client_type(struct wlan_objmgr_pdev *pdev, 1279 enum reg_6g_client_type 1280 *reg_cur_6g_client_mobility_type) 1281 { 1282 return reg_get_cur_6g_client_type(pdev, 1283 reg_cur_6g_client_mobility_type); 1284 } 1285 #endif 1286