xref: /wlan-dirver/qca-wifi-host-cmn/umac/dfs/dispatcher/inc/wlan_dfs_utils_api.h (revision 87a8e4458319c60b618522e263ed900e36aab528)
1 /*
2  * Copyright (c) 2016-2018 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 
31 /* Add channel to nol */
32 #define DFS_NOL_SET                  1
33 
34 /* Remove channel from nol */
35 #define DFS_NOL_RESET                0
36 
37 /* Max nol channels */
38 #define DFS_MAX_NOL_CHANNEL         80
39 
40 /* WLAN 2.4GHz start freq */
41 #define DFS_24_GHZ_BASE_FREQ     (2407)
42 
43 /* WLAN 5GHz start freq */
44 #define DFS_5_GHZ_BASE_FREQ      (5000)
45 
46 /* WLAN 2.4 GHz channel number 6 */
47 #define DFS_24_GHZ_CHANNEL_6        (6)
48 
49 /* WLAN 2.4 GHz channel number 14 */
50 #define DFS_24_GHZ_CHANNEL_14      (14)
51 
52 /* WLAN 2.4 GHz channel number 15 */
53 #define DFS_24_GHZ_CHANNEL_15      (15)
54 
55 /* WLAN 2.4 GHz channel number 27 */
56 #define DFS_24_GHZ_CHANNEL_27      (27)
57 
58 /* WLAN 5GHz channel number 170 */
59 #define DFS_5_GHZ_CHANNEL_170     (170)
60 
61 /* WLAN 5MHz channel spacing */
62 #define DFS_CHAN_SPACING_5MHZ       (5)
63 
64 /* WLAN 20Hz channel spacing */
65 #define DFS_CHAN_SPACING_20MHZ     (20)
66 
67 /* WLAN 2.4GHz channel number 14 freq */
68 #define DFS_CHAN_14_FREQ         (2484)
69 
70 /* WLAN 2.4GHz channel number 15 freq */
71 #define DFS_CHAN_15_FREQ         (2512)
72 
73 /* WLAN 5GHz channel number 170 freq */
74 #define DFS_CHAN_170_FREQ        (5852)
75 
76 
77 
78 extern struct dfs_to_mlme global_dfs_to_mlme;
79 
80 /**
81  * utils_dfs_cac_valid_reset() - Cancels the dfs_cac_valid_timer timer.
82  * @pdev: Pointer to DFS pdev object.
83  * @prevchan_ieee: Prevchan number.
84  * @prevchan_flags: Prevchan flags.
85  *
86  * Wrapper function for dfs_cac_valid_reset(). This function called from
87  * outside of DFS component.
88  */
89 
90 QDF_STATUS utils_dfs_cac_valid_reset(struct wlan_objmgr_pdev *pdev,
91 		uint8_t prevchan_ieee,
92 		uint32_t prevchan_flags);
93 
94 /**
95  * utils_dfs_reset() - Reset DFS members.
96  * @pdev: Pointer to DFS pdev object.
97  */
98 QDF_STATUS utils_dfs_reset(struct wlan_objmgr_pdev *pdev);
99 
100 /**
101  * utils_dfs_freq_is_in_nol() -  check if given channel in nol list
102  * @pdev: Pointer to DFS pdev object
103  * @freq: channel frequency
104  *
105  * check if given channel in nol list.
106  *
107  * Return: true if channel in nol, false else
108  */
109 bool utils_dfs_freq_is_in_nol(struct wlan_objmgr_pdev *pdev, uint32_t freq);
110 
111 /**
112  * utils_dfs_reset_precaclists() - Clears and initiakizes precac_required_list,
113  *                                 precac_done_list and precac_nol_list.
114  * @pdev: Pointer to DFS pdev object.
115  *
116  * Wrapper function for dfs_reset_precaclists(). This function called from
117  * outside of DFS component.
118  */
119 QDF_STATUS utils_dfs_reset_precaclists(struct wlan_objmgr_pdev *pdev);
120 
121 /**
122  * utils_dfs_reset_etsi_precaclists() - Clears and initializes etsi
123  *                                      precac_required_list,
124  *                                      etsi precac_done_list and
125  *                                      etsi precac_nol_list.
126  * @pdev: Pointer to DFS pdev object.
127  *
128  * Wrapper function for dfs_reset_etsiprecaclists(). This function called from
129  * outside of DFS component.
130  */
131 #ifdef QCA_SUPPORT_ETSI_PRECAC_DFS
132 QDF_STATUS utils_dfs_reset_etsi_precaclists(struct wlan_objmgr_pdev *pdev);
133 #else
134 static inline QDF_STATUS utils_dfs_reset_etsi_precaclists(
135 		struct wlan_objmgr_pdev *pdev)
136 {
137 	return QDF_STATUS_SUCCESS;
138 }
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 /**
164  * utils_dfs_is_precac_done() - Is precac done.
165  * @pdev: Pointer to DFS pdev object.
166  *
167  * wrapper function for dfs_is_precac_done(). this
168  * function called from outside of dfs component.
169  */
170 QDF_STATUS utils_dfs_is_precac_done(struct wlan_objmgr_pdev *pdev,
171 		bool *is_precac_done);
172 
173 #ifdef WLAN_DFS_PRECAC_AUTO_CHAN_SUPPORT
174 /**
175  * utils_dfs_precac_decide_pref_chan() - Choose preferred channel
176  * @pdev: Pointer to DFS pdev object.
177  * @ch_ieee: Pointer to channel number
178 
179  * Wrapper function for dfs_decide_precac_preferred_chan(). This
180  * function called from outside of dfs component.
181  *
182  * Return:
183  * * QDF_STATUS_E_FAILURE: Failed to decide preferred channel.
184  * * QDF_STATUS_SUCCESS: Set preferred channel successfully.
185  */
186 QDF_STATUS utils_dfs_precac_decide_pref_chan(struct wlan_objmgr_pdev *pdev,
187 					     uint8_t *ch_ieee);
188 #endif
189 
190 /**
191  * utils_dfs_is_esti_precac_done() - Is ETSI precac done.
192  * @pdev: Pointer to DFS pdev object.
193  *
194  * wrapper function for dfs_is_etsi_precac_done(). This
195  * function called from outside of dfs component.
196  */
197 #ifdef QCA_SUPPORT_ETSI_PRECAC_DFS
198 QDF_STATUS utils_dfs_is_etsi_precac_done(struct wlan_objmgr_pdev *pdev,
199 					 bool *is_etsi_precac_done);
200 #else
201 static inline QDF_STATUS utils_dfs_is_etsi_precac_done(
202 		struct wlan_objmgr_pdev *pdev,
203 		bool *is_etsi_precac_done)
204 {
205 	return QDF_STATUS_SUCCESS;
206 }
207 #endif
208 
209 /**
210  * utils_dfs_cancel_cac_timer() - Cancels the CAC timer.
211  * @pdev: Pointer to DFS pdev object.
212  *
213  * wrapper function for dfs_cancel_cac_timer(). this
214  * function called from outside of dfs component.
215  */
216 QDF_STATUS utils_dfs_cancel_cac_timer(struct wlan_objmgr_pdev *pdev);
217 
218 /**
219  * utils_dfs_start_cac_timer() - Starts the CAC timer.
220  * @pdev: Pointer to DFS pdev object.
221  *
222  * wrapper function for dfs_start_cac_timer(). this
223  * function called from outside of dfs component.
224  */
225 QDF_STATUS utils_dfs_start_cac_timer(struct wlan_objmgr_pdev *pdev);
226 
227 /**
228  * utils_dfs_cac_stop() - Clear the AP CAC timer.
229  * @pdev: Pointer to DFS pdev object.
230  *
231  * wrapper function for dfs_cac_stop(). this
232  * function called from outside of dfs component.
233  */
234 QDF_STATUS utils_dfs_cac_stop(struct wlan_objmgr_pdev *pdev);
235 
236 /**
237  * utils_dfs_stacac_stop() - Clear the STA CAC timer.
238  * @pdev: Pointer to DFS pdev object.
239  *
240  * wrapper function for dfs_stacac_stop(). this
241  * function called from outside of dfs component.
242  */
243 QDF_STATUS utils_dfs_stacac_stop(struct wlan_objmgr_pdev *pdev);
244 
245 /**
246  * utils_dfs_get_usenol() - Returns use_nol flag.
247  * @pdev: Pointer to DFS pdev object.
248  * @usenol: Pointer to usenol value.
249  *
250  * wrapper function for dfs_get_usenol(). this
251  * function called from outside of dfs component.
252  */
253 QDF_STATUS utils_dfs_get_usenol(struct wlan_objmgr_pdev *pdev,
254 		uint16_t *usenol);
255 
256 /**
257  * utils_dfs_radar_disable() - Disables the radar.
258  * @pdev: Pointer to DFS pdev object.
259  *
260  * wrapper function for  dfs_radar_disable(). this
261  * function called from outside of dfs component.
262  */
263 QDF_STATUS utils_dfs_radar_disable(struct wlan_objmgr_pdev *pdev);
264 
265 /**
266  * utils_dfs_set_update_nol_flag() - Sets update_nol flag.
267  * @pdev: Pointer to DFS pdev object.
268  * @val: update_nol flag.
269  *
270  * wrapper function for dfs_set_update_nol_flag(). this
271  * function called from outside of dfs component.
272  */
273 QDF_STATUS utils_dfs_set_update_nol_flag(struct wlan_objmgr_pdev *pdev,
274 		bool val);
275 
276 /**
277  * utils_dfs_get_update_nol_flag() - Returns update_nol flag.
278  * @pdev: Pointer to DFS pdev object.
279  * @nol_flag: Fill nol_flag in this variable.
280  *
281  * wrapper function for dfs_get_update_nol_flag(). this
282  * function called from outside of dfs component.
283  */
284 QDF_STATUS utils_dfs_get_update_nol_flag(struct wlan_objmgr_pdev *pdev,
285 		bool *nol_flag);
286 
287 /**
288  * utils_dfs_get_dfs_use_nol() - Get usenol.
289  * @pdev: Pointer to DFS pdev object.
290  * @dfs_use_nol: Pointer to dfs_use_nol.
291  *
292  * wrapper function for dfs_get_dfs_use_nol(). this
293  * function called from outside of dfs component.
294  */
295 QDF_STATUS utils_dfs_get_dfs_use_nol(struct wlan_objmgr_pdev *pdev,
296 		int *dfs_use_nol);
297 
298 /**
299  * utils_dfs_get_nol_timeout() - Get NOL timeout.
300  * @pdev: Pointer to DFS pdev object.
301  * @dfs_nol_timeout: Pointer to dfs_nol_timeout.
302  *
303  * wrapper function for dfs_get_nol_timeout(). this
304  * function called from outside of dfs component.
305  */
306 QDF_STATUS utils_dfs_get_nol_timeout(struct wlan_objmgr_pdev *pdev,
307 		int *dfs_nol_timeout);
308 
309 /**
310  * utils_dfs_nol_addchan() - Add channel to NOL.
311  * @pdev: Pointer to DFS pdev object.
312  * @chan: channel t o add NOL.
313  * @dfs_nol_timeout: NOL timeout.
314  *
315  * wrapper function for dfs_nol_addchan(). this
316  * function called from outside of dfs component.
317  */
318 QDF_STATUS utils_dfs_nol_addchan(struct wlan_objmgr_pdev *pdev,
319 		uint16_t freq,
320 		uint32_t dfs_nol_timeout);
321 
322 /**
323  * utils_dfs_nol_update() - NOL update
324  * @pdev: Pointer to DFS pdev object.
325  *
326  * wrapper function for dfs_nol_update(). this
327  * function called from outside of dfs component.
328  */
329 QDF_STATUS utils_dfs_nol_update(struct wlan_objmgr_pdev *pdev);
330 
331 /**
332  * utils_dfs_second_segment_radar_disable() - Disables the second segment radar.
333  * @pdev: Pointer to DFS pdev object.
334  *
335  * This is called when AP detects the radar, to (potentially) disable
336  * the radar code.
337  */
338 QDF_STATUS utils_dfs_second_segment_radar_disable(
339 		struct wlan_objmgr_pdev *pdev);
340 
341 /**
342  * utils_dfs_is_ignore_dfs() - Get Ignore DFS value.
343  * @pdev: Pointer to DFS pdev object.
344  * @ignore_dfs: Fill ignore_dfs value in this variable.
345  */
346 QDF_STATUS utils_dfs_is_ignore_dfs(struct wlan_objmgr_pdev *pdev,
347 		bool *ignore_dfs);
348 
349 /**
350  * utils_dfs_is_cac_valid() - Gets the value of is_cac_valid.
351  * @pdev: Pointer to DFS pdev object.
352  * @is_cac_valid: Fill is_cac_valid in this variable.
353  */
354 QDF_STATUS utils_dfs_is_cac_valid(struct wlan_objmgr_pdev *pdev,
355 		bool *is_cac_valid);
356 
357 /**
358  * utils_dfs_is_ignore_cac() - Gets the value of is_ignore_cac.
359  * @pdev: Pointer to DFS pdev object.
360  * @ignore_cac: Fill ignore_cac value in this variable.
361  */
362 QDF_STATUS utils_dfs_is_ignore_cac(struct wlan_objmgr_pdev *pdev,
363 		bool *ignore_cac);
364 
365 /**
366  * utils_dfs_set_cac_timer_running() - Sets the cac timer running.
367  * @pdev: Pointer to DFS pdev object.
368  * @val: Set this value to dfs_cac_timer_running variable.
369  */
370 QDF_STATUS utils_dfs_set_cac_timer_running(struct wlan_objmgr_pdev *pdev,
371 		int val);
372 
373 /**
374  * utils_dfs_get_nol_chfreq_and_chwidth() - Sets the cac timer running.
375  * @pdev: Pointer to DFS pdev object.
376  * @nollist: Pointer to NOL channel entry.
377  * @nol_chfreq: Pointer to save channel frequency.
378  * @nol_chwidth: Pointer to save channel width.
379  * @index: Index into nol list.
380  */
381 QDF_STATUS utils_dfs_get_nol_chfreq_and_chwidth(struct wlan_objmgr_pdev *pdev,
382 		void *nollist,
383 		uint32_t *nol_chfreq,
384 		uint32_t *nol_chwidth,
385 		int index);
386 
387 /**
388  * utils_dfs_get_random_channel() - Get random channel.
389  * @pdev: Pointer to DFS pdev object.
390  * @flags: random channel selection flags.
391  * @ch_params: current channel params.
392  * @hw_mode: current operating mode.
393  * @target_chan: Pointer to target_chan.
394  * @acs_info: acs range info.
395  *
396  * wrapper function for get_random_chan(). this
397  * function called from outside of dfs component.
398  *
399  * Return: QDF_STATUS
400  */
401 QDF_STATUS utils_dfs_get_random_channel(struct wlan_objmgr_pdev *pdev,
402 		uint16_t flags, struct ch_params *ch_params,
403 		uint32_t *hw_mode, uint8_t *target_chan,
404 		struct dfs_acs_info *acs_info);
405 
406 /**
407  * utils_dfs_bw_reduced_channel() - Get BW reduced channel.
408  * @pdev: Pointer to DFS pdev object.
409  * @flags: Reduced bandwidth channel flags.
410  * @ch_params: current channel params.
411  * @hw_mode: current operating mode.
412  * @target_chan: Pointer to target_chan.
413  *
414  * wrapper function for get bw_reduced_channel. this
415  * function called from outside of dfs component.
416  *
417  * Return: QDF_STATUS
418  */
419 QDF_STATUS utils_dfs_bw_reduced_channel(struct wlan_objmgr_pdev *pdev,
420 					uint16_t flags,
421 					struct ch_params *ch_params,
422 					uint32_t *hw_mode,
423 					uint8_t *target_chan);
424 /**
425  * utils_dfs_init_nol() - Initialize nol from platform driver.
426  * @pdev: pdev handler.
427  *
428  * Initialize nol from platform driver.
429  *
430  * Return: None
431  */
432 #ifdef QCA_DFS_NOL_PLATFORM_DRV_SUPPORT
433 void utils_dfs_init_nol(struct wlan_objmgr_pdev *pdev);
434 #else
435 static inline void utils_dfs_init_nol(struct wlan_objmgr_pdev *pdev)
436 {
437 }
438 #endif
439 /**
440  * utils_dfs_save_nol() - save nol list to platform driver.
441  * @pdev: pdev handler.
442  *
443  * Save nol list to platform driver.
444  *
445  * Return: None
446  */
447 void utils_dfs_save_nol(struct wlan_objmgr_pdev *pdev);
448 
449 /**
450  * utils_dfs_print_nol_channels() - log nol channels.
451  * @pdev: pdev handler.
452  *
453  * log nol channels.
454  *
455  * Return: None
456  */
457 #ifdef DFS_COMPONENT_ENABLE
458 void utils_dfs_print_nol_channels(struct wlan_objmgr_pdev *pdev);
459 #else
460 static inline void utils_dfs_print_nol_channels(struct wlan_objmgr_pdev *pdev)
461 {
462 }
463 #endif
464 
465 /**
466  * utils_dfs_clear_nol_channels() - clear nol list.
467  * @pdev: pdev handler.
468  *
469  * log nol channels.
470  *
471  * Return: None
472  */
473 void utils_dfs_clear_nol_channels(struct wlan_objmgr_pdev *pdev);
474 
475 /**
476  * utils_is_dfs_ch() - is channel dfs.
477  * @pdev: pdev handler.
478  *
479  * is channel dfs.
480  *
481  * Return: True if channel dfs, else false.
482  */
483 static inline bool utils_is_dfs_ch(struct wlan_objmgr_pdev *pdev, uint32_t chan)
484 {
485 	return wlan_reg_is_dfs_ch(pdev, chan);
486 }
487 /**
488  * utils_dfs_reg_update_nol_ch() - set nol channel
489  *
490  * @pdev: pdev ptr
491  * @ch_list: channel list to be returned
492  * @num_ch: number of channels
493  * @nol_ch: nol flag
494  *
495  * Return: void
496  */
497 void utils_dfs_reg_update_nol_ch(struct wlan_objmgr_pdev *pdev,
498 		uint8_t *ch_list,
499 		uint8_t num_ch,
500 		bool nol_ch);
501 
502 /**
503  * utils_dfs_freq_to_chan () - convert channel freq to channel number
504  * @freq: frequency
505  *
506  * Return: channel number
507  */
508 uint8_t utils_dfs_freq_to_chan(uint32_t freq);
509 
510 /**
511  * utils_dfs_chan_to_freq () - convert channel number to frequency
512  * @chan: channel number
513  *
514  * Return: frequency
515  */
516 #ifdef DFS_COMPONENT_ENABLE
517 uint32_t utils_dfs_chan_to_freq(uint8_t chan);
518 #else
519 static inline uint32_t utils_dfs_chan_to_freq(uint8_t chan)
520 {
521 	return 0;
522 }
523 #endif
524 /**
525  * utils_dfs_update_cur_chan_flags() - Update DFS channel flag and flagext.
526  * @pdev: Pointer to DFS pdev object.
527  * @flags: New channel flags
528  * @flagext: New Extended flags
529  *
530  * Return: QDF_STATUS
531  */
532 QDF_STATUS utils_dfs_update_cur_chan_flags(struct wlan_objmgr_pdev *pdev,
533 		uint64_t flags,
534 		uint16_t flagext);
535 
536 #ifdef QCA_MCL_DFS_SUPPORT
537 /**
538  * utils_dfs_mark_leaking_ch() - to mark channel leaking in to nol
539  * @pdev: Pointer to pdev structure.
540  * @ch_width: channel width
541  * @temp_ch_lst_sz: the target channel list
542  * @temp_ch_lst: the target channel list
543  *
544  * This function removes the channels from temp channel list that
545  * (if selected as target channel) will cause leakage in one of
546  * the NOL channels
547  *
548  * Return: QDF_STATUS
549  */
550 QDF_STATUS utils_dfs_mark_leaking_ch(struct wlan_objmgr_pdev *pdev,
551 	enum phy_ch_width ch_width,
552 	uint8_t temp_ch_lst_sz,
553 	uint8_t *temp_ch_lst);
554 #else
555 static inline QDF_STATUS utils_dfs_mark_leaking_ch
556 	(struct wlan_objmgr_pdev *pdev,
557 	enum phy_ch_width ch_width,
558 	uint8_t temp_ch_lst_sz,
559 	uint8_t *temp_ch_lst)
560 {
561 	return QDF_STATUS_SUCCESS;
562 }
563 #endif
564 /**
565  * utils_get_dfsdomain() - Get DFS domain.
566  * @pdev: Pointer to PDEV structure.
567  *
568  * Return: DFS domain.
569  */
570 int utils_get_dfsdomain(struct wlan_objmgr_pdev *pdev);
571 
572 /**
573  * utils_dfs_get_cur_rd() - Get current regdomain.
574  * @pdev: pdev ptr
575  *
576  * Return: Regdomain pair id.
577  */
578 uint16_t utils_dfs_get_cur_rd(struct wlan_objmgr_pdev *pdev);
579 
580 /**
581  * utils_dfs_is_spoof_check_failed() - get spoof check status.
582  * @pdev: pdev ptr
583  * @is_spoof_check_failed: pointer containing the status.
584  *
585  * Return: QDF_STATUS.
586  */
587 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) && defined(HOST_DFS_SPOOF_TEST)
588 QDF_STATUS utils_dfs_is_spoof_check_failed(struct wlan_objmgr_pdev *pdev,
589 					   bool *is_spoof_check_failed);
590 #else
591 static inline
592 QDF_STATUS utils_dfs_is_spoof_check_failed(struct wlan_objmgr_pdev *pdev,
593 					   bool *is_spoof_check_failed)
594 {
595 	return QDF_STATUS_SUCCESS;
596 }
597 #endif
598 #endif /* _WLAN_DFS_UTILS_API_H_ */
599