Skip to content

Commit 0926f94

Browse files
spikehaxboe
authored andcommitted
io_uring/zcrx: add io_fill_zcrx_offsets()
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> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent d7af80b commit 0926f94

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

io_uring/zcrx.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,13 @@ static void io_zcrx_get_niov_uref(struct net_iov *niov)
345345
atomic_inc(io_get_user_counter(niov));
346346
}
347347

348+
static void io_fill_zcrx_offsets(struct io_uring_zcrx_offsets *offsets)
349+
{
350+
offsets->head = offsetof(struct io_uring, head);
351+
offsets->tail = offsetof(struct io_uring, tail);
352+
offsets->rqes = ALIGN(sizeof(struct io_uring), L1_CACHE_BYTES);
353+
}
354+
348355
static int io_allocate_rbuf_ring(struct io_ring_ctx *ctx,
349356
struct io_zcrx_ifq *ifq,
350357
struct io_uring_zcrx_ifq_reg *reg,
@@ -356,7 +363,8 @@ static int io_allocate_rbuf_ring(struct io_ring_ctx *ctx,
356363
void *ptr;
357364
int ret;
358365

359-
off = ALIGN(sizeof(struct io_uring), L1_CACHE_BYTES);
366+
io_fill_zcrx_offsets(&reg->offsets);
367+
off = reg->offsets.rqes;
360368
size = off + sizeof(struct io_uring_zcrx_rqe) * reg->rq_entries;
361369
if (size > rd->size)
362370
return -EINVAL;
@@ -372,9 +380,6 @@ static int io_allocate_rbuf_ring(struct io_ring_ctx *ctx,
372380
ifq->rq_ring = (struct io_uring *)ptr;
373381
ifq->rqes = (struct io_uring_zcrx_rqe *)(ptr + off);
374382

375-
reg->offsets.head = offsetof(struct io_uring, head);
376-
reg->offsets.tail = offsetof(struct io_uring, tail);
377-
reg->offsets.rqes = off;
378383
return 0;
379384
}
380385

0 commit comments

Comments
 (0)