14 #include <sys/eventfd.h>
24 #include <linux/vhost.h>
25 #include <linux/virtio_ring.h>
27 #define RTE_VHOST_USER_CLIENT (1ULL << 0)
28 #define RTE_VHOST_USER_NO_RECONNECT (1ULL << 1)
29 #define RTE_VHOST_USER_DEQUEUE_ZERO_COPY (1ULL << 2)
30 #define RTE_VHOST_USER_IOMMU_SUPPORT (1ULL << 3)
33 #ifndef VHOST_USER_PROTOCOL_F_MQ
34 #define VHOST_USER_PROTOCOL_F_MQ 0
37 #ifndef VHOST_USER_PROTOCOL_F_LOG_SHMFD
38 #define VHOST_USER_PROTOCOL_F_LOG_SHMFD 1
41 #ifndef VHOST_USER_PROTOCOL_F_RARP
42 #define VHOST_USER_PROTOCOL_F_RARP 2
45 #ifndef VHOST_USER_PROTOCOL_F_REPLY_ACK
46 #define VHOST_USER_PROTOCOL_F_REPLY_ACK 3
49 #ifndef VHOST_USER_PROTOCOL_F_NET_MTU
50 #define VHOST_USER_PROTOCOL_F_NET_MTU 4
53 #ifndef VHOST_USER_PROTOCOL_F_SLAVE_REQ
54 #define VHOST_USER_PROTOCOL_F_SLAVE_REQ 5
57 #ifndef VHOST_USER_PROTOCOL_F_CRYPTO_SESSION
58 #define VHOST_USER_PROTOCOL_F_CRYPTO_SESSION 7
62 #ifndef VHOST_USER_F_PROTOCOL_FEATURES
63 #define VHOST_USER_F_PROTOCOL_FEATURES 30
71 uint64_t guest_phys_addr;
72 uint64_t guest_user_addr;
73 uint64_t host_user_addr;
88 struct rte_vhost_vring {
89 struct vring_desc *desc;
90 struct vring_avail *avail;
91 struct vring_used *used;
92 uint64_t log_guest_addr;
118 int (*new_connection)(
int vid);
119 void (*destroy_connection)(
int vid);
146 for (i = 0; i < mem->nregions; i++) {
147 reg = &mem->regions[i];
148 if (gpa >= reg->guest_phys_addr &&
149 gpa < reg->guest_phys_addr + reg->size) {
150 return gpa - reg->guest_phys_addr +
176 uint64_t gpa, uint64_t *len)
181 for (i = 0; i < mem->nregions; i++) {
182 r = &mem->regions[i];
183 if (gpa >= r->guest_phys_addr &&
184 gpa < r->guest_phys_addr + r->size) {
186 if (
unlikely(*len > r->guest_phys_addr + r->size - gpa))
187 *len = r->guest_phys_addr + r->size - gpa;
189 return gpa - r->guest_phys_addr +
198 #define RTE_VHOST_NEED_LOG(features) ((features) & (1ULL << VHOST_F_LOG_ALL))
239 uint64_t offset, uint64_t len);
241 int rte_vhost_enable_guest_notification(
int vid, uint16_t queue_id,
int enable);
250 int rte_vhost_driver_unregister(
const char *path);
262 int __rte_experimental
273 int __rte_experimental
284 int __rte_experimental
352 int __rte_experimental
354 uint64_t *protocol_features);
366 int __rte_experimental
382 int rte_vhost_driver_callback_register(
const char *path,
501 struct rte_mbuf **pkts, uint16_t count);
552 struct rte_vhost_vring *vring);
591 int __rte_experimental
608 int __rte_experimental
610 uint16_t *last_avail_idx, uint16_t *last_used_idx);
626 int __rte_experimental
628 uint16_t last_avail_idx, uint16_t last_used_idx);
638 int __rte_experimental