1 /* 2 * Copyright (c) 2016-2021 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 #include <wlan_objmgr_vdev_obj.h> 31 32 /* Add channel to nol */ 33 #define DFS_NOL_SET 1 34 35 /* Remove channel from nol */ 36 #define DFS_NOL_RESET 0 37 38 /* Mark nol-history flag for the channel */ 39 #define DFS_NOL_HISTORY_SET 1 40 41 /* Clear nol-history flag from the channel */ 42 #define DFS_NOL_HISTORY_RESET 0 43 44 /* Max nol channels */ 45 #define DFS_MAX_NOL_CHANNEL 80 46 47 /* WLAN 2.4GHz start freq */ 48 #define DFS_24_GHZ_BASE_FREQ (2407) 49 50 /* WLAN 5GHz start freq */ 51 #define DFS_5_GHZ_BASE_FREQ (5000) 52 53 /* WLAN 2.4 GHz channel number 6 */ 54 #define DFS_24_GHZ_CHANNEL_6 (6) 55 56 /* WLAN 2.4 GHz channel number 14 */ 57 #define DFS_24_GHZ_CHANNEL_14 (14) 58 59 /* WLAN 2.4 GHz channel number 15 */ 60 #define DFS_24_GHZ_CHANNEL_15 (15) 61 62 /* WLAN 2.4 GHz channel number 27 */ 63 #define DFS_24_GHZ_CHANNEL_27 (27) 64 65 /* WLAN 5GHz channel number 170 */ 66 #define DFS_5_GHZ_CHANNEL_170 (170) 67 68 /* WLAN 5MHz channel spacing */ 69 #define DFS_CHAN_SPACING_5MHZ (5) 70 71 /* WLAN 20Hz channel spacing */ 72 #define DFS_CHAN_SPACING_20MHZ (20) 73 74 /* WLAN 2.4GHz channel number 14 freq */ 75 #define DFS_CHAN_14_FREQ (2484) 76 77 /* WLAN 2.4GHz channel number 15 freq */ 78 #define DFS_CHAN_15_FREQ (2512) 79 80 /* WLAN 5GHz channel number 170 freq */ 81 #define DFS_CHAN_170_FREQ (5852) 82 83 84 85 extern struct dfs_to_mlme global_dfs_to_mlme; 86 87 /** 88 * utils_dfs_cac_valid_reset_for_freq() - Cancels the dfs_cac_valid_timer timer. 89 * @pdev: Pointer to DFS pdev object. 90 * @prevchan_freq: Prevchan frequency. 91 * @prevchan_flags: Prevchan flags. 92 * 93 * Wrapper function for dfs_cac_valid_reset_for_freq(). This function called 94 * from outside of DFS component. 95 */ 96 #ifdef CONFIG_CHAN_FREQ_API 97 QDF_STATUS utils_dfs_cac_valid_reset_for_freq(struct wlan_objmgr_pdev *pdev, 98 uint16_t prevchan_freq, 99 uint32_t prevchan_flags); 100 #endif 101 102 /** 103 * utils_dfs_reset() - Reset DFS members. 104 * @pdev: Pointer to DFS pdev object. 105 */ 106 QDF_STATUS utils_dfs_reset(struct wlan_objmgr_pdev *pdev); 107 108 /** 109 * utils_dfs_is_freq_in_nol() - check if given channel in nol list 110 * @pdev: Pointer to DFS pdev object 111 * @freq: channel frequency 112 * 113 * check if given channel in nol list. 114 * 115 * Return: true if channel in nol, false else 116 */ 117 bool utils_dfs_is_freq_in_nol(struct wlan_objmgr_pdev *pdev, uint32_t freq); 118 119 /** 120 * utils_dfs_reset_precaclists() - Clears and initializes precac_list. 121 * @pdev: Pointer to DFS pdev object. 122 * 123 * Wrapper function for dfs_reset_precaclists(). This function called from 124 * outside of DFS component. 125 */ 126 QDF_STATUS utils_dfs_reset_precaclists(struct wlan_objmgr_pdev *pdev); 127 128 /** 129 * utils_dfs_unmark_precac_nol_for_freq() - Clears precac channel marked as NOL. 130 * @pdev: Pointer to DFS pdev object. 131 * @chan_freq: channel freq to be unmarked as NOL. 132 * 133 * Return void. 134 */ 135 #ifdef CONFIG_CHAN_FREQ_API 136 void utils_dfs_unmark_precac_nol_for_freq(struct wlan_objmgr_pdev *pdev, 137 uint16_t chan_freq); 138 #endif 139 140 /** 141 * utils_dfs_cancel_precac_timer() - Cancel the precac timer. 142 * @pdev: Pointer to DFS pdev object. 143 * 144 * wrapper function for dfs_cancel_precac_timer(). this function called from 145 * outside of dfs component. 146 */ 147 QDF_STATUS utils_dfs_cancel_precac_timer(struct wlan_objmgr_pdev *pdev); 148 149 /** 150 * utils_dfs_start_precac_timer() - Start the precac timer. 151 * @pdev: Pointer to DFS pdev object. 152 * 153 * Wrapper function for dfs_start_precac_timer(). This function called from 154 * outside of dfs component. 155 * 156 * Return: 157 * * QDF_STATUS_E_FAILURE: Failed to start timer. 158 * * QDF_STATUS_SUCCESS: Timer started successfully. 159 */ 160 QDF_STATUS utils_dfs_start_precac_timer(struct wlan_objmgr_pdev *pdev); 161 162 #ifdef WLAN_DFS_PRECAC_AUTO_CHAN_SUPPORT 163 /** 164 * utils_dfs_precac_decide_pref_chan_for_freq() - Choose preferred channel 165 * @pdev: Pointer to DFS pdev object. 166 * @ch_freq: Pointer to channel frequency. 167 * @mode: Configured PHY mode. 168 * 169 * Wrapper function for dfs_decide_precac_preferred_chan_for_freq(). This 170 * function called from outside of dfs component. 171 * 172 * Return: True if intermediate channel needs to configure. False otherwise. 173 */ 174 #ifdef CONFIG_CHAN_FREQ_API 175 bool 176 utils_dfs_precac_decide_pref_chan_for_freq(struct wlan_objmgr_pdev *pdev, 177 uint16_t *ch_freq, 178 enum wlan_phymode mode); 179 #endif 180 #endif 181 182 /** 183 * utils_dfs_cancel_cac_timer() - Cancels the CAC timer. 184 * @pdev: Pointer to DFS pdev object. 185 * 186 * wrapper function for dfs_cancel_cac_timer(). this 187 * function called from outside of dfs component. 188 */ 189 QDF_STATUS utils_dfs_cancel_cac_timer(struct wlan_objmgr_pdev *pdev); 190 191 /** 192 * utils_dfs_start_cac_timer() - Starts the CAC timer. 193 * @pdev: Pointer to DFS pdev object. 194 * 195 * wrapper function for dfs_start_cac_timer(). this 196 * function called from outside of dfs component. 197 */ 198 QDF_STATUS utils_dfs_start_cac_timer(struct wlan_objmgr_pdev *pdev); 199 200 /** 201 * utils_dfs_cac_stop() - Clear the AP CAC timer. 202 * @pdev: Pointer to DFS pdev object. 203 * 204 * wrapper function for dfs_cac_stop(). this 205 * function called from outside of dfs component. 206 */ 207 QDF_STATUS utils_dfs_cac_stop(struct wlan_objmgr_pdev *pdev); 208 209 /** 210 * utils_dfs_stacac_stop() - Clear the STA CAC timer. 211 * @pdev: Pointer to DFS pdev object. 212 * 213 * wrapper function for dfs_stacac_stop(). this 214 * function called from outside of dfs component. 215 */ 216 QDF_STATUS utils_dfs_stacac_stop(struct wlan_objmgr_pdev *pdev); 217 218 /** 219 * utils_dfs_get_usenol() - Returns use_nol flag. 220 * @pdev: Pointer to DFS pdev object. 221 * @usenol: Pointer to usenol value. 222 * 223 * wrapper function for dfs_get_usenol(). this 224 * function called from outside of dfs component. 225 */ 226 QDF_STATUS utils_dfs_get_usenol(struct wlan_objmgr_pdev *pdev, 227 uint16_t *usenol); 228 /* 229 * utils_dfs_radar_disable() - Disables the radar. 230 * @pdev: Pointer to DFS pdev object. 231 * 232 * Return: true if Spruce spur WAR is applicable else false. 233 * 234 * Spur or leakage transmissions is observed in Spruce HW in 235 * frequencies from 5260MHz to 5320MHz when one of the following 236 * conditions is true, 237 * i) The AP is transmitting in 52/56/60/64 in 80MHz mode and then the AP 238 * moves to the adjacent channel 36/44/48 in 80MHz mode and starts 239 * transmitting. 240 * ii) The AP is transmitting in 36/44/48/52/56/60/64 in 160MHz mode and then 241 * the AP moves to the adjacent channel 36/44/48 in 80MHz mode and starts 242 * transmitting. 243 * 244 * Hence, the spruce spur WAR becomes applicable when, 245 * a) the target is Spruce, 246 * b) the primary channel is 52/56/60/64, and the home channel width is 80MHz. 247 * c) or, the primary channel is 36/44/48/52/56/60/64 and the home channel width 248 * is 160MHz. 249 * 250 * When the conditions (a) and (b) or (c) is true, random channel selection 251 * should make sure to prevent moving to the adjacent channels 36/44/48 in 252 * 80MHz mode. Failing to do so will cause spur transmissions in channel 52 253 * through 64. 254 */ 255 bool utils_dfs_is_spruce_spur_war_applicable(struct wlan_objmgr_pdev *pdev); 256 257 /** 258 * utils_dfs_radar_disable() - Disables the radar. 259 * @pdev: Pointer to DFS pdev object. 260 * 261 * wrapper function for dfs_radar_disable(). this 262 * function called from outside of dfs component. 263 */ 264 QDF_STATUS utils_dfs_radar_disable(struct wlan_objmgr_pdev *pdev); 265 266 /** 267 * utils_dfs_set_update_nol_flag() - Sets update_nol flag. 268 * @pdev: Pointer to DFS pdev object. 269 * @val: update_nol flag. 270 * 271 * wrapper function for dfs_set_update_nol_flag(). this 272 * function called from outside of dfs component. 273 */ 274 QDF_STATUS utils_dfs_set_update_nol_flag(struct wlan_objmgr_pdev *pdev, 275 bool val); 276 277 /** 278 * utils_dfs_get_update_nol_flag() - Returns update_nol flag. 279 * @pdev: Pointer to DFS pdev object. 280 * @nol_flag: Fill nol_flag in this variable. 281 * 282 * wrapper function for dfs_get_update_nol_flag(). this 283 * function called from outside of dfs component. 284 */ 285 QDF_STATUS utils_dfs_get_update_nol_flag(struct wlan_objmgr_pdev *pdev, 286 bool *nol_flag); 287 288 /** 289 * utils_dfs_get_dfs_use_nol() - Get usenol. 290 * @pdev: Pointer to DFS pdev object. 291 * @dfs_use_nol: Pointer to dfs_use_nol. 292 * 293 * wrapper function for dfs_get_dfs_use_nol(). this 294 * function called from outside of dfs component. 295 */ 296 QDF_STATUS utils_dfs_get_dfs_use_nol(struct wlan_objmgr_pdev *pdev, 297 int *dfs_use_nol); 298 299 /** 300 * utils_dfs_get_nol_timeout() - Get NOL timeout. 301 * @pdev: Pointer to DFS pdev object. 302 * @dfs_nol_timeout: Pointer to dfs_nol_timeout. 303 * 304 * wrapper function for dfs_get_nol_timeout(). this 305 * function called from outside of dfs component. 306 */ 307 QDF_STATUS utils_dfs_get_nol_timeout(struct wlan_objmgr_pdev *pdev, 308 int *dfs_nol_timeout); 309 310 /** 311 * utils_dfs_nol_addchan() - Add channel to NOL. 312 * @pdev: Pointer to DFS pdev object. 313 * @chan: channel t o add NOL. 314 * @dfs_nol_timeout: NOL timeout. 315 * 316 * wrapper function for dfs_nol_addchan(). this 317 * function called from outside of dfs component. 318 */ 319 QDF_STATUS utils_dfs_nol_addchan(struct wlan_objmgr_pdev *pdev, 320 uint16_t freq, 321 uint32_t dfs_nol_timeout); 322 323 /** 324 * utils_dfs_nol_update() - NOL update 325 * @pdev: Pointer to DFS pdev object. 326 * 327 * wrapper function for dfs_nol_update(). this 328 * function called from outside of dfs component. 329 */ 330 QDF_STATUS utils_dfs_nol_update(struct wlan_objmgr_pdev *pdev); 331 332 /** 333 * utils_dfs_second_segment_radar_disable() - Disables the second segment radar. 334 * @pdev: Pointer to DFS pdev object. 335 * 336 * This is called when AP detects the radar, to (potentially) disable 337 * the radar code. 338 */ 339 QDF_STATUS utils_dfs_second_segment_radar_disable( 340 struct wlan_objmgr_pdev *pdev); 341 342 /** 343 * utils_dfs_fetch_nol_ie_info() - Fills the arguments with NOL information 344 * needed for sending RCSA. 345 * pdev: Pointer to DFS pdev object. 346 * nol_ie_bandwidth: Minimum DFS subchannel Bandwidth. 347 * nol_ie_startfreq: Radar affected channel list start subchannel's centre 348 * frequency. 349 * nol_ie_bitmap: Bitmap of radar affected subchannels. 350 */ 351 QDF_STATUS utils_dfs_fetch_nol_ie_info(struct wlan_objmgr_pdev *pdev, 352 uint8_t *nol_ie_bandwidth, 353 uint16_t *nol_ie_startfreq, 354 uint8_t *nol_ie_bitmap); 355 356 /** 357 * utils_dfs_set_rcsa_flags() - Set flags that are required for sending 358 * RCSA and NOL IE. 359 * pdev: Pointer to DFS pdev object. 360 * is_rcsa_ie_sent: Boolean to check if RCSA IE should be sent or not. 361 * is_nol_ie_sent: Boolean to check if NOL IE should be sent or not. 362 */ 363 364 QDF_STATUS utils_dfs_set_rcsa_flags(struct wlan_objmgr_pdev *pdev, 365 bool is_rcsa_ie_sent, 366 bool is_nol_ie_sent); 367 368 /** 369 * utils_dfs_get_rcsa_flags() - Get flags that are required for sending 370 * RCSA and NOL IE. 371 * pdev: Pointer to DFS pdev object. 372 * is_rcsa_ie_sent: Boolean to check if RCSA IE should be sent or not. 373 * is_nol_ie_sent: Boolean to check if NOL IE should be sent or not. 374 */ 375 376 QDF_STATUS utils_dfs_get_rcsa_flags(struct wlan_objmgr_pdev *pdev, 377 bool *is_rcsa_ie_sent, 378 bool *is_nol_ie_sent); 379 380 /** 381 * utils_dfs_process_nol_ie_bitmap() - Update NOL with external radar 382 * information. 383 * pdev: Pointer to DFS pdev object. 384 * nol_ie_bandwidth: Minimum DFS subchannel Bandwidth. 385 * nol_ie_startfreq: Radar affected channel list start channel's 386 * centre frequency. 387 * nol_ie_bitmap: Bitmap of radar affected subchannels. 388 * 389 * Return: True if NOL IE should be propagated, else false. 390 */ 391 bool utils_dfs_process_nol_ie_bitmap(struct wlan_objmgr_pdev *pdev, 392 uint8_t nol_ie_bandwidth, 393 uint16_t nol_ie_startfreq, 394 uint8_t nol_ie_bitmap); 395 396 /** 397 * utils_dfs_bw_reduce() - Set bw reduce. 398 * @pdev: Pointer to DFS pdev object. 399 * @bw_reduce: Fill bw_reduce value in this variable. 400 * 401 * Return: QDF_STATUS 402 */ 403 QDF_STATUS utils_dfs_bw_reduce(struct wlan_objmgr_pdev *pdev, 404 bool bw_reduce); 405 406 /** 407 * utils_dfs_is_bw_reduce() - Get bw reduce. 408 * @pdev: Pointer to DFS pdev object. 409 * @bw_reduce: Pointer to get bw_reduce value. 410 * 411 * Return: QDF_STATUS 412 */ 413 QDF_STATUS utils_dfs_is_bw_reduce(struct wlan_objmgr_pdev *pdev, 414 bool *bw_reduce); 415 /** 416 * utils_dfs_set_cac_timer_running() - Sets the cac timer running. 417 * @pdev: Pointer to DFS pdev object. 418 * @val: Set this value to dfs_cac_timer_running variable. 419 */ 420 QDF_STATUS utils_dfs_set_cac_timer_running(struct wlan_objmgr_pdev *pdev, 421 int val); 422 423 /** 424 * utils_dfs_get_nol_chfreq_and_chwidth() - Sets the cac timer running. 425 * @pdev: Pointer to DFS pdev object. 426 * @nollist: Pointer to NOL channel entry. 427 * @nol_chfreq: Pointer to save channel frequency. 428 * @nol_chwidth: Pointer to save channel width. 429 * @index: Index into nol list. 430 */ 431 QDF_STATUS utils_dfs_get_nol_chfreq_and_chwidth(struct wlan_objmgr_pdev *pdev, 432 void *nollist, 433 uint32_t *nol_chfreq, 434 uint32_t *nol_chwidth, 435 int index); 436 437 /** 438 * utils_dfs_get_random_channel_for_freq() - Get random channel. 439 * @pdev: Pointer to DFS pdev object. 440 * @flags: random channel selection flags. 441 * @ch_params: current channel params. 442 * @hw_mode: current operating mode. 443 * @target_chan: Pointer to target_chan freq. 444 * @acs_info: acs range info. 445 * 446 * wrapper function for get_random_chan(). this 447 * function called from outside of dfs component. 448 * 449 * Return: QDF_STATUS 450 */ 451 #ifdef CONFIG_CHAN_FREQ_API 452 QDF_STATUS 453 utils_dfs_get_random_channel_for_freq(struct wlan_objmgr_pdev *pdev, 454 uint16_t flags, 455 struct ch_params *ch_params, 456 uint32_t *hw_mode, uint16_t *target_chan, 457 struct dfs_acs_info *acs_info); 458 #endif 459 460 /** 461 * utils_dfs_get_vdev_random_channel_for_freq() - Get random channel for vdev 462 * @pdev: Pointer to DFS pdev object. 463 * @vdev: vdev of the request 464 * @flags: random channel selection flags. 465 * @ch_params: current channel params. 466 * @hw_mode: current operating mode. 467 * @target_chan: Pointer to target_chan_freq. 468 * @acs_info: acs range info. 469 * 470 * Get random channel based on vdev interface type. If the vdev is null, 471 * the function will get random channel by SAP interface type. 472 * 473 * Return: QDF_STATUS 474 */ 475 #ifdef CONFIG_CHAN_FREQ_API 476 QDF_STATUS utils_dfs_get_vdev_random_channel_for_freq( 477 struct wlan_objmgr_pdev *pdev, struct wlan_objmgr_vdev *vdev, 478 uint16_t flags, struct ch_params *ch_params, uint32_t *hw_mode, 479 uint16_t *target_chan_freq, struct dfs_acs_info *acs_info); 480 #endif 481 482 /** 483 * utils_dfs_bw_reduced_channel_for_freq() - Get BW reduced channel. 484 * @pdev: Pointer to DFS pdev object. 485 * @ch_params: current channel params. 486 * @hw_mode: current operating mode. 487 * @target_chan: Pointer to target_chan freq. 488 * 489 * wrapper function for get bw_reduced_channel. this 490 * function called from outside of dfs component. 491 * 492 * Return: QDF_STATUS 493 */ 494 #ifdef CONFIG_CHAN_FREQ_API 495 QDF_STATUS utils_dfs_bw_reduced_channel_for_freq(struct wlan_objmgr_pdev *pdev, 496 struct ch_params *ch_params, 497 uint32_t *hw_mode, 498 uint16_t *target_chan_freq); 499 #endif 500 501 /** 502 * utils_dfs_init_nol() - Initialize nol from platform driver. 503 * @pdev: pdev handler. 504 * 505 * Initialize nol from platform driver. 506 * 507 * Return: None 508 */ 509 #ifdef QCA_DFS_NOL_PLATFORM_DRV_SUPPORT 510 void utils_dfs_init_nol(struct wlan_objmgr_pdev *pdev); 511 #else 512 static inline void utils_dfs_init_nol(struct wlan_objmgr_pdev *pdev) 513 { 514 } 515 #endif 516 /** 517 * utils_dfs_save_nol() - save nol list to platform driver. 518 * @pdev: pdev handler. 519 * 520 * Save nol list to platform driver. 521 * 522 * Return: None 523 */ 524 void utils_dfs_save_nol(struct wlan_objmgr_pdev *pdev); 525 526 /** 527 * utils_dfs_print_nol_channels() - log nol channels. 528 * @pdev: pdev handler. 529 * 530 * log nol channels. 531 * 532 * Return: None 533 */ 534 #ifdef DFS_COMPONENT_ENABLE 535 void utils_dfs_print_nol_channels(struct wlan_objmgr_pdev *pdev); 536 #else 537 static inline void utils_dfs_print_nol_channels(struct wlan_objmgr_pdev *pdev) 538 { 539 } 540 #endif 541 542 /** 543 * utils_dfs_clear_nol_channels() - clear nol list. 544 * @pdev: pdev handler. 545 * 546 * log nol channels. 547 * 548 * Return: None 549 */ 550 void utils_dfs_clear_nol_channels(struct wlan_objmgr_pdev *pdev); 551 552 /** 553 * utils_is_dfs_chan_for_freq() - is channel dfs. 554 * @pdev: pdev handler. 555 * @chan_freq: Channel frequency in MHZ. 556 * 557 * is channel dfs. 558 * 559 * Return: True if channel dfs, else false. 560 */ 561 #ifdef CONFIG_CHAN_FREQ_API 562 static inline bool utils_is_dfs_chan_for_freq(struct wlan_objmgr_pdev *pdev, 563 uint32_t chan_freq) 564 { 565 return wlan_reg_is_dfs_for_freq(pdev, chan_freq); 566 } 567 #endif 568 569 /** 570 * utils_is_dfs_cfreq2_ch() - is channel dfs cfreq2. 571 * @pdev: pdev handler. 572 * 573 * is channel dfs. 574 * 575 * Return: True if channel dfs cfreq2, else false. 576 */ 577 bool utils_is_dfs_cfreq2_ch(struct wlan_objmgr_pdev *pdev); 578 579 /** 580 * utils_dfs_reg_update_nol_chan_for_freq() - set nol channel 581 * 582 * @pdev: pdev ptr 583 * @ch_list: freq channel list to be returned 584 * @num_ch: number of channels 585 * @nol_ch: nol flag 586 * 587 * Return: void 588 */ 589 #ifdef CONFIG_CHAN_FREQ_API 590 void utils_dfs_reg_update_nol_chan_for_freq(struct wlan_objmgr_pdev *pdev, 591 uint16_t *ch_list, 592 uint8_t num_ch, 593 bool nol_ch); 594 #endif 595 /** 596 * utils_dfs_freq_to_chan () - convert channel freq to channel number 597 * @freq: frequency 598 * 599 * Return: channel number 600 */ 601 uint8_t utils_dfs_freq_to_chan(uint32_t freq); 602 603 /** 604 * utils_dfs_chan_to_freq () - convert channel number to frequency 605 * @chan: channel number 606 * 607 * Return: frequency 608 */ 609 #ifdef DFS_COMPONENT_ENABLE 610 uint32_t utils_dfs_chan_to_freq(uint8_t chan); 611 #else 612 static inline uint32_t utils_dfs_chan_to_freq(uint8_t chan) 613 { 614 return 0; 615 } 616 #endif 617 /** 618 * utils_dfs_update_cur_chan_flags() - Update DFS channel flag and flagext. 619 * @pdev: Pointer to DFS pdev object. 620 * @flags: New channel flags 621 * @flagext: New Extended flags 622 * 623 * Return: QDF_STATUS 624 */ 625 QDF_STATUS utils_dfs_update_cur_chan_flags(struct wlan_objmgr_pdev *pdev, 626 uint64_t flags, 627 uint16_t flagext); 628 629 #ifdef MOBILE_DFS_SUPPORT 630 /** 631 * utils_dfs_mark_leaking_chan_for_freq() - to mark channel leaking in to nol 632 * @pdev: Pointer to pdev structure. 633 * @ch_width: channel width 634 * @temp_ch_lst_sz: the target channel list 635 * @temp_ch_lst: the target frequency list 636 * 637 * This function removes the channels from temp channel list that 638 * (if selected as target channel) will cause leakage in one of 639 * the NOL channels 640 * 641 * Return: QDF_STATUS 642 */ 643 #ifdef CONFIG_CHAN_FREQ_API 644 QDF_STATUS utils_dfs_mark_leaking_chan_for_freq(struct wlan_objmgr_pdev *pdev, 645 enum phy_ch_width ch_width, 646 uint8_t temp_ch_lst_sz, 647 uint16_t *temp_ch_lst); 648 #endif 649 650 /** 651 * utils_dfs_can_ignore_radar_event() - check whether to skip radar event 652 * processing 653 * @pdev: Pointer to pdev structure. 654 * 655 * This function will check with policy mgr to process radar event or not based 656 * on current concurrency mode and dfs policy. 657 * 658 * Return: true - ignore radar event processing, otherwise false. 659 */ 660 bool utils_dfs_can_ignore_radar_event(struct wlan_objmgr_pdev *pdev); 661 #else 662 #ifdef CONFIG_CHAN_FREQ_API 663 static inline QDF_STATUS utils_dfs_mark_leaking_chan_for_freq 664 (struct wlan_objmgr_pdev *pdev, 665 enum phy_ch_width ch_width, 666 uint8_t temp_ch_lst_sz, 667 uint16_t *temp_ch_lst) 668 { 669 return QDF_STATUS_SUCCESS; 670 } 671 #endif 672 static inline bool 673 utils_dfs_can_ignore_radar_event(struct wlan_objmgr_pdev *pdev) 674 { 675 return false; 676 } 677 #endif 678 /** 679 * utils_get_dfsdomain() - Get DFS domain. 680 * @pdev: Pointer to PDEV structure. 681 * 682 * Return: DFS domain. 683 */ 684 int utils_get_dfsdomain(struct wlan_objmgr_pdev *pdev); 685 686 /** 687 * utils_dfs_get_cur_rd() - Get current regdomain. 688 * @pdev: pdev ptr 689 * 690 * Return: Regdomain pair id. 691 */ 692 uint16_t utils_dfs_get_cur_rd(struct wlan_objmgr_pdev *pdev); 693 694 /** 695 * utils_dfs_is_spoof_check_failed() - get spoof check status. 696 * @pdev: pdev ptr 697 * @is_spoof_check_failed: pointer containing the status. 698 * 699 * Return: QDF_STATUS. 700 701 * utils_dfs_is_spoof_done() - get spoof check status. 702 * @pdev: pdev ptr 703 * 704 * Return: True if dfs_spoof_test_done is set. 705 */ 706 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) && defined(HOST_DFS_SPOOF_TEST) 707 QDF_STATUS utils_dfs_is_spoof_check_failed(struct wlan_objmgr_pdev *pdev, 708 bool *is_spoof_check_failed); 709 710 bool utils_dfs_is_spoof_done(struct wlan_objmgr_pdev *pdev); 711 #else 712 static inline 713 QDF_STATUS utils_dfs_is_spoof_check_failed(struct wlan_objmgr_pdev *pdev, 714 bool *is_spoof_check_failed) 715 { 716 return QDF_STATUS_SUCCESS; 717 } 718 719 static inline 720 bool utils_dfs_is_spoof_done(struct wlan_objmgr_pdev *pdev) 721 { 722 return true; 723 } 724 #endif 725 726 /** 727 * dfs_get_num_chans() - Get the number of channels supported by the regulatory. 728 * 729 * Return: Number of supported channels. 730 */ 731 int dfs_get_num_chans(void); 732 733 /** 734 * utils_dfs_get_chan_list() - Get channel list from regdb. 735 * @pdev: Pointer to DFS pdev object. 736 * @clist: Pointer to current channel list 737 * @num_chan: number of channels in the current channel list. 738 */ 739 void utils_dfs_get_chan_list(struct wlan_objmgr_pdev *pdev, 740 void *clist, 741 uint32_t *num_chan); 742 743 /** 744 * utils_dfs_get_nol_history_chan_list() - Get nol_history channels from regdb 745 * component. 746 * @pdev: Pointer to pdev structure. 747 * @clist: Pointer to channel list. 748 * @num_chan: number of channels. 749 */ 750 void utils_dfs_get_nol_history_chan_list(struct wlan_objmgr_pdev *pdev, 751 void *clist, uint32_t *num_chan); 752 753 /** 754 * utils_dfs_reg_update_nol_history_chan_for_freq() - set nol history channel 755 * 756 * @pdev: pdev ptr 757 * @ch_list: freq channel list to be returned 758 * @num_ch: number of channels 759 * @nol_history_ch: nol history flag 760 * 761 * Return: void 762 */ 763 #ifdef CONFIG_CHAN_FREQ_API 764 void utils_dfs_reg_update_nol_history_chan_for_freq(struct wlan_objmgr_pdev *, 765 uint16_t *freq_list, 766 uint8_t num_ch, 767 bool nol_history_ch); 768 #endif 769 770 /** 771 * utils_dfs_is_cac_required() - Check if CAC is required on the cur_chan. 772 * @pdev: pdev ptr 773 * @cur_chan: Pointer to current channel of wlan_channel structure. 774 * @prev_chan: Pointer to previous channel of wlan_channel structure. 775 * @continue_current_cac: If AP can start CAC then this variable indicates 776 * whether to continue with the current CAC or restart the CAC. This variable 777 * is valid only if this function returns true. 778 * 779 * Return: true if AP requires CAC or can continue current CAC, else false. 780 */ 781 bool utils_dfs_is_cac_required(struct wlan_objmgr_pdev *pdev, 782 struct wlan_channel *cur_chan, 783 struct wlan_channel *prev_chan, 784 bool *continue_current_cac); 785 786 /** 787 * utils_dfs_is_cac_required_on_dfs_curchan() - Check if CAC is required on the 788 * dfs_curchan. 789 * @pdev: pdev ptr 790 * @continue_current_cac: If AP can start CAC then this variable indicates 791 * whether to continue with the current CAC or restart the CAC. This variable 792 * is valid only if this function returns true. 793 * @is_vap_restart: Flag to indicate if vap is restarted/started. 794 * True: VAP restart. False: VAP start 795 * 796 * This API checks if the dfs_curchan is a subset of the dfs_prevchan. 797 * dfs_curchan and dfs_prevchan are updated after start response by 798 * dfs_set_current_channel(). 799 * 800 * Return: true if AP requires CAC or can continue current CAC, else false. 801 */ 802 bool 803 utils_dfs_is_cac_required_on_dfs_curchan(struct wlan_objmgr_pdev *pdev, 804 bool *continue_current_cac, 805 bool is_vap_restart); 806 807 /** utils_dfs_is_precac_done() - Check if precac has been done in chosen channel 808 * @pdev: Pointer to DFS pdev object. 809 * @wlan_chan: Pointer to wlan channel object that can be accessed by other 810 * components. 811 * Wrapper function for dfs_is_precac_done(). This API is called from outside 812 * the dfs component. 813 * 814 * Return: 815 * * True :If precac is done on channel. 816 * * False:If precac is not done on channel. 817 */ 818 bool utils_dfs_is_precac_done(struct wlan_objmgr_pdev *pdev, 819 struct wlan_channel *wlan_chan); 820 /** 821 * utils_dfs_get_disable_radar_marking() - Retrieve the value of disable radar. 822 * marking. 823 * @pdev: Pointer to DFS pdev object. 824 * @dis_radar_marking: pointer to retrieve the value of disable_radar_marking. 825 */ 826 #if defined(WLAN_DFS_FULL_OFFLOAD) && defined(QCA_DFS_NOL_OFFLOAD) 827 QDF_STATUS utils_dfs_get_disable_radar_marking(struct wlan_objmgr_pdev *pdev, 828 bool *disable_radar_marking); 829 #else 830 static inline 831 QDF_STATUS utils_dfs_get_disable_radar_marking(struct wlan_objmgr_pdev *pdev, 832 bool *disable_radar_marking) 833 { 834 return QDF_STATUS_SUCCESS; 835 } 836 #endif 837 838 /** 839 * utils_dfs_deliver_event() - Deliver DFS event to userspace. 840 * @pdev: Pointer to DFS pdev object 841 * @chan: channel radar hit on 842 * @event: event being sent 843 */ 844 void utils_dfs_deliver_event(struct wlan_objmgr_pdev *pdev, uint16_t freq, 845 enum WLAN_DFS_EVENTS event); 846 847 /** 848 * utils_dfs_reset_dfs_prevchan() - Reset DFS previous channel structure. 849 * @pdev: Pointer to DFS pdev object. 850 * 851 * Return: None. 852 */ 853 void utils_dfs_reset_dfs_prevchan(struct wlan_objmgr_pdev *pdev); 854 855 #ifdef QCA_SUPPORT_AGILE_DFS 856 /** 857 * utils_dfs_agile_sm_deliver_evt() - API to post events to DFS Agile SM. 858 * @pdev: Pointer to DFS pdev object. 859 * @event: Event to be posted to DFS AGILE SM. 860 * 861 * Return: None. 862 */ 863 void utils_dfs_agile_sm_deliver_evt(struct wlan_objmgr_pdev *pdev, 864 enum dfs_agile_sm_evt event); 865 #else 866 static inline 867 void utils_dfs_agile_sm_deliver_evt(struct wlan_objmgr_pdev *pdev, 868 enum dfs_agile_sm_evt event) 869 { 870 } 871 #endif/*QCA_SUPPORT_AGILE_DFS*/ 872 873 #ifdef QCA_SUPPORT_ADFS_RCAC 874 /** 875 * utils_dfs_get_rcac_channel() - Get the completed Rolling CAC channel if 876 * available. 877 * @pdev: Pointer to DFS pdev object. 878 * @ch_params: current channel params. 879 * @target_chan: Pointer to target_chan freq. 880 * 881 * Return: QDF_STATUS. 882 */ 883 QDF_STATUS utils_dfs_get_rcac_channel(struct wlan_objmgr_pdev *pdev, 884 struct ch_params *chan_params, 885 qdf_freq_t *target_chan_freq); 886 #else 887 static inline 888 QDF_STATUS utils_dfs_get_rcac_channel(struct wlan_objmgr_pdev *pdev, 889 struct ch_params *chan_params, 890 qdf_freq_t *target_chan_freq) 891 { 892 return QDF_STATUS_SUCCESS; 893 } 894 #endif /* QCA_SUPPORT_ADFS_RCAC */ 895 896 #ifdef ATH_SUPPORT_ZERO_CAC_DFS 897 /** 898 * utils_dfs_precac_status_for_channel() - API to find the preCAC status 899 * of the given channel. 900 * @pdev: Pointer to DFS pdev object. 901 * @deschan: Pointer to desired channel of wlan_channel structure. 902 */ 903 enum precac_status_for_chan 904 utils_dfs_precac_status_for_channel(struct wlan_objmgr_pdev *pdev, 905 struct wlan_channel *deschan); 906 #else 907 static inline enum precac_status_for_chan 908 utils_dfs_precac_status_for_channel(struct wlan_objmgr_pdev *pdev, 909 struct wlan_channel *deschan) 910 { 911 return DFS_INVALID_PRECAC_STATUS; 912 } 913 #endif 914 915 #if defined(WLAN_DISP_CHAN_INFO) 916 /** 917 * utils_dfs_get_chan_dfs_state() - Get the channel state array of the channels 918 * in a radio. 919 * @pdev: Pointer to the pdev. 920 * @dfs_ch_s: Output channel state array of the dfs channels in the radio. 921 * 922 * Return: QDF_STATUS. 923 */ 924 QDF_STATUS utils_dfs_get_chan_dfs_state(struct wlan_objmgr_pdev *pdev, 925 enum channel_dfs_state *dfs_ch_s); 926 927 /** 928 * utils_dfs_update_chan_state_array() - Update the channel state of the dfs 929 * channel indicated by the frequency. The dfs event is converted to 930 * appropriate dfs state. 931 * @pdev: Pointer to the pdev. 932 * @freq: Input frequency. 933 * @event: Input dfs event. 934 * 935 * Return: QDF_STATUS. 936 */ 937 QDF_STATUS utils_dfs_update_chan_state_array(struct wlan_objmgr_pdev *pdev, 938 qdf_freq_t freq, 939 enum WLAN_DFS_EVENTS event); 940 941 /** 942 * dfs_init_chan_state_array() - Initialize the dfs channel state array. 943 * 944 * @pdev: Pointer to the pdev. 945 * 946 * Return: QDF_STATUS. 947 */ 948 QDF_STATUS dfs_init_chan_state_array(struct wlan_objmgr_pdev *pdev); 949 #else 950 static inline 951 QDF_STATUS utils_dfs_get_chan_dfs_state(struct wlan_objmgr_pdev *pdev, 952 enum channel_dfs_state *dfs_ch_s) 953 { 954 return QDF_STATUS_E_NOSUPPORT; 955 } 956 957 static inline 958 QDF_STATUS utils_dfs_update_chan_state_array(struct wlan_objmgr_pdev *pdev, 959 uint16_t freq, 960 enum WLAN_DFS_EVENTS event) 961 { 962 return QDF_STATUS_E_NOSUPPORT; 963 } 964 965 static inline 966 QDF_STATUS dfs_init_chan_state_array(struct wlan_objmgr_pdev *pdev) 967 { 968 return QDF_STATUS_E_NOSUPPORT; 969 } 970 #endif /* WLAN_DISP_CHAN_INFO */ 971 972 /** 973 * utils_dfs_radar_enable() - Enables the radar. 974 * @pdev: Pointer to DFS pdev object. 975 * 976 * This is called each time for eCSA occurs but don't change channel due 977 * to channel switch disabled in dfs test mode. 978 * 979 * Return: QDF_STATUS. 980 */ 981 QDF_STATUS utils_dfs_radar_enable(struct wlan_objmgr_pdev *pdev); 982 #endif /* _WLAN_DFS_UTILS_API_H_ */ 983