Jakub Kicinski kuba@kernel.org 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 kuba@kernel.org
Reviewed-by: Petr Machata petrm@nvidia.com
- # 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)