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 /** Connection closed, clean up resources */
38 int (*dev_cleanup)(int vid);
40 /** Enable/disable this vring (Mandatory) */
41 int (*set_vring_state)(int vid, int vring, int state);
43 /** Set features when changed (Mandatory) */
44 int (*set_features)(int vid);
46 /** Destination operations when migration done */
47 int (*migration_done)(int vid);
49 /** Get the vfio group fd */
50 int (*get_vfio_group_fd)(int vid);
52 /** Get the vfio device fd */
53 int (*get_vfio_device_fd)(int vid);
55 /** Get the notify area info of the queue */
56 int (*get_notify_area)(int vid, int qid,
57 uint64_t *offset, uint64_t *size);
59 /** Get statistics name */
60 int (*get_stats_names)(struct rte_vdpa_device *dev,
61 struct rte_vdpa_stat_name *stats_names,
64 /** Get statistics of the queue */
65 int (*get_stats)(struct rte_vdpa_device *dev, int qid,
66 struct rte_vdpa_stat *stats, unsigned int n);
68 /** Reset statistics of the queue */
69 int (*reset_stats)(struct rte_vdpa_device *dev, int qid);
71 /** Reserved for future extension */
76 * vdpa device structure includes device address and device operations.
78 struct rte_vdpa_device {
79 RTE_TAILQ_ENTRY(rte_vdpa_device) next;
80 /** Generic device information */
81 struct rte_device *device;
82 /** vdpa device operations */
83 struct rte_vdpa_dev_ops *ops;
87 * Register a vdpa device
90 * the generic device pointer
92 * the vdpa device operations
94 * vDPA device pointer on success, NULL on failure
97 struct rte_vdpa_device *
98 rte_vdpa_register_device(struct rte_device *rte_dev,
99 struct rte_vdpa_dev_ops *ops);
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);
114 * Enable/Disable host notifier mapping for a vdpa port.
119 * true for host notifier map, false for host notifier unmap
121 * vhost queue id, RTE_VHOST_QUEUE_ALL to configure all the device queues
123 * 0 on success, -1 on failure
127 rte_vhost_host_notifier_ctrl(int vid, uint16_t qid, bool enable);
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 /* _VDPA_DRIVER_H_ */