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_save_reg_rules_to_pdev() - Save psoc reg-rules to pdev. 71 * @pdev_priv_obj: Pointer to regdb pdev private object. 72 */ 73 void reg_save_reg_rules_to_pdev( 74 struct reg_rule_info *psoc_reg_rules, 75 struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj); 76 77 /** 78 * reg_compute_pdev_current_chan_list() - Compute pdev current channel list. 79 * @pdev_priv_obj: Pointer to regdb pdev private object. 80 */ 81 void reg_compute_pdev_current_chan_list( 82 struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj); 83 84 /** 85 * reg_propagate_mas_chan_list_to_pdev() - Propagate master channel list to pdev 86 * @psoc: Pointer to psoc object. 87 * @object: Void pointer to pdev object. 88 * @arg: Pointer to direction. 89 */ 90 void reg_propagate_mas_chan_list_to_pdev(struct wlan_objmgr_psoc *psoc, 91 void *object, void *arg); 92 93 #ifdef CONFIG_BAND_6GHZ 94 /** 95 * reg_process_master_chan_list_ext() - Compute master channel extended list 96 * based on the regulatory rules. 97 * @reg_info: Pointer to regulatory info 98 * 99 * Return: QDF_STATUS 100 */ 101 QDF_STATUS 102 reg_process_master_chan_list_ext(struct cur_regulatory_info *reg_info); 103 104 /** 105 * reg_get_6g_ap_master_chan_list() - Get an ap master channel list depending 106 * on * ap power type 107 * @ap_pwr_type: Power type (LPI/VLP/SP) 108 * @chan_list: Pointer to the channel list. The output channel list 109 * 110 * Return: QDF_STATUS 111 */ 112 QDF_STATUS reg_get_6g_ap_master_chan_list(struct wlan_objmgr_pdev *pdev, 113 enum reg_6g_ap_type ap_pwr_type, 114 struct regulatory_channel *chan_list); 115 116 /** 117 * reg_get_reg_maschan_lst_frm_6g_pwr_mode() - Return the mas_chan_list entry 118 * for based on the channel index and input power mode 119 * @supp_pwr_mode: 6G supported power mode 120 * @pdev_priv_obj: Pointer to pdev_priv_obj 121 * @chan_idx: Channel index 122 * 123 * Return: Pointer to struct regulatory_channel 124 */ 125 struct regulatory_channel *reg_get_reg_maschan_lst_frm_6g_pwr_mode( 126 enum supported_6g_pwr_types supp_pwr_mode, 127 struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj, 128 uint16_t chan_idx); 129 130 /** 131 * reg_convert_supported_6g_pwr_type_to_ap_pwr_type() - The supported 6G power 132 * type is a combination of AP and client power types. This API return the 6G AP 133 * power type portion of the supported 6G power type. 134 * @in_6g_pwr_type: input 6G supported power type. 135 * 136 * Return: 6G AP power type. 137 */ 138 enum reg_6g_ap_type 139 reg_convert_supported_6g_pwr_type_to_ap_pwr_type(enum supported_6g_pwr_types 140 in_6g_pwr_type); 141 142 #ifdef CONFIG_REG_CLIENT 143 /** 144 * reg_get_power_string() - get power string from power enum type 145 * @power_type: power type enum value 146 * 147 * Return: power type string 148 */ 149 const char *reg_get_power_string(enum reg_6g_ap_type power_type); 150 #endif 151 152 #ifdef CONFIG_AFC_SUPPORT 153 /** 154 * reg_process_afc_event() - Process the afc event and compute the 6G AFC 155 * channel list based on the frequency range and channel frequency indices set. 156 * @reg_info: Pointer to regulatory info 157 * 158 * Return: QDF_STATUS 159 */ 160 QDF_STATUS 161 reg_process_afc_event(struct afc_regulatory_info *afc_info); 162 163 /** 164 * reg_get_subchannels_for_opclass() - Get the list of subchannels based on the 165 * the channel frequency index and opclass. 166 * @cfi: Channel frequency index 167 * @opclass: Operating class 168 * @subchannels: Pointer to list of subchannels 169 * 170 * Return: void 171 */ 172 uint8_t reg_get_subchannels_for_opclass(uint8_t cfi, 173 uint8_t opclass, 174 uint8_t *subchannels); 175 #endif 176 177 /** 178 * reg_psd_2_eirp() - Calculate EIRP from PSD and bandwidth 179 * channel list 180 * @pdev: pdev pointer 181 * @psd: Power Spectral Density in dBm/MHz 182 * @ch_bw: Bandwdith of a channel in MHz (20/40/80/160/320 etc) 183 * @eirp: EIRP power in dBm 184 * 185 * Return: QDF_STATUS 186 */ 187 QDF_STATUS reg_psd_2_eirp(struct wlan_objmgr_pdev *pdev, 188 int16_t psd, 189 uint16_t ch_bw, 190 int16_t *eirp); 191 192 /** 193 * reg_eirp_2_psd() - Calculate PSD from EIRP and bandwidth 194 * channel list 195 * @pdev: pdev pointer 196 * @ch_bw: Bandwdith of a channel in MHz (20/40/80/160/320 etc) 197 * @eirp: EIRP power in dBm 198 * @psd: Power Spectral Density in dBm/MHz 199 * 200 * Return: QDF_STATUS 201 */ 202 QDF_STATUS reg_eirp_2_psd(struct wlan_objmgr_pdev *pdev, 203 uint16_t ch_bw, 204 int16_t eirp, 205 int16_t *psd); 206 207 /** 208 * reg_is_supp_pwr_mode_invalid - Indicates if the given 6G power mode is 209 * one of the valid power modes enumerated by enum supported_6g_pwr_types 210 * from REG_AP_LPI to REG_CLI_SUB_VLP. 211 * 212 * Note: REG_BEST_PWR_MODE and REG_CURRENT_PWR_MODE are not valid 6G power 213 * modes. 214 * 215 * Return: True for any valid power mode from REG_AP_LPI tp REG_CLI_SUB_VLP. 216 * False otherwise. 217 */ 218 static inline bool 219 reg_is_supp_pwr_mode_invalid(enum supported_6g_pwr_types supp_pwr_mode) 220 { 221 return (supp_pwr_mode < REG_AP_LPI || supp_pwr_mode > REG_CLI_SUB_VLP); 222 } 223 224 /** 225 * reg_copy_from_super_chan_info_to_reg_channel - Copy the structure fields from 226 * a super channel entry to the regulatory channel fields. 227 * 228 * chan - Pointer to the regulatory channel where the fields of super channel 229 * entry is copied to. 230 * sc_entry - Input super channel entry whose fields are copied to the 231 * regulatory channel structure. 232 * in_6g_pwr_mode - Input 6g power type. If the power type is best power mode, 233 * get the best power mode of the given super channel entry and copy its 234 * information to the regulatory channel fields. 235 */ 236 void 237 reg_copy_from_super_chan_info_to_reg_channel(struct regulatory_channel *chan, 238 const struct super_chan_info sc_entry, 239 enum supported_6g_pwr_types 240 in_6g_pwr_mode); 241 242 /** 243 * reg_set_ap_pwr_type() - Set the AP power type. 244 * @pdev_priv_obj: pdev private object 245 * 246 * Set the AP power type as per AFC device deployment if AFC is available. 247 * Otherwise set it to indoor by default. 248 * 249 * Return: None 250 */ 251 void reg_set_ap_pwr_type(struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj); 252 253 #else /* CONFIG_BAND_6GHZ */ 254 static inline QDF_STATUS 255 reg_get_6g_ap_master_chan_list(struct wlan_objmgr_pdev *pdev, 256 enum reg_6g_ap_type ap_pwr_type, 257 struct regulatory_channel *chan_list) 258 { 259 return QDF_STATUS_E_FAILURE; 260 } 261 262 static inline 263 struct regulatory_channel *reg_get_reg_maschan_lst_frm_6g_pwr_mode( 264 enum supported_6g_pwr_types supp_pwr_mode, 265 struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj, 266 uint16_t chan_idx) 267 { 268 return NULL; 269 } 270 271 static inline uint8_t 272 reg_get_subchannels_for_opclass(uint8_t cfi, 273 uint8_t opclass, 274 uint8_t *subchannels) 275 { 276 return 0; 277 } 278 279 static inline QDF_STATUS reg_psd_2_eirp(struct wlan_objmgr_pdev *pdev, 280 int16_t psd, 281 uint16_t ch_bw, 282 int16_t *eirp) 283 { 284 return QDF_STATUS_E_FAILURE; 285 } 286 287 static inline QDF_STATUS reg_eirp_2_psd(struct wlan_objmgr_pdev *pdev, 288 uint16_t ch_bw, 289 int16_t eirp, 290 int16_t *psd) 291 { 292 return QDF_STATUS_E_FAILURE; 293 } 294 295 static inline bool 296 reg_is_supp_pwr_mode_invalid(enum supported_6g_pwr_types supp_pwr_mode) 297 { 298 return true; 299 } 300 301 static inline void 302 reg_copy_from_super_chan_info_to_reg_channel(struct regulatory_channel *chan, 303 const struct super_chan_info sc_entry, 304 enum supported_6g_pwr_types 305 in_6g_pwr_mode) 306 { 307 } 308 309 static inline void 310 reg_set_ap_pwr_type(struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj) 311 { 312 } 313 #endif /* CONFIG_BAND_6GHZ */ 314 /** 315 * reg_process_master_chan_list() - Compute master channel list based on the 316 * regulatory rules. 317 * @reg_info: Pointer to regulatory info 318 * 319 * Return: QDF_STATUS 320 */ 321 QDF_STATUS reg_process_master_chan_list(struct cur_regulatory_info *reg_info); 322 323 /** 324 * reg_get_pwrmode_chan_list() - Get the modified channel list. A modified 325 * current channel list consists of 2G and 5G portions of the current channel 326 * list and the 6G portion of the current channel list is derived from the input 327 * 6g power type. 328 * @pdev: Pointer to pdev 329 * @in_6g_pwr_mode: Input 6GHz power mode. 330 * 331 * Return: 332 * QDF_STATUS_SUCCESS: Success 333 * QDF_STATUS_E_INVAL: Failed to get channel list 334 */ 335 QDF_STATUS reg_get_pwrmode_chan_list(struct wlan_objmgr_pdev *pdev, 336 struct regulatory_channel *chan_list, 337 enum supported_6g_pwr_types 338 in_6g_pwr_mode); 339 340 /** 341 * reg_get_current_chan_list() - provide the pdev current channel list 342 * @pdev: pdev pointer 343 * @chan_list: channel list pointer 344 * 345 * Return: QDF_STATUS 346 */ 347 QDF_STATUS reg_get_current_chan_list(struct wlan_objmgr_pdev *pdev, 348 struct regulatory_channel *chan_list); 349 350 #if defined(CONFIG_AFC_SUPPORT) && defined(CONFIG_BAND_6GHZ) 351 /** 352 * reg_get_6g_afc_chan_list() - provide the pdev afc channel list 353 * @pdev: pdev pointer 354 * @chan_list: channel list pointer 355 * 356 * Return: QDF_STATUS 357 */ 358 QDF_STATUS reg_get_6g_afc_chan_list(struct wlan_objmgr_pdev *pdev, 359 struct regulatory_channel *chan_list); 360 361 /** 362 * reg_get_6g_afc_mas_chan_list() - provide the pdev afc master channel list 363 * @pdev: pdev pointer 364 * @chan_list: channel list pointer 365 * 366 * Return: QDF_STATUS 367 */ 368 QDF_STATUS 369 reg_get_6g_afc_mas_chan_list(struct wlan_objmgr_pdev *pdev, 370 struct regulatory_channel *chan_list); 371 #endif 372 373 #ifdef CONFIG_REG_CLIENT 374 /** 375 * reg_get_secondary_current_chan_list() - provide the pdev secondary current 376 * channel list 377 * @pdev: pdev pointer 378 * @chan_list: channel list pointer 379 * 380 * Return: QDF_STATUS 381 */ 382 QDF_STATUS 383 reg_get_secondary_current_chan_list(struct wlan_objmgr_pdev *pdev, 384 struct regulatory_channel *chan_list); 385 #endif 386 387 /** 388 * reg_is_chan_disabled_and_not_nol() - In the regulatory channel list, a 389 * channel may be disabled by the regulatory/device or by radar. Radar is 390 * temporary and a radar disabled channel does not mean that the channel is 391 * permanently disabled. The API checks if the channel is disabled, but not due 392 * to radar. 393 * @chan - Regulatory channel object 394 * 395 * Return - True, the channel is disabled, but not due to radar, else false. 396 */ 397 bool reg_is_chan_disabled_and_not_nol(struct regulatory_channel *chan); 398 #endif 399