DPDK
18.02.2
Main Page
Related Pages
Data Structures
Files
Examples
File List
Globals
lib
librte_eal
common
include
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
27
__attribute__((format(printf, 2, 0)))
28
static inline
void
29
rte_pmd_debug_trace(const
char
*func_name, const
char
*fmt, ...)
30
{
31
va_list ap;
32
33
va_start(ap, fmt);
34
35
{
36
char
buffer[vsnprintf(NULL, 0, fmt, ap) + 1];
37
38
va_end(ap);
39
40
va_start(ap, fmt);
41
vsnprintf(buffer,
sizeof
(buffer), fmt, ap);
42
va_end(ap);
43
44
rte_log
(
RTE_LOG_ERR
,
RTE_LOGTYPE_PMD
,
"%s: %s"
,
45
func_name, buffer);
46
}
47
}
48
49
/*
50
* Enable RTE_PMD_DEBUG_TRACE() when at least one component relying on the
51
* RTE_*_RET() macros defined below is compiled in debug mode.
52
*/
53
#if defined(RTE_LIBRTE_ETHDEV_DEBUG) || \
54
defined(RTE_LIBRTE_CRYPTODEV_DEBUG) || \
55
defined(RTE_LIBRTE_EVENTDEV_DEBUG)
56
#define RTE_PMD_DEBUG_TRACE(...) \
57
rte_pmd_debug_trace(__func__, __VA_ARGS__)
58
#else
59
#define RTE_PMD_DEBUG_TRACE(...) (void)0
60
#endif
61
62
/* Macros for checking for restricting functions to primary instance only */
63
#define RTE_PROC_PRIMARY_OR_ERR_RET(retval) do { \
64
if (rte_eal_process_type() != RTE_PROC_PRIMARY) { \
65
RTE_PMD_DEBUG_TRACE("Cannot run in secondary processes\n"); \
66
return retval; \
67
} \
68
} while (0)
69
70
#define RTE_PROC_PRIMARY_OR_RET() do { \
71
if (rte_eal_process_type() != RTE_PROC_PRIMARY) { \
72
RTE_PMD_DEBUG_TRACE("Cannot run in secondary processes\n"); \
73
return; \
74
} \
75
} while (0)
76
77
/* Macros to check for invalid function pointers */
78
#define RTE_FUNC_PTR_OR_ERR_RET(func, retval) do { \
79
if ((func) == NULL) { \
80
RTE_PMD_DEBUG_TRACE("Function not supported\n"); \
81
return retval; \
82
} \
83
} while (0)
84
85
#define RTE_FUNC_PTR_OR_RET(func) do { \
86
if ((func) == NULL) { \
87
RTE_PMD_DEBUG_TRACE("Function not supported\n"); \
88
return; \
89
} \
90
} while (0)
91
95
enum
rte_kernel_driver
{
96
RTE_KDRV_UNKNOWN = 0,
97
RTE_KDRV_IGB_UIO,
98
RTE_KDRV_VFIO,
99
RTE_KDRV_UIO_GENERIC,
100
RTE_KDRV_NIC_UIO,
101
RTE_KDRV_NONE,
102
};
103
107
enum
rte_dev_policy
{
108
RTE_DEV_WHITELISTED,
109
RTE_DEV_BLACKLISTED,
110
};
111
115
struct
rte_mem_resource
{
116
uint64_t
phys_addr
;
117
uint64_t
len
;
118
void
*
addr
;
119
};
120
124
struct
rte_driver
{
125
TAILQ_ENTRY
(
rte_driver
) next;
126
const
char
*
name
;
127
const
char
*
alias
;
128
};
129
130
/*
131
* Internal identifier length
132
* Sufficiently large to allow for UUID or PCI address
133
*/
134
#define RTE_DEV_NAME_MAX_LEN 64
135
139
struct
rte_device
{
140
TAILQ_ENTRY
(
rte_device
) next;
141
const
char
*
name
;
142
const
struct
rte_driver
*
driver
;
143
int
numa_node
;
144
struct
rte_devargs
*
devargs
;
145
};
146
160
int
rte_eal_dev_attach
(
const
char
*
name
,
const
char
*devargs);
161
170
int
rte_eal_dev_detach
(
struct
rte_device
*dev);
171
188
int
__rte_experimental
rte_eal_hotplug_add
(
const
char
*busname,
const
char
*devname,
189
const
char
*devargs);
190
204
int
__rte_experimental
rte_eal_hotplug_remove
(
const
char
*busname,
205
const
char
*devname);
206
226
typedef
int (*
rte_dev_cmp_t
)(
const
struct
rte_device
*dev,
const
void
*data);
227
228
#define RTE_PMD_EXPORT_NAME_ARRAY(n, idx) n##idx[]
229
230
#define RTE_PMD_EXPORT_NAME(name, idx) \
231
static const char RTE_PMD_EXPORT_NAME_ARRAY(this_pmd_name, idx) \
232
__attribute__((used)) = RTE_STR(name)
233
234
#define DRV_EXP_TAG(name, tag) __##name##_##tag
235
236
#define RTE_PMD_REGISTER_PCI_TABLE(name, table) \
237
static const char DRV_EXP_TAG(name, pci_tbl_export)[] __attribute__((used)) = \
238
RTE_STR(table)
239
240
#define RTE_PMD_REGISTER_PARAM_STRING(name, str) \
241
static const char DRV_EXP_TAG(name, param_string_export)[] \
242
__attribute__((used)) = str
243
265
#define RTE_PMD_REGISTER_KMOD_DEP(name, str) \
266
static const char DRV_EXP_TAG(name, kmod_dep_export)[] \
267
__attribute__((used)) = str
268
269
#ifdef __cplusplus
270
}
271
#endif
272
273
#endif
/* _RTE_DEV_H_ */
Generated by
1.8.1.2