The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Ammar Faizi <ammarfaizi2@gmail.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: io-uring Mailing List <io-uring@vger.kernel.org>,
	Pavel Begunkov <asml.silence@gmail.com>,
	"David S . Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	Ammar Faizi <ammarfaizi2@gmail.com>, Nugra <richiisei@gmail.com>
Subject: [RFC PATCH liburing v1 3/5] liburing.h: Add `io_uring_prep_{sendto,sendto}` helper
Date: Fri, 31 Dec 2021 00:50:17 +0700	[thread overview]
Message-ID: <20211230174548.178641-4-ammar.faizi@intel.com> (raw)
In-Reply-To: <20211230174548.178641-1-ammar.faizi@intel.com>

This adds IORING_OP_SENDTO and IORING_OP_RECVFROM prep helper.

Signed-off-by: Ammar Faizi <ammarfaizi2@gmail.com>
---
 src/include/liburing.h | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/src/include/liburing.h b/src/include/liburing.h
index a36d3f6..c22e69c 100644
--- a/src/include/liburing.h
+++ b/src/include/liburing.h
@@ -750,6 +750,28 @@ static inline void io_uring_prep_fsetxattr(struct io_uring_sqe *sqe,
 	sqe->xattr_flags = flags;
 }
 
+static inline void io_uring_prep_sendto(struct io_uring_sqe *sqe, int sockfd,
+				      const void *buf, size_t len, int flags,
+				      const struct sockaddr *dest_addr,
+				      socklen_t addrlen)
+{
+	io_uring_prep_rw(IORING_OP_SENDTO, sqe, sockfd, buf, (__u32) len, 0);
+	sqe->msg_flags = (__u32) flags;
+	sqe->addr2 = (__u64) (uintptr_t) dest_addr;
+	sqe->addr3 = (__u64) addrlen;
+}
+
+static inline void io_uring_prep_recvfrom(struct io_uring_sqe *sqe, int sockfd,
+					  void *buf, size_t len, int flags,
+					  struct sockaddr *src_addr,
+					  socklen_t *addrlen)
+{
+	io_uring_prep_rw(IORING_OP_RECVFROM, sqe, sockfd, buf, (__u32) len, 0);
+	sqe->msg_flags = (__u32) flags;
+	sqe->addr2 = (__u64) (uintptr_t) src_addr;
+	sqe->addr3 = (__u64) (uintptr_t) addrlen;
+}
+
 /*
  * Returns number of unconsumed (if SQPOLL) or unsubmitted entries exist in
  * the SQ ring
-- 
2.32.0


  parent reply	other threads:[~2021-12-30 17:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-30 17:50 [RFC PATCH liburing v1 0/5] liburing: Add sendto(2) and recvfrom(2) support Ammar Faizi
2021-12-30 17:50 ` [RFC PATCH liburing v1 1/5] .gitignore: Add `/test/xattr` and `/test/getdents` Ammar Faizi
2021-12-30 17:50 ` [RFC PATCH liburing v1 2/5] io_uring.h: Add `IORING_OP_SENDTO` and `IORING_OP_RECVFROM` Ammar Faizi
2021-12-30 17:50 ` Ammar Faizi [this message]
2021-12-30 17:50 ` [RFC PATCH liburing v1 4/5] test: Add sendto_recvfrom test program Ammar Faizi
2021-12-30 17:50 ` [RFC PATCH liburing v1 5/5] man: Add `io_uring_prep_{sendto,recvfrom}` docs Ammar Faizi

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=20211230174548.178641-4-ammar.faizi@intel.com \
    --to=ammarfaizi2@gmail.com \
    --cc=asml.silence@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=davem@davemloft.net \
    --cc=io-uring@vger.kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=richiisei@gmail.com \
    /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