Merge branch 'zcrx-query-6.19' into for-6.19/io_uring

Merge zcrx SQ/CQ query changes from Pavel:

"Introduce zcrx and SQ/CQ layout queries. The former returns what zcrx
 features are available. And both return the ring size information to
 help with allocation size calculation for user provided rings like
 IORING_SETUP_NO_MMAP and. IORING_MEM_REGION_TYPE_USER"

Link: https://lore.kernel.org/io-uring/cover.1763030298.git.asml.silence@gmail.com/
Signed-off-by: Jens Axboe <axboe@kernel.dk>

* zcrx-query-6.19:
  io_uring/query: introduce rings info query
  io_uring/query: introduce zcrx query
This commit is contained in:
Jens Axboe 2025-11-13 11:18:19 -07:00
commit 5bd38e18d5
2 changed files with 56 additions and 0 deletions

View File

@ -18,6 +18,8 @@ struct io_uring_query_hdr {
enum {
IO_URING_QUERY_OPCODES = 0,
IO_URING_QUERY_ZCRX = 1,
IO_URING_QUERY_SCQ = 2,
__IO_URING_QUERY_MAX,
};
@ -41,4 +43,26 @@ struct io_uring_query_opcode {
__u32 __pad;
};
struct io_uring_query_zcrx {
/* Bitmask of supported ZCRX_REG_* flags, */
__u64 register_flags;
/* Bitmask of all supported IORING_ZCRX_AREA_* flags */
__u64 area_flags;
/* The number of supported ZCRX_CTRL_* opcodes */
__u32 nr_ctrl_opcodes;
__u32 __resv1;
/* The refill ring header size */
__u32 rq_hdr_size;
/* The alignment for the header */
__u32 rq_hdr_alignment;
__u64 __resv2;
};
struct io_uring_query_scq {
/* The SQ/CQ rings header size */
__u64 hdr_size;
/* The alignment for the header */
__u64 hdr_alignment;
};
#endif

View File

@ -4,9 +4,12 @@
#include "query.h"
#include "io_uring.h"
#include "zcrx.h"
union io_query_data {
struct io_uring_query_opcode opcodes;
struct io_uring_query_zcrx zcrx;
struct io_uring_query_scq scq;
};
#define IO_MAX_QUERY_SIZE sizeof(union io_query_data)
@ -27,6 +30,29 @@ static ssize_t io_query_ops(union io_query_data *data)
return sizeof(*e);
}
static ssize_t io_query_zcrx(union io_query_data *data)
{
struct io_uring_query_zcrx *e = &data->zcrx;
e->register_flags = ZCRX_REG_IMPORT;
e->area_flags = IORING_ZCRX_AREA_DMABUF;
e->nr_ctrl_opcodes = __ZCRX_CTRL_LAST;
e->rq_hdr_size = sizeof(struct io_uring);
e->rq_hdr_alignment = L1_CACHE_BYTES;
e->__resv1 = 0;
e->__resv2 = 0;
return sizeof(*e);
}
static ssize_t io_query_scq(union io_query_data *data)
{
struct io_uring_query_scq *e = &data->scq;
e->hdr_size = sizeof(struct io_rings);
e->hdr_alignment = SMP_CACHE_BYTES;
return sizeof(*e);
}
static int io_handle_query_entry(struct io_ring_ctx *ctx,
union io_query_data *data, void __user *uhdr,
u64 *next_entry)
@ -55,6 +81,12 @@ static int io_handle_query_entry(struct io_ring_ctx *ctx,
case IO_URING_QUERY_OPCODES:
ret = io_query_ops(data);
break;
case IO_URING_QUERY_ZCRX:
ret = io_query_zcrx(data);
break;
case IO_URING_QUERY_SCQ:
ret = io_query_scq(data);
break;
}
if (ret >= 0) {