1 /* 2 * Copyright (c) 2017-2021 The Linux Foundation. All rights reserved. 3 * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved. 4 * 5 * 6 * Permission to use, copy, modify, and/or distribute this software for 7 * any purpose with or without fee is hereby granted, provided that the 8 * above copyright notice and this permission notice appear in all 9 * copies. 10 * 11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 15 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 16 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 17 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 18 * PERFORMANCE OF THIS SOFTWARE. 19 */ 20 21 /** 22 * DOC: reg_build_chan_list.h 23 * This file provides prototypes of the regulatory component to build master 24 * and current channel list. 25 */ 26 27 #ifndef __REG_BUILD_CHAN_LIST_H__ 28 #define __REG_BUILD_CHAN_LIST_H__ 29 30 #define CHAN_12_CENT_FREQ 2467 31 #define CHAN_13_CENT_FREQ 2472 32 33 #ifdef WLAN_FEATURE_11BE 34 #define REG_MAX_20M_SUB_CH 16 35 #else 36 #define REG_MAX_20M_SUB_CH 8 37 #endif 38 39 #ifdef CONFIG_AFC_SUPPORT 40 #define MIN_AFC_BW 2 41 #ifdef WLAN_FEATURE_11BE 42 #define MAX_AFC_BW 320 43 #else 44 #define MAX_AFC_BW 160 45 #endif 46 #endif 47 48 #define HALF_IEEE_CH_SEP 2 49 #define IEEE_20MHZ_CH_SEP 4 50 51 #include "reg_priv_objs.h" 52 /** 53 * reg_reset_reg_rules() - provides the reg domain rules info 54 * @reg_rules: reg rules pointer 55 * 56 * Return: None 57 */ 58 void reg_reset_reg_rules(struct reg_rule_info *reg_rules); 59 60 /** 61 * reg_init_pdev_mas_chan_list() - Initialize pdev master channel list 62 * @pdev_priv_obj: Pointer to regdb pdev private object. 63 * @mas_chan_params: Master channel params. 64 */ 65 void reg_init_pdev_mas_chan_list( 66 struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj, 67 struct mas_chan_params *mas_chan_params); 68 69 /** 70 * reg_set_ap_pwr_type() - Set the AP power type. 71 * @pdev_priv_obj: pdev private object 72 * 73 * Set the AP power type as per AFC device deployment if AFC is available. 74 * Otherwise set it to indoor by default. 75 * 76 * Return: None 77 */ 78 void reg_set_ap_pwr_type(struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj); 79 80 /** 81 * reg_save_reg_rules_to_pdev() - Save psoc reg-rules to pdev. 82 * @pdev_priv_obj: Pointer to regdb pdev private object. 83 */ 84 void reg_save_reg_rules_to_pdev( 85 struct reg_rule_info *psoc_reg_rules, 86 struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj); 87 88 /** 89 * reg_compute_pdev_current_chan_list() - Compute pdev current channel list. 90 * @pdev_priv_obj: Pointer to regdb pdev private object. 91 */ 92 void reg_compute_pdev_current_chan_list( 93 struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj); 94 95 /** 96 * reg_propagate_mas_chan_list_to_pdev() - Propagate master channel list to pdev 97 * @psoc: Pointer to psoc object. 98 * @object: Void pointer to pdev object. 99 * @arg: Pointer to direction. 100 */ 101 void reg_propagate_mas_chan_list_to_pdev(struct wlan_objmgr_psoc *psoc, 102 void *object, void *arg); 103 104 #ifdef CONFIG_BAND_6GHZ 105 /** 106 * reg_process_master_chan_list_ext() - Compute master channel extended list 107 * based on the regulatory rules. 108 * @reg_info: Pointer to regulatory info 109 * 110 * Return: QDF_STATUS 111 */ 112 QDF_STATUS 113 reg_process_master_chan_list_ext(struct cur_regulatory_info *reg_info); 114 115 /** 116 * reg_get_6g_ap_master_chan_list() - Get an ap master channel list depending 117 * on * ap power type 118 * @ap_pwr_type: Power type (LPI/VLP/SP) 119 * @chan_list: Pointer to the channel list. The output channel list 120 * 121 * Return: QDF_STATUS 122 */ 123 QDF_STATUS reg_get_6g_ap_master_chan_list(struct wlan_objmgr_pdev *pdev, 124 enum reg_6g_ap_type ap_pwr_type, 125 struct regulatory_channel *chan_list); 126 127 /** 128 * reg_get_reg_maschan_lst_frm_6g_pwr_mode() - Return the mas_chan_list entry 129 * for based on the channel index and input power mode 130 * @supp_pwr_mode: 6G supported power mode 131 * @pdev_priv_obj: Pointer to pdev_priv_obj 132 * @chan_idx: Channel index 133 * 134 * Return: Pointer to struct regulatory_channel 135 */ 136 struct regulatory_channel *reg_get_reg_maschan_lst_frm_6g_pwr_mode( 137 enum supported_6g_pwr_types supp_pwr_mode, 138 struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj, 139 uint16_t chan_idx); 140 141 /** 142 * reg_convert_supported_6g_pwr_type_to_ap_pwr_type() - The supported 6G power 143 * type is a combination of AP and client power types. This API return the 6G AP 144 * power type portion of the supported 6G power type. 145 * @in_6g_pwr_type: input 6G supported power type. 146 * 147 * Return: 6G AP power type. 148 */ 149 enum reg_6g_ap_type 150 reg_convert_supported_6g_pwr_type_to_ap_pwr_type(enum supported_6g_pwr_types 151 in_6g_pwr_type); 152 153 #ifdef CONFIG_REG_CLIENT 154 /** 155 * reg_get_power_string() - get power string from power enum type 156 * @power_type: power type enum value 157 * 158 * Return: power type string 159 */ 160 const char *reg_get_power_string(enum reg_6g_ap_type power_type); 161 #endif 162 163 #ifdef CONFIG_AFC_SUPPORT 164 /** 165 * reg_process_afc_event() - Process the afc event and compute the 6G AFC 166 * channel list based on the frequency range and channel frequency indices set. 167 * @reg_info: Pointer to regulatory info 168 * 169 * Return: QDF_STATUS 170 */ 171 QDF_STATUS 172 reg_process_afc_event(struct afc_regulatory_info *afc_info); 173 174 /** 175 * reg_get_subchannels_for_opclass() - Get the list of subchannels based on the 176 * the channel frequency index and opclass. 177 * @cfi: Channel frequency index 178 * @opclass: Operating class 179 * @subchannels: Pointer to list of subchannels 180 * 181 * Return: void 182 */ 183 uint8_t reg_get_subchannels_for_opclass(uint8_t cfi, 184 uint8_t opclass, 185 uint8_t *subchannels); 186 #endif 187 188 /** 189 * reg_psd_2_eirp() - Calculate EIRP from PSD and bandwidth 190 * channel list 191 * @pdev: pdev pointer 192 * @psd: Power Spectral Density in dBm/MHz 193 * @ch_bw: Bandwdith of a channel in MHz (20/40/80/160/320 etc) 194 * @eirp: EIRP power in dBm 195 * 196 * Return: QDF_STATUS 197 */ 198 QDF_STATUS reg_psd_2_eirp(struct wlan_objmgr_pdev *pdev, 199 int16_t psd, 200 uint16_t ch_bw, 201 int16_t *eirp); 202 203 /** 204 * reg_eirp_2_psd() - Calculate PSD from EIRP and bandwidth 205 * channel list 206 * @pdev: pdev pointer 207 * @ch_bw: Bandwdith of a channel in MHz (20/40/80/160/320 etc) 208 * @eirp: EIRP power in dBm 209 * @psd: Power Spectral Density in dBm/MHz 210 * 211 * Return: QDF_STATUS 212 */ 213 QDF_STATUS reg_eirp_2_psd(struct wlan_objmgr_pdev *pdev, 214 uint16_t ch_bw, 215 int16_t eirp, 216 int16_t *psd); 217 218 /** 219 * reg_is_supp_pwr_mode_invalid - Indicates if the given 6G power mode is 220 * one of the valid power modes enumerated by enum supported_6g_pwr_types 221 * from REG_AP_LPI to REG_CLI_SUB_VLP. 222 * 223 * Note: REG_BEST_PWR_MODE and REG_CURRENT_PWR_MODE are not valid 6G power 224 * modes. 225 * 226 * Return: True for any valid power mode from REG_AP_LPI tp REG_CLI_SUB_VLP. 227 * False otherwise. 228 */ 229 static inline bool 230 reg_is_supp_pwr_mode_invalid(enum supported_6g_pwr_types supp_pwr_mode) 231 { 232 return (supp_pwr_mode < REG_AP_LPI || supp_pwr_mode > REG_CLI_SUB_VLP); 233 } 234 235 /** 236 * reg_copy_from_super_chan_info_to_reg_channel - Copy the structure fields from 237 * a super channel entry to the regulatory channel fields. 238 * 239 * chan - Pointer to the regulatory channel where the fields of super channel 240 * entry is copied to. 241 * sc_entry - Input super channel entry whose fields are copied to the 242 * regulatory channel structure. 243 * in_6g_pwr_mode - Input 6g power type. If the power type is best power mode, 244 * get the best power mode of the given super channel entry and copy its 245 * information to the regulatory channel fields. 246 */ 247 void 248 reg_copy_from_super_chan_info_to_reg_channel(struct regulatory_channel *chan, 249 const struct super_chan_info sc_entry, 250 enum supported_6g_pwr_types 251 in_6g_pwr_mode); 252 #else /* CONFIG_BAND_6GHZ */ 253 static inline QDF_STATUS 254 reg_get_6g_ap_master_chan_list(struct wlan_objmgr_pdev *pdev, 255 enum reg_6g_ap_type ap_pwr_type, 256 struct regulatory_channel *chan_list) 257 { 258 return QDF_STATUS_E_FAILURE; 259 } 260 261 static inline 262 struct regulatory_channel *reg_get_reg_maschan_lst_frm_6g_pwr_mode( 263 enum supported_6g_pwr_types supp_pwr_mode, 264 struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj, 265 uint16_t chan_idx) 266 { 267 return NULL; 268 } 269 270 static inline uint8_t 271 reg_get_subchannels_for_opclass(uint8_t cfi, 272 uint8_t opclass, 273 uint8_t *subchannels) 274 { 275 return 0; 276 } 277 278 static inline QDF_STATUS reg_psd_2_eirp(struct wlan_objmgr_pdev *pdev, 279 int16_t psd, 280 uint16_t ch_bw, 281 int16_t *eirp) 282 { 283 return QDF_STATUS_E_FAILURE; 284 } 285 286 static inline QDF_STATUS reg_eirp_2_psd(struct wlan_objmgr_pdev *pdev, 287 uint16_t ch_bw, 288 int16_t eirp, 289 int16_t *psd) 290 { 291 return QDF_STATUS_E_FAILURE; 292 } 293 294 static inline bool 295 reg_is_supp_pwr_mode_invalid(enum supported_6g_pwr_types supp_pwr_mode) 296 { 297 return true; 298 } 299 300 static inline void 301 reg_copy_from_super_chan_info_to_reg_channel(struct regulatory_channel *chan, 302 const struct super_chan_info sc_entry, 303 enum supported_6g_pwr_types 304 in_6g_pwr_mode) 305 { 306 } 307 #endif /* CONFIG_BAND_6GHZ */ 308 /** 309 * reg_process_master_chan_list() - Compute master channel list based on the 310 * regulatory rules. 311 * @reg_info: Pointer to regulatory info 312 * 313 * Return: QDF_STATUS 314 */ 315 QDF_STATUS reg_process_master_chan_list(struct cur_regulatory_info *reg_info); 316 317 /** 318 * reg_get_pwrmode_chan_list() - Get the modified channel list. A modified 319 * current channel list consists of 2G and 5G portions of the current channel 320 * list and the 6G portion of the current channel list is derived from the input 321 * 6g power type. 322 * @pdev: Pointer to pdev 323 * @in_6g_pwr_mode: Input 6GHz power mode. 324 * 325 * Return: 326 * QDF_STATUS_SUCCESS: Success 327 * QDF_STATUS_E_INVAL: Failed to get channel list 328 */ 329 QDF_STATUS reg_get_pwrmode_chan_list(struct wlan_objmgr_pdev *pdev, 330 struct regulatory_channel *chan_list, 331 enum supported_6g_pwr_types 332 in_6g_pwr_mode); 333 334 /** 335 * reg_get_current_chan_list() - provide the pdev current channel list 336 * @pdev: pdev pointer 337 * @chan_list: channel list pointer 338 * 339 * Return: QDF_STATUS 340 */ 341 QDF_STATUS reg_get_current_chan_list(struct wlan_objmgr_pdev *pdev, 342 struct regulatory_channel *chan_list); 343 344 #if defined(CONFIG_AFC_SUPPORT) && defined(CONFIG_BAND_6GHZ) 345 /** 346 * reg_get_6g_afc_chan_list() - provide the pdev afc channel list 347 * @pdev: pdev pointer 348 * @chan_list: channel list pointer 349 * 350 * Return: QDF_STATUS 351 */ 352 QDF_STATUS reg_get_6g_afc_chan_list(struct wlan_objmgr_pdev *pdev, 353 struct regulatory_channel *chan_list); 354 355 /** 356 * reg_get_6g_afc_mas_chan_list() - provide the pdev afc master channel list 357 * @pdev: pdev pointer 358 * @chan_list: channel list pointer 359 * 360 * Return: QDF_STATUS 361 */ 362 QDF_STATUS 363 reg_get_6g_afc_mas_chan_list(struct wlan_objmgr_pdev *pdev, 364 struct regulatory_channel *chan_list); 365 #endif 366 367 #ifdef CONFIG_REG_CLIENT 368 /** 369 * reg_get_secondary_current_chan_list() - provide the pdev secondary current 370 * channel list 371 * @pdev: pdev pointer 372 * @chan_list: channel list pointer 373 * 374 * Return: QDF_STATUS 375 */ 376 QDF_STATUS 377 reg_get_secondary_current_chan_list(struct wlan_objmgr_pdev *pdev, 378 struct regulatory_channel *chan_list); 379 #endif 380 381 /** 382 * reg_is_chan_disabled_and_not_nol() - In the regulatory channel list, a 383 * channel may be disabled by the regulatory/device or by radar. Radar is 384 * temporary and a radar disabled channel does not mean that the channel is 385 * permanently disabled. The API checks if the channel is disabled, but not due 386 * to radar. 387 * @chan - Regulatory channel object 388 * 389 * Return - True, the channel is disabled, but not due to radar, else false. 390 */ 391 bool reg_is_chan_disabled_and_not_nol(struct regulatory_channel *chan); 392 #endif 393