blob: 24cf671f142b3af2f18fec1c0125f30e9bc4b365 [file] [log] [blame]
Ben Cheng655a7c02013-10-16 16:09:24 -07001/****************************************************************************
2 ****************************************************************************
3 ***
4 *** This header was automatically generated from a Linux kernel header
5 *** of the same name, to make information necessary for userspace to
6 *** call into the kernel available to libc. It contains only constants,
7 *** structures, and macros generated from the original header, and thus,
8 *** contains no copyrightable information.
9 ***
10 *** To edit the content of this header, modify the corresponding
11 *** source file (e.g. under external/kernel-headers/original/) then
12 *** run bionic/libc/kernel/tools/update_all.py
13 ***
14 *** Any manual change here will be lost the next time this script will
15 *** be run. You've been warned!
16 ***
17 ****************************************************************************
18 ****************************************************************************/
19#ifndef _UAPI_LINUX_VIRTIO_RING_H
20#define _UAPI_LINUX_VIRTIO_RING_H
Christopher Ferris05d08e92016-02-04 13:16:38 -080021#include <stdint.h>
Ben Cheng655a7c02013-10-16 16:09:24 -070022#include <linux/types.h>
Christopher Ferris05d08e92016-02-04 13:16:38 -080023#include <linux/virtio_types.h>
24#define VRING_DESC_F_NEXT 1
Ben Cheng655a7c02013-10-16 16:09:24 -070025#define VRING_DESC_F_WRITE 2
26#define VRING_DESC_F_INDIRECT 4
Christopher Ferrisd842e432019-03-07 10:21:59 -080027#define VRING_PACKED_DESC_F_AVAIL 7
28#define VRING_PACKED_DESC_F_USED 15
Ben Cheng655a7c02013-10-16 16:09:24 -070029#define VRING_USED_F_NO_NOTIFY 1
30#define VRING_AVAIL_F_NO_INTERRUPT 1
Christopher Ferrisd842e432019-03-07 10:21:59 -080031#define VRING_PACKED_EVENT_FLAG_ENABLE 0x0
32#define VRING_PACKED_EVENT_FLAG_DISABLE 0x1
33#define VRING_PACKED_EVENT_FLAG_DESC 0x2
34#define VRING_PACKED_EVENT_F_WRAP_CTR 15
Ben Cheng655a7c02013-10-16 16:09:24 -070035#define VIRTIO_RING_F_INDIRECT_DESC 28
36#define VIRTIO_RING_F_EVENT_IDX 29
Christopher Ferris8177cdf2020-08-03 11:53:55 -070037#define VRING_AVAIL_ALIGN_SIZE 2
38#define VRING_USED_ALIGN_SIZE 4
39#define VRING_DESC_ALIGN_SIZE 16
Ben Cheng655a7c02013-10-16 16:09:24 -070040struct vring_desc {
Christopher Ferris05d08e92016-02-04 13:16:38 -080041 __virtio64 addr;
42 __virtio32 len;
43 __virtio16 flags;
Christopher Ferris05d08e92016-02-04 13:16:38 -080044 __virtio16 next;
Ben Cheng655a7c02013-10-16 16:09:24 -070045};
Ben Cheng655a7c02013-10-16 16:09:24 -070046struct vring_avail {
Christopher Ferris05d08e92016-02-04 13:16:38 -080047 __virtio16 flags;
Christopher Ferris05d08e92016-02-04 13:16:38 -080048 __virtio16 idx;
49 __virtio16 ring[];
Ben Cheng655a7c02013-10-16 16:09:24 -070050};
51struct vring_used_elem {
Christopher Ferris05d08e92016-02-04 13:16:38 -080052 __virtio32 id;
53 __virtio32 len;
Ben Cheng655a7c02013-10-16 16:09:24 -070054};
Christopher Ferris8177cdf2020-08-03 11:53:55 -070055typedef struct vring_used_elem __attribute__((aligned(VRING_USED_ALIGN_SIZE))) vring_used_elem_t;
Ben Cheng655a7c02013-10-16 16:09:24 -070056struct vring_used {
Christopher Ferris05d08e92016-02-04 13:16:38 -080057 __virtio16 flags;
58 __virtio16 idx;
Christopher Ferris8177cdf2020-08-03 11:53:55 -070059 vring_used_elem_t ring[];
Ben Cheng655a7c02013-10-16 16:09:24 -070060};
Christopher Ferris8177cdf2020-08-03 11:53:55 -070061typedef struct vring_desc __attribute__((aligned(VRING_DESC_ALIGN_SIZE))) vring_desc_t;
62typedef struct vring_avail __attribute__((aligned(VRING_AVAIL_ALIGN_SIZE))) vring_avail_t;
63typedef struct vring_used __attribute__((aligned(VRING_USED_ALIGN_SIZE))) vring_used_t;
Ben Cheng655a7c02013-10-16 16:09:24 -070064struct vring {
Tao Baod7db5942015-01-28 10:07:51 -080065 unsigned int num;
Christopher Ferris8177cdf2020-08-03 11:53:55 -070066 vring_desc_t * desc;
67 vring_avail_t * avail;
68 vring_used_t * used;
Ben Cheng655a7c02013-10-16 16:09:24 -070069};
Christopher Ferris8177cdf2020-08-03 11:53:55 -070070#ifndef VIRTIO_RING_NO_LEGACY
Ben Cheng655a7c02013-10-16 16:09:24 -070071#define vring_used_event(vr) ((vr)->avail->ring[(vr)->num])
Christopher Ferris05d08e92016-02-04 13:16:38 -080072#define vring_avail_event(vr) (* (__virtio16 *) & (vr)->used->ring[(vr)->num])
Christopher Ferris8177cdf2020-08-03 11:53:55 -070073#endif
Christopher Ferrisd842e432019-03-07 10:21:59 -080074struct vring_packed_desc_event {
75 __le16 off_wrap;
76 __le16 flags;
77};
78struct vring_packed_desc {
79 __le64 addr;
80 __le32 len;
81 __le16 id;
82 __le16 flags;
83};
Ben Cheng655a7c02013-10-16 16:09:24 -070084#endif