xref: /wlan-driver/qca-wifi-host-cmn/umac/scan/core/src/wlan_scan_cache_db_i.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2017, 2019-2020 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2023 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 internal api
22  */
23 
24 #ifndef _WLAN_SCAN_CACHE_DB_I_H_
25 #define _WLAN_SCAN_CACHE_DB_I_H_
26 
27 /**
28  * scm_filter_match() - private API to check if entry is match to filter
29  * @psoc: psoc ptr;
30  * @db_entry: db entry
31  * @filter: filter
32  * @security: negotiated security if match is found
33  *
34  * Return: true if entry match filter
35  */
36 bool scm_filter_match(struct wlan_objmgr_psoc *psoc,
37 	struct scan_cache_entry *db_entry,
38 	struct scan_filter *filter,
39 	struct security_info *security);
40 
41 /**
42  * wlan_pdevid_get_scan_db() - private API to get scan db from pdev id
43  * @psoc: psoc object
44  * @pdev_id: Pdev_id
45  *
46  * Return: scan db for the pdev id
47  */
48 static inline struct scan_dbs *
wlan_pdevid_get_scan_db(struct wlan_objmgr_psoc * psoc,uint8_t pdev_id)49 wlan_pdevid_get_scan_db(struct wlan_objmgr_psoc *psoc, uint8_t pdev_id)
50 {
51 	struct wlan_scan_obj *scan_obj = NULL;
52 
53 	if (pdev_id > WLAN_UMAC_MAX_PDEVS) {
54 		scm_err("invalid pdev_id %d", pdev_id);
55 		return NULL;
56 	}
57 	scan_obj = wlan_psoc_get_scan_obj(psoc);
58 
59 	if (!scan_obj)
60 		return NULL;
61 
62 	return &(scan_obj->scan_db[pdev_id]);
63 }
64 
65 /**
66  * wlan_pdev_get_scan_db() - private API to get scan db from pdev
67  * @psoc: psoc object
68  * @pdev: Pdev
69  *
70  * Return: scan db for the pdev
71  */
72 static inline struct scan_dbs *
wlan_pdev_get_scan_db(struct wlan_objmgr_psoc * psoc,struct wlan_objmgr_pdev * pdev)73 wlan_pdev_get_scan_db(struct wlan_objmgr_psoc *psoc,
74 	struct wlan_objmgr_pdev *pdev)
75 {
76 	uint8_t pdev_id;
77 
78 	if (!pdev) {
79 		scm_err("pdev is NULL");
80 		return NULL;
81 	}
82 	pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev);
83 
84 	return wlan_pdevid_get_scan_db(psoc, pdev_id);
85 }
86 
87 #endif
88