4 * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #include <linux/vhost.h>
35 #include <linux/virtio_net.h>
42 #ifdef RTE_LIBRTE_VHOST_NUMA
46 #include <sys/socket.h>
48 #include <rte_ethdev.h>
50 #include <rte_string_fns.h>
51 #include <rte_memory.h>
52 #include <rte_malloc.h>
53 #include <rte_virtio_net.h>
55 #include "vhost-net.h"
56 #include "virtio-net.h"
59 * Device linked list structure for configuration.
61 struct virtio_net_config_ll {
62 struct virtio_net dev; /* Virtio device.*/
63 struct virtio_net_config_ll *next; /* Next dev on linked list.*/
66 /* device ops to add/remove device to/from data core. */
67 struct virtio_net_device_ops const *notify_ops;
68 /* root address of the linked list of managed virtio devices */
69 static struct virtio_net_config_ll *ll_root;
71 #define VHOST_USER_F_PROTOCOL_FEATURES 30
73 /* Features supported by this lib. */
74 #define VHOST_SUPPORTED_FEATURES ((1ULL << VIRTIO_NET_F_MRG_RXBUF) | \
75 (1ULL << VIRTIO_NET_F_CTRL_VQ) | \
76 (1ULL << VIRTIO_NET_F_CTRL_RX) | \
77 (1ULL << VIRTIO_NET_F_GUEST_ANNOUNCE) | \
78 (VHOST_SUPPORTS_MQ) | \
79 (1ULL << VIRTIO_F_VERSION_1) | \
80 (1ULL << VHOST_F_LOG_ALL) | \
81 (1ULL << VHOST_USER_F_PROTOCOL_FEATURES) | \
82 (1ULL << VIRTIO_NET_F_HOST_TSO4) | \
83 (1ULL << VIRTIO_NET_F_HOST_TSO6) | \
84 (1ULL << VIRTIO_NET_F_CSUM) | \
85 (1ULL << VIRTIO_NET_F_GUEST_CSUM) | \
86 (1ULL << VIRTIO_NET_F_GUEST_TSO4) | \
87 (1ULL << VIRTIO_NET_F_GUEST_TSO6))
89 static uint64_t VHOST_FEATURES = VHOST_SUPPORTED_FEATURES;
93 * Converts QEMU virtual address to Vhost virtual address. This function is
94 * used to convert the ring addresses to our address space.
97 qva_to_vva(struct virtio_net *dev, uint64_t qemu_va)
99 struct virtio_memory_regions *region;
100 uint64_t vhost_va = 0;
101 uint32_t regionidx = 0;
103 /* Find the region where the address lives. */
104 for (regionidx = 0; regionidx < dev->mem->nregions; regionidx++) {
105 region = &dev->mem->regions[regionidx];
106 if ((qemu_va >= region->userspace_address) &&
107 (qemu_va <= region->userspace_address +
108 region->memory_size)) {
109 vhost_va = qemu_va + region->guest_phys_address +
110 region->address_offset -
111 region->userspace_address;
120 * Retrieves an entry from the devices configuration linked list.
122 static struct virtio_net_config_ll *
123 get_config_ll_entry(struct vhost_device_ctx ctx)
125 struct virtio_net_config_ll *ll_dev = ll_root;
127 /* Loop through linked list until the device_fh is found. */
128 while (ll_dev != NULL) {
129 if (ll_dev->dev.device_fh == ctx.fh)
131 ll_dev = ll_dev->next;
138 * Searches the configuration core linked list and
139 * retrieves the device if it exists.
142 get_device(struct vhost_device_ctx ctx)
144 struct virtio_net_config_ll *ll_dev;
146 ll_dev = get_config_ll_entry(ctx);
151 RTE_LOG(ERR, VHOST_CONFIG,
152 "(%"PRIu64") Device not found in linked list.\n", ctx.fh);
157 * Add entry containing a device to the device configuration linked list.
160 add_config_ll_entry(struct virtio_net_config_ll *new_ll_dev)
162 struct virtio_net_config_ll *ll_dev = ll_root;
164 /* If ll_dev == NULL then this is the first device so go to else */
166 /* If the 1st device_fh != 0 then we insert our device here. */
167 if (ll_dev->dev.device_fh != 0) {
168 new_ll_dev->dev.device_fh = 0;
169 new_ll_dev->next = ll_dev;
170 ll_root = new_ll_dev;
173 * Increment through the ll until we find un unused
174 * device_fh. Insert the device at that entry.
176 while ((ll_dev->next != NULL) &&
177 (ll_dev->dev.device_fh ==
178 (ll_dev->next->dev.device_fh - 1)))
179 ll_dev = ll_dev->next;
181 new_ll_dev->dev.device_fh = ll_dev->dev.device_fh + 1;
182 new_ll_dev->next = ll_dev->next;
183 ll_dev->next = new_ll_dev;
186 ll_root = new_ll_dev;
187 ll_root->dev.device_fh = 0;
193 cleanup_vq(struct vhost_virtqueue *vq, int destroy)
195 if ((vq->callfd >= 0) && (destroy != 0))
202 * Unmap any memory, close any file descriptors and
203 * free any memory owned by a device.
206 cleanup_device(struct virtio_net *dev, int destroy)
210 vhost_backend_cleanup(dev);
212 for (i = 0; i < dev->virt_qp_nb; i++) {
213 cleanup_vq(dev->virtqueue[i * VIRTIO_QNUM + VIRTIO_RXQ], destroy);
214 cleanup_vq(dev->virtqueue[i * VIRTIO_QNUM + VIRTIO_TXQ], destroy);
219 * Release virtqueues and device memory.
222 free_device(struct virtio_net_config_ll *ll_dev)
226 for (i = 0; i < ll_dev->dev.virt_qp_nb; i++)
227 rte_free(ll_dev->dev.virtqueue[i * VIRTIO_QNUM]);
233 * Remove an entry from the device configuration linked list.
235 static struct virtio_net_config_ll *
236 rm_config_ll_entry(struct virtio_net_config_ll *ll_dev,
237 struct virtio_net_config_ll *ll_dev_last)
239 /* First remove the device and then clean it up. */
240 if (ll_dev == ll_root) {
241 ll_root = ll_dev->next;
242 cleanup_device(&ll_dev->dev, 1);
246 if (likely(ll_dev_last != NULL)) {
247 ll_dev_last->next = ll_dev->next;
248 cleanup_device(&ll_dev->dev, 1);
250 return ll_dev_last->next;
252 cleanup_device(&ll_dev->dev, 1);
254 RTE_LOG(ERR, VHOST_CONFIG,
255 "Remove entry from config_ll failed\n");
262 init_vring_queue(struct vhost_virtqueue *vq, int qp_idx)
264 memset(vq, 0, sizeof(struct vhost_virtqueue));
269 /* Backends are set to -1 indicating an inactive device. */
272 /* always set the default vq pair to enabled */
278 init_vring_queue_pair(struct virtio_net *dev, uint32_t qp_idx)
280 uint32_t base_idx = qp_idx * VIRTIO_QNUM;
282 init_vring_queue(dev->virtqueue[base_idx + VIRTIO_RXQ], qp_idx);
283 init_vring_queue(dev->virtqueue[base_idx + VIRTIO_TXQ], qp_idx);
287 reset_vring_queue(struct vhost_virtqueue *vq, int qp_idx)
292 init_vring_queue(vq, qp_idx);
297 reset_vring_queue_pair(struct virtio_net *dev, uint32_t qp_idx)
299 uint32_t base_idx = qp_idx * VIRTIO_QNUM;
301 reset_vring_queue(dev->virtqueue[base_idx + VIRTIO_RXQ], qp_idx);
302 reset_vring_queue(dev->virtqueue[base_idx + VIRTIO_TXQ], qp_idx);
306 alloc_vring_queue_pair(struct virtio_net *dev, uint32_t qp_idx)
308 struct vhost_virtqueue *virtqueue = NULL;
309 uint32_t virt_rx_q_idx = qp_idx * VIRTIO_QNUM + VIRTIO_RXQ;
310 uint32_t virt_tx_q_idx = qp_idx * VIRTIO_QNUM + VIRTIO_TXQ;
312 virtqueue = rte_malloc(NULL,
313 sizeof(struct vhost_virtqueue) * VIRTIO_QNUM, 0);
314 if (virtqueue == NULL) {
315 RTE_LOG(ERR, VHOST_CONFIG,
316 "Failed to allocate memory for virt qp:%d.\n", qp_idx);
320 dev->virtqueue[virt_rx_q_idx] = virtqueue;
321 dev->virtqueue[virt_tx_q_idx] = virtqueue + VIRTIO_TXQ;
323 init_vring_queue_pair(dev, qp_idx);
325 dev->virt_qp_nb += 1;
331 * Reset some variables in device structure, while keeping few
332 * others untouched, such as device_fh, ifname, virt_qp_nb: they
333 * should be same unless the device is removed.
336 reset_device(struct virtio_net *dev)
341 dev->protocol_features = 0;
344 for (i = 0; i < dev->virt_qp_nb; i++)
345 reset_vring_queue_pair(dev, i);
349 * Function is called from the CUSE open function. The device structure is
350 * initialised and a new entry is added to the device configuration linked
354 vhost_new_device(struct vhost_device_ctx ctx)
356 struct virtio_net_config_ll *new_ll_dev;
358 /* Setup device and virtqueues. */
359 new_ll_dev = rte_zmalloc(NULL, sizeof(struct virtio_net_config_ll), 0);
360 if (new_ll_dev == NULL) {
361 RTE_LOG(ERR, VHOST_CONFIG,
362 "(%"PRIu64") Failed to allocate memory for dev.\n",
367 new_ll_dev->next = NULL;
369 /* Add entry to device configuration linked list. */
370 add_config_ll_entry(new_ll_dev);
372 return new_ll_dev->dev.device_fh;
376 * Function is called from the CUSE release function. This function will
377 * cleanup the device and remove it from device configuration linked list.
380 vhost_destroy_device(struct vhost_device_ctx ctx)
382 struct virtio_net_config_ll *ll_dev_cur_ctx, *ll_dev_last = NULL;
383 struct virtio_net_config_ll *ll_dev_cur = ll_root;
385 /* Find the linked list entry for the device to be removed. */
386 ll_dev_cur_ctx = get_config_ll_entry(ctx);
387 while (ll_dev_cur != NULL) {
389 * If the device is found or
390 * a device that doesn't exist is found then it is removed.
392 if (ll_dev_cur == ll_dev_cur_ctx) {
394 * If the device is running on a data core then call
395 * the function to remove it from the data core.
397 if ((ll_dev_cur->dev.flags & VIRTIO_DEV_RUNNING))
398 notify_ops->destroy_device(&(ll_dev_cur->dev));
399 ll_dev_cur = rm_config_ll_entry(ll_dev_cur,
402 ll_dev_last = ll_dev_cur;
403 ll_dev_cur = ll_dev_cur->next;
409 vhost_set_ifname(struct vhost_device_ctx ctx,
410 const char *if_name, unsigned int if_len)
412 struct virtio_net *dev;
415 dev = get_device(ctx);
419 len = if_len > sizeof(dev->ifname) ?
420 sizeof(dev->ifname) : if_len;
422 strncpy(dev->ifname, if_name, len);
427 * Called from CUSE IOCTL: VHOST_SET_OWNER
428 * This function just returns success at the moment unless
429 * the device hasn't been initialised.
432 vhost_set_owner(struct vhost_device_ctx ctx)
434 struct virtio_net *dev;
436 dev = get_device(ctx);
444 * Called from CUSE IOCTL: VHOST_RESET_OWNER
447 vhost_reset_owner(struct vhost_device_ctx ctx)
449 struct virtio_net *dev;
451 dev = get_device(ctx);
455 if (dev->flags & VIRTIO_DEV_RUNNING)
456 notify_ops->destroy_device(dev);
458 cleanup_device(dev, 0);
464 * Called from CUSE IOCTL: VHOST_GET_FEATURES
465 * The features that we support are requested.
468 vhost_get_features(struct vhost_device_ctx ctx, uint64_t *pu)
470 struct virtio_net *dev;
472 dev = get_device(ctx);
476 /* Send our supported features. */
477 *pu = VHOST_FEATURES;
482 * Called from CUSE IOCTL: VHOST_SET_FEATURES
483 * We receive the negotiated features supported by us and the virtio device.
486 vhost_set_features(struct vhost_device_ctx ctx, uint64_t *pu)
488 struct virtio_net *dev;
492 dev = get_device(ctx);
495 if (*pu & ~VHOST_FEATURES)
500 ((1 << VIRTIO_NET_F_MRG_RXBUF) | (1ULL << VIRTIO_F_VERSION_1))) {
501 vhost_hlen = sizeof(struct virtio_net_hdr_mrg_rxbuf);
503 vhost_hlen = sizeof(struct virtio_net_hdr);
505 LOG_DEBUG(VHOST_CONFIG,
506 "(%"PRIu64") Mergeable RX buffers %s, virtio 1 %s\n",
508 (dev->features & (1 << VIRTIO_NET_F_MRG_RXBUF)) ? "on" : "off",
509 (dev->features & (1ULL << VIRTIO_F_VERSION_1)) ? "on" : "off");
511 for (i = 0; i < dev->virt_qp_nb; i++) {
512 uint16_t base_idx = i * VIRTIO_QNUM;
514 dev->virtqueue[base_idx + VIRTIO_RXQ]->vhost_hlen = vhost_hlen;
515 dev->virtqueue[base_idx + VIRTIO_TXQ]->vhost_hlen = vhost_hlen;
522 * Called from CUSE IOCTL: VHOST_SET_VRING_NUM
523 * The virtio device sends us the size of the descriptor ring.
526 vhost_set_vring_num(struct vhost_device_ctx ctx,
527 struct vhost_vring_state *state)
529 struct virtio_net *dev;
531 dev = get_device(ctx);
535 /* State->index refers to the queue index. The txq is 1, rxq is 0. */
536 dev->virtqueue[state->index]->size = state->num;
542 * Reallocate virtio_dev and vhost_virtqueue data structure to make them on the
543 * same numa node as the memory of vring descriptor.
545 #ifdef RTE_LIBRTE_VHOST_NUMA
546 static struct virtio_net*
547 numa_realloc(struct virtio_net *dev, int index)
549 int oldnode, newnode;
550 struct virtio_net_config_ll *old_ll_dev, *new_ll_dev = NULL;
551 struct vhost_virtqueue *old_vq, *new_vq = NULL;
553 int realloc_dev = 0, realloc_vq = 0;
555 old_ll_dev = (struct virtio_net_config_ll *)dev;
556 old_vq = dev->virtqueue[index];
558 ret = get_mempolicy(&newnode, NULL, 0, old_vq->desc,
559 MPOL_F_NODE | MPOL_F_ADDR);
560 ret = ret | get_mempolicy(&oldnode, NULL, 0, old_ll_dev,
561 MPOL_F_NODE | MPOL_F_ADDR);
563 RTE_LOG(ERR, VHOST_CONFIG,
564 "Unable to get vring desc or dev numa information.\n");
567 if (oldnode != newnode)
570 ret = get_mempolicy(&oldnode, NULL, 0, old_vq,
571 MPOL_F_NODE | MPOL_F_ADDR);
573 RTE_LOG(ERR, VHOST_CONFIG,
574 "Unable to get vq numa information.\n");
577 if (oldnode != newnode)
580 if (realloc_dev == 0 && realloc_vq == 0)
584 new_ll_dev = rte_malloc_socket(NULL,
585 sizeof(struct virtio_net_config_ll), 0, newnode);
587 new_vq = rte_malloc_socket(NULL,
588 sizeof(struct vhost_virtqueue), 0, newnode);
589 if (!new_ll_dev && !new_vq)
593 memcpy(new_vq, old_vq, sizeof(*new_vq));
595 memcpy(new_ll_dev, old_ll_dev, sizeof(*new_ll_dev));
596 (new_ll_dev ? new_ll_dev : old_ll_dev)->dev.virtqueue[index] =
597 new_vq ? new_vq : old_vq;
601 if (ll_root == old_ll_dev)
602 ll_root = new_ll_dev;
604 struct virtio_net_config_ll *prev = ll_root;
605 while (prev->next != old_ll_dev)
607 prev->next = new_ll_dev;
608 new_ll_dev->next = old_ll_dev->next;
610 rte_free(old_ll_dev);
613 return realloc_dev ? &new_ll_dev->dev : dev;
616 static struct virtio_net*
617 numa_realloc(struct virtio_net *dev, int index __rte_unused)
624 * Called from CUSE IOCTL: VHOST_SET_VRING_ADDR
625 * The virtio device sends us the desc, used and avail ring addresses.
626 * This function then converts these to our address space.
629 vhost_set_vring_addr(struct vhost_device_ctx ctx, struct vhost_vring_addr *addr)
631 struct virtio_net *dev;
632 struct vhost_virtqueue *vq;
634 dev = get_device(ctx);
635 if ((dev == NULL) || (dev->mem == NULL))
638 /* addr->index refers to the queue index. The txq 1, rxq is 0. */
639 vq = dev->virtqueue[addr->index];
641 /* The addresses are converted from QEMU virtual to Vhost virtual. */
642 vq->desc = (struct vring_desc *)(uintptr_t)qva_to_vva(dev,
643 addr->desc_user_addr);
645 RTE_LOG(ERR, VHOST_CONFIG,
646 "(%"PRIu64") Failed to find desc ring address.\n",
651 dev = numa_realloc(dev, addr->index);
652 vq = dev->virtqueue[addr->index];
654 vq->avail = (struct vring_avail *)(uintptr_t)qva_to_vva(dev,
655 addr->avail_user_addr);
656 if (vq->avail == 0) {
657 RTE_LOG(ERR, VHOST_CONFIG,
658 "(%"PRIu64") Failed to find avail ring address.\n",
663 vq->used = (struct vring_used *)(uintptr_t)qva_to_vva(dev,
664 addr->used_user_addr);
666 RTE_LOG(ERR, VHOST_CONFIG,
667 "(%"PRIu64") Failed to find used ring address.\n",
672 vq->log_guest_addr = addr->log_guest_addr;
674 LOG_DEBUG(VHOST_CONFIG, "(%"PRIu64") mapped address desc: %p\n",
675 dev->device_fh, vq->desc);
676 LOG_DEBUG(VHOST_CONFIG, "(%"PRIu64") mapped address avail: %p\n",
677 dev->device_fh, vq->avail);
678 LOG_DEBUG(VHOST_CONFIG, "(%"PRIu64") mapped address used: %p\n",
679 dev->device_fh, vq->used);
680 LOG_DEBUG(VHOST_CONFIG, "(%"PRIu64") log_guest_addr: %"PRIx64"\n",
681 dev->device_fh, vq->log_guest_addr);
687 * Called from CUSE IOCTL: VHOST_SET_VRING_BASE
688 * The virtio device sends us the available ring last used index.
691 vhost_set_vring_base(struct vhost_device_ctx ctx,
692 struct vhost_vring_state *state)
694 struct virtio_net *dev;
696 dev = get_device(ctx);
700 /* State->index refers to the queue index. The txq is 1, rxq is 0. */
701 dev->virtqueue[state->index]->last_used_idx = state->num;
702 dev->virtqueue[state->index]->last_used_idx_res = state->num;
708 * Called from CUSE IOCTL: VHOST_GET_VRING_BASE
709 * We send the virtio device our available ring last used index.
712 vhost_get_vring_base(struct vhost_device_ctx ctx, uint32_t index,
713 struct vhost_vring_state *state)
715 struct virtio_net *dev;
717 dev = get_device(ctx);
721 state->index = index;
722 /* State->index refers to the queue index. The txq is 1, rxq is 0. */
723 state->num = dev->virtqueue[state->index]->last_used_idx;
730 * Called from CUSE IOCTL: VHOST_SET_VRING_CALL
731 * The virtio device sends an eventfd to interrupt the guest. This fd gets
732 * copied into our process space.
735 vhost_set_vring_call(struct vhost_device_ctx ctx, struct vhost_vring_file *file)
737 struct virtio_net *dev;
738 struct vhost_virtqueue *vq;
739 uint32_t cur_qp_idx = file->index / VIRTIO_QNUM;
741 dev = get_device(ctx);
746 * FIXME: VHOST_SET_VRING_CALL is the first per-vring message
747 * we get, so we do vring queue pair allocation here.
749 if (cur_qp_idx + 1 > dev->virt_qp_nb) {
750 if (alloc_vring_queue_pair(dev, cur_qp_idx) < 0)
754 /* file->index refers to the queue index. The txq is 1, rxq is 0. */
755 vq = dev->virtqueue[file->index];
761 vq->callfd = file->fd;
767 * Called from CUSE IOCTL: VHOST_SET_VRING_KICK
768 * The virtio device sends an eventfd that it can use to notify us.
769 * This fd gets copied into our process space.
772 vhost_set_vring_kick(struct vhost_device_ctx ctx, struct vhost_vring_file *file)
774 struct virtio_net *dev;
775 struct vhost_virtqueue *vq;
777 dev = get_device(ctx);
781 /* file->index refers to the queue index. The txq is 1, rxq is 0. */
782 vq = dev->virtqueue[file->index];
787 vq->kickfd = file->fd;
793 * Called from CUSE IOCTL: VHOST_NET_SET_BACKEND
794 * To complete device initialisation when the virtio driver is loaded,
795 * we are provided with a valid fd for a tap device (not used by us).
796 * If this happens then we can add the device to a data core.
797 * When the virtio driver is removed we get fd=-1.
798 * At that point we remove the device from the data core.
799 * The device will still exist in the device configuration linked list.
802 vhost_set_backend(struct vhost_device_ctx ctx, struct vhost_vring_file *file)
804 struct virtio_net *dev;
806 dev = get_device(ctx);
810 /* file->index refers to the queue index. The txq is 1, rxq is 0. */
811 dev->virtqueue[file->index]->backend = file->fd;
814 * If the device isn't already running and both backend fds are set,
817 if (!(dev->flags & VIRTIO_DEV_RUNNING)) {
818 if (((int)dev->virtqueue[VIRTIO_TXQ]->backend != VIRTIO_DEV_STOPPED) &&
819 ((int)dev->virtqueue[VIRTIO_RXQ]->backend != VIRTIO_DEV_STOPPED)) {
820 return notify_ops->new_device(dev);
822 /* Otherwise we remove it. */
824 if (file->fd == VIRTIO_DEV_STOPPED)
825 notify_ops->destroy_device(dev);
829 int rte_vhost_enable_guest_notification(struct virtio_net *dev,
830 uint16_t queue_id, int enable)
833 RTE_LOG(ERR, VHOST_CONFIG,
834 "guest notification isn't supported.\n");
838 dev->virtqueue[queue_id]->used->flags = VRING_USED_F_NO_NOTIFY;
842 uint64_t rte_vhost_feature_get(void)
844 return VHOST_FEATURES;
847 int rte_vhost_feature_disable(uint64_t feature_mask)
849 VHOST_FEATURES = VHOST_FEATURES & ~feature_mask;
853 int rte_vhost_feature_enable(uint64_t feature_mask)
855 if ((feature_mask & VHOST_SUPPORTED_FEATURES) == feature_mask) {
856 VHOST_FEATURES = VHOST_FEATURES | feature_mask;
863 * Register ops so that we can add/remove device to data core.
866 rte_vhost_driver_callback_register(struct virtio_net_device_ops const * const ops)