From: Wei Fang <wei.fang@nxp.com>
To: claudiu.manoil@nxp.com, vladimir.oltean@nxp.com,
xiaoning.wang@nxp.com, andrew+netdev@lunn.ch,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
imx@lists.linux.dev
Subject: [PATCH net-next 4/5] net: enetc: add unstructured pMAC counters for ENETC v1
Date: Wed, 8 Apr 2026 13:58:48 +0800 [thread overview]
Message-ID: <20260408055849.1314033-5-wei.fang@nxp.com> (raw)
In-Reply-To: <20260408055849.1314033-1-wei.fang@nxp.com>
The ENETC v1 has two MACs (eMAC and pMAC) to support preemption. The
existing unstructured counters include the eMAC counters, but not the
pMAC counters. So add pMAC counters to improve statistical coverage.
Signed-off-by: Wei Fang <wei.fang@nxp.com>
---
.../ethernet/freescale/enetc/enetc_ethtool.c | 77 ++++++++++++++-----
1 file changed, 56 insertions(+), 21 deletions(-)
diff --git a/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c b/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c
index 504def405489..bdc5916e4400 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c
+++ b/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c
@@ -129,18 +129,35 @@ static const struct {
static const struct {
int reg;
char name[ETH_GSTRING_LEN] __nonstring;
-} enetc_pm_counters[] = {
- { ENETC_PM_RVLAN(0), "MAC rx VLAN frames" },
- { ENETC_PM_RERR(0), "MAC rx frame errors" },
- { ENETC_PM_RUCA(0), "MAC rx unicast frames" },
- { ENETC_PM_RDRP(0), "MAC rx dropped packets" },
- { ENETC_PM_RPKT(0), "MAC rx packets" },
- { ENETC_PM_TOCT(0), "MAC tx octets" },
- { ENETC_PM_TFCS(0), "MAC tx fcs errors" },
- { ENETC_PM_TVLAN(0), "MAC tx VLAN frames" },
- { ENETC_PM_TUCA(0), "MAC tx unicast frames" },
- { ENETC_PM_TPKT(0), "MAC tx packets" },
- { ENETC_PM_TUND(0), "MAC tx undersized packets" },
+} enetc_emac_counters[] = {
+ { ENETC_PM_RVLAN(0), "eMAC rx VLAN frames" },
+ { ENETC_PM_RERR(0), "eMAC rx frame errors" },
+ { ENETC_PM_RUCA(0), "eMAC rx unicast frames" },
+ { ENETC_PM_RDRP(0), "eMAC rx dropped packets" },
+ { ENETC_PM_RPKT(0), "eMAC rx packets" },
+ { ENETC_PM_TOCT(0), "eMAC tx octets" },
+ { ENETC_PM_TFCS(0), "eMAC tx fcs errors" },
+ { ENETC_PM_TVLAN(0), "eMAC tx VLAN frames" },
+ { ENETC_PM_TUCA(0), "eMAC tx unicast frames" },
+ { ENETC_PM_TPKT(0), "eMAC tx packets" },
+ { ENETC_PM_TUND(0), "eMAC tx undersized packets" },
+};
+
+static const struct {
+ int reg;
+ char name[ETH_GSTRING_LEN] __nonstring;
+} enetc_pmac_counters[] = {
+ { ENETC_PM_RVLAN(1), "pMAC rx VLAN frames" },
+ { ENETC_PM_RERR(1), "pMAC rx frame errors" },
+ { ENETC_PM_RUCA(1), "pMAC rx unicast frames" },
+ { ENETC_PM_RDRP(1), "pMAC rx dropped packets" },
+ { ENETC_PM_RPKT(1), "pMAC rx packets" },
+ { ENETC_PM_TOCT(1), "pMAC tx octets" },
+ { ENETC_PM_TFCS(1), "pMAC tx fcs errors" },
+ { ENETC_PM_TVLAN(1), "pMAC tx VLAN frames" },
+ { ENETC_PM_TUCA(1), "pMAC tx unicast frames" },
+ { ENETC_PM_TPKT(1), "pMAC tx packets" },
+ { ENETC_PM_TUND(1), "pMAC tx undersized packets" },
};
static const struct {
@@ -181,6 +198,7 @@ static const char tx_ring_stats[][ETH_GSTRING_LEN] = {
static int enetc_get_sset_count(struct net_device *ndev, int sset)
{
struct enetc_ndev_priv *priv = netdev_priv(ndev);
+ struct enetc_si *si = priv->si;
int len;
if (sset != ETH_SS_STATS)
@@ -190,11 +208,14 @@ static int enetc_get_sset_count(struct net_device *ndev, int sset)
ARRAY_SIZE(tx_ring_stats) * priv->num_tx_rings +
ARRAY_SIZE(rx_ring_stats) * priv->num_rx_rings;
- if (!enetc_si_is_pf(priv->si))
+ if (!enetc_si_is_pf(si))
return len;
len += ARRAY_SIZE(enetc_port_counters);
- len += ARRAY_SIZE(enetc_pm_counters);
+ len += ARRAY_SIZE(enetc_emac_counters);
+
+ if (si->hw_features & ENETC_SI_F_QBU)
+ len += ARRAY_SIZE(enetc_pmac_counters);
return len;
}
@@ -202,6 +223,7 @@ static int enetc_get_sset_count(struct net_device *ndev, int sset)
static void enetc_get_strings(struct net_device *ndev, u32 stringset, u8 *data)
{
struct enetc_ndev_priv *priv = netdev_priv(ndev);
+ struct enetc_si *si = priv->si;
int i, j;
switch (stringset) {
@@ -215,14 +237,20 @@ static void enetc_get_strings(struct net_device *ndev, u32 stringset, u8 *data)
for (j = 0; j < ARRAY_SIZE(rx_ring_stats); j++)
ethtool_sprintf(&data, rx_ring_stats[j], i);
- if (!enetc_si_is_pf(priv->si))
+ if (!enetc_si_is_pf(si))
break;
for (i = 0; i < ARRAY_SIZE(enetc_port_counters); i++)
ethtool_cpy(&data, enetc_port_counters[i].name);
- for (i = 0; i < ARRAY_SIZE(enetc_pm_counters); i++)
- ethtool_cpy(&data, enetc_pm_counters[i].name);
+ for (i = 0; i < ARRAY_SIZE(enetc_emac_counters); i++)
+ ethtool_cpy(&data, enetc_emac_counters[i].name);
+
+ if (!(si->hw_features & ENETC_SI_F_QBU))
+ break;
+
+ for (i = 0; i < ARRAY_SIZE(enetc_pmac_counters); i++)
+ ethtool_cpy(&data, enetc_pmac_counters[i].name);
break;
}
@@ -232,7 +260,8 @@ static void enetc_get_ethtool_stats(struct net_device *ndev,
struct ethtool_stats *stats, u64 *data)
{
struct enetc_ndev_priv *priv = netdev_priv(ndev);
- struct enetc_hw *hw = &priv->si->hw;
+ struct enetc_si *si = priv->si;
+ struct enetc_hw *hw = &si->hw;
int i, o = 0;
for (i = 0; i < ARRAY_SIZE(enetc_si_counters); i++)
@@ -256,14 +285,20 @@ static void enetc_get_ethtool_stats(struct net_device *ndev,
data[o++] = enetc_rd(hw, ENETC_RBDCR(i));
}
- if (!enetc_si_is_pf(priv->si))
+ if (!enetc_si_is_pf(si))
return;
for (i = 0; i < ARRAY_SIZE(enetc_port_counters); i++)
data[o++] = enetc_port_rd(hw, enetc_port_counters[i].reg);
- for (i = 0; i < ARRAY_SIZE(enetc_pm_counters); i++)
- data[o++] = enetc_port_rd64(hw, enetc_pm_counters[i].reg);
+ for (i = 0; i < ARRAY_SIZE(enetc_emac_counters); i++)
+ data[o++] = enetc_port_rd64(hw, enetc_emac_counters[i].reg);
+
+ if (!(si->hw_features & ENETC_SI_F_QBU))
+ return;
+
+ for (i = 0; i < ARRAY_SIZE(enetc_pmac_counters); i++)
+ data[o++] = enetc_port_rd64(hw, enetc_pmac_counters[i].reg);
}
static void enetc_pause_stats(struct enetc_si *si, int mac,
--
2.34.1
next prev parent reply other threads:[~2026-04-08 6:24 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-08 5:58 [PATCH net-next 0/5] net: enetc: improve statistics for v1 and add statistics for v4 Wei Fang
2026-04-08 5:58 ` [PATCH net-next 1/5] net: enetc: add support for the standardized counters Wei Fang
2026-04-08 5:58 ` [PATCH net-next 2/5] net: enetc: show RX drop counters only for assigned RX rings Wei Fang
2026-04-08 5:58 ` [PATCH net-next 3/5] net: enetc: remove standardized counters from enetc_pm_counters Wei Fang
2026-04-08 5:58 ` Wei Fang [this message]
2026-04-08 5:58 ` [PATCH net-next 5/5] net: enetc: add unstructured counters for ENETC v4 Wei Fang
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=20260408055849.1314033-5-wei.fang@nxp.com \
--to=wei.fang@nxp.com \
--cc=andrew+netdev@lunn.ch \
--cc=claudiu.manoil@nxp.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=imx@lists.linux.dev \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=vladimir.oltean@nxp.com \
--cc=xiaoning.wang@nxp.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