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 #define RTE_VHOST_QUEUE_ALL UINT16_MAX
16 * vdpa device operations
18 struct rte_vdpa_dev_ops {
19 /** Get capabilities of this device (Mandatory) */
20 int (*get_queue_num)(struct rte_vdpa_device *dev, uint32_t *queue_num);
22 /** Get supported features of this device (Mandatory) */
23 int (*get_features)(struct rte_vdpa_device *dev, uint64_t *features);
25 /** Get supported protocol features of this device (Mandatory) */
26 int (*get_protocol_features)(struct rte_vdpa_device *dev,
27 uint64_t *protocol_features);
29 /** Driver configure the device (Mandatory) */
30 int (*dev_conf)(int vid);
32 /** Driver close the device (Mandatory) */
33 int (*dev_close)(int vid);
35 /** Enable/disable this vring (Mandatory) */
36 int (*set_vring_state)(int vid, int vring, int state);
38 /** Set features when changed (Mandatory) */
39 int (*set_features)(int vid);
41 /** Destination operations when migration done */
42 int (*migration_done)(int vid);
44 /** Get the vfio group fd */
45 int (*get_vfio_group_fd)(int vid);
47 /** Get the vfio device fd */
48 int (*get_vfio_device_fd)(int vid);
50 /** Get the notify area info of the queue */
51 int (*get_notify_area)(int vid, int qid,
52 uint64_t *offset, uint64_t *size);
54 /** Get statistics name */
55 int (*get_stats_names)(struct rte_vdpa_device *dev,
56 struct rte_vdpa_stat_name *stats_names,
59 /** Get statistics of the queue */
60 int (*get_stats)(struct rte_vdpa_device *dev, int qid,
61 struct rte_vdpa_stat *stats, unsigned int n);
63 /** Reset statistics of the queue */
64 int (*reset_stats)(struct rte_vdpa_device *dev, int qid);
66 /** Reserved for future extension */
71 * vdpa device structure includes device address and device operations.
73 struct rte_vdpa_device {
74 TAILQ_ENTRY(rte_vdpa_device) next;
75 /** Generic device information */
76 struct rte_device *device;
77 /** vdpa device operations */
78 struct rte_vdpa_dev_ops *ops;
82 * Register a vdpa device
85 * the generic device pointer
87 * the vdpa device operations
89 * vDPA device pointer on success, NULL on failure
91 struct rte_vdpa_device *
92 rte_vdpa_register_device(struct rte_device *rte_dev,
93 struct rte_vdpa_dev_ops *ops);
96 * Unregister a vdpa device
101 * device id on success, -1 on failure
104 rte_vdpa_unregister_device(struct rte_vdpa_device *dev);
107 * Enable/Disable host notifier mapping for a vdpa port.
112 * true for host notifier map, false for host notifier unmap
114 * vhost queue id, RTE_VHOST_QUEUE_ALL to configure all the device queues
116 * 0 on success, -1 on failure
119 rte_vhost_host_notifier_ctrl(int vid, uint16_t qid, bool enable);
122 * Synchronize the used ring from mediated ring to guest, log dirty
123 * page for each writeable buffer, caller should handle the used
124 * ring logging before device stop.
131 * mediated virtio ring pointer
133 * number of synced used entries on success, -1 on failure
136 rte_vdpa_relay_vring_used(int vid, uint16_t qid, void *vring_m);
138 #endif /* _RTE_VDPA_DEV_H_ */