1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2016 Intel Corporation
12 #include <sys/eventfd.h>
13 #include <sys/types.h>
16 #include <rte_string_fns.h>
17 #include <rte_eal_memconfig.h>
20 #include "virtio_user_dev.h"
21 #include "../virtio_ethdev.h"
23 #define VIRTIO_USER_MEM_EVENT_CLB_NAME "virtio_user_mem_event_clb"
26 virtio_user_create_queue(struct virtio_user_dev *dev, uint32_t queue_sel)
28 /* Of all per virtqueue MSGs, make sure VHOST_SET_VRING_CALL come
29 * firstly because vhost depends on this msg to allocate virtqueue
32 struct vhost_vring_file file;
34 file.index = queue_sel;
35 file.fd = dev->callfds[queue_sel];
36 dev->ops->send_request(dev, VHOST_USER_SET_VRING_CALL, &file);
42 virtio_user_kick_queue(struct virtio_user_dev *dev, uint32_t queue_sel)
44 struct vhost_vring_file file;
45 struct vhost_vring_state state;
46 struct vring *vring = &dev->vrings[queue_sel];
47 struct vring_packed *pq_vring = &dev->packed_vrings[queue_sel];
48 struct vhost_vring_addr addr = {
51 .flags = 0, /* disable log */
54 if (dev->features & (1ULL << VIRTIO_F_RING_PACKED)) {
56 (uint64_t)(uintptr_t)pq_vring->desc;
57 addr.avail_user_addr =
58 (uint64_t)(uintptr_t)pq_vring->driver;
60 (uint64_t)(uintptr_t)pq_vring->device;
62 addr.desc_user_addr = (uint64_t)(uintptr_t)vring->desc;
63 addr.avail_user_addr = (uint64_t)(uintptr_t)vring->avail;
64 addr.used_user_addr = (uint64_t)(uintptr_t)vring->used;
67 state.index = queue_sel;
68 state.num = vring->num;
69 dev->ops->send_request(dev, VHOST_USER_SET_VRING_NUM, &state);
71 state.index = queue_sel;
72 state.num = 0; /* no reservation */
73 if (dev->features & (1ULL << VIRTIO_F_RING_PACKED))
74 state.num |= (1 << 15);
75 dev->ops->send_request(dev, VHOST_USER_SET_VRING_BASE, &state);
77 dev->ops->send_request(dev, VHOST_USER_SET_VRING_ADDR, &addr);
79 /* Of all per virtqueue MSGs, make sure VHOST_USER_SET_VRING_KICK comes
80 * lastly because vhost depends on this msg to judge if
83 file.index = queue_sel;
84 file.fd = dev->kickfds[queue_sel];
85 dev->ops->send_request(dev, VHOST_USER_SET_VRING_KICK, &file);
91 virtio_user_queue_setup(struct virtio_user_dev *dev,
92 int (*fn)(struct virtio_user_dev *, uint32_t))
94 uint32_t i, queue_sel;
96 for (i = 0; i < dev->max_queue_pairs; ++i) {
97 queue_sel = 2 * i + VTNET_SQ_RQ_QUEUE_IDX;
98 if (fn(dev, queue_sel) < 0) {
99 PMD_DRV_LOG(INFO, "setup rx vq fails: %u", i);
103 for (i = 0; i < dev->max_queue_pairs; ++i) {
104 queue_sel = 2 * i + VTNET_SQ_TQ_QUEUE_IDX;
105 if (fn(dev, queue_sel) < 0) {
106 PMD_DRV_LOG(INFO, "setup tx vq fails: %u", i);
115 virtio_user_start_device(struct virtio_user_dev *dev)
123 * We need to make sure that the locks will be
124 * taken in the correct order to avoid deadlocks.
126 * Before releasing this lock, this thread should
127 * not trigger any memory hotplug events.
129 * This is a temporary workaround, and should be
130 * replaced when we get proper supports from the
131 * memory subsystem in the future.
133 rte_mcfg_mem_read_lock();
134 pthread_mutex_lock(&dev->mutex);
136 if (dev->backend_type == VIRTIO_USER_BACKEND_VHOST_USER &&
140 /* Step 0: tell vhost to create queues */
141 if (virtio_user_queue_setup(dev, virtio_user_create_queue) < 0)
144 /* Step 1: negotiate protocol features & set features */
145 features = dev->features;
148 /* Strip VIRTIO_NET_F_MAC, as MAC address is handled in vdev init */
149 features &= ~(1ull << VIRTIO_NET_F_MAC);
150 /* Strip VIRTIO_NET_F_CTRL_VQ, as devices do not really need to know */
151 features &= ~(1ull << VIRTIO_NET_F_CTRL_VQ);
152 features &= ~(1ull << VIRTIO_NET_F_STATUS);
153 ret = dev->ops->send_request(dev, VHOST_USER_SET_FEATURES, &features);
156 PMD_DRV_LOG(INFO, "set features: %" PRIx64, features);
158 /* Step 2: share memory regions */
159 ret = dev->ops->send_request(dev, VHOST_USER_SET_MEM_TABLE, NULL);
163 /* Step 3: kick queues */
164 if (virtio_user_queue_setup(dev, virtio_user_kick_queue) < 0)
167 /* Step 4: enable queues
168 * we enable the 1st queue pair by default.
170 dev->ops->enable_qp(dev, 0, 1);
173 pthread_mutex_unlock(&dev->mutex);
174 rte_mcfg_mem_read_unlock();
178 pthread_mutex_unlock(&dev->mutex);
179 rte_mcfg_mem_read_unlock();
180 /* TODO: free resource here or caller to check */
184 int virtio_user_stop_device(struct virtio_user_dev *dev)
186 struct vhost_vring_state state;
190 pthread_mutex_lock(&dev->mutex);
194 for (i = 0; i < dev->max_queue_pairs; ++i)
195 dev->ops->enable_qp(dev, i, 0);
197 /* Stop the backend. */
198 for (i = 0; i < dev->max_queue_pairs * 2; ++i) {
200 if (dev->ops->send_request(dev, VHOST_USER_GET_VRING_BASE,
202 PMD_DRV_LOG(ERR, "get_vring_base failed, index=%u\n",
209 dev->started = false;
211 pthread_mutex_unlock(&dev->mutex);
217 parse_mac(struct virtio_user_dev *dev, const char *mac)
219 struct rte_ether_addr tmp;
224 if (rte_ether_unformat_addr(mac, &tmp) == 0) {
225 memcpy(dev->mac_addr, &tmp, RTE_ETHER_ADDR_LEN);
226 dev->mac_specified = 1;
228 /* ignore the wrong mac, use random mac */
229 PMD_DRV_LOG(ERR, "wrong format of mac: %s", mac);
234 virtio_user_dev_init_notify(struct virtio_user_dev *dev)
240 for (i = 0; i < VIRTIO_MAX_VIRTQUEUES; ++i) {
241 if (i >= dev->max_queue_pairs * 2) {
242 dev->kickfds[i] = -1;
243 dev->callfds[i] = -1;
247 /* May use invalid flag, but some backend uses kickfd and
248 * callfd as criteria to judge if dev is alive. so finally we
251 callfd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
253 PMD_DRV_LOG(ERR, "callfd error, %s", strerror(errno));
256 kickfd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
258 PMD_DRV_LOG(ERR, "kickfd error, %s", strerror(errno));
261 dev->callfds[i] = callfd;
262 dev->kickfds[i] = kickfd;
265 if (i < VIRTIO_MAX_VIRTQUEUES) {
266 for (j = 0; j <= i; ++j) {
267 close(dev->callfds[j]);
268 close(dev->kickfds[j]);
278 virtio_user_fill_intr_handle(struct virtio_user_dev *dev)
281 struct rte_eth_dev *eth_dev = &rte_eth_devices[dev->port_id];
283 if (!eth_dev->intr_handle) {
284 eth_dev->intr_handle = malloc(sizeof(*eth_dev->intr_handle));
285 if (!eth_dev->intr_handle) {
286 PMD_DRV_LOG(ERR, "fail to allocate intr_handle");
289 memset(eth_dev->intr_handle, 0, sizeof(*eth_dev->intr_handle));
292 for (i = 0; i < dev->max_queue_pairs; ++i)
293 eth_dev->intr_handle->efds[i] = dev->callfds[i];
294 eth_dev->intr_handle->nb_efd = dev->max_queue_pairs;
295 eth_dev->intr_handle->max_intr = dev->max_queue_pairs + 1;
296 eth_dev->intr_handle->type = RTE_INTR_HANDLE_VDEV;
297 /* For virtio vdev, no need to read counter for clean */
298 eth_dev->intr_handle->efd_counter_size = 0;
299 eth_dev->intr_handle->fd = -1;
300 if (dev->vhostfd >= 0)
301 eth_dev->intr_handle->fd = dev->vhostfd;
302 else if (dev->is_server)
303 eth_dev->intr_handle->fd = dev->listenfd;
309 virtio_user_mem_event_cb(enum rte_mem_event type __rte_unused,
311 size_t len __rte_unused,
314 struct virtio_user_dev *dev = arg;
315 struct rte_memseg_list *msl;
318 /* ignore externally allocated memory */
319 msl = rte_mem_virt2memseg_list(addr);
323 pthread_mutex_lock(&dev->mutex);
325 if (dev->started == false)
328 /* Step 1: pause the active queues */
329 for (i = 0; i < dev->queue_pairs; i++)
330 dev->ops->enable_qp(dev, i, 0);
332 /* Step 2: update memory regions */
333 dev->ops->send_request(dev, VHOST_USER_SET_MEM_TABLE, NULL);
335 /* Step 3: resume the active queues */
336 for (i = 0; i < dev->queue_pairs; i++)
337 dev->ops->enable_qp(dev, i, 1);
340 pthread_mutex_unlock(&dev->mutex);
344 virtio_user_dev_setup(struct virtio_user_dev *dev)
349 dev->vhostfds = NULL;
352 if (dev->is_server) {
353 if (dev->backend_type != VIRTIO_USER_BACKEND_VHOST_USER) {
354 PMD_DRV_LOG(ERR, "Server mode only supports vhost-user!");
357 dev->ops = &virtio_ops_user;
359 if (dev->backend_type == VIRTIO_USER_BACKEND_VHOST_USER) {
360 dev->ops = &virtio_ops_user;
361 } else if (dev->backend_type ==
362 VIRTIO_USER_BACKEND_VHOST_KERNEL) {
363 dev->ops = &virtio_ops_kernel;
365 dev->vhostfds = malloc(dev->max_queue_pairs *
367 dev->tapfds = malloc(dev->max_queue_pairs *
369 if (!dev->vhostfds || !dev->tapfds) {
370 PMD_INIT_LOG(ERR, "Failed to malloc");
374 for (q = 0; q < dev->max_queue_pairs; ++q) {
375 dev->vhostfds[q] = -1;
381 if (dev->ops->setup(dev) < 0)
384 if (virtio_user_dev_init_notify(dev) < 0)
387 if (virtio_user_fill_intr_handle(dev) < 0)
393 /* Use below macro to filter features from vhost backend */
394 #define VIRTIO_USER_SUPPORTED_FEATURES \
395 (1ULL << VIRTIO_NET_F_MAC | \
396 1ULL << VIRTIO_NET_F_STATUS | \
397 1ULL << VIRTIO_NET_F_MQ | \
398 1ULL << VIRTIO_NET_F_CTRL_MAC_ADDR | \
399 1ULL << VIRTIO_NET_F_CTRL_VQ | \
400 1ULL << VIRTIO_NET_F_CTRL_RX | \
401 1ULL << VIRTIO_NET_F_CTRL_VLAN | \
402 1ULL << VIRTIO_NET_F_CSUM | \
403 1ULL << VIRTIO_NET_F_HOST_TSO4 | \
404 1ULL << VIRTIO_NET_F_HOST_TSO6 | \
405 1ULL << VIRTIO_NET_F_MRG_RXBUF | \
406 1ULL << VIRTIO_RING_F_INDIRECT_DESC | \
407 1ULL << VIRTIO_NET_F_GUEST_CSUM | \
408 1ULL << VIRTIO_NET_F_GUEST_TSO4 | \
409 1ULL << VIRTIO_NET_F_GUEST_TSO6 | \
410 1ULL << VIRTIO_F_IN_ORDER | \
411 1ULL << VIRTIO_F_VERSION_1 | \
412 1ULL << VIRTIO_F_RING_PACKED | \
413 1ULL << VHOST_USER_F_PROTOCOL_FEATURES)
415 #define VIRTIO_USER_SUPPORTED_PROTOCOL_FEATURES \
416 (1ULL << VHOST_USER_PROTOCOL_F_MQ | \
417 1ULL << VHOST_USER_PROTOCOL_F_REPLY_ACK | \
418 1ULL << VHOST_USER_PROTOCOL_F_STATUS)
421 virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues,
422 int cq, int queue_size, const char *mac, char **ifname,
423 int server, int mrg_rxbuf, int in_order, int packed_vq,
424 enum virtio_user_backend_type backend_type)
426 uint64_t protocol_features = 0;
428 pthread_mutex_init(&dev->mutex, NULL);
429 strlcpy(dev->path, path, PATH_MAX);
431 dev->max_queue_pairs = queues;
432 dev->queue_pairs = 1; /* mq disabled by default */
433 dev->queue_size = queue_size;
434 dev->is_server = server;
435 dev->mac_specified = 0;
436 dev->frontend_features = 0;
437 dev->unsupported_features = ~VIRTIO_USER_SUPPORTED_FEATURES;
438 dev->protocol_features = VIRTIO_USER_SUPPORTED_PROTOCOL_FEATURES;
439 dev->backend_type = backend_type;
444 dev->ifname = *ifname;
448 if (virtio_user_dev_setup(dev) < 0) {
449 PMD_INIT_LOG(ERR, "backend set up fails");
453 if (dev->backend_type != VIRTIO_USER_BACKEND_VHOST_USER)
454 dev->unsupported_features |=
455 (1ULL << VHOST_USER_F_PROTOCOL_FEATURES);
457 if (!dev->is_server) {
458 if (dev->ops->send_request(dev, VHOST_USER_SET_OWNER,
460 PMD_INIT_LOG(ERR, "set_owner fails: %s",
465 if (dev->ops->send_request(dev, VHOST_USER_GET_FEATURES,
466 &dev->device_features) < 0) {
467 PMD_INIT_LOG(ERR, "get_features failed: %s",
473 if (dev->device_features &
474 (1ULL << VHOST_USER_F_PROTOCOL_FEATURES)) {
475 if (dev->ops->send_request(dev,
476 VHOST_USER_GET_PROTOCOL_FEATURES,
480 dev->protocol_features &= protocol_features;
482 if (dev->ops->send_request(dev,
483 VHOST_USER_SET_PROTOCOL_FEATURES,
484 &dev->protocol_features))
487 if (!(dev->protocol_features &
488 (1ULL << VHOST_USER_PROTOCOL_F_MQ)))
489 dev->unsupported_features |=
490 (1ull << VIRTIO_NET_F_MQ);
493 /* We just pretend vhost-user can support all these features.
494 * Note that this could be problematic that if some feature is
495 * negotiated but not supported by the vhost-user which comes
498 dev->device_features = VIRTIO_USER_SUPPORTED_FEATURES;
504 dev->unsupported_features |= (1ull << VIRTIO_NET_F_MRG_RXBUF);
507 dev->unsupported_features |= (1ull << VIRTIO_F_IN_ORDER);
510 dev->unsupported_features |= (1ull << VIRTIO_F_RING_PACKED);
512 if (dev->mac_specified)
513 dev->frontend_features |= (1ull << VIRTIO_NET_F_MAC);
515 dev->unsupported_features |= (1ull << VIRTIO_NET_F_MAC);
518 /* device does not really need to know anything about CQ,
519 * so if necessary, we just claim to support CQ
521 dev->frontend_features |= (1ull << VIRTIO_NET_F_CTRL_VQ);
523 dev->unsupported_features |= (1ull << VIRTIO_NET_F_CTRL_VQ);
524 /* Also disable features that depend on VIRTIO_NET_F_CTRL_VQ */
525 dev->unsupported_features |= (1ull << VIRTIO_NET_F_CTRL_RX);
526 dev->unsupported_features |= (1ull << VIRTIO_NET_F_CTRL_VLAN);
527 dev->unsupported_features |=
528 (1ull << VIRTIO_NET_F_GUEST_ANNOUNCE);
529 dev->unsupported_features |= (1ull << VIRTIO_NET_F_MQ);
530 dev->unsupported_features |=
531 (1ull << VIRTIO_NET_F_CTRL_MAC_ADDR);
534 /* The backend will not report this feature, we add it explicitly */
535 if (dev->backend_type == VIRTIO_USER_BACKEND_VHOST_USER)
536 dev->frontend_features |= (1ull << VIRTIO_NET_F_STATUS);
540 * (frontend_features | backend_features) & ~unsupported_features;
542 dev->device_features |= dev->frontend_features;
543 dev->device_features &= ~dev->unsupported_features;
545 if (rte_mem_event_callback_register(VIRTIO_USER_MEM_EVENT_CLB_NAME,
546 virtio_user_mem_event_cb, dev)) {
547 if (rte_errno != ENOTSUP) {
548 PMD_INIT_LOG(ERR, "Failed to register mem event"
558 virtio_user_dev_uninit(struct virtio_user_dev *dev)
562 virtio_user_stop_device(dev);
564 rte_mem_event_callback_unregister(VIRTIO_USER_MEM_EVENT_CLB_NAME, dev);
566 for (i = 0; i < dev->max_queue_pairs * 2; ++i) {
567 close(dev->callfds[i]);
568 close(dev->kickfds[i]);
571 if (dev->vhostfd >= 0)
574 if (dev->is_server && dev->listenfd >= 0) {
575 close(dev->listenfd);
580 for (i = 0; i < dev->max_queue_pairs; ++i) {
581 close(dev->vhostfds[i]);
582 if (dev->tapfds[i] >= 0)
583 close(dev->tapfds[i]);
596 virtio_user_handle_mq(struct virtio_user_dev *dev, uint16_t q_pairs)
601 if (q_pairs > dev->max_queue_pairs) {
602 PMD_INIT_LOG(ERR, "multi-q config %u, but only %u supported",
603 q_pairs, dev->max_queue_pairs);
607 /* Server mode can't enable queue pairs if vhostfd is invalid,
608 * always return 0 in this case.
610 if (!dev->is_server || dev->vhostfd >= 0) {
611 for (i = 0; i < q_pairs; ++i)
612 ret |= dev->ops->enable_qp(dev, i, 1);
613 for (i = q_pairs; i < dev->max_queue_pairs; ++i)
614 ret |= dev->ops->enable_qp(dev, i, 0);
616 dev->queue_pairs = q_pairs;
622 virtio_user_handle_ctrl_msg(struct virtio_user_dev *dev, struct vring *vring,
625 struct virtio_net_ctrl_hdr *hdr;
626 virtio_net_ctrl_ack status = ~0;
627 uint16_t i, idx_data, idx_status;
628 uint32_t n_descs = 0;
630 /* locate desc for header, data, and status */
631 idx_data = vring->desc[idx_hdr].next;
635 while (vring->desc[i].flags == VRING_DESC_F_NEXT) {
636 i = vring->desc[i].next;
640 /* locate desc for status */
644 hdr = (void *)(uintptr_t)vring->desc[idx_hdr].addr;
645 if (hdr->class == VIRTIO_NET_CTRL_MQ &&
646 hdr->cmd == VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET) {
649 queues = *(uint16_t *)(uintptr_t)vring->desc[idx_data].addr;
650 status = virtio_user_handle_mq(dev, queues);
651 } else if (hdr->class == VIRTIO_NET_CTRL_RX ||
652 hdr->class == VIRTIO_NET_CTRL_MAC ||
653 hdr->class == VIRTIO_NET_CTRL_VLAN) {
658 *(virtio_net_ctrl_ack *)(uintptr_t)vring->desc[idx_status].addr = status;
664 desc_is_avail(struct vring_packed_desc *desc, bool wrap_counter)
666 uint16_t flags = __atomic_load_n(&desc->flags, __ATOMIC_ACQUIRE);
668 return wrap_counter == !!(flags & VRING_PACKED_DESC_F_AVAIL) &&
669 wrap_counter != !!(flags & VRING_PACKED_DESC_F_USED);
673 virtio_user_handle_ctrl_msg_packed(struct virtio_user_dev *dev,
674 struct vring_packed *vring,
677 struct virtio_net_ctrl_hdr *hdr;
678 virtio_net_ctrl_ack status = ~0;
679 uint16_t idx_data, idx_status;
680 /* initialize to one, header is first */
681 uint32_t n_descs = 1;
683 /* locate desc for header, data, and status */
684 idx_data = idx_hdr + 1;
685 if (idx_data >= dev->queue_size)
686 idx_data -= dev->queue_size;
690 idx_status = idx_data;
691 while (vring->desc[idx_status].flags & VRING_DESC_F_NEXT) {
693 if (idx_status >= dev->queue_size)
694 idx_status -= dev->queue_size;
698 hdr = (void *)(uintptr_t)vring->desc[idx_hdr].addr;
699 if (hdr->class == VIRTIO_NET_CTRL_MQ &&
700 hdr->cmd == VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET) {
703 queues = *(uint16_t *)(uintptr_t)
704 vring->desc[idx_data].addr;
705 status = virtio_user_handle_mq(dev, queues);
706 } else if (hdr->class == VIRTIO_NET_CTRL_RX ||
707 hdr->class == VIRTIO_NET_CTRL_MAC ||
708 hdr->class == VIRTIO_NET_CTRL_VLAN) {
713 *(virtio_net_ctrl_ack *)(uintptr_t)
714 vring->desc[idx_status].addr = status;
716 /* Update used descriptor */
717 vring->desc[idx_hdr].id = vring->desc[idx_status].id;
718 vring->desc[idx_hdr].len = sizeof(status);
724 virtio_user_handle_cq_packed(struct virtio_user_dev *dev, uint16_t queue_idx)
726 struct virtio_user_queue *vq = &dev->packed_queues[queue_idx];
727 struct vring_packed *vring = &dev->packed_vrings[queue_idx];
728 uint16_t n_descs, flags;
730 /* Perform a load-acquire barrier in desc_is_avail to
731 * enforce the ordering between desc flags and desc
734 while (desc_is_avail(&vring->desc[vq->used_idx],
735 vq->used_wrap_counter)) {
737 n_descs = virtio_user_handle_ctrl_msg_packed(dev, vring,
740 flags = VRING_DESC_F_WRITE;
741 if (vq->used_wrap_counter)
742 flags |= VRING_PACKED_DESC_F_AVAIL_USED;
744 __atomic_store_n(&vring->desc[vq->used_idx].flags, flags,
747 vq->used_idx += n_descs;
748 if (vq->used_idx >= dev->queue_size) {
749 vq->used_idx -= dev->queue_size;
750 vq->used_wrap_counter ^= 1;
756 virtio_user_handle_cq(struct virtio_user_dev *dev, uint16_t queue_idx)
758 uint16_t avail_idx, desc_idx;
759 struct vring_used_elem *uep;
761 struct vring *vring = &dev->vrings[queue_idx];
763 /* Consume avail ring, using used ring idx as first one */
764 while (__atomic_load_n(&vring->used->idx, __ATOMIC_RELAXED)
765 != vring->avail->idx) {
766 avail_idx = __atomic_load_n(&vring->used->idx, __ATOMIC_RELAXED)
768 desc_idx = vring->avail->ring[avail_idx];
770 n_descs = virtio_user_handle_ctrl_msg(dev, vring, desc_idx);
772 /* Update used ring */
773 uep = &vring->used->ring[avail_idx];
777 __atomic_add_fetch(&vring->used->idx, 1, __ATOMIC_RELAXED);
782 virtio_user_send_status_update(struct virtio_user_dev *dev, uint8_t status)
785 uint64_t arg = status;
787 /* Vhost-user only for now */
788 if (dev->backend_type != VIRTIO_USER_BACKEND_VHOST_USER)
791 if (!(dev->protocol_features & (1ULL << VHOST_USER_PROTOCOL_F_STATUS)))
794 ret = dev->ops->send_request(dev, VHOST_USER_SET_STATUS, &arg);
796 PMD_INIT_LOG(ERR, "VHOST_USER_SET_STATUS failed (%d): %s", ret,
805 virtio_user_update_status(struct virtio_user_dev *dev)
810 /* Vhost-user only for now */
811 if (dev->backend_type != VIRTIO_USER_BACKEND_VHOST_USER)
814 if (!(dev->protocol_features & (1UL << VHOST_USER_PROTOCOL_F_STATUS)))
817 err = dev->ops->send_request(dev, VHOST_USER_GET_STATUS, &ret);
819 PMD_INIT_LOG(ERR, "VHOST_USER_GET_STATUS failed (%d): %s", err,
823 if (ret > UINT8_MAX) {
824 PMD_INIT_LOG(ERR, "Invalid VHOST_USER_GET_STATUS response 0x%" PRIx64 "\n", ret);
829 PMD_INIT_LOG(DEBUG, "Updated Device Status(0x%08x):\n"
831 "\t-ACKNOWLEDGE: %u\n"
834 "\t-FEATURES_OK: %u\n"
835 "\t-DEVICE_NEED_RESET: %u\n"
838 (dev->status == VIRTIO_CONFIG_STATUS_RESET),
839 !!(dev->status & VIRTIO_CONFIG_STATUS_ACK),
840 !!(dev->status & VIRTIO_CONFIG_STATUS_DRIVER),
841 !!(dev->status & VIRTIO_CONFIG_STATUS_DRIVER_OK),
842 !!(dev->status & VIRTIO_CONFIG_STATUS_FEATURES_OK),
843 !!(dev->status & VIRTIO_CONFIG_STATUS_DEV_NEED_RESET),
844 !!(dev->status & VIRTIO_CONFIG_STATUS_FAILED));