Skip to content

Commit 22d3a63

Browse files
TaeheeYookuba-moo
authored andcommitted
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 <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 216a61d commit 22d3a63

File tree

1 file changed

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

1 file changed

+32
-1
lines changed

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

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from lib.py import ksft_run, ksft_exit, ksft_eq, ksft_raises, KsftSkipEx
77
from lib.py import CmdExitFailure, EthtoolFamily, NlError
88
from lib.py import NetDrvEnv
9-
from lib.py import defer, ethtool, ip
9+
from lib.py import defer, ethtool, ip, random
1010

1111

1212
def _get_hds_mode(cfg, netnl) -> str:
@@ -109,6 +109,36 @@ def set_hds_thresh_zero(cfg, netnl) -> None:
109109

110110
ksft_eq(0, rings['hds-thresh'])
111111

112+
def set_hds_thresh_random(cfg, netnl) -> None:
113+
try:
114+
rings = netnl.rings_get({'header': {'dev-index': cfg.ifindex}})
115+
except NlError as e:
116+
raise KsftSkipEx('ring-get not supported by device')
117+
if 'hds-thresh' not in rings:
118+
raise KsftSkipEx('hds-thresh not supported by device')
119+
if 'hds-thresh-max' not in rings:
120+
raise KsftSkipEx('hds-thresh-max not defined by device')
121+
122+
if rings['hds-thresh-max'] < 2:
123+
raise KsftSkipEx('hds-thresh-max is too small')
124+
elif rings['hds-thresh-max'] == 2:
125+
hds_thresh = 1
126+
else:
127+
while True:
128+
hds_thresh = random.randint(1, rings['hds-thresh-max'] - 1)
129+
if hds_thresh != rings['hds-thresh']:
130+
break
131+
132+
try:
133+
netnl.rings_set({'header': {'dev-index': cfg.ifindex}, 'hds-thresh': hds_thresh})
134+
except NlError as e:
135+
if e.error == errno.EINVAL:
136+
raise KsftSkipEx("hds-thresh-set not supported by the device")
137+
elif e.error == errno.EOPNOTSUPP:
138+
raise KsftSkipEx("ring-set not supported by the device")
139+
rings = netnl.rings_get({'header': {'dev-index': cfg.ifindex}})
140+
ksft_eq(hds_thresh, rings['hds-thresh'])
141+
112142
def set_hds_thresh_max(cfg, netnl) -> None:
113143
try:
114144
rings = netnl.rings_get({'header': {'dev-index': cfg.ifindex}})
@@ -243,6 +273,7 @@ def main() -> None:
243273
get_hds_thresh,
244274
set_hds_disable,
245275
set_hds_enable,
276+
set_hds_thresh_random,
246277
set_hds_thresh_zero,
247278
set_hds_thresh_max,
248279
set_hds_thresh_gt,

0 commit comments

Comments
 (0)