1 /* 2 * Copyright (c) 2017-2020 The Linux Foundation. All rights reserved. 3 * 4 * Permission to use, copy, modify, and/or distribute this software for 5 * any purpose with or without fee is hereby granted, provided that the 6 * above copyright notice and this permission notice appear in all 7 * copies. 8 * 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 16 * PERFORMANCE OF THIS SOFTWARE. 17 */ 18 19 /** 20 * DOC: dfs_process_radar_found_ind.h 21 * This file provides prototypes of the routines needed for the 22 * external components to utilize the services provided by the 23 * DFS component. 24 */ 25 26 #ifndef _DFS_PROCESS_RADAR_FOUND_IND_H_ 27 #define _DFS_PROCESS_RADAR_FOUND_IND_H_ 28 29 /* Number of channel marking offsets */ 30 #define DFS_NUM_FREQ_OFFSET 3 31 32 /* Lower channel from 20 Mhz center channel */ 33 #define DFS_20MHZ_LOWER_CHANNEL(_f) ((_f) - 20) 34 /* Upper channel from 20 Mhz center channel */ 35 #define DFS_20MHZ_UPPER_CHANNEL(_f) ((_f) + 20) 36 /* 1st lower channel from center channel of bandwidth 40/80/160Mhz */ 37 #define DFS_FIRST_LOWER_CHANNEL(_f) ((_f) - 10) 38 /* 2nd lower channel from center channel of bandwidth 40/80/160Mhz */ 39 #define DFS_SECOND_LOWER_CHANNEL(_f) ((_f) - 30) 40 /* 3rd lower channel from center channel of bandwidth 80/160Mhz */ 41 #define DFS_THIRD_LOWER_CHANNEL(_f) ((_f) - 50) 42 /* 1st upper channel from center channel of bandwidth 40/80/160Mhz */ 43 #define DFS_FIRST_UPPER_CHANNEL(_f) ((_f) + 10) 44 /* 2nd upper channel from center channel of bandwidth 40/80/160Mhz */ 45 #define DFS_SECOND_UPPER_CHANNEL(_f) ((_f) + 30) 46 /* 3rd upper channel from center channel of bandwidth 80/160Mhz */ 47 #define DFS_THIRD_UPPER_CHANNEL(_f) ((_f) + 50) 48 49 /* 20 Mhz freq_offset lower */ 50 #define DFS_20MZ_OFFSET_LOWER (-10) 51 /* 20 Mhz freq_offset upper */ 52 #define DFS_20MZ_OFFSET_UPPER (10) 53 /* 40/80 Mhz freq_offset first lower */ 54 #define DFS_OFFSET_FIRST_LOWER (-20) 55 /* 40/80 Mhz freq_offset second lower */ 56 #define DFS_OFFSET_SECOND_LOWER (-40) 57 /* 40/80 Mhz freq_offset first upper */ 58 #define DFS_OFFSET_FIRST_UPPER (20) 59 /* 40/80 Mhz freq_offset second upper */ 60 #define DFS_OFFSET_SECOND_UPPER (40) 61 62 /* Frequency offset to sidx */ 63 #define DFS_FREQ_OFFSET_TO_SIDX(_f) ((32 * (_f)) / 10) 64 /* Sidx to frequency offset */ 65 #define DFS_SIDX_TO_FREQ_OFFSET(_s) ((10 * (_s)) / 32) 66 /* sidx offset boundary */ 67 #define DFS_BOUNDARY_SIDX 32 68 /* freq offset for chirp */ 69 #define DFS_CHIRP_OFFSET 10 70 /* second segment freq offset */ 71 #define DFS_160MHZ_SECOND_SEG_OFFSET 40 72 /*Primary segment id is 0 */ 73 #define PRIMARY_SEG 0 74 75 /* Frequency offset indices */ 76 #define CENTER_CH 0 77 #define LEFT_CH 1 78 #define RIGHT_CH 2 79 80 #ifdef CONFIG_CHAN_NUM_API 81 /* Next channel number offset's from center channel number */ 82 #define DFS_5GHZ_NEXT_CHAN_OFFSET 2 83 #define DFS_5GHZ_2ND_CHAN_OFFSET 6 84 #define DFS_5GHZ_3RD_CHAN_OFFSET 10 85 #define DFS_5GHZ_4TH_CHAN_OFFSET 14 86 #endif 87 88 #ifdef CONFIG_CHAN_FREQ_API 89 /* Next channel frequency offsets from center channel frequency */ 90 #define DFS_5GHZ_NEXT_CHAN_FREQ_OFFSET 10 91 #define DFS_5GHZ_2ND_CHAN_FREQ_OFFSET 30 92 #define DFS_5GHZ_3RD_CHAN_FREQ_OFFSET 50 93 #define DFS_5GHZ_4TH_CHAN_FREQ_OFFSET 70 94 #endif 95 /* Max number of bonding channels in 160 MHz segment */ 96 #define NUM_CHANNELS_160MHZ 8 97 98 /** 99 * struct freqs_offsets - frequency and offset information 100 * @freq: channel frequency in mhz. 101 * @offset: offset from center frequency. 102 * 103 * Index 0 - Center channel affected by RADAR. 104 * Index 1 - Left of Center channel affected by RADAR. 105 * Index 2 - Right of Center channel affected by RADAR. 106 * 107 * This information is needed to find and mark radar infected 108 * channels in NOL and regulatory database. 109 */ 110 struct freqs_offsets { 111 uint32_t freq[DFS_NUM_FREQ_OFFSET]; 112 int32_t offset[DFS_NUM_FREQ_OFFSET]; 113 }; 114 115 /** 116 * dfs_process_radar_found_indication() - Process radar found indication 117 * @dfs: Pointer to wlan_dfs structure. 118 * @radar_found: radar found info. 119 * 120 * Process radar found indication and update radar effected channel in NOL 121 * and regulatory. 122 * 123 * Return: None 124 */ 125 void dfs_process_radar_found_indication(struct wlan_dfs *dfs, 126 struct radar_found_info *radar_found); 127 128 /** 129 * dfs_process_radar_ind() - Process radar indication event 130 * @dfs: Pointer to wlan_dfs structure. 131 * @radar_found: Pointer to radar_found_info structure. 132 * 133 * Wrapper function of dfs_process_radar_found_indication(). 134 * 135 * Return: QDF_STATUS 136 */ 137 QDF_STATUS dfs_process_radar_ind(struct wlan_dfs *dfs, 138 struct radar_found_info *radar_found); 139 140 /** 141 * dfs_process_radar_ind_on_home_chan() - Process radar indication event on 142 * home channel. 143 * @dfs: Pointer to wlan_dfs structure. 144 * @radar_found: Pointer to radar_found_info structure. 145 * 146 * Return: QDF_STATUS 147 */ 148 QDF_STATUS 149 dfs_process_radar_ind_on_home_chan(struct wlan_dfs *dfs, 150 struct radar_found_info *radar_found); 151 152 /** 153 * dfs_radarfound_action_generic() - The dfs action on radar detection by host 154 * for domains other than FCC. 155 * @dfs: Pointer to wlan_dfs structure. 156 * @seg_id: segment id. 157 * 158 * Return: None 159 */ 160 void dfs_radarfound_action_generic(struct wlan_dfs *dfs, uint8_t seg_id); 161 162 /** 163 * dfs_get_bonding_channels() - Get bonding channels. 164 * @dfs: Pointer to wlan_dfs structure. 165 * @curchan: Pointer to dfs_channels to know width and primary channel. 166 * @segment_id: Segment id, useful for 80+80/160 MHz operating band. 167 * @detector_id: Detector id, used to find if radar is detected on 168 * Agile detector. 169 * @channels: Pointer to save radar affected channels. 170 * 171 * Return: Number of channels. 172 */ 173 #ifdef CONFIG_CHAN_NUM_API 174 uint8_t dfs_get_bonding_channels(struct wlan_dfs *dfs, 175 struct dfs_channel *curchan, 176 uint32_t segment_id, 177 uint8_t detector_id, 178 uint8_t *channels); 179 #endif 180 181 /** 182 * dfs_get_bonding_channels_for_freq() - Get bonding channels. 183 * @dfs: Pointer to wlan_dfs structure. 184 * @curchan: Pointer to dfs_channels to know width and primary channel. 185 * @segment_id: Segment id, useful for 80+80/160 MHz operating band. 186 * @detector_id: Detector id, used to find if radar is detected on 187 * Agile detector. 188 * @freq_list: Pointer to save radar affected channel's frequency. 189 * 190 * Return: Number of channels. 191 */ 192 #ifdef CONFIG_CHAN_FREQ_API 193 uint8_t dfs_get_bonding_channels_for_freq(struct wlan_dfs *dfs, 194 struct dfs_channel *curchan, 195 uint32_t segment_id, 196 uint8_t detector_id, 197 uint16_t *freq_list); 198 199 /** 200 * dfs_compute_radar_found_cfreq(): Computes the centre frequency of the 201 * radar hit channel. 202 * @dfs: Pointer to wlan_dfs structure. 203 * @radar_found: Pointer to radar_found_info. 204 * @freq_center: Pointer to retrieve the value of radar found cfreq. 205 */ 206 void 207 dfs_compute_radar_found_cfreq(struct wlan_dfs *dfs, 208 struct radar_found_info *radar_found, 209 uint32_t *freq_center); 210 211 /** 212 * dfs_find_radar_affected_channels()- Find the radar affected 20MHz channels. 213 * @dfs: Pointer to wlan_dfs structure. 214 * @radar_found: Pointer to radar found structure. 215 * @freq_list: List of 20MHz frequencies on which radar has been detected. 216 * @freq_center: Frequency center of the band on which the radar was detected. 217 * 218 * Return: number of radar affected channels. 219 */ 220 uint8_t 221 dfs_find_radar_affected_channels(struct wlan_dfs *dfs, 222 struct radar_found_info *radar_found, 223 uint16_t *freq_list, 224 uint32_t freq_center); 225 226 /** 227 * dfs_radar_add_channel_list_to_nol_for_freq()- Add given channels to nol 228 * @dfs: Pointer to wlan_dfs structure. 229 * @freq_list: Pointer to list of frequency(has both nonDFS and DFS channels). 230 * Input frequency list. 231 * @nol_freq_list: Pointer to list of NOL frequencies. Output frequency list. 232 * @num_channels: Pointer to number of channels in the list. It is both input 233 * and output to this function. 234 * *Input: Number of subchannels in @freq_list. 235 * *Output: Number of subchannels in @nol_freq_list. 236 * 237 * Add list of channels to nol, only if the channel is dfs. 238 * 239 * Return: QDF_STATUS 240 */ 241 QDF_STATUS 242 dfs_radar_add_channel_list_to_nol_for_freq(struct wlan_dfs *dfs, 243 uint16_t *freq_list, 244 uint16_t *nol_freq_list, 245 uint8_t *num_channels); 246 #endif 247 248 /** 249 * dfs_reset_bangradar() - Rest bangradar parameters. 250 * @dfs: Pointer to wlan_dfs structure. 251 * 252 * Return: void. 253 */ 254 void dfs_reset_bangradar(struct wlan_dfs *dfs); 255 256 /** 257 * dfs_send_csa_to_current_chan() - Send CSA to current channel 258 * @dfs: Pointer to wlan_dfs structure. 259 * 260 * For the test mode(usenol = 0), don't do a CSA; but setup the test timer so 261 * we get a CSA _back_ to the current operating channel. 262 */ 263 void dfs_send_csa_to_current_chan(struct wlan_dfs *dfs); 264 265 /** 266 * dfs_get_bonding_channels_without_seg_info() - Get bonding channels in chan 267 * @chan: Pointer to dfs_channel structure. 268 * @channels: channel array holding list of bonded channels. 269 * 270 * Return: number of sub channels in the input channel. 271 */ 272 #ifdef CONFIG_CHAN_NUM_API 273 uint8_t dfs_get_bonding_channels_without_seg_info(struct dfs_channel *chan, 274 uint8_t *channels); 275 #endif 276 277 /** 278 * dfs_get_bonding_channel_without_seg_info_for_freq() - Get bonding channels 279 * in chan. 280 * @chan: Pointer to dfs_channel structure. 281 * @freq_list: channel array holding list of bonded channel's frequency. 282 * 283 * Return: number of sub channels in the input channel. 284 */ 285 #ifdef CONFIG_CHAN_FREQ_API 286 uint8_t 287 dfs_get_bonding_channel_without_seg_info_for_freq(struct dfs_channel *chan, 288 uint16_t *freq_list); 289 #endif 290 291 /** 292 * dfs_set_nol_subchannel_marking() - Set or unset NOL subchannel marking. 293 * @dfs: Pointer to wlan_dfs structure. 294 * @nol_subchannel_marking - Configure NOL subchannel marking. 295 * 296 * Return: Status of the configuration. 297 */ 298 int 299 dfs_set_nol_subchannel_marking(struct wlan_dfs *dfs, 300 bool nol_subchannel_marking); 301 302 /** 303 * dfs_get_nol_subchannel_marking() - Get the value of NOL subchannel marking. 304 * @dfs: Pointer to wlan_dfs structure. 305 * @nol_subchannel_marking - Read and store the value of NOL subchannel marking 306 * config. 307 * 308 * Return: Status of the read. 309 */ 310 int 311 dfs_get_nol_subchannel_marking(struct wlan_dfs *dfs, 312 bool *nol_subchannel_marking); 313 314 #if defined(WLAN_DFS_TRUE_160MHZ_SUPPORT) && defined(WLAN_DFS_FULL_OFFLOAD) 315 #define DFS_80P80MHZ_SECOND_SEG_OFFSET 85 316 /** 317 * dfs_translate_radar_params() - Translate the radar parameters received in 318 * true 160MHz supported chipsets. 319 * @dfs: Pointer to the wlan_dfs object. 320 * @radar_found: Radar found parameters. 321 * 322 * Radar found parameters in true 160MHz detectors are represented below: 323 * 324 * Offset received with respect to the center of 160MHz ranging from -80 to +80. 325 * __________________________________________ 326 * | | 327 * | 160 MHz Channel | 328 * |__________________________________________| 329 * | | | | | 330 * | | | | | 331 * -80 -ve offset center +ve offset +80 332 * 333 * 334 * Radar found parameters after translation by this API: 335 * 336 * Offsets with respect to pri/sec 80MHz center ranging from -40 to +40. 337 * __________________________________________ 338 * | | | 339 * | 160 MHz|Channel | 340 * |____________________|_____________________| 341 * | | | | | 342 * | | | | | 343 * -40 pri center +40/-40 sec center +40 344 * 345 * Return: void. 346 */ 347 void 348 dfs_translate_radar_params(struct wlan_dfs *dfs, 349 struct radar_found_info *radar_found); 350 #else 351 static inline void 352 dfs_translate_radar_params(struct wlan_dfs *dfs, 353 struct radar_found_info *radar_found) 354 { 355 } 356 #endif /* WLAN_DFS_TRUE_160MHZ_SUPPORT */ 357 #endif /*_DFS_PROCESS_RADAR_FOUND_IND_H_ */ 358