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
17extern "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
27struct rte_bus;
28struct rte_devargs;
29struct rte_device;
30struct rte_driver;
31
39};
40
41typedef 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) \
47do { \
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) \
53do { \
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
83const char *
84rte_driver_name(const struct rte_driver *driver);
85
94const struct rte_bus *
95rte_dev_bus(const struct rte_device *dev);
96
105const char *
106rte_dev_bus_info(const struct rte_device *dev);
107
116const struct rte_devargs *
117rte_dev_devargs(const struct rte_device *dev);
118
127const struct rte_driver *
128rte_dev_driver(const struct rte_device *dev);
129
138const char *
139rte_dev_name(const struct rte_device *dev);
140
149int
150rte_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
166int rte_dev_is_probed(const struct rte_device *dev);
167
184int rte_eal_hotplug_add(const char *busname, const char *devname,
185 const char *drvargs);
186
198int rte_dev_probe(const char *devargs);
199
213int rte_eal_hotplug_remove(const char *busname, const char *devname);
214
226int rte_dev_remove(struct rte_device *dev);
227
247typedef 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) \
252static 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) \
258static const char DRV_EXP_TAG(name, pci_tbl_export)[] __rte_used = \
259RTE_STR(table)
260
261#define RTE_PMD_REGISTER_PARAM_STRING(name, str) \
262static const char DRV_EXP_TAG(name, param_string_export)[] \
263__rte_used = str
264
286#define RTE_PMD_REGISTER_KMOD_DEP(name, str) \
287static 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;
303};
304
333typedef void *(*rte_dev_iterate_t)(const void *start,
334 const char *devstr,
335 const struct rte_dev_iterator *it);
336
357__rte_experimental
358int
359rte_dev_iterator_init(struct rte_dev_iterator *it, const char *str);
360
377__rte_experimental
378struct 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
407int
408rte_dev_event_callback_register(const char *device_name,
409 rte_dev_event_cb_fn cb_fn,
410 void *cb_arg);
411
431__rte_experimental
432int
433rte_dev_event_callback_unregister(const char *device_name,
434 rte_dev_event_cb_fn cb_fn,
435 void *cb_arg);
436
449__rte_experimental
450void
451rte_dev_event_callback_process(const char *device_name,
452 enum rte_dev_event_type event);
453
464__rte_experimental
465int
467
478__rte_experimental
479int
481
492__rte_experimental
493int
495
506__rte_experimental
507int
509
530__rte_experimental
531int
532rte_dev_dma_map(struct rte_device *dev, void *addr, uint64_t iova, size_t len);
533
554__rte_experimental
555int
556rte_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_hotplug_handle_disable(void)
rte_dev_policy
Definition: rte_dev.h:61
__rte_experimental int rte_dev_iterator_init(struct rte_dev_iterator *it, const char *str)
__rte_experimental int rte_dev_event_monitor_start(void)
__rte_experimental int rte_dev_event_monitor_stop(void)
__rte_experimental void rte_dev_event_callback_process(const char *device_name, enum rte_dev_event_type event)
int rte_dev_is_probed(const struct rte_device *dev)
const struct rte_driver * rte_dev_driver(const struct rte_device *dev)
int rte_dev_probe(const char *devargs)
const char * rte_dev_name(const struct rte_device *dev)
__rte_experimental int rte_dev_event_callback_unregister(const char *device_name, rte_dev_event_cb_fn cb_fn, void *cb_arg)
const struct rte_bus * rte_dev_bus(const struct rte_device *dev)
__rte_experimental int rte_dev_dma_map(struct rte_device *dev, void *addr, uint64_t iova, size_t len)
__rte_experimental int rte_dev_hotplug_handle_enable(void)
__rte_experimental struct rte_device * rte_dev_iterator_next(struct rte_dev_iterator *it)
__rte_experimental int rte_dev_event_callback_register(const char *device_name, rte_dev_event_cb_fn cb_fn, void *cb_arg)
const char * rte_driver_name(const struct rte_driver *driver)
int rte_dev_remove(struct rte_device *dev)
int rte_eal_hotplug_add(const char *busname, const char *devname, const char *drvargs)
int rte_dev_numa_node(const struct rte_device *dev)
const char * rte_dev_bus_info(const struct rte_device *dev)
const struct rte_devargs * rte_dev_devargs(const struct rte_device *dev)
__rte_experimental int rte_dev_dma_unmap(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
rte_dev_event_type
Definition: rte_dev.h:35
@ RTE_DEV_EVENT_ADD
Definition: rte_dev.h:36
@ RTE_DEV_EVENT_REMOVE
Definition: rte_dev.h:37
@ RTE_DEV_EVENT_MAX
Definition: rte_dev.h:38
int rte_eal_hotplug_remove(const char *busname, const char *devname)
const char * bus_str
Definition: rte_dev.h:297
struct rte_class * cls
Definition: rte_dev.h:300
void * class_device
Definition: rte_dev.h:302
struct rte_device * device
Definition: rte_dev.h:301
struct rte_bus * bus
Definition: rte_dev.h:299
const char * cls_str
Definition: rte_dev.h:298
const char * dev_str
Definition: rte_dev.h:296
uint64_t phys_addr
Definition: rte_dev.h:70
uint64_t len
Definition: rte_dev.h:71
void * addr
Definition: rte_dev.h:72