Skip to content

Commit cf46e18

Browse files
committed
Merge branch 'fix-wrong-hds-thresh-value-setting'
Taehee Yoo says: ==================== fix wrong hds-thresh value setting A hds-thresh value is not set correctly if input value is 0. The cause is that ethtool_ringparam_get_cfg(), which is a internal function that returns ringparameters from both ->get_ringparam() and dev->cfg can't return a correct hds-thresh value. The first patch fixes ethtool_ringparam_get_cfg() to set hds-thresh value correcltly. The second patch adds random test for hds-thresh value. So that we can test 0 value for a hds-thresh properly. ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 61f96e6 + 22d3a63 commit cf46e18

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

net/ethtool/common.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,7 @@ void ethtool_ringparam_get_cfg(struct net_device *dev,
830830

831831
/* Driver gives us current state, we want to return current config */
832832
kparam->tcp_data_split = dev->cfg->hds_config;
833+
kparam->hds_thresh = dev->cfg->hds_thresh;
833834
}
834835

835836
static void ethtool_init_tsinfo(struct kernel_ethtool_ts_info *info)

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)