DPDK  24.07.0
rte_thread.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2021 Mellanox Technologies, Ltd
3  * Copyright (C) 2022 Microsoft Corporation
4  */
5 
6 #include <stdint.h>
7 
8 #include <rte_os.h>
9 #include <rte_compat.h>
10 
11 #ifndef _RTE_THREAD_H_
12 #define _RTE_THREAD_H_
13 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
27 #define RTE_THREAD_NAME_SIZE 16
28 /* Old definition, aliased for compatibility. */
29 #define RTE_MAX_THREAD_NAME_LEN RTE_THREAD_NAME_SIZE
30 
32 #define RTE_THREAD_INTERNAL_PREFIX "dpdk-"
33 
34 #define RTE_THREAD_INTERNAL_NAME_SIZE 11
35 
39 typedef struct {
40  uintptr_t opaque_id;
41 } rte_thread_t;
42 
53 typedef uint32_t (*rte_thread_func) (void *arg);
54 
63 };
64 
68 typedef struct {
69  enum rte_thread_priority priority;
70 #ifdef RTE_HAS_CPUSET
71  rte_cpuset_t cpuset;
72 #endif
74 
78 typedef struct eal_tls_key *rte_thread_key;
79 
99 int rte_thread_create(rte_thread_t *thread_id,
100  const rte_thread_attr_t *thread_attr,
101  rte_thread_func thread_func, void *arg);
102 
125 int
126 rte_thread_create_control(rte_thread_t *thread, const char *name,
127  rte_thread_func thread_func, void *arg);
128 
153 __rte_internal
154 int
156  rte_thread_func func, void *arg);
157 
171 int rte_thread_join(rte_thread_t thread_id, uint32_t *value_ptr);
172 
184 int rte_thread_detach(rte_thread_t thread_id);
185 
193 
208 void
209 rte_thread_set_name(rte_thread_t thread_id, const char *thread_name);
210 
227 __rte_internal
228 void
229 rte_thread_set_prefixed_name(rte_thread_t id, const char *name);
230 
245 
259 
275  enum rte_thread_priority priority);
276 
277 #ifdef RTE_HAS_CPUSET
278 
294  rte_cpuset_t *cpuset);
295 
311  rte_cpuset_t *cpuset);
312 
328  const rte_cpuset_t *cpuset);
329 
345  rte_cpuset_t *cpuset);
346 
356 int rte_thread_set_affinity(rte_cpuset_t *cpusetp);
357 
365 void rte_thread_get_affinity(rte_cpuset_t *cpusetp);
366 
367 #endif /* RTE_HAS_CPUSET */
368 
383  enum rte_thread_priority *priority);
384 
399  enum rte_thread_priority priority);
400 
419 int rte_thread_key_create(rte_thread_key *key,
420  void (*destructor)(void *));
421 
434 int rte_thread_key_delete(rte_thread_key key);
435 
450 int rte_thread_value_set(rte_thread_key key, const void *value);
451 
464 void *rte_thread_value_get(rte_thread_key key);
465 
466 #ifdef __cplusplus
467 }
468 #endif
469 
470 #endif /* _RTE_THREAD_H_ */
void rte_thread_set_name(rte_thread_t thread_id, const char *thread_name)
void * rte_thread_value_get(rte_thread_key key)
int rte_thread_value_set(rte_thread_key key, const void *value)
int rte_thread_equal(rte_thread_t t1, rte_thread_t t2)
__rte_internal int rte_thread_create_internal_control(rte_thread_t *id, const char *name, rte_thread_func func, void *arg)
int rte_thread_attr_set_priority(rte_thread_attr_t *thread_attr, enum rte_thread_priority priority)
int rte_thread_join(rte_thread_t thread_id, uint32_t *value_ptr)
int rte_thread_attr_set_affinity(rte_thread_attr_t *thread_attr, rte_cpuset_t *cpuset)
int rte_thread_set_priority(rte_thread_t thread_id, enum rte_thread_priority priority)
__rte_internal void rte_thread_set_prefixed_name(rte_thread_t id, const char *name)
int rte_thread_create(rte_thread_t *thread_id, const rte_thread_attr_t *thread_attr, rte_thread_func thread_func, void *arg)
int rte_thread_attr_get_affinity(rte_thread_attr_t *thread_attr, rte_cpuset_t *cpuset)
struct eal_tls_key * rte_thread_key
Definition: rte_thread.h:78
rte_thread_priority
Definition: rte_thread.h:58
rte_cpuset_t cpuset
Definition: rte_thread.h:71
int rte_thread_attr_init(rte_thread_attr_t *attr)
uintptr_t opaque_id
Definition: rte_thread.h:40
int rte_thread_set_affinity(rte_cpuset_t *cpusetp)
int rte_thread_get_priority(rte_thread_t thread_id, enum rte_thread_priority *priority)
int rte_thread_detach(rte_thread_t thread_id)
void rte_thread_get_affinity(rte_cpuset_t *cpusetp)
rte_thread_t rte_thread_self(void)
int rte_thread_key_delete(rte_thread_key key)
int rte_thread_create_control(rte_thread_t *thread, const char *name, rte_thread_func thread_func, void *arg)
uint32_t(* rte_thread_func)(void *arg)
Definition: rte_thread.h:53
int rte_thread_key_create(rte_thread_key *key, void(*destructor)(void *))
int rte_thread_set_affinity_by_id(rte_thread_t thread_id, const rte_cpuset_t *cpuset)
int rte_thread_get_affinity_by_id(rte_thread_t thread_id, rte_cpuset_t *cpuset)