1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2018 Intel Corporation
11 * Device specific vhost lib
16 /** Maximum name length for statistics counters */
17 #define RTE_VDPA_STATS_NAME_SIZE 64
19 struct rte_vdpa_device;
22 * A vDPA device statistic structure
24 * This structure is used by rte_vdpa_stats_get() to provide
25 * statistics from the HW vDPA device.
27 * It maps a name id, corresponding to an index in the array returned
28 * by rte_vdpa_get_stats_names, to a statistic value.
30 struct rte_vdpa_stat {
31 uint64_t id; /**< The index in stats name array */
32 uint64_t value; /**< The statistic counter value */
36 * A name element for statistics
38 * An array of this structure is returned by rte_vdpa_get_stats_names
39 * It lists the names of extended statistics for a PMD. The rte_vdpa_stat
40 * structure references these names by their array index
42 struct rte_vdpa_stat_name {
43 char name[RTE_VDPA_STATS_NAME_SIZE]; /**< The statistic name */
47 * Find the device id of a vdpa device from its name
50 * the vdpa device name
52 * vDPA device pointer on success, NULL on failure
54 struct rte_vdpa_device *
55 rte_vdpa_find_device_by_name(const char *name);
58 * Get the generic device from the vdpa device
61 * the vdpa device pointer
63 * generic device pointer on success, NULL on failure
66 rte_vdpa_get_rte_device(struct rte_vdpa_device *vdpa_dev);
69 * Get number of queue pairs supported by the vDPA device
74 * pointer on where the number of queue is stored
76 * 0 on success, -1 on failure
79 rte_vdpa_get_queue_num(struct rte_vdpa_device *dev, uint32_t *queue_num);
82 * Get the Virtio features supported by the vDPA device
87 * pointer on where the supported features are stored
89 * 0 on success, -1 on failure
92 rte_vdpa_get_features(struct rte_vdpa_device *dev, uint64_t *features);
95 * Get the Vhost-user protocol features supported by the vDPA device
100 * pointer on where the supported protocol features are stored
102 * 0 on success, -1 on failure
105 rte_vdpa_get_protocol_features(struct rte_vdpa_device *dev, uint64_t *features);
108 * Synchronize the used ring from mediated ring to guest, log dirty
109 * page for each writeable buffer, caller should handle the used
110 * ring logging before device stop.
117 * mediated virtio ring pointer
119 * number of synced used entries on success, -1 on failure
122 rte_vdpa_relay_vring_used(int vid, uint16_t qid, void *vring_m);
125 * Retrieve names of statistics of a vDPA device.
127 * There is an assumption that 'stat_names' and 'stats' arrays are matched
128 * by array index: stats_names[i].name => stats[i].value
130 * And the array index is same with id field of 'struct rte_vdpa_stat':
134 * vDPA device pointer
136 * array of at least size elements to be filled.
137 * If set to NULL, the function returns the required number of elements.
139 * The number of elements in stats_names array.
141 * A negative value on error, otherwise the number of entries filled in the
145 rte_vdpa_get_stats_names(struct rte_vdpa_device *dev,
146 struct rte_vdpa_stat_name *stats_names,
150 * Retrieve 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
163 * A pointer to a table of structure of type rte_vdpa_stat to be filled with
164 * device statistics ids and values.
166 * The number of elements in stats array.
168 * A negative value on error, otherwise the number of entries filled in the
172 rte_vdpa_get_stats(struct rte_vdpa_device *dev, uint16_t qid,
173 struct rte_vdpa_stat *stats, unsigned int n);
175 * Reset statistics of a vDPA device.
178 * vDPA device pointer
182 * 0 on success, a negative value on error.
185 rte_vdpa_reset_stats(struct rte_vdpa_device *dev, uint16_t qid);
186 #endif /* _RTE_VDPA_H_ */