]> git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/dpdk/lib/librte_vhost/rte_vdpa.h
import 15.2.0 Octopus source
[ceph.git] / ceph / src / spdk / dpdk / lib / librte_vhost / rte_vdpa.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2018 Intel Corporation
3 */
4
5 #ifndef _RTE_VDPA_H_
6 #define _RTE_VDPA_H_
7
8 /**
9 * @file
10 *
11 * Device specific vhost lib
12 */
13
14 #include <stdbool.h>
15
16 #include <rte_pci.h>
17 #include "rte_vhost.h"
18
19 #define MAX_VDPA_NAME_LEN 128
20
21 enum vdpa_addr_type {
22 PCI_ADDR,
23 VDPA_ADDR_MAX
24 };
25
26 /**
27 * vdpa device address
28 */
29 struct rte_vdpa_dev_addr {
30 /** vdpa address type */
31 enum vdpa_addr_type type;
32
33 /** vdpa pci address */
34 union {
35 uint8_t __dummy[64];
36 struct rte_pci_addr pci_addr;
37 };
38 };
39
40 /**
41 * vdpa device operations
42 */
43 struct rte_vdpa_dev_ops {
44 /** Get capabilities of this device */
45 int (*get_queue_num)(int did, uint32_t *queue_num);
46
47 /** Get supported features of this device */
48 int (*get_features)(int did, uint64_t *features);
49
50 /** Get supported protocol features of this device */
51 int (*get_protocol_features)(int did, uint64_t *protocol_features);
52
53 /** Driver configure/close the device */
54 int (*dev_conf)(int vid);
55 int (*dev_close)(int vid);
56
57 /** Enable/disable this vring */
58 int (*set_vring_state)(int vid, int vring, int state);
59
60 /** Set features when changed */
61 int (*set_features)(int vid);
62
63 /** Destination operations when migration done */
64 int (*migration_done)(int vid);
65
66 /** Get the vfio group fd */
67 int (*get_vfio_group_fd)(int vid);
68
69 /** Get the vfio device fd */
70 int (*get_vfio_device_fd)(int vid);
71
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);
75
76 /** Reserved for future extension */
77 void *reserved[5];
78 };
79
80 /**
81 * vdpa device structure includes device address and device operations.
82 */
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;
89
90 /**
91 * @warning
92 * @b EXPERIMENTAL: this API may change without prior notice
93 *
94 * Register a vdpa device
95 *
96 * @param addr
97 * the vdpa device address
98 * @param ops
99 * the vdpa device operations
100 * @return
101 * device id on success, -1 on failure
102 */
103 int __rte_experimental
104 rte_vdpa_register_device(struct rte_vdpa_dev_addr *addr,
105 struct rte_vdpa_dev_ops *ops);
106
107 /**
108 * @warning
109 * @b EXPERIMENTAL: this API may change without prior notice
110 *
111 * Unregister a vdpa device
112 *
113 * @param did
114 * vdpa device id
115 * @return
116 * device id on success, -1 on failure
117 */
118 int __rte_experimental
119 rte_vdpa_unregister_device(int did);
120
121 /**
122 * @warning
123 * @b EXPERIMENTAL: this API may change without prior notice
124 *
125 * Find the device id of a vdpa device
126 *
127 * @param addr
128 * the vdpa device address
129 * @return
130 * device id on success, -1 on failure
131 */
132 int __rte_experimental
133 rte_vdpa_find_device_id(struct rte_vdpa_dev_addr *addr);
134
135 /**
136 * @warning
137 * @b EXPERIMENTAL: this API may change without prior notice
138 *
139 * Find a vdpa device based on device id
140 *
141 * @param did
142 * device id
143 * @return
144 * rte_vdpa_device on success, NULL on failure
145 */
146 struct rte_vdpa_device * __rte_experimental
147 rte_vdpa_get_device(int did);
148
149 /**
150 * @warning
151 * @b EXPERIMENTAL: this API may change without prior notice
152 *
153 * Get current available vdpa device number
154 *
155 * @return
156 * available vdpa device number
157 */
158 int __rte_experimental
159 rte_vdpa_get_device_num(void);
160
161 /**
162 * @warning
163 * @b EXPERIMENTAL: this API may change without prior notice
164 *
165 * Enable/Disable host notifier mapping for a vdpa port.
166 *
167 * @param vid
168 * vhost device id
169 * @param enable
170 * true for host notifier map, false for host notifier unmap
171 * @return
172 * 0 on success, -1 on failure
173 */
174 int __rte_experimental
175 rte_vhost_host_notifier_ctrl(int vid, bool enable);
176
177 /**
178 * @warning
179 * @b EXPERIMENTAL: this API may change without prior notice
180 *
181 * Synchronize the used ring from mediated ring to guest, log dirty
182 * page for each writeable buffer, caller should handle the used
183 * ring logging before device stop.
184 *
185 * @param vid
186 * vhost device id
187 * @param qid
188 * vhost queue id
189 * @param vring_m
190 * mediated virtio ring pointer
191 * @return
192 * number of synced used entries on success, -1 on failure
193 */
194 int __rte_experimental
195 rte_vdpa_relay_vring_used(int vid, uint16_t qid, void *vring_m);
196 #endif /* _RTE_VDPA_H_ */