blob: 570c30fdf3df22c421c3d22981b771d1936c84ca [file] [log] [blame]
Om Prakash Tripathi7e3f45d2016-12-28 16:58:54 +05301/*
Abhishek Singhbd80d5c2019-04-09 15:05:54 +05302 * Copyright (c) 2017-2019 The Linux Foundation. All rights reserved.
Om Prakash Tripathi7e3f45d2016-12-28 16:58:54 +05303 *
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>
Abhishek Singh4caf1a92017-02-21 15:01:08 +053027#include <wlan_objmgr_psoc_obj.h>
28#include <wlan_objmgr_pdev_obj.h>
29#include <wlan_objmgr_vdev_obj.h>
Om Prakash Tripathi7e3f45d2016-12-28 16:58:54 +053030#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)
Om Prakash Tripathi4fa65d82017-06-22 11:15:24 +053035
Abhishek Singh7b599032017-11-10 14:42:31 +053036#define SCM_PCL_RSSI_THRESHOLD -75
Abhishek Singhb80af7e2017-07-19 18:48:42 +053037#define BEST_CANDIDATE_MAX_BSS_SCORE 10000
38
Abhishek Singhc05285d2018-01-12 15:19:32 +053039#define ADJACENT_CHANNEL_RSSI_THRESHOLD -80
40
Om Prakash Tripathi7e3f45d2016-12-28 16:58:54 +053041/**
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 */
46struct 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 */
59struct 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
Abhishek Singhbd80d5c2019-04-09 15:05:54 +053068 * @msg: schedular msg with bcn info;
Om Prakash Tripathi7e3f45d2016-12-28 16:58:54 +053069 *
Abhishek Singha7bfb9b2019-04-16 09:33:04 +053070 * API to handle the beacon/probe resp. msg->bodyptr will be consumed and freed
71 * by this func
Om Prakash Tripathi7e3f45d2016-12-28 16:58:54 +053072 *
73 * Return: QDF status.
74 */
75QDF_STATUS scm_handle_bcn_probe(struct scheduler_msg *msg);
76
77/**
Abhishek Singhbd80d5c2019-04-09 15:05:54 +053078 * __scm_handle_bcn_probe() - Process beacon and probe rsp
79 * @bcn: beacon info;
80 *
Abhishek Singha7bfb9b2019-04-16 09:33:04 +053081 * API to handle the beacon/probe resp. bcn will be consumed and freed by this
82 * func
Abhishek Singhbd80d5c2019-04-09 15:05:54 +053083 *
84 * Return: QDF status.
85 */
86QDF_STATUS __scm_handle_bcn_probe(struct scan_bcn_probe_event *bcn);
87
Abhishek Singhbd80d5c2019-04-09 15:05:54 +053088/**
Abhishek Singh4caf1a92017-02-21 15:01:08 +053089 * scm_age_out_entries() - Age out entries older than aging time
Abhishek Singh6e7489e2017-03-23 10:54:22 +053090 * @psoc: psoc pointer
Om Prakash Tripathi7e3f45d2016-12-28 16:58:54 +053091 * @scan_db: scan database
Om Prakash Tripathi7e3f45d2016-12-28 16:58:54 +053092 *
Abhishek Singh4caf1a92017-02-21 15:01:08 +053093 * Return: void.
Om Prakash Tripathi7e3f45d2016-12-28 16:58:54 +053094 */
Abhishek Singh6e7489e2017-03-23 10:54:22 +053095void scm_age_out_entries(struct wlan_objmgr_psoc *psoc,
96 struct scan_dbs *scan_db);
Om Prakash Tripathi7e3f45d2016-12-28 16:58:54 +053097
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 */
107qdf_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 */
118QDF_STATUS scm_purge_scan_results(qdf_list_t *scan_result);
119
120/**
121 * scm_update_scan_mlme_info() - updates scan entry with mlme data
Om Prakash Tripathic3fcb682017-08-01 18:24:55 +0530122 * @pdev: pdev object
123 * @scan_entry: source scan entry to read mlme info
Om Prakash Tripathi7e3f45d2016-12-28 16:58:54 +0530124 *
Om Prakash Tripathic3fcb682017-08-01 18:24:55 +0530125 * This function updates scan db with scan_entry->mlme_info
Om Prakash Tripathi7e3f45d2016-12-28 16:58:54 +0530126 *
127 * Return: QDF_STATUS
128 */
Om Prakash Tripathic3fcb682017-08-01 18:24:55 +0530129QDF_STATUS scm_update_scan_mlme_info(struct wlan_objmgr_pdev *pdev,
130 struct scan_cache_entry *scan_entry);
Om Prakash Tripathi7e3f45d2016-12-28 16:58:54 +0530131
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 */
141QDF_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
hque131d312019-11-21 17:55:27 +0800148 * @chan_freq_list: valid channel frequency (in MHz) list
Om Prakash Tripathi7e3f45d2016-12-28 16:58:54 +0530149 * @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 */
156void scm_filter_valid_channel(struct wlan_objmgr_pdev *pdev,
hque131d312019-11-21 17:55:27 +0800157 uint32_t *chan_freq_list, uint32_t num_chan);
Om Prakash Tripathi7e3f45d2016-12-28 16:58:54 +0530158
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 */
170QDF_STATUS
171scm_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 */
183QDF_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 */
192QDF_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 */
200QDF_STATUS scm_db_deinit(struct wlan_objmgr_psoc *psoc);
Abhishek Singh7b599032017-11-10 14:42:31 +0530201
202/**
Sandeep Puligillad763fee2019-11-08 14:00:10 -0800203 * scm_channel_list_db_init() - API to init scan list priority list db
204 * @psoc: psoc
205 *
206 * Return: QDF_STATUS
207 */
208QDF_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 */
216QDF_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 */
224struct meta_rnr_channel *scm_get_chan_meta(uint32_t freq);
225
226/**
Abhishek Singh7b599032017-11-10 14:42:31 +0530227 * scm_validate_scoring_config() - validate score config
228 * @score_cfg: config to be validated
229 *
230 * Return: void
231 */
232void scm_validate_scoring_config(
233 struct scoring_config *score_cfg);
Sandeep Puligillae062e822018-02-28 00:27:10 -0800234
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 */
244QDF_STATUS scm_scan_update_mlme_by_bssinfo(struct wlan_objmgr_pdev *pdev,
245 struct bss_info *bss_info, struct mlme_info *mlme);
Om Prakash Tripathi7e3f45d2016-12-28 16:58:54 +0530246#endif