DPDK  21.02.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 
199 __rte_experimental
200 rte_cpuset_t
201 rte_lcore_cpuset(unsigned int lcore_id);
202 
212 int rte_lcore_is_enabled(unsigned int lcore_id);
213 
227 unsigned int rte_get_next_lcore(unsigned int i, int skip_main, int wrap);
228 
232 #define RTE_LCORE_FOREACH(i) \
233  for (i = rte_get_next_lcore(-1, 0, 0); \
234  i < RTE_MAX_LCORE; \
235  i = rte_get_next_lcore(i, 0, 0))
236 
240 #define RTE_LCORE_FOREACH_WORKER(i) \
241  for (i = rte_get_next_lcore(-1, 1, 0); \
242  i < RTE_MAX_LCORE; \
243  i = rte_get_next_lcore(i, 1, 0))
244 
245 #define RTE_LCORE_FOREACH_SLAVE(l) \
246  RTE_DEPRECATED(RTE_LCORE_FOREACH_SLAVE) RTE_LCORE_FOREACH_WORKER(l)
247 
259 typedef int (*rte_lcore_init_cb)(unsigned int lcore_id, void *arg);
260 
269 typedef void (*rte_lcore_uninit_cb)(unsigned int lcore_id, void *arg);
270 
299 __rte_experimental
300 void *
301 rte_lcore_callback_register(const char *name, rte_lcore_init_cb init,
302  rte_lcore_uninit_cb uninit, void *arg);
303 
314 __rte_experimental
315 void
316 rte_lcore_callback_unregister(void *handle);
317 
329 typedef int (*rte_lcore_iterate_cb)(unsigned int lcore_id, void *arg);
330 
347 __rte_experimental
348 int
350 
357 __rte_experimental
358 void
359 rte_lcore_dump(FILE *f);
360 
373 int rte_thread_setname(pthread_t id, const char *name);
374 
389 __rte_experimental
390 int rte_thread_getname(pthread_t id, char *name, size_t len);
391 
405 __rte_experimental
406 int
407 rte_thread_register(void);
408 
412 __rte_experimental
413 void
415 
438 int
439 rte_ctrl_thread_create(pthread_t *thread, const char *name,
440  const pthread_attr_t *attr,
441  void *(*start_routine)(void *), void *arg);
442 
443 #ifdef __cplusplus
444 }
445 #endif
446 
447 
448 #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:269
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:259
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:329
__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)