53#include <odp/helper/odph_api.h>
63#include "em_libconfig.h"
67static int error_handler_initialized;
69static early_log_t early_log = {default_log, vdefault_log};
75static const char *
const err_status_name_tbl[] = {
107COMPILE_TIME_ASSERT(ODPH_ARRAY_SIZE(err_status_name_tbl) ==
EM_ERR + 1, ERR_TBL_SIZE);
111 EM_ESCOPE_API_IS_NOT_PART_EM_ESCOPE__ERROR);
113 EM_ESCOPE_INTERNAL_IS_NOT_PART_OF_EM_ESCOPE__ERROR);
118#define ESCOPE_API_IDX(escope) ((escope) & ~EM_ESCOPE_API_MASK)
120static const char *
const escope_api_name_tbl[EM_ESCOPE_API_LAST -
121 EM_ESCOPE_API_FIRST + 1] = {
122#define ESCOPE_API_STR(escope) \
123 [ESCOPE_API_IDX(escope)] = #escope
126 ESCOPE_API_STR(EM_ESCOPE_ATOMIC_GROUP_CREATE),
127 ESCOPE_API_STR(EM_ESCOPE_ATOMIC_GROUP_DELETE),
128 ESCOPE_API_STR(EM_ESCOPE_ATOMIC_GROUP_FIND),
129 ESCOPE_API_STR(EM_ESCOPE_ATOMIC_GROUP_FIRST),
130 ESCOPE_API_STR(EM_ESCOPE_ATOMIC_GROUP_NAME),
131 ESCOPE_API_STR(EM_ESCOPE_ATOMIC_GROUP_NEXT),
132 ESCOPE_API_STR(EM_ESCOPE_ATOMIC_GROUP_QUEUE_FIRST),
133 ESCOPE_API_STR(EM_ESCOPE_ATOMIC_GROUP_QUEUE_NEXT),
134 ESCOPE_API_STR(EM_ESCOPE_QUEUE_CREATE_AG),
135 ESCOPE_API_STR(EM_ESCOPE_QUEUE_CREATE_STATIC_AG),
137 ESCOPE_API_STR(EM_ESCOPE_CORE_COUNT),
138 ESCOPE_API_STR(EM_ESCOPE_CORE_ID),
140 ESCOPE_API_STR(EM_ESCOPE_DISPATCH),
141 ESCOPE_API_STR(EM_ESCOPE_DISPATCH_DURATION),
142 ESCOPE_API_STR(EM_ESCOPE_DISPATCH_EVENTS),
143 ESCOPE_API_STR(EM_ESCOPE_DISPATCH_NS),
144 ESCOPE_API_STR(EM_ESCOPE_DISPATCH_OPT_INIT),
145 ESCOPE_API_STR(EM_ESCOPE_DISPATCH_REGISTER_ENTER_CB),
146 ESCOPE_API_STR(EM_ESCOPE_DISPATCH_REGISTER_EXIT_CB),
147 ESCOPE_API_STR(EM_ESCOPE_DISPATCH_ROUNDS),
148 ESCOPE_API_STR(EM_ESCOPE_DISPATCH_UNREGISTER_ENTER_CB),
149 ESCOPE_API_STR(EM_ESCOPE_DISPATCH_UNREGISTER_EXIT_CB),
151 ESCOPE_API_STR(EM_ESCOPE_EO_ADD_QUEUE),
152 ESCOPE_API_STR(EM_ESCOPE_EO_ADD_QUEUE_SYNC),
153 ESCOPE_API_STR(EM_ESCOPE_EO_CONTEXT),
154 ESCOPE_API_STR(EM_ESCOPE_EO_CREATE),
155 ESCOPE_API_STR(EM_ESCOPE_EO_CREATE_MULTIRCV),
156 ESCOPE_API_STR(EM_ESCOPE_EO_CREATE_PARAM),
157 ESCOPE_API_STR(EM_ESCOPE_EO_CURRENT),
158 ESCOPE_API_STR(EM_ESCOPE_EO_DELETE),
159 ESCOPE_API_STR(EM_ESCOPE_EO_FIND),
160 ESCOPE_API_STR(EM_ESCOPE_EO_FIRST),
161 ESCOPE_API_STR(EM_ESCOPE_EO_MULTIRCV_PARAM_INIT),
162 ESCOPE_API_STR(EM_ESCOPE_EO_NAME),
163 ESCOPE_API_STR(EM_ESCOPE_EO_NEXT),
164 ESCOPE_API_STR(EM_ESCOPE_EO_PARAM_INIT),
165 ESCOPE_API_STR(EM_ESCOPE_EO_QUEUE_FIRST),
166 ESCOPE_API_STR(EM_ESCOPE_EO_QUEUE_NEXT),
167 ESCOPE_API_STR(EM_ESCOPE_EO_REGISTER_ERROR_HANDLER),
168 ESCOPE_API_STR(EM_ESCOPE_EO_REMOVE_QUEUE),
169 ESCOPE_API_STR(EM_ESCOPE_EO_REMOVE_QUEUE_ALL),
170 ESCOPE_API_STR(EM_ESCOPE_EO_REMOVE_QUEUE_ALL_SYNC),
171 ESCOPE_API_STR(EM_ESCOPE_EO_REMOVE_QUEUE_SYNC),
172 ESCOPE_API_STR(EM_ESCOPE_EO_START),
173 ESCOPE_API_STR(EM_ESCOPE_EO_START_SYNC),
174 ESCOPE_API_STR(EM_ESCOPE_EO_STATE),
175 ESCOPE_API_STR(EM_ESCOPE_EO_STOP),
176 ESCOPE_API_STR(EM_ESCOPE_EO_STOP_SYNC),
177 ESCOPE_API_STR(EM_ESCOPE_EO_UNREGISTER_ERROR_HANDLER),
179 ESCOPE_API_STR(EM_ESCOPE_ERROR),
180 ESCOPE_API_STR(EM_ESCOPE_REGISTER_ERROR_HANDLER),
181 ESCOPE_API_STR(EM_ESCOPE_UNREGISTER_ERROR_HANDLER),
183 ESCOPE_API_STR(EM_ESCOPE_EVENT_GROUP_ABORT),
184 ESCOPE_API_STR(EM_ESCOPE_EVENT_GROUP_APPLY),
185 ESCOPE_API_STR(EM_ESCOPE_EVENT_GROUP_ASSIGN),
186 ESCOPE_API_STR(EM_ESCOPE_EVENT_GROUP_CREATE),
187 ESCOPE_API_STR(EM_ESCOPE_EVENT_GROUP_CURRENT),
188 ESCOPE_API_STR(EM_ESCOPE_EVENT_GROUP_DELETE),
189 ESCOPE_API_STR(EM_ESCOPE_EVENT_GROUP_FIRST),
190 ESCOPE_API_STR(EM_ESCOPE_EVENT_GROUP_INCREMENT),
191 ESCOPE_API_STR(EM_ESCOPE_EVENT_GROUP_IS_READY),
192 ESCOPE_API_STR(EM_ESCOPE_EVENT_GROUP_NEXT),
193 ESCOPE_API_STR(EM_ESCOPE_EVENT_GROUP_NOTIF),
194 ESCOPE_API_STR(EM_ESCOPE_EVENT_GROUP_PROCESSING_END),
195 ESCOPE_API_STR(EM_ESCOPE_SEND_GROUP),
196 ESCOPE_API_STR(EM_ESCOPE_SEND_GROUP_MULTI),
198 ESCOPE_API_STR(EM_ESCOPE_ALLOC),
199 ESCOPE_API_STR(EM_ESCOPE_ALLOC_MULTI),
200 ESCOPE_API_STR(EM_ESCOPE_EVENT_CLONE),
201 ESCOPE_API_STR(EM_ESCOPE_EVENT_CLONE_PART),
202 ESCOPE_API_STR(EM_ESCOPE_EVENT_HAS_REF),
203 ESCOPE_API_STR(EM_ESCOPE_EVENT_MARK_FREE),
204 ESCOPE_API_STR(EM_ESCOPE_EVENT_MARK_FREE_MULTI),
205 ESCOPE_API_STR(EM_ESCOPE_EVENT_MARK_SEND),
206 ESCOPE_API_STR(EM_ESCOPE_EVENT_POINTER),
207 ESCOPE_API_STR(EM_ESCOPE_EVENT_POINTER_AND_SIZE),
208 ESCOPE_API_STR(EM_ESCOPE_EVENT_POOL),
209 ESCOPE_API_STR(EM_ESCOPE_EVENT_POOL_SUBPOOL),
210 ESCOPE_API_STR(EM_ESCOPE_EVENT_REF),
211 ESCOPE_API_STR(EM_ESCOPE_EVENT_SAME_TYPE_MULTI),
212 ESCOPE_API_STR(EM_ESCOPE_EVENT_SET_TYPE),
213 ESCOPE_API_STR(EM_ESCOPE_EVENT_SIZE),
214 ESCOPE_API_STR(EM_ESCOPE_EVENT_TYPE),
215 ESCOPE_API_STR(EM_ESCOPE_EVENT_TYPE_MULTI),
216 ESCOPE_API_STR(EM_ESCOPE_EVENT_UAREA),
217 ESCOPE_API_STR(EM_ESCOPE_EVENT_UAREA_ID),
218 ESCOPE_API_STR(EM_ESCOPE_EVENT_UAREA_ID_SET),
219 ESCOPE_API_STR(EM_ESCOPE_EVENT_UAREA_INFO),
220 ESCOPE_API_STR(EM_ESCOPE_EVENT_UNMARK_FREE),
221 ESCOPE_API_STR(EM_ESCOPE_EVENT_UNMARK_FREE_MULTI),
222 ESCOPE_API_STR(EM_ESCOPE_EVENT_UNMARK_SEND),
223 ESCOPE_API_STR(EM_ESCOPE_EVENT_VECTOR_FREE),
224 ESCOPE_API_STR(EM_ESCOPE_EVENT_VECTOR_INFO),
225 ESCOPE_API_STR(EM_ESCOPE_EVENT_VECTOR_MAX_SIZE),
226 ESCOPE_API_STR(EM_ESCOPE_EVENT_VECTOR_SIZE),
227 ESCOPE_API_STR(EM_ESCOPE_EVENT_VECTOR_SIZE_SET),
228 ESCOPE_API_STR(EM_ESCOPE_EVENT_VECTOR_TBL),
229 ESCOPE_API_STR(EM_ESCOPE_EVENT_VECTOR_TYPE),
230 ESCOPE_API_STR(EM_ESCOPE_EVENT_VECTOR_TYPE_SET),
231 ESCOPE_API_STR(EM_ESCOPE_FREE),
232 ESCOPE_API_STR(EM_ESCOPE_FREE_MULTI),
233 ESCOPE_API_STR(EM_ESCOPE_SEND),
234 ESCOPE_API_STR(EM_ESCOPE_SEND_MULTI),
236 ESCOPE_API_STR(EM_ESCOPE_PACKET_HEADROOM),
237 ESCOPE_API_STR(EM_ESCOPE_PACKET_POINTER),
238 ESCOPE_API_STR(EM_ESCOPE_PACKET_POINTER_AND_SIZE),
239 ESCOPE_API_STR(EM_ESCOPE_PACKET_PULL_HEAD),
240 ESCOPE_API_STR(EM_ESCOPE_PACKET_PULL_TAIL),
241 ESCOPE_API_STR(EM_ESCOPE_PACKET_PUSH_HEAD),
242 ESCOPE_API_STR(EM_ESCOPE_PACKET_PUSH_TAIL),
243 ESCOPE_API_STR(EM_ESCOPE_PACKET_RESET),
244 ESCOPE_API_STR(EM_ESCOPE_PACKET_RESIZE),
245 ESCOPE_API_STR(EM_ESCOPE_PACKET_SIZE),
246 ESCOPE_API_STR(EM_ESCOPE_PACKET_TAILROOM),
247 ESCOPE_API_STR(EM_ESCOPE_PACKET_CONCAT),
249 ESCOPE_API_STR(EM_ESCOPE_HOOKS_REGISTER_ALLOC),
250 ESCOPE_API_STR(EM_ESCOPE_HOOKS_REGISTER_FREE),
251 ESCOPE_API_STR(EM_ESCOPE_HOOKS_REGISTER_SEND),
252 ESCOPE_API_STR(EM_ESCOPE_HOOKS_REGISTER_TO_ACTIVE),
253 ESCOPE_API_STR(EM_ESCOPE_HOOKS_REGISTER_TO_IDLE),
254 ESCOPE_API_STR(EM_ESCOPE_HOOKS_REGISTER_WHILE_IDLE),
255 ESCOPE_API_STR(EM_ESCOPE_HOOKS_UNREGISTER_ALLOC),
256 ESCOPE_API_STR(EM_ESCOPE_HOOKS_UNREGISTER_FREE),
257 ESCOPE_API_STR(EM_ESCOPE_HOOKS_UNREGISTER_SEND),
258 ESCOPE_API_STR(EM_ESCOPE_HOOKS_UNREGISTER_TO_ACTIVE),
259 ESCOPE_API_STR(EM_ESCOPE_HOOKS_UNREGISTER_TO_IDLE),
260 ESCOPE_API_STR(EM_ESCOPE_HOOKS_UNREGISTER_WHILE_IDLE),
262 ESCOPE_API_STR(EM_ESCOPE_CONF_INIT),
263 ESCOPE_API_STR(EM_ESCOPE_CONF_LOCAL_INIT),
264 ESCOPE_API_STR(EM_ESCOPE_CONF_OPTS),
265 ESCOPE_API_STR(EM_ESCOPE_CONF_LOCAL_OPTS),
266 ESCOPE_API_STR(EM_ESCOPE_INIT),
267 ESCOPE_API_STR(EM_ESCOPE_INIT_CORE),
268 ESCOPE_API_STR(EM_ESCOPE_INIT_LOCAL),
269 ESCOPE_API_STR(EM_ESCOPE_TERM),
270 ESCOPE_API_STR(EM_ESCOPE_TERM_CORE),
271 ESCOPE_API_STR(EM_ESCOPE_TERM_LOCAL),
272 ESCOPE_API_STR(EM_ESCOPE_TERM_LOCAL_INIT),
273 ESCOPE_API_STR(EM_ESCOPE_CFGFILE_OPTS),
275 ESCOPE_API_STR(EM_ESCOPE_POOL_CFG_INIT),
276 ESCOPE_API_STR(EM_ESCOPE_POOL_CREATE),
277 ESCOPE_API_STR(EM_ESCOPE_POOL_DELETE),
278 ESCOPE_API_STR(EM_ESCOPE_POOL_FIND),
279 ESCOPE_API_STR(EM_ESCOPE_POOL_FIRST),
280 ESCOPE_API_STR(EM_ESCOPE_POOL_INFO),
281 ESCOPE_API_STR(EM_ESCOPE_POOL_NAME),
282 ESCOPE_API_STR(EM_ESCOPE_POOL_NEXT),
283 ESCOPE_API_STR(EM_ESCOPE_POOL_NUM_SUBPOOLS),
284 ESCOPE_API_STR(EM_ESCOPE_POOL_STATS),
285 ESCOPE_API_STR(EM_ESCOPE_POOL_STATS_RESET),
286 ESCOPE_API_STR(EM_ESCOPE_POOL_STATS_SELECTED),
287 ESCOPE_API_STR(EM_ESCOPE_POOL_SUBPOOL_STATS),
288 ESCOPE_API_STR(EM_ESCOPE_POOL_SUBPOOL_STATS_RESET),
289 ESCOPE_API_STR(EM_ESCOPE_POOL_SUBPOOL_STATS_SELECTED),
290 ESCOPE_API_STR(EM_ESCOPE_POOL_STATS_OPT),
292 ESCOPE_API_STR(EM_ESCOPE_QUEUE_GROUP_CREATE),
293 ESCOPE_API_STR(EM_ESCOPE_QUEUE_GROUP_CREATE_SYNC),
294 ESCOPE_API_STR(EM_ESCOPE_QUEUE_GROUP_DELETE),
295 ESCOPE_API_STR(EM_ESCOPE_QUEUE_GROUP_DELETE_SYNC),
296 ESCOPE_API_STR(EM_ESCOPE_QUEUE_GROUP_FIND),
297 ESCOPE_API_STR(EM_ESCOPE_QUEUE_GROUP_FIRST),
298 ESCOPE_API_STR(EM_ESCOPE_QUEUE_GROUP_MASK),
299 ESCOPE_API_STR(EM_ESCOPE_QUEUE_GROUP_MODIFY),
300 ESCOPE_API_STR(EM_ESCOPE_QUEUE_GROUP_MODIFY_SYNC),
301 ESCOPE_API_STR(EM_ESCOPE_QUEUE_GROUP_NAME),
302 ESCOPE_API_STR(EM_ESCOPE_QUEUE_GROUP_NEXT),
303 ESCOPE_API_STR(EM_ESCOPE_QUEUE_GROUP_QUEUE_FIRST),
304 ESCOPE_API_STR(EM_ESCOPE_QUEUE_GROUP_QUEUE_NEXT),
306 ESCOPE_API_STR(EM_ESCOPE_QUEUE_AGGR_CONF_INIT),
307 ESCOPE_API_STR(EM_ESCOPE_QUEUE_AGGR),
308 ESCOPE_API_STR(EM_ESCOPE_QUEUE_AGGR_INFO),
309 ESCOPE_API_STR(EM_ESCOPE_QUEUE_AGGR_LIST),
310 ESCOPE_API_STR(EM_ESCOPE_QUEUE_AGGR_NUM),
311 ESCOPE_API_STR(EM_ESCOPE_QUEUE_AGROUP),
312 ESCOPE_API_STR(EM_ESCOPE_QUEUE_CONTEXT),
313 ESCOPE_API_STR(EM_ESCOPE_QUEUE_CREATE),
314 ESCOPE_API_STR(EM_ESCOPE_QUEUE_CREATE_STATIC),
315 ESCOPE_API_STR(EM_ESCOPE_QUEUE_CREATE_PARAM),
316 ESCOPE_API_STR(EM_ESCOPE_QUEUE_CURRENT),
317 ESCOPE_API_STR(EM_ESCOPE_QUEUE_DELETE),
318 ESCOPE_API_STR(EM_ESCOPE_QUEUE_DEQUEUE),
319 ESCOPE_API_STR(EM_ESCOPE_QUEUE_DEQUEUE_MULTI),
320 ESCOPE_API_STR(EM_ESCOPE_QUEUE_FIND),
321 ESCOPE_API_STR(EM_ESCOPE_QUEUE_FIRST),
322 ESCOPE_API_STR(EM_ESCOPE_QUEUE_INDEX),
323 ESCOPE_API_STR(EM_ESCOPE_QUEUE_NAME),
324 ESCOPE_API_STR(EM_ESCOPE_QUEUE_NEXT),
325 ESCOPE_API_STR(EM_ESCOPE_QUEUE_NUM_PRIO),
326 ESCOPE_API_STR(EM_ESCOPE_QUEUE_PARAM_INIT),
327 ESCOPE_API_STR(EM_ESCOPE_QUEUE_PRIORITY),
328 ESCOPE_API_STR(EM_ESCOPE_QUEUE_QGROUP),
329 ESCOPE_API_STR(EM_ESCOPE_QUEUE_SET_CONTEXT),
330 ESCOPE_API_STR(EM_ESCOPE_QUEUE_TYPE),
331 ESCOPE_API_STR(EM_ESCOPE_QUEUE_STATIC_HANDLE),
333 ESCOPE_API_STR(EM_ESCOPE_ATOMIC_PROCESSING_END),
334 ESCOPE_API_STR(EM_ESCOPE_ORDERED_PROCESSING_END),
335 ESCOPE_API_STR(EM_ESCOPE_PRESCHEDULE),
336 ESCOPE_API_STR(EM_ESCOPE_SCHED_CONTEXT_TYPE_CURRENT),
338 ESCOPE_API_STR(EM_ESCOPE_TIMER_ALL),
339 ESCOPE_API_STR(EM_ESCOPE_TIMER_ATTR),
340 ESCOPE_API_STR(EM_ESCOPE_TIMER_ATTR_INIT),
341 ESCOPE_API_STR(EM_ESCOPE_TIMER_CAPABILITY),
342 ESCOPE_API_STR(EM_ESCOPE_TIMER_CREATE),
343 ESCOPE_API_STR(EM_ESCOPE_TIMER_CUR_TICK),
344 ESCOPE_API_STR(EM_ESCOPE_TIMER_DELETE),
345 ESCOPE_API_STR(EM_ESCOPE_TIMER_FREQ),
346 ESCOPE_API_STR(EM_ESCOPE_TIMER_NS_TO_TICK),
347 ESCOPE_API_STR(EM_ESCOPE_TIMER_RES_CAPABILITY),
348 ESCOPE_API_STR(EM_ESCOPE_TIMER_RING_CREATE),
349 ESCOPE_API_STR(EM_ESCOPE_TIMER_RING_FREQ_CREATE),
350 ESCOPE_API_STR(EM_ESCOPE_TIMER_TICK_TO_NS),
351 ESCOPE_API_STR(EM_ESCOPE_TMO_ACK),
352 ESCOPE_API_STR(EM_ESCOPE_TMO_CANCEL),
353 ESCOPE_API_STR(EM_ESCOPE_TMO_CREATE),
354 ESCOPE_API_STR(EM_ESCOPE_TMO_CREATE_ARG),
355 ESCOPE_API_STR(EM_ESCOPE_TMO_DELETE),
356 ESCOPE_API_STR(EM_ESCOPE_TMO_SET_ABS),
357 ESCOPE_API_STR(EM_ESCOPE_TMO_SET_PERIODIC),
358 ESCOPE_API_STR(EM_ESCOPE_TMO_SET_PERIODIC_RING),
359 ESCOPE_API_STR(EM_ESCOPE_TMO_SET_PERIODIC_RING_FREQ),
360 ESCOPE_API_STR(EM_ESCOPE_TMO_SET_REL),
361 ESCOPE_API_STR(EM_ESCOPE_TMO_STATE),
362 ESCOPE_API_STR(EM_ESCOPE_TMO_STATS),
363 ESCOPE_API_STR(EM_ESCOPE_TMO_TIMER),
364 ESCOPE_API_STR(EM_ESCOPE_TMO_TYPE),
365 ESCOPE_API_STR(EM_ESCOPE_TMO_USERPTR),
366 ESCOPE_API_STR(EM_ESCOPE_TMO_RING_ACK)
371COMPILE_TIME_ASSERT(ODPH_ARRAY_SIZE(escope_api_name_tbl) <=
372 ESCOPE_API_IDX(EM_ESCOPE_API_LAST) + 1, ERR_ESCOPE_API_TBL_SIZE);
377#define ESCOPE_INTERNAL_IDX(escope) ((escope) & ~EM_ESCOPE_INTERNAL_MASK)
379static const char *
const escope_internal_name_tbl[EM_ESCOPE_INTERNAL_LAST -
380 EM_ESCOPE_INTERNAL_FIRST + 1] = {
381#define ESCOPE_INTERNAL_STR(escope) \
382 [ESCOPE_INTERNAL_IDX(escope)] = #escope
385 ESCOPE_INTERNAL_STR(EM_ESCOPE_EVENT_SEND_DEVICE),
386 ESCOPE_INTERNAL_STR(EM_ESCOPE_EVENT_SEND_DEVICE_MULTI),
388 ESCOPE_INTERNAL_STR(EM_ESCOPE_EVENT_GROUP_UPDATE),
389 ESCOPE_INTERNAL_STR(EM_ESCOPE_EVENT_GROUP_UPDATE_PRECNT),
390 ESCOPE_INTERNAL_STR(EM_ESCOPE_EVENT_GROUP_UPDATE_POSTCNT),
392 ESCOPE_INTERNAL_STR(EM_ESCOPE_EO_LOCAL_FUNC_CALL_REQ),
393 ESCOPE_INTERNAL_STR(EM_ESCOPE_EO_REMOVE_QUEUE_ALL_DONE_CB),
394 ESCOPE_INTERNAL_STR(EM_ESCOPE_EO_REMOVE_QUEUE_ALL_SYNC_DONE_CB),
395 ESCOPE_INTERNAL_STR(EM_ESCOPE_EO_REMOVE_QUEUE_DONE_CB),
396 ESCOPE_INTERNAL_STR(EM_ESCOPE_EO_REMOVE_QUEUE_SYNC_DONE_CB),
397 ESCOPE_INTERNAL_STR(EM_ESCOPE_EO_START_DONE_CB),
398 ESCOPE_INTERNAL_STR(EM_ESCOPE_EO_START_SYNC_DONE_CB),
399 ESCOPE_INTERNAL_STR(EM_ESCOPE_EO_STOP_DONE_CB),
400 ESCOPE_INTERNAL_STR(EM_ESCOPE_EO_STOP_SYNC_DONE_CB),
402 ESCOPE_INTERNAL_STR(EM_ESCOPE_QUEUE_DISABLE),
403 ESCOPE_INTERNAL_STR(EM_ESCOPE_QUEUE_DISABLE_ALL),
404 ESCOPE_INTERNAL_STR(EM_ESCOPE_QUEUE_ENABLE),
405 ESCOPE_INTERNAL_STR(EM_ESCOPE_QUEUE_ENABLE_ALL),
406 ESCOPE_INTERNAL_STR(EM_ESCOPE_QUEUE_STATE_CHANGE),
408 ESCOPE_INTERNAL_STR(EM_ESCOPE_QUEUE_GROUP_ADD_CORE),
409 ESCOPE_INTERNAL_STR(EM_ESCOPE_QUEUE_GROUP_REM_CORE),
411 ESCOPE_INTERNAL_STR(EM_ESCOPE_DELETE_CTRL_QUEUES),
412 ESCOPE_INTERNAL_STR(EM_ESCOPE_EVENT_INTERNAL_DONE),
413 ESCOPE_INTERNAL_STR(EM_ESCOPE_EVENT_INTERNAL_LFUNC_CALL),
414 ESCOPE_INTERNAL_STR(EM_ESCOPE_INTERNAL_DONE_W_NOTIF_REQ),
415 ESCOPE_INTERNAL_STR(EM_ESCOPE_INTERNAL_EVENT_RECV_FUNC),
416 ESCOPE_INTERNAL_STR(EM_ESCOPE_INTERNAL_NOTIF),
417 ESCOPE_INTERNAL_STR(EM_ESCOPE_SEND_CTRL_QUEUE),
421#undef ESCOPE_INTERNAL_STR
424COMPILE_TIME_ASSERT(ODPH_ARRAY_SIZE(escope_internal_name_tbl) <=
425 ESCOPE_INTERNAL_IDX(EM_ESCOPE_INTERNAL_LAST) + 1, ERR_ESCOPE_INTERNAL_TBL_SIZE);
429 if (status < ODPH_ARRAY_SIZE(err_status_name_tbl) &&
430 err_status_name_tbl[status] )
431 return err_status_name_tbl[status];
433 return "Unknown ERROR";
438 uint32_t escope_idx = ESCOPE_API_IDX(escope);
441 escope_idx < ODPH_ARRAY_SIZE(escope_api_name_tbl) &&
442 escope_api_name_tbl[escope_idx] )
443 return escope_api_name_tbl[escope_idx];
445 return "Unknown ESCOPE";
450 uint32_t escope_idx = ESCOPE_INTERNAL_IDX(escope);
453 escope_idx < ODPH_ARRAY_SIZE(escope_internal_name_tbl) &&
454 escope_internal_name_tbl[escope_idx] )
455 return escope_internal_name_tbl[escope_idx];
457 return "Unknown ESCOPE";
460const char *escope_addon_api_str(
em_escope_t escope)
463 return "EM Add-on API ESCOPE";
465 return "Unknown ESCOPE";
479 const char *eo_str, va_list args,
bool early_mode,
480 char err_msg[],
size_t errmsg_sz)
482 if (!err_msg || errmsg_sz == 0)
491 char *file = va_arg(args,
char *);
492 const char *func = va_arg(args,
const char *);
493 const int line = va_arg(args,
const int);
494 const char *user_fmt = va_arg(args,
const char *);
495 const char *base_file = basename(file);
496 const char *error_str = err_status_str(error);
497 const char *escope_str =
"Unknown ESCOPE";
501 escope_str = escope_api_str(escope);
503 escope_str = escope_internal_str(escope);
505 escope_str = escope_addon_api_str(escope);
508 int cpu_id = odp_cpu_id();
510 n = snprintf(err_msg, errmsg_sz,
511 "\nEM ERROR:0x%08X(%s) ESCOPE:0x%08X(%s) %s (Early Error)\n"
512 "cpu:%02d %s:%d %s()\n",
513 error, error_str, escope, escope_str, eo_str,
514 cpu_id, base_file, line, func);
517 const uint64_t global_err_cnt = load_global_err_cnt();
519 const int core_id = locm->
core_id;
521 n = snprintf(err_msg, errmsg_sz,
522 "\nEM ERROR:0x%08X(%s) ESCOPE:0x%08X(%s) %s\n"
523 "core:%02d ecount:%" PRIu64
"(%" PRIu64
") %s:%d %s()\n",
524 error, error_str, escope, escope_str, eo_str,
525 core_id, global_err_cnt, local_err_cnt, base_file, line, func);
530 else if (unlikely((
size_t)n >= errmsg_sz - 1))
531 return errmsg_sz - 1;
539 size_t rem_sz = errmsg_sz - n;
541#pragma GCC diagnostic push
542#pragma GCC diagnostic ignored "-Wformat-nonliteral"
543 int m = vsnprintf(&err_msg[n], rem_sz, user_fmt, args);
544#pragma GCC diagnostic pop
549 if ((
size_t)m >= rem_sz - 1)
550 return errmsg_sz - 1;
555 if ((
size_t)end + 1 < errmsg_sz) {
556 err_msg[end++] =
'\n';
563static void increment_global_err_cnt(
void)
565 odp_atomic_inc_u64(&
em_shm->error_handler.global_error_count);
568uint64_t load_global_err_cnt(
void)
570 return odp_atomic_load_u64(&
em_shm->error_handler.global_error_count);
573ODP_PRINTF_FORMAT(2, 0)
574int vdefault_log(
em_log_level_t level, const
char *fmt, va_list args)
590 r = vfprintf(logfd, fmt, args);
594ODP_PRINTF_FORMAT(2, 3)
601 r = vdefault_log(level, fmt, args);
634 format_errmsg(error, escope,
"EO:n/a", args,
true ,
635 err_msg ,
sizeof(err_msg));
636 log_fn(EM_LOG_ERR,
"%s", err_msg);
639 int cpu_id = odp_cpu_id();
641 log_fn(EM_LOG_ERR,
"\n"
642 "APPL ERROR:0x%08X ESCOPE:0x%08X (Early Error)\n"
643 "cpu:%02d\n", error, escope, cpu_id);
648 "FATAL EM ERROR:0x%08X (Early Error) - ABORT!\n",
684 nlen =
em_eo_name(eo, eo_name,
sizeof(eo_name));
685 eo_name[nlen] =
'\0';
687 snprintf(eo_str,
sizeof(eo_str),
688 "EO:%" PRI_EO "-\"%s\" ", eo, eo_name);
689 eo_str[
sizeof(eo_str) - 1] =
'\0';
695 format_errmsg(error, escope, eo_str, args,
697 err_msg ,
sizeof(err_msg));
699 EM_LOG(EM_LOG_ERR,
"%s", err_msg);
703 const uint64_t global_err_cnt = load_global_err_cnt();
706 EM_LOG(EM_LOG_ERR,
"\n"
707 "APPL ERROR:0x%08X ESCOPE:0x%08X %s\n"
708 "core:%02d ecount:%" PRIu64
"(%" PRIu64
")\n",
709 error, escope, eo_str, core_id,
710 global_err_cnt, local_err_cnt);
714 EM_LOG(EM_LOG_ERR,
"FATAL EM ERROR:0x%08X - ABORT!\n", error);
735 if (unlikely(!error_handler_initialized || !
em_shm)) {
740 error = early_error_handler(
EM_EO_UNDEF, error, escope, args_list);
747 const eo_elem_t *
const eo_elem = eo_elem_current();
751 error_handler =
em_shm->error_handler.em_error_handler;
753 if (eo_elem && eo_allocated(eo_elem)) {
757 error_handler = eo_handler;
761 if (unlikely(error_handler == NULL)) {
762 error_handler = early_error_handler;
763 log_fn = early_log.log_fn;
769 error = error_handler(eo, error, escope, args_list);
771 if (error !=
EM_OK) {
773 increment_global_err_cnt();
782 "FATAL EM ERROR:0x%08X ESCOPE:0x%08X - ABORT!\n"
783 "EM: an error-handler must not return a fatal EM-error!",
805 va_start(args, escope);
808 error = select_error_handler(error, escope, args);
821 odp_ticketlock_init(&
em_shm->error_handler.lock);
823 em_shm->error_handler.em_error_handler = default_error_handler;
825 odp_atomic_init_u64(&
em_shm->error_handler.global_error_count, 0);
827 em_shm->error_handler.initialized = 1;
828 error_handler_initialized = 1;
834 int is_log_null = user_log_fn == NULL;
835 int is_vlog_null = user_vlog_fn == NULL;
837 if (is_log_null != is_vlog_null)
841 if (user_log_fn != NULL) {
842 early_log.log_fn = user_log_fn;
843 early_log.vlog_fn = user_vlog_fn;
ENV_LOCAL em_locm_t em_locm
size_t em_eo_name(em_eo_t eo, char *name, size_t maxlen)
#define EM_ESCOPE_API_MASK
em_status_t(* em_error_handler_t)(em_eo_t eo, em_status_t error, em_escope_t escope, va_list args)
#define EM_ESCOPE_ADDON_API(escope)
#define EM_ESCOPE_INTERNAL(escope)
#define EM_ERROR_IS_FATAL(error)
#define EM_ESCOPE_INTERNAL_MASK
#define EM_ESCOPE_API(escope)
#define EM_ESCOPE(escope)
#define EM_ESCOPE_ODP_EXT
int(* em_log_func_t)(em_log_level_t level, const char *fmt,...) __attribute__((format(printf
int(*) typedef int(* em_vlog_func_t)(em_log_level_t level, const char *fmt, va_list args)
@ EM_ERR_OPERATION_FAILED
em_error_handler_t error_handler_func