* Copyright(c) 2010-2014 Intel Corporation
*/
+#include <rte_errno.h>
#include <rte_spinlock.h>
#include "rte_power.h"
rte_power_freq_change_t rte_power_freq_disable_turbo;
rte_power_get_capabilities_t rte_power_get_capabilities;
+static void
+reset_power_function_ptrs(void)
+{
+ rte_power_freqs = NULL;
+ rte_power_get_freq = NULL;
+ rte_power_set_freq = NULL;
+ rte_power_freq_up = NULL;
+ rte_power_freq_down = NULL;
+ rte_power_freq_max = NULL;
+ rte_power_freq_min = NULL;
+ rte_power_turbo_status = NULL;
+ rte_power_freq_enable_turbo = NULL;
+ rte_power_freq_disable_turbo = NULL;
+ rte_power_get_capabilities = NULL;
+}
+
+int
+rte_power_check_env_supported(enum power_management_env env)
+{
+ switch (env) {
+ case PM_ENV_ACPI_CPUFREQ:
+ return power_acpi_cpufreq_check_supported();
+ case PM_ENV_PSTATE_CPUFREQ:
+ return power_pstate_cpufreq_check_supported();
+ case PM_ENV_KVM_VM:
+ return power_kvm_vm_check_supported();
+ default:
+ rte_errno = EINVAL;
+ return -1;
+ }
+}
+
int
rte_power_set_env(enum power_management_env env)
{
rte_spinlock_lock(&global_env_cfg_lock);
if (global_default_env != PM_ENV_NOT_SET) {
+ RTE_LOG(ERR, POWER, "Power Management Environment already set.\n");
rte_spinlock_unlock(&global_env_cfg_lock);
- return 0;
+ return -1;
}
int ret = 0;
if (ret == 0)
global_default_env = env;
- else
+ else {
global_default_env = PM_ENV_NOT_SET;
+ reset_power_function_ptrs();
+ }
rte_spinlock_unlock(&global_env_cfg_lock);
return ret;
{
rte_spinlock_lock(&global_env_cfg_lock);
global_default_env = PM_ENV_NOT_SET;
+ reset_power_function_ptrs();
rte_spinlock_unlock(&global_env_cfg_lock);
}