Data Accelerator Offload
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Functions | Variables
dao_workers.h File Reference
#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.

Data Structures

struct  dao_worker
 

Macros

#define DAO_WORKER_INVALID_INDEX   UINT32_C(~0)
 

Typedefs

typedef struct dao_worker __rte_cache_aligned
 

Functions

static dao_worker_t * dao_workers_worker_get (dao_workers_main_t *dwm, uint8_t worker_index)
 
static int dao_workers_app_data_get (dao_worker_t *wrkr, void **app_data, size_t *size)
 
static int dao_workers_core_index_get (dao_worker_t *wrkr)
 
static int dao_workers_worker_index_get (dao_worker_t *wrkr)
 
static int dao_workers_numa_get (dao_worker_t *wrkr)
 
static int dao_workers_is_control_worker (dao_worker_t *worker)
 
static dao_worker_t * dao_workers_control_worker_get (dao_workers_main_t *dwm)
 
static dao_workers_main_t * dao_workers_get (void)
 
static int dao_workers_num_workers_get (void)
 
static int dao_workers_num_cores_get (void)
 
static dao_worker_t * dao_workers_self_worker_get (void)
 
int dao_workers_init (uint64_t core_mask, uint32_t control_core_index, size_t per_core_app_data_sz)
 
int dao_workers_fini (void)
 
int dao_workers_barrier_sync (dao_worker_t *worker)
 
int dao_workers_barrier_release (dao_worker_t *worker)
 
static void dao_workers_barrier_check (dao_worker_t *worker)
 

Variables

dao_workers_main_t * __dao_workers
 

Detailed Description

DAO workers provides set of APIs to manage workers for following use-cases:

Definition in file dao_workers.h.

Macro Definition Documentation

◆ DAO_WORKER_INVALID_INDEX

#define DAO_WORKER_INVALID_INDEX   UINT32_C(~0)

Invalid index of workers

Definition at line 74 of file dao_workers.h.

Typedef Documentation

◆ __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

Function Documentation

◆ 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
dwmdao worker main received by dao_workers_get()
worker_indexworker_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_dataIf passed, Pointer to cache-aligned memory
[out]sizeIf 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
wrkrdao worker handle
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
wrkrdao worker handle
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

Get dao worker handle corresponding to app-control-core. Returns NULL if control_core_index passed to dao_workers_init() is equal to DAO_WORKER_INVALID_INDEX

Returns
NULL: Failure !NULL: Success

Definition at line 266 of file dao_workers.h.

◆ 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_maskFor each set-bit, excluding control_core_index bit, designates core as app-worker.
control_core_indexIf 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_szSize 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
workerdao worker handle
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
workerdao worker handle
Returns
0: Success <0: Failure

◆ dao_workers_barrier_check()

static void dao_workers_barrier_check ( dao_worker_t *  worker)
inlinestatic

Check for worker barrier which makes this worker to stop if app-control-core has called dao_workers_barrier_sync(). API hangs until app-control-core does not call dao_workers_barrier_release

API must be called by each app-workers in a fast-path while-loop

Parameters
workerdao worker handle

Definition at line 427 of file dao_workers.h.

Variable Documentation

◆ __dao_workers

dao_workers_main_t* __dao_workers
extern

Variable declaration of global workers main