]>
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 | ||
2a6a4076 MA |
11 | #ifndef VHOST_BACKEND_H |
12 | #define VHOST_BACKEND_H | |
1be0ac21 | 13 | |
c471ad0e JW |
14 | #include "exec/memory.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 | ||
4c3e257b CL |
23 | typedef enum VhostSetConfigType { |
24 | VHOST_SET_CONFIG_TYPE_MASTER = 0, | |
25 | VHOST_SET_CONFIG_TYPE_MIGRATION = 1, | |
26 | } VhostSetConfigType; | |
27 | ||
5ad204bf | 28 | struct vhost_inflight; |
24d1eb33 | 29 | struct vhost_dev; |
9a78a5dd | 30 | struct vhost_log; |
21e70425 MAL |
31 | struct vhost_memory; |
32 | struct vhost_vring_file; | |
33 | struct vhost_vring_state; | |
34 | struct vhost_vring_addr; | |
35 | struct vhost_scsi_target; | |
020e571b | 36 | struct vhost_iotlb_msg; |
24d1eb33 | 37 | |
24d1eb33 NN |
38 | typedef int (*vhost_backend_init)(struct vhost_dev *dev, void *opaque); |
39 | typedef int (*vhost_backend_cleanup)(struct vhost_dev *dev); | |
2ce68e4c | 40 | typedef int (*vhost_backend_memslots_limit)(struct vhost_dev *dev); |
24d1eb33 | 41 | |
21e70425 MAL |
42 | typedef int (*vhost_net_set_backend_op)(struct vhost_dev *dev, |
43 | struct vhost_vring_file *file); | |
c5f048d8 | 44 | typedef int (*vhost_net_set_mtu_op)(struct vhost_dev *dev, uint16_t mtu); |
21e70425 MAL |
45 | typedef int (*vhost_scsi_set_endpoint_op)(struct vhost_dev *dev, |
46 | struct vhost_scsi_target *target); | |
47 | typedef int (*vhost_scsi_clear_endpoint_op)(struct vhost_dev *dev, | |
48 | struct vhost_scsi_target *target); | |
49 | typedef int (*vhost_scsi_get_abi_version_op)(struct vhost_dev *dev, | |
50 | int *version); | |
9a78a5dd MAL |
51 | typedef int (*vhost_set_log_base_op)(struct vhost_dev *dev, uint64_t base, |
52 | struct vhost_log *log); | |
21e70425 MAL |
53 | typedef int (*vhost_set_mem_table_op)(struct vhost_dev *dev, |
54 | struct vhost_memory *mem); | |
55 | typedef int (*vhost_set_vring_addr_op)(struct vhost_dev *dev, | |
56 | struct vhost_vring_addr *addr); | |
57 | typedef int (*vhost_set_vring_endian_op)(struct vhost_dev *dev, | |
58 | struct vhost_vring_state *ring); | |
59 | typedef int (*vhost_set_vring_num_op)(struct vhost_dev *dev, | |
60 | struct vhost_vring_state *ring); | |
61 | typedef int (*vhost_set_vring_base_op)(struct vhost_dev *dev, | |
62 | struct vhost_vring_state *ring); | |
63 | typedef int (*vhost_get_vring_base_op)(struct vhost_dev *dev, | |
64 | struct vhost_vring_state *ring); | |
65 | typedef int (*vhost_set_vring_kick_op)(struct vhost_dev *dev, | |
66 | struct vhost_vring_file *file); | |
67 | typedef int (*vhost_set_vring_call_op)(struct vhost_dev *dev, | |
68 | struct vhost_vring_file *file); | |
69e87b32 JW |
69 | typedef int (*vhost_set_vring_busyloop_timeout_op)(struct vhost_dev *dev, |
70 | struct vhost_vring_state *r); | |
21e70425 MAL |
71 | typedef int (*vhost_set_features_op)(struct vhost_dev *dev, |
72 | uint64_t features); | |
73 | typedef int (*vhost_get_features_op)(struct vhost_dev *dev, | |
74 | uint64_t *features); | |
75 | typedef int (*vhost_set_owner_op)(struct vhost_dev *dev); | |
76 | typedef int (*vhost_reset_device_op)(struct vhost_dev *dev); | |
77 | typedef int (*vhost_get_vq_index_op)(struct vhost_dev *dev, int idx); | |
78 | typedef int (*vhost_set_vring_enable_op)(struct vhost_dev *dev, | |
79 | int enable); | |
1be0ac21 | 80 | typedef bool (*vhost_requires_shm_log_op)(struct vhost_dev *dev); |
3e866365 TC |
81 | typedef int (*vhost_migration_done_op)(struct vhost_dev *dev, |
82 | char *mac_addr); | |
ffe42cc1 MT |
83 | typedef bool (*vhost_backend_can_merge_op)(struct vhost_dev *dev, |
84 | uint64_t start1, uint64_t size1, | |
85 | uint64_t start2, uint64_t size2); | |
fc0b9b0e SH |
86 | typedef int (*vhost_vsock_set_guest_cid_op)(struct vhost_dev *dev, |
87 | uint64_t guest_cid); | |
88 | typedef int (*vhost_vsock_set_running_op)(struct vhost_dev *dev, int start); | |
c471ad0e JW |
89 | typedef void (*vhost_set_iotlb_callback_op)(struct vhost_dev *dev, |
90 | int enabled); | |
020e571b MC |
91 | typedef int (*vhost_send_device_iotlb_msg_op)(struct vhost_dev *dev, |
92 | struct vhost_iotlb_msg *imsg); | |
4c3e257b CL |
93 | typedef int (*vhost_set_config_op)(struct vhost_dev *dev, const uint8_t *data, |
94 | uint32_t offset, uint32_t size, | |
95 | uint32_t flags); | |
96 | typedef int (*vhost_get_config_op)(struct vhost_dev *dev, uint8_t *config, | |
97 | uint32_t config_len); | |
c2bea314 | 98 | |
efbfeb81 GA |
99 | typedef int (*vhost_crypto_create_session_op)(struct vhost_dev *dev, |
100 | void *session_info, | |
101 | uint64_t *session_id); | |
102 | typedef int (*vhost_crypto_close_session_op)(struct vhost_dev *dev, | |
103 | uint64_t session_id); | |
104 | ||
988a2775 TB |
105 | typedef bool (*vhost_backend_mem_section_filter_op)(struct vhost_dev *dev, |
106 | MemoryRegionSection *section); | |
107 | ||
5ad204bf XY |
108 | typedef int (*vhost_get_inflight_fd_op)(struct vhost_dev *dev, |
109 | uint16_t queue_size, | |
110 | struct vhost_inflight *inflight); | |
111 | ||
112 | typedef int (*vhost_set_inflight_fd_op)(struct vhost_dev *dev, | |
113 | struct vhost_inflight *inflight); | |
114 | ||
24d1eb33 | 115 | typedef struct VhostOps { |
1a1bfac9 | 116 | VhostBackendType backend_type; |
24d1eb33 NN |
117 | vhost_backend_init vhost_backend_init; |
118 | vhost_backend_cleanup vhost_backend_cleanup; | |
2ce68e4c | 119 | vhost_backend_memslots_limit vhost_backend_memslots_limit; |
21e70425 | 120 | vhost_net_set_backend_op vhost_net_set_backend; |
c5f048d8 | 121 | vhost_net_set_mtu_op vhost_net_set_mtu; |
21e70425 MAL |
122 | vhost_scsi_set_endpoint_op vhost_scsi_set_endpoint; |
123 | vhost_scsi_clear_endpoint_op vhost_scsi_clear_endpoint; | |
124 | vhost_scsi_get_abi_version_op vhost_scsi_get_abi_version; | |
c2bea314 | 125 | vhost_set_log_base_op vhost_set_log_base; |
21e70425 MAL |
126 | vhost_set_mem_table_op vhost_set_mem_table; |
127 | vhost_set_vring_addr_op vhost_set_vring_addr; | |
128 | vhost_set_vring_endian_op vhost_set_vring_endian; | |
129 | vhost_set_vring_num_op vhost_set_vring_num; | |
130 | vhost_set_vring_base_op vhost_set_vring_base; | |
131 | vhost_get_vring_base_op vhost_get_vring_base; | |
132 | vhost_set_vring_kick_op vhost_set_vring_kick; | |
133 | vhost_set_vring_call_op vhost_set_vring_call; | |
69e87b32 | 134 | vhost_set_vring_busyloop_timeout_op vhost_set_vring_busyloop_timeout; |
21e70425 MAL |
135 | vhost_set_features_op vhost_set_features; |
136 | vhost_get_features_op vhost_get_features; | |
137 | vhost_set_owner_op vhost_set_owner; | |
138 | vhost_reset_device_op vhost_reset_device; | |
139 | vhost_get_vq_index_op vhost_get_vq_index; | |
140 | vhost_set_vring_enable_op vhost_set_vring_enable; | |
1be0ac21 | 141 | vhost_requires_shm_log_op vhost_requires_shm_log; |
3e866365 | 142 | vhost_migration_done_op vhost_migration_done; |
ffe42cc1 | 143 | vhost_backend_can_merge_op vhost_backend_can_merge; |
fc0b9b0e SH |
144 | vhost_vsock_set_guest_cid_op vhost_vsock_set_guest_cid; |
145 | vhost_vsock_set_running_op vhost_vsock_set_running; | |
c471ad0e | 146 | vhost_set_iotlb_callback_op vhost_set_iotlb_callback; |
020e571b | 147 | vhost_send_device_iotlb_msg_op vhost_send_device_iotlb_msg; |
4c3e257b CL |
148 | vhost_get_config_op vhost_get_config; |
149 | vhost_set_config_op vhost_set_config; | |
efbfeb81 GA |
150 | vhost_crypto_create_session_op vhost_crypto_create_session; |
151 | vhost_crypto_close_session_op vhost_crypto_close_session; | |
988a2775 | 152 | vhost_backend_mem_section_filter_op vhost_backend_mem_section_filter; |
5ad204bf XY |
153 | vhost_get_inflight_fd_op vhost_get_inflight_fd; |
154 | vhost_set_inflight_fd_op vhost_set_inflight_fd; | |
24d1eb33 NN |
155 | } VhostOps; |
156 | ||
0f03fb60 SW |
157 | extern const VhostOps user_ops; |
158 | ||
1a1bfac9 NN |
159 | int vhost_set_backend_type(struct vhost_dev *dev, |
160 | VhostBackendType backend_type); | |
161 | ||
020e571b MC |
162 | int vhost_backend_update_device_iotlb(struct vhost_dev *dev, |
163 | uint64_t iova, uint64_t uaddr, | |
164 | uint64_t len, | |
165 | IOMMUAccessFlags perm); | |
166 | ||
167 | int vhost_backend_invalidate_device_iotlb(struct vhost_dev *dev, | |
168 | uint64_t iova, uint64_t len); | |
169 | ||
170 | int vhost_backend_handle_iotlb_msg(struct vhost_dev *dev, | |
171 | struct vhost_iotlb_msg *imsg); | |
172 | ||
2a6a4076 | 173 | #endif /* VHOST_BACKEND_H */ |