Skip to content

Commit 5bd38e1

Browse files
committed
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
2 parents d741c62 + 4aaa9bc commit 5bd38e1

2 files changed

Lines changed: 56 additions & 0 deletions

File tree

include/uapi/linux/io_uring/query.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ struct io_uring_query_hdr {
1818

1919
enum {
2020
IO_URING_QUERY_OPCODES = 0,
21+
IO_URING_QUERY_ZCRX = 1,
22+
IO_URING_QUERY_SCQ = 2,
2123

2224
__IO_URING_QUERY_MAX,
2325
};
@@ -41,4 +43,26 @@ struct io_uring_query_opcode {
4143
__u32 __pad;
4244
};
4345

46+
struct io_uring_query_zcrx {
47+
/* Bitmask of supported ZCRX_REG_* flags, */
48+
__u64 register_flags;
49+
/* Bitmask of all supported IORING_ZCRX_AREA_* flags */
50+
__u64 area_flags;
51+
/* The number of supported ZCRX_CTRL_* opcodes */
52+
__u32 nr_ctrl_opcodes;
53+
__u32 __resv1;
54+
/* The refill ring header size */
55+
__u32 rq_hdr_size;
56+
/* The alignment for the header */
57+
__u32 rq_hdr_alignment;
58+
__u64 __resv2;
59+
};
60+
61+
struct io_uring_query_scq {
62+
/* The SQ/CQ rings header size */
63+
__u64 hdr_size;
64+
/* The alignment for the header */
65+
__u64 hdr_alignment;
66+
};
67+
4468
#endif

io_uring/query.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44

55
#include "query.h"
66
#include "io_uring.h"
7+
#include "zcrx.h"
78

89
union io_query_data {
910
struct io_uring_query_opcode opcodes;
11+
struct io_uring_query_zcrx zcrx;
12+
struct io_uring_query_scq scq;
1013
};
1114

1215
#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)
2730
return sizeof(*e);
2831
}
2932

33+
static ssize_t io_query_zcrx(union io_query_data *data)
34+
{
35+
struct io_uring_query_zcrx *e = &data->zcrx;
36+
37+
e->register_flags = ZCRX_REG_IMPORT;
38+
e->area_flags = IORING_ZCRX_AREA_DMABUF;
39+
e->nr_ctrl_opcodes = __ZCRX_CTRL_LAST;
40+
e->rq_hdr_size = sizeof(struct io_uring);
41+
e->rq_hdr_alignment = L1_CACHE_BYTES;
42+
e->__resv1 = 0;
43+
e->__resv2 = 0;
44+
return sizeof(*e);
45+
}
46+
47+
static ssize_t io_query_scq(union io_query_data *data)
48+
{
49+
struct io_uring_query_scq *e = &data->scq;
50+
51+
e->hdr_size = sizeof(struct io_rings);
52+
e->hdr_alignment = SMP_CACHE_BYTES;
53+
return sizeof(*e);
54+
}
55+
3056
static int io_handle_query_entry(struct io_ring_ctx *ctx,
3157
union io_query_data *data, void __user *uhdr,
3258
u64 *next_entry)
@@ -55,6 +81,12 @@ static int io_handle_query_entry(struct io_ring_ctx *ctx,
5581
case IO_URING_QUERY_OPCODES:
5682
ret = io_query_ops(data);
5783
break;
84+
case IO_URING_QUERY_ZCRX:
85+
ret = io_query_zcrx(data);
86+
break;
87+
case IO_URING_QUERY_SCQ:
88+
ret = io_query_scq(data);
89+
break;
5890
}
5991

6092
if (ret >= 0) {

0 commit comments

Comments
 (0)