From cb573e0592d25ef31158ad361433a3f80acbbe53 Mon Sep 17 00:00:00 2001 From: Paul Zhang Date: Tue, 6 Nov 2018 10:37:16 +0800 Subject: [PATCH] qcacld-3.0: Fix false alarm scan reject issue Currently, the scan is rejected if connection is in progress. And it uses last_scan_reject_timestamp and reset scan_reject_cnt to avoid scan stuck issue. last_scan_reject_timestamp and scan_reject_cnt reset when the next scan issues successfully. If: 1\ Scan happens and connection is in progress. Initialized last_scan_reject_timestamp and reset scan_reject_cnt; 2\ Maybe no scan happens for a long time; 3\ scan happens but unfortunately connection is in progress again. Then false alarm may happen because the time has already expired and scan_reject_cnt >= 15. Reset scan reject params if connection is success or it receives final failure from CSR after trying with all APs. Change-Id: Icd72d1d2c0adee8bb5b5b9c6537e1c48e37a7121 CRs-Fixed: 2333283 --- core/hdd/src/wlan_hdd_assoc.c | 7 +++++++ core/hdd/src/wlan_hdd_power.c | 5 +---- core/hdd/src/wlan_hdd_scan.c | 28 ++++++++++++++++++++++++---- core/hdd/src/wlan_hdd_scan.h | 22 +++++++++++++++++++++- 4 files changed, 53 insertions(+), 9 deletions(-) diff --git a/core/hdd/src/wlan_hdd_assoc.c b/core/hdd/src/wlan_hdd_assoc.c index 8ccda9788514..91d1fb609e35 100644 --- a/core/hdd/src/wlan_hdd_assoc.c +++ b/core/hdd/src/wlan_hdd_assoc.c @@ -61,6 +61,7 @@ #include "wlan_p2p_ucfg_api.h" #include "wlan_ipa_ucfg_api.h" #include "wlan_hdd_stats.h" +#include "wlan_hdd_scan.h" #include "wlan_hdd_nud_tracking.h" /* These are needed to recognize WPA and RSN suite types */ @@ -2740,6 +2741,12 @@ hdd_association_completion_handler(struct hdd_adapter *adapter, return QDF_STATUS_E_NULL_VALUE; } + /* + * reset scan reject params if connection is success or we received + * final failure from CSR after trying with all APs. + */ + hdd_reset_scan_reject_params(hdd_ctx, roamStatus, roamResult); + /* * Enable roaming on other STA iface except this one. * Firmware dosent support connection on one STA iface while diff --git a/core/hdd/src/wlan_hdd_power.c b/core/hdd/src/wlan_hdd_power.c index 7eae7ccf5982..6bdbd0867574 100644 --- a/core/hdd/src/wlan_hdd_power.c +++ b/core/hdd/src/wlan_hdd_power.c @@ -1408,10 +1408,7 @@ QDF_STATUS hdd_wlan_re_init(void) /* Restart all adapters */ hdd_start_all_adapters(hdd_ctx); - hdd_ctx->last_scan_reject_session_id = 0xFF; - hdd_ctx->last_scan_reject_reason = 0; - hdd_ctx->last_scan_reject_timestamp = 0; - hdd_ctx->scan_reject_cnt = 0; + hdd_init_scan_reject_params(hdd_ctx); hdd_set_roaming_in_progress(false); complete(&adapter->roaming_comp_var); diff --git a/core/hdd/src/wlan_hdd_scan.c b/core/hdd/src/wlan_hdd_scan.c index a6c25b394054..6059f7c09621 100644 --- a/core/hdd/src/wlan_hdd_scan.c +++ b/core/hdd/src/wlan_hdd_scan.c @@ -322,6 +322,28 @@ void wlan_hdd_cfg80211_scan_block_cb(struct work_struct *work) cds_ssr_unprotect(__func__); } +void hdd_init_scan_reject_params(struct hdd_context *hdd_ctx) +{ + if (hdd_ctx) { + hdd_ctx->last_scan_reject_timestamp = 0; + hdd_ctx->last_scan_reject_session_id = 0xFF; + hdd_ctx->last_scan_reject_reason = 0; + hdd_ctx->scan_reject_cnt = 0; + } +} + +void hdd_reset_scan_reject_params(struct hdd_context *hdd_ctx, + eRoamCmdStatus roam_status, + eCsrRoamResult roam_result) +{ + if ((roam_status == eCSR_ROAM_ASSOCIATION_FAILURE) || + (roam_status == eCSR_ROAM_CANCELLED) || + (roam_result == eCSR_ROAM_RESULT_ASSOCIATED)) { + hdd_debug("Reset scan reject params"); + hdd_init_scan_reject_params(hdd_ctx); + } +} + /* * wlan_hdd_update_scan_ies() - API to update the scan IEs of scan request * with already stored default scan IEs @@ -594,10 +616,8 @@ static int __wlan_hdd_cfg80211_scan(struct wiphy *wiphy, } return -EBUSY; } - hdd_ctx->last_scan_reject_timestamp = 0; - hdd_ctx->last_scan_reject_session_id = 0xFF; - hdd_ctx->last_scan_reject_reason = 0; - hdd_ctx->scan_reject_cnt = 0; + + hdd_init_scan_reject_params(hdd_ctx); /* Check whether SAP scan can be skipped or not */ if (adapter->device_mode == QDF_SAP_MODE && diff --git a/core/hdd/src/wlan_hdd_scan.h b/core/hdd/src/wlan_hdd_scan.h index 302d222f1a99..bcc874b43be3 100644 --- a/core/hdd/src/wlan_hdd_scan.h +++ b/core/hdd/src/wlan_hdd_scan.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2017 The Linux Foundation. All rights reserved. + * Copyright (c) 2012-2018 The Linux Foundation. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -115,6 +115,26 @@ void wlan_hdd_cfg80211_abort_scan(struct wiphy *wiphy, struct wireless_dev *wdev); #endif +/** + * hdd_init_scan_reject_params() - init scan reject params + * @hdd_ctx: hdd contxt + * + * Return: None + */ +void hdd_init_scan_reject_params(struct hdd_context *hdd_ctx); + +/** + * hdd_reset_scan_reject_params() - reset scan reject params per roam stats + * @hdd_ctx: hdd contxt + * @roam_status: roam status + * @roam_result: roam result + * + * Return: None + */ +void hdd_reset_scan_reject_params(struct hdd_context *hdd_ctx, + eRoamCmdStatus roam_status, + eCsrRoamResult roam_result); + /** * wlan_hdd_cfg80211_scan_block_cb() - scan block work handler * @work: Pointer to work