MCPcopy Create free account
hub / github.com/F-Stack/f-stack / __rte_timer_reset

Function __rte_timer_reset

dpdk/lib/timer/rte_timer.c:467–539  ·  view source on GitHub ↗

Reset and start the timer associated with the timer handle (private func) */

Source from the content-addressed store, hash-verified

465
466/* Reset and start the timer associated with the timer handle (private func) */
467static int
468__rte_timer_reset(struct rte_timer *tim, uint64_t expire,
469 uint64_t period, unsigned tim_lcore,
470 rte_timer_cb_t fct, void *arg,
471 int local_is_locked,
472 struct rte_timer_data *timer_data)
473{
474 union rte_timer_status prev_status, status;
475 int ret;
476 unsigned lcore_id = rte_lcore_id();
477 struct priv_timer *priv_timer = timer_data->priv_timer;
478
479 /* round robin for tim_lcore */
480 if (tim_lcore == (unsigned)LCORE_ID_ANY) {
481 if (lcore_id < RTE_MAX_LCORE) {
482 /* EAL thread with valid lcore_id */
483 tim_lcore = rte_get_next_lcore(
484 priv_timer[lcore_id].prev_lcore,
485 0, 1);
486 priv_timer[lcore_id].prev_lcore = tim_lcore;
487 } else
488 /* non-EAL thread do not run rte_timer_manage(),
489 * so schedule the timer on the first enabled lcore. */
490 tim_lcore = rte_get_next_lcore(LCORE_ID_ANY, 0, 1);
491 }
492
493 /* wait that the timer is in correct status before update,
494 * and mark it as being configured */
495 ret = timer_set_config_state(tim, &prev_status, priv_timer);
496 if (ret < 0)
497 return -1;
498
499 __TIMER_STAT_ADD(priv_timer, reset, 1);
500 if (prev_status.state == RTE_TIMER_RUNNING &&
501 lcore_id < RTE_MAX_LCORE) {
502 priv_timer[lcore_id].updated = 1;
503 }
504
505 /* remove it from list */
506 if (prev_status.state == RTE_TIMER_PENDING) {
507 timer_del(tim, prev_status, local_is_locked, priv_timer);
508 __TIMER_STAT_ADD(priv_timer, pending, -1);
509 }
510
511 tim->period = period;
512 tim->expire = expire;
513 tim->f = fct;
514 tim->arg = arg;
515
516 /* if timer needs to be scheduled on another core, we need to
517 * lock the destination list; if it is on local core, we need to lock if
518 * we are not called from rte_timer_manage()
519 */
520 if (tim_lcore != lcore_id || !local_is_locked)
521 rte_spinlock_lock(&priv_timer[tim_lcore].list_lock);
522
523 __TIMER_STAT_ADD(priv_timer, pending, 1);
524 timer_add(tim, tim_lcore, priv_timer);

Callers 3

rte_timer_alt_resetFunction · 0.85
__rte_timer_manageFunction · 0.85
rte_timer_alt_manageFunction · 0.85

Calls 7

rte_lcore_idFunction · 0.85
rte_get_next_lcoreFunction · 0.85
timer_set_config_stateFunction · 0.85
timer_delFunction · 0.85
timer_addFunction · 0.85
rte_spinlock_lockFunction · 0.50
rte_spinlock_unlockFunction · 0.50

Tested by

no test coverage detected