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>
41 #ifdef RTE_LIBRTE_VHOST_NUMA
45 #include <sys/socket.h>
47 #include <rte_ethdev.h>
49 #include <rte_string_fns.h>
50 #include <rte_memory.h>
51 #include <rte_malloc.h>
52 #include <rte_virtio_net.h>
54 #include "vhost-net.h"
55 #include "virtio-net.h"
58 * Device linked list structure for configuration.
60 struct virtio_net_config_ll {
61 struct virtio_net dev; /* Virtio device.*/
62 struct virtio_net_config_ll *next; /* Next dev on linked list.*/
65 /* device ops to add/remove device to/from data core. */
66 struct virtio_net_device_ops const *notify_ops;
67 /* root address of the linked list of managed virtio devices */
68 static struct virtio_net_config_ll *ll_root;
70 /* Features supported by this lib. */
71 #define VHOST_SUPPORTED_FEATURES ((1ULL << VIRTIO_NET_F_MRG_RXBUF) | \
72 (1ULL << VIRTIO_NET_F_CTRL_VQ) | \
73 (1ULL << VIRTIO_NET_F_CTRL_RX) | \
74 (1ULL << VHOST_F_LOG_ALL))
75 static uint64_t VHOST_FEATURES = VHOST_SUPPORTED_FEATURES;
79 * Converts QEMU virtual address to Vhost virtual address. This function is
80 * used to convert the ring addresses to our address space.
83 qva_to_vva(struct virtio_net *dev, uint64_t qemu_va)
85 struct virtio_memory_regions *region;
86 uint64_t vhost_va = 0;
87 uint32_t regionidx = 0;
89 /* Find the region where the address lives. */
90 for (regionidx = 0; regionidx < dev->mem->nregions; regionidx++) {
91 region = &dev->mem->regions[regionidx];
92 if ((qemu_va >= region->userspace_address) &&
93 (qemu_va <= region->userspace_address +
94 region->memory_size)) {
95 vhost_va = qemu_va + region->guest_phys_address +
96 region->address_offset -
97 region->userspace_address;
106 * Retrieves an entry from the devices configuration linked list.
108 static struct virtio_net_config_ll *
109 get_config_ll_entry(struct vhost_device_ctx ctx)
111 struct virtio_net_config_ll *ll_dev = ll_root;
113 /* Loop through linked list until the device_fh is found. */
114 while (ll_dev != NULL) {
115 if (ll_dev->dev.device_fh == ctx.fh)
117 ll_dev = ll_dev->next;
124 * Searches the configuration core linked list and
125 * retrieves the device if it exists.
128 get_device(struct vhost_device_ctx ctx)
130 struct virtio_net_config_ll *ll_dev;
132 ll_dev = get_config_ll_entry(ctx);
137 RTE_LOG(ERR, VHOST_CONFIG,
138 "(%"PRIu64") Device not found in linked list.\n", ctx.fh);
143 * Add entry containing a device to the device configuration linked list.
146 add_config_ll_entry(struct virtio_net_config_ll *new_ll_dev)
148 struct virtio_net_config_ll *ll_dev = ll_root;
150 /* If ll_dev == NULL then this is the first device so go to else */
152 /* If the 1st device_fh != 0 then we insert our device here. */
153 if (ll_dev->dev.device_fh != 0) {
154 new_ll_dev->dev.device_fh = 0;
155 new_ll_dev->next = ll_dev;
156 ll_root = new_ll_dev;
159 * Increment through the ll until we find un unused
160 * device_fh. Insert the device at that entry.
162 while ((ll_dev->next != NULL) &&
163 (ll_dev->dev.device_fh ==
164 (ll_dev->next->dev.device_fh - 1)))
165 ll_dev = ll_dev->next;
167 new_ll_dev->dev.device_fh = ll_dev->dev.device_fh + 1;
168 new_ll_dev->next = ll_dev->next;
169 ll_dev->next = new_ll_dev;
172 ll_root = new_ll_dev;
173 ll_root->dev.device_fh = 0;
179 * Unmap any memory, close any file descriptors and
180 * free any memory owned by a device.
183 cleanup_device(struct virtio_net *dev)
185 /* Unmap QEMU memory file if mapped. */
187 munmap((void *)(uintptr_t)dev->mem->mapped_address,
188 (size_t)dev->mem->mapped_size);
192 /* Close any event notifiers opened by device. */
193 if ((int)dev->virtqueue[VIRTIO_RXQ]->callfd >= 0)
194 close((int)dev->virtqueue[VIRTIO_RXQ]->callfd);
195 if ((int)dev->virtqueue[VIRTIO_RXQ]->kickfd >= 0)
196 close((int)dev->virtqueue[VIRTIO_RXQ]->kickfd);
197 if ((int)dev->virtqueue[VIRTIO_TXQ]->callfd >= 0)
198 close((int)dev->virtqueue[VIRTIO_TXQ]->callfd);
199 if ((int)dev->virtqueue[VIRTIO_TXQ]->kickfd >= 0)
200 close((int)dev->virtqueue[VIRTIO_TXQ]->kickfd);
204 * Release virtqueues and device memory.
207 free_device(struct virtio_net_config_ll *ll_dev)
209 /* Free any malloc'd memory */
210 rte_free(ll_dev->dev.virtqueue[VIRTIO_RXQ]);
211 rte_free(ll_dev->dev.virtqueue[VIRTIO_TXQ]);
216 * Remove an entry from the device configuration linked list.
218 static struct virtio_net_config_ll *
219 rm_config_ll_entry(struct virtio_net_config_ll *ll_dev,
220 struct virtio_net_config_ll *ll_dev_last)
222 /* First remove the device and then clean it up. */
223 if (ll_dev == ll_root) {
224 ll_root = ll_dev->next;
225 cleanup_device(&ll_dev->dev);
229 if (likely(ll_dev_last != NULL)) {
230 ll_dev_last->next = ll_dev->next;
231 cleanup_device(&ll_dev->dev);
233 return ll_dev_last->next;
235 cleanup_device(&ll_dev->dev);
237 RTE_LOG(ERR, VHOST_CONFIG,
238 "Remove entry from config_ll failed\n");
245 * Initialise all variables in device structure.
248 init_device(struct virtio_net *dev)
253 * Virtqueues have already been malloced so
254 * we don't want to set them to NULL.
256 vq_offset = offsetof(struct virtio_net, mem);
258 /* Set everything to 0. */
259 memset((void *)(uintptr_t)((uint64_t)(uintptr_t)dev + vq_offset), 0,
260 (sizeof(struct virtio_net) - (size_t)vq_offset));
261 memset(dev->virtqueue[VIRTIO_RXQ], 0, sizeof(struct vhost_virtqueue));
262 memset(dev->virtqueue[VIRTIO_TXQ], 0, sizeof(struct vhost_virtqueue));
264 dev->virtqueue[VIRTIO_RXQ]->kickfd = (eventfd_t)-1;
265 dev->virtqueue[VIRTIO_RXQ]->callfd = (eventfd_t)-1;
266 dev->virtqueue[VIRTIO_TXQ]->kickfd = (eventfd_t)-1;
267 dev->virtqueue[VIRTIO_TXQ]->callfd = (eventfd_t)-1;
269 /* Backends are set to -1 indicating an inactive device. */
270 dev->virtqueue[VIRTIO_RXQ]->backend = VIRTIO_DEV_STOPPED;
271 dev->virtqueue[VIRTIO_TXQ]->backend = VIRTIO_DEV_STOPPED;
275 * Function is called from the CUSE open function. The device structure is
276 * initialised and a new entry is added to the device configuration linked
280 new_device(struct vhost_device_ctx ctx)
282 struct virtio_net_config_ll *new_ll_dev;
283 struct vhost_virtqueue *virtqueue_rx, *virtqueue_tx;
285 /* Setup device and virtqueues. */
286 new_ll_dev = rte_malloc(NULL, sizeof(struct virtio_net_config_ll), 0);
287 if (new_ll_dev == NULL) {
288 RTE_LOG(ERR, VHOST_CONFIG,
289 "(%"PRIu64") Failed to allocate memory for dev.\n",
294 virtqueue_rx = rte_malloc(NULL, sizeof(struct vhost_virtqueue), 0);
295 if (virtqueue_rx == NULL) {
296 rte_free(new_ll_dev);
297 RTE_LOG(ERR, VHOST_CONFIG,
298 "(%"PRIu64") Failed to allocate memory for rxq.\n",
303 virtqueue_tx = rte_malloc(NULL, sizeof(struct vhost_virtqueue), 0);
304 if (virtqueue_tx == NULL) {
305 rte_free(virtqueue_rx);
306 rte_free(new_ll_dev);
307 RTE_LOG(ERR, VHOST_CONFIG,
308 "(%"PRIu64") Failed to allocate memory for txq.\n",
313 new_ll_dev->dev.virtqueue[VIRTIO_RXQ] = virtqueue_rx;
314 new_ll_dev->dev.virtqueue[VIRTIO_TXQ] = virtqueue_tx;
316 /* Initialise device and virtqueues. */
317 init_device(&new_ll_dev->dev);
319 new_ll_dev->next = NULL;
321 /* Add entry to device configuration linked list. */
322 add_config_ll_entry(new_ll_dev);
324 return new_ll_dev->dev.device_fh;
328 * Function is called from the CUSE release function. This function will
329 * cleanup the device and remove it from device configuration linked list.
332 destroy_device(struct vhost_device_ctx ctx)
334 struct virtio_net_config_ll *ll_dev_cur_ctx, *ll_dev_last = NULL;
335 struct virtio_net_config_ll *ll_dev_cur = ll_root;
337 /* Find the linked list entry for the device to be removed. */
338 ll_dev_cur_ctx = get_config_ll_entry(ctx);
339 while (ll_dev_cur != NULL) {
341 * If the device is found or
342 * a device that doesn't exist is found then it is removed.
344 if (ll_dev_cur == ll_dev_cur_ctx) {
346 * If the device is running on a data core then call
347 * the function to remove it from the data core.
349 if ((ll_dev_cur->dev.flags & VIRTIO_DEV_RUNNING))
350 notify_ops->destroy_device(&(ll_dev_cur->dev));
351 ll_dev_cur = rm_config_ll_entry(ll_dev_cur,
354 ll_dev_last = ll_dev_cur;
355 ll_dev_cur = ll_dev_cur->next;
361 set_ifname(struct vhost_device_ctx ctx,
362 const char *if_name, unsigned int if_len)
364 struct virtio_net *dev;
367 dev = get_device(ctx);
371 len = if_len > sizeof(dev->ifname) ?
372 sizeof(dev->ifname) : if_len;
374 strncpy(dev->ifname, if_name, len);
379 * Called from CUSE IOCTL: VHOST_SET_OWNER
380 * This function just returns success at the moment unless
381 * the device hasn't been initialised.
384 set_owner(struct vhost_device_ctx ctx)
386 struct virtio_net *dev;
388 dev = get_device(ctx);
396 * Called from CUSE IOCTL: VHOST_RESET_OWNER
399 reset_owner(struct vhost_device_ctx ctx)
401 struct virtio_net_config_ll *ll_dev;
403 ll_dev = get_config_ll_entry(ctx);
405 cleanup_device(&ll_dev->dev);
406 init_device(&ll_dev->dev);
412 * Called from CUSE IOCTL: VHOST_GET_FEATURES
413 * The features that we support are requested.
416 get_features(struct vhost_device_ctx ctx, uint64_t *pu)
418 struct virtio_net *dev;
420 dev = get_device(ctx);
424 /* Send our supported features. */
425 *pu = VHOST_FEATURES;
430 * Called from CUSE IOCTL: VHOST_SET_FEATURES
431 * We receive the negotiated features supported by us and the virtio device.
434 set_features(struct vhost_device_ctx ctx, uint64_t *pu)
436 struct virtio_net *dev;
438 dev = get_device(ctx);
441 if (*pu & ~VHOST_FEATURES)
444 /* Store the negotiated feature list for the device. */
447 /* Set the vhost_hlen depending on if VIRTIO_NET_F_MRG_RXBUF is set. */
448 if (dev->features & (1 << VIRTIO_NET_F_MRG_RXBUF)) {
449 LOG_DEBUG(VHOST_CONFIG,
450 "(%"PRIu64") Mergeable RX buffers enabled\n",
452 dev->virtqueue[VIRTIO_RXQ]->vhost_hlen =
453 sizeof(struct virtio_net_hdr_mrg_rxbuf);
454 dev->virtqueue[VIRTIO_TXQ]->vhost_hlen =
455 sizeof(struct virtio_net_hdr_mrg_rxbuf);
457 LOG_DEBUG(VHOST_CONFIG,
458 "(%"PRIu64") Mergeable RX buffers disabled\n",
460 dev->virtqueue[VIRTIO_RXQ]->vhost_hlen =
461 sizeof(struct virtio_net_hdr);
462 dev->virtqueue[VIRTIO_TXQ]->vhost_hlen =
463 sizeof(struct virtio_net_hdr);
469 * Called from CUSE IOCTL: VHOST_SET_VRING_NUM
470 * The virtio device sends us the size of the descriptor ring.
473 set_vring_num(struct vhost_device_ctx ctx, struct vhost_vring_state *state)
475 struct virtio_net *dev;
477 dev = get_device(ctx);
481 /* State->index refers to the queue index. The txq is 1, rxq is 0. */
482 dev->virtqueue[state->index]->size = state->num;
488 * Reallocate virtio_det and vhost_virtqueue data structure to make them on the
489 * same numa node as the memory of vring descriptor.
491 #ifdef RTE_LIBRTE_VHOST_NUMA
492 static struct virtio_net*
493 numa_realloc(struct virtio_net *dev, int index)
495 int oldnode, newnode;
496 struct virtio_net_config_ll *old_ll_dev, *new_ll_dev = NULL;
497 struct vhost_virtqueue *old_vq, *new_vq = NULL;
499 int realloc_dev = 0, realloc_vq = 0;
501 old_ll_dev = (struct virtio_net_config_ll *)dev;
502 old_vq = dev->virtqueue[index];
504 ret = get_mempolicy(&newnode, NULL, 0, old_vq->desc,
505 MPOL_F_NODE | MPOL_F_ADDR);
506 ret = ret | get_mempolicy(&oldnode, NULL, 0, old_ll_dev,
507 MPOL_F_NODE | MPOL_F_ADDR);
509 RTE_LOG(ERR, VHOST_CONFIG,
510 "Unable to get vring desc or dev numa information.\n");
513 if (oldnode != newnode)
516 ret = get_mempolicy(&oldnode, NULL, 0, old_vq,
517 MPOL_F_NODE | MPOL_F_ADDR);
519 RTE_LOG(ERR, VHOST_CONFIG,
520 "Unable to get vq numa information.\n");
523 if (oldnode != newnode)
526 if (realloc_dev == 0 && realloc_vq == 0)
530 new_ll_dev = rte_malloc_socket(NULL,
531 sizeof(struct virtio_net_config_ll), 0, newnode);
533 new_vq = rte_malloc_socket(NULL,
534 sizeof(struct vhost_virtqueue), 0, newnode);
535 if (!new_ll_dev && !new_vq)
539 memcpy(new_vq, old_vq, sizeof(*new_vq));
541 memcpy(new_ll_dev, old_ll_dev, sizeof(*new_ll_dev));
542 (new_ll_dev ? new_ll_dev : old_ll_dev)->dev.virtqueue[index] =
543 new_vq ? new_vq : old_vq;
547 if (ll_root == old_ll_dev)
548 ll_root = new_ll_dev;
550 struct virtio_net_config_ll *prev = ll_root;
551 while (prev->next != old_ll_dev)
553 prev->next = new_ll_dev;
554 new_ll_dev->next = old_ll_dev->next;
556 rte_free(old_ll_dev);
559 return realloc_dev ? &new_ll_dev->dev : dev;
562 static struct virtio_net*
563 numa_realloc(struct virtio_net *dev, int index __rte_unused)
570 * Called from CUSE IOCTL: VHOST_SET_VRING_ADDR
571 * The virtio device sends us the desc, used and avail ring addresses.
572 * This function then converts these to our address space.
575 set_vring_addr(struct vhost_device_ctx ctx, struct vhost_vring_addr *addr)
577 struct virtio_net *dev;
578 struct vhost_virtqueue *vq;
580 dev = get_device(ctx);
584 /* addr->index refers to the queue index. The txq 1, rxq is 0. */
585 vq = dev->virtqueue[addr->index];
587 /* The addresses are converted from QEMU virtual to Vhost virtual. */
588 vq->desc = (struct vring_desc *)(uintptr_t)qva_to_vva(dev,
589 addr->desc_user_addr);
591 RTE_LOG(ERR, VHOST_CONFIG,
592 "(%"PRIu64") Failed to find desc ring address.\n",
597 dev = numa_realloc(dev, addr->index);
598 vq = dev->virtqueue[addr->index];
600 vq->avail = (struct vring_avail *)(uintptr_t)qva_to_vva(dev,
601 addr->avail_user_addr);
602 if (vq->avail == 0) {
603 RTE_LOG(ERR, VHOST_CONFIG,
604 "(%"PRIu64") Failed to find avail ring address.\n",
609 vq->used = (struct vring_used *)(uintptr_t)qva_to_vva(dev,
610 addr->used_user_addr);
612 RTE_LOG(ERR, VHOST_CONFIG,
613 "(%"PRIu64") Failed to find used ring address.\n",
618 LOG_DEBUG(VHOST_CONFIG, "(%"PRIu64") mapped address desc: %p\n",
619 dev->device_fh, vq->desc);
620 LOG_DEBUG(VHOST_CONFIG, "(%"PRIu64") mapped address avail: %p\n",
621 dev->device_fh, vq->avail);
622 LOG_DEBUG(VHOST_CONFIG, "(%"PRIu64") mapped address used: %p\n",
623 dev->device_fh, vq->used);
629 * Called from CUSE IOCTL: VHOST_SET_VRING_BASE
630 * The virtio device sends us the available ring last used index.
633 set_vring_base(struct vhost_device_ctx ctx, struct vhost_vring_state *state)
635 struct virtio_net *dev;
637 dev = get_device(ctx);
641 /* State->index refers to the queue index. The txq is 1, rxq is 0. */
642 dev->virtqueue[state->index]->last_used_idx = state->num;
643 dev->virtqueue[state->index]->last_used_idx_res = state->num;
649 * Called from CUSE IOCTL: VHOST_GET_VRING_BASE
650 * We send the virtio device our available ring last used index.
653 get_vring_base(struct vhost_device_ctx ctx, uint32_t index,
654 struct vhost_vring_state *state)
656 struct virtio_net *dev;
658 dev = get_device(ctx);
662 state->index = index;
663 /* State->index refers to the queue index. The txq is 1, rxq is 0. */
664 state->num = dev->virtqueue[state->index]->last_used_idx;
671 * Called from CUSE IOCTL: VHOST_SET_VRING_CALL
672 * The virtio device sends an eventfd to interrupt the guest. This fd gets
673 * copied into our process space.
676 set_vring_call(struct vhost_device_ctx ctx, struct vhost_vring_file *file)
678 struct virtio_net *dev;
679 struct vhost_virtqueue *vq;
681 dev = get_device(ctx);
685 /* file->index refers to the queue index. The txq is 1, rxq is 0. */
686 vq = dev->virtqueue[file->index];
688 if ((int)vq->callfd >= 0)
689 close((int)vq->callfd);
691 vq->callfd = file->fd;
697 * Called from CUSE IOCTL: VHOST_SET_VRING_KICK
698 * The virtio device sends an eventfd that it can use to notify us.
699 * This fd gets copied into our process space.
702 set_vring_kick(struct vhost_device_ctx ctx, struct vhost_vring_file *file)
704 struct virtio_net *dev;
705 struct vhost_virtqueue *vq;
707 dev = get_device(ctx);
711 /* file->index refers to the queue index. The txq is 1, rxq is 0. */
712 vq = dev->virtqueue[file->index];
714 if ((int)vq->kickfd >= 0)
715 close((int)vq->kickfd);
717 vq->kickfd = file->fd;
723 * Called from CUSE IOCTL: VHOST_NET_SET_BACKEND
724 * To complete device initialisation when the virtio driver is loaded,
725 * we are provided with a valid fd for a tap device (not used by us).
726 * If this happens then we can add the device to a data core.
727 * When the virtio driver is removed we get fd=-1.
728 * At that point we remove the device from the data core.
729 * The device will still exist in the device configuration linked list.
732 set_backend(struct vhost_device_ctx ctx, struct vhost_vring_file *file)
734 struct virtio_net *dev;
736 dev = get_device(ctx);
740 /* file->index refers to the queue index. The txq is 1, rxq is 0. */
741 dev->virtqueue[file->index]->backend = file->fd;
744 * If the device isn't already running and both backend fds are set,
747 if (!(dev->flags & VIRTIO_DEV_RUNNING)) {
748 if (((int)dev->virtqueue[VIRTIO_TXQ]->backend != VIRTIO_DEV_STOPPED) &&
749 ((int)dev->virtqueue[VIRTIO_RXQ]->backend != VIRTIO_DEV_STOPPED)) {
750 return notify_ops->new_device(dev);
752 /* Otherwise we remove it. */
754 if (file->fd == VIRTIO_DEV_STOPPED)
755 notify_ops->destroy_device(dev);
760 * Function pointers are set for the device operations to allow CUSE to call
761 * functions when an IOCTL, device_add or device_release is received.
763 static const struct vhost_net_device_ops vhost_device_ops = {
764 .new_device = new_device,
765 .destroy_device = destroy_device,
767 .set_ifname = set_ifname,
769 .get_features = get_features,
770 .set_features = set_features,
772 .set_vring_num = set_vring_num,
773 .set_vring_addr = set_vring_addr,
774 .set_vring_base = set_vring_base,
775 .get_vring_base = get_vring_base,
777 .set_vring_kick = set_vring_kick,
778 .set_vring_call = set_vring_call,
780 .set_backend = set_backend,
782 .set_owner = set_owner,
783 .reset_owner = reset_owner,
787 * Called by main to setup callbacks when registering CUSE device.
789 struct vhost_net_device_ops const *
790 get_virtio_net_callbacks(void)
792 return &vhost_device_ops;
795 int rte_vhost_enable_guest_notification(struct virtio_net *dev,
796 uint16_t queue_id, int enable)
799 RTE_LOG(ERR, VHOST_CONFIG,
800 "guest notification isn't supported.\n");
804 dev->virtqueue[queue_id]->used->flags =
805 enable ? 0 : VRING_USED_F_NO_NOTIFY;
809 uint64_t rte_vhost_feature_get(void)
811 return VHOST_FEATURES;
814 int rte_vhost_feature_disable(uint64_t feature_mask)
816 VHOST_FEATURES = VHOST_FEATURES & ~feature_mask;
820 int rte_vhost_feature_enable(uint64_t feature_mask)
822 if ((feature_mask & VHOST_SUPPORTED_FEATURES) == feature_mask) {
823 VHOST_FEATURES = VHOST_FEATURES | feature_mask;
830 * Register ops so that we can add/remove device to data core.
833 rte_vhost_driver_callback_register(struct virtio_net_device_ops const * const ops)