[PATCH 3/3] selftests: drv-net: Relax total BW check in devlink_rate_tc_bw.py

From: Carolina Jubran
Date: Sun Aug 31 2025 - 04:08:31 EST


This test is meant to check TC bandwidth distribution, not the tx_max
of the VF. The total bandwidth check is only there to make sure that FW
tokens limit traffic, because the per-TC share is only meaningful when
the link is fully saturated.

Because the measured total is the sum of two iperf3 streams that do not
always start or stop at the same time, using a strict 1 Gbps target
caused random failures. This change adds a tolerance parameter to
BandwidthValidator, keeps per-TC checks tight at +-12%, and relaxes the
total bandwidth check to +-25% around 1 Gbps.

This avoids false failures while still confirming that the TC share
validation is meaningful.

Fixes: 23ca32e4ead4 ("selftests: drv-net: Add test for devlink-rate traffic class bandwidth distribution")
Tested-by: Carolina Jubran <cjubran@xxxxxxxxxx>
Signed-off-by: Carolina Jubran <cjubran@xxxxxxxxxx>
Reviewed-by: Cosmin Ratiu <cratiu@xxxxxxxxxx>
Reviewed-by: Nimrod Oren <noren@xxxxxxxxxx>
---
.../selftests/drivers/net/hw/devlink_rate_tc_bw.py | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/drivers/net/hw/devlink_rate_tc_bw.py b/tools/testing/selftests/drivers/net/hw/devlink_rate_tc_bw.py
index abc20bc4a34a..1713ca11f845 100755
--- a/tools/testing/selftests/drivers/net/hw/devlink_rate_tc_bw.py
+++ b/tools/testing/selftests/drivers/net/hw/devlink_rate_tc_bw.py
@@ -72,8 +72,8 @@ class BandwidthValidator:
relative to the overall total.
"""

- def __init__(self, shares):
- self.tolerance_percent = 12
+ def __init__(self, shares, tolerance):
+ self.tolerance_percent = tolerance
self.expected_total = sum(shares.values())
self.bounds = {}

@@ -438,8 +438,8 @@ def main() -> None:
raise KsftSkipEx("Could not get PCI address of the interface")
cfg.require_cmd("iperf3", local=True, remote=True)

- cfg.traffic_bw_validator = BandwidthValidator({"total": 1})
- cfg.tc_bw_validator = BandwidthValidator({"tc3": 20, "tc4": 80})
+ cfg.traffic_bw_validator = BandwidthValidator({"total": 1}, 25)
+ cfg.tc_bw_validator = BandwidthValidator({"tc3": 20, "tc4": 80}, 12)

cases = [test_no_tc_mapping_bandwidth, test_tc_mapping_bandwidth]

--
2.38.1