1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2017 Intel Corporation
10 * Interface to vhost-user
15 #include <sys/eventfd.h>
17 #include <rte_memory.h>
18 #include <rte_mempool.h>
25 /* These are not C++-aware. */
26 #include <linux/vhost.h>
27 #include <linux/virtio_ring.h>
28 #include <linux/virtio_net.h>
31 #define RTE_VHOST_USER_CLIENT (1ULL << 0)
32 #define RTE_VHOST_USER_NO_RECONNECT (1ULL << 1)
33 #define RTE_VHOST_USER_RESERVED_1 (1ULL << 2)
34 #define RTE_VHOST_USER_IOMMU_SUPPORT (1ULL << 3)
35 #define RTE_VHOST_USER_POSTCOPY_SUPPORT (1ULL << 4)
36 /* support mbuf with external buffer attached */
37 #define RTE_VHOST_USER_EXTBUF_SUPPORT (1ULL << 5)
38 /* support only linear buffers (no chained mbufs) */
39 #define RTE_VHOST_USER_LINEARBUF_SUPPORT (1ULL << 6)
40 #define RTE_VHOST_USER_ASYNC_COPY (1ULL << 7)
41 #define RTE_VHOST_USER_NET_COMPLIANT_OL_FLAGS (1ULL << 8)
42 #define RTE_VHOST_USER_NET_STATS_ENABLE (1ULL << 9)
45 #ifndef VIRTIO_NET_F_GUEST_ANNOUNCE
46 #define VIRTIO_NET_F_GUEST_ANNOUNCE 21
49 #ifndef VIRTIO_NET_F_MQ
50 #define VIRTIO_NET_F_MQ 22
53 #ifndef VIRTIO_NET_F_MTU
54 #define VIRTIO_NET_F_MTU 3
57 #ifndef VIRTIO_F_ANY_LAYOUT
58 #define VIRTIO_F_ANY_LAYOUT 27
61 /** Protocol features. */
62 #ifndef VHOST_USER_PROTOCOL_F_MQ
63 #define VHOST_USER_PROTOCOL_F_MQ 0
66 #ifndef VHOST_USER_PROTOCOL_F_LOG_SHMFD
67 #define VHOST_USER_PROTOCOL_F_LOG_SHMFD 1
70 #ifndef VHOST_USER_PROTOCOL_F_RARP
71 #define VHOST_USER_PROTOCOL_F_RARP 2
74 #ifndef VHOST_USER_PROTOCOL_F_REPLY_ACK
75 #define VHOST_USER_PROTOCOL_F_REPLY_ACK 3
78 #ifndef VHOST_USER_PROTOCOL_F_NET_MTU
79 #define VHOST_USER_PROTOCOL_F_NET_MTU 4
82 #ifndef VHOST_USER_PROTOCOL_F_SLAVE_REQ
83 #define VHOST_USER_PROTOCOL_F_SLAVE_REQ 5
86 #ifndef VHOST_USER_PROTOCOL_F_CRYPTO_SESSION
87 #define VHOST_USER_PROTOCOL_F_CRYPTO_SESSION 7
90 #ifndef VHOST_USER_PROTOCOL_F_PAGEFAULT
91 #define VHOST_USER_PROTOCOL_F_PAGEFAULT 8
94 #ifndef VHOST_USER_PROTOCOL_F_CONFIG
95 #define VHOST_USER_PROTOCOL_F_CONFIG 9
98 #ifndef VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD
99 #define VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD 10
102 #ifndef VHOST_USER_PROTOCOL_F_HOST_NOTIFIER
103 #define VHOST_USER_PROTOCOL_F_HOST_NOTIFIER 11
106 #ifndef VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD
107 #define VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD 12
110 #ifndef VHOST_USER_PROTOCOL_F_STATUS
111 #define VHOST_USER_PROTOCOL_F_STATUS 16
114 /** Indicate whether protocol features negotiation is supported. */
115 #ifndef VHOST_USER_F_PROTOCOL_FEATURES
116 #define VHOST_USER_F_PROTOCOL_FEATURES 30
119 #define RTE_MAX_VHOST_DEVICE 1024
121 #define RTE_VHOST_VDPA_DEVICE_TYPE_NET 0
122 #define RTE_VHOST_VDPA_DEVICE_TYPE_BLK 1
124 struct rte_vdpa_device;
127 * Information relating to memory regions including offsets to
128 * addresses in QEMUs memory file.
130 struct rte_vhost_mem_region {
131 uint64_t guest_phys_addr;
132 uint64_t guest_user_addr;
133 uint64_t host_user_addr;
141 * Memory structure includes region and mapping information.
143 struct rte_vhost_memory {
145 struct rte_vhost_mem_region regions[];
148 struct rte_vhost_inflight_desc_split {
155 struct rte_vhost_inflight_info_split {
159 uint16_t last_inflight_io;
161 struct rte_vhost_inflight_desc_split desc[0];
164 struct rte_vhost_inflight_desc_packed {
177 struct rte_vhost_inflight_info_packed {
182 uint16_t old_free_head;
184 uint16_t old_used_idx;
185 uint8_t used_wrap_counter;
186 uint8_t old_used_wrap_counter;
188 struct rte_vhost_inflight_desc_packed desc[0];
191 struct rte_vhost_resubmit_desc {
196 struct rte_vhost_resubmit_info {
197 struct rte_vhost_resubmit_desc *resubmit_list;
198 uint16_t resubmit_num;
201 struct rte_vhost_ring_inflight {
203 struct rte_vhost_inflight_info_split *inflight_split;
204 struct rte_vhost_inflight_info_packed *inflight_packed;
207 struct rte_vhost_resubmit_info *resubmit_inflight;
210 struct rte_vhost_vring {
212 struct vring_desc *desc;
213 struct vring_packed_desc *desc_packed;
216 struct vring_avail *avail;
217 struct vring_packed_desc_event *driver_event;
220 struct vring_used *used;
221 struct vring_packed_desc_event *device_event;
223 uint64_t log_guest_addr;
225 /** Deprecated, use rte_vhost_vring_call() instead. */
233 * Possible results of the vhost user message handling callbacks
235 enum rte_vhost_msg_result {
236 /* Message handling failed */
237 RTE_VHOST_MSG_RESULT_ERR = -1,
238 /* Message handling successful */
239 RTE_VHOST_MSG_RESULT_OK = 0,
240 /* Message handling successful and reply prepared */
241 RTE_VHOST_MSG_RESULT_REPLY = 1,
242 /* Message not handled */
243 RTE_VHOST_MSG_RESULT_NOT_HANDLED,
247 * Function prototype for the vhost backend to handle specific vhost user
255 * RTE_VHOST_MSG_RESULT_OK on success,
256 * RTE_VHOST_MSG_RESULT_REPLY on success with reply,
257 * RTE_VHOST_MSG_RESULT_ERR on failure,
258 * RTE_VHOST_MSG_RESULT_NOT_HANDLED if message was not handled.
260 typedef enum rte_vhost_msg_result (*rte_vhost_msg_handle)(int vid, void *msg);
263 * Optional vhost user message handlers.
265 struct rte_vhost_user_extern_ops {
266 /* Called prior to the master message handling. */
267 rte_vhost_msg_handle pre_msg_handle;
268 /* Called after the master message handling. */
269 rte_vhost_msg_handle post_msg_handle;
273 * Device and vring operations.
275 struct rte_vhost_device_ops {
276 int (*new_device)(int vid); /**< Add device. */
277 void (*destroy_device)(int vid); /**< Remove device. */
279 int (*vring_state_changed)(int vid, uint16_t queue_id, int enable); /**< triggered when a vring is enabled or disabled */
282 * Features could be changed after the feature negotiation.
283 * For example, VHOST_F_LOG_ALL will be set/cleared at the
284 * start/end of live migration, respectively. This callback
285 * is used to inform the application on such change.
287 int (*features_changed)(int vid, uint64_t features);
289 int (*new_connection)(int vid);
290 void (*destroy_connection)(int vid);
293 * This callback gets called each time a guest gets notified
294 * about waiting packets. This is the interrupt handling through
295 * the eventfd_write(callfd), which can be used for counting these
298 void (*guest_notified)(int vid);
300 void *reserved[1]; /**< Reserved for future extension */
304 * Power monitor condition.
306 struct rte_vhost_power_monitor_cond {
307 /**< Address to monitor for changes */
309 /**< If the `mask` is non-zero, location pointed
310 * to by `addr` will be read and masked, then
311 * compared with this value.
314 /**< 64-bit mask to extract value read from `addr` */
316 /**< Data size (in bytes) that will be read from the
317 * monitored memory location (`addr`).
320 /**< If 1, and masked value that read from 'addr' equals
321 * 'val', the driver should skip core sleep. If 0, and
322 * masked value that read from 'addr' does not equal 'val',
323 * the driver should skip core sleep.
328 /** Maximum name length for the statistics counters */
329 #define RTE_VHOST_STATS_NAME_SIZE 64
332 * Vhost virtqueue statistics structure
334 * This structure is used by rte_vhost_vring_stats_get() to provide
335 * virtqueue statistics to the calling application.
336 * It maps a name ID, corresponding to an index in the array returned
337 * by rte_vhost_vring_stats_get_names(), to a statistic value.
339 struct rte_vhost_stat {
340 uint64_t id; /**< The index in xstats name array. */
341 uint64_t value; /**< The statistic counter value. */
345 * Vhost virtqueue statistic name element
347 * This structure is used by rte_vhost_vring_stats_get_names() to
348 * provide virtqueue statistics names to the calling application.
350 struct rte_vhost_stat_name {
351 char name[RTE_VHOST_STATS_NAME_SIZE]; /**< The statistic name. */
355 * Convert guest physical address to host virtual address
357 * This function is deprecated because unsafe.
358 * New rte_vhost_va_from_guest_pa() should be used instead to ensure
359 * guest physical ranges are fully and contiguously mapped into
360 * process virtual address space.
363 * the guest memory regions
365 * the guest physical address for querying
367 * the host virtual address on success, 0 on failure
370 static __rte_always_inline uint64_t
371 rte_vhost_gpa_to_vva(struct rte_vhost_memory *mem, uint64_t gpa)
373 struct rte_vhost_mem_region *reg;
376 for (i = 0; i < mem->nregions; i++) {
377 reg = &mem->regions[i];
378 if (gpa >= reg->guest_phys_addr &&
379 gpa < reg->guest_phys_addr + reg->size) {
380 return gpa - reg->guest_phys_addr +
389 * Convert guest physical address to host virtual address safely
391 * This variant of rte_vhost_gpa_to_vva() takes care all the
392 * requested length is mapped and contiguous in process address
396 * the guest memory regions
398 * the guest physical address for querying
400 * the size of the requested area to map, updated with actual size mapped
402 * the host virtual address on success, 0 on failure
404 static __rte_always_inline uint64_t
405 rte_vhost_va_from_guest_pa(struct rte_vhost_memory *mem,
406 uint64_t gpa, uint64_t *len)
408 struct rte_vhost_mem_region *r;
411 for (i = 0; i < mem->nregions; i++) {
412 r = &mem->regions[i];
413 if (gpa >= r->guest_phys_addr &&
414 gpa < r->guest_phys_addr + r->size) {
416 if (unlikely(*len > r->guest_phys_addr + r->size - gpa))
417 *len = r->guest_phys_addr + r->size - gpa;
419 return gpa - r->guest_phys_addr +
428 #define RTE_VHOST_NEED_LOG(features) ((features) & (1ULL << VHOST_F_LOG_ALL))
431 * Log the memory write start with given address.
433 * This function only need be invoked when the live migration starts.
434 * Therefore, we won't need call it at all in the most of time. For
435 * making the performance impact be minimum, it's suggested to do a
436 * check before calling it:
438 * if (unlikely(RTE_VHOST_NEED_LOG(features)))
439 * rte_vhost_log_write(vid, addr, len);
444 * the starting address for write (in guest physical address space)
446 * the length to write
448 void rte_vhost_log_write(int vid, uint64_t addr, uint64_t len);
451 * Log the used ring update start at given offset.
453 * Same as rte_vhost_log_write, it's suggested to do a check before
456 * if (unlikely(RTE_VHOST_NEED_LOG(features)))
457 * rte_vhost_log_used_vring(vid, vring_idx, offset, len);
464 * the offset inside the used ring
466 * the length to write
468 void rte_vhost_log_used_vring(int vid, uint16_t vring_idx,
469 uint64_t offset, uint64_t len);
471 int rte_vhost_enable_guest_notification(int vid, uint16_t queue_id, int enable);
474 * Register vhost driver. path could be different for multiple
477 int rte_vhost_driver_register(const char *path, uint64_t flags);
479 /* Unregister vhost driver. This is only meaningful to vhost user. */
480 int rte_vhost_driver_unregister(const char *path);
483 * Set the vdpa device id, enforce single connection per socket
486 * The vhost-user socket file path
488 * vDPA device pointer
490 * 0 on success, -1 on failure
493 rte_vhost_driver_attach_vdpa_device(const char *path,
494 struct rte_vdpa_device *dev);
497 * Unset the vdpa device id
500 * The vhost-user socket file path
502 * 0 on success, -1 on failure
505 rte_vhost_driver_detach_vdpa_device(const char *path);
511 * The vhost-user socket file path
513 * vDPA device pointer, NULL on failure
515 struct rte_vdpa_device *
516 rte_vhost_driver_get_vdpa_device(const char *path);
519 * Get the device type of the vdpa device.
522 * The vhost-user socket file path
524 * the device type of the vdpa device
526 * 0 on success, -1 on failure
530 rte_vhost_driver_get_vdpa_dev_type(const char *path, uint32_t *type);
533 * Set the feature bits the vhost-user driver supports.
536 * The vhost-user socket file path
540 * 0 on success, -1 on failure
542 int rte_vhost_driver_set_features(const char *path, uint64_t features);
545 * Enable vhost-user driver features.
548 * - the param features should be a subset of the feature bits provided
549 * by rte_vhost_driver_set_features().
550 * - it must be invoked before vhost-user negotiation starts.
553 * The vhost-user socket file path
557 * 0 on success, -1 on failure
559 int rte_vhost_driver_enable_features(const char *path, uint64_t features);
562 * Disable vhost-user driver features.
564 * The two notes at rte_vhost_driver_enable_features() also apply here.
567 * The vhost-user socket file path
569 * Features to disable
571 * 0 on success, -1 on failure
573 int rte_vhost_driver_disable_features(const char *path, uint64_t features);
576 * Get the feature bits before feature negotiation.
579 * The vhost-user socket file path
581 * A pointer to store the queried feature bits
583 * 0 on success, -1 on failure
585 int rte_vhost_driver_get_features(const char *path, uint64_t *features);
588 * Set the protocol feature bits before feature negotiation.
591 * The vhost-user socket file path
592 * @param protocol_features
593 * Supported protocol features
595 * 0 on success, -1 on failure
598 rte_vhost_driver_set_protocol_features(const char *path,
599 uint64_t protocol_features);
602 * Get the protocol feature bits before feature negotiation.
605 * The vhost-user socket file path
606 * @param protocol_features
607 * A pointer to store the queried protocol feature bits
609 * 0 on success, -1 on failure
612 rte_vhost_driver_get_protocol_features(const char *path,
613 uint64_t *protocol_features);
616 * Get the queue number bits before feature negotiation.
619 * The vhost-user socket file path
621 * A pointer to store the queried queue number bits
623 * 0 on success, -1 on failure
626 rte_vhost_driver_get_queue_num(const char *path, uint32_t *queue_num);
629 * Get the feature bits after negotiation
634 * A pointer to store the queried feature bits
636 * 0 on success, -1 on failure
638 int rte_vhost_get_negotiated_features(int vid, uint64_t *features);
641 * Get the protocol feature bits after negotiation
645 * @param protocol_features
646 * A pointer to store the queried protocol feature bits
648 * 0 on success, -1 on failure
652 rte_vhost_get_negotiated_protocol_features(int vid,
653 uint64_t *protocol_features);
655 /* Register callbacks. */
656 int rte_vhost_driver_callback_register(const char *path,
657 struct rte_vhost_device_ops const * const ops);
661 * Start the vhost-user driver.
663 * This function triggers the vhost-user negotiation.
666 * The vhost-user socket file path
668 * 0 on success, -1 on failure
670 int rte_vhost_driver_start(const char *path);
673 * Get the MTU value of the device if set in QEMU.
676 * virtio-net device ID
678 * The variable to store the MTU value
682 * -EAGAIN: device not yet started
683 * -ENOTSUP: device does not support MTU feature
685 int rte_vhost_get_mtu(int vid, uint16_t *mtu);
688 * Get the numa node from which the virtio net device's memory
695 * The numa node, -1 on failure
697 int rte_vhost_get_numa_node(int vid);
701 * Get the number of queues the device supports.
703 * Note this function is deprecated, as it returns a queue pair number,
704 * which is vhost specific. Instead, rte_vhost_get_vring_num should
711 * The number of queues, 0 on failure
714 uint32_t rte_vhost_get_queue_num(int vid);
717 * Get the number of vrings the device supports.
723 * The number of vrings, 0 on failure
725 uint16_t rte_vhost_get_vring_num(int vid);
728 * Get the virtio net device's ifname, which is the vhost-user socket
734 * The buffer to stored the queried ifname
739 * 0 on success, -1 on failure
741 int rte_vhost_get_ifname(int vid, char *buf, size_t len);
744 * Get how many avail entries are left in the queue
752 * num of avail entries left
754 uint16_t rte_vhost_avail_entries(int vid, uint16_t queue_id);
759 * This function adds buffers to the virtio devices RX virtqueue. Buffers can
760 * be received from the physical port or from another virtual device. A packet
761 * count is returned to indicate the number of packets that were successfully
762 * added to the RX queue.
766 * virtio queue index in mq case
768 * array to contain packets to be enqueued
770 * packets num to be enqueued
772 * num of packets enqueued
774 uint16_t rte_vhost_enqueue_burst(int vid, uint16_t queue_id,
775 struct rte_mbuf **pkts, uint16_t count);
778 * This function gets guest buffers from the virtio device TX virtqueue,
779 * construct host mbufs, copies guest buffer content to host mbufs and
780 * store them in pkts to be processed.
784 * virtio queue index in mq case
786 * mbuf_pool where host mbuf is allocated.
788 * array to contain packets to be dequeued
790 * packets num to be dequeued
792 * num of packets dequeued
794 uint16_t rte_vhost_dequeue_burst(int vid, uint16_t queue_id,
795 struct rte_mempool *mbuf_pool, struct rte_mbuf **pkts, uint16_t count);
798 * Get guest mem table: a list of memory regions.
800 * An rte_vhost_vhost_memory object will be allocated internally, to hold the
801 * guest memory regions. Application should free it at destroy_device()
807 * To store the returned mem regions
809 * 0 on success, -1 on failure
811 int rte_vhost_get_mem_table(int vid, struct rte_vhost_memory **mem);
814 * Get guest vring info, including the vring address, vring size, etc.
821 * the structure to hold the requested vring info
823 * 0 on success, -1 on failure
825 int rte_vhost_get_vhost_vring(int vid, uint16_t vring_idx,
826 struct rte_vhost_vring *vring);
829 * Get guest inflight vring info, including inflight ring and resubmit list.
836 * the structure to hold the requested inflight vring info
838 * 0 on success, -1 on failure
841 rte_vhost_get_vhost_ring_inflight(int vid, uint16_t vring_idx,
842 struct rte_vhost_ring_inflight *vring);
845 * Set split inflight descriptor.
847 * This function save descriptors that has been consumed in available
855 * inflight entry index
857 * 0 on success, -1 on failure
860 rte_vhost_set_inflight_desc_split(int vid, uint16_t vring_idx,
864 * Set packed inflight descriptor and get corresponding inflight entry
866 * This function save descriptors that has been consumed
873 * head of descriptors
875 * last of descriptors
876 * @param inflight_entry
877 * corresponding inflight entry
879 * 0 on success, -1 on failure
882 rte_vhost_set_inflight_desc_packed(int vid, uint16_t vring_idx,
883 uint16_t head, uint16_t last, uint16_t *inflight_entry);
886 * Save the head of list that the last batch of used descriptors.
893 * descriptor entry index
895 * 0 on success, -1 on failure
898 rte_vhost_set_last_inflight_io_split(int vid,
899 uint16_t vring_idx, uint16_t idx);
902 * Update the inflight free_head, used_idx and used_wrap_counter.
904 * This function will update status first before updating descriptors
912 * head of descriptors
914 * 0 on success, -1 on failure
917 rte_vhost_set_last_inflight_io_packed(int vid,
918 uint16_t vring_idx, uint16_t head);
921 * Clear the split inflight status.
927 * @param last_used_idx
928 * last used idx of used ring
930 * inflight entry index
932 * 0 on success, -1 on failure
935 rte_vhost_clr_inflight_desc_split(int vid, uint16_t vring_idx,
936 uint16_t last_used_idx, uint16_t idx);
939 * Clear the packed inflight status.
946 * inflight entry index
948 * 0 on success, -1 on failure
951 rte_vhost_clr_inflight_desc_packed(int vid, uint16_t vring_idx,
955 * Notify the guest that used descriptors have been added to the vring. This
956 * function acts as a memory barrier.
963 * 0 on success, -1 on failure
965 int rte_vhost_vring_call(int vid, uint16_t vring_idx);
968 * Get vhost RX queue avail count.
973 * virtio queue index in mq case
975 * num of desc available
977 uint32_t rte_vhost_rx_queue_count(int vid, uint16_t qid);
980 * Get power monitor address of the vhost device
987 * power monitor condition
989 * 0 on success, -1 on failure
993 rte_vhost_get_monitor_addr(int vid, uint16_t queue_id,
994 struct rte_vhost_power_monitor_cond *pmc);
997 * Get log base and log size of the vhost device
1006 * 0 on success, -1 on failure
1009 rte_vhost_get_log_base(int vid, uint64_t *log_base, uint64_t *log_size);
1012 * Get last_avail/used_idx of the vhost virtqueue
1018 * @param last_avail_idx
1019 * vhost last_avail_idx to get
1020 * @param last_used_idx
1021 * vhost last_used_idx to get
1023 * 0 on success, -1 on failure
1026 rte_vhost_get_vring_base(int vid, uint16_t queue_id,
1027 uint16_t *last_avail_idx, uint16_t *last_used_idx);
1030 * Get last_avail/last_used of the vhost virtqueue
1032 * This function is designed for the reconnection and it's specific for
1033 * the packed ring as we can get the two parameters from the inflight
1040 * @param last_avail_idx
1041 * vhost last_avail_idx to get
1042 * @param last_used_idx
1043 * vhost last_used_idx to get
1045 * 0 on success, -1 on failure
1048 rte_vhost_get_vring_base_from_inflight(int vid,
1049 uint16_t queue_id, uint16_t *last_avail_idx, uint16_t *last_used_idx);
1052 * Set last_avail/used_idx of the vhost virtqueue
1058 * @param last_avail_idx
1059 * last_avail_idx to set
1060 * @param last_used_idx
1061 * last_used_idx to set
1063 * 0 on success, -1 on failure
1066 rte_vhost_set_vring_base(int vid, uint16_t queue_id,
1067 uint16_t last_avail_idx, uint16_t last_used_idx);
1070 * Register external message handling callbacks
1075 * virtio external callbacks to register
1077 * additional context passed to the callbacks
1079 * 0 on success, -1 on failure
1082 rte_vhost_extern_callback_register(int vid,
1083 struct rte_vhost_user_extern_ops const * const ops, void *ctx);
1086 * Get vdpa device id for vhost device.
1091 * vDPA device pointer on success, NULL on failure
1093 struct rte_vdpa_device *
1094 rte_vhost_get_vdpa_device(int vid);
1097 * Notify the guest that should get virtio configuration space from backend.
1102 * wait for the master response the status of this operation
1104 * 0 on success, < 0 on failure
1108 rte_vhost_slave_config_change(int vid, bool need_reply);
1111 * Retrieve names of statistics of a Vhost virtqueue.
1113 * There is an assumption that 'stat_names' and 'stats' arrays are matched
1114 * by array index: stats_names[i].name => stats[i].value
1121 * array of at least size elements to be filled.
1122 * If set to NULL, the function returns the required number of elements.
1124 * The number of elements in stats_names array.
1126 * - Success if greater than 0 and lower or equal to *size*. The return value
1127 * indicates the number of elements filled in the *names* array.
1128 * - Failure if greater than *size*. The return value indicates the number of
1129 * elements the *names* array that should be given to succeed.
1130 * - Failure if lower than 0. The device ID or queue ID is invalid or
1131 + statistics collection is not enabled.
1135 rte_vhost_vring_stats_get_names(int vid, uint16_t queue_id,
1136 struct rte_vhost_stat_name *name, unsigned int size);
1139 * Retrieve statistics of a Vhost virtqueue.
1141 * There is an assumption that 'stat_names' and 'stats' arrays are matched
1142 * by array index: stats_names[i].name => stats[i].value
1149 * A pointer to a table of structure of type rte_vhost_stat to be filled with
1150 * virtqueue statistics ids and values.
1152 * The number of elements in stats array.
1154 * - Success if greater than 0 and lower or equal to *n*. The return value
1155 * indicates the number of elements filled in the *stats* array.
1156 * - Failure if greater than *n*. The return value indicates the number of
1157 * elements the *stats* array that should be given to succeed.
1158 * - Failure if lower than 0. The device ID or queue ID is invalid, or
1159 * statistics collection is not enabled.
1163 rte_vhost_vring_stats_get(int vid, uint16_t queue_id,
1164 struct rte_vhost_stat *stats, unsigned int n);
1167 * Reset statistics of a Vhost virtqueue.
1174 * - Success if 0. Statistics have been reset.
1175 * - Failure if lower than 0. The device ID or queue ID is invalid, or
1176 * statistics collection is not enabled.
1180 rte_vhost_vring_stats_reset(int vid, uint16_t queue_id);
1186 #endif /* _RTE_VHOST_H_ */