EM-ODP  3.7.0
Event Machine on ODP
em_conf_t Struct Reference

#include <event_machine_init.h>

Collaboration diagram for em_conf_t:

Data Fields

uint16_t device_id
 
int event_timer
 
int thread_per_core
 
int process_per_core
 
int core_count
 
em_core_mask_t phys_mask
 
em_pool_cfg_t default_pool_cfg
 
struct {
   em_log_func_t   log_fn
 
   em_vlog_func_t   vlog_fn
 
log
 
struct {
   em_input_poll_func_t   input_poll_fn
 
   em_core_mask_t   input_poll_mask
 
input
 
struct {
   em_output_drain_func_t   output_drain_fn
 
   em_core_mask_t   output_drain_mask
 
output
 
em_api_hooks_t api_hooks
 
em_idle_hooks_t idle_hooks
 

Detailed Description

Event Machine run-time configuration options given at startup to em_init()

The 'em_conf_t' struct should be initialized with em_conf_init() before use. This initialization provides better backwards compatibility since all options will be set to default values. The user must further set the needed configuration and call em_init():

em_conf_t conf;
em_conf_init(&conf); // init with default values
conf.thread_per_core = 1;
...
conf.core_count = N;
conf.phys_mask = set N bits; // use em_core_mask_...() functions to set
...
ret = em_init(&conf); // on one core
...
ret = em_init_core(); // on each of the 'conf.core_count' cores

Content is copied into EM by em_init().

Note
Several EM options are configured through compile-time defines. Run-time options allow using the same EM-lib with different configs. Also see the overridable EM runtime config file values, default file: config/em-odp.config
See also
em_conf_init(), em_init()
Examples
bench_event.c, and bench_pool.c.

Definition at line 93 of file event_machine_init.h.

Field Documentation

◆ api_hooks

em_api_hooks_t em_conf_t::api_hooks

User provided API callback hooks. Set only the needed hooks to avoid performance degradation. Only used if EM_API_HOOKS_ENABLE != 0

Definition at line 218 of file event_machine_init.h.

◆ core_count

int em_conf_t::core_count

Number of EM-cores (== number of EM-threads or EM-processes). The 'core_count' must match the number of bits set in 'phys_mask'. EM-cores will be enumerated from 0 to 'core_count-1' regardless of the actual physical core ids. Default value is 0 and needs to be changed by the user.

Examples
bench_event.c, and bench_pool.c.

Definition at line 132 of file event_machine_init.h.

◆ default_pool_cfg

em_pool_cfg_t em_conf_t::default_pool_cfg

Pool configuration for the EM default pool (EM_POOL_DEFAULT). Default value is set by em_pool_cfg_init() and needs to be changed by the user.

Note that if the default pool configuration is also given in the config file through option 'startup_pools', it will override this default pool configuration.

Examples
bench_event.c, and bench_pool.c.

Definition at line 160 of file event_machine_init.h.

◆ device_id

uint16_t em_conf_t::device_id

EM device id - use different device ids for each EM instance or remote EM device that need to communicate with each other. Default value is 0.

Definition at line 99 of file event_machine_init.h.

◆ event_timer

int em_conf_t::event_timer

Event Timer: enable=1, disable=0. Default value is 0 (disable).

Definition at line 105 of file event_machine_init.h.

◆ idle_hooks

em_idle_hooks_t em_conf_t::idle_hooks

User provided idle callback hooks. Set only the needed hooks to avoid performance degradation. Only used if EM_IDLE_HOOKS_ENABLE != 0

Definition at line 225 of file event_machine_init.h.

◆ input

struct { ... } em_conf_t::input

EM event/pkt input related functions and config

◆ input_poll_fn

em_input_poll_func_t em_conf_t::input_poll_fn

User provided function, called from within the EM-dispatch loop, mainly for polling various input sources for events or pkts and then enqueue them into EM. Set to 'NULL' if not needed (default).

Definition at line 182 of file event_machine_init.h.

◆ input_poll_mask

em_core_mask_t em_conf_t::input_poll_mask

EM core mask to control which EM-cores (0 to 'core_count-1') input_poll_fn() will be called on. The provided mask has to be equal or a subset of the EM core mask with all 'core_count' bits set. A zero mask means execution on all EM cores (default).

Definition at line 190 of file event_machine_init.h.

◆ log

struct { ... } em_conf_t::log

EM log functions. Default values are NULL and causes EM to use internal default log-functions.

◆ log_fn

em_log_func_t em_conf_t::log_fn

EM log function, user overridable, variable number of args

Definition at line 169 of file event_machine_init.h.

◆ output

struct { ... } em_conf_t::output

EM event/pkt output related functions and config

◆ output_drain_fn

em_output_drain_func_t em_conf_t::output_drain_fn

User provided function, called from within the EM-dispatch loop, mainly for 'periodical' draining of buffered output to make sure events/pkts are eventually sent out even if the rate is low or stops for a while. Set to 'NULL' if not needed (default).

Definition at line 202 of file event_machine_init.h.

◆ output_drain_mask

em_core_mask_t em_conf_t::output_drain_mask

EM core mask to control which EM-cores (0 to 'core_count-1') output_drain_fn() will be called on. The provided mask has to be equal or a subset of the EM core mask with all 'core_count' bits set. A zero mask means execution on all EM cores (default).

Definition at line 210 of file event_machine_init.h.

◆ phys_mask

em_core_mask_t em_conf_t::phys_mask

Physical core mask, exactly listing the physical CPU cores to be used by EM (this is a physical core mask even though the 'em_core_mask_t' type is used). Default value is all-0 and needs to be changed by the user.

Note
EM otherwise operates on logical cores, i.e. enumerated contiguously from 0 to 'core_count-1' and a logical EM core mask has 'core_count' consecutively set bits. Example - physical mask vs. corresponding EM core mask: .core_count = 8 .physmask: 0xf0f0 (binary: 1111 0000 1111 0000 - 8 set bits) = 8 phys-cores (phys-cores 4-7,12-15) ==> EM-mask: 0x00ff (0000 0000 1111 1111 binary) - 8 EM cores = 8 EM-cores (EM-cores 0-7)
Examples
bench_event.c, and bench_pool.c.

Definition at line 149 of file event_machine_init.h.

◆ process_per_core

int em_conf_t::process_per_core

RunMode: EM run with one process per core. Set 'true' to select process-per-core mode. Default value is 0.

Note
The user must set either 'thread_per_core' or 'process_per_core' but not both.
Examples
bench_event.c, and bench_pool.c.

Definition at line 123 of file event_machine_init.h.

◆ thread_per_core

int em_conf_t::thread_per_core

RunMode: EM run with one thread per core. Set 'true' to select thread-per-core mode. This is the recommended mode, but the user must explicitly set it to enable. Default value is 0.

Note
The user must set either 'thread_per_core' or 'process_per_core' but not both.
Examples
bench_event.c, and bench_pool.c.

Definition at line 115 of file event_machine_init.h.

◆ vlog_fn

em_vlog_func_t em_conf_t::vlog_fn

EM log function, user overridable, va_list

Definition at line 171 of file event_machine_init.h.


The documentation for this struct was generated from the following file:
em_conf_t::thread_per_core
int thread_per_core
Definition: event_machine_init.h:115
em_init
em_status_t em_init(const em_conf_t *conf)
Definition: event_machine_init.c:65
em_conf_init
void em_conf_init(em_conf_t *conf)
Definition: event_machine_init.c:54
em_conf_t::phys_mask
em_core_mask_t phys_mask
Definition: event_machine_init.h:149
em_init_core
em_status_t em_init_core(void)
Definition: event_machine_init.c:247
em_conf_t
Definition: event_machine_init.h:93