xref: /wlan-dirver/qca-wifi-host-cmn/umac/scan/dispatcher/inc/wlan_scan_ucfg_api.h (revision 3149adf58a329e17232a4c0e58d460d025edd55a)
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_cancel() - Public API to stop a scan
247  * @req: stop scan request params
248  *
249  * The Public API to stop a scan. Post a msg to target_if queue
250  *
251  * Return: 0 for success or error code.
252  */
253 QDF_STATUS
254 ucfg_scan_cancel(struct scan_cancel_request *req);
255 
256 /**
257  * ucfg_scan_cancel_sync() - Public API to stop a scan and wait
258  * till all scan are completed
259  * @req: stop scan request params
260  *
261  * The Public API to stop a scan and wait
262  * till all scan are completed
263  *
264  * Return: 0 for success or error code.
265  */
266 QDF_STATUS
267 ucfg_scan_cancel_sync(struct scan_cancel_request *req);
268 
269 /**
270  * ucfg_scan_get_result() - The Public API to get scan results
271  * @pdev: pdev info
272  * @filter: Filters
273  *
274  * This function fetches scan result
275  *
276  * Return: scan list pointer
277  */
278 qdf_list_t *ucfg_scan_get_result(struct wlan_objmgr_pdev *pdev,
279 	struct scan_filter *filter);
280 
281 /**
282  * ucfg_scan_purge_results() - purge the scan list
283  * @scan_list: scan list to be purged
284  *
285  * This function purge the temp scan list
286  *
287  * Return: QDF_STATUS
288  */
289 QDF_STATUS ucfg_scan_purge_results(qdf_list_t *scan_list);
290 
291 /**
292  * ucfg_scan_flush_results() - The Public API to flush scan result
293  * @pdev: pdev object
294  * @filter: filter to flush the scan entries
295  *
296  * The Public API to flush scan result.
297  *
298  * Return: 0 for success or error code.
299  */
300 QDF_STATUS ucfg_scan_flush_results(struct wlan_objmgr_pdev *pdev,
301 	struct scan_filter *filter);
302 
303 /**
304  * ucfg_scan_filter_valid_channel() - The Public API to filter scan result
305  * based on valid channel list
306  * @pdev: pdev object
307  * @chan_list: valid channel list
308  * @num_chan: number of valid channels
309  *
310  * The Public API to to filter scan result
311  * based on valid channel list.
312  *
313  * Return: void.
314  */
315 void ucfg_scan_filter_valid_channel(struct wlan_objmgr_pdev *pdev,
316 	uint8_t *chan_list, uint32_t num_chan);
317 
318 /**
319  * ucfg_scan_db_iterate() - function to iterate scan table
320  * @pdev: pdev object
321  * @func: iterator function pointer
322  * @arg: argument to be passed to func()
323  *
324  * API, this API iterates scan table and invokes func
325  * on each scan enetry by passing scan entry and arg.
326  *
327  * Return: QDF_STATUS
328  */
329 QDF_STATUS
330 ucfg_scan_db_iterate(struct wlan_objmgr_pdev *pdev,
331 	scan_iterator_func func, void *arg);
332 
333 /**
334  * ucfg_scan_update_mlme_info() - The Public API to update mlme
335  * info in the scan entry
336  * @vdev: vdev object
337  * @bss: bss info to find the matching scan entry
338  * @mlme_info: mlme info to be updated.
339  *
340  * The Public API to update mlme info in the scan entry.
341  * Post a msg to target_if queue
342  *
343  * Return: 0 for success or error code.
344  */
345 QDF_STATUS
346 ucfg_scan_update_mlme_info(struct wlan_objmgr_vdev *vdev, struct bss_info *bss,
347 	struct mlme_info *mlme_info);
348 
349 /**
350  * ucfg_scan_register_event_handler() - The Public API to register
351  * an event cb handler
352  * @pdev: pdev object
353  * @event_cb: callback function to register
354  * @arg: component specific priv argument to @event_cb callback function
355  *
356  * The Public API to register a event cb handler. This cb is called whenever
357  * any scan event is received on @pdev.
358  *
359  * Return: 0 for success or error code.
360  */
361 
362 QDF_STATUS
363 ucfg_scan_register_event_handler(struct wlan_objmgr_pdev *pdev,
364 	scan_event_handler event_cb, void *arg);
365 
366 /**
367  * ucfg_scan_unregister_event_handler() - Public API to unregister
368  * event cb handler
369  * @pdev: pdev object
370  * @event_cb: callback function to unregister
371  * @arg: component specific priv argument to @event_cb callback function
372  *
373  * Unregister a event cb handler. cb and arg will be used to
374  * find the calback.
375  *
376  * Return: void
377  */
378 
379 void
380 ucfg_scan_unregister_event_handler(struct wlan_objmgr_pdev *pdev,
381 	scan_event_handler event_cb, void *arg);
382 
383 /**
384  * ucfg_scan_init_default_params() - get the defaults scan params
385  * @vdev: vdev object
386  * @req: scan request object
387  *
388  * get the defaults scan params
389  *
390  * Return: QDF_STATUS_SUCCESS or error code
391  */
392 QDF_STATUS
393 ucfg_scan_init_default_params(struct wlan_objmgr_vdev *vdev,
394 	struct scan_start_request *req);
395 
396 /**
397  * ucfg_scan_init_ssid_params() - initialize scan request ssid list
398  *
399  * @scan_req: scan request object
400  * @num_ssid: number of ssid's in ssid list
401  * @ssid_list: ssid list
402  *
403  * Return: QDF_STATUS_SUCCESS for success or error code
404  */
405 QDF_STATUS
406 ucfg_scan_init_ssid_params(struct scan_start_request *scan_req,
407 	uint32_t num_ssid, struct wlan_ssid *ssid_list);
408 
409 /**
410  * ucfg_scan_init_bssid_params() - initialize scan request bssid list
411  * @scan_req: scan request object
412  * @num_ssid: number of bssid's in bssid list
413  * @bssid_list: bssid list
414  *
415  * Return: QDF_STATUS_SUCCESS for success or error code
416  */
417 QDF_STATUS
418 ucfg_scan_init_bssid_params(struct scan_start_request *scan_req,
419 	uint32_t num_ssid, struct qdf_mac_addr *bssid_list);
420 
421 /**
422  * ucfg_scan_init_chanlist_params() - initialize scan request channel list
423  * @scan_req: scan request object
424  * @num_chans: number of channels in channel list
425  * @chan_list: channel list
426  * @phymode: phymode in which scan shall be done
427  *
428  * Return: QDF_STATUS_SUCCESS for success or error code
429  */
430 QDF_STATUS
431 ucfg_scan_init_chanlist_params(struct scan_start_request *scan_req,
432 	uint32_t num_chans, uint32_t *chan_list, uint32_t *phymode);
433 
434 /**
435  * ucfg_scan_get_vdev_status() - API to check vdev scan status
436  * @vdev: vdev object
437  *
438  * Return: enum scm_scan_status
439  */
440 enum scm_scan_status
441 ucfg_scan_get_vdev_status(struct wlan_objmgr_vdev *vdev);
442 
443 /**
444  * ucfg_scan_get_pdev_status() - API to check pdev scan status
445  * @pdev: vdev object
446  *
447  * Return: enum scm_scan_status
448  */
449 enum scm_scan_status
450 ucfg_scan_get_pdev_status(struct wlan_objmgr_pdev *pdev);
451 
452 /**
453  * ucfg_scan_register_bcn_cb() - API to register api
454  * to inform/update bcn/probe as soon as they are received
455  * @pdev: psoc
456  * @cb: callback to be registered
457  * @type: Type of callback to be registered
458  *
459  * Return: enum scm_scan_status
460  */
461 QDF_STATUS ucfg_scan_register_bcn_cb(struct wlan_objmgr_psoc *psoc,
462 	update_beacon_cb cb, enum scan_cb_type type);
463 
464 /*
465  * ucfg_scan_update_user_config() - Update scan cache user config
466  * @psoc: psoc
467  * @scan_cfg: scan user config
468  *
469  * Return: QDF_STATUS
470  */
471 QDF_STATUS ucfg_scan_update_user_config(struct wlan_objmgr_psoc *psoc,
472 	struct scan_user_cfg *scan_cfg);
473 
474 /**
475  * ucfg_scan_update_roam_params() - Store/Update the roam params
476  * @psoc: psoc
477  * @roam_params: roam params
478  *
479  * Return: QDF_STATUS
480  */
481 QDF_STATUS ucfg_scan_update_roam_params(struct wlan_objmgr_psoc *psoc,
482 	struct roam_filter_params *roam_params);
483 
484 /*
485  * ucfg_scan_init() - Scan module initialization API
486  *
487  * Return: QDF_STATUS
488  */
489 QDF_STATUS ucfg_scan_init(void);
490 
491 /**
492  * ucfg_scan_deinit() - Scan module deinitilization API
493  *
494  * Return: QDF_STATUS
495  */
496 QDF_STATUS ucfg_scan_deinit(void);
497 
498 /**
499  * ucfg_scan_psoc_enable() - Scan module enable API
500  * @psoc: psoc object
501  *
502  * Return: QDF_STATUS
503  */
504 QDF_STATUS ucfg_scan_psoc_enable(struct wlan_objmgr_psoc *psoc);
505 
506 /**
507  * ucfg_scan_psoc_enable() - Scan module disable API
508  * @psoc: psoc object
509  *
510  * Return: QDF_STATUS
511  */
512 QDF_STATUS ucfg_scan_psoc_disable(struct wlan_objmgr_psoc *psoc);
513 
514 /**
515  * ucfg_scan_psoc_open() - Scan module psoc open API
516  * @psoc: psoc object
517  *
518  * Return: QDF_STATUS
519  */
520 QDF_STATUS ucfg_scan_psoc_open(struct wlan_objmgr_psoc *psoc);
521 
522 /**
523  * ucfg_scan_psoc_close() - Scan module psoc close API
524  * @psoc: psoc object
525  *
526  * Return: QDF_STATUS
527  */
528 QDF_STATUS ucfg_scan_psoc_close(struct wlan_objmgr_psoc *psoc);
529 
530 /**
531  * ucfg_scan_get_max_active_scans() - API to get max active scans
532  * supported on this psoc
533  * @psoc: psoc object
534  *
535  * Return: uint32_t
536  */
537 uint32_t ucfg_scan_get_max_active_scans(struct wlan_objmgr_psoc *psoc);
538 
539 /**
540  * ucfg_ie_whitelist_enabled() - Checks for IE whitelisting enable
541  * @psoc: pointer to psoc object
542  * @vdev: pointer to vdev
543  *
544  * This function is used to check whether IE whitelisting is enabled or not
545  *
546  * Return: If enabled returns true else returns false
547  */
548 bool ucfg_ie_whitelist_enabled(struct wlan_objmgr_psoc *psoc,
549 			       struct wlan_objmgr_vdev *vdev);
550 
551 /**
552  * ucfg_copy_ie_whitelist_attrs() - Populate probe req IE whitelist attrs
553  * @psoc: pointer to psoc object
554  * @ie_whitelist: output parameter to hold ie whitelist attrs
555  *
556  * If IE whitelisting is enabled then invoke this function to copy
557  * IE whitelisting attrs from wlan scan object
558  *
559  * Return: true - successful copy
560  *         false - copy failed
561  */
562 bool ucfg_copy_ie_whitelist_attrs(struct wlan_objmgr_psoc *psoc,
563 				struct probe_req_whitelist_attr *ie_whitelist);
564 
565 /**
566  * ucfg_scan_set_bt_activity() - API to set bt activity
567  * @psoc: pointer to psoc object
568  * @bt_a2dp_active: bt activiy value
569  *
570  * Return: None
571  */
572 void ucfg_scan_set_bt_activity(struct wlan_objmgr_psoc *psoc,
573 			       bool bt_a2dp_active);
574 /**
575  * ucfg_scan_get_bt_activity() - API to get bt activity
576  * @psoc: pointer to psoc object
577  *
578  * Return: true if enabled else false.
579  */
580 bool ucfg_scan_get_bt_activity(struct wlan_objmgr_psoc *psoc);
581 #endif
582