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 #ifdef QCA_DFS_NOL_PLATFORM_DRV_SUPPORT 335 void utils_dfs_init_nol(struct wlan_objmgr_pdev *pdev); 336 #else 337 static inline void utils_dfs_init_nol(struct wlan_objmgr_pdev *pdev) 338 { 339 } 340 #endif 341 /** 342 * utils_dfs_save_nol() - save nol list to platform driver. 343 * @pdev: pdev handler. 344 * 345 * Save nol list to platform driver. 346 * 347 * Return: None 348 */ 349 void utils_dfs_save_nol(struct wlan_objmgr_pdev *pdev); 350 351 /** 352 * utils_dfs_print_nol_channels() - log nol channels. 353 * @pdev: pdev handler. 354 * 355 * log nol channels. 356 * 357 * Return: None 358 */ 359 #ifdef DFS_COMPONENT_ENABLE 360 void utils_dfs_print_nol_channels(struct wlan_objmgr_pdev *pdev); 361 #else 362 static inline void utils_dfs_print_nol_channels(struct wlan_objmgr_pdev *pdev) 363 { 364 } 365 #endif 366 367 /** 368 * utils_dfs_clear_nol_channels() - clear nol list. 369 * @pdev: pdev handler. 370 * 371 * log nol channels. 372 * 373 * Return: None 374 */ 375 void utils_dfs_clear_nol_channels(struct wlan_objmgr_pdev *pdev); 376 377 /** 378 * utils_is_dfs_ch() - is channel dfs. 379 * @pdev: pdev handler. 380 * 381 * is channel dfs. 382 * 383 * Return: True if channel dfs, else false. 384 */ 385 static inline bool utils_is_dfs_ch(struct wlan_objmgr_pdev *pdev, uint32_t chan) 386 { 387 return wlan_reg_is_dfs_ch(pdev, chan); 388 } 389 /** 390 * utils_dfs_reg_update_nol_ch() - set nol channel 391 * 392 * @pdev: pdev ptr 393 * @ch_list: channel list to be returned 394 * @num_ch: number of channels 395 * @nol_ch: nol flag 396 * 397 * Return: void 398 */ 399 void utils_dfs_reg_update_nol_ch(struct wlan_objmgr_pdev *pdev, 400 uint8_t *ch_list, 401 uint8_t num_ch, 402 bool nol_ch); 403 404 /** 405 * utils_dfs_freq_to_chan () - convert channel freq to channel number 406 * @freq: frequency 407 * 408 * Return: channel number 409 */ 410 uint8_t utils_dfs_freq_to_chan(uint32_t freq); 411 412 /** 413 * utils_dfs_chan_to_freq () - convert channel number to frequency 414 * @chan: channel number 415 * 416 * Return: frequency 417 */ 418 #ifdef DFS_COMPONENT_ENABLE 419 uint32_t utils_dfs_chan_to_freq(uint8_t chan); 420 #else 421 static inline uint32_t utils_dfs_chan_to_freq(uint8_t chan) 422 { 423 return 0; 424 } 425 #endif 426 /** 427 * utils_dfs_update_cur_chan_flags() - Update DFS channel flag and flagext. 428 * @pdev: Pointer to DFS pdev object. 429 * @flags: New channel flags 430 * @flagext: New Extended flags 431 * 432 * Return: QDF_STATUS 433 */ 434 QDF_STATUS utils_dfs_update_cur_chan_flags(struct wlan_objmgr_pdev *pdev, 435 uint64_t flags, 436 uint16_t flagext); 437 438 #ifdef QCA_MCL_DFS_SUPPORT 439 /** 440 * utils_dfs_mark_leaking_ch() - to mark channel leaking in to nol 441 * @pdev: Pointer to pdev structure. 442 * @ch_width: channel width 443 * @temp_ch_lst_sz: the target channel list 444 * @temp_ch_lst: the target channel list 445 * 446 * This function removes the channels from temp channel list that 447 * (if selected as target channel) will cause leakage in one of 448 * the NOL channels 449 * 450 * Return: QDF_STATUS 451 */ 452 QDF_STATUS utils_dfs_mark_leaking_ch(struct wlan_objmgr_pdev *pdev, 453 enum phy_ch_width ch_width, 454 uint8_t temp_ch_lst_sz, 455 uint8_t *temp_ch_lst); 456 #else 457 static inline QDF_STATUS utils_dfs_mark_leaking_ch 458 (struct wlan_objmgr_pdev *pdev, 459 enum phy_ch_width ch_width, 460 uint8_t temp_ch_lst_sz, 461 uint8_t *temp_ch_lst) 462 { 463 return QDF_STATUS_SUCCESS; 464 } 465 #endif 466 /** 467 * utils_get_dfsdomain() - Get DFS domain. 468 * @pdev: Pointer to PDEV structure. 469 * 470 * Return: DFS domain. 471 */ 472 int utils_get_dfsdomain(struct wlan_objmgr_pdev *pdev); 473 474 /** 475 * utils_dfs_get_cur_rd() - Get current regdomain. 476 * @pdev: pdev ptr 477 * 478 * Return: Regdomain pair id. 479 */ 480 uint16_t utils_dfs_get_cur_rd(struct wlan_objmgr_pdev *pdev); 481 482 /** 483 * utils_dfs_is_spoof_check_failed() - get spoof check status. 484 * @pdev: pdev ptr 485 * @is_spoof_check_failed: pointer containing the status. 486 * 487 * Return: QDF_STATUS. 488 */ 489 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) && defined(HOST_DFS_SPOOF_TEST) 490 QDF_STATUS utils_dfs_is_spoof_check_failed(struct wlan_objmgr_pdev *pdev, 491 bool *is_spoof_check_failed); 492 #else 493 static inline 494 QDF_STATUS utils_dfs_is_spoof_check_failed(struct wlan_objmgr_pdev *pdev, 495 bool *is_spoof_check_failed) 496 { 497 return QDF_STATUS_SUCCESS; 498 } 499 #endif 500 #endif /* _WLAN_DFS_UTILS_API_H_ */ 501