DPDK  19.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 __attribute__((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)[] __attribute__((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 __attribute__((used)) = str
219 
241 #define RTE_PMD_REGISTER_KMOD_DEP(name, str) \
242 static const char DRV_EXP_TAG(name, kmod_dep_export)[] \
243 __attribute__((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 int __rte_experimental
366 rte_dev_event_callback_register(const char *device_name,
367  rte_dev_event_cb_fn cb_fn,
368  void *cb_arg);
369 
389 int __rte_experimental
390 rte_dev_event_callback_unregister(const char *device_name,
391  rte_dev_event_cb_fn cb_fn,
392  void *cb_arg);
393 
406 void __rte_experimental
407 rte_dev_event_callback_process(const char *device_name,
408  enum rte_dev_event_type event);
409 
420 int __rte_experimental
422 
433 int __rte_experimental
435 
446 int __rte_experimental
448 
459 int __rte_experimental
461 
482 int __rte_experimental
483 rte_dev_dma_map(struct rte_device *dev, void *addr, uint64_t iova, size_t len);
484 
505 int __rte_experimental
506 rte_dev_dma_unmap(struct rte_device *dev, void *addr, uint64_t iova,
507  size_t len);
508 
509 #endif /* _RTE_DEV_H_ */