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