Michael S. Tsirkin | d597005 | 2010-03-17 13:08:17 +0200 | [diff] [blame] | 1 | #ifndef VHOST_H |
| 2 | #define VHOST_H |
| 3 | |
| 4 | #include "hw/hw.h" |
| 5 | #include "hw/virtio.h" |
| 6 | |
| 7 | /* Generic structures common for any vhost based device. */ |
| 8 | struct vhost_virtqueue { |
| 9 | int kick; |
| 10 | int call; |
| 11 | void *desc; |
| 12 | void *avail; |
| 13 | void *used; |
| 14 | int num; |
| 15 | unsigned long long used_phys; |
| 16 | unsigned used_size; |
| 17 | void *ring; |
| 18 | unsigned long long ring_phys; |
| 19 | unsigned ring_size; |
| 20 | }; |
| 21 | |
| 22 | typedef unsigned long vhost_log_chunk_t; |
| 23 | #define VHOST_LOG_PAGE 0x1000 |
| 24 | #define VHOST_LOG_BITS (8 * sizeof(vhost_log_chunk_t)) |
| 25 | #define VHOST_LOG_CHUNK (VHOST_LOG_PAGE * VHOST_LOG_BITS) |
| 26 | |
| 27 | struct vhost_memory; |
| 28 | struct vhost_dev { |
| 29 | CPUPhysMemoryClient client; |
| 30 | int control; |
| 31 | struct vhost_memory *mem; |
| 32 | struct vhost_virtqueue *vqs; |
| 33 | int nvqs; |
| 34 | unsigned long long features; |
| 35 | unsigned long long acked_features; |
| 36 | unsigned long long backend_features; |
| 37 | bool started; |
| 38 | bool log_enabled; |
| 39 | vhost_log_chunk_t *log; |
| 40 | unsigned long long log_size; |
| 41 | }; |
| 42 | |
| 43 | int vhost_dev_init(struct vhost_dev *hdev, int devfd); |
| 44 | void vhost_dev_cleanup(struct vhost_dev *hdev); |
| 45 | int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev); |
| 46 | void vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev); |
| 47 | |
| 48 | #endif |