From patchwork Mon May 22 16:09:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Enric Balletbo i Serra X-Patchwork-Id: 9740951 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 36A496034C for ; Mon, 22 May 2017 16:10:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 27F392871B for ; Mon, 22 May 2017 16:10:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1C6E128722; Mon, 22 May 2017 16:10:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8B0CD2871B for ; Mon, 22 May 2017 16:10:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759086AbdEVQKB (ORCPT ); Mon, 22 May 2017 12:10:01 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:53590 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760430AbdEVQJ6 (ORCPT ); Mon, 22 May 2017 12:09:58 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: eballetbo) with ESMTPSA id B923426037D From: Enric Balletbo i Serra To: Johannes Berg , "David S . Miller" , linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Dmitry Shmidt , helmut.schaa@googlemail.com Subject: [PATCH] cfg80211: Be able to set bss expire time at config stage. Date: Mon, 22 May 2017 18:09:46 +0200 Message-Id: <20170522160946.2057-1-enric.balletbo@collabora.com> X-Mailer: git-send-email 2.9.3 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The IEEE80211_SCAN_RESULT_EXPIRE value was modified several times in the past. Initially was set at 10 seconds (2a51931192), then increased at 15 seconds (09f97e0fc4) and finally to 30 seconds (f9616e0f88) to cover the use case when a station is having heavy uplink traffic. On some devices, like Chromebooks, this value is decreased to 7 seconds to avoid stall results, and other devices prefer set to 15 seconds. This simple patch tries to make the selection of this value a bit more flexible by being able to set the expire time at config stage. Most users can leave the default value set as 30 seconds, others can modify the value at config stage if they want lower or bigger values. Signed-off-by: Enric Balletbo i Serra --- net/wireless/Kconfig | 11 +++++++++++ net/wireless/core.c | 2 ++ net/wireless/core.h | 1 + net/wireless/scan.c | 6 ++---- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/net/wireless/Kconfig b/net/wireless/Kconfig index 6c60612..2a54e28 100644 --- a/net/wireless/Kconfig +++ b/net/wireless/Kconfig @@ -29,6 +29,17 @@ config CFG80211 When built as a module it will be called cfg80211. +config CFG80211_SCAN_RESULT_EXPIRE + int "Scan completion time" if CFG80211 + default 30 + ---help--- + This value is the time in seconds the mac80211 scan method needs + to finish. An expiration time to 30 seconds should be sufficient + for most cases but for some other cases we might be interested in + tweak this value. + + If unsure, leave the default of 30. + config NL80211_TESTMODE bool "nl80211 testmode command" depends on CFG80211 diff --git a/net/wireless/core.c b/net/wireless/core.c index 83ea164..2a5742c 100644 --- a/net/wireless/core.c +++ b/net/wireless/core.c @@ -499,6 +499,8 @@ struct wiphy *wiphy_new_nm(const struct cfg80211_ops *ops, int sizeof_priv, init_waitqueue_head(&rdev->dev_wait); + rdev->scan_result_expire = CONFIG_CFG80211_SCAN_RESULT_EXPIRE; + /* * Initialize wiphy parameters to IEEE 802.11 MIB default values. * Fragmentation and RTS threshold are disabled by default with the diff --git a/net/wireless/core.h b/net/wireless/core.h index 6e809325..6a8a164 100644 --- a/net/wireless/core.h +++ b/net/wireless/core.h @@ -72,6 +72,7 @@ struct cfg80211_registered_device { struct rb_root bss_tree; u32 bss_generation; u32 bss_entries; + unsigned int scan_result_expire; struct cfg80211_scan_request *scan_req; /* protected by RTNL */ struct sk_buff *scan_msg; struct list_head sched_scan_req_list; diff --git a/net/wireless/scan.c b/net/wireless/scan.c index 14d5f0c..f0b55a9 100644 --- a/net/wireless/scan.c +++ b/net/wireless/scan.c @@ -70,8 +70,6 @@ module_param(bss_entries_limit, int, 0644); MODULE_PARM_DESC(bss_entries_limit, "limit to number of scan BSS entries (per wiphy, default 1000)"); -#define IEEE80211_SCAN_RESULT_EXPIRE (30 * HZ) - static void bss_free(struct cfg80211_internal_bss *bss) { struct cfg80211_bss_ies *ies; @@ -476,7 +474,7 @@ void cfg80211_bss_age(struct cfg80211_registered_device *rdev, void cfg80211_bss_expire(struct cfg80211_registered_device *rdev) { - __cfg80211_bss_expire(rdev, jiffies - IEEE80211_SCAN_RESULT_EXPIRE); + __cfg80211_bss_expire(rdev, jiffies - rdev->scan_result_expire); } const u8 *cfg80211_find_ie_match(u8 eid, const u8 *ies, int len, @@ -737,7 +735,7 @@ struct cfg80211_bss *cfg80211_get_bss(struct wiphy *wiphy, if (!is_valid_ether_addr(bss->pub.bssid)) continue; /* Don't get expired BSS structs */ - if (time_after(now, bss->ts + IEEE80211_SCAN_RESULT_EXPIRE) && + if (time_after(now, bss->ts + rdev->scan_result_expire) && !atomic_read(&bss->hold)) continue; if (is_bss(&bss->pub, bssid, ssid, ssid_len)) {