1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2018 Intel Corporation
11 * Device specific vhost lib
17 #include "rte_vhost.h"
19 #define MAX_VDPA_NAME_LEN 128
29 struct rte_vdpa_dev_addr {
30 /** vdpa address type */
31 enum vdpa_addr_type type;
33 /** vdpa pci address */
36 struct rte_pci_addr pci_addr;
41 * vdpa device operations
43 struct rte_vdpa_dev_ops {
44 /** Get capabilities of this device */
45 int (*get_queue_num)(int did, uint32_t *queue_num);
47 /** Get supported features of this device */
48 int (*get_features)(int did, uint64_t *features);
50 /** Get supported protocol features of this device */
51 int (*get_protocol_features)(int did, uint64_t *protocol_features);
53 /** Driver configure/close the device */
54 int (*dev_conf)(int vid);
55 int (*dev_close)(int vid);
57 /** Enable/disable this vring */
58 int (*set_vring_state)(int vid, int vring, int state);
60 /** Set features when changed */
61 int (*set_features)(int vid);
63 /** Destination operations when migration done */
64 int (*migration_done)(int vid);
66 /** Get the vfio group fd */
67 int (*get_vfio_group_fd)(int vid);
69 /** Get the vfio device fd */
70 int (*get_vfio_device_fd)(int vid);
72 /** Get the notify area info of the queue */
73 int (*get_notify_area)(int vid, int qid,
74 uint64_t *offset, uint64_t *size);
76 /** Reserved for future extension */
81 * vdpa device structure includes device address and device operations.
83 struct rte_vdpa_device {
84 /** vdpa device address */
85 struct rte_vdpa_dev_addr addr;
86 /** vdpa device operations */
87 struct rte_vdpa_dev_ops *ops;
88 } __rte_cache_aligned;
92 * @b EXPERIMENTAL: this API may change without prior notice
94 * Register a vdpa device
97 * the vdpa device address
99 * the vdpa device operations
101 * device id on success, -1 on failure
103 int __rte_experimental
104 rte_vdpa_register_device(struct rte_vdpa_dev_addr *addr,
105 struct rte_vdpa_dev_ops *ops);
109 * @b EXPERIMENTAL: this API may change without prior notice
111 * Unregister a vdpa device
116 * device id on success, -1 on failure
118 int __rte_experimental
119 rte_vdpa_unregister_device(int did);
123 * @b EXPERIMENTAL: this API may change without prior notice
125 * Find the device id of a vdpa device
128 * the vdpa device address
130 * device id on success, -1 on failure
132 int __rte_experimental
133 rte_vdpa_find_device_id(struct rte_vdpa_dev_addr *addr);
137 * @b EXPERIMENTAL: this API may change without prior notice
139 * Find a vdpa device based on device id
144 * rte_vdpa_device on success, NULL on failure
146 struct rte_vdpa_device * __rte_experimental
147 rte_vdpa_get_device(int did);
151 * @b EXPERIMENTAL: this API may change without prior notice
153 * Get current available vdpa device number
156 * available vdpa device number
158 int __rte_experimental
159 rte_vdpa_get_device_num(void);
163 * @b EXPERIMENTAL: this API may change without prior notice
165 * Enable/Disable host notifier mapping for a vdpa port.
170 * true for host notifier map, false for host notifier unmap
172 * 0 on success, -1 on failure
174 int __rte_experimental
175 rte_vhost_host_notifier_ctrl(int vid, bool enable);
179 * @b EXPERIMENTAL: this API may change without prior notice
181 * Synchronize the available ring from guest to mediated ring, help to
182 * check desc validity to protect against malicious guest driver.
189 * mediated virtio ring pointer
191 * number of synced available entries on success, -1 on failure
193 int __rte_experimental
194 rte_vdpa_relay_vring_avail(int vid, uint16_t qid, void *vring_m);
198 * @b EXPERIMENTAL: this API may change without prior notice
200 * Synchronize the used ring from mediated ring to guest, log dirty
201 * page for each writeable buffer, caller should handle the used
202 * ring logging before device stop.
209 * mediated virtio ring pointer
211 * number of synced used entries on success, -1 on failure
213 int __rte_experimental
214 rte_vdpa_relay_vring_used(int vid, uint16_t qid, void *vring_m);
215 #endif /* _RTE_VDPA_H_ */