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