rte_vhost.h(3)
π rte_vhost.h(3) β Library Functions Manual π
okay bestie, welcome to the vhost-user chapter of your life. this is rte_vhost.h, and it's giving main character energy in DPDK. no cap.
β¨ NAME β¨
rte_vhost.h β yes, that's the whole name, periodt.
π¦ SYNOPSIS π¦
First, the includes. Don't skip a single one, iykyk:
#include <stdbool.h>
#include <stdint.h>
#include <sys/eventfd.h>
#include <rte_compat.h>
#include <rte_memory.h>
#include <rte_mempool.h>
#include <linux/vhost.h>
#include <linux/virtio_ring.h>
#include <linux/virtio_net.h>
Then we got the data structures, macros, typedefs, enumerations, and functions. Let's vibe through each.
π Data Structures π
struct rte_vhost_mem_regionstruct rte_vhost_memorystruct rte_vhost_user_extern_opsstruct rte_vhost_device_opsstruct rte_vhost_power_monitor_condstruct rte_vhost_statstruct rte_vhost_stat_name
These are the structs you'll be passing around, bestie. Obsessed.
β¨ Macros β¨
#define VHOST_USER_PROTOCOL_F_MQ 0#define VHOST_USER_F_PROTOCOL_FEATURES 30#define RTE_VHOST_STATS_NAME_SIZE 64
Macros, but make it fashion. π
π Typedefs π
typedef enum rte_vhost_msg_result(* rte_vhost_msg_handle) (int vid, void *msg)
This one's a function pointer typedef. The way it handles vhost user messages? iconic.
πΈ Enumerations πΈ
enum rte_vhost_msg_result
Just one enum here, but it's important, fr fr.
π Functions π
Here's the full lineup, no gatekeeping:
static __rte_always_inline uint64_t rte_vhost_va_from_guest_pa (struct rte_vhost_memory *mem, uint64_t gpa, uint64_t *len)
void rte_vhost_log_write (int vid, uint64_t addr, uint64_t len)
void rte_vhost_log_used_vring (int vid, uint16_t vring_idx, uint64_t offset, uint64_t len)
__rte_experimental void rte_vhost_notify_guest (int vid, uint16_t queue_id)
int rte_vhost_driver_register (const char *path, uint64_t flags)
int rte_vhost_driver_attach_vdpa_device (const char *path, struct rte_vdpa_device *dev)
int rte_vhost_driver_detach_vdpa_device (const char *path)
struct rte_vdpa_device * rte_vhost_driver_get_vdpa_device (const char *path)
int rte_vhost_driver_get_vdpa_dev_type (const char *path, uint32_t *type)
int rte_vhost_driver_set_features (const char *path, uint64_t features)
int rte_vhost_driver_enable_features (const char *path, uint64_t features)
int rte_vhost_driver_disable_features (const char *path, uint64_t features)
int rte_vhost_driver_get_features (const char *path, uint64_t *features)
int rte_vhost_driver_set_protocol_features (const char *path, uint64_t protocol_features)
int rte_vhost_driver_get_protocol_features (const char *path, uint64_t *protocol_features)
int rte_vhost_driver_get_queue_num (const char *path, uint32_t *queue_num)
int rte_vhost_driver_set_max_queue_num (const char *path, uint32_t max_queue_pairs)
int rte_vhost_get_negotiated_features (int vid, uint64_t *features)
int rte_vhost_get_negotiated_protocol_features (int vid, uint64_t *protocol_features)
int rte_vhost_driver_start (const char *path)
int rte_vhost_get_mtu (int vid, uint16_t *mtu)
int rte_vhost_get_numa_node (int vid)
uint16_t rte_vhost_get_vring_num (int vid)
int rte_vhost_get_ifname (int vid, char *buf, size_t len)
uint16_t rte_vhost_avail_entries (int vid, uint16_t queue_id)
uint16_t rte_vhost_enqueue_burst (int vid, uint16_t queue_id, struct rte_mbuf **pkts, uint16_t count)
uint16_t rte_vhost_dequeue_burst (int vid, uint16_t queue_id, struct rte_mempool *mbuf_pool, struct rte_mbuf **pkts, uint16_t count)
int rte_vhost_get_mem_table (int vid, struct rte_vhost_memory **mem)
int rte_vhost_get_vhost_vring (int vid, uint16_t vring_idx, struct rte_vhost_vring *vring)
int rte_vhost_get_vhost_ring_inflight (int vid, uint16_t vring_idx, struct rte_vhost_ring_inflight *vring)
int rte_vhost_set_inflight_desc_split (int vid, uint16_t vring_idx, uint16_t idx)
int rte_vhost_set_inflight_desc_packed (int vid, uint16_t vring_idx, uint16_t head, uint16_t last, uint16_t *inflight_entry)
int rte_vhost_set_last_inflight_io_split (int vid, uint16_t vring_idx, uint16_t idx)
int rte_vhost_set_last_inflight_io_packed (int vid, uint16_t vring_idx, uint16_t head)
int rte_vhost_clr_inflight_desc_split (int vid, uint16_t vring_idx, uint16_t last_used_idx, uint16_t idx)
int rte_vhost_clr_inflight_desc_packed (int vid, uint16_t vring_idx, uint16_t head)
int rte_vhost_vring_call (int vid, uint16_t vring_idx)
int rte_vhost_vring_call_nonblock (int vid, uint16_t vring_idx)
uint32_t rte_vhost_rx_queue_count (int vid, uint16_t qid)
int rte_vhost_get_monitor_addr (int vid, uint16_t queue_id, struct rte_vhost_power_monitor_cond *pmc)
int rte_vhost_get_log_base (int vid, uint64_t *log_base, uint64_t *log_size)
int rte_vhost_get_vring_base (int vid, uint16_t queue_id, uint16_t *last_avail_idx, uint16_t *last_used_idx)
int rte_vhost_get_vring_base_from_inflight (int vid, uint16_t queue_id, uint16_t *last_avail_idx, uint16_t *last_used_idx)
int rte_vhost_set_vring_base (int vid, uint16_t queue_id, uint16_t last_avail_idx, uint16_t last_used_idx)
int rte_vhost_extern_callback_register (int vid, struct rte_vhost_user_extern_ops const *const ops, void *ctx)
struct rte_vdpa_device * rte_vhost_get_vdpa_device (int vid)
int rte_vhost_backend_config_change (int vid, bool need_reply)
int rte_vhost_vring_stats_get_names (int vid, uint16_t queue_id, struct rte_vhost_stat_name *name, unsigned int size)
int rte_vhost_vring_stats_get (int vid, uint16_t queue_id, struct rte_vhost_stat *stats, unsigned int n)
int rte_vhost_vring_stats_reset (int vid, uint16_t queue_id)
That's a lot of functions, but we'll break them down below. Not me being obsessed with every single one. π«Ά
π Detailed Description π
It's the interface to vhost-user. Literally. The definition is in file rte_vhost.h.
π₯ Macro Definition Documentation π₯
#define VHOST_USER_PROTOCOL_F_MQ 0
Protocol features. Definition at line 65 of file rte_vhost.h.
#define VHOST_USER_F_PROTOCOL_FEATURES 30
Indicate whether protocol features negotiation is supported. Definition at line 118 of file rte_vhost.h.
#define RTE_VHOST_STATS_NAME_SIZE 64
Maximum name length for the statistics counters. Definition at line 337 of file rte_vhost.h.
β¨ Typedef Documentation β¨
rte_vhost_msg_handle
typedef enum rte_vhost_msg_result(* rte_vhost_msg_handle) (int vid, void *msg)
Function prototype for the vhost backend to handle specific vhost user messages. It's giving callback energy.
Parameters
- vid β vhost device id
- msg β Message pointer.
Returns
RTE_VHOST_MSG_RESULT_OKon successRTE_VHOST_MSG_RESULT_REPLYon success with replyRTE_VHOST_MSG_RESULT_ERRon failureRTE_VHOST_MSG_RESULT_NOT_HANDLEDif message was not handled.
Definition at line 1 of file rte_vhost.h.
π Enumeration Type Documentation π
enum rte_vhost_msg_result
Possible results of the vhost user message handling callbacks. Definition at line 237 of file rte_vhost.h.
π Function Documentation π
rte_vhost_va_from_guest_pa
__rte_always_inline uint64_t rte_vhost_va_from_guest_pa (struct rte_vhost_memory * mem, uint64_t gpa, uint64_t * len) [static]
Convert guest physical address to host virtual address. slay.
Parameters
- mem β the guest memory regions
- gpa β the guest physical address for querying
- len β the size of the requested area to map, updated with actual size mapped
Returns β the host virtual address on success, 0 on failure
Definition at line 375 of file rte_vhost.h.
rte_vhost_log_write
void rte_vhost_log_write (int vid, uint64_t addr, uint64_t len)
Log the memory write start with given address.
This function only need be invoked when the live migration starts. Therefore, we won't need call it at all in the most of time. For making the performance impact be minimum, it's suggested to do a check before calling it:
if (unlikely(RTE_VHOST_NEED_LOG(features)))
rte_vhost_log_write(vid, addr, len);
Parameters
- vid β vhost device ID
- addr β the starting address for write (in guest physical address space)
- len β the length to write
rte_vhost_log_used_vring
void rte_vhost_log_used_vring (int vid, uint16_t vring_idx, uint64_t offset, uint64_t len)
Log the used ring update start at given offset.
Same as rte_vhost_log_write, it's suggested to do a check before calling it:
if (unlikely(RTE_VHOST_NEED_LOG(features)))
rte_vhost_log_used_vring(vid, vring_idx, offset, len);
Parameters
- vid β vhost device ID
- vring_idx β the vring index
- offset β the offset inside the used ring
- len β the length to write
rte_vhost_notify_guest
__rte_experimental void rte_vhost_notify_guest (int vid, uint16_t queue_id)
Warning β EXPERIMENTAL: this API may change, or be removed, without prior notice.
Inject the offloaded interrupt into the vhost device's queue.
See also β guest_notify vhost device operation
Parameters
- vid β vhost device ID
- queue_id β virtio queue index
rte_vhost_driver_register
int rte_vhost_driver_register (const char * path, uint64_t flags)
Register vhost driver. path could be different for multiple instance support.
rte_vhost_driver_attach_vdpa_device
int rte_vhost_driver_attach_vdpa_device (const char * path, struct rte_vdpa_device * dev)
Set the vdpa device id, enforce single connection per socket.
Parameters
- path β The vhost-user socket file path
- dev β vDPA device pointer
Returns β 0 on success, -1 on failure
rte_vhost_driver_detach_vdpa_device
int rte_vhost_driver_detach_vdpa_device (const char * path)
Unset the vdpa device id.
Parameters
- path β The vhost-user socket file path
Returns β 0 on success, -1 on failure
rte_vhost_driver_get_vdpa_device
struct rte_vdpa_device * rte_vhost_driver_get_vdpa_device (const char * path)
Get the device id.
Parameters
- path β The vhost-user socket file path
Returns β vDPA device pointer, NULL on failure
rte_vhost_driver_get_vdpa_dev_type
int rte_vhost_driver_get_vdpa_dev_type (const char * path, uint32_t * type)
Get the device type of the vdpa device.
Parameters
- path β The vhost-user socket file path
- type β the device type of the vdpa device
Returns β 0 on success, -1 on failure
rte_vhost_driver_set_features
int rte_vhost_driver_set_features (const char * path, uint64_t features)
Set the feature bits the vhost-user driver supports.
Parameters
- path β The vhost-user socket file path
- features β Supported features
Returns β 0 on success, -1 on failure
rte_vhost_driver_enable_features
int rte_vhost_driver_enable_features (const char * path, uint64_t features)
Enable vhost-user driver features.
Note that:
- the param features should be a subset of the feature bits provided by
rte_vhost_driver_set_features(). - it must be invoked before vhost-user negotiation starts.
Parameters
- path β The vhost-user socket file path
- features β Features to enable
Returns β 0 on success, -1 on failure
rte_vhost_driver_disable_features
int rte_vhost_driver_disable_features (const char * path, uint64_t features)
Disable vhost-user driver features.
The two notes at rte_vhost_driver_enable_features() also apply here.
Parameters
- path β The vhost-user socket file path
- features β Features to disable
Returns β 0 on success, -1 on failure
rte_vhost_driver_get_features
int rte_vhost_driver_get_features (const char * path, uint64_t * features)
Get the feature bits before feature negotiation.
Parameters
- path β The vhost-user socket file path
- features β A pointer to store the queried feature bits
Returns β 0 on success, -1 on failure
int rte_vhost_driver_set_protocol_features(const char *path, uint64_t protocol_features)
okay so this one sets the protocol feature bits π and it has to happen before feature negotiation β like, before the whole handshake situation kicks off. Timing matters, bestie.
pathβ the vhost-user socket file path π¦protocol_featuresβ the supported protocol features
Returns: 0 on success, -1 on failure β¨
int rte_vhost_driver_get_protocol_features(const char *path, uint64_t *protocol_features)
the lil sibling of the one above β instead of setting, you're getting the protocol feature bits, again before feature negotiation β¨
pathβ the vhost-user socket file pathprotocol_featuresβ a pointer to store the queried protocol feature bits
Returns: 0 on success, -1 on failure
int rte_vhost_driver_get_queue_num(const char *path, uint32_t *queue_num)
get the queue number bits, and yep, before feature negotiation, same vibe π
pathβ the vhost-user socket file pathqueue_numβ a pointer to store the queried queue number bits
Returns: 0 on success, -1 on failure
int rte_vhost_driver_set_max_queue_num(const char *path, uint32_t max_queue_pairs)
sets the maximum number of queue pairs supported by the device π
β οΈ heads up bestie: the value you set here gets ignored for Vhost-user backends. it is only taken into account with VDUSE backends. so don't come crying to me when your vhost-user backend doesn't care π
pathβ the vhost-user socket file pathmax_queue_pairsβ the maximum number of queue pairs
Returns: 0 on success, -1 on failure
int rte_vhost_get_negotiated_features(int vid, uint64_t *features)
get the feature bits after negotiation. negotiation's over, the deal is done, this is the tea π΅
vidβ Vhost device IDfeaturesβ a pointer to store the queried feature bits
Returns: 0 on success, -1 on failure
int rte_vhost_get_negotiated_protocol_features(int vid, uint64_t *protocol_features)
same energy but for protocol feature bits, and again after negotiation π
vidβ Vhost device IDprotocol_featuresβ a pointer to store the queried protocol feature bits
Returns: 0 on success, -1 on failure
int rte_vhost_driver_start(const char *path)
start the vhost-user driver π β this is the function that triggers the vhost-user negotiation. main character moment fr.
pathβ the vhost-user socket file path
Returns: 0 on success, -1 on failure
int rte_vhost_get_mtu(int vid, uint16_t *mtu)
gets the MTU value of the device, if it was set in QEMU. conditional king π
vidβ virtio-net device IDmtuβ the variable to store the MTU value
Returns:
0β success π-EAGAINβ device not yet started (give it a sec, bestie)-ENOTSUPβ device does not support MTU feature π
int rte_vhost_get_numa_node(int vid)
tells you which numa node the virtio net device's memory is allocated from π§ β¨
vidβ vhost device ID
Returns: the numa node, -1 on failure
uint16_t rte_vhost_get_vring_num(int vid)
how many vrings does the device support? let's find out π
vidβ vhost device ID
Returns: the number of vrings, 0 on failure
int rte_vhost_get_ifname(int vid, char *buf, size_t len)
gets the virtio net device's ifname β which, plot twist, is the vhost-user socket file path π¦
vidβ vhost device IDbufβ the buffer to stored the queried ifnamelenβ the length ofbuf
Returns: 0 on success, -1 on failure
uint16_t rte_vhost_avail_entries(int vid, uint16_t queue_id)
how many avail entries are left in the queue π
vidβ vhost device IDqueue_idβ virtio queue index
Returns: num of avail entries left
uint16_t rte_vhost_enqueue_burst(int vid, uint16_t queue_id, struct rte_mbuf **pkts, uint16_t count)
this one adds buffers to the virtio device's RX virtqueue π₯ buffers can come from the physical port, or from another virtual device β no judgement. it hands you back a packet count so you know how many packets actually made it successfully into the RX queue β¨
vidβ vhost device IDqueue_idβ virtio queue index in mq casepktsβ array to contain packets to be enqueuedcountβ packets num to be enqueued
Returns: num of packets enqueued
uint16_t rte_vhost_dequeue_burst(int vid, uint16_t queue_id, struct rte_mempool *mbuf_pool, struct rte_mbuf **pkts, uint16_t count)
the reverse trick π« this grabs guest buffers from the virtio device's TX virtqueue, constructs host mbufs, copies the guest buffer content over to those host mbufs, and stores them in pkts so you can go process them. it's giving β¨move the dataβ¨
vidβ vhost device IDqueue_idβ virtio queue index in mq casembuf_poolβ mbuf_pool where host mbuf is allocated.pktsβ array to contain packets to be dequeuedcountβ packets num to be dequeued
Returns: num of packets dequeued
int rte_vhost_get_mem_table(int vid, struct rte_vhost_memory **mem)
get the guest mem table: a list of memory regions πΊοΈ
π IMPORTANT bestie: anrte_vhost_vhost_memoryobject will be allocated internally to hold the guest memory regions. your application should free it at thedestroy_device()callback. do not forget. do not be that person.
vidβ vhost device IDmemβ to store the returned mem regions
Returns: 0 on success, -1 on failure
int rte_vhost_get_vhost_vring(int vid, uint16_t vring_idx, struct rte_vhost_vring *vring)
get guest vring info β the vring address, vring size, etc. all the vring lore π
vidβ vhost device IDvring_idxβ vring indexvringβ the structure to hold the requested vring info
Returns: 0 on success, -1 on failure
int rte_vhost_get_vhost_ring_inflight(int vid, uint16_t vring_idx, struct rte_vhost_ring_inflight *vring)
get guest inflight vring info, which means the inflight ring and the resubmit list πΈ
vidβ vhost device IDvring_idxβ vring indexvringβ the structure to hold the requested inflight vring info
Returns: 0 on success, -1 on failure
int rte_vhost_set_inflight_desc_split(int vid, uint16_t vring_idx, uint16_t idx)
set split inflight descriptor π
this function saves descriptors that have been consumed in the available ring β¨
vidβ vhost device IDvring_idxβ vring indexidxβ inflight entry index
Returns: 0 on success, -1 on failure
int rte_vhost_set_inflight_desc_packed(int vid, uint16_t vring_idx, uint16_t head, uint16_t last, uint16_t *inflight_entry)
set packed inflight descriptor and get the corresponding inflight entry β two birds, one function π¦
this function saves descriptors that have been consumed β¨
vidβ vhost device IDvring_idxβ vring indexheadβ head of descriptorslastβ last of descriptorsinflight_entryβ corresponding inflight entry
Returns: 0 on success, -1 on failure
int rte_vhost_set_last_inflight_io_split(int vid, uint16_t vring_idx, uint16_t idx)
saves the head of the list that the last batch of used descriptors π
vidβ vhost device IDvring_idxβ vring indexidxβ descriptor entry index
Returns: 0 on success, -1 on failure
int rte_vhost_set_last_inflight_io_packed(int vid, uint16_t vring_idx, uint16_t head)
updates the inflight free_head, used_idx and used_wrap_counter π
note bestie: this function will update status first, before updating descriptors to used. order matters, no cap.
vidβ vhost device IDvring_idxβ vring indexheadβ head of descriptors
Returns: 0 on success, -1 on failure
int rte_vhost_clr_inflight_desc_split(int vid, uint16_t vring_idx, uint16_t last_used_idx, uint16_t idx)
clear the split inflight status π§Ήβ¨
vidβ vhost device IDvring_idxβ vring indexlast_used_idxβ last used idx of used ringidxβ inflight entry index
Returns: 0 on success, -1 on failure
int rte_vhost_clr_inflight_desc_packed(int vid, uint16_t vring_idx, uint16_t head)
clear the packed inflight status π§Ήπ
vidβ vhost device IDvring_idxβ vring indexheadβ inflight entry index
Returns: 0 on success, -1 on failure
int rte_vhost_vring_call(int vid, uint16_t vring_idx)
notify the guest that used descriptors have been added to the vring π£ β so basically you're like "hey bestie, new stuff in the ring" π«Ά
this function also acts as a memory barrier. respect the barrier.
vidβ vhost device IDvring_idxβ vring index
Returns: 0 on success, -1 on failure
int rte_vhost_vring_call_nonblock(int vid, uint16_t vring_idx)
same notification energy β tells the guest used descriptors got added to the vring, and it also acts as a memory barrier π§ β¨
BUT: this one will return -EAGAIN when vq's access lock is held by another thread, and in that case you should try again later. don't spam it, just circle back π
vidβ vhost device IDvring_idxβ vring index
Returns: 0 on success, -1 on failure, -EAGAIN for another retry
uint32_t rte_vhost_rx_queue_count(int vid, uint16_t qid)
get the vhost RX queue avail count π
vidβ vhost device IDqidβ virtio queue index in mq case
Returns: num of desc available
int rte_vhost_get_monitor_addr(int vid, uint16_t queue_id, struct rte_vhost_power_monitor_cond *pmc)
get the power monitor address of the vhost device πβ¨
vidβ vhost device IDqueue_idβ vhost queue IDpmcβ power monitor condition
Returns: 0 on success, -1 on failure
int rte_vhost_get_log_base(int vid, uint64_t *log_base, uint64_t *log_size)
get the log base and log size of the vhost device π
vidβ vhost device IDlog_baseβ vhost log baselog_sizeβ vhost log size
Returns: 0 on success, -1 on failure
int rte_vhost_get_vring_base(int vid, uint16_t queue_id, uint16_t *last_avail_idx, uint16_t *last_used_idx)
get the last_avail_idx/last_used_idx of the vhost virtqueue π―
vidβ vhost device IDqueue_idβ vhost queue indexlast_avail_idxβ vhostlast_avail_idxto getlast_used_idxβ vhostlast_used_idxto get
Returns: 0 on success, -1 on failure
int rte_vhost_get_vring_base_from_inflight(int vid, uint16_t queue_id, uint16_t *last_avail_idx, uint16_t *last_used_idx)
get last_avail/last_used of the vhost virtqueue π
this function is designed for reconnection, and it's specific for the packed ring, because we can get the two parameters from the inflight queue region π«
vidβ vhost device IDqueue_idβ vhost queue indexlast_avail_idxβ vhostlast_avail_idxto getlast_used_idxβ vhostlast_used_idxto get
Returns: 0 on success, -1 on failure
int rte_vhost_set_vring_base(int vid, uint16_t queue_id, uint16_t last_avail_idx, uint16_t last_used_idx)
and now the setter version β set the last_avail_idx/last_used_idx of the vhost virtqueue π
vidβ vhost device IDqueue_idβ vhost queue indexlast_avail_idxβlast_avail_idxto setlast_used_idxβlast_used_idxto set
Returns: 0 on success, -1 on failure
β¨ rte_vhost_extern_callback_register β¨
int rte_vhost_extern_callback_register (int vid, struct rte_vhost_user_extern_ops const *const ops, void * ctx)
okay so bestie, this one is literally how you sign up your own external message handling callbacks π like, you're telling vhost "hey, when messages come through, pls also let me have a lil say."
Parameters
vidβ the vhost device ID (iykyk, it's always the device ID π«Ά)opsβ the virtio external callbacks you wanna register, of typestruct rte_vhost_user_extern_ops const *constctxβ extra context that gets handed off to those callbacks, so your functions can actually know what's going on
Returns
0on success π-1on failure π
π¦ rte_vhost_get_vdpa_device π¦
struct rte_vdpa_device * rte_vhost_get_vdpa_device (int vid)
Get the vdpa device id for a vhost device. basically "which vDPA device is this vhost device vibing as?" β¨
Parameters
vidβ vhost device id
Returns
- a vDPA device pointer on success π
NULLon failure π
πΈ rte_vhost_backend_config_change πΈ
int rte_vhost_backend_config_change (int vid, bool need_reply)
Notify the guest that it should get virtio configuration space from the backend. like sending a lil "hey girl, the config space is over here now" text π
Parameters
vidβ vhost device IDneed_replyβ wait for the frontend's response about the status of this operation (so yes, you can wait for the read receipt π)
Returns
0on success< 0on failure
π rte_vhost_vring_stats_get_names π
int rte_vhost_vring_stats_get_names (int vid, uint16_t queue_id, struct rte_vhost_stat_name * name, unsigned int size)
Retrieve the names of a Vhost virtqueue's statistics. label szn β¨
Heads up bestie: there's an assumption baked in here thatstat_namesandstatsarrays are matched by array index, likestats_names[i].name => stats[i].value. no cap, it's positional.
Parameters
vidβ vhost device IDqueue_idβ vhost queue indexnameβ array of at leastsizeelements to be filled. If you set it toNULL, the function just returns the required number of elements instead (so you can ask "how many do I even need?" first, iconic)sizeβ the number of elements in thestats_namesarray
Returns
- Success if it's greater than
0and lower or equal tosize. The return value tells you the number of elements filled in thenamesarray π - Failure if it's greater than
size. The return value tells you the number of elements thenamesarray should be given to succeed. - Failure if it's lower than
0. Either the device ID or queue ID is invalid, or statistics collection is not enabled π
π rte_vhost_vring_stats_get π
int rte_vhost_vring_stats_get (int vid, uint16_t queue_id, struct rte_vhost_stat * stats, unsigned int n)
Retrieve the statistics of a Vhost virtqueue. the actual numbers, the receipts, the data π
Same assumption as above bestie:stat_namesandstatsarrays are matched by array index βstats_names[i].name => stats[i].value. it's giving positional matching.
Parameters
vidβ vhost device IDqueue_idβ vhost queue indexstatsβ a pointer to a table of structures of typerte_vhost_stat, to be filled with the virtqueue statistics ids and valuesnβ the number of elements in thestatsarray
Returns
- Success if it's greater than
0and lower or equal ton. The return value tells you the number of elements filled in thestatsarray β¨ - Failure if it's greater than
n. The return value tells you the number of elements thestatsarray should be given to succeed. - Failure if it's lower than
0. Either the device ID or queue ID is invalid, or statistics collection is not enabled.
π§ rte_vhost_vring_stats_reset π§
int rte_vhost_vring_stats_reset (int vid, uint16_t queue_id)
Reset the statistics of a Vhost virtqueue. clean slate energy πΈ fresh start, we love to see it.
Parameters
vidβ vhost device IDqueue_idβ vhost queue index
Returns
- Success if
0. The statistics have been reset π - Failure if it's lower than
0. Either the device ID or queue ID is invalid, or statistics collection is not enabled π
π Author π
Generated automatically by Doxygen for DPDK from the source code.
no thoughts, just a robot writing docs for us, and honestly? it ate π€β¨
and that's a wrap on the whole page bestie!! this iconic lil doc lives in DPDK, Version 25.11.3, filed under rte_vhost.h(3) π go forth, build your vhost stuff, and slay π«Ά periodt π
π¦ where this page comes from
- ubuntu resolute: dpdk-doc 25.11.3-0ubuntu0.26.04.1 Β· BSD-3-Clause
- ubuntu stonking: dpdk-doc 25.11.3-1 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms