1 /* 2 * Copyright (c) 2017-2021 The Linux Foundation. All rights reserved. 3 * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. 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: reg_priv_objs.h 22 * This file contains regulatory component private data structures. 23 */ 24 25 #ifndef __REG_PRIV_OBJS_H 26 #define __REG_PRIV_OBJS_H 27 28 #include <wlan_scan_public_structs.h> 29 #ifdef CONFIG_AFC_SUPPORT 30 #include "reg_services_common.h" 31 #endif 32 #include <wlan_objmgr_psoc_obj.h> 33 34 #define reg_alert(params...) \ 35 QDF_TRACE_FATAL(QDF_MODULE_ID_REGULATORY, params) 36 #define reg_err(params...) \ 37 QDF_TRACE_ERROR(QDF_MODULE_ID_REGULATORY, params) 38 #define reg_err_rl(params...) \ 39 QDF_TRACE_ERROR_RL(QDF_MODULE_ID_REGULATORY, params) 40 #define reg_warn(params...) \ 41 QDF_TRACE_WARN(QDF_MODULE_ID_REGULATORY, params) 42 #define reg_notice(params...) \ 43 QDF_TRACE_INFO(QDF_MODULE_ID_REGULATORY, params) 44 #define reg_info(params...) \ 45 QDF_TRACE_INFO(QDF_MODULE_ID_REGULATORY, params) 46 #define reg_debug(params...) \ 47 QDF_TRACE_DEBUG(QDF_MODULE_ID_REGULATORY, params) 48 #define reg_debug_rl(params...) \ 49 QDF_TRACE_DEBUG_RL(QDF_MODULE_ID_REGULATORY, params) 50 51 #define reg_nofl_alert(params...) \ 52 QDF_TRACE_FATAL_NO_FL(QDF_MODULE_ID_REGULATORY, params) 53 #define reg_nofl_err(params...) \ 54 QDF_TRACE_ERROR_NO_FL(QDF_MODULE_ID_REGULATORY, params) 55 #define reg_nofl_warn(params...) \ 56 QDF_TRACE_WARN_NO_FL(QDF_MODULE_ID_REGULATORY, params) 57 #define reg_nofl_info(params...) \ 58 QDF_TRACE_INFO_NO_FL(QDF_MODULE_ID_REGULATORY, params) 59 #define reg_nofl_debug(params...) \ 60 QDF_TRACE_DEBUG_NO_FL(QDF_MODULE_ID_REGULATORY, params) 61 62 /** 63 * typedef reg_chan_change_callback() - Regulatory channel change callback 64 * @psoc: Pointer to psoc 65 * @pdev: Pointer to pdev 66 * @chan_list: Pointer to regulatory channel list 67 * @avoid_freq_ind: Pointer to avoid frequencies 68 * @arg: list of arguments 69 */ 70 typedef void (*reg_chan_change_callback)( 71 struct wlan_objmgr_psoc *psoc, 72 struct wlan_objmgr_pdev *pdev, 73 struct regulatory_channel *chan_list, 74 struct avoid_freq_ind_data *avoid_freq_ind, 75 void *arg); 76 77 /** 78 * struct chan_change_cbk_entry - Channel change callback entry 79 * @cbk: Callback 80 * @arg: Arguments 81 */ 82 struct chan_change_cbk_entry { 83 reg_chan_change_callback cbk; 84 void *arg; 85 }; 86 87 /** 88 * struct wlan_regulatory_psoc_priv_obj - wlan regulatory psoc private object 89 * @mas_chan_params: master channel parameters list 90 * @chan_list_recvd: whether channel list has been received 91 * @new_user_ctry_pending: In this array, element[phy_id] is true if any user 92 * country update is pending for pdev (phy_id), used in case of MCL. 93 * @new_init_ctry_pending: In this array, element[phy_id] is true if any user 94 * country update is pending for pdev (phy_id), used in case of WIN. 95 * @new_11d_ctry_pending: In this array, element[phy_id] is true if any 11d 96 * country update is pending for pdev (phy_id). 97 * @world_country_pending: In this array, element[phy_id] is true if any world 98 * country update is pending for pdev (phy_id). 99 * @band_capability: bitmap of bands enabled, using enum reg_wifi_band as the 100 * bit position value 101 * @ignore_fw_reg_offload_ind: Ignore FW reg offload indication 102 * @six_ghz_supported: whether 6ghz is supported 103 * @five_dot_nine_ghz_supported: whether 5.9ghz is supported 104 * (service bit WMI_SERVICE_5_DOT_9GHZ_SUPPORT) 105 * @enable_5dot9_ghz_chan_in_master_mode: 5.9 GHz channel support in 106 * master mode (ini fcc_5dot9_ghz_chan_in_master_mode) 107 * @retain_nol_across_regdmn_update: Retain the NOL list across the regdomain 108 * changes. 109 * @domain_code_6g_ap: domain code for 6G AP 110 * @domain_code_6g_client: domain code for 6G client 111 * @is_ext_tpc_supported: Whether FW supports new WMI command for TPC 112 * @is_lower_6g_edge_ch_supported: whether lower 6ghz edge channel 5935MHz is 113 * supported 114 * @is_upper_6g_edge_ch_disabled: whether upper 6ghz edge channel 7115MHz is 115 * disabled 116 * @ch_avoid_ext_ind: whether need to update extended channel frequency list 117 * @avoid_freq_ext_list: the extended avoid channel frequency list 118 * @coex_unsafe_chan_nb_user_prefer: Honor coex unsafe chan cmd from firmware or 119 * userspace 120 * @coex_unsafe_chan_reg_disable: To disable reg channels for received coex 121 * unsafe channels list 122 * @reg_afc_dev_type: AFC device deployment type from BDF 123 * @sta_sap_scc_on_indoor_channel: Value of sap+sta scc on indoor support 124 * @fcc_rules_ptr : Value of fcc channel frequency and tx_power list received 125 * from firmware 126 */ 127 struct wlan_regulatory_psoc_priv_obj { 128 struct mas_chan_params mas_chan_params[PSOC_MAX_PHY_REG_CAP]; 129 bool chan_list_recvd[PSOC_MAX_PHY_REG_CAP]; 130 bool offload_enabled; 131 bool six_ghz_supported; 132 bool five_dot_nine_ghz_supported; 133 uint8_t num_phy; 134 char cur_country[REG_ALPHA2_LEN + 1]; 135 char def_country[REG_ALPHA2_LEN + 1]; 136 uint16_t def_country_code; 137 uint16_t def_region_domain; 138 enum country_src cc_src; 139 struct wlan_objmgr_psoc *psoc_ptr; 140 bool new_user_ctry_pending[PSOC_MAX_PHY_REG_CAP]; 141 bool new_init_ctry_pending[PSOC_MAX_PHY_REG_CAP]; 142 bool new_11d_ctry_pending[PSOC_MAX_PHY_REG_CAP]; 143 bool world_country_pending[PSOC_MAX_PHY_REG_CAP]; 144 bool dfs_enabled; 145 uint32_t band_capability; 146 bool indoor_chan_enabled; 147 bool ignore_fw_reg_offload_ind; 148 bool enable_11d_supp_original; 149 bool enable_11d_supp; 150 bool is_11d_offloaded; 151 uint8_t vdev_id_for_11d_scan; 152 uint8_t master_vdev_cnt; 153 uint8_t vdev_cnt_11d; 154 uint32_t scan_11d_interval; 155 #ifdef HOST_11D_SCAN 156 bool is_host_11d_inited; 157 wlan_scan_requester scan_req_id; 158 uint32_t scan_id; 159 qdf_mc_timer_t timer; 160 #endif 161 uint8_t vdev_ids_11d[MAX_STA_VDEV_CNT]; 162 bool user_ctry_priority; 163 bool user_ctry_set; 164 struct chan_change_cbk_entry cbk_list[REG_MAX_CHAN_CHANGE_CBKS]; 165 uint8_t num_chan_change_cbks; 166 uint8_t ch_avoid_ind; 167 struct unsafe_ch_list unsafe_chan_list; 168 struct ch_avoid_ind_type avoid_freq_list; 169 enum restart_beaconing_on_ch_avoid_rule restart_beaconing; 170 struct wlan_psoc_host_hal_reg_capabilities_ext 171 reg_cap[PSOC_MAX_PHY_REG_CAP]; 172 bool force_ssc_disable_indoor_channel; 173 uint8_t enable_srd_chan_in_master_mode; 174 bool enable_11d_in_world_mode; 175 bool enable_5dot9_ghz_chan_in_master_mode; 176 qdf_spinlock_t cbk_list_lock; 177 bool retain_nol_across_regdmn_update; 178 #ifdef CONFIG_BAND_6GHZ 179 uint8_t domain_code_6g_ap[REG_CURRENT_MAX_AP_TYPE]; 180 uint8_t domain_code_6g_client[REG_CURRENT_MAX_AP_TYPE][REG_MAX_CLIENT_TYPE]; 181 #endif 182 bool is_ext_tpc_supported; 183 #if defined(CONFIG_BAND_6GHZ) 184 bool is_lower_6g_edge_ch_supported; 185 bool is_upper_6g_edge_ch_disabled; 186 #endif 187 #ifdef FEATURE_WLAN_CH_AVOID_EXT 188 bool ch_avoid_ext_ind; 189 struct ch_avoid_ind_type avoid_freq_ext_list; 190 bool coex_unsafe_chan_nb_user_prefer; 191 bool coex_unsafe_chan_reg_disable; 192 #endif 193 #ifdef CONFIG_AFC_SUPPORT 194 enum reg_afc_dev_deploy_type reg_afc_dev_type; 195 #endif 196 bool sta_sap_scc_on_indoor_channel; 197 #ifdef CONFIG_REG_CLIENT 198 struct cur_fcc_rule fcc_rules_ptr[MAX_NUM_FCC_RULES]; 199 #endif 200 }; 201 202 /** 203 * struct wlan_regulatory_pdev_priv_obj - wlan regulatory pdev private object 204 * @cur_chan_list: current channel list, includes 6G channels 205 * @secondary_cur_chan_list: secondary current channel list, for concurrency 206 * situations 207 * @mas_chan_list: master channel list 208 * from the firmware. 209 * @is_6g_channel_list_populated: indicates the channel lists are populated 210 * @mas_chan_list_6g_ap: master channel list for 6G AP, includes all power types 211 * @mas_chan_list_6g_client: master channel list for 6G client, includes 212 * all power types 213 * @super_chan_list: 6G super channel list that includes the information of 214 * all 6G power modes for every 6G channel 215 * @band_capability: bitmap of bands enabled, using enum reg_wifi_band as the 216 * bit position value 217 * @reg_6g_superid: 6Ghz super domain id 218 * @pdev_opened: whether pdev has been opened by application 219 * @reg_cur_6g_ap_pwr_type: 6G AP type ie VLP/SP/LPI. 220 * @reg_cur_6g_client_mobility_type: 6G client type ie Default/Subordinate. 221 * @reg_rnr_tpe_usable: Indicates whether RNR IE is applicable for current reg 222 * domain. 223 * @reg_unspecified_ap_usable: Indicates if the AP type mentioned is not part of 224 * 802.11 standard. 225 * @max_phymode: The maximum phymode supported by the device and regulatory. 226 * @max_chwidth: The maximum bandwidth corresponding to the maximum phymode. 227 * @avoid_chan_ext_list: the extended avoid frequency list. 228 * @afc_cb_lock: The spinlock to synchronize afc callbacks 229 * @afc_cb_obj: The object containing the callback function and opaque argument 230 * @afc_pow_evt_cb_obj: The object containing the callback function and opaque 231 * argument for the AFC power event 232 * @afc_request_id: The last AFC request id received from FW/halphy 233 * @is_6g_afc_power_event_received: indicates if the AFC power event is 234 * received 235 * @is_6g_afc_expiry_event_received: indicates if the AFC exipiry event is 236 * received 237 * @afc_chan_list: Intersection of AFC master and Standard power channel list 238 * @mas_chan_list_6g_afc: AFC master channel list constructed from the AFC 239 * server response. 240 * @power_info: pointer to AFC power information received from the AFC event 241 * sent by the target 242 * @is_reg_noaction_on_afc_pwr_evt: indicates whether regulatory needs to 243 * take action when AFC Power event is received 244 * @reg_6g_thresh_priority_freq: All frequencies greater or equal will be given 245 * priority during channel selection by upper layer 246 * @reg_afc_dev_deployment_type: AFC device deployment type from BDF 247 * @sta_sap_scc_on_indoor_channel: Value of sap+sta scc on indoor support 248 * @fcc_rules_ptr : Value of fcc channel frequency and tx_power list received 249 * from firmware 250 */ 251 struct wlan_regulatory_pdev_priv_obj { 252 struct regulatory_channel cur_chan_list[NUM_CHANNELS]; 253 #ifdef CONFIG_REG_CLIENT 254 struct regulatory_channel secondary_cur_chan_list[NUM_CHANNELS]; 255 #endif 256 struct regulatory_channel mas_chan_list[NUM_CHANNELS]; 257 #ifdef CONFIG_BAND_6GHZ 258 bool is_6g_channel_list_populated; 259 struct regulatory_channel mas_chan_list_6g_ap[REG_CURRENT_MAX_AP_TYPE][NUM_6GHZ_CHANNELS]; 260 struct regulatory_channel mas_chan_list_6g_client[REG_CURRENT_MAX_AP_TYPE][REG_MAX_CLIENT_TYPE][NUM_6GHZ_CHANNELS]; 261 struct super_chan_info super_chan_list[NUM_6GHZ_CHANNELS]; 262 #endif 263 #ifdef DISABLE_CHANNEL_LIST 264 struct regulatory_channel cache_disable_chan_list[NUM_CHANNELS]; 265 uint32_t num_cache_channels; 266 bool disable_cached_channels; 267 #endif 268 char default_country[REG_ALPHA2_LEN + 1]; 269 uint16_t def_region_domain; 270 uint16_t def_country_code; 271 char current_country[REG_ALPHA2_LEN + 1]; 272 uint16_t reg_dmn_pair; 273 uint16_t reg_6g_superid; 274 uint16_t ctry_code; 275 #ifdef DISABLE_UNII_SHARED_BANDS 276 uint8_t unii_5g_bitmap; 277 #endif 278 enum dfs_reg dfs_region; 279 uint32_t phybitmap; 280 struct wlan_objmgr_pdev *pdev_ptr; 281 qdf_freq_t range_2g_low; 282 qdf_freq_t range_2g_high; 283 qdf_freq_t range_5g_low; 284 qdf_freq_t range_5g_high; 285 bool dfs_enabled; 286 bool set_fcc_channel; 287 uint32_t band_capability; 288 bool indoor_chan_enabled; 289 bool en_chan_144; 290 uint64_t wireless_modes; 291 struct ch_avoid_ind_type freq_avoid_list; 292 bool force_ssc_disable_indoor_channel; 293 bool sap_state; 294 struct reg_rule_info reg_rules; 295 qdf_spinlock_t reg_rules_lock; 296 bool chan_list_recvd; 297 bool pdev_opened; 298 #if defined(CONFIG_BAND_6GHZ) 299 enum reg_6g_ap_type reg_cur_6g_ap_pwr_type; 300 enum reg_6g_client_type reg_cur_6g_client_mobility_type; 301 bool reg_rnr_tpe_usable; 302 bool reg_unspecified_ap_usable; 303 qdf_freq_t reg_6g_thresh_priority_freq; 304 #endif 305 #ifdef CONFIG_HOST_FIND_CHAN 306 enum reg_phymode max_phymode; 307 enum phy_ch_width max_chwidth; 308 #endif 309 #ifdef FEATURE_WLAN_CH_AVOID_EXT 310 avoid_ch_ext_list avoid_chan_ext_list; 311 #endif 312 #ifdef CONFIG_AFC_SUPPORT 313 qdf_spinlock_t afc_cb_lock; 314 struct afc_cb_handler afc_cb_obj; 315 struct afc_pow_evt_cb_handler afc_pow_evt_cb_obj; 316 uint64_t afc_request_id; 317 bool is_6g_afc_power_event_received; 318 bool is_6g_afc_expiry_event_received; 319 struct regulatory_channel afc_chan_list[NUM_6GHZ_CHANNELS]; 320 struct regulatory_channel mas_chan_list_6g_afc[NUM_6GHZ_CHANNELS]; 321 struct reg_fw_afc_power_event *power_info; 322 bool is_reg_noaction_on_afc_pwr_evt; 323 enum reg_afc_dev_deploy_type reg_afc_dev_deployment_type; 324 #endif 325 bool sta_sap_scc_on_indoor_channel; 326 #ifdef CONFIG_REG_CLIENT 327 struct cur_fcc_rule fcc_rules_ptr[MAX_NUM_FCC_RULES]; 328 #endif 329 }; 330 331 /** 332 * reg_get_psoc_obj() - Provides the reg component object pointer 333 * @psoc: pointer to psoc object. 334 * 335 * Return: reg component object pointer 336 */ 337 struct wlan_regulatory_psoc_priv_obj *reg_get_psoc_obj( 338 struct wlan_objmgr_psoc *psoc); 339 340 /** 341 * reg_get_pdev_obj() - Provides the reg component object pointer 342 * @psoc: pointer to psoc object. 343 * 344 * Return: reg component object pointer 345 */ 346 struct wlan_regulatory_pdev_priv_obj *reg_get_pdev_obj( 347 struct wlan_objmgr_pdev *pdev); 348 349 /** 350 * wlan_regulatory_psoc_obj_created_notification() - PSOC obj create callback 351 * @psoc: PSOC object 352 * @arg_list: Variable argument list 353 * 354 * This callback is registered with object manager during initialization to 355 * get notified when the object is created. 356 * 357 * Return: Success or Failure 358 */ 359 QDF_STATUS wlan_regulatory_psoc_obj_created_notification( 360 struct wlan_objmgr_psoc *psoc, void *arg_list); 361 362 /** 363 * wlan_regulatory_psoc_obj_destroyed_notification() - PSOC obj delete callback 364 * @psoc: PSOC object 365 * @arg_list: Variable argument list 366 * 367 * This callback is registered with object manager during initialization to 368 * get notified when the object is deleted. 369 * 370 * Return: Success or Failure 371 */ 372 QDF_STATUS wlan_regulatory_psoc_obj_destroyed_notification( 373 struct wlan_objmgr_psoc *psoc, void *arg_list); 374 375 /** 376 * wlan_regulatory_pdev_obj_created_notification() - PDEV obj create callback 377 * @pdev: pdev object 378 * @arg_list: Variable argument list 379 * 380 * This callback is registered with object manager during initialization to 381 * get notified when the pdev object is created. 382 * 383 * Return: Success or Failure 384 */ 385 QDF_STATUS wlan_regulatory_pdev_obj_created_notification( 386 struct wlan_objmgr_pdev *pdev, void *arg_list); 387 388 /** 389 * wlan_regulatory_pdev_obj_destroyed_notification() - PDEV obj destroy callback 390 * @pdev: pdev object 391 * @arg_list: Variable argument list 392 * 393 * This callback is registered with object manager during initialization to 394 * get notified when the pdev object is destroyed. 395 * 396 * Return: Success or Failure 397 */ 398 QDF_STATUS wlan_regulatory_pdev_obj_destroyed_notification( 399 struct wlan_objmgr_pdev *pdev, void *arg_list); 400 401 #ifdef CONFIG_AFC_SUPPORT 402 /** 403 * reg_free_afc_pwr_info() - Free the AFC power information object 404 * @pdev_priv_obj: Pointer to pdev_priv_obj 405 * 406 * Return: void 407 */ 408 void 409 reg_free_afc_pwr_info(struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj); 410 #else 411 static inline void 412 reg_free_afc_pwr_info(struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj) 413 { 414 } 415 #endif 416 #endif 417