#ifdef ARCH_HAVE_IOURING
-typedef uint64_t u64;
-typedef uint32_t u32;
-typedef int32_t s32;
-typedef uint16_t u16;
-typedef uint8_t u8;
-
#include "../os/io_uring.h"
struct io_sq_ring {
- u32 *head;
- u32 *tail;
- u32 *ring_mask;
- u32 *ring_entries;
- u32 *flags;
- u32 *array;
+ unsigned *head;
+ unsigned *tail;
+ unsigned *ring_mask;
+ unsigned *ring_entries;
+ unsigned *flags;
+ unsigned *array;
};
struct io_cq_ring {
- u32 *head;
- u32 *tail;
- u32 *ring_mask;
- u32 *ring_entries;
+ unsigned *head;
+ unsigned *tail;
+ unsigned *ring_mask;
+ unsigned *ring_entries;
struct io_uring_event *events;
};
{
struct ioring_data *ld = td->io_ops_data;
struct io_cq_ring *ring = &ld->cq_ring;
- u32 head, reaped = 0;
+ unsigned head, reaped = 0;
head = *ring->head;
do {
struct io_cq_ring *cring = &ld->cq_ring;
void *ptr;
- ld->mmap[0].len = p->sq_off.array + p->sq_entries * sizeof(u32);
+ ld->mmap[0].len = p->sq_off.array + p->sq_entries * sizeof(__u32);
ptr = mmap(0, ld->mmap[0].len, PROT_READ | PROT_WRITE,
MAP_SHARED | MAP_POPULATE, ld->ring_fd,
IORING_OFF_SQ_RING);
-#ifndef IO_URING_H
-#define IO_URING_H
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/*
+ * Header file for the io_uring interface.
+ *
+ * Copyright (C) 2019 Jens Axboe
+ * Copyright (C) 2019 Christoph Hellwig
+ */
+#ifndef LINUX_IO_URING_H
+#define LINUX_IO_URING_H
#include <linux/fs.h>
+#include <linux/types.h>
/*
* IO submission data structure
*/
struct io_uring_iocb {
- u8 opcode;
- u8 flags;
- u16 ioprio;
- s32 fd;
- u64 off;
+ __u8 opcode;
+ __u8 flags;
+ __u16 ioprio;
+ __s32 fd;
+ __u64 off;
union {
void *addr;
- u64 __pad;
+ __u64 __pad;
};
- u32 len;
+ __u32 len;
union {
__kernel_rwf_t rw_flags;
- u32 __resv;
+ __u32 __resv;
};
};
*/
struct io_uring_event {
__u64 index; /* what iocb this event came from */
- s32 res; /* result code for this event */
- u32 flags;
+ __s32 res; /* result code for this event */
+ __u32 flags;
};
+/*
+ * io_uring_event->flags
+ */
#define IOEV_FLAG_CACHEHIT (1 << 0) /* IO did not hit media */
/*
* Filled with the offset for mmap(2)
*/
struct io_sqring_offsets {
- u32 head;
- u32 tail;
- u32 ring_mask;
- u32 ring_entries;
- u32 flags;
- u32 dropped;
- u32 array;
- u32 resv[3];
+ __u32 head;
+ __u32 tail;
+ __u32 ring_mask;
+ __u32 ring_entries;
+ __u32 flags;
+ __u32 dropped;
+ __u32 array;
+ __u32 resv[3];
};
#define IORING_SQ_NEED_WAKEUP (1 << 0) /* needs io_uring_enter wakeup */
struct io_cqring_offsets {
- u32 head;
- u32 tail;
- u32 ring_mask;
- u32 ring_entries;
- u32 overflow;
- u32 events;
- u32 resv[4];
+ __u32 head;
+ __u32 tail;
+ __u32 ring_mask;
+ __u32 ring_entries;
+ __u32 overflow;
+ __u32 events;
+ __u32 resv[4];
};
+/*
+ * io_uring_enter(2) flags
+ */
#define IORING_ENTER_GETEVENTS (1 << 0)
/*
* Passed in for io_uring_setup(2). Copied back with updated info on success
*/
struct io_uring_params {
- u32 sq_entries;
- u32 cq_entries;
- u32 flags;
- u16 sq_thread_cpu;
- u16 resv[9];
+ __u32 sq_entries;
+ __u32 cq_entries;
+ __u32 flags;
+ __u16 sq_thread_cpu;
+ __u16 resv[9];
struct io_sqring_offsets sq_off;
struct io_cqring_offsets cq_off;
};
#include <sched.h>
#include "../arch/arch.h"
-
-typedef uint64_t u64;
-typedef uint32_t u32;
-typedef int32_t s32;
-typedef uint16_t u16;
-typedef uint8_t u8;
-
#include "../os/io_uring.h"
#define barrier() __asm__ __volatile__("": : :"memory")
#define min(a, b) ((a < b) ? (a) : (b))
struct io_sq_ring {
- u32 *head;
- u32 *tail;
- u32 *ring_mask;
- u32 *ring_entries;
- u32 *array;
+ unsigned *head;
+ unsigned *tail;
+ unsigned *ring_mask;
+ unsigned *ring_entries;
+ unsigned *array;
};
struct io_cq_ring {
- u32 *head;
- u32 *tail;
- u32 *ring_mask;
- u32 *ring_entries;
+ unsigned *head;
+ unsigned *tail;
+ unsigned *ring_mask;
+ unsigned *ring_entries;
struct io_uring_event *events;
};
static int prep_more_ios(struct submitter *s, int fd, int max_ios)
{
struct io_sq_ring *ring = &s->sq_ring;
- u32 index, tail, next_tail, prepped = 0;
+ unsigned index, tail, next_tail, prepped = 0;
next_tail = tail = *ring->tail;
do {
{
struct io_cq_ring *ring = &s->cq_ring;
struct io_uring_event *ev;
- u32 head, reaped = 0;
+ unsigned head, reaped = 0;
head = *ring->head;
do {
}
s->ring_fd = fd;
- ptr = mmap(0, p.sq_off.array + p.sq_entries * sizeof(u32),
+ ptr = mmap(0, p.sq_off.array + p.sq_entries * sizeof(__u32),
PROT_READ | PROT_WRITE, MAP_SHARED | MAP_POPULATE, fd,
IORING_OFF_SQ_RING);
printf("sq_ring ptr = 0x%p\n", ptr);