linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: greearb@candelatech.com
To: linux-wireless@vger.kernel.org
Cc: Ben Greear <greearb@candelatech.com>
Subject: [PATCH 10/15] mt76: mt7915:  add ethtool tx/rx pkts/bytes
Date: Wed, 11 Aug 2021 14:44:34 -0700	[thread overview]
Message-ID: <20210811214439.17458-11-greearb@candelatech.com> (raw)
In-Reply-To: <20210811214439.17458-1-greearb@candelatech.com>

From: Ben Greear <greearb@candelatech.com>

These stats are provided with same name by ath10k
and some intel wired NIC drivers.  Add them to mt7915
as well to allow user-space code to more easily get some
basic stats out of the radio.

Signed-off-by: Ben Greear <greearb@candelatech.com>
---
 drivers/net/wireless/mediatek/mt76/mt7915/mac.c    |  7 +++++++
 drivers/net/wireless/mediatek/mt76/mt7915/main.c   | 11 +++++++++++
 drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h |  7 +++++++
 3 files changed, 25 insertions(+)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
index 7ca06b8c9671..9883d1e55f5b 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
@@ -782,6 +782,9 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb)
 			mt7915_mac_decode_he_mu_radiotap(skb, status, rxv);
 	}
 
+	mib->rx_pkts_nic++;
+	mib->rx_bytes_nic += skb->len;
+
 	if (!status->wcid || !ieee80211_is_data_qos(fc))
 		return 0;
 
@@ -1341,6 +1344,8 @@ mt7915_txwi_free(struct mt7915_dev *dev, struct mt76_txwi_cache *t,
 	u16 wcid_idx;
 	struct ieee80211_tx_info *info;
 	struct ieee80211_tx_rate *rate;
+	struct mt7915_phy *phy = &dev->phy;
+	struct mib_stats *mib = &phy->mib;
 
 	mt7915_txp_skb_unmap(mdev, t);
 	if (!t->skb)
@@ -1422,6 +1427,8 @@ mt7915_txwi_free(struct mt7915_dev *dev, struct mt76_txwi_cache *t,
 	/* Apply the values that this txfree path reports */
 	rate->count = tx_cnt;
 	if (tx_status == 0) {
+		mib->tx_pkts_nic++;
+		mib->tx_bytes_nic += t->skb->len;
 		info->flags |= IEEE80211_TX_STAT_ACK;
 		info->status.ampdu_ack_len = 1;
 	} else {
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/main.c b/drivers/net/wireless/mediatek/mt76/mt7915/main.c
index 22ceb46be4bf..4f609a5d38a4 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/main.c
@@ -1030,6 +1030,10 @@ static void mt7915_sta_set_decap_offload(struct ieee80211_hw *hw,
 }
 
 static const char mt7915_gstrings_stats[][ETH_GSTRING_LEN] = {
+	"tx_pkts_nic", /* from driver, phy tx-ok skb */
+	"tx_bytes_nic", /* from driver, phy tx-ok bytes */
+	"rx_pkts_nic", /* from driver, phy rx OK skb */
+	"rx_bytes_nic", /* from driver, phy rx OK bytes */
 	"tx_ampdu_cnt",
 	"tx_stop_q_empty_cnt",
 	"tx_mpdu_attempts",
@@ -1265,6 +1269,13 @@ void mt7915_get_et_stats(struct ieee80211_hw *hw,
 	if (!phy)
 		return;
 
+	/* driver phy-wide stats */
+	data[ei++] = mib->tx_pkts_nic;
+	data[ei++] = mib->tx_bytes_nic;
+	data[ei++] = mib->rx_pkts_nic;
+	data[ei++] = mib->rx_bytes_nic;
+
+	/* MIB stats from FW/HW */
 	data[ei++] = mib->tx_ampdu_cnt;
 	data[ei++] = mib->tx_stop_q_empty_cnt;
 	data[ei++] = mib->tx_mpdu_attempts_cnt;
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h
index 2d7c84946e40..1a0d7d62c582 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h
@@ -125,6 +125,13 @@ struct mt7915_vif {
 
 /* per-phy stats.  */
 struct mib_stats {
+	/* phy wide driver stats */
+	u32 tx_pkts_nic; /* tx OK skb */
+	u32 tx_bytes_nic; /* tx OK bytes */
+	u32 rx_pkts_nic; /* rx OK skb */
+	u32 rx_bytes_nic; /* rx OK bytes */
+
+	/* MIB counters from FW/HW */
 	u32 ack_fail_cnt;
 	u32 fcs_err_cnt;
 	u32 rts_cnt;
-- 
2.20.1


  parent reply	other threads:[~2021-08-11 21:45 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-11 21:44 [PATCH 00/15] mt7915 stats and debugging improvements greearb
2021-08-11 21:44 ` [PATCH 01/15] mt76: mt7915: add comments about rx descriptor parsing greearb
2021-08-11 21:44 ` [PATCH 02/15] mt76: mt7915: print out hw revision greearb
2021-08-11 21:44 ` [PATCH 03/15] mt76: mt7915: tx_stats debugfs to read from mib greearb
2021-08-11 21:44 ` [PATCH 04/15] mt76: mt7915: support enabling rx group-5 status greearb
2021-08-11 21:44 ` [PATCH 05/15] mt76: mt7915: use nss for calculating rx-chains greearb
2021-08-11 21:44 ` [PATCH 06/15] mt76: mt7915: rename amsdu_pack_stats to tx_amsdu_pack_stats greearb
2021-08-11 21:44 ` [PATCH 07/15] mt76: mt7915: ethtool group-5 rx stats information greearb
2021-08-11 21:44 ` [PATCH 08/15] mt76: mt7915: ethtool counters for driver rx path greearb
2021-08-11 21:44 ` [PATCH 09/15] mt76: mt7915: fix rate rix and flags in txs path greearb
2021-08-11 21:44 ` greearb [this message]
2021-08-11 21:44 ` [PATCH 11/15] mt76: mt7915: debugfs display for pse non-empty queues greearb
2021-08-11 21:44 ` [PATCH 12/15] mt76: mt7915: add more pse queue data to debugfs greearb
2021-08-11 21:44 ` [PATCH 13/15] mt76: mt7915: add rx-ppdu-size-out-of-range ethtool counter greearb
2021-08-11 21:44 ` [PATCH 14/15] mt76: mt7915: ethtool and mib rx stats greearb
2021-08-11 21:44 ` [PATCH 15/15] mt76: mt7915: poll mib counters every 200ms greearb

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=20210811214439.17458-11-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).