mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-04-04 18:11:39 -04:00
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/20250404122126.1555648-1-ap420073@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
@@ -830,6 +830,7 @@ void ethtool_ringparam_get_cfg(struct net_device *dev,
|
||||
|
||||
/* Driver gives us current state, we want to return current config */
|
||||
kparam->tcp_data_split = dev->cfg->hds_config;
|
||||
kparam->hds_thresh = dev->cfg->hds_thresh;
|
||||
}
|
||||
|
||||
static void ethtool_init_tsinfo(struct kernel_ethtool_ts_info *info)
|
||||
|
||||
@@ -6,7 +6,7 @@ import os
|
||||
from lib.py import ksft_run, ksft_exit, ksft_eq, ksft_raises, KsftSkipEx
|
||||
from lib.py import CmdExitFailure, EthtoolFamily, NlError
|
||||
from lib.py import NetDrvEnv
|
||||
from lib.py import defer, ethtool, ip
|
||||
from lib.py import defer, ethtool, ip, random
|
||||
|
||||
|
||||
def _get_hds_mode(cfg, netnl) -> str:
|
||||
@@ -109,6 +109,36 @@ def set_hds_thresh_zero(cfg, netnl) -> None:
|
||||
|
||||
ksft_eq(0, rings['hds-thresh'])
|
||||
|
||||
def set_hds_thresh_random(cfg, netnl) -> None:
|
||||
try:
|
||||
rings = netnl.rings_get({'header': {'dev-index': cfg.ifindex}})
|
||||
except NlError as e:
|
||||
raise KsftSkipEx('ring-get not supported by device')
|
||||
if 'hds-thresh' not in rings:
|
||||
raise KsftSkipEx('hds-thresh not supported by device')
|
||||
if 'hds-thresh-max' not in rings:
|
||||
raise KsftSkipEx('hds-thresh-max not defined by device')
|
||||
|
||||
if rings['hds-thresh-max'] < 2:
|
||||
raise KsftSkipEx('hds-thresh-max is too small')
|
||||
elif rings['hds-thresh-max'] == 2:
|
||||
hds_thresh = 1
|
||||
else:
|
||||
while True:
|
||||
hds_thresh = random.randint(1, rings['hds-thresh-max'] - 1)
|
||||
if hds_thresh != rings['hds-thresh']:
|
||||
break
|
||||
|
||||
try:
|
||||
netnl.rings_set({'header': {'dev-index': cfg.ifindex}, 'hds-thresh': hds_thresh})
|
||||
except NlError as e:
|
||||
if e.error == errno.EINVAL:
|
||||
raise KsftSkipEx("hds-thresh-set not supported by the device")
|
||||
elif e.error == errno.EOPNOTSUPP:
|
||||
raise KsftSkipEx("ring-set not supported by the device")
|
||||
rings = netnl.rings_get({'header': {'dev-index': cfg.ifindex}})
|
||||
ksft_eq(hds_thresh, rings['hds-thresh'])
|
||||
|
||||
def set_hds_thresh_max(cfg, netnl) -> None:
|
||||
try:
|
||||
rings = netnl.rings_get({'header': {'dev-index': cfg.ifindex}})
|
||||
@@ -243,6 +273,7 @@ def main() -> None:
|
||||
get_hds_thresh,
|
||||
set_hds_disable,
|
||||
set_hds_enable,
|
||||
set_hds_thresh_random,
|
||||
set_hds_thresh_zero,
|
||||
set_hds_thresh_max,
|
||||
set_hds_thresh_gt,
|
||||
|
||||
Reference in New Issue
Block a user