From patchwork Tue Oct 19 10:12:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 12569385 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98569C433EF for ; Tue, 19 Oct 2021 10:13:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 781AD6137C for ; Tue, 19 Oct 2021 10:13:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235138AbhJSKPS (ORCPT ); Tue, 19 Oct 2021 06:15:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:58674 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235085AbhJSKPR (ORCPT ); Tue, 19 Oct 2021 06:15:17 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 95DDB6137B; Tue, 19 Oct 2021 10:13:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634638384; bh=uwIxynG4HqzFEAdu6PlgnayApDY4v/p3FDquNNQR8LE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B7dK9NTLvoUWj8p+w3zYP+X6lAjq4th7b/7O3+zCVhRwth7gmB46Hb/QEN3OomZ8R LT4npLgZ5EjQVvex4ITNkN5i3fufqnm6zm7Z186xR3TdlWdb2aCvBqbmFKILyjoTFb FzsMFtK6cH3EvtSbm80QWcFm9Hy17/0g1AvRYSETDMwb0KFpKwqXi1zmXeyYOiadYV 6u5Rctba4wp+QuJDuIt5Qxx+fhRWH02rU+FiyVBx2k40H9VO6qMv8794HHwghzL5D6 rYZ4SkqnhRjtnsHZecOIxcP1xkl9KK4dCHjfZuvFUDqs5xyZzD3EaeBF2r9g5twaFB Y5/11rRXZtUZA== From: Lorenzo Bianconi To: nbd@nbd.name Cc: linux-wireless@vger.kernel.org, lorenzo.bianconi@redhat.com, sean.wang@mediatek.com, greearb@candelatech.com, ryder.lee@mediatek.com Subject: [PATCH v2 01/10] mt76: move mt76_sta_stats in mt76.h Date: Tue, 19 Oct 2021 12:12:23 +0200 Message-Id: <419b5c8fde70ba77603a42c7f86b7127fb567465.1634637742.git.lorenzo@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org This is a preliminary patch to add ethtool stats to mt7921 driver. Signed-off-by: Lorenzo Bianconi --- drivers/net/wireless/mediatek/mt76/mt76.h | 7 +++++++ drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 2 +- drivers/net/wireless/mediatek/mt76/mt7915/main.c | 2 +- drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h | 9 +-------- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h index 32d68ecf4c3a..ae6c3a735f49 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76.h +++ b/drivers/net/wireless/mediatek/mt76/mt76.h @@ -779,6 +779,13 @@ enum mt76_phy_type { __MT_PHY_TYPE_HE_MAX, }; +struct mt76_sta_stats { + u64 tx_mode[__MT_PHY_TYPE_HE_MAX]; + u64 tx_bw[4]; /* 20, 40, 80, 160 */ + u64 tx_nss[4]; /* 1, 2, 3, 4 */ + u64 tx_mcs[16]; /* mcs idx */ +}; + #define CCK_RATE(_idx, _rate) { \ .bitrate = _rate, \ .flags = IEEE80211_RATE_SHORT_PREAMBLE, \ diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c index b992fdd338e2..edf62e0a7ff0 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c @@ -1347,7 +1347,7 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, struct sk_buff *skb) static bool mt7915_mac_add_txs_skb(struct mt7915_dev *dev, struct mt76_wcid *wcid, int pid, - __le32 *txs_data, struct mt7915_sta_stats *stats) + __le32 *txs_data, struct mt76_sta_stats *stats) { struct ieee80211_supported_band *sband; struct mt76_dev *mdev = &dev->mt76; diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/main.c b/drivers/net/wireless/mediatek/mt76/mt7915/main.c index 244133d17cd1..bbf74e7452d8 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/main.c @@ -1199,10 +1199,10 @@ static void mt7915_ethtool_worker(void *wi_data, struct ieee80211_sta *sta) { struct mt7915_ethtool_worker_info *wi = wi_data; struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv; + struct mt76_sta_stats *mstats = &msta->stats; int ei = wi->initial_stat_idx; int q; u64 *data = wi->data; - struct mt7915_sta_stats *mstats = &msta->stats; if (msta->vif != wi->mvif) return; diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h index b09d2c758218..2acede0d5bf2 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h @@ -65,13 +65,6 @@ enum mt7915_rxq_id { MT7915_RXQ_MCU_WA_EXT, }; -struct mt7915_sta_stats { - unsigned long tx_mode[__MT_PHY_TYPE_HE_MAX]; /* See mt76_phy_type */ - unsigned long tx_bw[4]; /* 20, 40, 80, 160 */ - unsigned long tx_nss[4]; /* 1, 2, 3, 4 */ - unsigned long tx_mcs[16]; /* mcs idx */ -}; - struct mt7915_sta_key_conf { s8 keyidx; u8 key[16]; @@ -106,7 +99,7 @@ struct mt7915_sta { unsigned long jiffies; unsigned long ampdu_state; - struct mt7915_sta_stats stats; + struct mt76_sta_stats stats; struct mt7915_sta_key_conf bip; From patchwork Tue Oct 19 10:12:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 12569387 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7280C433F5 for ; Tue, 19 Oct 2021 10:13:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 84D5A6137B for ; Tue, 19 Oct 2021 10:13:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235152AbhJSKPX (ORCPT ); Tue, 19 Oct 2021 06:15:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:58698 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235150AbhJSKPU (ORCPT ); Tue, 19 Oct 2021 06:15:20 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 11CD761374; Tue, 19 Oct 2021 10:13:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634638388; bh=lMYbLm4buof14xRT4477wVXZ/86S0QxT/PfVtKW3bFk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OD9wO7hcvxQOMCPUt5ZNxDro/XbIJzOLCctyxLn8QDVvaGIY0Gk+epWjBIqRpUGxz fTlvCStD7U5B4ZxyWFfV0MTW0Tod42+kMKvu8uDV9IQGbkqFCvvJi0s69V0tR1T7iw pHBw5kOYFr4GizH5PpKLFGiLo4qSY6w1QWX9THdFIE90pEa5k3OPJC+F4xm6T3A2eq u6XJQO0D47wpDE8yN7uG+rg+B4up8XsO6oNZTeswXMQrEUptiRMb0t5PKzdRwui22G lyM4iGei8pVb8ZUpPPq2JOuXJPFqqK7W0/kTf/RIvgsEa9n/vFbemobliXjVd1yI7B e9o2K1wfSRKgw== From: Lorenzo Bianconi To: nbd@nbd.name Cc: linux-wireless@vger.kernel.org, lorenzo.bianconi@redhat.com, sean.wang@mediatek.com, greearb@candelatech.com, ryder.lee@mediatek.com Subject: [PATCH v2 02/10] mt76: move mt76_ethtool_worker_info in mt76 module Date: Tue, 19 Oct 2021 12:12:24 +0200 Message-Id: <32bbf1f6e927629573ab8fe6ac418f542842945d.1634637742.git.lorenzo@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Move mt76_ethtool_worker_info in common code in order to be reused in mt7921 driver. Signed-off-by: Lorenzo Bianconi --- drivers/net/wireless/mediatek/mt76/mac80211.c | 28 +++++++++++ drivers/net/wireless/mediatek/mt76/mt76.h | 10 ++++ .../net/wireless/mediatek/mt76/mt7915/main.c | 47 +++---------------- 3 files changed, 45 insertions(+), 40 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mac80211.c b/drivers/net/wireless/mediatek/mt76/mac80211.c index 766681a4f89e..62807dc311c1 100644 --- a/drivers/net/wireless/mediatek/mt76/mac80211.c +++ b/drivers/net/wireless/mediatek/mt76/mac80211.c @@ -1508,3 +1508,31 @@ u16 mt76_calculate_default_rate(struct mt76_phy *phy, int rateidx) return rate->hw_value; } EXPORT_SYMBOL_GPL(mt76_calculate_default_rate); + +void mt76_ethtool_worker(struct mt76_ethtool_worker_info *wi, + struct mt76_sta_stats *stats) +{ + int i, ei = wi->initial_stat_idx; + u64 *data = wi->data; + + wi->sta_count++; + + data[ei++] += stats->tx_mode[MT_PHY_TYPE_CCK]; + data[ei++] += stats->tx_mode[MT_PHY_TYPE_OFDM]; + data[ei++] += stats->tx_mode[MT_PHY_TYPE_HT]; + data[ei++] += stats->tx_mode[MT_PHY_TYPE_HT_GF]; + data[ei++] += stats->tx_mode[MT_PHY_TYPE_VHT]; + data[ei++] += stats->tx_mode[MT_PHY_TYPE_HE_SU]; + data[ei++] += stats->tx_mode[MT_PHY_TYPE_HE_EXT_SU]; + data[ei++] += stats->tx_mode[MT_PHY_TYPE_HE_TB]; + data[ei++] += stats->tx_mode[MT_PHY_TYPE_HE_MU]; + + for (i = 0; i < ARRAY_SIZE(stats->tx_bw); i++) + data[ei++] += stats->tx_bw[i]; + + for (i = 0; i < 12; i++) + data[ei++] += stats->tx_mcs[i]; + + wi->worker_stat_count = ei - wi->initial_stat_idx; +} +EXPORT_SYMBOL_GPL(mt76_ethtool_worker); diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h index ae6c3a735f49..e2da720a91b6 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76.h +++ b/drivers/net/wireless/mediatek/mt76/mt76.h @@ -786,6 +786,14 @@ struct mt76_sta_stats { u64 tx_mcs[16]; /* mcs idx */ }; +struct mt76_ethtool_worker_info { + u64 *data; + int idx; + int initial_stat_idx; + int worker_stat_count; + int sta_count; +}; + #define CCK_RATE(_idx, _rate) { \ .bitrate = _rate, \ .flags = IEEE80211_RATE_SHORT_PREAMBLE, \ @@ -1241,6 +1249,8 @@ mt76u_bulk_msg(struct mt76_dev *dev, void *data, int len, int *actual_len, return usb_bulk_msg(udev, pipe, data, len, actual_len, timeout); } +void mt76_ethtool_worker(struct mt76_ethtool_worker_info *wi, + struct mt76_sta_stats *stats); int mt76_skb_adjust_pad(struct sk_buff *skb, int pad); int mt76u_vendor_request(struct mt76_dev *dev, u8 req, u8 req_type, u16 val, u16 offset, diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/main.c b/drivers/net/wireless/mediatek/mt76/mt7915/main.c index bbf74e7452d8..f0fe4ee30e79 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/main.c @@ -1187,45 +1187,15 @@ int mt7915_get_et_sset_count(struct ieee80211_hw *hw, return 0; } -struct mt7915_ethtool_worker_info { - u64 *data; - struct mt7915_vif *mvif; - int initial_stat_idx; - int worker_stat_count; - int sta_count; -}; - static void mt7915_ethtool_worker(void *wi_data, struct ieee80211_sta *sta) { - struct mt7915_ethtool_worker_info *wi = wi_data; + struct mt76_ethtool_worker_info *wi = wi_data; struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv; - struct mt76_sta_stats *mstats = &msta->stats; - int ei = wi->initial_stat_idx; - int q; - u64 *data = wi->data; - if (msta->vif != wi->mvif) + if (msta->vif->idx != wi->idx) return; - wi->sta_count++; - - data[ei++] += mstats->tx_mode[MT_PHY_TYPE_CCK]; - data[ei++] += mstats->tx_mode[MT_PHY_TYPE_OFDM]; - data[ei++] += mstats->tx_mode[MT_PHY_TYPE_HT]; - data[ei++] += mstats->tx_mode[MT_PHY_TYPE_HT_GF]; - data[ei++] += mstats->tx_mode[MT_PHY_TYPE_VHT]; - data[ei++] += mstats->tx_mode[MT_PHY_TYPE_HE_SU]; - data[ei++] += mstats->tx_mode[MT_PHY_TYPE_HE_EXT_SU]; - data[ei++] += mstats->tx_mode[MT_PHY_TYPE_HE_TB]; - data[ei++] += mstats->tx_mode[MT_PHY_TYPE_HE_MU]; - - for (q = 0; q < ARRAY_SIZE(mstats->tx_bw); q++) - data[ei++] += mstats->tx_bw[q]; - - for (q = 0; q < 12; q++) - data[ei++] += mstats->tx_mcs[q]; - - wi->worker_stat_count = ei - wi->initial_stat_idx; + mt76_ethtool_worker(wi, &msta->stats); } static @@ -1236,9 +1206,11 @@ void mt7915_get_et_stats(struct ieee80211_hw *hw, struct mt7915_dev *dev = mt7915_hw_dev(hw); struct mt7915_phy *phy = mt7915_hw_phy(hw); struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; - struct mt7915_ethtool_worker_info wi; + struct mt76_ethtool_worker_info wi = { + .data = data, + .idx = mvif->idx, + }; struct mib_stats *mib = &phy->mib; - /* See mt7915_ampdu_stat_read_phy, etc */ bool ext_phy = phy != &dev->phy; int i, n, ei = 0; @@ -1303,12 +1275,7 @@ void mt7915_get_et_stats(struct ieee80211_hw *hw, data[ei++] = mib->rx_ba_cnt; /* Add values for all stations owned by this vif */ - wi.data = data; - wi.mvif = mvif; wi.initial_stat_idx = ei; - wi.worker_stat_count = 0; - wi.sta_count = 0; - ieee80211_iterate_stations_atomic(hw, mt7915_ethtool_worker, &wi); if (wi.sta_count == 0) From patchwork Tue Oct 19 10:12:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 12569389 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 078E8C433EF for ; Tue, 19 Oct 2021 10:13:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DF28B6137F for ; Tue, 19 Oct 2021 10:13:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235167AbhJSKPX (ORCPT ); Tue, 19 Oct 2021 06:15:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:58720 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235166AbhJSKPW (ORCPT ); Tue, 19 Oct 2021 06:15:22 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9B3B16137C; Tue, 19 Oct 2021 10:13:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634638389; bh=3tXRKb0n/fmzj+r29whG0hZdvaiqCsxyEu2emfzd+1w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EPDJVQZ9BkW1w5lUV+d1ApUXqERcE+FsMm2oz1rNwhD5+n8CHxKXMB90PwIcRD43k dXolnwCppE3H6D8BkYCXm+MnIvu+sBUoz9A9XWe+25SOWDuMHsGurcMyBGCD+Q6CIE U0vi4q6IB8hSJIrXDeRqsOL5B3TK6nBv5zAhcWIMG0vrU0JQBmOzYG3vZ3Xo6qxzbc 31+MQsCYEOsKTNvHCYk/uFTV7YzTs3ytH6BhSL0fpCJCyw7KL3YhFdkbHNsZJknKIJ nNPc9pt9CLrPPOta8IHuxkyGy1W2xmIItuZjCGWawOw6/wcK5uHEeTWC9XU9XlDe9g /VimQybuXdSHg== From: Lorenzo Bianconi To: nbd@nbd.name Cc: linux-wireless@vger.kernel.org, lorenzo.bianconi@redhat.com, sean.wang@mediatek.com, greearb@candelatech.com, ryder.lee@mediatek.com Subject: [PATCH v2 03/10] mt76: mt7915: run mt7915_get_et_stats holding mt76 mutex Date: Tue, 19 Oct 2021 12:12:25 +0200 Message-Id: <44d66f15f3cb34939812fd665fa52cf443a8d73a.1634637742.git.lorenzo@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Since it can run in parallel with mac_work, hold mutex lock in mt7915_get_et_stats. Moreover update mib counters running mt7915_get_et_stats. Signed-off-by: Lorenzo Bianconi --- drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c | 5 +++++ drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 3 +-- drivers/net/wireless/mediatek/mt76/mt7915/main.c | 6 ++++++ drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h | 1 + 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c b/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c index 6efa3d7e39be..a265069c4d4d 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c @@ -201,7 +201,10 @@ mt7915_tx_stats_show(struct seq_file *file, void *data) struct mt7915_dev *dev = phy->dev; int stat[8], i, n; + mutex_lock(&dev->mt76.mutex); + mt7915_ampdu_stat_read_phy(phy, file); + mt7915_mac_update_stats(phy); mt7915_txbf_stat_read_phy(phy, file); /* Tx amsdu info */ @@ -220,6 +223,8 @@ mt7915_tx_stats_show(struct seq_file *file, void *data) seq_puts(file, "\n"); } + mutex_unlock(&dev->mt76.mutex); + return 0; } diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c index edf62e0a7ff0..1fb0420276a1 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c @@ -1918,8 +1918,7 @@ void mt7915_mac_reset_work(struct work_struct *work) MT7915_WATCHDOG_TIME); } -static void -mt7915_mac_update_stats(struct mt7915_phy *phy) +void mt7915_mac_update_stats(struct mt7915_phy *phy) { struct mt7915_dev *dev = phy->dev; struct mib_stats *mib = &phy->mib; diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/main.c b/drivers/net/wireless/mediatek/mt76/mt7915/main.c index f0fe4ee30e79..1159059f705a 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/main.c @@ -1215,6 +1215,10 @@ void mt7915_get_et_stats(struct ieee80211_hw *hw, bool ext_phy = phy != &dev->phy; int i, n, ei = 0; + mutex_lock(&dev->mt76.mutex); + + mt7915_mac_update_stats(phy); + data[ei++] = mib->tx_ampdu_cnt; data[ei++] = mib->tx_stop_q_empty_cnt; data[ei++] = mib->tx_mpdu_attempts_cnt; @@ -1278,6 +1282,8 @@ void mt7915_get_et_stats(struct ieee80211_hw *hw, wi.initial_stat_idx = ei; ieee80211_iterate_stations_atomic(hw, mt7915_ethtool_worker, &wi); + mutex_unlock(&dev->mt76.mutex); + if (wi.sta_count == 0) return; diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h index 2acede0d5bf2..0a2dd2f18fe5 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h @@ -481,6 +481,7 @@ void mt7915_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif, void mt7915_mac_work(struct work_struct *work); void mt7915_mac_reset_work(struct work_struct *work); void mt7915_mac_sta_rc_work(struct work_struct *work); +void mt7915_mac_update_stats(struct mt7915_phy *phy); int mt7915_mmio_init(struct mt76_dev *mdev, void __iomem *mem_base, int irq); void mt7915_mac_twt_teardown_flow(struct mt7915_dev *dev, struct mt7915_sta *msta, From patchwork Tue Oct 19 10:12:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 12569391 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5E54AC433FE for ; Tue, 19 Oct 2021 10:13:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 414F26137C for ; Tue, 19 Oct 2021 10:13:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235172AbhJSKPY (ORCPT ); Tue, 19 Oct 2021 06:15:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:58748 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235166AbhJSKPY (ORCPT ); Tue, 19 Oct 2021 06:15:24 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2F0826137D; Tue, 19 Oct 2021 10:13:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634638391; bh=Cca1+UTn1Fdnb4g8mxWs84xLigH5uC2PSD0uGDb4lug=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ov44X2Fi76Udz7lY3NAp7U9MRY6ir3dytasljWWcmLjRSiXpP5fYgR3zTVmtPbQyh kaXeVGPIB9mbNPTuJ9OheP9z/3P3pgdqxdBuSr4anhIftwL8jrpJWWZLCeAiJiPdw3 WNjN6yoV3sLO5K7ig2MjdBGaqYRhANfaf3HCwMsd17rLuOXnRqjsKRpLiAAgWKXFPY 1i/87uy/esbYpbr2pznBlHdipZbfdMWNR5pUs+EWLW2arWxNxAnIeidooLGYB9za5N 5V5l4kEIhZoobv8ns+JqnWO0gMJHl72kN6N94W9dbA45YLHIuCQ3K2Fz9KwXu7n4z3 VoGHs0r6/hsnw== From: Lorenzo Bianconi To: nbd@nbd.name Cc: linux-wireless@vger.kernel.org, lorenzo.bianconi@redhat.com, sean.wang@mediatek.com, greearb@candelatech.com, ryder.lee@mediatek.com Subject: [PATCH v2 04/10] mt76: mt7915: move tx amsdu stats in mib_stats Date: Tue, 19 Oct 2021 12:12:26 +0200 Message-Id: X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Move tx_amsdu histogram stats in mib_stats structure since registers are clear-on-read Signed-off-by: Lorenzo Bianconi --- .../wireless/mediatek/mt76/mt7915/debugfs.c | 19 ++++++++----------- .../net/wireless/mediatek/mt76/mt7915/mac.c | 6 ++++++ .../net/wireless/mediatek/mt76/mt7915/main.c | 4 ++-- .../wireless/mediatek/mt76/mt7915/mt7915.h | 3 +++ 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c b/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c index a265069c4d4d..4b7f38fcbe64 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c @@ -199,7 +199,8 @@ mt7915_tx_stats_show(struct seq_file *file, void *data) { struct mt7915_phy *phy = file->private; struct mt7915_dev *dev = phy->dev; - int stat[8], i, n; + struct mib_stats *mib = &phy->mib; + int i; mutex_lock(&dev->mt76.mutex); @@ -209,16 +210,12 @@ mt7915_tx_stats_show(struct seq_file *file, void *data) /* Tx amsdu info */ seq_puts(file, "Tx MSDU statistics:\n"); - for (i = 0, n = 0; i < ARRAY_SIZE(stat); i++) { - stat[i] = mt76_rr(dev, MT_PLE_AMSDU_PACK_MSDU_CNT(i)); - n += stat[i]; - } - - for (i = 0; i < ARRAY_SIZE(stat); i++) { - seq_printf(file, "AMSDU pack count of %d MSDU in TXD: 0x%x ", - i + 1, stat[i]); - if (n != 0) - seq_printf(file, "(%d%%)\n", stat[i] * 100 / n); + for (i = 0; i < ARRAY_SIZE(mib->tx_amsdu); i++) { + seq_printf(file, "AMSDU pack count of %d MSDU in TXD: %8d ", + i + 1, mib->tx_amsdu[i]); + if (mib->tx_amsdu_cnt) + seq_printf(file, "(%3d%%)\n", + mib->tx_amsdu[i] * 100 / mib->tx_amsdu_cnt); else seq_puts(file, "\n"); } diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c index 1fb0420276a1..f6267b77ca97 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c @@ -2023,6 +2023,12 @@ void mt7915_mac_update_stats(struct mt7915_phy *phy) mib->tx_bf_fb_cpl_cnt += FIELD_GET(MT_ETBF_TX_FB_CPL, cnt); mib->tx_bf_fb_trig_cnt += FIELD_GET(MT_ETBF_TX_FB_TRI, cnt); + for (i = 0; i < ARRAY_SIZE(mib->tx_amsdu); i++) { + cnt = mt76_rr(dev, MT_PLE_AMSDU_PACK_MSDU_CNT(i)); + mib->tx_amsdu[i] += cnt; + mib->tx_amsdu_cnt += cnt; + } + aggr0 = ext_phy ? ARRAY_SIZE(dev->mt76.aggr_stats) / 2 : 0; for (i = 0, aggr1 = aggr0 + 4; i < 4; i++) { u32 val; diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/main.c b/drivers/net/wireless/mediatek/mt76/mt7915/main.c index 1159059f705a..15daacabed75 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/main.c @@ -1260,8 +1260,8 @@ void mt7915_get_et_stats(struct ieee80211_hw *hw, data[ei++] = mib->tx_su_acked_mpdu_cnt; /* Tx amsdu info (pack-count histogram) */ - for (i = 0; i < 8; i++) - data[ei++] = mt76_rr(dev, MT_PLE_AMSDU_PACK_MSDU_CNT(i)); + for (i = 0; i < ARRAY_SIZE(mib->tx_amsdu); i++) + data[ei++] = mib->tx_amsdu[i]; /* rx counters */ data[ei++] = mib->rx_fifo_full_cnt; diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h index 0a2dd2f18fe5..207114e2019d 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h @@ -171,6 +171,9 @@ struct mib_stats { u32 rx_pfdrop_cnt; u32 rx_vec_queue_overflow_drop_cnt; u32 rx_ba_cnt; + + u32 tx_amsdu[8]; + u32 tx_amsdu_cnt; }; struct mt7915_hif { From patchwork Tue Oct 19 10:12:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 12569393 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 40D31C433F5 for ; Tue, 19 Oct 2021 10:13:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2DBA061381 for ; Tue, 19 Oct 2021 10:13:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235169AbhJSKPZ (ORCPT ); Tue, 19 Oct 2021 06:15:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:58764 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235173AbhJSKPZ (ORCPT ); Tue, 19 Oct 2021 06:15:25 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B6B4A6137B; Tue, 19 Oct 2021 10:13:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634638392; bh=uatDr9PikZZvm1xJF/UuyOk8v1kSgPXBnlmJDtjCBEY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LdJoz43foHRtMe7SckqMtR9rEBy6iXLne/3atZrSsrdEWqMNRLJH9Kf53c09leFSu bJPqjO/oJ2va8nPV9ySOkDzveAA9utOS4HzgKUEUdq7Lk6reLvLAXuOid5fgEQlKyV e8dyaIwZVxd/dJnTyX4uNnCcGp0Y9NUrmeA4QXU4jUP59UjWI0hzoaQMkxpbtNWFB7 cBgUogsbZshoMYXP1CwXnqK2xbi9jOOi9RIge1LhawVxo9f6g2dzMiRIdTIdzmvFlh iXraS05F+u1iSFn+mjuvhT9BGE0egooPKTaBCrjf78Ec385du1q/GsHcBTX86PPbMG cR/7swNp+R9rg== From: Lorenzo Bianconi To: nbd@nbd.name Cc: linux-wireless@vger.kernel.org, lorenzo.bianconi@redhat.com, sean.wang@mediatek.com, greearb@candelatech.com, ryder.lee@mediatek.com Subject: [PATCH v2 05/10] mt76: do not reset MIB counters in get_stats callback Date: Tue, 19 Oct 2021 12:12:27 +0200 Message-Id: <803ee266c21ea1667960738c9d4b5801eac9d8e3.1634637742.git.lorenzo@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org MIB counters are used for ethtool stats as well Signed-off-by: Lorenzo Bianconi --- drivers/net/wireless/mediatek/mt76/mt7615/main.c | 2 -- drivers/net/wireless/mediatek/mt76/mt7915/main.c | 3 +-- drivers/net/wireless/mediatek/mt76/mt7921/main.c | 2 -- 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/main.c b/drivers/net/wireless/mediatek/mt76/mt7615/main.c index d5bcffef7122..343e157261ca 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/main.c @@ -862,8 +862,6 @@ mt7615_get_stats(struct ieee80211_hw *hw, stats->dot11FCSErrorCount = mib->fcs_err_cnt; stats->dot11ACKFailureCount = mib->ack_fail_cnt; - memset(mib, 0, sizeof(*mib)); - mt7615_mutex_release(phy->dev); return 0; diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/main.c b/drivers/net/wireless/mediatek/mt76/mt7915/main.c index 15daacabed75..34349961b751 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/main.c @@ -811,13 +811,12 @@ mt7915_get_stats(struct ieee80211_hw *hw, struct mib_stats *mib = &phy->mib; mutex_lock(&dev->mt76.mutex); + stats->dot11RTSSuccessCount = mib->rts_cnt; stats->dot11RTSFailureCount = mib->rts_retries_cnt; stats->dot11FCSErrorCount = mib->fcs_err_cnt; stats->dot11ACKFailureCount = mib->ack_fail_cnt; - memset(mib, 0, sizeof(*mib)); - mutex_unlock(&dev->mt76.mutex); return 0; diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net/wireless/mediatek/mt76/mt7921/main.c index d968990dac6e..22d5a0adb5ad 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c @@ -856,8 +856,6 @@ mt7921_get_stats(struct ieee80211_hw *hw, stats->dot11FCSErrorCount = mib->fcs_err_cnt; stats->dot11ACKFailureCount = mib->ack_fail_cnt; - memset(mib, 0, sizeof(*mib)); - mt7921_mutex_release(phy->dev); return 0; From patchwork Tue Oct 19 10:12:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 12569395 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 17AC9C433F5 for ; Tue, 19 Oct 2021 10:13:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EFBEF61374 for ; Tue, 19 Oct 2021 10:13:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235179AbhJSKP1 (ORCPT ); Tue, 19 Oct 2021 06:15:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:58782 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235176AbhJSKP0 (ORCPT ); Tue, 19 Oct 2021 06:15:26 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4AA2A6137F; Tue, 19 Oct 2021 10:13:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634638394; bh=Bo0YfX2aJLJYYHWPVAD1Y+BgbssyG92ng++77KCWyb8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cx92WdYW5o8TedO/sTLHTjXwlz8d/ouL97DFdeaDAMJ3AgA0twU7KDwpcxM9j3wYi +SEyPgRBsrDhLb6H79QQPOKMBqgyc/u19Dx1xAlkybtyT92mpQtDNezeSyxxihVdGo 5zDqvrGlJHRJzlwZPVDnHbxE+K9QgpMBKzNIN1QMXRWeop+wPuZNwA82L34+Xr+76f pd0x1cQB9poxyCgU1UacfpcCesNy3z/rhplgzqn79vo6kTcKII3sxgnjFISQT3HtrS RMqzLWajyMgFU1y6IgZBhightZEykgk7SwsSm+veBOddgNC15GZXCWZVa47MUT8tEY 7Ia1qj0ubNGgQ== From: Lorenzo Bianconi To: nbd@nbd.name Cc: linux-wireless@vger.kernel.org, lorenzo.bianconi@redhat.com, sean.wang@mediatek.com, greearb@candelatech.com, ryder.lee@mediatek.com Subject: [PATCH v2 06/10] mt76: mt7921: add some more MIB counters Date: Tue, 19 Oct 2021 12:12:28 +0200 Message-Id: <8923bf23c506e3abb65464e5a487118d25d7d1be.1634637742.git.lorenzo@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org This is a preliminary patch to introduce ethtool stats support to mt7921 driver. Signed-off-by: Lorenzo Bianconi --- .../net/wireless/mediatek/mt76/mt7921/mac.c | 26 ++++++++++++++++- .../wireless/mediatek/mt76/mt7921/mt7921.h | 18 ++++++++++++ .../net/wireless/mediatek/mt76/mt7921/regs.h | 28 +++++++++++++++++++ 3 files changed, 71 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c index f5b179601030..8a5b92b1e055 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c @@ -1326,6 +1326,7 @@ void mt7921_mac_update_mib_stats(struct mt7921_phy *phy) struct mt7921_dev *dev = phy->dev; struct mib_stats *mib = &phy->mib; int i, aggr0 = 0, aggr1; + u32 val; mib->fcs_err_cnt += mt76_get_field(dev, MT_MIB_SDR3(0), MT_MIB_SDR3_FCS_ERR_MASK); @@ -1338,8 +1339,31 @@ void mt7921_mac_update_mib_stats(struct mt7921_phy *phy) mib->rts_retries_cnt += mt76_get_field(dev, MT_MIB_MB_BSDR1(0), MT_MIB_RTS_FAIL_COUNT_MASK); + mib->tx_ampdu_cnt += mt76_rr(dev, MT_MIB_SDR12(0)); + mib->tx_mpdu_attempts_cnt += mt76_rr(dev, MT_MIB_SDR14(0)); + mib->tx_mpdu_success_cnt += mt76_rr(dev, MT_MIB_SDR15(0)); + + val = mt76_rr(dev, MT_MIB_SDR32(0)); + mib->tx_pkt_ebf_cnt += FIELD_GET(MT_MIB_SDR9_EBF_CNT_MASK, val); + mib->tx_pkt_ibf_cnt += FIELD_GET(MT_MIB_SDR9_IBF_CNT_MASK, val); + + val = mt76_rr(dev, MT_ETBF_TX_APP_CNT(0)); + mib->tx_bf_ibf_ppdu_cnt += FIELD_GET(MT_ETBF_TX_IBF_CNT, val); + mib->tx_bf_ebf_ppdu_cnt += FIELD_GET(MT_ETBF_TX_EBF_CNT, val); + + val = mt76_rr(dev, MT_ETBF_RX_FB_CNT(0)); + mib->tx_bf_rx_fb_all_cnt += FIELD_GET(MT_ETBF_RX_FB_ALL, val); + mib->tx_bf_rx_fb_he_cnt += FIELD_GET(MT_ETBF_RX_FB_HE, val); + mib->tx_bf_rx_fb_vht_cnt += FIELD_GET(MT_ETBF_RX_FB_VHT, val); + mib->tx_bf_rx_fb_ht_cnt += FIELD_GET(MT_ETBF_RX_FB_HT, val); + + mib->rx_mpdu_cnt += mt76_rr(dev, MT_MIB_SDR5(0)); + mib->rx_ampdu_cnt += mt76_rr(dev, MT_MIB_SDR22(0)); + mib->rx_ampdu_bytes_cnt += mt76_rr(dev, MT_MIB_SDR23(0)); + mib->rx_ba_cnt += mt76_rr(dev, MT_MIB_SDR31(0)); + for (i = 0, aggr1 = aggr0 + 4; i < 4; i++) { - u32 val, val2; + u32 val2; val = mt76_rr(dev, MT_TX_AGG_CNT(0, i)); val2 = mt76_rr(dev, MT_TX_AGG_CNT2(0, i)); diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h index eebf367be296..86c741569a9b 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h @@ -129,6 +129,24 @@ struct mib_stats { u32 rts_cnt; u32 rts_retries_cnt; u32 ba_miss_cnt; + + u32 tx_bf_ibf_ppdu_cnt; + u32 tx_bf_ebf_ppdu_cnt; + u32 tx_bf_rx_fb_all_cnt; + u32 tx_bf_rx_fb_he_cnt; + u32 tx_bf_rx_fb_vht_cnt; + u32 tx_bf_rx_fb_ht_cnt; + + u32 tx_ampdu_cnt; + u32 tx_mpdu_attempts_cnt; + u32 tx_mpdu_success_cnt; + u32 tx_pkt_ebf_cnt; + u32 tx_pkt_ibf_cnt; + + u32 rx_mpdu_cnt; + u32 rx_ampdu_cnt; + u32 rx_ampdu_bytes_cnt; + u32 rx_ba_cnt; }; struct mt7921_phy { diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/regs.h b/drivers/net/wireless/mediatek/mt76/mt7921/regs.h index cb6069024320..cbd38122c510 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/regs.h +++ b/drivers/net/wireless/mediatek/mt76/mt7921/regs.h @@ -92,6 +92,20 @@ #define MT_LPON_TCR_SW_MODE GENMASK(1, 0) #define MT_LPON_TCR_SW_WRITE BIT(0) +/* ETBF: band 0(0x24000), band 1(0xa4000) */ +#define MT_WF_ETBF_BASE(_band) ((_band) ? 0x820fa000 : 0x820ea000) +#define MT_WF_ETBF(_band, ofs) (MT_WF_ETBF_BASE(_band) + (ofs)) + +#define MT_ETBF_TX_APP_CNT(_band) MT_WF_ETBF(_band, 0x150) +#define MT_ETBF_TX_IBF_CNT GENMASK(31, 16) +#define MT_ETBF_TX_EBF_CNT GENMASK(15, 0) + +#define MT_ETBF_RX_FB_CNT(_band) MT_WF_ETBF(_band, 0x158) +#define MT_ETBF_RX_FB_ALL GENMASK(31, 24) +#define MT_ETBF_RX_FB_HE GENMASK(23, 16) +#define MT_ETBF_RX_FB_VHT GENMASK(15, 8) +#define MT_ETBF_RX_FB_HT GENMASK(7, 0) + /* MIB: band 0(0x24800), band 1(0xa4800) */ #define MT_WF_MIB_BASE(_band) ((_band) ? 0x820fd000 : 0x820ed000) #define MT_WF_MIB(_band, ofs) (MT_WF_MIB_BASE(_band) + (ofs)) @@ -103,12 +117,26 @@ #define MT_MIB_SDR3(_band) MT_WF_MIB(_band, 0x698) #define MT_MIB_SDR3_FCS_ERR_MASK GENMASK(31, 16) +#define MT_MIB_SDR5(_band) MT_WF_MIB(_band, 0x780) + #define MT_MIB_SDR9(_band) MT_WF_MIB(_band, 0x02c) #define MT_MIB_SDR9_BUSY_MASK GENMASK(23, 0) +#define MT_MIB_SDR12(_band) MT_WF_MIB(_band, 0x558) +#define MT_MIB_SDR14(_band) MT_WF_MIB(_band, 0x564) +#define MT_MIB_SDR15(_band) MT_WF_MIB(_band, 0x568) + #define MT_MIB_SDR16(_band) MT_WF_MIB(_band, 0x048) #define MT_MIB_SDR16_BUSY_MASK GENMASK(23, 0) +#define MT_MIB_SDR22(_band) MT_WF_MIB(_band, 0x770) +#define MT_MIB_SDR23(_band) MT_WF_MIB(_band, 0x774) +#define MT_MIB_SDR31(_band) MT_WF_MIB(_band, 0x55c) + +#define MT_MIB_SDR32(_band) MT_WF_MIB(_band, 0x7a8) +#define MT_MIB_SDR9_IBF_CNT_MASK GENMASK(31, 16) +#define MT_MIB_SDR9_EBF_CNT_MASK GENMASK(15, 0) + #define MT_MIB_SDR34(_band) MT_WF_MIB(_band, 0x090) #define MT_MIB_MU_BF_TX_CNT GENMASK(15, 0) From patchwork Tue Oct 19 10:12:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 12569397 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C50B5C433FE for ; Tue, 19 Oct 2021 10:13:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A9D4161381 for ; Tue, 19 Oct 2021 10:13:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235185AbhJSKP3 (ORCPT ); Tue, 19 Oct 2021 06:15:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:58800 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235180AbhJSKP2 (ORCPT ); Tue, 19 Oct 2021 06:15:28 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D1B4E6137C; Tue, 19 Oct 2021 10:13:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634638396; bh=jCkKSt0tthJ8gCn38kUdGHx4fp6r6SdWk4es9vm5gag=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rzrkuIalIINZQ6nqltVfz33nWGhiXcJTiaG45c4acQaQt9TdXVrcHFTizLnojtMZP cgd2dDZi+F5gUmQs+YpvAOPJKPETumFoemgDyDE2R7tGvr2j94c/OTMmwwAFt2v0Ks NIog0qFrWXEF16KkGmzykCHiS6Ro7VeKscj5nnAGEcOpxkX/Vl6zzivJooIMJ9pK7+ n46Cmg+gzc/GZWbe6b/JCqyrttS1c0OX1zof8huAuZpmuCRXg1QBP4RRPBDcjvnOLY J7WQtwrha/STwRHJUyrBq9qZBOetJmdCAI8780sy/j9vx0spg6yvXW+E6Qipew/A4S pdivEX+6f59Yg== From: Lorenzo Bianconi To: nbd@nbd.name Cc: linux-wireless@vger.kernel.org, lorenzo.bianconi@redhat.com, sean.wang@mediatek.com, greearb@candelatech.com, ryder.lee@mediatek.com Subject: [PATCH v2 07/10] mt76: mt7921: introduce stats reporting through ethtool Date: Tue, 19 Oct 2021 12:12:29 +0200 Message-Id: <579c1b1d45e36615fc53a97d45338c8e1197b0a8.1634637742.git.lorenzo@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Similar to mt7915 driver, add tx/rx statistics reporting through ethtool. Signed-off-by: Lorenzo Bianconi --- .../net/wireless/mediatek/mt76/mt7921/main.c | 116 ++++++++++++++++++ 1 file changed, 116 insertions(+) diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net/wireless/mediatek/mt76/mt7921/main.c index 22d5a0adb5ad..bd49cfd59617 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c @@ -861,6 +861,119 @@ mt7921_get_stats(struct ieee80211_hw *hw, return 0; } +static const char mt7921_gstrings_stats[][ETH_GSTRING_LEN] = { + /* tx counters */ + "tx_ampdu_cnt", + "tx_mpdu_attempts", + "tx_mpdu_success", + "tx_pkt_ebf_cnt", + "tx_pkt_ibf_cnt", + "tx_ampdu_len:0-1", + "tx_ampdu_len:2-10", + "tx_ampdu_len:11-19", + "tx_ampdu_len:20-28", + "tx_ampdu_len:29-37", + "tx_ampdu_len:38-46", + "tx_ampdu_len:47-55", + "tx_ampdu_len:56-79", + "tx_ampdu_len:80-103", + "tx_ampdu_len:104-127", + "tx_ampdu_len:128-151", + "tx_ampdu_len:152-175", + "tx_ampdu_len:176-199", + "tx_ampdu_len:200-223", + "tx_ampdu_len:224-247", + "ba_miss_count", + "tx_beamformer_ppdu_iBF", + "tx_beamformer_ppdu_eBF", + "tx_beamformer_rx_feedback_all", + "tx_beamformer_rx_feedback_he", + "tx_beamformer_rx_feedback_vht", + "tx_beamformer_rx_feedback_ht", + "tx_msdu_pack_1", + "tx_msdu_pack_2", + "tx_msdu_pack_3", + "tx_msdu_pack_4", + "tx_msdu_pack_5", + "tx_msdu_pack_6", + "tx_msdu_pack_7", + "tx_msdu_pack_8", + /* rx counters */ + "rx_mpdu_cnt", + "rx_ampdu_cnt", + "rx_ampdu_bytes_cnt", + "rx_ba_cnt" +}; + +static void +mt7921_get_et_strings(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + u32 sset, u8 *data) +{ + if (sset != ETH_SS_STATS) + return; + + memcpy(data, *mt7921_gstrings_stats, sizeof(mt7921_gstrings_stats)); +} + +static int +mt7921_get_et_sset_count(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + int sset) +{ + return sset == ETH_SS_STATS ? ARRAY_SIZE(mt7921_gstrings_stats) : 0; +} + +static +void mt7921_get_et_stats(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + struct ethtool_stats *stats, u64 *data) +{ + struct mt7921_phy *phy = mt7921_hw_phy(hw); + struct mt7921_dev *dev = phy->dev; + struct mib_stats *mib = &phy->mib; + int i, ei = 0; + + mt7921_mutex_acquire(dev); + + mt7921_mac_update_mib_stats(phy); + + data[ei++] = mib->tx_ampdu_cnt; + data[ei++] = mib->tx_mpdu_attempts_cnt; + data[ei++] = mib->tx_mpdu_success_cnt; + data[ei++] = mib->tx_pkt_ebf_cnt; + data[ei++] = mib->tx_pkt_ibf_cnt; + + /* Tx ampdu stat */ + for (i = 0; i < 15; i++) + data[ei++] = dev->mt76.aggr_stats[i]; + + data[ei++] = phy->mib.ba_miss_cnt; + + /* Tx Beamformer monitor */ + data[ei++] = mib->tx_bf_ibf_ppdu_cnt; + data[ei++] = mib->tx_bf_ebf_ppdu_cnt; + + /* Tx Beamformer Rx feedback monitor */ + data[ei++] = mib->tx_bf_rx_fb_all_cnt; + data[ei++] = mib->tx_bf_rx_fb_he_cnt; + data[ei++] = mib->tx_bf_rx_fb_vht_cnt; + data[ei++] = mib->tx_bf_rx_fb_ht_cnt; + + /* Tx amsdu info (pack-count histogram) */ + for (i = 0; i < 8; i++) + data[ei++] = mt76_rr(dev, MT_PLE_AMSDU_PACK_MSDU_CNT(i)); + + /* rx counters */ + data[ei++] = mib->rx_mpdu_cnt; + data[ei++] = mib->rx_ampdu_cnt; + data[ei++] = mib->rx_ampdu_bytes_cnt; + data[ei++] = mib->rx_ba_cnt; + + mt7921_mutex_release(dev); + + if (ei != ARRAY_SIZE(mt7921_gstrings_stats)) + dev_err(dev->mt76.dev, "ei: %d SSTATS_LEN: %lu", + ei, ARRAY_SIZE(mt7921_gstrings_stats)); +} + static u64 mt7921_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { @@ -1230,6 +1343,9 @@ const struct ieee80211_ops mt7921_ops = { .release_buffered_frames = mt76_release_buffered_frames, .get_txpower = mt76_get_txpower, .get_stats = mt7921_get_stats, + .get_et_sset_count = mt7921_get_et_sset_count, + .get_et_strings = mt7921_get_et_strings, + .get_et_stats = mt7921_get_et_stats, .get_tsf = mt7921_get_tsf, .set_tsf = mt7921_set_tsf, .get_survey = mt76_get_survey, From patchwork Tue Oct 19 10:12:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 12569399 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7910EC433F5 for ; Tue, 19 Oct 2021 10:13:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 61C9B61381 for ; Tue, 19 Oct 2021 10:13:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235190AbhJSKPa (ORCPT ); Tue, 19 Oct 2021 06:15:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:58816 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235189AbhJSKPa (ORCPT ); Tue, 19 Oct 2021 06:15:30 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 64D4961374; Tue, 19 Oct 2021 10:13:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634638397; bh=UtyRD+YgDOBURt12u6jiTenbZBbgK4PPniul/n7gnH8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gpJ3HKWuu9Hgm1UFqB0YUeyQb6z1XOZABaEi7wgSt0JR2gM/RbapWTIZhBZBwi6rv +g8nac6wAjZen9Xfrz/stP5eM0tjd0eA8AKb9r7M26I+aT8WWObYregowRFj/ZNvRO ixbta4R1k/kCYzEhZltL3HuERQAXjbkuq9secAgA47cvWQjDV6wAOuqrsSlge4GffV 18rhICQ9U7NJhrDv12kCJFG0IDExLrx6okTXa2rGOYphPQmORaIc9l9ATN7aOwo/be nnaKwEpC4qlzrGhT69PiCDKisjgGVebgYg/UvQgfxFPJZDGYZFI5JJabjkRziV6NUs fwCkw3GJ0D0lA== From: Lorenzo Bianconi To: nbd@nbd.name Cc: linux-wireless@vger.kernel.org, lorenzo.bianconi@redhat.com, sean.wang@mediatek.com, greearb@candelatech.com, ryder.lee@mediatek.com Subject: [PATCH v2 08/10] mt76: mt7921: add sta stats accounting in mt7921_mac_add_txs_skb Date: Tue, 19 Oct 2021 12:12:30 +0200 Message-Id: <5c3f18c8325f75e900c6a0ab3c0bcbc79cea936f.1634637742.git.lorenzo@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org This is a preliminary patch to add ethtool stats to mt7921 driver. Signed-off-by: Lorenzo Bianconi --- drivers/net/wireless/mediatek/mt76/mt7921/mac.c | 17 +++++++++++++++-- .../net/wireless/mediatek/mt76/mt7921/mt7921.h | 1 + 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c index 8a5b92b1e055..d45c54f92b9e 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c @@ -951,14 +951,16 @@ static bool mt7921_mac_add_txs_skb(struct mt7921_dev *dev, struct mt76_wcid *wcid, int pid, __le32 *txs_data) { + struct mt7921_sta *msta = container_of(wcid, struct mt7921_sta, wcid); + struct mt76_sta_stats *stats = &msta->stats; struct ieee80211_supported_band *sband; struct mt76_dev *mdev = &dev->mt76; struct ieee80211_tx_info *info; struct rate_info rate = {}; struct sk_buff_head list; + u32 txrate, txs, mode; struct sk_buff *skb; bool cck = false; - u32 txrate, txs; mt76_tx_status_lock(mdev, &list); skb = mt76_tx_status_skb_get(mdev, wcid, pid, &list); @@ -984,7 +986,13 @@ mt7921_mac_add_txs_skb(struct mt7921_dev *dev, struct mt76_wcid *wcid, int pid, rate.mcs = FIELD_GET(MT_TX_RATE_IDX, txrate); rate.nss = FIELD_GET(MT_TX_RATE_NSS, txrate) + 1; - switch (FIELD_GET(MT_TX_RATE_MODE, txrate)) { + if (rate.nss - 1 < ARRAY_SIZE(stats->tx_nss)) + stats->tx_nss[rate.nss - 1]++; + if (rate.mcs < ARRAY_SIZE(stats->tx_mcs)) + stats->tx_mcs[rate.mcs]++; + + mode = FIELD_GET(MT_TX_RATE_MODE, txrate); + switch (mode) { case MT_PHY_TYPE_CCK: cck = true; fallthrough; @@ -1027,19 +1035,24 @@ mt7921_mac_add_txs_skb(struct mt7921_dev *dev, struct mt76_wcid *wcid, int pid, default: goto out; } + stats->tx_mode[mode]++; switch (FIELD_GET(MT_TXS0_BW, txs)) { case IEEE80211_STA_RX_BW_160: rate.bw = RATE_INFO_BW_160; + stats->tx_bw[3]++; break; case IEEE80211_STA_RX_BW_80: rate.bw = RATE_INFO_BW_80; + stats->tx_bw[2]++; break; case IEEE80211_STA_RX_BW_40: rate.bw = RATE_INFO_BW_40; + stats->tx_bw[1]++; break; default: rate.bw = RATE_INFO_BW_20; + stats->tx_bw[0]++; break; } wcid->rate = rate; diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h index 86c741569a9b..9347859a291c 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h @@ -104,6 +104,7 @@ struct mt7921_sta { unsigned long last_txs; unsigned long ampdu_state; + struct mt76_sta_stats stats; struct mt7921_sta_key_conf bip; }; From patchwork Tue Oct 19 10:12:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 12569401 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16C00C433F5 for ; Tue, 19 Oct 2021 10:13:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 024856137B for ; Tue, 19 Oct 2021 10:13:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235187AbhJSKPc (ORCPT ); Tue, 19 Oct 2021 06:15:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:58842 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235194AbhJSKPb (ORCPT ); Tue, 19 Oct 2021 06:15:31 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id ECB546137D; Tue, 19 Oct 2021 10:13:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634638399; bh=DYrTMRvv0qJQvCgwqGkO5m54zGqLGootLTWmqAvNVG4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dM1MgSPQvfEU+8O3yTv8utrt9vmA6fI39T3r2/GNDdow5QoipRjQqUWMx9gXJpNna i/Xkzp8Ue/JX6lF1fxtu6rBR9FqfZG3yNUKGHDzWCnSEgEde66euS6A8eMg9tcSZrn ih2JVh+l/K2yV0TN67rpOMaMfBfNNs8FAAEyjqAERkLH/zioebZkdi7wImpA6kzRZf HqhK2MznOLfZSqeLtvfrGATFp10jaAnIYCYLbC/MwdZ52aD2fd1V/hY5KDF7o13kJu zyC1ZBGn1EZ+ugMJMM2n/VJF0VLVlvJU+UhotxISVQhhjGwER+lCNg+AHF1LVmTzDP Vi0r4hTPBSFAQ== From: Lorenzo Bianconi To: nbd@nbd.name Cc: linux-wireless@vger.kernel.org, lorenzo.bianconi@redhat.com, sean.wang@mediatek.com, greearb@candelatech.com, ryder.lee@mediatek.com Subject: [PATCH v2 09/10] mt76: mt7921: move tx amsdu stats in mib_stats Date: Tue, 19 Oct 2021 12:12:31 +0200 Message-Id: <7cb3453341a155b0d5e1f12dee945516f1fe8af1.1634637742.git.lorenzo@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Move tx_amsdu histogram stats in mib_stats structure since registers are clear-on-read Signed-off-by: Lorenzo Bianconi --- .../wireless/mediatek/mt76/mt7921/debugfs.c | 27 +++++++++---------- .../net/wireless/mediatek/mt76/mt7921/mac.c | 6 +++++ .../net/wireless/mediatek/mt76/mt7921/main.c | 4 +-- .../wireless/mediatek/mt76/mt7921/mt7921.h | 3 +++ 4 files changed, 23 insertions(+), 17 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c b/drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c index 68f393c07a31..7cdfdf83529f 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c @@ -95,30 +95,27 @@ static int mt7921_tx_stats_show(struct seq_file *file, void *data) { struct mt7921_dev *dev = file->private; - int stat[8], i, n; + struct mt7921_phy *phy = &dev->phy; + struct mib_stats *mib = &phy->mib; + int i; mt7921_mutex_acquire(dev); - mt7921_ampdu_stat_read_phy(&dev->phy, file); + mt7921_ampdu_stat_read_phy(phy, file); - /* Tx amsdu info */ seq_puts(file, "Tx MSDU stat:\n"); - for (i = 0, n = 0; i < ARRAY_SIZE(stat); i++) { - stat[i] = mt76_rr(dev, MT_PLE_AMSDU_PACK_MSDU_CNT(i)); - n += stat[i]; - } - - mt7921_mutex_release(dev); - - for (i = 0; i < ARRAY_SIZE(stat); i++) { - seq_printf(file, "AMSDU pack count of %d MSDU in TXD: 0x%x ", - i + 1, stat[i]); - if (n != 0) - seq_printf(file, "(%d%%)\n", stat[i] * 100 / n); + for (i = 0; i < ARRAY_SIZE(mib->tx_amsdu); i++) { + seq_printf(file, "AMSDU pack count of %d MSDU in TXD: %8d ", + i + 1, mib->tx_amsdu[i]); + if (mib->tx_amsdu_cnt) + seq_printf(file, "(%3d%%)\n", + mib->tx_amsdu[i] * 100 / mib->tx_amsdu_cnt); else seq_puts(file, "\n"); } + mt7921_mutex_release(dev); + return 0; } diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c index d45c54f92b9e..db3302b1576a 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c @@ -1375,6 +1375,12 @@ void mt7921_mac_update_mib_stats(struct mt7921_phy *phy) mib->rx_ampdu_bytes_cnt += mt76_rr(dev, MT_MIB_SDR23(0)); mib->rx_ba_cnt += mt76_rr(dev, MT_MIB_SDR31(0)); + for (i = 0; i < ARRAY_SIZE(mib->tx_amsdu); i++) { + val = mt76_rr(dev, MT_PLE_AMSDU_PACK_MSDU_CNT(i)); + mib->tx_amsdu[i] += val; + mib->tx_amsdu_cnt += val; + } + for (i = 0, aggr1 = aggr0 + 4; i < 4; i++) { u32 val2; diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net/wireless/mediatek/mt76/mt7921/main.c index bd49cfd59617..575f23d9ec52 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c @@ -958,8 +958,8 @@ void mt7921_get_et_stats(struct ieee80211_hw *hw, struct ieee80211_vif *vif, data[ei++] = mib->tx_bf_rx_fb_ht_cnt; /* Tx amsdu info (pack-count histogram) */ - for (i = 0; i < 8; i++) - data[ei++] = mt76_rr(dev, MT_PLE_AMSDU_PACK_MSDU_CNT(i)); + for (i = 0; i < ARRAY_SIZE(mib->tx_amsdu); i++) + data[ei++] = mib->tx_amsdu[i]; /* rx counters */ data[ei++] = mib->rx_mpdu_cnt; diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h index 9347859a291c..e9c7c3a19507 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h @@ -148,6 +148,9 @@ struct mib_stats { u32 rx_ampdu_cnt; u32 rx_ampdu_bytes_cnt; u32 rx_ba_cnt; + + u32 tx_amsdu[8]; + u32 tx_amsdu_cnt; }; struct mt7921_phy { From patchwork Tue Oct 19 10:12:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 12569403 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 74496C433FE for ; Tue, 19 Oct 2021 10:13:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5B89F6137B for ; Tue, 19 Oct 2021 10:13:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235192AbhJSKPd (ORCPT ); Tue, 19 Oct 2021 06:15:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:58862 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235194AbhJSKPd (ORCPT ); Tue, 19 Oct 2021 06:15:33 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7FBE161381; Tue, 19 Oct 2021 10:13:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634638400; bh=VVTlSBQOGa2kk4lyUAjz7dkItqkDENVUvqxqBMA5HFc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o4xDR2kYiPacRH6OPdPKbpIoIKfpKOTA6jj4Jq0UgVIgDOKOThtY0/xi/ZBy7vniu pJFLIEi3rMrWD7YriAJTSW7yb57yAivX7V4Q8aItB38vAqwB2uGmEKriZ792RY/065 aWjBCUC1uP/jJYNj6wrYD4FhZd4DQONylwjTCX04AP+wAEEsBwm5/eLiv4LEmrowTJ +CQCHj1+GaOE+ugyylTNMxKHxRi0XpywFa0CiIbnS4+uqpAA9N9A1KPiofP25162o1 rC3OCqfySvF2qMeux6tkSu3EPhZ5uzgtid1NEmPTUiUfSOaftdZB8HsUYZEXUqYs2I Uuw9L2Ca9aHQg== From: Lorenzo Bianconi To: nbd@nbd.name Cc: linux-wireless@vger.kernel.org, lorenzo.bianconi@redhat.com, sean.wang@mediatek.com, greearb@candelatech.com, ryder.lee@mediatek.com Subject: [PATCH v2 10/10] mt76: mt7921: add per-vif counters in ethtool Date: Tue, 19 Oct 2021 12:12:32 +0200 Message-Id: <68c6dbd092df7df071c707dadc0b5148e6b4c732.1634637742.git.lorenzo@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Similar to mt7915 driver, add per-vif tx counters in ethtool. Signed-off-by: Lorenzo Bianconi --- .../net/wireless/mediatek/mt76/mt7921/main.c | 53 ++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net/wireless/mediatek/mt76/mt7921/main.c index 575f23d9ec52..35a490c049e9 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c @@ -902,7 +902,33 @@ static const char mt7921_gstrings_stats[][ETH_GSTRING_LEN] = { "rx_mpdu_cnt", "rx_ampdu_cnt", "rx_ampdu_bytes_cnt", - "rx_ba_cnt" + "rx_ba_cnt", + /* per vif counters */ + "v_tx_mode_cck", + "v_tx_mode_ofdm", + "v_tx_mode_ht", + "v_tx_mode_ht_gf", + "v_tx_mode_vht", + "v_tx_mode_he_su", + "v_tx_mode_he_ext_su", + "v_tx_mode_he_tb", + "v_tx_mode_he_mu", + "v_tx_bw_20", + "v_tx_bw_40", + "v_tx_bw_80", + "v_tx_bw_160", + "v_tx_mcs_0", + "v_tx_mcs_1", + "v_tx_mcs_2", + "v_tx_mcs_3", + "v_tx_mcs_4", + "v_tx_mcs_5", + "v_tx_mcs_6", + "v_tx_mcs_7", + "v_tx_mcs_8", + "v_tx_mcs_9", + "v_tx_mcs_10", + "v_tx_mcs_11", }; static void @@ -922,13 +948,30 @@ mt7921_get_et_sset_count(struct ieee80211_hw *hw, struct ieee80211_vif *vif, return sset == ETH_SS_STATS ? ARRAY_SIZE(mt7921_gstrings_stats) : 0; } +static void +mt7921_ethtool_worker(void *wi_data, struct ieee80211_sta *sta) +{ + struct mt7921_sta *msta = (struct mt7921_sta *)sta->drv_priv; + struct mt76_ethtool_worker_info *wi = wi_data; + + if (msta->vif->mt76.idx != wi->idx) + return; + + mt76_ethtool_worker(wi, &msta->stats); +} + static void mt7921_get_et_stats(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ethtool_stats *stats, u64 *data) { + struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv; struct mt7921_phy *phy = mt7921_hw_phy(hw); struct mt7921_dev *dev = phy->dev; struct mib_stats *mib = &phy->mib; + struct mt76_ethtool_worker_info wi = { + .data = data, + .idx = mvif->mt76.idx, + }; int i, ei = 0; mt7921_mutex_acquire(dev); @@ -967,8 +1010,16 @@ void mt7921_get_et_stats(struct ieee80211_hw *hw, struct ieee80211_vif *vif, data[ei++] = mib->rx_ampdu_bytes_cnt; data[ei++] = mib->rx_ba_cnt; + /* Add values for all stations owned by this vif */ + wi.initial_stat_idx = ei; + ieee80211_iterate_stations_atomic(hw, mt7921_ethtool_worker, &wi); + mt7921_mutex_release(dev); + if (!wi.sta_count) + return; + + ei += wi.worker_stat_count; if (ei != ARRAY_SIZE(mt7921_gstrings_stats)) dev_err(dev->mt76.dev, "ei: %d SSTATS_LEN: %lu", ei, ARRAY_SIZE(mt7921_gstrings_stats));