1 /* 2 * Copyright (c) 2017-2021 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 #ifdef CONFIG_AFC_SUPPORT 245 QDF_STATUS ucfg_reg_register_afc_req_rx_callback(struct wlan_objmgr_pdev *pdev, 246 afc_req_rx_evt_handler cbf, 247 void *arg) 248 { 249 return reg_register_afc_req_rx_callback(pdev, cbf, arg); 250 } 251 252 qdf_export_symbol(ucfg_reg_register_afc_req_rx_callback); 253 254 QDF_STATUS ucfg_reg_unregister_afc_req_rx_callback(struct wlan_objmgr_pdev *pdev, 255 afc_req_rx_evt_handler cbf) 256 { 257 return reg_unregister_afc_req_rx_callback(pdev, cbf); 258 } 259 260 QDF_STATUS ucfg_reg_get_partial_afc_req_info( 261 struct wlan_objmgr_pdev *pdev, 262 struct wlan_afc_host_partial_request **afc_req, 263 uint64_t req_id) 264 { 265 QDF_STATUS status; 266 267 status = reg_get_partial_afc_req_info(pdev, afc_req); 268 269 if (!afc_req) 270 return QDF_STATUS_E_NOMEM; 271 272 if (status == QDF_STATUS_SUCCESS) 273 reg_dmn_set_afc_req_id(*afc_req, req_id); 274 275 return status; 276 } 277 #endif 278 279 enum country_src ucfg_reg_get_cc_and_src(struct wlan_objmgr_psoc *psoc, 280 uint8_t *alpha2) 281 { 282 return reg_get_cc_and_src(psoc, alpha2); 283 } 284 285 void ucfg_reg_unit_simulate_ch_avoid(struct wlan_objmgr_psoc *psoc, 286 struct ch_avoid_ind_type *ch_avoid) 287 { 288 reg_process_ch_avoid_event(psoc, ch_avoid); 289 } 290 291 void ucfg_reg_ch_avoid(struct wlan_objmgr_psoc *psoc, 292 struct ch_avoid_ind_type *ch_avoid) 293 { 294 reg_process_ch_avoid_event(psoc, ch_avoid); 295 } 296 297 #ifdef FEATURE_WLAN_CH_AVOID_EXT 298 void ucfg_reg_ch_avoid_ext(struct wlan_objmgr_psoc *psoc, 299 struct ch_avoid_ind_type *ch_avoid) 300 { 301 reg_process_ch_avoid_ext_event(psoc, ch_avoid); 302 } 303 #endif 304 305 QDF_STATUS ucfg_reg_11d_vdev_delete_update(struct wlan_objmgr_vdev *vdev) 306 { 307 return reg_11d_vdev_delete_update(vdev); 308 } 309 310 QDF_STATUS ucfg_reg_11d_vdev_created_update(struct wlan_objmgr_vdev *vdev) 311 { 312 return reg_11d_vdev_created_update(vdev); 313 } 314 315 struct wlan_psoc_host_hal_reg_capabilities_ext *ucfg_reg_get_hal_reg_cap( 316 struct wlan_objmgr_psoc *psoc) 317 { 318 return reg_get_hal_reg_cap(psoc); 319 } 320 qdf_export_symbol(ucfg_reg_get_hal_reg_cap); 321 322 QDF_STATUS ucfg_reg_set_hal_reg_cap(struct wlan_objmgr_psoc *psoc, 323 struct wlan_psoc_host_hal_reg_capabilities_ext *hal_reg_cap, 324 uint16_t phy_cnt) 325 326 { 327 return reg_set_hal_reg_cap(psoc, hal_reg_cap, phy_cnt); 328 } 329 qdf_export_symbol(ucfg_reg_set_hal_reg_cap); 330 331 QDF_STATUS ucfg_reg_update_hal_reg_cap(struct wlan_objmgr_psoc *psoc, 332 uint64_t wireless_modes, uint8_t phy_id) 333 { 334 return reg_update_hal_reg_cap(psoc, wireless_modes, phy_id); 335 } 336 337 qdf_export_symbol(ucfg_reg_update_hal_reg_cap); 338 339 #ifdef DISABLE_CHANNEL_LIST 340 #ifdef CONFIG_CHAN_FREQ_API 341 /** 342 * ucfg_reg_cache_channel_freq_state() - Cache the current state of the channels 343 * based of the channel center frequency. 344 * @pdev: The physical dev to cache the channels for 345 * @channel_list: List of the channels for which states needs to be cached 346 * @num_channels: Number of channels in the list 347 * 348 */ 349 void ucfg_reg_cache_channel_freq_state(struct wlan_objmgr_pdev *pdev, 350 uint32_t *channel_list, 351 uint32_t num_channels) 352 { 353 reg_cache_channel_freq_state(pdev, channel_list, num_channels); 354 } 355 #endif /* CONFIG_CHAN_FREQ_API */ 356 357 void ucfg_reg_restore_cached_channels(struct wlan_objmgr_pdev *pdev) 358 { 359 reg_restore_cached_channels(pdev); 360 } 361 362 void ucfg_reg_disable_cached_channels(struct wlan_objmgr_pdev *pdev) 363 { 364 reg_disable_cached_channels(pdev); 365 } 366 367 #endif 368 369 QDF_STATUS ucfg_set_ignore_fw_reg_offload_ind(struct wlan_objmgr_psoc *psoc) 370 { 371 return reg_set_ignore_fw_reg_offload_ind(psoc); 372 } 373 374 #ifdef DISABLE_UNII_SHARED_BANDS 375 QDF_STATUS 376 ucfg_reg_get_unii_5g_bitmap(struct wlan_objmgr_pdev *pdev, uint8_t *bitmap) 377 { 378 return reg_get_unii_5g_bitmap(pdev, bitmap); 379 } 380 #endif 381 382 #if defined(CONFIG_BAND_6GHZ) 383 QDF_STATUS 384 ucfg_reg_set_cur_6g_ap_pwr_type(struct wlan_objmgr_pdev *pdev, 385 enum reg_6g_ap_type reg_cur_6g_ap_pwr_type) 386 { 387 return reg_set_cur_6g_ap_pwr_type(pdev, reg_cur_6g_ap_pwr_type); 388 } 389 390 QDF_STATUS 391 ucfg_reg_get_cur_6g_ap_pwr_type(struct wlan_objmgr_pdev *pdev, 392 enum reg_6g_ap_type *reg_cur_6g_ap_pwr_type) 393 { 394 return reg_get_cur_6g_ap_pwr_type(pdev, reg_cur_6g_ap_pwr_type); 395 } 396 397 qdf_export_symbol(ucfg_reg_get_cur_6g_ap_pwr_type); 398 #endif 399 400 #if defined(CONFIG_AFC_SUPPORT) && defined(CONFIG_BAND_6GHZ) 401 QDF_STATUS 402 ucfg_reg_send_afc_resp_rx_ind(struct wlan_objmgr_pdev *pdev, 403 struct reg_afc_resp_rx_ind_info *afc_ind_obj) 404 { 405 return reg_send_afc_cmd(pdev, afc_ind_obj); 406 } 407 408 QDF_STATUS 409 ucfg_reg_afc_start(struct wlan_objmgr_pdev *pdev, uint64_t req_id) 410 { 411 return reg_afc_start(pdev, req_id); 412 } 413 #endif 414