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