2019-01-08 06:51:07 -07:00
|
|
|
#ifndef LIB_URING_H
|
|
|
|
|
#define LIB_URING_H
|
|
|
|
|
|
|
|
|
|
#include <sys/uio.h>
|
|
|
|
|
#include "io_uring.h"
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Library interface to io_uring
|
|
|
|
|
*/
|
|
|
|
|
struct io_uring_sq {
|
|
|
|
|
unsigned *khead;
|
|
|
|
|
unsigned *ktail;
|
|
|
|
|
unsigned *kring_mask;
|
|
|
|
|
unsigned *kring_entries;
|
|
|
|
|
unsigned *kflags;
|
|
|
|
|
unsigned *kdropped;
|
|
|
|
|
unsigned *array;
|
2019-01-09 15:26:20 -07:00
|
|
|
struct io_uring_sqe *sqes;
|
2019-01-08 06:51:07 -07:00
|
|
|
|
2019-01-09 15:26:20 -07:00
|
|
|
unsigned sqe_head;
|
|
|
|
|
unsigned sqe_tail;
|
2019-01-08 06:51:07 -07:00
|
|
|
|
|
|
|
|
size_t ring_sz;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct io_uring_cq {
|
|
|
|
|
unsigned *khead;
|
|
|
|
|
unsigned *ktail;
|
|
|
|
|
unsigned *kring_mask;
|
|
|
|
|
unsigned *kring_entries;
|
|
|
|
|
unsigned *koverflow;
|
2019-01-09 15:26:20 -07:00
|
|
|
struct io_uring_cqe *cqes;
|
2019-01-08 06:51:07 -07:00
|
|
|
|
|
|
|
|
size_t ring_sz;
|
|
|
|
|
};
|
|
|
|
|
|
2019-01-08 15:31:35 -07:00
|
|
|
struct io_uring {
|
|
|
|
|
struct io_uring_sq sq;
|
|
|
|
|
struct io_uring_cq cq;
|
2019-01-08 15:59:09 -07:00
|
|
|
int ring_fd;
|
2019-01-08 15:31:35 -07:00
|
|
|
};
|
|
|
|
|
|
2019-01-08 06:51:07 -07:00
|
|
|
/*
|
|
|
|
|
* System calls
|
|
|
|
|
*/
|
|
|
|
|
extern int io_uring_setup(unsigned entries, struct iovec *iovecs,
|
2019-01-10 09:32:41 -07:00
|
|
|
unsigned nr_iovecs, struct io_uring_params *p);
|
2019-01-08 06:51:07 -07:00
|
|
|
extern int io_uring_enter(unsigned fd, unsigned to_submit,
|
|
|
|
|
unsigned min_complete, unsigned flags);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Library interface
|
|
|
|
|
*/
|
|
|
|
|
extern int io_uring_queue_init(unsigned entries, struct io_uring_params *p,
|
2019-01-10 09:32:41 -07:00
|
|
|
struct iovec *iovecs, unsigned nr_iovecs, struct io_uring *ring);
|
2019-01-08 15:59:09 -07:00
|
|
|
extern void io_uring_queue_exit(struct io_uring *ring);
|
|
|
|
|
extern int io_uring_get_completion(struct io_uring *ring,
|
2019-01-09 15:26:20 -07:00
|
|
|
struct io_uring_cqe **cqe_ptr);
|
2019-01-08 15:59:09 -07:00
|
|
|
extern int io_uring_wait_completion(struct io_uring *ring,
|
2019-01-09 15:26:20 -07:00
|
|
|
struct io_uring_cqe **cqe_ptr);
|
2019-01-08 15:59:09 -07:00
|
|
|
extern int io_uring_submit(struct io_uring *ring);
|
2019-01-09 15:26:20 -07:00
|
|
|
extern struct io_uring_sqe *io_uring_get_sqe(struct io_uring *ring);
|
2019-01-08 06:51:07 -07:00
|
|
|
|
|
|
|
|
#endif
|