xref: /wlan-dirver/qca-wifi-host-cmn/umac/dfs/core/src/dfs_zero_cac.h (revision 8cfe6b10058a04cafb17eed051f2ddf11bee8931)
1 /*
2  * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2022-2023 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_freq: 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  * @psoc: Pointer to psoc object
591  */
592 void dfs_agile_soc_obj_init(struct wlan_dfs *dfs,
593 			    struct wlan_objmgr_psoc *psoc);
594 #else
595 static inline void dfs_agile_soc_obj_init(struct wlan_dfs *dfs,
596 					  struct wlan_objmgr_psoc *psoc)
597 {
598 }
599 #endif
600 
601 /**
602  * dfs_set_precac_enable() - Set precac enable flag.
603  * @dfs: Pointer to wlan_dfs structure.
604  * @value: input value for dfs_legacy_precac_ucfg flag.
605  */
606 #if !defined(MOBILE_DFS_SUPPORT) && (defined(ATH_SUPPORT_ZERO_CAC_DFS) || \
607 				     defined(QCA_SUPPORT_AGILE_DFS))
608 void dfs_set_precac_enable(struct wlan_dfs *dfs,
609 		uint32_t value);
610 #else
611 static inline void dfs_set_precac_enable(struct wlan_dfs *dfs,
612 		uint32_t value)
613 {
614 }
615 #endif
616 
617 /**
618  * dfs_is_agile_precac_enabled() - Check if agile preCAC is enabled for the DFS.
619  * @dfs: Pointer to the wlan_dfs object.
620  *
621  * Return: True if agile DFS is enabled, else false.
622  *
623  * For agile preCAC to be enabled,
624  * 1. User configuration should be set.
625  * 2. Target should support aDFS.
626  */
627 #ifdef QCA_SUPPORT_AGILE_DFS
628 bool dfs_is_agile_precac_enabled(struct wlan_dfs *dfs);
629 #else
630 static inline bool dfs_is_agile_precac_enabled(struct wlan_dfs *dfs)
631 {
632 	return false;
633 }
634 #endif
635 
636 /**
637  * dfs_is_precac_domain() - Check if current DFS domain supports preCAC.
638  * @dfs: Pointer to the wlan_dfs object.
639  *
640  * Return: True if current DFS domain supports preCAC, else false.
641  *
642  * preCAC is currently supported in,
643  * 1. ETSI domain.
644  *
645  */
646 #if defined(QCA_SUPPORT_AGILE_DFS) || defined(ATH_SUPPORT_ZERO_CAC_DFS)
647 bool dfs_is_precac_domain(struct wlan_dfs *dfs);
648 #else
649 static inline bool dfs_is_precac_domain(struct wlan_dfs *dfs)
650 {
651 	return false;
652 }
653 #endif
654 
655 /**
656  * dfs_is_rcac_domain() - Check if current DFS domain supports agile RCAC.
657  * @dfs: Pointer to the wlan_dfs object.
658  *
659  * Return: True if current DFS domain supports RCAC, else false.
660  *
661  * preCAC is currently supported in,
662  * 1. FCC domain.
663  * 2. MKK domain.
664  * 3. MKKN domain.
665  *
666  */
667 #if defined(QCA_SUPPORT_ADFS_RCAC)
668 bool dfs_is_rcac_domain(struct wlan_dfs *dfs);
669 #else
670 static inline bool dfs_is_rcac_domain(struct wlan_dfs *dfs)
671 {
672 	return false;
673 }
674 #endif
675 
676 #ifdef WLAN_DFS_PRECAC_AUTO_CHAN_SUPPORT
677 /**
678  * dfs_set_precac_intermediate_chan() - Set intermediate chan to be used while
679  *                                      doing precac.
680  * @dfs: Pointer to wlan_dfs structure.
681  * @value: input value for dfs_legacy_precac_ucfg flag.
682  *
683  * Return:
684  * * 0       - Successfully set intermediate channel.
685  * * -EINVAL - Invalid channel.
686  */
687 int32_t dfs_set_precac_intermediate_chan(struct wlan_dfs *dfs,
688 					 uint32_t value);
689 #else
690 static inline int32_t dfs_set_precac_intermediate_chan(struct wlan_dfs *dfs,
691 						       uint32_t value)
692 {
693 	return 0;
694 }
695 #endif
696 
697 #ifdef WLAN_DFS_PRECAC_AUTO_CHAN_SUPPORT
698 /**
699  * dfs_get_precac_intermediate_chan() - Get configured precac
700  *					intermediate channel.
701  * @dfs: Pointer to wlan_dfs structure.
702  *
703  * Return: Configured intermediate channel number.
704  */
705 uint32_t dfs_get_precac_intermediate_chan(struct wlan_dfs *dfs);
706 #else
707 static inline uint32_t dfs_get_intermediate_chan(struct wlan_dfs *dfs)
708 {
709 	return 0;
710 }
711 #endif
712 
713 #ifdef WLAN_DFS_PRECAC_AUTO_CHAN_SUPPORT
714 
715 /**
716  * dfs_get_precac_chan_state_for_freq() - Get precac status of a given channel.
717  * @dfs: Pointer to wlan_dfs structure.
718  * @precac_chan_freq: Channel freq for which precac state need to be checked.
719  */
720 
721 #ifdef CONFIG_CHAN_FREQ_API
722 enum precac_chan_state
723 dfs_get_precac_chan_state_for_freq(struct wlan_dfs *dfs,
724 				   uint16_t precac_chan_freq);
725 #endif
726 
727 #else
728 #ifdef CONFIG_CHAN_FREQ_API
729 static inline enum precac_chan_state
730 dfs_get_precac_chan_state_for_freq(struct wlan_dfs *dfs,
731 				   uint16_t precac_chan_freq)
732 {
733 	return PRECAC_REQUIRED;
734 }
735 #endif
736 #endif
737 
738 /**
739  * dfs_reinit_precac_lists() - Reinit DFS preCAC lists.
740  * @src_dfs: Source DFS from which the preCAC list is copied.
741  * @dest_dfs: Destination DFS to which the preCAC list is copied.
742  * @low_5g_freq: Low 5G frequency value of the destination DFS.
743  * @high_5g_freq: High 5G frequency value of the destination DFS.
744  *
745  * Copy all the preCAC list entries from the source DFS to the destination DFS
746  * which fall within the frequency range of low_5g_freq and high_5g_freq.
747  *
748  * Return: None (void).
749  */
750 #if !defined(MOBILE_DFS_SUPPORT) && (defined(ATH_SUPPORT_ZERO_CAC_DFS) || \
751 				     defined(QCA_SUPPORT_AGILE_DFS))
752 void dfs_reinit_precac_lists(struct wlan_dfs *src_dfs,
753 			     struct wlan_dfs *dest_dfs,
754 			     uint16_t low_5g_freq,
755 			     uint16_t high_5g_freq);
756 #else
757 static inline void dfs_reinit_precac_lists(struct wlan_dfs *src_dfs,
758 					   struct wlan_dfs *dest_dfs,
759 					   uint16_t low_5g_freq,
760 					   uint16_t high_5g_freq)
761 {
762 }
763 #endif
764 
765 /**
766  * dfs_is_precac_done_on_non_80p80_chan_for_freq() - Is precac done on
767  * a 20/40/80/160/165/320 MHz channel.
768  * @dfs: Pointer to wlan_dfs structure.
769  * @chan_freq: Channel frequency
770  *
771  * Return:
772  * * True:  If CAC is done on channel.
773  * * False: If CAC is not done on channel.
774  */
775 #ifdef CONFIG_CHAN_FREQ_API
776 bool
777 dfs_is_precac_done_on_non_80p80_chan_for_freq(struct wlan_dfs *dfs,
778 					      uint16_t chan_freq);
779 #endif
780 
781 /**
782  * dfs_is_precac_done_on_80p80_chan() - Is precac done on 80+80 MHz channel.
783  * @dfs: Pointer to wlan_dfs structure.
784  * @chan: Pointer to dfs_channel for which preCAC done is checked.
785  *
786  * Return:
787  * * True:  If CAC is done on channel.
788  * * False: If CAC is not done on channel.
789  */
790 bool dfs_is_precac_done_on_80p80_chan(struct wlan_dfs *dfs,
791 				      struct dfs_channel *chan);
792 
793 #if !defined(MOBILE_DFS_SUPPORT) && (defined(ATH_SUPPORT_ZERO_CAC_DFS) || \
794 				     defined(QCA_SUPPORT_AGILE_DFS))
795 #ifdef CONFIG_CHAN_FREQ_API
796 /**
797  * dfs_find_curchwidth_and_center_chan_for_freq() - Find the channel width
798  *                                                  enum, primary and secondary
799  *                                                  center channel value of
800  *                                                  the current channel.
801  * @dfs:                  Pointer to wlan_dfs structure.
802  * @chwidth:              Channel width enum of current channel.
803  * @primary_chan_freq:    Primary IEEE channel freq.
804  * @secondary_chan_freq:  Secondary IEEE channel freq (in HT80_80 mode).
805  */
806 void
807 dfs_find_curchwidth_and_center_chan_for_freq(struct wlan_dfs *dfs,
808 					     enum phy_ch_width *chwidth,
809 					     uint16_t *primary_chan_freq,
810 					     uint16_t *secondary_chan_freq);
811 #endif
812 
813 #ifdef CONFIG_CHAN_FREQ_API
814 /**
815  * dfs_mark_precac_done_for_freq() - Mark the channel as preCAC done.
816  * @dfs:             Pointer to wlan_dfs structure.
817  * @pri_chan_freq:   Primary channel IEEE freq.
818  * @sec_chan_freq:   Secondary channel IEEE freq(only in HT80_80 mode).
819  * @chan_width:      Channel width enum.
820  */
821 void dfs_mark_precac_done_for_freq(struct wlan_dfs *dfs,
822 				   uint16_t pri_chan_freq,
823 				   uint16_t sec_chan_freq,
824 				   enum phy_ch_width chan_width);
825 #endif
826 
827 /**
828  * dfs_mark_precac_nol_for_freq() - Mark the precac channel as radar.
829  * @dfs:                              Pointer to wlan_dfs structure.
830  * @is_radar_found_on_secondary_seg:  Radar found on secondary seg for Cascade.
831  * @detector_id:                      detector id which found RADAR in HW.
832  * @freq_list:                         Array of radar found frequencies.
833  * @num_channels:                     Number of radar found subchannels.
834  */
835 #ifdef CONFIG_CHAN_FREQ_API
836 void dfs_mark_precac_nol_for_freq(struct wlan_dfs *dfs,
837 				  uint8_t is_radar_found_on_secondary_seg,
838 				  uint8_t detector_id,
839 				  uint16_t *freq_list,
840 				  uint8_t num_channels);
841 #endif
842 
843 /**
844  * dfs_unmark_precac_nol_for_freq() - Unmark the precac channel as radar.
845  * @dfs:      Pointer to wlan_dfs structure.
846  * @chan_freq:  channel freq marked as radar.
847  */
848 #ifdef CONFIG_CHAN_FREQ_API
849 void dfs_unmark_precac_nol_for_freq(struct wlan_dfs *dfs, uint16_t chan_freq);
850 #endif
851 
852 #else
853 
854 #ifdef CONFIG_CHAN_FREQ_API
855 static inline void
856 dfs_find_curchwidth_and_center_chan_for_freq(struct wlan_dfs *dfs,
857 					     enum phy_ch_width *chwidth,
858 					     uint16_t *primary_chan_freq,
859 					     uint16_t *secondary_chan_freq)
860 {
861 }
862 #endif
863 
864 #ifdef CONFIG_CHAN_FREQ_API
865 static inline void dfs_mark_precac_done_for_freq(struct wlan_dfs *dfs,
866 						 uint16_t pri_chan_freq,
867 						 uint16_t sec_chan_freq,
868 						 enum phy_ch_width chan_width)
869 {
870 }
871 #endif
872 
873 #ifdef CONFIG_CHAN_FREQ_API
874 static inline void
875 dfs_mark_precac_nol_for_freq(struct wlan_dfs *dfs,
876 			     uint8_t is_radar_found_on_secondary_seg,
877 			     uint8_t detector_id,
878 			     uint16_t *freq,
879 			     uint8_t num_channels)
880 {
881 }
882 #endif
883 
884 #ifdef CONFIG_CHAN_FREQ_API
885 static inline void dfs_unmark_precac_nol_for_freq(struct wlan_dfs *dfs,
886 						  uint16_t chan_freq)
887 {
888 }
889 #endif
890 #endif
891 
892 /**
893  * dfs_is_precac_timer_running() - Check whether precac timer is running.
894  * @dfs: Pointer to wlan_dfs structure.
895  */
896 #if !defined(MOBILE_DFS_SUPPORT) && (defined(ATH_SUPPORT_ZERO_CAC_DFS) || \
897 				     defined(QCA_SUPPORT_AGILE_DFS))
898 bool dfs_is_precac_timer_running(struct wlan_dfs *dfs);
899 #else
900 static inline bool dfs_is_precac_timer_running(struct wlan_dfs *dfs)
901 {
902 	return false;
903 }
904 #endif
905 
906 #ifdef CONFIG_CHAN_FREQ_API
907 #define VHT160_FREQ_DIFF 80
908 
909 #define INITIAL_20_CHAN_FREQ_OFFSET           -70
910 #define INITIAL_40_CHAN_FREQ_OFFSET           -60
911 #define INITIAL_80_CHAN_FREQ_OFFSET           -40
912 #define INITIAL_160_CHAN_FREQ_OFFSET            0
913 
914 #define NEXT_20_CHAN_FREQ_OFFSET               20
915 #define NEXT_40_CHAN_FREQ_OFFSET               40
916 #define NEXT_80_CHAN_FREQ_OFFSET               80
917 #define NEXT_160_CHAN_FREQ_OFFSET             160
918 #define NEXT_320_CHAN_FREQ_OFFSET             320
919 
920 #define WEATHER_CHAN_START_FREQ              5600
921 #define WEATHER_CHAN_END_FREQ                5640
922 
923 #endif
924 
925 /**
926  * dfs_set_rcac_enable() - Set rcac enable flag.
927  * @dfs: Pointer to wlan_dfs structure.
928  * @rcac_en: input value to configure rolling cac feature.
929  */
930 #ifdef QCA_SUPPORT_ADFS_RCAC
931 QDF_STATUS dfs_set_rcac_enable(struct wlan_dfs *dfs,
932 			       bool rcac_en);
933 #else
934 static inline QDF_STATUS
935 dfs_set_rcac_enable(struct wlan_dfs *dfs,
936 		    bool rcac_en)
937 {
938 	return QDF_STATUS_SUCCESS;
939 }
940 #endif
941 
942 /**
943  * dfs_get_rcac_enable() - Get rcac enable flag.
944  * @dfs: Pointer to wlan_dfs structure.
945  * @rcac_en: Variable to hold the current rcac config.
946  */
947 #ifdef QCA_SUPPORT_ADFS_RCAC
948 QDF_STATUS dfs_get_rcac_enable(struct wlan_dfs *dfs,
949 			       bool *rcac_en);
950 #else
951 static inline QDF_STATUS
952 dfs_get_rcac_enable(struct wlan_dfs *dfs,
953 		    bool *rcac_en)
954 {
955 	return QDF_STATUS_SUCCESS;
956 }
957 #endif
958 
959 /**
960  * dfs_set_rcac_freq() - Set user configured rolling CAC frequency.
961  * @dfs: Pointer to wlan_dfs structure.
962  * @rcac_freq: User preferred rolling cac frequency.
963  */
964 #ifdef QCA_SUPPORT_ADFS_RCAC
965 QDF_STATUS dfs_set_rcac_freq(struct wlan_dfs *dfs,
966 			     qdf_freq_t rcac_freq);
967 #else
968 static inline QDF_STATUS
969 dfs_set_rcac_freq(struct wlan_dfs *dfs,
970 		  qdf_freq_t rcac_freq)
971 {
972 	return QDF_STATUS_SUCCESS;
973 }
974 #endif
975 
976 /**
977  * dfs_get_rcac_freq() - Get user configured rolling CAC frequency.
978  * @dfs: Pointer to wlan_dfs structure.
979  * @rcac_freq: Variable to store the user preferred rolling cac frequency.
980  */
981 #ifdef QCA_SUPPORT_ADFS_RCAC
982 QDF_STATUS dfs_get_rcac_freq(struct wlan_dfs *dfs,
983 			     qdf_freq_t *rcac_freq);
984 #else
985 static inline QDF_STATUS
986 dfs_get_rcac_freq(struct wlan_dfs *dfs,
987 		  qdf_freq_t *rcac_freq)
988 {
989 	return QDF_STATUS_SUCCESS;
990 }
991 #endif
992 
993 /**
994  * dfs_rcac_timer_init() - Initialize rolling cac timer.
995  * @dfs_soc_obj: Pointer to DFS SOC object structure.
996  */
997 #ifdef QCA_SUPPORT_ADFS_RCAC
998 void dfs_rcac_timer_init(struct dfs_soc_priv_obj *dfs_soc_obj);
999 #else
1000 static inline void
1001 dfs_rcac_timer_init(struct dfs_soc_priv_obj *dfs_soc_obj)
1002 {
1003 }
1004 #endif
1005 
1006 /**
1007  * dfs_rcac_timer_deinit() - Free rolling cac timer object.
1008  * @dfs_soc_obj: Pointer to dfs_soc_priv_obj structure.
1009  */
1010 #ifdef QCA_SUPPORT_ADFS_RCAC
1011 void dfs_rcac_timer_deinit(struct dfs_soc_priv_obj *dfs_soc_obj);
1012 #else
1013 static inline void
1014 dfs_rcac_timer_deinit(struct dfs_soc_priv_obj *dfs_soc_obj)
1015 {
1016 }
1017 #endif
1018 
1019 #ifdef QCA_SUPPORT_AGILE_DFS
1020 #define DFS_AGILE_SM_SPIN_LOCK(_soc_obj) \
1021 	qdf_spin_lock_bh(&((_soc_obj)->dfs_agile_sm_lock))
1022 #define DFS_AGILE_SM_SPIN_UNLOCK(_soc_obj) \
1023 	qdf_spin_unlock_bh(&((_soc_obj)->dfs_agile_sm_lock))
1024 
1025 /**
1026  * dfs_agile_sm_deliver_evt() - Deliver the event to AGILE SM.
1027  * @dfs_soc_obj: Pointer to DFS soc object that holds the SM handle.
1028  * @event: Event ID.
1029  * @event_data_len: Length of event data.
1030  * @event_data: pointer to event data.
1031  *
1032  * Return: Success if event is handled, else failure.
1033  */
1034 QDF_STATUS dfs_agile_sm_deliver_evt(struct dfs_soc_priv_obj *dfs_soc_obj,
1035 				    enum dfs_agile_sm_evt event,
1036 				    uint16_t event_data_len,
1037 				    void *event_data);
1038 
1039 /**
1040  * dfs_agile_sm_create() - Create the AGILE state machine.
1041  * @dfs_soc_obj: Pointer to dfs_soc object that holds the SM handle.
1042  *
1043  * Return: QDF_STATUS_SUCCESS if successful, else failure status.
1044  */
1045 QDF_STATUS dfs_agile_sm_create(struct dfs_soc_priv_obj *dfs_soc_obj);
1046 
1047 /**
1048  * dfs_agile_sm_destroy() - Destroy the AGILE state machine.
1049  * @dfs_soc_obj: Pointer to dfs_soc object that holds the SM handle.
1050  *
1051  * Return: QDF_STATUS_SUCCESS if successful, else failure status.
1052  */
1053 QDF_STATUS dfs_agile_sm_destroy(struct dfs_soc_priv_obj *dfs_soc_obj);
1054 
1055 /**
1056  * dfs_is_agile_cac_enabled() - Determine if Agile PreCAC/RCAC is enabled.
1057  * @dfs: Pointer to struct wlan_dfs.
1058  *
1059  * Return: True if either Agile PreCAC/RCAC is enabled, false otherwise.
1060  */
1061 bool dfs_is_agile_cac_enabled(struct wlan_dfs *dfs);
1062 
1063 /* dfs_translate_chwidth_enum2val() - Translate the given channel width enum
1064  *                                    to it's value.
1065  * @dfs:     Pointer to WLAN DFS structure.
1066  * @chwidth: Channel width enum of the pdev's current channel.
1067  *
1068  * Return: The Bandwidth value for the given channel width enum.
1069  */
1070 uint16_t
1071 dfs_translate_chwidth_enum2val(struct wlan_dfs *dfs,
1072 			       enum phy_ch_width chwidth);
1073 #else
1074 
1075 static inline
1076 QDF_STATUS dfs_agile_sm_deliver_evt(struct dfs_soc_priv_obj *dfs_soc_obj,
1077 				    enum dfs_agile_sm_evt event,
1078 				    uint16_t event_data_len,
1079 				    void *event_data)
1080 {
1081 	return QDF_STATUS_SUCCESS;
1082 }
1083 
1084 static inline
1085 QDF_STATUS dfs_agile_sm_create(struct dfs_soc_priv_obj *dfs_soc_obj)
1086 {
1087 	return QDF_STATUS_SUCCESS;
1088 }
1089 
1090 static inline
1091 QDF_STATUS dfs_agile_sm_destroy(struct dfs_soc_priv_obj *dfs_soc_obj)
1092 {
1093 	return QDF_STATUS_SUCCESS;
1094 }
1095 
1096 static inline bool dfs_is_agile_cac_enabled(struct wlan_dfs *dfs)
1097 {
1098 	return false;
1099 }
1100 
1101 static inline uint16_t dfs_translate_chwidth_enum2val(struct wlan_dfs *dfs,
1102 						      enum phy_ch_width chwidth)
1103 {
1104 	return false;
1105 }
1106 #endif /* QCA_SUPPORT_AGILE_DFS */
1107 
1108 #ifdef QCA_SUPPORT_ADFS_RCAC
1109 /**
1110  * dfs_is_agile_rcac_enabled() - Determine if Rolling CAC is enabled or not.
1111  * @dfs: Pointer to struct wlan_dfs.
1112  *
1113  * Following are the conditions needed to assertain that rolling CAC
1114  * is enabled:
1115  * 1. DFS domain of the PDEV must be FCC or MKK.
1116  * 2. User has enabled Rolling CAC configuration.
1117  * 3. FW capability to support ADFS. Only non-160 capability is checked here.
1118  *    If we happen to choose the next RCAC channel as 160/80-80,
1119  *    'dfs_fw_adfs_support_160' is also verified.
1120  *
1121  *
1122  * Return: True if RCAC support is enabled, false otherwise.
1123  */
1124 bool dfs_is_agile_rcac_enabled(struct wlan_dfs *dfs);
1125 
1126 /**
1127  * dfs_prepare_agile_rcac_channel() - Prepare agile RCAC channel.
1128  * @dfs: Pointer to struct wlan_dfs.
1129  * @is_rcac_chan_available: Flag to indicate if a valid RCAC channel is
1130  *                          found.
1131  */
1132 void dfs_prepare_agile_rcac_channel(struct wlan_dfs *dfs,
1133 				    bool *is_rcac_chan_available);
1134 /**
1135  * dfs_start_agile_rcac_timer() - Start Agile RCAC timer.
1136  * @dfs: Pointer to struct wlan_dfs.
1137  *
1138  */
1139 void dfs_start_agile_rcac_timer(struct wlan_dfs *dfs);
1140 
1141 /**
1142  * dfs_stop_agile_rcac_timer() - Stop Agile RCAC timer.
1143  * @dfs: Pointer to struct wlan_dfs.
1144  *
1145  */
1146 void dfs_stop_agile_rcac_timer(struct wlan_dfs *dfs);
1147 #else
1148 static inline bool dfs_is_agile_rcac_enabled(struct wlan_dfs *dfs)
1149 {
1150 	return false;
1151 }
1152 
1153 static inline void
1154 dfs_prepare_agile_rcac_channel(struct wlan_dfs *dfs,
1155 			       bool *is_rcac_chan_available)
1156 {
1157 }
1158 
1159 static inline void dfs_start_agile_rcac_timer(struct wlan_dfs *dfs)
1160 {
1161 }
1162 
1163 static inline void dfs_stop_agile_rcac_timer(struct wlan_dfs *dfs)
1164 {
1165 }
1166 #endif /* QCA_SUPPORT_ADFS_RCAC */
1167 
1168 #if defined(QCA_SUPPORT_AGILE_DFS) || defined(ATH_SUPPORT_ZERO_CAC_DFS) || \
1169 	defined(QCA_SUPPORT_ADFS_RCAC)
1170 /**
1171  * dfs_process_radar_ind_on_agile_chan() - Process radar indication event on
1172  * agile channel.
1173  * @dfs: Pointer to wlan_dfs structure.
1174  * @radar_found: Pointer to radar_found_info structure.
1175  *
1176  * Return: QDF_STATUS
1177  */
1178 QDF_STATUS
1179 dfs_process_radar_ind_on_agile_chan(struct wlan_dfs *dfs,
1180 				    struct radar_found_info *radar_found);
1181 #else
1182 static inline QDF_STATUS
1183 dfs_process_radar_ind_on_agile_chan(struct wlan_dfs *dfs,
1184 				    struct radar_found_info *radar_found)
1185 {
1186 	return QDF_STATUS_E_FAILURE;
1187 }
1188 #endif
1189 
1190 #ifdef ATH_SUPPORT_ZERO_CAC_DFS
1191 /**
1192  * dfs_precac_status_for_channel() - Find the preCAC status of the given
1193  * channel.
1194  *
1195  * @dfs: Pointer to wlan_dfs dfs.
1196  * @deschan: DFS channel to check preCAC status.
1197  *
1198  * Return:
1199  * DFS_NO_PRECAC_COMPLETED_CHANS - 0 preCAC completed channels.
1200  * DFS_PRECAC_COMPLETED_CHAN - Given channel is preCAC completed.
1201  * DFS_PRECAC_REQUIRED_CHAN - Given channel requires preCAC.
1202  */
1203 enum precac_status_for_chan
1204 dfs_precac_status_for_channel(struct wlan_dfs *dfs,
1205 			      struct dfs_channel *deschan);
1206 #else
1207 static inline enum precac_status_for_chan
1208 dfs_precac_status_for_channel(struct wlan_dfs *dfs,
1209 			      struct dfs_channel *deschan)
1210 {
1211 	return DFS_INVALID_PRECAC_STATUS;
1212 }
1213 #endif
1214 
1215 #if (defined(QCA_SUPPORT_AGILE_DFS) || defined(QCA_SUPPORT_ADFS_RCAC)) && \
1216 	defined(WLAN_DFS_TRUE_160MHZ_SUPPORT) && defined(WLAN_DFS_FULL_OFFLOAD)
1217 /**
1218  * dfs_translate_radar_params_for_agile_chan() - Translate radar params from
1219  * 160MHz synthesizer model to 80MHz synthesizer model for Agile channel.
1220  * @dfs: Pointer to wlan_dfs dfs.
1221  * @r_info: Radar found parameters received from FW that are converted to 80MHz
1222  * syntesizer model(both input and output).
1223  *
1224  * Return: void.
1225  */
1226 
1227 void dfs_translate_radar_params_for_agile_chan(struct wlan_dfs *dfs,
1228 					       struct radar_found_info *r_info);
1229 #else
1230 static inline void
1231 dfs_translate_radar_params_for_agile_chan(struct wlan_dfs *dfs,
1232 					  struct radar_found_info *r_info)
1233 {
1234 }
1235 #endif
1236 
1237 /**
1238  * dfs_is_subset_channel_for_freq() - Find out if prev channel and current
1239  * channel are subsets of each other.
1240  * @old_subchans_freq: Pointer to previous sub-channels freq.
1241  * @old_n_chans: Number of previous sub-channels.
1242  * @new_subchans_freq: Pointer to new sub-channels freq.
1243  * @new_n_chans:  Number of new sub-channels
1244  */
1245 #ifdef CONFIG_CHAN_FREQ_API
1246 bool
1247 dfs_is_subset_channel_for_freq(uint16_t *old_subchans_freq,
1248 			       uint8_t old_n_chans,
1249 			       uint16_t *new_subchans_freq,
1250 			       uint8_t new_n_chans);
1251 #endif
1252 
1253 #ifdef QCA_DFS_BW_EXPAND
1254 /**
1255  * dfs_bwexpand_find_usr_cnf_chan() - Find the User configured channel for
1256  * BW Expand.
1257  * @dfs: Pointer to wlan_dfs object.
1258  *
1259  * Return: User configured frequency.
1260  */
1261 qdf_freq_t dfs_bwexpand_find_usr_cnf_chan(struct wlan_dfs *dfs);
1262 
1263 /**
1264  * dfs_bwexpand_try_jumping_to_target_subchan() - Expand the current channel
1265  * bandwidth or jump to a (subset of) user configured target channel.
1266  * Example: Current channel is 60 HT20 and user configured target channel is
1267  * 100 HT160. Agile SM runs on the subchans with 20Mhz BW of 100 HT160, here
1268  * Agile SM runs on 100HT20 and after completion of agile CAC, it checks
1269  * the API dfs_bwexpand_try_jumping_to_target_subchan for possibility of
1270  * BW Expansion and only 20Mhz subchan is available. There is no possible for
1271  * higher bandwidth channel. Then agile CAC runs on the adjacent subchannel
1272  * 104 HT20. After agile CAC completion, the API is checked again for possible
1273  * bandwidth expansion and 102 HT40 is available. The API invokes channel change
1274  * to higher bandwidth.
1275  * @dfs: Pointer to wlan_dfs object.
1276  *
1277  * Return: TRUE, if Bandwidth expansion is success.
1278  * FALSE, if Bandwidth expansion is failure.
1279  */
1280 bool dfs_bwexpand_try_jumping_to_target_subchan(struct wlan_dfs *dfs);
1281 
1282 /**
1283  * dfs_is_rcac_cac_done()- Check RCAC is completed on the subset of the
1284  * user configured target channel.
1285  * @dfs: Pointer to wlan_dfs.
1286  * @chan: Pointer to dfs_channel object of user configured target channel.
1287  * @subset_chan: Pointer to dfs_channel object of subchannel in which RCAC is
1288  * completed.
1289  *
1290  * Return: Boolean value.
1291  */
1292 bool dfs_is_rcac_cac_done(struct wlan_dfs *dfs,
1293 			  struct dfs_channel *chan,
1294 			  struct dfs_channel *subset_chan);
1295 
1296 /*
1297  * dfs_get_configured_bwexpand_dfs_chan() - Get a DFS chan when frequency and
1298  * phymode is provided.
1299  * @dfs: pointer to wlan_dfs.
1300  * @user_chan: pointer to dfs_channel.
1301  * @target_mode: phymode of type wlan_phymode.
1302  */
1303 bool dfs_get_configured_bwexpand_dfs_chan(struct wlan_dfs *dfs,
1304 					  struct dfs_channel *user_chan,
1305 					  enum wlan_phymode target_mode);
1306 #else
1307 static inline
1308 qdf_freq_t dfs_bwexpand_find_usr_cnf_chan(struct wlan_dfs *dfs)
1309 {
1310 	return 0;
1311 }
1312 
1313 static inline
1314 bool dfs_bwexpand_try_jumping_to_target_subchan(struct wlan_dfs *dfs)
1315 {
1316 	return false;
1317 }
1318 
1319 static inline
1320 bool dfs_is_rcac_cac_done(struct wlan_dfs *dfs,
1321 			  struct dfs_channel *chan,
1322 			  struct dfs_channel *subset_chan)
1323 {
1324 	return false;
1325 }
1326 
1327 static inline
1328 bool dfs_get_configured_bwexpand_dfs_chan(struct wlan_dfs *dfs,
1329 					  struct dfs_channel *user_chan,
1330 					  enum wlan_phymode target_mode)
1331 {
1332 	return false;
1333 }
1334 #endif /* QCA_DFS_BW_EXPAND */
1335 #endif /* _DFS_ZERO_CAC_H_ */
1336