From: Vitaliy Sochnev <sochnev.v.74@gmail.com>
To: Lorenzo Bianconi <lorenzo@kernel.org>, netdev@vger.kernel.org
Cc: Andrew Lunn <andrew+netdev@lunn.ch>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
linux-mediatek@lists.infradead.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
Vitaliy Sochnev <sochnev.v.74@gmail.com>
Subject: [PATCH net-next 3/4] net: airoha: add rx_stall_recover ethtool counter
Date: Sun, 30 Aug 2026 10:57:16 +0100 [thread overview]
Message-ID: <20260830095717.37218-4-sochnev.v.74@gmail.com> (raw)
In-Reply-To: <20260830095717.37218-1-sochnev.v.74@gmail.com>
Make the RX-ring hw-stall recovery added by the previous commit
observable without grepping dmesg for its dev_warn_ratelimited():
add a custom ethtool -S statistic, rx_stall_recover, incremented once
per completed recovery.
It's tracked per-QDMA-instance rather than per-netdev, since the
stalled ring can carry traffic for more than one netdev at once (VIP
classification shares ring 4 across several protocols/ports on this
hardware) - there's no single netdev to attribute an individual event
to, so all netdevs behind the same QDMA instance report the same
aggregate count.
Kept separate from the actual recovery fix since this adds new
ethtool ABI and has no bearing on correctness; happy to have it queued
independently if that's preferred.
Signed-off-by: Vitaliy Sochnev <sochnev.v.74@gmail.com>
---
drivers/net/ethernet/airoha/airoha_eth.c | 44 ++++++++++++++++++++++++
drivers/net/ethernet/airoha/airoha_eth.h | 5 +++
2 files changed, 49 insertions(+)
diff --git a/drivers/net/ethernet/airoha/airoha_eth.c b/drivers/net/ethernet/airoha/airoha_eth.c
index b53fe5b17653..efb1dd69cc16 100644
--- a/drivers/net/ethernet/airoha/airoha_eth.c
+++ b/drivers/net/ethernet/airoha/airoha_eth.c
@@ -1000,6 +1000,7 @@ static void airoha_qdma_rx_recover_work(struct work_struct *work)
napi_enable(&q->napi);
napi_schedule(&q->napi);
+ qdma->rx_recover_count++;
dev_warn_ratelimited(qdma->eth->dev,
"qid=%d RX ring recovered after hw stall (RX DMA paused for %lld us on this QDMA instance)\n",
qid, rx_dma_off_us);
@@ -2600,6 +2601,46 @@ static void airoha_ethtool_get_drvinfo(struct net_device *netdev,
strscpy(info->bus_info, dev_name(eth->dev), sizeof(info->bus_info));
}
+static const char airoha_ethtool_stats_str[][ETH_GSTRING_LEN] = {
+ "rx_stall_recover",
+};
+
+static void airoha_ethtool_get_strings(struct net_device *netdev, u32 sset,
+ u8 *data)
+{
+ int i;
+
+ if (sset != ETH_SS_STATS)
+ return;
+
+ for (i = 0; i < ARRAY_SIZE(airoha_ethtool_stats_str); i++)
+ ethtool_puts(&data, airoha_ethtool_stats_str[i]);
+}
+
+static int airoha_ethtool_get_sset_count(struct net_device *netdev, int sset)
+{
+ return sset == ETH_SS_STATS ?
+ ARRAY_SIZE(airoha_ethtool_stats_str) : -EOPNOTSUPP;
+}
+
+static void airoha_ethtool_get_ethtool_stats(struct net_device *netdev,
+ struct ethtool_stats *stats,
+ u64 *data)
+{
+ struct airoha_gdm_dev *dev = netdev_priv(netdev);
+ struct airoha_qdma *qdma;
+
+ rcu_read_lock();
+ qdma = rcu_dereference(dev->qdma);
+ /* aggregate recovery count for the whole qdma instance: the
+ * stalled ring can carry traffic for more than one netdev (VIP
+ * classification shares ring 4 across several protocols/ports),
+ * so there's no single netdev to attribute an individual event to
+ */
+ data[0] = qdma ? qdma->rx_recover_count : 0;
+ rcu_read_unlock();
+}
+
static void airoha_ethtool_get_mac_stats(struct net_device *netdev,
struct ethtool_eth_mac_stats *stats)
{
@@ -3502,6 +3543,9 @@ static const struct net_device_ops airoha_netdev_ops = {
static const struct ethtool_ops airoha_ethtool_ops = {
.get_drvinfo = airoha_ethtool_get_drvinfo,
+ .get_strings = airoha_ethtool_get_strings,
+ .get_sset_count = airoha_ethtool_get_sset_count,
+ .get_ethtool_stats = airoha_ethtool_get_ethtool_stats,
.get_eth_mac_stats = airoha_ethtool_get_mac_stats,
.get_rmon_stats = airoha_ethtool_get_rmon_stats,
.get_link_ksettings = phy_ethtool_get_link_ksettings,
diff --git a/drivers/net/ethernet/airoha/airoha_eth.h b/drivers/net/ethernet/airoha/airoha_eth.h
index 483d6b59c351..d6591a779743 100644
--- a/drivers/net/ethernet/airoha/airoha_eth.h
+++ b/drivers/net/ethernet/airoha/airoha_eth.h
@@ -582,6 +582,11 @@ struct airoha_qdma {
*/
struct work_struct rx_recover_work;
DECLARE_BITMAP(rx_recover_mask, AIROHA_NUM_RX_RING);
+ /* count of completed hw-stall recoveries, exposed via ethtool -S
+ * so a recovery event (and the packets it drops) is observable
+ * without grepping dmesg for the dev_warn_ratelimited() above
+ */
+ u32 rx_recover_count;
DECLARE_BITMAP(qos_channel_map, AIROHA_NUM_QOS_CHANNELS);
};
--
2.55.0
next prev parent reply other threads:[~2026-08-30 7:58 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-30 9:57 [PATCH 0/4] net: airoha: fix silent RX packet loss on ring 4 Vitaliy Sochnev
2026-08-30 9:57 ` [PATCH net 1/4] net: airoha: handle RX_NO_CPU_DSCP interrupt, not just RX_DONE Vitaliy Sochnev
2026-08-30 13:26 ` Lorenzo Bianconi
2026-08-30 9:57 ` [PATCH net-next 2/4] net: airoha: recover RX ring after hw completion race Vitaliy Sochnev
2026-08-30 14:18 ` Lorenzo Bianconi
2026-08-30 9:57 ` Vitaliy Sochnev [this message]
2026-08-30 9:57 ` [PATCH net-next 4/4] net: airoha: grow RX ring 4 to 128 descriptors Vitaliy Sochnev
2026-08-30 14:24 ` 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=20260830095717.37218-4-sochnev.v.74@gmail.com \
--to=sochnev.v.74@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=lorenzo@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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
all inboxes | Powered by JetHome®