Statistics
| Branch: | Revision:

root / hw / vhost.h @ 43ad7e3e

History | View | Annotate | Download (1.2 kB)

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