DPDK  20.11.10
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 RTE_DECLARE_PER_LCORE(unsigned, _lcore_id);
30 enum rte_lcore_role_t {
31  ROLE_RTE,
32  ROLE_OFF,
33  ROLE_SERVICE,
34  ROLE_NON_EAL,
35 };
36 
45 enum rte_lcore_role_t rte_eal_lcore_role(unsigned int lcore_id);
46 
58 int
59 rte_lcore_has_role(unsigned int lcore_id, enum rte_lcore_role_t role);
60 
74 static inline unsigned
76 {
77  return RTE_PER_LCORE(_lcore_id);
78 }
79 
86 unsigned int rte_get_main_lcore(void);
87 
94 __rte_deprecated
95 static inline unsigned int rte_get_master_lcore(void)
96 {
97  return rte_get_main_lcore();
98 }
99 
106 unsigned int rte_lcore_count(void);
107 
122 int rte_lcore_index(int lcore_id);
123 
130 unsigned int rte_socket_id(void);
131 
142 unsigned int
143 rte_socket_count(void);
144 
159 int
160 rte_socket_id_by_idx(unsigned int idx);
161 
170 unsigned int
171 rte_lcore_to_socket_id(unsigned int lcore_id);
172 
184 __rte_experimental
185 int
186 rte_lcore_to_cpu_id(int lcore_id);
187 
188 #ifdef RTE_HAS_CPUSET
189 
200 __rte_experimental
201 rte_cpuset_t
202 rte_lcore_cpuset(unsigned int lcore_id);
203 
204 #endif /* RTE_HAS_CPUSET */
205 
215 int rte_lcore_is_enabled(unsigned int lcore_id);
216 
230 unsigned int rte_get_next_lcore(unsigned int i, int skip_main, int wrap);
231 
235 #define RTE_LCORE_FOREACH(i) \
236  for (i = rte_get_next_lcore(-1, 0, 0); \
237  i < RTE_MAX_LCORE; \
238  i = rte_get_next_lcore(i, 0, 0))
239 
243 #define RTE_LCORE_FOREACH_WORKER(i) \
244  for (i = rte_get_next_lcore(-1, 1, 0); \
245  i < RTE_MAX_LCORE; \
246  i = rte_get_next_lcore(i, 1, 0))
247 
248 #define RTE_LCORE_FOREACH_SLAVE(l) \
249  RTE_DEPRECATED(RTE_LCORE_FOREACH_SLAVE) RTE_LCORE_FOREACH_WORKER(l)
250 
262 typedef int (*rte_lcore_init_cb)(unsigned int lcore_id, void *arg);
263 
272 typedef void (*rte_lcore_uninit_cb)(unsigned int lcore_id, void *arg);
273 
302 __rte_experimental
303 void *
304 rte_lcore_callback_register(const char *name, rte_lcore_init_cb init,
305  rte_lcore_uninit_cb uninit, void *arg);
306 
317 __rte_experimental
318 void
319 rte_lcore_callback_unregister(void *handle);
320 
332 typedef int (*rte_lcore_iterate_cb)(unsigned int lcore_id, void *arg);
333 
350 __rte_experimental
351 int
353 
360 __rte_experimental
361 void
362 rte_lcore_dump(FILE *f);
363 
364 #ifdef RTE_HAS_CPUSET
365 
375 int rte_thread_set_affinity(rte_cpuset_t *cpusetp);
376 
385 void rte_thread_get_affinity(rte_cpuset_t *cpusetp);
386 
387 #endif /* RTE_HAS_CPUSET */
388 
401 int rte_thread_setname(pthread_t id, const char *name);
402 
417 __rte_experimental
418 int rte_thread_getname(pthread_t id, char *name, size_t len);
419 
433 __rte_experimental
434 int
435 rte_thread_register(void);
436 
440 __rte_experimental
441 void
443 
466 int
467 rte_ctrl_thread_create(pthread_t *thread, const char *name,
468  const pthread_attr_t *attr,
469  void *(*start_routine)(void *), void *arg);
470 
471 #ifdef __cplusplus
472 }
473 #endif
474 
475 
476 #endif /* _RTE_LCORE_H_ */
rte_lcore_role_t
Definition: rte_lcore.h:30
void(* rte_lcore_uninit_cb)(unsigned int lcore_id, void *arg)
Definition: rte_lcore.h:272
void rte_thread_get_affinity(rte_cpuset_t *cpusetp)
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:95
__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:262
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:332
__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:75
__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)
int rte_thread_set_affinity(rte_cpuset_t *cpusetp)
__rte_experimental int rte_thread_getname(pthread_t id, char *name, size_t len)