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 (Mandatory) */
19 int (*get_queue_num)(struct rte_vdpa_device *dev, uint32_t *queue_num);
21 /** Get supported features of this device (Mandatory) */
22 int (*get_features)(struct rte_vdpa_device *dev, uint64_t *features);
24 /** Get supported protocol features of this device (Mandatory) */
25 int (*get_protocol_features)(struct rte_vdpa_device *dev,
26 uint64_t *protocol_features);
28 /** Driver configure the device (Mandatory) */
29 int (*dev_conf)(int vid);
31 /** Driver close the device (Mandatory) */
32 int (*dev_close)(int vid);
34 /** Enable/disable this vring (Mandatory) */
35 int (*set_vring_state)(int vid, int vring, int state);
37 /** Set features when changed (Mandatory) */
38 int (*set_features)(int vid);
40 /** Destination operations when migration done */
41 int (*migration_done)(int vid);
43 /** Get the vfio group fd */
44 int (*get_vfio_group_fd)(int vid);
46 /** Get the vfio device fd */
47 int (*get_vfio_device_fd)(int vid);
49 /** Get the notify area info of the queue */
50 int (*get_notify_area)(int vid, int qid,
51 uint64_t *offset, uint64_t *size);
53 /** Get statistics name */
54 int (*get_stats_names)(struct rte_vdpa_device *dev,
55 struct rte_vdpa_stat_name *stats_names,
58 /** Get statistics of the queue */
59 int (*get_stats)(struct rte_vdpa_device *dev, int qid,
60 struct rte_vdpa_stat *stats, unsigned int n);
62 /** Reset statistics of the queue */
63 int (*reset_stats)(struct rte_vdpa_device *dev, int qid);
65 /** Reserved for future extension */
70 * vdpa device structure includes device address and device operations.
72 struct rte_vdpa_device {
73 TAILQ_ENTRY(rte_vdpa_device) next;
74 /** Generic device information */
75 struct rte_device *device;
76 /** vdpa device operations */
77 struct rte_vdpa_dev_ops *ops;
82 * @b EXPERIMENTAL: this API may change without prior notice
84 * Register a vdpa device
87 * the generic device pointer
89 * the vdpa device operations
91 * vDPA device pointer on success, NULL on failure
94 struct rte_vdpa_device *
95 rte_vdpa_register_device(struct rte_device *rte_dev,
96 struct rte_vdpa_dev_ops *ops);
100 * @b EXPERIMENTAL: this API may change without prior notice
102 * Unregister a vdpa device
105 * vDPA device pointer
107 * device id on success, -1 on failure
111 rte_vdpa_unregister_device(struct rte_vdpa_device *dev);
115 * @b EXPERIMENTAL: this API may change without prior notice
117 * Enable/Disable host notifier mapping for a vdpa port.
122 * true for host notifier map, false for host notifier unmap
124 * vhost queue id, RTE_VHOST_QUEUE_ALL to configure all the device queues
126 * 0 on success, -1 on failure
130 rte_vhost_host_notifier_ctrl(int vid, uint16_t qid, bool enable);
134 * @b EXPERIMENTAL: this API may change without prior notice
136 * Synchronize the used ring from mediated ring to guest, log dirty
137 * page for each writeable buffer, caller should handle the used
138 * ring logging before device stop.
145 * mediated virtio ring pointer
147 * number of synced used entries on success, -1 on failure
151 rte_vdpa_relay_vring_used(int vid, uint16_t qid, void *vring_m);
153 #endif /* _RTE_VDPA_DEV_H_ */