1 /* 2 * Copyright (c) 2017-2021 The Linux Foundation. All rights reserved. 3 * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved. 4 * 5 * 6 * Permission to use, copy, modify, and/or distribute this software for 7 * any purpose with or without fee is hereby granted, provided that the 8 * above copyright notice and this permission notice appear in all 9 * copies. 10 * 11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 15 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 16 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 17 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 18 * PERFORMANCE OF THIS SOFTWARE. 19 */ 20 21 /** 22 * DOC: wlan_req_ucfg_api.c 23 * contains regulatory user config interface definitions 24 */ 25 26 #include <wlan_objmgr_vdev_obj.h> 27 #include <wlan_reg_ucfg_api.h> 28 #include <wlan_objmgr_psoc_obj.h> 29 #include <../../core/src/reg_priv_objs.h> 30 #include <../../core/src/reg_utils.h> 31 #include <../../core/src/reg_services_common.h> 32 #include <../../core/src/reg_opclass.h> 33 #include <../../core/src/reg_lte.h> 34 #include <../../core/src/reg_offload_11d_scan.h> 35 #include <../../core/src/reg_build_chan_list.h> 36 #include <../../core/src/reg_callbacks.h> 37 #include <qdf_module.h> 38 39 QDF_STATUS ucfg_reg_register_event_handler(uint8_t vdev_id, reg_event_cb cb, 40 void *arg) 41 { 42 /* Register a event cb handler */ 43 return QDF_STATUS_SUCCESS; 44 } 45 46 QDF_STATUS ucfg_reg_unregister_event_handler(uint8_t vdev_id, reg_event_cb cb, 47 void *arg) 48 { 49 /* unregister a event cb handler */ 50 return QDF_STATUS_SUCCESS; 51 } 52 53 QDF_STATUS ucfg_reg_init_handler(uint8_t pdev_id) 54 { 55 /* regulatory initialization handler */ 56 return QDF_STATUS_SUCCESS; 57 } 58 59 QDF_STATUS ucfg_reg_get_current_chan_list(struct wlan_objmgr_pdev *pdev, 60 struct regulatory_channel *chan_list) 61 { 62 return reg_get_current_chan_list(pdev, chan_list); 63 } 64 65 qdf_export_symbol(ucfg_reg_get_current_chan_list); 66 67 QDF_STATUS ucfg_reg_modify_chan_144(struct wlan_objmgr_pdev *pdev, 68 bool enable_ch_144) 69 { 70 return reg_modify_chan_144(pdev, enable_ch_144); 71 } 72 73 bool ucfg_reg_get_en_chan_144(struct wlan_objmgr_pdev *pdev) 74 { 75 return reg_get_en_chan_144(pdev); 76 } 77 78 QDF_STATUS ucfg_reg_set_config_vars(struct wlan_objmgr_psoc *psoc, 79 struct reg_config_vars config_vars) 80 { 81 return reg_set_config_vars(psoc, config_vars); 82 } 83 84 bool ucfg_reg_is_regdb_offloaded(struct wlan_objmgr_psoc *psoc) 85 { 86 return reg_is_regdb_offloaded(psoc); 87 } 88 89 void ucfg_reg_program_mas_chan_list(struct wlan_objmgr_psoc *psoc, 90 struct regulatory_channel *reg_channels, 91 uint8_t *alpha2, 92 enum dfs_reg dfs_region) 93 { 94 reg_program_mas_chan_list(psoc, reg_channels, alpha2, dfs_region); 95 } 96 97 QDF_STATUS ucfg_reg_get_regd_rules(struct wlan_objmgr_pdev *pdev, 98 struct reg_rule_info *reg_rules) 99 { 100 return reg_get_regd_rules(pdev, reg_rules); 101 } 102 103 #ifdef WLAN_REG_PARTIAL_OFFLOAD 104 QDF_STATUS ucfg_reg_program_default_cc(struct wlan_objmgr_pdev *pdev, 105 uint16_t regdmn) 106 { 107 return reg_program_default_cc(pdev, regdmn); 108 } 109 #endif 110 111 QDF_STATUS ucfg_reg_program_cc(struct wlan_objmgr_pdev *pdev, 112 struct cc_regdmn_s *rd) 113 { 114 return reg_program_chan_list(pdev, rd); 115 } 116 117 QDF_STATUS ucfg_reg_get_current_cc(struct wlan_objmgr_pdev *pdev, 118 struct cc_regdmn_s *rd) 119 { 120 return reg_get_current_cc(pdev, rd); 121 } 122 123 #ifdef CONFIG_REG_CLIENT 124 125 QDF_STATUS ucfg_reg_set_band(struct wlan_objmgr_pdev *pdev, 126 uint32_t band_bitmap) 127 { 128 return reg_set_band(pdev, band_bitmap); 129 } 130 131 QDF_STATUS ucfg_reg_get_band(struct wlan_objmgr_pdev *pdev, 132 uint32_t *band_bitmap) 133 { 134 return reg_get_band(pdev, band_bitmap); 135 } 136 137 QDF_STATUS ucfg_reg_notify_sap_event(struct wlan_objmgr_pdev *pdev, 138 bool sap_state) 139 { 140 return reg_notify_sap_event(pdev, sap_state); 141 } 142 143 QDF_STATUS ucfg_reg_set_fcc_constraint(struct wlan_objmgr_pdev *pdev, 144 bool fcc_constraint) 145 { 146 return reg_set_fcc_constraint(pdev, fcc_constraint); 147 } 148 149 QDF_STATUS ucfg_reg_get_current_country(struct wlan_objmgr_psoc *psoc, 150 uint8_t *country_code) 151 { 152 return reg_read_current_country(psoc, country_code); 153 } 154 155 QDF_STATUS ucfg_reg_set_default_country(struct wlan_objmgr_psoc *psoc, 156 uint8_t *country) 157 { 158 return reg_set_default_country(psoc, country); 159 } 160 161 bool ucfg_reg_get_keep_6ghz_sta_cli_connection( 162 struct wlan_objmgr_pdev *pdev) 163 { 164 return reg_get_keep_6ghz_sta_cli_connection(pdev); 165 } 166 167 QDF_STATUS ucfg_reg_set_keep_6ghz_sta_cli_connection( 168 struct wlan_objmgr_pdev *pdev, 169 bool keep_6ghz_sta_cli_connection) 170 { 171 return reg_set_keep_6ghz_sta_cli_connection(pdev, 172 keep_6ghz_sta_cli_connection); 173 } 174 175 bool ucfg_reg_is_user_country_set_allowed(struct wlan_objmgr_psoc *psoc) 176 { 177 return reg_is_user_country_set_allowed(psoc); 178 } 179 180 bool ucfg_reg_is_fcc_constraint_set(struct wlan_objmgr_pdev *pdev) 181 { 182 return reg_is_fcc_constraint_set(pdev); 183 } 184 #endif 185 186 QDF_STATUS ucfg_reg_get_default_country(struct wlan_objmgr_psoc *psoc, 187 uint8_t *country_code) 188 { 189 return reg_read_default_country(psoc, country_code); 190 } 191 192 QDF_STATUS ucfg_reg_set_country(struct wlan_objmgr_pdev *pdev, 193 uint8_t *country) 194 { 195 return reg_set_country(pdev, country); 196 } 197 198 QDF_STATUS ucfg_reg_reset_country(struct wlan_objmgr_psoc *psoc) 199 { 200 return reg_reset_country(psoc); 201 } 202 203 QDF_STATUS ucfg_reg_enable_dfs_channels(struct wlan_objmgr_pdev *pdev, 204 bool dfs_enable) 205 { 206 return reg_enable_dfs_channels(pdev, dfs_enable); 207 } 208 209 void ucfg_reg_register_chan_change_callback(struct wlan_objmgr_psoc *psoc, 210 void *cbk, void *arg) 211 { 212 reg_register_chan_change_callback(psoc, (reg_chan_change_callback)cbk, 213 arg); 214 } 215 216 void ucfg_reg_unregister_chan_change_callback(struct wlan_objmgr_psoc *psoc, 217 void *cbk) 218 { 219 reg_unregister_chan_change_callback(psoc, 220 (reg_chan_change_callback)cbk); 221 } 222 223 #ifdef CONFIG_AFC_SUPPORT 224 QDF_STATUS ucfg_reg_register_afc_req_rx_callback(struct wlan_objmgr_pdev *pdev, 225 afc_req_rx_evt_handler cbf, 226 void *arg) 227 { 228 return reg_register_afc_req_rx_callback(pdev, cbf, arg); 229 } 230 231 qdf_export_symbol(ucfg_reg_register_afc_req_rx_callback); 232 233 QDF_STATUS ucfg_reg_unregister_afc_req_rx_callback(struct wlan_objmgr_pdev *pdev, 234 afc_req_rx_evt_handler cbf) 235 { 236 return reg_unregister_afc_req_rx_callback(pdev, cbf); 237 } 238 239 QDF_STATUS 240 ucfg_reg_register_afc_power_event_callback(struct wlan_objmgr_pdev *pdev, 241 afc_power_tx_evt_handler cbf, 242 void *arg) 243 { 244 return reg_register_afc_power_event_callback(pdev, cbf, arg); 245 } 246 247 qdf_export_symbol(ucfg_reg_register_afc_power_event_callback); 248 249 QDF_STATUS 250 ucfg_reg_unregister_afc_power_event_callback(struct wlan_objmgr_pdev *pdev, 251 afc_power_tx_evt_handler cbf) 252 { 253 return reg_unregister_afc_power_event_callback(pdev, cbf); 254 } 255 256 QDF_STATUS 257 ucfg_reg_register_afc_payload_reset_event_callback( 258 struct wlan_objmgr_pdev *pdev, 259 afc_payload_reset_tx_evt_handler cbf, 260 void *arg) { 261 return reg_register_afc_payload_reset_event_callback(pdev, cbf, arg); 262 } 263 264 qdf_export_symbol(ucfg_reg_register_afc_payload_reset_event_callback); 265 266 QDF_STATUS ucfg_reg_unregister_afc_payload_reset_event_callback( 267 struct wlan_objmgr_pdev *pdev, 268 afc_payload_reset_tx_evt_handler cbf) 269 { 270 return reg_unregister_afc_payload_reset_event_callback(pdev, cbf); 271 } 272 273 QDF_STATUS ucfg_reg_get_afc_req_info(struct wlan_objmgr_pdev *pdev, 274 struct wlan_afc_host_request **afc_req, 275 uint64_t req_id) 276 { 277 QDF_STATUS status; 278 279 status = reg_get_afc_req_info(pdev, afc_req); 280 281 if (status == QDF_STATUS_SUCCESS) 282 reg_dmn_set_afc_req_id(*afc_req, req_id); 283 284 return status; 285 } 286 287 void 288 ucfg_reg_free_afc_req(struct wlan_objmgr_pdev *pdev, 289 struct wlan_afc_host_request *afc_req) 290 { 291 reg_free_afc_req(pdev, afc_req); 292 } 293 #endif 294 295 enum country_src ucfg_reg_get_cc_and_src(struct wlan_objmgr_psoc *psoc, 296 uint8_t *alpha2) 297 { 298 return reg_get_cc_and_src(psoc, alpha2); 299 } 300 301 void ucfg_reg_unit_simulate_ch_avoid(struct wlan_objmgr_psoc *psoc, 302 struct ch_avoid_ind_type *ch_avoid) 303 { 304 reg_process_ch_avoid_event(psoc, ch_avoid); 305 } 306 307 void ucfg_reg_ch_avoid(struct wlan_objmgr_psoc *psoc, 308 struct ch_avoid_ind_type *ch_avoid) 309 { 310 reg_process_ch_avoid_event(psoc, ch_avoid); 311 } 312 313 #ifdef FEATURE_WLAN_CH_AVOID_EXT 314 void ucfg_reg_ch_avoid_ext(struct wlan_objmgr_psoc *psoc, 315 struct ch_avoid_ind_type *ch_avoid) 316 { 317 reg_process_ch_avoid_ext_event(psoc, ch_avoid); 318 } 319 #endif 320 321 #ifdef TARGET_11D_SCAN 322 QDF_STATUS ucfg_reg_11d_vdev_delete_update(struct wlan_objmgr_psoc *psoc, 323 enum QDF_OPMODE op_mode, 324 uint32_t vdev_id) 325 { 326 return reg_11d_vdev_delete_update(psoc, op_mode, vdev_id); 327 } 328 329 QDF_STATUS ucfg_reg_11d_vdev_created_update(struct wlan_objmgr_vdev *vdev) 330 { 331 return reg_11d_vdev_created_update(vdev); 332 } 333 #endif 334 335 QDF_STATUS ucfg_reg_update_hal_cap_wireless_modes(struct wlan_objmgr_psoc *psoc, 336 uint64_t modes, uint8_t phy_id) 337 { 338 return reg_update_hal_cap_wireless_modes(psoc, modes, phy_id); 339 } 340 341 qdf_export_symbol(ucfg_reg_update_hal_cap_wireless_modes); 342 343 struct wlan_psoc_host_hal_reg_capabilities_ext *ucfg_reg_get_hal_reg_cap( 344 struct wlan_objmgr_psoc *psoc) 345 { 346 return reg_get_hal_reg_cap(psoc); 347 } 348 qdf_export_symbol(ucfg_reg_get_hal_reg_cap); 349 350 QDF_STATUS ucfg_reg_set_hal_reg_cap(struct wlan_objmgr_psoc *psoc, 351 struct wlan_psoc_host_hal_reg_capabilities_ext *hal_reg_cap, 352 uint16_t phy_cnt) 353 354 { 355 return reg_set_hal_reg_cap(psoc, hal_reg_cap, phy_cnt); 356 } 357 qdf_export_symbol(ucfg_reg_set_hal_reg_cap); 358 359 QDF_STATUS ucfg_reg_update_hal_reg_range_caps(struct wlan_objmgr_psoc *psoc, 360 uint32_t low_2g_chan, 361 uint32_t high_2g_chan, 362 uint32_t low_5g_chan, 363 uint32_t high_5g_chan, 364 uint8_t phy_id) 365 { 366 return reg_update_hal_reg_range_caps(psoc, low_2g_chan, 367 high_2g_chan, low_5g_chan, high_5g_chan, 368 phy_id); 369 } 370 371 qdf_export_symbol(ucfg_reg_update_hal_reg_range_caps); 372 373 #ifdef DISABLE_CHANNEL_LIST 374 #ifdef CONFIG_CHAN_FREQ_API 375 void ucfg_reg_cache_channel_freq_state(struct wlan_objmgr_pdev *pdev, 376 uint32_t *channel_list, 377 uint32_t num_channels) 378 { 379 reg_cache_channel_freq_state(pdev, channel_list, num_channels); 380 } 381 #endif /* CONFIG_CHAN_FREQ_API */ 382 383 void ucfg_reg_restore_cached_channels(struct wlan_objmgr_pdev *pdev) 384 { 385 reg_restore_cached_channels(pdev); 386 } 387 388 void ucfg_reg_disable_cached_channels(struct wlan_objmgr_pdev *pdev) 389 { 390 reg_disable_cached_channels(pdev); 391 } 392 393 #endif 394 395 QDF_STATUS ucfg_set_ignore_fw_reg_offload_ind(struct wlan_objmgr_psoc *psoc) 396 { 397 return reg_set_ignore_fw_reg_offload_ind(psoc); 398 } 399 400 #ifdef DISABLE_UNII_SHARED_BANDS 401 QDF_STATUS 402 ucfg_reg_get_unii_5g_bitmap(struct wlan_objmgr_pdev *pdev, uint8_t *bitmap) 403 { 404 return reg_get_unii_5g_bitmap(pdev, bitmap); 405 } 406 #endif 407 408 #if defined(CONFIG_BAND_6GHZ) 409 QDF_STATUS 410 ucfg_reg_set_cur_6g_ap_pwr_type(struct wlan_objmgr_pdev *pdev, 411 enum reg_6g_ap_type reg_cur_6g_ap_pwr_type) 412 { 413 return reg_set_cur_6g_ap_pwr_type(pdev, reg_cur_6g_ap_pwr_type); 414 } 415 416 QDF_STATUS 417 ucfg_reg_get_cur_6g_ap_pwr_type(struct wlan_objmgr_pdev *pdev, 418 enum reg_6g_ap_type *reg_cur_6g_ap_pwr_type) 419 { 420 return reg_get_cur_6g_ap_pwr_type(pdev, reg_cur_6g_ap_pwr_type); 421 } 422 423 qdf_export_symbol(ucfg_reg_get_cur_6g_ap_pwr_type); 424 #endif 425 426 #if defined(CONFIG_AFC_SUPPORT) && defined(CONFIG_BAND_6GHZ) 427 bool ucfg_reg_get_enable_6ghz_sp_mode_support(struct wlan_objmgr_psoc *psoc) 428 { 429 return reg_get_enable_6ghz_sp_mode_support(psoc); 430 } 431 432 qdf_export_symbol(ucfg_reg_get_enable_6ghz_sp_mode_support); 433 434 void ucfg_reg_set_enable_6ghz_sp_mode_support(struct wlan_objmgr_psoc *psoc, 435 bool value) 436 { 437 reg_set_enable_6ghz_sp_mode_support(psoc, value); 438 } 439 440 qdf_export_symbol(ucfg_reg_set_enable_6ghz_sp_mode_support); 441 442 bool ucfg_reg_get_afc_disable_timer_check(struct wlan_objmgr_psoc *psoc) 443 { 444 return reg_get_afc_disable_timer_check(psoc); 445 } 446 447 qdf_export_symbol(ucfg_reg_get_afc_disable_timer_check); 448 449 void ucfg_reg_set_afc_disable_timer_check(struct wlan_objmgr_psoc *psoc, 450 bool value) 451 { 452 reg_set_afc_disable_timer_check(psoc, value); 453 } 454 455 qdf_export_symbol(ucfg_reg_set_afc_disable_timer_check); 456 457 bool ucfg_reg_get_afc_disable_request_id_check(struct wlan_objmgr_psoc *psoc) 458 { 459 return reg_get_afc_disable_request_id_check(psoc); 460 } 461 462 qdf_export_symbol(ucfg_reg_get_afc_disable_request_id_check); 463 464 void ucfg_reg_set_afc_disable_request_id_check(struct wlan_objmgr_psoc *psoc, 465 bool value) 466 { 467 reg_set_afc_disable_request_id_check(psoc, value); 468 } 469 470 qdf_export_symbol(ucfg_reg_set_afc_disable_request_id_check); 471 472 bool ucfg_reg_get_afc_no_action(struct wlan_objmgr_psoc *psoc) 473 { 474 return reg_get_afc_noaction(psoc); 475 } 476 477 qdf_export_symbol(ucfg_reg_get_afc_no_action); 478 479 void ucfg_reg_set_afc_no_action(struct wlan_objmgr_psoc *psoc, bool value) 480 { 481 reg_set_afc_noaction(psoc, value); 482 } 483 484 qdf_export_symbol(ucfg_reg_set_afc_no_action); 485 #endif 486 487 #if defined(CONFIG_AFC_SUPPORT) && defined(CONFIG_BAND_6GHZ) 488 QDF_STATUS 489 ucfg_reg_send_afc_resp_rx_ind(struct wlan_objmgr_pdev *pdev, 490 struct reg_afc_resp_rx_ind_info *afc_ind_obj) 491 { 492 return reg_send_afc_cmd(pdev, afc_ind_obj); 493 } 494 495 QDF_STATUS 496 ucfg_reg_afc_start(struct wlan_objmgr_pdev *pdev, uint64_t req_id) 497 { 498 return reg_afc_start(pdev, req_id); 499 } 500 #endif 501 502 #ifndef CONFIG_REG_CLIENT 503 QDF_STATUS ucfg_reg_enable_disable_opclass_chans(struct wlan_objmgr_pdev *pdev, 504 bool is_disable, 505 uint8_t opclass, 506 uint8_t *ieee_chan_list, 507 uint8_t chan_list_size, 508 bool global_tbl_lookup) 509 { 510 return reg_enable_disable_opclass_chans(pdev, is_disable, opclass, 511 ieee_chan_list, chan_list_size, 512 global_tbl_lookup); 513 } 514 #endif 515