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: 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
dfs_mlme_proc_spoof_success(struct wlan_objmgr_pdev * pdev)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_mhz: 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_for_freq() - 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 * @chan_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+80 MHz 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+80 MHz 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_set_tx_flag() - Set the Vap flag to block Tx on Radar detection.
233 * @pdev: Pointer to DFS pdev object.
234 * @is_tx_allowed: Flag value to be set.
235 * True indicate data Tx is allowed
236 * False indicate data Tx is blocked;
237 */
238 void dfs_mlme_set_tx_flag(struct wlan_objmgr_pdev *pdev, bool is_tx_allowed);
239
240 /**
241 * dfs_mlme_clist_update() - Mark the channel as RADAR.
242 * @pdev: Pointer to DFS pdev object.
243 * @nollist: Pointer to NOL list.
244 * @nentries: Number of channels in the NOL list.
245 */
246 void dfs_mlme_clist_update(struct wlan_objmgr_pdev *pdev,
247 void *nollist,
248 int nentries);
249
250 /**
251 * dfs_mlme_get_cac_timeout_for_freq() - Get cac_timeout.
252 * @pdev: Pointer to DFS pdev object.
253 * @dfs_chan_freq: Frequency in MHz.
254 * @dfs_chan_vhtop_freq_seg2_mhz: Channel Center frequency applicable for
255 * 80+80 MHz mode of operation.
256 * @dfs_chan_flags: Channel flags.
257 */
258 #ifdef CONFIG_CHAN_FREQ_API
259 int dfs_mlme_get_cac_timeout_for_freq(struct wlan_objmgr_pdev *pdev,
260 uint16_t dfs_chan_freq,
261 uint16_t dfs_chan_vhtop_freq_seg2_mhz,
262 uint64_t dfs_chan_flags);
263 #endif
264 /**
265 * dfs_mlme_rebuild_chan_list_with_non_dfs_channels() - Rebuild the channel list
266 * with only non DFS channels.
267 * @pdev: Pointer to DFS pdev object.
268 *
269 * return: On success return 1 or 0, else failure.
270 */
271 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) && defined(HOST_DFS_SPOOF_TEST)
272 int dfs_mlme_rebuild_chan_list_with_non_dfs_channels(
273 struct wlan_objmgr_pdev *pdev);
274 #else
dfs_mlme_rebuild_chan_list_with_non_dfs_channels(struct wlan_objmgr_pdev * pdev)275 static inline int dfs_mlme_rebuild_chan_list_with_non_dfs_channels(
276 struct wlan_objmgr_pdev *pdev)
277 {
278 return 0;
279 }
280 #endif
281
282 /**
283 * dfs_mlme_restart_vaps_with_non_dfs_chan() - Restart vaps with non DFS
284 * channels
285 * @pdev: Pointer to DFS pdev object.
286 * @no_chans_avail: Indicates if no channel is available.
287 */
288 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) && defined(HOST_DFS_SPOOF_TEST)
289 void dfs_mlme_restart_vaps_with_non_dfs_chan(struct wlan_objmgr_pdev *pdev,
290 int no_chans_avail);
291 #else
292 static inline
dfs_mlme_restart_vaps_with_non_dfs_chan(struct wlan_objmgr_pdev * pdev,int no_chans_avail)293 void dfs_mlme_restart_vaps_with_non_dfs_chan(struct wlan_objmgr_pdev *pdev,
294 int no_chans_avail)
295 {
296 }
297 #endif
298
299 /**
300 * dfs_mlme_check_allowed_prim_chanlist() - Check whether the given channel is
301 * present in the primary allowed channel list or not
302 * @pdev: Pointer to DFS pdev object.
303 * @chan_freq: Channel frequency
304 */
305 #if defined(WLAN_SUPPORT_PRIMARY_ALLOWED_CHAN)
306 bool dfs_mlme_check_allowed_prim_chanlist(struct wlan_objmgr_pdev *pdev,
307 uint32_t chan_freq);
308
309 #else
310 static inline
dfs_mlme_check_allowed_prim_chanlist(struct wlan_objmgr_pdev * pdev,uint32_t chan_freq)311 bool dfs_mlme_check_allowed_prim_chanlist(struct wlan_objmgr_pdev *pdev,
312 uint32_t chan_freq)
313 {
314 return true;
315 }
316 #endif
317
318 /**
319 * dfs_mlme_handle_dfs_scan_violation() - Handle scan start failure
320 * due to DFS violation (presence of NOL channel in scan channel list).
321 * @pdev: Pointer to pdev object.
322 */
323 #if defined(WLAN_DFS_FULL_OFFLOAD) && defined(QCA_DFS_NOL_OFFLOAD)
324 void dfs_mlme_handle_dfs_scan_violation(struct wlan_objmgr_pdev *pdev);
325 #else
326 static inline
dfs_mlme_handle_dfs_scan_violation(struct wlan_objmgr_pdev * pdev)327 void dfs_mlme_handle_dfs_scan_violation(struct wlan_objmgr_pdev *pdev)
328 {
329 }
330 #endif
331
332 /**
333 * dfs_mlme_is_opmode_sta() - Check if pdev opmode is STA.
334 * @pdev: Pointer to DFS pdev object.
335 *
336 * Return: true if pdev opmode is STA, else false.
337 */
338 bool dfs_mlme_is_opmode_sta(struct wlan_objmgr_pdev *pdev);
339
340 /**
341 * dfs_mlme_is_inter_band_chan_switch_allowed() - Check if inter-band channel
342 * switch is allowed.
343 * @pdev: Pointer to DFS pdev object.
344 *
345 * Return: true if inter-band channel switch is allowed.
346 */
347 bool dfs_mlme_is_inter_band_chan_switch_allowed(struct wlan_objmgr_pdev *pdev);
348
349 /**
350 * dfs_mlme_acquire_radar_mode_switch_lock() - Acquire lock for radar processing
351 * over mode switch handling.
352 * @pdev: Pointer to DFS pdev object.
353 *
354 * Return: void.
355 */
356 #ifdef QCA_HW_MODE_SWITCH
357 void dfs_mlme_acquire_radar_mode_switch_lock(struct wlan_objmgr_pdev *pdev);
358 #else
359 static inline
dfs_mlme_acquire_radar_mode_switch_lock(struct wlan_objmgr_pdev * pdev)360 void dfs_mlme_acquire_radar_mode_switch_lock(struct wlan_objmgr_pdev *pdev)
361 {
362 }
363 #endif
364
365 /**
366 * dfs_mlme_release_radar_mode_switch_lock() - Release lock taken for radar
367 * processing over mode switch handling.
368 * @pdev: Pointer to DFS pdev object.
369 *
370 * Return: void.
371 */
372 #ifdef QCA_HW_MODE_SWITCH
373 void dfs_mlme_release_radar_mode_switch_lock(struct wlan_objmgr_pdev *pdev);
374 #else
375 static inline
dfs_mlme_release_radar_mode_switch_lock(struct wlan_objmgr_pdev * pdev)376 void dfs_mlme_release_radar_mode_switch_lock(struct wlan_objmgr_pdev *pdev)
377 {
378 }
379 #endif
380 #endif /* _WLAN_DFS_MLME_API_H_ */
381