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 {
22 WAIT, /**< waiting a new command */
23 RUNNING, /**< executing command */
24 FINISHED, /**< command executed */
28 * Definition of a remote launch function.
30 typedef int (lcore_function_t)(void *);
33 * Launch a function on another lcore.
35 * To be executed on the MASTER lcore only.
37 * Sends a message to a slave lcore (identified by the slave_id) that
38 * is in the WAIT state (this is true after the first call to
39 * rte_eal_init()). This can be checked by first calling
40 * rte_eal_wait_lcore(slave_id).
42 * When the remote lcore receives the message, it switches to
43 * the RUNNING state, then calls the function f with argument arg. Once the
44 * execution is done, the remote lcore switches to a FINISHED state and
45 * the return value of f is stored in a local variable to be read using
46 * rte_eal_wait_lcore().
48 * The MASTER lcore returns as soon as the message is sent and knows
49 * nothing about the completion of f.
51 * Note: This function is not designed to offer optimum
52 * performance. It is just a practical way to launch a function on
53 * another lcore at initialization time.
56 * The function to be called.
58 * The argument for the function.
60 * The identifier of the lcore on which the function should be executed.
62 * - 0: Success. Execution of function f started on the remote lcore.
63 * - (-EBUSY): The remote lcore is not in a WAIT state.
65 int rte_eal_remote_launch(lcore_function_t *f, void *arg, unsigned slave_id);
68 * This enum indicates whether the master core must execute the handler
69 * launched on all logical cores.
71 enum rte_rmt_call_master_t {
72 SKIP_MASTER = 0, /**< lcore handler not executed by master core. */
73 CALL_MASTER, /**< lcore handler executed by master core. */
77 * Launch a function on all lcores.
79 * Check that each SLAVE lcore is in a WAIT state, then call
80 * rte_eal_remote_launch() for each lcore.
83 * The function to be called.
85 * The argument for the function.
87 * If call_master set to SKIP_MASTER, the MASTER lcore does not call
88 * the function. If call_master is set to CALL_MASTER, the function
89 * is also called on master before returning. In any case, the master
90 * lcore returns as soon as it finished its job and knows nothing
91 * about the completion of f on the other lcores.
93 * - 0: Success. Execution of function f started on all remote lcores.
94 * - (-EBUSY): At least one remote lcore is not in a WAIT state. In this
95 * case, no message is sent to any of the lcores.
97 int rte_eal_mp_remote_launch(lcore_function_t *f, void *arg,
98 enum rte_rmt_call_master_t call_master);
101 * Get the state of the lcore identified by slave_id.
103 * To be executed on the MASTER lcore only.
106 * The identifier of the lcore.
108 * The state of the lcore.
110 enum rte_lcore_state_t rte_eal_get_lcore_state(unsigned slave_id);
113 * Wait until an lcore finishes its job.
115 * To be executed on the MASTER lcore only.
117 * If the slave lcore identified by the slave_id is in a FINISHED state,
118 * switch to the WAIT state. If the lcore is in RUNNING state, wait until
119 * the lcore finishes its job and moves to the FINISHED state.
122 * The identifier of the lcore.
124 * - 0: If the lcore identified by the slave_id is in a WAIT state.
125 * - The value that was returned by the previous remote launch
126 * function call if the lcore identified by the slave_id was in a
127 * FINISHED or RUNNING state. In this case, it changes the state
128 * of the lcore to WAIT.
130 int rte_eal_wait_lcore(unsigned slave_id);
133 * Wait until all lcores finish their jobs.
135 * To be executed on the MASTER lcore only. Issue an
136 * rte_eal_wait_lcore() for every lcore. The return values are
139 * After a call to rte_eal_mp_wait_lcore(), the caller can assume
140 * that all slave lcores are in a WAIT state.
142 void rte_eal_mp_wait_lcore(void);
148 #endif /* _RTE_LAUNCH_H_ */