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