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