Frequency scale down timer callback */
| 425 | |
| 426 | /* Frequency scale down timer callback */ |
| 427 | static void |
| 428 | power_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 */ |
| 470 | static inline int |
nothing calls this directly
no test coverage detected