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