Skip to content

Commit e2160b7

Browse files
committed
selftests: drv-net: test random value for hds-thresh
JIRA: https://issues.redhat.com/browse/RHEL-75603 Conflicts: A conflict occurred due to code differences caused by a missing unrelated commit. I resolved the conflict by aligning the code to match the intended changes in this patch. commit 22d3a63 Author: Taehee Yoo <ap420073@gmail.com> Date: Fri Apr 4 12:21:26 2025 +0000 selftests: drv-net: test random value for hds-thresh hds.py has been testing 0(set_hds_thresh_zero()), MAX(set_hds_thresh_max()), GT(set_hds_thresh_gt()) values for hds-thresh. However if a hds-thresh value was already 0, set_hds_thresh_zero() can't test properly. So, it tests random value first and then tests 0, MAX, GT values. Testing bnxt: TAP version 13 1..13 ok 1 hds.get_hds ok 2 hds.get_hds_thresh ok 3 hds.set_hds_disable # SKIP disabling of HDS not supported by the device ok 4 hds.set_hds_enable ok 5 hds.set_hds_thresh_random ok 6 hds.set_hds_thresh_zero ok 7 hds.set_hds_thresh_max ok 8 hds.set_hds_thresh_gt ok 9 hds.set_xdp ok 10 hds.enabled_set_xdp ok 11 hds.ioctl ok 12 hds.ioctl_set_xdp ok 13 hds.ioctl_enabled_set_xdp # Totals: pass:12 fail:0 xfail:0 xpass:0 skip:1 error:0 Testing lo: TAP version 13 1..13 ok 1 hds.get_hds # SKIP tcp-data-split not supported by device ok 2 hds.get_hds_thresh # SKIP hds-thresh not supported by device ok 3 hds.set_hds_disable # SKIP ring-set not supported by the device ok 4 hds.set_hds_enable # SKIP ring-set not supported by the device ok 5 hds.set_hds_thresh_random # SKIP hds-thresh not supported by device ok 6 hds.set_hds_thresh_zero # SKIP ring-set not supported by the device ok 7 hds.set_hds_thresh_max # SKIP hds-thresh not supported by device ok 8 hds.set_hds_thresh_gt # SKIP hds-thresh not supported by device ok 9 hds.set_xdp # SKIP tcp-data-split not supported by device ok 10 hds.enabled_set_xdp # SKIP tcp-data-split not supported by device ok 11 hds.ioctl # SKIP tcp-data-split not supported by device ok 12 hds.ioctl_set_xdp # SKIP tcp-data-split not supported by device ok 13 hds.ioctl_enabled_set_xdp # SKIP tcp-data-split not supported by device # Totals: pass:0 fail:0 xfail:0 xpass:0 skip:13 error:0 Signed-off-by: Taehee Yoo <ap420073@gmail.com> Link: https://patch.msgid.link/20250404122126.1555648-3-ap420073@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Mohammad Heib <mheib@redhat.com>
1 parent 65e3609 commit e2160b7

File tree

1 file changed

+32
-0
lines changed
  • tools/testing/selftests/drivers/net

1 file changed

+32
-0
lines changed

tools/testing/selftests/drivers/net/hds.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from lib.py import ksft_run, ksft_exit, ksft_eq, ksft_raises, KsftSkipEx
66
from lib.py import EthtoolFamily, NlError
77
from lib.py import NetDrvEnv
8+
from lib.py import defer, ethtool, ip, random
89

910
def get_hds(cfg, netnl) -> None:
1011
try:
@@ -73,6 +74,36 @@ def set_hds_thresh_zero(cfg, netnl) -> None:
7374

7475
ksft_eq(0, rings['hds-thresh'])
7576

77+
def set_hds_thresh_random(cfg, netnl) -> None:
78+
try:
79+
rings = netnl.rings_get({'header': {'dev-index': cfg.ifindex}})
80+
except NlError as e:
81+
raise KsftSkipEx('ring-get not supported by device')
82+
if 'hds-thresh' not in rings:
83+
raise KsftSkipEx('hds-thresh not supported by device')
84+
if 'hds-thresh-max' not in rings:
85+
raise KsftSkipEx('hds-thresh-max not defined by device')
86+
87+
if rings['hds-thresh-max'] < 2:
88+
raise KsftSkipEx('hds-thresh-max is too small')
89+
elif rings['hds-thresh-max'] == 2:
90+
hds_thresh = 1
91+
else:
92+
while True:
93+
hds_thresh = random.randint(1, rings['hds-thresh-max'] - 1)
94+
if hds_thresh != rings['hds-thresh']:
95+
break
96+
97+
try:
98+
netnl.rings_set({'header': {'dev-index': cfg.ifindex}, 'hds-thresh': hds_thresh})
99+
except NlError as e:
100+
if e.error == errno.EINVAL:
101+
raise KsftSkipEx("hds-thresh-set not supported by the device")
102+
elif e.error == errno.EOPNOTSUPP:
103+
raise KsftSkipEx("ring-set not supported by the device")
104+
rings = netnl.rings_get({'header': {'dev-index': cfg.ifindex}})
105+
ksft_eq(hds_thresh, rings['hds-thresh'])
106+
76107
def set_hds_thresh_max(cfg, netnl) -> None:
77108
try:
78109
rings = netnl.rings_get({'header': {'dev-index': cfg.ifindex}})
@@ -110,6 +141,7 @@ def main() -> None:
110141
get_hds_thresh,
111142
set_hds_disable,
112143
set_hds_enable,
144+
set_hds_thresh_random,
113145
set_hds_thresh_zero,
114146
set_hds_thresh_max,
115147
set_hds_thresh_gt],

0 commit comments

Comments
 (0)