Skip to content

Commit

Permalink
Merge branch 'zcrx/next' of https://github.com/isilence/liburing into…
Browse files Browse the repository at this point in the history
… zcrx

* 'zcrx/next' of https://github.com/isilence/liburing:
  zcrx: add unit test
  zcrx: add zero copy rx support
  zcrx: add sh script for setting up flow steering

Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
axboe committed Oct 21, 2024
2 parents 01b9255 + 1ff3dfc commit b4cc83f
Show file tree
Hide file tree
Showing 6 changed files with 1,004 additions and 2 deletions.
10 changes: 10 additions & 0 deletions examples/zcrx_flow.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

ethtool -N eth0 delete 0
ethtool -X eth0 context 1 delete

ethtool -L eth0 combined 64
ethtool -X eth0 equal 12

ethtool -X eth0 context new start 12 equal 1
ethtool -N eth0 flow-type tcp6 dst-port 9999 context 1
12 changes: 12 additions & 0 deletions src/include/liburing.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,16 @@ struct io_uring {
unsigned pad2;
};

struct io_uring_zcrx_rq {
__u32 *khead;
__u32 *ktail;
__u32 rq_tail;
unsigned ring_entries;

struct io_uring_zcrx_rqe *rqes;
void *ring_ptr;
};

/*
* Library interface
*/
Expand Down Expand Up @@ -256,6 +266,8 @@ int io_uring_register_file_alloc_range(struct io_uring *ring,

int io_uring_register_napi(struct io_uring *ring, struct io_uring_napi *napi);
int io_uring_unregister_napi(struct io_uring *ring, struct io_uring_napi *napi);
int io_uring_register_ifq(struct io_uring *ring,
struct io_uring_zcrx_ifq_reg *reg);

int io_uring_register_clock(struct io_uring *ring,
struct io_uring_clock_register *arg);
Expand Down
61 changes: 59 additions & 2 deletions src/include/liburing/io_uring.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ struct io_uring_sqe {
union {
__s32 splice_fd_in;
__u32 file_index;
__u32 zcrx_ifq_idx;
__u32 optlen;
struct {
__u16 addr_len;
Expand Down Expand Up @@ -259,6 +260,7 @@ enum io_uring_op {
IORING_OP_FTRUNCATE,
IORING_OP_BIND,
IORING_OP_LISTEN,
IORING_OP_RECV_ZC,

/* this goes last, obviously */
IORING_OP_LAST,
Expand Down Expand Up @@ -361,7 +363,7 @@ enum io_uring_op {
* result will be the number of buffers send, with
* the starting buffer ID in cqe->flags as per
* usual for provided buffer usage. The buffers
* will be contiguous from the starting buffer ID.
* will be contigious from the starting buffer ID.
*/
#define IORING_RECVSEND_POLL_FIRST (1U << 0)
#define IORING_RECV_MULTISHOT (1U << 1)
Expand Down Expand Up @@ -421,7 +423,7 @@ enum io_uring_msg_ring_flags {
* IO completion data structure (Completion Queue Entry)
*/
struct io_uring_cqe {
__u64 user_data; /* sqe->user_data submission passed back */
__u64 user_data; /* sqe->user_data value passed back */
__s32 res; /* result code for this event */
__u32 flags;

Expand Down Expand Up @@ -467,6 +469,8 @@ struct io_uring_cqe {
#define IORING_OFF_PBUF_RING 0x80000000ULL
#define IORING_OFF_PBUF_SHIFT 16
#define IORING_OFF_MMAP_MASK 0xf8000000ULL
#define IORING_OFF_RQ_RING 0x20000000ULL
#define IORING_OFF_RQ_SHIFT 16

/*
* Filled with the offset for mmap(2)
Expand Down Expand Up @@ -612,6 +616,12 @@ enum io_uring_register_op {
/* clone registered buffers from source ring to current ring */
IORING_REGISTER_CLONE_BUFFERS = 30,

/* send MSG_RING without having a ring */
IORING_REGISTER_SEND_MSG_RING = 31,

/* register a netdev hw rx queue for zerocopy */
IORING_REGISTER_ZCRX_IFQ = 32,

/* this goes last */
IORING_REGISTER_LAST,

Expand Down Expand Up @@ -842,6 +852,53 @@ enum io_uring_socket_op {
SOCKET_URING_OP_SETSOCKOPT,
};

/* Zero copy receive refill queue entry */
struct io_uring_zcrx_rqe {
__u64 off;
__u32 len;
__u32 __pad;
};

struct io_uring_zcrx_cqe {
__u64 off;
__u64 __pad;
};

/* The bit from which area id is encoded into offsets */
#define IORING_ZCRX_AREA_SHIFT 48
#define IORING_ZCRX_AREA_MASK (~(((__u64)1 << IORING_ZCRX_AREA_SHIFT) - 1))

struct io_uring_zcrx_offsets {
__u32 head;
__u32 tail;
__u32 rqes;
__u32 mmap_sz;
__u64 __resv[2];
};

struct io_uring_zcrx_area_reg {
__u64 addr;
__u64 len;
__u64 rq_area_token;
__u32 flags;
__u32 __resv1;
__u64 __resv2[2];
};

/*
* Argument for IORING_REGISTER_ZCRX_IFQ
*/
struct io_uring_zcrx_ifq_reg {
__u32 if_idx;
__u32 if_rxq;
__u32 rq_entries;
__u32 flags;

__u64 area_ptr; /* pointer to struct io_uring_zcrx_area_reg */
struct io_uring_zcrx_offsets offsets;
__u64 __resv[3];
};

#ifdef __cplusplus
}
#endif
Expand Down
6 changes: 6 additions & 0 deletions src/register.c
Original file line number Diff line number Diff line change
Expand Up @@ -408,3 +408,9 @@ int io_uring_clone_buffers(struct io_uring *dst, struct io_uring *src)

return do_register(dst, IORING_REGISTER_CLONE_BUFFERS, &buf, 1);
}

int io_uring_register_ifq(struct io_uring *ring,
struct io_uring_zcrx_ifq_reg *reg)
{
return do_register(ring, IORING_REGISTER_ZCRX_IFQ, reg, 1);
}
1 change: 1 addition & 0 deletions test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ test_srcs := \
wakeup-hang.c \
wq-aff.c \
xattr.c \
zcrx.c \
# EOL

# Please keep this list sorted alphabetically.
Expand Down
Loading

0 comments on commit b4cc83f

Please sign in to comment.