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 * typedef reg_ctry_change_callback() - Regulatory country change callback 89 * @mac_ctx: Pointer to mac context 90 * @vdev_id: vdev ID 91 */ 92 typedef void (*reg_ctry_change_callback)( 93 uint8_t vdev_id); 94 95 /** 96 * struct ctry_change_cbk_entry - Country change callback entry 97 * @cbk: Callback 98 */ 99 struct ctry_change_cbk_entry { 100 reg_ctry_change_callback cbk; 101 }; 102 103 #ifdef CONFIG_REG_CLIENT 104 #define MAX_INDOOR_LIST_SIZE 3 105 106 /** 107 * struct indoor_concurrency_list - Active indoor station list 108 * @vdev_id: vdev ID 109 * @freq: frequency of the interface 110 * @chan_range: Range of channels based on bandwidth 111 */ 112 struct indoor_concurrency_list { 113 uint8_t vdev_id; 114 uint32_t freq; 115 const struct bonded_channel_freq *chan_range; 116 }; 117 #endif 118 /** 119 * struct wlan_regulatory_psoc_priv_obj - wlan regulatory psoc private object 120 * @mas_chan_params: master channel parameters list 121 * @chan_list_recvd: whether channel list has been received 122 * @new_user_ctry_pending: In this array, element[phy_id] is true if any user 123 * country update is pending for pdev (phy_id), used in case of MCL. 124 * @new_init_ctry_pending: In this array, element[phy_id] is true if any user 125 * country update is pending for pdev (phy_id), used in case of WIN. 126 * @new_11d_ctry_pending: In this array, element[phy_id] is true if any 11d 127 * country update is pending for pdev (phy_id). 128 * @world_country_pending: In this array, element[phy_id] is true if any world 129 * country update is pending for pdev (phy_id). 130 * @band_capability: bitmap of bands enabled, using enum reg_wifi_band as the 131 * bit position value 132 * @ignore_fw_reg_offload_ind: Ignore FW reg offload indication 133 * @six_ghz_supported: whether 6ghz is supported 134 * @five_dot_nine_ghz_supported: whether 5.9ghz is supported 135 * (service bit WMI_SERVICE_5_DOT_9GHZ_SUPPORT) 136 * @enable_5dot9_ghz_chan_in_master_mode: 5.9 GHz channel support in 137 * master mode (ini fcc_5dot9_ghz_chan_in_master_mode) 138 * @retain_nol_across_regdmn_update: Retain the NOL list across the regdomain 139 * changes. 140 * @domain_code_6g_ap: domain code for 6G AP 141 * @domain_code_6g_client: domain code for 6G client 142 * @is_ext_tpc_supported: Whether FW supports new WMI command for TPC 143 * @is_lower_6g_edge_ch_supported: whether lower 6ghz edge channel 5935MHz is 144 * supported 145 * @is_upper_6g_edge_ch_disabled: whether upper 6ghz edge channel 7115MHz is 146 * disabled 147 * @ch_avoid_ext_ind: whether need to update extended channel frequency list 148 * @avoid_freq_ext_list: the extended avoid channel frequency list 149 * @coex_unsafe_chan_nb_user_prefer: Honor coex unsafe chan cmd from firmware or 150 * userspace 151 * @coex_unsafe_chan_reg_disable: To disable reg channels for received coex 152 * unsafe channels list 153 * @reg_afc_dev_type: AFC device deployment type from BDF 154 * @reg_is_eirp_support_preferred: Whether target prefers EIRP format for 155 * WMI Set TPC command 156 * @enable_6ghz_sp_pwrmode_supp: Whether enable target Standard Power mode 157 * support 158 * @afc_disable_timer_check: Whether disable target AFC timer check 159 * @afc_disable_request_id_check: Whether disable target AFC request id check 160 * @is_afc_reg_noaction: Whether no action to AFC power event 161 * @sta_sap_scc_on_indoor_channel: Value of sap+sta scc on indoor support 162 * @fcc_rules_ptr : Value of fcc channel frequency and tx_power list received 163 * from firmware 164 * @set_fcc_channel: Flag to set fcc channels 165 */ 166 struct wlan_regulatory_psoc_priv_obj { 167 struct mas_chan_params mas_chan_params[PSOC_MAX_PHY_REG_CAP]; 168 bool chan_list_recvd[PSOC_MAX_PHY_REG_CAP]; 169 bool offload_enabled; 170 bool six_ghz_supported; 171 bool five_dot_nine_ghz_supported; 172 uint8_t num_phy; 173 char cur_country[REG_ALPHA2_LEN + 1]; 174 char def_country[REG_ALPHA2_LEN + 1]; 175 uint16_t def_country_code; 176 uint16_t def_region_domain; 177 enum country_src cc_src; 178 struct wlan_objmgr_psoc *psoc_ptr; 179 bool new_user_ctry_pending[PSOC_MAX_PHY_REG_CAP]; 180 bool new_init_ctry_pending[PSOC_MAX_PHY_REG_CAP]; 181 bool new_11d_ctry_pending[PSOC_MAX_PHY_REG_CAP]; 182 bool world_country_pending[PSOC_MAX_PHY_REG_CAP]; 183 bool dfs_enabled; 184 uint32_t band_capability; 185 bool indoor_chan_enabled; 186 bool ignore_fw_reg_offload_ind; 187 bool enable_11d_supp_original; 188 bool enable_11d_supp; 189 bool is_11d_offloaded; 190 uint8_t vdev_id_for_11d_scan; 191 uint8_t master_vdev_cnt; 192 uint8_t vdev_cnt_11d; 193 uint32_t scan_11d_interval; 194 #ifdef HOST_11D_SCAN 195 bool is_host_11d_inited; 196 wlan_scan_requester scan_req_id; 197 uint32_t scan_id; 198 qdf_mc_timer_t timer; 199 #endif 200 uint8_t vdev_ids_11d[MAX_STA_VDEV_CNT]; 201 bool user_ctry_priority; 202 bool user_ctry_set; 203 struct chan_change_cbk_entry cbk_list[REG_MAX_CHAN_CHANGE_CBKS]; 204 uint8_t num_chan_change_cbks; 205 struct ctry_change_cbk_entry cc_cbk; 206 uint8_t ch_avoid_ind; 207 struct unsafe_ch_list unsafe_chan_list; 208 struct ch_avoid_ind_type avoid_freq_list; 209 enum restart_beaconing_on_ch_avoid_rule restart_beaconing; 210 struct wlan_psoc_host_hal_reg_capabilities_ext 211 reg_cap[PSOC_MAX_PHY_REG_CAP]; 212 bool force_ssc_disable_indoor_channel; 213 uint8_t enable_srd_chan_in_master_mode; 214 bool enable_11d_in_world_mode; 215 bool enable_5dot9_ghz_chan_in_master_mode; 216 qdf_spinlock_t cbk_list_lock; 217 bool retain_nol_across_regdmn_update; 218 #ifdef CONFIG_BAND_6GHZ 219 uint8_t domain_code_6g_ap[REG_CURRENT_MAX_AP_TYPE]; 220 uint8_t domain_code_6g_client[REG_CURRENT_MAX_AP_TYPE][REG_MAX_CLIENT_TYPE]; 221 #endif 222 bool is_ext_tpc_supported; 223 #if defined(CONFIG_BAND_6GHZ) 224 bool is_lower_6g_edge_ch_supported; 225 bool is_upper_6g_edge_ch_disabled; 226 #endif 227 #ifdef FEATURE_WLAN_CH_AVOID_EXT 228 bool ch_avoid_ext_ind; 229 struct ch_avoid_ind_type avoid_freq_ext_list; 230 bool coex_unsafe_chan_nb_user_prefer; 231 bool coex_unsafe_chan_reg_disable; 232 #endif 233 #ifdef CONFIG_AFC_SUPPORT 234 enum reg_afc_dev_deploy_type reg_afc_dev_type; 235 bool reg_is_eirp_support_preferred; 236 bool enable_6ghz_sp_pwrmode_supp; 237 bool afc_disable_timer_check; 238 bool afc_disable_request_id_check; 239 bool is_afc_reg_noaction; 240 #endif 241 bool sta_sap_scc_on_indoor_channel; 242 #ifdef CONFIG_REG_CLIENT 243 struct cur_fcc_rule fcc_rules_ptr[MAX_NUM_FCC_RULES]; 244 #endif 245 bool set_fcc_channel; 246 }; 247 248 /** 249 * struct wlan_regulatory_pdev_priv_obj - wlan regulatory pdev private object 250 * @cur_chan_list: current channel list, includes 6G channels 251 * @secondary_cur_chan_list: secondary current channel list, for concurrency 252 * situations 253 * @mas_chan_list: master channel list 254 * from the firmware. 255 * @is_6g_channel_list_populated: indicates the channel lists are populated 256 * @mas_chan_list_6g_ap: master channel list for 6G AP, includes all power types 257 * @mas_chan_list_6g_client: master channel list for 6G client, includes 258 * all power types 259 * @super_chan_list: 6G super channel list that includes the information of 260 * all 6G power modes for every 6G channel 261 * @band_capability: bitmap of bands enabled, using enum reg_wifi_band as the 262 * bit position value 263 * @reg_6g_superid: 6Ghz super domain id 264 * @pdev_opened: whether pdev has been opened by application 265 * @reg_cur_6g_ap_pwr_type: 6G AP type ie VLP/SP/LPI. 266 * @reg_cur_6g_client_mobility_type: 6G client type ie Default/Subordinate. 267 * @reg_target_client_type: 6 GHz client type received from target. The Client 268 * type can be Default/Subordinate. 269 * @reg_rnr_tpe_usable: Indicates whether RNR IE is applicable for current reg 270 * domain. 271 * @reg_unspecified_ap_usable: Indicates if the AP type mentioned is not part of 272 * 802.11 standard. 273 * @max_phymode: The maximum phymode supported by the device and regulatory. 274 * @max_chwidth: The maximum bandwidth corresponding to the maximum phymode. 275 * @avoid_chan_ext_list: the extended avoid frequency list. 276 * @afc_cb_lock: The spinlock to synchronize afc callbacks 277 * @afc_cb_obj: The object containing the callback function and opaque argument 278 * @afc_pow_evt_cb_obj: The object containing the callback function and opaque 279 * argument for the AFC power event 280 * @afc_request_id: The last AFC request id received from FW/halphy 281 * @is_6g_afc_power_event_received: indicates if the AFC power event is 282 * received 283 * @is_6g_afc_expiry_event_received: indicates if the AFC exipiry event is 284 * received 285 * @afc_chan_list: Intersection of AFC master and Standard power channel list 286 * @mas_chan_list_6g_afc: AFC master channel list constructed from the AFC 287 * server response. 288 * @power_info: pointer to AFC power information received from the AFC event 289 * sent by the target 290 * @is_reg_noaction_on_afc_pwr_evt: indicates whether regulatory needs to 291 * take action when AFC Power event is received 292 * @reg_6g_thresh_priority_freq: All frequencies greater or equal will be given 293 * priority during channel selection by upper layer 294 * @reg_afc_dev_deployment_type: AFC device deployment type from BDF 295 * @sta_sap_scc_on_indoor_channel: Value of sap+sta scc on indoor support 296 * @indoor_concurrency_list: List of current indoor station interfaces 297 * @fcc_rules_ptr : Value of fcc channel frequency and tx_power list received 298 * from firmware 299 */ 300 struct wlan_regulatory_pdev_priv_obj { 301 struct regulatory_channel cur_chan_list[NUM_CHANNELS]; 302 #ifdef CONFIG_REG_CLIENT 303 struct regulatory_channel secondary_cur_chan_list[NUM_CHANNELS]; 304 #endif 305 struct regulatory_channel mas_chan_list[NUM_CHANNELS]; 306 #ifdef CONFIG_BAND_6GHZ 307 bool is_6g_channel_list_populated; 308 struct regulatory_channel mas_chan_list_6g_ap[REG_CURRENT_MAX_AP_TYPE][NUM_6GHZ_CHANNELS]; 309 struct regulatory_channel mas_chan_list_6g_client[REG_CURRENT_MAX_AP_TYPE][REG_MAX_CLIENT_TYPE][NUM_6GHZ_CHANNELS]; 310 struct super_chan_info super_chan_list[NUM_6GHZ_CHANNELS]; 311 #endif 312 #ifdef DISABLE_CHANNEL_LIST 313 struct regulatory_channel cache_disable_chan_list[NUM_CHANNELS]; 314 uint32_t num_cache_channels; 315 bool disable_cached_channels; 316 #endif 317 char default_country[REG_ALPHA2_LEN + 1]; 318 uint16_t def_region_domain; 319 uint16_t def_country_code; 320 char current_country[REG_ALPHA2_LEN + 1]; 321 uint16_t reg_dmn_pair; 322 uint16_t reg_6g_superid; 323 uint16_t ctry_code; 324 #ifdef DISABLE_UNII_SHARED_BANDS 325 uint8_t unii_5g_bitmap; 326 #endif 327 enum dfs_reg dfs_region; 328 uint32_t phybitmap; 329 struct wlan_objmgr_pdev *pdev_ptr; 330 qdf_freq_t range_2g_low; 331 qdf_freq_t range_2g_high; 332 qdf_freq_t range_5g_low; 333 qdf_freq_t range_5g_high; 334 bool dfs_enabled; 335 bool set_fcc_channel; 336 uint32_t band_capability; 337 bool indoor_chan_enabled; 338 bool en_chan_144; 339 uint64_t wireless_modes; 340 struct ch_avoid_ind_type freq_avoid_list; 341 bool force_ssc_disable_indoor_channel; 342 bool sap_state; 343 struct reg_rule_info reg_rules; 344 qdf_spinlock_t reg_rules_lock; 345 bool chan_list_recvd; 346 bool pdev_opened; 347 #if defined(CONFIG_BAND_6GHZ) 348 enum reg_6g_ap_type reg_cur_6g_ap_pwr_type; 349 enum reg_6g_client_type reg_cur_6g_client_mobility_type; 350 enum reg_6g_client_type reg_target_client_type; 351 bool reg_rnr_tpe_usable; 352 bool reg_unspecified_ap_usable; 353 qdf_freq_t reg_6g_thresh_priority_freq; 354 #endif 355 #ifdef CONFIG_HOST_FIND_CHAN 356 enum reg_phymode max_phymode; 357 enum phy_ch_width max_chwidth; 358 #endif 359 #ifdef FEATURE_WLAN_CH_AVOID_EXT 360 avoid_ch_ext_list avoid_chan_ext_list; 361 #endif 362 #ifdef CONFIG_AFC_SUPPORT 363 qdf_spinlock_t afc_cb_lock; 364 struct afc_cb_handler afc_cb_obj; 365 struct afc_pow_evt_cb_handler afc_pow_evt_cb_obj; 366 uint64_t afc_request_id; 367 bool is_6g_afc_power_event_received; 368 bool is_6g_afc_expiry_event_received; 369 struct regulatory_channel afc_chan_list[NUM_6GHZ_CHANNELS]; 370 struct regulatory_channel mas_chan_list_6g_afc[NUM_6GHZ_CHANNELS]; 371 struct reg_fw_afc_power_event *power_info; 372 bool is_reg_noaction_on_afc_pwr_evt; 373 enum reg_afc_dev_deploy_type reg_afc_dev_deployment_type; 374 #endif 375 bool sta_sap_scc_on_indoor_channel; 376 #ifdef CONFIG_REG_CLIENT 377 struct cur_fcc_rule fcc_rules_ptr[MAX_NUM_FCC_RULES]; 378 struct indoor_concurrency_list indoor_list[MAX_INDOOR_LIST_SIZE]; 379 #endif 380 }; 381 382 /** 383 * reg_get_psoc_obj() - Provides the reg component object pointer 384 * @psoc: pointer to psoc object. 385 * 386 * Return: reg component object pointer 387 */ 388 struct wlan_regulatory_psoc_priv_obj *reg_get_psoc_obj( 389 struct wlan_objmgr_psoc *psoc); 390 391 /** 392 * reg_get_pdev_obj() - Provides the reg component object pointer 393 * @psoc: pointer to psoc object. 394 * 395 * Return: reg component object pointer 396 */ 397 struct wlan_regulatory_pdev_priv_obj *reg_get_pdev_obj( 398 struct wlan_objmgr_pdev *pdev); 399 400 /** 401 * wlan_regulatory_psoc_obj_created_notification() - PSOC obj create callback 402 * @psoc: PSOC object 403 * @arg_list: Variable argument list 404 * 405 * This callback is registered with object manager during initialization to 406 * get notified when the object is created. 407 * 408 * Return: Success or Failure 409 */ 410 QDF_STATUS wlan_regulatory_psoc_obj_created_notification( 411 struct wlan_objmgr_psoc *psoc, void *arg_list); 412 413 /** 414 * wlan_regulatory_psoc_obj_destroyed_notification() - PSOC obj delete callback 415 * @psoc: PSOC object 416 * @arg_list: Variable argument list 417 * 418 * This callback is registered with object manager during initialization to 419 * get notified when the object is deleted. 420 * 421 * Return: Success or Failure 422 */ 423 QDF_STATUS wlan_regulatory_psoc_obj_destroyed_notification( 424 struct wlan_objmgr_psoc *psoc, void *arg_list); 425 426 /** 427 * wlan_regulatory_pdev_obj_created_notification() - PDEV obj create callback 428 * @pdev: pdev object 429 * @arg_list: Variable argument list 430 * 431 * This callback is registered with object manager during initialization to 432 * get notified when the pdev object is created. 433 * 434 * Return: Success or Failure 435 */ 436 QDF_STATUS wlan_regulatory_pdev_obj_created_notification( 437 struct wlan_objmgr_pdev *pdev, void *arg_list); 438 439 /** 440 * wlan_regulatory_pdev_obj_destroyed_notification() - PDEV obj destroy callback 441 * @pdev: pdev object 442 * @arg_list: Variable argument list 443 * 444 * This callback is registered with object manager during initialization to 445 * get notified when the pdev object is destroyed. 446 * 447 * Return: Success or Failure 448 */ 449 QDF_STATUS wlan_regulatory_pdev_obj_destroyed_notification( 450 struct wlan_objmgr_pdev *pdev, void *arg_list); 451 452 #ifdef CONFIG_AFC_SUPPORT 453 /** 454 * reg_free_afc_pwr_info() - Free the AFC power information object 455 * @pdev_priv_obj: Pointer to pdev_priv_obj 456 * 457 * Return: void 458 */ 459 void 460 reg_free_afc_pwr_info(struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj); 461 #else 462 static inline void 463 reg_free_afc_pwr_info(struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj) 464 { 465 } 466 #endif 467 #endif 468