4 * Copyright(c) 2017 Intel Corporation. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
16 * * Neither the name of Intel Corporation nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #ifndef _RTE_SERVICE_PRIVATE_H_
34 #define _RTE_SERVICE_PRIVATE_H_
36 /* This file specifies the internal service specification.
37 * Include this file if you are writing a component that requires CPU cycles to
38 * operate, and you wish to run the component using service cores
41 #include <rte_service.h>
45 * @b EXPERIMENTAL: this API may change without prior notice
47 * Signature of callback function to run a service.
49 typedef int32_t (*rte_service_func)(void *args);
53 * @b EXPERIMENTAL: this API may change without prior notice
55 * The specification of a service.
57 * This struct contains metadata about the service itself, the callback
58 * function to run one iteration of the service, a userdata pointer, flags etc.
60 struct rte_service_spec {
61 /** The name of the service. This should be used by the application to
62 * understand what purpose this service provides.
64 char name[RTE_SERVICE_NAME_MAX];
65 /** The callback to invoke to run one iteration of the service. */
66 rte_service_func callback;
67 /** The userdata pointer provided to the service callback. */
68 void *callback_userdata;
69 /** Flags to indicate the capabilities of this service. See defines in
70 * the public header file for values of RTE_SERVICE_CAP_*
72 uint32_t capabilities;
73 /** NUMA socket ID that this service is affinitized to */
79 * @b EXPERIMENTAL: this API may change without prior notice
81 * Register a new service.
83 * A service represents a component that the requires CPU time periodically to
84 * achieve its purpose.
86 * For example the eventdev SW PMD requires CPU cycles to perform its
87 * scheduling. This can be achieved by registering it as a service, and the
88 * application can then assign CPU resources to it using
89 * *rte_service_set_coremask*.
91 * @param spec The specification of the service to register
92 * @param[out] service_id A pointer to a uint32_t, which will be filled in
93 * during registration of the service. It is set to the integers
94 * service number given to the service. This parameter may be NULL.
95 * @retval 0 Successfully registered the service.
96 * -EINVAL Attempted to register an invalid service (eg, no callback
99 int32_t rte_service_component_register(const struct rte_service_spec *spec,
100 uint32_t *service_id);
104 * @b EXPERIMENTAL: this API may change without prior notice
106 * Unregister a service.
108 * The service being removed must be stopped before calling this function.
110 * @retval 0 The service was successfully unregistered.
111 * @retval -EBUSY The service is currently running, stop the service before
112 * calling unregister. No action has been taken.
114 int32_t rte_service_unregister(struct rte_service_spec *service);
118 * @b EXPERIMENTAL: this API may change without prior notice
120 * Private function to allow EAL to initialized default mappings.
122 * This function iterates all the services, and maps then to the available
123 * cores. Based on the capabilities of the services, they are set to run on the
124 * available cores in a round-robin manner.
127 * @retval -ENOTSUP No service lcores in use
128 * @retval -EINVAL Error while iterating over services
129 * @retval -ENODEV Error in enabling service lcore on a service
130 * @retval -ENOEXEC Error when starting services
132 int32_t rte_service_start_with_defaults(void);
136 * @b EXPERIMENTAL: this API may change without prior notice
138 * Initialize the service library.
140 * In order to use the service library, it must be initialized. EAL initializes
141 * the library at startup.
144 * @retval -EALREADY Service library is already initialized
146 int32_t rte_service_init(void);
148 #endif /* _RTE_SERVICE_PRIVATE_H_ */