1
2#ifndef _LINUX_VHOST_H
3#define _LINUX_VHOST_H
4
5
6
7
8
9
10
11
12
13
14#include <linux/types.h>
15#include <linux/compiler.h>
16#include <linux/ioctl.h>
17#include <linux/virtio_config.h>
18#include <linux/virtio_ring.h>
19
20struct vhost_vring_state {
21 unsigned int index;
22 unsigned int num;
23};
24
25struct vhost_vring_file {
26 unsigned int index;
27 int fd;
28
29};
30
31struct vhost_vring_addr {
32 unsigned int index;
33
34 unsigned int flags;
35
36
37#define VHOST_VRING_F_LOG 0
38
39
40 __u64 desc_user_addr;
41
42 __u64 used_user_addr;
43
44 __u64 avail_user_addr;
45
46
47
48 __u64 log_guest_addr;
49};
50
51
52struct vhost_iotlb_msg {
53 __u64 iova;
54 __u64 size;
55 __u64 uaddr;
56#define VHOST_ACCESS_RO 0x1
57#define VHOST_ACCESS_WO 0x2
58#define VHOST_ACCESS_RW 0x3
59 __u8 perm;
60#define VHOST_IOTLB_MISS 1
61#define VHOST_IOTLB_UPDATE 2
62#define VHOST_IOTLB_INVALIDATE 3
63#define VHOST_IOTLB_ACCESS_FAIL 4
64 __u8 type;
65};
66
67#define VHOST_IOTLB_MSG 0x1
68
69struct vhost_msg {
70 int type;
71 union {
72 struct vhost_iotlb_msg iotlb;
73 __u8 padding[64];
74 };
75};
76
77struct vhost_memory_region {
78 __u64 guest_phys_addr;
79 __u64 memory_size;
80 __u64 userspace_addr;
81 __u64 flags_padding;
82};
83
84
85#define VHOST_PAGE_SIZE 0x1000
86
87struct vhost_memory {
88 __u32 nregions;
89 __u32 padding;
90 struct vhost_memory_region regions[0];
91};
92
93
94
95#define VHOST_VIRTIO 0xAF
96
97
98
99#define VHOST_GET_FEATURES _IOR(VHOST_VIRTIO, 0x00, __u64)
100#define VHOST_SET_FEATURES _IOW(VHOST_VIRTIO, 0x00, __u64)
101
102
103
104
105#define VHOST_SET_OWNER _IO(VHOST_VIRTIO, 0x01)
106
107
108#define VHOST_RESET_OWNER _IO(VHOST_VIRTIO, 0x02)
109
110
111#define VHOST_SET_MEM_TABLE _IOW(VHOST_VIRTIO, 0x03, struct vhost_memory)
112
113
114
115
116
117
118#define VHOST_SET_LOG_BASE _IOW(VHOST_VIRTIO, 0x04, __u64)
119
120#define VHOST_SET_LOG_FD _IOW(VHOST_VIRTIO, 0x07, int)
121
122
123
124
125#define VHOST_SET_VRING_NUM _IOW(VHOST_VIRTIO, 0x10, struct vhost_vring_state)
126
127#define VHOST_SET_VRING_ADDR _IOW(VHOST_VIRTIO, 0x11, struct vhost_vring_addr)
128
129#define VHOST_SET_VRING_BASE _IOW(VHOST_VIRTIO, 0x12, struct vhost_vring_state)
130
131#define VHOST_GET_VRING_BASE _IOWR(VHOST_VIRTIO, 0x12, struct vhost_vring_state)
132
133
134
135
136
137
138
139
140
141
142#define VHOST_VRING_LITTLE_ENDIAN 0
143#define VHOST_VRING_BIG_ENDIAN 1
144#define VHOST_SET_VRING_ENDIAN _IOW(VHOST_VIRTIO, 0x13, struct vhost_vring_state)
145#define VHOST_GET_VRING_ENDIAN _IOW(VHOST_VIRTIO, 0x14, struct vhost_vring_state)
146
147
148
149
150
151#define VHOST_SET_VRING_KICK _IOW(VHOST_VIRTIO, 0x20, struct vhost_vring_file)
152
153#define VHOST_SET_VRING_CALL _IOW(VHOST_VIRTIO, 0x21, struct vhost_vring_file)
154
155#define VHOST_SET_VRING_ERR _IOW(VHOST_VIRTIO, 0x22, struct vhost_vring_file)
156
157#define VHOST_SET_VRING_BUSYLOOP_TIMEOUT _IOW(VHOST_VIRTIO, 0x23, \
158 struct vhost_vring_state)
159
160#define VHOST_GET_VRING_BUSYLOOP_TIMEOUT _IOW(VHOST_VIRTIO, 0x24, \
161 struct vhost_vring_state)
162
163
164
165
166
167
168
169#define VHOST_NET_SET_BACKEND _IOW(VHOST_VIRTIO, 0x30, struct vhost_vring_file)
170
171
172
173#define VHOST_F_LOG_ALL 26
174
175#define VHOST_NET_F_VIRTIO_NET_HDR 27
176
177
178
179
180
181
182
183
184
185
186
187
188#define VHOST_SCSI_ABI_VERSION 1
189
190struct vhost_scsi_target {
191 int abi_version;
192 char vhost_wwpn[224];
193 unsigned short vhost_tpgt;
194 unsigned short reserved;
195};
196
197#define VHOST_SCSI_SET_ENDPOINT _IOW(VHOST_VIRTIO, 0x40, struct vhost_scsi_target)
198#define VHOST_SCSI_CLEAR_ENDPOINT _IOW(VHOST_VIRTIO, 0x41, struct vhost_scsi_target)
199
200#define VHOST_SCSI_GET_ABI_VERSION _IOW(VHOST_VIRTIO, 0x42, int)
201
202#define VHOST_SCSI_SET_EVENTS_MISSED _IOW(VHOST_VIRTIO, 0x43, __u32)
203#define VHOST_SCSI_GET_EVENTS_MISSED _IOW(VHOST_VIRTIO, 0x44, __u32)
204
205
206
207#define VHOST_VSOCK_SET_GUEST_CID _IOW(VHOST_VIRTIO, 0x60, __u64)
208#define VHOST_VSOCK_SET_RUNNING _IOW(VHOST_VIRTIO, 0x61, int)
209
210#endif
211