From: Pavel Begunkov <asml.silence@gmail.com>
To: io-uring@vger.kernel.org
Cc: asml.silence@gmail.com, axboe@kernel.dk, netdev@vger.kernel.org,
David Wei <dw@davidwei.uk>
Subject: [PATCH 09/10] io_uring/zcrx: add io_fill_zcrx_offsets()
Date: Thu, 13 Nov 2025 10:46:17 +0000 [thread overview]
Message-ID: <fa48b1d6ee57977c7f4abb774aa888c474c295e0.1763029704.git.asml.silence@gmail.com> (raw)
In-Reply-To: <cover.1763029704.git.asml.silence@gmail.com>
From: David Wei <dw@davidwei.uk>
Add a helper io_fill_zcrx_offsets() that sets the constant offsets in
struct io_uring_zcrx_offsets returned to userspace.
Signed-off-by: David Wei <dw@davidwei.uk>
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
io_uring/zcrx.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/io_uring/zcrx.c b/io_uring/zcrx.c
index 815992aff246..da7e556c349e 100644
--- a/io_uring/zcrx.c
+++ b/io_uring/zcrx.c
@@ -345,6 +345,13 @@ static void io_zcrx_get_niov_uref(struct net_iov *niov)
atomic_inc(io_get_user_counter(niov));
}
+static void io_fill_zcrx_offsets(struct io_uring_zcrx_offsets *offsets)
+{
+ offsets->head = offsetof(struct io_uring, head);
+ offsets->tail = offsetof(struct io_uring, tail);
+ offsets->rqes = ALIGN(sizeof(struct io_uring), L1_CACHE_BYTES);
+}
+
static int io_allocate_rbuf_ring(struct io_ring_ctx *ctx,
struct io_zcrx_ifq *ifq,
struct io_uring_zcrx_ifq_reg *reg,
@@ -356,7 +363,8 @@ static int io_allocate_rbuf_ring(struct io_ring_ctx *ctx,
void *ptr;
int ret;
- off = ALIGN(sizeof(struct io_uring), L1_CACHE_BYTES);
+ io_fill_zcrx_offsets(®->offsets);
+ off = reg->offsets.rqes;
size = off + sizeof(struct io_uring_zcrx_rqe) * reg->rq_entries;
if (size > rd->size)
return -EINVAL;
@@ -372,9 +380,6 @@ static int io_allocate_rbuf_ring(struct io_ring_ctx *ctx,
ifq->rq_ring = (struct io_uring *)ptr;
ifq->rqes = (struct io_uring_zcrx_rqe *)(ptr + off);
- reg->offsets.head = offsetof(struct io_uring, head);
- reg->offsets.tail = offsetof(struct io_uring, tail);
- reg->offsets.rqes = off;
return 0;
}
--
2.49.0
next prev parent reply other threads:[~2025-11-13 10:46 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-13 10:46 [PATCH 00/10] io_uring for-6.19 zcrx updates Pavel Begunkov
2025-11-13 10:46 ` [PATCH 01/10] io_uring/zcrx: convert to use netmem_desc Pavel Begunkov
2025-11-13 10:46 ` [PATCH 02/10] io_uring/zcrx: use folio_nr_pages() instead of shift operation Pavel Begunkov
2025-11-13 10:46 ` [PATCH 03/10] io_uring/zcrx: elide passing msg flags Pavel Begunkov
2025-11-13 10:46 ` [PATCH 04/10] io_uring/zcrx: introduce IORING_REGISTER_ZCRX_CTRL Pavel Begunkov
2025-11-13 10:46 ` [PATCH 05/10] io_uring/zcrx: add sync refill queue flushing Pavel Begunkov
2025-11-13 10:46 ` [PATCH 06/10] io_uring/zcrx: count zcrx users Pavel Begunkov
2025-11-13 10:46 ` [PATCH 07/10] io_uring/zcrx: move io_zcrx_scrub() and dependencies up Pavel Begunkov
2025-11-13 10:46 ` [PATCH 08/10] io_uring/zcrx: export zcrx via a file Pavel Begunkov
2025-11-13 10:46 ` Pavel Begunkov [this message]
2025-11-13 10:46 ` [PATCH 10/10] io_uring/zcrx: share an ifq between rings Pavel Begunkov
2025-11-13 18:38 ` [PATCH 00/10] io_uring for-6.19 zcrx updates 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=fa48b1d6ee57977c7f4abb774aa888c474c295e0.1763029704.git.asml.silence@gmail.com \
--to=asml.silence@gmail.com \
--cc=axboe@kernel.dk \
--cc=dw@davidwei.uk \
--cc=io-uring@vger.kernel.org \
--cc=netdev@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