1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2018 Intel Corporation
11 * Device specific vhost lib
14 /** Maximum name length for statistics counters */
15 #define RTE_VDPA_STATS_NAME_SIZE 64
17 struct rte_vdpa_device;
20 * A vDPA device statistic structure
22 * This structure is used by rte_vdpa_stats_get() to provide
23 * statistics from the HW vDPA device.
25 * It maps a name id, corresponding to an index in the array returned
26 * by rte_vdpa_get_stats_names, to a statistic value.
28 struct rte_vdpa_stat {
29 uint64_t id; /**< The index in stats name array */
30 uint64_t value; /**< The statistic counter value */
34 * A name element for statistics
36 * An array of this structure is returned by rte_vdpa_get_stats_names
37 * It lists the names of extended statistics for a PMD. The rte_vdpa_stat
38 * structure references these names by their array index
40 struct rte_vdpa_stat_name {
41 char name[RTE_VDPA_STATS_NAME_SIZE]; /**< The statistic name */
46 * @b EXPERIMENTAL: this API may change without prior notice
48 * Find the device id of a vdpa device from its name
51 * the vdpa device name
53 * vDPA device pointer on success, NULL on failure
56 struct rte_vdpa_device *
57 rte_vdpa_find_device_by_name(const char *name);
61 * @b EXPERIMENTAL: this API may change without prior notice
63 * Get the generic device from the vdpa device
66 * the vdpa device pointer
68 * generic device pointer on success, NULL on failure
72 rte_vdpa_get_rte_device(struct rte_vdpa_device *vdpa_dev);
76 * @b EXPERIMENTAL: this API may change without prior notice
78 * Get number of queue pairs supported by the vDPA device
83 * pointer on where the number of queue is stored
85 * 0 on success, -1 on failure
89 rte_vdpa_get_queue_num(struct rte_vdpa_device *dev, uint32_t *queue_num);
93 * @b EXPERIMENTAL: this API may change without prior notice
95 * Get the Virtio features supported by the vDPA device
100 * pointer on where the supported features are stored
102 * 0 on success, -1 on failure
106 rte_vdpa_get_features(struct rte_vdpa_device *dev, uint64_t *features);
110 * @b EXPERIMENTAL: this API may change without prior notice
112 * Get the Vhost-user protocol features supported by the vDPA device
117 * pointer on where the supported protocol features are stored
119 * 0 on success, -1 on failure
123 rte_vdpa_get_protocol_features(struct rte_vdpa_device *dev, uint64_t *features);
127 * @b EXPERIMENTAL: this API may change without prior notice
129 * Synchronize the used ring from mediated ring to guest, log dirty
130 * page for each writeable buffer, caller should handle the used
131 * ring logging before device stop.
138 * mediated virtio ring pointer
140 * number of synced used entries on success, -1 on failure
144 rte_vdpa_relay_vring_used(int vid, uint16_t qid, void *vring_m);
148 * @b EXPERIMENTAL: this API may change without prior notice
150 * Retrieve names of statistics of a vDPA device.
152 * There is an assumption that 'stat_names' and 'stats' arrays are matched
153 * by array index: stats_names[i].name => stats[i].value
155 * And the array index is same with id field of 'struct rte_vdpa_stat':
159 * vDPA device pointer
161 * array of at least size elements to be filled.
162 * If set to NULL, the function returns the required number of elements.
164 * The number of elements in stats_names array.
166 * A negative value on error, otherwise the number of entries filled in the
171 rte_vdpa_get_stats_names(struct rte_vdpa_device *dev,
172 struct rte_vdpa_stat_name *stats_names,
177 * @b EXPERIMENTAL: this API may change without prior notice
179 * Retrieve statistics of a vDPA device.
181 * There is an assumption that 'stat_names' and 'stats' arrays are matched
182 * by array index: stats_names[i].name => stats[i].value
184 * And the array index is same with id field of 'struct rte_vdpa_stat':
188 * vDPA device pointer
192 * A pointer to a table of structure of type rte_vdpa_stat to be filled with
193 * device statistics ids and values.
195 * The number of elements in stats array.
197 * A negative value on error, otherwise the number of entries filled in the
202 rte_vdpa_get_stats(struct rte_vdpa_device *dev, uint16_t qid,
203 struct rte_vdpa_stat *stats, unsigned int n);
206 * @b EXPERIMENTAL: this API may change without prior notice
208 * Reset statistics of a vDPA device.
211 * vDPA device pointer
215 * 0 on success, a negative value on error.
219 rte_vdpa_reset_stats(struct rte_vdpa_device *dev, uint16_t qid);
220 #endif /* _RTE_VDPA_H_ */