io_uring/chan: add support for IORING_OP_CHAN_POST
authorJens Axboe <axboe@kernel.dk>
Thu, 24 Jul 2025 18:41:30 +0000 (12:41 -0600)
committerJens Axboe <axboe@kernel.dk>
Sat, 9 Aug 2025 14:38:27 +0000 (08:38 -0600)
commit11e8bd03794364ebfc3e3603334896e76e6fa976
tree333f6851fb06bfd7b4e19c772ecf2f5fb965bea3
parentf5f2de273c6c5a21dad75f5a83158886726b5d9f
io_uring/chan: add support for IORING_OP_CHAN_POST

If a ring has setup a unidirectional communication line between two
rings, it can use IORING_OP_CHAN_POST to efficiently send data from one
ring to another.

The destination ring must be setup with DEFER_TASKRUN and be able to
post 32b CQEs. The former for efficiency reasons, the latter to be able
to pass enough information in a IORING_OP_CHAN_POST request.

On the source ring, the SQE must be setup as follows:

->fd Queue to target. Queue IDs are 1..USHRT_MAX and returned
from io_uring_register() with IORING_OP_REGISTER_CHAN.
->rw_flags Modifier flags. Supports IORING_CHAN_IDLE for now, which
picks a source queue that is currently idle (eg waiting
on CQEs). If that flag is set, ->fd must be set to zero.
->addr Target ring cqe->user_data will be set to this value.
->off Target ring cqe->big_cqe[0] will be set to this value.

On the source ring, cqe->res will be set to < 0 in case of error. For
success, cqe->res will be set to the target queue ID that received the
message.

On the target, the cqe->res will be the queue ID to use for a response,
if the communication channel has been setup with IORING_CHAN_REG_BIDI.
If the channel is non-bidi, then the result will be 0.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
include/linux/io_uring_types.h
include/uapi/linux/io_uring.h
io_uring/chan.c
io_uring/chan.h
io_uring/io_uring.c
io_uring/opdef.c