From patchwork Wed Mar 14 16:58:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Pierre TOSONI X-Patchwork-Id: 10282871 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 C7146602C2 for ; Wed, 14 Mar 2018 16:58:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B76B428492 for ; Wed, 14 Mar 2018 16:58:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AB8332847D; Wed, 14 Mar 2018 16:58:44 +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,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI 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 5F3D92847D for ; Wed, 14 Mar 2018 16:58:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751695AbeCNQ6m (ORCPT ); Wed, 14 Mar 2018 12:58:42 -0400 Received: from mail-ve1eur01on0100.outbound.protection.outlook.com ([104.47.1.100]:58986 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751289AbeCNQ6j (ORCPT ); Wed, 14 Mar 2018 12:58:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ACKSYS.onmicrosoft.com; s=selector1-acksys-fr; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=YEeTIvGBqnGLD9y4Uzr/q3opAQdGva2nSNUdDjEbi6A=; b=VP5NBP/9neJMbkYVbtWPpckaBB25mKkwfQu5G3+FlYAK9KkQOPTxBxxBfMKVnteUDP0cZOs/0UkhIdltmtoItNiiTERt/LsaxDmNWnlzajLP8BBB5OPw4YyeUcz4PEzx83e8+UYNn6VYDBP1V2TScdTNRJ9YRcmgrRkIqbaI2q8= Received: from AM4PR0101MB2305.eurprd01.prod.exchangelabs.com (10.165.38.134) by AM4PR0101MB1651.eurprd01.prod.exchangelabs.com (10.166.129.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.548.13; Wed, 14 Mar 2018 16:58:34 +0000 Received: from AM4PR0101MB2305.eurprd01.prod.exchangelabs.com ([fe80::f938:2cea:e30d:8203]) by AM4PR0101MB2305.eurprd01.prod.exchangelabs.com ([fe80::f938:2cea:e30d:8203%2]) with mapi id 15.20.0567.018; Wed, 14 Mar 2018 16:58:35 +0000 From: Jean Pierre TOSONI To: Johannes Berg , "linux-wireless@vger.kernel.org" Subject: [PATCH v2 resend] mac80211: inform wireless layer when frame RSSI is invalid Thread-Topic: [PATCH v2 resend] mac80211: inform wireless layer when frame RSSI is invalid Thread-Index: AdO7tOrKNqM8w1k6Q3SlMAbtl1Zf7A== Date: Wed, 14 Mar 2018 16:58:34 +0000 Message-ID: Accept-Language: fr-FR, en-US Content-Language: fr-FR X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=jp.tosoni@acksys.fr; x-originating-ip: [195.6.104.67] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM4PR0101MB1651; 7:EixVWu/4Y+dJyiNe7Kq5bYqC6gf8U+lc8vLMk6AjmR02k87CV95HIykN3ZEGwUNyrt6M7EL9/898yHQDlLi1T3GgsLRvAc+a69VhcVjlnhtSuUJIUzVqaX5G6k4ykuVo7kfyLrtj7oWjnek5cjKFmHtkACMw5BHQEZZKYX1sJ9dflF+rFrCLCRwsO811ey2S6BI+JAC/aN4B9Td0HZNg63wMxLnIxInv8CY2t1CQVb7Smi8WwItlOM1uM08yY6se x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-correlation-id: aeda61a1-059d-45e5-0493-08d589ccd31e x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(7021125)(5600026)(4604075)(3008032)(4534165)(7022125)(4603075)(4627221)(201702281549075)(7048125)(7024125)(7027125)(7028125)(7023125)(2017052603328)(7153060)(7193020); SRVR:AM4PR0101MB1651; x-ms-traffictypediagnostic: AM4PR0101MB1651: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(5005006)(8121501046)(3231221)(944501244)(52105095)(93006095)(93001095)(3002001)(10201501046)(6041310)(20161123558120)(2016111802025)(20161123562045)(20161123564045)(20161123560045)(6043046)(6072148)(201708071742011); SRVR:AM4PR0101MB1651; BCL:0; PCL:0; RULEID:; SRVR:AM4PR0101MB1651; x-forefront-prvs: 0611A21987 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(346002)(396003)(376002)(39380400002)(366004)(39840400004)(199004)(189003)(478600001)(25786009)(305945005)(74482002)(74316002)(7736002)(6436002)(3846002)(106356001)(33656002)(2906002)(5660300001)(6116002)(5250100002)(55016002)(2501003)(105586002)(53936002)(66066001)(9686003)(2900100001)(8676002)(3660700001)(81156014)(99286004)(97736004)(68736007)(59450400001)(81166006)(7696005)(186003)(102836004)(6506007)(3280700002)(316002)(110136005)(14454004)(26005)(8936002)(86362001); DIR:OUT; SFP:1102; SCL:1; SRVR:AM4PR0101MB1651; H:AM4PR0101MB2305.eurprd01.prod.exchangelabs.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; received-spf: None (protection.outlook.com: acksys.fr does not designate permitted sender hosts) x-microsoft-antispam-message-info: VWM1uWDzbDMnJqxH16/FariaXQL6KEkhrokgOLRgC9mvGA3YBSbQSaU6IvlVDSYDS6LTj6z/DrmoBNklPepL9Liu3y/QKnu+zkzD/0SwJCHHp3wApUM0lnfNKN4Jz5F+jZTzr5LUd7/UqO2vzpcJS3JzM6aFLgX5C5Oz7cbVgnSiXtfeU+lgvnBm9LssFFc5ilSlAGJsXYds4VfL0YeSmKlXYCATNlbTMSDabNiArEZIf/cN42SKAbL79P56eX+tSPGpXKhCM/7hTuVrBdO+y7STqRK9uUf4LdITLgAxCdpUjNanyI0RKRustjm1LC2YHXXyQDBcZ86d3hQhgCunfw== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: acksys.fr X-MS-Exchange-CrossTenant-Network-Message-Id: aeda61a1-059d-45e5-0493-08d589ccd31e X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Mar 2018 16:58:34.9765 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f18a6414-d5f3-4b5c-9345-f30c01d87e32 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR0101MB1651 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 When the low-level driver returns an invalid RSSI indication, set the signal value to 0 as an indication to the upper layer. Also, skip average level computation if signal is invalid. Signed-off-by: Jean Pierre TOSONI --- @Johannes: what is the status of this patch? Something to improve? V2: Move the beacon rssi processing to a helper function which is called conditionally, instead of jumping over the code with a goto (this makes the code smarter but the patch is much harder to grasp :-) WARNING: This patch applies to wireless-testing retrieved on Feb 26, 2018 but it was tested on a much older version (OpenWrt kernel 3.18 with compat-wireless-2015-07-21). -- 1.7.2.5 ==========----------==========----------==========----------========== net/mac80211/mlme.c | 159 +++++++++++++++++++++++++++------------------------ net/mac80211/rx.c | 6 +- net/mac80211/scan.c | 4 +- 3 files changed, 92 insertions(+), 77 deletions(-) diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index 0024eff..8cb1710 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -3306,82 +3306,14 @@ static void ieee80211_rx_mgmt_probe_resp(struct ieee80211_sub_if_data *sdata, (1ULL << WLAN_EID_HT_OPERATION) | (1ULL << WLAN_EID_EXT_CHANSWITCH_ANN); -static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata, - struct ieee80211_mgmt *mgmt, size_t len, - struct ieee80211_rx_status *rx_status) +static void ieee80211_handle_beacon_signal(struct ieee80211_sub_if_data *sdata, + struct ieee80211_if_managed *ifmgd, + struct ieee80211_bss_conf *bss_conf, + struct ieee80211_local *local, + struct ieee80211_rx_status *rx_status) { - struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; - struct ieee80211_bss_conf *bss_conf = &sdata->vif.bss_conf; - size_t baselen; - struct ieee802_11_elems elems; - struct ieee80211_local *local = sdata->local; - struct ieee80211_chanctx_conf *chanctx_conf; - struct ieee80211_channel *chan; - struct sta_info *sta; - u32 changed = 0; - bool erp_valid; - u8 erp_value = 0; - u32 ncrc; - u8 *bssid; - u8 deauth_buf[IEEE80211_DEAUTH_FRAME_LEN]; - - sdata_assert_lock(sdata); - - /* Process beacon from the current BSS */ - baselen = (u8 *) mgmt->u.beacon.variable - (u8 *) mgmt; - if (baselen > len) - return; - - rcu_read_lock(); - chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); - if (!chanctx_conf) { - rcu_read_unlock(); - return; - } - - if (rx_status->freq != chanctx_conf->def.chan->center_freq) { - rcu_read_unlock(); - return; - } - chan = chanctx_conf->def.chan; - rcu_read_unlock(); - - if (ifmgd->assoc_data && ifmgd->assoc_data->need_beacon && - ether_addr_equal(mgmt->bssid, ifmgd->assoc_data->bss->bssid)) { - ieee802_11_parse_elems(mgmt->u.beacon.variable, - len - baselen, false, &elems); - - ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems); - if (elems.tim && !elems.parse_error) { - const struct ieee80211_tim_ie *tim_ie = elems.tim; - ifmgd->dtim_period = tim_ie->dtim_period; - } - ifmgd->have_beacon = true; - ifmgd->assoc_data->need_beacon = false; - if (ieee80211_hw_check(&local->hw, TIMING_BEACON_ONLY)) { - sdata->vif.bss_conf.sync_tsf = - le64_to_cpu(mgmt->u.beacon.timestamp); - sdata->vif.bss_conf.sync_device_ts = - rx_status->device_timestamp; - if (elems.tim) - sdata->vif.bss_conf.sync_dtim_count = - elems.tim->dtim_count; - else - sdata->vif.bss_conf.sync_dtim_count = 0; - } - /* continue assoc process */ - ifmgd->assoc_data->timeout = jiffies; - ifmgd->assoc_data->timeout_started = true; - run_again(sdata, ifmgd->assoc_data->timeout); - return; - } - - if (!ifmgd->associated || - !ether_addr_equal(mgmt->bssid, ifmgd->associated->bssid)) - return; - bssid = ifmgd->associated->bssid; - /* Track average RSSI from the Beacon frames of the current AP */ + if (ifmgd->flags & IEEE80211_STA_RESET_SIGNAL_AVE) { ifmgd->flags &= ~IEEE80211_STA_RESET_SIGNAL_AVE; ewma_beacon_signal_init(&ifmgd->ave_beacon_signal); @@ -3468,6 +3400,85 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata, sig, GFP_KERNEL); } } +} + +static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata, + struct ieee80211_mgmt *mgmt, size_t len, + struct ieee80211_rx_status *rx_status) +{ + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; + struct ieee80211_bss_conf *bss_conf = &sdata->vif.bss_conf; + size_t baselen; + struct ieee802_11_elems elems; + struct ieee80211_local *local = sdata->local; + struct ieee80211_chanctx_conf *chanctx_conf; + struct ieee80211_channel *chan; + struct sta_info *sta; + u32 changed = 0; + bool erp_valid; + u8 erp_value = 0; + u32 ncrc; + u8 *bssid; + u8 deauth_buf[IEEE80211_DEAUTH_FRAME_LEN]; + + sdata_assert_lock(sdata); + + /* Process beacon from the current BSS */ + baselen = (u8 *) mgmt->u.beacon.variable - (u8 *) mgmt; + if (baselen > len) + return; + + rcu_read_lock(); + chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); + if (!chanctx_conf) { + rcu_read_unlock(); + return; + } + + if (rx_status->freq != chanctx_conf->def.chan->center_freq) { + rcu_read_unlock(); + return; + } + chan = chanctx_conf->def.chan; + rcu_read_unlock(); + + if (ifmgd->assoc_data && ifmgd->assoc_data->need_beacon && + ether_addr_equal(mgmt->bssid, ifmgd->assoc_data->bss->bssid)) { + ieee802_11_parse_elems(mgmt->u.beacon.variable, + len - baselen, false, &elems); + + ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems); + if (elems.tim && !elems.parse_error) { + const struct ieee80211_tim_ie *tim_ie = elems.tim; + ifmgd->dtim_period = tim_ie->dtim_period; + } + ifmgd->have_beacon = true; + ifmgd->assoc_data->need_beacon = false; + if (ieee80211_hw_check(&local->hw, TIMING_BEACON_ONLY)) { + sdata->vif.bss_conf.sync_tsf = + le64_to_cpu(mgmt->u.beacon.timestamp); + sdata->vif.bss_conf.sync_device_ts = + rx_status->device_timestamp; + if (elems.tim) + sdata->vif.bss_conf.sync_dtim_count = + elems.tim->dtim_count; + else + sdata->vif.bss_conf.sync_dtim_count = 0; + } + /* continue assoc process */ + ifmgd->assoc_data->timeout = jiffies; + ifmgd->assoc_data->timeout_started = true; + run_again(sdata, ifmgd->assoc_data->timeout); + return; + } + + if (!ifmgd->associated || + !ether_addr_equal(mgmt->bssid, ifmgd->associated->bssid)) + return; + bssid = ifmgd->associated->bssid; + + if (!(rx_status->flag & RX_FLAG_NO_SIGNAL_VAL)) + ieee80211_handle_beacon_signal(sdata, ifmgd, bss_conf, local, rx_status); if (ifmgd->flags & IEEE80211_STA_CONNECTION_POLL) { mlme_dbg_ratelimited(sdata, diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index 5be957a..0afb8ce 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c @@ -2793,7 +2793,8 @@ static void ieee80211_process_sa_query_req(struct ieee80211_sub_if_data *sdata, !(rx->flags & IEEE80211_RX_BEACON_REPORTED)) { int sig = 0; - if (ieee80211_hw_check(&rx->local->hw, SIGNAL_DBM)) + if (ieee80211_hw_check(&rx->local->hw, SIGNAL_DBM) && + !(status->flag & RX_FLAG_NO_SIGNAL_VAL)) sig = status->signal; cfg80211_report_obss_beacon(rx->local->hw.wiphy, @@ -3134,7 +3135,8 @@ static void ieee80211_process_sa_query_req(struct ieee80211_sub_if_data *sdata, * it transmitted were processed or returned. */ - if (ieee80211_hw_check(&rx->local->hw, SIGNAL_DBM)) + if (ieee80211_hw_check(&rx->local->hw, SIGNAL_DBM) && + !(status->flag & RX_FLAG_NO_SIGNAL_VAL)) sig = status->signal; if (cfg80211_rx_mgmt(&rx->sdata->wdev, status->freq, sig, diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c index ef2beca..a3b1bcc 100644 --- a/net/mac80211/scan.c +++ b/net/mac80211/scan.c @@ -73,7 +73,9 @@ struct ieee80211_bss * bool signal_valid; struct ieee80211_sub_if_data *scan_sdata; - if (ieee80211_hw_check(&local->hw, SIGNAL_DBM)) + if (rx_status->flag & RX_FLAG_NO_SIGNAL_VAL) + bss_meta.signal = 0; /* invalid signal indication */ + else if (ieee80211_hw_check(&local->hw, SIGNAL_DBM)) bss_meta.signal = rx_status->signal * 100; else if (ieee80211_hw_check(&local->hw, SIGNAL_UNSPEC)) bss_meta.signal = (rx_status->signal * 100) / local->hw.max_signal;