1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2018 Intel Corporation
15 * Device specific vhost lib
20 /** Maximum name length for statistics counters */
21 #define RTE_VDPA_STATS_NAME_SIZE 64
23 struct rte_vdpa_device;
26 * A vDPA device statistic structure
28 * This structure is used by rte_vdpa_stats_get() to provide
29 * statistics from the HW vDPA device.
31 * It maps a name id, corresponding to an index in the array returned
32 * by rte_vdpa_get_stats_names, to a statistic value.
34 struct rte_vdpa_stat {
35 uint64_t id; /**< The index in stats name array */
36 uint64_t value; /**< The statistic counter value */
40 * A name element for statistics
42 * An array of this structure is returned by rte_vdpa_get_stats_names
43 * It lists the names of extended statistics for a PMD. The rte_vdpa_stat
44 * structure references these names by their array index
46 struct rte_vdpa_stat_name {
47 char name[RTE_VDPA_STATS_NAME_SIZE]; /**< The statistic name */
51 * Find the device id of a vdpa device from its name
54 * the vdpa device name
56 * vDPA device pointer on success, NULL on failure
58 struct rte_vdpa_device *
59 rte_vdpa_find_device_by_name(const char *name);
62 * Get the generic device from the vdpa device
65 * the vdpa device pointer
67 * generic device pointer on success, NULL on failure
70 rte_vdpa_get_rte_device(struct rte_vdpa_device *vdpa_dev);
73 * Get number of queue pairs supported by the vDPA device
78 * pointer on where the number of queue is stored
80 * 0 on success, -1 on failure
83 rte_vdpa_get_queue_num(struct rte_vdpa_device *dev, uint32_t *queue_num);
86 * Get the Virtio features supported by the vDPA device
91 * pointer on where the supported features are stored
93 * 0 on success, -1 on failure
96 rte_vdpa_get_features(struct rte_vdpa_device *dev, uint64_t *features);
99 * Get the Vhost-user protocol features supported by the vDPA device
104 * pointer on where the supported protocol features are stored
106 * 0 on success, -1 on failure
109 rte_vdpa_get_protocol_features(struct rte_vdpa_device *dev, uint64_t *features);
112 * Synchronize the used ring from mediated ring to guest, log dirty
113 * page for each writeable buffer, caller should handle the used
114 * ring logging before device stop.
121 * mediated virtio ring pointer
123 * number of synced used entries on success, -1 on failure
126 rte_vdpa_relay_vring_used(int vid, uint16_t qid, void *vring_m);
129 * Retrieve names of statistics of a vDPA device.
131 * There is an assumption that 'stat_names' and 'stats' arrays are matched
132 * by array index: stats_names[i].name => stats[i].value
134 * And the array index is same with id field of 'struct rte_vdpa_stat':
138 * vDPA device pointer
140 * array of at least size elements to be filled.
141 * If set to NULL, the function returns the required number of elements.
143 * The number of elements in stats_names array.
145 * A negative value on error, otherwise the number of entries filled in the
149 rte_vdpa_get_stats_names(struct rte_vdpa_device *dev,
150 struct rte_vdpa_stat_name *stats_names,
154 * Retrieve statistics of a vDPA device.
156 * There is an assumption that 'stat_names' and 'stats' arrays are matched
157 * by array index: stats_names[i].name => stats[i].value
159 * And the array index is same with id field of 'struct rte_vdpa_stat':
163 * vDPA device pointer
167 * A pointer to a table of structure of type rte_vdpa_stat to be filled with
168 * device statistics ids and values.
170 * The number of elements in stats array.
172 * A negative value on error, otherwise the number of entries filled in the
176 rte_vdpa_get_stats(struct rte_vdpa_device *dev, uint16_t qid,
177 struct rte_vdpa_stat *stats, unsigned int n);
179 * Reset statistics of a vDPA device.
182 * vDPA device pointer
186 * 0 on success, a negative value on error.
189 rte_vdpa_reset_stats(struct rte_vdpa_device *dev, uint16_t qid);
195 #endif /* _RTE_VDPA_H_ */