public inbox for [email protected]
 help / color / mirror / Atom feed
From: Pavel Begunkov <[email protected]>
To: [email protected]
Cc: Jens Axboe <[email protected]>, [email protected]
Subject: [PATCH liburing 1/1] liburing: add more zc helpers
Date: Wed, 28 Sep 2022 12:02:58 +0100	[thread overview]
Message-ID: <25a5e4ff7c480cf5c68be2e223a2fa9787ee6283.1664361932.git.asml.silence@gmail.com> (raw)

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

Signed-off-by: Pavel Begunkov <[email protected]>
---
 src/include/liburing.h | 19 +++++++++++++++++++
 test/send-zerocopy.c   |  3 +--
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/src/include/liburing.h b/src/include/liburing.h
index 902f26a..1d04923 100644
--- a/src/include/liburing.h
+++ b/src/include/liburing.h
@@ -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)
diff --git a/test/send-zerocopy.c b/test/send-zerocopy.c
index 88578e0..31d66e3 100644
--- a/test/send-zerocopy.c
+++ b/test/send-zerocopy.c
@@ -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;
-- 
2.37.2


             reply	other threads:[~2022-09-28 11:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-28 11:02 Pavel Begunkov [this message]
2022-09-28 13:53 ` [PATCH liburing 1/1] liburing: add more zc helpers Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=25a5e4ff7c480cf5c68be2e223a2fa9787ee6283.1664361932.git.asml.silence@gmail.com \
    [email protected] \
    [email protected] \
    [email protected] \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox