dpdk_governor: refactor _get_core_curr_freqs

Currently _get_core_curr_freqs returns an index from the array
of available frequencies for given core. This change aims to
make this function execute what its name suggests.

Signed-off-by: Krzysztof Karas <krzysztof.karas@intel.com>
Change-Id: I1143f692e7bbbf2f8f9e1cd4943f8e3ecd70ddea
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7452
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Krzysztof Karas 2021-04-16 12:31:56 +02:00 committed by Jim Harris
parent dbef0cfd02
commit 84c349e1d8

View File

@ -49,7 +49,25 @@ _get_core_freqs(uint32_t lcore_id, uint32_t *freqs, uint32_t num)
static uint32_t
_get_core_curr_freq(uint32_t lcore_id)
{
return rte_power_get_freq(lcore_id);
const uint32_t MAX_CORE_FREQ_NUM = 64;
uint32_t freqs[MAX_CORE_FREQ_NUM];
uint32_t freq_index;
int rc;
rc = rte_power_freqs(lcore_id, freqs, MAX_CORE_FREQ_NUM);
if (!rc) {
SPDK_ERRLOG("Unable to get current core frequency array for core %d\n.", lcore_id);
return 0;
}
freq_index = rte_power_get_freq(lcore_id);
if (freq_index >= MAX_CORE_FREQ_NUM) {
SPDK_ERRLOG("Unable to get current core frequency for core %d\n.", lcore_id);
return 0;
}
return freqs[freq_index];
}
static int