]>
Commit | Line | Data |
---|---|---|
d5970055 MT |
1 | #ifndef VHOST_H |
2 | #define VHOST_H | |
3 | ||
4 | #include "hw/hw.h" | |
5 | #include "hw/virtio.h" | |
022c62cb | 6 | #include "exec/memory.h" |
d5970055 MT |
7 | |
8 | /* Generic structures common for any vhost based device. */ | |
9 | struct vhost_virtqueue { | |
10 | int kick; | |
11 | int call; | |
12 | void *desc; | |
13 | void *avail; | |
14 | void *used; | |
15 | int num; | |
16 | unsigned long long used_phys; | |
17 | unsigned used_size; | |
18 | void *ring; | |
19 | unsigned long long ring_phys; | |
20 | unsigned ring_size; | |
f56a1247 | 21 | EventNotifier masked_notifier; |
d5970055 MT |
22 | }; |
23 | ||
24 | typedef unsigned long vhost_log_chunk_t; | |
25 | #define VHOST_LOG_PAGE 0x1000 | |
26 | #define VHOST_LOG_BITS (8 * sizeof(vhost_log_chunk_t)) | |
27 | #define VHOST_LOG_CHUNK (VHOST_LOG_PAGE * VHOST_LOG_BITS) | |
28 | ||
29 | struct vhost_memory; | |
30 | struct vhost_dev { | |
04097f7c | 31 | MemoryListener memory_listener; |
d5970055 MT |
32 | int control; |
33 | struct vhost_memory *mem; | |
2817b260 AK |
34 | int n_mem_sections; |
35 | MemoryRegionSection *mem_sections; | |
d5970055 MT |
36 | struct vhost_virtqueue *vqs; |
37 | int nvqs; | |
a9f98bb5 JW |
38 | /* the first virtuque which would be used by this vhost dev */ |
39 | int vq_index; | |
d5970055 MT |
40 | unsigned long long features; |
41 | unsigned long long acked_features; | |
42 | unsigned long long backend_features; | |
43 | bool started; | |
44 | bool log_enabled; | |
45 | vhost_log_chunk_t *log; | |
46 | unsigned long long log_size; | |
5430a28f | 47 | bool force; |
d5970055 MT |
48 | }; |
49 | ||
1241ed94 SH |
50 | int vhost_dev_init(struct vhost_dev *hdev, int devfd, const char *devpath, |
51 | bool force); | |
d5970055 | 52 | void vhost_dev_cleanup(struct vhost_dev *hdev); |
5430a28f | 53 | bool vhost_dev_query(struct vhost_dev *hdev, VirtIODevice *vdev); |
d5970055 MT |
54 | int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev); |
55 | void vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev); | |
b0b3db79 MT |
56 | int vhost_dev_enable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev); |
57 | void vhost_dev_disable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev); | |
d5970055 | 58 | |
f56a1247 MT |
59 | /* Test and clear masked event pending status. |
60 | * Should be called after unmask to avoid losing events. | |
61 | */ | |
62 | bool vhost_virtqueue_pending(struct vhost_dev *hdev, int n); | |
63 | ||
64 | /* Mask/unmask events from this vq. | |
65 | */ | |
66 | void vhost_virtqueue_mask(struct vhost_dev *hdev, VirtIODevice *vdev, int n, | |
67 | bool mask); | |
d5970055 | 68 | #endif |