43 #include <sys/eventfd.h>
53 #include <linux/vhost.h>
54 #include <linux/virtio_ring.h>
56 #define RTE_VHOST_USER_CLIENT (1ULL << 0)
57 #define RTE_VHOST_USER_NO_RECONNECT (1ULL << 1)
58 #define RTE_VHOST_USER_DEQUEUE_ZERO_COPY (1ULL << 2)
59 #define RTE_VHOST_USER_IOMMU_SUPPORT (1ULL << 3)
66 uint64_t guest_phys_addr;
67 uint64_t guest_user_addr;
68 uint64_t host_user_addr;
83 struct rte_vhost_vring {
84 struct vring_desc *desc;
85 struct vring_avail *avail;
86 struct vring_used *used;
87 uint64_t log_guest_addr;
111 int (*new_connection)(
int vid);
112 void (*destroy_connection)(
int vid);
139 for (i = 0; i < mem->nregions; i++) {
140 reg = &mem->regions[i];
141 if (gpa >= reg->guest_phys_addr &&
142 gpa < reg->guest_phys_addr + reg->size) {
143 return gpa - reg->guest_phys_addr +
169 uint64_t gpa, uint64_t *len)
174 for (i = 0; i < mem->nregions; i++) {
175 r = &mem->regions[i];
176 if (gpa >= r->guest_phys_addr &&
177 gpa < r->guest_phys_addr + r->size) {
179 if (
unlikely(*len > r->guest_phys_addr + r->size - gpa))
180 *len = r->guest_phys_addr + r->size - gpa;
182 return gpa - r->guest_phys_addr +
191 #define RTE_VHOST_NEED_LOG(features) ((features) & (1ULL << VHOST_F_LOG_ALL))
232 uint64_t offset, uint64_t len);
234 int rte_vhost_enable_guest_notification(
int vid, uint16_t queue_id,
int enable);
243 int rte_vhost_driver_unregister(
const char *path);
313 int rte_vhost_driver_callback_register(
const char *path,
432 struct rte_mbuf **pkts, uint16_t count);
483 struct rte_vhost_vring *vring);
static __rte_deprecated __rte_always_inline uint64_t rte_vhost_gpa_to_vva(struct rte_vhost_memory *mem, uint64_t gpa)
int rte_vhost_driver_start(const char *path)
#define __rte_always_inline
int rte_vhost_driver_register(const char *path, uint64_t flags)
uint16_t rte_vhost_avail_entries(int vid, uint16_t queue_id)
int rte_vhost_driver_disable_features(const char *path, uint64_t features)
void rte_vhost_log_used_vring(int vid, uint16_t vring_idx, uint64_t offset, uint64_t len)
int rte_vhost_get_vhost_vring(int vid, uint16_t vring_idx, struct rte_vhost_vring *vring)
uint16_t rte_vhost_enqueue_burst(int vid, uint16_t queue_id, struct rte_mbuf **pkts, uint16_t count)
__rte_deprecated uint32_t rte_vhost_get_queue_num(int vid)
int rte_vhost_get_mtu(int vid, uint16_t *mtu)
void(* destroy_device)(int vid)
static __rte_always_inline uint64_t rte_vhost_va_from_guest_pa(struct rte_vhost_memory *mem, uint64_t gpa, uint64_t *len)
uint16_t rte_vhost_get_vring_num(int vid)
int rte_vhost_get_numa_node(int vid)
int(* features_changed)(int vid, uint64_t features)
int rte_vhost_get_mem_table(int vid, struct rte_vhost_memory **mem)
int rte_vhost_get_negotiated_features(int vid, uint64_t *features)
uint32_t rte_vhost_rx_queue_count(int vid, uint16_t qid)
int(* new_device)(int vid)
uint16_t rte_vhost_dequeue_burst(int vid, uint16_t queue_id, struct rte_mempool *mbuf_pool, struct rte_mbuf **pkts, uint16_t count)
int rte_vhost_driver_get_features(const char *path, uint64_t *features)
int rte_vhost_driver_set_features(const char *path, uint64_t features)
int(* vring_state_changed)(int vid, uint16_t queue_id, int enable)
int rte_vhost_get_ifname(int vid, char *buf, size_t len)
int rte_vhost_driver_enable_features(const char *path, uint64_t features)
void rte_vhost_log_write(int vid, uint64_t addr, uint64_t len)