]> Gentwo Git Trees - linux/.git/commitdiff
io_uring/zcrx: introduce IORING_REGISTER_ZCRX_CTRL
authorPavel Begunkov <asml.silence@gmail.com>
Thu, 13 Nov 2025 10:46:12 +0000 (10:46 +0000)
committerJens Axboe <axboe@kernel.dk>
Thu, 13 Nov 2025 18:19:37 +0000 (11:19 -0700)
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>
include/uapi/linux/io_uring.h
io_uring/register.c
io_uring/zcrx.c
io_uring/zcrx.h

index e96080db3e4d82d355fa02b1090c1c4ef6f3cb32..0e1d353fab1d2f29f641b533cd0e8ce3c7364e67 100644 (file)
@@ -697,6 +697,9 @@ enum io_uring_register_op {
        /* query various aspects of io_uring, see linux/io_uring/query.h */
        IORING_REGISTER_QUERY                   = 35,
 
+       /* auxiliary zcrx configuration, see enum zcrx_ctrl_op */
+       IORING_REGISTER_ZCRX_CTRL               = 36,
+
        /* this goes last */
        IORING_REGISTER_LAST,
 
@@ -1078,6 +1081,16 @@ struct io_uring_zcrx_ifq_reg {
        __u64   __resv[3];
 };
 
+enum zcrx_ctrl_op {
+       __ZCRX_CTRL_LAST,
+};
+
+struct zcrx_ctrl {
+       __u32   zcrx_id;
+       __u32   op; /* see enum zcrx_ctrl_op */
+       __u64   __resv[8];
+};
+
 #ifdef __cplusplus
 }
 #endif
index 334a457da3f79bd956a57a3e243b6cf99d6206ba..fc66a536448359e94b3a07c41de45a55c211304a 100644 (file)
@@ -815,6 +815,9 @@ static int __io_uring_register(struct io_ring_ctx *ctx, unsigned opcode,
        case IORING_REGISTER_QUERY:
                ret = io_query(ctx, arg, nr_args);
                break;
+       case IORING_REGISTER_ZCRX_CTRL:
+               ret = io_zcrx_ctrl(ctx, arg, nr_args);
+               break;
        default:
                ret = -EINVAL;
                break;
index 149bf9d5b98305ab2bf4331c55ed712f7a9e9e1e..0b5f4320c7a98b623a8402c91fc2cff0c4a39ae0 100644 (file)
@@ -941,6 +941,27 @@ static const struct memory_provider_ops io_uring_pp_zc_ops = {
        .uninstall              = io_pp_uninstall,
 };
 
+int io_zcrx_ctrl(struct io_ring_ctx *ctx, void __user *arg, unsigned nr_args)
+{
+       struct zcrx_ctrl ctrl;
+       struct io_zcrx_ifq *zcrx;
+
+       if (nr_args)
+               return -EINVAL;
+       if (copy_from_user(&ctrl, arg, sizeof(ctrl)))
+               return -EFAULT;
+       if (!mem_is_zero(&ctrl.__resv, sizeof(ctrl.__resv)))
+               return -EFAULT;
+
+       zcrx = xa_load(&ctx->zcrx_ctxs, ctrl.zcrx_id);
+       if (!zcrx)
+               return -ENXIO;
+       if (ctrl.op >= __ZCRX_CTRL_LAST)
+               return -EOPNOTSUPP;
+
+       return -EINVAL;
+}
+
 static bool io_zcrx_queue_cqe(struct io_kiocb *req, struct net_iov *niov,
                              struct io_zcrx_ifq *ifq, int off, int len)
 {
index c9b9bfae05473bdf395f1ec892fdfe19d79c6c96..f29edc22c91f06e1b3965603f4e6e8f0ce26bdda 100644 (file)
@@ -65,6 +65,7 @@ struct io_zcrx_ifq {
 };
 
 #if defined(CONFIG_IO_URING_ZCRX)
+int io_zcrx_ctrl(struct io_ring_ctx *ctx, void __user *arg, unsigned nr_arg);
 int io_register_zcrx_ifq(struct io_ring_ctx *ctx,
                         struct io_uring_zcrx_ifq_reg __user *arg);
 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
 {
        return NULL;
 }
+static inline int io_zcrx_ctrl(struct io_ring_ctx *ctx,
+                               void __user *arg, unsigned nr_arg)
+{
+       return -EOPNOTSUPP;
+}
 #endif
 
 int io_recvzc(struct io_kiocb *req, unsigned int issue_flags);