| ... | @@ -3496,6 +3496,12 @@ pub const IORING_FEAT_RW_CUR_POS = 1 << 3; | ... | @@ -3496,6 +3496,12 @@ pub const IORING_FEAT_RW_CUR_POS = 1 << 3; |
| 3496 | pub const IORING_FEAT_CUR_PERSONALITY = 1 << 4; | 3496 | pub const IORING_FEAT_CUR_PERSONALITY = 1 << 4; |
| 3497 | pub const IORING_FEAT_FAST_POLL = 1 << 5; | 3497 | pub const IORING_FEAT_FAST_POLL = 1 << 5; |
| 3498 | pub const IORING_FEAT_POLL_32BITS = 1 << 6; | 3498 | pub const IORING_FEAT_POLL_32BITS = 1 << 6; |
| | 3499 | pub const IORING_FEAT_SQPOLL_NONFIXED = 1 << 7; |
| | 3500 | pub const IORING_FEAT_EXT_ARG = 1 << 8; |
| | 3501 | pub const IORING_FEAT_NATIVE_WORKERS = 1 << 9; |
| | 3502 | pub const IORING_FEAT_RSRC_TAGS = 1 << 10; |
| | 3503 | pub const IORING_FEAT_CQE_SKIP = 1 << 11; |
| | 3504 | pub const IORING_FEAT_LINKED_FILE = 1 << 12; |
| 3499 | | 3505 | |
| 3500 | // io_uring_params.flags | 3506 | // io_uring_params.flags |
| 3501 | | 3507 | |
| ... | @@ -3520,6 +3526,26 @@ pub const IORING_SETUP_ATTACH_WQ = 1 << 5; | ... | @@ -3520,6 +3526,26 @@ pub const IORING_SETUP_ATTACH_WQ = 1 << 5; |
| 3520 | /// start with ring disabled | 3526 | /// start with ring disabled |
| 3521 | pub const IORING_SETUP_R_DISABLED = 1 << 6; | 3527 | pub const IORING_SETUP_R_DISABLED = 1 << 6; |
| 3522 | | 3528 | |
| | 3529 | /// continue submit on error |
| | 3530 | pub const IORING_SETUP_SUBMIT_ALL = 1 << 7; |
| | 3531 | |
| | 3532 | /// Cooperative task running. When requests complete, they often require |
| | 3533 | /// forcing the submitter to transition to the kernel to complete. If this |
| | 3534 | /// flag is set, work will be done when the task transitions anyway, rather |
| | 3535 | /// than force an inter-processor interrupt reschedule. This avoids interrupting |
| | 3536 | /// a task running in userspace, and saves an IPI. |
| | 3537 | pub const IORING_SETUP_COOP_TASKRUN = 1 << 8; |
| | 3538 | |
| | 3539 | /// If COOP_TASKRUN is set, get notified if task work is available for |
| | 3540 | /// running and a kernel transition would be needed to run it. This sets |
| | 3541 | /// IORING_SQ_TASKRUN in the sq ring flags. Not valid with COOP_TASKRUN. |
| | 3542 | pub const IORING_SETUP_TASKRUN_FLAG = 1 << 9; |
| | 3543 | |
| | 3544 | /// SQEs are 128 byte |
| | 3545 | pub const IORING_SETUP_SQE128 = 1 << 10; |
| | 3546 | /// CQEs are 32 byte |
| | 3547 | pub const IORING_SETUP_CQE32 = 1 << 11; |
| | 3548 | |
| 3523 | pub const io_sqring_offsets = extern struct { | 3549 | pub const io_sqring_offsets = extern struct { |
| 3524 | /// offset of ring head | 3550 | /// offset of ring head |
| 3525 | head: u32, | 3551 | head: u32, |
| ... | @@ -3550,9 +3576,10 @@ pub const io_sqring_offsets = extern struct { | ... | @@ -3550,9 +3576,10 @@ pub const io_sqring_offsets = extern struct { |
| 3550 | | 3576 | |
| 3551 | /// needs io_uring_enter wakeup | 3577 | /// needs io_uring_enter wakeup |
| 3552 | pub const IORING_SQ_NEED_WAKEUP = 1 << 0; | 3578 | pub const IORING_SQ_NEED_WAKEUP = 1 << 0; |
| 3553 | | | |
| 3554 | /// kernel has cqes waiting beyond the cq ring | 3579 | /// kernel has cqes waiting beyond the cq ring |
| 3555 | pub const IORING_SQ_CQ_OVERFLOW = 1 << 1; | 3580 | pub const IORING_SQ_CQ_OVERFLOW = 1 << 1; |
| | 3581 | /// task should enter the kernel |
| | 3582 | pub const IORING_SQ_TASKRUN = 1 << 2; |
| 3556 | | 3583 | |
| 3557 | pub const io_cqring_offsets = extern struct { | 3584 | pub const io_cqring_offsets = extern struct { |
| 3558 | head: u32, | 3585 | head: u32, |
| ... | @@ -3587,6 +3614,7 @@ pub const IOSQE_BIT = enum(u8) { | ... | @@ -3587,6 +3614,7 @@ pub const IOSQE_BIT = enum(u8) { |
| 3587 | IO_HARDLINK, | 3614 | IO_HARDLINK, |
| 3588 | ASYNC, | 3615 | ASYNC, |
| 3589 | BUFFER_SELECT, | 3616 | BUFFER_SELECT, |
| | 3617 | CQE_SKIP_SUCCESS, |
| 3590 | | 3618 | |
| 3591 | _, | 3619 | _, |
| 3592 | }; | 3620 | }; |
| ... | @@ -3611,6 +3639,10 @@ pub const IOSQE_ASYNC = 1 << @enumToInt(IOSQE_BIT.ASYNC); | ... | @@ -3611,6 +3639,10 @@ pub const IOSQE_ASYNC = 1 << @enumToInt(IOSQE_BIT.ASYNC); |
| 3611 | /// select buffer from buf_group | 3639 | /// select buffer from buf_group |
| 3612 | pub const IOSQE_BUFFER_SELECT = 1 << @enumToInt(IOSQE_BIT.BUFFER_SELECT); | 3640 | pub const IOSQE_BUFFER_SELECT = 1 << @enumToInt(IOSQE_BIT.BUFFER_SELECT); |
| 3613 | | 3641 | |
| | 3642 | /// don't post CQE if request succeeded |
| | 3643 | /// Available since Linux 5.17 |
| | 3644 | pub const IOSQE_CQE_SKIP_SUCCESS = 1 << @enumToInt(IOSQE_BIT.CQE_SKIP_SUCCESS); |
| | 3645 | |
| 3614 | pub const IORING_OP = enum(u8) { | 3646 | pub const IORING_OP = enum(u8) { |
| 3615 | NOP, | 3647 | NOP, |
| 3616 | READV, | 3648 | READV, |
| ... | @@ -3656,11 +3688,51 @@ pub const IORING_OP = enum(u8) { | ... | @@ -3656,11 +3688,51 @@ pub const IORING_OP = enum(u8) { |
| 3656 | _, | 3688 | _, |
| 3657 | }; | 3689 | }; |
| 3658 | | 3690 | |
| 3659 | // io_uring_sqe.fsync_flags | 3691 | // io_uring_sqe.fsync_flags (rw_flags in the Zig struct) |
| 3660 | pub const IORING_FSYNC_DATASYNC = 1 << 0; | 3692 | pub const IORING_FSYNC_DATASYNC = 1 << 0; |
| 3661 | | 3693 | |
| 3662 | // io_uring_sqe.timeout_flags | 3694 | // io_uring_sqe.timeout_flags (rw_flags in the Zig struct) |
| 3663 | pub const IORING_TIMEOUT_ABS = 1 << 0; | 3695 | pub const IORING_TIMEOUT_ABS = 1 << 0; |
| | 3696 | pub const IORING_TIMEOUT_UPDATE = 1 << 1; // Available since Linux 5.11 |
| | 3697 | pub const IORING_TIMEOUT_BOOTTIME = 1 << 2; // Available since Linux 5.15 |
| | 3698 | pub const IORING_TIMEOUT_REALTIME = 1 << 3; // Available since Linux 5.15 |
| | 3699 | pub const IORING_LINK_TIMEOUT_UPDATE = 1 << 4; // Available since Linux 5.15 |
| | 3700 | pub const IORING_TIMEOUT_ETIME_SUCCESS = 1 << 5; // Available since Linux 5.16 |
| | 3701 | pub const IORING_TIMEOUT_CLOCK_MASK = IORING_TIMEOUT_BOOTTIME | IORING_TIMEOUT_REALTIME; |
| | 3702 | pub const IORING_TIMEOUT_UPDATE_MASK = IORING_TIMEOUT_UPDATE | IORING_LINK_TIMEOUT_UPDATE; |
| | 3703 | |
| | 3704 | // io_uring_sqe.splice_flags (rw_flags in the Zig struct) |
| | 3705 | // extends splice(2) flags |
| | 3706 | pub const IORING_SPLICE_F_FD_IN_FIXED = 1 << 31; |
| | 3707 | |
| | 3708 | // POLL_ADD flags. |
| | 3709 | // Note that since sqe->poll_events (rw_flags in the Zig struct) is the flag space, the command flags for POLL_ADD are stored in sqe->len. |
| | 3710 | |
| | 3711 | /// Multishot poll. Sets IORING_CQE_F_MORE if the poll handler will continue to report CQEs on behalf of the same SQE. |
| | 3712 | pub const IORING_POLL_ADD_MULTI = 1 << 0; |
| | 3713 | /// Update existing poll request, matching sqe->addr as the old user_data field. |
| | 3714 | pub const IORING_POLL_UPDATE_EVENTS = 1 << 1; |
| | 3715 | pub const IORING_POLL_UPDATE_USER_DATA = 1 << 2; |
| | 3716 | |
| | 3717 | // ASYNC_CANCEL flags. |
| | 3718 | |
| | 3719 | /// Cancel all requests that match the given key |
| | 3720 | pub const IORING_ASYNC_CANCEL_ALL = 1 << 0; |
| | 3721 | /// Key off 'fd' for cancelation rather than the request 'user_data'. |
| | 3722 | pub const IORING_ASYNC_CANCEL_FD = 1 << 1; |
| | 3723 | /// Match any request |
| | 3724 | pub const IORING_ASYNC_CANCEL_ANY = 1 << 2; |
| | 3725 | |
| | 3726 | // send/sendmsg and recv/recvmsg flags (sqe->ioprio) |
| | 3727 | |
| | 3728 | /// If set, instead of first attempting to send or receive and arm poll if that yields an -EAGAIN result, |
| | 3729 | /// arm poll upfront and skip the initial transfer attempt. |
| | 3730 | pub const IORING_RECVSEND_POLL_FIRST = 1 << 0; |
| | 3731 | /// Multishot recv. Sets IORING_CQE_F_MORE if the handler will continue to report CQEs on behalf of the same SQE. |
| | 3732 | pub const IORING_RECV_MULTISHOT = 1 << 1; |
| | 3733 | |
| | 3734 | /// accept flags stored in sqe->ioprio |
| | 3735 | pub const IORING_ACCEPT_MULTISHOT = 1 << 0; |
| 3664 | | 3736 | |
| 3665 | // IO completion data structure (Completion Queue Entry) | 3737 | // IO completion data structure (Completion Queue Entry) |
| 3666 | pub const io_uring_cqe = extern struct { | 3738 | pub const io_uring_cqe = extern struct { |
| ... | @@ -3683,7 +3755,13 @@ pub const io_uring_cqe = extern struct { | ... | @@ -3683,7 +3755,13 @@ pub const io_uring_cqe = extern struct { |
| 3683 | | 3755 | |
| 3684 | /// If set, the upper 16 bits are the buffer ID | 3756 | /// If set, the upper 16 bits are the buffer ID |
| 3685 | pub const IORING_CQE_F_BUFFER = 1 << 0; | 3757 | pub const IORING_CQE_F_BUFFER = 1 << 0; |
| | 3758 | /// If set, parent SQE will generate more CQE entries. |
| | 3759 | /// Avaiable since Linux 5.13. |
| | 3760 | pub const IORING_CQE_F_MORE = 1 << 1; |
| | 3761 | /// If set, more data to read after socket recv |
| | 3762 | pub const IORING_CQE_F_SOCK_NONEMPTY = 1 << 2; |
| 3686 | | 3763 | |
| | 3764 | /// Magic offsets for the application to mmap the data it needs |
| 3687 | pub const IORING_OFF_SQ_RING = 0; | 3765 | pub const IORING_OFF_SQ_RING = 0; |
| 3688 | pub const IORING_OFF_CQ_RING = 0x8000000; | 3766 | pub const IORING_OFF_CQ_RING = 0x8000000; |
| 3689 | pub const IORING_OFF_SQES = 0x10000000; | 3767 | pub const IORING_OFF_SQES = 0x10000000; |
| ... | @@ -3691,6 +3769,9 @@ pub const IORING_OFF_SQES = 0x10000000; | ... | @@ -3691,6 +3769,9 @@ pub const IORING_OFF_SQES = 0x10000000; |
| 3691 | // io_uring_enter flags | 3769 | // io_uring_enter flags |
| 3692 | pub const IORING_ENTER_GETEVENTS = 1 << 0; | 3770 | pub const IORING_ENTER_GETEVENTS = 1 << 0; |
| 3693 | pub const IORING_ENTER_SQ_WAKEUP = 1 << 1; | 3771 | pub const IORING_ENTER_SQ_WAKEUP = 1 << 1; |
| | 3772 | pub const IORING_ENTER_SQ_WAIT = 1 << 2; |
| | 3773 | pub const IORING_ENTER_EXT_ARG = 1 << 3; |
| | 3774 | pub const IORING_ENTER_REGISTERED_RING = 1 << 4; |
| 3694 | | 3775 | |
| 3695 | // io_uring_register opcodes and arguments | 3776 | // io_uring_register opcodes and arguments |
| 3696 | pub const IORING_REGISTER = enum(u8) { | 3777 | pub const IORING_REGISTER = enum(u8) { |
| ... | @@ -3708,6 +3789,33 @@ pub const IORING_REGISTER = enum(u8) { | ... | @@ -3708,6 +3789,33 @@ pub const IORING_REGISTER = enum(u8) { |
| 3708 | REGISTER_RESTRICTIONS, | 3789 | REGISTER_RESTRICTIONS, |
| 3709 | REGISTER_ENABLE_RINGS, | 3790 | REGISTER_ENABLE_RINGS, |
| 3710 | | 3791 | |
| | 3792 | // extended with tagging |
| | 3793 | IORING_REGISTER_FILES2, |
| | 3794 | IORING_REGISTER_FILES_UPDATE2, |
| | 3795 | IORING_REGISTER_BUFFERS2, |
| | 3796 | IORING_REGISTER_BUFFERS_UPDATE, |
| | 3797 | |
| | 3798 | // set/clear io-wq thread affinities |
| | 3799 | IORING_REGISTER_IOWQ_AFF, |
| | 3800 | IORING_UNREGISTER_IOWQ_AFF, |
| | 3801 | |
| | 3802 | // set/get max number of io-wq workers |
| | 3803 | IORING_REGISTER_IOWQ_MAX_WORKERS, |
| | 3804 | |
| | 3805 | // register/unregister io_uring fd with the ring |
| | 3806 | IORING_REGISTER_RING_FDS, |
| | 3807 | IORING_UNREGISTER_RING_FDS, |
| | 3808 | |
| | 3809 | // register ring based provide buffer group |
| | 3810 | IORING_REGISTER_PBUF_RING, |
| | 3811 | IORING_UNREGISTER_PBUF_RING, |
| | 3812 | |
| | 3813 | // sync cancelation API |
| | 3814 | IORING_REGISTER_SYNC_CANCEL, |
| | 3815 | |
| | 3816 | // register a range of fixed file slots for automatic slot allocation |
| | 3817 | IORING_REGISTER_FILE_ALLOC_RANGE, |
| | 3818 | |
| 3711 | _, | 3819 | _, |
| 3712 | }; | 3820 | }; |
| 3713 | | 3821 | |