xref: /wlan-dirver/qca-wifi-host-cmn/umac/dfs/core/src/misc/dfs_cac.c (revision 503663c6daafffe652fa360bde17243568cd6d2a)
1 /*
2  * Copyright (c) 2016-2019 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2007-2008 Sam Leffler, Errno Consulting
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  */
26 
27 /**
28  * DOC: This file has the functions related to DFS CAC.
29  */
30 
31 #include "../dfs_channel.h"
32 #include "../dfs_zero_cac.h"
33 #include <wlan_objmgr_vdev_obj.h>
34 #include "wlan_dfs_utils_api.h"
35 #include "wlan_dfs_mlme_api.h"
36 #include "../dfs_internal.h"
37 #include "../dfs_process_radar_found_ind.h"
38 
39 #define IS_CHANNEL_WEATHER_RADAR(freq) ((freq >= 5600) && (freq <= 5650))
40 #define ADJACENT_WEATHER_RADAR_CHANNEL   5580
41 #define CH100_START_FREQ                 5490
42 #define CH100                            100
43 
44 int dfs_override_cac_timeout(struct wlan_dfs *dfs, int cac_timeout)
45 {
46 	if (!dfs)
47 		return -EIO;
48 
49 	dfs->dfs_cac_timeout_override = cac_timeout;
50 	dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS, "CAC timeout is now %s %d",
51 		(cac_timeout == -1) ? "default" : "overridden",
52 		cac_timeout);
53 
54 	return 0;
55 }
56 
57 int dfs_get_override_cac_timeout(struct wlan_dfs *dfs, int *cac_timeout)
58 {
59 	if (!dfs)
60 		return -EIO;
61 
62 	(*cac_timeout) = dfs->dfs_cac_timeout_override;
63 
64 	return 0;
65 }
66 
67 #ifdef CONFIG_CHAN_NUM_API
68 void dfs_cac_valid_reset(struct wlan_dfs *dfs,
69 		uint8_t prevchan_ieee,
70 		uint32_t prevchan_flags)
71 {
72 	if (dfs->dfs_cac_valid_time) {
73 		if ((prevchan_ieee != dfs->dfs_curchan->dfs_ch_ieee) ||
74 			(prevchan_flags != dfs->dfs_curchan->dfs_ch_flags)) {
75 			dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,
76 					"Cancelling timer & clearing cac_valid"
77 					);
78 			qdf_timer_stop(&dfs->dfs_cac_valid_timer);
79 			dfs->dfs_cac_valid = 0;
80 		}
81 	}
82 }
83 #endif
84 
85 #ifdef CONFIG_CHAN_FREQ_API
86 void dfs_cac_valid_reset_for_freq(struct wlan_dfs *dfs,
87 				  uint16_t prevchan_freq,
88 				  uint32_t prevchan_flags)
89 {
90 	if (dfs->dfs_cac_valid_time) {
91 		if ((prevchan_freq != dfs->dfs_curchan->dfs_ch_freq) ||
92 		    (prevchan_flags != dfs->dfs_curchan->dfs_ch_flags)) {
93 			dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,
94 				"Cancelling timer & clearing cac_valid");
95 			qdf_timer_stop(&dfs->dfs_cac_valid_timer);
96 			dfs->dfs_cac_valid = 0;
97 		}
98 	}
99 }
100 #endif
101 
102 /**
103  * dfs_cac_valid_timeout() - Timeout function for dfs_cac_valid_timer
104  *                           cac_valid bit will be reset in this function.
105  */
106 static os_timer_func(dfs_cac_valid_timeout)
107 {
108 	struct wlan_dfs *dfs = NULL;
109 
110 	OS_GET_TIMER_ARG(dfs, struct wlan_dfs *);
111 	dfs->dfs_cac_valid = 0;
112 	dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS, ": Timed out!!");
113 }
114 
115 /**
116  * dfs_clear_cac_started_chan() - Clear dfs cac started channel.
117  * @dfs: Pointer to wlan_dfs structure.
118  */
119 static void dfs_clear_cac_started_chan(struct wlan_dfs *dfs)
120 {
121 	qdf_mem_zero(&dfs->dfs_cac_started_chan,
122 		     sizeof(dfs->dfs_cac_started_chan));
123 }
124 
125 /**
126  * dfs_cac_timeout() - DFS cactimeout function.
127  *
128  * Sets dfs_cac_timer_running to 0  and dfs_cac_valid_timer.
129  */
130 #ifdef CONFIG_CHAN_FREQ_API
131 static os_timer_func(dfs_cac_timeout)
132 {
133 	struct wlan_dfs *dfs = NULL;
134 	enum phy_ch_width ch_width = CH_WIDTH_INVALID;
135 	uint16_t primary_chan_freq = 0, secondary_chan_freq = 0;
136 	struct dfs_channel *dfs_curchan;
137 
138 	OS_GET_TIMER_ARG(dfs, struct wlan_dfs *);
139 	dfs->dfs_cac_timer_running = 0;
140 	dfs_curchan = dfs->dfs_curchan;
141 
142 	dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS, "cac expired, chan %d curr time %d",
143 		 dfs->dfs_curchan->dfs_ch_freq,
144 		 (qdf_system_ticks_to_msecs(qdf_system_ticks()) / 1000));
145 
146 	/*
147 	 * When radar is detected during a CAC we are woken up prematurely to
148 	 * switch to a new channel. Check the channel to decide how to act.
149 	 */
150 	if (WLAN_IS_CHAN_RADAR(dfs->dfs_curchan)) {
151 		dfs_mlme_mark_dfs_for_freq(dfs->dfs_pdev_obj,
152 					   dfs_curchan->dfs_ch_ieee,
153 					   dfs_curchan->dfs_ch_freq,
154 					   dfs_curchan->dfs_ch_mhz_freq_seg2,
155 					   dfs_curchan->dfs_ch_flags);
156 		dfs_debug(dfs, WLAN_DEBUG_DFS,
157 			  "CAC timer on channel %u (%u MHz) stopped due to radar",
158 			  dfs_curchan->dfs_ch_ieee,
159 			  dfs_curchan->dfs_ch_freq);
160 	} else {
161 		dfs_debug(dfs, WLAN_DEBUG_DFS,
162 			  "CAC timer on channel %u (%u MHz) expired; no radar detected",
163 			  dfs_curchan->dfs_ch_ieee,
164 			  dfs_curchan->dfs_ch_freq);
165 
166 		/* On CAC completion, set the bit 'cac_valid'.
167 		 * CAC will not be re-done if this bit is reset.
168 		 * The flag will be reset when dfs_cac_valid_timer
169 		 * timesout.
170 		 */
171 		if (dfs->dfs_cac_valid_time) {
172 			dfs->dfs_cac_valid = 1;
173 			qdf_timer_mod(&dfs->dfs_cac_valid_timer,
174 				      dfs->dfs_cac_valid_time * 1000);
175 		}
176 
177 		dfs_find_chwidth_and_center_chan_for_freq(dfs,
178 							  &ch_width,
179 							  &primary_chan_freq,
180 							  &secondary_chan_freq);
181 		/* Mark the current channel as preCAC done */
182 		dfs_mark_precac_done_for_freq(dfs, primary_chan_freq,
183 					      secondary_chan_freq, ch_width);
184 	}
185 
186 	dfs_clear_cac_started_chan(dfs);
187 	/* Iterate over the nodes, processing the CAC completion event. */
188 	dfs_mlme_proc_cac(dfs->dfs_pdev_obj, 0);
189 
190 	/* Send a CAC timeout, VAP up event to user space */
191 	dfs_mlme_deliver_event_up_after_cac(dfs->dfs_pdev_obj);
192 
193 	if (dfs->dfs_defer_precac_channel_change == 1) {
194 		dfs_mlme_channel_change_by_precac(dfs->dfs_pdev_obj);
195 		dfs->dfs_defer_precac_channel_change = 0;
196 	}
197 }
198 #else
199 #ifdef CONFIG_CHAN_NUM_API
200 static os_timer_func(dfs_cac_timeout)
201 {
202 	struct wlan_dfs *dfs = NULL;
203 	enum phy_ch_width ch_width = CH_WIDTH_INVALID;
204 	uint8_t primary_chan_ieee = 0, secondary_chan_ieee = 0;
205 
206 	OS_GET_TIMER_ARG(dfs, struct wlan_dfs *);
207 	dfs->dfs_cac_timer_running = 0;
208 
209 	dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS, "cac expired, chan %d curr time %d",
210 		dfs->dfs_curchan->dfs_ch_freq,
211 		(qdf_system_ticks_to_msecs(qdf_system_ticks()) / 1000));
212 
213 	/*
214 	 * When radar is detected during a CAC we are woken up prematurely to
215 	 * switch to a new channel. Check the channel to decide how to act.
216 	 */
217 	if (WLAN_IS_CHAN_RADAR(dfs->dfs_curchan)) {
218 		dfs_mlme_mark_dfs(dfs->dfs_pdev_obj,
219 				dfs->dfs_curchan->dfs_ch_ieee,
220 				dfs->dfs_curchan->dfs_ch_freq,
221 				dfs->dfs_curchan->dfs_ch_vhtop_ch_freq_seg2,
222 				dfs->dfs_curchan->dfs_ch_flags);
223 		dfs_debug(dfs, WLAN_DEBUG_DFS,
224 			"CAC timer on channel %u (%u MHz) stopped due to radar",
225 			dfs->dfs_curchan->dfs_ch_ieee,
226 			dfs->dfs_curchan->dfs_ch_freq);
227 	} else {
228 		dfs_debug(dfs, WLAN_DEBUG_DFS,
229 			"CAC timer on channel %u (%u MHz) expired; no radar detected",
230 			dfs->dfs_curchan->dfs_ch_ieee,
231 			dfs->dfs_curchan->dfs_ch_freq);
232 
233 		/* On CAC completion, set the bit 'cac_valid'.
234 		 * CAC will not be re-done if this bit is reset.
235 		 * The flag will be reset when dfs_cac_valid_timer
236 		 * timesout.
237 		 */
238 		if (dfs->dfs_cac_valid_time) {
239 			dfs->dfs_cac_valid = 1;
240 			qdf_timer_mod(&dfs->dfs_cac_valid_timer,
241 					dfs->dfs_cac_valid_time * 1000);
242 		}
243 
244 		dfs_find_chwidth_and_center_chan(dfs,
245 						 &ch_width,
246 						 &primary_chan_ieee,
247 						 &secondary_chan_ieee);
248 		/* Mark the current channel as preCAC done */
249 		dfs_mark_precac_done(dfs, primary_chan_ieee,
250 				     secondary_chan_ieee, ch_width);
251 	}
252 
253 	dfs_clear_cac_started_chan(dfs);
254 	/* Iterate over the nodes, processing the CAC completion event. */
255 	dfs_mlme_proc_cac(dfs->dfs_pdev_obj, 0);
256 
257 	/* Send a CAC timeout, VAP up event to user space */
258 	dfs_mlme_deliver_event_up_after_cac(dfs->dfs_pdev_obj);
259 
260 	if (dfs->dfs_defer_precac_channel_change == 1) {
261 		dfs_mlme_channel_change_by_precac(dfs->dfs_pdev_obj);
262 		dfs->dfs_defer_precac_channel_change = 0;
263 	}
264 }
265 #endif
266 #endif
267 
268 void dfs_cac_timer_attach(struct wlan_dfs *dfs)
269 {
270 	dfs->dfs_cac_timeout_override = -1;
271 	dfs->wlan_dfs_cac_time = WLAN_DFS_WAIT_MS;
272 	qdf_timer_init(NULL,
273 			&(dfs->dfs_cac_timer),
274 			dfs_cac_timeout,
275 			(void *)(dfs),
276 			QDF_TIMER_TYPE_WAKE_APPS);
277 
278 	qdf_timer_init(NULL,
279 			&(dfs->dfs_cac_valid_timer),
280 			dfs_cac_valid_timeout,
281 			(void *)(dfs),
282 			QDF_TIMER_TYPE_WAKE_APPS);
283 }
284 
285 void dfs_cac_timer_reset(struct wlan_dfs *dfs)
286 {
287 	qdf_timer_stop(&dfs->dfs_cac_timer);
288 	dfs_get_override_cac_timeout(dfs,
289 			&(dfs->dfs_cac_timeout_override));
290 	dfs_clear_cac_started_chan(dfs);
291 }
292 
293 void dfs_cac_timer_detach(struct wlan_dfs *dfs)
294 {
295 	qdf_timer_free(&dfs->dfs_cac_timer);
296 
297 	qdf_timer_free(&dfs->dfs_cac_valid_timer);
298 	dfs->dfs_cac_valid = 0;
299 }
300 
301 int dfs_is_ap_cac_timer_running(struct wlan_dfs *dfs)
302 {
303 	return dfs->dfs_cac_timer_running;
304 }
305 
306 #ifdef CONFIG_CHAN_FREQ_API
307 void dfs_start_cac_timer(struct wlan_dfs *dfs)
308 {
309 	int cac_timeout = 0;
310 	struct dfs_channel *chan = dfs->dfs_curchan;
311 
312 	cac_timeout =
313 	    dfs_mlme_get_cac_timeout_for_freq(dfs->dfs_pdev_obj,
314 					      chan->dfs_ch_freq,
315 					      chan->dfs_ch_mhz_freq_seg2,
316 					      chan->dfs_ch_flags);
317 
318 	dfs->dfs_cac_started_chan = *chan;
319 
320 	dfs_debug(dfs, WLAN_DEBUG_DFS,
321 		  "chan = %d cfreq2 = %d timeout = %d sec, curr_time = %d sec",
322 		  chan->dfs_ch_ieee, chan->dfs_ch_vhtop_ch_freq_seg2,
323 		  cac_timeout,
324 		  qdf_system_ticks_to_msecs(qdf_system_ticks()) / 1000);
325 
326 	qdf_timer_mod(&dfs->dfs_cac_timer, cac_timeout * 1000);
327 	dfs->dfs_cac_aborted = 0;
328 }
329 #else
330 #ifdef CONFIG_CHAN_NUM_API
331 void dfs_start_cac_timer(struct wlan_dfs *dfs)
332 {
333 	int cac_timeout = 0;
334 	struct dfs_channel *chan = dfs->dfs_curchan;
335 
336 	cac_timeout = dfs_mlme_get_cac_timeout(dfs->dfs_pdev_obj,
337 					       chan->dfs_ch_freq,
338 					       chan->dfs_ch_vhtop_ch_freq_seg2,
339 					       chan->dfs_ch_flags);
340 
341 	dfs->dfs_cac_started_chan = *chan;
342 
343 	dfs_debug(dfs, WLAN_DEBUG_DFS,
344 		  "chan = %d cfreq2 = %d timeout = %d sec, curr_time = %d sec",
345 		  chan->dfs_ch_ieee, chan->dfs_ch_vhtop_ch_freq_seg2,
346 		  cac_timeout,
347 		  qdf_system_ticks_to_msecs(qdf_system_ticks()) / 1000);
348 
349 	qdf_timer_mod(&dfs->dfs_cac_timer, cac_timeout * 1000);
350 	dfs->dfs_cac_aborted = 0;
351 }
352 #endif
353 #endif
354 
355 void dfs_cancel_cac_timer(struct wlan_dfs *dfs)
356 {
357 	qdf_timer_stop(&dfs->dfs_cac_timer);
358 	dfs_clear_cac_started_chan(dfs);
359 }
360 
361 void dfs_cac_stop(struct wlan_dfs *dfs)
362 {
363 	uint32_t phyerr;
364 
365 	dfs_get_debug_info(dfs, (void *)&phyerr);
366 	dfs_debug(dfs, WLAN_DEBUG_DFS,
367 		"Stopping CAC Timer %d procphyerr 0x%08x",
368 		 dfs->dfs_curchan->dfs_ch_freq, phyerr);
369 	qdf_timer_stop(&dfs->dfs_cac_timer);
370 	if (dfs->dfs_cac_timer_running)
371 		dfs->dfs_cac_aborted = 1;
372 	dfs_clear_cac_started_chan(dfs);
373 	dfs->dfs_cac_timer_running = 0;
374 }
375 
376 void dfs_stacac_stop(struct wlan_dfs *dfs)
377 {
378 	uint32_t phyerr;
379 
380 	dfs_get_debug_info(dfs, (void *)&phyerr);
381 	dfs_debug(dfs, WLAN_DEBUG_DFS,
382 		"Stopping STA CAC Timer %d procphyerr 0x%08x",
383 		 dfs->dfs_curchan->dfs_ch_freq, phyerr);
384 	dfs_clear_cac_started_chan(dfs);
385 }
386 
387 /*
388  * dfs_is_subset_channel_for_freq() - Find out if prev channel and current
389  * channel are subsets of each other.
390  * @old_subchans_freq: Pointer to previous sub-channels freq.
391  * @old_n_chans: Number of previous sub-channels.
392  * @new_subchans_freq: Pointer to new sub-channels freq.
393  * @new_n_chans:  Number of new sub-channels
394  */
395 #ifdef CONFIG_CHAN_FREQ_API
396 static bool
397 dfs_is_subset_channel_for_freq(uint16_t *old_subchans_freq,
398 			       uint8_t old_n_chans,
399 			       uint16_t *new_subchans_freq,
400 			       uint8_t new_n_chans)
401 {
402 	bool is_found;
403 	int i, j;
404 
405 	if (!new_n_chans)
406 		return true;
407 
408 	if (new_n_chans > old_n_chans)
409 		return false;
410 
411 	for (i = 0; i < new_n_chans; i++) {
412 		is_found = false;
413 		for (j = 0; j < old_n_chans; j++) {
414 			if (new_subchans_freq[i] == old_subchans_freq[j]) {
415 				is_found = true;
416 				break;
417 			}
418 		}
419 
420 		/* If new_subchans[i] is not found in old_subchans, then,
421 		 * new_chan is not subset of old_chan.
422 		 */
423 		if (!is_found)
424 			break;
425 	}
426 
427 	return is_found;
428 }
429 #endif
430 
431 #ifdef CONFIG_CHAN_FREQ_API
432 static uint8_t
433 dfs_find_dfs_sub_channels_for_freq(struct wlan_dfs *dfs,
434 				   struct dfs_channel *chan,
435 				   uint16_t *subchan_arr)
436 {
437 	if (WLAN_IS_CHAN_MODE_160(chan) || WLAN_IS_CHAN_MODE_80_80(chan)) {
438 		if (WLAN_IS_CHAN_DFS(chan) && WLAN_IS_CHAN_DFS_CFREQ2(chan))
439 			return dfs_get_bonding_channel_without_seg_info_for_freq
440 				(chan, subchan_arr);
441 		if (WLAN_IS_CHAN_DFS(chan))
442 			return dfs_get_bonding_channels_for_freq(dfs,
443 								 chan,
444 								 SEG_ID_PRIMARY,
445 								 DETECTOR_ID_0,
446 								 subchan_arr);
447 		if (WLAN_IS_CHAN_DFS_CFREQ2(chan))
448 			return dfs_get_bonding_channels_for_freq
449 				(dfs, chan, SEG_ID_SECONDARY,
450 				 DETECTOR_ID_0, subchan_arr);
451 		/* All channels in 160/80_80 BW are non DFS, return 0
452 		 * as number of subchannels
453 		 */
454 		return 0;
455 	} else if (WLAN_IS_CHAN_DFS(chan)) {
456 		return dfs_get_bonding_channel_without_seg_info_for_freq
457 			(chan, subchan_arr);
458 	}
459 	/* All channels are non DFS, return 0 as number of subchannels*/
460 	return 0;
461 }
462 #endif
463 
464 /* dfs_is_new_chan_subset_of_old_chan() - Find if new channel is subset of
465  * old channel.
466  * @dfs: Pointer to wlan_dfs structure.
467  * @new_chan: Pointer to new channel of dfs_channel structure.
468  * @old_chan: Pointer to old channel of dfs_channel structure.
469  *
470  * Return: True if new channel is subset of old channel, else false.
471  */
472 #ifdef CONFIG_CHAN_FREQ_API
473 static bool
474 dfs_is_new_chan_subset_of_old_chan(struct wlan_dfs *dfs,
475 				   struct dfs_channel *new_chan,
476 				   struct dfs_channel *old_chan)
477 {
478 	uint16_t new_subchans[NUM_CHANNELS_160MHZ];
479 	uint16_t old_subchans[NUM_CHANNELS_160MHZ];
480 	uint8_t n_new_subchans = 0;
481 	uint8_t n_old_subchans = 0;
482 
483 	/* Given channel is the old channel. i.e. The channel which
484 	 * should have the new channel as subset.
485 	 */
486 	n_old_subchans = dfs_find_dfs_sub_channels_for_freq(dfs, old_chan,
487 							    old_subchans);
488 	/* cur_chan is the new channel to be check if subset of old channel */
489 	n_new_subchans = dfs_find_dfs_sub_channels_for_freq(dfs, new_chan,
490 							    new_subchans);
491 
492 	return dfs_is_subset_channel_for_freq(old_subchans,
493 					      n_old_subchans,
494 					      new_subchans,
495 					      n_new_subchans);
496 }
497 #endif
498 
499 bool dfs_is_cac_required(struct wlan_dfs *dfs,
500 			 struct dfs_channel *cur_chan,
501 			 struct dfs_channel *prev_chan,
502 			 bool *continue_current_cac)
503 {
504 	struct dfs_channel *cac_started_chan = &dfs->dfs_cac_started_chan;
505 
506 	if (dfs->dfs_ignore_dfs || dfs->dfs_cac_valid || dfs->dfs_ignore_cac) {
507 		dfs_debug(dfs, WLAN_DEBUG_DFS,
508 			  "Skip CAC, ignore_dfs = %d cac_valid = %d ignore_cac = %d",
509 			  dfs->dfs_ignore_dfs, dfs->dfs_cac_valid,
510 			  dfs->dfs_ignore_cac);
511 		return false;
512 	}
513 
514 	/* If the channel has completed PRE-CAC then CAC can be skipped here. */
515 	if (dfs_is_precac_done(dfs, cur_chan)) {
516 		dfs_debug(dfs, WLAN_DEBUG_DFS,
517 			  "PRE-CAC alreay done on this channel %d",
518 			  cur_chan->dfs_ch_ieee);
519 		return false;
520 	}
521 
522 	if (dfs_is_ap_cac_timer_running(dfs)) {
523 		/* Check if we should continue the existing CAC or
524 		 * cancel the existing CAC.
525 		 * For example: - if an existing VAP(0) is already in
526 		 * DFS wait state (which means the radio(wifi) is
527 		 * running the CAC) and it is in channel A and another
528 		 * VAP(1) comes up in the same channel then instead of
529 		 * cancelling the CAC we can let the CAC continue.
530 		 */
531 		if (dfs_is_new_chan_subset_of_old_chan(dfs,
532 						       cur_chan,
533 						       cac_started_chan)) {
534 			*continue_current_cac = true;
535 		} else {
536 			/* New CAC is needed, cancel the running CAC
537 			 * timer.
538 			 * 1) When AP is in DFS_WAIT state and it is in
539 			 *    channel A and user restarts the AP vap in
540 			 *    channel B, then cancel the running CAC in
541 			 *    channel A and start new CAC in channel B.
542 			 *
543 			 * 2) When AP detects the RADAR during CAC in
544 			 *    channel A, it cancels the running CAC and
545 			 *    tries to find channel B with the reduced
546 			 *    bandwidth with of channel A.
547 			 *    In this case, since the CAC is aborted by
548 			 *    the RADAR, AP should start the CAC again.
549 			 */
550 			dfs_cancel_cac_timer(dfs);
551 		}
552 	} else { /* CAC timer is not running. */
553 		if (dfs_is_new_chan_subset_of_old_chan(dfs,
554 						       cur_chan,
555 						       prev_chan)) {
556 			/* AP bandwidth reduce case:
557 			 * When AP detects the RADAR in in-service monitoring
558 			 * mode in channel A, it cancels the running CAC and
559 			 * tries to find the channel B with the reduced
560 			 * bandwidth of channel A.
561 			 * If the new channel B is subset of the channel A
562 			 * then AP skips the CAC.
563 			 */
564 			if (!dfs->dfs_cac_aborted) {
565 				dfs_debug(dfs, WLAN_DEBUG_DFS, "Skip CAC");
566 				return false;
567 			}
568 		}
569 	}
570 
571 	return true;
572 }
573