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

Function power_timer_cb

dpdk/examples/l3fwd-power/main.c:427–467  ·  view source on GitHub ↗

Frequency scale down timer callback */

Source from the content-addressed store, hash-verified

425
426/* Frequency scale down timer callback */
427static void
428power_timer_cb(__rte_unused struct rte_timer *tim,
429 __rte_unused void *arg)
430{
431 uint64_t hz;
432 float sleep_time_ratio;
433 unsigned lcore_id = rte_lcore_id();
434
435 /* accumulate total execution time in us when callback is invoked */
436 sleep_time_ratio = (float)(stats[lcore_id].sleep_time) /
437 (float)SCALING_PERIOD;
438 /**
439 * check whether need to scale down frequency a step if it sleep a lot.
440 */
441 if (sleep_time_ratio >= SCALING_DOWN_TIME_RATIO_THRESHOLD) {
442 if (rte_power_freq_down)
443 rte_power_freq_down(lcore_id);
444 }
445 else if ( (unsigned)(stats[lcore_id].nb_rx_processed /
446 stats[lcore_id].nb_iteration_looped) < MAX_PKT_BURST) {
447 /**
448 * scale down a step if average packet per iteration less
449 * than expectation.
450 */
451 if (rte_power_freq_down)
452 rte_power_freq_down(lcore_id);
453 }
454
455 /**
456 * initialize another timer according to current frequency to ensure
457 * timer interval is relatively fixed.
458 */
459 hz = rte_get_timer_hz();
460 rte_timer_reset(&power_timers[lcore_id], hz/TIMER_NUMBER_PER_SECOND,
461 SINGLE, lcore_id, power_timer_cb, NULL);
462
463 stats[lcore_id].nb_rx_processed = 0;
464 stats[lcore_id].nb_iteration_looped = 0;
465
466 stats[lcore_id].sleep_time = 0;
467}
468
469/* Enqueue a single packet, and send burst if queue is filled */
470static inline int

Callers

nothing calls this directly

Calls 2

rte_lcore_idFunction · 0.85
rte_timer_resetFunction · 0.85

Tested by

no test coverage detected