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