From patchwork Thu May 6 13:20:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alvin_=C5=A0ipraga?= X-Patchwork-Id: 432449 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 22DFDC43461 for ; Thu, 6 May 2021 13:20:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DF41561157 for ; Thu, 6 May 2021 13:20:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233280AbhEFNVT (ORCPT ); Thu, 6 May 2021 09:21:19 -0400 Received: from mail-eopbgr40096.outbound.protection.outlook.com ([40.107.4.96]:7687 "EHLO EUR03-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S233373AbhEFNVR (ORCPT ); Thu, 6 May 2021 09:21:17 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fVPzJMeLeLymkgik4F/vp1Ij1IWlNMUiP2jvS4q6g6A+qk68hhWuVlhFDecXyt5gaNaUwb6n4ACDZeX68eznk6D3m+G99OiI+J6yE73po3ZL1HAZQXqQU4wJLgnnSf6YbeYLmKeK1Tbloe5FcR9yJ+Hq35u9UrblUccScCue0qIngkkYy/lYyW1jA17VyB6LdnD71rQ1XIJMnOXW6FWk6Wntm3kbQUHbF9Sr1UUPQvxb14cLOe0EJvU042FffPObCl09g6p9Ko1jEmdqvHKqrKeKWSALbrryTP5wSmcFiFsjBF8T94kcHCnPf5niisVn3jMW1XLmyULoxk2m9r5TjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4lewEenWLO8Zmn2QapUJK4lFm1McL1vhuhuStddHt1w=; b=UhIlkGGQVaKn+vAIyqGhNZah1qoy2S67sRDxYYAEF1LSnaqseMvUdFbyHZQUe0nOSZ+aD4MJdhMcLfHMKg9AnZzOMqgT7L89o2hUczeyvpAfLcE9NeBOu2JmCUAw11arY/GiCto5DBjbTnUB9sqXp4SC2oqw8lWfn8/5Lk4FM4YTo2+JnSCz981wrxe8cD1LEx0j0PNcs0GogXviYLEidvE+4LBKMPuuLWHKGCk158N0fkJSzL36KpAe2iqvzTdoCsZvWYIQrO0g4v5h+ZeekRMxMwBGpjNyJW8LIyl6vIauO0L2uepjMCnNwYQAHqIUdFSYwXDHejILLEsJkWEDZQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=bang-olufsen.dk; dmarc=pass action=none header.from=bang-olufsen.dk; dkim=pass header.d=bang-olufsen.dk; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bang-olufsen.dk; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4lewEenWLO8Zmn2QapUJK4lFm1McL1vhuhuStddHt1w=; b=i/kQ6ZzOXWUsA96QfVJp1zHRcOvT4y7RMDnKX4ROyhLGDlxBNR1iSsfniDh1zTMLm6XX+Iv/MmLNL9EON5LR0Kh3ksO7X4HGfmF+OpHm9p1hZyUDZGmrPjSBD2elR7hKJ9zWkCvnNZyG2fJxJmy+lE6D0Nlry1BvnWup/K9Y8xk= Received: from VI1PR03MB3166.eurprd03.prod.outlook.com (2603:10a6:802:32::30) by VI1PR03MB5135.eurprd03.prod.outlook.com (2603:10a6:803:bc::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25; Thu, 6 May 2021 13:20:15 +0000 Received: from VI1PR03MB3166.eurprd03.prod.outlook.com ([fe80::ddd3:cf29:124a:ef1e]) by VI1PR03MB3166.eurprd03.prod.outlook.com ([fe80::ddd3:cf29:124a:ef1e%4]) with mapi id 15.20.4087.044; Thu, 6 May 2021 13:20:15 +0000 From: =?utf-8?q?Alvin_=C5=A0ipraga?= To: Arend van Spriel , Franky Lin , Hante Meuleman , Chi-hsien Lin , Wright Feng , Chung-hsien Hsu , Kalle Valo CC: "linux-wireless@vger.kernel.org" , "brcm80211-dev-list.pdl@broadcom.com" , "SHA-cyfmac-dev-list@infineon.com" , =?utf-8?q?Alvin_=C5=A0ipraga?= Subject: [PATCH 2/2] brcmfmac: correctly report average RSSI in station info Thread-Topic: [PATCH 2/2] brcmfmac: correctly report average RSSI in station info Thread-Index: AQHXQnqLOmBXf+QmGkezfIsJga6FZw== Date: Thu, 6 May 2021 13:20:12 +0000 Message-ID: <20210506132010.3964484-2-alsi@bang-olufsen.dk> References: <20210506132010.3964484-1-alsi@bang-olufsen.dk> In-Reply-To: <20210506132010.3964484-1-alsi@bang-olufsen.dk> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.31.1 authentication-results: gmail.com; dkim=none (message not signed) header.d=none; gmail.com; dmarc=none action=none header.from=bang-olufsen.dk; x-originating-ip: [193.89.194.27] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: d193f3ee-3fe4-4f59-c717-08d91091b00e x-ms-traffictypediagnostic: VI1PR03MB5135: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8273; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: E/vEfCUUSsEmPS6tiY3sZeXueZlhRPHgzxv+ccrFYa7U2LBi0d9EXf6p2zxPBvPe8htbHXyzbtA3XbVmtcSf0kjamur0AVa+2V+l+WSG1gvEkBpPar68qCU6bzC09Sc3gTjRGhOX/0A1bSr1vXli1DBz9bGZ+8l9Wnu+71NLVlGzGv2cYAXitvxHCPvrOaZtRdt5MAcAlLba5WfDptBOS6Uk/VvM3VzPHGiEfqUfaKZuRFron6KNsNCCzdd4yoelf/5Tbl93pPKq1mBsfFtqBJuTQQPxTsUe3tVvofoomkh4y75lxbJmbC2cnxXBiiogEREnhLufDFYO2GCt5pgCNX+Z5iZRxJ6jQwvgb364Hs6vKPFsqRhfbdIIXTr2/VvT0fPhv++5vXXvvQNaNBAzvzbMcOgtwY3iuaukwt9BXRXKPxLP7KE1uMg+6jgJuOPm6rePCm1ZTCQbMl8lyDtC920ttLWeAcCIKa2Eex1/I5rELihVRYZ50E+oZBjuS2nS6yc2/jzNTQI/Afq4Tg7x0EFzpzFXffyQ/o6I68Ek9GVP68ajaa1sL1jNnYW60lvyMuaTfUYhzcqnHW8rNYlPNcI/8xeY8YxUo5JSEO7E60g= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR03MB3166.eurprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39850400004)(366004)(136003)(376002)(346002)(396003)(110136005)(4326008)(107886003)(186003)(1076003)(66476007)(6506007)(85202003)(2906002)(478600001)(64756008)(54906003)(83380400001)(76116006)(316002)(6666004)(66946007)(66556008)(66446008)(36756003)(6486002)(5660300002)(71200400001)(122000001)(2616005)(8936002)(86362001)(6512007)(8676002)(8976002)(85182001)(38100700002)(7416002)(91956017)(26005); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: =?utf-8?q?xGXd9eH5wJfiior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qIZQbYbZ2PP8awQ24w3s9XK4e?= =?utf-8?q?rtYIQi5zY4v9m3iFLBzon7rY5m1dBH2B8W7A6zYIHT+R9eS08nAIwUEk?= =?utf-8?q?VkYyW9S/RoLhrI2UU/FFMus8q2ff71c7dHddv6xT9s4YFMyD6HQfkE3s?= =?utf-8?q?Y9ltgsNfJm+LSEgdx4IXk7d0VyvOrg+tqrQAkd/TVoQNT7gG6wwWl7Gm?= =?utf-8?q?HSHy4hIxNzJPNc1mntwYgjo3lWKQ+5w+iifIMJjDWENnlwMDJ78xI3H5?= =?utf-8?q?0psv3tJQdYFyKrfLZXKjwu0HqpuIQtB4v+V1JG5qhoRLn+u3+twW8nfq?= =?utf-8?q?NSQk7FMmFTJE4ZtIFZi7W5SY/rm4OWiY6lCQpbsW4GIDDuOn1QoQRR6D?= =?utf-8?q?WUYwF/zMN+b+caSY7ZruVyltqiXKH66IFbMB43L3MYOiK5huBhrQk9Gb?= =?utf-8?q?dK2d/Zke3a/vw5nk7zhNhqzSzy20B?= Content-ID: MIME-Version: 1.0 X-OriginatorOrg: bang-olufsen.dk X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: VI1PR03MB3166.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: d193f3ee-3fe4-4f59-c717-08d91091b00e X-MS-Exchange-CrossTenant-originalarrivaltime: 06 May 2021 13:20:13.0033 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 210d08b8-83f7-470a-bc96-381193ca14a1 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 0kHpkuqDMnCnkJs4b/iJBuk8J2ObMNNUDzyGHGsUZkwrWdUhKf7hmVeO1TTBdr5kZcAD8vwUAPyg+/rCWuPKZA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR03MB5135 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org The rx_lastpkt_rssi field provided by the firmware is suitable for NL80211_STA_INFO_{SIGNAL,CHAIN_SIGNAL}, while the rssi field is an average. Fix up the assignments and set the correct STA_INFO bits. This lets userspace know that the average RSSI is part of the station info. Signed-off-by: Alvin Šipraga Fixes: cae355dc90db ("brcmfmac: Add RSSI information to get_station.") --- .../broadcom/brcm80211/brcmfmac/cfg80211.c | 36 ++++++++++--------- 1 file changed, 20 insertions(+), 16 deletions(-) -- 2.31.1 diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c index afa75cb83221..d8822a01d277 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c @@ -2767,8 +2767,9 @@ brcmf_cfg80211_get_station(struct wiphy *wiphy, struct net_device *ndev, struct brcmf_sta_info_le sta_info_le; u32 sta_flags; u32 is_tdls_peer; - s32 total_rssi; - s32 count_rssi; + s32 total_rssi_avg = 0; + s32 total_rssi = 0; + s32 count_rssi = 0; int rssi; u32 i; @@ -2834,24 +2835,27 @@ brcmf_cfg80211_get_station(struct wiphy *wiphy, struct net_device *ndev, sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_BYTES); sinfo->rx_bytes = le64_to_cpu(sta_info_le.rx_tot_bytes); } - total_rssi = 0; - count_rssi = 0; for (i = 0; i < BRCMF_ANT_MAX; i++) { - if (sta_info_le.rssi[i]) { - sinfo->chains |= BIT(count_rssi); - sinfo->chain_signal_avg[count_rssi] = - sta_info_le.rssi[i]; - sinfo->chain_signal[count_rssi] = - sta_info_le.rssi[i]; - total_rssi += sta_info_le.rssi[i]; - count_rssi++; - } + if (sta_info_le.rssi[i] == 0 || + sta_info_le.rx_lastpkt_rssi[i] == 0) + continue; + sinfo->chains |= BIT(count_rssi); + sinfo->chain_signal[count_rssi] = + sta_info_le.rx_lastpkt_rssi[i]; + sinfo->chain_signal_avg[count_rssi] = + sta_info_le.rssi[i]; + total_rssi += sta_info_le.rx_lastpkt_rssi[i]; + total_rssi_avg += sta_info_le.rssi[i]; + count_rssi++; } if (count_rssi) { - sinfo->filled |= BIT_ULL(NL80211_STA_INFO_CHAIN_SIGNAL); sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL); - total_rssi /= count_rssi; - sinfo->signal = total_rssi; + sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL_AVG); + sinfo->filled |= BIT_ULL(NL80211_STA_INFO_CHAIN_SIGNAL); + sinfo->filled |= + BIT_ULL(NL80211_STA_INFO_CHAIN_SIGNAL_AVG); + sinfo->signal = total_rssi / count_rssi; + sinfo->signal_avg = total_rssi_avg / count_rssi; } else if (test_bit(BRCMF_VIF_STATUS_CONNECTED, &ifp->vif->sme_state)) { memset(&scb_val, 0, sizeof(scb_val));