1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2018 Intel Corporation
5 #ifndef _RTE_VDPA_H_DEV_
6 #define _RTE_VDPA_H_DEV_
10 #include "rte_vhost.h"
13 * vdpa device operations
15 struct rte_vdpa_dev_ops {
16 /** Get capabilities of this device */
17 int (*get_queue_num)(struct rte_vdpa_device *dev, uint32_t *queue_num);
19 /** Get supported features of this device */
20 int (*get_features)(struct rte_vdpa_device *dev, uint64_t *features);
22 /** Get supported protocol features of this device */
23 int (*get_protocol_features)(struct rte_vdpa_device *dev,
24 uint64_t *protocol_features);
26 /** Driver configure/close the device */
27 int (*dev_conf)(int vid);
28 int (*dev_close)(int vid);
30 /** Enable/disable this vring */
31 int (*set_vring_state)(int vid, int vring, int state);
33 /** Set features when changed */
34 int (*set_features)(int vid);
36 /** Destination operations when migration done */
37 int (*migration_done)(int vid);
39 /** Get the vfio group fd */
40 int (*get_vfio_group_fd)(int vid);
42 /** Get the vfio device fd */
43 int (*get_vfio_device_fd)(int vid);
45 /** Get the notify area info of the queue */
46 int (*get_notify_area)(int vid, int qid,
47 uint64_t *offset, uint64_t *size);
49 /** Get statistics name */
50 int (*get_stats_names)(struct rte_vdpa_device *dev,
51 struct rte_vdpa_stat_name *stats_names,
54 /** Get statistics of the queue */
55 int (*get_stats)(struct rte_vdpa_device *dev, int qid,
56 struct rte_vdpa_stat *stats, unsigned int n);
58 /** Reset statistics of the queue */
59 int (*reset_stats)(struct rte_vdpa_device *dev, int qid);
61 /** Reserved for future extension */
66 * vdpa device structure includes device address and device operations.
68 struct rte_vdpa_device {
69 TAILQ_ENTRY(rte_vdpa_device) next;
70 /** Generic device information */
71 struct rte_device *device;
72 /** vdpa device operations */
73 struct rte_vdpa_dev_ops *ops;
78 * @b EXPERIMENTAL: this API may change without prior notice
80 * Register a vdpa device
83 * the generic device pointer
85 * the vdpa device operations
87 * vDPA device pointer on success, NULL on failure
90 struct rte_vdpa_device *
91 rte_vdpa_register_device(struct rte_device *rte_dev,
92 struct rte_vdpa_dev_ops *ops);
96 * @b EXPERIMENTAL: this API may change without prior notice
98 * Unregister a vdpa device
101 * vDPA device pointer
103 * device id on success, -1 on failure
107 rte_vdpa_unregister_device(struct rte_vdpa_device *dev);
111 * @b EXPERIMENTAL: this API may change without prior notice
113 * Enable/Disable host notifier mapping for a vdpa port.
118 * true for host notifier map, false for host notifier unmap
120 * 0 on success, -1 on failure
124 rte_vhost_host_notifier_ctrl(int vid, bool enable);
128 * @b EXPERIMENTAL: this API may change without prior notice
130 * Synchronize the used ring from mediated ring to guest, log dirty
131 * page for each writeable buffer, caller should handle the used
132 * ring logging before device stop.
139 * mediated virtio ring pointer
141 * number of synced used entries on success, -1 on failure
145 rte_vdpa_relay_vring_used(int vid, uint16_t qid, void *vring_m);
147 #endif /* _RTE_VDPA_DEV_H_ */