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
105 rte_vdpa_register_device(struct rte_vdpa_dev_addr *addr,
106 struct rte_vdpa_dev_ops *ops);
110 * @b EXPERIMENTAL: this API may change without prior notice
112 * Unregister a vdpa device
117 * device id on success, -1 on failure
121 rte_vdpa_unregister_device(int did);
125 * @b EXPERIMENTAL: this API may change without prior notice
127 * Find the device id of a vdpa device
130 * the vdpa device address
132 * device id on success, -1 on failure
136 rte_vdpa_find_device_id(struct rte_vdpa_dev_addr *addr);
140 * @b EXPERIMENTAL: this API may change without prior notice
142 * Find a vdpa device based on device id
147 * rte_vdpa_device on success, NULL on failure
150 struct rte_vdpa_device *
151 rte_vdpa_get_device(int did);
155 * @b EXPERIMENTAL: this API may change without prior notice
157 * Get current available vdpa device number
160 * available vdpa device number
164 rte_vdpa_get_device_num(void);
168 * @b EXPERIMENTAL: this API may change without prior notice
170 * Enable/Disable host notifier mapping for a vdpa port.
175 * true for host notifier map, false for host notifier unmap
177 * 0 on success, -1 on failure
181 rte_vhost_host_notifier_ctrl(int vid, bool enable);
185 * @b EXPERIMENTAL: this API may change without prior notice
187 * Synchronize the used ring from mediated ring to guest, log dirty
188 * page for each writeable buffer, caller should handle the used
189 * ring logging before device stop.
196 * mediated virtio ring pointer
198 * number of synced used entries on success, -1 on failure
202 rte_vdpa_relay_vring_used(int vid, uint16_t qid, void *vring_m);
203 #endif /* _RTE_VDPA_H_ */