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