DPDK  21.02.0
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 #define RTE_ETH_DEV_TO_VDEV(eth_dev) RTE_DEV_TO_VDEV((eth_dev)->device)
38 
39 static inline const char *
40 rte_vdev_device_name(const struct rte_vdev_device *dev)
41 {
42  if (dev && dev->device.name)
43  return dev->device.name;
44  return NULL;
45 }
46 
47 static inline const char *
48 rte_vdev_device_args(const struct rte_vdev_device *dev)
49 {
50  if (dev && dev->device.devargs)
51  return dev->device.devargs->args;
52  return "";
53 }
54 
56 TAILQ_HEAD(vdev_driver_list, rte_vdev_driver);
57 
61 typedef int (rte_vdev_probe_t)(struct rte_vdev_device *dev);
62 
66 typedef int (rte_vdev_remove_t)(struct rte_vdev_device *dev);
67 
84 typedef int (rte_vdev_dma_map_t)(struct rte_vdev_device *dev, void *addr,
85  uint64_t iova, size_t len);
86 
103 typedef int (rte_vdev_dma_unmap_t)(struct rte_vdev_device *dev, void *addr,
104  uint64_t iova, size_t len);
105 
110  TAILQ_ENTRY(rte_vdev_driver) next;
111  struct rte_driver driver;
116  uint32_t drv_flags;
117 };
118 
120 #define RTE_VDEV_DRV_NEED_IOVA_AS_VA 0x0001
121 
129 void rte_vdev_register(struct rte_vdev_driver *driver);
130 
138 void rte_vdev_unregister(struct rte_vdev_driver *driver);
139 
140 #define RTE_PMD_REGISTER_VDEV(nm, vdrv)\
141 static const char *vdrvinit_ ## nm ## _alias;\
142 RTE_INIT(vdrvinitfn_ ##vdrv)\
143 {\
144  (vdrv).driver.name = RTE_STR(nm);\
145  (vdrv).driver.alias = vdrvinit_ ## nm ## _alias;\
146  rte_vdev_register(&vdrv);\
147 } \
148 RTE_PMD_EXPORT_NAME(nm, __COUNTER__)
149 
150 #define RTE_PMD_REGISTER_ALIAS(nm, alias)\
151 static const char *vdrvinit_ ## nm ## _alias = RTE_STR(alias)
152 
153 typedef void (*rte_vdev_scan_callback)(void *user_arg);
154 
169 int
170 rte_vdev_add_custom_scan(rte_vdev_scan_callback callback, void *user_arg);
171 
185 int
186 rte_vdev_remove_custom_scan(rte_vdev_scan_callback callback, void *user_arg);
187 
198 int rte_vdev_init(const char *name, const char *args);
199 
208 int rte_vdev_uninit(const char *name);
209 
210 #ifdef __cplusplus
211 }
212 #endif
213 
214 #endif
rte_vdev_dma_map_t * dma_map
Definition: rte_bus_vdev.h:114
rte_vdev_probe_t * probe
Definition: rte_bus_vdev.h:112
int( rte_vdev_remove_t)(struct rte_vdev_device *dev)
Definition: rte_bus_vdev.h:66
int rte_vdev_uninit(const char *name)
int rte_vdev_init(const char *name, const char *args)
void rte_vdev_register(struct rte_vdev_driver *driver)
uint32_t drv_flags
Definition: rte_bus_vdev.h:116
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)
rte_vdev_dma_unmap_t * dma_unmap
Definition: rte_bus_vdev.h:115
int( rte_vdev_dma_unmap_t)(struct rte_vdev_device *dev, void *addr, uint64_t iova, size_t len)
Definition: rte_bus_vdev.h:103
const char * name
Definition: rte_dev.h:79
int( rte_vdev_dma_map_t)(struct rte_vdev_device *dev, void *addr, uint64_t iova, size_t len)
Definition: rte_bus_vdev.h:84
TAILQ_HEAD(vdev_driver_list, rte_vdev_driver)
int( rte_vdev_probe_t)(struct rte_vdev_device *dev)
Definition: rte_bus_vdev.h:61