summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2022-05-14 09:45:03 -0600
committerJens Axboe <axboe@kernel.dk>2022-05-18 14:24:03 -0600
commitc5988858dafe56dcdcce2c15731904c2a62104d8 (patch)
treeedb9b38dce97a60560406c151a3273e2f9358ddd
parentbb756586aa03e88a9b0b4beb09d9880fffa8cfc7 (diff)
downloadliburing-c5988858dafe56dcdcce2c15731904c2a62104d8.tar.gz
liburing-c5988858dafe56dcdcce2c15731904c2a62104d8.tar.bz2
Add ring based registered buffers
Add definitions and a helper to set them up. Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--src/include/liburing.h1
-rw-r--r--src/include/liburing/io_uring.h36
-rw-r--r--src/liburing.map1
-rw-r--r--src/register.c7
4 files changed, 45 insertions, 0 deletions
diff --git a/src/include/liburing.h b/src/include/liburing.h
index 4bdf0f6..16f10e1 100644
--- a/src/include/liburing.h
+++ b/src/include/liburing.h
@@ -178,6 +178,7 @@ int io_uring_register_iowq_max_workers(struct io_uring *ring,
unsigned int *values);
int io_uring_register_ring_fd(struct io_uring *ring);
int io_uring_unregister_ring_fd(struct io_uring *ring);
+int io_uring_register_buf_ring(struct io_uring *ring, struct io_uring_buf_reg *reg);
/*
* Helper for the peek/wait single cqe functions. Exported because of that,
diff --git a/src/include/liburing/io_uring.h b/src/include/liburing/io_uring.h
index c85f274..2f391c9 100644
--- a/src/include/liburing/io_uring.h
+++ b/src/include/liburing/io_uring.h
@@ -407,6 +407,10 @@ enum {
IORING_REGISTER_RING_FDS = 20,
IORING_UNREGISTER_RING_FDS = 21,
+ /* register ring based provide buffer group */
+ IORING_REGISTER_PBUF_RING = 22,
+ IORING_UNREGISTER_PBUF_RING = 23,
+
/* this goes last */
IORING_REGISTER_LAST
};
@@ -484,6 +488,38 @@ struct io_uring_restriction {
__u32 resv2[3];
};
+struct io_uring_buf {
+ __u64 addr;
+ __u32 len;
+ __u16 bid;
+ __u16 resv;
+};
+
+struct io_uring_buf_ring {
+ union {
+ /*
+ * To avoid spilling into more pages than we need to, the
+ * ring tail is overlaid with the io_uring_buf->resv field.
+ */
+ struct {
+ __u64 resv1;
+ __u32 resv2;
+ __u16 resv3;
+ __u16 tail;
+ };
+ struct io_uring_buf bufs[0];
+ };
+};
+
+/* argument for IORING_(UN)REGISTER_PBUF_RING */
+struct io_uring_buf_reg {
+ __u64 ring_addr;
+ __u32 ring_entries;
+ __u16 bgid;
+ __u16 pad;
+ __u64 resv[3];
+};
+
/*
* io_uring_restriction->opcode values
*/
diff --git a/src/liburing.map b/src/liburing.map
index 1e66849..287d683 100644
--- a/src/liburing.map
+++ b/src/liburing.map
@@ -51,4 +51,5 @@ LIBURING_2.2 {
io_uring_register_ring_fd;
io_uring_unregister_ring_fd;
io_uring_register_files_sparse;
+ io_uring_register_buf_ring;
} LIBURING_2.1;
diff --git a/src/register.c b/src/register.c
index dde2038..986e968 100644
--- a/src/register.c
+++ b/src/register.c
@@ -318,3 +318,10 @@ int io_uring_unregister_ring_fd(struct io_uring *ring)
}
return ret;
}
+
+int io_uring_register_buf_ring(struct io_uring *ring,
+ struct io_uring_buf_reg *reg)
+{
+ return ____sys_io_uring_register(ring->ring_fd,
+ IORING_REGISTER_PBUF_RING, reg, 1);
+}