Skip to contentSkip to conversation

liburing: add more zc helpers

PATCH Applied Pavel Begunkov 2 participants 2 messages Sep 28, 2022 io_uring

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 liburing: add more zc helpers

Add a helper for zc sendmsg and also for zc send with registered buffers (aka fixed).

---
 src/include/liburing.h | 19 +++++++++++++++++++
 test/send-zerocopy.c   |  3 +--
 2 files changed, 20 insertions(+), 2 deletions(-)
src/include/liburing.h +19 -0
index 902f26a..1d04923 100644
@@ -746,6 +746,25 @@ static inline void io_uring_prep_send_zc(struct io_uring_sqe *sqe, int sockfd,
 	sqe->ioprio = zc_flags;
 }
 
+static inline void io_uring_prep_send_zc_fixed(struct io_uring_sqe *sqe,
+						int sockfd, const void *buf,
+						size_t len, int flags,
+						unsigned zc_flags,
+						unsigned buf_index)
+{
+	io_uring_prep_send_zc(sqe, sockfd, buf, len, flags, zc_flags);
+	sqe->ioprio |= IORING_RECVSEND_FIXED_BUF;
+	sqe->buf_index = buf_index;
+}
+
+static inline void io_uring_prep_sendmsg_zc(struct io_uring_sqe *sqe, int fd,
+					    const struct msghdr *msg,
+					    unsigned flags)
+{
+	io_uring_prep_sendmsg(sqe, fd, msg, flags);
+	sqe->opcode = IORING_OP_SENDMSG_ZC;
+}
+
 static inline void io_uring_prep_send_set_addr(struct io_uring_sqe *sqe,
 						const struct sockaddr *dest_addr,
 						__u16 addr_len)
test/send-zerocopy.c +1 -2
index 88578e0..31d66e3 100644
@@ -301,8 +301,7 @@ static int do_test_inet_send(struct io_uring *ring, int sock_client, int sock_se
 				io_uring_prep_send_set_addr(sqe, (const struct sockaddr *)addr,
 							    addr_len);
 		} else {
-			io_uring_prep_sendmsg(sqe, sock_client, &msghdr[i], msg_flags);
-			sqe->opcode = IORING_OP_SENDMSG_ZC;
+			io_uring_prep_sendmsg_zc(sqe, sock_client, &msghdr[i], msg_flags);
 
 			memset(&msghdr[i], 0, sizeof(msghdr[i]));
 			iov[i].iov_len = cur_size;
Signature · 1 line
2.37.2
maintainer Applied
#1 lore raw
Quoted 4 lines · Pavel Begunkov

Add a helper for zc sendmsg and also for zc send with registered buffers (aka fixed).

Applied, thanks!

[1/1] liburing: add more zc helpers

      commit: 82a4dfc212478935f81f0f385da01458e8d5d7ec

Best regards,

Signature · 1 line
Jens Axboe