]>
Commit | Line | Data |
---|---|---|
24d1eb33 NN |
1 | /* |
2 | * vhost-backend | |
3 | * | |
4 | * Copyright (c) 2013 Virtual Open Systems Sarl. | |
5 | * | |
6 | * This work is licensed under the terms of the GNU GPL, version 2 or later. | |
7 | * See the COPYING file in the top-level directory. | |
8 | * | |
9 | */ | |
10 | ||
11 | #ifndef VHOST_BACKEND_H_ | |
12 | #define VHOST_BACKEND_H_ | |
13 | ||
1be0ac21 MAL |
14 | #include <stdbool.h> |
15 | ||
1a1bfac9 NN |
16 | typedef enum VhostBackendType { |
17 | VHOST_BACKEND_TYPE_NONE = 0, | |
18 | VHOST_BACKEND_TYPE_KERNEL = 1, | |
19 | VHOST_BACKEND_TYPE_USER = 2, | |
20 | VHOST_BACKEND_TYPE_MAX = 3, | |
21 | } VhostBackendType; | |
22 | ||
24d1eb33 | 23 | struct vhost_dev; |
9a78a5dd | 24 | struct vhost_log; |
21e70425 MAL |
25 | struct vhost_memory; |
26 | struct vhost_vring_file; | |
27 | struct vhost_vring_state; | |
28 | struct vhost_vring_addr; | |
29 | struct vhost_scsi_target; | |
24d1eb33 | 30 | |
24d1eb33 NN |
31 | typedef int (*vhost_backend_init)(struct vhost_dev *dev, void *opaque); |
32 | typedef int (*vhost_backend_cleanup)(struct vhost_dev *dev); | |
2ce68e4c | 33 | typedef int (*vhost_backend_memslots_limit)(struct vhost_dev *dev); |
24d1eb33 | 34 | |
21e70425 MAL |
35 | typedef int (*vhost_net_set_backend_op)(struct vhost_dev *dev, |
36 | struct vhost_vring_file *file); | |
37 | typedef int (*vhost_scsi_set_endpoint_op)(struct vhost_dev *dev, | |
38 | struct vhost_scsi_target *target); | |
39 | typedef int (*vhost_scsi_clear_endpoint_op)(struct vhost_dev *dev, | |
40 | struct vhost_scsi_target *target); | |
41 | typedef int (*vhost_scsi_get_abi_version_op)(struct vhost_dev *dev, | |
42 | int *version); | |
9a78a5dd MAL |
43 | typedef int (*vhost_set_log_base_op)(struct vhost_dev *dev, uint64_t base, |
44 | struct vhost_log *log); | |
21e70425 MAL |
45 | typedef int (*vhost_set_mem_table_op)(struct vhost_dev *dev, |
46 | struct vhost_memory *mem); | |
47 | typedef int (*vhost_set_vring_addr_op)(struct vhost_dev *dev, | |
48 | struct vhost_vring_addr *addr); | |
49 | typedef int (*vhost_set_vring_endian_op)(struct vhost_dev *dev, | |
50 | struct vhost_vring_state *ring); | |
51 | typedef int (*vhost_set_vring_num_op)(struct vhost_dev *dev, | |
52 | struct vhost_vring_state *ring); | |
53 | typedef int (*vhost_set_vring_base_op)(struct vhost_dev *dev, | |
54 | struct vhost_vring_state *ring); | |
55 | typedef int (*vhost_get_vring_base_op)(struct vhost_dev *dev, | |
56 | struct vhost_vring_state *ring); | |
57 | typedef int (*vhost_set_vring_kick_op)(struct vhost_dev *dev, | |
58 | struct vhost_vring_file *file); | |
59 | typedef int (*vhost_set_vring_call_op)(struct vhost_dev *dev, | |
60 | struct vhost_vring_file *file); | |
61 | typedef int (*vhost_set_features_op)(struct vhost_dev *dev, | |
62 | uint64_t features); | |
63 | typedef int (*vhost_get_features_op)(struct vhost_dev *dev, | |
64 | uint64_t *features); | |
65 | typedef int (*vhost_set_owner_op)(struct vhost_dev *dev); | |
66 | typedef int (*vhost_reset_device_op)(struct vhost_dev *dev); | |
67 | typedef int (*vhost_get_vq_index_op)(struct vhost_dev *dev, int idx); | |
68 | typedef int (*vhost_set_vring_enable_op)(struct vhost_dev *dev, | |
69 | int enable); | |
1be0ac21 | 70 | typedef bool (*vhost_requires_shm_log_op)(struct vhost_dev *dev); |
c2bea314 | 71 | |
24d1eb33 | 72 | typedef struct VhostOps { |
1a1bfac9 | 73 | VhostBackendType backend_type; |
24d1eb33 NN |
74 | vhost_backend_init vhost_backend_init; |
75 | vhost_backend_cleanup vhost_backend_cleanup; | |
2ce68e4c | 76 | vhost_backend_memslots_limit vhost_backend_memslots_limit; |
21e70425 MAL |
77 | vhost_net_set_backend_op vhost_net_set_backend; |
78 | vhost_scsi_set_endpoint_op vhost_scsi_set_endpoint; | |
79 | vhost_scsi_clear_endpoint_op vhost_scsi_clear_endpoint; | |
80 | vhost_scsi_get_abi_version_op vhost_scsi_get_abi_version; | |
c2bea314 | 81 | vhost_set_log_base_op vhost_set_log_base; |
21e70425 MAL |
82 | vhost_set_mem_table_op vhost_set_mem_table; |
83 | vhost_set_vring_addr_op vhost_set_vring_addr; | |
84 | vhost_set_vring_endian_op vhost_set_vring_endian; | |
85 | vhost_set_vring_num_op vhost_set_vring_num; | |
86 | vhost_set_vring_base_op vhost_set_vring_base; | |
87 | vhost_get_vring_base_op vhost_get_vring_base; | |
88 | vhost_set_vring_kick_op vhost_set_vring_kick; | |
89 | vhost_set_vring_call_op vhost_set_vring_call; | |
90 | vhost_set_features_op vhost_set_features; | |
91 | vhost_get_features_op vhost_get_features; | |
92 | vhost_set_owner_op vhost_set_owner; | |
93 | vhost_reset_device_op vhost_reset_device; | |
94 | vhost_get_vq_index_op vhost_get_vq_index; | |
95 | vhost_set_vring_enable_op vhost_set_vring_enable; | |
1be0ac21 | 96 | vhost_requires_shm_log_op vhost_requires_shm_log; |
24d1eb33 NN |
97 | } VhostOps; |
98 | ||
0f03fb60 SW |
99 | extern const VhostOps user_ops; |
100 | ||
1a1bfac9 NN |
101 | int vhost_set_backend_type(struct vhost_dev *dev, |
102 | VhostBackendType backend_type); | |
103 | ||
24d1eb33 | 104 | #endif /* VHOST_BACKEND_H_ */ |