From patchwork Thu Aug 25 04:09:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Wang X-Patchwork-Id: 12954167 X-Patchwork-Delegate: nbd@nbd.name Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 78C85C04AA5 for ; Thu, 25 Aug 2022 04:10:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230127AbiHYEKI (ORCPT ); Thu, 25 Aug 2022 00:10:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229437AbiHYEKH (ORCPT ); Thu, 25 Aug 2022 00:10:07 -0400 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 941A180011 for ; Wed, 24 Aug 2022 21:10:05 -0700 (PDT) X-UUID: a417e035550c4c09a0c8dcaba7aa0da6-20220825 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=3fp/5xwv376cjHNs+j3S4zFWc9y6yzeeTVroRO5+4fc=; b=bb80r28fuP73JdE9ubLTJ6J+4z5sgUvipkDsL3LBTubsDgKsPRIFSEvzECVPWQcm5dq7Bj3gYW0W5Itu+uy0ILlUMgYNQS28caSdn/tzWdjkd3KPtkabYvzkaA/oovN59aP/eYovNFnsiox+EW2+RO3JSjtSR6aYgVwx5OktDN0=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.10,REQID:9d2b801d-179c-4a54-aa51-c983e538e3e2,OB:10, LOB:10,IP:0,URL:0,TC:0,Content:0,EDM:0,RT:0,SF:100,FILE:0,BULK:0,RULE:Rele ase_Ham,ACTION:release,TS:100 X-CID-INFO: VERSION:1.1.10,REQID:9d2b801d-179c-4a54-aa51-c983e538e3e2,OB:10,LO B:10,IP:0,URL:0,TC:0,Content:0,EDM:0,RT:0,SF:100,FILE:0,BULK:0,RULE:Spam_G S981B3D,ACTION:quarantine,TS:100 X-CID-META: VersionHash:84eae18,CLOUDID:529d8bcf-20bd-4e5e-ace8-00692b7ab380,C OID:be194563f02c,Recheck:0,SF:28|17|19|48,TC:nil,Content:0,EDM:-3,IP:nil,U RL:11|1,File:nil,Bulk:40,QS:nil,BEC:nil,COL:0 X-UUID: a417e035550c4c09a0c8dcaba7aa0da6-20220825 Received: from mtkcas10.mediatek.inc [(172.21.101.39)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1835863810; Thu, 25 Aug 2022 12:09:59 +0800 Received: from mtkcas11.mediatek.inc (172.21.101.40) by MTKMBS09N1.mediatek.inc (172.21.101.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.792.15; Thu, 25 Aug 2022 12:09:58 +0800 Received: from mtkswgap22.mediatek.inc (172.21.77.33) by mtkcas11.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 25 Aug 2022 12:09:58 +0800 From: To: , CC: , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH] mt76: mt7921: reset msta->airtime_ac while clearing up hw value Date: Thu, 25 Aug 2022 12:09:57 +0800 Message-ID: X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Sean Wang We should reset mstat->airtime_ac along with clear up the entries in the hardware WLAN table for the Rx and Rx accumulative airtime. Otherwsie, the value msta->airtime_ac - [tx, rx]_last may be a negative and that is not the actual airtime the device took in the last run. Reported-by: YN Chen Signed-off-by: Sean Wang --- drivers/net/wireless/mediatek/mt76/mt7921/mac.c | 15 ++++++++++----- drivers/net/wireless/mediatek/mt76/mt7921/main.c | 9 +++------ .../net/wireless/mediatek/mt76/mt7921/mt7921.h | 2 ++ 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c index 47f0aa81ab02..87dd0babff7a 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c @@ -46,6 +46,14 @@ bool mt7921_mac_wtbl_update(struct mt7921_dev *dev, int idx, u32 mask) 0, 5000); } +void mt7921_mac_sta_airtime_clear(struct mt7921_dev *dev, + struct mt7921_sta *msta) +{ + mt7921_mac_wtbl_update(dev, msta->wcid.idx, + MT_WTBL_UPDATE_ADM_COUNT_CLEAR); + memset(msta->airtime_ac, 0, sizeof(msta->airtime_ac)); +} + void mt7921_mac_sta_poll(struct mt7921_dev *dev) { static const u8 ac_to_tid[] = { @@ -100,11 +108,8 @@ void mt7921_mac_sta_poll(struct mt7921_dev *dev) addr += 8; } - if (clear) { - mt7921_mac_wtbl_update(dev, idx, - MT_WTBL_UPDATE_ADM_COUNT_CLEAR); - memset(msta->airtime_ac, 0, sizeof(msta->airtime_ac)); - } + if (clear) + mt7921_mac_sta_airtime_clear(dev, msta); if (!msta->wcid.sta) continue; diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net/wireless/mediatek/mt76/mt7921/main.c index 1438a9f8d1fd..9d70884e24af 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c @@ -723,8 +723,7 @@ int mt7921_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif, if (vif->type == NL80211_IFTYPE_STATION) mvif->wep_sta = msta; - mt7921_mac_wtbl_update(dev, idx, - MT_WTBL_UPDATE_ADM_COUNT_CLEAR); + mt7921_mac_sta_airtime_clear(dev, msta); ret = mt7921_mcu_sta_update(dev, sta, vif, true, MT76_STA_INFO_STATE_NONE); @@ -750,8 +749,7 @@ void mt7921_mac_sta_assoc(struct mt76_dev *mdev, struct ieee80211_vif *vif, mt76_connac_mcu_uni_add_bss(&dev->mphy, vif, &mvif->sta.wcid, true); - mt7921_mac_wtbl_update(dev, msta->wcid.idx, - MT_WTBL_UPDATE_ADM_COUNT_CLEAR); + mt7921_mac_sta_airtime_clear(dev, msta); mt7921_mcu_sta_update(dev, sta, vif, true, MT76_STA_INFO_STATE_ASSOC); @@ -769,8 +767,7 @@ void mt7921_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif, mt76_connac_pm_wake(&dev->mphy, &dev->pm); mt7921_mcu_sta_update(dev, sta, vif, false, MT76_STA_INFO_STATE_NONE); - mt7921_mac_wtbl_update(dev, msta->wcid.idx, - MT_WTBL_UPDATE_ADM_COUNT_CLEAR); + mt7921_mac_sta_airtime_clear(dev, msta); if (vif->type == NL80211_IFTYPE_STATION) { struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv; diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h index c161031ac62a..8b704d08509d 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h @@ -362,6 +362,8 @@ void mt7921_stop(struct ieee80211_hw *hw); int mt7921_mac_init(struct mt7921_dev *dev); bool mt7921_mac_wtbl_update(struct mt7921_dev *dev, int idx, u32 mask); void mt7921_mac_reset_counters(struct mt7921_phy *phy); +void mt7921_mac_sta_airtime_clear(struct mt7921_dev *dev, + struct mt7921_sta *msta); void mt7921_mac_set_timing(struct mt7921_phy *phy); int mt7921_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif, struct ieee80211_sta *sta);