Implement reset_stats for netdevsim PSP so that the
reset-stats netlink command works.
Signed-off-by: Akhilesh Samineni <akhilesh.samineni@broadcom.com>
Reviewed-by: Kiran Kella <kiran.kella@broadcom.com>
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