diff mbox series

[liburing,2/4] add IORING_RECV_MULTISHOT to io_uring.h

Message ID 20220628150414.1386435-3-dylany@fb.com (mailing list archive)
State New
Headers show
Series liburing: multishot receive | expand

Commit Message

Dylan Yudaken June 28, 2022, 3:04 p.m. UTC
copy from include/uapi/linux/io_uring.h

Signed-off-by: Dylan Yudaken <dylany@fb.com>
---
 src/include/liburing/io_uring.h | 53 ++++++++++++++++++++++++---------
 1 file changed, 39 insertions(+), 14 deletions(-)

Comments

Ammar Faizi June 28, 2022, 4:10 p.m. UTC | #1
On 6/28/22 10:04 PM, Dylan Yudaken wrote:
> copy from include/uapi/linux/io_uring.h
> 
> Signed-off-by: Dylan Yudaken <dylany@fb.com>
> ---
>   src/include/liburing/io_uring.h | 53 ++++++++++++++++++++++++---------
>   1 file changed, 39 insertions(+), 14 deletions(-)
> 
> diff --git a/src/include/liburing/io_uring.h b/src/include/liburing/io_uring.h
> index 2f391c9..1e5bdb3 100644
> --- a/src/include/liburing/io_uring.h
> +++ b/src/include/liburing/io_uring.h
> @@ -10,10 +10,7 @@
>   
>   #include <linux/fs.h>
>   #include <linux/types.h>
> -
> -#ifdef __cplusplus
> -extern "C" {
> -#endif

Dylan,

That `extern "C"` thing is for C++, we shouldn't omit it.

Or better add that to the kernel tree as well, it won't break
the kernel because we have a __cplusplus guard here.

Jens what do you think?

Just for reference, that line is introduced in commit:

   commit 3d74c677c45eccf36b92f7ad4b3317adc1ed06bb
   Author: Bart Van Assche <bvanassche@acm.org>
   Date:   Sun Jun 28 12:58:19 2020 -0700

       Make the liburing header files again compatible with C++

       Include <atomic> instead of <stdatomic.h> if built with a C++ compiler.

       Fixes: b9c0bf79aa87 ("src/include/liburing/barrier.h: Use C11 atomics")
       Signed-off-by: Bart Van Assche <bvanassche@acm.org>
       Signed-off-by: Jens Axboe <axboe@kernel.dk>

  src/include/liburing.h          |  8 ++++----
  src/include/liburing/barrier.h  | 37 +++++++++++++++++++++++++++++++++++--
  src/include/liburing/io_uring.h |  8 ++++++++
  3 files changed, 47 insertions(+), 6 deletions(-)

Adding the author to the CC list.
Jens Axboe June 28, 2022, 4:12 p.m. UTC | #2
On 6/28/22 10:10 AM, Ammar Faizi wrote:
> On 6/28/22 10:04 PM, Dylan Yudaken wrote:
>> copy from include/uapi/linux/io_uring.h
>>
>> Signed-off-by: Dylan Yudaken <dylany@fb.com>
>> ---
>>   src/include/liburing/io_uring.h | 53 ++++++++++++++++++++++++---------
>>   1 file changed, 39 insertions(+), 14 deletions(-)
>>
>> diff --git a/src/include/liburing/io_uring.h b/src/include/liburing/io_uring.h
>> index 2f391c9..1e5bdb3 100644
>> --- a/src/include/liburing/io_uring.h
>> +++ b/src/include/liburing/io_uring.h
>> @@ -10,10 +10,7 @@
>>     #include <linux/fs.h>
>>   #include <linux/types.h>
>> -
>> -#ifdef __cplusplus
>> -extern "C" {
>> -#endif
> 
> Dylan,
> 
> That `extern "C"` thing is for C++, we shouldn't omit it.
> 
> Or better add that to the kernel tree as well, it won't break
> the kernel because we have a __cplusplus guard here.
> 
> Jens what do you think?

It'd be nice to keep them fully in sync. If I recall correctly, the only
differences right now is that clause, and the change to not using a zero
sized array at the end of a struct (which is slated for the kernel too).
Dylan Yudaken June 28, 2022, 4:12 p.m. UTC | #3
On Tue, 2022-06-28 at 23:10 +0700, Ammar Faizi wrote:
> On 6/28/22 10:04 PM, Dylan Yudaken wrote:
> > copy from include/uapi/linux/io_uring.h
> > 
> > Signed-off-by: Dylan Yudaken <dylany@fb.com>
> > ---
> >   src/include/liburing/io_uring.h | 53 ++++++++++++++++++++++++----
> > -----
> >   1 file changed, 39 insertions(+), 14 deletions(-)
> > 
> > diff --git a/src/include/liburing/io_uring.h
> > b/src/include/liburing/io_uring.h
> > index 2f391c9..1e5bdb3 100644
> > --- a/src/include/liburing/io_uring.h
> > +++ b/src/include/liburing/io_uring.h
> > @@ -10,10 +10,7 @@
> >   
> >   #include <linux/fs.h>
> >   #include <linux/types.h>
> > -
> > -#ifdef __cplusplus
> > -extern "C" {
> > -#endif
> 
> Dylan,
> 
> That `extern "C"` thing is for C++, we shouldn't omit it.
> 
> Or better add that to the kernel tree as well, it won't break
> the kernel because we have a __cplusplus guard here.
> 
> Jens what do you think?
> 
> Just for reference, that line is introduced in commit:
> 
>    commit 3d74c677c45eccf36b92f7ad4b3317adc1ed06bb
>    Author: Bart Van Assche <bvanassche@acm.org>
>    Date:   Sun Jun 28 12:58:19 2020 -0700
> 
>        Make the liburing header files again compatible with C++
> 
>        Include <atomic> instead of <stdatomic.h> if built with a C++
> compiler.
> 
>        Fixes: b9c0bf79aa87 ("src/include/liburing/barrier.h: Use C11
> atomics")
>        Signed-off-by: Bart Van Assche <bvanassche@acm.org>
>        Signed-off-by: Jens Axboe <axboe@kernel.dk>
> 
>   src/include/liburing.h          |  8 ++++----
>   src/include/liburing/barrier.h  | 37
> +++++++++++++++++++++++++++++++++++--
>   src/include/liburing/io_uring.h |  8 ++++++++
>   3 files changed, 47 insertions(+), 6 deletions(-)
> 
> Adding the author to the CC list.
> 

Yeah this makes sense. I think I just assumed the file was a manual
copy of the latest kernel one which it clearly is not.

I'll fix it up in v2
diff mbox series

Patch

diff --git a/src/include/liburing/io_uring.h b/src/include/liburing/io_uring.h
index 2f391c9..1e5bdb3 100644
--- a/src/include/liburing/io_uring.h
+++ b/src/include/liburing/io_uring.h
@@ -10,10 +10,7 @@ 
 
 #include <linux/fs.h>
 #include <linux/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
+#include <linux/time_types.h>
 
 /*
  * IO submission data structure (Submission Queue Entry)
@@ -26,6 +23,7 @@  struct io_uring_sqe {
 	union {
 		__u64	off;	/* offset into file */
 		__u64	addr2;
+		__u32	cmd_op;
 	};
 	union {
 		__u64	addr;	/* pointer to buffer or iovecs */
@@ -65,8 +63,17 @@  struct io_uring_sqe {
 		__s32	splice_fd_in;
 		__u32	file_index;
 	};
-	__u64	addr3;
-	__u64	__pad2[1];
+	union {
+		struct {
+			__u64	addr3;
+			__u64	__pad2[1];
+		};
+		/*
+		 * If the ring is initialized with IORING_SETUP_SQE128, then
+		 * this field is used for 80 bytes of arbitrary command data
+		 */
+		__u8	cmd[0];
+	};
 };
 
 /*
@@ -131,9 +138,12 @@  enum {
  * IORING_SQ_TASKRUN in the sq ring flags. Not valid with COOP_TASKRUN.
  */
 #define IORING_SETUP_TASKRUN_FLAG	(1U << 9)
-
 #define IORING_SETUP_SQE128		(1U << 10) /* SQEs are 128 byte */
 #define IORING_SETUP_CQE32		(1U << 11) /* CQEs are 32 byte */
+/*
+ * Only one task is allowed to submit requests
+ */
+#define IORING_SETUP_SINGLE_ISSUER	(1U << 12)
 
 enum io_uring_op {
 	IORING_OP_NOP,
@@ -220,10 +230,13 @@  enum io_uring_op {
  *
  * IORING_POLL_UPDATE		Update existing poll request, matching
  *				sqe->addr as the old user_data field.
+ *
+ * IORING_POLL_LEVEL		Level triggered poll.
  */
 #define IORING_POLL_ADD_MULTI	(1U << 0)
 #define IORING_POLL_UPDATE_EVENTS	(1U << 1)
 #define IORING_POLL_UPDATE_USER_DATA	(1U << 2)
+#define IORING_POLL_ADD_LEVEL		(1U << 3)
 
 /*
  * ASYNC_CANCEL flags.
@@ -232,10 +245,12 @@  enum io_uring_op {
  * IORING_ASYNC_CANCEL_FD	Key off 'fd' for cancelation rather than the
  *				request 'user_data'
  * IORING_ASYNC_CANCEL_ANY	Match any request
+ * IORING_ASYNC_CANCEL_FD_FIXED	'fd' passed in is a fixed descriptor
  */
 #define IORING_ASYNC_CANCEL_ALL	(1U << 0)
 #define IORING_ASYNC_CANCEL_FD	(1U << 1)
-#define IORING_ASYNC_CANCEL_ANY (1U << 2)
+#define IORING_ASYNC_CANCEL_ANY	(1U << 2)
+#define IORING_ASYNC_CANCEL_FD_FIXED	(1U << 3)
 
 /*
  * send/sendmsg and recv/recvmsg flags (sqe->addr2)
@@ -244,8 +259,13 @@  enum io_uring_op {
  *				or receive and arm poll if that yields an
  *				-EAGAIN result, arm poll upfront and skip
  *				the initial transfer attempt.
+ *
+ * IORING_RECV_MULTISHOT	Multishot recv. Sets IORING_CQE_F_MORE if
+ *				the handler will continue to report
+ *				CQEs on behalf of the same SQE.
  */
 #define IORING_RECVSEND_POLL_FIRST	(1U << 0)
+#define IORING_RECV_MULTISHOT	(1U << 1)
 
 /*
  * accept flags stored in sqe->ioprio
@@ -411,6 +431,9 @@  enum {
 	IORING_REGISTER_PBUF_RING		= 22,
 	IORING_UNREGISTER_PBUF_RING		= 23,
 
+	/* sync cancelation API */
+	IORING_REGISTER_SYNC_CANCEL		= 24,
+
 	/* this goes last */
 	IORING_REGISTER_LAST
 };
@@ -547,12 +570,14 @@  struct io_uring_getevents_arg {
 };
 
 /*
- * accept flags stored in sqe->ioprio
+ * Argument for IORING_REGISTER_SYNC_CANCEL
  */
-#define IORING_ACCEPT_MULTISHOT	(1U << 0)
-
-#ifdef __cplusplus
-}
-#endif
+struct io_uring_sync_cancel_reg {
+	__u64				addr;
+	__s32				fd;
+	__u32				flags;
+	struct __kernel_timespec	timeout;
+	__u64				pad[4];
+};
 
 #endif