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 #define REG_MAX_20M_SUB_CH 8 33 #ifdef CONFIG_AFC_SUPPORT 34 #define MIN_AFC_BW 2 35 #define MAX_AFC_BW 160 36 #endif 37 38 #include "reg_priv_objs.h" 39 /** 40 * reg_reset_reg_rules() - provides the reg domain rules info 41 * @reg_rules: reg rules pointer 42 * 43 * Return: None 44 */ 45 void reg_reset_reg_rules(struct reg_rule_info *reg_rules); 46 47 /** 48 * reg_init_pdev_mas_chan_list() - Initialize pdev master channel list 49 * @pdev_priv_obj: Pointer to regdb pdev private object. 50 * @mas_chan_params: Master channel params. 51 */ 52 void reg_init_pdev_mas_chan_list( 53 struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj, 54 struct mas_chan_params *mas_chan_params); 55 56 #ifdef CONFIG_REG_CLIENT 57 /** 58 * reg_save_reg_rules_to_pdev() - Save psoc reg-rules to pdev. 59 * @pdev_priv_obj: Pointer to regdb pdev private object. 60 */ 61 void reg_save_reg_rules_to_pdev( 62 struct reg_rule_info *psoc_reg_rules, 63 struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj); 64 #else 65 static inline void 66 reg_save_reg_rules_to_pdev(struct reg_rule_info *psoc_reg_rules, 67 struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj) 68 { 69 } 70 #endif 71 72 /** 73 * reg_compute_pdev_current_chan_list() - Compute pdev current channel list. 74 * @pdev_priv_obj: Pointer to regdb pdev private object. 75 */ 76 void reg_compute_pdev_current_chan_list( 77 struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj); 78 79 /** 80 * reg_propagate_mas_chan_list_to_pdev() - Propagate master channel list to pdev 81 * @psoc: Pointer to psoc object. 82 * @object: Void pointer to pdev object. 83 * @arg: Pointer to direction. 84 */ 85 void reg_propagate_mas_chan_list_to_pdev(struct wlan_objmgr_psoc *psoc, 86 void *object, void *arg); 87 88 #ifdef CONFIG_BAND_6GHZ 89 /** 90 * reg_process_master_chan_list_ext() - Compute master channel extended list 91 * based on the regulatory rules. 92 * @reg_info: Pointer to regulatory info 93 * 94 * Return: QDF_STATUS 95 */ 96 QDF_STATUS 97 reg_process_master_chan_list_ext(struct cur_regulatory_info *reg_info); 98 99 /** 100 * reg_get_6g_ap_master_chan_list() - Get an ap master channel list depending 101 * on * ap power type 102 * @ap_pwr_type: Power type (LPI/VLP/SP) 103 * @chan_list: Pointer to the channel list. The output channel list 104 * 105 * Return: QDF_STATUS 106 */ 107 QDF_STATUS reg_get_6g_ap_master_chan_list(struct wlan_objmgr_pdev *pdev, 108 enum reg_6g_ap_type ap_pwr_type, 109 struct regulatory_channel *chan_list); 110 111 /** 112 * reg_get_reg_maschan_lst_frm_6g_pwr_mode() - Return the mas_chan_list entry 113 * for based on the channel index and input power mode 114 * @supp_pwr_mode: 6G supported power mode 115 * @pdev_priv_obj: Pointer to pdev_priv_obj 116 * @chan_idx: Channel index 117 * 118 * Return: Pointer to struct regulatory_channel 119 */ 120 struct regulatory_channel *reg_get_reg_maschan_lst_frm_6g_pwr_mode( 121 enum supported_6g_pwr_types supp_pwr_mode, 122 struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj, 123 uint16_t chan_idx); 124 125 #ifdef CONFIG_REG_CLIENT 126 /** 127 * reg_get_power_string() - get power string from power enum type 128 * @power_type: power type enum value 129 * 130 * Return: power type string 131 */ 132 const char *reg_get_power_string(enum reg_6g_ap_type power_type); 133 #endif 134 135 #ifdef CONFIG_AFC_SUPPORT 136 /** 137 * reg_process_afc_event() - Process the afc event and compute the 6G AFC 138 * channel list based on the frequency range and channel frequency indices set. 139 * @reg_info: Pointer to regulatory info 140 * 141 * Return: QDF_STATUS 142 */ 143 QDF_STATUS 144 reg_process_afc_event(struct afc_regulatory_info *afc_info); 145 #endif 146 147 #else /* CONFIG_BAND_6GHZ */ 148 static inline QDF_STATUS 149 reg_get_6g_ap_master_chan_list(struct wlan_objmgr_pdev *pdev, 150 enum reg_6g_ap_type ap_pwr_type, 151 struct regulatory_channel *chan_list) 152 { 153 return QDF_STATUS_E_FAILURE; 154 } 155 156 static inline 157 struct regulatory_channel *reg_get_reg_maschan_lst_frm_6g_pwr_mode( 158 enum supported_6g_pwr_types supp_pwr_mode, 159 struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj, 160 uint16_t chan_idx) 161 { 162 return NULL; 163 } 164 #endif /* CONFIG_BAND_6GHZ */ 165 /** 166 * reg_process_master_chan_list() - Compute master channel list based on the 167 * regulatory rules. 168 * @reg_info: Pointer to regulatory info 169 * 170 * Return: QDF_STATUS 171 */ 172 QDF_STATUS reg_process_master_chan_list(struct cur_regulatory_info *reg_info); 173 174 /** 175 * reg_get_pwrmode_chan_list() - Get the modified channel list. A modified 176 * current channel list consists of 2G and 5G portions of the current channel 177 * list and the 6G portion of the current channel list is derived from the input 178 * 6g power type. 179 * @pdev: Pointer to pdev 180 * @in_6g_pwr_mode: Input 6GHz power mode. 181 * 182 * Return: 183 * QDF_STATUS_SUCCESS: Success 184 * QDF_STATUS_E_INVAL: Failed to get channel list 185 */ 186 QDF_STATUS reg_get_pwrmode_chan_list(struct wlan_objmgr_pdev *pdev, 187 struct regulatory_channel *chan_list, 188 enum supported_6g_pwr_types 189 in_6g_pwr_mode); 190 191 /** 192 * reg_get_current_chan_list() - provide the pdev current channel list 193 * @pdev: pdev pointer 194 * @chan_list: channel list pointer 195 * 196 * Return: QDF_STATUS 197 */ 198 QDF_STATUS reg_get_current_chan_list(struct wlan_objmgr_pdev *pdev, 199 struct regulatory_channel *chan_list); 200 201 #if defined(CONFIG_AFC_SUPPORT) && defined(CONFIG_BAND_6GHZ) 202 /** 203 * reg_get_6g_afc_chan_list() - provide the pdev afc channel list 204 * @pdev: pdev pointer 205 * @chan_list: channel list pointer 206 * 207 * Return: QDF_STATUS 208 */ 209 QDF_STATUS reg_get_6g_afc_chan_list(struct wlan_objmgr_pdev *pdev, 210 struct regulatory_channel *chan_list); 211 212 /** 213 * reg_get_6g_afc_mas_chan_list() - provide the pdev afc master channel list 214 * @pdev: pdev pointer 215 * @chan_list: channel list pointer 216 * 217 * Return: QDF_STATUS 218 */ 219 QDF_STATUS 220 reg_get_6g_afc_mas_chan_list(struct wlan_objmgr_pdev *pdev, 221 struct regulatory_channel *chan_list); 222 223 /** 224 * reg_psd_2_eirp() - Calculate EIRP from PSD and bandwidth 225 * channel list 226 * @pdev: pdev pointer 227 * @psd: Power Spectral Density in dBm/MHz 228 * @ch_bw: Bandwdith of a channel in MHz (20/40/80/160/320 etc) 229 * @eirp: EIRP power in dBm 230 * 231 * Return: QDF_STATUS 232 */ 233 QDF_STATUS reg_psd_2_eirp(struct wlan_objmgr_pdev *pdev, 234 int16_t psd, 235 uint16_t ch_bw, 236 int16_t *eirp); 237 #endif 238 239 #ifdef CONFIG_REG_CLIENT 240 /** 241 * reg_get_secondary_current_chan_list() - provide the pdev secondary current 242 * channel list 243 * @pdev: pdev pointer 244 * @chan_list: channel list pointer 245 * 246 * Return: QDF_STATUS 247 */ 248 QDF_STATUS 249 reg_get_secondary_current_chan_list(struct wlan_objmgr_pdev *pdev, 250 struct regulatory_channel *chan_list); 251 #endif 252 253 /** 254 * reg_is_chan_disabled_and_not_nol() - In the regulatory channel list, a 255 * channel may be disabled by the regulatory/device or by radar. Radar is 256 * temporary and a radar disabled channel does not mean that the channel is 257 * permanently disabled. The API checks if the channel is disabled, but not due 258 * to radar. 259 * @chan - Regulatory channel object 260 * 261 * Return - True, the channel is disabled, but not due to radar, else false. 262 */ 263 bool reg_is_chan_disabled_and_not_nol(struct regulatory_channel *chan); 264 #endif 265