Thread (14 messages) flat view 14 messages, 3 authors, 2026-03-06

[net-next 2/3] netdevsim: psp: Handle statistics reset

From: Akhilesh Samineni <hidden>
Date: 2026-03-02 19:54:41
Also in: lkml
Subsystem: netdevsim, networking drivers, the rest · Maintainers: Jakub Kicinski, Andrew Lunn, "David S. Miller", Eric Dumazet, Paolo Abeni, Linus Torvalds

Implement reset_stats for netdevsim PSP so that the
reset-stats netlink command works.

Signed-off-by: Akhilesh Samineni <redacted>
Reviewed-by: Kiran Kella <redacted>
Reviewed-by: Ajit Kumar Khaparde <ajit.khaparde@broadcom.com>
---
 drivers/net/netdevsim/psp.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
diff --git a/drivers/net/netdevsim/psp.c b/drivers/net/netdevsim/psp.c
index 0b4d717253b0..d4bede67f283 100644
--- a/drivers/net/netdevsim/psp.c
+++ b/drivers/net/netdevsim/psp.c
@@ -192,6 +192,19 @@ static void nsim_get_stats(struct psp_dev *psd, struct psp_dev_stats *stats)
 	} while (u64_stats_fetch_retry(&ns->psp.syncp, start));
 }
 
+static int nsim_reset_stats(struct psp_dev *psd, struct netlink_ext_ack *extack)
+{
+	struct netdevsim *ns = psd->drv_priv;
+
+	u64_stats_update_begin(&ns->psp.syncp);
+	u64_stats_set(&ns->psp.rx_bytes, 0);
+	u64_stats_set(&ns->psp.rx_packets, 0);
+	u64_stats_set(&ns->psp.tx_bytes, 0);
+	u64_stats_set(&ns->psp.tx_packets, 0);
+	u64_stats_update_end(&ns->psp.syncp);
+	return 0;
+}
+
 static struct psp_dev_ops nsim_psp_ops = {
 	.set_config	= nsim_psp_set_config,
 	.rx_spi_alloc	= nsim_rx_spi_alloc,
@@ -199,6 +212,7 @@ static struct psp_dev_ops nsim_psp_ops = {
 	.tx_key_del	= nsim_assoc_del,
 	.key_rotate	= nsim_key_rotate,
 	.get_stats	= nsim_get_stats,
+	.reset_stats	= nsim_reset_stats,
 };
 
 static struct psp_dev_caps nsim_psp_caps = {
-- 
2.45.4
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help