public inbox for io-uring@vger.kernel.org
 help / color / mirror / Atom feed
From: Pavel Begunkov <asml.silence@gmail.com>
To: io-uring@vger.kernel.org
Cc: asml.silence@gmail.com, David Wei <dw@davidwei.uk>
Subject: [PATCH liburing 3/5] tests/zcrx: use returned right zcrx id
Date: Wed, 16 Apr 2025 10:01:15 +0100	[thread overview]
Message-ID: <9ea2bd6f45b22e559327c235a6a44d5fe2c521b0.1744793980.git.asml.silence@gmail.com> (raw)
In-Reply-To: <cover.1744793980.git.asml.silence@gmail.com>

Now we return the zcrx id back to the user, use it.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
 test/zcrx.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/test/zcrx.c b/test/zcrx.c
index 0fa8f2bd..b60462a6 100644
--- a/test/zcrx.c
+++ b/test/zcrx.c
@@ -344,7 +344,7 @@ static int test_area_access(void)
 	return T_EXIT_PASS;
 }
 
-static int create_ring_with_ifq(struct io_uring *ring, void *area)
+static int create_ring_with_ifq(struct io_uring *ring, void *area, __u32 *id)
 {
 	struct io_uring_zcrx_area_reg area_reg = {
 		.addr = (__u64)(unsigned long)area,
@@ -371,6 +371,7 @@ static int create_ring_with_ifq(struct io_uring *ring, void *area)
 		fprintf(stderr, "ifq register failed %d\n", ret);
 		return T_EXIT_FAIL;
 	}
+	*id = reg.zcrx_id;
 	return 0;
 }
 
@@ -406,9 +407,10 @@ static int test_invalid_zcrx_request(void *area)
 	struct io_uring_cqe *cqe;
 	struct io_uring_sqe *sqe;
 	struct io_uring ring;
+	__u32 zcrx_id;
 	int ret, fds[2];
 
-	ret = create_ring_with_ifq(&ring, area);
+	ret = create_ring_with_ifq(&ring, area, &zcrx_id);
 	if (ret != T_SETUP_OK) {
 		fprintf(stderr, "ifq-ring create failed: %d\n", ret);
 		return T_EXIT_FAIL;
@@ -422,7 +424,7 @@ static int test_invalid_zcrx_request(void *area)
 
 	/* invalid file */
 	sqe = io_uring_get_sqe(&ring);
-	test_io_uring_prep_zcrx(sqe, ring.ring_fd, 0);
+	test_io_uring_prep_zcrx(sqe, ring.ring_fd, zcrx_id);
 
 	cqe = submit_and_wait_one(&ring);
 	if (!cqe) {
@@ -441,7 +443,7 @@ static int test_invalid_zcrx_request(void *area)
 
 	/* invalid ifq idx */
 	sqe = io_uring_get_sqe(&ring);
-	test_io_uring_prep_zcrx(sqe, fds[0], 1);
+	test_io_uring_prep_zcrx(sqe, fds[0], zcrx_id + 1);
 
 	cqe = submit_and_wait_one(&ring);
 	if (!cqe) {
@@ -478,7 +480,8 @@ struct recv_data {
 	struct io_uring_zcrx_rq rq_ring;
 };
 
-static int recv_prep(struct io_uring *ring, struct recv_data *rd, int *sock)
+static int recv_prep(struct io_uring *ring, struct recv_data *rd, int *sock,
+		     __u32 zcrx_id)
 {
 	struct sockaddr_in saddr;
 	struct io_uring_sqe *sqe;
@@ -526,7 +529,7 @@ static int recv_prep(struct io_uring *ring, struct recv_data *rd, int *sock)
 
 	sqe = io_uring_get_sqe(ring);
 	io_uring_prep_rw(IORING_OP_RECV_ZC, sqe, use_fd, NULL, 0, 0);
-	sqe->zcrx_ifq_idx = 0;
+	sqe->zcrx_ifq_idx = zcrx_id;
 	sqe->ioprio |= IORING_RECV_MULTISHOT;
 	sqe->user_data = 2;
 
@@ -693,7 +696,7 @@ static void *recv_fn(void *data)
 	rd->rq_ring.rq_tail = 0;
 	rd->rq_ring.ring_entries = reg.rq_entries;
 
-	ret = recv_prep(&ring, rd, &sock);
+	ret = recv_prep(&ring, rd, &sock, reg.zcrx_id);
 	if (ret) {
 		fprintf(stderr, "recv_prep failed: %d\n", ret);
 		goto err;
-- 
2.48.1


  parent reply	other threads:[~2025-04-16  9:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-16  9:01 [PATCH liburing 0/5] zcrx example and other changes Pavel Begunkov
2025-04-16  9:01 ` [PATCH liburing 1/5] Update io_uring.h for zcrx Pavel Begunkov
2025-04-16  9:01 ` [PATCH liburing 2/5] tests/zcrx: rename a test Pavel Begunkov
2025-04-16  9:01 ` Pavel Begunkov [this message]
2025-04-16  9:01 ` [PATCH liburing 4/5] examples: add extra helpers Pavel Begunkov
2025-04-16  9:01 ` [PATCH liburing 5/5] examples: add a zcrx example Pavel Begunkov
2025-04-16 14:48 ` [PATCH liburing 0/5] zcrx example and other changes Jens Axboe

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=9ea2bd6f45b22e559327c235a6a44d5fe2c521b0.1744793980.git.asml.silence@gmail.com \
    --to=asml.silence@gmail.com \
    --cc=dw@davidwei.uk \
    --cc=io-uring@vger.kernel.org \
    /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