summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2020-02-25 20:23:55 -0700
committerJens Axboe <axboe@kernel.dk>2020-02-25 20:23:55 -0700
commit4040b8fb2538acde5a56d02d53e9ffce8bbb197e (patch)
tree66b730e88e5d3d02d23adaa1e52b5d358071d1c0
parent98f6ebd52bfeb4217ba8a250c53586d8a594c36d (diff)
downloadliburing-4040b8fb2538acde5a56d02d53e9ffce8bbb197e.tar.gz
liburing-4040b8fb2538acde5a56d02d53e9ffce8bbb197e.tar.bz2
Add IORING_OP_PROVIDE_BUFFERS and helper
Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--src/include/liburing.h8
-rw-r--r--src/include/liburing/io_uring.h23
2 files changed, 29 insertions, 2 deletions
diff --git a/src/include/liburing.h b/src/include/liburing.h
index 7edd4f1..5a17b76 100644
--- a/src/include/liburing.h
+++ b/src/include/liburing.h
@@ -410,6 +410,14 @@ static inline void io_uring_prep_epoll_ctl(struct io_uring_sqe *sqe, int epfd,
io_uring_prep_rw(IORING_OP_EPOLL_CTL, sqe, epfd, ev, op, fd);
}
+static inline void io_uring_prep_provide_buffers(struct io_uring_sqe *sqe,
+ void *addr, int len, int nr,
+ int gid, int bid)
+{
+ io_uring_prep_rw(IORING_OP_PROVIDE_BUFFERS, sqe, nr, addr, len, bid);
+ sqe->buf_group = gid;
+}
+
static inline unsigned io_uring_sq_ready(struct io_uring *ring)
{
if (!(ring->flags & IORING_SETUP_SQPOLL))
diff --git a/src/include/liburing/io_uring.h b/src/include/liburing/io_uring.h
index a3d5e25..f66621f 100644
--- a/src/include/liburing/io_uring.h
+++ b/src/include/liburing/io_uring.h
@@ -45,8 +45,12 @@ struct io_uring_sqe {
__u64 user_data; /* data to be passed back at completion time */
union {
struct {
- /* index into fixed buffers, if used */
- __u16 buf_index;
+ union {
+ /* index into fixed buffers, if used */
+ __u16 buf_index;
+ /* for grouped buffer selection */
+ __u16 buf_group;
+ };
/* personality to use, if used */
__u16 personality;
__s32 splice_fd_in;
@@ -61,6 +65,7 @@ enum {
IOSQE_IO_LINK_BIT,
IOSQE_IO_HARDLINK_BIT,
IOSQE_ASYNC_BIT,
+ IOSQE_BUFFER_SELECT_BIT,
};
/*
@@ -76,6 +81,8 @@ enum {
#define IOSQE_IO_HARDLINK (1U << IOSQE_IO_HARDLINK_BIT)
/* always go async */
#define IOSQE_ASYNC (1U << IOSQE_ASYNC_BIT)
+/* select buffer from sqe->buf_group */
+#define IOSQE_BUFFER_SELECT (1U << IOSQE_BUFFER_SELECT_BIT)
/*
* io_uring_setup() flags
@@ -119,6 +126,7 @@ enum {
IORING_OP_OPENAT2,
IORING_OP_EPOLL_CTL,
IORING_OP_SPLICE,
+ IORING_OP_PROVIDE_BUFFERS,
/* this goes last, obviously */
IORING_OP_LAST,
@@ -150,6 +158,17 @@ struct io_uring_cqe {
};
/*
+ * cqe->flags
+ *
+ * IORING_CQE_F_BUFFER If set, the upper 16 bits are the buffer ID
+ */
+#define IORING_CQE_F_BUFFER (1U << 0)
+
+enum {
+ IORING_CQE_BUFFER_SHIFT = 16,
+};
+
+/*
* Magic offsets for the application to mmap the data it needs
*/
#define IORING_OFF_SQ_RING 0ULL