1 /* 2 * Copyright (c) 2017-2021 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 * DOC: wlan_reg_ucfg_api.h 22 * This file provides prototypes of the regulatory component user 23 * config interface routines 24 */ 25 26 #ifndef __WLAN_REG_UCFG_API_H 27 #define __WLAN_REG_UCFG_API_H 28 29 #ifdef CONFIG_AFC_SUPPORT 30 #include <wlan_reg_afc.h> 31 #endif 32 #include <reg_services_public_struct.h> 33 34 typedef QDF_STATUS (*reg_event_cb)(void *status_struct); 35 36 /** 37 * ucfg_reg_set_band() - Sets the band information for the PDEV 38 * @pdev: The physical pdev to set the band for 39 * @band_bitmap: The band bitmap parameter (over reg_wifi_band) to configure 40 * for the physical device 41 * 42 * Return: QDF_STATUS 43 */ 44 QDF_STATUS ucfg_reg_set_band(struct wlan_objmgr_pdev *pdev, 45 uint32_t band_bitmap); 46 47 /** 48 * ucfg_reg_get_band() - Gets the band information for the PDEV 49 * @pdev: The physical pdev to get the band for 50 * @band_bitmap: The band parameter of the physical device 51 * 52 * Return: QDF_STATUS 53 */ 54 QDF_STATUS ucfg_reg_get_band(struct wlan_objmgr_pdev *pdev, 55 uint32_t *band_bitmap); 56 57 /** 58 * ucfg_reg_notify_sap_event() - Notify regulatory domain for sap event 59 * @pdev: The physical dev to set the band for 60 * @sap_state: true for sap start else false 61 * 62 * Return: QDF_STATUS 63 */ 64 QDF_STATUS ucfg_reg_notify_sap_event(struct wlan_objmgr_pdev *pdev, 65 bool sap_state); 66 67 /** 68 * ucfg_reg_cache_channel_freq_state() - Cache the current state of the 69 * channels based on the channel center frequency. 70 * @pdev: Pointer to pdev. 71 * @channel_list: List of the channels for which states need to be cached. 72 * @num_channels: Number of channels in the list. 73 * 74 * Return: QDF_STATUS 75 */ 76 #if defined(DISABLE_CHANNEL_LIST) && defined(CONFIG_CHAN_FREQ_API) 77 void ucfg_reg_cache_channel_freq_state(struct wlan_objmgr_pdev *pdev, 78 uint32_t *channel_list, 79 uint32_t num_channels); 80 #else 81 static inline 82 void ucfg_reg_cache_channel_freq_state(struct wlan_objmgr_pdev *pdev, 83 uint32_t *channel_list, 84 uint32_t num_channels) 85 { 86 } 87 #endif /* CONFIG_CHAN_FREQ_API */ 88 89 #ifdef DISABLE_CHANNEL_LIST 90 /** 91 * ucfg_reg_disable_cached_channels() - Disable cached channels 92 * @pdev: The physical dev to cache the channels for 93 * 94 * Return: Void 95 */ 96 void ucfg_reg_disable_cached_channels(struct wlan_objmgr_pdev *pdev); 97 98 /** 99 * ucfg_reg_restore_cached_channels() - Restore disabled cached channels 100 * @pdev: The physical dev to cache the channels for 101 * 102 * Return: Void 103 */ 104 void ucfg_reg_restore_cached_channels(struct wlan_objmgr_pdev *pdev); 105 #else 106 static inline 107 void ucfg_reg_disable_cached_channels(struct wlan_objmgr_pdev *pdev) 108 { 109 } 110 111 static inline 112 void ucfg_reg_restore_cached_channels(struct wlan_objmgr_pdev *pdev) 113 { 114 } 115 #endif 116 117 /** 118 * ucfg_reg_set_fcc_constraint() - apply fcc constraints on channels 12/13 119 * @pdev: The physical pdev to reduce tx power for 120 * 121 * This function adjusts the transmit power on channels 12 and 13, to comply 122 * with FCC regulations in the USA. 123 * 124 * Return: QDF_STATUS 125 */ 126 QDF_STATUS ucfg_reg_set_fcc_constraint(struct wlan_objmgr_pdev *pdev, 127 bool fcc_constraint); 128 129 /** 130 * ucfg_reg_get_default_country() - Get the default regulatory country 131 * @psoc: The physical SoC to get default country from 132 * @country_code: the buffer to populate the country code into 133 * 134 * Return: QDF_STATUS 135 */ 136 QDF_STATUS ucfg_reg_get_default_country(struct wlan_objmgr_psoc *psoc, 137 uint8_t *country_code); 138 139 /** 140 * ucfg_reg_get_current_country() - Get the current regulatory country 141 * @psoc: The physical SoC to get current country from 142 * @country_code: the buffer to populate the country code into 143 * 144 * Return: QDF_STATUS 145 */ 146 QDF_STATUS ucfg_reg_get_current_country(struct wlan_objmgr_psoc *psoc, 147 uint8_t *country_code); 148 /** 149 * ucfg_reg_set_default_country() - Set the default regulatory country 150 * @psoc: The physical SoC to set default country for 151 * @country_code: The country information to configure 152 * 153 * Return: QDF_STATUS 154 */ 155 QDF_STATUS ucfg_reg_set_default_country(struct wlan_objmgr_psoc *psoc, 156 uint8_t *country_code); 157 158 /** 159 * ucfg_reg_set_country() - Set the current regulatory country 160 * @pdev: The physical dev to set current country for 161 * @country_code: The country information to configure 162 * 163 * Return: QDF_STATUS 164 */ 165 QDF_STATUS ucfg_reg_set_country(struct wlan_objmgr_pdev *dev, 166 uint8_t *country_code); 167 168 /** 169 * ucfg_reg_reset_country() - Reset the regulatory country to default 170 * @psoc: The physical SoC to reset country for 171 * 172 * Return: QDF_STATUS 173 */ 174 QDF_STATUS ucfg_reg_reset_country(struct wlan_objmgr_psoc *psoc); 175 176 /** 177 * ucfg_reg_enable_dfs_channels() - Enable the use of DFS channels 178 * @pdev: The physical dev to enable DFS channels for 179 * 180 * Return: QDF_STATUS 181 */ 182 QDF_STATUS ucfg_reg_enable_dfs_channels(struct wlan_objmgr_pdev *pdev, 183 bool dfs_enable); 184 185 QDF_STATUS ucfg_reg_register_event_handler(uint8_t vdev_id, reg_event_cb cb, 186 void *arg); 187 QDF_STATUS ucfg_reg_unregister_event_handler(uint8_t vdev_id, reg_event_cb cb, 188 void *arg); 189 QDF_STATUS ucfg_reg_init_handler(uint8_t pdev_id); 190 191 QDF_STATUS ucfg_reg_program_default_cc(struct wlan_objmgr_pdev *pdev, 192 uint16_t regdmn); 193 194 /** 195 * ucfg_reg_program_cc() - Program user country code or regdomain 196 * @pdev: The physical dev to program country code or regdomain 197 * @rd: User country code or regdomain 198 * 199 * Return: QDF_STATUS 200 */ 201 QDF_STATUS ucfg_reg_program_cc(struct wlan_objmgr_pdev *pdev, 202 struct cc_regdmn_s *rd); 203 204 /** 205 * ucfg_reg_get_current_cc() - get current country code or regdomain 206 * @pdev: The physical dev to program country code or regdomain 207 * @rd: Pointer to country code or regdomain 208 * 209 * Return: QDF_STATUS 210 */ 211 QDF_STATUS ucfg_reg_get_current_cc(struct wlan_objmgr_pdev *pdev, 212 struct cc_regdmn_s *rd); 213 214 /** 215 * ucfg_reg_set_config_vars () - Set the config vars in reg component 216 * @psoc: psoc ptr 217 * @config_vars: config variables structure 218 * 219 * Return: QDF_STATUS 220 */ 221 QDF_STATUS ucfg_reg_set_config_vars(struct wlan_objmgr_psoc *psoc, 222 struct reg_config_vars config_vars); 223 224 /** 225 * ucfg_reg_get_current_chan_list () - get current channel list 226 * @pdev: pdev ptr 227 * @chan_list: channel list 228 * 229 * Return: QDF_STATUS 230 */ 231 QDF_STATUS ucfg_reg_get_current_chan_list(struct wlan_objmgr_pdev *pdev, 232 struct regulatory_channel *chan_list); 233 234 /** 235 * ucfg_reg_modify_chan_144() - Enable/Disable channel 144 236 * @pdev: pdev pointer 237 * @enable_chan_144: flag to disable/enable channel 144 238 * 239 * Return: Success or Failure 240 */ 241 QDF_STATUS ucfg_reg_modify_chan_144(struct wlan_objmgr_pdev *pdev, 242 bool enable_ch_144); 243 244 /** 245 * ucfg_reg_get_en_chan_144() - get en_chan_144 flag value 246 * @pdev: pdev pointer 247 * 248 * Return: en_chan_144 flag value 249 */ 250 bool ucfg_reg_get_en_chan_144(struct wlan_objmgr_pdev *pdev); 251 252 /** 253 * ucfg_reg_is_regdb_offloaded () - is regulatory database offloaded 254 * @psoc: psoc ptr 255 * 256 * Return: bool 257 */ 258 bool ucfg_reg_is_regdb_offloaded(struct wlan_objmgr_psoc *psoc); 259 260 /** 261 * ucfg_reg_program_mas_chan_list () - program master channel list 262 * @psoc: psoc ptr 263 * @reg_channels: regulatory channels 264 * @alpha2: country code 265 * @dfs_region: dfs region 266 * 267 * Return: void 268 */ 269 void ucfg_reg_program_mas_chan_list(struct wlan_objmgr_psoc *psoc, 270 struct regulatory_channel *reg_channels, 271 uint8_t *alpha2, 272 enum dfs_reg dfs_region); 273 274 /** 275 * ucfg_reg_get_regd_rules() - provides the reg domain rules info pointer 276 * @pdev: pdev ptr 277 * @reg_rules: regulatory rules 278 * 279 * Return: QDF_STATUS 280 */ 281 QDF_STATUS ucfg_reg_get_regd_rules(struct wlan_objmgr_pdev *pdev, 282 struct reg_rule_info *reg_rules); 283 284 /** 285 * ucfg_reg_register_chan_change_callback () - add chan change cbk 286 * @psoc: psoc ptr 287 * @cbk: callback 288 * @arg: argument 289 * 290 * Return: void 291 */ 292 void ucfg_reg_register_chan_change_callback(struct wlan_objmgr_psoc *psoc, 293 void *cbk, void *arg); 294 295 /** 296 * ucfg_reg_unregister_chan_change_callback () - remove chan change cbk 297 * @psoc: psoc ptr 298 * @cbk: callback 299 * 300 * Return: void 301 */ 302 void ucfg_reg_unregister_chan_change_callback(struct wlan_objmgr_psoc *psoc, 303 void *cbk); 304 305 #ifdef CONFIG_AFC_SUPPORT 306 /** 307 * ucfg_reg_register_afc_req_rx_callback () - add AFC request received callback 308 * @pdev: Pointer to pdev 309 * @cbf: Pointer to callback function 310 * @arg: Pointer to opaque argument 311 * 312 * Return: QDF_STATUS 313 */ 314 QDF_STATUS ucfg_reg_register_afc_req_rx_callback(struct wlan_objmgr_pdev *pdev, 315 afc_req_rx_evt_handler cbf, 316 void *arg); 317 318 /** 319 * ucfg_reg_unregister_afc_req_rx_callback () - remove AFC request received 320 * callback 321 * @pdev: Pointer to pdev 322 * @cbf: Pointer to callback function 323 * 324 * Return: QDF_STATUS 325 */ 326 QDF_STATUS ucfg_reg_unregister_afc_req_rx_callback(struct wlan_objmgr_pdev *pdev, 327 afc_req_rx_evt_handler cbf); 328 329 /** 330 * ucfg_reg_get_partial_afc_req_info() - Get the the frequency ranges and 331 * opclass + channel ranges. This is partial because in the AFC request there 332 * are a few more parameters: Longitude, Latitude a few other information 333 * @pdev: Pointer to PDEV object. 334 * @afc_req: Address of AFC request pointer. 335 * @req_id: AFC request ID. 336 * 337 * Return: QDF_STATUS_E_INVAL if unable to set and QDF_STATUS_SUCCESS is set. 338 */ 339 QDF_STATUS ucfg_reg_get_partial_afc_req_info( 340 struct wlan_objmgr_pdev *pdev, 341 struct wlan_afc_host_partial_request **afc_req, 342 uint64_t req_id); 343 #endif 344 345 /** 346 * ucfg_reg_get_cc_and_src () - get country code and src 347 * @psoc: psoc ptr 348 * @alpha2: country code alpha2 349 * 350 * Return: void 351 */ 352 enum country_src ucfg_reg_get_cc_and_src(struct wlan_objmgr_psoc *psoc, 353 uint8_t *alpha2); 354 355 /** 356 * ucfg_reg_unit_simulate_ch_avoid () - fake a ch avoid event 357 * @psoc: psoc ptr 358 * @ch_avoid: ch_avoid_ind_type ranges 359 * 360 * This function inject a ch_avoid event for unit test sap chan switch. 361 * 362 * Return: void 363 */ 364 void ucfg_reg_unit_simulate_ch_avoid(struct wlan_objmgr_psoc *psoc, 365 struct ch_avoid_ind_type *ch_avoid); 366 367 /** 368 * ucfg_reg_ch_avoid () - Send channel avoid cmd to regulatory 369 * @psoc: psoc ptr 370 * @ch_avoid: ch_avoid_ind_type ranges 371 * 372 * This function send channel avoid cmd to regulatory from os_if/upper layer 373 * 374 * Return: void 375 */ 376 void ucfg_reg_ch_avoid(struct wlan_objmgr_psoc *psoc, 377 struct ch_avoid_ind_type *ch_avoid); 378 379 #ifdef FEATURE_WLAN_CH_AVOID_EXT 380 /** 381 * ucfg_reg_ch_avoid_ext () - Send channel avoid extend cmd to regulatory 382 * @psoc: psoc ptr 383 * @ch_avoid: ch_avoid_ind_type ranges 384 * 385 * This function send channel avoid extend cmd to regulatory from 386 * os_if/upper layer 387 * 388 * Return: void 389 */ 390 void ucfg_reg_ch_avoid_ext(struct wlan_objmgr_psoc *psoc, 391 struct ch_avoid_ind_type *ch_avoid); 392 #endif 393 394 /** 395 * ucfg_reg_11d_vdev_delete_update() - update vdev delete to regulatory 396 * @vdev: vdev ptr 397 * 398 * Return: QDF_STATUS 399 */ 400 QDF_STATUS ucfg_reg_11d_vdev_delete_update(struct wlan_objmgr_vdev *vdev); 401 402 /** 403 * ucfg_reg_11d_vdev_created_update() - update vdev create to regulatory 404 * @vdev: vdev ptr 405 * 406 * Return: QDF_STATUS 407 */ 408 QDF_STATUS ucfg_reg_11d_vdev_created_update(struct wlan_objmgr_vdev *vdev); 409 410 /** 411 * ucfg_reg_get_hal_reg_cap() - return hal reg cap 412 * @psoc: psoc ptr 413 * 414 * Return: ptr to wlan_psoc_host_hal_reg_capabilities_ext 415 */ 416 struct wlan_psoc_host_hal_reg_capabilities_ext *ucfg_reg_get_hal_reg_cap( 417 struct wlan_objmgr_psoc *psoc); 418 419 /** 420 * ucfg_reg_set_hal_reg_cap() - update hal reg cap 421 * @psoc: psoc ptr 422 * @reg_cap: Regulatory cap array 423 * @phy_cnt: Number of phy 424 * 425 * Return: QDF_STATUS 426 */ 427 QDF_STATUS ucfg_reg_set_hal_reg_cap(struct wlan_objmgr_psoc *psoc, 428 struct wlan_psoc_host_hal_reg_capabilities_ext *reg_cap, 429 uint16_t phy_cnt); 430 431 /** 432 * ucfg_reg_update_hal_reg_cap() - update hal reg cap 433 * @psoc: psoc ptr 434 * @wireless_modes: 11AX wireless modes 435 * @phy_id: phy id 436 * 437 * Return: QDF_STATUS 438 */ 439 QDF_STATUS ucfg_reg_update_hal_reg_cap(struct wlan_objmgr_psoc *psoc, 440 uint64_t wireless_modes, uint8_t phy_id); 441 442 /** 443 * ucfg_set_ignore_fw_reg_offload_ind() - API to set ignore regdb offload ind 444 * @psoc: psoc ptr 445 * 446 * Return: QDF_STATUS 447 */ 448 QDF_STATUS ucfg_set_ignore_fw_reg_offload_ind(struct wlan_objmgr_psoc *psoc); 449 450 /** 451 * ucfg_reg_get_unii_5g_bitmap() - get unii_5g_bitmap value 452 * @pdev: pdev pointer 453 * @bitmap: Pointer to retrieve unii_5g_bitmap of enum reg_unii_band. 454 * 455 * Return: QDF_STATUS 456 */ 457 #ifdef DISABLE_UNII_SHARED_BANDS 458 QDF_STATUS 459 ucfg_reg_get_unii_5g_bitmap(struct wlan_objmgr_pdev *pdev, uint8_t *bitmap); 460 #else 461 static inline QDF_STATUS 462 ucfg_reg_get_unii_5g_bitmap(struct wlan_objmgr_pdev *pdev, uint8_t *bitmap) 463 { 464 *bitmap = 0; 465 return QDF_STATUS_SUCCESS; 466 } 467 #endif 468 469 #if defined(CONFIG_BAND_6GHZ) 470 /** 471 * ucfg_reg_get_cur_6g_ap_pwr_type() - Get the current 6G regulatory AP power 472 * type. 473 * @pdev: Pointer to PDEV object. 474 * @reg_6g_ap_pwr_type: The current regulatory 6G AP type ie VLPI/LPI/SP. 475 * 476 * Return: QDF_STATUS. 477 */ 478 QDF_STATUS 479 ucfg_reg_get_cur_6g_ap_pwr_type(struct wlan_objmgr_pdev *pdev, 480 enum reg_6g_ap_type *reg_cur_6g_ap_pwr_type); 481 482 /** 483 * ucfg_reg_set_cur_6g_ap_pwr_type() - Set the current 6G regulatory AP power 484 * type. 485 * @pdev: Pointer to PDEV object. 486 * @reg_6g_ap_pwr_type: Regulatory 6G AP type ie VLPI/LPI/SP. 487 * 488 * Return: QDF_STATUS_E_INVAL if unable to set and QDF_STATUS_SUCCESS is set. 489 */ 490 QDF_STATUS 491 ucfg_reg_set_cur_6g_ap_pwr_type(struct wlan_objmgr_pdev *pdev, 492 enum reg_6g_ap_type reg_cur_6g_ap_type); 493 #else 494 static inline QDF_STATUS 495 ucfg_reg_get_cur_6g_ap_pwr_type(struct wlan_objmgr_pdev *pdev, 496 enum reg_6g_ap_type *reg_cur_6g_ap_pwr_type) 497 { 498 *reg_cur_6g_ap_pwr_type = REG_INDOOR_AP; 499 return QDF_STATUS_E_NOSUPPORT; 500 } 501 502 static inline QDF_STATUS 503 ucfg_reg_set_cur_6g_ap_pwr_type(struct wlan_objmgr_pdev *pdev, 504 enum reg_6g_ap_type reg_cur_6g_ap_type) 505 { 506 return QDF_STATUS_E_NOSUPPORT; 507 } 508 #endif 509 510 #if defined(CONFIG_AFC_SUPPORT) && defined(CONFIG_BAND_6GHZ) 511 /** 512 * ucfg_reg_send_afc_resp_rx_ind() - Send AFC response received indication to 513 * the FW. 514 * @pdev: pdev ptr 515 * @afc_ind_obj: Pointer to hold AFC indication 516 * 517 * Return: QDF_STATUS_SUCCESS if the WMI command is sent or QDF_STATUS_E_FAILURE 518 * otherwise 519 */ 520 QDF_STATUS 521 ucfg_reg_send_afc_resp_rx_ind(struct wlan_objmgr_pdev *pdev, 522 struct reg_afc_resp_rx_ind_info *afc_ind_obj); 523 524 /** 525 * ucfg_reg_afc_start() - Start the AFC request from regulatory. This finally 526 * sends the request to registered callbacks 527 * @pdev: Pointer to pdev 528 * @req_id: The AFC request ID 529 * 530 * Return: QDF_STATUS 531 */ 532 QDF_STATUS ucfg_reg_afc_start(struct wlan_objmgr_pdev *pdev, uint64_t req_id); 533 #endif 534 #endif 535