DPDK  20.11.10
rte_bus_vdev.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2016 RehiveTech. All rights reserved.
3  */
4 
5 #ifndef RTE_VDEV_H
6 #define RTE_VDEV_H
7 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
18 #include <sys/queue.h>
19 #include <rte_dev.h>
20 #include <rte_devargs.h>
21 
22 struct rte_vdev_device {
23  TAILQ_ENTRY(rte_vdev_device) next;
24  struct rte_device device;
25 };
26 
31 #define RTE_DEV_TO_VDEV(ptr) \
32  container_of(ptr, struct rte_vdev_device, device)
33 
34 #define RTE_DEV_TO_VDEV_CONST(ptr) \
35  container_of(ptr, const struct rte_vdev_device, device)
36 
37 static inline const char *
38 rte_vdev_device_name(const struct rte_vdev_device *dev)
39 {
40  if (dev && dev->device.name)
41  return dev->device.name;
42  return NULL;
43 }
44 
45 static inline const char *
46 rte_vdev_device_args(const struct rte_vdev_device *dev)
47 {
48  if (dev && dev->device.devargs)
49  return dev->device.devargs->args;
50  return "";
51 }
52 
54 TAILQ_HEAD(vdev_driver_list, rte_vdev_driver);
55 
59 typedef int (rte_vdev_probe_t)(struct rte_vdev_device *dev);
60 
64 typedef int (rte_vdev_remove_t)(struct rte_vdev_device *dev);
65 
82 typedef int (rte_vdev_dma_map_t)(struct rte_vdev_device *dev, void *addr,
83  uint64_t iova, size_t len);
84 
101 typedef int (rte_vdev_dma_unmap_t)(struct rte_vdev_device *dev, void *addr,
102  uint64_t iova, size_t len);
103 
108  TAILQ_ENTRY(rte_vdev_driver) next;
109  struct rte_driver driver;
114 };
115 
123 void rte_vdev_register(struct rte_vdev_driver *driver);
124 
132 void rte_vdev_unregister(struct rte_vdev_driver *driver);
133 
134 #define RTE_PMD_REGISTER_VDEV(nm, vdrv)\
135 static const char *vdrvinit_ ## nm ## _alias;\
136 RTE_INIT(vdrvinitfn_ ##vdrv)\
137 {\
138  (vdrv).driver.name = RTE_STR(nm);\
139  (vdrv).driver.alias = vdrvinit_ ## nm ## _alias;\
140  rte_vdev_register(&vdrv);\
141 } \
142 RTE_PMD_EXPORT_NAME(nm, __COUNTER__)
143 
144 #define RTE_PMD_REGISTER_ALIAS(nm, alias)\
145 static const char *vdrvinit_ ## nm ## _alias = RTE_STR(alias)
146 
147 typedef void (*rte_vdev_scan_callback)(void *user_arg);
148 
163 int
164 rte_vdev_add_custom_scan(rte_vdev_scan_callback callback, void *user_arg);
165 
179 int
180 rte_vdev_remove_custom_scan(rte_vdev_scan_callback callback, void *user_arg);
181 
192 int rte_vdev_init(const char *name, const char *args);
193 
202 int rte_vdev_uninit(const char *name);
203 
204 #ifdef __cplusplus
205 }
206 #endif
207 
208 #endif
rte_vdev_dma_map_t * dma_map
Definition: rte_bus_vdev.h:112
rte_vdev_probe_t * probe
Definition: rte_bus_vdev.h:110
int rte_vdev_uninit(const char *name)
int rte_vdev_init(const char *name, const char *args)
int() rte_vdev_dma_map_t(struct rte_vdev_device *dev, void *addr, uint64_t iova, size_t len)
Definition: rte_bus_vdev.h:82
void rte_vdev_register(struct rte_vdev_driver *driver)
int rte_vdev_remove_custom_scan(rte_vdev_scan_callback callback, void *user_arg)
void rte_vdev_unregister(struct rte_vdev_driver *driver)
int rte_vdev_add_custom_scan(rte_vdev_scan_callback callback, void *user_arg)
int() rte_vdev_remove_t(struct rte_vdev_device *dev)
Definition: rte_bus_vdev.h:64
rte_vdev_dma_unmap_t * dma_unmap
Definition: rte_bus_vdev.h:113
const char * name
Definition: rte_dev.h:79
TAILQ_HEAD(vdev_driver_list, rte_vdev_driver)
int() rte_vdev_dma_unmap_t(struct rte_vdev_device *dev, void *addr, uint64_t iova, size_t len)
Definition: rte_bus_vdev.h:101
int() rte_vdev_probe_t(struct rte_vdev_device *dev)
Definition: rte_bus_vdev.h:59