DPDK  21.05.0
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 #include <rte_thread.h>
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 #define LCORE_ID_ANY UINT32_MAX
26 RTE_DECLARE_PER_LCORE(unsigned, _lcore_id);
31 enum rte_lcore_role_t {
32  ROLE_RTE,
33  ROLE_OFF,
34  ROLE_SERVICE,
35  ROLE_NON_EAL,
36 };
37 
46 enum rte_lcore_role_t rte_eal_lcore_role(unsigned int lcore_id);
47 
59 int
60 rte_lcore_has_role(unsigned int lcore_id, enum rte_lcore_role_t role);
61 
75 static inline unsigned
77 {
78  return RTE_PER_LCORE(_lcore_id);
79 }
80 
87 unsigned int rte_get_main_lcore(void);
88 
95 __rte_deprecated
96 static inline unsigned int rte_get_master_lcore(void)
97 {
98  return rte_get_main_lcore();
99 }
100 
107 unsigned int rte_lcore_count(void);
108 
123 int rte_lcore_index(int lcore_id);
124 
131 unsigned int rte_socket_id(void);
132 
143 unsigned int
144 rte_socket_count(void);
145 
160 int
161 rte_socket_id_by_idx(unsigned int idx);
162 
171 unsigned int
172 rte_lcore_to_socket_id(unsigned int lcore_id);
173 
185 __rte_experimental
186 int
187 rte_lcore_to_cpu_id(int lcore_id);
188 
189 #ifdef RTE_HAS_CPUSET
190 
201 __rte_experimental
202 rte_cpuset_t
203 rte_lcore_cpuset(unsigned int lcore_id);
204 
205 #endif /* RTE_HAS_CPUSET */
206 
216 int rte_lcore_is_enabled(unsigned int lcore_id);
217 
231 unsigned int rte_get_next_lcore(unsigned int i, int skip_main, int wrap);
232 
236 #define RTE_LCORE_FOREACH(i) \
237  for (i = rte_get_next_lcore(-1, 0, 0); \
238  i < RTE_MAX_LCORE; \
239  i = rte_get_next_lcore(i, 0, 0))
240 
244 #define RTE_LCORE_FOREACH_WORKER(i) \
245  for (i = rte_get_next_lcore(-1, 1, 0); \
246  i < RTE_MAX_LCORE; \
247  i = rte_get_next_lcore(i, 1, 0))
248 
249 #define RTE_LCORE_FOREACH_SLAVE(l) \
250  RTE_DEPRECATED(RTE_LCORE_FOREACH_SLAVE) RTE_LCORE_FOREACH_WORKER(l)
251 
263 typedef int (*rte_lcore_init_cb)(unsigned int lcore_id, void *arg);
264 
273 typedef void (*rte_lcore_uninit_cb)(unsigned int lcore_id, void *arg);
274 
303 __rte_experimental
304 void *
305 rte_lcore_callback_register(const char *name, rte_lcore_init_cb init,
306  rte_lcore_uninit_cb uninit, void *arg);
307 
318 __rte_experimental
319 void
320 rte_lcore_callback_unregister(void *handle);
321 
333 typedef int (*rte_lcore_iterate_cb)(unsigned int lcore_id, void *arg);
334 
351 __rte_experimental
352 int
354 
361 __rte_experimental
362 void
363 rte_lcore_dump(FILE *f);
364 
377 int rte_thread_setname(pthread_t id, const char *name);
378 
393 __rte_experimental
394 int rte_thread_getname(pthread_t id, char *name, size_t len);
395 
409 __rte_experimental
410 int
411 rte_thread_register(void);
412 
416 __rte_experimental
417 void
419 
442 int
443 rte_ctrl_thread_create(pthread_t *thread, const char *name,
444  const pthread_attr_t *attr,
445  void *(*start_routine)(void *), void *arg);
446 
447 #ifdef __cplusplus
448 }
449 #endif
450 
451 
452 #endif /* _RTE_LCORE_H_ */
rte_lcore_role_t
Definition: rte_lcore.h:31
void(* rte_lcore_uninit_cb)(unsigned int lcore_id, void *arg)
Definition: rte_lcore.h:273
unsigned int rte_get_main_lcore(void)
__rte_experimental int rte_lcore_iterate(rte_lcore_iterate_cb cb, void *arg)
__rte_experimental void rte_thread_unregister(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)
static __rte_deprecated unsigned int rte_get_master_lcore(void)
Definition: rte_lcore.h:96
__rte_experimental void rte_lcore_callback_unregister(void *handle)
unsigned int rte_socket_count(void)
int(* rte_lcore_init_cb)(unsigned int lcore_id, void *arg)
Definition: rte_lcore.h:263
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_cb)(unsigned int lcore_id, void *arg)
Definition: rte_lcore.h:333
__rte_experimental void * rte_lcore_callback_register(const char *name, rte_lcore_init_cb init, rte_lcore_uninit_cb uninit, void *arg)
unsigned int rte_socket_id(void)
__rte_experimental rte_cpuset_t rte_lcore_cpuset(unsigned int lcore_id)
static unsigned rte_lcore_id(void)
Definition: rte_lcore.h:76
__rte_experimental int rte_thread_register(void)
__rte_experimental void rte_lcore_dump(FILE *f)
int rte_socket_id_by_idx(unsigned int idx)
__rte_experimental int rte_lcore_to_cpu_id(int lcore_id)
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)
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)