DPDK  23.03.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 <stdio.h>
15 
16 #include <rte_compat.h>
17 #include <rte_config.h>
18 #include <rte_per_lcore.h>
19 #include <rte_eal.h>
20 #include <rte_launch.h>
21 #include <rte_thread.h>
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 #define LCORE_ID_ANY UINT32_MAX
29 RTE_DECLARE_PER_LCORE(unsigned, _lcore_id);
34 enum rte_lcore_role_t {
35  ROLE_RTE,
36  ROLE_OFF,
37  ROLE_SERVICE,
38  ROLE_NON_EAL,
39 };
40 
49 enum rte_lcore_role_t rte_eal_lcore_role(unsigned int lcore_id);
50 
62 int
63 rte_lcore_has_role(unsigned int lcore_id, enum rte_lcore_role_t role);
64 
78 static inline unsigned
80 {
81  return RTE_PER_LCORE(_lcore_id);
82 }
83 
90 unsigned int rte_get_main_lcore(void);
91 
98 unsigned int rte_lcore_count(void);
99 
114 int rte_lcore_index(int lcore_id);
115 
122 unsigned int rte_socket_id(void);
123 
134 unsigned int
135 rte_socket_count(void);
136 
151 int
152 rte_socket_id_by_idx(unsigned int idx);
153 
162 unsigned int
163 rte_lcore_to_socket_id(unsigned int lcore_id);
164 
173 int rte_lcore_to_cpu_id(int lcore_id);
174 
175 #ifdef RTE_HAS_CPUSET
176 
185 rte_cpuset_t rte_lcore_cpuset(unsigned int lcore_id);
186 
187 #endif /* RTE_HAS_CPUSET */
188 
198 int rte_lcore_is_enabled(unsigned int lcore_id);
199 
213 unsigned int rte_get_next_lcore(unsigned int i, int skip_main, int wrap);
214 
218 #define RTE_LCORE_FOREACH(i) \
219  for (i = rte_get_next_lcore(-1, 0, 0); \
220  i < RTE_MAX_LCORE; \
221  i = rte_get_next_lcore(i, 0, 0))
222 
226 #define RTE_LCORE_FOREACH_WORKER(i) \
227  for (i = rte_get_next_lcore(-1, 1, 0); \
228  i < RTE_MAX_LCORE; \
229  i = rte_get_next_lcore(i, 1, 0))
230 
242 typedef int (*rte_lcore_init_cb)(unsigned int lcore_id, void *arg);
243 
252 typedef void (*rte_lcore_uninit_cb)(unsigned int lcore_id, void *arg);
253 
282 void *
283 rte_lcore_callback_register(const char *name, rte_lcore_init_cb init,
284  rte_lcore_uninit_cb uninit, void *arg);
285 
296 void
297 rte_lcore_callback_unregister(void *handle);
298 
310 typedef int (*rte_lcore_iterate_cb)(unsigned int lcore_id, void *arg);
311 
328 int
330 
339  uint64_t total_cycles;
344  uint64_t busy_cycles;
345 };
346 
360 typedef int (*rte_lcore_usage_cb)(unsigned int lcore_id, struct rte_lcore_usage *usage);
361 
377 __rte_experimental
379 
386 void
387 rte_lcore_dump(FILE *f);
388 
401 int rte_thread_setname(pthread_t id, const char *name);
402 
416 int
417 rte_thread_register(void);
418 
422 void
424 
448 int
449 rte_ctrl_thread_create(pthread_t *thread, const char *name,
450  const pthread_attr_t *attr,
451  void *(*start_routine)(void *), void *arg);
452 
453 #ifdef __cplusplus
454 }
455 #endif
456 
457 
458 #endif /* _RTE_LCORE_H_ */
rte_lcore_role_t
Definition: rte_lcore.h:34
void(* rte_lcore_uninit_cb)(unsigned int lcore_id, void *arg)
Definition: rte_lcore.h:252
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)
uint64_t total_cycles
Definition: rte_lcore.h:339
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:242
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)
uint64_t busy_cycles
Definition: rte_lcore.h:344
int(* rte_lcore_iterate_cb)(unsigned int lcore_id, void *arg)
Definition: rte_lcore.h:310
unsigned int rte_socket_id(void)
static unsigned rte_lcore_id(void)
Definition: rte_lcore.h:79
int rte_lcore_to_cpu_id(int lcore_id)
int(* rte_lcore_usage_cb)(unsigned int lcore_id, struct rte_lcore_usage *usage)
Definition: rte_lcore.h:360
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 void rte_lcore_register_usage_cb(rte_lcore_usage_cb cb)