selftests: drv-net: rss_api: factor out checking min queue count

Multiple tests check min queue count, create a helper.

Link: https://patch.msgid.link/20250716000331.1378807-3-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Jakub Kicinski 2025-07-15 17:03:22 -07:00
parent c0ae03588b
commit 1560af51e1

View File

@ -13,6 +13,13 @@ from lib.py import EthtoolFamily
from lib.py import NetDrvEnv
def _require_2qs(cfg):
qcnt = len(glob.glob(f"/sys/class/net/{cfg.ifname}/queues/rx-*"))
if qcnt < 2:
raise KsftSkipEx(f"Local has only {qcnt} queues")
return qcnt
def _ethtool_create(cfg, act, opts):
output = ethtool(f"{act} {cfg.ifname} {opts}").stdout
# Output will be something like: "New RSS context is 1" or
@ -57,10 +64,7 @@ def test_rxfh_indir_ntf(cfg):
Check that Netlink notifications are generated when RSS indirection
table was modified.
"""
qcnt = len(glob.glob(f"/sys/class/net/{cfg.ifname}/queues/rx-*"))
if qcnt < 2:
raise KsftSkipEx(f"Local has only {qcnt} queues")
_require_2qs(cfg)
ethnl = EthtoolFamily()
ethnl.ntf_subscribe("monitor")
@ -88,10 +92,7 @@ def test_rxfh_indir_ctx_ntf(cfg):
Check that Netlink notifications are generated when RSS indirection
table was modified on an additional RSS context.
"""
qcnt = len(glob.glob(f"/sys/class/net/{cfg.ifname}/queues/rx-*"))
if qcnt < 2:
raise KsftSkipEx(f"Local has only {qcnt} queues")
_require_2qs(cfg)
ctx_id = _ethtool_create(cfg, "-X", "context new")
defer(ethtool, f"-X {cfg.ifname} context {ctx_id} delete")