DPDK  18.11.11
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_NONE,
67 };
68 
73  RTE_DEV_WHITELISTED,
74  RTE_DEV_BLACKLISTED,
75 };
76 
81  uint64_t phys_addr;
82  uint64_t len;
83  void *addr;
84 };
85 
89 struct rte_driver {
90  TAILQ_ENTRY(rte_driver) next;
91  const char *name;
92  const char *alias;
93 };
94 
95 /*
96  * Internal identifier length
97  * Sufficiently large to allow for UUID or PCI address
98  */
99 #define RTE_DEV_NAME_MAX_LEN 64
100 
104 struct rte_device {
105  TAILQ_ENTRY(rte_device) next;
106  const char *name;
107  const struct rte_driver *driver;
108  const struct rte_bus *bus;
109  int numa_node;
111 };
112 
124 __rte_experimental
125 int rte_dev_is_probed(const struct rte_device *dev);
126 
143 int rte_eal_hotplug_add(const char *busname, const char *devname,
144  const char *drvargs);
145 
157 int rte_dev_probe(const char *devargs);
158 
172 int rte_eal_hotplug_remove(const char *busname, const char *devname);
173 
185 int rte_dev_remove(struct rte_device *dev);
186 
206 typedef int (*rte_dev_cmp_t)(const struct rte_device *dev, const void *data);
207 
208 #define RTE_PMD_EXPORT_NAME_ARRAY(n, idx) n##idx[]
209 
210 #define RTE_PMD_EXPORT_NAME(name, idx) \
211 static const char RTE_PMD_EXPORT_NAME_ARRAY(this_pmd_name, idx) \
212 __attribute__((used)) = RTE_STR(name)
213 
214 #define DRV_EXP_TAG(name, tag) __##name##_##tag
215 
216 #define RTE_PMD_REGISTER_PCI_TABLE(name, table) \
217 static const char DRV_EXP_TAG(name, pci_tbl_export)[] __attribute__((used)) = \
218 RTE_STR(table)
219 
220 #define RTE_PMD_REGISTER_PARAM_STRING(name, str) \
221 static const char DRV_EXP_TAG(name, param_string_export)[] \
222 __attribute__((used)) = str
223 
245 #define RTE_PMD_REGISTER_KMOD_DEP(name, str) \
246 static const char DRV_EXP_TAG(name, kmod_dep_export)[] \
247 __attribute__((used)) = str
248 
255  const char *dev_str;
256  const char *bus_str;
257  const char *cls_str;
258  struct rte_bus *bus;
259  struct rte_class *cls;
260  struct rte_device *device;
261  void *class_device;
262 };
263 
292 typedef void *(*rte_dev_iterate_t)(const void *start,
293  const char *devstr,
294  const struct rte_dev_iterator *it);
295 
316 __rte_experimental
317 int
318 rte_dev_iterator_init(struct rte_dev_iterator *it, const char *str);
319 
336 __rte_experimental
337 struct rte_device *
339 
340 #define RTE_DEV_FOREACH(dev, devstr, it) \
341  for (rte_dev_iterator_init(it, devstr), \
342  dev = rte_dev_iterator_next(it); \
343  dev != NULL; \
344  dev = rte_dev_iterator_next(it))
345 
346 #ifdef __cplusplus
347 }
348 #endif
349 
369 int __rte_experimental
370 rte_dev_event_callback_register(const char *device_name,
371  rte_dev_event_cb_fn cb_fn,
372  void *cb_arg);
373 
393 int __rte_experimental
394 rte_dev_event_callback_unregister(const char *device_name,
395  rte_dev_event_cb_fn cb_fn,
396  void *cb_arg);
397 
410 void __rte_experimental
411 rte_dev_event_callback_process(const char *device_name,
412  enum rte_dev_event_type event);
413 
424 int __rte_experimental
426 
437 int __rte_experimental
439 
450 int __rte_experimental
452 
463 int __rte_experimental
465 
466 #endif /* _RTE_DEV_H_ */
struct rte_device * device
Definition: rte_dev.h:260
int __rte_experimental rte_dev_event_monitor_stop(void)
uint64_t len
Definition: rte_dev.h:82
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:257
__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:83
void * class_device
Definition: rte_dev.h:261
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:259
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:81
__rte_experimental int rte_dev_is_probed(const struct rte_device *dev)
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)
rte_dev_policy
Definition: rte_dev.h:72
__rte_experimental struct rte_device * rte_dev_iterator_next(struct rte_dev_iterator *it)
struct rte_bus * bus
Definition: rte_dev.h:258
struct rte_devargs * devargs
Definition: rte_dev.h:110
int rte_eal_hotplug_remove(const char *busname, const char *devname)
int numa_node
Definition: rte_dev.h:109
const char * name
Definition: rte_dev.h:91
const char * bus_str
Definition: rte_dev.h:256
const char * name
Definition: rte_dev.h:106
const char * alias
Definition: rte_dev.h:92
const char * dev_str
Definition: rte_dev.h:255
const struct rte_driver * driver
Definition: rte_dev.h:107
const struct rte_bus * bus
Definition: rte_dev.h:108
int(* rte_dev_cmp_t)(const struct rte_device *dev, const void *data)
Definition: rte_dev.h:206