liburing: add an example for a TCP/UDP ZC RX server.
RFC 1/1 liburing: add an example for a TCP/UDP ZC RX server.
This is a WIP sample application that demonstrates the use of the API in the pevious RFC series. This is for demonstration purposes only!
copy io_uring-udp.c and make it handle TCP.
Wire up a simple example of the recvzc opcode.
Signed-off-by Jonathan Lemon <[email protected]>
--- examples/Makefile | 3 +- examples/io_uring-net.c | 835 ++++++++++++++++++++++++++++++++++++++++ src/include/liburing.h | 3 + src/register.c | 29 ++ 4 files changed, 869 insertions(+), 1 deletion(-) create mode 100644 examples/io_uring-net.c
examples/Makefile +2 -1
@@ -16,7 +16,8 @@ example_srcs := \ io_uring-udp.c \ link-cp.c \ poll-bench.c \ - send-zerocopy.c + send-zerocopy.c \ + io_uring-net.c all_targets :=
examples/io_uring-net.c new file +835 -0
835 lines not on this page · raw message
src/include/liburing.h +3 -0
@@ -235,6 +235,9 @@ int io_uring_register_sync_cancel(struct io_uring *ring,int io_uring_register_file_alloc_range (struct io_uring *ring,unsigned off,unsigned len); +int io_uring_register_ifq (struct io_uring *ring,int ifindex, +__u16 *queue_id,__u16 *ifq_id,__u16 bgid); +int io_uring_get_events (struct io_uring *ring);int io_uring_submit_and_get_events (struct io_uring *ring);
src/register.c +29 -0
@@ -364,3 +364,32 @@ int io_uring_register_file_alloc_range(struct io_uring *ring,IORING_REGISTER_FILE_ALLOC_RANGE , &range, 0); } + +#if 0 /* XXX temp development hack */ +#define IORING_REGISTER_IFQ 26 + +struct io_uring_ifq_req { +__u32 ifindex; +__u16 queue_id; +__u16 ifq_id; +__u16 fill_bgid; +__u16 __pad[3 ]; +}; +#endif + +int io_uring_register_ifq (struct io_uring *ring,int ifindex, +__u16 *queue_id,__u16 *ifq_id,__u16 bgid) +{ +struct io_uring_ifq_req reg = { + .ifindex = ifindex, + .queue_id = *queue_id, + .fill_bgid = bgid, + }; +int ret; + + ret =__sys_io_uring_register (ring->ring_fd,IORING_REGISTER_IFQ , + ®,1 ); + *queue_id = reg.queue_id; + *ifq_id = reg.ifq_id; +return ret; +}
Signature · 1 line
2.30.2