DPDK  19.08.0-rc0
rte_dev.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2014 6WIND S.A.
3  */
4 
5 #ifndef _RTE_DEV_H_
6 #define _RTE_DEV_H_
7 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19 
20 #include <stdio.h>
21 #include <sys/queue.h>
22 
23 #include <rte_config.h>
24 #include <rte_compat.h>
25 #include <rte_log.h>
26 
34 };
35 
36 struct rte_dev_event {
37  enum rte_dev_event_type type;
38  int subsystem;
39  char *devname;
40 };
41 
42 typedef void (*rte_dev_event_cb_fn)(const char *device_name,
43  enum rte_dev_event_type event,
44  void *cb_arg);
45 
46 /* Macros to check for invalid function pointers */
47 #define RTE_FUNC_PTR_OR_ERR_RET(func, retval) do { \
48  if ((func) == NULL) \
49  return retval; \
50 } while (0)
51 
52 #define RTE_FUNC_PTR_OR_RET(func) do { \
53  if ((func) == NULL) \
54  return; \
55 } while (0)
56 
61  RTE_KDRV_UNKNOWN = 0,
62  RTE_KDRV_IGB_UIO,
63  RTE_KDRV_VFIO,
64  RTE_KDRV_UIO_GENERIC,
65  RTE_KDRV_NIC_UIO,
66  RTE_KDRV_NIC_MLX,
67  RTE_KDRV_NONE,
68 };
69 
74  RTE_DEV_WHITELISTED,
75  RTE_DEV_BLACKLISTED,
76 };
77 
82  uint64_t phys_addr;
83  uint64_t len;
84  void *addr;
85 };
86 
90 struct rte_driver {
91  TAILQ_ENTRY(rte_driver) next;
92  const char *name;
93  const char *alias;
94 };
95 
96 /*
97  * Internal identifier length
98  * Sufficiently large to allow for UUID or PCI address
99  */
100 #define RTE_DEV_NAME_MAX_LEN 64
101 
105 struct rte_device {
106  TAILQ_ENTRY(rte_device) next;
107  const char *name;
108  const struct rte_driver *driver;
109  const struct rte_bus *bus;
110  int numa_node;
112 };
113 
122 int rte_dev_is_probed(const struct rte_device *dev);
123 
140 int rte_eal_hotplug_add(const char *busname, const char *devname,
141  const char *drvargs);
142 
154 int rte_dev_probe(const char *devargs);
155 
169 int rte_eal_hotplug_remove(const char *busname, const char *devname);
170 
182 int rte_dev_remove(struct rte_device *dev);
183 
203 typedef int (*rte_dev_cmp_t)(const struct rte_device *dev, const void *data);
204 
205 #define RTE_PMD_EXPORT_NAME_ARRAY(n, idx) n##idx[]
206 
207 #define RTE_PMD_EXPORT_NAME(name, idx) \
208 static const char RTE_PMD_EXPORT_NAME_ARRAY(this_pmd_name, idx) \
209 __attribute__((used)) = RTE_STR(name)
210 
211 #define DRV_EXP_TAG(name, tag) __##name##_##tag
212 
213 #define RTE_PMD_REGISTER_PCI_TABLE(name, table) \
214 static const char DRV_EXP_TAG(name, pci_tbl_export)[] __attribute__((used)) = \
215 RTE_STR(table)
216 
217 #define RTE_PMD_REGISTER_PARAM_STRING(name, str) \
218 static const char DRV_EXP_TAG(name, param_string_export)[] \
219 __attribute__((used)) = str
220 
242 #define RTE_PMD_REGISTER_KMOD_DEP(name, str) \
243 static const char DRV_EXP_TAG(name, kmod_dep_export)[] \
244 __attribute__((used)) = str
245 
252  const char *dev_str;
253  const char *bus_str;
254  const char *cls_str;
255  struct rte_bus *bus;
256  struct rte_class *cls;
257  struct rte_device *device;
258  void *class_device;
259 };
260 
289 typedef void *(*rte_dev_iterate_t)(const void *start,
290  const char *devstr,
291  const struct rte_dev_iterator *it);
292 
313 __rte_experimental
314 int
315 rte_dev_iterator_init(struct rte_dev_iterator *it, const char *str);
316 
333 __rte_experimental
334 struct rte_device *
336 
337 #define RTE_DEV_FOREACH(dev, devstr, it) \
338  for (rte_dev_iterator_init(it, devstr), \
339  dev = rte_dev_iterator_next(it); \
340  dev != NULL; \
341  dev = rte_dev_iterator_next(it))
342 
343 #ifdef __cplusplus
344 }
345 #endif
346 
366 int __rte_experimental
367 rte_dev_event_callback_register(const char *device_name,
368  rte_dev_event_cb_fn cb_fn,
369  void *cb_arg);
370 
390 int __rte_experimental
391 rte_dev_event_callback_unregister(const char *device_name,
392  rte_dev_event_cb_fn cb_fn,
393  void *cb_arg);
394 
407 void __rte_experimental
408 rte_dev_event_callback_process(const char *device_name,
409  enum rte_dev_event_type event);
410 
421 int __rte_experimental
423 
434 int __rte_experimental
436 
447 int __rte_experimental
449 
460 int __rte_experimental
462 
483 int __rte_experimental
484 rte_dev_dma_map(struct rte_device *dev, void *addr, uint64_t iova, size_t len);
485 
506 int __rte_experimental
507 rte_dev_dma_unmap(struct rte_device *dev, void *addr, uint64_t iova,
508  size_t len);
509 
510 #endif /* _RTE_DEV_H_ */
struct rte_device * device
Definition: rte_dev.h:257
int __rte_experimental rte_dev_event_monitor_stop(void)
uint64_t len
Definition: rte_dev.h:83
int __rte_experimental rte_dev_event_callback_register(const char *device_name, rte_dev_event_cb_fn cb_fn, void *cb_arg)
const char * cls_str
Definition: rte_dev.h:254
int rte_dev_is_probed(const struct rte_device *dev)
__rte_experimental int rte_dev_iterator_init(struct rte_dev_iterator *it, const char *str)
int __rte_experimental rte_dev_hotplug_handle_enable(void)
void * addr
Definition: rte_dev.h:84
void * class_device
Definition: rte_dev.h:258
int __rte_experimental rte_dev_event_monitor_start(void)
void __rte_experimental rte_dev_event_callback_process(const char *device_name, enum rte_dev_event_type event)
int rte_dev_remove(struct rte_device *dev)
struct rte_class * cls
Definition: rte_dev.h:256
int __rte_experimental rte_dev_dma_map(struct rte_device *dev, void *addr, uint64_t iova, size_t len)
rte_dev_event_type
Definition: rte_dev.h:30
int rte_dev_probe(const char *devargs)
TAILQ_ENTRY(rte_driver) next
uint64_t phys_addr
Definition: rte_dev.h:82
TAILQ_ENTRY(rte_device) next
int __rte_experimental rte_dev_event_callback_unregister(const char *device_name, rte_dev_event_cb_fn cb_fn, void *cb_arg)
int rte_eal_hotplug_add(const char *busname, const char *devname, const char *drvargs)
rte_kernel_driver
Definition: rte_dev.h:60
int __rte_experimental rte_dev_hotplug_handle_disable(void)
int __rte_experimental rte_dev_dma_unmap(struct rte_device *dev, void *addr, uint64_t iova, size_t len)
rte_dev_policy
Definition: rte_dev.h:73
__rte_experimental struct rte_device * rte_dev_iterator_next(struct rte_dev_iterator *it)
struct rte_bus * bus
Definition: rte_dev.h:255
struct rte_devargs * devargs
Definition: rte_dev.h:111
int rte_eal_hotplug_remove(const char *busname, const char *devname)
int numa_node
Definition: rte_dev.h:110
const char * name
Definition: rte_dev.h:92
const char * bus_str
Definition: rte_dev.h:253
const char * name
Definition: rte_dev.h:107
const char * alias
Definition: rte_dev.h:93
const char * dev_str
Definition: rte_dev.h:252
const struct rte_driver * driver
Definition: rte_dev.h:108
const struct rte_bus * bus
Definition: rte_dev.h:109
int(* rte_dev_cmp_t)(const struct rte_device *dev, const void *data)
Definition: rte_dev.h:203