Skip to content

Commit d663976

Browse files
isilenceaxboe
authored andcommitted
io_uring/zcrx: introduce IORING_REGISTER_ZCRX_CTRL
It'll be annoying and take enough of boilerplate code to implement new zcrx features as separate io_uring register opcode. Introduce IORING_REGISTER_ZCRX_CTRL that will multiplex such calls to zcrx. Note, there are no real users of the opcode in this patch. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 1b8b5d0 commit d663976

4 files changed

Lines changed: 43 additions & 0 deletions

File tree

include/uapi/linux/io_uring.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,9 @@ enum io_uring_register_op {
697697
/* query various aspects of io_uring, see linux/io_uring/query.h */
698698
IORING_REGISTER_QUERY = 35,
699699

700+
/* auxiliary zcrx configuration, see enum zcrx_ctrl_op */
701+
IORING_REGISTER_ZCRX_CTRL = 36,
702+
700703
/* this goes last */
701704
IORING_REGISTER_LAST,
702705

@@ -1078,6 +1081,16 @@ struct io_uring_zcrx_ifq_reg {
10781081
__u64 __resv[3];
10791082
};
10801083

1084+
enum zcrx_ctrl_op {
1085+
__ZCRX_CTRL_LAST,
1086+
};
1087+
1088+
struct zcrx_ctrl {
1089+
__u32 zcrx_id;
1090+
__u32 op; /* see enum zcrx_ctrl_op */
1091+
__u64 __resv[8];
1092+
};
1093+
10811094
#ifdef __cplusplus
10821095
}
10831096
#endif

io_uring/register.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -815,6 +815,9 @@ static int __io_uring_register(struct io_ring_ctx *ctx, unsigned opcode,
815815
case IORING_REGISTER_QUERY:
816816
ret = io_query(ctx, arg, nr_args);
817817
break;
818+
case IORING_REGISTER_ZCRX_CTRL:
819+
ret = io_zcrx_ctrl(ctx, arg, nr_args);
820+
break;
818821
default:
819822
ret = -EINVAL;
820823
break;

io_uring/zcrx.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -941,6 +941,27 @@ static const struct memory_provider_ops io_uring_pp_zc_ops = {
941941
.uninstall = io_pp_uninstall,
942942
};
943943

944+
int io_zcrx_ctrl(struct io_ring_ctx *ctx, void __user *arg, unsigned nr_args)
945+
{
946+
struct zcrx_ctrl ctrl;
947+
struct io_zcrx_ifq *zcrx;
948+
949+
if (nr_args)
950+
return -EINVAL;
951+
if (copy_from_user(&ctrl, arg, sizeof(ctrl)))
952+
return -EFAULT;
953+
if (!mem_is_zero(&ctrl.__resv, sizeof(ctrl.__resv)))
954+
return -EFAULT;
955+
956+
zcrx = xa_load(&ctx->zcrx_ctxs, ctrl.zcrx_id);
957+
if (!zcrx)
958+
return -ENXIO;
959+
if (ctrl.op >= __ZCRX_CTRL_LAST)
960+
return -EOPNOTSUPP;
961+
962+
return -EINVAL;
963+
}
964+
944965
static bool io_zcrx_queue_cqe(struct io_kiocb *req, struct net_iov *niov,
945966
struct io_zcrx_ifq *ifq, int off, int len)
946967
{

io_uring/zcrx.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ struct io_zcrx_ifq {
6565
};
6666

6767
#if defined(CONFIG_IO_URING_ZCRX)
68+
int io_zcrx_ctrl(struct io_ring_ctx *ctx, void __user *arg, unsigned nr_arg);
6869
int io_register_zcrx_ifq(struct io_ring_ctx *ctx,
6970
struct io_uring_zcrx_ifq_reg __user *arg);
7071
void io_unregister_zcrx_ifqs(struct io_ring_ctx *ctx);
@@ -93,6 +94,11 @@ static inline struct io_mapped_region *io_zcrx_get_region(struct io_ring_ctx *ct
9394
{
9495
return NULL;
9596
}
97+
static inline int io_zcrx_ctrl(struct io_ring_ctx *ctx,
98+
void __user *arg, unsigned nr_arg)
99+
{
100+
return -EOPNOTSUPP;
101+
}
96102
#endif
97103

98104
int io_recvzc(struct io_kiocb *req, unsigned int issue_flags);

0 commit comments

Comments
 (0)