DPDK  17.08.2
Macros | Functions
rte_service.h File Reference
#include <stdio.h>
#include <stdint.h>
#include <sys/queue.h>
#include <rte_lcore.h>

Go to the source code of this file.

Macros

#define RTE_SERVICE_CAP_MT_SAFE   (1 << 0)

Functions

uint32_t rte_service_get_count (void)
struct rte_service_specrte_service_get_by_id (uint32_t id)
struct rte_service_specrte_service_get_by_name (const char *name)
const char * rte_service_get_name (const struct rte_service_spec *service)
int32_t rte_service_probe_capability (const struct rte_service_spec *service, uint32_t capability)
int32_t rte_service_enable_on_lcore (struct rte_service_spec *service, uint32_t lcore)
int32_t rte_service_disable_on_lcore (struct rte_service_spec *service, uint32_t lcore)
int32_t rte_service_get_enabled_on_lcore (struct rte_service_spec *service, uint32_t lcore)
int32_t rte_service_start (struct rte_service_spec *service)
int32_t rte_service_stop (struct rte_service_spec *service)
int32_t rte_service_is_running (const struct rte_service_spec *service)
int32_t rte_service_lcore_start (uint32_t lcore_id)
int32_t rte_service_lcore_stop (uint32_t lcore_id)
int32_t rte_service_lcore_add (uint32_t lcore)
int32_t rte_service_lcore_del (uint32_t lcore)
int32_t rte_service_lcore_count (void)
int32_t rte_service_lcore_reset_all (void)
int32_t rte_service_set_stats_enable (struct rte_service_spec *service, int32_t enable)
int32_t rte_service_lcore_list (uint32_t array[], uint32_t n)
int32_t rte_service_dump (FILE *f, struct rte_service_spec *service)

Detailed Description

Service functions

The service functionality provided by this header allows a DPDK component to indicate that it requires a function call in order for it to perform its processing.

An example usage of this functionality would be a component that registers a service to perform a particular packet processing duty: for example the eventdev software PMD. At startup the application requests all services that have been registered, and the cores in the service-coremask run the required services. The EAL removes these number of cores from the available runtime cores, and dedicates them to performing service-core workloads. The application has access to the remaining lcores as normal.

Definition in file rte_service.h.

Macro Definition Documentation

#define RTE_SERVICE_CAP_MT_SAFE   (1 << 0)

When set, the service is capable of having multiple threads run it at the same time.

Definition at line 77 of file rte_service.h.

Function Documentation

uint32_t rte_service_get_count ( void  )
Warning
EXPERIMENTAL: this API may change without prior notice

Return the number of services registered.

The number of services registered can be passed to rte_service_get_by_id, enabling the application to retrieve the specification of each service.

Returns
The number of services registered.
struct rte_service_spec* rte_service_get_by_id ( uint32_t  id)
read
Warning
EXPERIMENTAL: this API may change without prior notice

Return the specification of a service by integer id.

This function provides the specification of a service. This can be used by the application to understand what the service represents. The service must not be modified by the application directly, only passed to the various rte_service_* functions.

Parameters
idThe integer id of the service to retrieve
Return values
non-zeroA valid pointer to the service_spec
NULLInvalid id provided.
struct rte_service_spec* rte_service_get_by_name ( const char *  name)
read
Warning
EXPERIMENTAL: this API may change without prior notice

Return the specification of a service by name.

This function provides the specification of a service using the service name as lookup key. This can be used by the application to understand what the service represents. The service must not be modified by the application directly, only passed to the various rte_service_* functions.

Parameters
nameThe name of the service to retrieve
Return values
non-zeroA valid pointer to the service_spec
NULLInvalid name provided.
const char* rte_service_get_name ( const struct rte_service_spec service)
Warning
EXPERIMENTAL: this API may change without prior notice

Return the name of the service.

Returns
A pointer to the name of the service. The returned pointer remains in ownership of the service, and the application must not free it.
int32_t rte_service_probe_capability ( const struct rte_service_spec service,
uint32_t  capability 
)
Warning
EXPERIMENTAL: this API may change without prior notice

Check if a service has a specific capability.

This function returns if service has implements capability. See RTE_SERVICE_CAP_* defines for a list of valid capabilities.

Return values
1Capability supported by this service instance
0Capability not supported by this service instance
int32_t rte_service_enable_on_lcore ( struct rte_service_spec service,
uint32_t  lcore 
)
Warning
EXPERIMENTAL: this API may change without prior notice

Enable a core to run a service.

Each core can be added or removed from running specific services. This functions adds lcore to the set of cores that will run service.

If multiple cores are enabled on a service, an atomic is used to ensure that only one cores runs the service at a time. The exception to this is when a service indicates that it is multi-thread safe by setting the capability called RTE_SERVICE_CAP_MT_SAFE. With the multi-thread safe capability set, the service function can be run on multiple threads at the same time.

Return values
0lcore added successfully
-EINVALAn invalid service or lcore was provided.
int32_t rte_service_disable_on_lcore ( struct rte_service_spec service,
uint32_t  lcore 
)
Warning
EXPERIMENTAL: this API may change without prior notice

Disable a core to run a service.

Each core can be added or removed from running specific services. This functions removes lcore to the set of cores that will run service.

Return values
0Lcore removed successfully
-EINVALAn invalid service or lcore was provided.
int32_t rte_service_get_enabled_on_lcore ( struct rte_service_spec service,
uint32_t  lcore 
)
Warning
EXPERIMENTAL: this API may change without prior notice

Return if an lcore is enabled for the service.

This function allows the application to query if lcore is currently set to run service.

Return values
1Lcore enabled on this lcore
0Lcore disabled on this lcore
-EINVALAn invalid service or lcore was provided.
int32_t rte_service_start ( struct rte_service_spec service)
Warning
EXPERIMENTAL: this API may change without prior notice

Enable service to run.

This function switches on a service during runtime.

Return values
0The service was successfully started
int32_t rte_service_stop ( struct rte_service_spec service)
Warning
EXPERIMENTAL: this API may change without prior notice

Disable service.

Switch off a service, so it is not run until it is rte_service_start is called on it.

Return values
0Service successfully switched off
int32_t rte_service_is_running ( const struct rte_service_spec service)
Warning
EXPERIMENTAL: this API may change without prior notice

Returns if service is currently running.

This function returns true if the service has been started using rte_service_start, AND a service core is mapped to the service. This function can be used to ensure that the service will be run.

Return values
1Service is currently running, and has a service lcore mapped
0Service is currently stopped, or no service lcore is mapped
-EINVALInvalid service pointer provided
int32_t rte_service_lcore_start ( uint32_t  lcore_id)
Warning
EXPERIMENTAL: this API may change without prior notice

Start a service core.

Starting a core makes the core begin polling. Any services assigned to it will be run as fast as possible.

Return values
0Success
-EINVALFailed to start core. The lcore_id passed in is not currently assigned to be a service core.
int32_t rte_service_lcore_stop ( uint32_t  lcore_id)
Warning
EXPERIMENTAL: this API may change without prior notice

Stop a service core.

Stopping a core makes the core become idle, but remains assigned as a service core.

Return values
0Success
-EINVALInvalid lcore_id provided
-EALREADYAlready stopped core
-EBUSYFailed to stop core, as it would cause a service to not be run, as this is the only core currently running the service. The application must stop the service first, and then stop the lcore.
int32_t rte_service_lcore_add ( uint32_t  lcore)
Warning
EXPERIMENTAL: this API may change without prior notice

Adds lcore to the list of service cores.

This functions can be used at runtime in order to modify the service core mask.

Return values
0Success
-EBUSYlcore is busy, and not available for service core duty
-EALREADYlcore is already added to the service core list
-EINVALInvalid lcore provided
int32_t rte_service_lcore_del ( uint32_t  lcore)
Warning
EXPERIMENTAL: this API may change without prior notice

Removes lcore from the list of service cores.

This can fail if the core is not stopped, see rte_service_core_stop.

Return values
0Success
-EBUSYLcore is not stopped, stop service core before removing.
-EINVALfailed to add lcore to service core mask.
int32_t rte_service_lcore_count ( void  )
Warning
EXPERIMENTAL: this API may change without prior notice

Retrieve the number of service cores currently available.

This function returns the integer count of service cores available. The service core count can be used in mapping logic when creating mappings from service cores to services.

See rte_service_lcore_list for details on retrieving the lcore_id of each service core.

Returns
The number of service cores currently configured.
int32_t rte_service_lcore_reset_all ( void  )
Warning
EXPERIMENTAL: this API may change without prior notice

Resets all service core mappings. This does not remove the service cores from duty, just unmaps all services / cores, and stops() the service cores. The runstate of services is not modified.

Return values
0Success
int32_t rte_service_set_stats_enable ( struct rte_service_spec service,
int32_t  enable 
)
Warning
EXPERIMENTAL: this API may change without prior notice

Enable or disable statistics collection for service.

This function enables per core, per-service cycle count collection.

Parameters
serviceThe service to enable statistics gathering on.
enableZero to disable statistics, non-zero to enable.
Return values
0Success
-EINVALInvalid service pointer passed
int32_t rte_service_lcore_list ( uint32_t  array[],
uint32_t  n 
)
Warning
EXPERIMENTAL: this API may change without prior notice

Retrieve the list of currently enabled service cores.

This function fills in an application supplied array, with each element indicating the lcore_id of a service core.

Adding and removing service cores can be performed using rte_service_lcore_add and rte_service_lcore_del.

Parameters
[out]arrayAn array of at least rte_service_lcore_count items. If statically allocating the buffer, use RTE_MAX_LCORE.
[out]nThe size of array.
Return values
>=0Number of service cores that have been populated in the array
-ENOMEMThe provided array is not large enough to fill in the service core list. No items have been populated, call this function with a size of at least rte_service_core_count items.
int32_t rte_service_dump ( FILE *  f,
struct rte_service_spec service 
)
Warning
EXPERIMENTAL: this API may change without prior notice

Dumps any information available about the service. If service is NULL, dumps info for all services.