All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH liburing 0/5] zcrx example and other changes
@ 2025-04-16  9:01 Pavel Begunkov
  2025-04-16  9:01 ` [PATCH liburing 1/5] Update io_uring.h for zcrx Pavel Begunkov
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Pavel Begunkov @ 2025-04-16  9:01 UTC (permalink / raw)
  To: io-uring; +Cc: asml.silence, David Wei

We need a simple example for zcrx to show case how the api works
and how to use features. Patch 5 is a brushed up version of the
zcrx selftest.

Apart from that update headers and use the kernel return zcrx id.

Pavel Begunkov (5):
  Update io_uring.h for zcrx
  tests/zcrx: rename a test
  tests/zcrx: use returned right zcrx id
  examples: add extra helpers
  examples: add a zcrx example

 examples/Makefile               |   1 +
 examples/helpers.c              |  15 ++
 examples/helpers.h              |   6 +
 examples/zcrx.c                 | 335 ++++++++++++++++++++++++++++++++
 src/include/liburing/io_uring.h |   4 +-
 test/zcrx.c                     |  21 +-
 6 files changed, 372 insertions(+), 10 deletions(-)
 create mode 100644 examples/zcrx.c

-- 
2.48.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH liburing 1/5] Update io_uring.h for zcrx
  2025-04-16  9:01 [PATCH liburing 0/5] zcrx example and other changes Pavel Begunkov
@ 2025-04-16  9:01 ` Pavel Begunkov
  2025-04-16  9:01 ` [PATCH liburing 2/5] tests/zcrx: rename a test Pavel Begunkov
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Pavel Begunkov @ 2025-04-16  9:01 UTC (permalink / raw)
  To: io-uring; +Cc: asml.silence, David Wei

Pull in an updated version if struct io_uring_zcrx_ifq_reg

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
 src/include/liburing/io_uring.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/include/liburing/io_uring.h b/src/include/liburing/io_uring.h
index cb9f82fa..572ff59f 100644
--- a/src/include/liburing/io_uring.h
+++ b/src/include/liburing/io_uring.h
@@ -977,7 +977,9 @@ struct io_uring_zcrx_ifq_reg {
 	__u64	region_ptr; /* struct io_uring_region_desc * */
 
 	struct io_uring_zcrx_offsets offsets;
-	__u64	__resv[4];
+	__u32	zcrx_id;
+	__u32	__resv2;
+	__u64	__resv[3];
 };
 
 #ifdef __cplusplus
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH liburing 2/5] tests/zcrx: rename a test
  2025-04-16  9:01 [PATCH liburing 0/5] zcrx example and other changes Pavel Begunkov
  2025-04-16  9:01 ` [PATCH liburing 1/5] Update io_uring.h for zcrx Pavel Begunkov
@ 2025-04-16  9:01 ` Pavel Begunkov
  2025-04-16  9:01 ` [PATCH liburing 3/5] tests/zcrx: use returned right zcrx id Pavel Begunkov
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Pavel Begunkov @ 2025-04-16  9:01 UTC (permalink / raw)
  To: io-uring; +Cc: asml.silence, David Wei

There should've been some mishap for a test to be called
"test_invalid_invalid_request", rename it.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
 test/zcrx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/test/zcrx.c b/test/zcrx.c
index 95230c65..0fa8f2bd 100644
--- a/test/zcrx.c
+++ b/test/zcrx.c
@@ -401,7 +401,7 @@ static struct io_uring_cqe *submit_and_wait_one(struct io_uring *ring)
 	return cqe;
 }
 
-static int test_invalid_invalid_request(void *area)
+static int test_invalid_zcrx_request(void *area)
 {
 	struct io_uring_cqe *cqe;
 	struct io_uring_sqe *sqe;
@@ -901,7 +901,7 @@ int main(int argc, char *argv[])
 		return ret;
 	}
 
-	ret = test_invalid_invalid_request(area);
+	ret = test_invalid_zcrx_request(area);
 	if (ret) {
 		fprintf(stderr, "test_invalid_ifq_collision failed\n");
 		return ret;
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH liburing 3/5] tests/zcrx: use returned right zcrx id
  2025-04-16  9:01 [PATCH liburing 0/5] zcrx example and other changes Pavel Begunkov
  2025-04-16  9:01 ` [PATCH liburing 1/5] Update io_uring.h for zcrx Pavel Begunkov
  2025-04-16  9:01 ` [PATCH liburing 2/5] tests/zcrx: rename a test Pavel Begunkov
@ 2025-04-16  9:01 ` Pavel Begunkov
  2025-04-16  9:01 ` [PATCH liburing 4/5] examples: add extra helpers Pavel Begunkov
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Pavel Begunkov @ 2025-04-16  9:01 UTC (permalink / raw)
  To: io-uring; +Cc: asml.silence, David Wei

Now we return the zcrx id back to the user, use it.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
 test/zcrx.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/test/zcrx.c b/test/zcrx.c
index 0fa8f2bd..b60462a6 100644
--- a/test/zcrx.c
+++ b/test/zcrx.c
@@ -344,7 +344,7 @@ static int test_area_access(void)
 	return T_EXIT_PASS;
 }
 
-static int create_ring_with_ifq(struct io_uring *ring, void *area)
+static int create_ring_with_ifq(struct io_uring *ring, void *area, __u32 *id)
 {
 	struct io_uring_zcrx_area_reg area_reg = {
 		.addr = (__u64)(unsigned long)area,
@@ -371,6 +371,7 @@ static int create_ring_with_ifq(struct io_uring *ring, void *area)
 		fprintf(stderr, "ifq register failed %d\n", ret);
 		return T_EXIT_FAIL;
 	}
+	*id = reg.zcrx_id;
 	return 0;
 }
 
@@ -406,9 +407,10 @@ static int test_invalid_zcrx_request(void *area)
 	struct io_uring_cqe *cqe;
 	struct io_uring_sqe *sqe;
 	struct io_uring ring;
+	__u32 zcrx_id;
 	int ret, fds[2];
 
-	ret = create_ring_with_ifq(&ring, area);
+	ret = create_ring_with_ifq(&ring, area, &zcrx_id);
 	if (ret != T_SETUP_OK) {
 		fprintf(stderr, "ifq-ring create failed: %d\n", ret);
 		return T_EXIT_FAIL;
@@ -422,7 +424,7 @@ static int test_invalid_zcrx_request(void *area)
 
 	/* invalid file */
 	sqe = io_uring_get_sqe(&ring);
-	test_io_uring_prep_zcrx(sqe, ring.ring_fd, 0);
+	test_io_uring_prep_zcrx(sqe, ring.ring_fd, zcrx_id);
 
 	cqe = submit_and_wait_one(&ring);
 	if (!cqe) {
@@ -441,7 +443,7 @@ static int test_invalid_zcrx_request(void *area)
 
 	/* invalid ifq idx */
 	sqe = io_uring_get_sqe(&ring);
-	test_io_uring_prep_zcrx(sqe, fds[0], 1);
+	test_io_uring_prep_zcrx(sqe, fds[0], zcrx_id + 1);
 
 	cqe = submit_and_wait_one(&ring);
 	if (!cqe) {
@@ -478,7 +480,8 @@ struct recv_data {
 	struct io_uring_zcrx_rq rq_ring;
 };
 
-static int recv_prep(struct io_uring *ring, struct recv_data *rd, int *sock)
+static int recv_prep(struct io_uring *ring, struct recv_data *rd, int *sock,
+		     __u32 zcrx_id)
 {
 	struct sockaddr_in saddr;
 	struct io_uring_sqe *sqe;
@@ -526,7 +529,7 @@ static int recv_prep(struct io_uring *ring, struct recv_data *rd, int *sock)
 
 	sqe = io_uring_get_sqe(ring);
 	io_uring_prep_rw(IORING_OP_RECV_ZC, sqe, use_fd, NULL, 0, 0);
-	sqe->zcrx_ifq_idx = 0;
+	sqe->zcrx_ifq_idx = zcrx_id;
 	sqe->ioprio |= IORING_RECV_MULTISHOT;
 	sqe->user_data = 2;
 
@@ -693,7 +696,7 @@ static void *recv_fn(void *data)
 	rd->rq_ring.rq_tail = 0;
 	rd->rq_ring.ring_entries = reg.rq_entries;
 
-	ret = recv_prep(&ring, rd, &sock);
+	ret = recv_prep(&ring, rd, &sock, reg.zcrx_id);
 	if (ret) {
 		fprintf(stderr, "recv_prep failed: %d\n", ret);
 		goto err;
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH liburing 4/5] examples: add extra helpers
  2025-04-16  9:01 [PATCH liburing 0/5] zcrx example and other changes Pavel Begunkov
                   ` (2 preceding siblings ...)
  2025-04-16  9:01 ` [PATCH liburing 3/5] tests/zcrx: use returned right zcrx id Pavel Begunkov
@ 2025-04-16  9:01 ` Pavel Begunkov
  2025-04-16  9:01 ` [PATCH liburing 5/5] examples: add a zcrx example Pavel Begunkov
  2025-04-16 14:48 ` [PATCH liburing 0/5] zcrx example and other changes Jens Axboe
  5 siblings, 0 replies; 7+ messages in thread
From: Pavel Begunkov @ 2025-04-16  9:01 UTC (permalink / raw)
  To: io-uring; +Cc: asml.silence, David Wei

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
 examples/helpers.c | 15 +++++++++++++++
 examples/helpers.h |  6 ++++++
 2 files changed, 21 insertions(+)

diff --git a/examples/helpers.c b/examples/helpers.c
index 59b31ecb..0c9e0160 100644
--- a/examples/helpers.c
+++ b/examples/helpers.c
@@ -9,6 +9,7 @@
 #include <sys/socket.h>
 #include <sys/time.h>
 #include <unistd.h>
+#include <stdarg.h>
 
 #include "helpers.h"
 
@@ -70,3 +71,17 @@ void *aligned_alloc(size_t alignment, size_t size)
 
 	return ret;
 }
+
+void t_error(int status, int errnum, const char *format, ...)
+{
+	va_list args;
+	va_start(args, format);
+
+	vfprintf(stderr, format, args);
+	if (errnum)
+		fprintf(stderr, ": %s", strerror(errnum));
+
+	fprintf(stderr, "\n");
+	va_end(args);
+	exit(status);
+}
diff --git a/examples/helpers.h b/examples/helpers.h
index d73ee4a5..c8bf7332 100644
--- a/examples/helpers.h
+++ b/examples/helpers.h
@@ -2,6 +2,10 @@
 #ifndef LIBURING_EX_HELPERS_H
 #define LIBURING_EX_HELPERS_H
 
+#include <stddef.h>
+
+#define T_ALIGN_UP(v, align) (((v) + (align) - 1) & ~((align) - 1))
+
 int setup_listening_socket(int port, int ipv6);
 
 /*
@@ -11,4 +15,6 @@ int setup_listening_socket(int port, int ipv6);
  */
 void *aligned_alloc(size_t alignment, size_t size);
 
+void t_error(int status, int errnum, const char *format, ...);
+
 #endif
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH liburing 5/5] examples: add a zcrx example
  2025-04-16  9:01 [PATCH liburing 0/5] zcrx example and other changes Pavel Begunkov
                   ` (3 preceding siblings ...)
  2025-04-16  9:01 ` [PATCH liburing 4/5] examples: add extra helpers Pavel Begunkov
@ 2025-04-16  9:01 ` Pavel Begunkov
  2025-04-16 14:48 ` [PATCH liburing 0/5] zcrx example and other changes Jens Axboe
  5 siblings, 0 replies; 7+ messages in thread
From: Pavel Begunkov @ 2025-04-16  9:01 UTC (permalink / raw)
  To: io-uring; +Cc: asml.silence, David Wei

Copy-pasted from selftests/.../iou_zcrx.c by David and brushed up on
top.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
 examples/Makefile |   1 +
 examples/zcrx.c   | 335 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 336 insertions(+)
 create mode 100644 examples/zcrx.c

diff --git a/examples/Makefile b/examples/Makefile
index 7b740ca9..47bdfbf3 100644
--- a/examples/Makefile
+++ b/examples/Makefile
@@ -32,6 +32,7 @@ example_srcs := \
 	send-zerocopy.c \
 	rsrc-update-bench.c \
 	proxy.c \
+	zcrx.c \
 	kdigest.c
 
 all_targets :=
diff --git a/examples/zcrx.c b/examples/zcrx.c
new file mode 100644
index 00000000..8393cfe3
--- /dev/null
+++ b/examples/zcrx.c
@@ -0,0 +1,335 @@
+// SPDX-License-Identifier: GPL-2.0
+#include <assert.h>
+#include <errno.h>
+#include <error.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <stdarg.h>
+
+#include <arpa/inet.h>
+#include <linux/errqueue.h>
+#include <linux/if_packet.h>
+#include <linux/ipv6.h>
+#include <linux/socket.h>
+#include <linux/sockios.h>
+#include <net/ethernet.h>
+#include <net/if.h>
+#include <netinet/in.h>
+#include <netinet/ip.h>
+#include <netinet/ip6.h>
+#include <netinet/tcp.h>
+#include <netinet/udp.h>
+#include <sys/epoll.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <sys/resource.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/un.h>
+#include <sys/wait.h>
+
+#include "liburing.h"
+#include "helpers.h"
+
+#define PAGE_SIZE (4096)
+#define AREA_SIZE (8192 * PAGE_SIZE)
+#define SEND_SIZE (512 * 4096)
+
+static int cfg_port = 8000;
+static const char *cfg_ifname;
+static int cfg_queue_id = -1;
+static bool cfg_oneshot;
+static int cfg_oneshot_recvs;
+static bool cfg_verify_data = false;
+static struct sockaddr_in6 cfg_addr;
+
+static void *area_ptr;
+static void *ring_ptr;
+static size_t ring_size;
+static struct io_uring_zcrx_rq rq_ring;
+static unsigned long area_token;
+static int connfd;
+static bool stop;
+static size_t received;
+static __u32 zcrx_id;
+
+static inline size_t get_refill_ring_size(unsigned int rq_entries)
+{
+	ring_size = rq_entries * sizeof(struct io_uring_zcrx_rqe);
+	/* add space for the header (head/tail/etc.) */
+	ring_size += PAGE_SIZE;
+	return T_ALIGN_UP(ring_size, 4096);
+}
+
+static void setup_zcrx(struct io_uring *ring)
+{
+	unsigned int ifindex;
+	unsigned int rq_entries = 4096;
+	int ret;
+
+	ifindex = if_nametoindex(cfg_ifname);
+	if (!ifindex)
+		t_error(1, 0, "bad interface name: %s", cfg_ifname);
+
+	area_ptr = mmap(NULL,
+			AREA_SIZE,
+			PROT_READ | PROT_WRITE,
+			MAP_ANONYMOUS | MAP_PRIVATE,
+			0,
+			0);
+	if (area_ptr == MAP_FAILED)
+		t_error(1, 0, "mmap(): zero copy area");
+
+	ring_size = get_refill_ring_size(rq_entries);
+	ring_ptr = mmap(NULL,
+			ring_size,
+			PROT_READ | PROT_WRITE,
+			MAP_ANONYMOUS | MAP_PRIVATE,
+			0,
+			0);
+	if (ring_ptr == MAP_FAILED)
+		t_error(1, 0, "mmap(): refill ring");
+
+	struct io_uring_region_desc region_reg = {
+		.size = ring_size,
+		.user_addr = (__u64)(unsigned long)ring_ptr,
+		.flags = IORING_MEM_REGION_TYPE_USER,
+	};
+
+	struct io_uring_zcrx_area_reg area_reg = {
+		.addr = (__u64)(unsigned long)area_ptr,
+		.len = AREA_SIZE,
+		.flags = 0,
+	};
+
+	struct io_uring_zcrx_ifq_reg reg = {
+		.if_idx = ifindex,
+		.if_rxq = cfg_queue_id,
+		.rq_entries = rq_entries,
+		.area_ptr = (__u64)(unsigned long)&area_reg,
+		.region_ptr = (__u64)(unsigned long)&region_reg,
+	};
+
+	ret = io_uring_register_ifq(ring, &reg);
+	if (ret)
+		t_error(1, 0, "io_uring_register_ifq(): %d", ret);
+
+	rq_ring.khead = (unsigned int *)((char *)ring_ptr + reg.offsets.head);
+	rq_ring.ktail = (unsigned int *)((char *)ring_ptr + reg.offsets.tail);
+	rq_ring.rqes = (struct io_uring_zcrx_rqe *)((char *)ring_ptr + reg.offsets.rqes);
+	rq_ring.rq_tail = 0;
+	rq_ring.ring_entries = reg.rq_entries;
+
+	zcrx_id = reg.zcrx_id;
+	area_token = area_reg.rq_area_token;
+}
+
+static void add_accept(struct io_uring *ring, int sockfd)
+{
+	struct io_uring_sqe *sqe = io_uring_get_sqe(ring);
+
+	io_uring_prep_accept(sqe, sockfd, NULL, NULL, 0);
+	sqe->user_data = 1;
+}
+
+static void add_recvzc(struct io_uring *ring, int sockfd)
+{
+	struct io_uring_sqe *sqe = io_uring_get_sqe(ring);
+
+	io_uring_prep_rw(IORING_OP_RECV_ZC, sqe, sockfd, NULL, 0, 0);
+	sqe->ioprio |= IORING_RECV_MULTISHOT;
+	sqe->zcrx_ifq_idx = zcrx_id;
+	sqe->user_data = 2;
+}
+
+static void add_recvzc_oneshot(struct io_uring *ring, int sockfd, size_t len)
+{
+	struct io_uring_sqe *sqe = io_uring_get_sqe(ring);
+
+	io_uring_prep_rw(IORING_OP_RECV_ZC, sqe, sockfd, NULL, len, 0);
+	sqe->ioprio |= IORING_RECV_MULTISHOT;
+	sqe->zcrx_ifq_idx = zcrx_id;
+	sqe->user_data = 2;
+}
+
+static void process_accept(struct io_uring *ring, struct io_uring_cqe *cqe)
+{
+	if (cqe->res < 0)
+		t_error(1, 0, "accept()");
+	if (connfd)
+		t_error(1, 0, "Unexpected second connection");
+
+	connfd = cqe->res;
+	if (cfg_oneshot)
+		add_recvzc_oneshot(ring, connfd, PAGE_SIZE);
+	else
+		add_recvzc(ring, connfd);
+}
+
+static void verify_data(char *data, size_t size, unsigned long seq)
+{
+	int i;
+
+	if (!cfg_verify_data)
+		return;
+
+	for (i = 0; i < size; i++) {
+		char expected = 'a' + (seq + i) % 26;
+
+		if (data[i] != expected)
+			t_error(1, 0, "payload mismatch at %i", i);
+	}
+}
+
+static void process_recvzc(struct io_uring *ring, struct io_uring_cqe *cqe)
+{
+	unsigned rq_mask = rq_ring.ring_entries - 1;
+	struct io_uring_zcrx_cqe *rcqe;
+	struct io_uring_zcrx_rqe *rqe;
+	uint64_t mask;
+	char *data;
+
+	if (cqe->res < 0)
+		t_error(1, 0, "recvzc(): %d", cqe->res);
+
+	if (cqe->res == 0 && cqe->flags == 0 && cfg_oneshot_recvs == 0) {
+		stop = true;
+		return;
+	}
+
+	if (cfg_oneshot) {
+		if (cqe->res == 0 && cqe->flags == 0 && cfg_oneshot_recvs) {
+			add_recvzc_oneshot(ring, connfd, PAGE_SIZE);
+			cfg_oneshot_recvs--;
+		}
+	} else if (!(cqe->flags & IORING_CQE_F_MORE)) {
+		add_recvzc(ring, connfd);
+	}
+
+	rcqe = (struct io_uring_zcrx_cqe *)(cqe + 1);
+	mask = (1ULL << IORING_ZCRX_AREA_SHIFT) - 1;
+	data = (char *)area_ptr + (rcqe->off & mask);
+
+	verify_data(data, cqe->res, received);
+	received += cqe->res;
+
+	/* processed, return back to the kernel */
+	rqe = &rq_ring.rqes[rq_ring.rq_tail & rq_mask];
+	rqe->off = (rcqe->off & ~IORING_ZCRX_AREA_MASK) | area_token;
+	rqe->len = cqe->res;
+	io_uring_smp_store_release(rq_ring.ktail, ++rq_ring.rq_tail);
+}
+
+static void server_loop(struct io_uring *ring)
+{
+	struct io_uring_cqe *cqe;
+	unsigned int head, count = 0;
+
+	io_uring_submit_and_wait(ring, 1);
+
+	io_uring_for_each_cqe(ring, head, cqe) {
+		if (cqe->user_data == 1)
+			process_accept(ring, cqe);
+		else if (cqe->user_data == 2)
+			process_recvzc(ring, cqe);
+		else
+			t_error(1, 0, "unknown cqe");
+		count++;
+	}
+	io_uring_cq_advance(ring, count);
+}
+
+static void run_server(void)
+{
+	unsigned int flags = 0;
+	struct io_uring ring;
+	int fd, enable, ret;
+
+	fd = socket(AF_INET6, SOCK_STREAM, 0);
+	if (fd == -1)
+		t_error(1, 0, "socket()");
+
+	enable = 1;
+	ret = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(int));
+	if (ret < 0)
+		t_error(1, 0, "setsockopt(SO_REUSEADDR)");
+
+	ret = bind(fd, (struct sockaddr *)&cfg_addr, sizeof(cfg_addr));
+	if (ret < 0)
+		t_error(1, 0, "bind()");
+
+	if (listen(fd, 1024) < 0)
+		t_error(1, 0, "listen()");
+
+	flags |= IORING_SETUP_COOP_TASKRUN;
+	flags |= IORING_SETUP_SINGLE_ISSUER;
+	flags |= IORING_SETUP_DEFER_TASKRUN;
+	flags |= IORING_SETUP_SUBMIT_ALL;
+	flags |= IORING_SETUP_CQE32;
+
+	ret = io_uring_queue_init(512, &ring, flags);
+	if (ret)
+		t_error(1, ret, "ring init failed");
+
+	setup_zcrx(&ring);
+	add_accept(&ring, fd);
+
+	while (!stop)
+		server_loop(&ring);
+}
+
+static void usage(const char *filepath)
+{
+	t_error(1, 0, "Usage: %s (-4|-6) -p<port> -i<ifname> -q<rxq_id>", filepath);
+}
+
+static void parse_opts(int argc, char **argv)
+{
+	struct sockaddr_in6 *addr6 = (void *) &cfg_addr;
+	int c;
+
+	if (argc <= 1)
+		usage(argv[0]);
+
+	while ((c = getopt(argc, argv, "vp:i:q:o:")) != -1) {
+		switch (c) {
+		case 'p':
+			cfg_port = strtoul(optarg, NULL, 0);
+			break;
+		case 'i':
+			cfg_ifname = optarg;
+			break;
+		case 'o': {
+			cfg_oneshot = true;
+			cfg_oneshot_recvs = strtoul(optarg, NULL, 0);
+			break;
+		}
+		case 'q':
+			cfg_queue_id = strtoul(optarg, NULL, 0);
+			break;
+		case 'v':
+			cfg_verify_data = true;
+			break;
+		}
+	}
+
+	memset(addr6, 0, sizeof(*addr6));
+	addr6->sin6_family = AF_INET6;
+	addr6->sin6_port = htons(cfg_port);
+	addr6->sin6_addr = in6addr_any;
+}
+
+int main(int argc, char **argv)
+{
+	parse_opts(argc, argv);
+	run_server();
+	return 0;
+}
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH liburing 0/5] zcrx example and other changes
  2025-04-16  9:01 [PATCH liburing 0/5] zcrx example and other changes Pavel Begunkov
                   ` (4 preceding siblings ...)
  2025-04-16  9:01 ` [PATCH liburing 5/5] examples: add a zcrx example Pavel Begunkov
@ 2025-04-16 14:48 ` Jens Axboe
  5 siblings, 0 replies; 7+ messages in thread
From: Jens Axboe @ 2025-04-16 14:48 UTC (permalink / raw)
  To: io-uring, Pavel Begunkov; +Cc: David Wei


On Wed, 16 Apr 2025 10:01:12 +0100, Pavel Begunkov wrote:
> We need a simple example for zcrx to show case how the api works
> and how to use features. Patch 5 is a brushed up version of the
> zcrx selftest.
> 
> Apart from that update headers and use the kernel return zcrx id.
> 
> Pavel Begunkov (5):
>   Update io_uring.h for zcrx
>   tests/zcrx: rename a test
>   tests/zcrx: use returned right zcrx id
>   examples: add extra helpers
>   examples: add a zcrx example
> 
> [...]

Applied, thanks!

[1/5] Update io_uring.h for zcrx
      (no commit info)
[2/5] tests/zcrx: rename a test
      (no commit info)
[3/5] tests/zcrx: use returned right zcrx id
      (no commit info)
[4/5] examples: add extra helpers
      (no commit info)
[5/5] examples: add a zcrx example
      (no commit info)

Best regards,
-- 
Jens Axboe




^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-04-16 14:48 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-16  9:01 [PATCH liburing 0/5] zcrx example and other changes Pavel Begunkov
2025-04-16  9:01 ` [PATCH liburing 1/5] Update io_uring.h for zcrx Pavel Begunkov
2025-04-16  9:01 ` [PATCH liburing 2/5] tests/zcrx: rename a test Pavel Begunkov
2025-04-16  9:01 ` [PATCH liburing 3/5] tests/zcrx: use returned right zcrx id Pavel Begunkov
2025-04-16  9:01 ` [PATCH liburing 4/5] examples: add extra helpers Pavel Begunkov
2025-04-16  9:01 ` [PATCH liburing 5/5] examples: add a zcrx example Pavel Begunkov
2025-04-16 14:48 ` [PATCH liburing 0/5] zcrx example and other changes Jens Axboe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.