Subject: Re: [PATCH net-next v2 10/12] selftests: drv-net: hw: convert the Toeplitz test to Python

From: Petr Machata <[email-masked]>
Date: Wed, 19 Nov 2025 17:39:46 +0100

Jakub Kicinski <[email-masked]> writes:

> Rewrite the existing toeplitz.sh test in Python. The conversion
> is a lot less exact than the GRO one. We use Netlink APIs to
> get the device RSS and IRQ information. We expect that the device
> has neither RPS nor RFS configured, and set RPS up as part of
> the test.
>
> Signed-off-by: Jakub Kicinski <[email-masked]>

Reviewed-by: Petr Machata <[email-masked]>

> +    # Set RPS bitmap for all rx queues
> +    for rps_file in glob.glob(f"/sys/class/net/{cfg.ifname}/queues/rx-*/rps_cpus"):
> +        cmd(f"echo {mask} > {rps_file}", shell=True)

A bit odd to use echo like this, the other test does this through open /
write. Unless I'm missing something and this actually runs remotely...?

Anyway, not important. Just that maybe eventually some helpers that
support this sysfs-based configuration might be handy.

> +    return mask
> +
> +
> +def _send_traffic(cfg, proto_flag, ipver, port):
> +    """Send 20 packets of requested type."""
> +
> +    # Determine protocol and IP version for socat
> +    if proto_flag == "-u":
> +        proto = "UDP"
> +    else:
> +        proto = "TCP"
> +
> +    baddr = f"[{cfg.addr_v['6']}]" if ipver == "6" else cfg.addr_v["4"]
> +
> +    # Run socat in a loop to send traffic periodically
> +    # Use sh -c with a loop similar to toeplitz_client.sh
> +    socat_cmd = f"""
> +    for i in `seq 20`; do
> +        echo "msg $i" | socat -{ipver} -t 0.1 - {proto}:{baddr}:{port};
> +        sleep 0.001;
> +    done
> +    """

Yeah, what with the remote execution, this probably makes sense.

> +    cmd(socat_cmd, shell=True, host=cfg.remote)