1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation
11 * Launch tasks on other lcores
21 enum rte_lcore_state_t {
23 /**< waiting for new command */
25 /**< executing command */
29 * Definition of a remote launch function.
31 typedef int (lcore_function_t)(void *);
34 * Launch a function on another lcore.
36 * To be executed on the MAIN lcore only.
38 * Sends a message to a worker lcore (identified by the worker_id) that
39 * is in the WAIT state (this is true after the first call to
40 * rte_eal_init()). This can be checked by first calling
41 * rte_eal_wait_lcore(worker_id).
43 * When the remote lcore receives the message, it switches to
44 * the RUNNING state, then calls the function f with argument arg. Once the
45 * execution is done, the remote lcore switches to WAIT state and
46 * the return value of f is stored in a local variable to be read using
47 * rte_eal_wait_lcore().
49 * The MAIN lcore returns as soon as the message is sent and knows
50 * nothing about the completion of f.
52 * Note: This function is not designed to offer optimum
53 * performance. It is just a practical way to launch a function on
54 * another lcore at initialization time.
57 * The function to be called.
59 * The argument for the function.
61 * The identifier of the lcore on which the function should be executed.
63 * - 0: Success. Execution of function f started on the remote lcore.
64 * - (-EBUSY): The remote lcore is not in a WAIT state.
66 int rte_eal_remote_launch(lcore_function_t *f, void *arg, unsigned worker_id);
69 * This enum indicates whether the main core must execute the handler
70 * launched on all logical cores.
72 enum rte_rmt_call_main_t {
73 SKIP_MAIN = 0, /**< lcore handler not executed by main core. */
74 CALL_MAIN, /**< lcore handler executed by main core. */
78 * Launch a function on all lcores.
80 * Check that each WORKER lcore is in a WAIT state, then call
81 * rte_eal_remote_launch() for each lcore.
84 * The function to be called.
86 * The argument for the function.
88 * If call_main set to SKIP_MAIN, the MAIN lcore does not call
89 * the function. If call_main is set to CALL_MAIN, the function
90 * is also called on main before returning. In any case, the main
91 * lcore returns as soon as it finished its job and knows nothing
92 * about the completion of f on the other lcores.
94 * - 0: Success. Execution of function f started on all remote lcores.
95 * - (-EBUSY): At least one remote lcore is not in a WAIT state. In this
96 * case, no message is sent to any of the lcores.
98 int rte_eal_mp_remote_launch(lcore_function_t *f, void *arg,
99 enum rte_rmt_call_main_t call_main);
102 * Get the state of the lcore identified by worker_id.
104 * To be executed on the MAIN lcore only.
107 * The identifier of the lcore.
109 * The state of the lcore.
111 enum rte_lcore_state_t rte_eal_get_lcore_state(unsigned int worker_id);
114 * Wait until an lcore finishes its job.
116 * To be executed on the MAIN lcore only.
118 * If the lcore identified by the worker_id is in RUNNING state, wait until
119 * the lcore finishes its job and moves to the WAIT state.
122 * The identifier of the lcore.
124 * - 0: If the remote launch function was never called on the lcore
125 * identified by the worker_id.
126 * - The value that was returned by the previous remote launch
129 int rte_eal_wait_lcore(unsigned worker_id);
132 * Wait until all lcores finish their jobs.
134 * To be executed on the MAIN lcore only. Issue an
135 * rte_eal_wait_lcore() for every lcore. The return values are
138 * After a call to rte_eal_mp_wait_lcore(), the caller can assume
139 * that all worker lcores are in a WAIT state.
141 void rte_eal_mp_wait_lcore(void);
147 #endif /* _RTE_LAUNCH_H_ */