DPDK
18.02.2
Main Page
Related Pages
Data Structures
Files
Examples
File List
Globals
lib
librte_eal
common
include
rte_lcore.h
Go to the documentation of this file.
1
/* SPDX-License-Identifier: BSD-3-Clause
2
* Copyright(c) 2010-2014 Intel Corporation
3
*/
4
5
#ifndef _RTE_LCORE_H_
6
#define _RTE_LCORE_H_
7
14
#include <rte_config.h>
15
#include <
rte_per_lcore.h
>
16
#include <
rte_eal.h
>
17
#include <
rte_launch.h
>
18
19
#ifdef __cplusplus
20
extern
"C"
{
21
#endif
22
23
#define LCORE_ID_ANY UINT32_MAX
25
#if defined(__linux__)
26
typedef
cpu_set_t rte_cpuset_t;
27
#elif defined(__FreeBSD__)
28
#include <pthread_np.h>
29
typedef
cpuset_t rte_cpuset_t;
30
#endif
31
35
struct
lcore_config
{
36
unsigned
detected
;
37
pthread_t
thread_id
;
38
int
pipe_master2slave
[2];
39
int
pipe_slave2master
[2];
40
lcore_function_t
*
volatile
f
;
41
void
*
volatile
arg
;
42
volatile
int
ret
;
43
volatile
enum
rte_lcore_state_t
state
;
44
unsigned
socket_id
;
45
unsigned
core_id
;
46
int
core_index
;
47
rte_cpuset_t
cpuset
;
48
uint8_t
core_role
;
49
};
50
54
extern
struct
lcore_config
lcore_config
[RTE_MAX_LCORE];
55
56
RTE_DECLARE_PER_LCORE
(
unsigned
, _lcore_id);
57
RTE_DECLARE_PER_LCORE
(rte_cpuset_t, _cpuset);
71
static
inline
unsigned
72
rte_lcore_id
(
void
)
73
{
74
return
RTE_PER_LCORE
(_lcore_id);
75
}
76
83
static
inline
unsigned
84
rte_get_master_lcore
(
void
)
85
{
86
return
rte_eal_get_configuration
()->
master_lcore
;
87
}
88
95
static
inline
unsigned
96
rte_lcore_count
(
void
)
97
{
98
const
struct
rte_config
*cfg =
rte_eal_get_configuration
();
99
return
cfg->
lcore_count
;
100
}
101
116
static
inline
int
117
rte_lcore_index
(
int
lcore_id)
118
{
119
if
(lcore_id >= RTE_MAX_LCORE)
120
return
-1;
121
if
(lcore_id < 0)
122
lcore_id = (int)
rte_lcore_id
();
123
return
lcore_config
[lcore_id].
core_index
;
124
}
125
132
unsigned
rte_socket_id
(
void
);
133
142
static
inline
unsigned
143
rte_lcore_to_socket_id
(
unsigned
lcore_id)
144
{
145
return
lcore_config
[lcore_id].
socket_id
;
146
}
147
157
static
inline
int
158
rte_lcore_is_enabled
(
unsigned
lcore_id)
159
{
160
struct
rte_config
*cfg =
rte_eal_get_configuration
();
161
if
(lcore_id >= RTE_MAX_LCORE)
162
return
0;
163
return
cfg->
lcore_role
[lcore_id] == ROLE_RTE;
164
}
165
179
static
inline
unsigned
180
rte_get_next_lcore
(
unsigned
i,
int
skip_master,
int
wrap)
181
{
182
i++;
183
if
(wrap)
184
i %= RTE_MAX_LCORE;
185
186
while
(i < RTE_MAX_LCORE) {
187
if
(!
rte_lcore_is_enabled
(i) ||
188
(skip_master && (i ==
rte_get_master_lcore
()))) {
189
i++;
190
if
(wrap)
191
i %= RTE_MAX_LCORE;
192
continue
;
193
}
194
break
;
195
}
196
return
i;
197
}
201
#define RTE_LCORE_FOREACH(i) \
202
for (i = rte_get_next_lcore(-1, 0, 0); \
203
i<RTE_MAX_LCORE; \
204
i = rte_get_next_lcore(i, 0, 0))
205
209
#define RTE_LCORE_FOREACH_SLAVE(i) \
210
for (i = rte_get_next_lcore(-1, 1, 0); \
211
i<RTE_MAX_LCORE; \
212
i = rte_get_next_lcore(i, 1, 0))
213
223
int
rte_thread_set_affinity
(rte_cpuset_t *cpusetp);
224
233
void
rte_thread_get_affinity
(rte_cpuset_t *cpusetp);
234
247
int
rte_thread_setname
(pthread_t
id
,
const
char
*name);
248
260
int
261
rte_lcore_has_role
(
unsigned
int
lcore_id,
enum
rte_lcore_role_t
role);
262
263
#ifdef __cplusplus
264
}
265
#endif
266
267
268
#endif
/* _RTE_LCORE_H_ */
Generated by
1.8.1.2