xref: /wlan-dirver/qca-wifi-host-cmn/umac/dfs/dispatcher/inc/wlan_dfs_utils_api.h (revision d0c05845839e5f2ba5a8dcebe0cd3e4cd4e8dfcf)
1 /*
2  * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  *
6  * Permission to use, copy, modify, and/or distribute this software for
7  * any purpose with or without fee is hereby granted, provided that the
8  * above copyright notice and this permission notice appear in all
9  * copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
12  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
13  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
14  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
15  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
16  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
17  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
18  * PERFORMANCE OF THIS SOFTWARE.
19  */
20 
21 /**
22  * DOC: This file has the DFS dispatcher API which is exposed to outside of DFS
23  * component.
24  */
25 
26 #ifndef _WLAN_DFS_UTILS_API_H_
27 #define _WLAN_DFS_UTILS_API_H_
28 
29 #include "wlan_dfs_ucfg_api.h"
30 #include "wlan_reg_services_api.h"
31 #include <wlan_objmgr_vdev_obj.h>
32 
33 /* Add channel to nol */
34 #define DFS_NOL_SET                  1
35 
36 /* Remove channel from nol */
37 #define DFS_NOL_RESET                0
38 
39 /* Mark nol-history flag for the channel */
40 #define DFS_NOL_HISTORY_SET 1
41 
42 /* Clear nol-history flag from the channel */
43 #define DFS_NOL_HISTORY_RESET 0
44 
45 /* Max nol channels */
46 #define DFS_MAX_NOL_CHANNEL         80
47 
48 /* WLAN 2.4GHz start freq */
49 #define DFS_24_GHZ_BASE_FREQ     (2407)
50 
51 /* WLAN 5GHz start freq */
52 #define DFS_5_GHZ_BASE_FREQ      (5000)
53 
54 /* WLAN 2.4 GHz channel number 6 */
55 #define DFS_24_GHZ_CHANNEL_6        (6)
56 
57 /* WLAN 2.4 GHz channel number 14 */
58 #define DFS_24_GHZ_CHANNEL_14      (14)
59 
60 /* WLAN 2.4 GHz channel number 15 */
61 #define DFS_24_GHZ_CHANNEL_15      (15)
62 
63 /* WLAN 2.4 GHz channel number 27 */
64 #define DFS_24_GHZ_CHANNEL_27      (27)
65 
66 /* WLAN 5GHz channel number 170 */
67 #define DFS_5_GHZ_CHANNEL_170     (170)
68 
69 /* WLAN 5MHz channel spacing */
70 #define DFS_CHAN_SPACING_5MHZ       (5)
71 
72 /* WLAN 20Hz channel spacing */
73 #define DFS_CHAN_SPACING_20MHZ     (20)
74 
75 /* WLAN 2.4GHz channel number 14 freq */
76 #define DFS_CHAN_14_FREQ         (2484)
77 
78 /* WLAN 2.4GHz channel number 15 freq */
79 #define DFS_CHAN_15_FREQ         (2512)
80 
81 /* WLAN 5GHz channel number 170 freq */
82 #define DFS_CHAN_170_FREQ        (5852)
83 
84 
85 
86 extern struct dfs_to_mlme global_dfs_to_mlme;
87 
88 /**
89  * utils_dfs_cac_valid_reset_for_freq() - Cancels the dfs_cac_valid_timer timer.
90  * @pdev: Pointer to DFS pdev object.
91  * @prevchan_freq: Prevchan frequency.
92  * @prevchan_flags: Prevchan flags.
93  *
94  * Wrapper function for dfs_cac_valid_reset_for_freq(). This function called
95  * from outside of DFS component.
96  */
97 #ifdef CONFIG_CHAN_FREQ_API
98 QDF_STATUS utils_dfs_cac_valid_reset_for_freq(struct wlan_objmgr_pdev *pdev,
99 					      uint16_t prevchan_freq,
100 					      uint32_t prevchan_flags);
101 #endif
102 
103 /**
104  * utils_dfs_reset() - Reset DFS members.
105  * @pdev: Pointer to DFS pdev object.
106  */
107 QDF_STATUS utils_dfs_reset(struct wlan_objmgr_pdev *pdev);
108 
109 /**
110  * utils_dfs_is_freq_in_nol() -  check if given channel in nol list
111  * @pdev: Pointer to DFS pdev object
112  * @freq: channel frequency
113  *
114  * check if given channel in nol list.
115  *
116  * Return: true if channel in nol, false else
117  */
118 bool utils_dfs_is_freq_in_nol(struct wlan_objmgr_pdev *pdev, uint32_t freq);
119 
120 /**
121  * utils_dfs_reset_precaclists() - Clears and initializes precac_list.
122  * @pdev: Pointer to DFS pdev object.
123  *
124  * Wrapper function for dfs_reset_precaclists(). This function called from
125  * outside of DFS component.
126  */
127 QDF_STATUS utils_dfs_reset_precaclists(struct wlan_objmgr_pdev *pdev);
128 
129 /**
130  * utils_dfs_unmark_precac_nol_for_freq() - Clears precac channel marked as NOL.
131  * @pdev: Pointer to DFS pdev object.
132  * @chan_freq: channel freq to be unmarked as NOL.
133  *
134  * Return void.
135  */
136 #ifdef CONFIG_CHAN_FREQ_API
137 void utils_dfs_unmark_precac_nol_for_freq(struct wlan_objmgr_pdev *pdev,
138 					  uint16_t chan_freq);
139 #endif
140 
141 /**
142  * utils_dfs_cancel_precac_timer() - Cancel the precac timer.
143  * @pdev: Pointer to DFS pdev object.
144  *
145  * wrapper function for dfs_cancel_precac_timer(). this function called from
146  * outside of dfs component.
147  */
148 QDF_STATUS utils_dfs_cancel_precac_timer(struct wlan_objmgr_pdev *pdev);
149 
150 /**
151  * utils_dfs_start_precac_timer() - Start the precac timer.
152  * @pdev: Pointer to DFS pdev object.
153  *
154  * Wrapper function for dfs_start_precac_timer(). This function called from
155  * outside of dfs component.
156  *
157  * Return:
158  * * QDF_STATUS_E_FAILURE: Failed to start timer.
159  * * QDF_STATUS_SUCCESS: Timer started successfully.
160  */
161 QDF_STATUS utils_dfs_start_precac_timer(struct wlan_objmgr_pdev *pdev);
162 
163 #ifdef WLAN_DFS_PRECAC_AUTO_CHAN_SUPPORT
164 /**
165  * utils_dfs_precac_decide_pref_chan_for_freq() - Choose preferred channel
166  * @pdev: Pointer to DFS pdev object.
167  * @ch_freq: Pointer to channel frequency.
168  * @mode: Configured PHY mode.
169  *
170  * Wrapper function for dfs_decide_precac_preferred_chan_for_freq(). This
171  * function called from outside of dfs component.
172  *
173  * Return: True if intermediate channel needs to configure. False otherwise.
174  */
175 #ifdef CONFIG_CHAN_FREQ_API
176 bool
177 utils_dfs_precac_decide_pref_chan_for_freq(struct wlan_objmgr_pdev *pdev,
178 					   uint16_t *ch_freq,
179 					   enum wlan_phymode mode);
180 #endif
181 #endif
182 
183 /**
184  * utils_dfs_cancel_cac_timer() - Cancels the CAC timer.
185  * @pdev: Pointer to DFS pdev object.
186  *
187  * wrapper function for dfs_cancel_cac_timer(). this
188  * function called from outside of dfs component.
189  */
190 QDF_STATUS utils_dfs_cancel_cac_timer(struct wlan_objmgr_pdev *pdev);
191 
192 /**
193  * utils_dfs_start_cac_timer() - Starts the CAC timer.
194  * @pdev: Pointer to DFS pdev object.
195  *
196  * wrapper function for dfs_start_cac_timer(). this
197  * function called from outside of dfs component.
198  */
199 QDF_STATUS utils_dfs_start_cac_timer(struct wlan_objmgr_pdev *pdev);
200 
201 /**
202  * utils_dfs_cac_stop() - Clear the AP CAC timer.
203  * @pdev: Pointer to DFS pdev object.
204  *
205  * wrapper function for dfs_cac_stop(). this
206  * function called from outside of dfs component.
207  */
208 QDF_STATUS utils_dfs_cac_stop(struct wlan_objmgr_pdev *pdev);
209 
210 /**
211  * utils_dfs_stacac_stop() - Clear the STA CAC timer.
212  * @pdev: Pointer to DFS pdev object.
213  *
214  * wrapper function for dfs_stacac_stop(). this
215  * function called from outside of dfs component.
216  */
217 QDF_STATUS utils_dfs_stacac_stop(struct wlan_objmgr_pdev *pdev);
218 
219 /**
220  * utils_dfs_get_usenol() - Returns use_nol flag.
221  * @pdev: Pointer to DFS pdev object.
222  * @usenol: Pointer to usenol value.
223  *
224  * wrapper function for dfs_get_usenol(). this
225  * function called from outside of dfs component.
226  */
227 QDF_STATUS utils_dfs_get_usenol(struct wlan_objmgr_pdev *pdev,
228 		uint16_t *usenol);
229 /*
230  * utils_dfs_radar_disable() - Disables the radar.
231  * @pdev: Pointer to DFS pdev object.
232  *
233  * Return: true if Spruce spur WAR is applicable else false.
234  *
235  * Spur or leakage transmissions is observed in Spruce HW in
236  * frequencies from 5260MHz to 5320MHz when one of the following
237  * conditions is true,
238  * i) The AP is transmitting in 52/56/60/64 in 80MHz mode and then the  AP
239  * moves to the adjacent channel 36/44/48 in 80MHz mode and starts
240  * transmitting.
241  * ii) The AP is transmitting in 36/44/48/52/56/60/64 in 160MHz mode and then
242  * the  AP moves to the adjacent channel 36/44/48 in 80MHz mode and starts
243  * transmitting.
244  *
245  * Hence, the spruce spur WAR becomes applicable when,
246  * a) the target is Spruce,
247  * b) the primary channel is 52/56/60/64, and the home channel width is 80MHz.
248  * c) or, the primary channel is 36/44/48/52/56/60/64 and the home channel width
249  *    is 160MHz.
250  *
251  * When the conditions (a) and (b) or (c) is true, random channel selection
252  * should make sure to prevent moving to the adjacent channels 36/44/48 in
253  * 80MHz mode. Failing to do so will cause spur transmissions in channel 52
254  * through 64.
255  */
256 bool utils_dfs_is_spruce_spur_war_applicable(struct wlan_objmgr_pdev *pdev);
257 
258 /**
259  * utils_dfs_radar_disable() - Disables the radar.
260  * @pdev: Pointer to DFS pdev object.
261  *
262  * wrapper function for  dfs_radar_disable(). this
263  * function called from outside of dfs component.
264  */
265 QDF_STATUS utils_dfs_radar_disable(struct wlan_objmgr_pdev *pdev);
266 
267 /**
268  * utils_dfs_set_update_nol_flag() - Sets update_nol flag.
269  * @pdev: Pointer to DFS pdev object.
270  * @val: update_nol flag.
271  *
272  * wrapper function for dfs_set_update_nol_flag(). this
273  * function called from outside of dfs component.
274  */
275 QDF_STATUS utils_dfs_set_update_nol_flag(struct wlan_objmgr_pdev *pdev,
276 		bool val);
277 
278 /**
279  * utils_dfs_get_update_nol_flag() - Returns update_nol flag.
280  * @pdev: Pointer to DFS pdev object.
281  * @nol_flag: Fill nol_flag in this variable.
282  *
283  * wrapper function for dfs_get_update_nol_flag(). this
284  * function called from outside of dfs component.
285  */
286 QDF_STATUS utils_dfs_get_update_nol_flag(struct wlan_objmgr_pdev *pdev,
287 		bool *nol_flag);
288 
289 /**
290  * utils_dfs_get_dfs_use_nol() - Get usenol.
291  * @pdev: Pointer to DFS pdev object.
292  * @dfs_use_nol: Pointer to dfs_use_nol.
293  *
294  * wrapper function for dfs_get_dfs_use_nol(). this
295  * function called from outside of dfs component.
296  */
297 QDF_STATUS utils_dfs_get_dfs_use_nol(struct wlan_objmgr_pdev *pdev,
298 		int *dfs_use_nol);
299 
300 /**
301  * utils_dfs_get_nol_timeout() - Get NOL timeout.
302  * @pdev: Pointer to DFS pdev object.
303  * @dfs_nol_timeout: Pointer to dfs_nol_timeout.
304  *
305  * wrapper function for dfs_get_nol_timeout(). this
306  * function called from outside of dfs component.
307  */
308 QDF_STATUS utils_dfs_get_nol_timeout(struct wlan_objmgr_pdev *pdev,
309 		int *dfs_nol_timeout);
310 
311 /**
312  * utils_dfs_nol_addchan() - Add channel to NOL.
313  * @pdev: Pointer to DFS pdev object.
314  * @chan: channel t o add NOL.
315  * @dfs_nol_timeout: NOL timeout.
316  *
317  * wrapper function for dfs_nol_addchan(). this
318  * function called from outside of dfs component.
319  */
320 QDF_STATUS utils_dfs_nol_addchan(struct wlan_objmgr_pdev *pdev,
321 		uint16_t freq,
322 		uint32_t dfs_nol_timeout);
323 
324 /**
325  * utils_dfs_nol_update() - NOL update
326  * @pdev: Pointer to DFS pdev object.
327  *
328  * wrapper function for dfs_nol_update(). this
329  * function called from outside of dfs component.
330  */
331 QDF_STATUS utils_dfs_nol_update(struct wlan_objmgr_pdev *pdev);
332 
333 /**
334  * utils_dfs_second_segment_radar_disable() - Disables the second segment radar.
335  * @pdev: Pointer to DFS pdev object.
336  *
337  * This is called when AP detects the radar, to (potentially) disable
338  * the radar code.
339  */
340 QDF_STATUS utils_dfs_second_segment_radar_disable(
341 		struct wlan_objmgr_pdev *pdev);
342 
343 /**
344  * utils_dfs_fetch_nol_ie_info() - Fills the arguments with NOL information
345  * needed for sending RCSA.
346  * pdev: Pointer to DFS pdev object.
347  * nol_ie_bandwidth: Minimum DFS subchannel Bandwidth.
348  * nol_ie_startfreq: Radar affected channel list start subchannel's centre
349  * frequency.
350  * nol_ie_bitmap: Bitmap of radar affected subchannels.
351  */
352 QDF_STATUS utils_dfs_fetch_nol_ie_info(struct wlan_objmgr_pdev *pdev,
353 				       uint8_t *nol_ie_bandwidth,
354 				       uint16_t *nol_ie_startfreq,
355 				       uint8_t *nol_ie_bitmap);
356 
357 /**
358  * utils_dfs_set_rcsa_flags() - Set flags that are required for sending
359  * RCSA and NOL IE.
360  * pdev: Pointer to DFS pdev object.
361  * is_rcsa_ie_sent: Boolean to check if RCSA IE should be sent or not.
362  * is_nol_ie_sent: Boolean to check if NOL IE should be sent or not.
363  */
364 
365 QDF_STATUS utils_dfs_set_rcsa_flags(struct wlan_objmgr_pdev *pdev,
366 				    bool is_rcsa_ie_sent,
367 				    bool is_nol_ie_sent);
368 
369 /**
370  * utils_dfs_get_rcsa_flags() - Get flags that are required for sending
371  * RCSA and NOL IE.
372  * pdev: Pointer to DFS pdev object.
373  * is_rcsa_ie_sent: Boolean to check if RCSA IE should be sent or not.
374  * is_nol_ie_sent: Boolean to check if NOL IE should be sent or not.
375  */
376 
377 QDF_STATUS utils_dfs_get_rcsa_flags(struct wlan_objmgr_pdev *pdev,
378 				    bool *is_rcsa_ie_sent,
379 				    bool *is_nol_ie_sent);
380 
381 /**
382  * utils_dfs_process_nol_ie_bitmap() - Update NOL with external radar
383  * information.
384  * pdev: Pointer to DFS pdev object.
385  * nol_ie_bandwidth: Minimum DFS subchannel Bandwidth.
386  * nol_ie_startfreq: Radar affected channel list start channel's
387  * centre frequency.
388  * nol_ie_bitmap: Bitmap of radar affected subchannels.
389  *
390  * Return: True if NOL IE should be propagated, else false.
391  */
392 bool utils_dfs_process_nol_ie_bitmap(struct wlan_objmgr_pdev *pdev,
393 				     uint8_t nol_ie_bandwidth,
394 				     uint16_t nol_ie_startfreq,
395 				     uint8_t nol_ie_bitmap);
396 
397 /**
398  * utils_dfs_bw_reduce() - Set bw reduce.
399  * @pdev: Pointer to DFS pdev object.
400  * @bw_reduce: Fill bw_reduce value in this variable.
401  *
402  * Return: QDF_STATUS
403  */
404 QDF_STATUS utils_dfs_bw_reduce(struct wlan_objmgr_pdev *pdev,
405 				bool bw_reduce);
406 
407 /**
408  * utils_dfs_is_bw_reduce() - Get bw reduce.
409  * @pdev: Pointer to DFS pdev object.
410  * @bw_reduce: Pointer to get bw_reduce value.
411  *
412  * Return: QDF_STATUS
413  */
414 QDF_STATUS utils_dfs_is_bw_reduce(struct wlan_objmgr_pdev *pdev,
415 				  bool *bw_reduce);
416 /**
417  * utils_dfs_set_cac_timer_running() - Sets the cac timer running.
418  * @pdev: Pointer to DFS pdev object.
419  * @val: Set this value to dfs_cac_timer_running variable.
420  */
421 QDF_STATUS utils_dfs_set_cac_timer_running(struct wlan_objmgr_pdev *pdev,
422 		int val);
423 
424 /**
425  * utils_dfs_get_nol_chfreq_and_chwidth() - Sets the cac timer running.
426  * @pdev: Pointer to DFS pdev object.
427  * @nollist: Pointer to NOL channel entry.
428  * @nol_chfreq: Pointer to save channel frequency.
429  * @nol_chwidth: Pointer to save channel width.
430  * @index: Index into nol list.
431  */
432 QDF_STATUS utils_dfs_get_nol_chfreq_and_chwidth(struct wlan_objmgr_pdev *pdev,
433 		void *nollist,
434 		uint32_t *nol_chfreq,
435 		uint32_t *nol_chwidth,
436 		int index);
437 
438 /**
439  * utils_dfs_get_random_channel_for_freq() - Get random channel.
440  * @pdev: Pointer to DFS pdev object.
441  * @flags: random channel selection flags.
442  * @ch_params: current channel params.
443  * @hw_mode: current operating mode.
444  * @target_chan: Pointer to target_chan freq.
445  * @acs_info: acs range info.
446  *
447  * wrapper function for get_random_chan(). this
448  * function called from outside of dfs component.
449  *
450  * Return: QDF_STATUS
451  */
452 #ifdef CONFIG_CHAN_FREQ_API
453 QDF_STATUS
454 utils_dfs_get_random_channel_for_freq(struct wlan_objmgr_pdev *pdev,
455 				      uint16_t flags,
456 				      struct ch_params *ch_params,
457 				      uint32_t *hw_mode, uint16_t *target_chan,
458 				      struct dfs_acs_info *acs_info);
459 #endif
460 
461 /**
462  * utils_dfs_get_vdev_random_channel_for_freq() - Get random channel for vdev
463  * @pdev: Pointer to DFS pdev object.
464  * @vdev: vdev of the request
465  * @flags: random channel selection flags.
466  * @ch_params: current channel params.
467  * @hw_mode: current operating mode.
468  * @target_chan: Pointer to target_chan_freq.
469  * @acs_info: acs range info.
470  *
471  * Get random channel based on vdev interface type. If the vdev is null,
472  * the function will get random channel by SAP interface type.
473  *
474  * Return: QDF_STATUS
475  */
476 #ifdef CONFIG_CHAN_FREQ_API
477 QDF_STATUS utils_dfs_get_vdev_random_channel_for_freq(
478 	struct wlan_objmgr_pdev *pdev, struct wlan_objmgr_vdev *vdev,
479 	uint16_t flags, struct ch_params *ch_params, uint32_t *hw_mode,
480 	uint16_t *target_chan_freq, struct dfs_acs_info *acs_info);
481 #endif
482 
483 /**
484  * utils_dfs_bw_reduced_channel_for_freq() - Get BW reduced channel.
485  * @pdev: Pointer to DFS pdev object.
486  * @ch_params: current channel params.
487  * @hw_mode: current operating mode.
488  * @target_chan: Pointer to target_chan freq.
489  *
490  * wrapper function for get bw_reduced_channel. this
491  * function called from outside of dfs component.
492  *
493  * Return: QDF_STATUS
494  */
495 #ifdef CONFIG_CHAN_FREQ_API
496 QDF_STATUS utils_dfs_bw_reduced_channel_for_freq(struct wlan_objmgr_pdev *pdev,
497 						 struct ch_params *ch_params,
498 						 uint32_t *hw_mode,
499 						 uint16_t *target_chan_freq);
500 #endif
501 
502 /**
503  * utils_dfs_init_nol() - Initialize nol from platform driver.
504  * @pdev: pdev handler.
505  *
506  * Initialize nol from platform driver.
507  *
508  * Return: None
509  */
510 #ifdef QCA_DFS_NOL_PLATFORM_DRV_SUPPORT
511 void utils_dfs_init_nol(struct wlan_objmgr_pdev *pdev);
512 #else
513 static inline void utils_dfs_init_nol(struct wlan_objmgr_pdev *pdev)
514 {
515 }
516 #endif
517 /**
518  * utils_dfs_save_nol() - save nol list to platform driver.
519  * @pdev: pdev handler.
520  *
521  * Save nol list to platform driver.
522  *
523  * Return: None
524  */
525 void utils_dfs_save_nol(struct wlan_objmgr_pdev *pdev);
526 
527 /**
528  * utils_dfs_print_nol_channels() - log nol channels.
529  * @pdev: pdev handler.
530  *
531  * log nol channels.
532  *
533  * Return: None
534  */
535 #ifdef DFS_COMPONENT_ENABLE
536 void utils_dfs_print_nol_channels(struct wlan_objmgr_pdev *pdev);
537 #else
538 static inline void utils_dfs_print_nol_channels(struct wlan_objmgr_pdev *pdev)
539 {
540 }
541 #endif
542 
543 /**
544  * utils_dfs_clear_nol_channels() - clear nol list.
545  * @pdev: pdev handler.
546  *
547  * log nol channels.
548  *
549  * Return: None
550  */
551 void utils_dfs_clear_nol_channels(struct wlan_objmgr_pdev *pdev);
552 
553 /**
554  * utils_is_dfs_chan_for_freq() - is channel dfs.
555  * @pdev: pdev handler.
556  * @chan_freq: Channel frequency in MHZ.
557  *
558  * is channel dfs.
559  *
560  * Return: True if channel dfs, else false.
561  */
562 #ifdef CONFIG_CHAN_FREQ_API
563 static inline bool utils_is_dfs_chan_for_freq(struct wlan_objmgr_pdev *pdev,
564 					      uint32_t chan_freq)
565 {
566 	return wlan_reg_is_dfs_for_freq(pdev, chan_freq);
567 }
568 #endif
569 
570 /**
571  * utils_is_dfs_cfreq2_ch() - is channel dfs cfreq2.
572  * @pdev: pdev handler.
573  *
574  * is channel dfs.
575  *
576  * Return: True if channel dfs cfreq2, else false.
577  */
578 bool utils_is_dfs_cfreq2_ch(struct wlan_objmgr_pdev *pdev);
579 
580 /**
581  * utils_dfs_reg_update_nol_chan_for_freq() - set nol channel
582  *
583  * @pdev: pdev ptr
584  * @ch_list: freq channel list to be returned
585  * @num_ch: number of channels
586  * @nol_ch: nol flag
587  *
588  * Return: void
589  */
590 #ifdef CONFIG_CHAN_FREQ_API
591 void utils_dfs_reg_update_nol_chan_for_freq(struct wlan_objmgr_pdev *pdev,
592 					    uint16_t *ch_list,
593 					    uint8_t num_ch,
594 					    bool nol_ch);
595 #endif
596 /**
597  * utils_dfs_freq_to_chan () - convert channel freq to channel number
598  * @freq: frequency
599  *
600  * Return: channel number
601  */
602 uint8_t utils_dfs_freq_to_chan(uint32_t freq);
603 
604 /**
605  * utils_dfs_chan_to_freq () - convert channel number to frequency
606  * @chan: channel number
607  *
608  * Return: frequency
609  */
610 #ifdef DFS_COMPONENT_ENABLE
611 uint32_t utils_dfs_chan_to_freq(uint8_t chan);
612 #else
613 static inline uint32_t utils_dfs_chan_to_freq(uint8_t chan)
614 {
615 	return 0;
616 }
617 #endif
618 /**
619  * utils_dfs_update_cur_chan_flags() - Update DFS channel flag and flagext.
620  * @pdev: Pointer to DFS pdev object.
621  * @flags: New channel flags
622  * @flagext: New Extended flags
623  *
624  * Return: QDF_STATUS
625  */
626 QDF_STATUS utils_dfs_update_cur_chan_flags(struct wlan_objmgr_pdev *pdev,
627 		uint64_t flags,
628 		uint16_t flagext);
629 
630 #ifdef MOBILE_DFS_SUPPORT
631 /**
632  * utils_dfs_mark_leaking_chan_for_freq() - to mark channel leaking in to nol
633  * @pdev: Pointer to pdev structure.
634  * @ch_width: channel width
635  * @temp_ch_lst_sz: the target channel list
636  * @temp_ch_lst: the target frequency list
637  *
638  * This function removes the channels from temp channel list that
639  * (if selected as target channel) will cause leakage in one of
640  * the NOL channels
641  *
642  * Return: QDF_STATUS
643  */
644 #ifdef CONFIG_CHAN_FREQ_API
645 QDF_STATUS utils_dfs_mark_leaking_chan_for_freq(struct wlan_objmgr_pdev *pdev,
646 						enum phy_ch_width ch_width,
647 						uint8_t temp_ch_lst_sz,
648 						uint16_t *temp_ch_lst);
649 #endif
650 
651 /**
652  * utils_dfs_can_ignore_radar_event() - check whether to skip radar event
653  * processing
654  * @pdev: Pointer to pdev structure.
655  *
656  * This function will check with policy mgr to process radar event or not based
657  * on current concurrency mode and dfs policy.
658  *
659  * Return: true - ignore radar event processing, otherwise false.
660  */
661 bool utils_dfs_can_ignore_radar_event(struct wlan_objmgr_pdev *pdev);
662 #else
663 #ifdef CONFIG_CHAN_FREQ_API
664 static inline QDF_STATUS utils_dfs_mark_leaking_chan_for_freq
665 	(struct wlan_objmgr_pdev *pdev,
666 	enum phy_ch_width ch_width,
667 	uint8_t temp_ch_lst_sz,
668 	uint16_t *temp_ch_lst)
669 {
670 	return QDF_STATUS_SUCCESS;
671 }
672 #endif
673 static inline bool
674 utils_dfs_can_ignore_radar_event(struct wlan_objmgr_pdev *pdev)
675 {
676 	return false;
677 }
678 #endif
679 /**
680  * utils_get_dfsdomain() - Get DFS domain.
681  * @pdev: Pointer to PDEV structure.
682  *
683  * Return: DFS domain.
684  */
685 int utils_get_dfsdomain(struct wlan_objmgr_pdev *pdev);
686 
687 /**
688  * utils_dfs_is_spoof_check_failed() - get spoof check status.
689  * @pdev: pdev ptr
690  * @is_spoof_check_failed: pointer containing the status.
691  *
692  * Return: QDF_STATUS.
693 
694  * utils_dfs_is_spoof_done() - get spoof check status.
695  * @pdev: pdev ptr
696  *
697  * Return: True if dfs_spoof_test_done is set.
698  */
699 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) && defined(HOST_DFS_SPOOF_TEST)
700 QDF_STATUS utils_dfs_is_spoof_check_failed(struct wlan_objmgr_pdev *pdev,
701 					   bool *is_spoof_check_failed);
702 
703 bool utils_dfs_is_spoof_done(struct wlan_objmgr_pdev *pdev);
704 #else
705 static inline
706 QDF_STATUS utils_dfs_is_spoof_check_failed(struct wlan_objmgr_pdev *pdev,
707 					   bool *is_spoof_check_failed)
708 {
709 	return QDF_STATUS_SUCCESS;
710 }
711 
712 static inline
713 bool utils_dfs_is_spoof_done(struct wlan_objmgr_pdev *pdev)
714 {
715 	return true;
716 }
717 #endif
718 
719 /**
720  * dfs_get_num_chans() - Get the number of channels supported by the regulatory.
721  *
722  * Return: Number of supported channels.
723  */
724 int dfs_get_num_chans(void);
725 
726 /**
727  * utils_dfs_get_chan_list() - Get channel list from regdb.
728  * @pdev: Pointer to DFS pdev object.
729  * @clist: Pointer to current channel list
730  * @num_chan: number of channels in the current channel list.
731  */
732 void utils_dfs_get_chan_list(struct wlan_objmgr_pdev *pdev,
733 			     void *clist,
734 			     uint32_t *num_chan);
735 
736 /**
737  * utils_dfs_get_nol_history_chan_list() - Get nol_history channels from regdb
738  * component.
739  * @pdev: Pointer to pdev structure.
740  * @clist: Pointer to channel list.
741  * @num_chan: number of channels.
742  */
743 void utils_dfs_get_nol_history_chan_list(struct wlan_objmgr_pdev *pdev,
744 					 void *clist, uint32_t *num_chan);
745 
746 /**
747  * utils_dfs_reg_update_nol_history_chan_for_freq() - set nol history channel
748  *
749  * @pdev: pdev ptr
750  * @ch_list: freq channel list to be returned
751  * @num_ch: number of channels
752  * @nol_history_ch: nol history flag
753  *
754  * Return: void
755  */
756 #ifdef CONFIG_CHAN_FREQ_API
757 void utils_dfs_reg_update_nol_history_chan_for_freq(struct wlan_objmgr_pdev *,
758 						    uint16_t *freq_list,
759 						    uint8_t num_ch,
760 						    bool nol_history_ch);
761 #endif
762 
763 /**
764  * utils_dfs_is_cac_required() - Check if CAC is required on the cur_chan.
765  * @pdev: pdev ptr
766  * @cur_chan: Pointer to current channel of wlan_channel structure.
767  * @prev_chan: Pointer to previous channel of wlan_channel structure.
768  * @continue_current_cac: If AP can start CAC then this variable indicates
769  * whether to continue with the current CAC or restart the CAC. This variable
770  * is valid only if this function returns true.
771  *
772  * Return: true if AP requires CAC or can continue current CAC, else false.
773  */
774 bool utils_dfs_is_cac_required(struct wlan_objmgr_pdev *pdev,
775 			       struct wlan_channel *cur_chan,
776 			       struct wlan_channel *prev_chan,
777 			       bool *continue_current_cac);
778 
779 /**
780  * utils_dfs_is_cac_required_on_dfs_curchan() - Check if CAC is required on the
781  * dfs_curchan.
782  * @pdev: pdev ptr
783  * @continue_current_cac: If AP can start CAC then this variable indicates
784  * whether to continue with the current CAC or restart the CAC. This variable
785  * is valid only if this function returns true.
786  * @is_vap_restart: Flag to indicate if vap is restarted/started.
787  * True: VAP restart. False: VAP start
788  *
789  * This API checks if the dfs_curchan is a subset of the dfs_prevchan.
790  * dfs_curchan and dfs_prevchan are updated after start response by
791  * dfs_set_current_channel().
792  *
793  * Return: true if AP requires CAC or can continue current CAC, else false.
794  */
795 bool
796 utils_dfs_is_cac_required_on_dfs_curchan(struct wlan_objmgr_pdev *pdev,
797 					 bool *continue_current_cac,
798 					 bool is_vap_restart);
799 
800 /** utils_dfs_is_precac_done() - Check if precac has been done in chosen channel
801  * @pdev: Pointer to DFS pdev object.
802  * @wlan_chan: Pointer to wlan channel object that can be accessed by other
803  * components.
804  * Wrapper function for dfs_is_precac_done(). This API is called from outside
805  * the dfs component.
806  *
807  * Return:
808  * * True :If precac is done on channel.
809  * * False:If precac is not done on channel.
810  */
811 bool utils_dfs_is_precac_done(struct wlan_objmgr_pdev *pdev,
812 			      struct wlan_channel *wlan_chan);
813 /**
814  * utils_dfs_get_disable_radar_marking() - Retrieve the value of disable radar.
815  * marking.
816  * @pdev: Pointer to DFS pdev object.
817  * @dis_radar_marking: pointer to retrieve the value of disable_radar_marking.
818  */
819 #if defined(WLAN_DFS_FULL_OFFLOAD) && defined(QCA_DFS_NOL_OFFLOAD)
820 QDF_STATUS utils_dfs_get_disable_radar_marking(struct wlan_objmgr_pdev *pdev,
821 					       bool *disable_radar_marking);
822 #else
823 static inline
824 QDF_STATUS utils_dfs_get_disable_radar_marking(struct wlan_objmgr_pdev *pdev,
825 					       bool *disable_radar_marking)
826 {
827 	return QDF_STATUS_SUCCESS;
828 }
829 #endif
830 
831 /**
832  * utils_dfs_deliver_event() - Deliver DFS event to userspace.
833  * @pdev: Pointer to DFS pdev object
834  * @chan: channel radar hit on
835  * @event: event being sent
836  */
837 void utils_dfs_deliver_event(struct wlan_objmgr_pdev *pdev, uint16_t freq,
838 			     enum WLAN_DFS_EVENTS event);
839 
840 /**
841  * utils_dfs_reset_dfs_prevchan() - Reset DFS previous channel structure.
842  * @pdev: Pointer to DFS pdev object.
843  *
844  * Return: None.
845  */
846 void utils_dfs_reset_dfs_prevchan(struct wlan_objmgr_pdev *pdev);
847 
848 #ifdef QCA_SUPPORT_AGILE_DFS
849 /**
850  * utils_dfs_agile_sm_deliver_evt() - API to post events to DFS Agile SM.
851  * @pdev: Pointer to DFS pdev object.
852  * @event: Event to be posted to DFS AGILE SM.
853  *
854  * Return: None.
855  */
856 void utils_dfs_agile_sm_deliver_evt(struct wlan_objmgr_pdev *pdev,
857 				    enum dfs_agile_sm_evt event);
858 #else
859 static inline
860 void utils_dfs_agile_sm_deliver_evt(struct wlan_objmgr_pdev *pdev,
861 				    enum dfs_agile_sm_evt event)
862 {
863 }
864 #endif/*QCA_SUPPORT_AGILE_DFS*/
865 
866 #ifdef QCA_SUPPORT_ADFS_RCAC
867 /**
868  * utils_dfs_get_rcac_channel() - Get the completed Rolling CAC channel if
869  *                                available.
870  * @pdev: Pointer to DFS pdev object.
871  * @ch_params: current channel params.
872  * @target_chan: Pointer to target_chan freq.
873  *
874  * Return: QDF_STATUS.
875  */
876 QDF_STATUS utils_dfs_get_rcac_channel(struct wlan_objmgr_pdev *pdev,
877 				      struct ch_params *chan_params,
878 				      qdf_freq_t *target_chan_freq);
879 #else
880 static inline
881 QDF_STATUS utils_dfs_get_rcac_channel(struct wlan_objmgr_pdev *pdev,
882 				      struct ch_params *chan_params,
883 				      qdf_freq_t *target_chan_freq)
884 {
885 	return QDF_STATUS_SUCCESS;
886 }
887 #endif /* QCA_SUPPORT_ADFS_RCAC */
888 
889 #ifdef ATH_SUPPORT_ZERO_CAC_DFS
890 /**
891  * utils_dfs_precac_status_for_channel() - API to find the preCAC status
892  * of the given channel.
893  * @pdev: Pointer to DFS pdev object.
894  * @deschan: Pointer to desired channel of wlan_channel structure.
895  */
896 enum precac_status_for_chan
897 utils_dfs_precac_status_for_channel(struct wlan_objmgr_pdev *pdev,
898 				    struct wlan_channel *deschan);
899 #else
900 static inline enum precac_status_for_chan
901 utils_dfs_precac_status_for_channel(struct wlan_objmgr_pdev *pdev,
902 				    struct wlan_channel *deschan)
903 {
904 	return DFS_INVALID_PRECAC_STATUS;
905 }
906 #endif
907 
908 #if defined(WLAN_DISP_CHAN_INFO)
909 /**
910  * utils_dfs_get_chan_dfs_state() - Get the channel state array of the channels
911  * in a radio.
912  * @pdev: Pointer to the pdev.
913  * @dfs_ch_s: Output channel state array of the dfs channels in the radio.
914  *
915  * Return: QDF_STATUS.
916  */
917 QDF_STATUS utils_dfs_get_chan_dfs_state(struct wlan_objmgr_pdev *pdev,
918 					enum channel_dfs_state *dfs_ch_s);
919 
920 /**
921  * utils_dfs_update_chan_state_array() - Update the channel state of the dfs
922  * channel indicated by the frequency. The dfs event is converted to
923  * appropriate dfs state.
924  * @pdev: Pointer to the pdev.
925  * @freq: Input frequency.
926  * @event: Input dfs event.
927  *
928  * Return: QDF_STATUS.
929  */
930 QDF_STATUS utils_dfs_update_chan_state_array(struct wlan_objmgr_pdev *pdev,
931 					     qdf_freq_t freq,
932 					     enum WLAN_DFS_EVENTS event);
933 
934 /**
935  * dfs_init_chan_state_array() - Initialize the dfs channel state array.
936  *
937  * @pdev: Pointer to the pdev.
938  *
939  * Return: QDF_STATUS.
940  */
941 QDF_STATUS dfs_init_chan_state_array(struct wlan_objmgr_pdev *pdev);
942 #else
943 static inline
944 QDF_STATUS utils_dfs_get_chan_dfs_state(struct wlan_objmgr_pdev *pdev,
945 					enum channel_dfs_state *dfs_ch_s)
946 {
947 	return QDF_STATUS_E_NOSUPPORT;
948 }
949 
950 static inline
951 QDF_STATUS utils_dfs_update_chan_state_array(struct wlan_objmgr_pdev *pdev,
952 					     uint16_t freq,
953 					     enum WLAN_DFS_EVENTS event)
954 {
955 	return QDF_STATUS_E_NOSUPPORT;
956 }
957 
958 static inline
959 QDF_STATUS dfs_init_chan_state_array(struct wlan_objmgr_pdev *pdev)
960 {
961 	return QDF_STATUS_E_NOSUPPORT;
962 }
963 #endif /* WLAN_DISP_CHAN_INFO */
964 
965 /**
966  * utils_dfs_radar_enable() - Enables the radar.
967  * @pdev: Pointer to DFS pdev object.
968  *
969  * This is called each time for eCSA occurs but don't change channel due
970  * to channel switch disabled in dfs test mode.
971  *
972  * Return: QDF_STATUS.
973  */
974 QDF_STATUS utils_dfs_radar_enable(struct wlan_objmgr_pdev *pdev);
975 #endif /* _WLAN_DFS_UTILS_API_H_ */
976