1 /* SPDX-License-Identifier: (GPL-2.0 WITH Linux-syscall-note) OR MIT */ 2 /* 3 * Header file for the io_uring zerocopy receive (zcrx) interface. 4 * 5 * Copyright (C) 2026 Pavel Begunkov 6 * Copyright (C) 2026 David Wei 7 * Copyright (C) Meta Platforms, Inc. 8 */ 9 #ifndef LINUX_IO_ZCRX_H 10 #define LINUX_IO_ZCRX_H 11 12 #include <linux/types.h> 13 14 /* Zero copy receive refill queue entry */ 15 struct io_uring_zcrx_rqe { 16 __u64 off; 17 __u32 len; 18 __u32 __pad; 19 }; 20 21 struct io_uring_zcrx_cqe { 22 __u64 off; 23 __u64 __pad; 24 }; 25 26 /* The bit from which area id is encoded into offsets */ 27 #define IORING_ZCRX_AREA_SHIFT 48 28 #define IORING_ZCRX_AREA_MASK (~(((__u64)1 << IORING_ZCRX_AREA_SHIFT) - 1)) 29 30 struct io_uring_zcrx_offsets { 31 __u32 head; 32 __u32 tail; 33 __u32 rqes; 34 __u32 __resv2; 35 __u64 __resv[2]; 36 }; 37 38 enum io_uring_zcrx_area_flags { 39 IORING_ZCRX_AREA_DMABUF = 1, 40 }; 41 42 struct io_uring_zcrx_area_reg { 43 __u64 addr; 44 __u64 len; 45 __u64 rq_area_token; 46 __u32 flags; 47 __u32 dmabuf_fd; 48 __u64 __resv2[2]; 49 }; 50 51 enum zcrx_reg_flags { 52 ZCRX_REG_IMPORT = 1, 53 54 /* 55 * Register a zcrx instance without a net device. All data will be 56 * copied. The refill queue entries might not be automatically 57 * consumed and need to be flushed, see ZCRX_CTRL_FLUSH_RQ. 58 */ 59 ZCRX_REG_NODEV = 2, 60 }; 61 62 enum zcrx_features { 63 /* 64 * The user can ask for the desired rx page size by passing the 65 * value in struct io_uring_zcrx_ifq_reg::rx_buf_len. 66 */ 67 ZCRX_FEATURE_RX_PAGE_SIZE = 1 << 0, 68 }; 69 70 /* 71 * Argument for IORING_REGISTER_ZCRX_IFQ 72 */ 73 struct io_uring_zcrx_ifq_reg { 74 __u32 if_idx; 75 __u32 if_rxq; 76 __u32 rq_entries; 77 __u32 flags; 78 79 __u64 area_ptr; /* pointer to struct io_uring_zcrx_area_reg */ 80 __u64 region_ptr; /* struct io_uring_region_desc * */ 81 82 struct io_uring_zcrx_offsets offsets; 83 __u32 zcrx_id; 84 __u32 rx_buf_len; 85 __u64 __resv[3]; 86 }; 87 88 enum zcrx_ctrl_op { 89 ZCRX_CTRL_FLUSH_RQ, 90 ZCRX_CTRL_EXPORT, 91 92 __ZCRX_CTRL_LAST, 93 }; 94 95 struct zcrx_ctrl_flush_rq { 96 __u64 __resv[6]; 97 }; 98 99 struct zcrx_ctrl_export { 100 __u32 zcrx_fd; 101 __u32 __resv1[11]; 102 }; 103 104 struct zcrx_ctrl { 105 __u32 zcrx_id; 106 __u32 op; /* see enum zcrx_ctrl_op */ 107 __u64 __resv[2]; 108 109 union { 110 struct zcrx_ctrl_export zc_export; 111 struct zcrx_ctrl_flush_rq zc_flush; 112 }; 113 }; 114 115 #endif /* LINUX_IO_ZCRX_H */ 116