xref: /wlan-dirver/qca-wifi-host-cmn/umac/dfs/dispatcher/inc/wlan_dfs_mlme_api.h (revision 2888b71da71bce103343119fa1b31f4a0cee07c8)
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: These APIs are used by DFS core functions to call mlme functions.
23  */
24 
25 #ifndef _WLAN_DFS_MLME_API_H_
26 #define _WLAN_DFS_MLME_API_H_
27 
28 #include "wlan_dfs_ucfg_api.h"
29 
30 extern struct dfs_to_mlme global_dfs_to_mlme;
31 
32 /**
33  * dfs_mlme_start_rcsa() - Send RCSA to RootAP.
34  * @pdev: Pointer to DFS pdev object.
35  * @wait_for_csa: Wait for CSA from RootAP.
36  */
37 #if defined(QCA_DFS_RCSA_SUPPORT)
38 void dfs_mlme_start_rcsa(struct wlan_objmgr_pdev *pdev,
39 		bool *wait_for_csa);
40 #endif
41 
42 /**
43  * dfs_mlme_mark_dfs() - Mark the channel in the channel list.
44  * @pdev: Pointer to DFS pdev object.
45  * @ieee: Channel number.
46  * @freq: Channel frequency.
47  * @vhtop_ch_freq_seg2: VHT80 Cfreq2.
48  * @flags: channel flags.
49  * @dfs_radar_bitmap: Radar bitmap.
50  */
51 void dfs_mlme_mark_dfs(struct wlan_objmgr_pdev *pdev,
52 			uint8_t ieee,
53 			uint16_t freq,
54 			uint16_t vhtop_ch_freq_seg2,
55 			uint64_t flags,
56 			uint16_t dfs_radar_bitmap);
57 
58 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) && defined(HOST_DFS_SPOOF_TEST)
59 /**
60  * dfs_mlme_proc_spoof_success() - Process Spoof Completion status
61  * @pdev: Pointer to DFS pdev object.
62  */
63 void dfs_mlme_proc_spoof_success(struct wlan_objmgr_pdev *pdev);
64 #else
65 static inline void
66 dfs_mlme_proc_spoof_success(struct wlan_objmgr_pdev *pdev)
67 {
68 }
69 #endif
70 
71 /**
72  * dfs_mlme_start_csa_for_freq() - Sends CSA in ieeeChan
73  * @pdev: Pointer to DFS pdev object.
74  * @ieee_chan: Channel number.
75  * @freq: Channel frequency.
76  * @cfreq2: HT80 cfreq2 in Mhz.
77  * @flags: channel flags.
78  */
79 #ifdef CONFIG_CHAN_FREQ_API
80 void dfs_mlme_start_csa_for_freq(struct wlan_objmgr_pdev *pdev,
81 				 uint8_t ieee_chan,
82 				 uint16_t freq,
83 				 uint16_t cfreq2_mhz,
84 				 uint64_t flags);
85 #endif
86 /**
87  * dfs_mlme_proc_cac() - Process the CAC completion event.
88  * @pdev: Pointer to DFS pdev object.
89  * @vdev_id: vdev id.
90  */
91 void dfs_mlme_proc_cac(struct wlan_objmgr_pdev *pdev, uint32_t vdev_id);
92 
93 /**
94  * dfs_mlme_deliver_event_up_after_cac() - Send a CAC timeout, VAP up event to
95  * userspace.
96  * @pdev: Pointer to DFS pdev object.
97  */
98 void dfs_mlme_deliver_event_up_after_cac(struct wlan_objmgr_pdev *pdev);
99 
100 /**
101  * dfs_mlme_get_extchan() - Get extension channel.
102  * @pdev: Pointer to DFS pdev object.
103  * @dfs_chan_freq:                Frequency in Mhz.
104  * @dfs_chan_flags:               Channel flags.
105  * @dfs_chan_flagext:             Extended channel flags.
106  * @dfs_chan_ieee:                IEEE channel number.
107  * @dfs_chan_vhtop_ch_freq_seg1:  Channel Center IEEE.
108  * @dfs_chan_vhtop_ch_freq_seg2:  Channel Center IEEE applicable for 80+80MHz
109  *                                mode of operation.
110  * @dfs_chan_mhz_freq_seg1:       Primary channel center freq.
111  * @dfs_chan_mhz_freq_seg2:       Secondary channel center freq applicable for
112  *                                80+80 MHZ.
113  */
114 
115 #ifdef CONFIG_CHAN_FREQ_API
116 QDF_STATUS dfs_mlme_get_extchan_for_freq(struct wlan_objmgr_pdev *pdev,
117 					 uint16_t *dfs_chan_freq,
118 					 uint64_t *dfs_chan_flags,
119 					 uint16_t *dfs_chan_flagext,
120 					 uint8_t *dfs_chan_ieee,
121 					 uint8_t *dfs_chan_vhtop_ch_freq_seg1,
122 					 uint8_t *dfs_chan_vhtop_ch_freq_seg2,
123 					 uint16_t *dfs_chan_mhz_freq_seg1,
124 					 uint16_t *dfs_chan_mhz_freq_seg2);
125 #endif
126 
127 /**
128  * dfs_mlme_set_no_chans_available() - Set no_chans_available flag.
129  * @pdev: Pointer to DFS pdev object.
130  * @val: Set this value to no_chans_available flag.
131  */
132 void dfs_mlme_set_no_chans_available(struct wlan_objmgr_pdev *pdev,
133 		int val);
134 
135 /**
136  * dfs_mlme_ieee2mhz() - Get the frequency from channel number.
137  * @pdev: Pointer to DFS pdev object.
138  * @ieee: Channel number.
139  * @flag: Channel flag.
140  */
141 int dfs_mlme_ieee2mhz(struct wlan_objmgr_pdev *pdev,
142 		int ieee,
143 		uint64_t flag);
144 
145 /**
146  * dfs_mlme_find_dot11_chan_for_freq() - Find a channel pointer given the mode,
147  * frequency and channel flags.
148  * @pdev: Pointer to DFS pdev object.
149  * @ch_freq: Channel frequency.
150  * @des_cfreq2_mhz: cfreq2 in MHZ.
151  * @mode: Phymode
152  * @dfs_chan_freq:                Frequency in Mhz.
153  * @dfs_chan_flags:               Channel flags.
154  * @dfs_chan_flagext:             Extended channel flags.
155  * @dfs_chan_ieee:                IEEE channel number.
156  * @dfs_chan_vhtop_ch_freq_seg1:  Channel Center IEEE for primary 80 segment.
157  * @dfs_chan_vhtop_ch_freq_seg2:  Channel Center frequency applicable for
158  *                                80+80MHz mode of operation.
159  * @dfs_chan_mhz_freq_seg1:       Channel center frequency of primary 80 segment.
160  * @dfs_chan_mhz_freq_seg2:       Channel center frequency for secondary 80
161  *                                segment applicable only for 80+80MHZ mode of
162  *                                operation.
163  *
164  * Return:
165  * * QDF_STATUS_SUCCESS  : Channel found.
166  * * QDF_STATUS_E_FAILURE: Channel not found.
167  */
168 #ifdef CONFIG_CHAN_FREQ_API
169 QDF_STATUS
170 dfs_mlme_find_dot11_chan_for_freq(struct wlan_objmgr_pdev *pdev,
171 				  uint16_t chan_freq,
172 				  uint16_t des_cfreq2_mhz,
173 				  int mode,
174 				  uint16_t *dfs_chan_freq,
175 				  uint64_t *dfs_chan_flags,
176 				  uint16_t *dfs_chan_flagext,
177 				  uint8_t *dfs_chan_ieee,
178 				  uint8_t *dfs_chan_vhtop_ch_freq_seg1,
179 				  uint8_t *dfs_chan_vhtop_ch_freq_seg2,
180 				  uint16_t *dfs_chan_mhz_freq_seg1,
181 				  uint16_t *dfs_chan_mhz_freq_seg2);
182 #endif
183 
184 /**
185  * dfs_mlme_get_dfs_channels_for_freq() - Get DFS channel from channel list.
186  * @pdev: Pointer to DFS pdev object.
187  * @dfs_chan_freq:                Frequency in Mhz.
188  * @dfs_chan_flags:               Channel flags.
189  * @dfs_chan_flagext:             Extended channel flags.
190  * @dfs_chan_ieee:                IEEE channel number.
191  * @dfs_chan_vhtop_ch_freq_seg1:  Channel Center IEEE number.
192  * @dfs_chan_vhtop_ch_freq_seg2:  Channel Center IEEE applicable for 80+80MHz
193  *                                mode of operation.
194  * @dfs_chan_mhz_freq_seg1 :      Primary 80 Channel Center frequency.
195  * @dfs_chan_mhz_freq_seg2 :      Channel center frequency applicable only for
196  *                                80+80 mode of operation.
197  * @index: Index into channel list.
198  */
199 #ifdef CONFIG_CHAN_FREQ_API
200 void
201 dfs_mlme_get_dfs_channels_for_freq(struct wlan_objmgr_pdev *pdev,
202 				   uint16_t *dfs_chan_freq,
203 				   uint64_t *dfs_chan_flags,
204 				   uint16_t *dfs_chan_flagext,
205 				   uint8_t *dfs_chan_ieee,
206 				   uint8_t *dfs_chan_vhtop_ch_freq_seg1,
207 				   uint8_t *dfs_chan_vhtop_ch_freq_seg2,
208 				   uint16_t *dfs_chan_mhz_freq_seg1,
209 				   uint16_t *dfs_chan_mhz_freq_seg2,
210 				   int index);
211 #endif
212 
213 /**
214  * dfs_mlme_dfs_ch_flags_ext() - Get extension channel flags.
215  * @pdev: Pointer to DFS pdev object.
216  */
217 uint32_t dfs_mlme_dfs_ch_flags_ext(struct wlan_objmgr_pdev *pdev);
218 
219 /**
220  * dfs_mlme_channel_change_by_precac() - Channel change by PreCAC.
221  * @pdev: Pointer to DFS pdev object.
222  */
223 void dfs_mlme_channel_change_by_precac(struct wlan_objmgr_pdev *pdev);
224 
225 /**
226  * dfs_mlme_nol_timeout_notification() - NOL timeout notification to userspace.
227  * @pdev: Pointer to DFS pdev object.
228  */
229 void dfs_mlme_nol_timeout_notification(struct wlan_objmgr_pdev *pdev);
230 
231 /**
232  * dfs_mlme_clist_update() - Mark the channel as RADAR.
233  * @pdev: Pointer to DFS pdev object.
234  * @nollist: Pointer to NOL list.
235  * @nentries: Number of channels in the NOL list.
236  */
237 void dfs_mlme_clist_update(struct wlan_objmgr_pdev *pdev,
238 		void *nollist,
239 		int nentries);
240 
241 /**
242  * dfs_mlme_get_cac_timeout_for_freq() - Get cac_timeout.
243  * @pdev: Pointer to DFS pdev object.
244  * @dfs_chan_freq:                Frequency in Mhz.
245  * @dfs_chan_vhtop_freq_seg2:  Channel Center frequency applicable for 80+80MHz
246  *                              mode of operation.
247  * @dfs_chan_flags:               Channel flags.
248  */
249 #ifdef CONFIG_CHAN_FREQ_API
250 int dfs_mlme_get_cac_timeout_for_freq(struct wlan_objmgr_pdev *pdev,
251 				      uint16_t dfs_chan_freq,
252 				      uint16_t dfs_chan_vhtop_freq_seg2_mhz,
253 				      uint64_t dfs_chan_flags);
254 #endif
255 /**
256  * dfs_mlme_rebuild_chan_list_with_non_dfs_channels() - Rebuild the channel list
257  * with only non DFS channels.
258  * @pdev: Pointer to DFS pdev object.
259  *
260  * return: On success return 1 or 0, else failure.
261  */
262 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) && defined(HOST_DFS_SPOOF_TEST)
263 int dfs_mlme_rebuild_chan_list_with_non_dfs_channels(
264 		struct wlan_objmgr_pdev *pdev);
265 #else
266 static inline int dfs_mlme_rebuild_chan_list_with_non_dfs_channels(
267 		struct wlan_objmgr_pdev *pdev)
268 {
269 	return 0;
270 }
271 #endif
272 
273 /**
274  * dfs_mlme_restart_vaps_with_non_dfs_chan() - Restart vaps with non DFS
275  * channels
276  * @pdev: Pointer to DFS pdev object.
277  * @no_chans_avail: Indicates if no channel is available.
278  */
279 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) && defined(HOST_DFS_SPOOF_TEST)
280 void dfs_mlme_restart_vaps_with_non_dfs_chan(struct wlan_objmgr_pdev *pdev,
281 					     int no_chans_avail);
282 #else
283 static inline
284 void dfs_mlme_restart_vaps_with_non_dfs_chan(struct wlan_objmgr_pdev *pdev,
285 					     int no_chans_avail)
286 {
287 }
288 #endif
289 
290 /**
291  * dfs_mlme_check_allowed_prim_chanlist() - Check whether the given channel is
292  * present in the primary allowed channel list or not
293  * @pdev: Pointer to DFS pdev object.
294  * @chan_num: Channel number
295  */
296 #if defined(WLAN_SUPPORT_PRIMARY_ALLOWED_CHAN)
297 bool dfs_mlme_check_allowed_prim_chanlist(struct wlan_objmgr_pdev *pdev,
298 					  uint32_t chan_freq);
299 
300 #else
301 static inline
302 bool dfs_mlme_check_allowed_prim_chanlist(struct wlan_objmgr_pdev *pdev,
303 					  uint32_t chan_freq)
304 {
305 	return true;
306 }
307 #endif
308 
309 /**
310  * dfs_mlme_handle_dfs_scan_violation() - Handle scan start failure
311  * due to DFS violation (presence of NOL channel in scan channel list).
312  * @pdev: Pointer to pdev object.
313  */
314 #if defined(WLAN_DFS_FULL_OFFLOAD) && defined(QCA_DFS_NOL_OFFLOAD)
315 void dfs_mlme_handle_dfs_scan_violation(struct wlan_objmgr_pdev *pdev);
316 #else
317 static inline
318 void dfs_mlme_handle_dfs_scan_violation(struct wlan_objmgr_pdev *pdev)
319 {
320 }
321 #endif
322 
323 /**
324  * dfs_mlme_is_opmode_sta() - Check if pdev opmode is STA.
325  * @pdev: Pointer to DFS pdev object.
326  *
327  * Return: true if pdev opmode is STA, else false.
328  */
329 bool dfs_mlme_is_opmode_sta(struct wlan_objmgr_pdev *pdev);
330 
331 /**
332  * dfs_mlme_is_inter_band_chan_switch_allowed() - Check if inter-band channel
333  * switch is allowed.
334  * @pdev: Pointer to DFS pdev object.
335  *
336  * Return: true if inter-band channel switch is allowed.
337  */
338 bool dfs_mlme_is_inter_band_chan_switch_allowed(struct wlan_objmgr_pdev *pdev);
339 
340 /**
341  * dfs_mlme_acquire_radar_mode_switch_lock() - Acquire lock for radar processing
342  * over mode switch handling.
343  * @pdev: Pointer to DFS pdev object.
344  *
345  * Return: void.
346  */
347 #ifdef QCA_HW_MODE_SWITCH
348 void dfs_mlme_acquire_radar_mode_switch_lock(struct wlan_objmgr_pdev *pdev);
349 #else
350 static inline
351 void dfs_mlme_acquire_radar_mode_switch_lock(struct wlan_objmgr_pdev *pdev)
352 {
353 }
354 #endif
355 
356 /**
357  * dfs_mlme_release_radar_mode_switch_lock() - Release lock taken for radar
358  * processing over mode switch handling.
359  * @pdev: Pointer to DFS pdev object.
360  *
361  * Return: void.
362  */
363 #ifdef QCA_HW_MODE_SWITCH
364 void dfs_mlme_release_radar_mode_switch_lock(struct wlan_objmgr_pdev *pdev);
365 #else
366 static inline
367 void dfs_mlme_release_radar_mode_switch_lock(struct wlan_objmgr_pdev *pdev)
368 {
369 }
370 #endif
371 #endif /* _WLAN_DFS_MLME_API_H_ */
372