67 const bool do_schedule_pause =
em_shm->
opt.dispatch.sched_pause;
70 EM_LOG(EM_LOG_ERR,
"%s(): Not an EM-core, can not dispatch!", __func__);
75 odp_schedule_resume();
82 if (input_poll_fn || output_drain_fn)
83 events = dispatch_with_userfn(rounds, input_poll_fn, output_drain_fn);
85 events = dispatch_no_userfn(rounds);
87 if (do_schedule_pause) {
96 round_events = dispatch_round(ODP_SCHED_NO_WAIT,
98 events += round_events;
99 }
while (round_events > 0);
108 if (unlikely(!opt)) {
110 "Bad argument, opt=NULL");
114 *opt = dispatch_opt_default;
131 EM_LOG(EM_LOG_ERR,
"%s(): Not an EM-core, can not dispatch!", __func__);
133 memset(results, 0,
sizeof(*results));
138 odp_schedule_resume();
145 if (do_input_poll || do_output_drain)
146 events = dispatch_duration_with_userfn(duration, opt,
147 input_poll_fn, output_drain_fn,
150 events = dispatch_duration_no_userfn(duration, opt, results );
153 if (do_sched_pause) {
154 odp_schedule_pause();
163 round_events = dispatch_round(ODP_SCHED_NO_WAIT,
165 events += round_events;
167 }
while (round_events > 0);
170 results->
rounds += rounds;
188 "Bad argument: duration=NULL");
191 opt = &dispatch_opt_default;
195 "Not initialized: em_dispatch_opt_init(opt) not called");
201 "Bad option: 0 < opt.burst_size (%" PRIu64
") <= %u (max)",
208 (EM_DISPATCH_DURATION_LAST >> 1) << 2;
212 "Bad option: duration->select=0x%x invalid", duration->
select);
216 duration->
ns == 0) ||
220 duration->no_events.
rounds == 0) ||
222 duration->no_events.
ns == 0)),
224 "Bad option: opt.duration is zero(0).");
227 return dispatch_duration(duration, opt, results);
235 "Bad argument: ns=0");
238 opt = &dispatch_opt_default;
242 "Not initialized: em_dispatch_opt_init(opt) not called");
248 "Bad option: 0 < opt.burst_size (%" PRIu64
") <= %u (max)",
257 return dispatch_duration(&duration, opt, results);
265 "Bad argument: events=0");
268 opt = &dispatch_opt_default;
272 "Not initialized: em_dispatch_opt_init(opt) not called");
278 "Bad option: 0 < opt.burst_size (%" PRIu64
") <= %u (max)",
287 return dispatch_duration(&duration, opt, results);
295 "Bad argument: rounds=0");
298 opt = &dispatch_opt_default;
302 "Not initialized: em_dispatch_opt_init(opt) not called");
308 "Bad option: 0 < opt.burst_size (%" PRIu64
") <= %u (max)",
317 return dispatch_duration(&duration, opt, results);
327 EM_ESCOPE_DISPATCH_REGISTER_ENTER_CB,
328 "EM dispatch callbacks disabled");
330 hook_fn.disp_enter = func;
331 stat = hook_register(DISPATCH_CALLBACK_ENTER, hook_fn);
333 EM_ESCOPE_DISPATCH_REGISTER_ENTER_CB,
334 "Dispatch callback register failed");
346 EM_ESCOPE_DISPATCH_UNREGISTER_ENTER_CB,
347 "EM dispatch callbacks disabled");
349 hook_fn.disp_enter = func;
350 stat = hook_unregister(DISPATCH_CALLBACK_ENTER, hook_fn);
352 EM_ESCOPE_DISPATCH_UNREGISTER_ENTER_CB,
353 "Dispatch callback unregister failed");
365 EM_ESCOPE_DISPATCH_REGISTER_EXIT_CB,
366 "EM dispatch callbacks disabled");
368 hook_fn.disp_exit = func;
369 stat = hook_register(DISPATCH_CALLBACK_EXIT, hook_fn);
371 EM_ESCOPE_DISPATCH_REGISTER_EXIT_CB,
372 "Dispatch callback register failed");
383 EM_ESCOPE_DISPATCH_UNREGISTER_EXIT_CB,
384 "EM dispatch callbacks disabled");
386 hook_fn.disp_exit = func;
387 stat = hook_unregister(DISPATCH_CALLBACK_EXIT, hook_fn);
389 EM_ESCOPE_DISPATCH_UNREGISTER_EXIT_CB,
390 "Dispatch callback unregister failed");
#define INTERNAL_ERROR(error, escope, fmt,...)
#define RETURN_ERROR_IF(cond, error, escope, fmt,...)
#define EM_CHECK_INIT_CALLED
ENV_LOCAL em_locm_t em_locm
#define EM_SCHED_MULTI_MAX_BURST
em_status_t em_dispatch_events(uint64_t events, const em_dispatch_opt_t *opt, em_dispatch_results_t *results)
Run the EM dispatcher until a given number of events have been dispatched.
em_status_t em_dispatch_unregister_exit_cb(em_dispatch_exit_func_t func)
em_status_t em_dispatch_register_enter_cb(em_dispatch_enter_func_t func)
uint64_t em_dispatch(uint64_t rounds)
void em_dispatch_opt_init(em_dispatch_opt_t *opt)
Initialize the EM dispatch options.
em_status_t em_dispatch_register_exit_cb(em_dispatch_exit_func_t func)
em_status_t em_dispatch_ns(uint64_t ns, const em_dispatch_opt_t *opt, em_dispatch_results_t *results)
Run the EM dispatcher for a given amount of time (in nanoseconds).
em_status_t em_dispatch_rounds(uint64_t rounds, const em_dispatch_opt_t *opt, em_dispatch_results_t *results)
Run the EM dispatcher for a given number of dispatch-rounds.
em_status_t em_dispatch_unregister_enter_cb(em_dispatch_enter_func_t func)
em_status_t em_dispatch_duration(const em_dispatch_duration_t *duration, const em_dispatch_opt_t *opt, em_dispatch_results_t *results)
Run the EM dispatcher for a certain duration with options.
void(* em_dispatch_enter_func_t)(em_eo_t eo, void **eo_ctx, em_event_t events[], int num, em_queue_t *queue, void **q_ctx)
void(* em_dispatch_exit_func_t)(em_eo_t eo)
em_dispatch_duration_select_t
EM dispatch duration selection flags.
@ EM_DISPATCH_DURATION_ROUNDS
@ EM_DISPATCH_DURATION_NO_EVENTS_NS
@ EM_DISPATCH_DURATION_EVENTS
@ EM_DISPATCH_DURATION_NS
@ EM_DISPATCH_DURATION_NO_EVENTS_ROUNDS
int(* em_input_poll_func_t)(void)
int(* em_output_drain_func_t)(void)
em_dispatch_duration_select_t select
uint32_t __internal_check
em_output_drain_func_t output_drain_fn
em_input_poll_func_t input_poll_fn