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