EM-ODP  3.7.0
Event Machine on ODP
em_init.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-2024, Nokia Solutions and Networks
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  * * Neither the name of the copyright holder nor the names of its
15  * contributors may be used to endorse or promote products derived
16  * from this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 #ifndef EM_INIT_H_
32 #define EM_INIT_H_
33 
34 /**
35  * @file
36  * EM internal initialization types & definitions
37  *
38  */
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
44 /**
45  * Pool configuration
46  */
47 typedef struct {
48  em_pool_t pool;
49  char name[EM_POOL_NAME_LEN];
50  em_pool_cfg_t cfg;
52 
53 /**
54  * EM config options read from the config file.
55  *
56  * See the config/em-odp.conf file for description of the options.
57  */
58 typedef struct {
59  struct {
60  em_pool_stats_opt_t statistics;
61  unsigned int align_offset; /* bytes */
62  unsigned int pkt_headroom; /* bytes */
63  size_t user_area_size; /* bytes */
64  } pool;
65 
66  struct {
67  bool create_core_queue_groups;
68  } queue_group;
69 
70  struct {
71  unsigned int max_num;
72  unsigned int min_events_default; /* default min nbr of events */
73  struct {
74  int map_mode;
75  int custom_map[EM_QUEUE_PRIO_NUM];
76  } priority;
77  } queue;
78 
79  struct {
80  bool order_keep;
81  unsigned int num_order_queues;
82  } event_chaining;
83 
84  struct {
85  int enable;
86  int store_state;
87  int store_first_u32;
88  int prealloc_pools;
89  } esv;
90 
91  struct {
92  int enable;
93  const char *ip_addr;
94  int port;
95  } cli;
96 
97  struct {
98  unsigned int poll_ctrl_interval;
99  uint64_t poll_ctrl_interval_ns;
100  /** convert option 'poll_ctrl_interval_ns' to odp_time_t */
102 
103  unsigned int poll_drain_interval;
104  uint64_t poll_drain_interval_ns;
105  odp_time_t poll_drain_interval_time;
106 
107  uint64_t sched_wait_ns;
108  uint64_t sched_wait; /* odp_schedule_wait_time(sched_wait_ns) */
109  bool sched_pause;
110  } dispatch;
111 
112  struct {
113  bool shared_tmo_pool_enable;
114  uint32_t shared_tmo_pool_size;
115  uint32_t tmo_pool_cache;
116  struct {
117  uint32_t timer_event_pool_size;
118  uint32_t timer_event_pool_cache;
119  } ring;
120  } timer;
121 
122  struct {
123  uint32_t num;
125  } startup_pools;
126 } opt_t;
127 
128 em_status_t input_poll_check(const em_core_mask_t *logic_mask, const em_conf_t *conf);
129 em_status_t output_drain_check(const em_core_mask_t *logic_mask, const em_conf_t *conf);
130 
131 em_status_t input_poll_init_local(void);
132 em_status_t output_drain_init_local(void);
133 
134 /**
135  * Set EM core local log function.
136  *
137  * Called by EM-core (= process, thread or bare metal core) when a
138  * different log function than EM internal log is needed.
139  *
140  */
141 void core_log_fn_set(em_log_func_t func);
142 
143 /**
144  * Set EM core local log function with va_list.
145  *
146  * Called by EM-core (= process, thread or bare metal core) when a
147  * different log function than EM internal log is needed.
148  *
149  */
151 
152 /**
153  * Initialize a thread external to EM.
154  *
155  * This function makes sure that EM shared memory has been setup properly before
156  * an EM external thread is created.
157  *
158  * Must be called once by non EM core which wants to access EM shared memory or
159  * use EM APIs.
160  *
161  * @return EM_OK if successful.
162  */
164 
165 em_status_t sync_api_init_local(void);
166 
167 #ifdef __cplusplus
168 }
169 #endif
170 
171 #endif /* EM_INIT_H_ */
EM_QUEUE_PRIO_NUM
#define EM_QUEUE_PRIO_NUM
Definition: event_machine_hw_config.h:103
init_ext_thread
em_status_t init_ext_thread(void)
Definition: em_init.c:90
em_log_func_t
int(* em_log_func_t)(em_log_level_t level, const char *fmt,...) __attribute__((format(printf
Definition: event_machine_hw_types.h:329
core_vlog_fn_set
void core_vlog_fn_set(em_vlog_func_t func)
Definition: em_init.c:83
em_core_mask_t
Definition: event_machine_hw_types.h:242
em_pool_cfg_t
Definition: event_machine_pool.h:141
opt_t
Definition: em_init.h:58
core_log_fn_set
void core_log_fn_set(em_log_func_t func)
Definition: em_init.c:76
startup_pool_conf_t
Definition: em_init.h:47
em_status_t
uint32_t em_status_t
Definition: event_machine_types.h:321
opt_t::poll_ctrl_interval_time
odp_time_t poll_ctrl_interval_time
Definition: em_init.h:101
em_pool_stats_opt_t
Definition: event_machine_pool.h:98
EM_POOL_NAME_LEN
#define EM_POOL_NAME_LEN
Definition: event_machine_hw_config.h:196
em_vlog_func_t
int(*) typedef int(* em_vlog_func_t)(em_log_level_t level, const char *fmt, va_list args)
Definition: event_machine_hw_types.h:337
EM_CONFIG_POOLS
#define EM_CONFIG_POOLS
Definition: event_machine_config.h:119
em_conf_t
Definition: event_machine_init.h:93