1 /*
2 * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved.
3 * Copyright (c) 2022-2023 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 #define IS_CHAN_DFS(_flags) ((_flags) & REGULATORY_CHAN_RADAR)
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 /**
231 * utils_dfs_is_spruce_spur_war_applicable() - Is Spruce spur WAR applicable
232 * @pdev: Pointer to DFS pdev object.
233 *
234 * Spur or leakage transmissions is observed in Spruce HW in
235 * frequencies from 5260MHz to 5320MHz when one of the following
236 * conditions is true,
237 * i) The AP is transmitting in 52/56/60/64 in 80MHz mode and then the AP
238 * moves to the adjacent channel 36/44/48 in 80MHz mode and starts
239 * transmitting.
240 * ii) The AP is transmitting in 36/44/48/52/56/60/64 in 160MHz mode and then
241 * the AP moves to the adjacent channel 36/44/48 in 80MHz mode and starts
242 * transmitting.
243 *
244 * Hence, the spruce spur WAR becomes applicable when,
245 * a) the target is Spruce,
246 * b) the primary channel is 52/56/60/64, and the home channel width is 80MHz.
247 * c) or, the primary channel is 36/44/48/52/56/60/64 and the home channel width
248 * is 160MHz.
249 *
250 * When the conditions (a) and (b) or (c) is true, random channel selection
251 * should make sure to prevent moving to the adjacent channels 36/44/48 in
252 * 80MHz mode. Failing to do so will cause spur transmissions in channel 52
253 * through 64.
254 *
255 * Return: true if Spruce spur WAR is applicable else false.
256 */
257 bool utils_dfs_is_spruce_spur_war_applicable(struct wlan_objmgr_pdev *pdev);
258
259 /**
260 * utils_dfs_radar_disable() - Disables the radar.
261 * @pdev: Pointer to DFS pdev object.
262 *
263 * wrapper function for dfs_radar_disable(). this
264 * function called from outside of dfs component.
265 */
266 QDF_STATUS utils_dfs_radar_disable(struct wlan_objmgr_pdev *pdev);
267
268 /**
269 * utils_dfs_set_update_nol_flag() - Sets update_nol flag.
270 * @pdev: Pointer to DFS pdev object.
271 * @val: update_nol flag.
272 *
273 * wrapper function for dfs_set_update_nol_flag(). this
274 * function called from outside of dfs component.
275 */
276 QDF_STATUS utils_dfs_set_update_nol_flag(struct wlan_objmgr_pdev *pdev,
277 bool val);
278
279 /**
280 * utils_dfs_get_update_nol_flag() - Returns update_nol flag.
281 * @pdev: Pointer to DFS pdev object.
282 * @nol_flag: Fill nol_flag in this variable.
283 *
284 * wrapper function for dfs_get_update_nol_flag(). this
285 * function called from outside of dfs component.
286 */
287 QDF_STATUS utils_dfs_get_update_nol_flag(struct wlan_objmgr_pdev *pdev,
288 bool *nol_flag);
289
290 /**
291 * utils_dfs_get_dfs_use_nol() - Get usenol.
292 * @pdev: Pointer to DFS pdev object.
293 * @dfs_use_nol: Pointer to dfs_use_nol.
294 *
295 * wrapper function for dfs_get_dfs_use_nol(). this
296 * function called from outside of dfs component.
297 */
298 QDF_STATUS utils_dfs_get_dfs_use_nol(struct wlan_objmgr_pdev *pdev,
299 int *dfs_use_nol);
300
301 /**
302 * utils_dfs_get_nol_timeout() - Get NOL timeout.
303 * @pdev: Pointer to DFS pdev object.
304 * @dfs_nol_timeout: Pointer to dfs_nol_timeout.
305 *
306 * wrapper function for dfs_get_nol_timeout(). this
307 * function called from outside of dfs component.
308 */
309 QDF_STATUS utils_dfs_get_nol_timeout(struct wlan_objmgr_pdev *pdev,
310 int *dfs_nol_timeout);
311
312 /**
313 * utils_dfs_nol_addchan() - Add channel to NOL.
314 * @pdev: Pointer to DFS pdev object.
315 * @freq: channel frequency to add to NOL.
316 * @dfs_nol_timeout: NOL timeout.
317 *
318 * wrapper function for dfs_nol_addchan(). this
319 * function called from outside of dfs component.
320 */
321 QDF_STATUS utils_dfs_nol_addchan(struct wlan_objmgr_pdev *pdev,
322 uint16_t freq,
323 uint32_t dfs_nol_timeout);
324
325 /**
326 * utils_dfs_nol_update() - NOL update
327 * @pdev: Pointer to DFS pdev object.
328 *
329 * wrapper function for dfs_nol_update(). this
330 * function called from outside of dfs component.
331 */
332 QDF_STATUS utils_dfs_nol_update(struct wlan_objmgr_pdev *pdev);
333
334 /**
335 * utils_dfs_second_segment_radar_disable() - Disables the second segment radar.
336 * @pdev: Pointer to DFS pdev object.
337 *
338 * This is called when AP detects the radar, to (potentially) disable
339 * the radar code.
340 */
341 QDF_STATUS utils_dfs_second_segment_radar_disable(
342 struct wlan_objmgr_pdev *pdev);
343
344 /**
345 * utils_dfs_fetch_nol_ie_info() - Fills the arguments with NOL information
346 * needed for sending RCSA.
347 * @pdev: Pointer to DFS pdev object.
348 * @nol_ie_bandwidth: Minimum DFS subchannel Bandwidth.
349 * @nol_ie_startfreq: Radar affected channel list start subchannel's centre
350 * frequency.
351 * @nol_ie_bitmap: Bitmap of radar affected subchannels.
352 */
353 QDF_STATUS utils_dfs_fetch_nol_ie_info(struct wlan_objmgr_pdev *pdev,
354 uint8_t *nol_ie_bandwidth,
355 uint16_t *nol_ie_startfreq,
356 uint8_t *nol_ie_bitmap);
357
358 /**
359 * utils_dfs_set_rcsa_flags() - Set flags that are required for sending
360 * RCSA and NOL IE.
361 * @pdev: Pointer to DFS pdev object.
362 * @is_rcsa_ie_sent: Boolean to check if RCSA IE should be sent or not.
363 * @is_nol_ie_sent: Boolean to check if NOL IE should be sent or not.
364 */
365
366 QDF_STATUS utils_dfs_set_rcsa_flags(struct wlan_objmgr_pdev *pdev,
367 bool is_rcsa_ie_sent,
368 bool is_nol_ie_sent);
369
370 /**
371 * utils_dfs_get_rcsa_flags() - Get flags that are required for sending
372 * RCSA and NOL IE.
373 * @pdev: Pointer to DFS pdev object.
374 * @is_rcsa_ie_sent: Boolean to check if RCSA IE should be sent or not.
375 * @is_nol_ie_sent: Boolean to check if NOL IE should be sent or not.
376 */
377
378 QDF_STATUS utils_dfs_get_rcsa_flags(struct wlan_objmgr_pdev *pdev,
379 bool *is_rcsa_ie_sent,
380 bool *is_nol_ie_sent);
381
382 /**
383 * utils_dfs_process_nol_ie_bitmap() - Update NOL with external radar
384 * information.
385 * @pdev: Pointer to DFS pdev object.
386 * @nol_ie_bandwidth: Minimum DFS subchannel Bandwidth.
387 * @nol_ie_startfreq: Radar affected channel list start channel's
388 * centre frequency.
389 * @nol_ie_bitmap: Bitmap of radar affected subchannels.
390 *
391 * Return: True if NOL IE should be propagated, else false.
392 */
393 bool utils_dfs_process_nol_ie_bitmap(struct wlan_objmgr_pdev *pdev,
394 uint8_t nol_ie_bandwidth,
395 uint16_t nol_ie_startfreq,
396 uint8_t nol_ie_bitmap);
397
398 /**
399 * utils_dfs_bw_reduce() - Set bw reduce.
400 * @pdev: Pointer to DFS pdev object.
401 * @bw_reduce: Fill bw_reduce value in this variable.
402 *
403 * Return: QDF_STATUS
404 */
405 QDF_STATUS utils_dfs_bw_reduce(struct wlan_objmgr_pdev *pdev,
406 bool bw_reduce);
407
408 /**
409 * utils_dfs_is_bw_reduce() - Get bw reduce.
410 * @pdev: Pointer to DFS pdev object.
411 * @bw_reduce: Pointer to get bw_reduce value.
412 *
413 * Return: QDF_STATUS
414 */
415 QDF_STATUS utils_dfs_is_bw_reduce(struct wlan_objmgr_pdev *pdev,
416 bool *bw_reduce);
417 /**
418 * utils_dfs_set_cac_timer_running() - Sets the cac timer running.
419 * @pdev: Pointer to DFS pdev object.
420 * @val: Set this value to dfs_cac_timer_running variable.
421 */
422 QDF_STATUS utils_dfs_set_cac_timer_running(struct wlan_objmgr_pdev *pdev,
423 int val);
424
425 /**
426 * utils_dfs_get_nol_chfreq_and_chwidth() - Sets the cac timer running.
427 * @pdev: Pointer to DFS pdev object.
428 * @nollist: Pointer to NOL channel entry.
429 * @nol_chfreq: Pointer to save channel frequency.
430 * @nol_chwidth: Pointer to save channel width.
431 * @index: Index into nol list.
432 */
433 QDF_STATUS utils_dfs_get_nol_chfreq_and_chwidth(struct wlan_objmgr_pdev *pdev,
434 void *nollist,
435 uint32_t *nol_chfreq,
436 uint32_t *nol_chwidth,
437 int index);
438
439 /**
440 * utils_dfs_get_random_channel_for_freq() - Get random channel.
441 * @pdev: Pointer to DFS pdev object.
442 * @flags: random channel selection flags.
443 * @ch_params: current channel params.
444 * @hw_mode: current operating mode.
445 * @target_chan: Pointer to target_chan freq.
446 * @acs_info: acs range info.
447 *
448 * wrapper function for get_random_chan(). this
449 * function called from outside of dfs component.
450 *
451 * Return: QDF_STATUS
452 */
453 #ifdef CONFIG_CHAN_FREQ_API
454 QDF_STATUS
455 utils_dfs_get_random_channel_for_freq(struct wlan_objmgr_pdev *pdev,
456 uint16_t flags,
457 struct ch_params *ch_params,
458 uint32_t *hw_mode, uint16_t *target_chan,
459 struct dfs_acs_info *acs_info);
460 #endif
461
462 /**
463 * utils_dfs_get_vdev_random_channel_for_freq() - Get random channel for vdev
464 * @pdev: Pointer to DFS pdev object.
465 * @vdev: vdev of the request
466 * @flags: random channel selection flags.
467 * @ch_params: current channel params.
468 * @hw_mode: current operating mode.
469 * @target_chan_freq: Pointer to target_chan_freq.
470 * @acs_info: acs range info.
471 *
472 * Get random channel based on vdev interface type. If the vdev is null,
473 * the function will get random channel by SAP interface type.
474 *
475 * Return: QDF_STATUS
476 */
477 #ifdef CONFIG_CHAN_FREQ_API
478 QDF_STATUS utils_dfs_get_vdev_random_channel_for_freq(
479 struct wlan_objmgr_pdev *pdev, struct wlan_objmgr_vdev *vdev,
480 uint16_t flags, struct ch_params *ch_params, uint32_t *hw_mode,
481 uint16_t *target_chan_freq, struct dfs_acs_info *acs_info);
482 #endif
483
484 /**
485 * utils_dfs_bw_reduced_channel_for_freq() - Get BW reduced channel.
486 * @pdev: Pointer to DFS pdev object.
487 * @ch_params: current channel params.
488 * @hw_mode: current operating mode.
489 * @target_chan_freq: Pointer to target_chan freq.
490 *
491 * wrapper function for get bw_reduced_channel. this
492 * function called from outside of dfs component.
493 *
494 * Return: QDF_STATUS
495 */
496 #ifdef CONFIG_CHAN_FREQ_API
497 QDF_STATUS utils_dfs_bw_reduced_channel_for_freq(struct wlan_objmgr_pdev *pdev,
498 struct ch_params *ch_params,
499 uint32_t *hw_mode,
500 uint16_t *target_chan_freq);
501 #endif
502
503 /**
504 * utils_dfs_init_nol() - Initialize nol from platform driver.
505 * @pdev: pdev handler.
506 *
507 * Initialize nol from platform driver.
508 *
509 * Return: None
510 */
511 #ifdef QCA_DFS_NOL_PLATFORM_DRV_SUPPORT
512 void utils_dfs_init_nol(struct wlan_objmgr_pdev *pdev);
513 #else
utils_dfs_init_nol(struct wlan_objmgr_pdev * pdev)514 static inline void utils_dfs_init_nol(struct wlan_objmgr_pdev *pdev)
515 {
516 }
517 #endif
518 /**
519 * utils_dfs_save_nol() - save nol list to platform driver.
520 * @pdev: pdev handler.
521 *
522 * Save nol list to platform driver.
523 *
524 * Return: None
525 */
526 void utils_dfs_save_nol(struct wlan_objmgr_pdev *pdev);
527
528 /**
529 * utils_dfs_print_nol_channels() - log nol channels.
530 * @pdev: pdev handler.
531 *
532 * log nol channels.
533 *
534 * Return: None
535 */
536 #ifdef DFS_COMPONENT_ENABLE
537 void utils_dfs_print_nol_channels(struct wlan_objmgr_pdev *pdev);
538 #else
utils_dfs_print_nol_channels(struct wlan_objmgr_pdev * pdev)539 static inline void utils_dfs_print_nol_channels(struct wlan_objmgr_pdev *pdev)
540 {
541 }
542 #endif
543
544 /**
545 * utils_dfs_clear_nol_channels() - clear nol list.
546 * @pdev: pdev handler.
547 *
548 * log nol channels.
549 *
550 * Return: None
551 */
552 void utils_dfs_clear_nol_channels(struct wlan_objmgr_pdev *pdev);
553
554 /**
555 * utils_is_dfs_chan_for_freq() - is channel dfs.
556 * @pdev: pdev handler.
557 * @chan_freq: Channel frequency in MHZ.
558 *
559 * is channel dfs.
560 *
561 * Return: True if channel dfs, else false.
562 */
563 #ifdef CONFIG_CHAN_FREQ_API
utils_is_dfs_chan_for_freq(struct wlan_objmgr_pdev * pdev,uint32_t chan_freq)564 static inline bool utils_is_dfs_chan_for_freq(struct wlan_objmgr_pdev *pdev,
565 uint32_t chan_freq)
566 {
567 return wlan_reg_is_dfs_for_freq(pdev, chan_freq);
568 }
569 #endif
570
571 /**
572 * utils_is_dfs_cfreq2_ch() - is channel dfs cfreq2.
573 * @pdev: pdev handler.
574 *
575 * is channel dfs.
576 *
577 * Return: True if channel dfs cfreq2, else false.
578 */
579 bool utils_is_dfs_cfreq2_ch(struct wlan_objmgr_pdev *pdev);
580
581 /**
582 * utils_dfs_reg_update_nol_chan_for_freq() - set nol channel
583 *
584 * @pdev: pdev ptr
585 * @ch_list: freq channel list to be returned
586 * @num_ch: number of channels
587 * @nol_ch: nol flag
588 *
589 * Return: void
590 */
591 #ifdef CONFIG_CHAN_FREQ_API
592 void utils_dfs_reg_update_nol_chan_for_freq(struct wlan_objmgr_pdev *pdev,
593 uint16_t *ch_list,
594 uint8_t num_ch,
595 bool nol_ch);
596 #endif
597 /**
598 * utils_dfs_freq_to_chan() - convert channel freq to channel number
599 * @freq: frequency
600 *
601 * Return: channel number
602 */
603 uint8_t utils_dfs_freq_to_chan(uint32_t freq);
604
605 /**
606 * utils_dfs_chan_to_freq() - convert channel number to frequency
607 * @chan: channel number
608 *
609 * Return: frequency
610 */
611 #ifdef DFS_COMPONENT_ENABLE
612 uint32_t utils_dfs_chan_to_freq(uint8_t chan);
613 #else
utils_dfs_chan_to_freq(uint8_t chan)614 static inline uint32_t utils_dfs_chan_to_freq(uint8_t chan)
615 {
616 return 0;
617 }
618 #endif
619 /**
620 * utils_dfs_update_cur_chan_flags() - Update DFS channel flag and flagext.
621 * @pdev: Pointer to DFS pdev object.
622 * @flags: New channel flags
623 * @flagext: New Extended flags
624 *
625 * Return: QDF_STATUS
626 */
627 QDF_STATUS utils_dfs_update_cur_chan_flags(struct wlan_objmgr_pdev *pdev,
628 uint64_t flags,
629 uint16_t flagext);
630
631 #ifdef MOBILE_DFS_SUPPORT
632 /**
633 * utils_dfs_mark_leaking_chan_for_freq() - to mark channel leaking in to nol
634 * @pdev: Pointer to pdev structure.
635 * @ch_width: channel width
636 * @temp_ch_lst_sz: the target channel list
637 * @temp_ch_lst: the target frequency list
638 *
639 * This function removes the channels from temp channel list that
640 * (if selected as target channel) will cause leakage in one of
641 * the NOL channels
642 *
643 * Return: QDF_STATUS
644 */
645 #ifdef CONFIG_CHAN_FREQ_API
646 QDF_STATUS utils_dfs_mark_leaking_chan_for_freq(struct wlan_objmgr_pdev *pdev,
647 enum phy_ch_width ch_width,
648 uint8_t temp_ch_lst_sz,
649 uint16_t *temp_ch_lst);
650 #endif
651
652 /**
653 * utils_dfs_can_ignore_radar_event() - check whether to skip radar event
654 * processing
655 * @pdev: Pointer to pdev structure.
656 *
657 * This function will check with policy mgr to process radar event or not based
658 * on current concurrency mode and dfs policy.
659 *
660 * Return: true - ignore radar event processing, otherwise false.
661 */
662 bool utils_dfs_can_ignore_radar_event(struct wlan_objmgr_pdev *pdev);
663 #else
664 #ifdef CONFIG_CHAN_FREQ_API
utils_dfs_mark_leaking_chan_for_freq(struct wlan_objmgr_pdev * pdev,enum phy_ch_width ch_width,uint8_t temp_ch_lst_sz,uint16_t * temp_ch_lst)665 static inline QDF_STATUS utils_dfs_mark_leaking_chan_for_freq
666 (struct wlan_objmgr_pdev *pdev,
667 enum phy_ch_width ch_width,
668 uint8_t temp_ch_lst_sz,
669 uint16_t *temp_ch_lst)
670 {
671 return QDF_STATUS_SUCCESS;
672 }
673 #endif
674 static inline bool
utils_dfs_can_ignore_radar_event(struct wlan_objmgr_pdev * pdev)675 utils_dfs_can_ignore_radar_event(struct wlan_objmgr_pdev *pdev)
676 {
677 return false;
678 }
679 #endif
680 /**
681 * utils_get_dfsdomain() - Get DFS domain.
682 * @pdev: Pointer to PDEV structure.
683 *
684 * Return: DFS domain.
685 */
686 int utils_get_dfsdomain(struct wlan_objmgr_pdev *pdev);
687
688 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) && defined(HOST_DFS_SPOOF_TEST)
689 /**
690 * utils_dfs_is_spoof_check_failed() - get spoof check status.
691 * @pdev: pdev ptr
692 * @is_spoof_check_failed: pointer containing the status.
693 *
694 * Return: QDF_STATUS.
695 */
696 QDF_STATUS utils_dfs_is_spoof_check_failed(struct wlan_objmgr_pdev *pdev,
697 bool *is_spoof_check_failed);
698
699 /**
700 * utils_dfs_is_spoof_done() - get spoof check status.
701 * @pdev: pdev ptr
702 *
703 * Return: True if dfs_spoof_test_done is set.
704 */
705 bool utils_dfs_is_spoof_done(struct wlan_objmgr_pdev *pdev);
706 #else
707 static inline
utils_dfs_is_spoof_check_failed(struct wlan_objmgr_pdev * pdev,bool * is_spoof_check_failed)708 QDF_STATUS utils_dfs_is_spoof_check_failed(struct wlan_objmgr_pdev *pdev,
709 bool *is_spoof_check_failed)
710 {
711 return QDF_STATUS_SUCCESS;
712 }
713
714 static inline
utils_dfs_is_spoof_done(struct wlan_objmgr_pdev * pdev)715 bool utils_dfs_is_spoof_done(struct wlan_objmgr_pdev *pdev)
716 {
717 return true;
718 }
719 #endif
720
721 /**
722 * dfs_get_num_chans() - Get the number of channels supported by the regulatory.
723 *
724 * Return: Number of supported channels.
725 */
726 int dfs_get_num_chans(void);
727
728 /**
729 * utils_dfs_get_chan_list() - Get channel list from regdb.
730 * @pdev: Pointer to DFS pdev object.
731 * @clist: Pointer to current channel list
732 * @num_chan: number of channels in the current channel list.
733 */
734 void utils_dfs_get_chan_list(struct wlan_objmgr_pdev *pdev,
735 void *clist,
736 uint32_t *num_chan);
737
738 /**
739 * utils_dfs_get_nol_history_chan_list() - Get nol_history channels from regdb
740 * component.
741 * @pdev: Pointer to pdev structure.
742 * @clist: Pointer to channel list.
743 * @num_chan: number of channels.
744 */
745 void utils_dfs_get_nol_history_chan_list(struct wlan_objmgr_pdev *pdev,
746 void *clist, uint32_t *num_chan);
747
748 /**
749 * utils_dfs_reg_update_nol_history_chan_for_freq() - set nol history channel
750 *
751 * @pdev: pdev ptr
752 * @freq_list: freq channel list to be returned
753 * @num_chan: number of channels
754 * @nol_history_chan: nol history flag
755 *
756 * Return: void
757 */
758 #ifdef CONFIG_CHAN_FREQ_API
759 void
760 utils_dfs_reg_update_nol_history_chan_for_freq(struct wlan_objmgr_pdev *pdev,
761 uint16_t *freq_list,
762 uint8_t num_chan,
763 bool nol_history_chan);
764 #endif
765
766 /**
767 * utils_dfs_is_cac_required() - Check if CAC is required on the cur_chan.
768 * @pdev: pdev ptr
769 * @cur_chan: Pointer to current channel of wlan_channel structure.
770 * @prev_chan: Pointer to previous channel of wlan_channel structure.
771 * @continue_current_cac: If AP can start CAC then this variable indicates
772 * whether to continue with the current CAC or restart the CAC. This variable
773 * is valid only if this function returns true.
774 *
775 * Return: true if AP requires CAC or can continue current CAC, else false.
776 */
777 bool utils_dfs_is_cac_required(struct wlan_objmgr_pdev *pdev,
778 struct wlan_channel *cur_chan,
779 struct wlan_channel *prev_chan,
780 bool *continue_current_cac);
781
782 /**
783 * utils_dfs_is_cac_required_on_dfs_curchan() - Check if CAC is required on the
784 * dfs_curchan.
785 * @pdev: pdev ptr
786 * @continue_current_cac: If AP can start CAC then this variable indicates
787 * whether to continue with the current CAC or restart the CAC. This variable
788 * is valid only if this function returns true.
789 * @is_vap_restart: Flag to indicate if vap is restarted/started.
790 * True: VAP restart. False: VAP start
791 *
792 * This API checks if the dfs_curchan is a subset of the dfs_prevchan.
793 * dfs_curchan and dfs_prevchan are updated after start response by
794 * dfs_set_current_channel().
795 *
796 * Return: true if AP requires CAC or can continue current CAC, else false.
797 */
798 bool
799 utils_dfs_is_cac_required_on_dfs_curchan(struct wlan_objmgr_pdev *pdev,
800 bool *continue_current_cac,
801 bool is_vap_restart);
802
803 /**
804 * utils_dfs_is_precac_done() - Check if precac has been done in chosen channel
805 * @pdev: Pointer to DFS pdev object.
806 * @wlan_chan: Pointer to wlan channel object that can be accessed by other
807 * components.
808 * Wrapper function for dfs_is_precac_done(). This API is called from outside
809 * the dfs component.
810 *
811 * Return:
812 * * True :If precac is done on channel.
813 * * False:If precac is not done on channel.
814 */
815 bool utils_dfs_is_precac_done(struct wlan_objmgr_pdev *pdev,
816 struct wlan_channel *wlan_chan);
817 /**
818 * utils_dfs_get_disable_radar_marking() - Retrieve the value of disable radar.
819 * marking.
820 * @pdev: Pointer to DFS pdev object.
821 * @disable_radar_marking: pointer to retrieve the value of
822 * disable_radar_marking.
823 */
824 #if defined(WLAN_DFS_FULL_OFFLOAD) && defined(QCA_DFS_NOL_OFFLOAD)
825 QDF_STATUS utils_dfs_get_disable_radar_marking(struct wlan_objmgr_pdev *pdev,
826 bool *disable_radar_marking);
827 #else
828 static inline
utils_dfs_get_disable_radar_marking(struct wlan_objmgr_pdev * pdev,bool * disable_radar_marking)829 QDF_STATUS utils_dfs_get_disable_radar_marking(struct wlan_objmgr_pdev *pdev,
830 bool *disable_radar_marking)
831 {
832 return QDF_STATUS_SUCCESS;
833 }
834 #endif
835
836 /**
837 * utils_dfs_deliver_event() - Deliver DFS event to userspace.
838 * @pdev: Pointer to DFS pdev object
839 * @freq: frequency radar hit on
840 * @event: event being sent
841 */
842 void utils_dfs_deliver_event(struct wlan_objmgr_pdev *pdev, uint16_t freq,
843 enum WLAN_DFS_EVENTS event);
844
845 /**
846 * utils_dfs_reset_dfs_prevchan() - Reset DFS previous channel structure.
847 * @pdev: Pointer to DFS pdev object.
848 *
849 * Return: None.
850 */
851 void utils_dfs_reset_dfs_prevchan(struct wlan_objmgr_pdev *pdev);
852
853 #ifdef QCA_SUPPORT_AGILE_DFS
854 /**
855 * utils_dfs_agile_sm_deliver_evt() - API to post events to DFS Agile SM.
856 * @pdev: Pointer to DFS pdev object.
857 * @event: Event to be posted to DFS AGILE SM.
858 *
859 * Return: None.
860 */
861 void utils_dfs_agile_sm_deliver_evt(struct wlan_objmgr_pdev *pdev,
862 enum dfs_agile_sm_evt event);
863 #else
864 static inline
utils_dfs_agile_sm_deliver_evt(struct wlan_objmgr_pdev * pdev,enum dfs_agile_sm_evt event)865 void utils_dfs_agile_sm_deliver_evt(struct wlan_objmgr_pdev *pdev,
866 enum dfs_agile_sm_evt event)
867 {
868 }
869 #endif/*QCA_SUPPORT_AGILE_DFS*/
870
871 #ifdef QCA_SUPPORT_ADFS_RCAC
872 /**
873 * utils_dfs_get_rcac_channel() - Get the completed Rolling CAC channel if
874 * available.
875 * @pdev: Pointer to DFS pdev object.
876 * @chan_params: current channel params.
877 * @target_chan_freq: Pointer to target_chan freq.
878 *
879 * Return: QDF_STATUS.
880 */
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 #else
885 static inline
utils_dfs_get_rcac_channel(struct wlan_objmgr_pdev * pdev,struct ch_params * chan_params,qdf_freq_t * target_chan_freq)886 QDF_STATUS utils_dfs_get_rcac_channel(struct wlan_objmgr_pdev *pdev,
887 struct ch_params *chan_params,
888 qdf_freq_t *target_chan_freq)
889 {
890 return QDF_STATUS_SUCCESS;
891 }
892 #endif /* QCA_SUPPORT_ADFS_RCAC */
893
894 #ifdef ATH_SUPPORT_ZERO_CAC_DFS
895 /**
896 * utils_dfs_precac_status_for_channel() - API to find the preCAC status
897 * of the given channel.
898 * @pdev: Pointer to DFS pdev object.
899 * @deschan: Pointer to desired channel of wlan_channel structure.
900 */
901 enum precac_status_for_chan
902 utils_dfs_precac_status_for_channel(struct wlan_objmgr_pdev *pdev,
903 struct wlan_channel *deschan);
904 #else
905 static inline enum precac_status_for_chan
utils_dfs_precac_status_for_channel(struct wlan_objmgr_pdev * pdev,struct wlan_channel * deschan)906 utils_dfs_precac_status_for_channel(struct wlan_objmgr_pdev *pdev,
907 struct wlan_channel *deschan)
908 {
909 return DFS_INVALID_PRECAC_STATUS;
910 }
911 #endif
912
913 #if defined(WLAN_DISP_CHAN_INFO)
914 /**
915 * utils_dfs_get_chan_dfs_state() - Get the channel state array of the channels
916 * in a radio.
917 * @pdev: Pointer to the pdev.
918 * @dfs_ch_s: Output channel state array of the dfs channels in the radio.
919 *
920 * Return: QDF_STATUS.
921 */
922 QDF_STATUS utils_dfs_get_chan_dfs_state(struct wlan_objmgr_pdev *pdev,
923 enum channel_dfs_state *dfs_ch_s);
924
925 /**
926 * utils_dfs_update_chan_state_array() - Update the channel state of the dfs
927 * channel indicated by the frequency. The dfs event is converted to
928 * appropriate dfs state.
929 * @pdev: Pointer to the pdev.
930 * @freq: Input frequency.
931 * @event: Input dfs event.
932 *
933 * Return: QDF_STATUS.
934 */
935 QDF_STATUS utils_dfs_update_chan_state_array(struct wlan_objmgr_pdev *pdev,
936 qdf_freq_t freq,
937 enum WLAN_DFS_EVENTS event);
938
939 /**
940 * dfs_init_chan_state_array() - Initialize the dfs channel state array.
941 *
942 * @pdev: Pointer to the pdev.
943 *
944 * Return: QDF_STATUS.
945 */
946 QDF_STATUS dfs_init_chan_state_array(struct wlan_objmgr_pdev *pdev);
947 #else
948 static inline
utils_dfs_get_chan_dfs_state(struct wlan_objmgr_pdev * pdev,enum channel_dfs_state * dfs_ch_s)949 QDF_STATUS utils_dfs_get_chan_dfs_state(struct wlan_objmgr_pdev *pdev,
950 enum channel_dfs_state *dfs_ch_s)
951 {
952 return QDF_STATUS_E_NOSUPPORT;
953 }
954
955 static inline
utils_dfs_update_chan_state_array(struct wlan_objmgr_pdev * pdev,uint16_t freq,enum WLAN_DFS_EVENTS event)956 QDF_STATUS utils_dfs_update_chan_state_array(struct wlan_objmgr_pdev *pdev,
957 uint16_t freq,
958 enum WLAN_DFS_EVENTS event)
959 {
960 return QDF_STATUS_E_NOSUPPORT;
961 }
962
963 static inline
dfs_init_chan_state_array(struct wlan_objmgr_pdev * pdev)964 QDF_STATUS dfs_init_chan_state_array(struct wlan_objmgr_pdev *pdev)
965 {
966 return QDF_STATUS_E_NOSUPPORT;
967 }
968 #endif /* WLAN_DISP_CHAN_INFO */
969
970 /**
971 * utils_dfs_radar_enable() - Enables the radar.
972 * @pdev: Pointer to DFS pdev object.
973 *
974 * This is called each time for eCSA occurs but don't change channel due
975 * to channel switch disabled in dfs test mode.
976 *
977 * Return: QDF_STATUS.
978 */
979 QDF_STATUS utils_dfs_radar_enable(struct wlan_objmgr_pdev *pdev);
980
981 /**
982 * utils_dfs_convert_freq_to_index() - Converts a channel frequency
983 * to the DFS channel state array index. The input frequency should be a 5 GHz
984 * channel frequency and this check should be done in the caller.
985 *
986 * @freq: Input DFS channel frequency.
987 * @index: Output DFS channel state array index.
988 *
989 * Return: None.
990 */
991 void utils_dfs_convert_freq_to_index(qdf_freq_t freq, int8_t *index);
992
993 /**
994 * utils_dfs_convert_wlan_phymode_to_chwidth() - Map phymode to
995 * channel width.
996 * @phymode: phymode of type wlan_phymode.
997 *
998 * Return channel width of type phy_ch_width
999 */
1000 enum phy_ch_width
1001 utils_dfs_convert_wlan_phymode_to_chwidth(enum wlan_phymode phymode);
1002
1003 /**
1004 * utils_dfs_get_radar_bitmap_from_nolie() - Read the NOL IE bitmap of the RCSA
1005 * frame, puncture the nol infected channels and formulate the radar puncture
1006 * bitmap.
1007 * @pdev: Pointer to struct wlan_objmgr_pdev
1008 * @phy_mode: Phymode of enum wlan_phymode.
1009 * @nol_ie_start_freq: Start frequency of the NOL infected channels
1010 * @nol_ie_bitmap : NOL IE bitmap
1011 *
1012 * Return: Punctured radar bitmap
1013 */
1014 #if defined(WLAN_FEATURE_11BE) && defined(QCA_DFS_BW_EXPAND) && \
1015 defined(QCA_DFS_RCSA_SUPPORT)
1016 uint16_t
1017 utils_dfs_get_radar_bitmap_from_nolie(struct wlan_objmgr_pdev *pdev,
1018 enum wlan_phymode phy_mode,
1019 qdf_freq_t nol_ie_start_freq,
1020 uint8_t nol_ie_bitmap);
1021 #else
1022 static inline uint16_t
utils_dfs_get_radar_bitmap_from_nolie(struct wlan_objmgr_pdev * pdev,enum wlan_phymode phy_mode,qdf_freq_t nol_ie_start_freq,uint8_t nol_ie_bitmap)1023 utils_dfs_get_radar_bitmap_from_nolie(struct wlan_objmgr_pdev *pdev,
1024 enum wlan_phymode phy_mode,
1025 qdf_freq_t nol_ie_start_freq,
1026 uint8_t nol_ie_bitmap)
1027 {
1028 return NO_SCHANS_PUNC;
1029 }
1030 #endif
1031 #endif /* _WLAN_DFS_UTILS_API_H_ */
1032