1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2018 Intel Corporation
11 * Device specific vhost lib
15 #include "rte_vhost.h"
17 #define MAX_VDPA_NAME_LEN 128
27 struct rte_vdpa_dev_addr {
28 /** vdpa address type */
29 enum vdpa_addr_type type;
31 /** vdpa pci address */
34 struct rte_pci_addr pci_addr;
39 * vdpa device operations
41 struct rte_vdpa_dev_ops {
42 /** Get capabilities of this device */
43 int (*get_queue_num)(int did, uint32_t *queue_num);
45 /** Get supported features of this device */
46 int (*get_features)(int did, uint64_t *features);
48 /** Get supported protocol features of this device */
49 int (*get_protocol_features)(int did, uint64_t *protocol_features);
51 /** Driver configure/close the device */
52 int (*dev_conf)(int vid);
53 int (*dev_close)(int vid);
55 /** Enable/disable this vring */
56 int (*set_vring_state)(int vid, int vring, int state);
58 /** Set features when changed */
59 int (*set_features)(int vid);
61 /** Destination operations when migration done */
62 int (*migration_done)(int vid);
64 /** Get the vfio group fd */
65 int (*get_vfio_group_fd)(int vid);
67 /** Get the vfio device fd */
68 int (*get_vfio_device_fd)(int vid);
70 /** Get the notify area info of the queue */
71 int (*get_notify_area)(int vid, int qid,
72 uint64_t *offset, uint64_t *size);
74 /** Reserved for future extension */
79 * vdpa device structure includes device address and device operations.
81 struct rte_vdpa_device {
82 /** vdpa device address */
83 struct rte_vdpa_dev_addr addr;
84 /** vdpa device operations */
85 struct rte_vdpa_dev_ops *ops;
86 } __rte_cache_aligned;
90 * @b EXPERIMENTAL: this API may change without prior notice
92 * Register a vdpa device
95 * the vdpa device address
97 * the vdpa device operations
99 * device id on success, -1 on failure
101 int __rte_experimental
102 rte_vdpa_register_device(struct rte_vdpa_dev_addr *addr,
103 struct rte_vdpa_dev_ops *ops);
107 * @b EXPERIMENTAL: this API may change without prior notice
109 * Unregister a vdpa device
114 * device id on success, -1 on failure
116 int __rte_experimental
117 rte_vdpa_unregister_device(int did);
121 * @b EXPERIMENTAL: this API may change without prior notice
123 * Find the device id of a vdpa device
126 * the vdpa device address
128 * device id on success, -1 on failure
130 int __rte_experimental
131 rte_vdpa_find_device_id(struct rte_vdpa_dev_addr *addr);
135 * @b EXPERIMENTAL: this API may change without prior notice
137 * Find a vdpa device based on device id
142 * rte_vdpa_device on success, NULL on failure
144 struct rte_vdpa_device * __rte_experimental
145 rte_vdpa_get_device(int did);
149 * @b EXPERIMENTAL: this API may change without prior notice
151 * Get current available vdpa device number
154 * available vdpa device number
156 int __rte_experimental
157 rte_vdpa_get_device_num(void);
158 #endif /* _RTE_VDPA_H_ */