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 */ 125 struct wlan_regulatory_psoc_priv_obj { 126 struct mas_chan_params mas_chan_params[PSOC_MAX_PHY_REG_CAP]; 127 bool chan_list_recvd[PSOC_MAX_PHY_REG_CAP]; 128 bool offload_enabled; 129 bool six_ghz_supported; 130 bool five_dot_nine_ghz_supported; 131 uint8_t num_phy; 132 char cur_country[REG_ALPHA2_LEN + 1]; 133 char def_country[REG_ALPHA2_LEN + 1]; 134 uint16_t def_country_code; 135 uint16_t def_region_domain; 136 enum country_src cc_src; 137 struct wlan_objmgr_psoc *psoc_ptr; 138 bool new_user_ctry_pending[PSOC_MAX_PHY_REG_CAP]; 139 bool new_init_ctry_pending[PSOC_MAX_PHY_REG_CAP]; 140 bool new_11d_ctry_pending[PSOC_MAX_PHY_REG_CAP]; 141 bool world_country_pending[PSOC_MAX_PHY_REG_CAP]; 142 bool dfs_enabled; 143 uint32_t band_capability; 144 bool indoor_chan_enabled; 145 bool ignore_fw_reg_offload_ind; 146 bool enable_11d_supp_original; 147 bool enable_11d_supp; 148 bool is_11d_offloaded; 149 uint8_t vdev_id_for_11d_scan; 150 uint8_t master_vdev_cnt; 151 uint8_t vdev_cnt_11d; 152 uint32_t scan_11d_interval; 153 #ifdef HOST_11D_SCAN 154 bool is_host_11d_inited; 155 wlan_scan_requester scan_req_id; 156 uint32_t scan_id; 157 qdf_mc_timer_t timer; 158 #endif 159 uint8_t vdev_ids_11d[MAX_STA_VDEV_CNT]; 160 bool user_ctry_priority; 161 bool user_ctry_set; 162 struct chan_change_cbk_entry cbk_list[REG_MAX_CHAN_CHANGE_CBKS]; 163 uint8_t num_chan_change_cbks; 164 uint8_t ch_avoid_ind; 165 struct unsafe_ch_list unsafe_chan_list; 166 struct ch_avoid_ind_type avoid_freq_list; 167 enum restart_beaconing_on_ch_avoid_rule restart_beaconing; 168 struct wlan_psoc_host_hal_reg_capabilities_ext 169 reg_cap[PSOC_MAX_PHY_REG_CAP]; 170 bool force_ssc_disable_indoor_channel; 171 uint8_t enable_srd_chan_in_master_mode; 172 bool enable_11d_in_world_mode; 173 bool enable_5dot9_ghz_chan_in_master_mode; 174 qdf_spinlock_t cbk_list_lock; 175 bool retain_nol_across_regdmn_update; 176 #ifdef CONFIG_BAND_6GHZ 177 uint8_t domain_code_6g_ap[REG_CURRENT_MAX_AP_TYPE]; 178 uint8_t domain_code_6g_client[REG_CURRENT_MAX_AP_TYPE][REG_MAX_CLIENT_TYPE]; 179 #endif 180 bool is_ext_tpc_supported; 181 #if defined(CONFIG_BAND_6GHZ) 182 bool is_lower_6g_edge_ch_supported; 183 bool is_upper_6g_edge_ch_disabled; 184 #endif 185 #ifdef FEATURE_WLAN_CH_AVOID_EXT 186 bool ch_avoid_ext_ind; 187 struct ch_avoid_ind_type avoid_freq_ext_list; 188 bool coex_unsafe_chan_nb_user_prefer; 189 bool coex_unsafe_chan_reg_disable; 190 #endif 191 #ifdef CONFIG_AFC_SUPPORT 192 enum reg_afc_dev_deploy_type reg_afc_dev_type; 193 #endif 194 bool sta_sap_scc_on_indoor_channel; 195 }; 196 197 /** 198 * struct wlan_regulatory_pdev_priv_obj - wlan regulatory pdev private object 199 * @cur_chan_list: current channel list, includes 6G channels 200 * @secondary_cur_chan_list: secondary current channel list, for concurrency 201 * situations 202 * @mas_chan_list: master channel list 203 * from the firmware. 204 * @is_6g_channel_list_populated: indicates the channel lists are populated 205 * @mas_chan_list_6g_ap: master channel list for 6G AP, includes all power types 206 * @mas_chan_list_6g_client: master channel list for 6G client, includes 207 * all power types 208 * @super_chan_list: 6G super channel list that includes the information of 209 * all 6G power modes for every 6G channel 210 * @band_capability: bitmap of bands enabled, using enum reg_wifi_band as the 211 * bit position value 212 * @reg_6g_superid: 6Ghz super domain id 213 * @pdev_opened: whether pdev has been opened by application 214 * @reg_cur_6g_ap_pwr_type: 6G AP type ie VLP/SP/LPI. 215 * @reg_cur_6g_client_mobility_type: 6G client type ie Default/Subordinate. 216 * @reg_rnr_tpe_usable: Indicates whether RNR IE is applicable for current reg 217 * domain. 218 * @reg_unspecified_ap_usable: Indicates if the AP type mentioned is not part of 219 * 802.11 standard. 220 * @max_phymode: The maximum phymode supported by the device and regulatory. 221 * @max_chwidth: The maximum bandwidth corresponding to the maximum phymode. 222 * @avoid_chan_ext_list: the extended avoid frequency list. 223 * @afc_cb_lock: The spinlock to synchronize afc callbacks 224 * @afc_cb_obj: The object containing the callback function and opaque argument 225 * @afc_pow_evt_cb_obj: The object containing the callback function and opaque 226 * argument for the AFC power event 227 * @afc_request_id: The last AFC request id received from FW/halphy 228 * @is_6g_afc_power_event_received: indicates if the AFC power event is 229 * received 230 * @is_6g_afc_expiry_event_received: indicates if the AFC exipiry event is 231 * received 232 * @afc_chan_list: Intersection of AFC master and Standard power channel list 233 * @mas_chan_list_6g_afc: AFC master channel list constructed from the AFC 234 * server response. 235 * @power_info: pointer to AFC power information received from the AFC event 236 * sent by the target 237 * @is_reg_noaction_on_afc_pwr_evt: indicates whether regulatory needs to 238 * take action when AFC Power event is received 239 * @reg_6g_thresh_priority_freq: All frequencies greater or equal will be given 240 * priority during channel selection by upper layer 241 * @reg_afc_dev_deployment_type: AFC device deployment type from BDF 242 * @sta_sap_scc_on_indoor_channel: Value of sap+sta scc on indoor support 243 */ 244 struct wlan_regulatory_pdev_priv_obj { 245 struct regulatory_channel cur_chan_list[NUM_CHANNELS]; 246 #ifdef CONFIG_REG_CLIENT 247 struct regulatory_channel secondary_cur_chan_list[NUM_CHANNELS]; 248 #endif 249 struct regulatory_channel mas_chan_list[NUM_CHANNELS]; 250 #ifdef CONFIG_BAND_6GHZ 251 bool is_6g_channel_list_populated; 252 struct regulatory_channel mas_chan_list_6g_ap[REG_CURRENT_MAX_AP_TYPE][NUM_6GHZ_CHANNELS]; 253 struct regulatory_channel mas_chan_list_6g_client[REG_CURRENT_MAX_AP_TYPE][REG_MAX_CLIENT_TYPE][NUM_6GHZ_CHANNELS]; 254 struct super_chan_info super_chan_list[NUM_6GHZ_CHANNELS]; 255 #endif 256 #ifdef DISABLE_CHANNEL_LIST 257 struct regulatory_channel cache_disable_chan_list[NUM_CHANNELS]; 258 uint32_t num_cache_channels; 259 bool disable_cached_channels; 260 #endif 261 char default_country[REG_ALPHA2_LEN + 1]; 262 uint16_t def_region_domain; 263 uint16_t def_country_code; 264 char current_country[REG_ALPHA2_LEN + 1]; 265 uint16_t reg_dmn_pair; 266 uint16_t reg_6g_superid; 267 uint16_t ctry_code; 268 #ifdef DISABLE_UNII_SHARED_BANDS 269 uint8_t unii_5g_bitmap; 270 #endif 271 enum dfs_reg dfs_region; 272 uint32_t phybitmap; 273 struct wlan_objmgr_pdev *pdev_ptr; 274 qdf_freq_t range_2g_low; 275 qdf_freq_t range_2g_high; 276 qdf_freq_t range_5g_low; 277 qdf_freq_t range_5g_high; 278 bool dfs_enabled; 279 bool set_fcc_channel; 280 uint32_t band_capability; 281 bool indoor_chan_enabled; 282 bool en_chan_144; 283 uint64_t wireless_modes; 284 struct ch_avoid_ind_type freq_avoid_list; 285 bool force_ssc_disable_indoor_channel; 286 bool sap_state; 287 struct reg_rule_info reg_rules; 288 qdf_spinlock_t reg_rules_lock; 289 bool chan_list_recvd; 290 bool pdev_opened; 291 #if defined(CONFIG_BAND_6GHZ) 292 enum reg_6g_ap_type reg_cur_6g_ap_pwr_type; 293 enum reg_6g_client_type reg_cur_6g_client_mobility_type; 294 bool reg_rnr_tpe_usable; 295 bool reg_unspecified_ap_usable; 296 qdf_freq_t reg_6g_thresh_priority_freq; 297 #endif 298 #ifdef CONFIG_HOST_FIND_CHAN 299 enum reg_phymode max_phymode; 300 enum phy_ch_width max_chwidth; 301 #endif 302 #ifdef FEATURE_WLAN_CH_AVOID_EXT 303 avoid_ch_ext_list avoid_chan_ext_list; 304 #endif 305 #ifdef CONFIG_AFC_SUPPORT 306 qdf_spinlock_t afc_cb_lock; 307 struct afc_cb_handler afc_cb_obj; 308 struct afc_pow_evt_cb_handler afc_pow_evt_cb_obj; 309 uint64_t afc_request_id; 310 bool is_6g_afc_power_event_received; 311 bool is_6g_afc_expiry_event_received; 312 struct regulatory_channel afc_chan_list[NUM_6GHZ_CHANNELS]; 313 struct regulatory_channel mas_chan_list_6g_afc[NUM_6GHZ_CHANNELS]; 314 struct reg_fw_afc_power_event *power_info; 315 bool is_reg_noaction_on_afc_pwr_evt; 316 enum reg_afc_dev_deploy_type reg_afc_dev_deployment_type; 317 #endif 318 bool sta_sap_scc_on_indoor_channel; 319 }; 320 321 /** 322 * reg_get_psoc_obj() - Provides the reg component object pointer 323 * @psoc: pointer to psoc object. 324 * 325 * Return: reg component object pointer 326 */ 327 struct wlan_regulatory_psoc_priv_obj *reg_get_psoc_obj( 328 struct wlan_objmgr_psoc *psoc); 329 330 /** 331 * reg_get_pdev_obj() - Provides the reg component object pointer 332 * @psoc: pointer to psoc object. 333 * 334 * Return: reg component object pointer 335 */ 336 struct wlan_regulatory_pdev_priv_obj *reg_get_pdev_obj( 337 struct wlan_objmgr_pdev *pdev); 338 339 /** 340 * wlan_regulatory_psoc_obj_created_notification() - PSOC obj create callback 341 * @psoc: PSOC object 342 * @arg_list: Variable argument list 343 * 344 * This callback is registered with object manager during initialization to 345 * get notified when the object is created. 346 * 347 * Return: Success or Failure 348 */ 349 QDF_STATUS wlan_regulatory_psoc_obj_created_notification( 350 struct wlan_objmgr_psoc *psoc, void *arg_list); 351 352 /** 353 * wlan_regulatory_psoc_obj_destroyed_notification() - PSOC obj delete callback 354 * @psoc: PSOC object 355 * @arg_list: Variable argument list 356 * 357 * This callback is registered with object manager during initialization to 358 * get notified when the object is deleted. 359 * 360 * Return: Success or Failure 361 */ 362 QDF_STATUS wlan_regulatory_psoc_obj_destroyed_notification( 363 struct wlan_objmgr_psoc *psoc, void *arg_list); 364 365 /** 366 * wlan_regulatory_pdev_obj_created_notification() - PDEV obj create callback 367 * @pdev: pdev object 368 * @arg_list: Variable argument list 369 * 370 * This callback is registered with object manager during initialization to 371 * get notified when the pdev object is created. 372 * 373 * Return: Success or Failure 374 */ 375 QDF_STATUS wlan_regulatory_pdev_obj_created_notification( 376 struct wlan_objmgr_pdev *pdev, void *arg_list); 377 378 /** 379 * wlan_regulatory_pdev_obj_destroyed_notification() - PDEV obj destroy callback 380 * @pdev: pdev object 381 * @arg_list: Variable argument list 382 * 383 * This callback is registered with object manager during initialization to 384 * get notified when the pdev object is destroyed. 385 * 386 * Return: Success or Failure 387 */ 388 QDF_STATUS wlan_regulatory_pdev_obj_destroyed_notification( 389 struct wlan_objmgr_pdev *pdev, void *arg_list); 390 391 #ifdef CONFIG_AFC_SUPPORT 392 /** 393 * reg_free_afc_pwr_info() - Free the AFC power information object 394 * @pdev_priv_obj: Pointer to pdev_priv_obj 395 * 396 * Return: void 397 */ 398 void 399 reg_free_afc_pwr_info(struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj); 400 #else 401 static inline void 402 reg_free_afc_pwr_info(struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj) 403 { 404 } 405 #endif 406 #endif 407