Netdev List
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Cc: netdev@vger.kernel.org, magnus.karlsson@intel.com,
	stfomichev@gmail.com, pabeni@redhat.com,
	tushar.vyavahare@intel.com, kerneljasonxing@gmail.com,
	bjorn@kernel.org
Subject: Re: [PATCH v5 net-next 12/13] selftests: drv-net: run the AF_XDP tests over veth or a NIC
Date: Mon, 23 Nov 2026 17:29:46 -0800	[thread overview]
Message-ID: <20261123172946.54f8323a@kernel.org> (raw)
In-Reply-To: <20261119164636.1071385-13-maciej.fijalkowski@intel.com>

On Thu, 19 Nov 2026 17:46:35 +0100 Maciej Fijalkowski wrote:
> +Without NETIF, the interfaces are a veth pair with the remote end in a
> +network namespace of its own. Each listed case runs in SKB and DRV mode,
> +with the local endpoint receiving in that mode. A copy-mode socket sends
> +alike in both modes, so the remote endpoint sends as it would in DRV mode.
> +The variant name starts with the mode, e.g. test_xsk.drv_SEND_RECEIVE. The
> +cases in VETH_XFAIL cannot pass over veth and are reported as expected
> +failures without being run. veth does not tie its NAPI instances to its
> +queues, so a socket on it has no NAPI to busy poll.

I think it does now? Merged last week.

> Only the initial
> +network namespace has the net.core.max_skb_frags sysctl, so the remote
> +endpoint takes 17 frags. --max-frags hands the sysctl value to both
> +endpoints for TOO_MANY_FRAGS, but the cases in TAILROOM_CASES size the
> +UMEM tailroom by the value of each endpoint, and are expected failures
> +when the sysctl is not 17.
> +
> +With NETIF, the local endpoint runs in zero-copy mode on NETIF, the DUT,
> +and binds to its last queue, and the remote endpoint binds to queue 0.
> +Before the cases run, main() takes the DUT queue out of RSS and adds an
> +ntuple filter on each host that steers the test UDP flow to the queue of
> +the receiving endpoint, and it undoes that however the run ends. A NIC
> +that rebuilds its RSS indirection table on a reset, such as one for an
> +XDP, MTU or ring change, puts the queue back into RSS, so a case fails if
> +the queue is back in RSS after it.

Yeah but that'd be an outrageous driver bug :/ If AI made you mention it
- drop it pls.

> +# The TX ring of the sender and the RX ring of the receiver that a case
> +# needs at a given size, 64 being the default batch size of xskxceiver.
> +RING_SIZES = {

We usually "glue" this sort of cached state onto env and check for it
being cached already with hasattr() but I guess global is fine...

> +def _setup_busy_poll(ifname):
> +    """Set napi_defer_hard_irqs and gro_flush_timeout of ifname until the
> +    case ends, so that SO_PREFER_BUSY_POLL of xskxceiver -b keeps the IRQs
> +    masked."""
> +    for attr, val in (("napi_defer_hard_irqs", 2),
> +                      ("gro_flush_timeout", 200000)):
> +        path = f"/sys/class/net/{ifname}/{attr}"
> +        old = cmd(f"cat {path}").stdout.strip()
> +        if old == str(val):
> +            continue
> +        cmd(f"echo {val} > {path}", shell=True)
> +        defer(cmd, f"echo {old} > {path}", shell=True)

ctl_file_write(), ask you agent to check for lib helpers perhaps?

> +
> +
> +def _restore_rss(cfg, indir):
> +    """Restore the RSS indirection table of the DUT. Reset it to the default
> +    first, which leaves it to the driver again, and write indir back only if
> +    it was not the default."""
> +    ethtool(f"-X {cfg.ifname} default")

IIRC indir table of 0 size is the same as reset so you can add below an

> +    req = {"header": {"dev-index": cfg.ifindex}}
> +    if cfg.ethnl.rss_get(req).get("indir") != indir:
> +        cfg.ethnl.rss_set({**req, "indir": indir})

	else:
		cfg.ethnl.rss_set({**req, "indir": []})

instead?

> +def _reserve_queue(cfg, undo):
> +    """Take the last queue with both an RX and a TX ring out of RSS until
> +    undo, return None if the DUT cannot. A TX endpoint fills no RX buffers,
> +    so in zero-copy mode its queue drops what it receives, the control
> +    connection included."""
> +    req = {"header": {"dev-index": cfg.ifindex}}
> +    try:
> +        ch = cfg.ethnl.channels_get(req)
> +        rss = cfg.ethnl.rss_get(req)
> +    except NlError:
> +        print(f"1..0 # SKIP cannot get the channels or RSS of {cfg.ifname}")

No no, never print() in netdev py tests. You're not allowed to output
any TAP directly. let the ksft_run() handle that. If you need to print
something - ksft_pr() which does necessary escaping.

> +def main():
> +    """Run the cases over veth without NETIF, else on NETIF."""
> +    # defer() works only within a case, so undo restores what main() sets up
> +    # for all of them, however the run ends.
> +    with NetDrvEpEnv(__file__, veth_test=True) as cfg, \
> +         ExitStack() as undo:
> +        cfg.bin_local = cfg.net_lib_dir / "xskxceiver"
> +        if not cfg.bin_local.exists():
> +            print(f"1..0 # SKIP {cfg.bin_local} was not built")
> +            sys.exit(SKIP_CODE)
> +
> +        # Before _setup_nic(), as ntuple-filters can reset a NIC.
> +        local_dmac = _next_hop_mac(cfg, cfg.remote_addr,
> +                                   cfg.remote_dev["address"], cfg.ifname)
> +        remote_dmac = _next_hop_mac(cfg, cfg.addr, cfg.dev["address"],
> +                                    cfg.remote_ifname, cfg.remote)
> +
> +        cfg.udp_port = rand_port()
> +        if cfg.veth_test:
> +            _setup_veth(cfg)
> +        elif not _setup_nic(cfg, undo):
> +            sys.exit(SKIP_CODE)
> +
> +        cfg.bin_remote = cfg.remote.deploy(cfg.bin_local)
> +
> +        saved_hugepages = []
> +        undo.callback(_release_hugepages, saved_hugepages)
> +        cfg.hugepages = (_reserve_hugepages(saved_hugepages) and
> +                         _reserve_hugepages(saved_hugepages, cfg.remote))
> +        if not cfg.hugepages:
> +            _release_hugepages(saved_hugepages)
> +            saved_hugepages.clear()
> +
> +        cases = _get_cases(cfg)
> +        _set_args(cfg, local_dmac, remote_dmac)

You're doing way too much outside the test cases. Don't optimize for
execution time, let each test case prepare a clean environment. If
we want to optimize for shared prep we'll do it later in a structured
way, inside ksft_run(). Not now.

> +        tests = [ksft_variants(cases)(test_xsk)]
> +        if not cfg.veth_test:
> +            tests.append(ksft_variants(cases)(test_xsk_busy_poll))
> +        ksft_run(tests, args=(cfg,))
> +    ksft_exit()


  parent reply	other threads:[~2026-11-24  1:29 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 16:46 [PATCH v5 net-next 00/13] selftests: net: adjust xskxceiver to drv-net Maciej Fijalkowski
2026-11-19 16:46 ` [PATCH v5 net-next 01/13] selftests: xsk: factor endpoint work out of pthread wrappers Maciej Fijalkowski
2026-11-19 16:46 ` [PATCH v5 net-next 02/13] selftests: xsk: size the TX UMEM in HW_SW_MAX_RING_SIZE Maciej Fijalkowski
2026-11-23 18:46   ` netdev-bot+sashiko
2026-11-19 16:46 ` [PATCH v5 net-next 03/13] selftests: xsk: drop the single-interface loopback mode Maciej Fijalkowski
2026-11-19 16:46 ` [PATCH v5 net-next 04/13] selftests: xsk: collect interface capabilities in struct xsk_caps Maciej Fijalkowski
2026-11-19 16:46 ` [PATCH v5 net-next 05/13] selftests: xsk: split xskxceiver main() into setup, run and cleanup Maciej Fijalkowski
2026-11-23 18:46   ` netdev-bot+sashiko
2026-11-19 16:46 ` [PATCH v5 net-next 06/13] selftests: xsk: run one test case per xskxceiver invocation Maciej Fijalkowski
2026-11-23 18:46   ` netdev-bot+sashiko
2026-11-19 16:46 ` [PATCH v5 net-next 07/13] selftests: xsk: run the RX and TX endpoints in separate processes Maciej Fijalkowski
2026-11-23 18:46   ` netdev-bot+sashiko
2026-11-19 16:46 ` [PATCH v5 net-next 08/13] selftests: xsk: send UDP over IPv4 or IPv6 between the interface MACs Maciej Fijalkowski
2026-11-23 18:46   ` netdev-bot+sashiko
2026-11-23 19:08   ` Björn Töpel
2026-11-19 16:46 ` [PATCH v5 net-next 09/13] selftests: xsk: prepare xskxceiver for endpoints on two hosts Maciej Fijalkowski
2026-11-23 18:46   ` netdev-bot+sashiko
2026-11-23 19:10   ` Björn Töpel
2026-11-19 16:46 ` [PATCH v5 net-next 10/13] selftests: xsk: list the endpoint roles of the test cases Maciej Fijalkowski
2026-11-23 19:12   ` Björn Töpel
2026-11-19 16:46 ` [PATCH v5 net-next 11/13] selftests: drv-net: decouple local link setup from netdevsim Maciej Fijalkowski
2026-11-23 19:12   ` Björn Töpel
2026-11-24  1:09   ` Jakub Kicinski
2026-11-19 16:46 ` [PATCH v5 net-next 12/13] selftests: drv-net: run the AF_XDP tests over veth or a NIC Maciej Fijalkowski
2026-11-23 18:46   ` netdev-bot+sashiko
2026-11-24  1:15   ` Jakub Kicinski
2026-11-24  1:29   ` Jakub Kicinski [this message]
2026-11-19 16:46 ` [PATCH v5 net-next 13/13] selftests: xsk: document generic and hardware endpoint runs Maciej Fijalkowski
2026-11-23 19:40   ` Björn Töpel
2026-11-24  1:32   ` Jakub Kicinski
2026-11-23 21:13 ` [PATCH v5 net-next 00/13] selftests: net: adjust xskxceiver to drv-net Jakub Kicinski
2026-11-23 22:06   ` Maciej Fijalkowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261123172946.54f8323a@kernel.org \
    --to=kuba@kernel.org \
    --cc=bjorn@kernel.org \
    --cc=kerneljasonxing@gmail.com \
    --cc=maciej.fijalkowski@intel.com \
    --cc=magnus.karlsson@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=stfomichev@gmail.com \
    --cc=tushar.vyavahare@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox