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
61 #ifndef VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD
62 #define VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD 10
65 #ifndef VHOST_USER_PROTOCOL_F_HOST_NOTIFIER
66 #define VHOST_USER_PROTOCOL_F_HOST_NOTIFIER 11
70 #ifndef VHOST_USER_F_PROTOCOL_FEATURES
71 #define VHOST_USER_F_PROTOCOL_FEATURES 30
79 uint64_t guest_phys_addr;
80 uint64_t guest_user_addr;
81 uint64_t host_user_addr;
96 struct rte_vhost_vring {
97 struct vring_desc *desc;
98 struct vring_avail *avail;
99 struct vring_used *used;
100 uint64_t log_guest_addr;
126 int (*new_connection)(
int vid);
127 void (*destroy_connection)(
int vid);
154 for (i = 0; i < mem->nregions; i++) {
155 reg = &mem->regions[i];
156 if (gpa >= reg->guest_phys_addr &&
157 gpa < reg->guest_phys_addr + reg->size) {
158 return gpa - reg->guest_phys_addr +
184 uint64_t gpa, uint64_t *len)
189 for (i = 0; i < mem->nregions; i++) {
190 r = &mem->regions[i];
191 if (gpa >= r->guest_phys_addr &&
192 gpa < r->guest_phys_addr + r->size) {
194 if (
unlikely(*len > r->guest_phys_addr + r->size - gpa))
195 *len = r->guest_phys_addr + r->size - gpa;
197 return gpa - r->guest_phys_addr +
206 #define RTE_VHOST_NEED_LOG(features) ((features) & (1ULL << VHOST_F_LOG_ALL))
247 uint64_t offset, uint64_t len);
249 int rte_vhost_enable_guest_notification(
int vid, uint16_t queue_id,
int enable);
258 int rte_vhost_driver_unregister(
const char *path);
270 int __rte_experimental
281 int __rte_experimental
292 int __rte_experimental
360 int __rte_experimental
362 uint64_t *protocol_features);
374 int __rte_experimental
390 int rte_vhost_driver_callback_register(
const char *path,
509 struct rte_mbuf **pkts, uint16_t count);
560 struct rte_vhost_vring *vring);
599 int __rte_experimental
616 int __rte_experimental
618 uint16_t *last_avail_idx, uint16_t *last_used_idx);
634 int __rte_experimental
636 uint16_t last_avail_idx, uint16_t last_used_idx);
646 int __rte_experimental