xref: /wlan-dirver/qca-wifi-host-cmn/umac/scan/dispatcher/inc/wlan_scan_ucfg_api.h (revision 6ecd284e5a94a1c96e26d571dd47419ac305990d)
1 /*
2  * Copyright (c) 2017-2018 The Linux Foundation. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for
5  * any purpose with or without fee is hereby granted, provided that the
6  * above copyright notice and this permission notice appear in all
7  * copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16  * PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 /*
20  * DOC: contains scan north bound interface api
21  */
22 
23 #ifndef _WLAN_SCAN_UCFG_API_H_
24 #define _WLAN_SCAN_UCFG_API_H_
25 
26 #include <scheduler_api.h>
27 #include <wlan_objmgr_psoc_obj.h>
28 #include <wlan_objmgr_pdev_obj.h>
29 #include <wlan_objmgr_vdev_obj.h>
30 #include <wlan_scan_public_structs.h>
31 
32 /**
33  * ucfg_scan_register_requester() - assigns requester ID to caller and
34  * registers scan event call back handler
35  * @psoc:       psoc object
36  * @module_name:name of requester module
37  * @event_cb:   event callback function pointer
38  * @arg:        argument to @event_cb
39  *
40  * API, allows other components to allocate requester id
41  * Normally used by modules at init time to register their callback
42  * and get one requester id. @event_cb will be invoked for
43  * all scan events whose requester id matches with @requester.
44  *
45  * Return: assigned non zero requester id for success
46  *         zero (0) for failure
47  */
48 wlan_scan_requester
49 ucfg_scan_register_requester(struct wlan_objmgr_psoc *psoc,
50 	uint8_t *module_name, scan_event_handler event_cb, void *arg);
51 
52 /**
53  * ucfg_scan_unregister_requester() -reclaims previously allocated requester ID
54  * @psoc:       psoc object
55  * @requester:  requester ID to reclaim.
56  *
57  * API, reclaims previously allocated requester id by
58  * ucfg_scan_get_req_id_reg_cb()
59  *
60  * Return: void
61  */
62 void ucfg_scan_unregister_requester(struct wlan_objmgr_psoc *psoc,
63 	wlan_scan_requester requester);
64 
65 
66 /**
67  * ucfg_get_scan_requester_name()- returns module name of requester ID owner
68  * @psoc:       psoc object
69  * @requester:  requester ID
70  *
71  * API, returns module name of requester id owner
72  *
73  * Return: pointer to module name or "unknown" if requester id not found.
74  */
75 uint8_t *ucfg_get_scan_requester_name(struct wlan_objmgr_psoc *psoc,
76 	wlan_scan_requester requester);
77 
78 
79 
80 /**
81  * ucfg_scan_get_scan_id() - allocates scan ID
82  * @psoc: psoc object
83  *
84  * API, allocates a new scan id for caller
85  *
86  * Return: newly allocated scan ID
87  */
88 wlan_scan_id
89 ucfg_scan_get_scan_id(struct wlan_objmgr_psoc *psoc);
90 
91 #ifdef FEATURE_WLAN_SCAN_PNO
92 /**
93  * ucfg_scan_pno_start() - Public API to start PNO
94  * @vdev: vdev pointer
95  * @req: pno req params
96  *
97  * Return: 0 for success or error code.
98  */
99 QDF_STATUS ucfg_scan_pno_start(struct wlan_objmgr_vdev *vdev,
100 struct pno_scan_req_params *req);
101 
102 /**
103  * ucfg_scan_pno_stop() - Public API to stop PNO
104  * @vdev: vdev pointer
105  * @req: pno req params
106  *
107  * Return: 0 for success or error code.
108  */
109 QDF_STATUS ucfg_scan_pno_stop(struct wlan_objmgr_vdev *vdev);
110 
111 /**
112  * ucfg_scan_get_pno_in_progress() - Public API to check if pno is in progress
113  * @vdev: vdev pointer
114  *
115  * Return: true if pno in progress else false.
116  */
117 bool ucfg_scan_get_pno_in_progress(struct wlan_objmgr_vdev *vdev);
118 
119 /**
120  * ucfg_scan_get_pno_match() - Public API to check if pno matched
121  * @vdev: vdev pointer
122  *
123  * Return: true if pno matched else false.
124  */
125 bool ucfg_scan_get_pno_match(struct wlan_objmgr_vdev *vdev);
126 
127 /**
128  * ucfg_scan_register_pno_cb() - register pno cb
129  * @psoc: psoc object
130  * @event_cb: callback function pointer
131  * @arg: argument to @event_cb
132  *
133  * Return: QDF_STATUS
134  */
135 QDF_STATUS
136 ucfg_scan_register_pno_cb(struct wlan_objmgr_psoc *psoc,
137 	scan_event_handler event_cb, void *arg);
138 
139 /**
140  * ucfg_scan_get_pno_def_params() - get the defaults pno params
141  * @vdev: vdev object
142  * @req: pno request object
143  *
144  * Return: QDF_STATUS_SUCCESS or error code
145  */
146 QDF_STATUS
147 ucfg_scan_get_pno_def_params(struct wlan_objmgr_vdev *vdev,
148 	struct pno_scan_req_params *req);
149 
150 #else
151 
152 static inline bool
153 ucfg_scan_get_pno_in_progress(struct wlan_objmgr_vdev *vdev)
154 {
155 	return false;
156 }
157 
158 static inline bool
159 ucfg_scan_get_pno_match(struct wlan_objmgr_vdev *vdev)
160 {
161 	return false;
162 }
163 #endif /* FEATURE_WLAN_SCAN_PNO */
164 /**
165  * ucfg_scan_start() - Public API to start a scan
166  * @req: start scan req params
167  *
168  * The Public API to start a scan. Post a msg to target_if queue
169  *
170  * Return: 0 for success or error code.
171  */
172 QDF_STATUS
173 ucfg_scan_start(struct scan_start_request *req);
174 
175 /**
176  * ucfg_scan_set_enable() - Public API to disable/enable scans
177  * @psoc: psoc on which scans need to be disabled
178  * @enable: enable scan if true disable is false
179  *
180  * Return: QDF_STATUS.
181  */
182 QDF_STATUS ucfg_scan_set_enable(struct wlan_objmgr_psoc *psoc, bool enable);
183 
184 /**
185  * ucfg_scan_get_enable() - Public API to get if scan is enabled or disabled
186  * @psoc: psoc on which scans status need to be checked
187  *
188  * Return: true if enabled else false.
189  */
190 bool ucfg_scan_get_enable(struct wlan_objmgr_psoc *psoc);
191 
192 /**
193  * ucfg_scan_set_miracast() - Public API to disable/enable miracast flag
194  * @psoc: psoc pointer
195  * @enable: enable miracast if true disable is false
196  *
197  * Return: QDF_STATUS.
198  */
199 QDF_STATUS ucfg_scan_set_miracast(
200 		struct wlan_objmgr_psoc *psoc, bool enable);
201 
202 /**
203  * ucfg_scan_set_global_config() - Public API to set global scan config
204  * @psoc: psoc context
205  * @config: config to set
206  * @val: new config value
207  *
208  * Return: QDF_STATUS.
209  */
210 QDF_STATUS
211 ucfg_scan_set_global_config(struct wlan_objmgr_psoc *psoc,
212 		enum scan_config config, uint32_t val);
213 
214 /**
215  * ucfg_scan_get_global_config() - Public API to get global scan config
216  * @psoc: psoc context
217  * @config: config to set
218  * @val: uint32* to hold returned config value
219  *
220  * Return: QDF_STATUS.
221  */
222 QDF_STATUS
223 ucfg_scan_get_global_config(struct wlan_objmgr_psoc *psoc,
224 		enum scan_config config, uint32_t *val);
225 
226 /**
227  * ucfg_scan_set_wide_band_scan() - Public API to disable/enable wide band scan
228  * @pdev: psoc on which scans need to be disabled
229  * @enable: enable wide band scan if @enable is true, disable otherwise
230  *
231  * Return: QDF_STATUS.
232  */
233 QDF_STATUS ucfg_scan_set_wide_band_scan(
234 		struct wlan_objmgr_pdev *pdev, bool enable);
235 
236 /**
237  * ucfg_scan_get_wide_band_scan() - Public API to check if
238  * wide band scan is enabled or disabled
239  * @pdev: psoc on which scans status need to be checked
240  *
241  * Return: true if enabled else false.
242  */
243 bool ucfg_scan_get_wide_band_scan(struct wlan_objmgr_pdev *pdev);
244 
245 /**
246  * ucfg_scan_set_custom_scan_chan_list() - Public API to restrict scan
247  * to few pre configured channels
248  * @pdev: psoc on which scans need to be disabled
249  * @chan_list: list of channels to scan if set
250  *
251  * Return: QDF_STATUS.
252  */
253 QDF_STATUS ucfg_scan_set_custom_scan_chan_list(
254 		struct wlan_objmgr_pdev *pdev, struct chan_list *chan_list);
255 
256 /**
257  * ucfg_scan_cancel() - Public API to stop a scan
258  * @req: stop scan request params
259  *
260  * The Public API to stop a scan. Post a msg to target_if queue
261  *
262  * Return: 0 for success or error code.
263  */
264 QDF_STATUS
265 ucfg_scan_cancel(struct scan_cancel_request *req);
266 
267 /**
268  * ucfg_scan_cancel_sync() - Public API to stop a scan and wait
269  * till all scan are completed
270  * @req: stop scan request params
271  *
272  * The Public API to stop a scan and wait
273  * till all scan are completed
274  *
275  * Return: 0 for success or error code.
276  */
277 QDF_STATUS
278 ucfg_scan_cancel_sync(struct scan_cancel_request *req);
279 
280 /**
281  * ucfg_scan_get_result() - The Public API to get scan results
282  * @pdev: pdev info
283  * @filter: Filters
284  *
285  * This function fetches scan result
286  *
287  * Return: scan list pointer
288  */
289 qdf_list_t *ucfg_scan_get_result(struct wlan_objmgr_pdev *pdev,
290 	struct scan_filter *filter);
291 
292 /**
293  * ucfg_scan_purge_results() - purge the scan list
294  * @scan_list: scan list to be purged
295  *
296  * This function purge the temp scan list
297  *
298  * Return: QDF_STATUS
299  */
300 QDF_STATUS ucfg_scan_purge_results(qdf_list_t *scan_list);
301 
302 /**
303  * ucfg_scan_flush_results() - The Public API to flush scan result
304  * @pdev: pdev object
305  * @filter: filter to flush the scan entries
306  *
307  * The Public API to flush scan result.
308  *
309  * Return: 0 for success or error code.
310  */
311 QDF_STATUS ucfg_scan_flush_results(struct wlan_objmgr_pdev *pdev,
312 	struct scan_filter *filter);
313 
314 /**
315  * ucfg_scan_filter_valid_channel() - The Public API to filter scan result
316  * based on valid channel list
317  * @pdev: pdev object
318  * @chan_list: valid channel list
319  * @num_chan: number of valid channels
320  *
321  * The Public API to to filter scan result
322  * based on valid channel list.
323  *
324  * Return: void.
325  */
326 void ucfg_scan_filter_valid_channel(struct wlan_objmgr_pdev *pdev,
327 	uint8_t *chan_list, uint32_t num_chan);
328 
329 /**
330  * ucfg_scan_db_iterate() - function to iterate scan table
331  * @pdev: pdev object
332  * @func: iterator function pointer
333  * @arg: argument to be passed to func()
334  *
335  * API, this API iterates scan table and invokes func
336  * on each scan enetry by passing scan entry and arg.
337  *
338  * Return: QDF_STATUS
339  */
340 QDF_STATUS
341 ucfg_scan_db_iterate(struct wlan_objmgr_pdev *pdev,
342 	scan_iterator_func func, void *arg);
343 
344 /**
345  * ucfg_scan_update_mlme_by_bssinfo() - The Public API to update mlme
346  * info in the scan entry
347  * @pdev: pdev object
348  * @bssid: bssid info to find the matching scan entry
349  * @mlme_info: mlme info to be updated.
350  *
351  * The Public API to update mlme info in the scan entry.
352  * Post a msg to target_if queue
353  *
354  * Return: 0 for success or error code.
355  */
356 QDF_STATUS
357 ucfg_scan_update_mlme_by_bssinfo(struct wlan_objmgr_pdev *pdev,
358 	struct bss_info *bss_info,
359 	struct mlme_info *mlme_info);
360 
361 /**
362  * ucfg_scan_register_event_handler() - The Public API to register
363  * an event cb handler
364  * @pdev: pdev object
365  * @event_cb: callback function to register
366  * @arg: component specific priv argument to @event_cb callback function
367  *
368  * The Public API to register a event cb handler. This cb is called whenever
369  * any scan event is received on @pdev.
370  *
371  * Return: 0 for success or error code.
372  */
373 
374 QDF_STATUS
375 ucfg_scan_register_event_handler(struct wlan_objmgr_pdev *pdev,
376 	scan_event_handler event_cb, void *arg);
377 
378 /**
379  * ucfg_scan_unregister_event_handler() - Public API to unregister
380  * event cb handler
381  * @pdev: pdev object
382  * @event_cb: callback function to unregister
383  * @arg: component specific priv argument to @event_cb callback function
384  *
385  * Unregister a event cb handler. cb and arg will be used to
386  * find the calback.
387  *
388  * Return: void
389  */
390 
391 void
392 ucfg_scan_unregister_event_handler(struct wlan_objmgr_pdev *pdev,
393 	scan_event_handler event_cb, void *arg);
394 
395 /**
396  * ucfg_scan_init_default_params() - get the defaults scan params
397  * @vdev: vdev object
398  * @req: scan request object
399  *
400  * get the defaults scan params
401  *
402  * Return: QDF_STATUS_SUCCESS or error code
403  */
404 QDF_STATUS
405 ucfg_scan_init_default_params(struct wlan_objmgr_vdev *vdev,
406 	struct scan_start_request *req);
407 
408 /**
409  * ucfg_scan_init_ssid_params() - initialize scan request ssid list
410  *
411  * @scan_req: scan request object
412  * @num_ssid: number of ssid's in ssid list
413  * @ssid_list: ssid list
414  *
415  * Return: QDF_STATUS_SUCCESS for success or error code
416  */
417 QDF_STATUS
418 ucfg_scan_init_ssid_params(struct scan_start_request *scan_req,
419 	uint32_t num_ssid, struct wlan_ssid *ssid_list);
420 
421 /**
422  * ucfg_scan_init_bssid_params() - initialize scan request bssid list
423  * @scan_req: scan request object
424  * @num_ssid: number of bssid's in bssid list
425  * @bssid_list: bssid list
426  *
427  * Return: QDF_STATUS_SUCCESS for success or error code
428  */
429 QDF_STATUS
430 ucfg_scan_init_bssid_params(struct scan_start_request *scan_req,
431 	uint32_t num_ssid, struct qdf_mac_addr *bssid_list);
432 
433 /**
434  * ucfg_scan_init_chanlist_params() - initialize scan request channel list
435  * @scan_req: scan request object
436  * @num_chans: number of channels in channel list
437  * @chan_list: channel list
438  * @phymode: phymode in which scan shall be done
439  *
440  * Return: QDF_STATUS_SUCCESS for success or error code
441  */
442 QDF_STATUS
443 ucfg_scan_init_chanlist_params(struct scan_start_request *scan_req,
444 	uint32_t num_chans, uint32_t *chan_list, uint32_t *phymode);
445 
446 /**
447  * ucfg_scan_get_vdev_status() - API to check vdev scan status
448  * @vdev: vdev object
449  *
450  * Return: enum scm_scan_status
451  */
452 enum scm_scan_status
453 ucfg_scan_get_vdev_status(struct wlan_objmgr_vdev *vdev);
454 
455 /**
456  * ucfg_scan_get_pdev_status() - API to check pdev scan status
457  * @pdev: vdev object
458  *
459  * Return: enum scm_scan_status
460  */
461 enum scm_scan_status
462 ucfg_scan_get_pdev_status(struct wlan_objmgr_pdev *pdev);
463 
464 /**
465  * ucfg_scan_register_bcn_cb() - API to register api
466  * to inform/update bcn/probe as soon as they are received
467  * @pdev: psoc
468  * @cb: callback to be registered
469  * @type: Type of callback to be registered
470  *
471  * Return: enum scm_scan_status
472  */
473 QDF_STATUS ucfg_scan_register_bcn_cb(struct wlan_objmgr_psoc *psoc,
474 	update_beacon_cb cb, enum scan_cb_type type);
475 
476 /*
477  * ucfg_scan_update_user_config() - Update scan cache user config
478  * @psoc: psoc
479  * @scan_cfg: scan user config
480  *
481  * Return: QDF_STATUS
482  */
483 QDF_STATUS ucfg_scan_update_user_config(struct wlan_objmgr_psoc *psoc,
484 	struct scan_user_cfg *scan_cfg);
485 
486 /**
487  * ucfg_scan_update_roam_params() - Store/Update the roam params
488  * @psoc: psoc
489  * @roam_params: roam params
490  *
491  * Return: QDF_STATUS
492  */
493 QDF_STATUS ucfg_scan_update_roam_params(struct wlan_objmgr_psoc *psoc,
494 	struct roam_filter_params *roam_params);
495 
496 /*
497  * ucfg_scan_init() - Scan module initialization API
498  *
499  * Return: QDF_STATUS
500  */
501 QDF_STATUS ucfg_scan_init(void);
502 
503 /**
504  * ucfg_scan_deinit() - Scan module deinitilization API
505  *
506  * Return: QDF_STATUS
507  */
508 QDF_STATUS ucfg_scan_deinit(void);
509 
510 /**
511  * ucfg_scan_psoc_enable() - Scan module enable API
512  * @psoc: psoc object
513  *
514  * Return: QDF_STATUS
515  */
516 QDF_STATUS ucfg_scan_psoc_enable(struct wlan_objmgr_psoc *psoc);
517 
518 /**
519  * ucfg_scan_psoc_enable() - Scan module disable API
520  * @psoc: psoc object
521  *
522  * Return: QDF_STATUS
523  */
524 QDF_STATUS ucfg_scan_psoc_disable(struct wlan_objmgr_psoc *psoc);
525 
526 /**
527  * ucfg_scan_psoc_open() - Scan module psoc open API
528  * @psoc: psoc object
529  *
530  * Return: QDF_STATUS
531  */
532 QDF_STATUS ucfg_scan_psoc_open(struct wlan_objmgr_psoc *psoc);
533 
534 /**
535  * ucfg_scan_psoc_close() - Scan module psoc close API
536  * @psoc: psoc object
537  *
538  * Return: QDF_STATUS
539  */
540 QDF_STATUS ucfg_scan_psoc_close(struct wlan_objmgr_psoc *psoc);
541 
542 /**
543  * ucfg_scan_get_max_active_scans() - API to get max active scans
544  * supported on this psoc
545  * @psoc: psoc object
546  *
547  * Return: uint32_t
548  */
549 uint32_t ucfg_scan_get_max_active_scans(struct wlan_objmgr_psoc *psoc);
550 
551 /**
552  * ucfg_ie_whitelist_enabled() - Checks for IE whitelisting enable
553  * @psoc: pointer to psoc object
554  * @vdev: pointer to vdev
555  *
556  * This function is used to check whether IE whitelisting is enabled or not
557  *
558  * Return: If enabled returns true else returns false
559  */
560 bool ucfg_ie_whitelist_enabled(struct wlan_objmgr_psoc *psoc,
561 			       struct wlan_objmgr_vdev *vdev);
562 
563 /**
564  * ucfg_copy_ie_whitelist_attrs() - Populate probe req IE whitelist attrs
565  * @psoc: pointer to psoc object
566  * @ie_whitelist: output parameter to hold ie whitelist attrs
567  *
568  * If IE whitelisting is enabled then invoke this function to copy
569  * IE whitelisting attrs from wlan scan object
570  *
571  * Return: true - successful copy
572  *         false - copy failed
573  */
574 bool ucfg_copy_ie_whitelist_attrs(struct wlan_objmgr_psoc *psoc,
575 				struct probe_req_whitelist_attr *ie_whitelist);
576 
577 /**
578  * ucfg_scan_set_bt_activity() - API to set bt activity
579  * @psoc: pointer to psoc object
580  * @bt_a2dp_active: bt activiy value
581  *
582  * Return: None
583  */
584 void ucfg_scan_set_bt_activity(struct wlan_objmgr_psoc *psoc,
585 			       bool bt_a2dp_active);
586 /**
587  * ucfg_scan_get_bt_activity() - API to get bt activity
588  * @psoc: pointer to psoc object
589  *
590  * Return: true if enabled else false.
591  */
592 bool ucfg_scan_get_bt_activity(struct wlan_objmgr_psoc *psoc);
593 #endif
594