DPDK  22.11.6
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 
22 #include <rte_config.h>
23 #include <rte_common.h>
24 #include <rte_compat.h>
25 #include <rte_log.h>
26 
27 struct rte_bus;
28 struct rte_devargs;
29 struct rte_device;
30 struct rte_driver;
31 
39 };
40 
41 typedef void (*rte_dev_event_cb_fn)(const char *device_name,
42  enum rte_dev_event_type event,
43  void *cb_arg);
44 
45 /* Macros to check for invalid function pointers */
46 #define RTE_FUNC_PTR_OR_ERR_RET(func, retval) RTE_DEPRECATED(RTE_FUNC_PTR_OR_ERR_RET) \
47 do { \
48  if ((func) == NULL) \
49  return retval; \
50 } while (0)
51 
52 #define RTE_FUNC_PTR_OR_RET(func) RTE_DEPRECATED(RTE_FUNC_PTR_OR_RET) \
53 do { \
54  if ((func) == NULL) \
55  return; \
56 } while (0)
57 
62  RTE_DEV_ALLOWED,
63  RTE_DEV_BLOCKED,
64 };
65 
70  uint64_t phys_addr;
71  uint64_t len;
72  void *addr;
73 };
74 
83 const char *
84 rte_driver_name(const struct rte_driver *driver);
85 
94 const struct rte_bus *
95 rte_dev_bus(const struct rte_device *dev);
96 
105 const char *
106 rte_dev_bus_info(const struct rte_device *dev);
107 
116 const struct rte_devargs *
117 rte_dev_devargs(const struct rte_device *dev);
118 
127 const struct rte_driver *
128 rte_dev_driver(const struct rte_device *dev);
129 
138 const char *
139 rte_dev_name(const struct rte_device *dev);
140 
149 int
150 rte_dev_numa_node(const struct rte_device *dev);
151 
152 /*
153  * Internal identifier length
154  * Sufficiently large to allow for UUID or PCI address
155  */
156 #define RTE_DEV_NAME_MAX_LEN 64
157 
166 int rte_dev_is_probed(const struct rte_device *dev);
167 
184 int rte_eal_hotplug_add(const char *busname, const char *devname,
185  const char *drvargs);
186 
198 int rte_dev_probe(const char *devargs);
199 
213 int rte_eal_hotplug_remove(const char *busname, const char *devname);
214 
226 int rte_dev_remove(struct rte_device *dev);
227 
247 typedef int (*rte_dev_cmp_t)(const struct rte_device *dev, const void *data);
248 
249 #define RTE_PMD_EXPORT_NAME_ARRAY(n, idx) n##idx[]
250 
251 #define RTE_PMD_EXPORT_NAME(name, idx) \
252 static const char RTE_PMD_EXPORT_NAME_ARRAY(this_pmd_name, idx) \
253 __rte_used = RTE_STR(name)
254 
255 #define DRV_EXP_TAG(name, tag) __##name##_##tag
256 
257 #define RTE_PMD_REGISTER_PCI_TABLE(name, table) \
258 static const char DRV_EXP_TAG(name, pci_tbl_export)[] __rte_used = \
259 RTE_STR(table)
260 
261 #define RTE_PMD_REGISTER_PARAM_STRING(name, str) \
262 static const char DRV_EXP_TAG(name, param_string_export)[] \
263 __rte_used = str
264 
286 #define RTE_PMD_REGISTER_KMOD_DEP(name, str) \
287 static const char DRV_EXP_TAG(name, kmod_dep_export)[] \
288 __rte_used = str
289 
296  const char *dev_str;
297  const char *bus_str;
298  const char *cls_str;
299  struct rte_bus *bus;
300  struct rte_class *cls;
301  struct rte_device *device;
302  void *class_device;
303 };
304 
333 typedef void *(*rte_dev_iterate_t)(const void *start,
334  const char *devstr,
335  const struct rte_dev_iterator *it);
336 
357 __rte_experimental
358 int
359 rte_dev_iterator_init(struct rte_dev_iterator *it, const char *str);
360 
377 __rte_experimental
378 struct rte_device *
380 
381 #define RTE_DEV_FOREACH(dev, devstr, it) \
382  for (rte_dev_iterator_init(it, devstr), \
383  dev = rte_dev_iterator_next(it); \
384  dev != NULL; \
385  dev = rte_dev_iterator_next(it))
386 
406 __rte_experimental
407 int
408 rte_dev_event_callback_register(const char *device_name,
409  rte_dev_event_cb_fn cb_fn,
410  void *cb_arg);
411 
431 __rte_experimental
432 int
433 rte_dev_event_callback_unregister(const char *device_name,
434  rte_dev_event_cb_fn cb_fn,
435  void *cb_arg);
436 
449 __rte_experimental
450 void
451 rte_dev_event_callback_process(const char *device_name,
452  enum rte_dev_event_type event);
453 
464 __rte_experimental
465 int
467 
478 __rte_experimental
479 int
481 
492 __rte_experimental
493 int
495 
506 __rte_experimental
507 int
509 
530 __rte_experimental
531 int
532 rte_dev_dma_map(struct rte_device *dev, void *addr, uint64_t iova, size_t len);
533 
554 __rte_experimental
555 int
556 rte_dev_dma_unmap(struct rte_device *dev, void *addr, uint64_t iova,
557  size_t len);
558 
559 #ifdef __cplusplus
560 }
561 #endif
562 
563 #endif /* _RTE_DEV_H_ */
__rte_experimental int rte_dev_event_monitor_start(void)
struct rte_device * device
Definition: rte_dev.h:301
__rte_experimental int rte_dev_hotplug_handle_enable(void)
const struct rte_bus * rte_dev_bus(const struct rte_device *dev)
uint64_t len
Definition: rte_dev.h:71
const char * cls_str
Definition: rte_dev.h:298
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_dev_numa_node(const struct rte_device *dev)
void * addr
Definition: rte_dev.h:72
void * class_device
Definition: rte_dev.h:302
int rte_dev_remove(struct rte_device *dev)
struct rte_class * cls
Definition: rte_dev.h:300
__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:35
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)
const char * rte_dev_bus_info(const struct rte_device *dev)
uint64_t phys_addr
Definition: rte_dev.h:70
int rte_eal_hotplug_add(const char *busname, const char *devname, const char *drvargs)
const char * rte_dev_name(const struct rte_device *dev)
const struct rte_devargs * rte_dev_devargs(const struct rte_device *dev)
const struct rte_driver * rte_dev_driver(const struct rte_device *dev)
const char * rte_driver_name(const struct rte_driver *driver)
__rte_experimental int rte_dev_event_monitor_stop(void)
rte_dev_policy
Definition: rte_dev.h:61
__rte_experimental struct rte_device * rte_dev_iterator_next(struct rte_dev_iterator *it)
struct rte_bus * bus
Definition: rte_dev.h:299
int rte_eal_hotplug_remove(const char *busname, const char *devname)
__rte_experimental int rte_dev_hotplug_handle_disable(void)
const char * bus_str
Definition: rte_dev.h:297
__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 * dev_str
Definition: rte_dev.h:296
__rte_experimental int rte_dev_dma_map(struct rte_device *dev, void *addr, uint64_t iova, size_t len)
int(* rte_dev_cmp_t)(const struct rte_device *dev, const void *data)
Definition: rte_dev.h:247