X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=examples%2Fvm_power_manager%2Fpower_manager.c;h=9d4e587b0f99369fe5710ded2135753f607e93fa;hb=84057fd07e6664e8a656531f23b64ed5c41e039a;hp=b7769c3c329945185708690f3b8d5da271dc8c5d;hpb=711f43ba568acadf6cbccb9f8a29abf0fb3baa25;p=dpdk.git diff --git a/examples/vm_power_manager/power_manager.c b/examples/vm_power_manager/power_manager.c index b7769c3c32..9d4e587b0f 100644 --- a/examples/vm_power_manager/power_manager.c +++ b/examples/vm_power_manager/power_manager.c @@ -33,27 +33,13 @@ rte_spinlock_unlock(&global_core_freq_info[core_num].power_sl); \ } while (0) -#define POWER_SCALE_MASK(DIRECTION, core_mask, ret) do { \ - int i; \ - for (i = 0; core_mask; core_mask &= ~(1 << i++)) { \ - if ((core_mask >> i) & 1) { \ - if (!(ci.cd[i].global_enabled_cpus)) \ - continue; \ - rte_spinlock_lock(&global_core_freq_info[i].power_sl); \ - if (rte_power_freq_##DIRECTION(i) != 1) \ - ret = -1; \ - rte_spinlock_unlock(&global_core_freq_info[i].power_sl); \ - } \ - } \ -} while (0) - struct freq_info { rte_spinlock_t power_sl; uint32_t freqs[RTE_MAX_LCORE_FREQS]; unsigned num_freqs; } __rte_cache_aligned; -static struct freq_info global_core_freq_info[POWER_MGR_MAX_CPUS]; +static struct freq_info global_core_freq_info[RTE_MAX_LCORE]; struct core_info ci; @@ -95,8 +81,9 @@ power_manager_init(void) unsigned int i, num_cpus = 0, num_freqs = 0; int ret = 0; struct core_info *ci; + unsigned int max_core_num; - rte_power_set_env(PM_ENV_ACPI_CPUFREQ); + rte_power_set_env(PM_ENV_NOT_SET); ci = get_core_info(); if (!ci) { @@ -105,7 +92,12 @@ power_manager_init(void) return -1; } - for (i = 0; i < ci->core_count; i++) { + if (ci->core_count > RTE_MAX_LCORE) + max_core_num = RTE_MAX_LCORE; + else + max_core_num = ci->core_count; + + for (i = 0; i < max_core_num; i++) { if (ci->cd[i].global_enabled_cpus) { if (rte_power_init(i) < 0) RTE_LOG(ERR, POWER_MANAGER, @@ -140,9 +132,9 @@ power_manager_get_current_frequency(unsigned core_num) { uint32_t freq, index; - if (core_num >= POWER_MGR_MAX_CPUS) { + if (core_num >= RTE_MAX_LCORE) { RTE_LOG(ERR, POWER_MANAGER, "Core(%u) is out of range 0...%d\n", - core_num, POWER_MGR_MAX_CPUS-1); + core_num, RTE_MAX_LCORE-1); return -1; } if (!(ci.cd[core_num].global_enabled_cpus)) @@ -151,7 +143,7 @@ power_manager_get_current_frequency(unsigned core_num) rte_spinlock_lock(&global_core_freq_info[core_num].power_sl); index = rte_power_get_freq(core_num); rte_spinlock_unlock(&global_core_freq_info[core_num].power_sl); - if (index >= POWER_MGR_MAX_CPUS) + if (index >= RTE_MAX_LCORE_FREQS) freq = 0; else freq = global_core_freq_info[core_num].freqs[index]; @@ -165,6 +157,7 @@ power_manager_exit(void) unsigned int i; int ret = 0; struct core_info *ci; + unsigned int max_core_num; ci = get_core_info(); if (!ci) { @@ -173,7 +166,12 @@ power_manager_exit(void) return -1; } - for (i = 0; i < ci->core_count; i++) { + if (ci->core_count > RTE_MAX_LCORE) + max_core_num = RTE_MAX_LCORE; + else + max_core_num = ci->core_count; + + for (i = 0; i < max_core_num; i++) { if (ci->cd[i].global_enabled_cpus) { if (rte_power_exit(i) < 0) { RTE_LOG(ERR, POWER_MANAGER, "Unable to shutdown power manager " @@ -187,60 +185,6 @@ power_manager_exit(void) return ret; } -int -power_manager_scale_mask_up(uint64_t core_mask) -{ - int ret = 0; - - POWER_SCALE_MASK(up, core_mask, ret); - return ret; -} - -int -power_manager_scale_mask_down(uint64_t core_mask) -{ - int ret = 0; - - POWER_SCALE_MASK(down, core_mask, ret); - return ret; -} - -int -power_manager_scale_mask_min(uint64_t core_mask) -{ - int ret = 0; - - POWER_SCALE_MASK(min, core_mask, ret); - return ret; -} - -int -power_manager_scale_mask_max(uint64_t core_mask) -{ - int ret = 0; - - POWER_SCALE_MASK(max, core_mask, ret); - return ret; -} - -int -power_manager_enable_turbo_mask(uint64_t core_mask) -{ - int ret = 0; - - POWER_SCALE_MASK(enable_turbo, core_mask, ret); - return ret; -} - -int -power_manager_disable_turbo_mask(uint64_t core_mask) -{ - int ret = 0; - - POWER_SCALE_MASK(disable_turbo, core_mask, ret); - return ret; -} - int power_manager_scale_core_up(unsigned core_num) { @@ -302,7 +246,7 @@ power_manager_scale_core_med(unsigned int core_num) struct core_info *ci; ci = get_core_info(); - if (core_num >= POWER_MGR_MAX_CPUS) + if (core_num >= RTE_MAX_LCORE) return -1; if (!(ci->cd[core_num].global_enabled_cpus)) return -1;