4 * Copyright(c) 2010-2016 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.
40 #include <sys/types.h>
43 #ifdef RTE_LIBRTE_VHOST_NUMA
47 #include <rte_common.h>
48 #include <rte_malloc.h>
52 #include "vhost_user.h"
54 static const char *vhost_message_str[VHOST_USER_MAX] = {
55 [VHOST_USER_NONE] = "VHOST_USER_NONE",
56 [VHOST_USER_GET_FEATURES] = "VHOST_USER_GET_FEATURES",
57 [VHOST_USER_SET_FEATURES] = "VHOST_USER_SET_FEATURES",
58 [VHOST_USER_SET_OWNER] = "VHOST_USER_SET_OWNER",
59 [VHOST_USER_RESET_OWNER] = "VHOST_USER_RESET_OWNER",
60 [VHOST_USER_SET_MEM_TABLE] = "VHOST_USER_SET_MEM_TABLE",
61 [VHOST_USER_SET_LOG_BASE] = "VHOST_USER_SET_LOG_BASE",
62 [VHOST_USER_SET_LOG_FD] = "VHOST_USER_SET_LOG_FD",
63 [VHOST_USER_SET_VRING_NUM] = "VHOST_USER_SET_VRING_NUM",
64 [VHOST_USER_SET_VRING_ADDR] = "VHOST_USER_SET_VRING_ADDR",
65 [VHOST_USER_SET_VRING_BASE] = "VHOST_USER_SET_VRING_BASE",
66 [VHOST_USER_GET_VRING_BASE] = "VHOST_USER_GET_VRING_BASE",
67 [VHOST_USER_SET_VRING_KICK] = "VHOST_USER_SET_VRING_KICK",
68 [VHOST_USER_SET_VRING_CALL] = "VHOST_USER_SET_VRING_CALL",
69 [VHOST_USER_SET_VRING_ERR] = "VHOST_USER_SET_VRING_ERR",
70 [VHOST_USER_GET_PROTOCOL_FEATURES] = "VHOST_USER_GET_PROTOCOL_FEATURES",
71 [VHOST_USER_SET_PROTOCOL_FEATURES] = "VHOST_USER_SET_PROTOCOL_FEATURES",
72 [VHOST_USER_GET_QUEUE_NUM] = "VHOST_USER_GET_QUEUE_NUM",
73 [VHOST_USER_SET_VRING_ENABLE] = "VHOST_USER_SET_VRING_ENABLE",
74 [VHOST_USER_SEND_RARP] = "VHOST_USER_SEND_RARP",
83 ret = fstat(fd, &stat);
84 return ret == -1 ? (uint64_t)-1 : (uint64_t)stat.st_blksize;
88 free_mem_region(struct virtio_net *dev)
91 struct virtio_memory_region *reg;
93 if (!dev || !dev->mem)
96 for (i = 0; i < dev->mem->nregions; i++) {
97 reg = &dev->mem->regions[i];
98 if (reg->host_user_addr) {
99 munmap(reg->mmap_addr, reg->mmap_size);
106 vhost_backend_cleanup(struct virtio_net *dev)
109 free_mem_region(dev);
114 munmap((void *)(uintptr_t)dev->log_addr, dev->log_size);
120 * This function just returns success at the moment unless
121 * the device hasn't been initialised.
124 vhost_user_set_owner(void)
130 vhost_user_reset_owner(struct virtio_net *dev)
132 if (dev->flags & VIRTIO_DEV_RUNNING) {
133 dev->flags &= ~VIRTIO_DEV_RUNNING;
134 notify_ops->destroy_device(dev->vid);
137 cleanup_device(dev, 0);
143 * The features that we support are requested.
146 vhost_user_get_features(void)
148 return VHOST_FEATURES;
152 * We receive the negotiated features supported by us and the virtio device.
155 vhost_user_set_features(struct virtio_net *dev, uint64_t features)
157 if (features & ~VHOST_FEATURES)
160 dev->features = features;
162 ((1 << VIRTIO_NET_F_MRG_RXBUF) | (1ULL << VIRTIO_F_VERSION_1))) {
163 dev->vhost_hlen = sizeof(struct virtio_net_hdr_mrg_rxbuf);
165 dev->vhost_hlen = sizeof(struct virtio_net_hdr);
167 LOG_DEBUG(VHOST_CONFIG,
168 "(%d) mergeable RX buffers %s, virtio 1 %s\n",
170 (dev->features & (1 << VIRTIO_NET_F_MRG_RXBUF)) ? "on" : "off",
171 (dev->features & (1ULL << VIRTIO_F_VERSION_1)) ? "on" : "off");
177 * The virtio device sends us the size of the descriptor ring.
180 vhost_user_set_vring_num(struct virtio_net *dev,
181 struct vhost_vring_state *state)
183 dev->virtqueue[state->index]->size = state->num;
189 * Reallocate virtio_dev and vhost_virtqueue data structure to make them on the
190 * same numa node as the memory of vring descriptor.
192 #ifdef RTE_LIBRTE_VHOST_NUMA
193 static struct virtio_net*
194 numa_realloc(struct virtio_net *dev, int index)
196 int oldnode, newnode;
197 struct virtio_net *old_dev;
198 struct vhost_virtqueue *old_vq, *vq;
202 * vq is allocated on pairs, we should try to do realloc
203 * on first queue of one queue pair only.
205 if (index % VIRTIO_QNUM != 0)
209 vq = old_vq = dev->virtqueue[index];
211 ret = get_mempolicy(&newnode, NULL, 0, old_vq->desc,
212 MPOL_F_NODE | MPOL_F_ADDR);
214 /* check if we need to reallocate vq */
215 ret |= get_mempolicy(&oldnode, NULL, 0, old_vq,
216 MPOL_F_NODE | MPOL_F_ADDR);
218 RTE_LOG(ERR, VHOST_CONFIG,
219 "Unable to get vq numa information.\n");
222 if (oldnode != newnode) {
223 RTE_LOG(INFO, VHOST_CONFIG,
224 "reallocate vq from %d to %d node\n", oldnode, newnode);
225 vq = rte_malloc_socket(NULL, sizeof(*vq) * VIRTIO_QNUM, 0,
230 memcpy(vq, old_vq, sizeof(*vq) * VIRTIO_QNUM);
234 /* check if we need to reallocate dev */
235 ret = get_mempolicy(&oldnode, NULL, 0, old_dev,
236 MPOL_F_NODE | MPOL_F_ADDR);
238 RTE_LOG(ERR, VHOST_CONFIG,
239 "Unable to get dev numa information.\n");
242 if (oldnode != newnode) {
243 RTE_LOG(INFO, VHOST_CONFIG,
244 "reallocate dev from %d to %d node\n",
246 dev = rte_malloc_socket(NULL, sizeof(*dev), 0, newnode);
252 memcpy(dev, old_dev, sizeof(*dev));
257 dev->virtqueue[index] = vq;
258 dev->virtqueue[index + 1] = vq + 1;
259 vhost_devices[dev->vid] = dev;
264 static struct virtio_net*
265 numa_realloc(struct virtio_net *dev, int index __rte_unused)
272 * Converts QEMU virtual address to Vhost virtual address. This function is
273 * used to convert the ring addresses to our address space.
276 qva_to_vva(struct virtio_net *dev, uint64_t qva)
278 struct virtio_memory_region *reg;
281 /* Find the region where the address lives. */
282 for (i = 0; i < dev->mem->nregions; i++) {
283 reg = &dev->mem->regions[i];
285 if (qva >= reg->guest_user_addr &&
286 qva < reg->guest_user_addr + reg->size) {
287 return qva - reg->guest_user_addr +
296 * The virtio device sends us the desc, used and avail ring addresses.
297 * This function then converts these to our address space.
300 vhost_user_set_vring_addr(struct virtio_net *dev, struct vhost_vring_addr *addr)
302 struct vhost_virtqueue *vq;
304 if (dev->mem == NULL)
307 /* addr->index refers to the queue index. The txq 1, rxq is 0. */
308 vq = dev->virtqueue[addr->index];
310 /* The addresses are converted from QEMU virtual to Vhost virtual. */
311 vq->desc = (struct vring_desc *)(uintptr_t)qva_to_vva(dev,
312 addr->desc_user_addr);
314 RTE_LOG(ERR, VHOST_CONFIG,
315 "(%d) failed to find desc ring address.\n",
320 dev = numa_realloc(dev, addr->index);
321 vq = dev->virtqueue[addr->index];
323 vq->avail = (struct vring_avail *)(uintptr_t)qva_to_vva(dev,
324 addr->avail_user_addr);
325 if (vq->avail == 0) {
326 RTE_LOG(ERR, VHOST_CONFIG,
327 "(%d) failed to find avail ring address.\n",
332 vq->used = (struct vring_used *)(uintptr_t)qva_to_vva(dev,
333 addr->used_user_addr);
335 RTE_LOG(ERR, VHOST_CONFIG,
336 "(%d) failed to find used ring address.\n",
341 if (vq->last_used_idx != vq->used->idx) {
342 RTE_LOG(WARNING, VHOST_CONFIG,
343 "last_used_idx (%u) and vq->used->idx (%u) mismatches; "
344 "some packets maybe resent for Tx and dropped for Rx\n",
345 vq->last_used_idx, vq->used->idx);
346 vq->last_used_idx = vq->used->idx;
349 vq->log_guest_addr = addr->log_guest_addr;
351 LOG_DEBUG(VHOST_CONFIG, "(%d) mapped address desc: %p\n",
353 LOG_DEBUG(VHOST_CONFIG, "(%d) mapped address avail: %p\n",
354 dev->vid, vq->avail);
355 LOG_DEBUG(VHOST_CONFIG, "(%d) mapped address used: %p\n",
357 LOG_DEBUG(VHOST_CONFIG, "(%d) log_guest_addr: %" PRIx64 "\n",
358 dev->vid, vq->log_guest_addr);
364 * The virtio device sends us the available ring last used index.
367 vhost_user_set_vring_base(struct virtio_net *dev,
368 struct vhost_vring_state *state)
370 dev->virtqueue[state->index]->last_used_idx = state->num;
376 vhost_user_set_mem_table(struct virtio_net *dev, struct VhostUserMsg *pmsg)
378 struct VhostUserMemory memory = pmsg->payload.memory;
379 struct virtio_memory_region *reg;
382 uint64_t mmap_offset;
387 /* Remove from the data plane. */
388 if (dev->flags & VIRTIO_DEV_RUNNING) {
389 dev->flags &= ~VIRTIO_DEV_RUNNING;
390 notify_ops->destroy_device(dev->vid);
394 free_mem_region(dev);
399 dev->mem = rte_zmalloc("vhost-mem-table", sizeof(struct virtio_memory) +
400 sizeof(struct virtio_memory_region) * memory.nregions, 0);
401 if (dev->mem == NULL) {
402 RTE_LOG(ERR, VHOST_CONFIG,
403 "(%d) failed to allocate memory for dev->mem\n",
407 dev->mem->nregions = memory.nregions;
409 for (i = 0; i < memory.nregions; i++) {
411 reg = &dev->mem->regions[i];
413 reg->guest_phys_addr = memory.regions[i].guest_phys_addr;
414 reg->guest_user_addr = memory.regions[i].userspace_addr;
415 reg->size = memory.regions[i].memory_size;
418 mmap_offset = memory.regions[i].mmap_offset;
419 mmap_size = reg->size + mmap_offset;
421 /* mmap() without flag of MAP_ANONYMOUS, should be called
422 * with length argument aligned with hugepagesz at older
423 * longterm version Linux, like 2.6.32 and 3.2.72, or
424 * mmap() will fail with EINVAL.
426 * to avoid failure, make sure in caller to keep length
429 alignment = get_blk_size(fd);
430 if (alignment == (uint64_t)-1) {
431 RTE_LOG(ERR, VHOST_CONFIG,
432 "couldn't get hugepage size through fstat\n");
435 mmap_size = RTE_ALIGN_CEIL(mmap_size, alignment);
437 mmap_addr = mmap(NULL, mmap_size,
438 PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
440 if (mmap_addr == MAP_FAILED) {
441 RTE_LOG(ERR, VHOST_CONFIG,
442 "mmap region %u failed.\n", i);
446 reg->mmap_addr = mmap_addr;
447 reg->mmap_size = mmap_size;
448 reg->host_user_addr = (uint64_t)(uintptr_t)mmap_addr +
451 RTE_LOG(INFO, VHOST_CONFIG,
452 "guest memory region %u, size: 0x%" PRIx64 "\n"
453 "\t guest physical addr: 0x%" PRIx64 "\n"
454 "\t guest virtual addr: 0x%" PRIx64 "\n"
455 "\t host virtual addr: 0x%" PRIx64 "\n"
456 "\t mmap addr : 0x%" PRIx64 "\n"
457 "\t mmap size : 0x%" PRIx64 "\n"
458 "\t mmap align: 0x%" PRIx64 "\n"
459 "\t mmap off : 0x%" PRIx64 "\n",
461 reg->guest_phys_addr,
462 reg->guest_user_addr,
464 (uint64_t)(uintptr_t)mmap_addr,
473 free_mem_region(dev);
480 vq_is_ready(struct vhost_virtqueue *vq)
482 return vq && vq->desc &&
483 vq->kickfd != VIRTIO_UNINITIALIZED_EVENTFD &&
484 vq->callfd != VIRTIO_UNINITIALIZED_EVENTFD;
488 virtio_is_ready(struct virtio_net *dev)
490 struct vhost_virtqueue *rvq, *tvq;
493 for (i = 0; i < dev->virt_qp_nb; i++) {
494 rvq = dev->virtqueue[i * VIRTIO_QNUM + VIRTIO_RXQ];
495 tvq = dev->virtqueue[i * VIRTIO_QNUM + VIRTIO_TXQ];
497 if (!vq_is_ready(rvq) || !vq_is_ready(tvq)) {
498 RTE_LOG(INFO, VHOST_CONFIG,
499 "virtio is not ready for processing.\n");
504 RTE_LOG(INFO, VHOST_CONFIG,
505 "virtio is now ready for processing.\n");
510 vhost_user_set_vring_call(struct virtio_net *dev, struct VhostUserMsg *pmsg)
512 struct vhost_vring_file file;
513 struct vhost_virtqueue *vq;
516 file.index = pmsg->payload.u64 & VHOST_USER_VRING_IDX_MASK;
517 if (pmsg->payload.u64 & VHOST_USER_VRING_NOFD_MASK)
518 file.fd = VIRTIO_INVALID_EVENTFD;
520 file.fd = pmsg->fds[0];
521 RTE_LOG(INFO, VHOST_CONFIG,
522 "vring call idx:%d file:%d\n", file.index, file.fd);
525 * FIXME: VHOST_SET_VRING_CALL is the first per-vring message
526 * we get, so we do vring queue pair allocation here.
528 cur_qp_idx = file.index / VIRTIO_QNUM;
529 if (cur_qp_idx + 1 > dev->virt_qp_nb) {
530 if (alloc_vring_queue_pair(dev, cur_qp_idx) < 0)
534 vq = dev->virtqueue[file.index];
540 vq->callfd = file.fd;
544 * In vhost-user, when we receive kick message, will test whether virtio
545 * device is ready for packet processing.
548 vhost_user_set_vring_kick(struct virtio_net *dev, struct VhostUserMsg *pmsg)
550 struct vhost_vring_file file;
551 struct vhost_virtqueue *vq;
553 file.index = pmsg->payload.u64 & VHOST_USER_VRING_IDX_MASK;
554 if (pmsg->payload.u64 & VHOST_USER_VRING_NOFD_MASK)
555 file.fd = VIRTIO_INVALID_EVENTFD;
557 file.fd = pmsg->fds[0];
558 RTE_LOG(INFO, VHOST_CONFIG,
559 "vring kick idx:%d file:%d\n", file.index, file.fd);
561 vq = dev->virtqueue[file.index];
564 vq->kickfd = file.fd;
566 if (virtio_is_ready(dev) && !(dev->flags & VIRTIO_DEV_RUNNING)) {
567 if (notify_ops->new_device(dev->vid) == 0)
568 dev->flags |= VIRTIO_DEV_RUNNING;
573 * when virtio is stopped, qemu will send us the GET_VRING_BASE message.
576 vhost_user_get_vring_base(struct virtio_net *dev,
577 struct vhost_vring_state *state)
579 /* We have to stop the queue (virtio) if it is running. */
580 if (dev->flags & VIRTIO_DEV_RUNNING) {
581 dev->flags &= ~VIRTIO_DEV_RUNNING;
582 notify_ops->destroy_device(dev->vid);
585 /* Here we are safe to get the last used index */
586 state->num = dev->virtqueue[state->index]->last_used_idx;
588 RTE_LOG(INFO, VHOST_CONFIG,
589 "vring base idx:%d file:%d\n", state->index, state->num);
591 * Based on current qemu vhost-user implementation, this message is
592 * sent and only sent in vhost_vring_stop.
593 * TODO: cleanup the vring, it isn't usable since here.
595 if (dev->virtqueue[state->index]->kickfd >= 0)
596 close(dev->virtqueue[state->index]->kickfd);
598 dev->virtqueue[state->index]->kickfd = VIRTIO_UNINITIALIZED_EVENTFD;
604 * when virtio queues are ready to work, qemu will send us to
605 * enable the virtio queue pair.
608 vhost_user_set_vring_enable(struct virtio_net *dev,
609 struct vhost_vring_state *state)
611 int enable = (int)state->num;
613 RTE_LOG(INFO, VHOST_CONFIG,
614 "set queue enable: %d to qp idx: %d\n",
615 enable, state->index);
617 if (notify_ops->vring_state_changed)
618 notify_ops->vring_state_changed(dev->vid, state->index, enable);
620 dev->virtqueue[state->index]->enabled = enable;
626 vhost_user_set_protocol_features(struct virtio_net *dev,
627 uint64_t protocol_features)
629 if (protocol_features & ~VHOST_USER_PROTOCOL_FEATURES)
632 dev->protocol_features = protocol_features;
636 vhost_user_set_log_base(struct virtio_net *dev, struct VhostUserMsg *msg)
638 int fd = msg->fds[0];
643 RTE_LOG(ERR, VHOST_CONFIG, "invalid log fd: %d\n", fd);
647 if (msg->size != sizeof(VhostUserLog)) {
648 RTE_LOG(ERR, VHOST_CONFIG,
649 "invalid log base msg size: %"PRId32" != %d\n",
650 msg->size, (int)sizeof(VhostUserLog));
654 size = msg->payload.log.mmap_size;
655 off = msg->payload.log.mmap_offset;
656 RTE_LOG(INFO, VHOST_CONFIG,
657 "log mmap size: %"PRId64", offset: %"PRId64"\n",
661 * mmap from 0 to workaround a hugepage mmap bug: mmap will
662 * fail when offset is not page size aligned.
664 addr = mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
666 if (addr == MAP_FAILED) {
667 RTE_LOG(ERR, VHOST_CONFIG, "mmap log base failed!\n");
672 * Free previously mapped log memory on occasionally
673 * multiple VHOST_USER_SET_LOG_BASE.
676 munmap((void *)(uintptr_t)dev->log_addr, dev->log_size);
678 dev->log_addr = (uint64_t)(uintptr_t)addr;
679 dev->log_base = dev->log_addr + off;
680 dev->log_size = size;
686 * An rarp packet is constructed and broadcasted to notify switches about
687 * the new location of the migrated VM, so that packets from outside will
688 * not be lost after migration.
690 * However, we don't actually "send" a rarp packet here, instead, we set
691 * a flag 'broadcast_rarp' to let rte_vhost_dequeue_burst() inject it.
694 vhost_user_send_rarp(struct virtio_net *dev, struct VhostUserMsg *msg)
696 uint8_t *mac = (uint8_t *)&msg->payload.u64;
698 RTE_LOG(DEBUG, VHOST_CONFIG,
699 ":: mac: %02x:%02x:%02x:%02x:%02x:%02x\n",
700 mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
701 memcpy(dev->mac.addr_bytes, mac, 6);
704 * Set the flag to inject a RARP broadcast packet at
705 * rte_vhost_dequeue_burst().
707 * rte_smp_wmb() is for making sure the mac is copied
708 * before the flag is set.
711 rte_atomic16_set(&dev->broadcast_rarp, 1);
716 /* return bytes# of read on success or negative val on failure. */
718 read_vhost_message(int sockfd, struct VhostUserMsg *msg)
722 ret = read_fd_message(sockfd, (char *)msg, VHOST_USER_HDR_SIZE,
723 msg->fds, VHOST_MEMORY_MAX_NREGIONS);
727 if (msg && msg->size) {
728 if (msg->size > sizeof(msg->payload)) {
729 RTE_LOG(ERR, VHOST_CONFIG,
730 "invalid msg size: %d\n", msg->size);
733 ret = read(sockfd, &msg->payload, msg->size);
736 if (ret != (int)msg->size) {
737 RTE_LOG(ERR, VHOST_CONFIG,
738 "read control message failed\n");
747 send_vhost_message(int sockfd, struct VhostUserMsg *msg)
754 msg->flags &= ~VHOST_USER_VERSION_MASK;
755 msg->flags |= VHOST_USER_VERSION;
756 msg->flags |= VHOST_USER_REPLY_MASK;
758 ret = send_fd_message(sockfd, (char *)msg,
759 VHOST_USER_HDR_SIZE + msg->size, NULL, 0);
765 vhost_user_msg_handler(int vid, int fd)
767 struct virtio_net *dev;
768 struct VhostUserMsg msg;
771 dev = get_device(vid);
775 ret = read_vhost_message(fd, &msg);
776 if (ret <= 0 || msg.request >= VHOST_USER_MAX) {
778 RTE_LOG(ERR, VHOST_CONFIG,
779 "vhost read message failed\n");
781 RTE_LOG(INFO, VHOST_CONFIG,
782 "vhost peer closed\n");
784 RTE_LOG(ERR, VHOST_CONFIG,
785 "vhost read incorrect message\n");
790 RTE_LOG(INFO, VHOST_CONFIG, "read message %s\n",
791 vhost_message_str[msg.request]);
792 switch (msg.request) {
793 case VHOST_USER_GET_FEATURES:
794 msg.payload.u64 = vhost_user_get_features();
795 msg.size = sizeof(msg.payload.u64);
796 send_vhost_message(fd, &msg);
798 case VHOST_USER_SET_FEATURES:
799 vhost_user_set_features(dev, msg.payload.u64);
802 case VHOST_USER_GET_PROTOCOL_FEATURES:
803 msg.payload.u64 = VHOST_USER_PROTOCOL_FEATURES;
804 msg.size = sizeof(msg.payload.u64);
805 send_vhost_message(fd, &msg);
807 case VHOST_USER_SET_PROTOCOL_FEATURES:
808 vhost_user_set_protocol_features(dev, msg.payload.u64);
811 case VHOST_USER_SET_OWNER:
812 vhost_user_set_owner();
814 case VHOST_USER_RESET_OWNER:
815 vhost_user_reset_owner(dev);
818 case VHOST_USER_SET_MEM_TABLE:
819 vhost_user_set_mem_table(dev, &msg);
822 case VHOST_USER_SET_LOG_BASE:
823 vhost_user_set_log_base(dev, &msg);
825 /* it needs a reply */
826 msg.size = sizeof(msg.payload.u64);
827 send_vhost_message(fd, &msg);
829 case VHOST_USER_SET_LOG_FD:
831 RTE_LOG(INFO, VHOST_CONFIG, "not implemented.\n");
834 case VHOST_USER_SET_VRING_NUM:
835 vhost_user_set_vring_num(dev, &msg.payload.state);
837 case VHOST_USER_SET_VRING_ADDR:
838 vhost_user_set_vring_addr(dev, &msg.payload.addr);
840 case VHOST_USER_SET_VRING_BASE:
841 vhost_user_set_vring_base(dev, &msg.payload.state);
844 case VHOST_USER_GET_VRING_BASE:
845 ret = vhost_user_get_vring_base(dev, &msg.payload.state);
846 msg.size = sizeof(msg.payload.state);
847 send_vhost_message(fd, &msg);
850 case VHOST_USER_SET_VRING_KICK:
851 vhost_user_set_vring_kick(dev, &msg);
853 case VHOST_USER_SET_VRING_CALL:
854 vhost_user_set_vring_call(dev, &msg);
857 case VHOST_USER_SET_VRING_ERR:
858 if (!(msg.payload.u64 & VHOST_USER_VRING_NOFD_MASK))
860 RTE_LOG(INFO, VHOST_CONFIG, "not implemented\n");
863 case VHOST_USER_GET_QUEUE_NUM:
864 msg.payload.u64 = VHOST_MAX_QUEUE_PAIRS;
865 msg.size = sizeof(msg.payload.u64);
866 send_vhost_message(fd, &msg);
869 case VHOST_USER_SET_VRING_ENABLE:
870 vhost_user_set_vring_enable(dev, &msg.payload.state);
872 case VHOST_USER_SEND_RARP:
873 vhost_user_send_rarp(dev, &msg);