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 * @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_MCL_REGDB 120 /** 121 * ucfg_reg_set_band() - Sets the band information for the PDEV 122 * @pdev: The physical pdev to set the band for 123 * @band: The set band parameter to configure for the pysical device 124 * 125 * Return: QDF_STATUS 126 */ 127 QDF_STATUS ucfg_reg_set_band(struct wlan_objmgr_pdev *pdev, 128 enum band_info band) 129 { 130 return reg_set_band(pdev, band); 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 QDF_STATUS ucfg_reg_get_curr_band(struct wlan_objmgr_pdev *pdev, 231 enum band_info *band) 232 { 233 return reg_get_curr_band(pdev, band); 234 235 } 236 237 void ucfg_reg_register_chan_change_callback(struct wlan_objmgr_psoc *psoc, 238 void *cbk, void *arg) 239 { 240 reg_register_chan_change_callback(psoc, (reg_chan_change_callback)cbk, 241 arg); 242 } 243 244 void ucfg_reg_unregister_chan_change_callback(struct wlan_objmgr_psoc *psoc, 245 void *cbk) 246 { 247 reg_unregister_chan_change_callback(psoc, 248 (reg_chan_change_callback)cbk); 249 } 250 251 enum country_src ucfg_reg_get_cc_and_src(struct wlan_objmgr_psoc *psoc, 252 uint8_t *alpha2) 253 { 254 return reg_get_cc_and_src(psoc, alpha2); 255 } 256 257 void ucfg_reg_unit_simulate_ch_avoid(struct wlan_objmgr_psoc *psoc, 258 struct ch_avoid_ind_type *ch_avoid) 259 { 260 reg_process_ch_avoid_event(psoc, ch_avoid); 261 } 262 263 QDF_STATUS ucfg_reg_11d_vdev_delete_update(struct wlan_objmgr_vdev *vdev) 264 { 265 return reg_11d_vdev_delete_update(vdev); 266 } 267 268 QDF_STATUS ucfg_reg_11d_vdev_created_update(struct wlan_objmgr_vdev *vdev) 269 { 270 return reg_11d_vdev_created_update(vdev); 271 } 272 273 struct wlan_psoc_host_hal_reg_capabilities_ext *ucfg_reg_get_hal_reg_cap( 274 struct wlan_objmgr_psoc *psoc) 275 { 276 return reg_get_hal_reg_cap(psoc); 277 } 278 qdf_export_symbol(ucfg_reg_get_hal_reg_cap); 279 280 QDF_STATUS ucfg_reg_set_hal_reg_cap(struct wlan_objmgr_psoc *psoc, 281 struct wlan_psoc_host_hal_reg_capabilities_ext *hal_reg_cap, 282 uint16_t phy_cnt) 283 284 { 285 return reg_set_hal_reg_cap(psoc, hal_reg_cap, phy_cnt); 286 } 287 qdf_export_symbol(ucfg_reg_set_hal_reg_cap); 288 289 #ifdef DISABLE_CHANNEL_LIST 290 /** 291 * ucfg_reg_cache_channel_state() - Cache the current state of the channles 292 * @pdev: The physical dev to cache the channels for 293 * @channel_list: List of the channels for which states needs to be cached 294 * @num_channels: Number of channels in the list 295 * 296 */ 297 void ucfg_reg_cache_channel_state(struct wlan_objmgr_pdev *pdev, 298 uint32_t *channel_list, uint32_t num_channels) 299 { 300 reg_cache_channel_state(pdev, channel_list, num_channels); 301 } 302 303 /** 304 * ucfg_reg_restore_cached_channels() - Cache the current state of the channles 305 * @pdev: The physical dev to cache the channels for 306 */ 307 void ucfg_reg_restore_cached_channels(struct wlan_objmgr_pdev *pdev) 308 { 309 reg_restore_cached_channels(pdev); 310 } 311 #endif 312