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_freq_is_in_nol() - check if given channel in nol list 102 * @pdev: Pointer to DFS pdev object 103 * @freq: channel frequency 104 * 105 * check if given channel in nol list. 106 * 107 * Return: true if channel in nol, false else 108 */ 109 bool utils_dfs_freq_is_in_nol(struct wlan_objmgr_pdev *pdev, uint32_t freq); 110 111 /** 112 * utils_dfs_reset_precaclists() - Clears and initiakizes precac_required_list, 113 * precac_done_list and precac_nol_list. 114 * @pdev: Pointer to DFS pdev object. 115 * 116 * Wrapper function for dfs_reset_precaclists(). This function called from 117 * outside of DFS component. 118 */ 119 QDF_STATUS utils_dfs_reset_precaclists(struct wlan_objmgr_pdev *pdev); 120 121 /** 122 * utils_dfs_reset_etsi_precaclists() - Clears and initializes etsi 123 * precac_required_list, 124 * etsi precac_done_list and 125 * etsi precac_nol_list. 126 * @pdev: Pointer to DFS pdev object. 127 * 128 * Wrapper function for dfs_reset_etsiprecaclists(). This function called from 129 * outside of DFS component. 130 */ 131 #ifdef QCA_SUPPORT_ETSI_PRECAC_DFS 132 QDF_STATUS utils_dfs_reset_etsi_precaclists(struct wlan_objmgr_pdev *pdev); 133 #else 134 static inline QDF_STATUS utils_dfs_reset_etsi_precaclists( 135 struct wlan_objmgr_pdev *pdev) 136 { 137 return QDF_STATUS_SUCCESS; 138 } 139 #endif 140 141 /** 142 * utils_dfs_cancel_precac_timer() - Cancel the precac timer. 143 * @pdev: Pointer to DFS pdev object. 144 * 145 * wrapper function for dfs_cancel_precac_timer(). this function called from 146 * outside of dfs component. 147 */ 148 QDF_STATUS utils_dfs_cancel_precac_timer(struct wlan_objmgr_pdev *pdev); 149 150 /** 151 * utils_dfs_start_precac_timer() - Start the precac timer. 152 * @pdev: Pointer to DFS pdev object. 153 * 154 * Wrapper function for dfs_start_precac_timer(). This function called from 155 * outside of dfs component. 156 * 157 * Return: 158 * * QDF_STATUS_E_FAILURE: Failed to start timer. 159 * * QDF_STATUS_SUCCESS: Timer started successfully. 160 */ 161 QDF_STATUS utils_dfs_start_precac_timer(struct wlan_objmgr_pdev *pdev); 162 163 /** 164 * utils_dfs_is_precac_done() - Is precac done. 165 * @pdev: Pointer to DFS pdev object. 166 * 167 * wrapper function for dfs_is_precac_done(). this 168 * function called from outside of dfs component. 169 */ 170 QDF_STATUS utils_dfs_is_precac_done(struct wlan_objmgr_pdev *pdev, 171 bool *is_precac_done); 172 173 #ifdef WLAN_DFS_PRECAC_AUTO_CHAN_SUPPORT 174 /** 175 * utils_dfs_precac_decide_pref_chan() - Choose preferred channel 176 * @pdev: Pointer to DFS pdev object. 177 * @ch_ieee: Pointer to channel number 178 179 * Wrapper function for dfs_decide_precac_preferred_chan(). This 180 * function called from outside of dfs component. 181 * 182 * Return: 183 * * QDF_STATUS_E_FAILURE: Failed to decide preferred channel. 184 * * QDF_STATUS_SUCCESS: Set preferred channel successfully. 185 */ 186 QDF_STATUS utils_dfs_precac_decide_pref_chan(struct wlan_objmgr_pdev *pdev, 187 uint8_t *ch_ieee); 188 #endif 189 190 /** 191 * utils_dfs_is_esti_precac_done() - Is ETSI precac done. 192 * @pdev: Pointer to DFS pdev object. 193 * 194 * wrapper function for dfs_is_etsi_precac_done(). This 195 * function called from outside of dfs component. 196 */ 197 #ifdef QCA_SUPPORT_ETSI_PRECAC_DFS 198 QDF_STATUS utils_dfs_is_etsi_precac_done(struct wlan_objmgr_pdev *pdev, 199 bool *is_etsi_precac_done); 200 #else 201 static inline QDF_STATUS utils_dfs_is_etsi_precac_done( 202 struct wlan_objmgr_pdev *pdev, 203 bool *is_etsi_precac_done) 204 { 205 return QDF_STATUS_SUCCESS; 206 } 207 #endif 208 209 /** 210 * utils_dfs_cancel_cac_timer() - Cancels the CAC timer. 211 * @pdev: Pointer to DFS pdev object. 212 * 213 * wrapper function for dfs_cancel_cac_timer(). this 214 * function called from outside of dfs component. 215 */ 216 QDF_STATUS utils_dfs_cancel_cac_timer(struct wlan_objmgr_pdev *pdev); 217 218 /** 219 * utils_dfs_start_cac_timer() - Starts the CAC timer. 220 * @pdev: Pointer to DFS pdev object. 221 * 222 * wrapper function for dfs_start_cac_timer(). this 223 * function called from outside of dfs component. 224 */ 225 QDF_STATUS utils_dfs_start_cac_timer(struct wlan_objmgr_pdev *pdev); 226 227 /** 228 * utils_dfs_cac_stop() - Clear the AP CAC timer. 229 * @pdev: Pointer to DFS pdev object. 230 * 231 * wrapper function for dfs_cac_stop(). this 232 * function called from outside of dfs component. 233 */ 234 QDF_STATUS utils_dfs_cac_stop(struct wlan_objmgr_pdev *pdev); 235 236 /** 237 * utils_dfs_stacac_stop() - Clear the STA CAC timer. 238 * @pdev: Pointer to DFS pdev object. 239 * 240 * wrapper function for dfs_stacac_stop(). this 241 * function called from outside of dfs component. 242 */ 243 QDF_STATUS utils_dfs_stacac_stop(struct wlan_objmgr_pdev *pdev); 244 245 /** 246 * utils_dfs_get_usenol() - Returns use_nol flag. 247 * @pdev: Pointer to DFS pdev object. 248 * @usenol: Pointer to usenol value. 249 * 250 * wrapper function for dfs_get_usenol(). this 251 * function called from outside of dfs component. 252 */ 253 QDF_STATUS utils_dfs_get_usenol(struct wlan_objmgr_pdev *pdev, 254 uint16_t *usenol); 255 256 /** 257 * utils_dfs_radar_disable() - Disables the radar. 258 * @pdev: Pointer to DFS pdev object. 259 * 260 * wrapper function for dfs_radar_disable(). this 261 * function called from outside of dfs component. 262 */ 263 QDF_STATUS utils_dfs_radar_disable(struct wlan_objmgr_pdev *pdev); 264 265 /** 266 * utils_dfs_set_update_nol_flag() - Sets update_nol flag. 267 * @pdev: Pointer to DFS pdev object. 268 * @val: update_nol flag. 269 * 270 * wrapper function for dfs_set_update_nol_flag(). this 271 * function called from outside of dfs component. 272 */ 273 QDF_STATUS utils_dfs_set_update_nol_flag(struct wlan_objmgr_pdev *pdev, 274 bool val); 275 276 /** 277 * utils_dfs_get_update_nol_flag() - Returns update_nol flag. 278 * @pdev: Pointer to DFS pdev object. 279 * @nol_flag: Fill nol_flag in this variable. 280 * 281 * wrapper function for dfs_get_update_nol_flag(). this 282 * function called from outside of dfs component. 283 */ 284 QDF_STATUS utils_dfs_get_update_nol_flag(struct wlan_objmgr_pdev *pdev, 285 bool *nol_flag); 286 287 /** 288 * utils_dfs_get_dfs_use_nol() - Get usenol. 289 * @pdev: Pointer to DFS pdev object. 290 * @dfs_use_nol: Pointer to dfs_use_nol. 291 * 292 * wrapper function for dfs_get_dfs_use_nol(). this 293 * function called from outside of dfs component. 294 */ 295 QDF_STATUS utils_dfs_get_dfs_use_nol(struct wlan_objmgr_pdev *pdev, 296 int *dfs_use_nol); 297 298 /** 299 * utils_dfs_get_nol_timeout() - Get NOL timeout. 300 * @pdev: Pointer to DFS pdev object. 301 * @dfs_nol_timeout: Pointer to dfs_nol_timeout. 302 * 303 * wrapper function for dfs_get_nol_timeout(). this 304 * function called from outside of dfs component. 305 */ 306 QDF_STATUS utils_dfs_get_nol_timeout(struct wlan_objmgr_pdev *pdev, 307 int *dfs_nol_timeout); 308 309 /** 310 * utils_dfs_nol_addchan() - Add channel to NOL. 311 * @pdev: Pointer to DFS pdev object. 312 * @chan: channel t o add NOL. 313 * @dfs_nol_timeout: NOL timeout. 314 * 315 * wrapper function for dfs_nol_addchan(). this 316 * function called from outside of dfs component. 317 */ 318 QDF_STATUS utils_dfs_nol_addchan(struct wlan_objmgr_pdev *pdev, 319 uint16_t freq, 320 uint32_t dfs_nol_timeout); 321 322 /** 323 * utils_dfs_nol_update() - NOL update 324 * @pdev: Pointer to DFS pdev object. 325 * 326 * wrapper function for dfs_nol_update(). this 327 * function called from outside of dfs component. 328 */ 329 QDF_STATUS utils_dfs_nol_update(struct wlan_objmgr_pdev *pdev); 330 331 /** 332 * utils_dfs_second_segment_radar_disable() - Disables the second segment radar. 333 * @pdev: Pointer to DFS pdev object. 334 * 335 * This is called when AP detects the radar, to (potentially) disable 336 * the radar code. 337 */ 338 QDF_STATUS utils_dfs_second_segment_radar_disable( 339 struct wlan_objmgr_pdev *pdev); 340 341 /** 342 * utils_dfs_is_ignore_dfs() - Get Ignore DFS value. 343 * @pdev: Pointer to DFS pdev object. 344 * @ignore_dfs: Fill ignore_dfs value in this variable. 345 */ 346 QDF_STATUS utils_dfs_is_ignore_dfs(struct wlan_objmgr_pdev *pdev, 347 bool *ignore_dfs); 348 349 /** 350 * utils_dfs_is_cac_valid() - Gets the value of is_cac_valid. 351 * @pdev: Pointer to DFS pdev object. 352 * @is_cac_valid: Fill is_cac_valid in this variable. 353 */ 354 QDF_STATUS utils_dfs_is_cac_valid(struct wlan_objmgr_pdev *pdev, 355 bool *is_cac_valid); 356 357 /** 358 * utils_dfs_is_ignore_cac() - Gets the value of is_ignore_cac. 359 * @pdev: Pointer to DFS pdev object. 360 * @ignore_cac: Fill ignore_cac value in this variable. 361 */ 362 QDF_STATUS utils_dfs_is_ignore_cac(struct wlan_objmgr_pdev *pdev, 363 bool *ignore_cac); 364 365 /** 366 * utils_dfs_set_cac_timer_running() - Sets the cac timer running. 367 * @pdev: Pointer to DFS pdev object. 368 * @val: Set this value to dfs_cac_timer_running variable. 369 */ 370 QDF_STATUS utils_dfs_set_cac_timer_running(struct wlan_objmgr_pdev *pdev, 371 int val); 372 373 /** 374 * utils_dfs_get_nol_chfreq_and_chwidth() - Sets the cac timer running. 375 * @pdev: Pointer to DFS pdev object. 376 * @nollist: Pointer to NOL channel entry. 377 * @nol_chfreq: Pointer to save channel frequency. 378 * @nol_chwidth: Pointer to save channel width. 379 * @index: Index into nol list. 380 */ 381 QDF_STATUS utils_dfs_get_nol_chfreq_and_chwidth(struct wlan_objmgr_pdev *pdev, 382 void *nollist, 383 uint32_t *nol_chfreq, 384 uint32_t *nol_chwidth, 385 int index); 386 387 /** 388 * utils_dfs_get_random_channel() - Get random channel. 389 * @pdev: Pointer to DFS pdev object. 390 * @flags: random channel selection flags. 391 * @ch_params: current channel params. 392 * @hw_mode: current operating mode. 393 * @target_chan: Pointer to target_chan. 394 * @acs_info: acs range info. 395 * 396 * wrapper function for get_random_chan(). this 397 * function called from outside of dfs component. 398 * 399 * Return: QDF_STATUS 400 */ 401 QDF_STATUS utils_dfs_get_random_channel(struct wlan_objmgr_pdev *pdev, 402 uint16_t flags, struct ch_params *ch_params, 403 uint32_t *hw_mode, uint8_t *target_chan, 404 struct dfs_acs_info *acs_info); 405 406 /** 407 * utils_dfs_init_nol() - Initialize nol from platform driver. 408 * @pdev: pdev handler. 409 * 410 * Initialize nol from platform driver. 411 * 412 * Return: None 413 */ 414 #ifdef QCA_DFS_NOL_PLATFORM_DRV_SUPPORT 415 void utils_dfs_init_nol(struct wlan_objmgr_pdev *pdev); 416 #else 417 static inline void utils_dfs_init_nol(struct wlan_objmgr_pdev *pdev) 418 { 419 } 420 #endif 421 /** 422 * utils_dfs_save_nol() - save nol list to platform driver. 423 * @pdev: pdev handler. 424 * 425 * Save nol list to platform driver. 426 * 427 * Return: None 428 */ 429 void utils_dfs_save_nol(struct wlan_objmgr_pdev *pdev); 430 431 /** 432 * utils_dfs_print_nol_channels() - log nol channels. 433 * @pdev: pdev handler. 434 * 435 * log nol channels. 436 * 437 * Return: None 438 */ 439 #ifdef DFS_COMPONENT_ENABLE 440 void utils_dfs_print_nol_channels(struct wlan_objmgr_pdev *pdev); 441 #else 442 static inline void utils_dfs_print_nol_channels(struct wlan_objmgr_pdev *pdev) 443 { 444 } 445 #endif 446 447 /** 448 * utils_dfs_clear_nol_channels() - clear nol list. 449 * @pdev: pdev handler. 450 * 451 * log nol channels. 452 * 453 * Return: None 454 */ 455 void utils_dfs_clear_nol_channels(struct wlan_objmgr_pdev *pdev); 456 457 /** 458 * utils_is_dfs_ch() - is channel dfs. 459 * @pdev: pdev handler. 460 * 461 * is channel dfs. 462 * 463 * Return: True if channel dfs, else false. 464 */ 465 static inline bool utils_is_dfs_ch(struct wlan_objmgr_pdev *pdev, uint32_t chan) 466 { 467 return wlan_reg_is_dfs_ch(pdev, chan); 468 } 469 /** 470 * utils_dfs_reg_update_nol_ch() - set nol channel 471 * 472 * @pdev: pdev ptr 473 * @ch_list: channel list to be returned 474 * @num_ch: number of channels 475 * @nol_ch: nol flag 476 * 477 * Return: void 478 */ 479 void utils_dfs_reg_update_nol_ch(struct wlan_objmgr_pdev *pdev, 480 uint8_t *ch_list, 481 uint8_t num_ch, 482 bool nol_ch); 483 484 /** 485 * utils_dfs_freq_to_chan () - convert channel freq to channel number 486 * @freq: frequency 487 * 488 * Return: channel number 489 */ 490 uint8_t utils_dfs_freq_to_chan(uint32_t freq); 491 492 /** 493 * utils_dfs_chan_to_freq () - convert channel number to frequency 494 * @chan: channel number 495 * 496 * Return: frequency 497 */ 498 #ifdef DFS_COMPONENT_ENABLE 499 uint32_t utils_dfs_chan_to_freq(uint8_t chan); 500 #else 501 static inline uint32_t utils_dfs_chan_to_freq(uint8_t chan) 502 { 503 return 0; 504 } 505 #endif 506 /** 507 * utils_dfs_update_cur_chan_flags() - Update DFS channel flag and flagext. 508 * @pdev: Pointer to DFS pdev object. 509 * @flags: New channel flags 510 * @flagext: New Extended flags 511 * 512 * Return: QDF_STATUS 513 */ 514 QDF_STATUS utils_dfs_update_cur_chan_flags(struct wlan_objmgr_pdev *pdev, 515 uint64_t flags, 516 uint16_t flagext); 517 518 #ifdef QCA_MCL_DFS_SUPPORT 519 /** 520 * utils_dfs_mark_leaking_ch() - to mark channel leaking in to nol 521 * @pdev: Pointer to pdev structure. 522 * @ch_width: channel width 523 * @temp_ch_lst_sz: the target channel list 524 * @temp_ch_lst: the target channel list 525 * 526 * This function removes the channels from temp channel list that 527 * (if selected as target channel) will cause leakage in one of 528 * the NOL channels 529 * 530 * Return: QDF_STATUS 531 */ 532 QDF_STATUS utils_dfs_mark_leaking_ch(struct wlan_objmgr_pdev *pdev, 533 enum phy_ch_width ch_width, 534 uint8_t temp_ch_lst_sz, 535 uint8_t *temp_ch_lst); 536 #else 537 static inline QDF_STATUS utils_dfs_mark_leaking_ch 538 (struct wlan_objmgr_pdev *pdev, 539 enum phy_ch_width ch_width, 540 uint8_t temp_ch_lst_sz, 541 uint8_t *temp_ch_lst) 542 { 543 return QDF_STATUS_SUCCESS; 544 } 545 #endif 546 /** 547 * utils_get_dfsdomain() - Get DFS domain. 548 * @pdev: Pointer to PDEV structure. 549 * 550 * Return: DFS domain. 551 */ 552 int utils_get_dfsdomain(struct wlan_objmgr_pdev *pdev); 553 554 /** 555 * utils_dfs_get_cur_rd() - Get current regdomain. 556 * @pdev: pdev ptr 557 * 558 * Return: Regdomain pair id. 559 */ 560 uint16_t utils_dfs_get_cur_rd(struct wlan_objmgr_pdev *pdev); 561 562 /** 563 * utils_dfs_is_spoof_check_failed() - get spoof check status. 564 * @pdev: pdev ptr 565 * @is_spoof_check_failed: pointer containing the status. 566 * 567 * Return: QDF_STATUS. 568 */ 569 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) && defined(HOST_DFS_SPOOF_TEST) 570 QDF_STATUS utils_dfs_is_spoof_check_failed(struct wlan_objmgr_pdev *pdev, 571 bool *is_spoof_check_failed); 572 #else 573 static inline 574 QDF_STATUS utils_dfs_is_spoof_check_failed(struct wlan_objmgr_pdev *pdev, 575 bool *is_spoof_check_failed) 576 { 577 return QDF_STATUS_SUCCESS; 578 } 579 #endif 580 #endif /* _WLAN_DFS_UTILS_API_H_ */ 581