47 .local_queues.empty = 1,
48 .do_input_poll =
false,
49 .do_output_drain =
false,
50 .sync_api.in_progress =
false
56 if (unlikely(!conf)) {
72 "Conf pointer NULL!");
76 "Not initialized: em_conf_init(conf) not called");
85 "EM shared memory ptr set - already initialized?");
89 "Select EITHER process-per-core OR thread-per-core!");
95 odp_shm_capability_t shm_capa;
97 ret = odp_shm_capability(&shm_capa);
99 "shm capability error:%d", ret);
101 if (shm_capa.flags & ODP_SHM_SINGLE_VA)
102 flags |= ODP_SHM_SINGLE_VA;
104 odp_shm_t shm = odp_shm_reserve(
"em_shm",
sizeof(
em_shm_t),
105 ODP_CACHE_LINE_SIZE, flags);
110 em_shm = odp_shm_addr(shm);
113 "Shared memory ptr NULL!");
124 memset(&
em_shm->conf.api_hooks, 0,
125 sizeof(
em_shm->conf.api_hooks));
135 "libconfig initialization failed:%d", ret);
147 "core_map_init() failed:%" PRI_STAT
"", stat);
150 stat = dispatch_init();
152 "dispatch_init() failed:%" PRI_STAT
"", stat);
160 stat = input_poll_check(&
em_shm->core_map.logic_mask, conf);
162 "input_poll_init() failed:%" PRI_STAT
"", stat);
163 stat = output_drain_check(&
em_shm->core_map.logic_mask, conf);
165 "output_drain_init() failed:%" PRI_STAT
"", stat);
173 "esv_init() failed:%" PRI_STAT
"", stat);
181 "hooks_init() failed:%" PRI_STAT
"", stat);
188 stat = pool_init(&
em_shm->mpool_tbl, &
em_shm->mpool_pool,
191 "pool_init() failed:%" PRI_STAT
"", stat);
195 "event_init() failed:%" PRI_STAT
"", stat);
197 stat = event_group_init(&
em_shm->event_group_tbl,
198 &
em_shm->event_group_stash);
200 "event_group_init() failed:%" PRI_STAT
"", stat);
203 &
em_shm->queue_pool_static);
205 "queue_init() failed:%" PRI_STAT
"", stat);
208 &
em_shm->queue_group_pool);
210 "queue_group_init() failed:%" PRI_STAT
"", stat);
213 &
em_shm->atomic_group_pool);
215 "atomic_group_init() failed:%" PRI_STAT
"", stat);
219 "eo_init() failed:%" PRI_STAT
"", stat);
223 "create_ctrl_queues() failed:%" PRI_STAT
"", stat);
227 stat = timer_init(&
em_shm->timers);
230 "timer_init() failed:%" PRI_STAT
"",
237 "chaining_init() failed:%" PRI_STAT
"", stat);
242 "emcli_init() failed:%" PRI_STAT
"", stat);
247 print_version_info();
260 shm = odp_shm_lookup(
"em_shm");
263 "Shared memory lookup failed!");
265 shm_addr = odp_shm_addr(shm);
267 "Shared memory ptr NULL");
269 if (shm_addr->conf.process_per_core &&
em_shm == NULL)
273 "Shared memory init fails: em_shm:%p != shm_addr:%p",
277 stat = core_map_init_local(&
em_shm->core_map);
279 "core_map_init_local() failed:%" PRI_STAT
"", stat);
281 stat = queue_group_init_local();
283 "queue_group_init_local() failed:%" PRI_STAT
"", stat);
285 stat = dispatch_init_local();
287 "dispatch_init_local() failed:%" PRI_STAT
"", stat);
290 stat = input_poll_init_local();
292 "input_poll_init_local() failed:%" PRI_STAT
"", stat);
295 stat = output_drain_init_local();
297 "output_drain_init_local() failed:%" PRI_STAT
"", stat);
301 "queue_init_local() failed:%" PRI_STAT
"", stat);
307 stat = timer_init_local();
309 "timer_init_local() failed:%" PRI_STAT
"", stat);
311 stat = sync_api_init_local();
313 "sync_api_init_local() failed:%" PRI_STAT
"", stat);
318 "emcli_init_local() failed:%" PRI_STAT
"", stat);
325 for (
int i = 0; i < EM_DEBUG_TSP_LAST; i++)
335 static void flush_scheduler_events(
void)
350 event_init_odp_multi(odp_ev_tbl, em_ev_tbl, ev_hdr_tbl,
353 }
while (num_events > 0);
376 odp_schedule_resume();
378 for (
int i = 0; i < 2; i++) {
379 flush_scheduler_events();
381 odp_schedule_pause();
386 "delete_ctrl_queues() failed:%" PRI_STAT
"", stat);
388 if (
em_shm->conf.event_timer)
389 timer_term(&
em_shm->timers);
393 "emcli_term() failed:%" PRI_STAT
"", stat);
397 "chaining_term() failed:%" PRI_STAT
"", stat);
401 "EM config term failed:%d");
403 stat = pool_term(&
em_shm->mpool_tbl);
405 "pool_term() failed:%" PRI_STAT
"", stat);
407 env_shared_free(
em_shm->queue_tbl.queue_elem);
409 stat = event_group_term();
411 "event_group_term() failed.");
418 "odp_shm_free() failed:%d", ret);
442 odp_schedule_pause();
444 flush_scheduler_events();
447 stat = timer_term_local();
451 "timer_term_local() fails: %" PRI_STAT
"", stat);
459 "emcli_term_local() fails: %" PRI_STAT
"", stat);
467 "queue_term_local() fails: %" PRI_STAT
"", stat);
470 stat = core_map_term_local(&
em_shm->core_map);
472 "core_map_term_local() failed:%" PRI_STAT
"", stat);
479 return em_shm->conf.device_id;
em_status_t atomic_group_init(atomic_group_tbl_t *const atomic_group_tbl, atomic_group_pool_t *const atomic_group_pool)
em_status_t chaining_init(event_chaining_t *event_chaining)
em_status_t chaining_term(const event_chaining_t *event_chaining)
#define INTERNAL_ERROR(error, escope, fmt,...)
#define RETURN_ERROR_IF(cond, error, escope, fmt,...)
void esv_disabled_warn_config(void)
em_status_t esv_init(void)
em_status_t hooks_init(const em_api_hooks_t *api_hooks, const em_idle_hooks_t *idle_hooks)
#define EM_CHECK_INIT_CALLED
em_status_t create_ctrl_queues(void)
Create EM's internal unscheduled control queues at startup.
void poll_unsched_ctrl_queue(void)
Poll EM's internal unscheduled control queues during dispatch.
em_status_t delete_ctrl_queues(void)
Delete EM's internal unscheduled control queues at teardown.
ENV_LOCAL em_locm_t em_locm
em_status_t queue_init(queue_tbl_t *const queue_tbl, queue_pool_t *const queue_pool, queue_pool_t *const queue_pool_static)
em_status_t queue_term_local(void)
em_status_t queue_init_local(void)
void queue_group_join_all(void)
The calling core joins all available queue groups.
em_status_t queue_group_init(queue_group_tbl_t *const queue_group_tbl, queue_group_pool_t *const queue_group_pool)
#define EM_DEBUG_TIMESTAMP_ENABLE
#define EM_API_HOOKS_ENABLE
#define EM_SCHED_MULTI_MAX_BURST
#define EM_ESCOPE_TERM_CORE
@ EM_ERR_OPERATION_FAILED
#define EM_ESCOPE_INIT_CORE
#define EM_ESCOPE_CONF_INIT
#define EM_EVENT_GROUP_UNDEF
@ EM_SCHED_CONTEXT_TYPE_NONE
em_status_t emcli_init_local(void)
Initialize the EM CLI locally on an EM core (if enabled)
em_status_t emcli_term(void)
Terminate the EM CLI (if enabled)
em_status_t emcli_term_local(void)
Terminate the EM CLI locally on an EM core (if enabled)
em_status_t emcli_init(void)
Initialize the EM CLI (if enabled)
void em_free_multi(em_event_t events[], int num)
void em_pool_cfg_init(em_pool_cfg_t *const pool_cfg)
em_status_t em_term(const em_conf_t *conf)
em_status_t em_term_core(void)
void em_conf_init(em_conf_t *conf)
em_status_t em_init(const em_conf_t *conf)
uint16_t em_device_id(void)
em_status_t em_init_core(void)
em_pool_cfg_t default_pool_cfg
uint32_t __internal_check
em_idle_hooks_t idle_hooks
uint64_t debug_ts[EM_DEBUG_TSP_LAST]