From nobody Mon Dec 1 22:34:53 2025 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 07987302775 for ; Sun, 30 Nov 2025 23:35:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764545751; cv=none; b=V91W0CuqcAh9aQkMBhJlB2obtly/tIPitwXGN1StptSYWDvhxU477Jdfw5uNzxnX45ZI526+O3iez40BK6Q/MubNgcwftHxdGvNHZUp/WX5cD4tLoOllOM6Nc36hVPAqkwxJ3461YqdDirJ4U6xhCeoDQBQNCSa0YCQ2jaTT3s0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764545751; c=relaxed/simple; bh=/jxCrpK8l6glGcqt49LNeHrXzbo3WZk9EY0AmmIwENo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MYVfcGis4Hf2p/EfDyceg8nFc+3mW1IdpKNDjoY8bEKky2DdcylqkRNSWeMBcPOBKDhMJH/OKCYRfrd21cc7Xx2ZDCeG+4n8CqhxqZMYRuYF3B6CVBy56WjHeWEvMQg+AfH95sH8qgtiTTzyC4qy/3wKVkx4N2ynthTvUzWP3dI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=K4C57Jqn; arc=none smtp.client-ip=209.85.128.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="K4C57Jqn" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-477a2ab455fso37852385e9.3 for ; Sun, 30 Nov 2025 15:35:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764545747; x=1765150547; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WJRC4dPidxMIa9vqar4Y3LK2OFHt6WzESXNCWKhLD0s=; b=K4C57JqneyOxdD+kcxOXNpAtHCFPZDZ4ziofb7b6ea+Y5GVoCFxSbm7+jof8fDJCPT RzLjLX3oitW4dXH7lTRxBco/3yQ8N2meGswMXf9aS/ZlylTtKbRiR/RlXsxTWjVj9tvy XLGC/dkShYW7RecqSdBQOiS7EXSzeWin1aNR9QvsQWQUGnqd9TXVNyOdnfn5JSMkF/z5 2iZN3vIe1zaaTbRws2GJIsdfvR4O8RSAzvLX63Eo20FNTa2w0Um66CwqSPj06w6F88Lw vOkBnHkWF6BuWnNxxwsKJfBDOlw6nUvkK44ZZyL7H+F79sl6FFu1v9j727Un1B3tyRle y6YA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764545747; x=1765150547; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=WJRC4dPidxMIa9vqar4Y3LK2OFHt6WzESXNCWKhLD0s=; b=ZDHF0ZrKS6kKEQHSxJX18FX/4r0p9D346PWHgEybKN3xSuWyAyfdJhejeY04O4M5ct QbeqwFV2C641szQ5/6OfcnQCWwDrpO0pxThu5GuN1bL5gcwhf9pINv6OyeBu715F0xz/ CZFyBiUekEWDpJSrdpHgeykkVytILQ2/T/o8PfipWabZUS+prixPMa0OKtCLd7c/GCEP ALAYFgJtUSxMjKVkjgZIoyFqbPilrGTmu6KMStwSd2Glr/rdsYRNf7hW8xoW25Ax2Q8o tQnpXiA1eoursW6QPVa79azRG7RC44q5CAJWECKrrtaw7FjrSSB8eg8MS7es8hFFC0o4 AycQ== X-Forwarded-Encrypted: i=1; AJvYcCVT2j/VDGruGYR43soCP2FQtX76l2bdPu60oXiZJR1goBCbpeLUXmWomYhV1aCddhleLp+i4xgPDRFRwx0=@vger.kernel.org X-Gm-Message-State: AOJu0YzRx1EDXo4H7hE7zWOFP6AGQ4ezJwCTJgZwmXpTI0Z+Va5jnGTB xSorQIcuQbBpEkVJ0JmZgA/bxuc6UUk6lcQGtiRAXgV9Myi19wUua6ii X-Gm-Gg: ASbGncvb1IDhnvqpsUYjV4bnX8kGuYUYbsK19VKKUD48CEuBOwvprTH56PZN1u/XBKt zjrxEoUzmlQ5vA8Unr1xGbhJkq31Rq3++jYIOUxwPio4QwkfVis+IIK52bxBXrcuoZGHyXI6f0n SpRyXE0DFck0DLLrHdIB2ybfJTxCiXaUI4892CkRtqOzOJpiRBIlK8vfyqqXTFarxbW/EpJ4ZgW sStmMrhoThHrV+HlpDO3ImTLo10hLCQowL9SFHJwKj6W3yd3srDvVrtYnUFjvJzoHUmBfWTeMxE 5LWcNOmVZYt28mVTfvjynre4dCeKmWkMzatcTsksS6bpdLP2ZDpMn3AGYekHPioKx7N3wFht7RE 4h115wTFM53LKXe7b+S+13zLgu1C03meNL1VFAdWXTzOZzvKFmA6liDXb3xm7p5MibUfwl+fBUz VhnXPgTi/Fp3ZgwCZJMqjATbd9BTo/z71MzCtgR8fHOfM7p2JajLTTKaqh3XvU5LpnhnrDFY2IS ROzvB/Ub78Hros2 X-Google-Smtp-Source: AGHT+IF1C3BU+0TmVLhFFFLC7lJAEa9+OLBtLvpfXcpFjqpVlWK06cPRlsUJhKHpdqODVbDSNRV+FQ== X-Received: by 2002:a05:600c:8b35:b0:475:d8b3:a9d5 with SMTP id 5b1f17b1804b1-477c10d6fdamr359420355e9.10.1764545747159; Sun, 30 Nov 2025 15:35:47 -0800 (PST) Received: from 127.mynet ([2a01:4b00:bd21:4f00:7cc6:d3ca:494:116c]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-479040b3092sm142722075e9.1.2025.11.30.15.35.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Nov 2025 15:35:46 -0800 (PST) From: Pavel Begunkov To: netdev@vger.kernel.org Cc: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jonathan Corbet , Michael Chan , Pavan Chebbi , Andrew Lunn , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Ilias Apalodimas , Shuah Khan , Mina Almasry , Stanislav Fomichev , Pavel Begunkov , Yue Haibing , David Wei , Haiyue Wang , Jens Axboe , Joe Damato , Simon Horman , Vishwanath Seshagiri , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, io-uring@vger.kernel.org, dtatulea@nvidia.com Subject: [PATCH net-next v7 9/9] selftests: iou-zcrx: test large chunk sizes Date: Sun, 30 Nov 2025 23:35:24 +0000 Message-ID: <0339cb58a22925687ce66dbeb1efec7f13bdd7c3.1764542851.git.asml.silence@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add a test using large chunks for zcrx memory area. Signed-off-by: Pavel Begunkov --- .../selftests/drivers/net/hw/iou-zcrx.c | 72 +++++++++++++++---- .../selftests/drivers/net/hw/iou-zcrx.py | 37 ++++++++++ 2 files changed, 97 insertions(+), 12 deletions(-) diff --git a/tools/testing/selftests/drivers/net/hw/iou-zcrx.c b/tools/test= ing/selftests/drivers/net/hw/iou-zcrx.c index 62456df947bc..0a19b573f4f5 100644 --- a/tools/testing/selftests/drivers/net/hw/iou-zcrx.c +++ b/tools/testing/selftests/drivers/net/hw/iou-zcrx.c @@ -12,6 +12,7 @@ #include =20 #include +#include #include #include #include @@ -37,6 +38,23 @@ =20 #include =20 +#define SKIP_CODE 42 + +struct t_io_uring_zcrx_ifq_reg { + __u32 if_idx; + __u32 if_rxq; + __u32 rq_entries; + __u32 flags; + + __u64 area_ptr; /* pointer to struct io_uring_zcrx_area_reg */ + __u64 region_ptr; /* struct io_uring_region_desc * */ + + struct io_uring_zcrx_offsets offsets; + __u32 zcrx_id; + __u32 rx_buf_len; + __u64 __resv[3]; +}; + static long page_size; #define AREA_SIZE (8192 * page_size) #define SEND_SIZE (512 * 4096) @@ -65,6 +83,8 @@ static bool cfg_oneshot; static int cfg_oneshot_recvs; static int cfg_send_size =3D SEND_SIZE; static struct sockaddr_in6 cfg_addr; +static unsigned cfg_rx_buf_len; +static bool cfg_dry_run; =20 static char *payload; static void *area_ptr; @@ -128,14 +148,28 @@ static void setup_zcrx(struct io_uring *ring) if (!ifindex) error(1, 0, "bad interface name: %s", cfg_ifname); =20 - area_ptr =3D mmap(NULL, - AREA_SIZE, - PROT_READ | PROT_WRITE, - MAP_ANONYMOUS | MAP_PRIVATE, - 0, - 0); - if (area_ptr =3D=3D MAP_FAILED) - error(1, 0, "mmap(): zero copy area"); + if (cfg_rx_buf_len && cfg_rx_buf_len !=3D page_size) { + area_ptr =3D mmap(NULL, + AREA_SIZE, + PROT_READ | PROT_WRITE, + MAP_ANONYMOUS | MAP_PRIVATE | + MAP_HUGETLB | MAP_HUGE_2MB, + -1, + 0); + if (area_ptr =3D=3D MAP_FAILED) { + printf("Can't allocate huge pages\n"); + exit(SKIP_CODE); + } + } else { + area_ptr =3D mmap(NULL, + AREA_SIZE, + PROT_READ | PROT_WRITE, + MAP_ANONYMOUS | MAP_PRIVATE, + 0, + 0); + if (area_ptr =3D=3D MAP_FAILED) + error(1, 0, "mmap(): zero copy area"); + } =20 ring_size =3D get_refill_ring_size(rq_entries); ring_ptr =3D mmap(NULL, @@ -157,17 +191,23 @@ static void setup_zcrx(struct io_uring *ring) .flags =3D 0, }; =20 - struct io_uring_zcrx_ifq_reg reg =3D { + struct t_io_uring_zcrx_ifq_reg reg =3D { .if_idx =3D ifindex, .if_rxq =3D cfg_queue_id, .rq_entries =3D rq_entries, .area_ptr =3D (__u64)(unsigned long)&area_reg, .region_ptr =3D (__u64)(unsigned long)®ion_reg, + .rx_buf_len =3D cfg_rx_buf_len, }; =20 - ret =3D io_uring_register_ifq(ring, ®); - if (ret) + ret =3D io_uring_register_ifq(ring, (void *)®); + if (cfg_rx_buf_len && (ret =3D=3D -EINVAL || ret =3D=3D -EOPNOTSUPP || + ret =3D=3D -ERANGE)) { + printf("Large chunks are not supported %i\n", ret); + exit(SKIP_CODE); + } else if (ret) { error(1, 0, "io_uring_register_ifq(): %d", ret); + } =20 rq_ring.khead =3D (unsigned int *)((char *)ring_ptr + reg.offsets.head); rq_ring.ktail =3D (unsigned int *)((char *)ring_ptr + reg.offsets.tail); @@ -323,6 +363,8 @@ static void run_server(void) io_uring_queue_init(512, &ring, flags); =20 setup_zcrx(&ring); + if (cfg_dry_run) + return; =20 add_accept(&ring, fd); =20 @@ -383,7 +425,7 @@ static void parse_opts(int argc, char **argv) usage(argv[0]); cfg_payload_len =3D max_payload_len; =20 - while ((c =3D getopt(argc, argv, "sch:p:l:i:q:o:z:")) !=3D -1) { + while ((c =3D getopt(argc, argv, "sch:p:l:i:q:o:z:x:d")) !=3D -1) { switch (c) { case 's': if (cfg_client) @@ -418,6 +460,12 @@ static void parse_opts(int argc, char **argv) case 'z': cfg_send_size =3D strtoul(optarg, NULL, 0); break; + case 'x': + cfg_rx_buf_len =3D page_size * strtoul(optarg, NULL, 0); + break; + case 'd': + cfg_dry_run =3D true; + break; } } =20 diff --git a/tools/testing/selftests/drivers/net/hw/iou-zcrx.py b/tools/tes= ting/selftests/drivers/net/hw/iou-zcrx.py index 712c806508b5..83061b27f2f2 100755 --- a/tools/testing/selftests/drivers/net/hw/iou-zcrx.py +++ b/tools/testing/selftests/drivers/net/hw/iou-zcrx.py @@ -7,6 +7,7 @@ from lib.py import ksft_run, ksft_exit, KsftSkipEx from lib.py import NetDrvEpEnv from lib.py import bkg, cmd, defer, ethtool, rand_port, wait_port_listen =20 +SKIP_CODE =3D 42 =20 def _get_current_settings(cfg): output =3D ethtool(f"-g {cfg.ifname}", json=3DTrue)[0] @@ -132,6 +133,42 @@ def test_zcrx_rss(cfg) -> None: cmd(tx_cmd, host=3Dcfg.remote) =20 =20 +def test_zcrx_large_chunks(cfg) -> None: + cfg.require_ipver('6') + + combined_chans =3D _get_combined_channels(cfg) + if combined_chans < 2: + raise KsftSkipEx('at least 2 combined channels required') + (rx_ring, hds_thresh) =3D _get_current_settings(cfg) + port =3D rand_port() + + ethtool(f"-G {cfg.ifname} tcp-data-split on") + defer(ethtool, f"-G {cfg.ifname} tcp-data-split auto") + + ethtool(f"-G {cfg.ifname} hds-thresh 0") + defer(ethtool, f"-G {cfg.ifname} hds-thresh {hds_thresh}") + + ethtool(f"-G {cfg.ifname} rx 64") + defer(ethtool, f"-G {cfg.ifname} rx {rx_ring}") + + ethtool(f"-X {cfg.ifname} equal {combined_chans - 1}") + defer(ethtool, f"-X {cfg.ifname} default") + + flow_rule_id =3D _set_flow_rule(cfg, port, combined_chans - 1) + defer(ethtool, f"-N {cfg.ifname} delete {flow_rule_id}") + + rx_cmd =3D f"{cfg.bin_local} -s -p {port} -i {cfg.ifname} -q {combined= _chans - 1} -x 2" + tx_cmd =3D f"{cfg.bin_remote} -c -h {cfg.addr_v['6']} -p {port} -l 128= 40" + + probe =3D cmd(rx_cmd + " -d", fail=3DFalse) + if probe.ret =3D=3D SKIP_CODE: + raise KsftSkipEx(probe.stdout) + + with bkg(rx_cmd, exit_wait=3DTrue): + wait_port_listen(port, proto=3D"tcp") + cmd(tx_cmd, host=3Dcfg.remote) + + def main() -> None: with NetDrvEpEnv(__file__) as cfg: cfg.bin_local =3D path.abspath(path.dirname(__file__) + "/../../..= /drivers/net/hw/iou-zcrx") --=20 2.52.0