DPDK  20.05.0
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 
121 int rte_dev_is_probed(const struct rte_device *dev);
122 
139 int rte_eal_hotplug_add(const char *busname, const char *devname,
140  const char *drvargs);
141 
153 int rte_dev_probe(const char *devargs);
154 
168 int rte_eal_hotplug_remove(const char *busname, const char *devname);
169 
181 int rte_dev_remove(struct rte_device *dev);
182 
202 typedef int (*rte_dev_cmp_t)(const struct rte_device *dev, const void *data);
203 
204 #define RTE_PMD_EXPORT_NAME_ARRAY(n, idx) n##idx[]
205 
206 #define RTE_PMD_EXPORT_NAME(name, idx) \
207 static const char RTE_PMD_EXPORT_NAME_ARRAY(this_pmd_name, idx) \
208 __rte_used = RTE_STR(name)
209 
210 #define DRV_EXP_TAG(name, tag) __##name##_##tag
211 
212 #define RTE_PMD_REGISTER_PCI_TABLE(name, table) \
213 static const char DRV_EXP_TAG(name, pci_tbl_export)[] __rte_used = \
214 RTE_STR(table)
215 
216 #define RTE_PMD_REGISTER_PARAM_STRING(name, str) \
217 static const char DRV_EXP_TAG(name, param_string_export)[] \
218 __rte_used = str
219 
241 #define RTE_PMD_REGISTER_KMOD_DEP(name, str) \
242 static const char DRV_EXP_TAG(name, kmod_dep_export)[] \
243 __rte_used = str
244 
251  const char *dev_str;
252  const char *bus_str;
253  const char *cls_str;
254  struct rte_bus *bus;
255  struct rte_class *cls;
256  struct rte_device *device;
257  void *class_device;
258 };
259 
288 typedef void *(*rte_dev_iterate_t)(const void *start,
289  const char *devstr,
290  const struct rte_dev_iterator *it);
291 
312 __rte_experimental
313 int
314 rte_dev_iterator_init(struct rte_dev_iterator *it, const char *str);
315 
332 __rte_experimental
333 struct rte_device *
335 
336 #define RTE_DEV_FOREACH(dev, devstr, it) \
337  for (rte_dev_iterator_init(it, devstr), \
338  dev = rte_dev_iterator_next(it); \
339  dev != NULL; \
340  dev = rte_dev_iterator_next(it))
341 
342 #ifdef __cplusplus
343 }
344 #endif
345 
365 __rte_experimental
366 int
367 rte_dev_event_callback_register(const char *device_name,
368  rte_dev_event_cb_fn cb_fn,
369  void *cb_arg);
370 
390 __rte_experimental
391 int
392 rte_dev_event_callback_unregister(const char *device_name,
393  rte_dev_event_cb_fn cb_fn,
394  void *cb_arg);
395 
408 __rte_experimental
409 void
410 rte_dev_event_callback_process(const char *device_name,
411  enum rte_dev_event_type event);
412 
423 __rte_experimental
424 int
426 
437 __rte_experimental
438 int
440 
451 __rte_experimental
452 int
454 
465 __rte_experimental
466 int
468 
489 __rte_experimental
490 int
491 rte_dev_dma_map(struct rte_device *dev, void *addr, uint64_t iova, size_t len);
492 
513 __rte_experimental
514 int
515 rte_dev_dma_unmap(struct rte_device *dev, void *addr, uint64_t iova,
516  size_t len);
517 
518 #endif /* _RTE_DEV_H_ */
__rte_experimental int rte_dev_event_monitor_start(void)
struct rte_device * device
Definition: rte_dev.h:256
__rte_experimental int rte_dev_hotplug_handle_enable(void)
uint64_t len
Definition: rte_dev.h:82
const char * cls_str
Definition: rte_dev.h:253
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)
void * addr
Definition: rte_dev.h:83
void * class_device
Definition: rte_dev.h:257
int rte_dev_remove(struct rte_device *dev)
struct rte_class * cls
Definition: rte_dev.h:255
__rte_experimental int rte_dev_event_callback_register(const char *device_name, rte_dev_event_cb_fn cb_fn, void *cb_arg)
rte_dev_event_type
Definition: rte_dev.h:30
int rte_dev_probe(const char *devargs)
__rte_experimental int rte_dev_event_callback_unregister(const char *device_name, rte_dev_event_cb_fn cb_fn, void *cb_arg)
TAILQ_ENTRY(rte_driver) next
uint64_t phys_addr
Definition: rte_dev.h:81
TAILQ_ENTRY(rte_device) next
int rte_eal_hotplug_add(const char *busname, const char *devname, const char *drvargs)
rte_kernel_driver
Definition: rte_dev.h:60
__rte_experimental int rte_dev_event_monitor_stop(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:254
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
__rte_experimental int rte_dev_hotplug_handle_disable(void)
const char * name
Definition: rte_dev.h:91
const char * bus_str
Definition: rte_dev.h:252
__rte_experimental void rte_dev_event_callback_process(const char *device_name, enum rte_dev_event_type event)
__rte_experimental int rte_dev_dma_unmap(struct rte_device *dev, void *addr, uint64_t iova, size_t len)
const char * name
Definition: rte_dev.h:106
const char * alias
Definition: rte_dev.h:92
const char * dev_str
Definition: rte_dev.h:251
const struct rte_driver * driver
Definition: rte_dev.h:107
__rte_experimental int rte_dev_dma_map(struct rte_device *dev, void *addr, uint64_t iova, size_t len)
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:202