target-lm32: Update VMStateDescription to LM32CPU
[qemu/rayw.git] / hw / dataplane / ioq.h
blobb49b5de7f49e975a3609c9686e6f30403b56d222
1 /*
2 * Linux AIO request queue
4 * Copyright 2012 IBM, Corp.
5 * Copyright 2012 Red Hat, Inc. and/or its affiliates
7 * Authors:
8 * Stefan Hajnoczi <stefanha@redhat.com>
10 * This work is licensed under the terms of the GNU GPL, version 2 or later.
11 * See the COPYING file in the top-level directory.
15 #ifndef IOQ_H
16 #define IOQ_H
18 #include <libaio.h>
19 #include "qemu/event_notifier.h"
21 typedef struct {
22 int fd; /* file descriptor */
23 unsigned int max_reqs; /* max length of freelist and queue */
25 io_context_t io_ctx; /* Linux AIO context */
26 EventNotifier io_notifier; /* Linux AIO eventfd */
28 /* Requests can complete in any order so a free list is necessary to manage
29 * available iocbs.
31 struct iocb **freelist; /* free iocbs */
32 unsigned int freelist_idx;
34 /* Multiple requests are queued up before submitting them all in one go */
35 struct iocb **queue; /* queued iocbs */
36 unsigned int queue_idx;
37 } IOQueue;
39 void ioq_init(IOQueue *ioq, int fd, unsigned int max_reqs);
40 void ioq_cleanup(IOQueue *ioq);
41 EventNotifier *ioq_get_notifier(IOQueue *ioq);
42 struct iocb *ioq_get_iocb(IOQueue *ioq);
43 void ioq_put_iocb(IOQueue *ioq, struct iocb *iocb);
44 struct iocb *ioq_rdwr(IOQueue *ioq, bool read, struct iovec *iov,
45 unsigned int count, long long offset);
46 int ioq_submit(IOQueue *ioq);
48 static inline unsigned int ioq_num_queued(IOQueue *ioq)
50 return ioq->queue_idx;
53 typedef void IOQueueCompletion(struct iocb *iocb, ssize_t ret, void *opaque);
54 int ioq_run_completion(IOQueue *ioq, IOQueueCompletion *completion,
55 void *opaque);
57 #endif /* IOQ_H */