vhost: generic vhost API
PATCH v4 8/22 vhost: export API to translate gpa to vva
In reply to Yuanhan Liu--- lib/librte_vhost/rte_vhost_version.map | 1 + lib/librte_vhost/rte_virtio_net.h | 28 ++++++++++++++++++++++++++++ lib/librte_vhost/vhost.h | 19 ------------------- lib/librte_vhost/virtio_net.c | 23 +++++++++++++---------- 4 files changed, 42 insertions(+), 29 deletions(-)
lib/librte_vhost/rte_vhost_version.map +1 -0
@@ -39,5 +39,6 @@ DPDK_17.05 { rte_vhost_get_mtu; rte_vhost_get_negotiated_features; rte_vhost_get_vhost_vring; + rte_vhost_gpa_to_vva; } DPDK_16.07;
lib/librte_vhost/rte_virtio_net.h +28 -0
@@ -103,6 +103,34 @@ struct virtio_net_device_ops {void *reserved[5 ];/**< Reserved for future extension */ }; +/** +* Convert guest physical address to host virtual address +* +* @param mem +* the guest memory regions +* @param gpa +* the guest physical address for querying +* @return +* the host virtual address on success, 0 on failure +*/ +static inline uint64_t __attribute__((always_inline)) +rte_vhost_gpa_to_vva (struct rte_vhost_memory *mem,uint64_t gpa) +{ +struct rte_vhost_mem_region *reg; +uint32_t i; + +for (i =0 ; i < mem->nregions; i++) { + reg = &mem->regions[i]; +if (gpa >= reg->guest_phys_addr && + gpa < reg->guest_phys_addr + reg->size) { +return gpa - reg->guest_phys_addr + + reg->host_user_addr; + } + } + +return 0 ; +} +int rte_vhost_enable_guest_notification (int vid,uint16_t queue_id,int enable);/**
lib/librte_vhost/vhost.h +0 -19
@@ -229,25 +229,6 @@ struct virtio_net {#define MAX_VHOST_DEVICE 1024extern struct virtio_net *vhost_devices[MAX_VHOST_DEVICE ]; -/* Convert guest physical Address to host virtual address */ -static inline uint64_t __attribute__((always_inline)) -gpa_to_vva (struct virtio_net *dev,uint64_t gpa) -{ -struct rte_vhost_mem_region *reg; -uint32_t i; - -for (i =0 ; i < dev->mem->nregions; i++) { - reg = &dev->mem->regions[i]; -if (gpa >= reg->guest_phys_addr && - gpa < reg->guest_phys_addr + reg->size) { -return gpa - reg->guest_phys_addr + - reg->host_user_addr; - } - } - -return 0 ; -} -/* Convert guest physical address to host physical address */ static inline phys_addr_t __attribute__((always_inline))gpa_to_hpa (struct virtio_net *dev,uint64_t gpa,uint64_t size)
lib/librte_vhost/virtio_net.c +13 -10
@@ -199,7 +199,7 @@ static inline int __attribute__((always_inline))uint16_t nr_desc =1 ; desc = &descs[desc_idx]; - desc_addr =gpa_to_vva (dev, desc->addr); + desc_addr =rte_vhost_gpa_to_vva (dev->mem, desc->addr);/* * Checking of 'desc_addr' placed outside of 'unlikely' macro to avoid * performance issue with some versions of gcc (4.8.4 and 5.3.0) which
@@ -239,7 +239,7 @@ static inline int __attribute__((always_inline))return -1 ; desc = &descs[desc->next]; - desc_addr =gpa_to_vva (dev, desc->addr); + desc_addr =rte_vhost_gpa_to_vva (dev->mem, desc->addr);if (unlikely (!desc_addr))return -1 ;
@@ -323,7 +323,8 @@ static inline uint32_t __attribute__((always_inline))int err;if (vq->desc[desc_idx].flags &VRING_DESC_F_INDIRECT ) { - descs = (struct vring_desc *)(uintptr_t )gpa_to_vva (dev, + descs = (struct vring_desc *)(uintptr_t ) +rte_vhost_gpa_to_vva (dev->mem, vq->desc[desc_idx].addr);if (unlikely (!descs)) { count = i;
@@ -383,7 +384,7 @@ static inline int __attribute__((always_inline))if (vq->desc[idx].flags &VRING_DESC_F_INDIRECT ) { descs = (struct vring_desc *)(uintptr_t ) -gpa_to_vva (dev, vq->desc[idx].addr); +rte_vhost_gpa_to_vva (dev->mem, vq->desc[idx].addr);if (unlikely (!descs))return -1 ;
@@ -473,7 +474,7 @@ static inline int __attribute__((always_inline))if (unlikely (m ==NULL ))return -1 ; - desc_addr =gpa_to_vva (dev, buf_vec[vec_idx].buf_addr); + desc_addr =rte_vhost_gpa_to_vva (dev->mem, buf_vec[vec_idx].buf_addr);if (buf_vec[vec_idx].buf_len < dev->vhost_hlen || !desc_addr)return -1 ;
@@ -495,7 +496,8 @@ static inline int __attribute__((always_inline))/* done with current desc buf, get the next one */ if (desc_avail ==0 ) { vec_idx++; - desc_addr =gpa_to_vva (dev, buf_vec[vec_idx].buf_addr); + desc_addr =rte_vhost_gpa_to_vva (dev->mem, + buf_vec[vec_idx].buf_addr);if (unlikely (!desc_addr))return -1 ;
@@ -798,7 +800,7 @@ static inline int __attribute__((always_inline)) (desc->flags & VRING_DESC_F_INDIRECT))return -1 ; - desc_addr =gpa_to_vva (dev, desc->addr); + desc_addr =rte_vhost_gpa_to_vva (dev->mem, desc->addr);if (unlikely (!desc_addr))return -1 ;
@@ -818,7 +820,7 @@ static inline int __attribute__((always_inline))if (unlikely (desc->flags &VRING_DESC_F_INDIRECT ))return -1 ; - desc_addr =gpa_to_vva (dev, desc->addr); + desc_addr =rte_vhost_gpa_to_vva (dev->mem, desc->addr);if (unlikely (!desc_addr))return -1 ;
@@ -882,7 +884,7 @@ static inline int __attribute__((always_inline))if (unlikely (desc->flags &VRING_DESC_F_INDIRECT ))return -1 ; - desc_addr =gpa_to_vva (dev, desc->addr); + desc_addr =rte_vhost_gpa_to_vva (dev->mem, desc->addr);if (unlikely (!desc_addr))return -1 ;
@@ -1125,7 +1127,8 @@ static inline bool __attribute__((always_inline))rte_prefetch0 (&vq->desc[desc_indexes[i +1 ]]);if (vq->desc[desc_indexes[i]].flags &VRING_DESC_F_INDIRECT ) { - desc = (struct vring_desc *)(uintptr_t )gpa_to_vva (dev, + desc = (struct vring_desc *)(uintptr_t ) +rte_vhost_gpa_to_vva (dev->mem, vq->desc[desc_indexes[i]].addr);if (unlikely (!desc))break ;
Signature · 1 line
1.9.0
PATCH v4 9/22 vhost: turn queue pair to vring
In reply to Yuanhan LiuThe queue pair is very virtio-net specific, other devices don't have such concept. To make it generic, we should log the number of vrings instead of the number of queue pairs.
This patch just does a simple convert, a later patch would export the number of vrings to applications.
---
v2: enable all vrings by unconditionally
--- lib/librte_vhost/vhost.c | 80 +++++++++++++++---------------------------- lib/librte_vhost/vhost.h | 4 +-- lib/librte_vhost/vhost_user.c | 28 +++++---------- lib/librte_vhost/virtio_net.c | 10 +++--- 4 files changed, 42 insertions(+), 80 deletions(-)
lib/librte_vhost/vhost.c +27 -53
@@ -84,10 +84,8 @@ struct virtio_net *vhost_backend_cleanup (dev); -for (i =0 ; i < dev->virt_qp_nb; i++) { -cleanup_vq (dev->virtqueue[i *VIRTIO_QNUM +VIRTIO_RXQ ], destroy); -cleanup_vq (dev->virtqueue[i *VIRTIO_QNUM +VIRTIO_TXQ ], destroy); - } +for (i =0 ; i < dev->nr_vring; i++) +cleanup_vq (dev->virtqueue[i], destroy); }/*
@@ -97,24 +95,21 @@ struct virtio_net * free_device(struct virtio_net *dev) {uint32_t i; -struct vhost_virtqueue *rxq, *txq; +struct vhost_virtqueue *vq; -for (i =0 ; i < dev->virt_qp_nb; i++) { - rxq = dev->virtqueue[i *VIRTIO_QNUM +VIRTIO_RXQ ]; - txq = dev->virtqueue[i *VIRTIO_QNUM +VIRTIO_TXQ ]; +for (i =0 ; i < dev->nr_vring; i++) { + vq = dev->virtqueue[i]; -rte_free (rxq->shadow_used_ring); -rte_free (txq->shadow_used_ring); +rte_free (vq->shadow_used_ring); -/* rxq and txq are allocated together as queue-pair */ -rte_free (rxq); +rte_free (vq); }rte_free (dev); }static void -init_vring_queue (struct vhost_virtqueue *vq,int qp_idx) +init_vring_queue (struct vhost_virtqueue *vq) {memset (vq,0 ,sizeof (struct vhost_virtqueue ));
@@ -124,69 +119,48 @@ struct virtio_net */* Backends are set to -1 indicating an inactive device. */ vq->backend =-1 ; -/* always set the default vq pair to enabled */ -if (qp_idx ==0 ) - vq->enabled =1 ; +/* +* always set the vq to enabled; this is to keep compatibility +* with the old QEMU, whereas there is no SET_VRING_ENABLE message. +*/ + vq->enabled =1 ;TAILQ_INIT (&vq->zmbuf_list); }static void -init_vring_queue_pair (struct virtio_net *dev,uint32_t qp_idx) -{ -uint32_t base_idx = qp_idx *VIRTIO_QNUM ; - -init_vring_queue (dev->virtqueue[base_idx +VIRTIO_RXQ ], qp_idx); -init_vring_queue (dev->virtqueue[base_idx +VIRTIO_TXQ ], qp_idx); -} - -static void -reset_vring_queue (struct vhost_virtqueue *vq,int qp_idx) +reset_vring_queue (struct vhost_virtqueue *vq) {int callfd; callfd = vq->callfd; -init_vring_queue (vq, qp_idx); +init_vring_queue (vq); vq->callfd = callfd; } -static void -reset_vring_queue_pair (struct virtio_net *dev,uint32_t qp_idx) -{ -uint32_t base_idx = qp_idx *VIRTIO_QNUM ; - -reset_vring_queue (dev->virtqueue[base_idx +VIRTIO_RXQ ], qp_idx); -reset_vring_queue (dev->virtqueue[base_idx +VIRTIO_TXQ ], qp_idx); -} -int -alloc_vring_queue_pair (struct virtio_net *dev,uint32_t qp_idx) +alloc_vring_queue (struct virtio_net *dev,uint32_t vring_idx) { -struct vhost_virtqueue *virtqueue =NULL ; -uint32_t virt_rx_q_idx = qp_idx *VIRTIO_QNUM +VIRTIO_RXQ ; -uint32_t virt_tx_q_idx = qp_idx *VIRTIO_QNUM +VIRTIO_TXQ ; +struct vhost_virtqueue *vq; - virtqueue =rte_malloc (NULL , -sizeof (struct vhost_virtqueue ) *VIRTIO_QNUM ,0 ); -if (virtqueue ==NULL ) { + vq =rte_malloc (NULL ,sizeof (struct vhost_virtqueue ),0 ); +if (vq ==NULL ) {RTE_LOG (ERR ,VHOST_CONFIG , -"Failed to allocate memory for virt qp:%d.\n" , qp_idx); +"Failed to allocate memory for vring:%u.\n" , vring_idx);return -1 ; } - dev->virtqueue[virt_rx_q_idx] = virtqueue; - dev->virtqueue[virt_tx_q_idx] = virtqueue +VIRTIO_TXQ ; - -init_vring_queue_pair (dev, qp_idx); + dev->virtqueue[vring_idx] = vq; +init_vring_queue (vq); - dev->virt_qp_nb +=1 ; + dev->nr_vring +=1 ;return 0 ; }/* * Reset some variables in device structure, while keeping few -* others untouched, such as vid, ifname, virt_qp_nb: they +* others untouched, such as vid, ifname, nr_vring: they * should be same unless the device is removed. */ void
@@ -198,8 +172,8 @@ struct virtio_net * dev->protocol_features =0 ; dev->flags =0 ; -for (i =0 ; i < dev->virt_qp_nb; i++) -reset_vring_queue_pair (dev, i); +for (i =0 ; i < dev->nr_vring; i++) +reset_vring_queue (dev->virtqueue[i]); }/*
@@ -340,7 +314,7 @@ struct virtio_net *if (dev ==NULL )return 0 ; -return dev->virt_qp_nb; +return dev->nr_vring /2 ; }int
lib/librte_vhost/vhost.h +2 -2
@@ -176,7 +176,7 @@ struct virtio_net {uint16_t vhost_hlen;/* to tell if we need broadcast rarp packet */ rte_atomic16_t broadcast_rarp; -uint32_t virt_qp_nb; +uint32_t nr_vring;int dequeue_zero_copy;struct vhost_virtqueue *virtqueue[VHOST_MAX_QUEUE_PAIRS *2 ];#define IF_NAME_SZ (PATH_MAX > IFNAMSIZ ? PATH_MAX : IFNAMSIZ)
@@ -256,7 +256,7 @@ static inline phys_addr_t __attribute__((always_inline))void reset_device (struct virtio_net *dev);void vhost_destroy_device (int ); -int alloc_vring_queue_pair (struct virtio_net *dev,uint32_t qp_idx); +int alloc_vring_queue (struct virtio_net *dev,uint32_t vring_idx);void vhost_set_ifname (int ,const char *if_name,unsigned int if_len);void vhost_enable_dequeue_zero_copy (int vid);
lib/librte_vhost/vhost_user.c +8 -20
@@ -233,13 +233,6 @@struct vhost_virtqueue *old_vq, *vq;int ret; -/* -* vq is allocated on pairs, we should try to do realloc -* on first queue of one queue pair only. -*/ -if (index %VIRTIO_QNUM !=0 ) -return dev; - old_dev = dev; vq = old_vq = dev->virtqueue[index];
@@ -257,8 +250,7 @@if (oldnode != newnode) {RTE_LOG (INFO ,VHOST_CONFIG ,"reallocate vq from %d to %d node\n" , oldnode, newnode); - vq =rte_malloc_socket (NULL ,sizeof (*vq) *VIRTIO_QNUM ,0 , - newnode); + vq =rte_malloc_socket (NULL ,sizeof (*vq),0 , newnode);if (!vq)return dev;
@@ -290,7 +282,6 @@ out: dev->virtqueue[index] = vq; - dev->virtqueue[index +1 ] = vq +1 ; vhost_devices[dev->vid] = dev;return dev;
@@ -621,14 +612,13 @@static int virtio_is_ready (struct virtio_net *dev) { -struct vhost_virtqueue *rvq, *tvq; +struct vhost_virtqueue *vq;uint32_t i; -for (i =0 ; i < dev->virt_qp_nb; i++) { - rvq = dev->virtqueue[i *VIRTIO_QNUM +VIRTIO_RXQ ]; - tvq = dev->virtqueue[i *VIRTIO_QNUM +VIRTIO_TXQ ]; +for (i =0 ; i < dev->nr_vring; i++) { + vq = dev->virtqueue[i]; -if (!vq_is_ready (rvq) || !vq_is_ready (tvq)) { +if (!vq_is_ready (vq)) {RTE_LOG (INFO ,VHOST_CONFIG ,"virtio is not ready for processing.\n" );return 0 ;
@@ -940,7 +930,6 @@ vhost_user_check_and_alloc_queue_pair(struct virtio_net *dev, VhostUserMsg *msg) { uint16_t vring_idx; -uint16_t qp_idx;switch (msg->request) {case VHOST_USER_SET_VRING_KICK :
@@ -960,17 +949,16 @@return 0 ; } - qp_idx = vring_idx /VIRTIO_QNUM ; -if (qp_idx >=VHOST_MAX_QUEUE_PAIRS ) { +if (vring_idx >=VHOST_MAX_VRING ) {RTE_LOG (ERR ,VHOST_CONFIG ,"invalid vring index: %u\n" , vring_idx);return -1 ; } -if (dev->virtqueue[qp_idx]) +if (dev->virtqueue[vring_idx])return 0 ; -return alloc_vring_queue_pair (dev, qp_idx); +return alloc_vring_queue (dev, vring_idx); }int
lib/librte_vhost/virtio_net.c +5 -5
@@ -86,9 +86,9 @@ static inline void __attribute__((always_inline)) }static bool -is_valid_virt_queue_idx (uint32_t idx,int is_tx,uint32_t qp_nb) +is_valid_virt_queue_idx (uint32_t idx,int is_tx,uint32_t nr_vring) { -return (is_tx ^ (idx &1 )) ==0 && idx < qp_nb *VIRTIO_QNUM ; +return (is_tx ^ (idx &1 )) ==0 && idx < nr_vring; } static inline void __attribute__((always_inline))
@@ -283,7 +283,7 @@ static inline uint32_t __attribute__((always_inline))uint32_t i, sz;LOG_DEBUG (VHOST_DATA ,"(%d) %s\n" , dev->vid, __func__); -if (unlikely (!is_valid_virt_queue_idx (queue_id,0 , dev->virt_qp_nb))) { +if (unlikely (!is_valid_virt_queue_idx (queue_id,0 , dev->nr_vring))) {RTE_LOG (ERR ,VHOST_DATA ,"(%d) %s: invalid virtqueue idx %d.\n" , dev->vid, __func__, queue_id);return 0 ;
@@ -554,7 +554,7 @@ static inline uint32_t __attribute__((always_inline))uint16_t avail_head;LOG_DEBUG (VHOST_DATA ,"(%d) %s\n" , dev->vid, __func__); -if (unlikely (!is_valid_virt_queue_idx (queue_id,0 , dev->virt_qp_nb))) { +if (unlikely (!is_valid_virt_queue_idx (queue_id,0 , dev->nr_vring))) {RTE_LOG (ERR ,VHOST_DATA ,"(%d) %s: invalid virtqueue idx %d.\n" , dev->vid, __func__, queue_id);return 0 ;
@@ -1019,7 +1019,7 @@ static inline bool __attribute__((always_inline))if (!dev)return 0 ; -if (unlikely (!is_valid_virt_queue_idx (queue_id,1 , dev->virt_qp_nb))) { +if (unlikely (!is_valid_virt_queue_idx (queue_id,1 , dev->nr_vring))) {RTE_LOG (ERR ,VHOST_DATA ,"(%d) %s: invalid virtqueue idx %d.\n" , dev->vid, __func__, queue_id);return 0 ;
Signature · 1 line
1.9.0
PATCH v4 10/22 vhost: export the number of vrings
In reply to Yuanhan LiuWe used to use rte_vhost_get_queue_num() for telling how many vrings. However, the return value is the number of "queue pairs", which is very virtio-net specific. To make it generic, we should return the number of vrings instead, and let the driver do the proper translation. Say, virtio-net driver could turn it to the number of queue pairs by dividing 2.
Meanwhile, mark rte_vhost_get_queue_num as deprecated.
---
v2: - update release note
--- doc/guides/rel_notes/release_17_05.rst | 3 +++ drivers/net/vhost/rte_eth_vhost.c | 2 +- lib/librte_vhost/rte_vhost_version.map | 1 + lib/librte_vhost/rte_virtio_net.h | 17 +++++++++++++++++ lib/librte_vhost/vhost.c | 11 +++++++++++ 5 files changed, 33 insertions(+), 1 deletion(-)
doc/guides/rel_notes/release_17_05.rst +3 -0
@@ -208,6 +208,9 @@ API Changes be per vhost-user socket file. Thus, it takes one more argument: ``rte_vhost_driver_callback_register(path, ops)``. + * The vhost API ``rte_vhost_get_queue_num`` is deprecated, instead, + ``rte_vhost_get_vring_num`` should be used. + ABI Changes -----------
drivers/net/vhost/rte_eth_vhost.c +1 -1
@@ -569,7 +569,7 @@ struct vhost_xstats_name_off { vq->port = eth_dev->data->port_id; } -for (i =0 ; i <rte_vhost_get_queue_num (vid) *VIRTIO_QNUM ; i++) +for (i =0 ; i <rte_vhost_get_vring_num (vid); i++)rte_vhost_enable_guest_notification (vid, i,0 );rte_vhost_get_mtu (vid, ð_dev->data->mtu);
lib/librte_vhost/rte_vhost_version.map +1 -0
@@ -39,6 +39,7 @@ DPDK_17.05 { rte_vhost_get_mtu; rte_vhost_get_negotiated_features; rte_vhost_get_vhost_vring; + rte_vhost_get_vring_num; rte_vhost_gpa_to_vva; } DPDK_16.07;
lib/librte_vhost/rte_virtio_net.h +17 -0
@@ -241,17 +241,34 @@ int rte_vhost_driver_callback_register(const char *path,int rte_vhost_get_numa_node (int vid);/** +* @deprecated * Get the number of queues the device supports. * +* Note this function is deprecated, as it returns a queue pair number, +* which is virtio-net specific. Instead, rte_vhost_get_vring_num should +* be used. +* * @param vid * virtio-net device ID * * @return * The number of queues, 0 on failure */ +__rte_deprecated uint32_t rte_vhost_get_queue_num(int vid);/** +* Get the number of vrings the device supports. +* +* @param vid +* vhost device ID +* +* @return +* The number of vrings, 0 on failure +*/ +uint16_t rte_vhost_get_vring_num (int vid); + +/** * Get the virtio net device's ifname, which is the vhost-user socket * file path. *
lib/librte_vhost/vhost.c +11 -0
@@ -317,6 +317,17 @@ struct virtio_net *return dev->nr_vring /2 ; } +uint16_t +rte_vhost_get_vring_num (int vid) +{ +struct virtio_net *dev =get_device (vid); + +if (dev ==NULL ) +return 0 ; + +return dev->nr_vring; +} +int rte_vhost_get_ifname (int vid,char *buf,size_t len) {
Signature · 1 line
1.9.0
PATCH v4 11/22 vhost: move the device ready check at proper place
In reply to Yuanhan LiuCurrently, we check vq->desc, vq->kickfd and vq->callfd to know whether a virtio device is ready or not. However, we only do it when handling SET_VRING_KICK message, which could be wrong if a vhost-user frontend send SET_VRING_KICK first and SET_VRING_CALL later.
To work for all possible vhost-user frontend implementations, we could move the ready check at the end of vhost-user message handler.
Meanwhile, since we do the check more often than before, the "virtio not ready" message is dropped, to not flood the screen.
--- lib/librte_vhost/vhost_user.c | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-)
lib/librte_vhost/vhost_user.c +18 -22
@@ -615,14 +615,14 @@struct vhost_virtqueue *vq;uint32_t i; +if (dev->nr_vring ==0 ) +return 0 ; +for (i =0 ; i < dev->nr_vring; i++) { vq = dev->virtqueue[i]; -if (!vq_is_ready (vq)) { -RTE_LOG (INFO ,VHOST_CONFIG , -"virtio is not ready for processing.\n" ); +if (!vq_is_ready (vq))return 0 ; - } } RTE_LOG(INFO, VHOST_CONFIG,
@@ -651,10 +651,6 @@ vq->callfd = file.fd; } -/* -* In vhost-user, when we receive kick message, will test whether virtio -* device is ready for packet processing. -*/ static void vhost_user_set_vring_kick (struct virtio_net *dev,struct VhostUserMsg *pmsg) {
@@ -673,20 +669,6 @@if (vq->kickfd >=0 )close (vq->kickfd); vq->kickfd = file.fd; - -if (virtio_is_ready (dev)) { - dev->flags |=VIRTIO_DEV_READY ; - -if (!(dev->flags &VIRTIO_DEV_RUNNING )) { -if (dev->dequeue_zero_copy) { -RTE_LOG (INFO ,VHOST_CONFIG , -"dequeue zero copy is enabled\n" ); - } - -if (dev->notify_ops->new_device (dev->vid) ==0 ) - dev->flags |=VIRTIO_DEV_RUNNING ; - } - } } static void
@@ -1108,5 +1090,19 @@send_vhost_message (fd, &msg); } +if (!(dev->flags &VIRTIO_DEV_RUNNING ) &&virtio_is_ready (dev)) { + dev->flags |=VIRTIO_DEV_READY ; + +if (!(dev->flags &VIRTIO_DEV_RUNNING )) { +if (dev->dequeue_zero_copy) { +RTE_LOG (INFO ,VHOST_CONFIG , +"dequeue zero copy is enabled\n" ); + } + +if (dev->notify_ops->new_device (dev->vid) ==0 ) + dev->flags |=VIRTIO_DEV_RUNNING ; + } + } +return 0 ; }
Signature · 1 line
1.9.0
PATCH v4 12/22 vhost: drop the Rx and Tx queue macro
In reply to Yuanhan LiuThey are virtio-net specific and should be defined inside the virtio-net driver.
---
v2: - update release note
--- doc/guides/rel_notes/release_17_05.rst | 6 ++++++ drivers/net/vhost/rte_eth_vhost.c | 2 ++ examples/tep_termination/main.h | 2 ++ examples/vhost/main.h | 2 ++ lib/librte_vhost/rte_virtio_net.h | 3 --- 5 files changed, 12 insertions(+), 3 deletions(-)
doc/guides/rel_notes/release_17_05.rst +6 -0
@@ -211,6 +211,12 @@ API Changes * The vhost API ``rte_vhost_get_queue_num`` is deprecated, instead, ``rte_vhost_get_vring_num`` should be used. + * Following macros are removed in ``rte_virtio_net.h`` + + * ``VIRTIO_RXQ`` + * ``VIRTIO_TXQ`` + * ``VIRTIO_QNUM`` + ABI Changes -----------
drivers/net/vhost/rte_eth_vhost.c +2 -0
@@ -45,6 +45,8 @@#include "rte_eth_vhost.h" +enum {VIRTIO_RXQ ,VIRTIO_TXQ ,VIRTIO_QNUM }; +#define ETH_VHOST_IFACE_ARG "iface"#define ETH_VHOST_QUEUES_ARG "queues"#define ETH_VHOST_CLIENT_ARG "client"
examples/tep_termination/main.h +2 -0
@@ -54,6 +54,8 @@/* Max number of devices. Limited by the application. */ #define MAX_DEVICES 64 +enum {VIRTIO_RXQ ,VIRTIO_TXQ ,VIRTIO_QNUM }; +/* Per-device statistics struct */ struct device_statistics {uint64_t tx_total;
examples/vhost/main.h +2 -0
@@ -41,6 +41,8 @@#define RTE_LOGTYPE_VHOST_DATA RTE_LOGTYPE_USER2#define RTE_LOGTYPE_VHOST_PORT RTE_LOGTYPE_USER3 +enum {VIRTIO_RXQ ,VIRTIO_TXQ ,VIRTIO_QNUM }; +struct device_statistics {uint64_t tx;uint64_t tx_total;
lib/librte_vhost/rte_virtio_net.h +0 -3
@@ -55,9 +55,6 @@#define RTE_VHOST_USER_NO_RECONNECT (1ULL << 1)#define RTE_VHOST_USER_DEQUEUE_ZERO_COPY (1ULL << 2) -/* Enum for virtqueue management. */ -enum {VIRTIO_RXQ ,VIRTIO_TXQ ,VIRTIO_QNUM }; -/** * Information relating to memory regions including offsets to * addresses in QEMUs memory file.
Signature · 1 line
1.9.0
Re: [PATCH v4 12/22] vhost: drop the Rx and Tx queue macro
2017-04-01 15:22, Yuanhan Liu:
Quoted 7 lines
They are virtio-net specific and should be defined inside the virtio-net driver.
Signed-off-by Yuanhan Liu <[email protected]>Reviewed-by Maxime Coquelin <[email protected]>---
Quoted 8 lines
v2: - update release note
--- doc/guides/rel_notes/release_17_05.rst | 6 ++++++ drivers/net/vhost/rte_eth_vhost.c | 2 ++ examples/tep_termination/main.h | 2 ++ examples/vhost/main.h | 2 ++ lib/librte_vhost/rte_virtio_net.h | 3 --- 5 files changed, 12 insertions(+), 3 deletions(-)
The enum is missing in lib/librte_vhost/vhost_user.c when RTE_LIBRTE_VHOST_NUMA is enabled.
PATCH v4 13/22 vhost: do not include net specific headers
In reply to Yuanhan LiuInclude it internally, at vhost.h.
---
v2: - update release note
--- doc/guides/rel_notes/release_17_05.rst | 7 +++++++ examples/vhost/main.h | 2 ++ lib/librte_vhost/rte_virtio_net.h | 4 ---- lib/librte_vhost/vhost.h | 4 ++++ 4 files changed, 13 insertions(+), 4 deletions(-)
doc/guides/rel_notes/release_17_05.rst +7 -0
@@ -217,6 +217,13 @@ API Changes * ``VIRTIO_TXQ`` * ``VIRTIO_QNUM`` + * Following net specific header files are removed in ``rte_virtio_net.h`` + + * ``linux/virtio_net.h`` + * ``sys/socket.h`` + * ``linux/if.h`` + * ``rte_ether.h`` + ABI Changes -----------
examples/vhost/main.h +2 -0
@@ -36,6 +36,8 @@#include <sys/queue.h> +#include <rte_ether.h> +/* Macros for printing using RTE_LOG */ #define RTE_LOGTYPE_VHOST_CONFIG RTE_LOGTYPE_USER1#define RTE_LOGTYPE_VHOST_DATA RTE_LOGTYPE_USER2
lib/librte_vhost/rte_virtio_net.h +0 -4
@@ -42,14 +42,10 @@#include <stdint.h> #include <linux/vhost.h> #include <linux/virtio_ring.h> -#include <linux/virtio_net.h> #include <sys/eventfd.h> -#include <sys/socket.h> -#include <linux/if.h> #include <rte_memory.h> #include <rte_mempool.h> -#include <rte_ether.h> #define RTE_VHOST_USER_CLIENT (1ULL << 0)#define RTE_VHOST_USER_NO_RECONNECT (1ULL << 1)
lib/librte_vhost/vhost.h +4 -0
@@ -39,8 +39,12 @@#include <sys/queue.h> #include <unistd.h> #include <linux/vhost.h> +#include <linux/virtio_net.h> +#include <sys/socket.h> +#include <linux/if.h> #include <rte_log.h> +#include <rte_ether.h> #include "rte_virtio_net.h"
Signature · 1 line
1.9.0
PATCH v4 14/22 vhost: rename device ops struct
In reply to Yuanhan Liurename "virtio_net_device_ops" to "vhost_device_ops", to not let it be virtio-net specific.
--- doc/guides/prog_guide/vhost_lib.rst | 2 +- doc/guides/rel_notes/release_17_05.rst | 3 +++ drivers/net/vhost/rte_eth_vhost.c | 2 +- examples/tep_termination/main.c | 2 +- examples/vhost/main.c | 2 +- lib/librte_vhost/Makefile | 2 +- lib/librte_vhost/rte_virtio_net.h | 4 ++-- lib/librte_vhost/socket.c | 6 +++--- lib/librte_vhost/vhost.h | 4 ++-- 9 files changed, 15 insertions(+), 12 deletions(-)
doc/guides/prog_guide/vhost_lib.rst +1 -1
@@ -122,7 +122,7 @@ The following is an overview of some key Vhost API functions: starts an infinite loop, therefore it should be called in a dedicated thread. -* ``rte_vhost_driver_callback_register(path, virtio_net_device_ops)`` +* ``rte_vhost_driver_callback_register(path, vhost_device_ops)`` This function registers a set of callbacks, to let DPDK applications take the appropriate action when some events happen. The following events are
doc/guides/rel_notes/release_17_05.rst +3 -0
@@ -224,6 +224,9 @@ API Changes * ``linux/if.h`` * ``rte_ether.h`` + * The vhost struct ``virtio_net_device_ops`` is renamed to + ``vhost_device_ops`` + ABI Changes -----------
drivers/net/vhost/rte_eth_vhost.c +1 -1
@@ -671,7 +671,7 @@ struct vhost_xstats_name_off {return 0 ; } -static struct virtio_net_device_ops vhost_ops = { +static struct vhost_device_ops vhost_ops = { .new_device = new_device, .destroy_device = destroy_device, .vring_state_changed = vring_state_changed,
examples/tep_termination/main.c +1 -1
@@ -1081,7 +1081,7 @@ static inline void __attribute__((always_inline))* These callback allow devices to be added to the data core when configuration * has been fully complete. */ -static const struct virtio_net_device_ops virtio_net_device_ops = { +static const struct vhost_device_ops virtio_net_device_ops = { .new_device = new_device, .destroy_device = destroy_device, };
examples/vhost/main.c +1 -1
@@ -1270,7 +1270,7 @@ static inline void __attribute__((always_inline))* These callback allow devices to be added to the data core when configuration * has been fully complete. */ -static const struct virtio_net_device_ops virtio_net_device_ops = +static const struct vhost_device_ops virtio_net_device_ops = { .new_device = new_device, .destroy_device = destroy_device,
lib/librte_vhost/Makefile +1 -1
@@ -36,7 +36,7 @@ LIB = librte_vhost.a EXPORT_MAP := rte_vhost_version.map -LIBABIVER := 3 +LIBABIVER := 4 CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR) -O3 -D_FILE_OFFSET_BITS=64 CFLAGS += -I vhost_user
lib/librte_vhost/rte_virtio_net.h +2 -2
@@ -87,7 +87,7 @@ struct rte_vhost_vring {/** * Device and vring operations. */ -struct virtio_net_device_ops { +struct vhost_device_ops {int (*new_device)(int vid);/**< Add device. */ void (*destroy_device)(int vid);/**< Remove device. */
@@ -202,7 +202,7 @@ static inline uint64_t __attribute__((always_inline))/* Register callbacks. */ int rte_vhost_driver_callback_register (const char *path, -struct virtio_net_device_ops const *const ops); +struct vhost_device_ops const *const ops);/* Start vhost driver session blocking loop. */ int rte_vhost_driver_session_start (void );
lib/librte_vhost/socket.c +3 -3
@@ -78,7 +78,7 @@ struct vhost_user_socket {uint64_t supported_features;uint64_t features; -struct virtio_net_device_ops const *notify_ops; +struct vhost_device_ops const *notify_ops; };struct vhost_user_connection {
@@ -750,7 +750,7 @@ struct vhost_user_reconnect_list {*/ int rte_vhost_driver_callback_register (const char *path, -struct virtio_net_device_ops const *const ops) +struct vhost_device_ops const *const ops) {struct vhost_user_socket *vsocket;
@@ -763,7 +763,7 @@ struct vhost_user_reconnect_list {return vsocket ?0 :-1 ; } -struct virtio_net_device_ops const * +struct vhost_device_ops const *vhost_driver_callback_get (const char *path) {struct vhost_user_socket *vsocket;
lib/librte_vhost/vhost.h +2 -2
@@ -191,7 +191,7 @@ struct virtio_net {struct ether_addr mac;uint16_t mtu; -struct virtio_net_device_ops const *notify_ops; +struct vhost_device_ops const *notify_ops;uint32_t nr_guest_pages;uint32_t max_guest_pages;
@@ -265,7 +265,7 @@ static inline phys_addr_t __attribute__((always_inline))void vhost_set_ifname (int ,const char *if_name,unsigned int if_len);void vhost_enable_dequeue_zero_copy (int vid); -struct virtio_net_device_ops const *vhost_driver_callback_get (const char *path); +struct vhost_device_ops const *vhost_driver_callback_get (const char *path);/* * Backend-specific cleanup.
Signature · 1 line
1.9.0
PATCH v4 15/22 vhost: rename virtio-net to vhost
In reply to Yuanhan LiuRename "virtio-net" to "vhost" in the API comments and vhost prog guide.
--- doc/guides/prog_guide/vhost_lib.rst | 6 +++--- lib/librte_vhost/rte_virtio_net.h | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-)
doc/guides/prog_guide/vhost_lib.rst +3 -3
@@ -130,12 +130,12 @@ The following is an overview of some key Vhost API functions: * ``new_device(int vid)`` - This callback is invoked when a virtio net device becomes ready. ``vid`` - is the virtio net device ID. + This callback is invoked when a virtio device becomes ready. ``vid`` + is the vhost device ID. * ``destroy_device(int vid)`` - This callback is invoked when a virtio net device shuts down (or when the + This callback is invoked when a virtio device shuts down (or when the vhost connection is broken). * ``vring_state_changed(int vid, uint16_t queue_id, int enable)``
lib/librte_vhost/rte_virtio_net.h +7 -7
@@ -226,7 +226,7 @@ int rte_vhost_driver_callback_register(const char *path,* is allocated. * * @param vid -* virtio-net device ID +* vhost device ID * * @return * The numa node, -1 on failure
@@ -238,11 +238,11 @@ int rte_vhost_driver_callback_register(const char *path,* Get the number of queues the device supports. * * Note this function is deprecated, as it returns a queue pair number, -* which is virtio-net specific. Instead, rte_vhost_get_vring_num should +* which is vhost specific. Instead, rte_vhost_get_vring_num should * be used. * * @param vid -* virtio-net device ID +* vhost device ID * * @return * The number of queues, 0 on failure
@@ -266,7 +266,7 @@ int rte_vhost_driver_callback_register(const char *path,* file path. * * @param vid -* virtio-net device ID +* vhost device ID * @param buf * The buffer to stored the queried ifname * @param len
@@ -281,7 +281,7 @@ int rte_vhost_driver_callback_register(const char *path,* Get how many avail entries are left in the queue * * @param vid -* virtio-net device ID +* vhost device ID * @param queue_id * virtio queue index *
@@ -296,7 +296,7 @@ int rte_vhost_driver_callback_register(const char *path,* count is returned to indicate the number of packets that were succesfully * added to the RX queue. * @param vid -* virtio-net device ID +* vhost device ID * @param queue_id * virtio queue index in mq case * @param pkts
@@ -314,7 +314,7 @@ uint16_t rte_vhost_enqueue_burst(int vid, uint16_t queue_id,* construct host mbufs, copies guest buffer content to host mbufs and * store them in pkts to be processed. * @param vid -* virtio-net device +* vhost device ID * @param queue_id * virtio queue index in mq case * @param mbuf_pool
Signature · 1 line
1.9.0
PATCH v4 16/22 vhost: add features changed callback
In reply to Yuanhan LiuFeatures could be changed after the feature negotiation. For example, VHOST_F_LOG_ALL will be set/cleared at the start/end of live migration, respecitively. Thus, we need a new callback to inform the application on such change.
--- doc/guides/prog_guide/vhost_lib.rst | 6 ++++++ lib/librte_vhost/rte_virtio_net.h | 10 +++++++++- lib/librte_vhost/vhost_user.c | 5 +++++ 3 files changed, 20 insertions(+), 1 deletion(-)
doc/guides/prog_guide/vhost_lib.rst +6 -0
@@ -143,6 +143,12 @@ The following is an overview of some key Vhost API functions: This callback is invoked when a specific queue's state is changed, for example to enabled or disabled. + * ``features_changed(int vid, uint64_t features)`` + + This callback is invoked when the features is changed. For example, + ``VHOST_F_LOG_ALL`` will be set/cleared at the start/end of live + migration, respectively. + * ``rte_vhost_enqueue_burst(vid, queue_id, pkts, count)`` Transmits (enqueues) ``count`` packets from host to guest.
lib/librte_vhost/rte_virtio_net.h +9 -1
@@ -93,7 +93,15 @@ struct vhost_device_ops {int (*vring_state_changed)(int vid,uint16_t queue_id,int enable);/**< triggered when a vring is enabled or disabled */ -void *reserved[5 ];/**< Reserved for future extension */ +/** +* Features could be changed after the feature negotiation. +* For example, VHOST_F_LOG_ALL will be set/cleared at the +* start/end of live migration, respectively. This callback +* is used to inform the application on such change. +*/ +int (*features_changed)(int vid,uint64_t features); + +void *reserved[4 ];/**< Reserved for future extension */ };/**
lib/librte_vhost/vhost_user.c +5 -0
@@ -167,6 +167,11 @@if (features & ~vhost_features)return -1 ; +if ((dev->flags &VIRTIO_DEV_RUNNING ) && dev->features != features) { +if (dev->notify_ops->features_changed) + dev->notify_ops->features_changed (dev->vid, features); + } + dev->features = features;if (dev->features & ((1 <<VIRTIO_NET_F_MRG_RXBUF ) | (1ULL <<VIRTIO_F_VERSION_1 ))) {
Signature · 1 line
1.9.0
PATCH v4 17/22 vhost: export APIs for live migration support
In reply to Yuanhan LiuExport few APIs for the vhost-user driver to log the guest memory writes, which is a must for live migration support.
This patch basically moves vhost_log_write() and vhost_log_used_vring() into vhost.h and then add an wrapper (the public API) to them.
--- lib/librte_vhost/rte_vhost_version.map | 2 ++ lib/librte_vhost/rte_virtio_net.h | 43 ++++++++++++++++++++++++++++++++++ lib/librte_vhost/vhost.c | 31 ++++++++++++++++++++++++ lib/librte_vhost/vhost.h | 38 ++++++++++++++++++++++++++++++ lib/librte_vhost/virtio_net.c | 36 ---------------------------- 5 files changed, 114 insertions(+), 36 deletions(-)
lib/librte_vhost/rte_vhost_version.map +2 -0
@@ -41,5 +41,7 @@ DPDK_17.05 { rte_vhost_get_vhost_vring; rte_vhost_get_vring_num; rte_vhost_gpa_to_vva; + rte_vhost_log_used_vring; + rte_vhost_log_write; } DPDK_16.07;
lib/librte_vhost/rte_virtio_net.h +43 -0
49 lines not on this page · raw message
lib/librte_vhost/vhost.c +31 -0
@@ -444,3 +444,34 @@ struct virtio_net * dev->virtqueue[queue_id]->used->flags =VRING_USED_F_NO_NOTIFY ;return 0 ; } + +void +rte_vhost_log_write (int vid,uint64_t addr,uint64_t len) +{ +struct virtio_net *dev =get_device (vid); + +if (dev ==NULL ) +return ; + +vhost_log_write (dev, addr, len); +} + +void +rte_vhost_log_used_vring (int vid,uint16_t vring_idx, +uint64_t offset,uint64_t len) +{ +struct virtio_net *dev; +struct vhost_virtqueue *vq; + + dev =get_device (vid); +if (dev ==NULL ) +return ; + +if (vring_idx >=VHOST_MAX_VRING ) +return ; + vq = dev->virtqueue[vring_idx]; +if (!vq) +return ; + +vhost_log_used_vring (dev, vq, offset, len); +}
lib/librte_vhost/vhost.h +38 -0
@@ -198,6 +198,44 @@ struct virtio_net {struct guest_page *guest_pages; } __rte_cache_aligned; + +#define VHOST_LOG_PAGE 4096 + +static inline void __attribute__((always_inline)) +vhost_log_page (uint8_t *log_base,uint64_t page) +{ + log_base[page /8 ] |=1 << (page %8 ); +} + +static inline void __attribute__((always_inline)) +vhost_log_write (struct virtio_net *dev,uint64_t addr,uint64_t len) +{ +uint64_t page; + +if (likely (((dev->features & (1ULL <<VHOST_F_LOG_ALL )) ==0 ) || + !dev->log_base || !len)) +return ; + +if (unlikely (dev->log_size <= ((addr + len -1 ) /VHOST_LOG_PAGE /8 ))) +return ; + +/* To make sure guest memory updates are committed before logging */ +rte_smp_wmb (); + + page = addr /VHOST_LOG_PAGE ; +while (page *VHOST_LOG_PAGE < addr + len) { +vhost_log_page ((uint8_t *)(uintptr_t )dev->log_base, page); + page +=1 ; + } +} + +static inline void __attribute__((always_inline)) +vhost_log_used_vring (struct virtio_net *dev,struct vhost_virtqueue *vq, +uint64_t offset,uint64_t len) +{ +vhost_log_write (dev, vq->log_guest_addr + offset, len); +} +/* Macros for printing using RTE_LOG */ #define RTE_LOGTYPE_VHOST_CONFIG RTE_LOGTYPE_USER1#define RTE_LOGTYPE_VHOST_DATA RTE_LOGTYPE_USER1
lib/librte_vhost/virtio_net.c +0 -36
@@ -48,42 +48,6 @@#include "vhost.h" #define MAX_PKT_BURST 32 -#define VHOST_LOG_PAGE 4096 - -static inline void __attribute__((always_inline)) -vhost_log_page (uint8_t *log_base,uint64_t page) -{ - log_base[page /8 ] |=1 << (page %8 ); -} - -static inline void __attribute__((always_inline)) -vhost_log_write (struct virtio_net *dev,uint64_t addr,uint64_t len) -{ -uint64_t page; - -if (likely (((dev->features & (1ULL <<VHOST_F_LOG_ALL )) ==0 ) || - !dev->log_base || !len)) -return ; - -if (unlikely (dev->log_size <= ((addr + len -1 ) /VHOST_LOG_PAGE /8 ))) -return ; - -/* To make sure guest memory updates are committed before logging */ -rte_smp_wmb (); - - page = addr /VHOST_LOG_PAGE ; -while (page *VHOST_LOG_PAGE < addr + len) { -vhost_log_page ((uint8_t *)(uintptr_t )dev->log_base, page); - page +=1 ; - } -} - -static inline void __attribute__((always_inline)) -vhost_log_used_vring (struct virtio_net *dev,struct vhost_virtqueue *vq, -uint64_t offset,uint64_t len) -{ -vhost_log_write (dev, vq->log_guest_addr + offset, len); -}static bool is_valid_virt_queue_idx (uint32_t idx,int is_tx,uint32_t nr_vring)
Signature · 1 line
1.9.0
PATCH v4 18/22 vhost: introduce API to start a specific driver
In reply to Yuanhan LiuWe used to use rte_vhost_driver_session_start() to trigger the vhost-user session. It takes no argument, thus it's a global trigger. And it could be problematic.
The issue is, currently, rte_vhost_driver_register(path, flags) actually tries to put it into the session loop (by fdset_add). However, it needs a set of APIs to set a vhost-user driver properly:
* rte_vhost_driver_register(path, flags);
* rte_vhost_driver_set_features(path, features);
* rte_vhost_driver_callback_register(path, vhost_device_ops);
If a new vhost-user driver is registered after the trigger (think OVS-DPDK that could add a port dynamically from cmdline), the current code will effectively starts the session for the new driver just after the first API rte_vhost_driver_register() is invoked, leaving later calls taking no effect at all.
To handle the case properly, this patch introduce a new API, rte_vhost_driver_start(path), to trigger a specific vhost-user driver. To do that, the rte_vhost_driver_register(path, flags) is simplified to create the socket only and let rte_vhost_driver_start(path) to actually put it into the session loop.
Meanwhile, the rte_vhost_driver_session_start is removed: we could hide the session thread internally (create the thread if it has not been created). This would also simplify the application.
NOTE: the API order in prog guide is slightly adjusted for showing the correct invoke order.
---
v3: - fix broken reconnect
--- doc/guides/prog_guide/vhost_lib.rst | 24 +++++----- doc/guides/rel_notes/release_17_05.rst | 4 ++ drivers/net/vhost/rte_eth_vhost.c | 50 ++------------------ examples/tep_termination/main.c | 8 +++- examples/vhost/main.c | 9 +++- lib/librte_vhost/fd_man.c | 9 ++-- lib/librte_vhost/fd_man.h | 2 +- lib/librte_vhost/rte_vhost_version.map | 2 +- lib/librte_vhost/rte_virtio_net.h | 15 +++++- lib/librte_vhost/socket.c | 84 ++++++++++++++++++++-------------- 10 files changed, 104 insertions(+), 103 deletions(-)
doc/guides/prog_guide/vhost_lib.rst +11 -13
@@ -116,12 +116,6 @@ The following is an overview of some key Vhost API functions: vhost-user driver could be vhost-user net, yet it could be something else, say, vhost-user SCSI. -* ``rte_vhost_driver_session_start()`` - - This function starts the vhost session loop to handle vhost messages. It - starts an infinite loop, therefore it should be called in a dedicated - thread. - * ``rte_vhost_driver_callback_register(path, vhost_device_ops)`` This function registers a set of callbacks, to let DPDK applications take
@@ -149,6 +143,17 @@ The following is an overview of some key Vhost API functions: ``VHOST_F_LOG_ALL`` will be set/cleared at the start/end of live migration, respectively. +* ``rte_vhost_driver_disable/enable_features(path, features))`` + + This function disables/enables some features. For example, it can be used to + disable mergeable buffers and TSO features, which both are enabled by + default. + +* ``rte_vhost_driver_start(path)`` + + This function triggers the vhost-user negotiation. It should be invoked at + the end of initializing a vhost-user driver. + * ``rte_vhost_enqueue_burst(vid, queue_id, pkts, count)`` Transmits (enqueues) ``count`` packets from host to guest.
@@ -157,13 +162,6 @@ The following is an overview of some key Vhost API functions: Receives (dequeues) ``count`` packets from guest, and stored them at ``pkts``. -* ``rte_vhost_driver_disable/enable_features(path, features))`` - - This function disables/enables some features. For example, it can be used to - disable mergeable buffers and TSO features, which both are enabled by - default. - - Vhost-user Implementations --------------------------
doc/guides/rel_notes/release_17_05.rst +4 -0
@@ -227,6 +227,10 @@ API Changes * The vhost struct ``virtio_net_device_ops`` is renamed to ``vhost_device_ops`` + * The vhost API ``rte_vhost_driver_session_start`` is removed. Instead, + ``rte_vhost_driver_start`` should be used, and no need to create a + thread to call it. + ABI Changes -----------
drivers/net/vhost/rte_eth_vhost.c +4 -46
74 lines not on this page · raw message
examples/tep_termination/main.c +7 -1
@@ -1263,7 +1263,13 @@ static inline void __attribute__((always_inline)) "failed to register vhost driver callbacks.\n"); } -rte_vhost_driver_session_start (); +if (rte_vhost_driver_start (dev_basename) <0 ) { +rte_exit (EXIT_FAILURE , +"failed to start vhost driver.\n" ); + } + +RTE_LCORE_FOREACH_SLAVE (lcore_id) +rte_eal_wait_lcore (lcore_id);return 0 ; }
examples/vhost/main.c +8 -1
@@ -1545,9 +1545,16 @@ static inline void __attribute__((always_inline))rte_exit (EXIT_FAILURE ,"failed to register vhost driver callbacks.\n" ); } + +if (rte_vhost_driver_start (file) <0 ) { +rte_exit (EXIT_FAILURE , +"failed to start vhost driver.\n" ); + } } -rte_vhost_driver_session_start (); +RTE_LCORE_FOREACH_SLAVE (lcore_id) +rte_eal_wait_lcore (lcore_id); +return 0 ; }
lib/librte_vhost/fd_man.c +6 -3
@@ -210,8 +210,8 @@* will wait until the flag is reset to zero(which indicates the callback is * finished), then it could free the context after fdset_del. */ -void -fdset_event_dispatch (struct fdset *pfdset) +void * +fdset_event_dispatch (void *arg) {int i;struct pollfd *pfd;
@@ -221,9 +221,10 @@int fd, numfds;int remove1, remove2;int need_shrink; +struct fdset *pfdset = arg;if (pfdset ==NULL ) -return ; +return NULL ;while (1 ) {
@@ -294,4 +295,6 @@if (need_shrink)fdset_shrink (pfdset); } + +return NULL ; }
lib/librte_vhost/fd_man.h +1 -1
@@ -64,6 +64,6 @@ int fdset_add(struct fdset *pfdset, int fd,void *fdset_del (struct fdset *pfdset,int fd); -void fdset_event_dispatch (struct fdset *pfdset); +void *fdset_event_dispatch (void *arg);#endif
lib/librte_vhost/rte_vhost_version.map +1 -1
@@ -4,7 +4,6 @@ DPDK_2.0 { rte_vhost_dequeue_burst; rte_vhost_driver_callback_register; rte_vhost_driver_register; - rte_vhost_driver_session_start; rte_vhost_enable_guest_notification; rte_vhost_enqueue_burst;
@@ -35,6 +34,7 @@ DPDK_17.05 { rte_vhost_driver_enable_features; rte_vhost_driver_get_features; rte_vhost_driver_set_features; + rte_vhost_driver_start; rte_vhost_get_mem_table; rte_vhost_get_mtu; rte_vhost_get_negotiated_features;
lib/librte_vhost/rte_virtio_net.h +13 -2
@@ -254,8 +254,19 @@ void rte_vhost_log_used_vring(int vid, uint16_t vring_idx,/* Register callbacks. */ int rte_vhost_driver_callback_register (const char *path,struct vhost_device_ops const *const ops); -/* Start vhost driver session blocking loop. */ -int rte_vhost_driver_session_start (void ); + +/** +* +* Start the vhost-user driver. +* +* This function triggers the vhost-user negotiation. +* +* @param path +* The vhost-user socket file path +* @return +* 0 on success, -1 on failure +*/ +int rte_vhost_driver_start (const char *path);/** * Get the MTU value of the device if set in QEMU.
lib/librte_vhost/socket.c +49 -35
172 lines not on this page · raw message
Signature · 1 line
1.9.0
PATCH v4 19/22 vhost: rename header file
In reply to Yuanhan LiuRename "rte_virtio_net.h" to "rte_vhost.h", to not let it be virtio net specific.
--- doc/guides/rel_notes/deprecation.rst | 9 - doc/guides/rel_notes/release_17_05.rst | 3 + drivers/net/vhost/rte_eth_vhost.c | 2 +- drivers/net/vhost/rte_eth_vhost.h | 2 +- examples/tep_termination/main.c | 2 +- examples/tep_termination/vxlan_setup.c | 2 +- examples/vhost/main.c | 2 +- lib/librte_vhost/Makefile | 2 +- lib/librte_vhost/rte_vhost.h | 425 +++++++++++++++++++++++++++++++++ lib/librte_vhost/rte_virtio_net.h | 425 --------------------------------- lib/librte_vhost/vhost.c | 2 +- lib/librte_vhost/vhost.h | 2 +- lib/librte_vhost/vhost_user.h | 2 +- lib/librte_vhost/virtio_net.c | 2 +- 14 files changed, 438 insertions(+), 444 deletions(-) create mode 100644 lib/librte_vhost/rte_vhost.h delete mode 100644 lib/librte_vhost/rte_virtio_net.h
doc/guides/rel_notes/deprecation.rst +0 -9
@@ -95,15 +95,6 @@ Deprecation Notices Target release for removal of the legacy API will be defined once most PMDs have switched to rte_flow. -* vhost: API/ABI changes are planned for 17.05, for making DPDK vhost library - generic enough so that applications can build different vhost-user drivers - (instead of vhost-user net only) on top of that. - Specifically, ``virtio_net_device_ops`` will be renamed to ``vhost_device_ops``. - Correspondingly, some API's parameter need be changed. Few more functions also - need be reworked to let it be device aware. For example, different virtio device - has different feature set, meaning functions like ``rte_vhost_feature_disable`` - need be changed. Last, file rte_virtio_net.h will be renamed to rte_vhost.h. - * ABI changes are planned for 17.05 in the ``rte_cryptodev_ops`` structure. A pointer to a rte_cryptodev_config structure will be added to the function prototype ``cryptodev_configure_t``, as a new parameter.
doc/guides/rel_notes/release_17_05.rst +3 -0
@@ -231,6 +231,9 @@ API Changes ``rte_vhost_driver_start`` should be used, and no need to create a thread to call it. + * The vhost public header file ``rte_virtio_net.h`` is renamed to + ``rte_vhost.h`` + ABI Changes -----------
drivers/net/vhost/rte_eth_vhost.c +1 -1
@@ -40,7 +40,7 @@#include <rte_memcpy.h> #include <rte_vdev.h> #include <rte_kvargs.h> -#include <rte_virtio_net.h> +#include <rte_vhost.h> #include <rte_spinlock.h> #include "rte_eth_vhost.h"
drivers/net/vhost/rte_eth_vhost.h +1 -1
@@ -41,7 +41,7 @@#include <stdint.h> #include <stdbool.h> -#include <rte_virtio_net.h> +#include <rte_vhost.h> /* * Event description.
examples/tep_termination/main.c +1 -1
@@ -49,7 +49,7 @@#include <rte_log.h> #include <rte_string_fns.h> #include <rte_malloc.h> -#include <rte_virtio_net.h> +#include <rte_vhost.h> #include "main.h" #include "vxlan.h"
examples/tep_termination/vxlan_setup.c +1 -1
@@ -49,7 +49,7 @@#include <rte_tcp.h> #include "main.h" -#include "rte_virtio_net.h" +#include "rte_vhost.h" #include "vxlan.h" #include "vxlan_setup.h"
examples/vhost/main.c +1 -1
@@ -49,7 +49,7 @@#include <rte_log.h> #include <rte_string_fns.h> #include <rte_malloc.h> -#include <rte_virtio_net.h> +#include <rte_vhost.h> #include <rte_ip.h> #include <rte_tcp.h>
lib/librte_vhost/Makefile +1 -1
@@ -51,6 +51,6 @@ SRCS-$(CONFIG_RTE_LIBRTE_VHOST) := fd_man.c socket.c vhost.c vhost_user.c \ virtio_net.c # install includes -SYMLINK-$(CONFIG_RTE_LIBRTE_VHOST)-include += rte_virtio_net.h +SYMLINK-$(CONFIG_RTE_LIBRTE_VHOST)-include += rte_vhost.h include $(RTE_SDK)/mk/rte.lib.mk
lib/librte_vhost/rte_vhost.h new file +425 -0
425 lines not on this page · raw message
lib/librte_vhost/rte_virtio_net.h deleted +0 -425
425 lines not on this page · raw message
lib/librte_vhost/vhost.c +1 -1
@@ -45,7 +45,7 @@#include <rte_string_fns.h> #include <rte_memory.h> #include <rte_malloc.h> -#include <rte_virtio_net.h> +#include <rte_vhost.h> #include "vhost.h"
lib/librte_vhost/vhost.h +1 -1
@@ -46,7 +46,7 @@#include <rte_log.h> #include <rte_ether.h> -#include "rte_virtio_net.h" +#include "rte_vhost.h" /* Used to indicate that the device is running on a data core */ #define VIRTIO_DEV_RUNNING 1
lib/librte_vhost/vhost_user.h +1 -1
@@ -37,7 +37,7 @@#include <stdint.h> #include <linux/vhost.h> -#include "rte_virtio_net.h" +#include "rte_vhost.h" /* refer to hw/virtio/vhost-user.c */
lib/librte_vhost/virtio_net.c +1 -1
@@ -39,7 +39,7 @@#include <rte_memcpy.h> #include <rte_ether.h> #include <rte_ip.h> -#include <rte_virtio_net.h> +#include <rte_vhost.h> #include <rte_tcp.h> #include <rte_udp.h> #include <rte_sctp.h>
Signature · 1 line
1.9.0
Re: [PATCH v4 19/22] vhost: rename header file
2017-04-01 15:22, Yuanhan Liu:
Quoted 15 lines
Rename "
rte_virtio_net.h" to "rte_vhost.h", to not let it be virtio net specific.Signed-off-by Yuanhan Liu <[email protected]>Reviewed-by Maxime Coquelin <[email protected]>--- doc/guides/rel_notes/deprecation.rst | 9 - doc/guides/rel_notes/release_17_05.rst | 3 + drivers/net/vhost/rte_eth_vhost.c | 2 +- drivers/net/vhost/rte_eth_vhost.h | 2 +- examples/tep_termination/main.c | 2 +- examples/tep_termination/vxlan_setup.c | 2 +- examples/vhost/main.c | 2 +- lib/librte_vhost/Makefile | 2 +- lib/librte_vhost/rte_vhost.h | 425 +++++++++++++++++++++++++++++++++
Quoted 8 lines
lib/librte_vhost/rte_virtio_net.h | 425 --------------------------------- lib/librte_vhost/vhost.c | 2 +- lib/librte_vhost/vhost.h | 2 +- lib/librte_vhost/vhost_user.h | 2 +- lib/librte_vhost/virtio_net.c | 2 +- 14 files changed, 438 insertions(+), 444 deletions(-) create mode 100644 lib/librte_vhost/rte_vhost.h delete mode 100644 lib/librte_vhost/rte_virtio_net.h
It must be renamed also in doc/api/doxy-api-index.md:
- [vhost] (@ref rte_virtio_net.h), + [vhost] (@ref rte_vhost.h),
Re: [PATCH v4 19/22] vhost: rename header file
Quoted 26 lines · Thomas Monjalon
2017-04-01 15:22, Yuanhan Liu:
Quoted 15 lines
Rename "
rte_virtio_net.h" to "rte_vhost.h", to not let it be virtio net specific.Signed-off-by Yuanhan Liu <[email protected]>Reviewed-by Maxime Coquelin <[email protected]>--- doc/guides/rel_notes/deprecation.rst | 9 - doc/guides/rel_notes/release_17_05.rst | 3 + drivers/net/vhost/rte_eth_vhost.c | 2 +- drivers/net/vhost/rte_eth_vhost.h | 2 +- examples/tep_termination/main.c | 2 +- examples/tep_termination/vxlan_setup.c | 2 +- examples/vhost/main.c | 2 +- lib/librte_vhost/Makefile | 2 +- lib/librte_vhost/rte_vhost.h | 425 +++++++++++++++++++++++++++++++++Quoted 8 lines
lib/librte_vhost/rte_virtio_net.h | 425 --------------------------------- lib/librte_vhost/vhost.c | 2 +- lib/librte_vhost/vhost.h | 2 +- lib/librte_vhost/vhost_user.h | 2 +- lib/librte_vhost/virtio_net.c | 2 +- 14 files changed, 438 insertions(+), 444 deletions(-) create mode 100644 lib/librte_vhost/rte_vhost.h delete mode 100644 lib/librte_vhost/rte_virtio_net.hIt must be renamed also in
doc/api/doxy-api-index.md:
Review
Quoted 2 lines
(quoted diff) +1
-1- [vhost] (@ref rte_virtio_net.h), + [vhost] (@ref rte_vhost.h),
Oops, wasn't aware of that. I saw you have already handled that while applying. Thanks for that!
--yliu
PATCH v4 20/22 vhost: workaround the build dependency on mbuf header
In reply to Yuanhan Liurte_mbuf struct is something more likely will be used only in vhost-user net driver, while we have made vhost-user generic enough that it can be used for implementing other drivers (such as vhost-user SCSI), they have also include <rte_mbuf.h>. Otherwise, the build will be broken.
We could workaround it by using forward declaration, so that other non-net drivers won't need include <rte_mbuf.h>.
--- lib/librte_vhost/rte_vhost.h | 2 ++ 1 file changed, 2 insertions(+)
lib/librte_vhost/rte_vhost.h +2 -0
@@ -352,6 +352,8 @@ int rte_vhost_driver_callback_register(const char *path,*/ uint16_t rte_vhost_avail_entries (int vid,uint16_t queue_id); +struct rte_mbuf ; +struct rte_mempool ;/** * This function adds buffers to the virtio devices RX virtqueue. Buffers can * be received from the physical port or from another virtual device. A packet
Signature · 1 line
1.9.0
PATCH v4 21/22 vhost: do not destroy device on repeat mem table message
In reply to Yuanhan LiuIt doesn't make any sense to invoke destroy_device() callback at while handling SET_MEM_TABLE message.
Quoted 1 line
From the vhost-user spec, it's the
GET_VRING_BASEmessage indicates
the end of a vhost device: the destroy_device() should be invoked from there (luckily, we already did that).
--- lib/librte_vhost/vhost_user.c | 6 ------ 1 file changed, 6 deletions(-)
lib/librte_vhost/vhost_user.c +0 -6
@@ -502,12 +502,6 @@uint32_t i;int fd; -/* Remove from the data plane. */ -if (dev->flags &VIRTIO_DEV_RUNNING ) { - dev->flags &= ~VIRTIO_DEV_RUNNING ; - dev->notify_ops->destroy_device (dev->vid); - } -if (dev->mem) {free_mem_region (dev);rte_free (dev->mem);
Signature · 1 line
1.9.0
PATCH v4 22/22 examples/vhost: demonstrate the new generic vhost APIs
In reply to Yuanhan LiuNow DPDK vhost lib has been generic enough, that it can be used to implement any vhost-user drivers.
For example, this patch implements a very simple vhost-user net driver, mainly for demonstrating how to use those generic vhost APIs.
And when the --builtin-net-driver option is used, the example virtio-net driver code will be invoked, instead of the one provided from the vhost library.
--- examples/vhost/Makefile | 2 +- examples/vhost/main.c | 37 +++- examples/vhost/main.h | 28 ++- examples/vhost/virtio_net.c | 405 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 465 insertions(+), 7 deletions(-) create mode 100644 examples/vhost/virtio_net.c
examples/vhost/Makefile +1 -1
@@ -48,7 +48,7 @@ else APP = vhost-switch # all source are stored in SRCS-y -SRCS-y := main.c +SRCS-y := main.c virtio_net.c CFLAGS += -O2 -D_FILE_OFFSET_BITS=64 CFLAGS += $(WERROR_FLAGS)
examples/vhost/main.c +32 -5
@@ -1,7 +1,7 @@/*- * BSD LICENSE * -* Copyright(c) 2010-2016 Intel Corporation. All rights reserved. +* Copyright(c) 2010-2017 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without
@@ -65,7 +65,6 @@#define MBUF_CACHE_SIZE 128#define MBUF_DATA_SIZE RTE_MBUF_DEFAULT_BUF_SIZE -#define MAX_PKT_BURST 32/* Max burst size for RX/TX */ #define BURST_TX_DRAIN_US 100/* TX drain every ~100us */ #define BURST_RX_WAIT_US 15/* Defines how long we wait between retries on RX */
@@ -129,6 +128,8 @@static int client_mode;static int dequeue_zero_copy; +static int builtin_net_driver; +/* Specify timeout (in useconds) between retries on RX. */ static uint32_t burst_rx_delay_time =BURST_RX_WAIT_US ;/* Specify the number of retries on RX. */
@@ -499,6 +500,7 @@ struct mbuf_table { {"tso", required_argument, NULL, 0}, {"client", no_argument, &client_mode, 1}, {"dequeue-zero-copy", no_argument, &dequeue_zero_copy, 1}, + {"builtin-net-driver", no_argument, &builtin_net_driver, 1}, {NULL, 0, 0, 0}, };
@@ -795,7 +797,12 @@ static inline void __attribute__((always_inline)) {uint16_t ret; - ret =rte_vhost_enqueue_burst (dst_vdev->vid,VIRTIO_RXQ , &m,1 ); +if (builtin_net_driver) { + ret =vs_enqueue_pkts (dst_vdev,VIRTIO_RXQ , &m,1 ); + }else { + ret =rte_vhost_enqueue_burst (dst_vdev->vid,VIRTIO_RXQ , &m,1 ); + } +if (enable_stats) {rte_atomic64_inc (&dst_vdev->stats.rx_total_atomic);rte_atomic64_add (&dst_vdev->stats.rx_atomic, ret);
@@ -1066,8 +1073,13 @@ static inline void __attribute__((always_inline)) } } - enqueue_count =rte_vhost_enqueue_burst (vdev->vid,VIRTIO_RXQ , +if (builtin_net_driver) { + enqueue_count =vs_enqueue_pkts (vdev,VIRTIO_RXQ , pkts, rx_count); + }else { + enqueue_count =rte_vhost_enqueue_burst (vdev->vid,VIRTIO_RXQ , + pkts, rx_count); + }if (enable_stats) {rte_atomic64_add (&vdev->stats.rx_total_atomic, rx_count);rte_atomic64_add (&vdev->stats.rx_atomic, enqueue_count);
@@ -1083,8 +1095,13 @@ static inline void __attribute__((always_inline))uint16_t count;uint16_t i; - count =rte_vhost_dequeue_burst (vdev->vid,VIRTIO_TXQ , mbuf_pool, +if (builtin_net_driver) { + count =vs_dequeue_pkts (vdev,VIRTIO_TXQ , mbuf_pool, pkts,MAX_PKT_BURST ); + }else { + count =rte_vhost_dequeue_burst (vdev->vid,VIRTIO_TXQ , + mbuf_pool, pkts,MAX_PKT_BURST ); + }/* setup VMDq for the first packet */ if (unlikely (vdev->ready ==DEVICE_MAC_LEARNING ) && count) {
@@ -1187,6 +1204,9 @@ static inline void __attribute__((always_inline))rte_pause (); } +if (builtin_net_driver) +vs_vhost_net_remove (vdev); +TAILQ_REMOVE (&lcore_info[vdev->coreid].vdev_list, vdev, lcore_vdev_entry);TAILQ_REMOVE (&vhost_dev_list, vdev, global_vdev_entry);
@@ -1235,6 +1255,9 @@ static inline void __attribute__((always_inline)) } vdev->vid = vid; +if (builtin_net_driver) +vs_vhost_net_setup (vdev); +TAILQ_INSERT_TAIL (&vhost_dev_list, vdev, global_vdev_entry); vdev->vmdq_rx_q = vid * queues_per_pool + vmdq_queue_base;
@@ -1513,6 +1536,10 @@ static inline void __attribute__((always_inline))rte_exit (EXIT_FAILURE ,"vhost driver register failure.\n" ); } + +if (builtin_net_driver) +rte_vhost_driver_set_features (file,VIRTIO_NET_FEATURES ); +if (mergeable ==0 ) {rte_vhost_driver_disable_features (file,1ULL <<VIRTIO_NET_F_MRG_RXBUF );
examples/vhost/main.h +27 -1
@@ -1,7 +1,7 @@/*- * BSD LICENSE * -* Copyright(c) 2010-2016 Intel Corporation. All rights reserved. +* Copyright(c) 2010-2017 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without
@@ -45,6 +45,8 @@enum {VIRTIO_RXQ ,VIRTIO_TXQ ,VIRTIO_QNUM }; +#define MAX_PKT_BURST 32/* Max burst size for RX/TX */ +struct device_statistics {uint64_t tx;uint64_t tx_total;
@@ -52,6 +54,12 @@ struct device_statistics {rte_atomic64_t rx_total_atomic; }; +struct vhost_queue { +struct rte_vhost_vring vr; +uint16_t last_avail_idx; +uint16_t last_used_idx; +}; +struct vhost_dev {/**< Number of memory regions for gpa to hpa translation. */ uint32_t nregions_hpa;
@@ -69,9 +77,16 @@ struct vhost_dev {volatile uint8_t remove;int vid; +uint64_t features; +size_t hdr_len; +uint16_t nr_vrings; +struct rte_vhost_memory *mem;struct device_statistics stats;TAILQ_ENTRY (vhost_dev) global_vdev_entry;TAILQ_ENTRY (vhost_dev) lcore_vdev_entry; + +#define MAX_QUEUE_PAIRS 4 +struct vhost_queue queues[MAX_QUEUE_PAIRS *2 ]; } __rte_cache_aligned;TAILQ_HEAD (vhost_dev_tailq_list, vhost_dev);
@@ -92,4 +107,15 @@ struct lcore_info { struct vhost_dev_tailq_list vdev_list; }; +/* we implement non-extra virtio net features */ +#define VIRTIO_NET_FEATURES 0 + +void vs_vhost_net_setup (struct vhost_dev *dev); +void vs_vhost_net_remove (struct vhost_dev *dev); +uint16_t vs_enqueue_pkts (struct vhost_dev *dev,uint16_t queue_id, +struct rte_mbuf **pkts,uint32_t count); + +uint16_t vs_dequeue_pkts (struct vhost_dev *dev,uint16_t queue_id, +struct rte_mempool *mbuf_pool, +struct rte_mbuf **pkts,uint16_t count);#endif /* _MAIN_H_ */
examples/vhost/virtio_net.c new file +405 -0
405 lines not on this page · raw message
Signature · 1 line
1.9.0
Quoted 11 lines · Yuanhan Liu
This patchset makes DPDK vhost library generic enough, so that we could build other vhost-user drivers on top of it. For example, SPDK (Storage Performance Development Kit) is trying to enable vhost-user SCSI.
The basic idea is, let DPDK vhost be a vhost-user agent. It stores all the info about the virtio device (i.e. vring address, negotiated features, etc) and let the specific vhost-user driver to fetch them (by the API provided by DPDK vhost lib). With those info being provided, the vhost-user driver then could get/put vring entries, thus, it could exchange data between the guest and host.
Quoted 2 lines
The last patch demonstrates how to use these new APIs to implement a very simple vhost-user net driver, without any fancy features enabled.
Series applied to dpdk-next-virtio.
--yliu
Quoted 116 lines
Change log
==========v2: - rebase
- updated release note
- updated API comments
- renamedrte_vhost_get_vhost_memorytorte_vhost_get_mem_table- added a new device callback:
features_changed(), bascially for live migration support
- introducedrte_vhost_driver_start()to start a specific driver
- misc fixesv3: - rebaseon top of vhost-user socket fix
- fix reconnect
- fix shared build
- fix typosv4: - rebase
- let rte_vhost_get.*_features() to return features by parameter and return -1 on failure
- Follow the style of ring rework to update the release note: use one entry for all vhost changes and add sub items for each change.Major API/ABI Changes summary
=============================- some renames
* "structvirtio_net_device_ops" ==> "structvhost_device_ops"
* "rte_virtio_net.h" ==> "rte_vhost.h"- driver related APIs are bond with the socket file
*rte_vhost_driver_set_features(socket_file, features);
*rte_vhost_driver_get_features(socket_file, features);
*rte_vhost_driver_enable_features(socket_file, features)
*rte_vhost_driver_disable_features(socket_file, features)
*rte_vhost_driver_callback_register(socket_file, notify_ops);
*rte_vhost_driver_start(socket_file);
This function replacesrte_vhost_driver_session_start(). Check patch 18 for more information.- new APIs to fetch guest and vring info
*rte_vhost_get_mem_table(vid, mem);
*rte_vhost_get_negotiated_features(vid);
*rte_vhost_get_vhost_vring(vid, vring_idx, vring);- new exported structures
* structrte_vhost_vring
* structrte_vhost_mem_region
* structrte_vhost_memory- a new device ops callback:
features_changed().--yliu---
Yuanhan Liu (22):
vhost: introduce driver features related APIs net/vhost: remove feature related APIs
vhost: use new APIs to handle features
vhost: make notify ops per vhost driver
vhost: export guest memory regions
vhost: introduce API to fetch negotiated features
vhost: export vhost vring info
vhost: export API to translate gpa to vva
vhost: turn queue pair to vring
vhost: export the number of vrings
vhost: move the device ready check at proper place
vhost: drop the Rx and Tx queue macro
vhost: do not include net specific headers
vhost: rename device ops struct
vhost: rename virtio-net to vhost
vhost: add features changed callback
vhost: export APIs for live migration support
vhost: introduce API to start a specific driver
vhost: rename header file
vhost: workaround the build dependency on mbuf header
vhost: do not destroy device on repeat mem table message examples/vhost: demonstrate the new generic vhost APIsdoc/guides/prog_guide/vhost_lib.rst | 42 +-- doc/guides/rel_notes/deprecation.rst | 9 - doc/guides/rel_notes/release_17_05.rst | 43 +++ drivers/net/vhost/rte_eth_vhost.c | 101 ++----- drivers/net/vhost/rte_eth_vhost.h | 32 +-- drivers/net/vhost/rte_pmd_vhost_version.map | 3 - examples/tep_termination/main.c | 23 +- examples/tep_termination/main.h | 2 + examples/tep_termination/vxlan_setup.c | 2 +- examples/vhost/Makefile | 2 +- examples/vhost/main.c | 100 +++++-- examples/vhost/main.h | 32 ++- examples/vhost/virtio_net.c | 405 ++++++++++++++++++++++++++ lib/librte_vhost/Makefile | 4 +- lib/librte_vhost/fd_man.c | 9 +- lib/librte_vhost/fd_man.h | 2 +- lib/librte_vhost/rte_vhost.h | 427 ++++++++++++++++++++++++++++ lib/librte_vhost/rte_vhost_version.map | 16 +- lib/librte_vhost/rte_virtio_net.h | 208 -------------- lib/librte_vhost/socket.c | 229 ++++++++++++--- lib/librte_vhost/vhost.c | 230 ++++++++------- lib/librte_vhost/vhost.h | 113 +++++--- lib/librte_vhost/vhost_user.c | 121 ++++---- lib/librte_vhost/vhost_user.h | 2 +- lib/librte_vhost/virtio_net.c | 71 ++--- 25 files changed, 1541 insertions(+), 687 deletions(-) create mode 100644 examples/vhost/virtio_net.c create mode 100644 lib/librte_vhost/rte_vhost.h delete mode 100644 lib/librte_vhost/rte_virtio_net.hSignature · 1 line
1.9.0