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"
12 #define RTE_VHOST_QUEUE_ALL UINT16_MAX
15 * vdpa device operations
17 struct rte_vdpa_dev_ops {
18 /** Get capabilities of this device */
19 int (*get_queue_num)(struct rte_vdpa_device *dev, uint32_t *queue_num);
21 /** Get supported features of this device */
22 int (*get_features)(struct rte_vdpa_device *dev, uint64_t *features);
24 /** Get supported protocol features of this device */
25 int (*get_protocol_features)(struct rte_vdpa_device *dev,
26 uint64_t *protocol_features);
28 /** Driver configure/close the device */
29 int (*dev_conf)(int vid);
30 int (*dev_close)(int vid);
32 /** Enable/disable this vring */
33 int (*set_vring_state)(int vid, int vring, int state);
35 /** Set features when changed */
36 int (*set_features)(int vid);
38 /** Destination operations when migration done */
39 int (*migration_done)(int vid);
41 /** Get the vfio group fd */
42 int (*get_vfio_group_fd)(int vid);
44 /** Get the vfio device fd */
45 int (*get_vfio_device_fd)(int vid);
47 /** Get the notify area info of the queue */
48 int (*get_notify_area)(int vid, int qid,
49 uint64_t *offset, uint64_t *size);
51 /** Get statistics name */
52 int (*get_stats_names)(struct rte_vdpa_device *dev,
53 struct rte_vdpa_stat_name *stats_names,
56 /** Get statistics of the queue */
57 int (*get_stats)(struct rte_vdpa_device *dev, int qid,
58 struct rte_vdpa_stat *stats, unsigned int n);
60 /** Reset statistics of the queue */
61 int (*reset_stats)(struct rte_vdpa_device *dev, int qid);
63 /** Reserved for future extension */
68 * vdpa device structure includes device address and device operations.
70 struct rte_vdpa_device {
71 TAILQ_ENTRY(rte_vdpa_device) next;
72 /** Generic device information */
73 struct rte_device *device;
74 /** vdpa device operations */
75 struct rte_vdpa_dev_ops *ops;
80 * @b EXPERIMENTAL: this API may change without prior notice
82 * Register a vdpa device
85 * the generic device pointer
87 * the vdpa device operations
89 * vDPA device pointer on success, NULL on failure
92 struct rte_vdpa_device *
93 rte_vdpa_register_device(struct rte_device *rte_dev,
94 struct rte_vdpa_dev_ops *ops);
98 * @b EXPERIMENTAL: this API may change without prior notice
100 * Unregister a vdpa device
103 * vDPA device pointer
105 * device id on success, -1 on failure
109 rte_vdpa_unregister_device(struct rte_vdpa_device *dev);
113 * @b EXPERIMENTAL: this API may change without prior notice
115 * Enable/Disable host notifier mapping for a vdpa port.
120 * true for host notifier map, false for host notifier unmap
122 * vhost queue id, RTE_VHOST_QUEUE_ALL to configure all the device queues
124 * 0 on success, -1 on failure
128 rte_vhost_host_notifier_ctrl(int vid, uint16_t qid, bool enable);
132 * @b EXPERIMENTAL: this API may change without prior notice
134 * Synchronize the used ring from mediated ring to guest, log dirty
135 * page for each writeable buffer, caller should handle the used
136 * ring logging before device stop.
143 * mediated virtio ring pointer
145 * number of synced used entries on success, -1 on failure
149 rte_vdpa_relay_vring_used(int vid, uint16_t qid, void *vring_m);
151 #endif /* _RTE_VDPA_DEV_H_ */