doc: announce behavior change in bus probing
[dpdk.git] / lib / vhost / vdpa_driver.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2018 Intel Corporation
3  */
4
5 #ifndef _VDPA_DRIVER_H_
6 #define _VDPA_DRIVER_H_
7
8 #include <stdbool.h>
9
10 #include <rte_compat.h>
11
12 #include "rte_vhost.h"
13 #include "rte_vdpa.h"
14
15 #define RTE_VHOST_QUEUE_ALL UINT16_MAX
16
17 /**
18  * vdpa device operations
19  */
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);
23
24         /** Get supported features of this device (Mandatory) */
25         int (*get_features)(struct rte_vdpa_device *dev, uint64_t *features);
26
27         /** Get supported protocol features of this device (Mandatory) */
28         int (*get_protocol_features)(struct rte_vdpa_device *dev,
29                         uint64_t *protocol_features);
30
31         /** Driver configure the device (Mandatory) */
32         int (*dev_conf)(int vid);
33
34         /** Driver close the device (Mandatory) */
35         int (*dev_close)(int vid);
36
37         /** Enable/disable this vring (Mandatory) */
38         int (*set_vring_state)(int vid, int vring, int state);
39
40         /** Set features when changed (Mandatory) */
41         int (*set_features)(int vid);
42
43         /** Destination operations when migration done */
44         int (*migration_done)(int vid);
45
46         /** Get the vfio group fd */
47         int (*get_vfio_group_fd)(int vid);
48
49         /** Get the vfio device fd */
50         int (*get_vfio_device_fd)(int vid);
51
52         /** Get the notify area info of the queue */
53         int (*get_notify_area)(int vid, int qid,
54                         uint64_t *offset, uint64_t *size);
55
56         /** Get statistics name */
57         int (*get_stats_names)(struct rte_vdpa_device *dev,
58                         struct rte_vdpa_stat_name *stats_names,
59                         unsigned int size);
60
61         /** Get statistics of the queue */
62         int (*get_stats)(struct rte_vdpa_device *dev, int qid,
63                         struct rte_vdpa_stat *stats, unsigned int n);
64
65         /** Reset statistics of the queue */
66         int (*reset_stats)(struct rte_vdpa_device *dev, int qid);
67
68         /** Reserved for future extension */
69         void *reserved[2];
70 };
71
72 /**
73  * vdpa device structure includes device address and device operations.
74  */
75 struct rte_vdpa_device {
76         RTE_TAILQ_ENTRY(rte_vdpa_device) next;
77         /** Generic device information */
78         struct rte_device *device;
79         /** vdpa device operations */
80         struct rte_vdpa_dev_ops *ops;
81 };
82
83 /**
84  * Register a vdpa device
85  *
86  * @param rte_dev
87  *  the generic device pointer
88  * @param ops
89  *  the vdpa device operations
90  * @return
91  *  vDPA device pointer on success, NULL on failure
92  */
93 __rte_internal
94 struct rte_vdpa_device *
95 rte_vdpa_register_device(struct rte_device *rte_dev,
96                 struct rte_vdpa_dev_ops *ops);
97
98 /**
99  * Unregister a vdpa device
100  *
101  * @param dev
102  *  vDPA device pointer
103  * @return
104  *  device id on success, -1 on failure
105  */
106 __rte_internal
107 int
108 rte_vdpa_unregister_device(struct rte_vdpa_device *dev);
109
110 /**
111  * Enable/Disable host notifier mapping for a vdpa port.
112  *
113  * @param vid
114  *  vhost device id
115  * @param enable
116  *  true for host notifier map, false for host notifier unmap
117  * @param qid
118  *  vhost queue id, RTE_VHOST_QUEUE_ALL to configure all the device queues
119  * @return
120  *  0 on success, -1 on failure
121  */
122 __rte_internal
123 int
124 rte_vhost_host_notifier_ctrl(int vid, uint16_t qid, bool enable);
125
126 /**
127  * Synchronize the used ring from mediated ring to guest, log dirty
128  * page for each writeable buffer, caller should handle the used
129  * ring logging before device stop.
130  *
131  * @param vid
132  *  vhost device id
133  * @param qid
134  *  vhost queue id
135  * @param vring_m
136  *  mediated virtio ring pointer
137  * @return
138  *  number of synced used entries on success, -1 on failure
139  */
140 __rte_internal
141 int
142 rte_vdpa_relay_vring_used(int vid, uint16_t qid, void *vring_m);
143
144 #endif /* _VDPA_DRIVER_H_ */