#include <errno.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stddef.h>
#include <signal.h>
#include <assert.h>
#include <rte_common.h>
#include <rte_compat.h>
#include <rte_debug.h>
#include <rte_lcore.h>
#include <rte_bitops.h>
#include <rte_atomic.h>
#include <rte_pause.h>
#include <dao_log.h>
#include <dao_util.h>
Go to the source code of this file.
DAO workers provides set of APIs to manage workers for following use-cases:
- From a given set of core-lists (via rte_eal), application can designate subset of cores as app-workers and app-control-core (See dao_workers_init())
- API assigns each app-worker a unique worker-id ranging from [0 - num_workers], excluding app-control-core, which allows application to sequentially allocate/manage data structures for workers
- If valid control_core_index is passed to dao_workers_init(), core having (lcore-id == control_core_index) is designated as app-control-core instead of app-worker. app-control-core does not get valid worker-id. dao_workers_is_control_worker() returns true for app-control-core and false for app-workers. In case no app-control-core is required by application, DAO_WORKER_INVALID_INDEX shall be passed for control_core_index argument in dao_workers_init()
- dao_workers_init() also allows to allocate cache-aligned memory for each worker with size equal to per_core_app_data_sz argument. API rounds-up this size to nearest cache-line value and allocates memory for each worker-core.. Each worker, once launched, can access to its memory via dao_workers_app_data_get()
- A core can grab its "dao worker handle" via dao_workers_self_worker_get() which can be saved in software cache for accessing fast path APIs like (dao_workers_worker_index_get())
In order to apply control configurations like route-updates or IPsec SA/policy updates, it might be required by application to
Each workers must be calling dao_workers_barrier_check() at the start of data-path loop.
Definition in file dao_workers.h.
◆ DAO_WORKER_INVALID_INDEX
#define DAO_WORKER_INVALID_INDEX UINT32_C(~0) |
◆ __rte_cache_aligned
struct dao_worker represents single worker which holds fast path access to
- core_index (including control_core)
- worker_index (excluding control_core)
- socket_id or numa_id
- Pointer to barrier_mask
◆ dao_workers_worker_get()
static dao_worker_t * dao_workers_worker_get |
( |
dao_workers_main_t * |
dwm, |
|
|
uint8_t |
worker_index |
|
) |
| |
|
inlinestatic |
Get dao_worker_t pointer in fast path
- Parameters
-
dwm | dao worker main received by dao_workers_get() |
worker_index | worker_index in the range of [0 - dwm->num_workers] |
Definition at line 166 of file dao_workers.h.
◆ dao_workers_app_data_get()
static int dao_workers_app_data_get |
( |
dao_worker_t * |
wrkr, |
|
|
void ** |
app_data, |
|
|
size_t * |
size |
|
) |
| |
|
inlinestatic |
Grab cache-aligned memory for app-worker with size >= per_core_app_data_sz passed to dao_workers_init()
- Parameters
-
wrkr | "dao worker handle". ( |
- See also
- dao_workers_self_worker_get)
- Parameters
-
[out] | app_data | If passed, Pointer to cache-aligned memory |
[out] | size | If passed, size of cache-aligned memory. Should be >= per_core_app_data_sz |
Definition at line 186 of file dao_workers.h.
◆ dao_workers_core_index_get()
static int dao_workers_core_index_get |
( |
dao_worker_t * |
wrkr | ) |
|
|
inlinestatic |
Get core index for provided wrkr handle. Ranging from [0 - num_cores] including app-control-core
- Parameters
-
- Returns
- Core index
Definition at line 211 of file dao_workers.h.
◆ dao_workers_worker_index_get()
static int dao_workers_worker_index_get |
( |
dao_worker_t * |
wrkr | ) |
|
|
inlinestatic |
Get worker index for provided wrkr handle. Ranging from [0 - num_workers] excluding app-control-core
- Parameters
-
- Returns
- Worker index
Definition at line 227 of file dao_workers.h.
◆ dao_workers_numa_get()
static int dao_workers_numa_get |
( |
dao_worker_t * |
wrkr | ) |
|
|
inlinestatic |
Get socket/numa id for the worker
- Returns
- Valid socket-id. Same as rte_lcore_to_socket_id()
Definition at line 239 of file dao_workers.h.
◆ dao_workers_is_control_worker()
static int dao_workers_is_control_worker |
( |
dao_worker_t * |
worker | ) |
|
|
inlinestatic |
Returns true or false if passed worker is app-control-core
- Returns
- 1: Passed worker is app-control-core 0: Passed worker is not app-control-core
Definition at line 251 of file dao_workers.h.
◆ dao_workers_control_worker_get()
static dao_worker_t * dao_workers_control_worker_get |
( |
dao_workers_main_t * |
dwm | ) |
|
|
inlinestatic |
◆ dao_workers_get()
static dao_workers_main_t * dao_workers_get |
( |
void |
| ) |
|
|
inlinestatic |
Get dao worker main handle
- Returns
- NULL: Failure !NULL: Success
Definition at line 280 of file dao_workers.h.
◆ dao_workers_num_workers_get()
static int dao_workers_num_workers_get |
( |
void |
| ) |
|
|
inlinestatic |
Get number of workers.
- Returns
- Number of cores
Definition at line 297 of file dao_workers.h.
◆ dao_workers_num_cores_get()
static int dao_workers_num_cores_get |
( |
void |
| ) |
|
|
inlinestatic |
Get number of cores. Includes app-workers and app-control-core
- Returns
- Number of cores
Definition at line 308 of file dao_workers.h.
◆ dao_workers_self_worker_get()
static dao_worker_t * dao_workers_self_worker_get |
( |
void |
| ) |
|
|
inlinestatic |
Get dao_worker_t object corresponding to worker core on which this API is called
- Returns
- NULL: Failure !NULL: Success
Definition at line 324 of file dao_workers.h.
◆ dao_workers_init()
int dao_workers_init |
( |
uint64_t |
core_mask, |
|
|
uint32_t |
control_core_index, |
|
|
size_t |
per_core_app_data_sz |
|
) |
| |
Initialize dao workers API infra.
rte_eal_init() is a pre-requisite for this API. Each core bit set in core_mask must have valid rte_lcore_id().
- Parameters
-
core_mask | For each set-bit, excluding control_core_index bit, designates core as app-worker. |
control_core_index | If control_core_index != DAO_WORKER_INVALID_INDEX, designate core having (lcore_id == control_core_index) as app-control-core. Here core_id means set bit in core_mask |
per_core_app_data_sz | Size of cache-aligned memory to be allocated for each app-worker (not for app-control-core) |
- Returns
- 0: Success <0: Failure
◆ dao_workers_fini()
int dao_workers_fini |
( |
void |
| ) |
|
Cleanup memory associated with dao workers APIs
- Returns
- 0: Success <0: Failure
◆ dao_workers_barrier_sync()
int dao_workers_barrier_sync |
( |
dao_worker_t * |
worker | ) |
|
Take barrier sync lock and make all app-workers to stop before returning from API
API must be called by app-control-core
- Parameters
-
- Returns
- 0: Success <0: Failure
◆ dao_workers_barrier_release()
int dao_workers_barrier_release |
( |
dao_worker_t * |
worker | ) |
|
Release barrier held-up by app-control-core and allows workers to resume their work
API must be called by app-control-core
- Parameters
-
- Returns
- 0: Success <0: Failure
◆ dao_workers_barrier_check()
static void dao_workers_barrier_check |
( |
dao_worker_t * |
worker | ) |
|
|
inlinestatic |
◆ __dao_workers
dao_workers_main_t* __dao_workers |
|
extern |
Variable declaration of global workers main