From: greearb@candelatech.com
To: linux-wireless@vger.kernel.org
Cc: Ben Greear <greearb@candelatech.com>
Subject: [PATCH v3 3/8] mt76 - mt7915: Add some per-station tx stats to ethtool.
Date: Thu, 22 Jul 2021 13:24:59 -0700 [thread overview]
Message-ID: <20210722202504.6180-3-greearb@candelatech.com> (raw)
In-Reply-To: <20210722202504.6180-1-greearb@candelatech.com>
From: Ben Greear <greearb@candelatech.com>
The tx status callback is not called for every frame, so
those specific counters under-count, but at least they give
some idea of what is going on.
Signed-off-by: Ben Greear <greearb@candelatech.com>
---
.../wireless/mediatek/mt76/mt7915/debugfs.c | 116 +++++++++++++++++-
1 file changed, 110 insertions(+), 6 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c b/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c
index 469028d641c7..ad400ddf36c3 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c
@@ -425,6 +425,35 @@ static const char mt7915_gstrings_stats[][ETH_GSTRING_LEN] = {
"tx_msdu_pack_6",
"tx_msdu_pack_7",
"tx_msdu_pack_8",
+ /* per vif counters */
+ "v_tx_mpdu_attempts",
+ "v_tx_mpdu_fail",
+ "v_tx_mpdu_retry",
+ "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",
};
#define MT7915_SSTATS_LEN ARRAY_SIZE(mt7915_gstrings_stats)
@@ -454,14 +483,15 @@ void mt7915_debug_get_et_stats(struct ieee80211_hw *hw,
{
struct mt7915_dev *dev = mt7915_hw_dev(hw);
struct mt7915_phy *phy = mt7915_hw_phy(hw);
-
- /* TODO: These are mostly dev-wide stats at this point.
- * Get some per-vif stats?
- */
+ struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv;
+ struct mt76_wcid *wcid;
+ struct mt7915_sta *msta;
+ struct mt7915_sta_stats *mstats;
+ bool found_sta = false;
/* See mt7915_ampdu_stat_read_phy, etc */
bool ext_phy = phy != &dev->phy;
- int i, n, cnt;
+ int i, j, n, cnt, next_ei;
int ei = 0;
if (!phy)
@@ -515,6 +545,80 @@ void mt7915_debug_get_et_stats(struct ieee80211_hw *hw,
for (i = 0; i < 8; i++)
data[ei++] = mt76_rr(dev, MT_PLE_AMSDU_PACK_MSDU_CNT(i));
- WARN_ON(ei != MT7915_SSTATS_LEN);
+ /* Add values for all stations owned by this vif */
+
+ /* See mt76_get_min_avr_rssi for example of how to find all sta
+ * for a vif
+ */
+ local_bh_disable();
+ rcu_read_lock();
+
+ next_ei = ei;
+
+ for (i = 0; i < ARRAY_SIZE(dev->mt76.wcid_mask); i++) {
+ u32 mask = dev->mt76.wcid_mask[i];
+ u32 phy_mask = dev->mt76.wcid_phy_mask[i];
+ int q;
+
+ if (!mask)
+ continue;
+
+ for (j = i * 32; mask; j++, mask >>= 1, phy_mask >>= 1) {
+ if (!(mask & 1))
+ continue;
+
+ if (!!(phy_mask & 1) != ext_phy)
+ continue;
+
+ wcid = rcu_dereference(dev->mt76.wcid[j]);
+ if (!wcid)
+ continue;
+
+ msta = container_of(wcid, struct mt7915_sta, wcid);
+
+ if (msta->vif != mvif)
+ continue;
+
+ ei = next_ei;
+ mstats = &msta->stats;
+ data[ei++] += mstats->tx_mpdu_attempts;
+ data[ei++] += mstats->tx_mpdu_fail;
+ data[ei++] += mstats->tx_mpdu_retry;
+ 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];
+ found_sta = true;
+ }
+ }
+
+ rcu_read_unlock();
+ local_bh_enable();
+
+ /* If we have no stations above, then we will not have filled out
+ * the STA stats. Zero those stats.
+ */
+ if (!found_sta) {
+ int q;
+
+ for (q = 0; q < 28; q++)
+ data[ei++] = 0;
+ }
+
+ if (ei != MT7915_SSTATS_LEN) {
+ pr_err("ei: %d MT7915_SSTATS_LEN: %d", ei, (int)(MT7915_SSTATS_LEN));
+ WARN_ON_ONCE(ei != MT7915_SSTATS_LEN);
+ }
}
--
2.20.1
next prev parent reply other threads:[~2021-07-22 20:25 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-22 20:24 [PATCH v3 1/8] mt76 - mt7915: Add ethtool stats support greearb
2021-07-22 20:24 ` [PATCH v3 2/8] mt76 - mt7915: Add tx stats gathered from tx-status callbacks greearb
2021-07-22 21:45 ` Lorenzo Bianconi
2021-07-22 20:24 ` greearb [this message]
2021-07-22 21:46 ` [PATCH v3 3/8] mt76 - mt7915: Add some per-station tx stats to ethtool Lorenzo Bianconi
2021-07-22 20:25 ` [PATCH v3 4/8] mt76 - mt7915: Add tx mu/su counters to mib greearb
2021-07-22 21:48 ` Lorenzo Bianconi
2021-07-22 20:25 ` [PATCH v3 5/8] mt76 - mt7915: Move more tx-bf stats " greearb
2021-07-22 20:25 ` [PATCH v3 6/8] mt76 - mt7915: Fix he_mcs capabilities for 160mhz greearb
2021-07-22 20:25 ` [PATCH v3 7/8] mt76 - mt7915: Add more MIB registers greearb
2021-07-22 20:25 ` [PATCH v3 8/8] mt76 - mt7915: Add mib counters to ethtool stats greearb
2021-07-22 20:52 ` [PATCH v3 1/8] mt76 - mt7915: Add ethtool stats support Lorenzo Bianconi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210722202504.6180-3-greearb@candelatech.com \
--to=greearb@candelatech.com \
--cc=linux-wireless@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).