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 struct rte_vdpa_device;
124 * Information relating to memory regions including offsets to
125 * addresses in QEMUs memory file.
127 struct rte_vhost_mem_region {
128 uint64_t guest_phys_addr;
129 uint64_t guest_user_addr;
130 uint64_t host_user_addr;
138 * Memory structure includes region and mapping information.
140 struct rte_vhost_memory {
142 struct rte_vhost_mem_region regions[];
145 struct rte_vhost_inflight_desc_split {
152 struct rte_vhost_inflight_info_split {
156 uint16_t last_inflight_io;
158 struct rte_vhost_inflight_desc_split desc[0];
161 struct rte_vhost_inflight_desc_packed {
174 struct rte_vhost_inflight_info_packed {
179 uint16_t old_free_head;
181 uint16_t old_used_idx;
182 uint8_t used_wrap_counter;
183 uint8_t old_used_wrap_counter;
185 struct rte_vhost_inflight_desc_packed desc[0];
188 struct rte_vhost_resubmit_desc {
193 struct rte_vhost_resubmit_info {
194 struct rte_vhost_resubmit_desc *resubmit_list;
195 uint16_t resubmit_num;
198 struct rte_vhost_ring_inflight {
200 struct rte_vhost_inflight_info_split *inflight_split;
201 struct rte_vhost_inflight_info_packed *inflight_packed;
204 struct rte_vhost_resubmit_info *resubmit_inflight;
207 struct rte_vhost_vring {
209 struct vring_desc *desc;
210 struct vring_packed_desc *desc_packed;
213 struct vring_avail *avail;
214 struct vring_packed_desc_event *driver_event;
217 struct vring_used *used;
218 struct vring_packed_desc_event *device_event;
220 uint64_t log_guest_addr;
222 /** Deprecated, use rte_vhost_vring_call() instead. */
230 * Possible results of the vhost user message handling callbacks
232 enum rte_vhost_msg_result {
233 /* Message handling failed */
234 RTE_VHOST_MSG_RESULT_ERR = -1,
235 /* Message handling successful */
236 RTE_VHOST_MSG_RESULT_OK = 0,
237 /* Message handling successful and reply prepared */
238 RTE_VHOST_MSG_RESULT_REPLY = 1,
239 /* Message not handled */
240 RTE_VHOST_MSG_RESULT_NOT_HANDLED,
244 * Function prototype for the vhost backend to handle specific vhost user
252 * RTE_VHOST_MSG_RESULT_OK on success,
253 * RTE_VHOST_MSG_RESULT_REPLY on success with reply,
254 * RTE_VHOST_MSG_RESULT_ERR on failure,
255 * RTE_VHOST_MSG_RESULT_NOT_HANDLED if message was not handled.
257 typedef enum rte_vhost_msg_result (*rte_vhost_msg_handle)(int vid, void *msg);
260 * Optional vhost user message handlers.
262 struct rte_vhost_user_extern_ops {
263 /* Called prior to the master message handling. */
264 rte_vhost_msg_handle pre_msg_handle;
265 /* Called after the master message handling. */
266 rte_vhost_msg_handle post_msg_handle;
270 * Device and vring operations.
272 struct rte_vhost_device_ops {
273 int (*new_device)(int vid); /**< Add device. */
274 void (*destroy_device)(int vid); /**< Remove device. */
276 int (*vring_state_changed)(int vid, uint16_t queue_id, int enable); /**< triggered when a vring is enabled or disabled */
279 * Features could be changed after the feature negotiation.
280 * For example, VHOST_F_LOG_ALL will be set/cleared at the
281 * start/end of live migration, respectively. This callback
282 * is used to inform the application on such change.
284 int (*features_changed)(int vid, uint64_t features);
286 int (*new_connection)(int vid);
287 void (*destroy_connection)(int vid);
290 * This callback gets called each time a guest gets notified
291 * about waiting packets. This is the interrupt handling through
292 * the eventfd_write(callfd), which can be used for counting these
295 void (*guest_notified)(int vid);
297 void *reserved[1]; /**< Reserved for future extension */
301 * Power monitor condition.
303 struct rte_vhost_power_monitor_cond {
304 /**< Address to monitor for changes */
306 /**< If the `mask` is non-zero, location pointed
307 * to by `addr` will be read and masked, then
308 * compared with this value.
311 /**< 64-bit mask to extract value read from `addr` */
313 /**< Data size (in bytes) that will be read from the
314 * monitored memory location (`addr`).
317 /**< If 1, and masked value that read from 'addr' equals
318 * 'val', the driver should skip core sleep. If 0, and
319 * masked value that read from 'addr' does not equal 'val',
320 * the driver should skip core sleep.
325 /** Maximum name length for the statistics counters */
326 #define RTE_VHOST_STATS_NAME_SIZE 64
329 * Vhost virtqueue statistics structure
331 * This structure is used by rte_vhost_vring_stats_get() to provide
332 * virtqueue statistics to the calling application.
333 * It maps a name ID, corresponding to an index in the array returned
334 * by rte_vhost_vring_stats_get_names(), to a statistic value.
336 struct rte_vhost_stat {
337 uint64_t id; /**< The index in xstats name array. */
338 uint64_t value; /**< The statistic counter value. */
342 * Vhost virtqueue statistic name element
344 * This structure is used by rte_vhost_vring_stats_get_names() to
345 * provide virtqueue statistics names to the calling application.
347 struct rte_vhost_stat_name {
348 char name[RTE_VHOST_STATS_NAME_SIZE]; /**< The statistic name. */
352 * Convert guest physical address to host virtual address
354 * This function is deprecated because unsafe.
355 * New rte_vhost_va_from_guest_pa() should be used instead to ensure
356 * guest physical ranges are fully and contiguously mapped into
357 * process virtual address space.
360 * the guest memory regions
362 * the guest physical address for querying
364 * the host virtual address on success, 0 on failure
367 static __rte_always_inline uint64_t
368 rte_vhost_gpa_to_vva(struct rte_vhost_memory *mem, uint64_t gpa)
370 struct rte_vhost_mem_region *reg;
373 for (i = 0; i < mem->nregions; i++) {
374 reg = &mem->regions[i];
375 if (gpa >= reg->guest_phys_addr &&
376 gpa < reg->guest_phys_addr + reg->size) {
377 return gpa - reg->guest_phys_addr +
386 * Convert guest physical address to host virtual address safely
388 * This variant of rte_vhost_gpa_to_vva() takes care all the
389 * requested length is mapped and contiguous in process address
393 * the guest memory regions
395 * the guest physical address for querying
397 * the size of the requested area to map, updated with actual size mapped
399 * the host virtual address on success, 0 on failure
401 static __rte_always_inline uint64_t
402 rte_vhost_va_from_guest_pa(struct rte_vhost_memory *mem,
403 uint64_t gpa, uint64_t *len)
405 struct rte_vhost_mem_region *r;
408 for (i = 0; i < mem->nregions; i++) {
409 r = &mem->regions[i];
410 if (gpa >= r->guest_phys_addr &&
411 gpa < r->guest_phys_addr + r->size) {
413 if (unlikely(*len > r->guest_phys_addr + r->size - gpa))
414 *len = r->guest_phys_addr + r->size - gpa;
416 return gpa - r->guest_phys_addr +
425 #define RTE_VHOST_NEED_LOG(features) ((features) & (1ULL << VHOST_F_LOG_ALL))
428 * Log the memory write start with given address.
430 * This function only need be invoked when the live migration starts.
431 * Therefore, we won't need call it at all in the most of time. For
432 * making the performance impact be minimum, it's suggested to do a
433 * check before calling it:
435 * if (unlikely(RTE_VHOST_NEED_LOG(features)))
436 * rte_vhost_log_write(vid, addr, len);
441 * the starting address for write (in guest physical address space)
443 * the length to write
445 void rte_vhost_log_write(int vid, uint64_t addr, uint64_t len);
448 * Log the used ring update start at given offset.
450 * Same as rte_vhost_log_write, it's suggested to do a check before
453 * if (unlikely(RTE_VHOST_NEED_LOG(features)))
454 * rte_vhost_log_used_vring(vid, vring_idx, offset, len);
461 * the offset inside the used ring
463 * the length to write
465 void rte_vhost_log_used_vring(int vid, uint16_t vring_idx,
466 uint64_t offset, uint64_t len);
468 int rte_vhost_enable_guest_notification(int vid, uint16_t queue_id, int enable);
471 * Register vhost driver. path could be different for multiple
474 int rte_vhost_driver_register(const char *path, uint64_t flags);
476 /* Unregister vhost driver. This is only meaningful to vhost user. */
477 int rte_vhost_driver_unregister(const char *path);
480 * Set the vdpa device id, enforce single connection per socket
483 * The vhost-user socket file path
485 * vDPA device pointer
487 * 0 on success, -1 on failure
490 rte_vhost_driver_attach_vdpa_device(const char *path,
491 struct rte_vdpa_device *dev);
494 * Unset the vdpa device id
497 * The vhost-user socket file path
499 * 0 on success, -1 on failure
502 rte_vhost_driver_detach_vdpa_device(const char *path);
508 * The vhost-user socket file path
510 * vDPA device pointer, NULL on failure
512 struct rte_vdpa_device *
513 rte_vhost_driver_get_vdpa_device(const char *path);
516 * Set the feature bits the vhost-user driver supports.
519 * The vhost-user socket file path
523 * 0 on success, -1 on failure
525 int rte_vhost_driver_set_features(const char *path, uint64_t features);
528 * Enable vhost-user driver features.
531 * - the param features should be a subset of the feature bits provided
532 * by rte_vhost_driver_set_features().
533 * - it must be invoked before vhost-user negotiation starts.
536 * The vhost-user socket file path
540 * 0 on success, -1 on failure
542 int rte_vhost_driver_enable_features(const char *path, uint64_t features);
545 * Disable vhost-user driver features.
547 * The two notes at rte_vhost_driver_enable_features() also apply here.
550 * The vhost-user socket file path
552 * Features to disable
554 * 0 on success, -1 on failure
556 int rte_vhost_driver_disable_features(const char *path, uint64_t features);
559 * Get the feature bits before feature negotiation.
562 * The vhost-user socket file path
564 * A pointer to store the queried feature bits
566 * 0 on success, -1 on failure
568 int rte_vhost_driver_get_features(const char *path, uint64_t *features);
571 * Set the protocol feature bits before feature negotiation.
574 * The vhost-user socket file path
575 * @param protocol_features
576 * Supported protocol features
578 * 0 on success, -1 on failure
581 rte_vhost_driver_set_protocol_features(const char *path,
582 uint64_t protocol_features);
585 * Get the protocol feature bits before feature negotiation.
588 * The vhost-user socket file path
589 * @param protocol_features
590 * A pointer to store the queried protocol feature bits
592 * 0 on success, -1 on failure
595 rte_vhost_driver_get_protocol_features(const char *path,
596 uint64_t *protocol_features);
599 * Get the queue number bits before feature negotiation.
602 * The vhost-user socket file path
604 * A pointer to store the queried queue number bits
606 * 0 on success, -1 on failure
609 rte_vhost_driver_get_queue_num(const char *path, uint32_t *queue_num);
612 * Get the feature bits after negotiation
617 * A pointer to store the queried feature bits
619 * 0 on success, -1 on failure
621 int rte_vhost_get_negotiated_features(int vid, uint64_t *features);
624 * Get the protocol feature bits after negotiation
628 * @param protocol_features
629 * A pointer to store the queried protocol feature bits
631 * 0 on success, -1 on failure
635 rte_vhost_get_negotiated_protocol_features(int vid,
636 uint64_t *protocol_features);
638 /* Register callbacks. */
639 int rte_vhost_driver_callback_register(const char *path,
640 struct rte_vhost_device_ops const * const ops);
644 * Start the vhost-user driver.
646 * This function triggers the vhost-user negotiation.
649 * The vhost-user socket file path
651 * 0 on success, -1 on failure
653 int rte_vhost_driver_start(const char *path);
656 * Get the MTU value of the device if set in QEMU.
659 * virtio-net device ID
661 * The variable to store the MTU value
665 * -EAGAIN: device not yet started
666 * -ENOTSUP: device does not support MTU feature
668 int rte_vhost_get_mtu(int vid, uint16_t *mtu);
671 * Get the numa node from which the virtio net device's memory
678 * The numa node, -1 on failure
680 int rte_vhost_get_numa_node(int vid);
684 * Get the number of queues the device supports.
686 * Note this function is deprecated, as it returns a queue pair number,
687 * which is vhost specific. Instead, rte_vhost_get_vring_num should
694 * The number of queues, 0 on failure
697 uint32_t rte_vhost_get_queue_num(int vid);
700 * Get the number of vrings the device supports.
706 * The number of vrings, 0 on failure
708 uint16_t rte_vhost_get_vring_num(int vid);
711 * Get the virtio net device's ifname, which is the vhost-user socket
717 * The buffer to stored the queried ifname
722 * 0 on success, -1 on failure
724 int rte_vhost_get_ifname(int vid, char *buf, size_t len);
727 * Get how many avail entries are left in the queue
735 * num of avail entries left
737 uint16_t rte_vhost_avail_entries(int vid, uint16_t queue_id);
742 * This function adds buffers to the virtio devices RX virtqueue. Buffers can
743 * be received from the physical port or from another virtual device. A packet
744 * count is returned to indicate the number of packets that were successfully
745 * added to the RX queue.
749 * virtio queue index in mq case
751 * array to contain packets to be enqueued
753 * packets num to be enqueued
755 * num of packets enqueued
757 uint16_t rte_vhost_enqueue_burst(int vid, uint16_t queue_id,
758 struct rte_mbuf **pkts, uint16_t count);
761 * This function gets guest buffers from the virtio device TX virtqueue,
762 * construct host mbufs, copies guest buffer content to host mbufs and
763 * store them in pkts to be processed.
767 * virtio queue index in mq case
769 * mbuf_pool where host mbuf is allocated.
771 * array to contain packets to be dequeued
773 * packets num to be dequeued
775 * num of packets dequeued
777 uint16_t rte_vhost_dequeue_burst(int vid, uint16_t queue_id,
778 struct rte_mempool *mbuf_pool, struct rte_mbuf **pkts, uint16_t count);
781 * Get guest mem table: a list of memory regions.
783 * An rte_vhost_vhost_memory object will be allocated internally, to hold the
784 * guest memory regions. Application should free it at destroy_device()
790 * To store the returned mem regions
792 * 0 on success, -1 on failure
794 int rte_vhost_get_mem_table(int vid, struct rte_vhost_memory **mem);
797 * Get guest vring info, including the vring address, vring size, etc.
804 * the structure to hold the requested vring info
806 * 0 on success, -1 on failure
808 int rte_vhost_get_vhost_vring(int vid, uint16_t vring_idx,
809 struct rte_vhost_vring *vring);
812 * Get guest inflight vring info, including inflight ring and resubmit list.
819 * the structure to hold the requested inflight vring info
821 * 0 on success, -1 on failure
824 rte_vhost_get_vhost_ring_inflight(int vid, uint16_t vring_idx,
825 struct rte_vhost_ring_inflight *vring);
828 * Set split inflight descriptor.
830 * This function save descriptors that has been consumed in available
838 * inflight entry index
840 * 0 on success, -1 on failure
843 rte_vhost_set_inflight_desc_split(int vid, uint16_t vring_idx,
847 * Set packed inflight descriptor and get corresponding inflight entry
849 * This function save descriptors that has been consumed
856 * head of descriptors
858 * last of descriptors
859 * @param inflight_entry
860 * corresponding inflight entry
862 * 0 on success, -1 on failure
865 rte_vhost_set_inflight_desc_packed(int vid, uint16_t vring_idx,
866 uint16_t head, uint16_t last, uint16_t *inflight_entry);
869 * Save the head of list that the last batch of used descriptors.
876 * descriptor entry index
878 * 0 on success, -1 on failure
881 rte_vhost_set_last_inflight_io_split(int vid,
882 uint16_t vring_idx, uint16_t idx);
885 * Update the inflight free_head, used_idx and used_wrap_counter.
887 * This function will update status first before updating descriptors
895 * head of descriptors
897 * 0 on success, -1 on failure
900 rte_vhost_set_last_inflight_io_packed(int vid,
901 uint16_t vring_idx, uint16_t head);
904 * Clear the split inflight status.
910 * @param last_used_idx
911 * last used idx of used ring
913 * inflight entry index
915 * 0 on success, -1 on failure
918 rte_vhost_clr_inflight_desc_split(int vid, uint16_t vring_idx,
919 uint16_t last_used_idx, uint16_t idx);
922 * Clear the packed inflight status.
929 * inflight entry index
931 * 0 on success, -1 on failure
934 rte_vhost_clr_inflight_desc_packed(int vid, uint16_t vring_idx,
938 * Notify the guest that used descriptors have been added to the vring. This
939 * function acts as a memory barrier.
946 * 0 on success, -1 on failure
948 int rte_vhost_vring_call(int vid, uint16_t vring_idx);
951 * Get vhost RX queue avail count.
956 * virtio queue index in mq case
958 * num of desc available
960 uint32_t rte_vhost_rx_queue_count(int vid, uint16_t qid);
963 * Get power monitor address of the vhost device
970 * power monitor condition
972 * 0 on success, -1 on failure
976 rte_vhost_get_monitor_addr(int vid, uint16_t queue_id,
977 struct rte_vhost_power_monitor_cond *pmc);
980 * Get log base and log size of the vhost device
989 * 0 on success, -1 on failure
992 rte_vhost_get_log_base(int vid, uint64_t *log_base, uint64_t *log_size);
995 * Get last_avail/used_idx of the vhost virtqueue
1001 * @param last_avail_idx
1002 * vhost last_avail_idx to get
1003 * @param last_used_idx
1004 * vhost last_used_idx to get
1006 * 0 on success, -1 on failure
1009 rte_vhost_get_vring_base(int vid, uint16_t queue_id,
1010 uint16_t *last_avail_idx, uint16_t *last_used_idx);
1013 * Get last_avail/last_used of the vhost virtqueue
1015 * This function is designed for the reconnection and it's specific for
1016 * the packed ring as we can get the two parameters from the inflight
1023 * @param last_avail_idx
1024 * vhost last_avail_idx to get
1025 * @param last_used_idx
1026 * vhost last_used_idx to get
1028 * 0 on success, -1 on failure
1031 rte_vhost_get_vring_base_from_inflight(int vid,
1032 uint16_t queue_id, uint16_t *last_avail_idx, uint16_t *last_used_idx);
1035 * Set last_avail/used_idx of the vhost virtqueue
1041 * @param last_avail_idx
1042 * last_avail_idx to set
1043 * @param last_used_idx
1044 * last_used_idx to set
1046 * 0 on success, -1 on failure
1049 rte_vhost_set_vring_base(int vid, uint16_t queue_id,
1050 uint16_t last_avail_idx, uint16_t last_used_idx);
1053 * Register external message handling callbacks
1058 * virtio external callbacks to register
1060 * additional context passed to the callbacks
1062 * 0 on success, -1 on failure
1065 rte_vhost_extern_callback_register(int vid,
1066 struct rte_vhost_user_extern_ops const * const ops, void *ctx);
1069 * Get vdpa device id for vhost device.
1074 * vDPA device pointer on success, NULL on failure
1076 struct rte_vdpa_device *
1077 rte_vhost_get_vdpa_device(int vid);
1080 * Notify the guest that should get virtio configuration space from backend.
1085 * wait for the master response the status of this operation
1087 * 0 on success, < 0 on failure
1091 rte_vhost_slave_config_change(int vid, bool need_reply);
1094 * Retrieve names of statistics of a Vhost virtqueue.
1096 * There is an assumption that 'stat_names' and 'stats' arrays are matched
1097 * by array index: stats_names[i].name => stats[i].value
1104 * array of at least size elements to be filled.
1105 * If set to NULL, the function returns the required number of elements.
1107 * The number of elements in stats_names array.
1109 * - Success if greater than 0 and lower or equal to *size*. The return value
1110 * indicates the number of elements filled in the *names* array.
1111 * - Failure if greater than *size*. The return value indicates the number of
1112 * elements the *names* array that should be given to succeed.
1113 * - Failure if lower than 0. The device ID or queue ID is invalid or
1114 + statistics collection is not enabled.
1118 rte_vhost_vring_stats_get_names(int vid, uint16_t queue_id,
1119 struct rte_vhost_stat_name *name, unsigned int size);
1122 * Retrieve statistics of a Vhost virtqueue.
1124 * There is an assumption that 'stat_names' and 'stats' arrays are matched
1125 * by array index: stats_names[i].name => stats[i].value
1132 * A pointer to a table of structure of type rte_vhost_stat to be filled with
1133 * virtqueue statistics ids and values.
1135 * The number of elements in stats array.
1137 * - Success if greater than 0 and lower or equal to *n*. The return value
1138 * indicates the number of elements filled in the *stats* array.
1139 * - Failure if greater than *n*. The return value indicates the number of
1140 * elements the *stats* array that should be given to succeed.
1141 * - Failure if lower than 0. The device ID or queue ID is invalid, or
1142 * statistics collection is not enabled.
1146 rte_vhost_vring_stats_get(int vid, uint16_t queue_id,
1147 struct rte_vhost_stat *stats, unsigned int n);
1150 * Reset statistics of a Vhost virtqueue.
1157 * - Success if 0. Statistics have been reset.
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_reset(int vid, uint16_t queue_id);
1169 #endif /* _RTE_VHOST_H_ */