1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2018 Intel Corporation
5 #ifndef _VDPA_DRIVER_H_
6 #define _VDPA_DRIVER_H_
10 #include <rte_compat.h>
12 #include "rte_vhost.h"
15 #define RTE_VHOST_QUEUE_ALL UINT16_MAX
18 * vdpa device operations
20 struct rte_vdpa_dev_ops {
21 /** Get capabilities of this device (Mandatory) */
22 int (*get_queue_num)(struct rte_vdpa_device *dev, uint32_t *queue_num);
24 /** Get supported features of this device (Mandatory) */
25 int (*get_features)(struct rte_vdpa_device *dev, uint64_t *features);
27 /** Get supported protocol features of this device (Mandatory) */
28 int (*get_protocol_features)(struct rte_vdpa_device *dev,
29 uint64_t *protocol_features);
31 /** Driver configure the device (Mandatory) */
32 int (*dev_conf)(int vid);
34 /** Driver close the device (Mandatory) */
35 int (*dev_close)(int vid);
37 /** Enable/disable this vring (Mandatory) */
38 int (*set_vring_state)(int vid, int vring, int state);
40 /** Set features when changed (Mandatory) */
41 int (*set_features)(int vid);
43 /** Destination operations when migration done */
44 int (*migration_done)(int vid);
46 /** Get the vfio group fd */
47 int (*get_vfio_group_fd)(int vid);
49 /** Get the vfio device fd */
50 int (*get_vfio_device_fd)(int vid);
52 /** Get the notify area info of the queue */
53 int (*get_notify_area)(int vid, int qid,
54 uint64_t *offset, uint64_t *size);
56 /** Get statistics name */
57 int (*get_stats_names)(struct rte_vdpa_device *dev,
58 struct rte_vdpa_stat_name *stats_names,
61 /** Get statistics of the queue */
62 int (*get_stats)(struct rte_vdpa_device *dev, int qid,
63 struct rte_vdpa_stat *stats, unsigned int n);
65 /** Reset statistics of the queue */
66 int (*reset_stats)(struct rte_vdpa_device *dev, int qid);
68 /** Reserved for future extension */
73 * vdpa device structure includes device address and device operations.
75 struct rte_vdpa_device {
76 RTE_TAILQ_ENTRY(rte_vdpa_device) next;
77 /** Generic device information */
78 struct rte_device *device;
79 /** vdpa device operations */
80 struct rte_vdpa_dev_ops *ops;
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);
99 * Unregister a vdpa device
102 * vDPA device pointer
104 * device id on success, -1 on failure
108 rte_vdpa_unregister_device(struct rte_vdpa_device *dev);
111 * Enable/Disable host notifier mapping for a vdpa port.
116 * true for host notifier map, false for host notifier unmap
118 * vhost queue id, RTE_VHOST_QUEUE_ALL to configure all the device queues
120 * 0 on success, -1 on failure
124 rte_vhost_host_notifier_ctrl(int vid, uint16_t qid, bool enable);
127 * Synchronize the used ring from mediated ring to guest, log dirty
128 * page for each writeable buffer, caller should handle the used
129 * ring logging before device stop.
136 * mediated virtio ring pointer
138 * number of synced used entries on success, -1 on failure
142 rte_vdpa_relay_vring_used(int vid, uint16_t qid, void *vring_m);
144 #endif /* _VDPA_DRIVER_H_ */