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