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