DPDK  20.11.3
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 typedef void (*rte_dev_event_cb_fn)(const char *device_name,
37  enum rte_dev_event_type event,
38  void *cb_arg);
39 
40 /* Macros to check for invalid function pointers */
41 #define RTE_FUNC_PTR_OR_ERR_RET(func, retval) do { \
42  if ((func) == NULL) \
43  return retval; \
44 } while (0)
45 
46 #define RTE_FUNC_PTR_OR_RET(func) do { \
47  if ((func) == NULL) \
48  return; \
49 } while (0)
50 
55  RTE_DEV_ALLOWED,
56  RTE_DEV_BLOCKED,
57 };
58 
59 /* Backwards compatibility will be removed */
60 #define RTE_DEV_WHITELISTED \
61  RTE_DEPRECATED(RTE_DEV_WHITELISTED) RTE_DEV_ALLOWED
62 #define RTE_DEV_BLACKLISTED \
63  RTE_DEPRECATED(RTE_DEV_BLACKLISTED) RTE_DEV_BLOCKED
64 
69  uint64_t phys_addr;
70  uint64_t len;
71  void *addr;
72 };
73 
77 struct rte_driver {
78  TAILQ_ENTRY(rte_driver) next;
79  const char *name;
80  const char *alias;
81 };
82 
83 /*
84  * Internal identifier length
85  * Sufficiently large to allow for UUID or PCI address
86  */
87 #define RTE_DEV_NAME_MAX_LEN 64
88 
92 struct rte_device {
93  TAILQ_ENTRY(rte_device) next;
94  const char *name;
95  const struct rte_driver *driver;
96  const struct rte_bus *bus;
97  int numa_node;
98  struct rte_devargs *devargs;
99 };
100 
109 int rte_dev_is_probed(const struct rte_device *dev);
110 
127 int rte_eal_hotplug_add(const char *busname, const char *devname,
128  const char *drvargs);
129 
141 int rte_dev_probe(const char *devargs);
142 
156 int rte_eal_hotplug_remove(const char *busname, const char *devname);
157 
169 int rte_dev_remove(struct rte_device *dev);
170 
190 typedef int (*rte_dev_cmp_t)(const struct rte_device *dev, const void *data);
191 
192 #define RTE_PMD_EXPORT_NAME_ARRAY(n, idx) n##idx[]
193 
194 #define RTE_PMD_EXPORT_NAME(name, idx) \
195 static const char RTE_PMD_EXPORT_NAME_ARRAY(this_pmd_name, idx) \
196 __rte_used = RTE_STR(name)
197 
198 #define DRV_EXP_TAG(name, tag) __##name##_##tag
199 
200 #define RTE_PMD_REGISTER_PCI_TABLE(name, table) \
201 static const char DRV_EXP_TAG(name, pci_tbl_export)[] __rte_used = \
202 RTE_STR(table)
203 
204 #define RTE_PMD_REGISTER_PARAM_STRING(name, str) \
205 static const char DRV_EXP_TAG(name, param_string_export)[] \
206 __rte_used = str
207 
229 #define RTE_PMD_REGISTER_KMOD_DEP(name, str) \
230 static const char DRV_EXP_TAG(name, kmod_dep_export)[] \
231 __rte_used = str
232 
239  const char *dev_str;
240  const char *bus_str;
241  const char *cls_str;
242  struct rte_bus *bus;
243  struct rte_class *cls;
244  struct rte_device *device;
245  void *class_device;
246 };
247 
276 typedef void *(*rte_dev_iterate_t)(const void *start,
277  const char *devstr,
278  const struct rte_dev_iterator *it);
279 
300 __rte_experimental
301 int
302 rte_dev_iterator_init(struct rte_dev_iterator *it, const char *str);
303 
320 __rte_experimental
321 struct rte_device *
323 
324 #define RTE_DEV_FOREACH(dev, devstr, it) \
325  for (rte_dev_iterator_init(it, devstr), \
326  dev = rte_dev_iterator_next(it); \
327  dev != NULL; \
328  dev = rte_dev_iterator_next(it))
329 
330 #ifdef __cplusplus
331 }
332 #endif
333 
353 __rte_experimental
354 int
355 rte_dev_event_callback_register(const char *device_name,
356  rte_dev_event_cb_fn cb_fn,
357  void *cb_arg);
358 
378 __rte_experimental
379 int
380 rte_dev_event_callback_unregister(const char *device_name,
381  rte_dev_event_cb_fn cb_fn,
382  void *cb_arg);
383 
396 __rte_experimental
397 void
398 rte_dev_event_callback_process(const char *device_name,
399  enum rte_dev_event_type event);
400 
411 __rte_experimental
412 int
414 
425 __rte_experimental
426 int
428 
439 __rte_experimental
440 int
442 
453 __rte_experimental
454 int
456 
477 __rte_experimental
478 int
479 rte_dev_dma_map(struct rte_device *dev, void *addr, uint64_t iova, size_t len);
480 
501 __rte_experimental
502 int
503 rte_dev_dma_unmap(struct rte_device *dev, void *addr, uint64_t iova,
504  size_t len);
505 
506 #endif /* _RTE_DEV_H_ */
__rte_experimental int rte_dev_event_monitor_start(void)
struct rte_device * device
Definition: rte_dev.h:244
__rte_experimental int rte_dev_hotplug_handle_enable(void)
uint64_t len
Definition: rte_dev.h:70
const char * cls_str
Definition: rte_dev.h:241
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:71
void * class_device
Definition: rte_dev.h:245
int rte_dev_remove(struct rte_device *dev)
struct rte_class * cls
Definition: rte_dev.h:243
__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)
uint64_t phys_addr
Definition: rte_dev.h:69
int rte_eal_hotplug_add(const char *busname, const char *devname, const char *drvargs)
__rte_experimental int rte_dev_event_monitor_stop(void)
rte_dev_policy
Definition: rte_dev.h:54
__rte_experimental struct rte_device * rte_dev_iterator_next(struct rte_dev_iterator *it)
struct rte_bus * bus
Definition: rte_dev.h:242
struct rte_devargs * devargs
Definition: rte_dev.h:98
int rte_eal_hotplug_remove(const char *busname, const char *devname)
int numa_node
Definition: rte_dev.h:97
__rte_experimental int rte_dev_hotplug_handle_disable(void)
const char * name
Definition: rte_dev.h:79
const char * bus_str
Definition: rte_dev.h:240
__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:94
const char * alias
Definition: rte_dev.h:80
const char * dev_str
Definition: rte_dev.h:239
const struct rte_driver * driver
Definition: rte_dev.h:95
__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:96
int(* rte_dev_cmp_t)(const struct rte_device *dev, const void *data)
Definition: rte_dev.h:190