power: add environment capability probing
[dpdk.git] / lib / librte_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
12 #define RTE_VHOST_QUEUE_ALL UINT16_MAX
13
14 /**
15  * vdpa device operations
16  */
17 struct rte_vdpa_dev_ops {
18         /** Get capabilities of this device */
19         int (*get_queue_num)(struct rte_vdpa_device *dev, uint32_t *queue_num);
20
21         /** Get supported features of this device */
22         int (*get_features)(struct rte_vdpa_device *dev, uint64_t *features);
23
24         /** Get supported protocol features of this device */
25         int (*get_protocol_features)(struct rte_vdpa_device *dev,
26                         uint64_t *protocol_features);
27
28         /** Driver configure/close the device */
29         int (*dev_conf)(int vid);
30         int (*dev_close)(int vid);
31
32         /** Enable/disable this vring */
33         int (*set_vring_state)(int vid, int vring, int state);
34
35         /** Set features when changed */
36         int (*set_features)(int vid);
37
38         /** Destination operations when migration done */
39         int (*migration_done)(int vid);
40
41         /** Get the vfio group fd */
42         int (*get_vfio_group_fd)(int vid);
43
44         /** Get the vfio device fd */
45         int (*get_vfio_device_fd)(int vid);
46
47         /** Get the notify area info of the queue */
48         int (*get_notify_area)(int vid, int qid,
49                         uint64_t *offset, uint64_t *size);
50
51         /** Get statistics name */
52         int (*get_stats_names)(struct rte_vdpa_device *dev,
53                         struct rte_vdpa_stat_name *stats_names,
54                         unsigned int size);
55
56         /** Get statistics of the queue */
57         int (*get_stats)(struct rte_vdpa_device *dev, int qid,
58                         struct rte_vdpa_stat *stats, unsigned int n);
59
60         /** Reset statistics of the queue */
61         int (*reset_stats)(struct rte_vdpa_device *dev, int qid);
62
63         /** Reserved for future extension */
64         void *reserved[2];
65 };
66
67 /**
68  * vdpa device structure includes device address and device operations.
69  */
70 struct rte_vdpa_device {
71         TAILQ_ENTRY(rte_vdpa_device) next;
72         /** Generic device information */
73         struct rte_device *device;
74         /** vdpa device operations */
75         struct rte_vdpa_dev_ops *ops;
76 };
77
78 /**
79  * @warning
80  * @b EXPERIMENTAL: this API may change without prior notice
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 __rte_experimental
92 struct rte_vdpa_device *
93 rte_vdpa_register_device(struct rte_device *rte_dev,
94                 struct rte_vdpa_dev_ops *ops);
95
96 /**
97  * @warning
98  * @b EXPERIMENTAL: this API may change without prior notice
99  *
100  * Unregister a vdpa device
101  *
102  * @param dev
103  *  vDPA device pointer
104  * @return
105  *  device id on success, -1 on failure
106  */
107 __rte_experimental
108 int
109 rte_vdpa_unregister_device(struct rte_vdpa_device *dev);
110
111 /**
112  * @warning
113  * @b EXPERIMENTAL: this API may change without prior notice
114  *
115  * Enable/Disable host notifier mapping for a vdpa port.
116  *
117  * @param vid
118  *  vhost device id
119  * @param enable
120  *  true for host notifier map, false for host notifier unmap
121  * @param qid
122  *  vhost queue id, RTE_VHOST_QUEUE_ALL to configure all the device queues
123  * @return
124  *  0 on success, -1 on failure
125  */
126 __rte_experimental
127 int
128 rte_vhost_host_notifier_ctrl(int vid, uint16_t qid, bool enable);
129
130 /**
131  * @warning
132  * @b EXPERIMENTAL: this API may change without prior notice
133  *
134  * Synchronize the used ring from mediated ring to guest, log dirty
135  * page for each writeable buffer, caller should handle the used
136  * ring logging before device stop.
137  *
138  * @param vid
139  *  vhost device id
140  * @param qid
141  *  vhost queue id
142  * @param vring_m
143  *  mediated virtio ring pointer
144  * @return
145  *  number of synced used entries on success, -1 on failure
146  */
147 __rte_experimental
148 int
149 rte_vdpa_relay_vring_used(int vid, uint16_t qid, void *vring_m);
150
151 #endif /* _RTE_VDPA_DEV_H_ */