xref: /wlan-dirver/qca-wifi-host-cmn/umac/scan/core/src/wlan_scan_cache_db.h (revision bea437e2293c3d4fb1b5704fcf633aedac996962)
1 /*
2  * Copyright (c) 2017-2019 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 cache entry api
21  */
22 
23 #ifndef _WLAN_SCAN_CACHE_DB_H_
24 #define _WLAN_SCAN_CACHE_DB_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 #define SCAN_HASH_SIZE 64
33 #define SCAN_GET_HASH(addr) \
34 	(((const uint8_t *)(addr))[QDF_MAC_ADDR_SIZE - 1] % SCAN_HASH_SIZE)
35 
36 #define SCM_PCL_RSSI_THRESHOLD -75
37 #define BEST_CANDIDATE_MAX_BSS_SCORE 10000
38 
39 #define ADJACENT_CHANNEL_RSSI_THRESHOLD -80
40 
41 /**
42  * struct scan_dbs - scan cache data base definition
43  * @num_entries: number of scan entries
44  * @scan_hash_tbl: link list of bssid hashed scan cache entries for a pdev
45  */
46 struct scan_dbs {
47 	uint32_t num_entries;
48 	qdf_spinlock_t scan_db_lock;
49 	qdf_list_t scan_hash_tbl[SCAN_HASH_SIZE];
50 };
51 
52 /**
53  * struct scan_bcn_probe_event - beacon/probe info
54  * @frm_type: frame type
55  * @rx_data: mgmt rx data
56  * @psoc: psoc pointer
57  * @buf: rx frame
58  */
59 struct scan_bcn_probe_event {
60 	uint32_t frm_type;
61 	struct mgmt_rx_event_params *rx_data;
62 	struct wlan_objmgr_psoc *psoc;
63 	qdf_nbuf_t buf;
64 };
65 
66 /**
67  * scm_handle_bcn_probe() - Process beacon and probe rsp
68  * @msg: schedular msg with bcn info;
69  *
70  * API to handle the beacon/probe resp. msg->bodyptr will be consumed and freed
71  * by this func
72  *
73  * Return: QDF status.
74  */
75 QDF_STATUS scm_handle_bcn_probe(struct scheduler_msg *msg);
76 
77 /**
78  * __scm_handle_bcn_probe() - Process beacon and probe rsp
79  * @bcn: beacon info;
80  *
81  * API to handle the beacon/probe resp. bcn will be consumed and freed by this
82  * func
83  *
84  * Return: QDF status.
85  */
86 QDF_STATUS __scm_handle_bcn_probe(struct scan_bcn_probe_event *bcn);
87 
88 /**
89  * scm_age_out_entries() - Age out entries older than aging time
90  * @psoc: psoc pointer
91  * @scan_db: scan database
92  *
93  * Return: void.
94  */
95 void scm_age_out_entries(struct wlan_objmgr_psoc *psoc,
96 	struct scan_dbs *scan_db);
97 
98 /**
99  * scm_get_scan_result() - fetches scan result
100  * @pdev: pdev info
101  * @filter: Filters
102  *
103  * This function fetches scan result
104  *
105  * Return: scan list
106  */
107 qdf_list_t *scm_get_scan_result(struct wlan_objmgr_pdev *pdev,
108 	struct scan_filter *filter);
109 
110 /**
111  * scm_purge_scan_results() - purge the scan list
112  * @scan_result: scan list to be purged
113  *
114  * This function purge the temp scan list
115  *
116  * Return: QDF_STATUS
117  */
118 QDF_STATUS scm_purge_scan_results(qdf_list_t *scan_result);
119 
120 /**
121  * scm_update_scan_mlme_info() - updates scan entry with mlme data
122  * @pdev: pdev object
123  * @scan_entry: source scan entry to read mlme info
124  *
125  * This function updates scan db with scan_entry->mlme_info
126  *
127  * Return: QDF_STATUS
128  */
129 QDF_STATUS scm_update_scan_mlme_info(struct wlan_objmgr_pdev *pdev,
130 	struct scan_cache_entry *scan_entry);
131 
132 /**
133  * scm_flush_results() - flush scan entries matching the filter
134  * @pdev: vdev object
135  * @filter: filter to flush the scan entries
136  *
137  * Flush scan entries matching the filter.
138  *
139  * Return: QDF status.
140  */
141 QDF_STATUS scm_flush_results(struct wlan_objmgr_pdev *pdev,
142 	struct scan_filter *filter);
143 
144 /**
145  * scm_filter_valid_channel() - The Public API to filter scan result
146  * based on valid channel list
147  * @pdev: pdev object
148  * @chan_freq_list: valid channel frequency (in MHz) list
149  * @num_chan: number of valid channels
150  *
151  * The Public API to to filter scan result
152  * based on valid channel list.
153  *
154  * Return: void.
155  */
156 void scm_filter_valid_channel(struct wlan_objmgr_pdev *pdev,
157 	uint32_t *chan_freq_list, uint32_t num_chan);
158 
159 /**
160  * scm_iterate_scan_db() - function to iterate scan table
161  * @pdev: pdev object
162  * @func: iterator function pointer
163  * @arg: argument to be passed to func()
164  *
165  * API, this API iterates scan table and invokes func
166  * on each scan enetry by passing scan entry and arg.
167  *
168  * Return: QDF_STATUS
169  */
170 QDF_STATUS
171 scm_iterate_scan_db(struct wlan_objmgr_pdev *pdev,
172 	scan_iterator_func func, void *arg);
173 
174 /**
175  * scm_scan_register_bcn_cb() - API to register api to indicate bcn/probe
176  * as soon as they are received
177  * @pdev: psoc
178  * @cb: callback to be registered
179  * @type: Type of callback to be registered
180  *
181  * Return: enum scm_scan_status
182  */
183 QDF_STATUS scm_scan_register_bcn_cb(struct wlan_objmgr_psoc *psoc,
184 	update_beacon_cb cb, enum scan_cb_type type);
185 
186 /**
187  * scm_db_init() - API to init scan db
188  * @psoc: psoc
189  *
190  * Return: QDF_STATUS
191  */
192 QDF_STATUS scm_db_init(struct wlan_objmgr_psoc *psoc);
193 
194 /**
195  * scm_db_deinit() - API to deinit scan db
196  * @psoc: psoc
197  *
198  * Return: QDF_STATUS
199  */
200 QDF_STATUS scm_db_deinit(struct wlan_objmgr_psoc *psoc);
201 
202 /**
203  * scm_channel_list_db_init() - API to init scan list priority list db
204  * @psoc: psoc
205  *
206  * Return: QDF_STATUS
207  */
208 QDF_STATUS scm_channel_list_db_init(struct wlan_objmgr_psoc *psoc);
209 
210 /**
211  * scm_channel_list_db_deinit() - API to deinit scan list priority list db
212  * @psoc: psoc
213  *
214  * Return: QDF_STATUS
215  */
216 QDF_STATUS scm_channel_list_db_deinit(struct wlan_objmgr_psoc *psoc);
217 
218 /**
219  * scm_get_chan_meta() - API to return channel meta
220  * @freq: channel frequency
221  *
222  * Return: channel meta information
223  */
224 struct meta_rnr_channel *scm_get_chan_meta(uint32_t freq);
225 
226 /**
227  * scm_validate_scoring_config() - validate score config
228  * @score_cfg: config to be validated
229  *
230  * Return: void
231  */
232 void scm_validate_scoring_config(
233 			struct scoring_config *score_cfg);
234 
235 /**
236  * scm_scan_update_mlme_by_bssinfo() - updates scan entry with mlme data
237  * @pdev: pdev object
238  * @bss_info: BSS information
239  *
240  * This function updates scan db with scan_entry->mlme_info
241  *
242  * Return: QDF_STATUS
243  */
244 QDF_STATUS scm_scan_update_mlme_by_bssinfo(struct wlan_objmgr_pdev *pdev,
245 		struct bss_info *bss_info, struct mlme_info *mlme);
246 #endif
247