linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lorenzo Bianconi <lorenzo@kernel.org>
To: nbd@nbd.name
Cc: linux-wireless@vger.kernel.org, lorenzo.bianconi@redhat.com,
	sean.wang@mediatek.com, greearb@candelatech.com
Subject: [PATCH 02/10] mt76: mt7921: add sta stats accounting in mt7921_mac_add_txs_skb
Date: Mon, 18 Oct 2021 14:14:01 +0200	[thread overview]
Message-ID: <4284f5579ab00f3fb591953fc2ac4c90393781cf.1634558817.git.lorenzo@kernel.org> (raw)
In-Reply-To: <cover.1634558817.git.lorenzo@kernel.org>

This is a preliminary patch to add ethtool stats to mt7921 driver.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
 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 0659ff290af9..5380e91c5886 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c
@@ -1165,14 +1165,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);
@@ -1198,7 +1200,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;
@@ -1241,19 +1249,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 e14b86b1c6d1..be9da985d129 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
@@ -81,6 +81,7 @@ struct mt7921_sta {
 
 	unsigned long last_txs;
 	unsigned long ampdu_state;
+	struct mt76_sta_stats stats;
 
 	struct mt7921_sta_key_conf bip;
 };
-- 
2.31.1


  parent reply	other threads:[~2021-10-18 12:14 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-18 12:13 [PATCH 00/10] mt76: ethtool stats features and fixes Lorenzo Bianconi
2021-10-18 12:14 ` [PATCH 01/10] mt76: move mt76_sta_stats in mt76.h Lorenzo Bianconi
2021-10-18 12:14 ` Lorenzo Bianconi [this message]
2021-10-18 12:14 ` [PATCH 03/10] mt76: mt7921: add some more MIB counters Lorenzo Bianconi
2021-10-18 12:14 ` [PATCH 04/10] mt76: mt7921: introduce stats reporting through ethtool Lorenzo Bianconi
2021-10-18 12:14 ` [PATCH 05/10] mt76: mt7921: move tx amsdu stats in mib_stats Lorenzo Bianconi
2021-10-18 12:14 ` [PATCH 06/10] mt76: move mt76_ethtool_worker_info in mt76 module Lorenzo Bianconi
2021-10-18 12:14 ` [PATCH 07/10] mt76: mt7921: add per-vif counters in ethtool Lorenzo Bianconi
2021-10-18 12:14 ` [PATCH 08/10] mt76: mt7915: run mt7915_get_et_stats holding mt76 mutex Lorenzo Bianconi
2021-10-18 12:14 ` [PATCH 09/10] mt76: mt7915: do not overwrite all mib counters in mt7915_get_stats Lorenzo Bianconi
2021-10-18 12:14 ` [PATCH 10/10] mt76: mt7915: move tx amsdu stats in mib_stats Lorenzo Bianconi
2021-10-18 21:04 ` [PATCH 00/10] mt76: ethtool stats features and fixes 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=4284f5579ab00f3fb591953fc2ac4c90393781cf.1634558817.git.lorenzo@kernel.org \
    --to=lorenzo@kernel.org \
    --cc=greearb@candelatech.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=lorenzo.bianconi@redhat.com \
    --cc=nbd@nbd.name \
    --cc=sean.wang@mediatek.com \
    /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).