14
14
//!
15
15
//! # References
16
16
//! - [Linux]
17
+ //! - [io_uring header]
17
18
//!
18
19
//! [Linux]: https://man.archlinux.org/man/io_uring.7.en
19
20
//! [io_uring]: https://en.wikipedia.org/wiki/Io_uring
21
+ //! [io_uring header]: https://github.com/torvalds/linux/blob/master/include/uapi/linux/io_uring.h
20
22
#![ allow( unsafe_code) ]
21
23
22
24
use crate :: fd:: { AsFd , BorrowedFd , OwnedFd , RawFd } ;
@@ -383,6 +385,18 @@ impl Default for IoringRestrictionOp {
383
385
}
384
386
}
385
387
388
+ /// `IORING_MSG_*` constants which represent commands for use with [`IoringOp::Msgring`], (`seq.addr`)
389
+ #[ derive( Debug , Clone , Copy , Eq , PartialEq , Hash ) ]
390
+ #[ repr( u64 ) ]
391
+ #[ non_exhaustive]
392
+ pub enum IoringMsgringCmds {
393
+ /// `IORING_MSG_DATA`
394
+ Data = sys:: IORING_MSG_DATA as _ ,
395
+
396
+ /// `IORING_MSG_SEND_FD`
397
+ SendFd = sys:: IORING_MSG_SEND_FD as _ ,
398
+ }
399
+
386
400
bitflags:: bitflags! {
387
401
/// `IORING_SETUP_*` flags for use with [`io_uring_params`].
388
402
#[ derive( Default ) ]
@@ -525,6 +539,33 @@ bitflags::bitflags! {
525
539
}
526
540
}
527
541
542
+ bitflags:: bitflags! {
543
+ /// `IORING_MSG_RING_*` flags for use with [`io_uring_sqe`].
544
+ #[ derive( Default ) ]
545
+ pub struct IoringMsgringFlags : u32 {
546
+ /// `IORING_MSG_RING_CQE_SKIP`
547
+ const CQE_SKIP = sys:: IORING_MSG_RING_CQE_SKIP ;
548
+ }
549
+ }
550
+
551
+ bitflags:: bitflags! {
552
+ /// `IORING_ASYNC_CANCEL_*` flags for use with [`io_uring_sqe`].
553
+ #[ derive( Default ) ]
554
+ pub struct IoringAsyncCancelFlags : u32 {
555
+ /// `IORING_ASYNC_CANCEL_ALL`
556
+ const ALL = sys:: IORING_ASYNC_CANCEL_ALL ;
557
+
558
+ /// `IORING_ASYNC_CANCEL_FD`
559
+ const FD = sys:: IORING_ASYNC_CANCEL_FD ;
560
+
561
+ /// `IORING_ASYNC_CANCEL_FD`
562
+ const ANY = sys:: IORING_ASYNC_CANCEL_ANY ;
563
+
564
+ /// `IORING_ASYNC_CANCEL_FD`
565
+ const FD_FIXED = sys:: IORING_ASYNC_CANCEL_FD_FIXED ;
566
+ }
567
+ }
568
+
528
569
bitflags:: bitflags! {
529
570
/// `IORING_FEAT_*` flags for use with [`io_uring_params`].
530
571
#[ derive( Default ) ]
@@ -633,7 +674,7 @@ bitflags::bitflags! {
633
674
bitflags:: bitflags! {
634
675
/// send/sendmsg & recv/recvmsg flags (`sqe.ioprio`)
635
676
#[ derive( Default ) ]
636
- pub struct IoringRecvSendFlags : u16 {
677
+ pub struct IoringRecvsendFlags : u16 {
637
678
/// `IORING_RECVSEND_POLL_FIRST`
638
679
const POLL_FIRST = sys:: IORING_RECVSEND_POLL_FIRST as _;
639
680
@@ -819,11 +860,11 @@ impl core::fmt::Debug for io_uring_user_data {
819
860
pub struct io_uring_sqe {
820
861
pub opcode : IoringOp ,
821
862
pub flags : IoringSqeFlags ,
822
- pub ioprio_or_flags : ioprio_or_flags_union ,
863
+ pub ioprio : ioprio_union ,
823
864
pub fd : RawFd ,
824
865
pub off_or_addr2 : off_or_addr2_union ,
825
866
pub addr_or_splice_off_in : addr_or_splice_off_in_union ,
826
- pub len : u32 ,
867
+ pub len : len_union ,
827
868
pub op_flags : op_flags_union ,
828
869
pub user_data : io_uring_user_data ,
829
870
pub buf : buf_union ,
@@ -835,12 +876,20 @@ pub struct io_uring_sqe {
835
876
#[ allow( missing_docs) ]
836
877
#[ repr( C ) ]
837
878
#[ derive( Copy , Clone ) ]
838
- pub union ioprio_or_flags_union {
839
- pub recvsend : IoringRecvSendFlags ,
840
- pub accept : IoringAcceptFlags ,
879
+ pub union ioprio_union {
880
+ pub recvsend_flags : IoringRecvsendFlags ,
881
+ pub accept_flags : IoringAcceptFlags ,
841
882
pub ioprio : u16 ,
842
883
}
843
884
885
+ #[ allow( missing_docs) ]
886
+ #[ repr( C ) ]
887
+ #[ derive( Copy , Clone ) ]
888
+ pub union len_union {
889
+ pub poll_flags : IoringPollFlags ,
890
+ pub len : u32 ,
891
+ }
892
+
844
893
#[ allow( missing_docs) ]
845
894
#[ repr( C ) ]
846
895
#[ derive( Copy , Clone ) ]
@@ -864,6 +913,7 @@ pub union off_or_addr2_union {
864
913
pub off : u64 ,
865
914
pub addr2 : io_uring_ptr ,
866
915
pub cmd_op : cmd_op_struct ,
916
+ pub user_data : io_uring_user_data ,
867
917
}
868
918
869
919
#[ allow( missing_docs) ]
@@ -880,6 +930,8 @@ pub struct cmd_op_struct {
880
930
pub union addr_or_splice_off_in_union {
881
931
pub addr : io_uring_ptr ,
882
932
pub splice_off_in : u64 ,
933
+ pub msgring_cmd : IoringMsgringCmds ,
934
+ pub user_data : io_uring_user_data ,
883
935
}
884
936
885
937
#[ allow( missing_docs) ]
@@ -899,14 +951,15 @@ pub union op_flags_union {
899
951
pub recv_flags : crate :: net:: RecvFlags ,
900
952
pub timeout_flags : IoringTimeoutFlags ,
901
953
pub accept_flags : crate :: net:: AcceptFlags ,
902
- pub cancel_flags : u32 ,
903
- pub open_flags : crate :: fs:: AtFlags ,
954
+ pub cancel_flags : IoringAsyncCancelFlags ,
955
+ pub open_flags : crate :: fs:: OFlags ,
904
956
pub statx_flags : crate :: fs:: AtFlags ,
905
957
pub fadvise_advice : crate :: fs:: Advice ,
906
958
pub splice_flags : SpliceFlags ,
907
959
pub rename_flags : crate :: fs:: RenameFlags ,
908
960
pub unlink_flags : crate :: fs:: AtFlags ,
909
961
pub hardlink_flags : crate :: fs:: AtFlags ,
962
+ pub msg_ring_flags : IoringMsgringFlags ,
910
963
}
911
964
912
965
#[ allow( missing_docs) ]
@@ -1128,7 +1181,15 @@ pub struct io_uring_buf {
1128
1181
pub resv : u16 ,
1129
1182
}
1130
1183
1131
- impl Default for ioprio_or_flags_union {
1184
+ impl Default for ioprio_union {
1185
+ #[ inline]
1186
+ fn default ( ) -> Self {
1187
+ // Safety: All of Linux's io_uring structs may be zero-initialized.
1188
+ unsafe { :: core:: mem:: zeroed :: < Self > ( ) }
1189
+ }
1190
+ }
1191
+
1192
+ impl Default for len_union {
1132
1193
#[ inline]
1133
1194
fn default ( ) -> Self {
1134
1195
// Safety: All of Linux's io_uring structs may be zero-initialized.
@@ -1275,7 +1336,7 @@ fn io_uring_layouts() {
1275
1336
check_type ! ( io_uring_sqe) ;
1276
1337
check_struct_field ! ( io_uring_sqe, opcode) ;
1277
1338
check_struct_field ! ( io_uring_sqe, flags) ;
1278
- check_struct_renamed_field ! ( io_uring_sqe, ioprio_or_flags , ioprio) ;
1339
+ check_struct_field ! ( io_uring_sqe, ioprio) ;
1279
1340
check_struct_field ! ( io_uring_sqe, fd) ;
1280
1341
check_struct_renamed_field ! ( io_uring_sqe, off_or_addr2, __bindgen_anon_1) ;
1281
1342
check_struct_renamed_field ! ( io_uring_sqe, addr_or_splice_off_in, __bindgen_anon_2) ;
0 commit comments