xref: /wlan-dirver/qca-wifi-host-cmn/umac/dfs/core/src/dfs.h (revision dd4dc88b837a295134aa9869114a2efee0f4894b)
1 /*
2  * Copyright (c) 2013, 2016-2019 The Linux Foundation.  All rights reserved.
3  * Copyright (c) 2005-2006 Atheros Communications, Inc.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  */
17 
18 /**
19  * DOC: This file has main dfs structures.
20  */
21 
22 #ifndef _DFS_H_
23 #define _DFS_H_
24 
25 #include <qdf_types.h>       /* QDF_NBUF_EXEMPT_NO_EXEMPTION, etc. */
26 #include <qdf_net_types.h>   /* QDF_NBUF_EXEMPT_NO_EXEMPTION, etc. */
27 #include <qdf_nbuf.h>        /* qdf_nbuf_t, etc. */
28 #include <qdf_util.h>        /* qdf_assert */
29 #include <qdf_lock.h>        /* qdf_spinlock */
30 #include <qdf_time.h>
31 #include <qdf_timer.h>
32 
33 #include <wlan_dfs_ioctl.h>
34 #include "dfs_structs.h"
35 #include "dfs_channel.h"
36 #include "dfs_ioctl_private.h"
37 #include <i_qdf_types.h>     /* For qdf_packed*/
38 #include <queue.h>           /* For STAILQ_ENTRY */
39 #include <wlan_objmgr_psoc_obj.h>
40 #include <wlan_objmgr_pdev_obj.h>
41 #include <osdep.h>
42 
43 /* File Line and Submodule String */
44 #define FLSM(x, str)   #str " : " FL(x)
45 /* Cast to dfs type */
46 #define DC(x)  ((struct wlan_dfs *)(x))
47 
48 /**
49  * dfs_log: dfs logging using submodule MASKs and
50  * QDF trace level.
51  * The logging is controlled by two bitmasks:
52  * 1) submodule bitmask: sm
53  * 2) trace level masks: level
54  *
55  * @dfs: The dfs object pointer or NULL if dfs is not defined.
56  * @sm: Submodule BITMASK.
57  * @level: QDF trace level.
58  * @args...: Variable argument list.
59  *
60  * The submodule(sm) cannot be empty even if argument dfs is NULL.
61  * Else the macro will create a  compilation  error.
62  * One may provide WLAN_DEBUG_DFS_ALWAYS when  the argument dfs is NULL.
63  * Example:-
64  * dfs_log(NULL, WLAN_DEBUG_DFS_ALWAYS, QDF_TRACE_LEVEL_INFO,"Error pulse");
65  *
66  * Why DC(x) is required?
67  * Since NULL is defined as ((void *)(0)), if the argument "dfs"
68  * in a call to the macro "dfs_log" is NULL
69  * then during compilation (NULL)->dfs_debug_mask will dereference
70  * a (void *) type, which is illegal. Therefore, we need
71  * the cast: (DC(dfs))->dfs_debug_mask.
72  * Example:-
73  * dfs_log(NULL, WLAN_DEBUG_DFS, QDF_TRACE_LEVEL_INFO,"dfs is NULL");
74  */
75 #define dfs_log(dfs, sm, level, args...)  do {        \
76 	if (((dfs) == NULL) ||                            \
77 			((sm) == WLAN_DEBUG_DFS_ALWAYS) ||        \
78 			((sm) & ((DC(dfs))->dfs_debug_mask))) {   \
79 		QDF_TRACE(QDF_MODULE_ID_DFS, level, ## args); \
80 	}                                                 \
81 } while (0)
82 
83 #define dfs_logfl(dfs, level, sm, format, args...) \
84 	dfs_log(dfs, sm, level, FLSM(format, sm), ## args)
85 
86 #define dfs_alert(dfs, sm, format, args...) \
87 	dfs_logfl(dfs, QDF_TRACE_LEVEL_FATAL, sm, format, ## args)
88 
89 #define dfs_err(dfs, sm, format, args...) \
90 	dfs_logfl(dfs, QDF_TRACE_LEVEL_ERROR, sm, format, ## args)
91 
92 #define dfs_warn(dfs, sm, format, args...) \
93 	dfs_logfl(dfs, QDF_TRACE_LEVEL_WARN, sm, format, ## args)
94 
95 #define dfs_info(dfs, sm, format, args...) \
96 	dfs_logfl(dfs, QDF_TRACE_LEVEL_INFO, sm, format, ## args)
97 
98 #define dfs_debug(dfs, sm, format, args...) \
99 	dfs_logfl(dfs, QDF_TRACE_LEVEL_DEBUG, sm, format, ## args)
100 
101 #define DFS_MIN(a, b) ((a) < (b)?(a):(b))
102 #define DFS_MAX(a, b) ((a) > (b)?(a) : (b))
103 #define DFS_DIFF(a, b)(DFS_MAX(a, b) - DFS_MIN(a, b))
104 
105 /**
106  * Maximum number of radar events to be processed in a single iteration.
107  * Allows soft watchdog to run.
108  */
109 #define MAX_EVENTS 100
110 
111 /**
112  * Constants to use for chirping detection.
113  *
114  * All are unconverted as HW reports them.
115  *
116  * XXX Are these constants with or without fast clock 5GHz operation?
117  * XXX Peregrine reports pulses in microseconds, not hardware clocks!
118  */
119 
120 #define MAX_DUR_FOR_LOW_RSSI 4
121 
122 /**
123  * Cascade has issue with reported duration especially when there is a
124  * crossover of chirp from one segment to another. It may report a value
125  * of duration that is well below 50us for a valid FCC type 5 chirping
126  * pulse. For now changing minimum duration as a work around. This will
127  * affect all chips but since we detect chirp with Merlin+, we may be OK
128  * for now. We need a more robust solution for this.
129  */
130 #define MIN_BIN5_DUR_CAS            25 /* 50 * 1.25*/
131 #define MIN_BIN5_DUR_MICROSEC_CAS   20
132 #define MIN_BIN5_DUR                63 /* 50 * 1.25*/
133 #define MIN_BIN5_DUR_MICROSEC       50
134 #define MAYBE_BIN5_DUR              35 /* 28 * 1.25*/
135 #define MAYBE_BIN5_DUR_MICROSEC     28
136 
137 /* Conversion is already done using dfs->dur_multiplier */
138 #define MAX_BIN5_DUR                145   /* use 145 for osprey */
139 #define MAX_BIN5_DUR_MICROSEC       105
140 
141 #define DFS_MARGIN_EQUAL(a, b, margin)	((DFS_DIFF(a, b)) <= margin)
142 #define DFS_MAX_STAGGERED_BURSTS    3
143 
144 /**
145  * All filter thresholds in the radar filter tables are effective at a 50%
146  * channel loading.
147  */
148 #define DFS_CHAN_LOADING_THRESH     50
149 #define DFS_EXT_CHAN_LOADING_THRESH 30
150 #define DFS_DEFAULT_PRI_MARGIN      6
151 #define DFS_DEFAULT_FIXEDPATTERN_PRI_MARGIN	4
152 
153 #define WLAN_DFSQ_LOCK(_dfs)         qdf_spin_lock_bh(&(_dfs)->dfs_radarqlock)
154 #define WLAN_DFSQ_UNLOCK(_dfs)       qdf_spin_unlock_bh(&(_dfs)->dfs_radarqlock)
155 #define WLAN_DFSQ_LOCK_CREATE(_dfs)  qdf_spinlock_create( \
156 		&(_dfs)->dfs_radarqlock)
157 #define WLAN_DFSQ_LOCK_DESTROY(_dfs) qdf_spinlock_destroy( \
158 		&(_dfs)->dfs_radarqlock)
159 
160 #define WLAN_ARQ_LOCK(_dfs)          qdf_spin_lock_bh(&(_dfs)->dfs_arqlock)
161 #define WLAN_ARQ_UNLOCK(_dfs)        qdf_spin_unlock_bh(&(_dfs)->dfs_arqlock)
162 #define WLAN_ARQ_LOCK_CREATE(_dfs)   qdf_spinlock_create(&(_dfs)->dfs_arqlock)
163 #define WLAN_ARQ_LOCK_DESTROY(_dfs)  qdf_spinlock_destroy(&(_dfs)->dfs_arqlock)
164 
165 #define WLAN_DFSEVENTQ_LOCK(_dfs)         qdf_spin_lock_bh(&(_dfs)->dfs_eventqlock)
166 #define WLAN_DFSEVENTQ_UNLOCK(_dfs)       qdf_spin_unlock_bh( \
167 		&(_dfs)->dfs_eventqlock)
168 #define WLAN_DFSEVENTQ_LOCK_CREATE(_dfs)  qdf_spinlock_create( \
169 		&(_dfs)->dfs_eventqlock)
170 #define WLAN_DFSEVENTQ_LOCK_DESTROY(_dfs) qdf_spinlock_destroy( \
171 		&(_dfs)->dfs_eventqlock)
172 
173 #define WLAN_DFSNOL_LOCK(_dfs)         qdf_spin_lock_bh(&(_dfs)->dfs_nol_lock)
174 #define WLAN_DFSNOL_UNLOCK(_dfs)       qdf_spin_unlock_bh(&(_dfs)->dfs_nol_lock)
175 #define WLAN_DFSNOL_LOCK_CREATE(_dfs)  qdf_spinlock_create( \
176 		&(_dfs)->dfs_nol_lock)
177 #define WLAN_DFSNOL_LOCK_DESTROY(_dfs) qdf_spinlock_destroy( \
178 		&(_dfs)->dfs_nol_lock)
179 
180 #define PRECAC_LIST_LOCK(_dfs)         qdf_spin_lock_irqsave( \
181 		&(_dfs)->dfs_precac_lock)
182 #define PRECAC_LIST_UNLOCK(_dfs)       qdf_spin_unlock_irqrestore( \
183 		&(_dfs)->dfs_precac_lock)
184 #define PRECAC_LIST_LOCK_CREATE(_dfs)  qdf_spinlock_create( \
185 		&(_dfs)->dfs_precac_lock)
186 #define PRECAC_LIST_LOCK_DESTROY(_dfs) qdf_spinlock_destroy( \
187 		&(_dfs)->dfs_precac_lock)
188 
189 #define WLAN_DFS_DATA_STRUCT_LOCK(_dfs) \
190 	qdf_spin_lock_bh(&(_dfs)->dfs_data_struct_lock)
191 #define WLAN_DFS_DATA_STRUCT_UNLOCK(_dfs) \
192 	qdf_spin_unlock_bh(&(_dfs)->dfs_data_struct_lock)
193 #define WLAN_DFS_DATA_STRUCT_LOCK_CREATE(_dfs) \
194 	qdf_spinlock_create(&(_dfs)->dfs_data_struct_lock)
195 #define WLAN_DFS_DATA_STRUCT_LOCK_DESTROY(_dfs) \
196 	qdf_spinlock_destroy(&(_dfs)->dfs_data_struct_lock)
197 
198 /* Mask for time stamp from descriptor */
199 #define DFS_TSMASK    0xFFFFFFFF
200 /* Shift for time stamp from descriptor */
201 #define DFS_TSSHIFT   32
202 /* 64 bit TSF wrap value */
203 #define DFS_TSF_WRAP  0xFFFFFFFFFFFFFFFFULL
204 /* TS mask for 64 bit value */
205 #define DFS_64BIT_TSFMASK 0x0000000000007FFFULL
206 
207 #define DFS_AR_RADAR_RSSI_THR          5 /* in dB */
208 #define DFS_AR_RADAR_RESET_INT         1 /* in secs */
209 #define DFS_AR_RADAR_MAX_HISTORY       500
210 #define DFS_AR_REGION_WIDTH            128
211 #define DFS_AR_RSSI_THRESH_STRONG_PKTS 17 /* in dB */
212 #define DFS_AR_RSSI_DOUBLE_THRESHOLD   15 /* in dB */
213 #define DFS_AR_MAX_NUM_ACK_REGIONS     9
214 #define DFS_AR_ACK_DETECT_PAR_THRESH   20
215 #define DFS_AR_PKT_COUNT_THRESH        20
216 
217 #define DFS_MAX_DL_SIZE                64
218 #define DFS_MAX_DL_MASK                0x3F
219 
220 #define DFS_NOL_TIME DFS_NOL_TIMEOUT_US
221 /* 30 minutes in usecs */
222 
223 #define DFS_WAIT_TIME (60*1000000) /* 1 minute in usecs */
224 
225 #define DFS_DISABLE_TIME (3*60*1000000) /* 3 minutes in usecs */
226 
227 #define DFS_MAX_B5_SIZE 128
228 #define DFS_MAX_B5_MASK 0x0000007F /* 128 */
229 
230 /* Max number of overlapping filters */
231 #define DFS_MAX_RADAR_OVERLAP 16
232 
233 /* Max number of dfs events which can be q'd */
234 #define DFS_MAX_EVENTS 1024
235 
236 #define DFS_RADAR_EN       0x80000000 /* Radar detect is capable */
237 #define DFS_AR_EN          0x40000000 /* AR detect is capable */
238 /* Radar detect in second segment is capable */
239 #define DFS_SECOND_SEGMENT_RADAR_EN 0x20000000
240 #define DFS_MAX_RSSI_VALUE 0x7fffffff /* Max rssi value */
241 
242 #define DFS_BIN_MAX_PULSES 60 /* max num of pulses in a burst */
243 #define DFS_BIN5_PRI_LOWER_LIMIT 990 /* us */
244 
245 /**
246  * To cover the single pusle burst case, change from 2010 us to
247  * 2010000 us.
248  */
249 
250 /**
251  * This is reverted back to 2010 as larger value causes false
252  * bin5 detect (EV76432, EV76320)
253  */
254 #define DFS_BIN5_PRI_HIGHER_LIMIT 2010 /* us */
255 
256 #define DFS_BIN5_WIDTH_MARGIN 4 /* us */
257 #define DFS_BIN5_RSSI_MARGIN  5 /* dBm */
258 
259 /**
260  * Following threshold is not specified but should be
261  * okay statistically.
262  */
263 #define DFS_BIN5_BRI_LOWER_LIMIT 300000   /* us */
264 #define DFS_BIN5_BRI_UPPER_LIMIT 12000000 /* us */
265 
266 /* Max number of pulses kept in buffer */
267 #define DFS_MAX_PULSE_BUFFER_SIZE   1024
268 #define DFS_MAX_PULSE_BUFFER_MASK   0x3ff
269 
270 #define DFS_FAST_CLOCK_MULTIPLIER    (800/11)
271 #define DFS_NO_FAST_CLOCK_MULTIPLIER (80)
272 #define DFS_BIG_SIDX 10000
273 
274 /* Min value of valid psidx diff */
275 #define DFS_MIN_PSIDX_DIFF 4
276 /* Max value of valid psidx diff */
277 #define DFS_MAX_PSIDX_DIFF 16
278 
279 /**
280  * Software use: channel interference used for as AR as well as RADAR
281  * interference detection.
282  */
283 #define CHANNEL_INTERFERENCE    0x01
284 
285 #define CHANNEL_2GHZ      0x00080 /* 2 GHz spectrum channel. */
286 #define CHANNEL_OFDM      0x00040 /* OFDM channel */
287 #define CHANNEL_TURBO     0x00010 /* Turbo Channel */
288 #define CHANNEL_108G (CHANNEL_2GHZ|CHANNEL_OFDM|CHANNEL_TURBO)
289 
290 /* qdf_packed - denotes structure is packed. */
291 #define qdf_packed __qdf_packed
292 
293 #define SEG_ID_PRIMARY         0
294 #define SEG_ID_SECONDARY       1
295 
296 /* MIN and MAX width for different regions */
297 #define REG0_MIN_WIDTH 33
298 #define REG0_MAX_WIDTH 38
299 #define REG1_MIN_WIDTH 39
300 #define REG1_MAX_WIDTH 44
301 #define REG2_MIN_WIDTH 53
302 #define REG2_MAX_WIDTH 58
303 #define REG3_MIN_WIDTH 126
304 #define REG3_MAX_WIDTH 140
305 #define REG4_MIN_WIDTH 141
306 #define REG4_MAX_WIDTH 160
307 #define REG5_MIN_WIDTH 189
308 #define REG5_MAX_WIDTH 210
309 #define REG6_MIN_WIDTH 360
310 #define REG6_MAX_WIDTH 380
311 #define REG7_MIN_WIDTH 257
312 #define REG7_MAX_WIDTH 270
313 #define REG8_MIN_WIDTH 295
314 #define REG8_MAX_WIDTH 302
315 
316 #define OVER_SAMPLING_FREQ 44000
317 #define SAMPLING_FREQ 40000
318 #define HUNDRED 100
319 #define NUM_BINS 128
320 #define THOUSAND 1000
321 
322 /* ETSI11_WORLD regdmn pair id */
323 #define ETSI11_WORLD_REGDMN_PAIR_ID 0x26
324 #define ETSI12_WORLD_REGDMN_PAIR_ID 0x28
325 #define ETSI13_WORLD_REGDMN_PAIR_ID 0x27
326 #define ETSI14_WORLD_REGDMN_PAIR_ID 0x29
327 
328 /* Array offset to ETSI legacy pulse */
329 #define ETSI_LEGACY_PULSE_ARR_OFFSET 2
330 
331 #define ETSI_RADAR_EN302_502_FREQ_LOWER 5725
332 #define ETSI_RADAR_EN302_502_FREQ_UPPER 5865
333 
334 #define DFS_NOL_ADD_CHAN_LOCKED(dfs, freq, timeout)         \
335 	do {                                                \
336 		WLAN_DFSNOL_LOCK(dfs);                      \
337 		dfs_nol_addchan(dfs, freq, timeout);        \
338 		WLAN_DFSNOL_UNLOCK(dfs);                    \
339 	} while (0)
340 
341 /*
342  * Free the NOL element in a thread. This is to avoid freeing the
343  * timer object from within timer callback function . The nol element
344  * contains the timer Object.
345  */
346 #define DFS_NOL_DELETE_CHAN_LOCKED(dfs, freq, chwidth)      \
347 	do {                                                \
348 		WLAN_DFSNOL_LOCK(dfs);                      \
349 		dfs_nol_delete(dfs, freq, chwidth);         \
350 		qdf_sched_work(NULL, &dfs->dfs_nol_elem_free_work); \
351 		WLAN_DFSNOL_UNLOCK(dfs);                    \
352 	} while (0)
353 
354 #define DFS_GET_NOL_LOCKED(dfs, dfs_nol, nchan)             \
355 	do {                                                \
356 		WLAN_DFSNOL_LOCK(dfs);                      \
357 		dfs_get_nol(dfs, dfs_nol, nchan);           \
358 		WLAN_DFSNOL_UNLOCK(dfs);                    \
359 	} while (0)
360 
361 #define DFS_PRINT_NOL_LOCKED(dfs)                           \
362 	do {                                                \
363 		WLAN_DFSNOL_LOCK(dfs);                      \
364 		dfs_print_nol(dfs);                         \
365 		WLAN_DFSNOL_UNLOCK(dfs);                    \
366 	} while (0)
367 
368 #define DFS_NOL_FREE_LIST_LOCKED(dfs)                       \
369 	do {                                                \
370 		WLAN_DFSNOL_LOCK(dfs);                      \
371 		dfs_nol_free_list(dfs);                     \
372 		WLAN_DFSNOL_UNLOCK(dfs);                    \
373 	} while (0)
374 
375 /* Host sends the average parameters of the radar pulses and starts the status
376  * wait timer with this timeout.
377  */
378 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) && defined(HOST_DFS_SPOOF_TEST)
379 #define HOST_DFS_STATUS_WAIT_TIMER_MS 200
380 #endif
381 
382 /*
383  * USENOL_DISABLE_NOL_HOST_AND_FW : Do not add radar hit channel to NOL
384  * in host and FW. Enable CSA on the same channel.
385  */
386 #define USENOL_DISABLE_NOL_HOST_AND_FW 0
387 /*
388  * USENOL_ENABLE_NOL_HOST_AND_FW : Add the radar hit channel to NOL in
389  * host and FW (in case of FO). NOL timer cannot be configured by the user
390  * as FW does not allow manipulating NOL timeout. If noltimeout is configured,
391  * (say 1 min) FW will not be intimated about the configuration and hence NOL
392  * timer may elapse at different instances in host (after 1 min) and FW (after
393  * default 30 min) which could lead to DFS Violation if host tries to come up
394  * on the channel after host NOL timeout (of 1 min) as the FW would still
395  * have the channel in NOL list.
396  */
397 #define USENOL_ENABLE_NOL_HOST_AND_FW 1
398 /*
399  * USENOL_ENABLE_NOL_HOST_DISABLE_NOL_FW : Add the radar hit channel to NOL
400  * in host. NOL timer can be configured by user. NOL in FW (for FO) is disabled.
401  */
402 #define USENOL_ENABLE_NOL_HOST_DISABLE_NOL_FW 2
403 #define AGILE_DETECTOR_ID 2
404 
405 /**
406  * struct dfs_pulseparams - DFS pulse param structure.
407  * @p_time:        Time for start of pulse in usecs.
408  * @p_dur:         Duration of pulse in usecs.
409  * @p_rssi:        RSSI of pulse.
410  * @p_seg_id:      Segment id.
411  * @p_sidx:        Sidx value.
412  * @p_delta_peak:  Delta peak value.
413  * @p_psidx_diff:  The difference in the FFT peak index between the short FFT
414  *                 and the first long FFT.
415  * @p_seq_num:     Sequence number.
416  */
417 struct dfs_pulseparams {
418 	uint64_t p_time;
419 	uint8_t  p_dur;
420 	uint8_t  p_rssi;
421 	uint8_t  p_seg_id;
422 	int16_t  p_sidx;
423 	int8_t   p_delta_peak;
424 	int16_t  p_psidx_diff;
425 	uint32_t p_seq_num;
426 } qdf_packed;
427 
428 /**
429  * struct dfs_pulseline - Pulseline structure.
430  * @pl_elems[]:     array of pulses in delay line.
431  * @pl_firstelem:   Index of the first element.
432  * @pl_lastelem:    Index of the last element.
433  * @pl_numelems:    Number of elements in the delay line.
434  */
435 struct dfs_pulseline {
436 	struct dfs_pulseparams pl_elems[DFS_MAX_PULSE_BUFFER_SIZE];
437 	uint32_t pl_firstelem;
438 	uint32_t pl_lastelem;
439 	uint32_t pl_numelems;
440 } qdf_packed;
441 
442 #define DFS_EVENT_CHECKCHIRP  0x01 /* Whether to check the chirp flag */
443 #define DFS_EVENT_HW_CHIRP    0x02 /* hardware chirp */
444 #define DFS_EVENT_SW_CHIRP    0x04 /* software chirp */
445 /* Whether the event contains valid psidx diff value*/
446 #define DFS_EVENT_VALID_PSIDX_DIFF 0x08
447 
448 /* Use this only if the event has CHECKCHIRP set. */
449 #define DFS_EVENT_ISCHIRP(e) \
450 	((e)->re_flags & (DFS_EVENT_HW_CHIRP | DFS_EVENT_SW_CHIRP))
451 
452 /**
453  * Check if the given event is to be rejected as not possibly
454  * a chirp.  This means:
455  *   (a) it's a hardware or software checked chirp, and
456  *   (b) the HW/SW chirp bits are both 0.
457  */
458 #define DFS_EVENT_NOTCHIRP(e) \
459 	(((e)->re_flags & (DFS_EVENT_CHECKCHIRP)) && (!DFS_EVENT_ISCHIRP((e))))
460 
461 /**
462  * struct dfs_event - DFS event structure.
463  * @re_full_ts:          64-bit full timestamp from interrupt time.
464  * @re_ts:               Original 15 bit recv timestamp.
465  * @re_rssi:             Rssi of radar event.
466  * @re_dur:              Duration of radar pulse.
467  * @re_chanindex:        Channel of event.
468  * @re_flags:            Event flags.
469  * @re_freq:             Centre frequency of event, KHz.
470  * @re_freq_lo:          Lower bounds of frequency, KHz.
471  * @re_freq_hi:          Upper bounds of frequency, KHz.
472  * @re_seg_id:           HT80_80/HT160 use.
473  * @re_sidx:             Seg index.
474  * @re_freq_offset_khz:  Freq offset in KHz
475  * @re_peak_mag:         Peak mag.
476  * @re_total_gain:       Total gain.
477  * @re_mb_gain:          Mb gain.
478  * @re_relpwr_db:        Relpower in db.
479  * @re_delta_diff:       Delta diff.
480  * @re_delta_peak:       Delta peak.
481  * @re_psidx_diff:       Psidx diff.
482  * @re_list:             List of radar events.
483  */
484 struct dfs_event {
485 	uint64_t  re_full_ts;
486 	uint32_t  re_ts;
487 	uint8_t   re_rssi;
488 	uint8_t   re_dur;
489 	uint8_t   re_chanindex;
490 	uint8_t   re_flags;
491 	uint32_t  re_freq;
492 	uint32_t  re_freq_lo;
493 	uint32_t  re_freq_hi;
494 	uint8_t   re_seg_id;
495 	int       re_sidx;
496 	u_int     re_freq_offset_khz;
497 	int       re_peak_mag;
498 	int       re_total_gain;
499 	int       re_mb_gain;
500 	int       re_relpwr_db;
501 	uint8_t   re_delta_diff;
502 	int8_t    re_delta_peak;
503 	int16_t   re_psidx_diff;
504 
505 	STAILQ_ENTRY(dfs_event) re_list;
506 } qdf_packed;
507 
508 #define DFS_AR_MAX_ACK_RADAR_DUR   511
509 #define DFS_AR_MAX_NUM_PEAKS       3
510 #define DFS_AR_ARQ_SIZE            2048 /* 8K AR events for buffer size */
511 #define DFS_AR_ARQ_SEQSIZE         2049 /* Sequence counter wrap for AR */
512 
513 #define DFS_RADARQ_SIZE      512 /* 1K radar events for buffer size */
514 #define DFS_RADARQ_SEQSIZE   513 /* Sequence counter wrap for radar */
515 /* Number of radar channels we keep state for */
516 #define DFS_NUM_RADAR_STATES 64
517 /* Max number radar filters for each type */
518 #define DFS_MAX_NUM_RADAR_FILTERS 10
519 /* Number of different radar types */
520 #define DFS_MAX_RADAR_TYPES  32
521 /* Number of filter index table rows */
522 #define DFS_NUM_FT_IDX_TBL_ROWS  256
523 
524 /* RADAR filter pattern type 1*/
525 #define WLAN_DFS_RF_PATTERN_TYPE_1 1
526 
527 /**
528  * struct dfs_ar_state - DFS AR state structure.
529  * @ar_prevwidth:         Previous width.
530  * @ar_phyerrcount[]:     Phy error count.
531  * @ar_acksum:            Acksum.
532  * @ar_packetthreshold:   Thresh to determine traffic load.
533  * @ar_parthreshold:      Thresh to determine peak.
534  * @ar_radarrssi:         Rssi threshold for AR event.
535  * @ar_prevtimestamp:     Prev time stamp.
536  * @ar_peaklist[]:        Peak list.
537  */
538 struct dfs_ar_state {
539 	uint32_t ar_prevwidth;
540 	uint32_t ar_phyerrcount[DFS_AR_MAX_ACK_RADAR_DUR];
541 	uint32_t ar_acksum;
542 	uint32_t ar_packetthreshold;
543 	uint32_t ar_parthreshold;
544 	uint32_t ar_radarrssi;
545 	uint16_t ar_prevtimestamp;
546 	uint16_t ar_peaklist[DFS_AR_MAX_NUM_PEAKS];
547 };
548 
549 /**
550  * struct dfs_delayelem - Delay Element.
551  * @de_time:       Current "filter" time for start of pulse in usecs.
552  * @de_dur:        Duration of pulse in usecs.
553  * @de_rssi:       Rssi of pulse in dB.
554  * @de_ts:         Time stamp for this delay element.
555  * @de_seg_id:     Segment id for HT80_80/HT160 use.
556  * @de_sidx:       Sidx value.
557  * @de_delta_peak: Delta peak.
558  * @de_psidx_diff: Psidx diff.
559  * @de_seq_num:    Sequence number.
560  */
561 struct dfs_delayelem {
562 	uint32_t de_time;
563 	uint8_t  de_dur;
564 	uint8_t  de_rssi;
565 	uint64_t de_ts;
566 	uint8_t  de_seg_id;
567 	int16_t  de_sidx;
568 	int8_t   de_delta_peak;
569 	int16_t  de_psidx_diff;
570 	uint32_t de_seq_num;
571 } qdf_packed;
572 
573 /**
574  * struct dfs_delayline - DFS Delay Line.
575  * @dl_elems[]:    Array of pulses in delay line.
576  * @dl_last_ts:    Last timestamp the delay line was used (in usecs).
577  * @dl_firstelem:  Index of the first element.
578  * @dl_lastelem:   Index of the last element.
579  * @dl_numelems:   Number of elements in the delay line.
580  * The following is to handle fractional PRI pulses that can cause false
581  * detection.
582  * @dl_seq_num_start: Sequence number of first pulse that was part of
583  *                    threshold match.
584  * @dl_seq_num_stop:  Sequence number of last pulse that was part of threshold
585  *                    match.
586  * The following is required because the first pulse may or may not be in the
587  * delay line but we will find it iin the pulse line using dl_seq_num_second's
588  * diff_ts value.
589  * @dl_seq_num_second: Sequence number of second pulse that was part of
590  *                     threshold match.
591  * @dl_search_pri:     We need final search PRI to identify possible fractional
592  *                     PRI issue.
593  * @dl_min_sidx:       Minimum sidx value of pulses used to match thershold.
594  *                     Used for sidx spread check.
595  * @dl_max_sidx:       Maximum sidx value of pulses used to match thershold.
596  *                     Used for sidx spread check.
597  * @dl_delta_peak_match_count: Number of pulse in the delay line that had valid
598  *                             delta peak value.
599  * @dl_psidx_diff_match_count: Number of pulse in the delay line that had valid
600  *                             psidx diff value.
601  */
602 struct dfs_delayline {
603 	struct dfs_delayelem dl_elems[DFS_MAX_DL_SIZE];
604 	uint64_t dl_last_ts;
605 	uint32_t dl_firstelem;
606 	uint32_t dl_lastelem;
607 	uint32_t dl_numelems;
608 	uint32_t dl_seq_num_start;
609 	uint32_t dl_seq_num_stop;
610 	uint32_t dl_seq_num_second;
611 	uint32_t dl_search_pri;
612 	int16_t  dl_min_sidx;
613 	int8_t   dl_max_sidx;
614 	uint8_t  dl_delta_peak_match_count;
615 	uint8_t  dl_psidx_diff_match_count;
616 } qdf_packed;
617 
618 /**
619  * struct dfs_filter - Dfs filter.
620  * @rf_dl:              Delay line of pulses for this filter.
621  * @rf_numpulses:       Number of pulses in the filter.
622  * @rf_minpri:          Min pri to be considered for this filter.
623  * @rf_maxpri:          Max pri to be considered for this filter.
624  * @rf_threshold:       Match filter output threshold for radar detect.
625  * @rf_filterlen:       Length (in usecs) of the filter.
626  * @rf_patterntype:     Fixed or variable pattern type.
627  * @rf_fixed_pri_radar_pulse: indicates if it is a fixed pri pulse.
628  * @rf_mindur:          Min duration for this radar filter.
629  * @rf_maxdur:          Max duration for this radar filter.
630  * @rf_ignore_pri_window: Ignore pri window.
631  * @rf_pulseid:         Unique ID corresponding to the original filter ID.
632  * To reduce false detection, look at frequency spread. For now we will use
633  * sidx spread. But for HT160 frequency spread will be a better measure.
634  * @rf_sidx_spread:     Maximum SIDX value spread in a matched sequence
635  *                      excluding FCC Bin 5.
636  * @rf_check_delta_peak: Minimum allowed delta_peak value for a pulse to be
637  *                       considetred for this filter's match.
638  */
639 struct dfs_filter {
640 	struct dfs_delayline rf_dl;
641 	uint32_t  rf_numpulses;
642 	uint32_t  rf_minpri;
643 	uint32_t  rf_maxpri;
644 	uint32_t  rf_threshold;
645 	uint32_t  rf_filterlen;
646 	uint32_t  rf_patterntype;
647 	uint32_t  rf_fixed_pri_radar_pulse;
648 	uint32_t  rf_mindur;
649 	uint32_t  rf_maxdur;
650 	uint32_t  rf_ignore_pri_window;
651 	uint32_t  rf_pulseid;
652 	uint16_t  rf_sidx_spread;
653 	int8_t    rf_check_delta_peak;
654 } qdf_packed;
655 
656 /**
657  * struct dfs_filtertype - Structure of DFS Filter type.
658  * @ft_filters[]:      Array of ptrs storing addresses for struct of dfs_filter.
659  * @ft_filterdur:      Duration of pulse which specifies filter type.
660  * @ft_numfilters:     Num filters of this type.
661  * @ft_last_ts:        Last timestamp this filtertype was used (in usecs).
662  * @ft_mindur:         Min pulse duration to be considered for this filter type.
663  * @ft_maxdur:         Max pulse duration to be considered for this filter type.
664  * @ft_rssithresh:     Min rssi to be considered for this filter type.
665  * @ft_numpulses:      Num pulses in each filter of this type.
666  * @ft_patterntype:    Fixed or variable pattern type.
667  * @ft_minpri:         Min pri to be considered for this type.
668  * @ft_rssimargin:     Rssi threshold margin. In Turbo Mode HW reports rssi 3dB
669  *                     lower than in non TURBO mode. This will offset that diff.
670  */
671 struct dfs_filtertype {
672 	struct dfs_filter *ft_filters[DFS_MAX_NUM_RADAR_FILTERS];
673 	uint32_t  ft_filterdur;
674 	uint32_t  ft_numfilters;
675 	uint64_t  ft_last_ts;
676 	uint32_t  ft_mindur;
677 	uint32_t  ft_maxdur;
678 	uint32_t  ft_rssithresh;
679 	uint32_t  ft_numpulses;
680 	uint32_t  ft_patterntype;
681 	uint32_t  ft_minpri;
682 	uint32_t  ft_rssimargin;
683 };
684 
685 /**
686  * struct dfs_channel - Channel structure for dfs component.
687  * @dfs_ch_freq:                Frequency in Mhz.
688  * @dfs_ch_flags:               Channel flags.
689  * @dfs_ch_flagext:             Extended channel flags.
690  * @dfs_ch_ieee:                IEEE channel number.
691  * @dfs_ch_vhtop_ch_freq_seg1:  Channel Center frequency.
692  * @dfs_ch_vhtop_ch_freq_seg2:  Channel Center frequency applicable for 80+80MHz
693  *                          mode of operation.
694  */
695 struct dfs_channel {
696 	uint16_t       dfs_ch_freq;
697 	uint64_t       dfs_ch_flags;
698 	uint16_t       dfs_ch_flagext;
699 	uint8_t        dfs_ch_ieee;
700 	uint8_t        dfs_ch_vhtop_ch_freq_seg1;
701 	uint8_t        dfs_ch_vhtop_ch_freq_seg2;
702 };
703 
704 /**
705  * struct dfs_state - DFS state.
706  * @rs_chan:            Channel info.
707  * @rs_chanindex:       Channel index in radar structure.
708  * @rs_numradarevents:  Number of radar events.
709  * @rs_param:           Phy param.
710  */
711 struct dfs_state {
712 	struct dfs_channel rs_chan;
713 	uint8_t  rs_chanindex;
714 	uint32_t rs_numradarevents;
715 	struct wlan_dfs_phyerr_param rs_param;
716 };
717 
718 #define DFS_NOL_TIMEOUT_S  (30*60)    /* 30 minutes in seconds */
719 #define DFS_NOL_TIMEOUT_MS (DFS_NOL_TIMEOUT_S * 1000)
720 #define DFS_NOL_TIMEOUT_US (DFS_NOL_TIMEOUT_MS * 1000)
721 
722 /**
723  * struct dfs_nolelem - DFS NOL element.
724  * @nol_dfs           Back pointer to dfs object.
725  * @nol_freq:         Centre frequency.
726  * @nol_chwidth:      Event width (MHz).
727  * @nol_start_ticks:  NOL start time in OS ticks.
728  * @nol_timeout_ms:   NOL timeout value in msec.
729  * @nol_timer:        Per element NOL timer.
730  * @nol_next:         Next element pointer.
731  */
732 struct dfs_nolelem {
733 	TAILQ_ENTRY(dfs_nolelem) nolelem_list;
734 	struct wlan_dfs *nol_dfs;
735 	uint32_t       nol_freq;
736 	uint32_t       nol_chwidth;
737 	unsigned long  nol_start_ticks;
738 	uint32_t       nol_timeout_ms;
739 	qdf_timer_t    nol_timer;
740 	struct dfs_nolelem *nol_next;
741 } qdf_packed;
742 
743 
744 /**
745  * struct dfs_info - DFS Info.
746  * @rn_ftindex:            Number of different types of radars.
747  * @rn_lastfull_ts:        Last 64 bit timstamp from recv interrupt.
748  * @rn_last_ts:            last 15 bit ts from recv descriptor.
749  * @rn_last_unique_ts:     last unique 32 bit ts from recv descriptor.
750  * @rn_ts_prefix:          Prefix to prepend to 15 bit recv ts.
751  * @rn_numbin5radars:      Number of bin5 radar pulses to search for.
752  * @rn_fastdivGCval:       Value of fast diversity gc limit from init file.
753  * @rn_minrssithresh:      Min rssi for all radar types.
754  * @rn_maxpulsedur:        Max pulse width in TSF ticks.
755  * @dfs_ext_chan_busy:     Ext chan busy.
756  * @ext_chan_busy_ts:      Ext chan busy time.
757  * @dfs_bin5_chirp_ts:     Ext bin5 chrip time.
758  * @dfs_last_bin5_dur:     Last bin5 during.
759  */
760 struct dfs_info {
761 	uint32_t  rn_ftindex;
762 	uint64_t  rn_lastfull_ts;
763 	uint16_t  rn_last_ts;
764 	uint32_t  rn_last_unique_ts;
765 	uint64_t  rn_ts_prefix;
766 	uint32_t  rn_numbin5radars;
767 	uint32_t  rn_fastdivGCval;
768 	int32_t   rn_minrssithresh;
769 	uint32_t  rn_maxpulsedur;
770 	uint8_t   dfs_ext_chan_busy;
771 	uint64_t  ext_chan_busy_ts;
772 	uint64_t  dfs_bin5_chirp_ts;
773 	uint8_t   dfs_last_bin5_dur;
774 } qdf_packed;
775 
776 /**
777  * struct dfs_bin5elem - BIN5 elements.
778  * @be_ts:   Timestamp for the bin5 element.
779  * @be_rssi: Rssi for the bin5 element.
780  * @be_dur:  Duration of bin5 element.
781  */
782 struct dfs_bin5elem {
783 	uint64_t  be_ts;
784 	uint32_t  be_rssi;
785 	uint32_t  be_dur;
786 };
787 
788 /**
789  * struct dfs_bin5radars - BIN5 radars.
790  * @br_elems[]:    List of bin5 elems that fall within the time window.
791  * @br_firstelem:  Index of the first element.
792  * @br_lastelem:   Index of the last element.
793  * @br_numelems:   Number of elements in the delay line.
794  * @br_pulse:      Original info about bin5 pulse.
795  */
796 struct dfs_bin5radars {
797 	struct dfs_bin5elem br_elems[DFS_MAX_B5_SIZE];
798 	uint32_t  br_firstelem;
799 	uint32_t  br_lastelem;
800 	uint32_t  br_numelems;
801 	struct dfs_bin5pulse br_pulse;
802 };
803 
804 /**
805  * struct dfs_stats - DFS stats.
806  * @num_radar_detects:    Total num. of radar detects.
807  * @num_seg_two_radar_detects: Total num. of radar detected in secondary segment
808  * @total_phy_errors:     Total PHY errors.
809  * @owl_phy_errors:       OWL PHY errors.
810  * @pri_phy_errors:       Primary channel phy errors.
811  * @ext_phy_errors:       Extension channel phy errors.
812  * @dc_phy_errors:        DC PHY errors.
813  * @early_ext_phy_errors: Extension channel early radar found error.
814  * @bwinfo_errors:        Bogus bandwidth info received in descriptor.
815  * @datalen_discards:     data length at least three bytes of payload.
816  * @rssi_discards:        RSSI is not accurate.
817  * @last_reset_tstamp:    Last reset timestamp.
818  */
819 struct dfs_stats {
820 	uint32_t       num_radar_detects;
821 	uint32_t  num_seg_two_radar_detects;
822 	uint32_t  total_phy_errors;
823 	uint32_t  owl_phy_errors;
824 	uint32_t  pri_phy_errors;
825 	uint32_t  ext_phy_errors;
826 	uint32_t  dc_phy_errors;
827 	uint32_t  early_ext_phy_errors;
828 	uint32_t  bwinfo_errors;
829 	uint32_t  datalen_discards;
830 	uint32_t  rssi_discards;
831 	uint64_t  last_reset_tstamp;
832 };
833 
834 #define DFS_EVENT_LOG_SIZE      256
835 
836 /**
837  * struct dfs_event_log - DFS event log.
838  * @ts:               64-bit full timestamp from interrupt time.
839  * @diff_ts:          Diff timestamp.
840  * @rssi:             Rssi of radar event.
841  * @dur:              Duration of radar pulse.
842  * @is_chirp:         Chirp flag.
843  * @seg_id:           HT80_80/HT160 use.
844  * @sidx:             Seg index.
845  * @freq_offset_khz:  Freq offset in KHz
846  * @peak_mag:         Peak mag.
847  * @total_gain:       Total gain.
848  * @mb_gain:          Mb gain.
849  * @relpwr_db:        Relpower in db.
850  * @delta_diff:       Delta diff.
851  * @delta_peak:       Delta peak.
852  * @psidx_diff:       Psidx diff.
853  */
854 
855 struct dfs_event_log {
856 	uint64_t  ts;
857 	uint32_t  diff_ts;
858 	uint8_t   rssi;
859 	uint8_t   dur;
860 	int       is_chirp;
861 	uint8_t   seg_id;
862 	int       sidx;
863 	u_int     freq_offset_khz;
864 	int       peak_mag;
865 	int       total_gain;
866 	int       mb_gain;
867 	int       relpwr_db;
868 	uint8_t   delta_diff;
869 	int8_t    delta_peak;
870 	int16_t   psidx_diff;
871 };
872 
873 #define WLAN_DFS_WEATHER_CHANNEL_WAIT_MIN 10 /*10 minutes*/
874 #define WLAN_DFS_WEATHER_CHANNEL_WAIT_S (WLAN_DFS_WEATHER_CHANNEL_WAIT_MIN * 60)
875 #define WLAN_DFS_WEATHER_CHANNEL_WAIT_MS  \
876 	((WLAN_DFS_WEATHER_CHANNEL_WAIT_S) * 1000) /*in MS*/
877 
878 #define WLAN_DFS_WAIT_POLL_PERIOD 2  /* 2 seconds */
879 #define WLAN_DFS_WAIT_POLL_PERIOD_MS  \
880 	((WLAN_DFS_WAIT_POLL_PERIOD) * 1000)  /*in MS*/
881 
882 #define DFS_DEBUG_TIMEOUT_S     30 /* debug timeout is 30 seconds */
883 #define DFS_DEBUG_TIMEOUT_MS    (DFS_DEBUG_TIMEOUT_S * 1000)
884 
885 #define RSSI_POSSIBLY_FALSE              50
886 #define SEARCH_FFT_REPORT_PEAK_MAG_THRSH 40
887 
888 #define MIN_DFS_SUBCHAN_BW 20 /* Minimum bandwidth of each subchannel. */
889 
890 #define FREQ_OFFSET_BOUNDARY_FOR_80MHZ 40
891 
892 /**
893  * struct wlan_dfs -                 The main dfs structure.
894  * @dfs_debug_mask:                  Current debug bitmask.
895  * @dfs_curchan_radindex:            Current channel radar index.
896  * @dfs_extchan_radindex:            Extension channel radar index.
897  * @dfsdomain:                       Current DFS domain.
898  * @dfs_proc_phyerr:                 Flags for Phy Errs to process.
899  * @dfs_eventq:                      Q of free dfs event objects.
900  * @dfs_eventqlock:                  Lock for free dfs event list.
901  * @dfs_radarq:                      Q of radar events.
902  * @dfs_radarqlock:                  Lock for dfs q.
903  * @dfs_arq:                         Q of AR events.
904  * @dfs_arqlock:                     Lock for AR q.
905  * @dfs_ar_state:                    AR state.
906  * @dfs_radar[]:                     Per-Channel Radar detector state.
907  * @dfs_radarf[]:                    One filter for each radar pulse type.
908  * @dfs_rinfo:                       State vars for radar processing.
909  * @dfs_b5radars:                    Array of bin5 radar events.
910  * @dfs_ftindextable:                Map of radar durs to filter types.
911  * @dfs_nol:                         Non occupancy list for radar.
912  * @dfs_nol_count:                   How many items?
913  * @dfs_defaultparams:               Default phy params per radar state.
914  * @wlan_dfs_stats:                  DFS related stats.
915  * @pulses:                          Pulse history.
916  * @events:                          Events structure.
917  * @wlan_radar_tasksched:            Radar task is scheduled.
918  * @wlan_dfswait:                    Waiting on channel for radar detect.
919  * @wlan_dfstest:                    Test timer in progress.
920  * @dfs_caps:                        Object of wlan_dfs_caps structure.
921  * @wlan_dfstest_ieeechan:           IEEE chan num to return to after a dfs mute
922  *                                   test.
923  * @wlan_dfs_cac_time:               CAC period.
924  * @wlan_dfstesttime:                Time to stay off chan during dfs test.
925  * @wlan_dfswaittimer:               Dfs wait timer.
926  * @wlan_dfstesttimer:               Dfs mute test timer.
927  * @wlan_dfs_debug_timer:            Dfs debug timer.
928  * @dfs_bangradar_type:              Radar simulation type.
929  * @is_radar_found_on_secondary_seg: Radar on second segment.
930  * @dfs_radar_found_for_fo:          Radar found event for FO(Full Offload) is
931  *                                   received.
932  * @is_radar_during_precac:          Radar found during precac.
933  * @dfs_precac_lock:                 Lock to protect precac lists.
934  * @dfs_precac_enable:               Enable the precac.
935  * @dfs_precac_secondary_freq:       Second segment freq for precac.
936  * @dfs_precac_primary_freq:         Primary freq.
937  * @dfs_defer_precac_channel_change: Defer precac channel change.
938  * @dfs_precac_inter_chan:           Intermediate non-DFS channel used while
939  *                                   doing precac.
940  * @dfs_autoswitch_des_chan:         Desired channel which has to be used
941  *                                   after precac.
942  * @dfs_autoswitch_des_mode:         Desired PHY mode which has to be used
943  *                                   after precac.
944  * @dfs_pre_cac_timeout_channel_change: Channel change due to precac timeout.
945  * @wlan_dfs_task_timer:             Dfs wait timer.
946  * @dur_multiplier:                  Duration multiplier.
947  * @wlan_dfs_isdfsregdomain:         True when AP is in DFS domain
948  * @wlan_dfs_false_rssi_thres:       False RSSI Threshold.
949  * @wlan_dfs_peak_mag:               Peak mag.
950  * @radar_log[]:                     Radar log.
951  * @dfs_event_log_count:             Event log count.
952  * @dfs_event_log_on:                Event log on.
953  * @dfs_phyerr_count:                Same as number of PHY radar interrupts.
954  * @dfs_phyerr_reject_count:         When TLV is supported, # of radar events
955  *                                   ignored after TLV is parsed.
956  * @dfs_phyerr_queued_count:         Number of radar events queued for matching
957  *                                   the filters.
958  * @dfs_phyerr_freq_min:             Phyerr min freq.
959  * @dfs_phyerr_freq_max:             Phyerr max freq.
960  * @dfs_phyerr_w53_counter:          Phyerr w53 counter.
961  * @dfs_pri_multiplier:              Allow pulse if they are within multiple of
962  *                                   PRI for the radar type.
963  * @wlan_dfs_nol_timeout:            NOL timeout.
964  * @update_nol:                      Update NOL.
965  * @dfs_seq_num:                     Sequence number.
966  * @dfs_nol_event[]:                 NOL event.
967  * @dfs_nol_timer:                   NOL list processing.
968  * @dfs_nol_free_list:               NOL free list.
969  * @dfs_nol_elem_free_work:          The work queue to free an NOL element.
970  * @dfs_cac_timer:                   CAC timer.
971  * @dfs_cac_valid_timer:             Ignore CAC when this timer is running.
972  * @dfs_cac_timeout_override:        Overridden cac timeout.
973  * @dfs_enable:                      DFS Enable.
974  * @dfs_cac_timer_running:           DFS CAC timer running.
975  * @dfs_ignore_dfs:                  Ignore DFS.
976  * @dfs_ignore_cac:                  Ignore CAC.
977  * @dfs_cac_valid:                   DFS CAC valid.
978  * @dfs_cac_valid_time:              Time for which CAC will be valid and will
979  *                                   not be re-done.
980  * @dfs_precac_timeout_override:     Overridden precac timeout.
981  * @dfs_num_precac_freqs:            Number of PreCAC VHT80 frequencies.
982  * @dfs_precac_required_list:        PreCAC required list.
983  * @dfs_precac_done_list:            PreCAC done list.
984  * @dfs_precac_nol_list:             PreCAC NOL List.
985  * @dfs_curchan:                     DFS current channel.
986  * @dfs_cac_started_chan:            CAC started channel.
987  * @dfs_pdev_obj:                    DFS pdev object.
988  * @dfs_is_offload_enabled:          Set if DFS offload enabled.
989  * @dfs_use_nol:                     Use the NOL when radar found(default: TRUE)
990  * @dfs_nol_lock:                    Lock to protect nol list.
991  * @tx_leakage_threshold:            Tx leakage threshold for dfs.
992  * @dfs_use_nol_subchannel_marking:  Use subchannel marking logic to add only
993  *                                   radar affected subchannel instead of all
994  *                                   bonding channels.
995  * @dfs_host_wait_timer:             The timer that is started from host after
996  *                                   sending the average radar parameters.
997  *                                   Before this timeout host expects its dfs
998  *                                   status from fw.
999  * @dfs_average_pri:                 Average pri value of the received radar
1000  *                                   pulses.
1001  * @dfs_average_duration:            Average duration of the received radar
1002  *                                   pulses.
1003  * @dfs_average_sidx:                Average sidx of the received radar pulses.
1004  * @dfs_is_host_wait_running:        Indicates if host dfs status wait timer is
1005  *                                   running.
1006  * @dfs_average_params_sent:         Indicates if host has sent the average
1007  *                                   radar parameters.
1008  * @dfs_no_res_from_fw:              Indicates no response from fw.
1009  * @dfs_spoof_check_failed:          Indicates if the spoof check has failed.
1010  * @dfs_spoof_test_done:             Indicates if the sppof test is done.
1011  * @dfs_status_timeout_override:     Used to change the timeout value of
1012  *                                   dfs_host_wait_timer.
1013  * @dfs_is_stadfs_enabled:           Is STADFS enabled.
1014  * @dfs_min_sidx:                    Minimum sidx of the received radar pulses.
1015  * @dfs_max_sidx:                    Maximum sidx of the received radar pulses.
1016  * @dfs_seg_id:                      Segment ID of the radar hit channel.
1017  * @dfs_is_chirp:                    Radar Chirp in pulse present or not.
1018  * @dfs_bw_reduced:                  DFS bandwidth reduced channel bit.
1019  * @dfs_freq_offset:                 Frequency offset where radar was found.
1020  * @dfs_cac_aborted:                 DFS cac is aborted.
1021  * @dfs_disable_radar_marking:       To mark or unmark NOL chan as radar hit.
1022  * @dfs_data_struct_lock:            DFS data structure lock. This is to protect
1023  *                                   all the filtering data structures. For
1024  *                                   example: dfs_bin5radars, dfs_filtertype,
1025  *                                   etc.
1026  * @dfs_nol_ie_bandwidth:            Minimum Bandwidth of subchannels that
1027  *                                   are added to NOL.
1028  * @dfs_nol_ie_startfreq:            The centre frequency of the starting
1029  *                                   subchannel in the current channel list
1030  *                                   to be sent in NOL IE with RCSA.
1031  * @dfs_nol_ie_bitmap:               The bitmap of radar affected subchannels
1032  *                                   in the current channel list
1033  *                                   to be sent in NOL IE with RCSA.
1034  * @dfs_is_rcsa_ie_sent              To send or to not send RCSA IE.
1035  * @dfs_is_nol_ie_sent               To send or to not send NOL IE.
1036  */
1037 struct wlan_dfs {
1038 	uint32_t       dfs_debug_mask;
1039 	int16_t        dfs_curchan_radindex;
1040 	int16_t        dfs_extchan_radindex;
1041 	uint32_t       dfsdomain;
1042 	uint32_t       dfs_proc_phyerr;
1043 
1044 	STAILQ_HEAD(, dfs_event) dfs_eventq;
1045 	qdf_spinlock_t dfs_eventqlock;
1046 
1047 	STAILQ_HEAD(, dfs_event) dfs_radarq;
1048 	qdf_spinlock_t dfs_radarqlock;
1049 
1050 	STAILQ_HEAD(, dfs_event) dfs_arq;
1051 	qdf_spinlock_t dfs_arqlock;
1052 
1053 	struct dfs_ar_state   dfs_ar_state;
1054 	struct dfs_state      dfs_radar[DFS_NUM_RADAR_STATES];
1055 	struct dfs_filtertype *dfs_radarf[DFS_MAX_RADAR_TYPES];
1056 	struct dfs_info       dfs_rinfo;
1057 	struct dfs_bin5radars *dfs_b5radars;
1058 	int8_t                **dfs_ftindextable;
1059 	struct dfs_nolelem    *dfs_nol;
1060 	int                   dfs_nol_count;
1061 	struct wlan_dfs_phyerr_param dfs_defaultparams;
1062 	struct dfs_stats      wlan_dfs_stats;
1063 	struct dfs_pulseline  *pulses;
1064 	struct dfs_event      *events;
1065 
1066 	uint32_t       wlan_radar_tasksched:1,
1067 				   wlan_dfswait:1,
1068 				   wlan_dfstest:1;
1069 	struct wlan_dfs_caps dfs_caps;
1070 	uint8_t        wlan_dfstest_ieeechan;
1071 	uint32_t       wlan_dfs_cac_time;
1072 	uint32_t       wlan_dfstesttime;
1073 	qdf_timer_t    wlan_dfswaittimer;
1074 	qdf_timer_t    wlan_dfstesttimer;
1075 	qdf_timer_t    wlan_dfs_debug_timer;
1076 	enum dfs_bangradar_types dfs_bangradar_type;
1077 	bool           is_radar_found_on_secondary_seg;
1078 	bool           dfs_radar_found_for_fo;
1079 	bool           is_radar_during_precac;
1080 	qdf_spinlock_t dfs_precac_lock;
1081 	bool           dfs_precac_enable;
1082 	uint8_t        dfs_precac_secondary_freq;
1083 	uint8_t        dfs_precac_primary_freq;
1084 	uint8_t        dfs_defer_precac_channel_change;
1085 #ifdef WLAN_DFS_PRECAC_AUTO_CHAN_SUPPORT
1086 	uint8_t        dfs_precac_inter_chan;
1087 	uint8_t        dfs_autoswitch_des_chan;
1088 	enum wlan_phymode dfs_autoswitch_des_mode;
1089 #endif
1090 	uint8_t        dfs_pre_cac_timeout_channel_change:1;
1091 	qdf_timer_t    wlan_dfs_task_timer;
1092 	int            dur_multiplier;
1093 	uint16_t       wlan_dfs_isdfsregdomain;
1094 	int            wlan_dfs_false_rssi_thres;
1095 	int            wlan_dfs_peak_mag;
1096 	struct dfs_event_log radar_log[DFS_EVENT_LOG_SIZE];
1097 	int            dfs_event_log_count;
1098 	int            dfs_event_log_on;
1099 	int            dfs_phyerr_count;
1100 	int            dfs_phyerr_reject_count;
1101 	int            dfs_phyerr_queued_count;
1102 	int            dfs_phyerr_freq_min;
1103 	int            dfs_phyerr_freq_max;
1104 	int            dfs_phyerr_w53_counter;
1105 	int            dfs_pri_multiplier;
1106 	int            wlan_dfs_nol_timeout;
1107 	bool           update_nol;
1108 	uint32_t       dfs_seq_num;
1109 	int            dfs_nol_event[DFS_CHAN_MAX];
1110 	qdf_timer_t    dfs_nol_timer;
1111 
1112 	TAILQ_HEAD(, dfs_nolelem) dfs_nol_free_list;
1113 	qdf_work_t     dfs_nol_elem_free_work;
1114 
1115 	qdf_timer_t    dfs_cac_timer;
1116 	qdf_timer_t    dfs_cac_valid_timer;
1117 	int            dfs_cac_timeout_override;
1118 	uint8_t        dfs_enable:1,
1119 				   dfs_cac_timer_running:1,
1120 				   dfs_ignore_dfs:1,
1121 				   dfs_ignore_cac:1,
1122 				   dfs_cac_valid:1;
1123 	uint32_t       dfs_cac_valid_time;
1124 	int            dfs_precac_timeout_override;
1125 	uint8_t        dfs_num_precac_freqs;
1126 #if defined(WLAN_DFS_FULL_OFFLOAD) && defined(QCA_DFS_NOL_OFFLOAD)
1127 	uint8_t        dfs_disable_radar_marking;
1128 #endif
1129 	TAILQ_HEAD(, dfs_precac_entry) dfs_precac_required_list;
1130 	TAILQ_HEAD(, dfs_precac_entry) dfs_precac_done_list;
1131 	TAILQ_HEAD(, dfs_precac_entry) dfs_precac_nol_list;
1132 
1133 #ifdef QCA_SUPPORT_ETSI_PRECAC_DFS
1134 	TAILQ_HEAD(, dfs_etsi_precac_entry) dfs_etsiprecac_required_list;
1135 	TAILQ_HEAD(, dfs_etsi_precac_entry) dfs_etsiprecac_done_list;
1136 #endif
1137 
1138 	struct dfs_channel *dfs_curchan;
1139 	struct dfs_channel dfs_cac_started_chan;
1140 	struct wlan_objmgr_pdev *dfs_pdev_obj;
1141 	struct dfs_soc_priv_obj *dfs_soc_obj;
1142 #if defined(QCA_SUPPORT_AGILE_DFS) || defined(ATH_SUPPORT_ZERO_CAC_DFS)
1143 	uint8_t dfs_psoc_idx;
1144 	uint8_t        dfs_agile_precac_freq;
1145 #endif
1146 	bool           dfs_is_offload_enabled;
1147 	int            dfs_use_nol;
1148 	qdf_spinlock_t dfs_nol_lock;
1149 	uint16_t tx_leakage_threshold;
1150 	bool dfs_use_nol_subchannel_marking;
1151 	uint8_t        dfs_spoof_test_done:1;
1152 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) && defined(HOST_DFS_SPOOF_TEST)
1153 	qdf_timer_t    dfs_host_wait_timer;
1154 	uint32_t       dfs_average_pri;
1155 	uint32_t       dfs_average_duration;
1156 	uint32_t       dfs_average_sidx;
1157 	uint8_t        dfs_is_host_wait_running:1,
1158 				   dfs_average_params_sent:1,
1159 				   dfs_no_res_from_fw:1,
1160 				   dfs_spoof_check_failed:1;
1161 	struct dfs_channel dfs_radar_found_chan;
1162 	int            dfs_status_timeout_override;
1163 #endif
1164 	bool           dfs_is_stadfs_enabled;
1165 	int32_t        dfs_min_sidx;
1166 	int32_t        dfs_max_sidx;
1167 	uint8_t        dfs_seg_id;
1168 	uint8_t        dfs_is_chirp;
1169 	bool           dfs_bw_reduced;
1170 	int32_t        dfs_freq_offset;
1171 	bool           dfs_cac_aborted;
1172 	qdf_spinlock_t dfs_data_struct_lock;
1173 	uint8_t        dfs_nol_ie_bandwidth;
1174 	uint16_t       dfs_nol_ie_startfreq;
1175 	uint8_t        dfs_nol_ie_bitmap;
1176 	bool           dfs_is_rcsa_ie_sent;
1177 	bool           dfs_is_nol_ie_sent;
1178 	bool           dfs_agile_precac_enable;
1179 };
1180 
1181 #if defined(QCA_SUPPORT_AGILE_DFS) || defined(ATH_SUPPORT_ZERO_CAC_DFS)
1182 /**
1183  * struct wlan_dfs_priv - dfs private struct with agile capability info
1184  * @wlan_dfs: pointer to wlan_dfs object.
1185  * @agile_precac_active: agile precac active information for wlan_dfs_priv obj
1186  */
1187 struct wlan_dfs_priv {
1188 	struct wlan_dfs *dfs;
1189 	bool agile_precac_active;
1190 };
1191 #endif
1192 
1193 /**
1194  * struct dfs_soc_priv_obj - dfs private data
1195  * @psoc: pointer to PSOC object information
1196  * @pdev: pointer to PDEV object information
1197  * @dfs_is_phyerr_filter_offload: For some chip like Rome indicates too many
1198  *                                phyerr packets in a short time, which causes
1199  *                                OS hang. If this feild is configured as true,
1200  *                                FW will do the pre-check, filter out some
1201  *                                kinds of invalid phyerrors and indicate
1202  *                                radar detection related information to host.
1203  * @dfs_priv: array of dfs private structs with agile capability info
1204  * @num_dfs_privs: array size of dfs private structs for given psoc.
1205  * @cur_precac_dfs_index: current precac dfs index
1206  * @dfs_precac_timer: agile precac timer
1207  * @dfs_precac_timer_running: precac timer running flag
1208  * @ocac_status: Off channel CAC complete status
1209  */
1210 struct dfs_soc_priv_obj {
1211 	struct wlan_objmgr_psoc *psoc;
1212 	struct wlan_objmgr_pdev *pdev;
1213 	bool dfs_is_phyerr_filter_offload;
1214 #if defined(QCA_SUPPORT_AGILE_DFS) || defined(ATH_SUPPORT_ZERO_CAC_DFS)
1215 	struct wlan_dfs_priv dfs_priv[WLAN_UMAC_MAX_PDEVS];
1216 	uint8_t num_dfs_privs;
1217 	uint8_t cur_precac_dfs_index;
1218 	qdf_timer_t     dfs_precac_timer;
1219 	uint8_t dfs_precac_timer_running;
1220 	bool precac_state_started;
1221 	bool ocac_status;
1222 #endif
1223 };
1224 
1225 /**
1226  * enum DFS debug - This should match the table from if_ath.c.
1227  * @WLAN_DEBUG_DFS:             Minimal DFS debug.
1228  * @WLAN_DEBUG_DFS1:            Normal DFS debug.
1229  * @WLAN_DEBUG_DFS2:            Maximal DFS debug.
1230  * @WLAN_DEBUG_DFS3:            Matched filterID display.
1231  * @WLAN_DEBUG_DFS_PHYERR:      Phy error parsing.
1232  * @WLAN_DEBUG_DFS_NOL:         NOL related entries.
1233  * @WLAN_DEBUG_DFS_PHYERR_SUM:  PHY error summary.
1234  * @WLAN_DEBUG_DFS_PHYERR_PKT:  PHY error payload.
1235  * @WLAN_DEBUG_DFS_BIN5:        BIN5 checks.
1236  * @WLAN_DEBUG_DFS_BIN5_FFT:    BIN5 FFT check.
1237  * @WLAN_DEBUG_DFS_BIN5_PULSE:  BIN5 pulse check.
1238  * @WLAN_DEBUG_DFS_FALSE_DET:   False detection debug related prints.
1239  * @WLAN_DEBUG_DFS_FALSE_DET2:  Second level check to confirm poisitive
1240  *                              detection.
1241  * @WLAN_DEBUG_DFS_RANDOM_CHAN: Random channel selection.
1242  */
1243 enum {
1244 	WLAN_DEBUG_DFS  = 0x00000100,
1245 	WLAN_DEBUG_DFS1 = 0x00000200,
1246 	WLAN_DEBUG_DFS2 = 0x00000400,
1247 	WLAN_DEBUG_DFS3 = 0x00000800,
1248 	WLAN_DEBUG_DFS_PHYERR = 0x00001000,
1249 	WLAN_DEBUG_DFS_NOL    = 0x00002000,
1250 	WLAN_DEBUG_DFS_PHYERR_SUM = 0x00004000,
1251 	WLAN_DEBUG_DFS_PHYERR_PKT = 0x00008000,
1252 	WLAN_DEBUG_DFS_BIN5       = 0x00010000,
1253 	WLAN_DEBUG_DFS_BIN5_FFT   = 0x00020000,
1254 	WLAN_DEBUG_DFS_BIN5_PULSE = 0x00040000,
1255 	WLAN_DEBUG_DFS_FALSE_DET  = 0x00080000,
1256 	WLAN_DEBUG_DFS_FALSE_DET2 = 0x00100000,
1257 	WLAN_DEBUG_DFS_RANDOM_CHAN = 0x00200000,
1258 	WLAN_DEBUG_DFS_MAX        = 0x80000000,
1259 	WLAN_DEBUG_DFS_ALWAYS     = WLAN_DEBUG_DFS_MAX
1260 };
1261 
1262 /**
1263  * enum host dfs spoof check status.
1264  * @HOST_DFS_CHECK_PASSED: Host indicates RADAR detected and the FW
1265  *                         confirms it to be spoof radar to host.
1266  * @HOST_DFS_CHECK_FAILED: Host doesn't indicate RADAR detected or spoof
1267  *                         radar parameters by
1268  *                         WMI_HOST_DFS_RADAR_FOUND_CMDID doesn't match.
1269  * @HOST_DFS_STATUS_CHECK_HW_RADAR: Host indicates RADAR detected and the
1270  *                             FW confirms it to be real HW radar to host.
1271  */
1272 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) && defined(HOST_DFS_SPOOF_TEST)
1273 enum {
1274 	HOST_DFS_STATUS_CHECK_PASSED = 0,
1275 	HOST_DFS_STATUS_CHECK_FAILED = 1,
1276 	HOST_DFS_STATUS_CHECK_HW_RADAR = 2
1277 };
1278 #endif
1279 
1280 /**
1281  * struct dfs_phy_err - DFS phy error.
1282  * @fulltsf:             64-bit TSF as read from MAC.
1283  * @is_pri:              Detected on primary channel.
1284  * @is_ext:              Detected on extension channel.
1285  * @is_dc:               Detected at DC.
1286  * @is_early:            Early detect.
1287  * @do_check_chirp:      Whether to check hw_chirp/sw_chirp.
1288  * @is_hw_chirp:         Hardware-detected chirp.
1289  * @is_sw_chirp:         Software detected chirp.
1290  * @rs_tstamp:           32 bit TSF from RX descriptor (event).
1291  * @freq:                Centre frequency of event - KHz.
1292  * @freq_lo:             Lower bounds of frequency - KHz.
1293  * @freq_hi:             Upper bounds of frequency - KHz.
1294  * @rssi:                Pulse RSSI.
1295  * @dur:                 Pulse duration, raw (not uS).
1296  * @seg_id:              HT80_80/HT160 use.
1297  * @sidx:                Seg index.
1298  * @freq_offset_khz:     Freq offset in KHz.
1299  * @peak_mag:            Peak mag.
1300  * @total_gain:          Total gain.
1301  * @mb_gain:             Mb gain.
1302  * @relpwr_db:           Relpower in DB.
1303  * @pulse_delta_diff:    Pulse delta diff.
1304  * @pulse_delta_peak:    Pulse delta peak.
1305  * @pulse_psidx_diff:    Pulse psidx diff.
1306  *
1307  * Chirp notes!
1308  *
1309  * Pre-Sowl chips don't do FFT reports, so chirp pulses simply show up
1310  * as long duration pulses.
1311  *
1312  * The bin5 checking code would simply look for a chirp pulse of the correct
1313  * duration (within MIN_BIN5_DUR and MAX_BIN5_DUR) and add it to the "chirp"
1314  * pattern.
1315  *
1316  * For Sowl and later, an FFT was done on longer duration frames.  If those
1317  * frames looked like a chirp, their duration was adjusted to fall within
1318  * the chirp duration limits.  If the pulse failed the chirp test (it had
1319  * no FFT data or the FFT didn't meet the chirping requirements) then the
1320  * pulse duration was adjusted to be greater than MAX_BIN5_DUR, so it
1321  * would always fail chirp detection.
1322  *
1323  * This is pretty horrible.
1324  *
1325  * The eventual goal for chirp handling is thus:
1326  *
1327  * 1)In case someone ever wants to do chirp detection with this code on
1328  *   chips that don't support chirp detection, you can still do it based
1329  *   on pulse duration.  That's your problem to solve.
1330  *
1331  * 2)For chips that do hardware chirp detection or FFT, the "do_check_chirp"
1332  *   bit should be set.
1333  *
1334  * 3)Then, either is_hw_chirp or is_sw_chirp is set, indicating that
1335  *   the hardware or software post-processing of the chirp event found
1336  *   that indeed it was a chirp.
1337  *
1338  * 4)Finally, the bin5 code should just check whether the chirp bits are
1339  *   set and behave appropriately, falling back onto the duration checks
1340  *   if someone wishes to use this on older hardware (or with disabled
1341  *   FFTs, for whatever reason.)
1342  *
1343  * XXX TODO:
1344  *
1345  * 1)add duration in uS and raw duration, so the PHY error parsing
1346  *   code is responsible for doing the duration calculation;
1347  * 2)add ts in raw and corrected, so the PHY error parsing
1348  *   code is responsible for doing the offsetting, not the radar
1349  *   event code.
1350  */
1351 struct dfs_phy_err {
1352 	uint64_t fulltsf;
1353 	uint32_t is_pri:1,
1354 			 is_ext:1,
1355 			 is_dc:1,
1356 			 is_early:1,
1357 			 do_check_chirp:1,
1358 			 is_hw_chirp:1,
1359 			 is_sw_chirp:1;
1360 	uint32_t rs_tstamp;
1361 	uint32_t freq;
1362 	uint32_t freq_lo;
1363 	uint32_t freq_hi;
1364 	uint8_t  rssi;
1365 	uint8_t  dur;
1366 	uint8_t  seg_id;
1367 	int      sidx;
1368 	u_int    freq_offset_khz;
1369 	int      peak_mag;
1370 	int      total_gain;
1371 	int      mb_gain;
1372 	int      relpwr_db;
1373 	uint8_t  pulse_delta_diff;
1374 	int8_t   pulse_delta_peak;
1375 	int16_t  pulse_psidx_diff;
1376 };
1377 
1378 /**
1379  * struct rx_radar_status - Parsed radar status
1380  * @raw_tsf:           Raw tsf
1381  * @tsf_offset:        TSF offset.
1382  * @rssi:              RSSI.
1383  * @pulse_duration:    Pulse duration.
1384  * @is_chirp:          Is chirp.
1385  * @delta_peak:        Delta peak.
1386  * @delta_diff:        Delta diff.
1387  * @sidx:              Starting frequency.
1388  * @freq_offset:       Frequency offset.
1389  * @agc_total_gain:    AGC total gain.
1390  * @agc_mb_gain:       AGC MB gain.
1391  */
1392 struct rx_radar_status {
1393 	uint32_t raw_tsf;
1394 	uint32_t tsf_offset;
1395 	int      rssi;
1396 	int      pulse_duration;
1397 	int      is_chirp:1;
1398 	int      delta_peak;
1399 	int      delta_diff;
1400 	int      sidx;
1401 	int      freq_offset; /* in KHz */
1402 	int      agc_total_gain;
1403 	int      agc_mb_gain;
1404 };
1405 
1406 /**
1407  * struct rx_search_fft_report - FFT report.
1408  * @total_gain_db:     Total gain in Db.
1409  * @base_pwr_db:       Base power in Db.
1410  * @fft_chn_idx:       FFT channel index.
1411  * @peak_sidx:         Peak sidx.
1412  * @relpwr_db:         Real power in Db.
1413  * @avgpwr_db:         Average power in Db.
1414  * @peak_mag:          Peak Mag.
1415  * @num_str_bins_ib:   Num dtr BINs IB
1416  * @seg_id:            Segment ID
1417  */
1418 struct rx_search_fft_report {
1419 	uint32_t total_gain_db;
1420 	uint32_t base_pwr_db;
1421 	int      fft_chn_idx;
1422 	int      peak_sidx;
1423 	int      relpwr_db;
1424 	int      avgpwr_db;
1425 	int      peak_mag;
1426 	int      num_str_bins_ib;
1427 	int      seg_id;
1428 };
1429 
1430 /**
1431  * dfs_process_radarevent() - process the radar event generated for a pulse.
1432  * @dfs: Pointer to wlan_dfs structure.
1433  * @chan: Current channel.
1434  *
1435  * There is currently no way to specify that a radar event has occurred on
1436  * a specific channel, so the current methodology is to mark both the pri
1437  * and ext channels as being unavailable. This should be fixed for 802.11ac
1438  * or we'll quickly run out of valid channels to use.
1439  *
1440  * If Radar found, this marks the channel (and the extension channel, if HT40)
1441  * as having seen a radar event. It marks CHAN_INTERFERENCE and will add it to
1442  * the local NOL implementation. This is only done for 'usenol=1', as the other
1443  * two modes don't do radar notification or CAC/CSA/NOL; it just notes there
1444  * was a radar.
1445  */
1446 void  dfs_process_radarevent(struct wlan_dfs *dfs,
1447 		struct dfs_channel *chan);
1448 
1449 /**
1450  * dfs_nol_addchan() - Add channel to NOL.
1451  * @dfs: Pointer to wlan_dfs structure.
1452  * @freq: frequency to add to NOL.
1453  * @dfs_nol_timeout: NOL timeout.
1454  */
1455 void dfs_nol_addchan(struct wlan_dfs *dfs,
1456 		uint16_t freq,
1457 		uint32_t dfs_nol_timeout);
1458 
1459 /**
1460  * dfs_get_nol() - Get NOL.
1461  * @dfs: Pointer to wlan_dfs structure.
1462  * @dfs_nol: Pointer to dfsreq_nolelem structure to save the channels from NOL.
1463  * @nchan: Number of channels.
1464  */
1465 void dfs_get_nol(struct wlan_dfs *dfs,
1466 		struct dfsreq_nolelem *dfs_nol,
1467 		int *nchan);
1468 
1469 /**
1470  * dfs_set_nol() - Set NOL.
1471  * @dfs: Pointer to wlan_dfs structure.
1472  * @dfs_nol: Pointer to dfsreq_nolelem structure.
1473  * @nchan: Number of channels.
1474  */
1475 void dfs_set_nol(struct wlan_dfs *dfs,
1476 		struct dfsreq_nolelem *dfs_nol,
1477 		int nchan);
1478 
1479 /**
1480  * dfs_nol_update() - NOL update
1481  * @dfs: Pointer to wlan_dfs structure.
1482  *
1483  * Notify the driver/umac that it should update the channel radar/NOL flags
1484  * based on the current NOL list.
1485  */
1486 void dfs_nol_update(struct wlan_dfs *dfs);
1487 
1488 /**
1489  * dfs_nol_timer_cleanup() - NOL timer cleanup.
1490  * @dfs: Pointer to wlan_dfs structure.
1491  *
1492  * Cancels the NOL timer and frees the NOL elements.
1493  */
1494 void dfs_nol_timer_cleanup(struct wlan_dfs *dfs);
1495 
1496 /**
1497  * dfs_nol_timer_detach() - Free NOL timer.
1498  * @dfs: Pointer to wlan_dfs structure.
1499  */
1500 void dfs_nol_timer_detach(struct wlan_dfs *dfs);
1501 
1502 /**
1503  * dfs_nol_workqueue_cleanup() - Flushes NOL workqueue.
1504  * @dfs: Pointer to wlan_dfs structure.
1505  *
1506  * Flushes the NOL workqueue.
1507  */
1508 void dfs_nol_workqueue_cleanup(struct wlan_dfs *dfs);
1509 
1510 /**
1511  * dfs_retain_bin5_burst_pattern() - Retain the BIN5 burst pattern.
1512  * @dfs: Pointer to wlan_dfs structure.
1513  * @diff_ts: Timestamp diff.
1514  * @old_dur: Old duration.
1515  */
1516 uint8_t dfs_retain_bin5_burst_pattern(struct wlan_dfs *dfs,
1517 		uint32_t diff_ts,
1518 		uint8_t old_dur);
1519 
1520 /**
1521  * dfs_bin5_check_pulse() - BIN5 check pulse.
1522  * @dfs: Pointer to wlan_dfs structure.
1523  * @re: Pointer to dfs_event structure.
1524  * @br: Pointer to dfs_bin5radars structure.
1525  *
1526  * Reject the pulse if:
1527  * 1) It's outside the RSSI threshold;
1528  * 2) It's outside the pulse duration;
1529  * 3) It's been verified by HW/SW chirp checking
1530  *    and neither of those found a chirp.
1531  */
1532 int dfs_bin5_check_pulse(struct wlan_dfs *dfs,
1533 		struct dfs_event *re,
1534 		struct dfs_bin5radars *br);
1535 
1536 /**
1537  * dfs_bin5_addpulse() - BIN5 add pulse.
1538  * @dfs: Pointer to wlan_dfs structure.
1539  * @br: Pointer to dfs_bin5radars structure.
1540  * @re: Pointer to dfs_event structure.
1541  * @thists: Timestamp.
1542  */
1543 int dfs_bin5_addpulse(struct wlan_dfs *dfs,
1544 		struct dfs_bin5radars *br,
1545 		struct dfs_event *re,
1546 		uint64_t thists);
1547 
1548 /**
1549  * dfs_bin5_check() - BIN5 check.
1550  * @dfs: Pointer to wlan_dfs structure.
1551  *
1552  * If the dfs structure is NULL (which should be illegal if everyting is working
1553  * properly, then signify that a bin5 radar was found.
1554  */
1555 int dfs_bin5_check(struct wlan_dfs *dfs);
1556 
1557 /**
1558  * dfs_check_chirping() - Check chirping.
1559  * @dfs: Pointer to wlan_dfs structure.
1560  * @buf: Phyerr buffer
1561  * @datalen: Phyerr buf length
1562  * @is_ctl: detected on primary channel.
1563  * @is_ext: detected on extension channel.
1564  * @slope: Slope
1565  * @is_dc: DC found
1566  *
1567  * This examines the FFT data contained in the PHY error information to figure
1568  * out whether the pulse is moving across frequencies.
1569  */
1570 int dfs_check_chirping(struct wlan_dfs *dfs,
1571 		void *buf,
1572 		uint16_t datalen,
1573 		int is_ctl,
1574 		int is_ext,
1575 		int *slope,
1576 		int *is_dc);
1577 
1578 /**
1579  * dfs_get_random_bin5_dur() - Get random BIN5 duration.
1580  * @dfs: Pointer to wlan_dfs structure.
1581  * @tstamp: Timestamp.
1582  *
1583  * Chirping pulses may get cut off at DC and report lower durations.
1584  * This function will compute a suitable random duration for each pulse.
1585  * Duration must be between 50 and 100 us, but remember that in
1586  * wlan_process_phyerr() which calls this function, we are dealing with the
1587  * HW reported duration (unconverted). dfs_process_radarevent() will
1588  * actually convert the duration into the correct value.
1589  * This function doesn't take into account whether the hardware
1590  * is operating in 5GHz fast clock mode or not.
1591  * And this function doesn't take into account whether the hardware
1592  * is peregrine or not.
1593  */
1594 int dfs_get_random_bin5_dur(struct wlan_dfs *dfs,
1595 		uint64_t tstamp);
1596 
1597 /**
1598  * dfs_print_delayline() - Prints delayline.
1599  * @dfs: Pointer to wlan_dfs structure.
1600  * @dl: Pointer to dfs_delayline structure.
1601  */
1602 void dfs_print_delayline(struct wlan_dfs *dfs,
1603 		struct dfs_delayline *dl);
1604 
1605 /**
1606  * dfs_print_nol() - Print NOL elements.
1607  * @dfs: Pointer to wlan_dfs structure.
1608  */
1609 void dfs_print_nol(struct wlan_dfs *dfs);
1610 
1611 /**
1612  * dfs_print_filter() - Prints the filter.
1613  * @dfs: Pointer to wlan_dfs structure.
1614  * @rf: Pointer to dfs_filter structure.
1615  */
1616 void dfs_print_filter(struct wlan_dfs *dfs,
1617 		struct dfs_filter *rf);
1618 
1619 /**
1620  * dfs_getchanstate() - Get chan state.
1621  * @dfs: Pointer to wlan_dfs structure.
1622  * @index: To save the index of dfs_radar[]
1623  * @ext_chan_flag: Extension channel flag;
1624  */
1625 struct dfs_state *dfs_getchanstate(struct wlan_dfs *dfs,
1626 		uint8_t *index,
1627 		int ext_ch_flag);
1628 
1629 /**
1630  * dfs_round() - DFS found.
1631  * @val: Convert durations to TSF ticks.
1632  *
1633  * Return: TSF ticks.
1634  */
1635 uint32_t dfs_round(int32_t val);
1636 
1637 /**
1638  * dfs_reset_alldelaylines() - Reset alldelaylines.
1639  * @dfs: Pointer to wlan_dfs structure.
1640  */
1641 #if defined(WLAN_DFS_DIRECT_ATTACH) || defined(WLAN_DFS_PARTIAL_OFFLOAD)
1642 void dfs_reset_alldelaylines(struct wlan_dfs *dfs);
1643 #else
1644 static inline void dfs_reset_alldelaylines(struct wlan_dfs *dfs)
1645 {
1646 }
1647 #endif
1648 
1649 /**
1650  * dfs_reset_delayline() - Clear only a single delay line.
1651  * @dl: Pointer to dfs_delayline structure.
1652  */
1653 void dfs_reset_delayline(struct dfs_delayline *dl);
1654 
1655 /**
1656  * dfs_reset_filter_delaylines() - Reset filter delaylines.
1657  * @dft: Pointer to dfs_filtertype structure.
1658  */
1659 void dfs_reset_filter_delaylines(struct dfs_filtertype *dft);
1660 
1661 /**
1662  * dfs_reset_radarq() - Reset radar queue.
1663  * @dfs: Pointer to wlan_dfs structure.
1664  */
1665 #if defined(WLAN_DFS_DIRECT_ATTACH) || defined(WLAN_DFS_PARTIAL_OFFLOAD)
1666 void dfs_reset_radarq(struct wlan_dfs *dfs);
1667 #else
1668 static inline void dfs_reset_radarq(struct wlan_dfs *dfs)
1669 {
1670 }
1671 #endif
1672 
1673 /**
1674  * dfs_add_pulse() - Adds pulse to the queue.
1675  * @dfs: Pointer to wlan_dfs structure.
1676  * @rf: Pointer to dfs_filter structure.
1677  * @re: Pointer to dfs_event structure.
1678  * @deltaT: deltaT value.
1679  * @this_ts: Last time stamp.
1680  */
1681 void dfs_add_pulse(struct wlan_dfs *dfs,
1682 		struct dfs_filter *rf,
1683 		struct dfs_event *re,
1684 		uint32_t deltaT,
1685 		uint64_t this_ts);
1686 
1687 /**
1688  * dfs_bin_check() - BIN check
1689  * @dfs: Pointer to wlan_dfs structure.
1690  * @rf: Pointer to dfs_filter structure.
1691  * @deltaT: deltaT value.
1692  * @width: Width
1693  * @ext_chan_flag: Extension channel flag.
1694  */
1695 int dfs_bin_check(struct wlan_dfs *dfs,
1696 		struct dfs_filter *rf,
1697 		uint32_t deltaT,
1698 		uint32_t dur,
1699 		int ext_chan_flag);
1700 
1701 /**
1702  * dfs_bin_pri_check() - BIN PRI check
1703  * @dfs: Pointer to wlan_dfs structure.
1704  * @rf: Pointer to dfs_filter structure.
1705  * @dl: Pointer to dfs_delayline structure.
1706  * @score: Primary score.
1707  * @refpri: Current "filter" time for start of pulse in usecs.
1708  * @refdur: Duration value.
1709  * @ext_chan_flag: Extension channel flag.
1710  * @fundamentalpri: Highest PRI.
1711  */
1712 int dfs_bin_pri_check(struct wlan_dfs *dfs,
1713 		struct dfs_filter *rf,
1714 		struct dfs_delayline *dl,
1715 		uint32_t score,
1716 		uint32_t refpri,
1717 		uint32_t refdur,
1718 		int ext_chan_flag,
1719 		int fundamentalpri);
1720 
1721 /**
1722  * dfs_staggered_check() - Detection implementation for staggered PRIs.
1723  * @dfs: Pointer to wlan_dfs structure.
1724  * @rf: Pointer to dfs_filter structure.
1725  * @deltaT: Delta of the Timestamp.
1726  * @width: Duration of radar pulse.
1727  *
1728  * Return: 1 on success and 0 on failure.
1729  */
1730 int dfs_staggered_check(struct wlan_dfs *dfs,
1731 		struct dfs_filter *rf,
1732 		uint32_t deltaT,
1733 		uint32_t width);
1734 
1735 /**
1736  * dfs_get_pri_margin() - Get Primary margin.
1737  * @dfs: Pointer to wlan_dfs structure.
1738  * @is_extchan_detect: Extension channel detect.
1739  * @is_fixed_pattern: Fixed pattern.
1740  *
1741  * For the extension channel, if legacy traffic is present, we see a lot of
1742  * false alarms, so make the PRI margin narrower depending on the busy % for
1743  * the extension channel.
1744  *
1745  * Return: Returns pri_margin.
1746  */
1747 int dfs_get_pri_margin(struct wlan_dfs *dfs,
1748 		int is_extchan_detect,
1749 		int is_fixed_pattern);
1750 
1751 /**
1752  * dfs_get_filter_threshold() - Get filter threshold.
1753  * @dfs: Pointer to wlan_dfs structure.
1754  * @rf: Pointer to dfs_filter structure.
1755  * @is_extchan_detect: Extension channel detect.
1756  *
1757  * For the extension channel, if legacy traffic is present, we see a lot of
1758  * false alarms, so make the thresholds higher depending on the busy % for the
1759  * extension channel.
1760  *
1761  * Return: Returns threshold.
1762  */
1763 int dfs_get_filter_threshold(struct wlan_dfs *dfs,
1764 		struct dfs_filter *rf,
1765 		int is_extchan_detect);
1766 
1767 #if defined(QCA_MCL_DFS_SUPPORT)
1768 /**
1769  * dfs_process_ar_event() - Process the ar event.
1770  * @dfs: Pointer to wlan_dfs structure.
1771  * @chan: Current channel structure.
1772  */
1773 static inline void dfs_process_ar_event(struct wlan_dfs *dfs,
1774 					struct dfs_channel *chan)
1775 {
1776 }
1777 
1778 /**
1779  * dfs_reset_ar() - resets the ar state.
1780  * @dfs: pointer to wlan_dfs structure.
1781  */
1782 static inline void dfs_reset_ar(struct wlan_dfs *dfs)
1783 {
1784 }
1785 
1786 /**
1787  * dfs_reset_arq() - resets the ar queue.
1788  * @dfs: pointer to wlan_dfs structure.
1789  */
1790 static inline void dfs_reset_arq(struct wlan_dfs *dfs)
1791 {
1792 }
1793 
1794 #else
1795 void dfs_process_ar_event(struct wlan_dfs *dfs,
1796 			  struct dfs_channel *chan);
1797 
1798 void dfs_reset_ar(struct wlan_dfs *dfs);
1799 void dfs_reset_arq(struct wlan_dfs *dfs);
1800 #endif
1801 
1802 /**
1803  * dfs_is_radar_enabled() - check if radar detection is enabled.
1804  * @dfs: Pointer to wlan_dfs structure.
1805  * @ignore_dfs: if 1 then radar detection is disabled..
1806  */
1807 #if defined(WLAN_DFS_DIRECT_ATTACH) || defined(WLAN_DFS_PARTIAL_OFFLOAD)
1808 void dfs_is_radar_enabled(struct wlan_dfs *dfs,
1809 			  int *ignore_dfs);
1810 #else
1811 static inline void dfs_is_radar_enabled(struct wlan_dfs *dfs,
1812 					int *ignore_dfs)
1813 {
1814 }
1815 #endif
1816 
1817 /**
1818  * dfs_process_phyerr_bb_tlv() - Parses the PHY error and populates the
1819  *                               dfs_phy_err struct.
1820  * @dfs: Pointer to wlan_dfs structure.
1821  * @buf: Phyerr buffer
1822  * @datalen: Phyerr buf len
1823  * @rssi: RSSI
1824  * @ext_rssi: Extension RSSI.
1825  * @rs_tstamp: Time stamp.
1826  * @fulltsf: TSF64.
1827  * @e: Pointer to dfs_phy_err structure.
1828  *
1829  * Return: Returns 1.
1830  */
1831 int dfs_process_phyerr_bb_tlv(struct wlan_dfs *dfs,
1832 		void *buf,
1833 		uint16_t datalen,
1834 		uint8_t rssi,
1835 		uint8_t ext_rssi,
1836 		uint32_t rs_tstamp,
1837 		uint64_t fulltsf,
1838 		struct dfs_phy_err *e);
1839 
1840 /**
1841  * dfs_reset() - DFS reset
1842  * @dfs: Pointer to wlan_dfs structure.
1843  */
1844 void dfs_reset(struct wlan_dfs *dfs);
1845 
1846 /**
1847  * dfs_radar_enable() - Enables the radar.
1848  * @dfs: Pointer to wlan_dfs structure.
1849  * @no_cac: If no_cac is 0, it cancels the CAC.
1850  */
1851 #if defined(WLAN_DFS_DIRECT_ATTACH) || defined(WLAN_DFS_PARTIAL_OFFLOAD)
1852 void dfs_radar_enable(struct wlan_dfs *dfs,
1853 		int no_cac, uint32_t opmode);
1854 #else
1855 static inline void dfs_radar_enable(struct wlan_dfs *dfs,
1856 		int no_cac, uint32_t opmode)
1857 {
1858 }
1859 #endif
1860 
1861 /**
1862  * dfs_process_phyerr() - Process phyerr.
1863  * @dfs: Pointer to wlan_dfs structure.
1864  * @buf: Phyerr buffer.
1865  * @datalen: phyerr buffer length.
1866  * @r_rssi: RSSI.
1867  * @r_ext_rssi: Extension channel RSSI.
1868  * @r_rs_tstamp: Timestamp.
1869  * @r_fulltsf: TSF64.
1870  */
1871 #if defined(WLAN_DFS_DIRECT_ATTACH) || defined(WLAN_DFS_PARTIAL_OFFLOAD)
1872 void dfs_process_phyerr(struct wlan_dfs *dfs,
1873 		void *buf,
1874 		uint16_t datalen,
1875 		uint8_t r_rssi,
1876 		uint8_t r_ext_rssi,
1877 		uint32_t r_rs_tstamp,
1878 		uint64_t r_fulltsf);
1879 #else
1880 static inline void dfs_process_phyerr(struct wlan_dfs *dfs,
1881 		void *buf,
1882 		uint16_t datalen,
1883 		uint8_t r_rssi,
1884 		uint8_t r_ext_rssi,
1885 		uint32_t r_rs_tstamp,
1886 		uint64_t r_fulltsf)
1887 {
1888 }
1889 #endif
1890 
1891 #ifdef QCA_MCL_DFS_SUPPORT
1892 /**
1893  * dfs_process_phyerr_filter_offload() - Process radar event.
1894  * @dfs: Pointer to wlan_dfs structure.
1895  * @wlan_radar_event: Pointer to radar_event_info structure.
1896  *
1897  * Return: None
1898  */
1899 #if defined(WLAN_DFS_PARTIAL_OFFLOAD)
1900 void dfs_process_phyerr_filter_offload(struct wlan_dfs *dfs,
1901 		struct radar_event_info *wlan_radar_event);
1902 #else
1903 static inline void dfs_process_phyerr_filter_offload(
1904 		struct wlan_dfs *dfs,
1905 		struct radar_event_info *wlan_radar_event)
1906 {
1907 }
1908 #endif
1909 #endif
1910 
1911 /**
1912  * dfs_get_radars() - Based on the chipset, calls init radar table functions.
1913  * @dfs: Pointer to wlan_dfs structure.
1914  */
1915 #if defined(WLAN_DFS_DIRECT_ATTACH) || defined(WLAN_DFS_PARTIAL_OFFLOAD)
1916 void dfs_get_radars(struct wlan_dfs *dfs);
1917 #else
1918 static inline void dfs_get_radars(struct wlan_dfs *dfs)
1919 {
1920 }
1921 #endif
1922 
1923 /**
1924  * dfs_attach() - Wrapper function to allocate memory for wlan_dfs members.
1925  * @dfs: Pointer to wlan_dfs structure.
1926  */
1927 int dfs_attach(struct wlan_dfs *dfs);
1928 
1929 
1930 /**
1931  * dfs_create_object() - Creates DFS object.
1932  * @dfs: Pointer to wlan_dfs structure.
1933  */
1934 int dfs_create_object(struct wlan_dfs **dfs);
1935 
1936 /**
1937  * dfs_destroy_object() - Destroys the DFS object.
1938  * @dfs: Pointer to wlan_dfs structure.
1939  */
1940 void dfs_destroy_object(struct wlan_dfs *dfs);
1941 
1942 /**
1943  * dfs_detach() - Wrapper function to free dfs variables.
1944  * @dfs: Pointer to wlan_dfs structure.
1945  */
1946 void dfs_detach(struct wlan_dfs *dfs);
1947 
1948 /**
1949  * dfs_cac_valid_reset() - Cancels the dfs_cac_valid_timer timer.
1950  * @dfs: Pointer to wlan_dfs structure.
1951  * @prevchan_ieee: Prevchan number.
1952  * @prevchan_flags: Prevchan flags.
1953  */
1954 void dfs_cac_valid_reset(struct wlan_dfs *dfs,
1955 		uint8_t prevchan_ieee,
1956 		uint32_t prevchan_flags);
1957 
1958 /**
1959  * dfs_cac_stop() - Clear the AP CAC timer.
1960  * @dfs: Pointer to wlan_dfs structure.
1961  */
1962 void dfs_cac_stop(struct wlan_dfs *dfs);
1963 
1964 /**
1965  * dfs_cancel_cac_timer() - Cancels the CAC timer.
1966  * @dfs: Pointer to wlan_dfs structure.
1967  */
1968 void dfs_cancel_cac_timer(struct wlan_dfs *dfs);
1969 
1970 /**
1971  * dfs_start_cac_timer() - Starts the CAC timer.
1972  * @dfs: Pointer to wlan_dfs structure.
1973  */
1974 void dfs_start_cac_timer(struct wlan_dfs *dfs);
1975 
1976 /**
1977  * dfs_is_subset_channel() - Check if the new_chan is subset of the old_chan.
1978  * @dfs: Pointer to wlan_dfs structure.
1979  * @old_chan: Pointer to old channel.
1980  * @new_chan: Pointer to new channel.
1981  *
1982  * Return: true if the new channel is subset of or same as the old channel,
1983  * else false.
1984  */
1985 bool dfs_is_subset_channel(struct wlan_dfs *dfs,
1986 			   struct dfs_channel *old_chan,
1987 			   struct dfs_channel *new_chan);
1988 
1989 /**
1990  * dfs_is_curchan_subset_of_cac_started_chan() - Check if the dfs current
1991  * channel is subset of cac started channel.
1992  * @dfs: Pointer to wlan_dfs structure.
1993  *
1994  * If the current channel and the cac_started_chan is same or
1995  * if the current channel is subset of the cac_started_chan then
1996  * this function returns true.
1997  *
1998  * Return: true if current channel is same or subset of  cac started channel,
1999  * else false.
2000  */
2001 bool dfs_is_curchan_subset_of_cac_started_chan(struct wlan_dfs *dfs);
2002 
2003 /**
2004  * dfs_clear_cac_started_chan() - Clear dfs cac started channel.
2005  * @dfs: Pointer to wlan_dfs structure.
2006  */
2007 void dfs_clear_cac_started_chan(struct wlan_dfs *dfs);
2008 
2009 /**
2010  * dfs_set_update_nol_flag() - Sets update_nol flag.
2011  * @dfs: Pointer to wlan_dfs structure.
2012  * @val: update_nol flag.
2013  */
2014 void dfs_set_update_nol_flag(struct wlan_dfs *dfs,
2015 		bool val);
2016 
2017 /**
2018  * dfs_get_update_nol_flag() - Returns update_nol flag.
2019  * @dfs: Pointer to wlan_dfs structure.
2020  */
2021 bool dfs_get_update_nol_flag(struct wlan_dfs *dfs);
2022 
2023 /**
2024  * dfs_get_use_nol() - Get usenol.
2025  * @dfs: Pointer to wlan_dfs structure.
2026  */
2027 int dfs_get_use_nol(struct wlan_dfs *dfs);
2028 
2029 /**
2030  * dfs_get_nol_timeout() - Get NOL timeout.
2031  * @dfs: Pointer to wlan_dfs structure.
2032  */
2033 int dfs_get_nol_timeout(struct wlan_dfs *dfs);
2034 
2035 /**
2036  * dfs_is_ap_cac_timer_running() - Returns the dfs cac timer.
2037  * @dfs: Pointer to wlan_dfs structure.
2038  */
2039 int dfs_is_ap_cac_timer_running(struct wlan_dfs *dfs);
2040 
2041 /**
2042  * dfs_control()- Used to process ioctls related to DFS.
2043  * @dfs: Pointer to wlan_dfs structure.
2044  * @id: Command type.
2045  * @indata: Input buffer.
2046  * @insize: size of the input buffer.
2047  * @outdata: A buffer for the results.
2048  * @outsize: Size of the output buffer.
2049  */
2050 int dfs_control(struct wlan_dfs *dfs,
2051 		u_int id,
2052 		void *indata,
2053 		uint32_t insize,
2054 		void *outdata,
2055 		uint32_t *outsize);
2056 
2057 /**
2058  * dfs_getnol() - Wrapper function for dfs_get_nol()
2059  * @dfs: Pointer to wlan_dfs structure.
2060  * @dfs_nolinfo: Pointer to dfsreq_nolinfo structure.
2061  */
2062 void dfs_getnol(struct wlan_dfs *dfs,
2063 		void *dfs_nolinfo);
2064 
2065 /**
2066  * dfs_get_override_cac_timeout() -  Get override CAC timeout value.
2067  * @dfs: Pointer to DFS object.
2068  * @cac_timeout: Pointer to save the CAC timeout value.
2069  */
2070 int dfs_get_override_cac_timeout(struct wlan_dfs *dfs,
2071 		int *cac_timeout);
2072 
2073 /**
2074  * dfs_override_cac_timeout() -  Override the default CAC timeout.
2075  * @dfs: Pointer to DFS object.
2076  * @cac_timeout: CAC timeout value.
2077  */
2078 int dfs_override_cac_timeout(struct wlan_dfs *dfs,
2079 		int cac_timeout);
2080 
2081 /**
2082  * dfs_clear_nolhistory() - unmarks WLAN_CHAN_CLR_HISTORY_RADAR flag for
2083  *                          all the channels in dfs_ch_channels.
2084  * @dfs: Pointer to wlan_dfs structure.
2085  */
2086 void dfs_clear_nolhistory(struct wlan_dfs *dfs);
2087 
2088 /**
2089  * ol_if_dfs_configure() - Initialize the RADAR table for offload chipsets.
2090  * @dfs: Pointer to wlan_dfs structure.
2091  *
2092  * This is called during a channel change or regulatory domain
2093  * reset; in order to fetch the new configuration information and
2094  * program the DFS pattern matching module.
2095  *
2096  * Eventually this should be split into "fetch config" (which can
2097  * happen at regdomain selection time) and "configure DFS" (which
2098  * can happen at channel config time) so as to minimise overheads
2099  * when doing channel changes.  However, this'll do for now.
2100  */
2101 void ol_if_dfs_configure(struct wlan_dfs *dfs);
2102 
2103 /**
2104  * dfs_init_radar_filters() - Init Radar filters.
2105  * @dfs: Pointer to wlan_dfs structure.
2106  * @radar_info: Pointer to wlan_dfs_radar_tab_info structure.
2107  */
2108 int dfs_init_radar_filters(struct wlan_dfs *dfs,
2109 		struct wlan_dfs_radar_tab_info *radar_info);
2110 
2111 /**
2112  * dfs_get_radars_for_ar5212() - Initialize radar table for AR5212 chipsets.
2113  * @dfs: Pointer to wlan_dfs structure.
2114  */
2115 void dfs_get_radars_for_ar5212(struct wlan_dfs *dfs);
2116 
2117 /**
2118  * dfs_get_radars_for_ar5416() - Initialize radar table for AR5416 chipsets.
2119  * @dfs: Pointer to wlan_dfs structure.
2120  */
2121 void dfs_get_radars_for_ar5416(struct wlan_dfs *dfs);
2122 
2123 /**
2124  * dfs_get_radars_for_ar9300() - Initialize radar table for AR9300 chipsets.
2125  * @dfs: Pointer to wlan_dfs structure.
2126  */
2127 void dfs_get_radars_for_ar9300(struct wlan_dfs *dfs);
2128 
2129 /**
2130  * dfs_print_filters() - Print the filters.
2131  * @dfs: Pointer to wlan_dfs structure.
2132  */
2133 void dfs_print_filters(struct wlan_dfs *dfs);
2134 
2135 /**
2136  * dfs_clear_stats() - Clear stats.
2137  * @dfs: Pointer to wlan_dfs structure.
2138  */
2139 void dfs_clear_stats(struct wlan_dfs *dfs);
2140 
2141 /**
2142  * dfs_radar_disable() - Disables the radar.
2143  * @dfs: Pointer to wlan_dfs structure.
2144  */
2145 #if defined(WLAN_DFS_DIRECT_ATTACH) || defined(WLAN_DFS_PARTIAL_OFFLOAD)
2146 int dfs_radar_disable(struct wlan_dfs *dfs);
2147 #else
2148 static inline int dfs_radar_disable(struct wlan_dfs *dfs)
2149 {
2150 	return 0;
2151 }
2152 #endif
2153 
2154 /**
2155  * dfs_get_debug_info() - Get debug info.
2156  * @dfs: Pointer to wlan_dfs structure.
2157  * @data: void pointer to the data to save dfs_proc_phyerr.
2158  */
2159 int dfs_get_debug_info(struct wlan_dfs *dfs,
2160 		void *data);
2161 
2162 /**
2163  * dfs_cac_timer_init() - Initialize cac timers.
2164  * @dfs: Pointer to wlan_dfs structure.
2165  */
2166 void dfs_cac_timer_init(struct wlan_dfs *dfs);
2167 
2168 /**
2169  * dfs_cac_attach() - Initialize dfs cac variables.
2170  * @dfs: Pointer to wlan_dfs structure.
2171  */
2172 void dfs_cac_attach(struct wlan_dfs *dfs);
2173 
2174 /**
2175  * dfs_cac_timer_reset() - Cancel dfs cac timers.
2176  * @dfs: Pointer to wlan_dfs structure.
2177  */
2178 void dfs_cac_timer_reset(struct wlan_dfs *dfs);
2179 
2180 /**
2181  * dfs_cac_timer_detach() - Free dfs cac timers.
2182  * @dfs: Pointer to wlan_dfs structure.
2183  */
2184 void dfs_cac_timer_detach(struct wlan_dfs *dfs);
2185 
2186 /**
2187  * dfs_nol_timer_init() - Initialize NOL timers.
2188  * @dfs: Pointer to wlan_dfs structure.
2189  */
2190 void dfs_nol_timer_init(struct wlan_dfs *dfs);
2191 
2192 /**
2193  * dfs_nol_attach() - Initialize NOL variables.
2194  * @dfs: Pointer to wlan_dfs structure.
2195  */
2196 void dfs_nol_attach(struct wlan_dfs *dfs);
2197 
2198 /**
2199  * dfs_nol_detach() - Detach NOL variables.
2200  * @dfs: Pointer to wlan_dfs structure.
2201  */
2202 void dfs_nol_detach(struct wlan_dfs *dfs);
2203 
2204 /**
2205  * dfs_print_nolhistory() - Print NOL history.
2206  * @dfs: Pointer to wlan_dfs structure.
2207  */
2208 void dfs_print_nolhistory(struct wlan_dfs *dfs);
2209 
2210 /**
2211  * dfs_stacac_stop() - Clear the STA CAC timer.
2212  * @dfs: Pointer to wlan_dfs structure.
2213  */
2214 void dfs_stacac_stop(struct wlan_dfs *dfs);
2215 
2216 /**
2217  * dfs_find_precac_secondary_vht80_chan() - Get a VHT80 channel with the
2218  *                                          precac primary center frequency.
2219  * @dfs: Pointer to wlan_dfs structure.
2220  * @chan: Pointer to dfs channel structure.
2221  */
2222 void dfs_find_precac_secondary_vht80_chan(struct wlan_dfs *dfs,
2223 		struct dfs_channel *chan);
2224 
2225 #ifdef WLAN_DFS_PRECAC_AUTO_CHAN_SUPPORT
2226 /**
2227  * dfs_precac_csa() - Automatically switch the channel to the DFS channel
2228  *			on which PreCAC was completed without finding a RADAR.
2229  *			Use CSA with TBTT_COUNT to switch the channel.
2230  * @dfs: Pointer to dfs handler.
2231  *
2232  * Return: Void
2233  */
2234 void dfs_precac_csa(struct wlan_dfs *dfs);
2235 #endif
2236 
2237 /**
2238  * dfs_phyerr_param_copy() - Function to copy src buf to dest buf.
2239  * @dst: dest buf.
2240  * @src: src buf.
2241  */
2242 void dfs_phyerr_param_copy(struct wlan_dfs_phyerr_param *dst,
2243 		struct wlan_dfs_phyerr_param *src);
2244 
2245 /**
2246  * dfs_get_thresholds() - Get the threshold value.
2247  * @dfs: Pointer to wlan_dfs structure.
2248  * @param: Pointer to wlan_dfs_phyerr_param structure.
2249  */
2250 #if defined(WLAN_DFS_DIRECT_ATTACH) || defined(WLAN_DFS_PARTIAL_OFFLOAD)
2251 int dfs_get_thresholds(struct wlan_dfs *dfs,
2252 		struct wlan_dfs_phyerr_param *param);
2253 #else
2254 static inline int dfs_get_thresholds(struct wlan_dfs *dfs,
2255 		struct wlan_dfs_phyerr_param *param)
2256 {
2257 		return 0;
2258 }
2259 #endif
2260 
2261 /**
2262  * dfs_set_thresholds() - Sets the threshold value.
2263  * @dfs: Pointer to wlan_dfs structure.
2264  * @threshtype: DFS ioctl param type.
2265  * @value: Threshold value.
2266  */
2267 #if defined(WLAN_DFS_DIRECT_ATTACH) || defined(WLAN_DFS_PARTIAL_OFFLOAD)
2268 int dfs_set_thresholds(struct wlan_dfs *dfs,
2269 		const uint32_t threshtype,
2270 		const uint32_t value);
2271 #else
2272 static inline int dfs_set_thresholds(struct wlan_dfs *dfs,
2273 		const uint32_t threshtype,
2274 		const uint32_t value)
2275 {
2276 		return 0;
2277 }
2278 #endif
2279 
2280 /**
2281  * dfs_check_intersect_excl() - Check whether curfreq falls within lower_freq
2282  * and upper_freq, exclusively.
2283  * @low_freq : lower bound frequency value.
2284  * @high_freq: upper bound frequency value.
2285  * @chan_freq: Current frequency value to be checked.
2286  *
2287  * Return: returns true if overlap found, else returns false.
2288  */
2289 #if defined(WLAN_DFS_DIRECT_ATTACH) || defined(WLAN_DFS_PARTIAL_OFFLOAD)
2290 bool dfs_check_intersect_excl(int low_freq, int high_freq, int chan_freq);
2291 #else
2292 static inline bool dfs_check_intersect_excl(int low_freq, int high_freq,
2293 					    int chan_freq)
2294 {
2295 		return false;
2296 }
2297 #endif
2298 
2299 /**
2300  * dfs_check_etsi_overlap() - Check whether given frequency centre/channel
2301  * width entry overlap with frequency spread in any way.
2302  * @center_freq         : current channel centre frequency.
2303  * @chan_width          : current channel width.
2304  * @en302_502_freq_low  : overlap frequency lower bound.
2305  * @en302_502_freq_high : overlap frequency upper bound.
2306  *
2307  * Return: returns 1 if overlap found, else returns 0.
2308  */
2309 #if defined(WLAN_DFS_DIRECT_ATTACH) || defined(WLAN_DFS_PARTIAL_OFFLOAD)
2310 int dfs_check_etsi_overlap(int center_freq, int chan_width,
2311 			   int en302_502_freq_low, int en302_502_freq_high);
2312 #else
2313 static inline int dfs_check_etsi_overlap(int center_freq, int chan_width,
2314 					 int en302_502_freq_low,
2315 					 int en302_502_freq_high)
2316 {
2317 		return 0;
2318 }
2319 #endif
2320 
2321 /**
2322  * dfs_is_en302_502_applicable() - Check whether current channel frequecy spread
2323  *					overlaps with EN 302 502 radar type
2324  *					frequency range.
2325  *@dfs: Pointer to wlan_dfs structure.
2326  *
2327  * Return: returns true if overlap found, else returns false.
2328  */
2329 #if defined(WLAN_DFS_DIRECT_ATTACH) || defined(WLAN_DFS_PARTIAL_OFFLOAD)
2330 bool dfs_is_en302_502_applicable(struct wlan_dfs *dfs);
2331 #else
2332 static inline bool dfs_is_en302_502_applicable(struct wlan_dfs *dfs)
2333 {
2334 		return false;
2335 }
2336 #endif
2337 
2338 /**
2339  * dfs_set_current_channel() - Set DFS current channel.
2340  * @dfs: Pointer to wlan_dfs structure.
2341  * @dfs_ch_freq: Frequency in Mhz.
2342  * @dfs_ch_flags: Channel flags.
2343  * @dfs_ch_flagext: Extended channel flags.
2344  * @dfs_ch_ieee: IEEE channel number.
2345  * @dfs_ch_vhtop_ch_freq_seg1: Channel Center frequency1.
2346  * @dfs_ch_vhtop_ch_freq_seg2: Channel Center frequency2.
2347  */
2348 void dfs_set_current_channel(struct wlan_dfs *dfs,
2349 		uint16_t dfs_ch_freq,
2350 		uint64_t dfs_ch_flags,
2351 		uint16_t dfs_ch_flagext,
2352 		uint8_t dfs_ch_ieee,
2353 		uint8_t dfs_ch_vhtop_ch_freq_seg1,
2354 		uint8_t dfs_ch_vhtop_ch_freq_seg2);
2355 
2356 /**
2357  * dfs_get_nol_chfreq_and_chwidth() - Get channel freq and width from NOL list.
2358  * @dfs_nol: Pointer to NOL channel entry.
2359  * @nol_chfreq: Pointer to save channel frequency.
2360  * @nol_chwidth: Pointer to save channel width.
2361  * @index: Index to dfs_nol list.
2362  */
2363 void dfs_get_nol_chfreq_and_chwidth(struct dfsreq_nolelem *dfs_nol,
2364 		uint32_t *nol_chfreq,
2365 		uint32_t *nol_chwidth,
2366 		int index);
2367 
2368 /**
2369  * dfs_process_phyerr_owl() - Process an Owl-style phy error.
2370  * @dfs: Pointer to wlan_dfs structure.
2371  * @buf: Phyerr buffer
2372  * @datalen: Phyerr buf len
2373  * @rssi: RSSI
2374  * @ext_rssi: Extension RSSI.
2375  * @rs_tstamp: Time stamp.
2376  * @fulltsf: TSF64.
2377  * @e: Pointer to dfs_phy_err structure.
2378  *
2379  * Return: Returns 1.
2380  */
2381 int dfs_process_phyerr_owl(struct wlan_dfs *dfs,
2382 		void *buf,
2383 		uint16_t datalen,
2384 		uint8_t rssi,
2385 		uint8_t ext_rssi,
2386 		uint32_t rs_tstamp,
2387 		uint64_t fulltsf,
2388 		struct dfs_phy_err *e);
2389 
2390 /**
2391  * dfs_process_phyerr_sowl() -Process a Sowl/Howl style phy error.
2392  * @dfs: Pointer to wlan_dfs structure.
2393  * @buf: Phyerr buffer
2394  * @datalen: Phyerr buf len
2395  * @rssi: RSSI
2396  * @ext_rssi: Extension RSSI.
2397  * @rs_tstamp: Time stamp.
2398  * @fulltsf: TSF64.
2399  * @e: Pointer to dfs_phy_err structure.
2400  *
2401  * Return: Returns 1.
2402  */
2403 int dfs_process_phyerr_sowl(struct wlan_dfs *dfs,
2404 		void *buf,
2405 		uint16_t datalen,
2406 		uint8_t rssi,
2407 		uint8_t ext_rssi,
2408 		uint32_t rs_tstamp,
2409 		uint64_t fulltsf,
2410 		struct dfs_phy_err *e);
2411 
2412 /**
2413  * dfs_process_phyerr_merlin() - Process a Merlin/Osprey style phy error.
2414  *                               dfs_phy_err struct.
2415  * @dfs: Pointer to wlan_dfs structure.
2416  * @buf: Phyerr buffer
2417  * @datalen: Phyerr buf len
2418  * @rssi: RSSI
2419  * @ext_rssi: Extension RSSI.
2420  * @rs_tstamp: Time stamp.
2421  * @fulltsf: TSF64.
2422  * @e: Pointer to dfs_phy_err structure.
2423  *
2424  * Return: Returns 1.
2425  */
2426 int dfs_process_phyerr_merlin(struct wlan_dfs *dfs,
2427 		void *buf,
2428 		uint16_t datalen,
2429 		uint8_t rssi,
2430 		uint8_t ext_rssi,
2431 		uint32_t rs_tstamp,
2432 		uint64_t fulltsf,
2433 		struct dfs_phy_err *e);
2434 
2435 /*
2436  * __dfs_process_radarevent() - Continuation of process a radar event function.
2437  * @dfs: Pointer to wlan_dfs structure.
2438  * @ft: Pointer to dfs_filtertype structure.
2439  * @re: Pointer to dfs_event structure.
2440  * @this_ts: Timestamp.
2441  *
2442  * There is currently no way to specify that a radar event has occurred on
2443  * a specific channel, so the current methodology is to mark both the pri
2444  * and ext channels as being unavailable.  This should be fixed for 802.11ac
2445  * or we'll quickly run out of valid channels to use.
2446  *
2447  * Return: If a radar event is found, return 1.  Otherwise, return 0.
2448  */
2449 void __dfs_process_radarevent(struct wlan_dfs *dfs,
2450 		struct dfs_filtertype *ft,
2451 		struct dfs_event *re,
2452 		uint64_t this_ts,
2453 		int *found,
2454 		int *false_radar_found);
2455 
2456 /**
2457  * dfs_radar_found_action() - Radar found action
2458  * @dfs: Pointer to wlan_dfs structure.
2459  * @bangradar: true if radar is due to bangradar command.
2460  * @seg_id: Segment id.
2461  */
2462 void dfs_radar_found_action(struct wlan_dfs *dfs,
2463 			    bool bangradar,
2464 			    uint8_t seg_id);
2465 
2466 /**
2467  * bin5_rules_check_internal() - This is a extension of dfs_bin5_check().
2468  * @dfs: Pointer to wlan_dfs structure.
2469  * @br: Pointer to dfs_bin5radars structure.
2470  * @bursts: Bursts.
2471  * @numevents: Number of events.
2472  * @prev: prev index.
2473  * @i: Index.
2474  * @this: index to br_elems[]
2475  */
2476 void bin5_rules_check_internal(struct wlan_dfs *dfs,
2477 		struct dfs_bin5radars *br,
2478 		uint32_t *bursts,
2479 		uint32_t *numevents,
2480 		uint32_t prev,
2481 		uint32_t i,
2482 		uint32_t this,
2483 		int *index);
2484 
2485 /**
2486  * dfs_main_task_testtimer_init() - Initialize dfs task testtimer.
2487  * @dfs: Pointer to wlan_dfs structure.
2488  */
2489 void dfs_main_task_testtimer_init(struct wlan_dfs *dfs);
2490 
2491 /**
2492  * dfs_stop() - Clear dfs timers.
2493  * @dfs: Pointer to wlan_dfs structure.
2494  */
2495 void dfs_stop(struct wlan_dfs *dfs);
2496 
2497 /**
2498  * dfs_update_cur_chan_flags() - Update DFS channel flag and flagext.
2499  * @dfs: Pointer to wlan_dfs structure.
2500  * @flags: New channel flags
2501  * @flagext: New Extended flags
2502  */
2503 void dfs_update_cur_chan_flags(struct wlan_dfs *dfs,
2504 		uint64_t flags,
2505 		uint16_t flagext);
2506 
2507 /**
2508  * dfs_radarevent_basic_sanity() - Check basic sanity of the radar event
2509  * @dfs: Pointer to wlan_dfs structure.
2510  * @chan: Current channel.
2511  *
2512  * Return: If a radar event found on NON-DFS channel  return 0.  Otherwise,
2513  * return 1.
2514  */
2515 int dfs_radarevent_basic_sanity(struct wlan_dfs *dfs,
2516 		struct dfs_channel *chan);
2517 
2518 /**
2519  * wlan_psoc_get_dfs_txops() - Get dfs_tx_ops pointer
2520  * @psoc: Pointer to psoc structure.
2521  *
2522  * Return: Pointer to dfs_tx_ops.
2523  */
2524 struct wlan_lmac_if_dfs_tx_ops *
2525 wlan_psoc_get_dfs_txops(struct wlan_objmgr_psoc *psoc);
2526 
2527 /**
2528  * dfs_nol_free_list() - Free NOL elements.
2529  * @dfs: Pointer to wlan_dfs structure.
2530  */
2531 void dfs_nol_free_list(struct wlan_dfs *dfs);
2532 
2533 /**
2534  * dfs_second_segment_radar_disable() - Disables the second segment radar.
2535  * @dfs: Pointer to wlan_dfs structure.
2536  *
2537  * This is called when AP detects the radar, to (potentially) disable
2538  * the radar code.
2539  *
2540  * Return: returns 0.
2541  */
2542 int dfs_second_segment_radar_disable(struct wlan_dfs *dfs);
2543 
2544 /**
2545  * dfs_fetch_nol_ie_info() - Fill NOL information to be sent with RCSA.
2546  * @dfs                    - Pointer to wlan_dfs structure.
2547  * @nol_ie_bandwidth       - Minimum subchannel bandwidth.
2548  * @nol_ie_startfreq       - Radar affected channel list's first subchannel's
2549  *                         - centre frequency.
2550  * @nol_ie_bitmap          - NOL bitmap denoting affected subchannels.
2551  */
2552 void dfs_fetch_nol_ie_info(struct wlan_dfs *dfs, uint8_t *nol_ie_bandwidth,
2553 			   uint16_t *nol_ie_startfreq, uint8_t *nol_ie_bitmap);
2554 
2555 /**
2556  * dfs_set_rcsa_flags() - Set flags that are required for sending RCSA and
2557  * NOL IE.
2558  * @dfs: Pointer to wlan_dfs structure.
2559  * @is_rcsa_ie_sent: Boolean to check if RCSA IE should be sent or not.
2560  * @is_nol_ie_sent: Boolean to check if NOL IE should be sent or not.
2561  */
2562 void dfs_set_rcsa_flags(struct wlan_dfs *dfs, bool is_rcsa_ie_sent,
2563 			bool is_nol_ie_sent);
2564 
2565 /**
2566  * dfs_get_rcsa_flags() - Get flags that are required for sending RCSA and
2567  * NOL IE.
2568  * @dfs: Pointer to wlan_dfs structure.
2569  * @is_rcsa_ie_sent: Boolean to check if RCSA IE should be sent or not.
2570  * @is_nol_ie_sent: Boolean to check if NOL IE should be sent or not.
2571  */
2572 void dfs_get_rcsa_flags(struct wlan_dfs *dfs, bool *is_rcsa_ie_sent,
2573 			bool *is_nol_ie_sent);
2574 
2575 /**
2576  * dfs_process_nol_ie_bitmap() - Update NOL with external radar information.
2577  * @dfs               - Pointer to wlan_dfs structure.
2578  * @nol_ie_bandwidth  - Minimum subchannel bandwidth.
2579  * @nol_ie_starfreq   - Radar affected channel list's first subchannel's
2580  *                    - centre frequency.
2581  * @nol_ie_bitmap     - Bitmap denoting radar affected subchannels.
2582  *
2583  * Return: True if NOL IE should be propagated, else false.
2584  */
2585 bool dfs_process_nol_ie_bitmap(struct wlan_dfs *dfs, uint8_t nol_ie_bandwidth,
2586 			       uint16_t nol_ie_startfreq,
2587 			       uint8_t nol_ie_bitmap);
2588 
2589 /**
2590  * dfs_check_for_cac_start() - Check for DFS CAC start conditions.
2591  * @dfs: Pointer to wlan_dfs structure.
2592  * @continue_current_cac: If AP can start CAC then this variable indicates
2593  * whether to continue with the current CAC or restart the CAC. This variable
2594  * is valid only if this function returns true.
2595  *
2596  * Return: true if AP can start or continue the current CAC, else false.
2597  */
2598 bool dfs_check_for_cac_start(struct wlan_dfs *dfs,
2599 			     bool *continue_current_cac);
2600 
2601 /**
2602  * dfs_task_testtimer_reset() - stop dfs test timer.
2603  * @dfs: Pointer to wlan_dfs structure.
2604  */
2605 void dfs_task_testtimer_reset(struct wlan_dfs *dfs);
2606 
2607 /**
2608  * dfs_is_freq_in_nol() - check if given channel in nol list
2609  * @dfs: Pointer to wlan_dfs structure
2610  * @freq: channel frequency
2611  *
2612  * check if given channel in nol list.
2613  *
2614  * Return: true if channel in nol, false else
2615  */
2616 bool dfs_is_freq_in_nol(struct wlan_dfs *dfs, uint32_t freq);
2617 
2618 /**
2619  * dfs_task_testtimer_detach() - Free dfs test timer.
2620  * @dfs: Pointer to wlan_dfs structure.
2621  */
2622 void dfs_task_testtimer_detach(struct wlan_dfs *dfs);
2623 
2624 /**
2625  * dfs_timer_detach() - Free dfs timers.
2626  * @dfs: Pointer to wlan_dfs structure.
2627  */
2628 void dfs_timer_detach(struct wlan_dfs *dfs);
2629 
2630 /**
2631  * dfs_is_disable_radar_marking_set() - Check if radar marking is set on
2632  * NOL chan.
2633  * @dfs: Pointer to wlan_dfs structure.
2634  */
2635 #if defined(WLAN_DFS_FULL_OFFLOAD) && defined(QCA_DFS_NOL_OFFLOAD)
2636 int dfs_is_disable_radar_marking_set(struct wlan_dfs *dfs,
2637 				     bool *disable_radar_marking);
2638 #else
2639 static inline int dfs_is_disable_radar_marking_set(struct wlan_dfs *dfs,
2640 						   bool *disable_radar_marking)
2641 {
2642 	return QDF_STATUS_SUCCESS;
2643 }
2644 #endif
2645 /**
2646  * dfs_get_disable_radar_marking() - Get the value of disable radar marking.
2647  * @dfs: Pointer to wlan_dfs structure.
2648  */
2649 #if defined(WLAN_DFS_FULL_OFFLOAD) && defined(QCA_DFS_NOL_OFFLOAD)
2650 bool dfs_get_disable_radar_marking(struct wlan_dfs *dfs);
2651 #endif
2652 #endif  /* _DFS_H_ */
2653