1 /* 2 * Copyright (c) 2017-2020 The Linux Foundation. All rights reserved. 3 * Copyright (c) 2022 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 cache entry api 22 */ 23 24 #ifndef _WLAN_SCAN_CACHE_DB_H_ 25 #define _WLAN_SCAN_CACHE_DB_H_ 26 27 #include <scheduler_api.h> 28 #include <wlan_objmgr_psoc_obj.h> 29 #include <wlan_objmgr_pdev_obj.h> 30 #include <wlan_objmgr_vdev_obj.h> 31 #include <wlan_scan_public_structs.h> 32 33 #define SCAN_HASH_SIZE 64 34 #define SCAN_GET_HASH(addr) \ 35 (((const uint8_t *)(addr))[QDF_MAC_ADDR_SIZE - 1] % SCAN_HASH_SIZE) 36 37 #define ADJACENT_CHANNEL_RSSI_THRESHOLD -80 38 39 /** 40 * struct scan_dbs - scan cache data base definition 41 * @num_entries: number of scan entries 42 * @scan_hash_tbl: link list of bssid hashed scan cache entries for a pdev 43 */ 44 struct scan_dbs { 45 uint32_t num_entries; 46 qdf_spinlock_t scan_db_lock; 47 qdf_list_t scan_hash_tbl[SCAN_HASH_SIZE]; 48 }; 49 50 /** 51 * struct scan_bcn_probe_event - beacon/probe info 52 * @frm_type: frame type 53 * @rx_data: mgmt rx data 54 * @psoc: psoc pointer 55 * @buf: rx frame 56 */ 57 struct scan_bcn_probe_event { 58 uint32_t frm_type; 59 struct mgmt_rx_event_params *rx_data; 60 struct wlan_objmgr_psoc *psoc; 61 qdf_nbuf_t buf; 62 }; 63 64 /** 65 * scm_handle_bcn_probe() - Process beacon and probe rsp 66 * @msg: schedular msg with bcn info; 67 * 68 * API to handle the beacon/probe resp. msg->bodyptr will be consumed and freed 69 * by this func 70 * 71 * Return: QDF status. 72 */ 73 QDF_STATUS scm_handle_bcn_probe(struct scheduler_msg *msg); 74 75 /** 76 * __scm_handle_bcn_probe() - Process beacon and probe rsp 77 * @bcn: beacon info; 78 * 79 * API to handle the beacon/probe resp. bcn will be consumed and freed by this 80 * func 81 * 82 * Return: QDF status. 83 */ 84 QDF_STATUS __scm_handle_bcn_probe(struct scan_bcn_probe_event *bcn); 85 86 /** 87 * scm_age_out_entries() - Age out entries older than aging time 88 * @psoc: psoc pointer 89 * @scan_db: scan database 90 * 91 * Return: void. 92 */ 93 void scm_age_out_entries(struct wlan_objmgr_psoc *psoc, 94 struct scan_dbs *scan_db); 95 96 /** 97 * scm_get_scan_result() - fetches scan result 98 * @pdev: pdev info 99 * @filter: Filters 100 * 101 * This function fetches scan result 102 * 103 * Return: scan list 104 */ 105 qdf_list_t *scm_get_scan_result(struct wlan_objmgr_pdev *pdev, 106 struct scan_filter *filter); 107 108 /** 109 * scm_purge_scan_results() - purge the scan list 110 * @scan_result: scan list to be purged 111 * 112 * This function purge the temp scan list 113 * 114 * Return: QDF_STATUS 115 */ 116 QDF_STATUS scm_purge_scan_results(qdf_list_t *scan_result); 117 118 /** 119 * scm_update_scan_mlme_info() - updates scan entry with mlme data 120 * @pdev: pdev object 121 * @scan_entry: source scan entry to read mlme info 122 * 123 * This function updates scan db with scan_entry->mlme_info 124 * 125 * Return: QDF_STATUS 126 */ 127 QDF_STATUS scm_update_scan_mlme_info(struct wlan_objmgr_pdev *pdev, 128 struct scan_cache_entry *scan_entry); 129 130 /** 131 * scm_flush_results() - flush scan entries matching the filter 132 * @pdev: vdev object 133 * @filter: filter to flush the scan entries 134 * 135 * Flush scan entries matching the filter. 136 * 137 * Return: QDF status. 138 */ 139 QDF_STATUS scm_flush_results(struct wlan_objmgr_pdev *pdev, 140 struct scan_filter *filter); 141 142 /** 143 * scm_filter_valid_channel() - The Public API to filter scan result 144 * based on valid channel list 145 * @pdev: pdev object 146 * @chan_freq_list: valid channel frequency (in MHz) list 147 * @num_chan: number of valid channels 148 * 149 * The Public API to to filter scan result 150 * based on valid channel list. 151 * 152 * Return: void. 153 */ 154 void scm_filter_valid_channel(struct wlan_objmgr_pdev *pdev, 155 uint32_t *chan_freq_list, uint32_t num_chan); 156 157 /** 158 * scm_iterate_scan_db() - function to iterate scan table 159 * @pdev: pdev object 160 * @func: iterator function pointer 161 * @arg: argument to be passed to func() 162 * 163 * API, this API iterates scan table and invokes func 164 * on each scan enetry by passing scan entry and arg. 165 * 166 * Return: QDF_STATUS 167 */ 168 QDF_STATUS 169 scm_iterate_scan_db(struct wlan_objmgr_pdev *pdev, 170 scan_iterator_func func, void *arg); 171 172 /** 173 * scm_scan_register_bcn_cb() - API to register api to indicate bcn/probe 174 * as soon as they are received 175 * @pdev: psoc 176 * @cb: callback to be registered 177 * @type: Type of callback to be registered 178 * 179 * Return: enum scm_scan_status 180 */ 181 QDF_STATUS scm_scan_register_bcn_cb(struct wlan_objmgr_psoc *psoc, 182 update_beacon_cb cb, enum scan_cb_type type); 183 184 /** 185 * scm_db_init() - API to init scan db 186 * @psoc: psoc 187 * 188 * Return: QDF_STATUS 189 */ 190 QDF_STATUS scm_db_init(struct wlan_objmgr_psoc *psoc); 191 192 /** 193 * scm_db_deinit() - API to deinit scan db 194 * @psoc: psoc 195 * 196 * Return: QDF_STATUS 197 */ 198 QDF_STATUS scm_db_deinit(struct wlan_objmgr_psoc *psoc); 199 200 #ifdef FEATURE_6G_SCAN_CHAN_SORT_ALGO 201 202 /** 203 * scm_get_rnr_channel_db() - API to get rnr db 204 * @psoc: psoc 205 * 206 * Return: rnr db 207 */ 208 struct channel_list_db *scm_get_rnr_channel_db(struct wlan_objmgr_psoc *psoc); 209 210 /** 211 * scm_get_chan_meta() - API to return channel meta 212 * @psoc: psoc 213 * @freq: channel frequency 214 * 215 * Return: channel meta information 216 */ 217 struct meta_rnr_channel *scm_get_chan_meta(struct wlan_objmgr_psoc *psoc, 218 uint32_t chan_freq); 219 220 /** 221 * scm_channel_list_db_init() - API to init scan list priority list db 222 * @psoc: psoc 223 * 224 * Return: QDF_STATUS 225 */ 226 QDF_STATUS scm_channel_list_db_init(struct wlan_objmgr_psoc *psoc); 227 228 /** 229 * scm_channel_list_db_deinit() - API to deinit scan list priority list db 230 * @psoc: psoc 231 * 232 * Return: QDF_STATUS 233 */ 234 QDF_STATUS scm_channel_list_db_deinit(struct wlan_objmgr_psoc *psoc); 235 236 /** 237 * scm_rnr_db_flush() - API to flush rnr entries 238 * @psoc: psoc 239 * 240 * Return: QDF_STATUS 241 */ 242 QDF_STATUS scm_rnr_db_flush(struct wlan_objmgr_psoc *psoc); 243 244 /** 245 * scm_update_rnr_from_scan_cache() - API to update rnr info from scan cache 246 * @pdev: pdev 247 * 248 * Return: void 249 */ 250 void scm_update_rnr_from_scan_cache(struct wlan_objmgr_pdev *pdev); 251 252 /** 253 * scm_filter_rnr_flag_pno() - Remove FLAG_SCAN_ONLY_IF_RNR_FOUND flag 254 * in channel if ssid is different for colocated AP, 255 * during pno scan request 256 * @vdev: vdev 257 * @short_ssid: short ssid 258 * @pno_chan_list: channel list 259 * 260 * Remove FLAG_SCAN_ONLY_IF_RNR_FOUND flag in channel if ssid is different for 261 * colocated AP, in pno scan request 262 * 263 * Return: None 264 */ 265 void 266 scm_filter_rnr_flag_pno(struct wlan_objmgr_vdev *vdev, 267 uint32_t short_ssid, 268 struct chan_list *chan_list); 269 270 #else 271 static inline QDF_STATUS scm_channel_list_db_init(struct wlan_objmgr_psoc *psoc) 272 { 273 return QDF_STATUS_SUCCESS; 274 } 275 276 static inline 277 QDF_STATUS scm_channel_list_db_deinit(struct wlan_objmgr_psoc *psoc) 278 { 279 return QDF_STATUS_SUCCESS; 280 } 281 282 static inline void 283 scm_filter_rnr_flag_pno(struct wlan_objmgr_vdev *vdev, 284 uint32_t short_ssid, 285 struct chan_list *chan_list) 286 { 287 } 288 #endif 289 290 /** 291 * scm_scan_update_mlme_by_bssinfo() - updates scan entry with mlme data 292 * @pdev: pdev object 293 * @bss_info: BSS information 294 * 295 * This function updates scan db with scan_entry->mlme_info 296 * 297 * Return: QDF_STATUS 298 */ 299 QDF_STATUS scm_scan_update_mlme_by_bssinfo(struct wlan_objmgr_pdev *pdev, 300 struct bss_info *bss_info, struct mlme_info *mlme); 301 302 uint32_t scm_get_last_scan_time_per_channel(struct wlan_objmgr_vdev *vdev, 303 uint32_t freq); 304 305 /** 306 * scm_scan_get_entry_by_mac_addr() - Get bcn/probe rsp from scan db 307 * @pdev: pdev info 308 * @bssid: BSSID of the bcn/probe response to be fetched from scan db 309 * @frame: Frame from scan db with given bssid. 310 * 311 * This API allocates the memory for bcn/probe rsp frame and returns 312 * to caller through @frame->ptr. It's caller responsibility to free 313 * the memory once it's done with the usage. 314 * 315 * Return: QDF_STATUS_SUCCESS if scan entry is present in db 316 */ 317 QDF_STATUS 318 scm_scan_get_entry_by_mac_addr(struct wlan_objmgr_pdev *pdev, 319 struct qdf_mac_addr *bssid, 320 struct element_info *frame); 321 322 /** 323 * scm_scan_get_entry_by_bssid() - function to get scan entry by bssid 324 * @pdev: pdev object 325 * @bssid: bssid to be fetched from scan db 326 * 327 * Return : scan entry if found, else NULL 328 */ 329 struct scan_cache_entry * 330 scm_scan_get_entry_by_bssid(struct wlan_objmgr_pdev *pdev, 331 struct qdf_mac_addr *bssid); 332 #endif 333