DPDK  22.11.0-rc0
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 <stdio.h>
15 
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
23 extern "C" {
24 #endif
25 
26 #define LCORE_ID_ANY UINT32_MAX
28 RTE_DECLARE_PER_LCORE(unsigned, _lcore_id);
33 enum rte_lcore_role_t {
34  ROLE_RTE,
35  ROLE_OFF,
36  ROLE_SERVICE,
37  ROLE_NON_EAL,
38 };
39 
48 enum rte_lcore_role_t rte_eal_lcore_role(unsigned int lcore_id);
49 
61 int
62 rte_lcore_has_role(unsigned int lcore_id, enum rte_lcore_role_t role);
63 
77 static inline unsigned
79 {
80  return RTE_PER_LCORE(_lcore_id);
81 }
82 
89 unsigned int rte_get_main_lcore(void);
90 
97 unsigned int rte_lcore_count(void);
98 
113 int rte_lcore_index(int lcore_id);
114 
121 unsigned int rte_socket_id(void);
122 
133 unsigned int
134 rte_socket_count(void);
135 
150 int
151 rte_socket_id_by_idx(unsigned int idx);
152 
161 unsigned int
162 rte_lcore_to_socket_id(unsigned int lcore_id);
163 
172 int rte_lcore_to_cpu_id(int lcore_id);
173 
174 #ifdef RTE_HAS_CPUSET
175 
184 rte_cpuset_t rte_lcore_cpuset(unsigned int lcore_id);
185 
186 #endif /* RTE_HAS_CPUSET */
187 
197 int rte_lcore_is_enabled(unsigned int lcore_id);
198 
212 unsigned int rte_get_next_lcore(unsigned int i, int skip_main, int wrap);
213 
217 #define RTE_LCORE_FOREACH(i) \
218  for (i = rte_get_next_lcore(-1, 0, 0); \
219  i < RTE_MAX_LCORE; \
220  i = rte_get_next_lcore(i, 0, 0))
221 
225 #define RTE_LCORE_FOREACH_WORKER(i) \
226  for (i = rte_get_next_lcore(-1, 1, 0); \
227  i < RTE_MAX_LCORE; \
228  i = rte_get_next_lcore(i, 1, 0))
229 
241 typedef int (*rte_lcore_init_cb)(unsigned int lcore_id, void *arg);
242 
251 typedef void (*rte_lcore_uninit_cb)(unsigned int lcore_id, void *arg);
252 
281 void *
282 rte_lcore_callback_register(const char *name, rte_lcore_init_cb init,
283  rte_lcore_uninit_cb uninit, void *arg);
284 
295 void
296 rte_lcore_callback_unregister(void *handle);
297 
309 typedef int (*rte_lcore_iterate_cb)(unsigned int lcore_id, void *arg);
310 
327 int
329 
336 void
337 rte_lcore_dump(FILE *f);
338 
351 int rte_thread_setname(pthread_t id, const char *name);
352 
367 __rte_experimental
368 int rte_thread_getname(pthread_t id, char *name, size_t len);
369 
383 int
384 rte_thread_register(void);
385 
389 void
391 
415 int
416 rte_ctrl_thread_create(pthread_t *thread, const char *name,
417  const pthread_attr_t *attr,
418  void *(*start_routine)(void *), void *arg);
419 
420 #ifdef __cplusplus
421 }
422 #endif
423 
424 
425 #endif /* _RTE_LCORE_H_ */
rte_lcore_role_t
Definition: rte_lcore.h:33
void(* rte_lcore_uninit_cb)(unsigned int lcore_id, void *arg)
Definition: rte_lcore.h:251
unsigned int rte_get_main_lcore(void)
int rte_thread_setname(pthread_t id, const char *name)
unsigned int rte_lcore_count(void)
int rte_lcore_has_role(unsigned int lcore_id, enum rte_lcore_role_t role)
unsigned int rte_socket_count(void)
void rte_lcore_callback_unregister(void *handle)
void rte_thread_unregister(void)
rte_cpuset_t rte_lcore_cpuset(unsigned int lcore_id)
int(* rte_lcore_init_cb)(unsigned int lcore_id, void *arg)
Definition: rte_lcore.h:241
unsigned int rte_get_next_lcore(unsigned int i, int skip_main, int wrap)
unsigned int rte_lcore_to_socket_id(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:309
unsigned int rte_socket_id(void)
static unsigned rte_lcore_id(void)
Definition: rte_lcore.h:78
int rte_lcore_to_cpu_id(int lcore_id)
int rte_socket_id_by_idx(unsigned int idx)
void * rte_lcore_callback_register(const char *name, rte_lcore_init_cb init, rte_lcore_uninit_cb uninit, void *arg)
int rte_thread_register(void)
int rte_lcore_index(int lcore_id)
int rte_ctrl_thread_create(pthread_t *thread, const char *name, const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg)
void rte_lcore_dump(FILE *f)
int rte_lcore_is_enabled(unsigned int lcore_id)
#define RTE_PER_LCORE(name)
Definition: rte_per_lcore.h:44
enum rte_lcore_role_t rte_eal_lcore_role(unsigned int lcore_id)
__rte_experimental int rte_thread_getname(pthread_t id, char *name, size_t len)