]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /*- |
2 | * BSD LICENSE | |
3 | * | |
4 | * Copyright(c) 2010-2014 Intel Corporation. All rights reserved. | |
5 | * All rights reserved. | |
6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | |
10 | * | |
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 | |
16 | * distribution. | |
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. | |
20 | * | |
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. | |
32 | */ | |
33 | ||
34 | #ifndef _RTE_LAUNCH_H_ | |
35 | #define _RTE_LAUNCH_H_ | |
36 | ||
37 | /** | |
38 | * @file | |
39 | * | |
40 | * Launch tasks on other lcores | |
41 | */ | |
42 | ||
43 | #ifdef __cplusplus | |
44 | extern "C" { | |
45 | #endif | |
46 | ||
47 | /** | |
48 | * State of an lcore. | |
49 | */ | |
50 | enum rte_lcore_state_t { | |
51 | WAIT, /**< waiting a new command */ | |
52 | RUNNING, /**< executing command */ | |
53 | FINISHED, /**< command executed */ | |
54 | }; | |
55 | ||
56 | /** | |
57 | * Definition of a remote launch function. | |
58 | */ | |
59 | typedef int (lcore_function_t)(void *); | |
60 | ||
61 | /** | |
62 | * Launch a function on another lcore. | |
63 | * | |
64 | * To be executed on the MASTER lcore only. | |
65 | * | |
66 | * Sends a message to a slave lcore (identified by the slave_id) that | |
67 | * is in the WAIT state (this is true after the first call to | |
68 | * rte_eal_init()). This can be checked by first calling | |
69 | * rte_eal_wait_lcore(slave_id). | |
70 | * | |
71 | * When the remote lcore receives the message, it switches to | |
72 | * the RUNNING state, then calls the function f with argument arg. Once the | |
73 | * execution is done, the remote lcore switches to a FINISHED state and | |
74 | * the return value of f is stored in a local variable to be read using | |
75 | * rte_eal_wait_lcore(). | |
76 | * | |
77 | * The MASTER lcore returns as soon as the message is sent and knows | |
78 | * nothing about the completion of f. | |
79 | * | |
80 | * Note: This function is not designed to offer optimum | |
81 | * performance. It is just a practical way to launch a function on | |
82 | * another lcore at initialization time. | |
83 | * | |
84 | * @param f | |
85 | * The function to be called. | |
86 | * @param arg | |
87 | * The argument for the function. | |
88 | * @param slave_id | |
89 | * The identifier of the lcore on which the function should be executed. | |
90 | * @return | |
91 | * - 0: Success. Execution of function f started on the remote lcore. | |
92 | * - (-EBUSY): The remote lcore is not in a WAIT state. | |
93 | */ | |
94 | int rte_eal_remote_launch(lcore_function_t *f, void *arg, unsigned slave_id); | |
95 | ||
96 | /** | |
97 | * This enum indicates whether the master core must execute the handler | |
98 | * launched on all logical cores. | |
99 | */ | |
100 | enum rte_rmt_call_master_t { | |
101 | SKIP_MASTER = 0, /**< lcore handler not executed by master core. */ | |
102 | CALL_MASTER, /**< lcore handler executed by master core. */ | |
103 | }; | |
104 | ||
105 | /** | |
106 | * Launch a function on all lcores. | |
107 | * | |
108 | * Check that each SLAVE lcore is in a WAIT state, then call | |
109 | * rte_eal_remote_launch() for each lcore. | |
110 | * | |
111 | * @param f | |
112 | * The function to be called. | |
113 | * @param arg | |
114 | * The argument for the function. | |
115 | * @param call_master | |
116 | * If call_master set to SKIP_MASTER, the MASTER lcore does not call | |
117 | * the function. If call_master is set to CALL_MASTER, the function | |
118 | * is also called on master before returning. In any case, the master | |
119 | * lcore returns as soon as it finished its job and knows nothing | |
120 | * about the completion of f on the other lcores. | |
121 | * @return | |
122 | * - 0: Success. Execution of function f started on all remote lcores. | |
123 | * - (-EBUSY): At least one remote lcore is not in a WAIT state. In this | |
124 | * case, no message is sent to any of the lcores. | |
125 | */ | |
126 | int rte_eal_mp_remote_launch(lcore_function_t *f, void *arg, | |
127 | enum rte_rmt_call_master_t call_master); | |
128 | ||
129 | /** | |
130 | * Get the state of the lcore identified by slave_id. | |
131 | * | |
132 | * To be executed on the MASTER lcore only. | |
133 | * | |
134 | * @param slave_id | |
135 | * The identifier of the lcore. | |
136 | * @return | |
137 | * The state of the lcore. | |
138 | */ | |
139 | enum rte_lcore_state_t rte_eal_get_lcore_state(unsigned slave_id); | |
140 | ||
141 | /** | |
142 | * Wait until an lcore finishes its job. | |
143 | * | |
144 | * To be executed on the MASTER lcore only. | |
145 | * | |
146 | * If the slave lcore identified by the slave_id is in a FINISHED state, | |
147 | * switch to the WAIT state. If the lcore is in RUNNING state, wait until | |
148 | * the lcore finishes its job and moves to the FINISHED state. | |
149 | * | |
150 | * @param slave_id | |
151 | * The identifier of the lcore. | |
152 | * @return | |
153 | * - 0: If the lcore identified by the slave_id is in a WAIT state. | |
154 | * - The value that was returned by the previous remote launch | |
155 | * function call if the lcore identified by the slave_id was in a | |
156 | * FINISHED or RUNNING state. In this case, it changes the state | |
157 | * of the lcore to WAIT. | |
158 | */ | |
159 | int rte_eal_wait_lcore(unsigned slave_id); | |
160 | ||
161 | /** | |
162 | * Wait until all lcores finish their jobs. | |
163 | * | |
164 | * To be executed on the MASTER lcore only. Issue an | |
165 | * rte_eal_wait_lcore() for every lcore. The return values are | |
166 | * ignored. | |
167 | * | |
168 | * After a call to rte_eal_mp_wait_lcore(), the caller can assume | |
169 | * that all slave lcores are in a WAIT state. | |
170 | */ | |
171 | void rte_eal_mp_wait_lcore(void); | |
172 | ||
173 | #ifdef __cplusplus | |
174 | } | |
175 | #endif | |
176 | ||
177 | #endif /* _RTE_LAUNCH_H_ */ |