DPDK 26.11.0-rc1
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
13#include <stdio.h>
14
15#include <rte_compat.h>
16#include <rte_config.h>
17#include <rte_per_lcore.h>
18#include <rte_eal.h>
19#include <rte_launch.h>
20#include <rte_thread.h>
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26#define LCORE_ID_ANY UINT32_MAX
28RTE_DECLARE_PER_LCORE(unsigned, _lcore_id);
34 RTE_LCORE_ROLE_RTE,
35 RTE_LCORE_ROLE_OFF,
36 RTE_LCORE_ROLE_SERVICE,
37 RTE_LCORE_ROLE_NON_EAL,
38};
39
40/* Old lcore role aliases for backward compatibility. */
41#define ROLE_RTE RTE_LCORE_ROLE_RTE
42#define ROLE_OFF RTE_LCORE_ROLE_OFF
43#define ROLE_SERVICE RTE_LCORE_ROLE_SERVICE
44#define ROLE_NON_EAL RTE_LCORE_ROLE_NON_EAL
45
54enum rte_lcore_role_t rte_eal_lcore_role(unsigned int lcore_id);
55
67int
68rte_lcore_has_role(unsigned int lcore_id, enum rte_lcore_role_t role);
69
83static inline unsigned
85{
86 return RTE_PER_LCORE(_lcore_id);
87}
88
95unsigned int rte_get_main_lcore(void);
96
103unsigned int rte_lcore_count(void);
104
118int rte_lcore_index(int lcore_id);
119
125unsigned int rte_socket_id(void);
126
137unsigned int
139
155int
156rte_socket_id_by_idx(unsigned int idx);
157
166unsigned int
167rte_lcore_to_socket_id(unsigned int lcore_id);
168
184__rte_experimental
185unsigned int
186rte_cpu_socket_id(unsigned int cpu_id);
187
196int rte_lcore_to_cpu_id(int lcore_id);
197
198#ifdef RTE_HAS_CPUSET
199
208rte_cpuset_t rte_lcore_cpuset(unsigned int lcore_id);
209
210#endif /* RTE_HAS_CPUSET */
211
221int rte_lcore_is_enabled(unsigned int lcore_id);
222
236unsigned int rte_get_next_lcore(unsigned int i, int skip_main, int wrap);
237
241#define RTE_LCORE_FOREACH(i) \
242 for (i = rte_get_next_lcore(-1, 0, 0); \
243 i < RTE_MAX_LCORE; \
244 i = rte_get_next_lcore(i, 0, 0))
245
249#define RTE_LCORE_FOREACH_WORKER(i) \
250 for (i = rte_get_next_lcore(-1, 1, 0); \
251 i < RTE_MAX_LCORE; \
252 i = rte_get_next_lcore(i, 1, 0))
253
265typedef int (*rte_lcore_init_cb)(unsigned int lcore_id, void *arg);
266
275typedef void (*rte_lcore_uninit_cb)(unsigned int lcore_id, void *arg);
276
305void *
307 rte_lcore_uninit_cb uninit, void *arg);
308
319void
321
333typedef int (*rte_lcore_iterate_cb)(unsigned int lcore_id, void *arg);
334
352int
354
363 uint64_t total_cycles;
368 uint64_t busy_cycles;
369};
370
384typedef int (*rte_lcore_usage_cb)(unsigned int lcore_id, struct rte_lcore_usage *usage);
385
399
406void
408
422int
424
428void
430
431#ifdef __cplusplus
432}
433#endif
434
435
436#endif /* _RTE_LCORE_H_ */
unsigned int rte_lcore_to_socket_id(unsigned int lcore_id)
void rte_lcore_callback_unregister(void *handle)
RTE_DECLARE_PER_LCORE(unsigned, _lcore_id)
unsigned int rte_lcore_count(void)
void(* rte_lcore_uninit_cb)(unsigned int lcore_id, void *arg)
Definition: rte_lcore.h:275
__rte_experimental unsigned int rte_cpu_socket_id(unsigned int cpu_id)
int rte_lcore_index(int lcore_id)
int(* rte_lcore_usage_cb)(unsigned int lcore_id, struct rte_lcore_usage *usage)
Definition: rte_lcore.h:384
rte_lcore_role_t
Definition: rte_lcore.h:33
void rte_lcore_register_usage_cb(rte_lcore_usage_cb cb)
int rte_lcore_has_role(unsigned int lcore_id, enum rte_lcore_role_t role)
int rte_lcore_is_enabled(unsigned int lcore_id)
unsigned int rte_get_main_lcore(void)
int rte_socket_id_by_idx(unsigned int idx)
void rte_lcore_dump(FILE *f)
int rte_thread_register(void)
unsigned int rte_socket_id(void)
rte_cpuset_t rte_lcore_cpuset(unsigned int lcore_id)
void * rte_lcore_callback_register(const char *name, rte_lcore_init_cb init, rte_lcore_uninit_cb uninit, void *arg)
enum rte_lcore_role_t rte_eal_lcore_role(unsigned int lcore_id)
int rte_lcore_iterate(rte_lcore_iterate_cb cb, void *arg)
int(* rte_lcore_iterate_cb)(unsigned int lcore_id, void *arg)
Definition: rte_lcore.h:333
int(* rte_lcore_init_cb)(unsigned int lcore_id, void *arg)
Definition: rte_lcore.h:265
unsigned int rte_get_next_lcore(unsigned int i, int skip_main, int wrap)
int rte_lcore_to_cpu_id(int lcore_id)
void rte_thread_unregister(void)
unsigned int rte_socket_count(void)
static unsigned rte_lcore_id(void)
Definition: rte_lcore.h:84
#define RTE_PER_LCORE(name)
Definition: rte_per_lcore.h:46
uint64_t busy_cycles
Definition: rte_lcore.h:368
uint64_t total_cycles
Definition: rte_lcore.h:363