4 * Copyright(c) 2010-2012 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 * version: DPDK.L.1.2.3-3
36 #ifndef _RTE_LAUNCH_H_
37 #define _RTE_LAUNCH_H_
42 * Launch tasks on other lcores
52 enum rte_lcore_state_t {
53 WAIT, /**< waiting a new command */
54 RUNNING, /**< executing command */
55 FINISHED, /**< command executed */
59 * Definition of a remote launch function.
61 typedef int (lcore_function_t)(void *);
64 * Launch a function on another lcore.
66 * To be executed on the MASTER lcore only.
68 * Sends a message to a slave lcore (identified by the slave_id) that
69 * is in the WAIT state (this is true after the first call to
70 * rte_eal_init()). This can be checked by first calling
71 * rte_eal_wait_lcore(slave_id).
73 * When the remote lcore receives the message, it switches to
74 * the RUNNING state, then calls the function f with argument arg. Once the
75 * execution is done, the remote lcore switches to a FINISHED state and
76 * the return value of f is stored in a local variable to be read using
77 * rte_eal_wait_lcore().
79 * The MASTER lcore returns as soon as the message is sent and knows
80 * nothing about the completion of f.
82 * Note: This function is not designed to offer optimum
83 * performance. It is just a practical way to launch a function on
84 * another lcore at initialization time.
87 * The function to be called.
89 * The argument for the function.
91 * The identifier of the lcore on which the function should be executed.
93 * - 0: Success. Execution of function f started on the remote lcore.
94 * - (-EBUSY): The remote lcore is not in a WAIT state.
96 int rte_eal_remote_launch(lcore_function_t *f, void *arg, unsigned slave_id);
99 * This enum indicates whether the master core must execute the handler
100 * launched on all logical cores.
102 enum rte_rmt_call_master_t {
103 SKIP_MASTER = 0, /**< lcore handler not executed by master core. */
104 CALL_MASTER, /**< lcore handler executed by master core. */
108 * Launch a function on all lcores.
110 * Check that each SLAVE lcore is in a WAIT state, then call
111 * rte_eal_remote_launch() for each lcore.
114 * The function to be called.
116 * The argument for the function.
118 * If call_master set to SKIP_MASTER, the MASTER lcore does not call
119 * the function. If call_master is set to CALL_MASTER, the function
120 * is also called on master before returning. In any case, the master
121 * lcore returns as soon as it finished its job and knows nothing
122 * about the completion of f on the other lcores.
124 * - 0: Success. Execution of function f started on all remote lcores.
125 * - (-EBUSY): At least one remote lcore is not in a WAIT state. In this
126 * case, no message is sent to any of the lcores.
128 int rte_eal_mp_remote_launch(lcore_function_t *f, void *arg,
129 enum rte_rmt_call_master_t call_master);
132 * Get the state of the lcore identified by slave_id.
134 * To be executed on the MASTER lcore only.
137 * The identifier of the lcore.
139 * The state of the lcore.
141 enum rte_lcore_state_t rte_eal_get_lcore_state(unsigned slave_id);
144 * Wait until an lcore finishes its job.
146 * To be executed on the MASTER lcore only.
148 * If the slave lcore identified by the slave_id is in a FINISHED state,
149 * switch to the WAIT state. If the lcore is in RUNNING state, wait until
150 * the lcore finishes its job and moves to the FINISHED state.
153 * The identifier of the lcore.
155 * - 0: If the lcore identified by the slave_id is in a WAIT state.
156 * - The value that was returned by the previous remote launch
157 * function call if the lcore identified by the slave_id was in a
158 * FINISHED or RUNNING state. In this case, it changes the state
159 * of the lcore to WAIT.
161 int rte_eal_wait_lcore(unsigned slave_id);
164 * Wait until all lcores finish their jobs.
166 * To be executed on the MASTER lcore only. Issue an
167 * rte_eal_wait_lcore() for every lcore. The return values are
170 * After a call to rte_eal_mp_wait_lcores(), the caller can assume
171 * that all slave lcores are in a WAIT state.
173 void rte_eal_mp_wait_lcore(void);
179 #endif /* _RTE_LAUNCH_H_ */