[net-next 3/3] selftests: drv-net: psp: add reset statistics test

Akhilesh Samineni posted 3 patches 7 hours ago
[net-next 3/3] selftests: drv-net: psp: add reset statistics test
Posted by Akhilesh Samineni 7 hours ago
Add get stats and reset stats verification within _data_basic_send()
to exercise the reset-stats netlink command in the data path test.

Signed-off-by: Akhilesh Samineni <akhilesh.samineni@broadcom.com>
Reviewed-by: Kiran Kella <kiran.kella@broadcom.com>
---
 tools/testing/selftests/drivers/net/psp.py | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/tools/testing/selftests/drivers/net/psp.py b/tools/testing/selftests/drivers/net/psp.py
index 864d9fce1094..b7a59d0dbe25 100755
--- a/tools/testing/selftests/drivers/net/psp.py
+++ b/tools/testing/selftests/drivers/net/psp.py
@@ -113,6 +113,9 @@ def _check_data_outq(s, exp_len, force_wait=False):
 def _get_stat(cfg, key):
     return cfg.pspnl.get_stats({'dev-id': cfg.psp_dev_id})[key]
 
+
+def _reset_stat(cfg):
+    cfg.pspnl.reset_stats({"id": cfg.psp_dev_id})
+
 #
 # Test case boiler plate
 #
@@ -389,8 +392,22 @@ def _data_basic_send(cfg, version, ipver):
                         "tx-key": tx,
                         "sock-fd": s.fileno()})
 
+    _reset_stat(cfg)
+    rx_packets = _get_stat(cfg, 'rx-packets')
+    rx_bytes = _get_stat(cfg, 'rx-bytes')
+    ksft_eq(rx_packets, 0)
+    ksft_eq(rx_bytes, 0)
     data_len = _send_careful(cfg, s, 100)
     _check_data_rx(cfg, data_len)
+    rx_packets = _get_stat(cfg, 'rx-packets')
+    rx_bytes = _get_stat(cfg, 'rx-bytes')
+    ksft_ne(rx_packets, 0)
+    ksft_ne(rx_bytes, 0)
+    _reset_stat(cfg)
+    rx_packets = _get_stat(cfg, 'rx-packets')
+    rx_bytes = _get_stat(cfg, 'rx-bytes')
+    ksft_eq(rx_packets, 0)
+    ksft_eq(rx_bytes, 0)
     _close_psp_conn(cfg, s)
 
 
-- 
2.45.4
Re: [net-next 3/3] selftests: drv-net: psp: add reset statistics test
Posted by Jakub Kicinski 4 hours ago
On Mon,  2 Mar 2026 11:53:52 -0800 Akhilesh Samineni wrote:
> Add get stats and reset stats verification within _data_basic_send()
> to exercise the reset-stats netlink command in the data path test.

Please make this a new/separate test. 
(of course definite +1 to Willem's question)