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 * @retval 0 Successfully registered the service.
93 * -EINVAL Attempted to register an invalid service (eg, no callback
96 int32_t rte_service_register(const struct rte_service_spec *spec);
100 * @b EXPERIMENTAL: this API may change without prior notice
102 * Unregister a service.
104 * The service being removed must be stopped before calling this function.
106 * @retval 0 The service was successfully unregistered.
107 * @retval -EBUSY The service is currently running, stop the service before
108 * calling unregister. No action has been taken.
110 int32_t rte_service_unregister(struct rte_service_spec *service);
114 * @b EXPERIMENTAL: this API may change without prior notice
116 * Private function to allow EAL to initialized default mappings.
118 * This function iterates all the services, and maps then to the available
119 * cores. Based on the capabilities of the services, they are set to run on the
120 * available cores in a round-robin manner.
123 * @retval -ENOTSUP No service lcores in use
124 * @retval -EINVAL Error while iterating over services
125 * @retval -ENODEV Error in enabling service lcore on a service
126 * @retval -ENOEXEC Error when starting services
128 int32_t rte_service_start_with_defaults(void);
132 * @b EXPERIMENTAL: this API may change without prior notice
134 * Initialize the service library.
136 * In order to use the service library, it must be initialized. EAL initializes
137 * the library at startup.
140 * @retval -EALREADY Service library is already initialized
142 int32_t rte_service_init(void);
144 #endif /* _RTE_SERVICE_PRIVATE_H_ */