4 * Copyright(c) 2010-2014 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.
37 /* callback function pointer when specific slave leaves */
38 typedef void (slave_exit_notify)(unsigned slaveid, int stat);
44 ST_ZOMBIE, /* Not implemented yet */
48 * Initialize the fork lib.
51 * - 0 : fork lib initialized successfully
52 * - -1 : fork lib initialized failed
57 * Check that every SLAVE lcores are in WAIT state, then call
58 * flib_remote_launch() for all of them. If call_master is true
59 * (set to CALL_MASTER), also call the function on the master lcore.
62 * function pointer need to run
64 * argument for f to carry
66 * - SKIP_MASTER : only launch function on slave lcores
67 * - CALL_MASTER : launch function on master and slave lcores
69 * - 0 : function execute successfully
70 * - -1 : function execute failed
72 int flib_mp_remote_launch(lcore_function_t *f,
73 void *arg, enum rte_rmt_call_master_t call_master);
76 * Send a message to a slave lcore identified by slave_id to call a
77 * function f with argument arg.
80 * function pointer need to run
82 * argument for f to carry
84 * slave lcore id to run on
86 * - 0 : function execute successfully
87 * - -1 : function execute failed
89 int flib_remote_launch(lcore_function_t *f,
90 void *arg, unsigned slave_id);
93 * Query the running stat for specific slave, wont' work in with master id
96 * lcore id which should not be master id
98 * - ST_FREEZE : lcore is not in enabled core mask
99 * - ST_IDLE : lcore is idle
100 * - ST_RUN : lcore is running something
103 flib_query_slave_status(unsigned slave_id);
106 * Register a callback function to be notified in case specific slave exit.
109 * lcore id which should not be master id
111 * callback pointer to register
113 * - 0 : function execute successfully
114 * - -EFAULT : argument error
115 * - -ENOENT : slave_id not correct
117 int flib_register_slave_exit_notify(unsigned slave_id,
118 slave_exit_notify *cb);
121 * Assign a lcore ID to non-slave thread. Non-slave thread refers to thread that
122 * not created by function rte_eal_remote_launch or rte_eal_mp_remote_launch.
123 * These threads can either bind lcore or float among differnt lcores.
124 * This lcore ID will be unique in multi-thread or multi-process DPDK running
125 * environment, then it can benefit from using the cache mechanism provided in
127 * After calling successfully, use rte_lcore_id() to get the assigned lcore ID, but
128 * other lcore funtions can't guarantee to work correctly.
131 * - -1 : can't assign a lcore id with 3 possibilities.
132 * - it's not non-slave thread.
133 * - it had assign a lcore id previously
134 * - the lcore id is running out.
135 * - > 0 : the assigned lcore id.
137 int flib_assign_lcore_id(void);
140 * Free the lcore_id that assigned in flib_assign_lcore_id().
141 * call it in case non-slave thread is leaving or left.
144 * The identifier of the lcore, which MUST be between 1 and
147 void flib_free_lcore_id(unsigned lcore_id);
149 #endif /* __FLIB_H */