1 /* 2 * Copyright (c) 2016-2018 The Linux Foundation. All rights reserved. 3 * 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: This file has the DFS dispatcher API which is exposed to outside of DFS 22 * component. 23 */ 24 25 #ifndef _WLAN_DFS_UTILS_API_H_ 26 #define _WLAN_DFS_UTILS_API_H_ 27 28 #include "wlan_dfs_ucfg_api.h" 29 #include "wlan_reg_services_api.h" 30 31 /* Add channel to nol */ 32 #define DFS_NOL_SET 1 33 34 /* Remove channel from nol */ 35 #define DFS_NOL_RESET 0 36 37 /* Max nol channels */ 38 #define DFS_MAX_NOL_CHANNEL 80 39 40 /* WLAN 2.4GHz start freq */ 41 #define DFS_24_GHZ_BASE_FREQ (2407) 42 43 /* WLAN 5GHz start freq */ 44 #define DFS_5_GHZ_BASE_FREQ (5000) 45 46 /* WLAN 2.4 GHz channel number 6 */ 47 #define DFS_24_GHZ_CHANNEL_6 (6) 48 49 /* WLAN 2.4 GHz channel number 14 */ 50 #define DFS_24_GHZ_CHANNEL_14 (14) 51 52 /* WLAN 2.4 GHz channel number 15 */ 53 #define DFS_24_GHZ_CHANNEL_15 (15) 54 55 /* WLAN 2.4 GHz channel number 27 */ 56 #define DFS_24_GHZ_CHANNEL_27 (27) 57 58 /* WLAN 5GHz channel number 170 */ 59 #define DFS_5_GHZ_CHANNEL_170 (170) 60 61 /* WLAN 5MHz channel spacing */ 62 #define DFS_CHAN_SPACING_5MHZ (5) 63 64 /* WLAN 20Hz channel spacing */ 65 #define DFS_CHAN_SPACING_20MHZ (20) 66 67 /* WLAN 2.4GHz channel number 14 freq */ 68 #define DFS_CHAN_14_FREQ (2484) 69 70 /* WLAN 2.4GHz channel number 15 freq */ 71 #define DFS_CHAN_15_FREQ (2512) 72 73 /* WLAN 5GHz channel number 170 freq */ 74 #define DFS_CHAN_170_FREQ (5852) 75 76 77 78 extern struct dfs_to_mlme global_dfs_to_mlme; 79 80 /** 81 * utils_dfs_cac_valid_reset() - Cancels the dfs_cac_valid_timer timer. 82 * @pdev: Pointer to DFS pdev object. 83 * @prevchan_ieee: Prevchan number. 84 * @prevchan_flags: Prevchan flags. 85 * 86 * Wrapper function for dfs_cac_valid_reset(). This function called from 87 * outside of DFS component. 88 */ 89 90 QDF_STATUS utils_dfs_cac_valid_reset(struct wlan_objmgr_pdev *pdev, 91 uint8_t prevchan_ieee, 92 uint32_t prevchan_flags); 93 94 /** 95 * utils_dfs_reset() - Reset DFS members. 96 * @pdev: Pointer to DFS pdev object. 97 */ 98 QDF_STATUS utils_dfs_reset(struct wlan_objmgr_pdev *pdev); 99 100 /** 101 * utils_dfs_reset_precaclists() - Clears and initiakizes precac_required_list, 102 * precac_done_list and precac_nol_list. 103 * @pdev: Pointer to DFS pdev object. 104 * 105 * Wrapper function for dfs_reset_precaclists(). This function called from 106 * outside of DFS component. 107 */ 108 QDF_STATUS utils_dfs_reset_precaclists(struct wlan_objmgr_pdev *pdev); 109 110 /** 111 * utils_dfs_cancel_precac_timer() - Cancel the precac timer. 112 * @pdev: Pointer to DFS pdev object. 113 * 114 * wrapper function for dfs_cancel_precac_timer(). this function called from 115 * outside of dfs component. 116 */ 117 QDF_STATUS utils_dfs_cancel_precac_timer(struct wlan_objmgr_pdev *pdev); 118 119 /** 120 * utils_dfs_is_precac_done() - Is precac done. 121 * @pdev: Pointer to DFS pdev object. 122 * 123 * wrapper function for dfs_is_precac_done(). this 124 * function called from outside of dfs component. 125 */ 126 QDF_STATUS utils_dfs_is_precac_done(struct wlan_objmgr_pdev *pdev, 127 bool *is_precac_done); 128 129 /** 130 * utils_dfs_cancel_cac_timer() - Cancels the CAC timer. 131 * @pdev: Pointer to DFS pdev object. 132 * 133 * wrapper function for dfs_cancel_cac_timer(). this 134 * function called from outside of dfs component. 135 */ 136 QDF_STATUS utils_dfs_cancel_cac_timer(struct wlan_objmgr_pdev *pdev); 137 138 /** 139 * utils_dfs_start_cac_timer() - Starts the CAC timer. 140 * @pdev: Pointer to DFS pdev object. 141 * 142 * wrapper function for dfs_start_cac_timer(). this 143 * function called from outside of dfs component. 144 */ 145 QDF_STATUS utils_dfs_start_cac_timer(struct wlan_objmgr_pdev *pdev); 146 147 /** 148 * utils_dfs_cac_stop() - Clear the AP CAC timer. 149 * @pdev: Pointer to DFS pdev object. 150 * 151 * wrapper function for dfs_cac_stop(). this 152 * function called from outside of dfs component. 153 */ 154 QDF_STATUS utils_dfs_cac_stop(struct wlan_objmgr_pdev *pdev); 155 156 /** 157 * utils_dfs_stacac_stop() - Clear the STA CAC timer. 158 * @pdev: Pointer to DFS pdev object. 159 * 160 * wrapper function for dfs_stacac_stop(). this 161 * function called from outside of dfs component. 162 */ 163 QDF_STATUS utils_dfs_stacac_stop(struct wlan_objmgr_pdev *pdev); 164 165 /** 166 * utils_dfs_get_usenol() - Returns use_nol flag. 167 * @pdev: Pointer to DFS pdev object. 168 * @usenol: Pointer to usenol value. 169 * 170 * wrapper function for dfs_get_usenol(). this 171 * function called from outside of dfs component. 172 */ 173 QDF_STATUS utils_dfs_get_usenol(struct wlan_objmgr_pdev *pdev, 174 uint16_t *usenol); 175 176 /** 177 * utils_dfs_radar_disable() - Disables the radar. 178 * @pdev: Pointer to DFS pdev object. 179 * 180 * wrapper function for dfs_radar_disable(). this 181 * function called from outside of dfs component. 182 */ 183 QDF_STATUS utils_dfs_radar_disable(struct wlan_objmgr_pdev *pdev); 184 185 /** 186 * utils_dfs_set_update_nol_flag() - Sets update_nol flag. 187 * @pdev: Pointer to DFS pdev object. 188 * @val: update_nol flag. 189 * 190 * wrapper function for dfs_set_update_nol_flag(). this 191 * function called from outside of dfs component. 192 */ 193 QDF_STATUS utils_dfs_set_update_nol_flag(struct wlan_objmgr_pdev *pdev, 194 bool val); 195 196 /** 197 * utils_dfs_get_update_nol_flag() - Returns update_nol flag. 198 * @pdev: Pointer to DFS pdev object. 199 * @nol_flag: Fill nol_flag in this variable. 200 * 201 * wrapper function for dfs_get_update_nol_flag(). this 202 * function called from outside of dfs component. 203 */ 204 QDF_STATUS utils_dfs_get_update_nol_flag(struct wlan_objmgr_pdev *pdev, 205 bool *nol_flag); 206 207 /** 208 * utils_dfs_get_dfs_use_nol() - Get usenol. 209 * @pdev: Pointer to DFS pdev object. 210 * @dfs_use_nol: Pointer to dfs_use_nol. 211 * 212 * wrapper function for dfs_get_dfs_use_nol(). this 213 * function called from outside of dfs component. 214 */ 215 QDF_STATUS utils_dfs_get_dfs_use_nol(struct wlan_objmgr_pdev *pdev, 216 int *dfs_use_nol); 217 218 /** 219 * utils_dfs_get_nol_timeout() - Get NOL timeout. 220 * @pdev: Pointer to DFS pdev object. 221 * @dfs_nol_timeout: Pointer to dfs_nol_timeout. 222 * 223 * wrapper function for dfs_get_nol_timeout(). this 224 * function called from outside of dfs component. 225 */ 226 QDF_STATUS utils_dfs_get_nol_timeout(struct wlan_objmgr_pdev *pdev, 227 int *dfs_nol_timeout); 228 229 /** 230 * utils_dfs_nol_addchan() - Add channel to NOL. 231 * @pdev: Pointer to DFS pdev object. 232 * @chan: channel t o add NOL. 233 * @dfs_nol_timeout: NOL timeout. 234 * 235 * wrapper function for dfs_nol_addchan(). this 236 * function called from outside of dfs component. 237 */ 238 QDF_STATUS utils_dfs_nol_addchan(struct wlan_objmgr_pdev *pdev, 239 uint16_t freq, 240 uint32_t dfs_nol_timeout); 241 242 /** 243 * utils_dfs_nol_update() - NOL update 244 * @pdev: Pointer to DFS pdev object. 245 * 246 * wrapper function for dfs_nol_update(). this 247 * function called from outside of dfs component. 248 */ 249 QDF_STATUS utils_dfs_nol_update(struct wlan_objmgr_pdev *pdev); 250 251 /** 252 * utils_dfs_second_segment_radar_disable() - Disables the second segment radar. 253 * @pdev: Pointer to DFS pdev object. 254 * 255 * This is called when AP detects the radar, to (potentially) disable 256 * the radar code. 257 */ 258 QDF_STATUS utils_dfs_second_segment_radar_disable( 259 struct wlan_objmgr_pdev *pdev); 260 261 /** 262 * utils_dfs_is_ignore_dfs() - Get Ignore DFS value. 263 * @pdev: Pointer to DFS pdev object. 264 * @ignore_dfs: Fill ignore_dfs value in this variable. 265 */ 266 QDF_STATUS utils_dfs_is_ignore_dfs(struct wlan_objmgr_pdev *pdev, 267 bool *ignore_dfs); 268 269 /** 270 * utils_dfs_is_cac_valid() - Gets the value of is_cac_valid. 271 * @pdev: Pointer to DFS pdev object. 272 * @is_cac_valid: Fill is_cac_valid in this variable. 273 */ 274 QDF_STATUS utils_dfs_is_cac_valid(struct wlan_objmgr_pdev *pdev, 275 bool *is_cac_valid); 276 277 /** 278 * utils_dfs_is_ignore_cac() - Gets the value of is_ignore_cac. 279 * @pdev: Pointer to DFS pdev object. 280 * @ignore_cac: Fill ignore_cac value in this variable. 281 */ 282 QDF_STATUS utils_dfs_is_ignore_cac(struct wlan_objmgr_pdev *pdev, 283 bool *ignore_cac); 284 285 /** 286 * utils_dfs_set_cac_timer_running() - Sets the cac timer running. 287 * @pdev: Pointer to DFS pdev object. 288 * @val: Set this value to dfs_cac_timer_running variable. 289 */ 290 QDF_STATUS utils_dfs_set_cac_timer_running(struct wlan_objmgr_pdev *pdev, 291 int val); 292 293 /** 294 * utils_dfs_get_nol_chfreq_and_chwidth() - Sets the cac timer running. 295 * @pdev: Pointer to DFS pdev object. 296 * @nollist: Pointer to NOL channel entry. 297 * @nol_chfreq: Pointer to save channel frequency. 298 * @nol_chwidth: Pointer to save channel width. 299 * @index: Index into nol list. 300 */ 301 QDF_STATUS utils_dfs_get_nol_chfreq_and_chwidth(struct wlan_objmgr_pdev *pdev, 302 void *nollist, 303 uint32_t *nol_chfreq, 304 uint32_t *nol_chwidth, 305 int index); 306 307 /** 308 * utils_dfs_get_random_channel() - Get random channel. 309 * @pdev: Pointer to DFS pdev object. 310 * @flags: random channel selection flags. 311 * @ch_params: current channel params. 312 * @hw_mode: current operating mode. 313 * @target_chan: Pointer to target_chan. 314 * @acs_info: acs range info. 315 * 316 * wrapper function for get_random_chan(). this 317 * function called from outside of dfs component. 318 * 319 * Return: QDF_STATUS 320 */ 321 QDF_STATUS utils_dfs_get_random_channel(struct wlan_objmgr_pdev *pdev, 322 uint16_t flags, struct ch_params *ch_params, 323 uint32_t *hw_mode, uint8_t *target_chan, 324 struct dfs_acs_info *acs_info); 325 326 /** 327 * utils_dfs_init_nol() - Initialize nol from platform driver. 328 * @pdev: pdev handler. 329 * 330 * Initialize nol from platform driver. 331 * 332 * Return: None 333 */ 334 void utils_dfs_init_nol(struct wlan_objmgr_pdev *pdev); 335 336 /** 337 * utils_dfs_save_nol() - save nol list to platform driver. 338 * @pdev: pdev handler. 339 * 340 * Save nol list to platform driver. 341 * 342 * Return: None 343 */ 344 void utils_dfs_save_nol(struct wlan_objmgr_pdev *pdev); 345 346 /** 347 * utils_dfs_print_nol_channels() - log nol channels. 348 * @pdev: pdev handler. 349 * 350 * log nol channels. 351 * 352 * Return: None 353 */ 354 void utils_dfs_print_nol_channels(struct wlan_objmgr_pdev *pdev); 355 356 /** 357 * utils_dfs_clear_nol_channels() - clear nol list. 358 * @pdev: pdev handler. 359 * 360 * log nol channels. 361 * 362 * Return: None 363 */ 364 void utils_dfs_clear_nol_channels(struct wlan_objmgr_pdev *pdev); 365 366 /** 367 * utils_is_dfs_ch() - is channel dfs. 368 * @pdev: pdev handler. 369 * 370 * is channel dfs. 371 * 372 * Return: True if channel dfs, else false. 373 */ 374 bool utils_is_dfs_ch(struct wlan_objmgr_pdev *pdev, uint32_t chan); 375 376 /** 377 * utils_dfs_reg_update_nol_ch() - set nol channel 378 * 379 * @pdev: pdev ptr 380 * @ch_list: channel list to be returned 381 * @num_ch: number of channels 382 * @nol_ch: nol flag 383 * 384 * Return: void 385 */ 386 void utils_dfs_reg_update_nol_ch(struct wlan_objmgr_pdev *pdev, 387 uint8_t *ch_list, 388 uint8_t num_ch, 389 bool nol_ch); 390 391 /** 392 * utils_dfs_freq_to_chan () - convert channel freq to channel number 393 * @freq: frequency 394 * 395 * Return: channel number 396 */ 397 uint8_t utils_dfs_freq_to_chan(uint32_t freq); 398 399 /** 400 * utils_dfs_chan_to_freq () - convert channel number to frequency 401 * @chan: channel number 402 * 403 * Return: frequency 404 */ 405 uint32_t utils_dfs_chan_to_freq(uint8_t chan); 406 407 /** 408 * utils_dfs_update_cur_chan_flags() - Update DFS channel flag and flagext. 409 * @pdev: Pointer to DFS pdev object. 410 * @flags: New channel flags 411 * @flagext: New Extended flags 412 * 413 * Return: QDF_STATUS 414 */ 415 QDF_STATUS utils_dfs_update_cur_chan_flags(struct wlan_objmgr_pdev *pdev, 416 uint64_t flags, 417 uint16_t flagext); 418 419 #ifdef QCA_MCL_DFS_SUPPORT 420 /** 421 * utils_dfs_mark_leaking_ch() - to mark channel leaking in to nol 422 * @pdev: Pointer to pdev structure. 423 * @ch_width: channel width 424 * @temp_ch_lst_sz: the target channel list 425 * @temp_ch_lst: the target channel list 426 * 427 * This function removes the channels from temp channel list that 428 * (if selected as target channel) will cause leakage in one of 429 * the NOL channels 430 * 431 * Return: QDF_STATUS 432 */ 433 QDF_STATUS utils_dfs_mark_leaking_ch(struct wlan_objmgr_pdev *pdev, 434 enum phy_ch_width ch_width, 435 uint8_t temp_ch_lst_sz, 436 uint8_t *temp_ch_lst); 437 #endif 438 439 /** 440 * utils_get_dfsdomain() - Get DFS domain. 441 * @pdev: Pointer to PDEV structure. 442 * 443 * Return: DFS domain. 444 */ 445 int utils_get_dfsdomain(struct wlan_objmgr_pdev *pdev); 446 447 /** 448 * utils_dfs_get_cur_rd() - Get current regdomain. 449 * @pdev: pdev ptr 450 * 451 * Return: Regdomain pair id. 452 */ 453 uint16_t utils_dfs_get_cur_rd(struct wlan_objmgr_pdev *pdev); 454 455 /** 456 * utils_dfs_is_spoof_check_failed() - get spoof check status. 457 * @pdev: pdev ptr 458 * @is_spoof_check_failed: pointer containing the status. 459 * 460 * Return: QDF_STATUS. 461 */ 462 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) && defined(HOST_DFS_SPOOF_TEST) 463 QDF_STATUS utils_dfs_is_spoof_check_failed(struct wlan_objmgr_pdev *pdev, 464 bool *is_spoof_check_failed); 465 #else 466 static inline 467 QDF_STATUS utils_dfs_is_spoof_check_failed(struct wlan_objmgr_pdev *pdev, 468 bool *is_spoof_check_failed) 469 { 470 return QDF_STATUS_SUCCESS; 471 } 472 #endif 473 #endif /* _WLAN_DFS_UTILS_API_H_ */ 474