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 */
45 * Find the device id of a vdpa device from its name
48 * the vdpa device name
50 * vDPA device pointer on success, NULL on failure
52 struct rte_vdpa_device *
53 rte_vdpa_find_device_by_name(const char *name);
56 * Get the generic device from the vdpa device
59 * the vdpa device pointer
61 * generic device pointer on success, NULL on failure
64 rte_vdpa_get_rte_device(struct rte_vdpa_device *vdpa_dev);
67 * Get number of queue pairs supported by the vDPA device
72 * pointer on where the number of queue is stored
74 * 0 on success, -1 on failure
77 rte_vdpa_get_queue_num(struct rte_vdpa_device *dev, uint32_t *queue_num);
80 * Get the Virtio features supported by the vDPA device
85 * pointer on where the supported features are stored
87 * 0 on success, -1 on failure
90 rte_vdpa_get_features(struct rte_vdpa_device *dev, uint64_t *features);
93 * Get the Vhost-user protocol features supported by the vDPA device
98 * pointer on where the supported protocol features are stored
100 * 0 on success, -1 on failure
103 rte_vdpa_get_protocol_features(struct rte_vdpa_device *dev, uint64_t *features);
106 * Synchronize the used ring from mediated ring to guest, log dirty
107 * page for each writeable buffer, caller should handle the used
108 * ring logging before device stop.
115 * mediated virtio ring pointer
117 * number of synced used entries on success, -1 on failure
120 rte_vdpa_relay_vring_used(int vid, uint16_t qid, void *vring_m);
123 * Retrieve names of statistics of a vDPA device.
125 * There is an assumption that 'stat_names' and 'stats' arrays are matched
126 * by array index: stats_names[i].name => stats[i].value
128 * And the array index is same with id field of 'struct rte_vdpa_stat':
132 * vDPA device pointer
134 * array of at least size elements to be filled.
135 * If set to NULL, the function returns the required number of elements.
137 * The number of elements in stats_names array.
139 * A negative value on error, otherwise the number of entries filled in the
143 rte_vdpa_get_stats_names(struct rte_vdpa_device *dev,
144 struct rte_vdpa_stat_name *stats_names,
148 * Retrieve statistics of a vDPA device.
150 * There is an assumption that 'stat_names' and 'stats' arrays are matched
151 * by array index: stats_names[i].name => stats[i].value
153 * And the array index is same with id field of 'struct rte_vdpa_stat':
157 * vDPA device pointer
161 * A pointer to a table of structure of type rte_vdpa_stat to be filled with
162 * device statistics ids and values.
164 * The number of elements in stats array.
166 * A negative value on error, otherwise the number of entries filled in the
170 rte_vdpa_get_stats(struct rte_vdpa_device *dev, uint16_t qid,
171 struct rte_vdpa_stat *stats, unsigned int n);
173 * Reset statistics of a vDPA device.
176 * vDPA device pointer
180 * 0 on success, a negative value on error.
183 rte_vdpa_reset_stats(struct rte_vdpa_device *dev, uint16_t qid);
184 #endif /* _RTE_VDPA_H_ */