199a2dd95SBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause 299a2dd95SBruce Richardson * Copyright(c) 2017 Intel Corporation 399a2dd95SBruce Richardson */ 499a2dd95SBruce Richardson 599a2dd95SBruce Richardson #ifndef _RTE_SERVICE_H_ 699a2dd95SBruce Richardson #define _RTE_SERVICE_H_ 799a2dd95SBruce Richardson 899a2dd95SBruce Richardson /** 999a2dd95SBruce Richardson * @file 1099a2dd95SBruce Richardson * 1199a2dd95SBruce Richardson * Service functions 1299a2dd95SBruce Richardson * 1399a2dd95SBruce Richardson * The service functionality provided by this header allows a DPDK component 1499a2dd95SBruce Richardson * to indicate that it requires a function call in order for it to perform 1599a2dd95SBruce Richardson * its processing. 1699a2dd95SBruce Richardson * 1799a2dd95SBruce Richardson * An example usage of this functionality would be a component that registers 1899a2dd95SBruce Richardson * a service to perform a particular packet processing duty: for example the 1999a2dd95SBruce Richardson * eventdev software PMD. At startup the application requests all services 2099a2dd95SBruce Richardson * that have been registered, and the cores in the service-coremask run the 2199a2dd95SBruce Richardson * required services. The EAL removes these number of cores from the available 2299a2dd95SBruce Richardson * runtime cores, and dedicates them to performing service-core workloads. The 2399a2dd95SBruce Richardson * application has access to the remaining lcores as normal. 2499a2dd95SBruce Richardson */ 2599a2dd95SBruce Richardson 2699a2dd95SBruce Richardson #include<stdio.h> 2799a2dd95SBruce Richardson #include <stdint.h> 2899a2dd95SBruce Richardson 2999a2dd95SBruce Richardson #include <rte_config.h> 3099a2dd95SBruce Richardson #include <rte_lcore.h> 3199a2dd95SBruce Richardson 32*719834a6SMattias Rönnblom #ifdef __cplusplus 33*719834a6SMattias Rönnblom extern "C" { 34*719834a6SMattias Rönnblom #endif 35*719834a6SMattias Rönnblom 3699a2dd95SBruce Richardson #define RTE_SERVICE_NAME_MAX 32 3799a2dd95SBruce Richardson 3899a2dd95SBruce Richardson /* Capabilities of a service. 3999a2dd95SBruce Richardson * 40c5bff4c5SMattias Rönnblom * Use the rte_service_probe_capability() function to check if a service is 4199a2dd95SBruce Richardson * capable of a specific capability. 4299a2dd95SBruce Richardson */ 4399a2dd95SBruce Richardson /** When set, the service is capable of having multiple threads run it at the 4499a2dd95SBruce Richardson * same time. 4599a2dd95SBruce Richardson */ 4699a2dd95SBruce Richardson #define RTE_SERVICE_CAP_MT_SAFE (1 << 0) 4799a2dd95SBruce Richardson 4899a2dd95SBruce Richardson /** 4999a2dd95SBruce Richardson * Return the number of services registered. 5099a2dd95SBruce Richardson * 5199a2dd95SBruce Richardson * @return The number of services registered. 5299a2dd95SBruce Richardson */ 5399a2dd95SBruce Richardson uint32_t rte_service_get_count(void); 5499a2dd95SBruce Richardson 5599a2dd95SBruce Richardson /** 5699a2dd95SBruce Richardson * Return the id of a service by name. 5799a2dd95SBruce Richardson * 5899a2dd95SBruce Richardson * This function provides the id of the service using the service name as 5999a2dd95SBruce Richardson * lookup key. The service id is to be passed to other functions in the 6099a2dd95SBruce Richardson * rte_service_* API. 6199a2dd95SBruce Richardson * 6299a2dd95SBruce Richardson * Example usage: 6399a2dd95SBruce Richardson * @code 6499a2dd95SBruce Richardson * uint32_t service_id; 6599a2dd95SBruce Richardson * int32_t ret = rte_service_get_by_name("service_X", &service_id); 6699a2dd95SBruce Richardson * if (ret) { 6799a2dd95SBruce Richardson * // handle error 6899a2dd95SBruce Richardson * } 6999a2dd95SBruce Richardson * @endcode 7099a2dd95SBruce Richardson * 7199a2dd95SBruce Richardson * @param name The name of the service to retrieve 7299a2dd95SBruce Richardson * @param[out] service_id A pointer to a uint32_t, to be filled in with the id. 7399a2dd95SBruce Richardson * @retval 0 Success. The service id is provided in *service_id*. 7499a2dd95SBruce Richardson * @retval -EINVAL Null *service_id* pointer provided 7599a2dd95SBruce Richardson * @retval -ENODEV No such service registered 7699a2dd95SBruce Richardson */ 7799a2dd95SBruce Richardson int32_t rte_service_get_by_name(const char *name, uint32_t *service_id); 7899a2dd95SBruce Richardson 7999a2dd95SBruce Richardson /** 8099a2dd95SBruce Richardson * Return the name of the service. 8199a2dd95SBruce Richardson * 8299a2dd95SBruce Richardson * @return A pointer to the name of the service. The returned pointer remains 8399a2dd95SBruce Richardson * in ownership of the service, and the application must not free it. 8499a2dd95SBruce Richardson */ 8599a2dd95SBruce Richardson const char *rte_service_get_name(uint32_t id); 8699a2dd95SBruce Richardson 8799a2dd95SBruce Richardson /** 8899a2dd95SBruce Richardson * Check if a service has a specific capability. 8999a2dd95SBruce Richardson * 9099a2dd95SBruce Richardson * This function returns if *service* has implements *capability*. 9199a2dd95SBruce Richardson * See RTE_SERVICE_CAP_* defines for a list of valid capabilities. 9299a2dd95SBruce Richardson * @retval 1 Capability supported by this service instance 9399a2dd95SBruce Richardson * @retval 0 Capability not supported by this service instance 9499a2dd95SBruce Richardson */ 9599a2dd95SBruce Richardson int32_t rte_service_probe_capability(uint32_t id, uint32_t capability); 9699a2dd95SBruce Richardson 9799a2dd95SBruce Richardson /** 9899a2dd95SBruce Richardson * Map or unmap a lcore to a service. 9999a2dd95SBruce Richardson * 10099a2dd95SBruce Richardson * Each core can be added or removed from running a specific service. This 10199a2dd95SBruce Richardson * function enables or disables *lcore* to run *service_id*. 10299a2dd95SBruce Richardson * 10399a2dd95SBruce Richardson * If multiple cores are enabled on a service, a lock is used to ensure that 10499a2dd95SBruce Richardson * only one core runs the service at a time. The exception to this is when 10599a2dd95SBruce Richardson * a service indicates that it is multi-thread safe by setting the capability 10699a2dd95SBruce Richardson * called RTE_SERVICE_CAP_MT_SAFE. With the multi-thread safe capability set, 10799a2dd95SBruce Richardson * the service function can be run on multiple threads at the same time. 10899a2dd95SBruce Richardson * 10999a2dd95SBruce Richardson * If the service is known to be mapped to a single lcore, setting the 11099a2dd95SBruce Richardson * capability of the service to RTE_SERVICE_CAP_MT_SAFE can achieve 11199a2dd95SBruce Richardson * better performance by avoiding the use of lock. 11299a2dd95SBruce Richardson * 11399a2dd95SBruce Richardson * @param service_id the service to apply the lcore to 11499a2dd95SBruce Richardson * @param lcore The lcore that will be mapped to service 11599a2dd95SBruce Richardson * @param enable Zero to unmap or disable the core, non-zero to enable 11699a2dd95SBruce Richardson * 11799a2dd95SBruce Richardson * @retval 0 lcore map updated successfully 11899a2dd95SBruce Richardson * @retval -EINVAL An invalid service or lcore was provided. 11999a2dd95SBruce Richardson */ 12099a2dd95SBruce Richardson int32_t rte_service_map_lcore_set(uint32_t service_id, uint32_t lcore, 12199a2dd95SBruce Richardson uint32_t enable); 12299a2dd95SBruce Richardson 12399a2dd95SBruce Richardson /** 12499a2dd95SBruce Richardson * Retrieve the mapping of an lcore to a service. 12599a2dd95SBruce Richardson * 12699a2dd95SBruce Richardson * @param service_id the service to apply the lcore to 12799a2dd95SBruce Richardson * @param lcore The lcore that will be mapped to service 12899a2dd95SBruce Richardson * 12999a2dd95SBruce Richardson * @retval 1 lcore is mapped to service 13099a2dd95SBruce Richardson * @retval 0 lcore is not mapped to service 13199a2dd95SBruce Richardson * @retval -EINVAL An invalid service or lcore was provided. 13299a2dd95SBruce Richardson */ 13399a2dd95SBruce Richardson int32_t rte_service_map_lcore_get(uint32_t service_id, uint32_t lcore); 13499a2dd95SBruce Richardson 13599a2dd95SBruce Richardson /** 13699a2dd95SBruce Richardson * Set the runstate of the service. 13799a2dd95SBruce Richardson * 13899a2dd95SBruce Richardson * Each service is either running or stopped. Setting a non-zero runstate 13999a2dd95SBruce Richardson * enables the service to run, while setting runstate zero disables it. 14099a2dd95SBruce Richardson * 14199a2dd95SBruce Richardson * @param id The id of the service 14299a2dd95SBruce Richardson * @param runstate The run state to apply to the service 14399a2dd95SBruce Richardson * 14499a2dd95SBruce Richardson * @retval 0 The service was successfully started 14599a2dd95SBruce Richardson * @retval -EINVAL Invalid service id 14699a2dd95SBruce Richardson */ 14799a2dd95SBruce Richardson int32_t rte_service_runstate_set(uint32_t id, uint32_t runstate); 14899a2dd95SBruce Richardson 14999a2dd95SBruce Richardson /** 150c5bff4c5SMattias Rönnblom * Get the runstate for the service with *id*. See rte_service_runstate_set() 15199a2dd95SBruce Richardson * for details of runstates. A service can call this function to ensure that 15299a2dd95SBruce Richardson * the application has indicated that it will receive CPU cycles. Either a 15399a2dd95SBruce Richardson * service-core is mapped (default case), or the application has explicitly 15499a2dd95SBruce Richardson * disabled the check that a service-cores is mapped to the service and takes 15599a2dd95SBruce Richardson * responsibility to run the service manually using the available function 156c5bff4c5SMattias Rönnblom * rte_service_run_iter_on_app_lcore() to do so. 15799a2dd95SBruce Richardson * 15899a2dd95SBruce Richardson * @retval 1 Service is running 15999a2dd95SBruce Richardson * @retval 0 Service is stopped 16099a2dd95SBruce Richardson * @retval -EINVAL Invalid service id 16199a2dd95SBruce Richardson */ 16299a2dd95SBruce Richardson int32_t rte_service_runstate_get(uint32_t id); 16399a2dd95SBruce Richardson 16499a2dd95SBruce Richardson /** 16599a2dd95SBruce Richardson * This function returns whether the service may be currently executing on 16699a2dd95SBruce Richardson * at least one lcore, or definitely is not. This function can be used to 16799a2dd95SBruce Richardson * determine if, after setting the service runstate to stopped, the service 16899a2dd95SBruce Richardson * is still executing a service lcore. 16999a2dd95SBruce Richardson * 17099a2dd95SBruce Richardson * Care must be taken if calling this function when the service runstate is 17199a2dd95SBruce Richardson * running, since the result of this function may be incorrect by the time the 17299a2dd95SBruce Richardson * function returns due to service cores running in parallel. 17399a2dd95SBruce Richardson * 17499a2dd95SBruce Richardson * @retval 1 Service may be running on one or more lcores 17599a2dd95SBruce Richardson * @retval 0 Service is not running on any lcore 17699a2dd95SBruce Richardson * @retval -EINVAL Invalid service id 17799a2dd95SBruce Richardson */ 17899a2dd95SBruce Richardson int32_t 17999a2dd95SBruce Richardson rte_service_may_be_active(uint32_t id); 18099a2dd95SBruce Richardson 18199a2dd95SBruce Richardson /** 18299a2dd95SBruce Richardson * Enable or disable the check for a service-core being mapped to the service. 18399a2dd95SBruce Richardson * An application can disable the check when takes the responsibility to run a 184c5bff4c5SMattias Rönnblom * service itself using rte_service_run_iter_on_app_lcore(). 18599a2dd95SBruce Richardson * 18699a2dd95SBruce Richardson * @param id The id of the service to set the check on 18799a2dd95SBruce Richardson * @param enable When zero, the check is disabled. Non-zero enables the check. 18899a2dd95SBruce Richardson * 18999a2dd95SBruce Richardson * @retval 0 Success 19099a2dd95SBruce Richardson * @retval -EINVAL Invalid service ID 19199a2dd95SBruce Richardson */ 19299a2dd95SBruce Richardson int32_t rte_service_set_runstate_mapped_check(uint32_t id, int32_t enable); 19399a2dd95SBruce Richardson 19499a2dd95SBruce Richardson /** 19599a2dd95SBruce Richardson * This function runs a service callback from a non-service lcore. 19699a2dd95SBruce Richardson * 19799a2dd95SBruce Richardson * This function is designed to enable gradual porting to service cores, and 19899a2dd95SBruce Richardson * to enable unit tests to verify a service behaves as expected. 19999a2dd95SBruce Richardson * 20099a2dd95SBruce Richardson * When called, this function ensures that the service identified by *id* is 20199a2dd95SBruce Richardson * safe to run on this lcore. Multi-thread safe services are invoked even if 20299a2dd95SBruce Richardson * other cores are simultaneously running them as they are multi-thread safe. 20399a2dd95SBruce Richardson * 20499a2dd95SBruce Richardson * Multi-thread unsafe services are handled depending on the variable 20599a2dd95SBruce Richardson * *serialize_multithread_unsafe*: 20699a2dd95SBruce Richardson * - When set, the function will check if a service is already being invoked 20799a2dd95SBruce Richardson * on another lcore, refusing to run it and returning -EBUSY. 20899a2dd95SBruce Richardson * - When zero, the application takes responsibility to ensure that the service 20999a2dd95SBruce Richardson * indicated by *id* is not going to be invoked by another lcore. This setting 21099a2dd95SBruce Richardson * avoids atomic operations, so is likely to be more performant. 21199a2dd95SBruce Richardson * 21299a2dd95SBruce Richardson * @param id The ID of the service to run 21399a2dd95SBruce Richardson * @param serialize_multithread_unsafe This parameter indicates to the service 21499a2dd95SBruce Richardson * cores library if it is required to use atomics to serialize access 21599a2dd95SBruce Richardson * to mult-thread unsafe services. As there is an overhead in using 21699a2dd95SBruce Richardson * atomics, applications can choose to enable or disable this feature 21799a2dd95SBruce Richardson * 21899a2dd95SBruce Richardson * Note that any thread calling this function MUST be a DPDK EAL thread, as 219c5bff4c5SMattias Rönnblom * the rte_lcore_id() function is used to access internal data structures. 22099a2dd95SBruce Richardson * 22199a2dd95SBruce Richardson * @retval 0 Service was run on the calling thread successfully 22299a2dd95SBruce Richardson * @retval -EBUSY Another lcore is executing the service, and it is not a 22399a2dd95SBruce Richardson * multi-thread safe service, so the service was not run on this lcore 22499a2dd95SBruce Richardson * @retval -ENOEXEC Service is not in a run-able state 22599a2dd95SBruce Richardson * @retval -EINVAL Invalid service id 22699a2dd95SBruce Richardson */ 22799a2dd95SBruce Richardson int32_t rte_service_run_iter_on_app_lcore(uint32_t id, 22899a2dd95SBruce Richardson uint32_t serialize_multithread_unsafe); 22999a2dd95SBruce Richardson 23099a2dd95SBruce Richardson /** 23199a2dd95SBruce Richardson * Start a service core. 23299a2dd95SBruce Richardson * 23399a2dd95SBruce Richardson * Starting a core makes the core begin polling. Any services assigned to it 23499a2dd95SBruce Richardson * will be run as fast as possible. The application must ensure that the lcore 235c5bff4c5SMattias Rönnblom * is in a launchable state: e.g. call rte_eal_lcore_wait() on the lcore_id 23699a2dd95SBruce Richardson * before calling this function. 23799a2dd95SBruce Richardson * 23899a2dd95SBruce Richardson * @retval 0 Success 23999a2dd95SBruce Richardson * @retval -EINVAL Failed to start core. The *lcore_id* passed in is not 24099a2dd95SBruce Richardson * currently assigned to be a service core. 24199a2dd95SBruce Richardson */ 24299a2dd95SBruce Richardson int32_t rte_service_lcore_start(uint32_t lcore_id); 24399a2dd95SBruce Richardson 24499a2dd95SBruce Richardson /** 24599a2dd95SBruce Richardson * Stop a service core. 24699a2dd95SBruce Richardson * 24799a2dd95SBruce Richardson * Stopping a core makes the core become idle, but remains assigned as a 24899a2dd95SBruce Richardson * service core. Note that the service lcore thread may not have returned from 24999a2dd95SBruce Richardson * the service it is running when this API returns. 25099a2dd95SBruce Richardson * 251c5bff4c5SMattias Rönnblom * The rte_service_lcore_may_be_active() API can be used to check if the 25299a2dd95SBruce Richardson * service lcore is * still active. 25399a2dd95SBruce Richardson * 25499a2dd95SBruce Richardson * @retval 0 Success 25599a2dd95SBruce Richardson * @retval -EINVAL Invalid *lcore_id* provided 25699a2dd95SBruce Richardson * @retval -EALREADY Already stopped core 25799a2dd95SBruce Richardson * @retval -EBUSY Failed to stop core, as it would cause a service to not 25899a2dd95SBruce Richardson * be run, as this is the only core currently running the service. 25999a2dd95SBruce Richardson * The application must stop the service first, and then stop the 26099a2dd95SBruce Richardson * lcore. 26199a2dd95SBruce Richardson */ 26299a2dd95SBruce Richardson int32_t rte_service_lcore_stop(uint32_t lcore_id); 26399a2dd95SBruce Richardson 26499a2dd95SBruce Richardson /** 26599a2dd95SBruce Richardson * Reports if a service lcore is currently running. 26699a2dd95SBruce Richardson * 26799a2dd95SBruce Richardson * This function returns if the core has finished service cores code, and has 268c5bff4c5SMattias Rönnblom * returned to EAL control. If rte_service_lcore_stop() has been called but 26999a2dd95SBruce Richardson * the lcore has not returned to EAL yet, it might be required to wait and call 27099a2dd95SBruce Richardson * this function again. The amount of time to wait before the core returns 27199a2dd95SBruce Richardson * depends on the duration of the services being run. 27299a2dd95SBruce Richardson * 27399a2dd95SBruce Richardson * @retval 0 Service thread is not active, and lcore has been returned to EAL. 27499a2dd95SBruce Richardson * @retval 1 Service thread is in the service core polling loop. 27599a2dd95SBruce Richardson * @retval -EINVAL Invalid *lcore_id* provided. 27699a2dd95SBruce Richardson */ 27799a2dd95SBruce Richardson int32_t rte_service_lcore_may_be_active(uint32_t lcore_id); 27899a2dd95SBruce Richardson 27999a2dd95SBruce Richardson /** 28099a2dd95SBruce Richardson * Adds lcore to the list of service cores. 28199a2dd95SBruce Richardson * 28299a2dd95SBruce Richardson * This functions can be used at runtime in order to modify the service core 28399a2dd95SBruce Richardson * mask. 28499a2dd95SBruce Richardson * 28599a2dd95SBruce Richardson * @retval 0 Success 28699a2dd95SBruce Richardson * @retval -EBUSY lcore is busy, and not available for service core duty 28799a2dd95SBruce Richardson * @retval -EALREADY lcore is already added to the service core list 28899a2dd95SBruce Richardson * @retval -EINVAL Invalid lcore provided 28999a2dd95SBruce Richardson */ 29099a2dd95SBruce Richardson int32_t rte_service_lcore_add(uint32_t lcore); 29199a2dd95SBruce Richardson 29299a2dd95SBruce Richardson /** 29399a2dd95SBruce Richardson * Removes lcore from the list of service cores. 29499a2dd95SBruce Richardson * 295c5bff4c5SMattias Rönnblom * This can fail if the core is not stopped, see rte_service_core_stop(). 29699a2dd95SBruce Richardson * 29799a2dd95SBruce Richardson * @retval 0 Success 29899a2dd95SBruce Richardson * @retval -EBUSY Lcore is not stopped, stop service core before removing. 29999a2dd95SBruce Richardson * @retval -EINVAL failed to add lcore to service core mask. 30099a2dd95SBruce Richardson */ 30199a2dd95SBruce Richardson int32_t rte_service_lcore_del(uint32_t lcore); 30299a2dd95SBruce Richardson 30399a2dd95SBruce Richardson /** 30499a2dd95SBruce Richardson * Retrieve the number of service cores currently available. 30599a2dd95SBruce Richardson * 30699a2dd95SBruce Richardson * This function returns the integer count of service cores available. The 30799a2dd95SBruce Richardson * service core count can be used in mapping logic when creating mappings 30899a2dd95SBruce Richardson * from service cores to services. 30999a2dd95SBruce Richardson * 310c5bff4c5SMattias Rönnblom * See rte_service_lcore_list() for details on retrieving the lcore_id of each 31199a2dd95SBruce Richardson * service core. 31299a2dd95SBruce Richardson * 31399a2dd95SBruce Richardson * @return The number of service cores currently configured. 31499a2dd95SBruce Richardson */ 31599a2dd95SBruce Richardson int32_t rte_service_lcore_count(void); 31699a2dd95SBruce Richardson 31799a2dd95SBruce Richardson /** 31899a2dd95SBruce Richardson * Resets all service core mappings. This does not remove the service cores 31999a2dd95SBruce Richardson * from duty, just unmaps all services / cores, and stops() the service cores. 32099a2dd95SBruce Richardson * The runstate of services is not modified. 32199a2dd95SBruce Richardson * 322f6c6c686SHonnappa Nagarahalli * The cores that are stopped with this call, are in WAIT state. 32399a2dd95SBruce Richardson * 32499a2dd95SBruce Richardson * @retval 0 Success 32599a2dd95SBruce Richardson */ 32699a2dd95SBruce Richardson int32_t rte_service_lcore_reset_all(void); 32799a2dd95SBruce Richardson 32899a2dd95SBruce Richardson /** 32999a2dd95SBruce Richardson * Enable or disable statistics collection for *service*. 33099a2dd95SBruce Richardson * 33199a2dd95SBruce Richardson * This function enables per core, per-service cycle count collection. 33299a2dd95SBruce Richardson * @param id The service to enable statistics gathering on. 33399a2dd95SBruce Richardson * @param enable Zero to disable statistics, non-zero to enable. 33499a2dd95SBruce Richardson * @retval 0 Success 33599a2dd95SBruce Richardson * @retval -EINVAL Invalid service pointer passed 33699a2dd95SBruce Richardson */ 33799a2dd95SBruce Richardson int32_t rte_service_set_stats_enable(uint32_t id, int32_t enable); 33899a2dd95SBruce Richardson 33999a2dd95SBruce Richardson /** 34099a2dd95SBruce Richardson * Retrieve the list of currently enabled service cores. 34199a2dd95SBruce Richardson * 34299a2dd95SBruce Richardson * This function fills in an application supplied array, with each element 34399a2dd95SBruce Richardson * indicating the lcore_id of a service core. 34499a2dd95SBruce Richardson * 34599a2dd95SBruce Richardson * Adding and removing service cores can be performed using 346c5bff4c5SMattias Rönnblom * rte_service_lcore_add() and rte_service_lcore_del(). 347c5bff4c5SMattias Rönnblom * @param [out] array An array of at least rte_service_lcore_count() items. 34899a2dd95SBruce Richardson * If statically allocating the buffer, use RTE_MAX_LCORE. 34999a2dd95SBruce Richardson * @param [out] n The size of *array*. 35099a2dd95SBruce Richardson * @retval >=0 Number of service cores that have been populated in the array 35199a2dd95SBruce Richardson * @retval -ENOMEM The provided array is not large enough to fill in the 35299a2dd95SBruce Richardson * service core list. No items have been populated, call this function 353c5bff4c5SMattias Rönnblom * with a size of at least rte_service_core_count() items. 35499a2dd95SBruce Richardson */ 35599a2dd95SBruce Richardson int32_t rte_service_lcore_list(uint32_t array[], uint32_t n); 35699a2dd95SBruce Richardson 35799a2dd95SBruce Richardson /** 35899a2dd95SBruce Richardson * Get the number of services running on the supplied lcore. 35999a2dd95SBruce Richardson * 36099a2dd95SBruce Richardson * @param lcore Id of the service core. 36199a2dd95SBruce Richardson * @retval >=0 Number of services registered to this core. 36299a2dd95SBruce Richardson * @retval -EINVAL Invalid lcore provided 36399a2dd95SBruce Richardson * @retval -ENOTSUP The provided lcore is not a service core. 36499a2dd95SBruce Richardson */ 36599a2dd95SBruce Richardson int32_t rte_service_lcore_count_services(uint32_t lcore); 36699a2dd95SBruce Richardson 36799a2dd95SBruce Richardson /** 36899a2dd95SBruce Richardson * Dumps any information available about the service. When id is UINT32_MAX, 36999a2dd95SBruce Richardson * this function dumps info for all services. 37099a2dd95SBruce Richardson * 37199a2dd95SBruce Richardson * @retval 0 Statistics have been successfully dumped 37299a2dd95SBruce Richardson * @retval -EINVAL Invalid service id provided 37399a2dd95SBruce Richardson */ 37499a2dd95SBruce Richardson int32_t rte_service_dump(FILE *f, uint32_t id); 37599a2dd95SBruce Richardson 37699a2dd95SBruce Richardson /** 377a37e053bSMattias Rönnblom * Returns the number of cycles that this service has consumed. Only 378a37e053bSMattias Rönnblom * cycles spent in non-idle calls (i.e., calls not returning -EAGAIN) 379a37e053bSMattias Rönnblom * count. 38099a2dd95SBruce Richardson */ 38199a2dd95SBruce Richardson #define RTE_SERVICE_ATTR_CYCLES 0 38299a2dd95SBruce Richardson 38399a2dd95SBruce Richardson /** 384a37e053bSMattias Rönnblom * Returns the total number of invocations of this service function 385a37e053bSMattias Rönnblom * (regardless of return value). 38699a2dd95SBruce Richardson */ 38799a2dd95SBruce Richardson #define RTE_SERVICE_ATTR_CALL_COUNT 1 38899a2dd95SBruce Richardson 38999a2dd95SBruce Richardson /** 390a37e053bSMattias Rönnblom * Returns the number of invocations of this service function where the 391a37e053bSMattias Rönnblom * service reported having not performed any useful work (i.e., 392a37e053bSMattias Rönnblom * returned -EAGAIN). 393a37e053bSMattias Rönnblom */ 394a37e053bSMattias Rönnblom #define RTE_SERVICE_ATTR_IDLE_CALL_COUNT 2 395a37e053bSMattias Rönnblom 396a37e053bSMattias Rönnblom /** 397a37e053bSMattias Rönnblom * Returns the number of invocations of this service function where the 398a37e053bSMattias Rönnblom * service reported an error (i.e., the return value was neither 0 nor 399a37e053bSMattias Rönnblom * -EAGAIN). 400a37e053bSMattias Rönnblom */ 401a37e053bSMattias Rönnblom #define RTE_SERVICE_ATTR_ERROR_CALL_COUNT 3 402a37e053bSMattias Rönnblom 403a37e053bSMattias Rönnblom /** 40499a2dd95SBruce Richardson * Get an attribute from a service. 40599a2dd95SBruce Richardson * 40699a2dd95SBruce Richardson * @retval 0 Success, the attribute value has been written to *attr_value*. 40799a2dd95SBruce Richardson * -EINVAL Invalid id, attr_id or attr_value was NULL. 40899a2dd95SBruce Richardson */ 40999a2dd95SBruce Richardson int32_t rte_service_attr_get(uint32_t id, uint32_t attr_id, 41099a2dd95SBruce Richardson uint64_t *attr_value); 41199a2dd95SBruce Richardson 41299a2dd95SBruce Richardson /** 41399a2dd95SBruce Richardson * Reset all attribute values of a service. 41499a2dd95SBruce Richardson * 41599a2dd95SBruce Richardson * @param id The service to reset all statistics of 41699a2dd95SBruce Richardson * @retval 0 Successfully reset attributes 41799a2dd95SBruce Richardson * -EINVAL Invalid service id provided 41899a2dd95SBruce Richardson */ 41999a2dd95SBruce Richardson int32_t rte_service_attr_reset_all(uint32_t id); 42099a2dd95SBruce Richardson 42199a2dd95SBruce Richardson /** 42299a2dd95SBruce Richardson * Returns the number of times the service runner has looped. 42399a2dd95SBruce Richardson */ 42499a2dd95SBruce Richardson #define RTE_SERVICE_LCORE_ATTR_LOOPS 0 42599a2dd95SBruce Richardson 42699a2dd95SBruce Richardson /** 427b54ade8fSMattias Rönnblom * Returns the total number of cycles that the lcore has spent on 428a37e053bSMattias Rönnblom * running services. Only non-idle calls (i.e., calls not returning 429a37e053bSMattias Rönnblom * -EAGAIN) count toward this total. 430b54ade8fSMattias Rönnblom */ 431b54ade8fSMattias Rönnblom #define RTE_SERVICE_LCORE_ATTR_CYCLES 1 432b54ade8fSMattias Rönnblom 433b54ade8fSMattias Rönnblom /** 43499a2dd95SBruce Richardson * Get an attribute from a service core. 43599a2dd95SBruce Richardson * 43699a2dd95SBruce Richardson * @param lcore Id of the service core. 43799a2dd95SBruce Richardson * @param attr_id Id of the attribute to be retrieved. 43899a2dd95SBruce Richardson * @param [out] attr_value Pointer to storage in which to write retrieved value. 43999a2dd95SBruce Richardson * @retval 0 Success, the attribute value has been written to *attr_value*. 44099a2dd95SBruce Richardson * -EINVAL Invalid lcore, attr_id or attr_value was NULL. 44199a2dd95SBruce Richardson * -ENOTSUP lcore is not a service core. 44299a2dd95SBruce Richardson */ 44399a2dd95SBruce Richardson int32_t 44499a2dd95SBruce Richardson rte_service_lcore_attr_get(uint32_t lcore, uint32_t attr_id, 44599a2dd95SBruce Richardson uint64_t *attr_value); 44699a2dd95SBruce Richardson 44799a2dd95SBruce Richardson /** 44899a2dd95SBruce Richardson * Reset all attribute values of a service core. 44999a2dd95SBruce Richardson * 45099a2dd95SBruce Richardson * @param lcore The service core to reset all the statistics of 45199a2dd95SBruce Richardson * @retval 0 Successfully reset attributes 45299a2dd95SBruce Richardson * -EINVAL Invalid service id provided 45399a2dd95SBruce Richardson * -ENOTSUP lcore is not a service core. 45499a2dd95SBruce Richardson */ 45599a2dd95SBruce Richardson int32_t 45699a2dd95SBruce Richardson rte_service_lcore_attr_reset_all(uint32_t lcore); 45799a2dd95SBruce Richardson 45899a2dd95SBruce Richardson #ifdef __cplusplus 45999a2dd95SBruce Richardson } 46099a2dd95SBruce Richardson #endif 46199a2dd95SBruce Richardson 46299a2dd95SBruce Richardson 46399a2dd95SBruce Richardson #endif /* _RTE_SERVICE_H_ */ 464