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 * 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 #include <reg_services_public_struct.h> 30 31 typedef QDF_STATUS (*reg_event_cb)(void *status_struct); 32 33 /** 34 * ucfg_reg_set_band() - Sets the band information for the PDEV 35 * @pdev: The physical pdev to set the band for 36 * @band_bitmap: The band bitmap parameter (over reg_wifi_band) to configure 37 * for the physical device 38 * 39 * Return: QDF_STATUS 40 */ 41 QDF_STATUS ucfg_reg_set_band(struct wlan_objmgr_pdev *pdev, 42 uint32_t band_bitmap); 43 44 /** 45 * ucfg_reg_get_band() - Gets the band information for the PDEV 46 * @pdev: The physical pdev to get the band for 47 * @band_bitmap: The band parameter of the physical device 48 * 49 * Return: QDF_STATUS 50 */ 51 QDF_STATUS ucfg_reg_get_band(struct wlan_objmgr_pdev *pdev, 52 uint32_t *band_bitmap); 53 54 /** 55 * ucfg_reg_notify_sap_event() - Notify regulatory domain for sap event 56 * @pdev: The physical dev to set the band for 57 * @sap_state: true for sap start else false 58 * 59 * Return: QDF_STATUS 60 */ 61 QDF_STATUS ucfg_reg_notify_sap_event(struct wlan_objmgr_pdev *pdev, 62 bool sap_state); 63 64 /** 65 * ucfg_reg_cache_channel_state() - Cache the current state of the channles 66 * @pdev: The physical dev to cache the channels for 67 * @channel_list: List of the channels for which states needs to be cached 68 * @num_channels: Number of channels in the list 69 * 70 * Return: QDF_STATUS 71 */ 72 #if defined(DISABLE_CHANNEL_LIST) && defined(CONFIG_CHAN_NUM_API) 73 void ucfg_reg_cache_channel_state(struct wlan_objmgr_pdev *pdev, 74 uint32_t *channel_list, 75 uint32_t num_channels); 76 #else 77 static inline 78 void ucfg_reg_cache_channel_state(struct wlan_objmgr_pdev *pdev, 79 uint32_t *channel_list, 80 uint32_t num_channels) 81 { 82 } 83 #endif /* CONFIG_CHAN_NUM_API */ 84 85 /** 86 * ucfg_reg_cache_channel_freq_state() - Cache the current state of the 87 * channels based on the channel center frequency. 88 * @pdev: Pointer to pdev. 89 * @channel_list: List of the channels for which states need to be cached. 90 * @num_channels: Number of channels in the list. 91 * 92 * Return: QDF_STATUS 93 */ 94 #if defined(DISABLE_CHANNEL_LIST) && defined(CONFIG_CHAN_FREQ_API) 95 void ucfg_reg_cache_channel_freq_state(struct wlan_objmgr_pdev *pdev, 96 uint32_t *channel_list, 97 uint32_t num_channels); 98 #else 99 static inline 100 void ucfg_reg_cache_channel_freq_state(struct wlan_objmgr_pdev *pdev, 101 uint32_t *channel_list, 102 uint32_t num_channels) 103 { 104 } 105 #endif /* CONFIG_CHAN_FREQ_API */ 106 107 /** 108 * ucfg_reg_restore_cached_channels() - Cache the current state of the channles 109 * @pdev: The physical dev to cache the channels for 110 * 111 * Return: QDF_STATUS 112 */ 113 #ifdef DISABLE_CHANNEL_LIST 114 void ucfg_reg_restore_cached_channels(struct wlan_objmgr_pdev *pdev); 115 #else 116 static inline 117 void ucfg_reg_restore_cached_channels(struct wlan_objmgr_pdev *pdev) 118 { 119 } 120 #endif 121 122 /** 123 * ucfg_reg_set_fcc_constraint() - apply fcc constraints on channels 12/13 124 * @pdev: The physical pdev to reduce tx power for 125 * 126 * This function adjusts the transmit power on channels 12 and 13, to comply 127 * with FCC regulations in the USA. 128 * 129 * Return: QDF_STATUS 130 */ 131 QDF_STATUS ucfg_reg_set_fcc_constraint(struct wlan_objmgr_pdev *pdev, 132 bool fcc_constraint); 133 134 /** 135 * ucfg_reg_get_default_country() - Get the default regulatory country 136 * @psoc: The physical SoC to get default country from 137 * @country_code: the buffer to populate the country code into 138 * 139 * Return: QDF_STATUS 140 */ 141 QDF_STATUS ucfg_reg_get_default_country(struct wlan_objmgr_psoc *psoc, 142 uint8_t *country_code); 143 144 /** 145 * ucfg_reg_get_current_country() - Get the current regulatory country 146 * @psoc: The physical SoC to get current country from 147 * @country_code: the buffer to populate the country code into 148 * 149 * Return: QDF_STATUS 150 */ 151 QDF_STATUS ucfg_reg_get_current_country(struct wlan_objmgr_psoc *psoc, 152 uint8_t *country_code); 153 /** 154 * ucfg_reg_set_default_country() - Set the default regulatory country 155 * @psoc: The physical SoC to set default country for 156 * @country_code: The country information to configure 157 * 158 * Return: QDF_STATUS 159 */ 160 QDF_STATUS ucfg_reg_set_default_country(struct wlan_objmgr_psoc *psoc, 161 uint8_t *country_code); 162 163 /** 164 * ucfg_reg_set_country() - Set the current regulatory country 165 * @pdev: The physical dev to set current country for 166 * @country_code: The country information to configure 167 * 168 * Return: QDF_STATUS 169 */ 170 QDF_STATUS ucfg_reg_set_country(struct wlan_objmgr_pdev *dev, 171 uint8_t *country_code); 172 173 /** 174 * ucfg_reg_reset_country() - Reset the regulatory country to default 175 * @psoc: The physical SoC to reset country for 176 * 177 * Return: QDF_STATUS 178 */ 179 QDF_STATUS ucfg_reg_reset_country(struct wlan_objmgr_psoc *psoc); 180 181 /** 182 * ucfg_reg_enable_dfs_channels() - Enable the use of DFS channels 183 * @pdev: The physical dev to enable DFS channels for 184 * 185 * Return: QDF_STATUS 186 */ 187 QDF_STATUS ucfg_reg_enable_dfs_channels(struct wlan_objmgr_pdev *pdev, 188 bool dfs_enable); 189 190 QDF_STATUS ucfg_reg_register_event_handler(uint8_t vdev_id, reg_event_cb cb, 191 void *arg); 192 QDF_STATUS ucfg_reg_unregister_event_handler(uint8_t vdev_id, reg_event_cb cb, 193 void *arg); 194 QDF_STATUS ucfg_reg_init_handler(uint8_t pdev_id); 195 196 QDF_STATUS ucfg_reg_program_default_cc(struct wlan_objmgr_pdev *pdev, 197 uint16_t regdmn); 198 199 /** 200 * ucfg_reg_program_cc() - Program user country code or regdomain 201 * @pdev: The physical dev to program country code or regdomain 202 * @rd: User country code or regdomain 203 * 204 * Return: QDF_STATUS 205 */ 206 QDF_STATUS ucfg_reg_program_cc(struct wlan_objmgr_pdev *pdev, 207 struct cc_regdmn_s *rd); 208 209 /** 210 * ucfg_reg_get_current_cc() - get current country code or regdomain 211 * @pdev: The physical dev to program country code or regdomain 212 * @rd: Pointer to country code or regdomain 213 * 214 * Return: QDF_STATUS 215 */ 216 QDF_STATUS ucfg_reg_get_current_cc(struct wlan_objmgr_pdev *pdev, 217 struct cc_regdmn_s *rd); 218 219 /** 220 * ucfg_reg_set_config_vars () - Set the config vars in reg component 221 * @psoc: psoc ptr 222 * @config_vars: config variables structure 223 * 224 * Return: QDF_STATUS 225 */ 226 QDF_STATUS ucfg_reg_set_config_vars(struct wlan_objmgr_psoc *psoc, 227 struct reg_config_vars config_vars); 228 229 /** 230 * ucfg_reg_get_current_chan_list () - get current channel list 231 * @pdev: pdev ptr 232 * @chan_list: channel list 233 * 234 * Return: QDF_STATUS 235 */ 236 QDF_STATUS ucfg_reg_get_current_chan_list(struct wlan_objmgr_pdev *pdev, 237 struct regulatory_channel *chan_list); 238 239 /** 240 * ucfg_reg_modify_chan_144() - Enable/Disable channel 144 241 * @pdev: pdev pointer 242 * @enable_chan_144: flag to disable/enable channel 144 243 * 244 * Return: Success or Failure 245 */ 246 QDF_STATUS ucfg_reg_modify_chan_144(struct wlan_objmgr_pdev *pdev, 247 bool enable_ch_144); 248 249 /** 250 * ucfg_reg_get_en_chan_144() - get en_chan_144 flag value 251 * @pdev: pdev pointer 252 * 253 * Return: en_chan_144 flag value 254 */ 255 bool ucfg_reg_get_en_chan_144(struct wlan_objmgr_pdev *pdev); 256 257 /** 258 * ucfg_reg_is_regdb_offloaded () - is regulatory database offloaded 259 * @psoc: psoc ptr 260 * 261 * Return: bool 262 */ 263 bool ucfg_reg_is_regdb_offloaded(struct wlan_objmgr_psoc *psoc); 264 265 /** 266 * ucfg_reg_program_mas_chan_list () - program master channel list 267 * @psoc: psoc ptr 268 * @reg_channels: regulatory channels 269 * @alpha2: country code 270 * @dfs_region: dfs region 271 * 272 * Return: void 273 */ 274 void ucfg_reg_program_mas_chan_list(struct wlan_objmgr_psoc *psoc, 275 struct regulatory_channel *reg_channels, 276 uint8_t *alpha2, 277 enum dfs_reg dfs_region); 278 279 /** 280 * ucfg_reg_get_regd_rules() - provides the reg domain rules info pointer 281 * @pdev: pdev ptr 282 * @reg_rules: regulatory rules 283 * 284 * Return: QDF_STATUS 285 */ 286 QDF_STATUS ucfg_reg_get_regd_rules(struct wlan_objmgr_pdev *pdev, 287 struct reg_rule_info *reg_rules); 288 289 /** 290 * ucfg_reg_register_chan_change_callback () - add chan change cbk 291 * @psoc: psoc ptr 292 * @cbk: callback 293 * @arg: argument 294 * 295 * Return: void 296 */ 297 void ucfg_reg_register_chan_change_callback(struct wlan_objmgr_psoc *psoc, 298 void *cbk, void *arg); 299 300 /** 301 * ucfg_reg_unregister_chan_change_callback () - remove chan change cbk 302 * @psoc: psoc ptr 303 * @cbk: callback 304 * 305 * Return: void 306 */ 307 void ucfg_reg_unregister_chan_change_callback(struct wlan_objmgr_psoc *psoc, 308 void *cbk); 309 310 /** 311 * ucfg_reg_get_cc_and_src () - get country code and src 312 * @psoc: psoc ptr 313 * @alpha2: country code alpha2 314 * 315 * Return: void 316 */ 317 enum country_src ucfg_reg_get_cc_and_src(struct wlan_objmgr_psoc *psoc, 318 uint8_t *alpha2); 319 320 /** 321 * ucfg_reg_unit_simulate_ch_avoid () - fake a ch avoid event 322 * @psoc: psoc ptr 323 * @ch_avoid: ch_avoid_ind_type ranges 324 * 325 * This function inject a ch_avoid event for unit test sap chan switch. 326 * 327 * Return: void 328 */ 329 void ucfg_reg_unit_simulate_ch_avoid(struct wlan_objmgr_psoc *psoc, 330 struct ch_avoid_ind_type *ch_avoid); 331 332 /** 333 * ucfg_reg_11d_vdev_delete_update() - update vdev delete to regulatory 334 * @vdev: vdev ptr 335 * 336 * Return: QDF_STATUS 337 */ 338 QDF_STATUS ucfg_reg_11d_vdev_delete_update(struct wlan_objmgr_vdev *vdev); 339 340 /** 341 * ucfg_reg_11d_vdev_created_update() - update vdev create to regulatory 342 * @vdev: vdev ptr 343 * 344 * Return: QDF_STATUS 345 */ 346 QDF_STATUS ucfg_reg_11d_vdev_created_update(struct wlan_objmgr_vdev *vdev); 347 348 /** 349 * ucfg_reg_get_hal_reg_cap() - return hal reg cap 350 * @psoc: psoc ptr 351 * 352 * Return: ptr to wlan_psoc_host_hal_reg_capabilities_ext 353 */ 354 struct wlan_psoc_host_hal_reg_capabilities_ext *ucfg_reg_get_hal_reg_cap( 355 struct wlan_objmgr_psoc *psoc); 356 357 /** 358 * ucfg_reg_set_hal_reg_cap() - update hal reg cap 359 * @psoc: psoc ptr 360 * @reg_cap: Regulatory cap array 361 * @phy_cnt: Number of phy 362 * 363 * Return: QDF_STATUS 364 */ 365 QDF_STATUS ucfg_reg_set_hal_reg_cap(struct wlan_objmgr_psoc *psoc, 366 struct wlan_psoc_host_hal_reg_capabilities_ext *reg_cap, 367 uint16_t phy_cnt); 368 369 /** 370 * ucfg_reg_update_hal_reg_cap() - update hal reg cap 371 * @psoc: psoc ptr 372 * @wireless_modes: 11AX wireless modes 373 * @phy_id: phy id 374 * 375 * Return: QDF_STATUS 376 */ 377 QDF_STATUS ucfg_reg_update_hal_reg_cap(struct wlan_objmgr_psoc *psoc, 378 uint32_t wireless_modes, uint8_t phy_id); 379 380 /** 381 * ucfg_set_ignore_fw_reg_offload_ind() - API to set ignore regdb offload ind 382 * @psoc: psoc ptr 383 * 384 * Return: QDF_STATUS 385 */ 386 QDF_STATUS ucfg_set_ignore_fw_reg_offload_ind(struct wlan_objmgr_psoc *psoc); 387 388 /** 389 * ucfg_reg_get_unii_5g_bitmap() - get unii_5g_bitmap value 390 * @pdev: pdev pointer 391 * @bitmap: Pointer to retrieve unii_5g_bitmap of enum reg_unii_band. 392 * 393 * Return: QDF_STATUS 394 */ 395 #ifdef DISABLE_UNII_SHARED_BANDS 396 QDF_STATUS 397 ucfg_reg_get_unii_5g_bitmap(struct wlan_objmgr_pdev *pdev, uint8_t *bitmap); 398 #else 399 static inline QDF_STATUS 400 ucfg_reg_get_unii_5g_bitmap(struct wlan_objmgr_pdev *pdev, uint8_t *bitmap) 401 { 402 *bitmap = 0; 403 return QDF_STATUS_SUCCESS; 404 } 405 #endif 406 407 #endif 408