1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2010-2014 Intel Corporation 3 */ 4 5 #ifndef EAL_THREAD_H 6 #define EAL_THREAD_H 7 8 #include <rte_common.h> 9 #include <rte_lcore.h> 10 11 /** 12 * Basic loop of EAL thread, called for each worker thread by rte_eal_init(). 13 * 14 * @param arg 15 * The lcore_id (passed as an integer) of this worker thread. 16 */ 17 __rte_noreturn uint32_t eal_thread_loop(void *arg); 18 19 /** 20 * Get the NUMA socket id from cpu id. 21 * This function is private to EAL. 22 * 23 * @param cpu_id 24 * The logical process id. 25 * @return 26 * socket_id or SOCKET_ID_ANY 27 */ 28 unsigned eal_cpu_socket_id(unsigned cpu_id); 29 30 /** 31 * Default buffer size to use with eal_thread_dump_affinity() 32 */ 33 #define RTE_CPU_AFFINITY_STR_LEN 256 34 35 /** 36 * Dump the cpuset as a human readable string. 37 * This function is private to EAL. 38 * 39 * Note: 40 * If the dump size is greater than the size of given buffer, 41 * the string will be truncated and with '\0' at the end. 42 * 43 * @param cpuset 44 * The CPU affinity object to dump. 45 * @param str 46 * The string buffer the cpuset will dump to. 47 * @param size 48 * The string buffer size. 49 * @return 50 * 0 for success, -1 if truncation happens. 51 */ 52 int 53 eal_thread_dump_affinity(rte_cpuset_t *cpuset, char *str, unsigned int size); 54 55 /** 56 * Dump the current thread cpuset. 57 * This is a wrapper on eal_thread_dump_affinity(). 58 */ 59 int 60 eal_thread_dump_current_affinity(char *str, unsigned int size); 61 62 /** 63 * Called by the main thread to wake up a worker in 'WAIT' state. 64 * This function blocks until the worker acknowledge it started processing a 65 * new command. 66 * This function is private to EAL. 67 * 68 * @param worker_id 69 * The lcore_id of a worker thread. 70 * @return 71 * 0 on success, negative errno on error 72 */ 73 int 74 eal_thread_wake_worker(unsigned int worker_id); 75 76 /** 77 * Called by a worker thread to sleep after entering 'WAIT' state. 78 * This function is private to EAL. 79 */ 80 void 81 eal_thread_wait_command(void); 82 83 /** 84 * Called by a worker thread to acknowledge new command after leaving 'WAIT' 85 * state. 86 * This function is private to EAL. 87 */ 88 void 89 eal_thread_ack_command(void); 90 91 #endif /* EAL_THREAD_H */ 92