selftests: drv-net: rss_api: context create and delete tests

Add test cases for creating and deleting contexts.

  TAP version 13
  1..12
  ok 1 rss_api.test_rxfh_nl_set_fail
  ok 2 rss_api.test_rxfh_nl_set_indir
  ok 3 rss_api.test_rxfh_nl_set_indir_ctx
  ok 4 rss_api.test_rxfh_indir_ntf
  ok 5 rss_api.test_rxfh_indir_ctx_ntf
  ok 6 rss_api.test_rxfh_nl_set_key
  ok 7 rss_api.test_rxfh_fields
  ok 8 rss_api.test_rxfh_fields_set
  ok 9 rss_api.test_rxfh_fields_set_xfrm # SKIP no input-xfrm supported
  ok 10 rss_api.test_rxfh_fields_ntf
  ok 11 rss_api.test_rss_ctx_add
  ok 12 rss_api.test_rss_ctx_ntf
  # Totals: pass:11 fail:0 xfail:0 xpass:0 skip:1 error:0

Link: https://patch.msgid.link/20250717234343.2328602-9-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Jakub Kicinski
2025-07-21 18:21:19 -07:00
parent fbe09277fa
commit 4c86c9fdf6
@@ -5,6 +5,7 @@
API level tests for RSS (mostly Netlink vs IOCTL).
"""
import errno
import glob
import random
from lib.py import ksft_run, ksft_exit, ksft_eq, ksft_is, ksft_ne, ksft_raises
@@ -390,6 +391,78 @@ def test_rxfh_fields_ntf(cfg):
ksft_eq(next(ethnl.poll_ntf(duration=0.01), None), None)
def test_rss_ctx_add(cfg):
""" Test creating an additional RSS context via Netlink """
_require_2qs(cfg)
# Test basic creation
ctx = cfg.ethnl.rss_create_act({"header": {"dev-index": cfg.ifindex}})
d = defer(ethtool, f"-X {cfg.ifname} context {ctx.get('context')} delete")
ksft_ne(ctx.get("context", 0), 0)
ksft_ne(set(ctx.get("indir", [0])), {0},
comment="Driver should init the indirection table")
# Try requesting the ID we just got allocated
with ksft_raises(NlError) as cm:
ctx = cfg.ethnl.rss_create_act({
"header": {"dev-index": cfg.ifindex},
"context": ctx.get("context"),
})
ethtool(f"-X {cfg.ifname} context {ctx.get('context')} delete")
d.exec()
ksft_eq(cm.exception.nl_msg.error, -errno.EBUSY)
# Test creating with a specified RSS table, and context ID
ctx_id = ctx.get("context")
ctx = cfg.ethnl.rss_create_act({
"header": {"dev-index": cfg.ifindex},
"context": ctx_id,
"indir": [1],
})
ethtool(f"-X {cfg.ifname} context {ctx.get('context')} delete")
ksft_eq(ctx.get("context"), ctx_id)
ksft_eq(set(ctx.get("indir", [0])), {1})
def test_rss_ctx_ntf(cfg):
""" Test notifications for creating additional RSS contexts """
ethnl = EthtoolFamily()
ethnl.ntf_subscribe("monitor")
# Create / delete via Netlink
ctx = cfg.ethnl.rss_create_act({"header": {"dev-index": cfg.ifindex}})
cfg.ethnl.rss_delete_act({
"header": {"dev-index": cfg.ifindex},
"context": ctx["context"],
})
ntf = next(ethnl.poll_ntf(duration=0.2), None)
if ntf is None:
raise KsftFailEx("[NL] No notification after context creation")
ksft_eq(ntf["name"], "rss-create-ntf")
ksft_eq(ctx, ntf["msg"])
ntf = next(ethnl.poll_ntf(duration=0.2), None)
if ntf is None:
raise KsftFailEx("[NL] No notification after context deletion")
ksft_eq(ntf["name"], "rss-delete-ntf")
# Create / deleve via IOCTL
ctx_id = _ethtool_create(cfg, "--disable-netlink -X", "context new")
ethtool(f"--disable-netlink -X {cfg.ifname} context {ctx_id} delete")
ntf = next(ethnl.poll_ntf(duration=0.2), None)
if ntf is None:
raise KsftFailEx("[IOCTL] No notification after context creation")
ksft_eq(ntf["name"], "rss-create-ntf")
ntf = next(ethnl.poll_ntf(duration=0.2), None)
if ntf is None:
raise KsftFailEx("[IOCTL] No notification after context deletion")
ksft_eq(ntf["name"], "rss-delete-ntf")
def main() -> None:
""" Ksft boiler plate main """