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 void ucfg_reg_ch_avoid(struct wlan_objmgr_psoc *psoc, 257 struct ch_avoid_ind_type *ch_avoid) 258 { 259 reg_process_ch_avoid_event(psoc, ch_avoid); 260 } 261 262 QDF_STATUS ucfg_reg_11d_vdev_delete_update(struct wlan_objmgr_vdev *vdev) 263 { 264 return reg_11d_vdev_delete_update(vdev); 265 } 266 267 QDF_STATUS ucfg_reg_11d_vdev_created_update(struct wlan_objmgr_vdev *vdev) 268 { 269 return reg_11d_vdev_created_update(vdev); 270 } 271 272 struct wlan_psoc_host_hal_reg_capabilities_ext *ucfg_reg_get_hal_reg_cap( 273 struct wlan_objmgr_psoc *psoc) 274 { 275 return reg_get_hal_reg_cap(psoc); 276 } 277 qdf_export_symbol(ucfg_reg_get_hal_reg_cap); 278 279 QDF_STATUS ucfg_reg_set_hal_reg_cap(struct wlan_objmgr_psoc *psoc, 280 struct wlan_psoc_host_hal_reg_capabilities_ext *hal_reg_cap, 281 uint16_t phy_cnt) 282 283 { 284 return reg_set_hal_reg_cap(psoc, hal_reg_cap, phy_cnt); 285 } 286 qdf_export_symbol(ucfg_reg_set_hal_reg_cap); 287 288 QDF_STATUS ucfg_reg_update_hal_reg_cap(struct wlan_objmgr_psoc *psoc, 289 uint32_t wireless_modes, uint8_t phy_id) 290 { 291 return reg_update_hal_reg_cap(psoc, wireless_modes, phy_id); 292 } 293 294 qdf_export_symbol(ucfg_reg_update_hal_reg_cap); 295 296 #ifdef DISABLE_CHANNEL_LIST 297 #ifdef CONFIG_CHAN_FREQ_API 298 /** 299 * ucfg_reg_cache_channel_freq_state() - Cache the current state of the channels 300 * based of the channel center frequency. 301 * @pdev: The physical dev to cache the channels for 302 * @channel_list: List of the channels for which states needs to be cached 303 * @num_channels: Number of channels in the list 304 * 305 */ 306 void ucfg_reg_cache_channel_freq_state(struct wlan_objmgr_pdev *pdev, 307 uint32_t *channel_list, 308 uint32_t num_channels) 309 { 310 reg_cache_channel_freq_state(pdev, channel_list, num_channels); 311 } 312 #endif /* CONFIG_CHAN_FREQ_API */ 313 314 #ifdef CONFIG_CHAN_NUM_API 315 /** 316 * ucfg_reg_cache_channel_state() - Cache the current state of the channles 317 * @pdev: The physical dev to cache the channels for 318 * @channel_list: List of the channels for which states needs to be cached 319 * @num_channels: Number of channels in the list 320 * 321 */ 322 void ucfg_reg_cache_channel_state(struct wlan_objmgr_pdev *pdev, 323 uint32_t *channel_list, uint32_t num_channels) 324 { 325 reg_cache_channel_state(pdev, channel_list, num_channels); 326 } 327 #endif /* CONFIG_CHAN_NUM_API */ 328 329 /** 330 * ucfg_reg_restore_cached_channels() - Cache the current state of the channles 331 * @pdev: The physical dev to cache the channels for 332 */ 333 void ucfg_reg_restore_cached_channels(struct wlan_objmgr_pdev *pdev) 334 { 335 reg_restore_cached_channels(pdev); 336 } 337 #endif 338 339 QDF_STATUS ucfg_set_ignore_fw_reg_offload_ind(struct wlan_objmgr_psoc *psoc) 340 { 341 return reg_set_ignore_fw_reg_offload_ind(psoc); 342 } 343 344 #ifdef DISABLE_UNII_SHARED_BANDS 345 QDF_STATUS 346 ucfg_reg_get_unii_5g_bitmap(struct wlan_objmgr_pdev *pdev, uint8_t *bitmap) 347 { 348 return reg_get_unii_5g_bitmap(pdev, bitmap); 349 } 350 #endif 351 352 #if defined(CONFIG_BAND_6GHZ) 353 QDF_STATUS 354 ucfg_reg_set_cur_6g_ap_pwr_type(struct wlan_objmgr_pdev *pdev, 355 enum reg_6g_ap_type reg_cur_6g_ap_pwr_type) 356 { 357 return reg_set_cur_6g_ap_pwr_type(pdev, reg_cur_6g_ap_pwr_type); 358 } 359 360 QDF_STATUS 361 ucfg_reg_get_cur_6g_ap_pwr_type(struct wlan_objmgr_pdev *pdev, 362 enum reg_6g_ap_type *reg_cur_6g_ap_pwr_type) 363 { 364 return reg_get_cur_6g_ap_pwr_type(pdev, reg_cur_6g_ap_pwr_type); 365 } 366 #endif 367