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_req_ucfg_api.c 22 * @brief contains regulatory user config interface definations 23 */ 24 25 #include <wlan_objmgr_vdev_obj.h> 26 #include <wlan_reg_ucfg_api.h> 27 #include <wlan_objmgr_psoc_obj.h> 28 #include <../../core/src/reg_priv_objs.h> 29 #include <../../core/src/reg_utils.h> 30 #include <../../core/src/reg_services_common.h> 31 #include <../../core/src/reg_lte.h> 32 #include <../../core/src/reg_offload_11d_scan.h> 33 #include <../../core/src/reg_build_chan_list.h> 34 #include <../../core/src/reg_callbacks.h> 35 #include <qdf_module.h> 36 37 QDF_STATUS ucfg_reg_register_event_handler(uint8_t vdev_id, reg_event_cb cb, 38 void *arg) 39 { 40 /* Register a event cb handler */ 41 return QDF_STATUS_SUCCESS; 42 } 43 44 QDF_STATUS ucfg_reg_unregister_event_handler(uint8_t vdev_id, reg_event_cb cb, 45 void *arg) 46 { 47 /* unregister a event cb handler */ 48 return QDF_STATUS_SUCCESS; 49 } 50 51 QDF_STATUS ucfg_reg_init_handler(uint8_t pdev_id) 52 { 53 /* regulatory initialization handler */ 54 return QDF_STATUS_SUCCESS; 55 } 56 57 QDF_STATUS ucfg_reg_get_current_chan_list(struct wlan_objmgr_pdev *pdev, 58 struct regulatory_channel *chan_list) 59 { 60 return reg_get_current_chan_list(pdev, chan_list); 61 } 62 63 qdf_export_symbol(ucfg_reg_get_current_chan_list); 64 65 QDF_STATUS ucfg_reg_modify_chan_144(struct wlan_objmgr_pdev *pdev, 66 bool enable_ch_144) 67 { 68 return reg_modify_chan_144(pdev, enable_ch_144); 69 } 70 71 bool ucfg_reg_get_en_chan_144(struct wlan_objmgr_pdev *pdev) 72 { 73 return reg_get_en_chan_144(pdev); 74 } 75 76 QDF_STATUS ucfg_reg_set_config_vars(struct wlan_objmgr_psoc *psoc, 77 struct reg_config_vars config_vars) 78 { 79 return reg_set_config_vars(psoc, config_vars); 80 } 81 82 bool ucfg_reg_is_regdb_offloaded(struct wlan_objmgr_psoc *psoc) 83 { 84 return reg_is_regdb_offloaded(psoc); 85 } 86 87 void ucfg_reg_program_mas_chan_list(struct wlan_objmgr_psoc *psoc, 88 struct regulatory_channel *reg_channels, 89 uint8_t *alpha2, 90 enum dfs_reg dfs_region) 91 { 92 reg_program_mas_chan_list(psoc, reg_channels, alpha2, dfs_region); 93 } 94 95 QDF_STATUS ucfg_reg_get_regd_rules(struct wlan_objmgr_pdev *pdev, 96 struct reg_rule_info *reg_rules) 97 { 98 return reg_get_regd_rules(pdev, reg_rules); 99 } 100 101 QDF_STATUS ucfg_reg_program_default_cc(struct wlan_objmgr_pdev *pdev, 102 uint16_t regdmn) 103 { 104 return reg_program_default_cc(pdev, regdmn); 105 } 106 107 QDF_STATUS ucfg_reg_program_cc(struct wlan_objmgr_pdev *pdev, 108 struct cc_regdmn_s *rd) 109 { 110 return reg_program_chan_list(pdev, rd); 111 } 112 113 QDF_STATUS ucfg_reg_get_current_cc(struct wlan_objmgr_pdev *pdev, 114 struct cc_regdmn_s *rd) 115 { 116 return reg_get_current_cc(pdev, rd); 117 } 118 119 #ifdef CONFIG_REG_CLIENT 120 121 QDF_STATUS ucfg_reg_set_band(struct wlan_objmgr_pdev *pdev, 122 uint32_t band_bitmap) 123 { 124 return reg_set_band(pdev, band_bitmap); 125 } 126 127 QDF_STATUS ucfg_reg_get_band(struct wlan_objmgr_pdev *pdev, 128 uint32_t *band_bitmap) 129 { 130 return reg_get_band(pdev, band_bitmap); 131 } 132 133 /** 134 * ucfg_reg_notify_sap_event() - Notify regulatory domain for sap event 135 * @pdev: The physical dev to set the band for 136 * @sap_state: true for sap start else false 137 * 138 * Return: QDF_STATUS 139 */ 140 QDF_STATUS ucfg_reg_notify_sap_event(struct wlan_objmgr_pdev *pdev, 141 bool sap_state) 142 { 143 return reg_notify_sap_event(pdev, sap_state); 144 } 145 146 /** 147 * ucfg_reg_set_fcc_constraint() - apply fcc constraints on channels 12/13 148 * @pdev: The physical pdev to reduce tx power for 149 * 150 * This function adjusts the transmit power on channels 12 and 13, to comply 151 * with FCC regulations in the USA. 152 * 153 * Return: QDF_STATUS 154 */ 155 QDF_STATUS ucfg_reg_set_fcc_constraint(struct wlan_objmgr_pdev *pdev, 156 bool fcc_constraint) 157 { 158 return reg_set_fcc_constraint(pdev, fcc_constraint); 159 } 160 161 QDF_STATUS ucfg_reg_get_current_country(struct wlan_objmgr_psoc *psoc, 162 uint8_t *country_code) 163 { 164 return reg_read_current_country(psoc, country_code); 165 } 166 167 /** 168 * ucfg_reg_set_default_country() - Set the default regulatory country 169 * @psoc: The physical SoC to set default country for 170 * @country: The country information to configure 171 * 172 * Return: QDF_STATUS 173 */ 174 QDF_STATUS ucfg_reg_set_default_country(struct wlan_objmgr_psoc *psoc, 175 uint8_t *country) 176 { 177 return reg_set_default_country(psoc, country); 178 } 179 #endif 180 181 /** 182 * ucfg_reg_get_default_country() - Get the default regulatory country 183 * @psoc: The physical SoC to get default country from 184 * @country_code: the buffer to populate the country code into 185 * 186 * Return: QDF_STATUS 187 */ 188 QDF_STATUS ucfg_reg_get_default_country(struct wlan_objmgr_psoc *psoc, 189 uint8_t *country_code) 190 { 191 return reg_read_default_country(psoc, country_code); 192 } 193 194 /** 195 * ucfg_reg_set_country() - Set the current regulatory country 196 * @pdev: The physical dev to set current country for 197 * @country: The country information to configure 198 * 199 * Return: QDF_STATUS 200 */ 201 QDF_STATUS ucfg_reg_set_country(struct wlan_objmgr_pdev *pdev, 202 uint8_t *country) 203 { 204 return reg_set_country(pdev, country); 205 } 206 207 /** 208 * ucfg_reg_reset_country() - Reset the regulatory country to default 209 * @psoc: The physical SoC to reset country for 210 * 211 * Return: QDF_STATUS 212 */ 213 QDF_STATUS ucfg_reg_reset_country(struct wlan_objmgr_psoc *psoc) 214 { 215 return reg_reset_country(psoc); 216 } 217 218 /** 219 * ucfg_reg_enable_dfs_channels() - Enable the use of DFS channels 220 * @pdev: The physical dev to enable DFS channels for 221 * 222 * Return: QDF_STATUS 223 */ 224 QDF_STATUS ucfg_reg_enable_dfs_channels(struct wlan_objmgr_pdev *pdev, 225 bool dfs_enable) 226 { 227 return reg_enable_dfs_channels(pdev, dfs_enable); 228 } 229 230 void ucfg_reg_register_chan_change_callback(struct wlan_objmgr_psoc *psoc, 231 void *cbk, void *arg) 232 { 233 reg_register_chan_change_callback(psoc, (reg_chan_change_callback)cbk, 234 arg); 235 } 236 237 void ucfg_reg_unregister_chan_change_callback(struct wlan_objmgr_psoc *psoc, 238 void *cbk) 239 { 240 reg_unregister_chan_change_callback(psoc, 241 (reg_chan_change_callback)cbk); 242 } 243 244 enum country_src ucfg_reg_get_cc_and_src(struct wlan_objmgr_psoc *psoc, 245 uint8_t *alpha2) 246 { 247 return reg_get_cc_and_src(psoc, alpha2); 248 } 249 250 void ucfg_reg_unit_simulate_ch_avoid(struct wlan_objmgr_psoc *psoc, 251 struct ch_avoid_ind_type *ch_avoid) 252 { 253 reg_process_ch_avoid_event(psoc, ch_avoid); 254 } 255 256 QDF_STATUS ucfg_reg_11d_vdev_delete_update(struct wlan_objmgr_vdev *vdev) 257 { 258 return reg_11d_vdev_delete_update(vdev); 259 } 260 261 QDF_STATUS ucfg_reg_11d_vdev_created_update(struct wlan_objmgr_vdev *vdev) 262 { 263 return reg_11d_vdev_created_update(vdev); 264 } 265 266 struct wlan_psoc_host_hal_reg_capabilities_ext *ucfg_reg_get_hal_reg_cap( 267 struct wlan_objmgr_psoc *psoc) 268 { 269 return reg_get_hal_reg_cap(psoc); 270 } 271 qdf_export_symbol(ucfg_reg_get_hal_reg_cap); 272 273 QDF_STATUS ucfg_reg_set_hal_reg_cap(struct wlan_objmgr_psoc *psoc, 274 struct wlan_psoc_host_hal_reg_capabilities_ext *hal_reg_cap, 275 uint16_t phy_cnt) 276 277 { 278 return reg_set_hal_reg_cap(psoc, hal_reg_cap, phy_cnt); 279 } 280 qdf_export_symbol(ucfg_reg_set_hal_reg_cap); 281 282 QDF_STATUS ucfg_reg_update_hal_reg_cap(struct wlan_objmgr_psoc *psoc, 283 uint32_t wireless_modes, uint8_t phy_id) 284 { 285 return reg_update_hal_reg_cap(psoc, wireless_modes, phy_id); 286 } 287 288 qdf_export_symbol(ucfg_reg_update_hal_reg_cap); 289 290 #ifdef DISABLE_CHANNEL_LIST 291 #ifdef CONFIG_CHAN_FREQ_API 292 /** 293 * ucfg_reg_cache_channel_freq_state() - Cache the current state of the channels 294 * based of the channel center frequency. 295 * @pdev: The physical dev to cache the channels for 296 * @channel_list: List of the channels for which states needs to be cached 297 * @num_channels: Number of channels in the list 298 * 299 */ 300 void ucfg_reg_cache_channel_freq_state(struct wlan_objmgr_pdev *pdev, 301 uint32_t *channel_list, 302 uint32_t num_channels) 303 { 304 reg_cache_channel_freq_state(pdev, channel_list, num_channels); 305 } 306 #endif /* CONFIG_CHAN_FREQ_API */ 307 308 #ifdef CONFIG_CHAN_NUM_API 309 /** 310 * ucfg_reg_cache_channel_state() - Cache the current state of the channles 311 * @pdev: The physical dev to cache the channels for 312 * @channel_list: List of the channels for which states needs to be cached 313 * @num_channels: Number of channels in the list 314 * 315 */ 316 void ucfg_reg_cache_channel_state(struct wlan_objmgr_pdev *pdev, 317 uint32_t *channel_list, uint32_t num_channels) 318 { 319 reg_cache_channel_state(pdev, channel_list, num_channels); 320 } 321 #endif /* CONFIG_CHAN_NUM_API */ 322 323 /** 324 * ucfg_reg_restore_cached_channels() - Cache the current state of the channles 325 * @pdev: The physical dev to cache the channels for 326 */ 327 void ucfg_reg_restore_cached_channels(struct wlan_objmgr_pdev *pdev) 328 { 329 reg_restore_cached_channels(pdev); 330 } 331 #endif 332 333 QDF_STATUS ucfg_set_ignore_fw_reg_offload_ind(struct wlan_objmgr_psoc *psoc) 334 { 335 return reg_set_ignore_fw_reg_offload_ind(psoc); 336 } 337 338 #ifdef DISABLE_UNII_SHARED_BANDS 339 QDF_STATUS 340 ucfg_reg_get_unii_5g_bitmap(struct wlan_objmgr_pdev *pdev, uint8_t *bitmap) 341 { 342 return reg_get_unii_5g_bitmap(pdev, bitmap); 343 } 344 #endif 345