mirror of https://github.com/torvalds/linux.git
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>
This commit is contained in:
parent
d7af80b213
commit
0926f94ab3
|
|
@ -345,6 +345,13 @@ static void io_zcrx_get_niov_uref(struct net_iov *niov)
|
||||||
atomic_inc(io_get_user_counter(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,
|
static int io_allocate_rbuf_ring(struct io_ring_ctx *ctx,
|
||||||
struct io_zcrx_ifq *ifq,
|
struct io_zcrx_ifq *ifq,
|
||||||
struct io_uring_zcrx_ifq_reg *reg,
|
struct io_uring_zcrx_ifq_reg *reg,
|
||||||
|
|
@ -356,7 +363,8 @@ static int io_allocate_rbuf_ring(struct io_ring_ctx *ctx,
|
||||||
void *ptr;
|
void *ptr;
|
||||||
int ret;
|
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;
|
size = off + sizeof(struct io_uring_zcrx_rqe) * reg->rq_entries;
|
||||||
if (size > rd->size)
|
if (size > rd->size)
|
||||||
return -EINVAL;
|
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->rq_ring = (struct io_uring *)ptr;
|
||||||
ifq->rqes = (struct io_uring_zcrx_rqe *)(ptr + off);
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue