Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 32 additions & 2 deletions lib/std/os/linux.zig
Original file line number Diff line number Diff line change
Expand Up @@ -6587,7 +6587,7 @@ pub const IORING_REGISTER = enum(u32) {

// register/unregister io_uring fd with the ring
REGISTER_RING_FDS,
NREGISTER_RING_FDS,
UNREGISTER_RING_FDS,

// register ring based provide buffer group
REGISTER_PBUF_RING,
Expand All @@ -6599,8 +6599,31 @@ pub const IORING_REGISTER = enum(u32) {
// register a range of fixed file slots for automatic slot allocation
REGISTER_FILE_ALLOC_RANGE,

// return status information for a buffer group
REGISTER_PBUF_STATUS,

// set/clear busy poll settings
REGISTER_NAPI,
UNREGISTER_NAPI,

REGISTER_CLOCK,

// clone registered buffers from source ring to current ring
REGISTER_CLONE_BUFFERS,

// send MSG_RING without having a ring
REGISTER_SEND_MSG_RING,

// register a netdev hw rx queue for zerocopy
REGISTER_ZCRX_IFQ,

// resize CQ ring
REGISTER_RESIZE_RINGS,

REGISTER_MEM_REGION,

// flag added to the opcode to use a registered ring fd
IORING_REGISTER_USE_REGISTERED_RING = 1 << 31,
REGISTER_USE_REGISTERED_RING = 1 << 31,

_,
};
Expand Down Expand Up @@ -6657,6 +6680,13 @@ pub const io_uring_notification_register = extern struct {
resv3: u64,
};

pub const io_uring_napi = extern struct {
busy_poll_to: u32,
prefer_busy_poll: u8,
_pad: [3]u8,
resv: u64,
};

/// Skip updating fd indexes set to this value in the fd table */
pub const IORING_REGISTER_FILES_SKIP = -2;

Expand Down
12 changes: 12 additions & 0 deletions lib/std/os/linux/IoUring.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1270,6 +1270,18 @@ pub fn unregister_eventfd(self: *IoUring) !void {
try handle_registration_result(res);
}

pub fn register_napi(self: *IoUring, napi: *linux.io_uring_napi) !void {
assert(self.fd >= 0);
const res = linux.io_uring_register(self.fd, .REGISTER_NAPI, napi, 1);
try handle_registration_result(res);
}

pub fn unregister_napi(self: *IoUring, napi: *linux.io_uring_napi) !void {
assert(self.fd >= 0);
const res = linux.io_uring_register(self.fd, .UNREGISTER_NAPI, napi, 1);
try handle_registration_result(res);
}

/// Registers an array of buffers for use with `read_fixed` and `write_fixed`.
pub fn register_buffers(self: *IoUring, buffers: []const posix.iovec) !void {
assert(self.fd >= 0);
Expand Down
Loading