From e2be5043108964bf3f48d65cbb247dda30073ffa Mon Sep 17 00:00:00 2001 From: Abhishek Singh Date: Thu, 9 Mar 2017 16:06:45 +0530 Subject: qcacld-3.0: Consider RSSI while purging scan result qcacld-2.0 to qcacld-3.0 propagation When scan cache is full and new BSS is added, oldest BSS is removed. Thus if num of BSS in environment are more than scan cache size the BSSes which are scanned on initial channels are removed. Also low RSSI APs may still be present in scan cache while APs with good RSSI are removed. To fix if entry with RSSI less than CSR_PURGE_RSSI_THRESHOLD remove it. If all entries RSSI is better than CSR_PURGE_RSSI_THRESHOLD remove the oldest entry. And thus APs with bad RSS will be removed first. Change-Id: I795d12aaea28d6acb5103eb25ba3758796643383 CRs-Fixed: 2010211 --- core/sme/src/csr/csr_api_scan.c | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/core/sme/src/csr/csr_api_scan.c b/core/sme/src/csr/csr_api_scan.c index a810f1436f1d..8338b3f4b116 100644 --- a/core/sme/src/csr/csr_api_scan.c +++ b/core/sme/src/csr/csr_api_scan.c @@ -71,6 +71,7 @@ #define HIDDEN_TIMER (1*60*1000) #define CSR_SCAN_RESULT_RSSI_WEIGHT 80 /* must be less than 100, represent the persentage of new RSSI */ +#define CSR_PURGE_RSSI_THRESHOLD -70 #define MAX_ACTIVE_SCAN_FOR_ONE_CHANNEL 140 #define MIN_ACTIVE_SCAN_FOR_ONE_CHANNEL 120 @@ -2868,20 +2869,23 @@ static bool csr_process_bss_desc_for_bkid_list(tpAniSirGlobal pMac, #endif /** - * csr_purge_old_scan_results() - This function removes old scan entries + * csr_purge_scan_results() - This function removes scan entry based + * on RSSI or AGE * @mac_ctx: pointer to Global MAC structure * - * This function removes old scan entries + * This function removes scan entry based on RSSI or AGE. + * If an scan entry with RSSI less than CSR_PURGE_RSSI_THRESHOLD, + * the scan entry is removed else oldest entry is removed. * * Return: None */ - -static void csr_purge_old_scan_results(tpAniSirGlobal mac_ctx) +static void csr_purge_scan_results(tpAniSirGlobal mac_ctx) { tListElem *pentry, *tmp_entry; - tCsrScanResult *presult, *oldest_bss = NULL; + tCsrScanResult *presult, *oldest_bss = NULL, *weakest_bss = NULL; uint64_t oldest_entry = 0; uint64_t curr_time = (uint64_t)qdf_mc_timer_get_system_time(); + int8_t weakest_rssi = 0; csr_ll_unlock(&mac_ctx->scan.scanResultList); pentry = csr_ll_peek_head(&mac_ctx->scan.scanResultList, @@ -2896,19 +2900,31 @@ static void csr_purge_old_scan_results(tpAniSirGlobal mac_ctx) presult->Result.BssDescriptor.received_time; oldest_bss = presult; } + if (presult->Result.BssDescriptor.rssi < weakest_rssi) { + weakest_rssi = presult->Result.BssDescriptor.rssi; + weakest_bss = presult; + } pentry = tmp_entry; } if (oldest_bss) { + tCsrScanResult *bss_to_remove; + + if (weakest_rssi < CSR_PURGE_RSSI_THRESHOLD) + bss_to_remove = weakest_bss; + else + bss_to_remove = oldest_bss; /* Free the old BSS Entries */ if (csr_ll_remove_entry(&mac_ctx->scan.scanResultList, - &oldest_bss->Link, LL_ACCESS_NOLOCK)) { + &bss_to_remove->Link, LL_ACCESS_NOLOCK)) { sms_log(mac_ctx, LOGD, - FL("Current time delta (%llu) of BSSID to be removed" MAC_ADDRESS_STR), - (curr_time - - oldest_bss->Result.BssDescriptor.received_time), + FL("BSSID: "MAC_ADDRESS_STR" Removed, time delta (%llu) RSSI %d"), MAC_ADDR_ARRAY( - oldest_bss->Result.BssDescriptor.bssId)); - csr_free_scan_result_entry(mac_ctx, oldest_bss); + bss_to_remove->Result.BssDescriptor.bssId), + (curr_time - + bss_to_remove-> + Result.BssDescriptor.received_time), + bss_to_remove->Result.BssDescriptor.rssi); + csr_free_scan_result_entry(mac_ctx, bss_to_remove); } } csr_ll_unlock(&mac_ctx->scan.scanResultList); @@ -2958,7 +2974,7 @@ csr_remove_from_tmp_list(tpAniSirGlobal mac_ctx, */ if (CSR_SCAN_IS_OVER_BSS_LIMIT(mac_ctx)) { sms_log(mac_ctx, LOGD, FL("BSS Limit reached")); - csr_purge_old_scan_results(mac_ctx); + csr_purge_scan_results(mac_ctx); } /* check for duplicate scan results */ if (!dup_bss) { -- cgit v1.2.3