Commit 99c4890559

Özgür Akkurt <oezgurmakkurt@gmail.com>
2025-08-16 09:18:49
implement registering NAPI on IoUring (#24850)
1 parent 9854771
Changed files (2)
lib
lib/std/os/linux/IoUring.zig
@@ -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);
lib/std/os/linux.zig
@@ -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,
@@ -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,
 
     _,
 };
@@ -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;