DPDK 21.11.9
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_compat.h>
24#include <rte_log.h>
25
33};
34
35typedef void (*rte_dev_event_cb_fn)(const char *device_name,
36 enum rte_dev_event_type event,
37 void *cb_arg);
38
39/* Macros to check for invalid function pointers */
40#define RTE_FUNC_PTR_OR_ERR_RET(func, retval) do { \
41 if ((func) == NULL) \
42 return retval; \
43} while (0)
44
45#define RTE_FUNC_PTR_OR_RET(func) do { \
46 if ((func) == NULL) \
47 return; \
48} while (0)
49
54 RTE_DEV_ALLOWED,
55 RTE_DEV_BLOCKED,
56};
57
62 uint64_t phys_addr;
63 uint64_t len;
64 void *addr;
65};
66
70struct rte_driver {
72 const char *name;
73 const char *alias;
74};
75
76/*
77 * Internal identifier length
78 * Sufficiently large to allow for UUID or PCI address
79 */
80#define RTE_DEV_NAME_MAX_LEN 64
81
85struct rte_device {
87 const char *name;
88 const struct rte_driver *driver;
89 const struct rte_bus *bus;
92};
93
102int rte_dev_is_probed(const struct rte_device *dev);
103
120int rte_eal_hotplug_add(const char *busname, const char *devname,
121 const char *drvargs);
122
134int rte_dev_probe(const char *devargs);
135
149int rte_eal_hotplug_remove(const char *busname, const char *devname);
150
162int rte_dev_remove(struct rte_device *dev);
163
183typedef int (*rte_dev_cmp_t)(const struct rte_device *dev, const void *data);
184
185#define RTE_PMD_EXPORT_NAME_ARRAY(n, idx) n##idx[]
186
187#define RTE_PMD_EXPORT_NAME(name, idx) \
188static const char RTE_PMD_EXPORT_NAME_ARRAY(this_pmd_name, idx) \
189__rte_used = RTE_STR(name)
190
191#define DRV_EXP_TAG(name, tag) __##name##_##tag
192
193#define RTE_PMD_REGISTER_PCI_TABLE(name, table) \
194static const char DRV_EXP_TAG(name, pci_tbl_export)[] __rte_used = \
195RTE_STR(table)
196
197#define RTE_PMD_REGISTER_PARAM_STRING(name, str) \
198static const char DRV_EXP_TAG(name, param_string_export)[] \
199__rte_used = str
200
222#define RTE_PMD_REGISTER_KMOD_DEP(name, str) \
223static const char DRV_EXP_TAG(name, kmod_dep_export)[] \
224__rte_used = str
225
232 const char *dev_str;
233 const char *bus_str;
234 const char *cls_str;
235 struct rte_bus *bus;
236 struct rte_class *cls;
239};
240
269typedef void *(*rte_dev_iterate_t)(const void *start,
270 const char *devstr,
271 const struct rte_dev_iterator *it);
272
293__rte_experimental
294int
295rte_dev_iterator_init(struct rte_dev_iterator *it, const char *str);
296
313__rte_experimental
314struct rte_device *
316
317#define RTE_DEV_FOREACH(dev, devstr, it) \
318 for (rte_dev_iterator_init(it, devstr), \
319 dev = rte_dev_iterator_next(it); \
320 dev != NULL; \
321 dev = rte_dev_iterator_next(it))
322
342__rte_experimental
343int
344rte_dev_event_callback_register(const char *device_name,
345 rte_dev_event_cb_fn cb_fn,
346 void *cb_arg);
347
367__rte_experimental
368int
369rte_dev_event_callback_unregister(const char *device_name,
370 rte_dev_event_cb_fn cb_fn,
371 void *cb_arg);
372
385__rte_experimental
386void
387rte_dev_event_callback_process(const char *device_name,
388 enum rte_dev_event_type event);
389
400__rte_experimental
401int
403
414__rte_experimental
415int
417
428__rte_experimental
429int
431
442__rte_experimental
443int
445
466__rte_experimental
467int
468rte_dev_dma_map(struct rte_device *dev, void *addr, uint64_t iova, size_t len);
469
490__rte_experimental
491int
492rte_dev_dma_unmap(struct rte_device *dev, void *addr, uint64_t iova,
493 size_t len);
494
495#ifdef __cplusplus
496}
497#endif
498
499#endif /* _RTE_DEV_H_ */
__rte_experimental int rte_dev_hotplug_handle_disable(void)
rte_dev_policy
Definition: rte_dev.h:53
__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)
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)
__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)
int rte_dev_remove(struct rte_device *dev)
int rte_eal_hotplug_add(const char *busname, const char *devname, const char *drvargs)
__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:183
rte_dev_event_type
Definition: rte_dev.h:29
@ RTE_DEV_EVENT_ADD
Definition: rte_dev.h:30
@ RTE_DEV_EVENT_REMOVE
Definition: rte_dev.h:31
@ RTE_DEV_EVENT_MAX
Definition: rte_dev.h:32
int rte_eal_hotplug_remove(const char *busname, const char *devname)
const char * bus_str
Definition: rte_dev.h:233
struct rte_class * cls
Definition: rte_dev.h:236
void * class_device
Definition: rte_dev.h:238
struct rte_device * device
Definition: rte_dev.h:237
struct rte_bus * bus
Definition: rte_dev.h:235
const char * cls_str
Definition: rte_dev.h:234
const char * dev_str
Definition: rte_dev.h:232
const struct rte_driver * driver
Definition: rte_dev.h:88
const char * name
Definition: rte_dev.h:87
const struct rte_bus * bus
Definition: rte_dev.h:89
RTE_TAILQ_ENTRY(rte_device) next
struct rte_devargs * devargs
Definition: rte_dev.h:91
int numa_node
Definition: rte_dev.h:90
const char * name
Definition: rte_dev.h:72
RTE_TAILQ_ENTRY(rte_driver) next
const char * alias
Definition: rte_dev.h:73
uint64_t phys_addr
Definition: rte_dev.h:62
uint64_t len
Definition: rte_dev.h:63
void * addr
Definition: rte_dev.h:64