1 /* 2 * Copyright (c) 2016-2020 The Linux Foundation. All rights reserved. 3 * Copyright (c) 2007-2008 Sam Leffler, Errno Consulting 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27 /** 28 * DOC: This file has Zero CAC DFS APIs. 29 */ 30 31 #ifndef _DFS_ZERO_CAC_H_ 32 #define _DFS_ZERO_CAC_H_ 33 34 #include "dfs.h" 35 #include <wlan_dfs_tgt_api.h> 36 37 #ifdef CONFIG_CHAN_NUM_API 38 #define VHT160_IEEE_FREQ_DIFF 16 39 #endif 40 41 #define OCAC_SUCCESS 0 42 #define OCAC_RESET 1 43 #define OCAC_CANCEL 2 44 45 #define TREE_DEPTH_MAX TREE_DEPTH_160 46 #define TREE_DEPTH_160 4 47 #define TREE_DEPTH_80 3 48 #define TREE_DEPTH_40 2 49 #define TREE_DEPTH_20 1 50 #define N_SUBCHANS_FOR_80BW 4 51 #define N_SUBCHANS_FOR_160BW 8 52 53 #define INITIAL_20_CHAN_OFFSET -6 54 #define INITIAL_40_CHAN_OFFSET -4 55 #define INITIAL_80_CHAN_OFFSET 0 56 57 #define NEXT_20_CHAN_OFFSET 4 58 #define NEXT_40_CHAN_OFFSET 8 59 #define NEXT_80_CHAN_OFFSET 16 60 61 #define DFS_CHWIDTH_20_VAL 20 62 #define DFS_CHWIDTH_40_VAL 40 63 #define DFS_CHWIDTH_80_VAL 80 64 #define DFS_CHWIDTH_160_VAL 160 65 #define DFS_CHWIDTH_165_VAL 165 66 67 #define WEATHER_CHAN_START 120 68 #define WEATHER_CHAN_END 128 69 70 /* PreCAC timeout durations in ms. */ 71 #define MIN_PRECAC_DURATION (6 * 60 * 1000) /* 6 mins */ 72 #define MIN_WEATHER_PRECAC_DURATION (60 * 60 * 1000) /* 1 hour */ 73 #define MAX_PRECAC_DURATION (4 * 60 * 60 * 1000) /* 4 hours */ 74 #define MAX_WEATHER_PRECAC_DURATION (24 * 60 * 60 * 1000) /* 24 hours */ 75 #define MIN_RCAC_DURATION (62 * 1000) /* 62 seconds */ 76 #define MAX_RCAC_DURATION 0xffffffff 77 78 #define PCAC_DFS_INDEX_ZERO 0 79 #define PCAC_TIMER_NOT_RUNNING 0 80 #define PRECAC_NOT_STARTED 0 81 82 /* While building precac tree, the center of the 165MHz channel or the 83 * restricted 80p80 channel(which includes channels 132, 136, 140, 144, 84 * 149, 153, 157 and 161) is assumed to be 146(center channel) or 85 * 5730(center frequency). 86 */ 87 #define RESTRICTED_80P80_CHAN_CENTER_FREQ 5730 88 #define RESTRICTED_80P80_LEFT_80_CENTER_CHAN 138 89 #define RESTRICTED_80P80_RIGHT_80_CENTER_CHAN 155 90 #define RESTRICTED_80P80_LEFT_80_CENTER_FREQ 5690 91 #define RESTRICTED_80P80_RIGHT_80_CENTER_FREQ 5775 92 #define DEPTH_160_ROOT 0 93 #define DEPTH_80_ROOT 1 94 #define DEPTH_40_ROOT 2 95 #define DEPTH_20_ROOT 3 96 97 /** 98 * struct precac_tree_node - Individual tree node structure for every node in 99 * the precac forest maintained. 100 * @left_child: Pointer to the left child of the node. 101 * @right_child: Pointer to the right child of the node. 102 * @ch_ieee: Center channel ieee value. 103 * @ch_freq: Center channel frequency value (BSTree node key value). 104 * @n_caced_subchs: Number of CACed subchannels of the ch_ieee. 105 * @n_nol_subchs: Number of subchannels of the ch_ieee in NOL. 106 * @n_valid_subchs: Number of subchannels of the ch_ieee available (as per 107 * the country's channel list). 108 * @bandwidth: Bandwidth of the ch_ieee (in the current node). 109 * @depth: Depth of the precac tree node. 110 */ 111 struct precac_tree_node { 112 struct precac_tree_node *left_child; 113 struct precac_tree_node *right_child; 114 uint8_t ch_ieee; 115 uint16_t ch_freq; 116 uint8_t n_caced_subchs; 117 uint8_t n_nol_subchs; 118 uint8_t n_valid_subchs; 119 uint8_t bandwidth; 120 uint8_t depth; 121 }; 122 123 /** 124 * enum precac_chan_state - Enum for PreCAC state of a channel. 125 * @PRECAC_ERR: Invalid preCAC state. 126 * @PRECAC_REQUIRED: preCAC need to be done on the channel. 127 * @PRECAC_NOW: preCAC is running on the channel. 128 * @PRECAC_DONE: preCAC is done and channel is clear. 129 * @PRECAC_NOL: preCAC is done and radar is detected. 130 */ 131 enum precac_chan_state { 132 PRECAC_ERR = -1, 133 PRECAC_REQUIRED, 134 PRECAC_NOW, 135 PRECAC_DONE, 136 PRECAC_NOL, 137 }; 138 139 /** 140 * struct dfs_precac_entry - PreCAC entry. 141 * @pe_list: PreCAC entry. 142 * @vht80_ch_ieee: VHT80 centre channel IEEE value. 143 * @vht80_ch_freq: VHT80 centre channel frequency value. 144 * @center_ch_ieee: Center channel IEEE value of given bandwidth 20/40/80/ 145 * 160. For 165MHz channel, the value is 146. 146 * @center_ch_freq: Center frequency of given bandwidth 20/40/80/160. For 147 * 165MHz channel, the value is 5730. 148 * @bw: Bandwidth of the precac entry. 149 * @dfs: Pointer to wlan_dfs structure. 150 * @tree_root: Tree root node with 80MHz channel key. 151 * @non_dfs_subch_count: Number of non DFS subchannels in the entry. 152 */ 153 struct dfs_precac_entry { 154 TAILQ_ENTRY(dfs_precac_entry) pe_list; 155 uint8_t vht80_ch_ieee; 156 uint16_t vht80_ch_freq; 157 uint8_t center_ch_ieee; 158 uint16_t center_ch_freq; 159 uint16_t bw; 160 struct wlan_dfs *dfs; 161 struct precac_tree_node *tree_root; 162 uint8_t non_dfs_subch_count; 163 }; 164 165 /** 166 * dfs_zero_cac_timer_init() - Initialize zero-cac timers 167 * @dfs_soc_obj: Pointer to DFS SOC object structure. 168 */ 169 #if defined(ATH_SUPPORT_ZERO_CAC_DFS) && !defined(QCA_MCL_DFS_SUPPORT) 170 void dfs_zero_cac_timer_init(struct dfs_soc_priv_obj *dfs_soc_obj); 171 #else 172 static inline void 173 dfs_zero_cac_timer_init(struct dfs_soc_priv_obj *dfs_soc_obj) 174 { 175 } 176 #endif 177 /** 178 * dfs_print_precaclists() - Print precac list. 179 * @dfs: Pointer to wlan_dfs structure. 180 */ 181 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) && !defined(QCA_MCL_DFS_SUPPORT) 182 void dfs_print_precaclists(struct wlan_dfs *dfs); 183 #else 184 static inline void dfs_print_precaclists(struct wlan_dfs *dfs) 185 { 186 } 187 #endif 188 189 /** 190 * dfs_reset_precac_lists() - Resets the precac lists. 191 * @dfs: Pointer to wlan_dfs structure. 192 */ 193 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) && !defined(QCA_MCL_DFS_SUPPORT) 194 void dfs_reset_precac_lists(struct wlan_dfs *dfs); 195 #else 196 static inline void dfs_reset_precac_lists(struct wlan_dfs *dfs) 197 { 198 } 199 #endif 200 201 /** 202 * dfs_reset_precaclists() - Clears and initializes precac_list. 203 * @dfs: Pointer to wlan_dfs structure. 204 */ 205 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) && !defined(QCA_MCL_DFS_SUPPORT) 206 void dfs_reset_precaclists(struct wlan_dfs *dfs); 207 #else 208 static inline void dfs_reset_precaclists(struct wlan_dfs *dfs) 209 { 210 } 211 #endif 212 213 /** 214 * dfs_deinit_precac_list() - Clears the precac list. 215 * @dfs: Pointer to wlan_dfs dtructure. 216 */ 217 void dfs_deinit_precac_list(struct wlan_dfs *dfs); 218 219 /** 220 * dfs_zero_cac_detach() - Free zero_cac memory. 221 * @dfs: Pointer to wlan_dfs dtructure. 222 */ 223 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) && !defined(QCA_MCL_DFS_SUPPORT) 224 void dfs_zero_cac_detach(struct wlan_dfs *dfs); 225 #else 226 static inline void dfs_zero_cac_detach(struct wlan_dfs *dfs) 227 { 228 } 229 #endif 230 231 /** 232 * dfs_init_precac_list() - Init precac list. 233 * @dfs: Pointer to wlan_dfs dtructure. 234 */ 235 void dfs_init_precac_list(struct wlan_dfs *dfs); 236 237 /** 238 * dfs_start_precac_timer() - Start precac timer. 239 * @dfs: Pointer to wlan_dfs structure. 240 * @precac_chan: Start thr precac timer in this channel. 241 */ 242 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) && !defined(QCA_MCL_DFS_SUPPORT) 243 #ifdef CONFIG_CHAN_NUM_API 244 void dfs_start_precac_timer(struct wlan_dfs *dfs, 245 uint8_t precac_chan); 246 #endif 247 248 /** 249 * dfs_start_precac_timer() - Start precac timer. 250 * @dfs: Pointer to wlan_dfs structure. 251 * @precac_chan_freq: Frequency to start precac timer. 252 */ 253 #ifdef CONFIG_CHAN_FREQ_API 254 void dfs_start_precac_timer_for_freq(struct wlan_dfs *dfs, 255 uint16_t precac_chan_freq); 256 #endif 257 #else 258 #ifdef CONFIG_CHAN_NUM_API 259 static inline void dfs_start_precac_timer(struct wlan_dfs *dfs, 260 uint8_t precac_chan) 261 { 262 } 263 #endif 264 #ifdef CONFIG_CHAN_FREQ_API 265 static inline 266 void dfs_start_precac_timer_for_freq(struct wlan_dfs *dfs, 267 uint16_t precac_chan_freq) 268 { 269 } 270 #endif 271 #endif 272 273 /** 274 * dfs_cancel_precac_timer() - Cancel the precac timer. 275 * @dfs: Pointer to wlan_dfs structure. 276 */ 277 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) && !defined(QCA_MCL_DFS_SUPPORT) 278 void dfs_cancel_precac_timer(struct wlan_dfs *dfs); 279 #else 280 static inline void dfs_cancel_precac_timer(struct wlan_dfs *dfs) 281 { 282 } 283 #endif 284 285 /** 286 * dfs_zero_cac_attach() - Initialize dfs zerocac variables. 287 * @dfs: Pointer to DFS structure. 288 */ 289 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) && !defined(QCA_MCL_DFS_SUPPORT) 290 void dfs_zero_cac_attach(struct wlan_dfs *dfs); 291 #else 292 static inline void dfs_zero_cac_attach(struct wlan_dfs *dfs) 293 { 294 } 295 #endif 296 297 /** 298 * dfs_zero_cac_reset() - Reset Zero cac DFS variables. 299 * @dfs: Pointer to wlan_dfs structure. 300 */ 301 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) && !defined(QCA_MCL_DFS_SUPPORT) 302 void dfs_zero_cac_reset(struct wlan_dfs *dfs); 303 #else 304 static inline void dfs_zero_cac_reset(struct wlan_dfs *dfs) 305 { 306 } 307 #endif 308 309 /** 310 * dfs_zero_cac_timer_detach() - Free Zero cac DFS variables. 311 * @dfs_soc_obj: Pointer to dfs_soc_priv_obj structure. 312 */ 313 #if defined(ATH_SUPPORT_ZERO_CAC_DFS) && !defined(QCA_MCL_DFS_SUPPORT) 314 void dfs_zero_cac_timer_detach(struct dfs_soc_priv_obj *dfs_soc_obj); 315 #else 316 static inline void 317 dfs_zero_cac_timer_detach(struct dfs_soc_priv_obj *dfs_soc_obj) 318 { 319 } 320 #endif 321 322 /** 323 * dfs_is_precac_done() - Is precac done. 324 * @dfs: Pointer to wlan_dfs structure. 325 * @chan: Pointer to dfs_channel for which preCAC done is checked. 326 * 327 * Return: 328 * * True: If precac is done on channel. 329 * * False: If precac is not done on channel. 330 */ 331 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) && !defined(QCA_MCL_DFS_SUPPORT) 332 bool dfs_is_precac_done(struct wlan_dfs *dfs, struct dfs_channel *chan); 333 #else 334 static inline bool dfs_is_precac_done(struct wlan_dfs *dfs, 335 struct dfs_channel *chan) 336 { 337 return false; 338 } 339 #endif 340 341 #ifdef WLAN_DFS_PRECAC_AUTO_CHAN_SUPPORT 342 /** 343 * dfs_decide_precac_preferred_chan() - Choose operating channel among 344 * configured DFS channel and 345 * intermediate channel based on 346 * precac status of configured 347 * DFS channel. 348 * @dfs: Pointer to wlan_dfs structure. 349 * @pref_chan: Configured DFS channel. 350 * @mode: Configured PHY mode. 351 * 352 * Return: True if intermediate channel needs to configure. False otherwise. 353 */ 354 #ifdef CONFIG_CHAN_NUM_API 355 bool 356 dfs_decide_precac_preferred_chan(struct wlan_dfs *dfs, 357 uint8_t *pref_chan, 358 enum wlan_phymode mode); 359 #endif 360 361 /** 362 * dfs_decide_precac_preferred_chan_for_freq() - Choose operating channel among 363 * configured DFS channel and 364 * intermediate channel based on 365 * precac status of configured 366 * DFS channel. 367 * @dfs: Pointer to wlan_dfs structure. 368 * @pref_chan: Configured DFS channel frequency 369 * @mode: Configured PHY mode. 370 * 371 * Return: True if intermediate channel needs to configure. False otherwise. 372 */ 373 374 #ifdef CONFIG_CHAN_FREQ_API 375 bool 376 dfs_decide_precac_preferred_chan_for_freq(struct wlan_dfs *dfs, 377 uint16_t *pref_chan_freq, 378 enum wlan_phymode mode); 379 #endif 380 #else 381 #ifdef CONFIG_CHAN_NUM_API 382 static inline void dfs_decide_precac_preferred_chan(struct wlan_dfs *dfs, 383 uint8_t *pref_chan, 384 enum wlan_phymode mode) 385 { 386 } 387 #endif 388 #ifdef CONFIG_CHAN_FREQ_API 389 static inline void 390 dfs_decide_precac_preferred_chan_for_freq(struct wlan_dfs *dfs, 391 uint8_t *pref_chan, 392 enum wlan_phymode mode) 393 { 394 } 395 #endif 396 #endif 397 398 /** 399 * dfs_get_ieeechan_for_precac() - Get chan of required bandwidth from 400 * precac_list. 401 * @dfs: Pointer to wlan_dfs structure. 402 * @exclude_pri_ch_ieee: Primary channel IEEE to be excluded for preCAC. 403 * @exclude_sec_ch_ieee: Secondary channel IEEE to be excluded for preCAC. 404 * @bandwidth: Bandwidth of requested channel. 405 */ 406 #ifdef CONFIG_CHAN_NUM_API 407 uint8_t dfs_get_ieeechan_for_precac(struct wlan_dfs *dfs, 408 uint8_t exclude_pri_ch_ieee, 409 uint8_t exclude_sec_ch_ieee, 410 uint8_t bandwidth); 411 #endif 412 413 /** 414 * dfs_get_ieeechan_for_precac_for_freq() - Get chan of required bandwidth from 415 * precac_list. 416 * @dfs: Pointer to wlan_dfs structure. 417 * @exclude_pri_chan_freq: Primary channel freq to be excluded for preCAC. 418 * @exclude_sec_chan_freq: Secondary channel freq to be excluded for preCAC. 419 * @bandwidth: Bandwidth of requested channel. 420 */ 421 #ifdef CONFIG_CHAN_FREQ_API 422 uint16_t dfs_get_ieeechan_for_precac_for_freq(struct wlan_dfs *dfs, 423 uint16_t exclude_pri_chan_freq, 424 uint16_t exclude_sec_chan_freq, 425 uint8_t bandwidth); 426 #endif 427 428 /** 429 * dfs_override_precac_timeout() - Override the default precac timeout. 430 * @dfs: Pointer to wlan_dfs structure. 431 * @precac_timeout: Precac timeout value. 432 */ 433 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) && !defined(QCA_MCL_DFS_SUPPORT) 434 int dfs_override_precac_timeout(struct wlan_dfs *dfs, 435 int precac_timeout); 436 #else 437 static inline int dfs_override_precac_timeout(struct wlan_dfs *dfs, 438 int precac_timeout) 439 { 440 return 0; 441 } 442 #endif 443 444 /** 445 * dfs_get_override_precac_timeout() - Get precac timeout. 446 * @dfs: Pointer wlan_dfs structure. 447 * @precac_timeout: Get precac timeout value in this variable. 448 */ 449 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) && !defined(QCA_MCL_DFS_SUPPORT) 450 int dfs_get_override_precac_timeout(struct wlan_dfs *dfs, 451 int *precac_timeout); 452 #else 453 static inline int dfs_get_override_precac_timeout(struct wlan_dfs *dfs, 454 int *precac_timeout) 455 { 456 return 0; 457 } 458 #endif 459 460 /** 461 * dfs_find_vht80_chan_for_precac() - Find VHT80 channel for precac. 462 * @dfs: Pointer to wlan_dfs structure. 463 * @chan_mode: Channel mode. 464 * @ch_freq_seg1: Segment1 channel freq. 465 * @cfreq1: cfreq1. 466 * @cfreq2: cfreq2. 467 * @phy_mode: Precac phymode. 468 * @dfs_set_cfreq2: Precac cfreq2 469 * @set_agile: Agile mode flag. 470 * 471 * Zero-CAC-DFS algorithm:- 472 * Zero-CAC-DFS algorithm works in stealth mode. 473 * 1) When any channel change happens in VHT80 mode the algorithm 474 * changes the HW channel mode to VHT80_80/VHT160 mode and adds a 475 * new channel in the secondary VHT80 to perform precac and a 476 * precac timer is started. However the upper layer/UMAC is unaware 477 * of this change. 478 * 2) When the precac timer expires without being interrupted by 479 * any channel change the secondary VHT80 channel is moved from 480 * precac-required-list to precac-done-list. 481 * 3) If there is a radar detect at any time in any segment 482 * (segment-1 is preimary VHT80 and segment-2 is VHT80)then the 483 * channel is searched in both precac-reuired-list and precac-done-list 484 * and moved to precac-nol-list. 485 * 4) Whenever channel change happens if the new channel is a DFS 486 * channel then precac-done-list is searched and if the channel is 487 * found in the precac-done-list then the CAC is skipped. 488 * 5) The precac expiry timer makes a vedv_restart(channel change 489 * with current-upper-layer-channel-mode which is VHT80). In channel 490 * change the algorithm tries to pick a new channel from the 491 * precac-required list. If none found then channel mode remains same. 492 * Which means when all the channels in precac-required-list are 493 * exhausted the VHT80_80/VHT160 comes back to VHT80 mode. 494 */ 495 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) && !defined(QCA_MCL_DFS_SUPPORT) 496 #ifdef CONFIG_CHAN_NUM_API 497 void dfs_find_vht80_chan_for_precac(struct wlan_dfs *dfs, 498 uint32_t chan_mode, 499 uint8_t ch_freq_seg1, 500 uint32_t *cfreq1, 501 uint32_t *cfreq2, 502 uint32_t *phy_mode, 503 bool *dfs_set_cfreq2, 504 bool *set_agile); 505 #endif 506 507 /* 508 * dfs_find_vht80_chan_for_precac() - Find VHT80 channel for precac. 509 * @dfs: Pointer to wlan_dfs structure. 510 * @chan_mode: Channel mode. 511 * @ch_freq_seg1: Segment1 channel freq in mhz. 512 * @cfreq1: cfreq1. 513 * @cfreq2: cfreq2. 514 * @phy_mode: Precac phymode. 515 * @dfs_set_cfreq2: Precac cfreq2 516 * @set_agile: Agile mode flag. 517 */ 518 #ifdef CONFIG_CHAN_FREQ_API 519 void dfs_find_vht80_chan_for_precac_for_freq(struct wlan_dfs *dfs, 520 uint32_t chan_mode, 521 uint16_t ch_freq_seg1_mhz, 522 uint32_t *cfreq1, 523 uint32_t *cfreq2, 524 uint32_t *phy_mode, 525 bool *dfs_set_cfreq2, 526 bool *set_agile); 527 #endif 528 529 #else 530 #ifdef CONFIG_CHAN_NUM_API 531 static inline void dfs_find_vht80_chan_for_precac(struct wlan_dfs *dfs, 532 uint32_t chan_mode, 533 uint8_t ch_freq_seg1, 534 uint32_t *cfreq1, 535 uint32_t *cfreq2, 536 uint32_t *phy_mode, 537 bool *dfs_set_cfreq2, 538 bool *set_agile) 539 { 540 } 541 #endif 542 543 #ifdef CONFIG_CHAN_FREQ_API 544 static inline 545 void dfs_find_vht80_chan_for_precac_for_freq(struct wlan_dfs *dfs, 546 uint32_t chan_mode, 547 uint16_t ch_freq_seg1_mhz, 548 uint32_t *cfreq1, 549 uint32_t *cfreq2, 550 uint32_t *phy_mode, 551 bool *dfs_set_cfreq2, 552 bool *set_agile) 553 { 554 } 555 #endif 556 #endif 557 558 #if defined(QCA_SUPPORT_AGILE_DFS) 559 /** 560 * dfs_find_pdev_for_agile_precac() - Find pdev to select channel for precac. 561 * @pdev: Pointer to wlan_objmgr_pdev structure. 562 * @cur_agile_dfs_index: current agile dfs index 563 */ 564 void dfs_find_pdev_for_agile_precac(struct wlan_objmgr_pdev *pdev, 565 uint8_t *cur_agile_dfs_index); 566 567 /** 568 * dfs_prepare_agile_precac_chan() - Send Agile set request for given pdev. 569 * @dfs: Pointer to wlan_dfs structure. 570 * @is_chan_found: True if a channel is available for PreCAC, false otherwise. 571 */ 572 void dfs_prepare_agile_precac_chan(struct wlan_dfs *dfs, bool *is_chan_found); 573 574 /** 575 * dfs_process_ocac_complete() - Process Off-Channel CAC complete indication. 576 * @pdev :Pointer to wlan_objmgr_pdev structure. 577 * @ocac_status: Off channel CAC complete status 578 * @center_freq1 : For 20/40/80/160Mhz, it is the center of the corresponding 579 * band. For 80P80/165MHz, it is the center of the left 80MHz. 580 * @center_freq2 : It is valid and non-zero only for 80P80/165MHz. It indicates 581 * the Center Frequency of the right 80MHz segment. 582 * @chwidth : Width of the channel for which OCAC completion is received. 583 */ 584 void dfs_process_ocac_complete(struct wlan_objmgr_pdev *pdev, 585 uint32_t ocac_status, 586 uint32_t center_freq1, 587 uint32_t center_freq2, 588 enum phy_ch_width chwidth); 589 590 /** 591 * dfs_get_ieeechan_for_agilecac() - Find an IEEE channel for agile CAC. 592 * @dfs: Pointer to wlan_dfs structure. 593 * @ch_ieee: Pointer to channel number for agile set request. 594 * @pri_ch_ieee: Current primary IEEE channel. 595 * @sec_ch_ieee: Current secondary IEEE channel (in HT80_80 mode). 596 * 597 * Find an IEEE channel for agileCAC which is not the current operating 598 * channels (indicated by pri_ch_ieee, sec_ch_ieee). 599 */ 600 #ifdef CONFIG_CHAN_NUM_API 601 void dfs_get_ieeechan_for_agilecac(struct wlan_dfs *dfs, 602 uint8_t *ch_ieee, 603 uint8_t pri_ch_ieee, 604 uint8_t sec_ch_ieee); 605 #endif 606 607 /** 608 * dfs_set_agilecac_chan_for_freq() - Find chan freq for agile CAC. 609 * @dfs: Pointer to wlan_dfs structure. 610 * @chan_freq: Pointer to channel freq for agile set request. 611 * @pri_chan_freq: Current primary IEEE channel freq. 612 * @sec_chan_freq: Current secondary IEEE channel freq (in HT80_80 mode). 613 * 614 * Find an IEEE channel freq for agileCAC which is not the current operating 615 * channels (indicated by pri_chan_freq, sec_chan_freq). 616 */ 617 #ifdef CONFIG_CHAN_FREQ_API 618 void dfs_set_agilecac_chan_for_freq(struct wlan_dfs *dfs, 619 uint16_t *chan_freq, 620 uint16_t pri_chan_freq, 621 uint16_t sec_chan_freq); 622 #endif 623 624 /** 625 * dfs_agile_precac_start() - Start agile precac. 626 * @dfs: Pointer to wlan_dfs structure. 627 */ 628 void dfs_agile_precac_start(struct wlan_dfs *dfs); 629 630 /** 631 * dfs_start_agile_precac_timer() - Start precac timer for the given channel. 632 * @dfs: Pointer to wlan_dfs structure. 633 * @ocac_status: Status of the off channel CAC. 634 * @adfs_param: Agile DFS CAC parameters. 635 * 636 * Start the precac timer with proper timeout values based on the channel to 637 * be preCACed. The preCAC channel number and chwidth information is present 638 * in the adfs_param argument. Once the timer is started, update the timeout 639 * fields in adfs_param. 640 */ 641 void dfs_start_agile_precac_timer(struct wlan_dfs *dfs, 642 uint8_t ocac_status, 643 struct dfs_agile_cac_params *adfs_param); 644 645 /** 646 * dfs_set_fw_adfs_support() - Set FW aDFS support in dfs object. 647 * @dfs: Pointer to wlan_dfs structure. 648 * @fw_adfs_support_160: aDFS enabled when pdev is on 160/80P80MHz. 649 * @fw_adfs_support_non_160: aDFS enabled when pdev is on 20/40/80MHz. 650 * 651 * Return: void. 652 */ 653 void dfs_set_fw_adfs_support(struct wlan_dfs *dfs, 654 bool fw_adfs_support_160, 655 bool fw_adfs_support_non_160); 656 #else 657 static inline void dfs_find_pdev_for_agile_precac(struct wlan_objmgr_pdev *pdev, 658 uint8_t *cur_agile_dfs_index) 659 { 660 } 661 662 static inline void dfs_prepare_agile_precac_chan(struct wlan_dfs *dfs, 663 bool *is_chan_found) 664 { 665 } 666 667 static inline void 668 dfs_process_ocac_complete(struct wlan_objmgr_pdev *pdev, 669 uint32_t ocac_status, 670 uint32_t center_freq1, 671 uint32_t center_freq2, 672 enum phy_ch_width chwidth) 673 { 674 } 675 676 #ifdef CONFIG_CHAN_NUM_API 677 static inline void dfs_get_ieeechan_for_agilecac(struct wlan_dfs *dfs, 678 uint8_t *ch_ieee, 679 uint8_t pri_ch_ieee, 680 uint8_t sec_ch_ieee) 681 { 682 } 683 #endif 684 685 #ifdef CONFIG_CHAN_FREQ_API 686 static inline void 687 dfs_set_agilecac_chan_for_freq(struct wlan_dfs *dfs, 688 uint16_t *chan_freq, 689 uint16_t pri_chan_freq, 690 uint16_t sec_chan_freq) 691 { 692 } 693 #endif 694 695 static inline void dfs_agile_precac_start(struct wlan_dfs *dfs) 696 { 697 } 698 699 static inline void 700 dfs_start_agile_precac_timer(struct wlan_dfs *dfs, 701 uint8_t ocac_status, 702 struct dfs_agile_cac_params *adfs_param) 703 { 704 } 705 706 static inline void 707 dfs_set_fw_adfs_support(struct wlan_dfs *dfs, 708 bool fw_adfs_support_160, 709 bool fw_adfs_support_non_160) 710 { 711 } 712 #endif 713 714 #if defined(QCA_SUPPORT_AGILE_DFS) || defined(ATH_SUPPORT_ZERO_CAC_DFS) 715 /** 716 * dfs_agile_soc_obj_init() - Initialize soc obj for agile precac. 717 * @dfs: Pointer to wlan_dfs structure. 718 * @precac_chan: Start thr precac timer in this channel. 719 * @ocac_status: Status of the off channel CAC. 720 */ 721 void dfs_agile_soc_obj_init(struct wlan_dfs *dfs, 722 struct wlan_objmgr_psoc *psoc); 723 #else 724 static inline void dfs_agile_soc_obj_init(struct wlan_dfs *dfs, 725 struct wlan_objmgr_psoc *psoc) 726 { 727 } 728 #endif 729 730 /** 731 * dfs_set_precac_enable() - Set precac enable flag. 732 * @dfs: Pointer to wlan_dfs structure. 733 * @value: input value for dfs_legacy_precac_ucfg flag. 734 */ 735 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) && !defined(QCA_MCL_DFS_SUPPORT) 736 void dfs_set_precac_enable(struct wlan_dfs *dfs, 737 uint32_t value); 738 #else 739 static inline void dfs_set_precac_enable(struct wlan_dfs *dfs, 740 uint32_t value) 741 { 742 } 743 #endif 744 745 /** 746 * dfs_is_legacy_precac_enabled() - Check if legacy preCAC is enabled for the 747 * DFS onject. 748 * @dfs: Pointer to the wlan_dfs object. 749 * 750 * Return: True if legacy preCAC is enabled, else false. 751 */ 752 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) && !defined(QCA_MCL_DFS_SUPPORT) 753 bool dfs_is_legacy_precac_enabled(struct wlan_dfs *dfs); 754 #else 755 static inline bool dfs_is_legacy_precac_enabled(struct wlan_dfs *dfs) 756 { 757 return 0; 758 } 759 #endif 760 761 /** 762 * dfs_is_agile_precac_enabled() - Check if agile preCAC is enabled for the DFS. 763 * @dfs: Pointer to the wlan_dfs object. 764 * 765 * Return: True if agile DFS is enabled, else false. 766 * 767 * For agile preCAC to be enabled, 768 * 1. User configuration should be set. 769 * 2. Target should support aDFS. 770 */ 771 #ifdef QCA_SUPPORT_AGILE_DFS 772 bool dfs_is_agile_precac_enabled(struct wlan_dfs *dfs); 773 #else 774 static inline bool dfs_is_agile_precac_enabled(struct wlan_dfs *dfs) 775 { 776 return false; 777 } 778 #endif 779 780 #ifdef WLAN_DFS_PRECAC_AUTO_CHAN_SUPPORT 781 /** 782 * dfs_set_precac_intermediate_chan() - Set intermediate chan to be used while 783 * doing precac. 784 * @dfs: Pointer to wlan_dfs structure. 785 * @value: input value for dfs_legacy_precac_ucfg flag. 786 * 787 * Return: 788 * * 0 - Successfully set intermediate channel. 789 * * -EINVAL - Invalid channel. 790 */ 791 int32_t dfs_set_precac_intermediate_chan(struct wlan_dfs *dfs, 792 uint32_t value); 793 #else 794 static inline int32_t dfs_set_precac_intermediate_chan(struct wlan_dfs *dfs, 795 uint32_t value) 796 { 797 return 0; 798 } 799 #endif 800 801 #ifdef WLAN_DFS_PRECAC_AUTO_CHAN_SUPPORT 802 /** 803 * dfs_get_precac_intermediate_chan() - Get configured precac 804 * intermediate channel. 805 * @dfs: Pointer to wlan_dfs structure. 806 * 807 * Return: Configured intermediate channel number. 808 */ 809 uint32_t dfs_get_precac_intermediate_chan(struct wlan_dfs *dfs); 810 #else 811 static inline uint32_t dfs_get_intermediate_chan(struct wlan_dfs *dfs) 812 { 813 return 0; 814 } 815 #endif 816 817 #ifdef WLAN_DFS_PRECAC_AUTO_CHAN_SUPPORT 818 /** 819 * dfs_get_precac_chan_state() - Get precac status of a given channel. 820 * @dfs: Pointer to wlan_dfs structure. 821 * @precac_chan: Channel number for which precac state need to be checked. 822 * 823 * Return: 824 * * PRECAC_REQUIRED: Precac has not done on precac_chan. 825 * * PRECAC_NOW : Precac is running on precac_chan. 826 * * PRECAC_DONE : precac_chan is in CAC done state in precac list. 827 * * PRECAC_NOL : precac_chan is in NOL state in precac list. 828 * * PRECAC_ERR : Invalid precac state. 829 */ 830 enum precac_chan_state 831 dfs_get_precac_chan_state(struct wlan_dfs *dfs, uint8_t precac_chan); 832 833 /** 834 * dfs_get_precac_chan_state_for_freq() - Get precac status of a given channel. 835 * @dfs: Pointer to wlan_dfs structure. 836 * @precac_chan: Channel freq for which precac state need to be checked. 837 */ 838 839 #ifdef CONFIG_CHAN_FREQ_API 840 enum precac_chan_state 841 dfs_get_precac_chan_state_for_freq(struct wlan_dfs *dfs, 842 uint16_t precac_chan_freq); 843 #endif 844 845 #else 846 847 #ifdef CONFIG_CHAN_NUM_API 848 static inline enum precac_chan_state 849 dfs_get_precac_chan_state(struct wlan_dfs *dfs, 850 uint8_t precac_chan) 851 { 852 return PRECAC_REQUIRED; 853 } 854 #endif 855 856 #ifdef CONFIG_CHAN_FREQ_API 857 static inline enum precac_chan_state 858 dfs_get_precac_chan_state_for_freq(struct wlan_dfs *dfs, 859 uint16_t precac_chan_freq) 860 { 861 return PRECAC_REQUIRED; 862 } 863 #endif 864 #endif 865 866 /** 867 * dfs_zero_cac_reset() - Reset Zero cac DFS variables. 868 * @dfs: Pointer to wlan_dfs structure. 869 */ 870 void dfs_zero_cac_reset(struct wlan_dfs *dfs); 871 872 /** 873 * dfs_reinit_precac_lists() - Reinit DFS preCAC lists. 874 * @src_dfs: Source DFS from which the preCAC list is copied. 875 * @dest_dfs: Destination DFS to which the preCAC list is copied. 876 * @low_5g_freq: Low 5G frequency value of the destination DFS. 877 * @high_5g_freq: High 5G frequency value of the destination DFS. 878 * 879 * Copy all the preCAC list entries from the source DFS to the destination DFS 880 * which fall within the frequency range of low_5g_freq and high_5g_freq. 881 * 882 * Return: None (void). 883 */ 884 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) && !defined(QCA_MCL_DFS_SUPPORT) 885 void dfs_reinit_precac_lists(struct wlan_dfs *src_dfs, 886 struct wlan_dfs *dest_dfs, 887 uint16_t low_5g_freq, 888 uint16_t high_5g_freq); 889 #else 890 static inline void dfs_reinit_precac_lists(struct wlan_dfs *src_dfs, 891 struct wlan_dfs *dest_dfs, 892 uint16_t low_5g_freq, 893 uint16_t high_5g_freq) 894 { 895 } 896 #endif 897 898 /** 899 * dfs_is_precac_done_on_ht20_40_80_chan() - Is precac done on a 900 * VHT20/40/80 channel. 901 *@dfs: Pointer to wlan_dfs structure. 902 *@chan: Channel IEEE value. 903 * 904 * Return: 905 * * True: If CAC is done on channel. 906 * * False: If CAC is not done on channel. 907 */ 908 #ifdef CONFIG_CHAN_NUM_API 909 bool dfs_is_precac_done_on_ht20_40_80_chan(struct wlan_dfs *dfs, 910 uint8_t chan); 911 #endif 912 913 /** 914 * dfs_is_precac_done_on_ht20_40_80_160_165_chan_for_freq() - Is precac done on 915 * a VHT20/40/80/160/165 channel. 916 *@dfs: Pointer to wlan_dfs structure. 917 *@chan: Channel frequency 918 * 919 * Return: 920 * * True: If CAC is done on channel. 921 * * False: If CAC is not done on channel. 922 */ 923 #ifdef CONFIG_CHAN_FREQ_API 924 bool 925 dfs_is_precac_done_on_ht20_40_80_160_165_chan_for_freq(struct wlan_dfs *dfs, 926 uint16_t chan_freq); 927 #endif 928 929 /** 930 * dfs_is_precac_done_on_ht8080_chan() - Is precac done on VHT80+80 channel 931 * channel other than the restricted 932 * 80+80 channel. 933 * @dfs: Pointer to wlan_dfs structure. 934 * @chan: Pointer to dfs_channel for which preCAC done is checked. 935 * 936 * Return: 937 * * True: If CAC is done on channel. 938 * * False: If CAC is not done on channel. 939 */ 940 bool dfs_is_precac_done_on_ht8080_chan(struct wlan_dfs *dfs, 941 struct dfs_channel *chan); 942 943 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) && !defined(QCA_MCL_DFS_SUPPORT) 944 /** 945 * dfs_find_chwidth_and_center_chan() - Find the channel width enum and 946 * primary and secondary center channel 947 * value of the current channel. 948 * @dfs: Pointer to wlan_dfs structure. 949 * @chwidth: Channel width enum of current channel. 950 * @primary_chan_ieee: Primary IEEE channel. 951 * @secondary_chan_ieee: Secondary IEEE channel (in HT80_80 mode). 952 */ 953 #ifdef CONFIG_CHAN_NUM_API 954 void dfs_find_chwidth_and_center_chan(struct wlan_dfs *dfs, 955 enum phy_ch_width *chwidth, 956 uint8_t *primary_chan_ieee, 957 uint8_t *secondary_chan_ieee); 958 959 #endif 960 961 #ifdef CONFIG_CHAN_FREQ_API 962 /** 963 * dfs_find_curchwidth_and_center_chan_for_freq() - Find the channel width 964 * enum, primary and secondary 965 * center channel value of 966 * the current channel. 967 * @dfs: Pointer to wlan_dfs structure. 968 * @chwidth: Channel width enum of current channel. 969 * @primary_chan_freq: Primary IEEE channel freq. 970 * @secondary_chan_freq: Secondary IEEE channel freq (in HT80_80 mode). 971 */ 972 void 973 dfs_find_curchwidth_and_center_chan_for_freq(struct wlan_dfs *dfs, 974 enum phy_ch_width *chwidth, 975 uint16_t *primary_chan_freq, 976 uint16_t *secondary_chan_freq); 977 #endif 978 979 /** 980 * dfs_mark_precac_done() - Mark the channel as preCAC done. 981 * @dfs: Pointer to wlan_dfs structure. 982 * @pri_ch_ieee: Primary channel IEEE. 983 * @sec_ch_ieee: Secondary channel IEEE (only in HT80_80 mode). 984 * @ch_width: Channel width enum. 985 */ 986 #ifdef CONFIG_CHAN_NUM_API 987 void dfs_mark_precac_done(struct wlan_dfs *dfs, 988 uint8_t pri_ch_ieee, 989 uint8_t sec_ch_ieee, 990 enum phy_ch_width ch_width); 991 #endif 992 993 #ifdef CONFIG_CHAN_FREQ_API 994 /** 995 * dfs_mark_precac_done_for_freq() - Mark the channel as preCAC done. 996 * @dfs: Pointer to wlan_dfs structure. 997 * @pri_chan_freq: Primary channel IEEE freq. 998 * @sec_chan_freq: Secondary channel IEEE freq(only in HT80_80 mode). 999 * @chan_width: Channel width enum. 1000 */ 1001 void dfs_mark_precac_done_for_freq(struct wlan_dfs *dfs, 1002 uint16_t pri_chan_freq, 1003 uint16_t sec_chan_freq, 1004 enum phy_ch_width chan_width); 1005 #endif 1006 1007 /** 1008 * dfs_mark_precac_nol() - Mark the precac channel as radar. 1009 * @dfs: Pointer to wlan_dfs structure. 1010 * @is_radar_found_on_secondary_seg: Radar found on secondary seg for Cascade. 1011 * @detector_id: detector id which found RADAR in HW. 1012 * @channels: Array of radar found subchannels. 1013 * @num_channels: Number of radar found subchannels. 1014 */ 1015 #ifdef CONFIG_CHAN_NUM_API 1016 void dfs_mark_precac_nol(struct wlan_dfs *dfs, 1017 uint8_t is_radar_found_on_secondary_seg, 1018 uint8_t detector_id, 1019 uint8_t *channels, 1020 uint8_t num_channels); 1021 #endif 1022 1023 /** 1024 * dfs_mark_precac_nol_for_freq() - Mark the precac channel as radar. 1025 * @dfs: Pointer to wlan_dfs structure. 1026 * @is_radar_found_on_secondary_seg: Radar found on secondary seg for Cascade. 1027 * @detector_id: detector id which found RADAR in HW. 1028 * @freq_list: Array of radar found frequencies. 1029 * @num_channels: Number of radar found subchannels. 1030 */ 1031 #ifdef CONFIG_CHAN_FREQ_API 1032 void dfs_mark_precac_nol_for_freq(struct wlan_dfs *dfs, 1033 uint8_t is_radar_found_on_secondary_seg, 1034 uint8_t detector_id, 1035 uint16_t *freq_list, 1036 uint8_t num_channels); 1037 #endif 1038 1039 /** 1040 * dfs_unmark_precac_nol() - Unmark the precac channel as radar. 1041 * @dfs: Pointer to wlan_dfs structure. 1042 * @channel: channel marked as radar. 1043 */ 1044 #ifdef CONFIG_CHAN_NUM_API 1045 void dfs_unmark_precac_nol(struct wlan_dfs *dfs, uint8_t channel); 1046 #endif 1047 1048 /** 1049 * dfs_unmark_precac_nol_for_freq() - Unmark the precac channel as radar. 1050 * @dfs: Pointer to wlan_dfs structure. 1051 * @channel: channel freq marked as radar. 1052 */ 1053 #ifdef CONFIG_CHAN_FREQ_API 1054 void dfs_unmark_precac_nol_for_freq(struct wlan_dfs *dfs, uint16_t chan_freq); 1055 #endif 1056 1057 #else 1058 #ifdef CONFIG_CHAN_NUM_API 1059 static inline void 1060 dfs_find_chwidth_and_center_chan(struct wlan_dfs *dfs, 1061 enum phy_ch_width *chwidth, 1062 uint8_t *primary_chan_ieee, 1063 uint8_t *secondary_chan_ieee) 1064 { 1065 } 1066 #endif 1067 1068 #ifdef CONFIG_CHAN_FREQ_API 1069 static inline void 1070 dfs_find_curchwidth_and_center_chan_for_freq(struct wlan_dfs *dfs, 1071 enum phy_ch_width *chwidth, 1072 uint16_t *primary_chan_freq, 1073 uint16_t *secondary_chan_freq) 1074 { 1075 } 1076 #endif 1077 1078 #ifdef CONFIG_CHAN_NUM_API 1079 static inline void dfs_mark_precac_done(struct wlan_dfs *dfs, 1080 uint8_t pri_ch_ieee, 1081 uint8_t sec_ch_ieee, 1082 enum phy_ch_width ch_width) 1083 { 1084 } 1085 #endif 1086 1087 #ifdef CONFIG_CHAN_FREQ_API 1088 static inline void dfs_mark_precac_done_for_freq(struct wlan_dfs *dfs, 1089 uint16_t pri_chan_freq, 1090 uint16_t sec_chan_freq, 1091 enum phy_ch_width chan_width) 1092 { 1093 } 1094 #endif 1095 1096 #ifdef CONFIG_CHAN_NUM_API 1097 static inline void dfs_mark_precac_nol(struct wlan_dfs *dfs, 1098 uint8_t is_radar_found_on_secondary_seg, 1099 uint8_t detector_id, 1100 uint8_t *channels, 1101 uint8_t num_channels) 1102 { 1103 } 1104 #endif 1105 1106 #ifdef CONFIG_CHAN_FREQ_API 1107 static inline void 1108 dfs_mark_precac_nol_for_freq(struct wlan_dfs *dfs, 1109 uint8_t is_radar_found_on_secondary_seg, 1110 uint8_t detector_id, 1111 uint16_t *freq, 1112 uint8_t num_channels) 1113 { 1114 } 1115 #endif 1116 1117 #ifdef CONFIG_CHAN_NUM_API 1118 static inline void dfs_unmark_precac_nol(struct wlan_dfs *dfs, uint8_t channel) 1119 { 1120 } 1121 #endif 1122 1123 #ifdef CONFIG_CHAN_FREQ_API 1124 static inline void dfs_unmark_precac_nol_for_freq(struct wlan_dfs *dfs, 1125 uint16_t chan_freq) 1126 { 1127 } 1128 #endif 1129 #endif 1130 1131 /** 1132 * dfs_is_precac_timer_running() - Check whether precac timer is running. 1133 * @dfs: Pointer to wlan_dfs structure. 1134 */ 1135 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) && !defined(QCA_MCL_DFS_SUPPORT) 1136 bool dfs_is_precac_timer_running(struct wlan_dfs *dfs); 1137 #else 1138 static inline bool dfs_is_precac_timer_running(struct wlan_dfs *dfs) 1139 { 1140 return false; 1141 } 1142 #endif 1143 1144 #ifdef CONFIG_CHAN_FREQ_API 1145 #define VHT160_FREQ_DIFF 80 1146 1147 #define INITIAL_20_CHAN_FREQ_OFFSET -70 1148 #define INITIAL_40_CHAN_FREQ_OFFSET -60 1149 #define INITIAL_80_CHAN_FREQ_OFFSET -40 1150 #define INITIAL_160_CHAN_FREQ_OFFSET 0 1151 1152 #define NEXT_20_CHAN_FREQ_OFFSET 20 1153 #define NEXT_40_CHAN_FREQ_OFFSET 40 1154 #define NEXT_80_CHAN_FREQ_OFFSET 80 1155 #define NEXT_160_CHAN_FREQ_OFFSET 160 1156 1157 #define WEATHER_CHAN_START_FREQ 5600 1158 #define WEATHER_CHAN_END_FREQ 5640 1159 1160 #endif 1161 1162 /** 1163 * dfs_set_rcac_enable() - Set rcac enable flag. 1164 * @dfs: Pointer to wlan_dfs structure. 1165 * @rcac_en: input value to configure rolling cac feature. 1166 */ 1167 #ifdef QCA_SUPPORT_ADFS_RCAC 1168 QDF_STATUS dfs_set_rcac_enable(struct wlan_dfs *dfs, 1169 bool rcac_en); 1170 #else 1171 static inline QDF_STATUS 1172 dfs_set_rcac_enable(struct wlan_dfs *dfs, 1173 bool rcac_en) 1174 { 1175 return QDF_STATUS_SUCCESS; 1176 } 1177 #endif 1178 1179 /** 1180 * dfs_get_rcac_enable() - Get rcac enable flag. 1181 * @dfs: Pointer to wlan_dfs structure. 1182 * @rcac_en: Variable to hold the current rcac config. 1183 */ 1184 #ifdef QCA_SUPPORT_ADFS_RCAC 1185 QDF_STATUS dfs_get_rcac_enable(struct wlan_dfs *dfs, 1186 bool *rcac_en); 1187 #else 1188 static inline QDF_STATUS 1189 dfs_get_rcac_enable(struct wlan_dfs *dfs, 1190 bool *rcac_en) 1191 { 1192 return QDF_STATUS_SUCCESS; 1193 } 1194 #endif 1195 1196 /** 1197 * dfs_set_rcac_freq() - Set user configured rolling CAC frequency. 1198 * @dfs: Pointer to wlan_dfs structure. 1199 * @rcac_freq: User preferred rolling cac frequency. 1200 */ 1201 #ifdef QCA_SUPPORT_ADFS_RCAC 1202 QDF_STATUS dfs_set_rcac_freq(struct wlan_dfs *dfs, 1203 qdf_freq_t rcac_freq); 1204 #else 1205 static inline QDF_STATUS 1206 dfs_set_rcac_freq(struct wlan_dfs *dfs, 1207 qdf_freq_t rcac_freq) 1208 { 1209 return QDF_STATUS_SUCCESS; 1210 } 1211 #endif 1212 1213 /** 1214 * dfs_get_rcac_freq() - Get user configured rolling CAC frequency. 1215 * @dfs: Pointer to wlan_dfs structure. 1216 * @rcac_freq: Variable to store the user preferred rolling cac frequency. 1217 */ 1218 #ifdef QCA_SUPPORT_ADFS_RCAC 1219 QDF_STATUS dfs_get_rcac_freq(struct wlan_dfs *dfs, 1220 qdf_freq_t *rcac_freq); 1221 #else 1222 static inline QDF_STATUS 1223 dfs_get_rcac_freq(struct wlan_dfs *dfs, 1224 qdf_freq_t *rcac_freq) 1225 { 1226 return QDF_STATUS_SUCCESS; 1227 } 1228 #endif 1229 1230 /** 1231 * dfs_rcac_timer_init() - Initialize rolling cac timer. 1232 * @dfs_soc_obj: Pointer to DFS SOC object structure. 1233 */ 1234 #ifdef QCA_SUPPORT_ADFS_RCAC 1235 void dfs_rcac_timer_init(struct dfs_soc_priv_obj *dfs_soc_obj); 1236 #else 1237 static inline void 1238 dfs_rcac_timer_init(struct dfs_soc_priv_obj *dfs_soc_obj) 1239 { 1240 } 1241 #endif 1242 1243 /** 1244 * dfs_rcac_timer_deinit() - Free rolling cac timer object. 1245 * @dfs_soc_obj: Pointer to dfs_soc_priv_obj structure. 1246 */ 1247 #ifdef QCA_SUPPORT_ADFS_RCAC 1248 void dfs_rcac_timer_deinit(struct dfs_soc_priv_obj *dfs_soc_obj); 1249 #else 1250 static inline void 1251 dfs_rcac_timer_deinit(struct dfs_soc_priv_obj *dfs_soc_obj) 1252 { 1253 } 1254 #endif 1255 1256 #ifdef QCA_SUPPORT_AGILE_DFS 1257 #define DFS_AGILE_SM_SPIN_LOCK(_soc_obj) \ 1258 qdf_spin_lock_bh(&((_soc_obj)->dfs_agile_sm_lock)) 1259 #define DFS_AGILE_SM_SPIN_UNLOCK(_soc_obj) \ 1260 qdf_spin_unlock_bh(&((_soc_obj)->dfs_agile_sm_lock)) 1261 1262 /** 1263 * dfs_agile_sm_deliver_evt() - Deliver the event to AGILE SM. 1264 * @dfs_soc_obj: Pointer to DFS soc object that holds the SM handle. 1265 * @event: Event ID. 1266 * @event_data_len: Length of event data. 1267 * @event_data: pointer to event data. 1268 * 1269 * Return: Success if event is handled, else failure. 1270 */ 1271 QDF_STATUS dfs_agile_sm_deliver_evt(struct dfs_soc_priv_obj *dfs_soc_obj, 1272 enum dfs_agile_sm_evt event, 1273 uint16_t event_data_len, 1274 void *event_data); 1275 1276 /** 1277 * dfs_agile_sm_create() - Create the AGILE state machine. 1278 * @dfs_soc_obj: Pointer to dfs_soc object that holds the SM handle. 1279 * 1280 * Return: QDF_STATUS_SUCCESS if successful, else failure status. 1281 */ 1282 QDF_STATUS dfs_agile_sm_create(struct dfs_soc_priv_obj *dfs_soc_obj); 1283 1284 /** 1285 * dfs_agile_sm_destroy() - Destroy the AGILE state machine. 1286 * @dfs_soc_obj: Pointer to dfs_soc object that holds the SM handle. 1287 * 1288 * Return: QDF_STATUS_SUCCESS if successful, else failure status. 1289 */ 1290 QDF_STATUS dfs_agile_sm_destroy(struct dfs_soc_priv_obj *dfs_soc_obj); 1291 1292 /** 1293 * dfs_is_agile_cac_enabled() - Determine if Agile PreCAC/RCAC is enabled. 1294 * @dfs: Pointer to struct wlan_dfs. 1295 * 1296 * Return: True if either Agile PreCAC/RCAC is enabled, false otherwise. 1297 */ 1298 bool dfs_is_agile_cac_enabled(struct wlan_dfs *dfs); 1299 1300 #else 1301 1302 static inline 1303 QDF_STATUS dfs_agile_sm_deliver_evt(struct dfs_soc_priv_obj *dfs_soc_obj, 1304 enum dfs_agile_sm_evt event, 1305 uint16_t event_data_len, 1306 void *event_data) 1307 { 1308 return QDF_STATUS_SUCCESS; 1309 } 1310 1311 static inline 1312 QDF_STATUS dfs_agile_sm_create(struct dfs_soc_priv_obj *dfs_soc_obj) 1313 { 1314 return QDF_STATUS_SUCCESS; 1315 } 1316 1317 static inline 1318 QDF_STATUS dfs_agile_sm_destroy(struct dfs_soc_priv_obj *dfs_soc_obj) 1319 { 1320 return QDF_STATUS_SUCCESS; 1321 } 1322 1323 static inline bool dfs_is_agile_cac_enabled(struct wlan_dfs *dfs) 1324 { 1325 return false; 1326 } 1327 #endif /* QCA_SUPPORT_AGILE_DFS */ 1328 1329 #ifdef QCA_SUPPORT_ADFS_RCAC 1330 /** 1331 * dfs_is_agile_rcac_enabled() - Determine if Rolling CAC is enabled or not. 1332 * @dfs: Pointer to struct wlan_dfs. 1333 * 1334 * Following are the conditions needed to assertain that rolling CAC 1335 * is enabled: 1336 * 1. DFS domain of the PDEV must be FCC or MKK. 1337 * 2. User has enabled Rolling CAC configuration. 1338 * 3. FW capability to support ADFS. Only non-160 capability is checked here. 1339 * If we happen to choose the next RCAC channel as 160/80-80, 1340 * 'dfs_fw_adfs_support_160' is also verified. 1341 * 1342 * 1343 * Return: True if RCAC support is enabled, false otherwise. 1344 */ 1345 bool dfs_is_agile_rcac_enabled(struct wlan_dfs *dfs); 1346 1347 /** 1348 * dfs_prepare_agile_rcac_channel() - Prepare agile RCAC channel. 1349 * @dfs: Pointer to struct wlan_dfs. 1350 * @is_rcac_chan_available: Flag to indicate if a valid RCAC channel is 1351 * found. 1352 */ 1353 void dfs_prepare_agile_rcac_channel(struct wlan_dfs *dfs, 1354 bool *is_rcac_chan_available); 1355 /** 1356 * dfs_start_agile_rcac_timer() - Start Agile RCAC timer. 1357 * @dfs: Pointer to struct wlan_dfs. 1358 * 1359 */ 1360 void dfs_start_agile_rcac_timer(struct wlan_dfs *dfs); 1361 1362 /** 1363 * dfs_stop_agile_rcac_timer() - Stop Agile RCAC timer. 1364 * @dfs: Pointer to struct wlan_dfs. 1365 * 1366 */ 1367 void dfs_stop_agile_rcac_timer(struct wlan_dfs *dfs); 1368 #else 1369 static inline bool dfs_is_agile_rcac_enabled(struct wlan_dfs *dfs) 1370 { 1371 return false; 1372 } 1373 1374 static inline void 1375 dfs_prepare_agile_rcac_channel(struct wlan_dfs *dfs, 1376 bool *is_rcac_chan_available) 1377 { 1378 } 1379 1380 static inline void dfs_start_agile_rcac_timer(struct wlan_dfs *dfs) 1381 { 1382 } 1383 1384 static inline void dfs_stop_agile_rcac_timer(struct wlan_dfs *dfs) 1385 { 1386 } 1387 #endif /* QCA_SUPPORT_ADFS_RCAC */ 1388 1389 #if defined(QCA_SUPPORT_AGILE_DFS) || defined(ATH_SUPPORT_ZERO_CAC_DFS) || \ 1390 defined(QCA_SUPPORT_ADFS_RCAC) 1391 /** 1392 * dfs_process_radar_ind_on_agile_chan() - Process radar indication event on 1393 * agile channel. 1394 * @dfs: Pointer to wlan_dfs structure. 1395 * @radar_found: Pointer to radar_found_info structure. 1396 * 1397 * Return: QDF_STATUS 1398 */ 1399 QDF_STATUS 1400 dfs_process_radar_ind_on_agile_chan(struct wlan_dfs *dfs, 1401 struct radar_found_info *radar_found); 1402 #else 1403 static inline QDF_STATUS 1404 dfs_process_radar_ind_on_agile_chan(struct wlan_dfs *dfs, 1405 struct radar_found_info *radar_found) 1406 { 1407 return QDF_STATUS_E_FAILURE; 1408 } 1409 #endif 1410 1411 #ifdef ATH_SUPPORT_ZERO_CAC_DFS 1412 /** 1413 * dfs_precac_status_for_channel() - Find the preCAC status of the given 1414 * channel. 1415 * 1416 * @dfs: Pointer to wlan_dfs dfs. 1417 * @deschan: DFS channel to check preCAC status. 1418 * 1419 * Return: 1420 * DFS_NO_PRECAC_COMPLETED_CHANS - 0 preCAC completed channels. 1421 * DFS_PRECAC_COMPLETED_CHAN - Given channel is preCAC completed. 1422 * DFS_PRECAC_REQUIRED_CHAN - Given channel requires preCAC. 1423 */ 1424 enum precac_status_for_chan 1425 dfs_precac_status_for_channel(struct wlan_dfs *dfs, 1426 struct dfs_channel *deschan); 1427 #else 1428 static inline enum precac_status_for_chan 1429 dfs_precac_status_for_channel(struct wlan_dfs *dfs, 1430 struct dfs_channel *deschan) 1431 { 1432 return DFS_INVALID_PRECAC_STATUS; 1433 } 1434 #endif 1435 1436 #if (defined(QCA_SUPPORT_AGILE_DFS) || defined(QCA_SUPPORT_ADFS_RCAC)) && \ 1437 defined(WLAN_DFS_TRUE_160MHZ_SUPPORT) && defined(WLAN_DFS_FULL_OFFLOAD) 1438 /** 1439 * dfs_translate_radar_params_for_agile_chan() - Translate radar params from 1440 * 160MHz synthesizer model to 80MHz synthesizer model for Agile channel. 1441 * @dfs: Pointer to wlan_dfs dfs. 1442 * @r_info: Radar found parameters received from FW that are converted to 80MHz 1443 * syntesizer model(both input and output). 1444 * 1445 * Return: void. 1446 */ 1447 1448 void dfs_translate_radar_params_for_agile_chan(struct wlan_dfs *dfs, 1449 struct radar_found_info *r_info); 1450 #else 1451 static inline void 1452 dfs_translate_radar_params_for_agile_chan(struct wlan_dfs *dfs, 1453 struct radar_found_info *r_info) 1454 { 1455 } 1456 #endif 1457 #endif /* _DFS_ZERO_CAC_H_ */ 1458