xref: /wlan-driver/qca-wifi-host-cmn/umac/scan/dispatcher/inc/wlan_scan_api.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2017-2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved.
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: contains scan api
22  */
23 
24 #ifndef _WLAN_SCAN_API_H_
25 #define _WLAN_SCAN_API_H_
26 
27 #include <wlan_objmgr_psoc_obj.h>
28 #include <wlan_objmgr_pdev_obj.h>
29 #include <wlan_objmgr_vdev_obj.h>
30 #include "../../core/src/wlan_scan_main.h"
31 
32 #ifdef FEATURE_SET
33 /**
34  * wlan_scan_get_feature_info() - Get scan feature set info
35  * @psoc: pointer to psoc object
36  * @scan_feature_set: feature set info which needs to be filled
37  *
38  * Return: none
39  */
40 void wlan_scan_get_feature_info(struct wlan_objmgr_psoc *psoc,
41 				struct wlan_scan_features *scan_feature_set);
42 #endif
43 
44 /**
45  * wlan_scan_get_scan_entry_by_mac_freq() - API to get scan entry
46  * info from scan db by mac addr
47  * @pdev: pointer to pdev object
48  * @bssid: pointer to mac addr
49  * @freq: frequency for scan filter
50  *
51  * Return: scan entry if found, else NULL
52  */
53 struct scan_cache_entry *
54 wlan_scan_get_scan_entry_by_mac_freq(struct wlan_objmgr_pdev *pdev,
55 				     struct qdf_mac_addr *bssid,
56 				     uint16_t freq);
57 
58 /**
59  * wlan_scan_cfg_set_active_2g_dwelltime() - API to set scan active 2g dwelltime
60  * @psoc: pointer to psoc object
61  * @dwell_time: scan active dwell time
62  *
63  * Return: none
64  */
65 void wlan_scan_cfg_set_active_2g_dwelltime(struct wlan_objmgr_psoc *psoc,
66 					   uint32_t dwell_time);
67 
68 /**
69  * wlan_scan_cfg_get_active_2g_dwelltime() - API to get active 2g dwelltime
70  * @psoc: pointer to psoc object
71  * @dwell_time: scan active dwelltime
72  *
73  * Return: scan active dwell time
74  */
75 void wlan_scan_cfg_get_active_2g_dwelltime(struct wlan_objmgr_psoc *psoc,
76 					   uint32_t *dwell_time);
77 
78 #ifdef CONFIG_BAND_6GHZ
79 /**
80  * wlan_scan_cfg_set_active_6g_dwelltime() - API to set scan active 6g dwelltime
81  * @psoc: pointer to psoc object
82  * @dwell_time: scan active dwell time
83  *
84  * Return: QDF_STATUS
85  */
86 QDF_STATUS wlan_scan_cfg_set_active_6g_dwelltime(struct wlan_objmgr_psoc *psoc,
87 						 uint32_t dwell_time);
88 
89 /**
90  * wlan_scan_cfg_get_active_6g_dwelltime() - API to get active 6g dwelltime
91  * @psoc: pointer to psoc object
92  * @dwell_time: scan active dwelltime
93  *
94  * Return: QDF_STATUS
95  */
96 QDF_STATUS wlan_scan_cfg_get_active_6g_dwelltime(struct wlan_objmgr_psoc *psoc,
97 						 uint32_t *dwell_time);
98 
99 /**
100  * wlan_scan_cfg_set_passive_6g_dwelltime() - API to set scan passive 6g
101  *                                            dwelltime
102  * @psoc: pointer to psoc object
103  * @dwell_time: scan passive dwell time
104  *
105  * Return: QDF_STATUS
106  */
107 QDF_STATUS wlan_scan_cfg_set_passive_6g_dwelltime(struct wlan_objmgr_psoc *psoc,
108 						  uint32_t dwell_time);
109 
110 /**
111  * wlan_scan_cfg_get_passive_6g_dwelltime() - API to get passive 6g dwelltime
112  * @psoc: pointer to psoc object
113  * @dwell_time: scan passive dwelltime
114  *
115  * Return: QDF_STATUS
116  */
117 QDF_STATUS wlan_scan_cfg_get_passive_6g_dwelltime(struct wlan_objmgr_psoc *psoc,
118 						  uint32_t *dwell_time);
119 
120 /**
121  * wlan_scan_cfg_get_min_dwelltime_6g() - API to get minimum 6g dwelltime
122  * @psoc: pointer to psoc object
123  * @min_dwell_time_6ghz: minimum dwelltime 6g
124  *
125  * Return: QDF_STATUS
126  */
127 void wlan_scan_cfg_get_min_dwelltime_6g(struct wlan_objmgr_psoc *psoc,
128 					uint32_t *min_dwell_time_6ghz);
129 
130 /**
131  * wlan_scan_cfg_set_scan_mode_6g() - API to set scan mode for 6 GHz
132  * @psoc: pointer to psoc object
133  * @scan_mode_6g: scan mode value for 6 GHz
134  *
135  * Return: QDF_STATUS
136  */
137 QDF_STATUS wlan_scan_cfg_set_scan_mode_6g(struct wlan_objmgr_psoc *psoc,
138 					  enum scan_mode_6ghz scan_mode_6g);
139 #else
140 static inline
wlan_scan_cfg_get_min_dwelltime_6g(struct wlan_objmgr_psoc * psoc,uint32_t * min_dwell_time_6ghz)141 void wlan_scan_cfg_get_min_dwelltime_6g(struct wlan_objmgr_psoc *psoc,
142 					uint32_t *min_dwell_time_6ghz)
143 {
144 }
145 
146 static inline
wlan_scan_cfg_set_scan_mode_6g(struct wlan_objmgr_psoc * psoc,enum scan_mode_6ghz scan_mode_6g)147 QDF_STATUS wlan_scan_cfg_set_scan_mode_6g(struct wlan_objmgr_psoc *psoc,
148 					  enum scan_mode_6ghz scan_mode_6g)
149 {
150 	return QDF_STATUS_E_NOSUPPORT;
151 }
152 #endif
153 
154 /**
155  * wlan_scan_cfg_set_active_dwelltime() - API to set scan active dwelltime
156  * @psoc: pointer to psoc object
157  * @dwell_time: scan active dwell time
158  *
159  * Return: none
160  */
161 void wlan_scan_cfg_set_active_dwelltime(struct wlan_objmgr_psoc *psoc,
162 					uint32_t dwell_time);
163 /**
164  * wlan_scan_cfg_get_active_dwelltime() - API to get active dwelltime
165  * @psoc: pointer to psoc object
166  * @dwell_time: scan active dwelltime
167  *
168  * Return: scan active dwell time
169  */
170 void wlan_scan_cfg_get_active_dwelltime(struct wlan_objmgr_psoc *psoc,
171 					uint32_t *dwell_time);
172 
173 /**
174  * wlan_scan_cfg_set_passive_dwelltime() - API to set scan passive dwelltime
175  * @psoc: pointer to psoc object
176  * @dwell_time: scan passive dwell time
177  *
178  * Return: none
179  */
180 void wlan_scan_cfg_set_passive_dwelltime(struct wlan_objmgr_psoc *psoc,
181 					 uint32_t dwell_time);
182 /**
183  * wlan_scan_cfg_get_passive_dwelltime() - API to get passive dwelltime
184  * @psoc: pointer to psoc object
185  * @dwell_time: scan passive dwelltime
186  *
187  * Return: scan passive dwell time
188  */
189 void wlan_scan_cfg_get_passive_dwelltime(struct wlan_objmgr_psoc *psoc,
190 					 uint32_t *dwell_time);
191 
192 #ifdef WLAN_POLICY_MGR_ENABLE
193 /*
194  * wlan_scan_update_pno_dwell_time() - update active and passive dwell time
195  * depending on active concurrency modes
196  * @vdev: vdev object pointer
197  * @req: scan request
198  *
199  * Return: void
200  */
201 void wlan_scan_update_pno_dwell_time(struct wlan_objmgr_vdev *vdev,
202 				     struct pno_scan_req_params *req,
203 				     struct scan_default_params *scan_def);
204 
205 /*
206  * wlan_scan_update_low_latency_profile_chnlist() - Low latency SAP + scan
207  * concurrencies
208  * @vdev: vdev object pointer
209  * @req: scan request
210  *
211  * Return: void
212  */
213 void wlan_scan_update_low_latency_profile_chnlist(
214 				struct wlan_objmgr_vdev *vdev,
215 				struct scan_start_request *req);
216 #else
217 static inline
wlan_scan_update_low_latency_profile_chnlist(struct wlan_objmgr_vdev * vdev,struct scan_start_request * req)218 void wlan_scan_update_low_latency_profile_chnlist(
219 				struct wlan_objmgr_vdev *vdev,
220 				struct scan_start_request *req)
221 {
222 }
223 
224 #endif
225 
226 /**
227  * wlan_scan_cfg_get_conc_active_dwelltime() - Get concurrent active dwelltime
228  * @psoc: pointer to psoc object
229  * @dwell_time: scan active dwelltime
230  *
231  * Return: scan concurrent active dwell time
232  */
233 void wlan_scan_cfg_get_conc_active_dwelltime(struct wlan_objmgr_psoc *psoc,
234 					     uint32_t *dwell_time);
235 
236 /**
237  * wlan_scan_cfg_set_conc_active_dwelltime() - Set concurrent active dwelltime
238  * @psoc: pointer to psoc object
239  * @dwell_time: scan active dwelltime
240  *
241  * Return: scan concurrent active dwell time
242  */
243 void wlan_scan_cfg_set_conc_active_dwelltime(struct wlan_objmgr_psoc *psoc,
244 					     uint32_t dwell_time);
245 
246 /**
247  * wlan_scan_cfg_get_conc_passive_dwelltime() - Get passive concurrent dwelltime
248  * @psoc: pointer to psoc object
249  * @dwell_time: scan passive dwelltime
250  *
251  * Return: scan concurrent passive dwell time
252  */
253 void wlan_scan_cfg_get_conc_passive_dwelltime(struct wlan_objmgr_psoc *psoc,
254 					      uint32_t *dwell_time);
255 
256 /**
257  * wlan_scan_cfg_set_conc_passive_dwelltime() - Set passive concurrent dwelltime
258  * @psoc: pointer to psoc object
259  * @dwell_time: scan passive dwelltime
260  *
261  * Return: scan concurrent passive dwell time
262  */
263 void wlan_scan_cfg_set_conc_passive_dwelltime(struct wlan_objmgr_psoc *psoc,
264 					      uint32_t dwell_time);
265 
266 /**
267  * wlan_scan_cfg_honour_nl_scan_policy_flags() - API to get nl scan policy
268  * flags honoured
269  * @psoc: pointer to psoc object
270  *
271  * Return: nl scan policy flags honoured or not
272  */
273 bool wlan_scan_cfg_honour_nl_scan_policy_flags(struct wlan_objmgr_psoc *psoc);
274 
275 /**
276  * wlan_scan_cfg_get_conc_max_resttime() - API to get max rest time
277  * @psoc: pointer to psoc object
278  * @rest_time: scan concurrent max resttime
279  *
280  * Return: scan concurrent max rest time
281  */
282 void wlan_scan_cfg_get_conc_max_resttime(struct wlan_objmgr_psoc *psoc,
283 					 uint32_t *rest_time);
284 
285 /**
286  * wlan_scan_cfg_get_dfs_chan_scan_allowed() - API to get dfs scan enabled
287  * @psoc: pointer to psoc object
288  * @enable_dfs_scan: DFS scan enabled or not.
289  *
290  * Return: None
291  */
292 void wlan_scan_cfg_get_dfs_chan_scan_allowed(struct wlan_objmgr_psoc *psoc,
293 					     bool *enable_dfs_scan);
294 
295 /**
296  * wlan_scan_cfg_set_dfs_chan_scan_allowed() - API to set dfs scan enabled.
297  * @psoc: pointer to psoc object
298  * @enable_dfs_scan: Set dfs scan enabled or not.
299  *
300  * Return: None
301  */
302 void wlan_scan_cfg_set_dfs_chan_scan_allowed(struct wlan_objmgr_psoc *psoc,
303 					     bool enable_dfs_scan);
304 
305 /**
306  * wlan_scan_cfg_get_conc_min_resttime() - API to get concurrent min rest time
307  * @psoc: pointer to psoc object
308  * @rest_time: scan concurrent min rest time
309  *
310  * Return: scan concurrent min rest time
311  */
312 void wlan_scan_cfg_get_conc_min_resttime(struct wlan_objmgr_psoc *psoc,
313 					 uint32_t *rest_time);
314 
315 /**
316  * wlan_scan_is_snr_monitor_enabled() - API to get SNR monitoring enabled or not
317  * @psoc: pointer to psoc object
318  *
319  * Return: enable/disable snr monitor mode.
320  */
321 bool wlan_scan_is_snr_monitor_enabled(struct wlan_objmgr_psoc *psoc);
322 
323 /**
324  * wlan_scan_process_bcn_probe_rx_sync() - handle bcn without posting to
325  * scheduler thread
326  * @psoc: psoc context
327  * @buf: frame buf
328  * @rx_param: rx event params
329  * @frm_type: frame type
330  *
331  * handle bcn without posting to scheduler thread, this should be called
332  * while caller is already in scheduler thread context
333  *
334  * Return: success or error code.
335  */
336 QDF_STATUS
337 wlan_scan_process_bcn_probe_rx_sync(struct wlan_objmgr_psoc *psoc,
338 				    qdf_nbuf_t buf,
339 				    struct mgmt_rx_event_params *rx_param,
340 				    enum mgmt_frame_type frm_type);
341 
342 /**
343  * wlan_scan_get_aging_time  - Get the scan aging time config
344  * @psoc: psoc context
345  *
346  * Return: Scan aging time config
347  */
348 qdf_time_t wlan_scan_get_aging_time(struct wlan_objmgr_psoc *psoc);
349 
350 /**
351  * wlan_scan_set_aging_time  - Set the scan aging time config
352  * @psoc: psoc context
353  * @time: scan aging time
354  *
355  * Return: success or error code.
356  */
357 QDF_STATUS wlan_scan_set_aging_time(struct wlan_objmgr_psoc *psoc,
358 				    qdf_time_t time);
359 
360 /**
361  * wlan_scan_purge_results() - purge the scan list
362  * @scan_list: scan list to be purged
363  *
364  * This function purge the temp scan list
365  *
366  * Return: QDF_STATUS
367  */
wlan_scan_purge_results(qdf_list_t * scan_list)368 static inline QDF_STATUS wlan_scan_purge_results(qdf_list_t *scan_list)
369 {
370 	return scm_purge_scan_results(scan_list);
371 }
372 
373 /**
374  * wlan_scan_get_result() - The Public API to get scan results
375  * @pdev: pdev info
376  * @filter: Filters
377  *
378  * This function fetches scan result
379  *
380  * Return: scan list pointer
381  */
wlan_scan_get_result(struct wlan_objmgr_pdev * pdev,struct scan_filter * filter)382 static inline qdf_list_t *wlan_scan_get_result(struct wlan_objmgr_pdev *pdev,
383 					       struct scan_filter *filter)
384 {
385 	return scm_get_scan_result(pdev, filter);
386 }
387 
388 /**
389  * wlan_scan_update_mlme_by_bssinfo() - The Public API to update mlme
390  * info in the scan entry
391  * @pdev: pdev object
392  * @bss_info: bssid info to find the matching scan entry
393  * @mlme_info: mlme info to be updated.
394  *
395  * Return: QDF_STATUS
396  */
397 static inline QDF_STATUS
wlan_scan_update_mlme_by_bssinfo(struct wlan_objmgr_pdev * pdev,struct bss_info * bss_info,struct mlme_info * mlme_info)398 wlan_scan_update_mlme_by_bssinfo(struct wlan_objmgr_pdev *pdev,
399 				 struct bss_info *bss_info,
400 				 struct mlme_info *mlme_info)
401 {
402 	return scm_scan_update_mlme_by_bssinfo(pdev, bss_info, mlme_info);
403 }
404 
405 /**
406  * wlan_scan_start() - Public API to start a scan
407  * @req: start scan req params
408  *
409  * The Public API to start a scan. Post a msg to target_if queue
410  *
411  * Return: QDF_STATUS.
412  */
413 QDF_STATUS wlan_scan_start(struct scan_start_request *req);
414 
415 /**
416  * wlan_scan_cancel() - Public API to stop a scan
417  * @req: stop scan request params
418  *
419  * The Public API to stop a scan. Post a msg to target_if queue
420  *
421  * Return: QDF_STATUS.
422  */
423 QDF_STATUS wlan_scan_cancel(struct scan_cancel_request *req);
424 
425 /**
426  * wlan_scan_get_scan_id() - Public API to allocate scan ID
427  * @psoc: psoc object
428  *
429  * Public API, allocates a new scan id for caller
430  *
431  * Return: newly allocated scan ID
432  */
433 wlan_scan_id
434 wlan_scan_get_scan_id(struct wlan_objmgr_psoc *psoc);
435 
436 /**
437  * wlan_scan_init_default_params() - Public API to initialize scan params
438  * @vdev: vdev object
439  * @req: scan request object
440  *
441  * Public API to initialize scan start request with defaults scan params
442  *
443  * Return: QDF_STATUS_SUCCESS or error code
444  */
445 QDF_STATUS
446 wlan_scan_init_default_params(struct wlan_objmgr_vdev *vdev,
447 			      struct scan_start_request *req);
448 
449 /**
450  * wlan_scan_register_requester() - Public API, assigns requester ID
451  * to caller and registers scan event call back handler
452  * @psoc:       psoc object
453  * @module_name:name of requester module
454  * @event_cb:   event callback function pointer
455  * @arg:        argument to @event_cb
456  *
457  * API, allows other components to allocate requester id.
458  * Normally used by modules at init time to register their callback
459  * and get one requester id. @event_cb will be invoked for
460  * all scan events whose requester id matches with @requester.
461  *
462  * Return: assigned non zero requester id for success
463  *         zero (0) for failure
464  */
465 wlan_scan_requester
466 wlan_scan_register_requester(struct wlan_objmgr_psoc *psoc,
467 			     uint8_t *module_name,
468 			     scan_event_handler event_cb,
469 			     void *arg);
470 
471 /**
472  * wlan_scan_unregister_requester() -Public API, reclaims previously
473  * allocated requester ID
474  * @psoc:       psoc object
475  * @requester:  requester ID to reclaim.
476  *
477  * API, reclaims previously allocated requester id.
478  *
479  * Return: void
480  */
481 void
482 wlan_scan_unregister_requester(struct wlan_objmgr_psoc *psoc,
483 			       wlan_scan_requester requester);
484 
485 /**
486  * wlan_scan_cfg_skip_6g_and_indoor_freq() - API to get 6g and indoor freq
487  * scan ini val
488  * @psoc: psoc object
489  *
490  * Return: skip 6g and indoor freq scan or not
491  */
492 bool wlan_scan_cfg_skip_6g_and_indoor_freq(
493 			struct wlan_objmgr_psoc *psoc);
494 
495 /**
496  * wlan_scan_register_mbssid_cb() - register api to inform bcn/probe rsp
497  * @psoc: psoc object
498  * @cb: callback to be registered
499  *
500  * Return: QDF_STATUS
501  */
502 QDF_STATUS wlan_scan_register_mbssid_cb(struct wlan_objmgr_psoc *psoc,
503 					update_mbssid_bcn_prb_rsp cb);
504 
505 /**
506  * wlan_scan_get_entry_by_mac_addr() - Get bcn/probe rsp from scan db
507  * @pdev: pdev info
508  * @bssid: BSSID of the bcn/probe response to be fetched from scan db
509  * @frame: Frame from scan db with given bssid.
510  *
511  * This is a wrapper to fetch the bcn/probe rsp frame with given mac address
512  * through scm_scan_get_entry_by_mac_addr(). scm_scan_get_entry_by_mac_add()
513  * allocates memory for the frame and it's caller responsibility to free
514  * the memory once it's done with the usage i.e. frame->ptr.
515  *
516  * Return: QDF_STATUS_SUCCESS if scan entry is present in db
517  */
518 QDF_STATUS
519 wlan_scan_get_entry_by_mac_addr(struct wlan_objmgr_pdev *pdev,
520 				struct qdf_mac_addr *bssid,
521 				struct element_info *frame);
522 
523 /**
524  * wlan_scan_get_last_scan_ageout_time() - API to get last scan
525  * ageout time
526  * @psoc: psoc object
527  * @last_scan_ageout_time: last scan ageout time
528  *
529  * Return: void
530  */
531 void
532 wlan_scan_get_last_scan_ageout_time(struct wlan_objmgr_psoc *psoc,
533 				    uint32_t *last_scan_ageout_time);
534 /**
535  * wlan_scan_get_entry_by_bssid() - function to get scan entry by bssid
536  * @pdev: pdev object
537  * @bssid: bssid to be fetched from scan db
538  *
539  * Return : scan entry if found, else NULL
540  */
541 struct scan_cache_entry *
542 wlan_scan_get_entry_by_bssid(struct wlan_objmgr_pdev *pdev,
543 			     struct qdf_mac_addr *bssid);
544 
545 /**
546  * wlan_scan_get_mld_addr_by_link_addr() - Function to get MLD address
547  * in the scan entry from the link BSSID.
548  * @pdev: pdev object
549  * @link_addr: Link BSSID to match the scan filter
550  * @mld_mac_addr: Pointer to fill the MLD address.
551  *
552  * A wrapper API which fills @mld_mac_addr with MLD address of scan entry
553  * whose bssid field matches @link_addr.
554  *
555  * Return: QDF_STATUS
556  */
557 QDF_STATUS
558 wlan_scan_get_mld_addr_by_link_addr(struct wlan_objmgr_pdev *pdev,
559 				    struct qdf_mac_addr *link_addr,
560 				    struct qdf_mac_addr *mld_mac_addr);
561 
562 /**
563  * wlan_scan_get_aux_support() - get aux scan policy
564  * @psoc: psoc object
565  *
566  * Set aux scan bits in scan_ctrl_ext_flag value depending on scan type.
567  *
568  * Return: true/false
569  */
570 bool wlan_scan_get_aux_support(struct wlan_objmgr_psoc *psoc);
571 
572 static inline bool
wlan_scan_entries_contain_cmn_akm(struct scan_cache_entry * entry1,struct scan_cache_entry * entry2)573 wlan_scan_entries_contain_cmn_akm(struct scan_cache_entry *entry1,
574 				  struct scan_cache_entry *entry2)
575 {
576 	return scm_scan_entries_contain_cmn_akm(entry1, entry2);
577 }
578 #endif
579