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)
31 #define RTE_VHOST_USER_POSTCOPY_SUPPORT (1ULL << 4)
34 #ifndef VHOST_USER_PROTOCOL_F_MQ
35 #define VHOST_USER_PROTOCOL_F_MQ 0
38 #ifndef VHOST_USER_PROTOCOL_F_LOG_SHMFD
39 #define VHOST_USER_PROTOCOL_F_LOG_SHMFD 1
42 #ifndef VHOST_USER_PROTOCOL_F_RARP
43 #define VHOST_USER_PROTOCOL_F_RARP 2
46 #ifndef VHOST_USER_PROTOCOL_F_REPLY_ACK
47 #define VHOST_USER_PROTOCOL_F_REPLY_ACK 3
50 #ifndef VHOST_USER_PROTOCOL_F_NET_MTU
51 #define VHOST_USER_PROTOCOL_F_NET_MTU 4
54 #ifndef VHOST_USER_PROTOCOL_F_SLAVE_REQ
55 #define VHOST_USER_PROTOCOL_F_SLAVE_REQ 5
58 #ifndef VHOST_USER_PROTOCOL_F_CRYPTO_SESSION
59 #define VHOST_USER_PROTOCOL_F_CRYPTO_SESSION 7
62 #ifndef VHOST_USER_PROTOCOL_F_PAGEFAULT
63 #define VHOST_USER_PROTOCOL_F_PAGEFAULT 8
66 #ifndef VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD
67 #define VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD 10
70 #ifndef VHOST_USER_PROTOCOL_F_HOST_NOTIFIER
71 #define VHOST_USER_PROTOCOL_F_HOST_NOTIFIER 11
75 #ifndef VHOST_USER_F_PROTOCOL_FEATURES
76 #define VHOST_USER_F_PROTOCOL_FEATURES 30
84 uint64_t guest_phys_addr;
85 uint64_t guest_user_addr;
86 uint64_t host_user_addr;
101 struct rte_vhost_vring {
102 struct vring_desc *desc;
103 struct vring_avail *avail;
104 struct vring_used *used;
105 uint64_t log_guest_addr;
131 int (*new_connection)(
int vid);
132 void (*destroy_connection)(
int vid);
159 for (i = 0; i < mem->nregions; i++) {
160 reg = &mem->regions[i];
161 if (gpa >= reg->guest_phys_addr &&
162 gpa < reg->guest_phys_addr + reg->size) {
163 return gpa - reg->guest_phys_addr +
189 uint64_t gpa, uint64_t *len)
194 for (i = 0; i < mem->nregions; i++) {
195 r = &mem->regions[i];
196 if (gpa >= r->guest_phys_addr &&
197 gpa < r->guest_phys_addr + r->size) {
199 if (
unlikely(*len > r->guest_phys_addr + r->size - gpa))
200 *len = r->guest_phys_addr + r->size - gpa;
202 return gpa - r->guest_phys_addr +
211 #define RTE_VHOST_NEED_LOG(features) ((features) & (1ULL << VHOST_F_LOG_ALL))
252 uint64_t offset, uint64_t len);
254 int rte_vhost_enable_guest_notification(
int vid, uint16_t queue_id,
int enable);
263 int rte_vhost_driver_unregister(
const char *path);
275 int __rte_experimental
286 int __rte_experimental
297 int __rte_experimental
365 int __rte_experimental
367 uint64_t *protocol_features);
379 int __rte_experimental
395 int rte_vhost_driver_callback_register(
const char *path,
514 struct rte_mbuf **pkts, uint16_t count);
565 struct rte_vhost_vring *vring);
604 int __rte_experimental
621 int __rte_experimental
623 uint16_t *last_avail_idx, uint16_t *last_used_idx);
639 int __rte_experimental
641 uint16_t last_avail_idx, uint16_t last_used_idx);
651 int __rte_experimental