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