From: Gagandeep Singh <g.singh@nxp.com>
To: dev@dpdk.org
Cc: hemant.agrawal@nxp.com, Gagandeep Singh <g.singh@nxp.com>
Subject: [PATCH v6 09/13] net/enetc: support stats reset for VF
Date: Tue, 11 Aug 2026 13:10:28 +0530 [thread overview]
Message-ID: <20260811074032.3646324-10-g.singh@nxp.com> (raw)
In-Reply-To: <20260811074032.3646324-1-g.singh@nxp.com>
The NETC SI-level hardware counters (SIROCT0, SIRFRM0, SITOCT0,
SITFRM0, SITDFCR) are read-only for a VF and cannot be directly
zeroed. No VSI-PSI command class exists for stats reset, and using
FLR/soft-reset to clear counters is not reliable due to a known
hardware erratum on some NETC platforms.
Implement stats_reset for the enetc4 VF PMD using a software
snapshot/delta approach: on stats_reset, the current HW counter
values are captured as a baseline in a new per-device
enetc4_vf_stats_saved struct. stats_get then reports the delta
(current_hw_value - saved_baseline), so counters appear to start
from zero after each reset call. Per-ring software Rx error
accumulators (ierrors) are zeroed directly on reset.
Register the stats_reset callback in both VF ops tables
(enetc4_vf_ops and enetc4_vf_ops_no_vsi_m) so the feature is
available regardless of whether the VSI messaging path is enabled.
Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
doc/guides/rel_notes/release_26_11.rst | 1 +
drivers/net/enetc/enetc.h | 17 +++++++
drivers/net/enetc/enetc4_vf.c | 61 +++++++++++++++++++++++---
3 files changed, 74 insertions(+), 5 deletions(-)
diff --git a/doc/guides/rel_notes/release_26_11.rst b/doc/guides/rel_notes/release_26_11.rst
index 1765adc1bc..a42577c681 100644
--- a/doc/guides/rel_notes/release_26_11.rst
+++ b/doc/guides/rel_notes/release_26_11.rst
@@ -70,6 +70,7 @@ New Features
* Added register dump support for ENETC4 PF and VF.
* Added ring parameters support for the ENETC4 VF (rxq_info_get / txq_info_get).
* Refreshed VF link speed on the link-up interrupt in the ENETC4 VF driver.
+ * Added stats reset for the ENETC4 VF using a software snapshot/delta approach.
Removed Items
-------------
diff --git a/drivers/net/enetc/enetc.h b/drivers/net/enetc/enetc.h
index 185fd8c4ee..96e18028a6 100644
--- a/drivers/net/enetc/enetc.h
+++ b/drivers/net/enetc/enetc.h
@@ -105,6 +105,21 @@ struct enetc_bdr {
uint8_t rsc_enable;
};
+/*
+ * Saved SI counter baseline for VF stats reset. Since the SI-level
+ * hardware counters (SIROCT0, SIRFRM0, SITOCT0, SITFRM0, SITDFCR)
+ * are read-only for a VF and cannot be directly zeroed, stats_reset
+ * captures the current counter values as a baseline. stats_get then
+ * reports the delta: current_hw_value - baseline.
+ */
+struct enetc4_vf_stats_saved {
+ uint64_t ipackets;
+ uint64_t opackets;
+ uint64_t ibytes;
+ uint64_t obytes;
+ uint64_t oerrors;
+};
+
struct enetc_eth_hw {
struct rte_eth_dev *ndev;
struct enetc_hw hw;
@@ -125,6 +140,8 @@ struct enetc_eth_hw {
*/
uint8_t vf_link_legacy;
pthread_mutex_t vsi_lock; /* serializes all VSI-PSI mailbox transactions */
+ /* Baseline snapshot for VF stats reset (software delta approach). */
+ struct enetc4_vf_stats_saved vf_stats_saved;
};
/*
diff --git a/drivers/net/enetc/enetc4_vf.c b/drivers/net/enetc/enetc4_vf.c
index da41b999cb..fb777bbeac 100644
--- a/drivers/net/enetc/enetc4_vf.c
+++ b/drivers/net/enetc/enetc4_vf.c
@@ -224,15 +224,64 @@ enetc4_vf_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats,
uint8_t i;
PMD_INIT_FUNC_TRACE();
- stats->ipackets = enetc4_rd(enetc_hw, ENETC4_SIRFRM0);
- stats->opackets = enetc4_rd(enetc_hw, ENETC4_SITFRM0);
- stats->ibytes = enetc4_rd(enetc_hw, ENETC4_SIROCT0);
- stats->obytes = enetc4_rd(enetc_hw, ENETC4_SITOCT0);
- stats->oerrors = enetc4_rd(enetc_hw, ENETC4_SITDFCR);
+
+ /*
+ * The SI-level counters are read-only for a VF; they cannot be
+ * zeroed directly. Instead, stats_reset captures a baseline
+ * snapshot, and stats_get reports the delta so that the reported
+ * values appear to start from zero after each reset call.
+ */
+ stats->ipackets = enetc4_rd(enetc_hw, ENETC4_SIRFRM0) -
+ hw->vf_stats_saved.ipackets;
+ stats->opackets = enetc4_rd(enetc_hw, ENETC4_SITFRM0) -
+ hw->vf_stats_saved.opackets;
+ stats->ibytes = enetc4_rd(enetc_hw, ENETC4_SIROCT0) -
+ hw->vf_stats_saved.ibytes;
+ stats->obytes = enetc4_rd(enetc_hw, ENETC4_SITOCT0) -
+ hw->vf_stats_saved.obytes;
+ stats->oerrors = enetc4_rd(enetc_hw, ENETC4_SITDFCR) -
+ hw->vf_stats_saved.oerrors;
+
for (i = 0; i < dev->data->nb_rx_queues; i++) {
rx_ring = dev->data->rx_queues[i];
stats->ierrors += rx_ring->ierrors;
}
+
+ return 0;
+}
+
+/*
+ * Reset VF statistics by capturing a new baseline snapshot of the
+ * SI-level hardware counters. Because those counters are read-only
+ * for a VF (hardware erratum prevents reliable clear via FLR/soft
+ * reset too), the driver uses a software delta approach: every
+ * stats_get call reports current_hw_value - saved_baseline.
+ */
+static int
+enetc4_vf_stats_reset(struct rte_eth_dev *dev)
+{
+ struct enetc_eth_hw *hw =
+ ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+ struct enetc_hw *enetc_hw = &hw->hw;
+ struct enetc_bdr *rx_ring;
+ uint8_t i;
+
+ PMD_INIT_FUNC_TRACE();
+
+ /* Snapshot current HW SI counter values as the new zero baseline. */
+ hw->vf_stats_saved.ipackets = enetc4_rd(enetc_hw, ENETC4_SIRFRM0);
+ hw->vf_stats_saved.opackets = enetc4_rd(enetc_hw, ENETC4_SITFRM0);
+ hw->vf_stats_saved.ibytes = enetc4_rd(enetc_hw, ENETC4_SIROCT0);
+ hw->vf_stats_saved.obytes = enetc4_rd(enetc_hw, ENETC4_SITOCT0);
+ hw->vf_stats_saved.oerrors = enetc4_rd(enetc_hw, ENETC4_SITDFCR);
+
+ /* Reset the per-ring software Rx error accumulators. */
+ for (i = 0; i < dev->data->nb_rx_queues; i++) {
+ rx_ring = dev->data->rx_queues[i];
+ if (rx_ring)
+ rx_ring->ierrors = 0;
+ }
+
return 0;
}
@@ -1547,6 +1596,7 @@ static const struct eth_dev_ops enetc4_vf_ops_no_vsi_m = {
.dev_stop = enetc4_vf_dev_stop,
.dev_close = enetc4_dev_close,
.stats_get = enetc4_vf_stats_get,
+ .stats_reset = enetc4_vf_stats_reset,
.dev_infos_get = enetc4_vf_dev_infos_get,
.get_reg = enetc4_vf_get_regs,
.mtu_set = enetc4_vf_mtu_set,
@@ -1570,6 +1620,7 @@ static const struct eth_dev_ops enetc4_vf_ops = {
.dev_stop = enetc4_vf_dev_stop,
.dev_close = enetc4_dev_close,
.stats_get = enetc4_vf_stats_get,
+ .stats_reset = enetc4_vf_stats_reset,
.dev_infos_get = enetc4_vf_dev_infos_get,
.fw_version_get = enetc4_vf_fw_version_get,
.get_reg = enetc4_vf_get_regs,
--
2.25.1
next prev parent reply other threads:[~2026-08-11 7:41 UTC|newest]
Thread overview: 110+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-06 11:28 [PATCH 00/14] net/enetc: add new features for ENETC4 VF on i.MX95 Gagandeep Singh
2026-08-06 11:28 ` [PATCH 01/14] net/enetc: add KEEP_CRC offload support for ENETC4 Gagandeep Singh
2026-08-06 11:28 ` [PATCH 02/14] net/enetc: add TSO support for ENETC4 VF Gagandeep Singh
2026-08-06 11:28 ` [PATCH 03/14] net/enetc: add RSC (hardware LRO) support for ENETC4 Gagandeep Singh
2026-08-06 11:28 ` [PATCH 04/14] net/enetc: extend link speed code field to 8-bit for PF-to-VF message Gagandeep Singh
2026-08-06 11:28 ` [PATCH 05/14] net/enetc: support firmware version get for VF Gagandeep Singh
2026-08-06 11:28 ` [PATCH 06/14] net/enetc: support registers dump Gagandeep Singh
2026-08-06 11:28 ` [PATCH 07/14] net/enetc: support ethtool ring parameters Gagandeep Singh
2026-08-06 11:28 ` [PATCH 08/14] net/enetc: refresh link speed on VF link-up interrupt Gagandeep Singh
2026-08-06 11:28 ` [PATCH 09/14] net/enetc: support stats reset for VF Gagandeep Singh
2026-08-06 11:28 ` [PATCH 10/14] net/enetc4: add per-queue Rx interrupt support " Gagandeep Singh
2026-08-06 11:28 ` [PATCH 11/14] net/enetc4: add SI-based port VLAN insertion and removal Gagandeep Singh
2026-08-06 11:28 ` [PATCH 12/14] net/enetc4: update VF link status to bitmask encoding Gagandeep Singh
2026-08-06 11:28 ` [PATCH 13/14] net/enetc4: enable TX PAUSE via VF RX congestion mode Gagandeep Singh
2026-08-06 11:28 ` [PATCH 14/14] net/enetc4: add WRR Tx scheduler devarg for VF rings Gagandeep Singh
2026-08-06 17:00 ` [PATCH 00/14] net/enetc: add new features for ENETC4 VF on i.MX95 Stephen Hemminger
2026-08-07 3:48 ` [PATCH v2 00/14] net/enetc: add new features for ENETC4 VF on i.MX9 Gagandeep Singh
2026-08-07 3:48 ` [PATCH v2 01/14] net/enetc: add KEEP_CRC offload support for ENETC4 Gagandeep Singh
2026-08-07 3:48 ` [PATCH v2 02/14] net/enetc: add TSO support for ENETC4 VF Gagandeep Singh
2026-08-07 3:48 ` [PATCH v2 03/14] net/enetc: add RSC (hardware LRO) support for ENETC4 Gagandeep Singh
2026-08-07 3:48 ` [PATCH v2 04/14] net/enetc: extend link speed code field to 8-bit for PF-to-VF message Gagandeep Singh
2026-08-07 3:48 ` [PATCH v2 05/14] net/enetc: support firmware version get for VF Gagandeep Singh
2026-08-07 3:48 ` [PATCH v2 06/14] net/enetc: support registers dump Gagandeep Singh
2026-08-07 3:48 ` [PATCH v2 07/14] net/enetc: support ethtool ring parameters Gagandeep Singh
2026-08-07 3:48 ` [PATCH v2 08/14] net/enetc: refresh link speed on VF link-up interrupt Gagandeep Singh
2026-08-07 3:48 ` [PATCH v2 09/14] net/enetc: support stats reset for VF Gagandeep Singh
2026-08-07 3:48 ` [PATCH v2 10/14] net/enetc4: add per-queue Rx interrupt support " Gagandeep Singh
2026-08-07 3:48 ` [PATCH v2 11/14] net/enetc4: add SI-based port VLAN insertion and removal Gagandeep Singh
2026-08-07 3:48 ` [PATCH v2 12/14] net/enetc4: update VF link status to bitmask encoding Gagandeep Singh
2026-08-07 3:48 ` [PATCH v2 13/14] net/enetc4: enable TX PAUSE via VF RX congestion mode Gagandeep Singh
2026-08-07 3:48 ` [PATCH v2 14/14] net/enetc4: add WRR Tx scheduler devarg for VF rings Gagandeep Singh
2026-08-07 7:02 ` [PATCH v3 00/14] net/enetc: add new features for ENETC4 VF on i.MX9 Gagandeep Singh
2026-08-07 7:02 ` [PATCH v3 01/14] net/enetc: add KEEP_CRC offload support for ENETC4 Gagandeep Singh
2026-08-07 7:02 ` [PATCH v3 02/14] net/enetc: add TSO support for ENETC4 VF Gagandeep Singh
2026-08-07 7:02 ` [PATCH v3 03/14] net/enetc: add RSC (hardware LRO) support for ENETC4 Gagandeep Singh
2026-08-07 7:02 ` [PATCH v3 04/14] net/enetc: extend link speed code field to 8-bit for PF-to-VF message Gagandeep Singh
2026-08-07 7:02 ` [PATCH v3 05/14] net/enetc: support firmware version get for VF Gagandeep Singh
2026-08-07 7:02 ` [PATCH v3 06/14] net/enetc: support registers dump Gagandeep Singh
2026-08-07 7:02 ` [PATCH v3 07/14] net/enetc: support ethtool ring parameters Gagandeep Singh
2026-08-07 7:02 ` [PATCH v3 08/14] net/enetc: refresh link speed on VF link-up interrupt Gagandeep Singh
2026-08-07 7:02 ` [PATCH v3 09/14] net/enetc: support stats reset for VF Gagandeep Singh
2026-08-07 7:02 ` [PATCH v3 10/14] net/enetc4: add per-queue Rx interrupt support " Gagandeep Singh
2026-08-07 7:02 ` [PATCH v3 11/14] net/enetc4: add SI-based port VLAN insertion and removal Gagandeep Singh
2026-08-07 7:02 ` [PATCH v3 12/14] net/enetc4: update VF link status to bitmask encoding Gagandeep Singh
2026-08-07 7:02 ` [PATCH v3 13/14] net/enetc4: enable TX PAUSE via VF RX congestion mode Gagandeep Singh
2026-08-07 7:02 ` [PATCH v3 14/14] net/enetc4: add WRR Tx scheduler devarg for VF rings Gagandeep Singh
2026-08-07 11:26 ` [PATCH v4 00/14] net/enetc: add new features for ENETC4 on i.MX95 Gagandeep Singh
2026-08-07 11:26 ` [PATCH v4 01/14] net/enetc: add KEEP_CRC offload support for ENETC4 Gagandeep Singh
2026-08-07 11:26 ` [PATCH v4 02/14] net/enetc: add TSO support for ENETC4 VF Gagandeep Singh
2026-08-07 11:26 ` [PATCH v4 03/14] net/enetc: add RSC (hardware LRO) support for ENETC4 Gagandeep Singh
2026-08-07 11:26 ` [PATCH v4 04/14] net/enetc: extend link speed code field to 8-bit for PF-to-VF message Gagandeep Singh
2026-08-07 11:26 ` [PATCH v4 05/14] net/enetc: support firmware version get for VF Gagandeep Singh
2026-08-07 11:26 ` [PATCH v4 06/14] net/enetc: support registers dump Gagandeep Singh
2026-08-07 11:26 ` [PATCH v4 07/14] net/enetc: support ethtool ring parameters Gagandeep Singh
2026-08-07 11:26 ` [PATCH v4 08/14] net/enetc: refresh link speed on VF link-up interrupt Gagandeep Singh
2026-08-07 11:26 ` [PATCH v4 09/14] net/enetc: support stats reset for VF Gagandeep Singh
2026-08-07 11:26 ` [PATCH v4 10/14] net/enetc4: add per-queue Rx interrupt support " Gagandeep Singh
2026-08-07 11:26 ` [PATCH v4 11/14] net/enetc4: add SI-based port VLAN insertion and removal Gagandeep Singh
2026-08-07 11:26 ` [PATCH v4 12/14] net/enetc4: update VF link status to bitmask encoding Gagandeep Singh
2026-08-07 11:26 ` [PATCH v4 13/14] net/enetc4: enable TX PAUSE via VF RX congestion mode Gagandeep Singh
2026-08-07 11:26 ` [PATCH v4 14/14] net/enetc4: add WRR Tx scheduler devarg for VF rings Gagandeep Singh
2026-08-09 21:00 ` [PATCH v4 00/14] net/enetc: add new features for ENETC4 on i.MX95 Stephen Hemminger
2026-08-10 10:58 ` Gagandeep Singh
2026-08-10 10:48 ` [PATCH v5 " Gagandeep Singh
2026-08-10 10:48 ` [PATCH v5 01/14] net/enetc: add keep-CRC Rx offload for ENETC4 Gagandeep Singh
2026-08-10 10:48 ` [PATCH v5 02/14] net/enetc: add TSO support for ENETC4 VF Gagandeep Singh
2026-08-10 10:48 ` [PATCH v5 03/14] net/enetc: add RSC (hardware LRO) support for ENETC4 Gagandeep Singh
2026-08-10 10:48 ` [PATCH v5 04/14] net/enetc: extend PF-VF link speed field to 8 bits Gagandeep Singh
2026-08-10 10:48 ` [PATCH v5 05/14] net/enetc: support firmware version get for VF Gagandeep Singh
2026-08-10 10:48 ` [PATCH v5 06/14] net/enetc: support registers dump Gagandeep Singh
2026-08-10 10:48 ` [PATCH v5 07/14] net/enetc: support ethtool ring parameters Gagandeep Singh
2026-08-10 10:48 ` [PATCH v5 08/14] net/enetc: refresh link speed on VF link-up interrupt Gagandeep Singh
2026-08-10 10:48 ` [PATCH v5 09/14] net/enetc: support stats reset for VF Gagandeep Singh
2026-08-10 10:48 ` [PATCH v5 10/14] net/enetc4: add per-queue Rx interrupt support " Gagandeep Singh
2026-08-10 10:48 ` [PATCH v5 11/14] net/enetc4: add SI-based port VLAN insertion and removal Gagandeep Singh
2026-08-10 10:48 ` [PATCH v5 12/14] net/enetc4: update VF link status to bitmask encoding Gagandeep Singh
2026-08-10 10:48 ` [PATCH v5 13/14] net/enetc4: enable Tx PAUSE via VF Rx congestion mode Gagandeep Singh
2026-08-10 10:48 ` [PATCH v5 14/14] net/enetc4: add WRR Tx scheduler devarg for VF rings Gagandeep Singh
2026-08-10 15:25 ` [PATCH v5 00/14] net/enetc: add new features for ENETC4 on i.MX95 Stephen Hemminger
2026-08-10 15:40 ` Stephen Hemminger
2026-08-11 7:40 ` [PATCH v6 00/13] " Gagandeep Singh
2026-08-11 7:40 ` [PATCH v6 01/13] net/enetc: add keep-CRC Rx offload for ENETC4 Gagandeep Singh
2026-08-11 7:40 ` [PATCH v6 02/13] net/enetc: add TSO support for ENETC4 VF Gagandeep Singh
2026-08-11 7:40 ` [PATCH v6 03/13] net/enetc: add RSC (hardware LRO) support for ENETC4 Gagandeep Singh
2026-08-11 7:40 ` [PATCH v6 04/13] net/enetc: extend PF-VF link speed field to 8 bits Gagandeep Singh
2026-08-11 7:40 ` [PATCH v6 05/13] net/enetc: support firmware version get for VF Gagandeep Singh
2026-08-11 7:40 ` [PATCH v6 06/13] net/enetc: support registers dump Gagandeep Singh
2026-08-11 7:40 ` [PATCH v6 07/13] net/enetc: support ethtool ring parameters Gagandeep Singh
2026-08-11 7:40 ` [PATCH v6 08/13] net/enetc: refresh link speed on VF link-up interrupt Gagandeep Singh
2026-08-11 7:40 ` Gagandeep Singh [this message]
2026-08-11 7:40 ` [PATCH v6 10/13] net/enetc4: add per-queue Rx interrupt support for VF Gagandeep Singh
2026-08-11 7:40 ` [PATCH v6 11/13] net/enetc4: add SI-based port VLAN insertion and removal Gagandeep Singh
2026-08-11 7:40 ` [PATCH v6 12/13] net/enetc4: update VF link status to bitmask encoding Gagandeep Singh
2026-08-11 7:40 ` [PATCH v6 13/13] net/enetc4: enable Tx PAUSE via VF Rx congestion mode Gagandeep Singh
2026-08-11 7:47 ` [PATCH v7 00/14] net/enetc: add new features for ENETC4 on i.MX95 Gagandeep Singh
2026-08-11 7:47 ` [PATCH v7 01/14] net/enetc: add keep-CRC Rx offload for ENETC4 Gagandeep Singh
2026-08-11 7:47 ` [PATCH v7 02/14] net/enetc: add TSO support for ENETC4 VF Gagandeep Singh
2026-08-11 7:47 ` [PATCH v7 03/14] net/enetc: add RSC (hardware LRO) support for ENETC4 Gagandeep Singh
2026-08-11 7:47 ` [PATCH v7 04/14] net/enetc: extend PF-VF link speed field to 8 bits Gagandeep Singh
2026-08-11 7:47 ` [PATCH v7 05/14] net/enetc: support firmware version get for VF Gagandeep Singh
2026-08-11 7:47 ` [PATCH v7 06/14] net/enetc: support registers dump Gagandeep Singh
2026-08-11 7:47 ` [PATCH v7 07/14] net/enetc: support ethtool ring parameters Gagandeep Singh
2026-08-11 7:47 ` [PATCH v7 08/14] net/enetc: refresh link speed on VF link-up interrupt Gagandeep Singh
2026-08-11 7:47 ` [PATCH v7 09/14] net/enetc: support stats reset for VF Gagandeep Singh
2026-08-11 7:47 ` [PATCH v7 10/14] net/enetc4: add per-queue Rx interrupt support " Gagandeep Singh
2026-08-11 7:47 ` [PATCH v7 11/14] net/enetc4: add SI-based port VLAN insertion and removal Gagandeep Singh
2026-08-11 7:47 ` [PATCH v7 12/14] net/enetc4: update VF link status to bitmask encoding Gagandeep Singh
2026-08-11 7:47 ` [PATCH v7 13/14] net/enetc4: enable Tx PAUSE via VF Rx congestion mode Gagandeep Singh
2026-08-11 7:47 ` [PATCH v7 14/14] net/enetc4: add WRR Tx scheduler devarg for VF rings Gagandeep Singh
2026-08-11 15:39 ` [PATCH v7 00/14] net/enetc: add new features for ENETC4 on i.MX95 Stephen Hemminger
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=20260811074032.3646324-10-g.singh@nxp.com \
--to=g.singh@nxp.com \
--cc=dev@dpdk.org \
--cc=hemant.agrawal@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