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 v2 1/4] examples/zcrx: consolidate add_recvzc variants
Date: Mon, 21 Apr 2025 08:25:29 +0100	[thread overview]
Message-ID: <321d834fffb337204ade9e693c97f3730747362b.1745220124.git.asml.silence@gmail.com> (raw)
In-Reply-To: <cover.1745220124.git.asml.silence@gmail.com>

Pass len to add_recvzc, 0 means it's unlimited, and kill the oneshot
variant.

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

diff --git a/examples/zcrx.c b/examples/zcrx.c
index 32d9e4ae..727943c4 100644
--- a/examples/zcrx.c
+++ b/examples/zcrx.c
@@ -140,17 +140,7 @@ static void add_accept(struct io_uring *ring, int sockfd)
 	sqe->user_data = 1;
 }
 
-static void add_recvzc(struct io_uring *ring, int sockfd)
-{
-	struct io_uring_sqe *sqe = io_uring_get_sqe(ring);
-
-	io_uring_prep_rw(IORING_OP_RECV_ZC, sqe, sockfd, NULL, 0, 0);
-	sqe->ioprio |= IORING_RECV_MULTISHOT;
-	sqe->zcrx_ifq_idx = zcrx_id;
-	sqe->user_data = 2;
-}
-
-static void add_recvzc_oneshot(struct io_uring *ring, int sockfd, size_t len)
+static void add_recvzc(struct io_uring *ring, int sockfd, size_t len)
 {
 	struct io_uring_sqe *sqe = io_uring_get_sqe(ring);
 
@@ -168,10 +158,7 @@ static void process_accept(struct io_uring *ring, struct io_uring_cqe *cqe)
 		t_error(1, 0, "Unexpected second connection");
 
 	connfd = cqe->res;
-	if (cfg_oneshot)
-		add_recvzc_oneshot(ring, connfd, page_size);
-	else
-		add_recvzc(ring, connfd);
+	add_recvzc(ring, connfd, cfg_oneshot ? page_size : 0);
 }
 
 static void verify_data(char *data, size_t size, unsigned long seq)
@@ -207,11 +194,11 @@ static void process_recvzc(struct io_uring *ring, struct io_uring_cqe *cqe)
 
 	if (cfg_oneshot) {
 		if (cqe->res == 0 && cqe->flags == 0 && cfg_oneshot_recvs) {
-			add_recvzc_oneshot(ring, connfd, page_size);
+			add_recvzc(ring, connfd, page_size);
 			cfg_oneshot_recvs--;
 		}
 	} else if (!(cqe->flags & IORING_CQE_F_MORE)) {
-		add_recvzc(ring, connfd);
+		add_recvzc(ring, connfd, 0);
 	}
 
 	rcqe = (struct io_uring_zcrx_cqe *)(cqe + 1);
-- 
2.48.1


  reply	other threads:[~2025-04-21  7:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-21  7:25 [PATCH liburing v2 0/4] zcrx refill queue allocation modes Pavel Begunkov
2025-04-21  7:25 ` Pavel Begunkov [this message]
2025-04-21  7:25 ` [PATCH liburing v2 2/4] examples/zcrx: rework size limiting Pavel Begunkov
2025-04-21  7:25 ` [PATCH liburing v2 3/4] examples/zcrx: constants for request types Pavel Begunkov
2025-04-21  7:25 ` [PATCH liburing v2 4/4] examples/zcrx: add refill queue allocation modes Pavel Begunkov
2025-04-21 15:26 ` [PATCH liburing v2 0/4] zcrx " 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=321d834fffb337204ade9e693c97f3730747362b.1745220124.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