# all source are stored in SRCS-y
SRCS-$(CONFIG_RTE_LIBRTE_POWER) := rte_power.c power_acpi_cpufreq.c
-SRCS-$(CONFIG_RTE_LIBRTE_POWER) += rte_power_kvm_vm.c guest_channel.c
+SRCS-$(CONFIG_RTE_LIBRTE_POWER) += power_kvm_vm.c guest_channel.c
# install this header file
SYMLINK-$(CONFIG_RTE_LIBRTE_POWER)-include := rte_power.h
--- /dev/null
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2014 Intel Corporation
+ */
+#include <errno.h>
+#include <string.h>
+
+#include <rte_log.h>
+
+#include "guest_channel.h"
+#include "channel_commands.h"
+#include "power_kvm_vm.h"
+#include "power_common.h"
+
+#define FD_PATH "/dev/virtio-ports/virtio.serial.port.poweragent"
+
+static struct channel_packet pkt[CHANNEL_CMDS_MAX_VM_CHANNELS];
+
+
+int
+power_kvm_vm_init(unsigned int lcore_id)
+{
+ if (lcore_id >= CHANNEL_CMDS_MAX_VM_CHANNELS) {
+ RTE_LOG(ERR, POWER, "Core(%u) is out of range 0...%d\n",
+ lcore_id, CHANNEL_CMDS_MAX_VM_CHANNELS-1);
+ return -1;
+ }
+ pkt[lcore_id].command = CPU_POWER;
+ pkt[lcore_id].resource_id = lcore_id;
+ return guest_channel_host_connect(FD_PATH, lcore_id);
+}
+
+int
+power_kvm_vm_exit(unsigned int lcore_id)
+{
+ guest_channel_host_disconnect(lcore_id);
+ return 0;
+}
+
+uint32_t
+power_kvm_vm_freqs(__attribute__((unused)) unsigned int lcore_id,
+ __attribute__((unused)) uint32_t *freqs,
+ __attribute__((unused)) uint32_t num)
+{
+ RTE_LOG(ERR, POWER, "rte_power_freqs is not implemented "
+ "for Virtual Machine Power Management\n");
+ return -ENOTSUP;
+}
+
+uint32_t
+power_kvm_vm_get_freq(__attribute__((unused)) unsigned int lcore_id)
+{
+ RTE_LOG(ERR, POWER, "rte_power_get_freq is not implemented "
+ "for Virtual Machine Power Management\n");
+ return -ENOTSUP;
+}
+
+int
+power_kvm_vm_set_freq(__attribute__((unused)) unsigned int lcore_id,
+ __attribute__((unused)) uint32_t index)
+{
+ RTE_LOG(ERR, POWER, "rte_power_set_freq is not implemented "
+ "for Virtual Machine Power Management\n");
+ return -ENOTSUP;
+}
+
+static inline int
+send_msg(unsigned int lcore_id, uint32_t scale_direction)
+{
+ int ret;
+
+ if (lcore_id >= CHANNEL_CMDS_MAX_VM_CHANNELS) {
+ RTE_LOG(ERR, POWER, "Core(%u) is out of range 0...%d\n",
+ lcore_id, CHANNEL_CMDS_MAX_VM_CHANNELS-1);
+ return -1;
+ }
+ pkt[lcore_id].unit = scale_direction;
+ ret = guest_channel_send_msg(&pkt[lcore_id], lcore_id);
+ if (ret == 0)
+ return 1;
+ RTE_LOG(DEBUG, POWER, "Error sending message: %s\n",
+ ret > 0 ? strerror(ret) : "channel not connected");
+ return -1;
+}
+
+int
+power_kvm_vm_freq_up(unsigned int lcore_id)
+{
+ return send_msg(lcore_id, CPU_POWER_SCALE_UP);
+}
+
+int
+power_kvm_vm_freq_down(unsigned int lcore_id)
+{
+ return send_msg(lcore_id, CPU_POWER_SCALE_DOWN);
+}
+
+int
+power_kvm_vm_freq_max(unsigned int lcore_id)
+{
+ return send_msg(lcore_id, CPU_POWER_SCALE_MAX);
+}
+
+int
+power_kvm_vm_freq_min(unsigned int lcore_id)
+{
+ return send_msg(lcore_id, CPU_POWER_SCALE_MIN);
+}
+
+int
+power_kvm_vm_turbo_status(__attribute__((unused)) unsigned int lcore_id)
+{
+ RTE_LOG(ERR, POWER, "rte_power_turbo_status is not implemented for Virtual Machine Power Management\n");
+ return -ENOTSUP;
+}
+
+int
+power_kvm_vm_enable_turbo(unsigned int lcore_id)
+{
+ return send_msg(lcore_id, CPU_POWER_ENABLE_TURBO);
+}
+
+int
+power_kvm_vm_disable_turbo(unsigned int lcore_id)
+{
+ return send_msg(lcore_id, CPU_POWER_DISABLE_TURBO);
+}
--- /dev/null
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2014 Intel Corporation
+ */
+
+#ifndef _POWER_KVM_VM_H
+#define _POWER_KVM_VM_H
+
+/**
+ * @file
+ * RTE Power Management KVM VM
+ */
+
+#include <rte_common.h>
+#include <rte_byteorder.h>
+#include <rte_log.h>
+#include <rte_string_fns.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Initialize power management for a specific lcore.
+ *
+ * @param lcore_id
+ * lcore id.
+ *
+ * @return
+ * - 0 on success.
+ * - Negative on error.
+ */
+int power_kvm_vm_init(unsigned int lcore_id);
+
+/**
+ * Exit power management on a specific lcore.
+ *
+ * @param lcore_id
+ * lcore id.
+ *
+ * @return
+ * - 0 on success.
+ * - Negative on error.
+ */
+int power_kvm_vm_exit(unsigned int lcore_id);
+
+/**
+ * Get the available frequencies of a specific lcore.
+ * It is not currently supported for VM Power Management.
+ *
+ * @param lcore_id
+ * lcore id.
+ * @param freqs
+ * The buffer array to save the frequencies.
+ * @param num
+ * The number of frequencies to get.
+ *
+ * @return
+ * -ENOTSUP
+ */
+uint32_t power_kvm_vm_freqs(unsigned int lcore_id, uint32_t *freqs,
+ uint32_t num);
+
+/**
+ * Return the current index of available frequencies of a specific lcore.
+ * It is not currently supported for VM Power Management.
+ *
+ * @param lcore_id
+ * lcore id.
+ *
+ * @return
+ * -ENOTSUP
+ */
+uint32_t power_kvm_vm_get_freq(unsigned int lcore_id);
+
+/**
+ * Set the new frequency for a specific lcore by indicating the index of
+ * available frequencies.
+ * It is not currently supported for VM Power Management.
+ *
+ * @param lcore_id
+ * lcore id.
+ * @param index
+ * The index of available frequencies.
+ *
+ * @return
+ * -ENOTSUP
+ */
+int power_kvm_vm_set_freq(unsigned int lcore_id, uint32_t index);
+
+/**
+ * Scale up the frequency of a specific lcore. This request is forwarded to the
+ * host monitor.
+ * It should be protected outside of this function for threadsafe.
+ *
+ * @param lcore_id
+ * lcore id.
+ *
+ * @return
+ * - 1 on success.
+ * - Negative on error.
+ */
+int power_kvm_vm_freq_up(unsigned int lcore_id);
+
+/**
+ * Scale down the frequency of a specific lcore according to the available
+ * frequencies.
+ * It should be protected outside of this function for threadsafe.
+ *
+ * @param lcore_id
+ * lcore id.
+ *
+ * @return
+ * - 1 on success.
+ * - Negative on error.
+ */
+int power_kvm_vm_freq_down(unsigned int lcore_id);
+
+/**
+ * Scale up the frequency of a specific lcore to the highest according to the
+ * available frequencies.
+ * It should be protected outside of this function for threadsafe.
+ *
+ * @param lcore_id
+ * lcore id.
+ *
+ * @return
+ * - 1 on success.
+ * - Negative on error.
+ */
+int power_kvm_vm_freq_max(unsigned int lcore_id);
+
+/**
+ * Scale down the frequency of a specific lcore to the lowest according to the
+ * available frequencies.
+ * It should be protected outside of this function for threadsafe.
+ *
+ * @param lcore_id
+ * lcore id.
+ *
+ * @return
+ * - 1 on success.
+ * - Negative on error.
+ */
+int power_kvm_vm_freq_min(unsigned int lcore_id);
+
+/**
+ * It should be protected outside of this function for threadsafe.
+ *
+ * @param lcore_id
+ * lcore id.
+ *
+ * @return
+ * -ENOTSUP
+ */
+int power_kvm_vm_turbo_status(unsigned int lcore_id);
+
+/**
+ * It should be protected outside of this function for threadsafe.
+ *
+ * @param lcore_id
+ * lcore id.
+ *
+ * @return
+ * - 1 on success.
+ * - Negative on error.
+ */
+int power_kvm_vm_enable_turbo(unsigned int lcore_id);
+
+/**
+ * It should be protected outside of this function for threadsafe.
+ *
+ * @param lcore_id
+ * lcore id.
+ *
+ * @return
+ * - 1 on success.
+ * - Negative on error.
+ */
+int power_kvm_vm_disable_turbo(unsigned int lcore_id);
+#ifdef __cplusplus
+}
+#endif
+#endif
#include "rte_power.h"
#include "power_acpi_cpufreq.h"
-#include "rte_power_kvm_vm.h"
+#include "power_kvm_vm.h"
#include "power_common.h"
enum power_management_env global_default_env = PM_ENV_NOT_SET;
rte_power_freq_enable_turbo = power_acpi_enable_turbo;
rte_power_freq_disable_turbo = power_acpi_disable_turbo;
} else if (env == PM_ENV_KVM_VM) {
- rte_power_freqs = rte_power_kvm_vm_freqs;
- rte_power_get_freq = rte_power_kvm_vm_get_freq;
- rte_power_set_freq = rte_power_kvm_vm_set_freq;
- rte_power_freq_up = rte_power_kvm_vm_freq_up;
- rte_power_freq_down = rte_power_kvm_vm_freq_down;
- rte_power_freq_min = rte_power_kvm_vm_freq_min;
- rte_power_freq_max = rte_power_kvm_vm_freq_max;
- rte_power_turbo_status = rte_power_kvm_vm_turbo_status;
- rte_power_freq_enable_turbo = rte_power_kvm_vm_enable_turbo;
- rte_power_freq_disable_turbo = rte_power_kvm_vm_disable_turbo;
+ rte_power_freqs = power_kvm_vm_freqs;
+ rte_power_get_freq = power_kvm_vm_get_freq;
+ rte_power_set_freq = power_kvm_vm_set_freq;
+ rte_power_freq_up = power_kvm_vm_freq_up;
+ rte_power_freq_down = power_kvm_vm_freq_down;
+ rte_power_freq_min = power_kvm_vm_freq_min;
+ rte_power_freq_max = power_kvm_vm_freq_max;
+ rte_power_turbo_status = power_kvm_vm_turbo_status;
+ rte_power_freq_enable_turbo = power_kvm_vm_enable_turbo;
+ rte_power_freq_disable_turbo = power_kvm_vm_disable_turbo;
} else {
RTE_LOG(ERR, POWER, "Invalid Power Management Environment(%d) set\n",
env);
return power_acpi_cpufreq_init(lcore_id);
}
if (global_default_env == PM_ENV_KVM_VM) {
- return rte_power_kvm_vm_init(lcore_id);
+ return power_kvm_vm_init(lcore_id);
}
/* Auto detect Environment */
RTE_LOG(INFO, POWER, "Attempting to initialise ACPI cpufreq power "
}
RTE_LOG(INFO, POWER, "Attempting to initialise VM power management...\n");
- ret = rte_power_kvm_vm_init(lcore_id);
+ ret = power_kvm_vm_init(lcore_id);
if (ret == 0) {
rte_power_set_env(PM_ENV_KVM_VM);
goto out;
if (global_default_env == PM_ENV_ACPI_CPUFREQ)
return power_acpi_cpufreq_exit(lcore_id);
if (global_default_env == PM_ENV_KVM_VM)
- return rte_power_kvm_vm_exit(lcore_id);
+ return power_kvm_vm_exit(lcore_id);
RTE_LOG(ERR, POWER, "Environment has not been set, unable to exit "
"gracefully\n");
+++ /dev/null
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2010-2014 Intel Corporation
- */
-#include <errno.h>
-#include <string.h>
-
-#include <rte_log.h>
-
-#include "guest_channel.h"
-#include "channel_commands.h"
-#include "rte_power_kvm_vm.h"
-#include "power_common.h"
-
-#define FD_PATH "/dev/virtio-ports/virtio.serial.port.poweragent"
-
-static struct channel_packet pkt[CHANNEL_CMDS_MAX_VM_CHANNELS];
-
-
-int
-rte_power_kvm_vm_init(unsigned int lcore_id)
-{
- if (lcore_id >= CHANNEL_CMDS_MAX_VM_CHANNELS) {
- RTE_LOG(ERR, POWER, "Core(%u) is out of range 0...%d\n",
- lcore_id, CHANNEL_CMDS_MAX_VM_CHANNELS-1);
- return -1;
- }
- pkt[lcore_id].command = CPU_POWER;
- pkt[lcore_id].resource_id = lcore_id;
- return guest_channel_host_connect(FD_PATH, lcore_id);
-}
-
-int
-rte_power_kvm_vm_exit(unsigned int lcore_id)
-{
- guest_channel_host_disconnect(lcore_id);
- return 0;
-}
-
-uint32_t
-rte_power_kvm_vm_freqs(__attribute__((unused)) unsigned int lcore_id,
- __attribute__((unused)) uint32_t *freqs,
- __attribute__((unused)) uint32_t num)
-{
- RTE_LOG(ERR, POWER, "rte_power_freqs is not implemented "
- "for Virtual Machine Power Management\n");
- return -ENOTSUP;
-}
-
-uint32_t
-rte_power_kvm_vm_get_freq(__attribute__((unused)) unsigned int lcore_id)
-{
- RTE_LOG(ERR, POWER, "rte_power_get_freq is not implemented "
- "for Virtual Machine Power Management\n");
- return -ENOTSUP;
-}
-
-int
-rte_power_kvm_vm_set_freq(__attribute__((unused)) unsigned int lcore_id,
- __attribute__((unused)) uint32_t index)
-{
- RTE_LOG(ERR, POWER, "rte_power_set_freq is not implemented "
- "for Virtual Machine Power Management\n");
- return -ENOTSUP;
-}
-
-static inline int
-send_msg(unsigned int lcore_id, uint32_t scale_direction)
-{
- int ret;
-
- if (lcore_id >= CHANNEL_CMDS_MAX_VM_CHANNELS) {
- RTE_LOG(ERR, POWER, "Core(%u) is out of range 0...%d\n",
- lcore_id, CHANNEL_CMDS_MAX_VM_CHANNELS-1);
- return -1;
- }
- pkt[lcore_id].unit = scale_direction;
- ret = guest_channel_send_msg(&pkt[lcore_id], lcore_id);
- if (ret == 0)
- return 1;
- RTE_LOG(DEBUG, POWER, "Error sending message: %s\n",
- ret > 0 ? strerror(ret) : "channel not connected");
- return -1;
-}
-
-int
-rte_power_kvm_vm_freq_up(unsigned int lcore_id)
-{
- return send_msg(lcore_id, CPU_POWER_SCALE_UP);
-}
-
-int
-rte_power_kvm_vm_freq_down(unsigned int lcore_id)
-{
- return send_msg(lcore_id, CPU_POWER_SCALE_DOWN);
-}
-
-int
-rte_power_kvm_vm_freq_max(unsigned int lcore_id)
-{
- return send_msg(lcore_id, CPU_POWER_SCALE_MAX);
-}
-
-int
-rte_power_kvm_vm_freq_min(unsigned int lcore_id)
-{
- return send_msg(lcore_id, CPU_POWER_SCALE_MIN);
-}
-
-int
-rte_power_kvm_vm_turbo_status(__attribute__((unused)) unsigned int lcore_id)
-{
- RTE_LOG(ERR, POWER, "rte_power_turbo_status is not implemented for Virtual Machine Power Management\n");
- return -ENOTSUP;
-}
-
-int
-rte_power_kvm_vm_enable_turbo(unsigned int lcore_id)
-{
- return send_msg(lcore_id, CPU_POWER_ENABLE_TURBO);
-}
-
-int
-rte_power_kvm_vm_disable_turbo(unsigned int lcore_id)
-{
- return send_msg(lcore_id, CPU_POWER_DISABLE_TURBO);
-}
+++ /dev/null
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2010-2014 Intel Corporation
- */
-
-#ifndef _RTE_POWER_KVM_VM_H
-#define _RTE_POWER_KVM_VM_H
-
-/**
- * @file
- * RTE Power Management KVM VM
- */
-
-#include <rte_common.h>
-#include <rte_byteorder.h>
-#include <rte_log.h>
-#include <rte_string_fns.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * Initialize power management for a specific lcore.
- *
- * @param lcore_id
- * lcore id.
- *
- * @return
- * - 0 on success.
- * - Negative on error.
- */
-int rte_power_kvm_vm_init(unsigned int lcore_id);
-
-/**
- * Exit power management on a specific lcore.
- *
- * @param lcore_id
- * lcore id.
- *
- * @return
- * - 0 on success.
- * - Negative on error.
- */
-int rte_power_kvm_vm_exit(unsigned int lcore_id);
-
-/**
- * Get the available frequencies of a specific lcore.
- * It is not currently supported for VM Power Management.
- *
- * @param lcore_id
- * lcore id.
- * @param freqs
- * The buffer array to save the frequencies.
- * @param num
- * The number of frequencies to get.
- *
- * @return
- * -ENOTSUP
- */
-uint32_t rte_power_kvm_vm_freqs(unsigned int lcore_id, uint32_t *freqs,
- uint32_t num);
-
-/**
- * Return the current index of available frequencies of a specific lcore.
- * It is not currently supported for VM Power Management.
- *
- * @param lcore_id
- * lcore id.
- *
- * @return
- * -ENOTSUP
- */
-uint32_t rte_power_kvm_vm_get_freq(unsigned int lcore_id);
-
-/**
- * Set the new frequency for a specific lcore by indicating the index of
- * available frequencies.
- * It is not currently supported for VM Power Management.
- *
- * @param lcore_id
- * lcore id.
- * @param index
- * The index of available frequencies.
- *
- * @return
- * -ENOTSUP
- */
-int rte_power_kvm_vm_set_freq(unsigned int lcore_id, uint32_t index);
-
-/**
- * Scale up the frequency of a specific lcore. This request is forwarded to the
- * host monitor.
- * It should be protected outside of this function for threadsafe.
- *
- * @param lcore_id
- * lcore id.
- *
- * @return
- * - 1 on success.
- * - Negative on error.
- */
-int rte_power_kvm_vm_freq_up(unsigned int lcore_id);
-
-/**
- * Scale down the frequency of a specific lcore according to the available
- * frequencies.
- * It should be protected outside of this function for threadsafe.
- *
- * @param lcore_id
- * lcore id.
- *
- * @return
- * - 1 on success.
- * - Negative on error.
- */
-int rte_power_kvm_vm_freq_down(unsigned int lcore_id);
-
-/**
- * Scale up the frequency of a specific lcore to the highest according to the
- * available frequencies.
- * It should be protected outside of this function for threadsafe.
- *
- * @param lcore_id
- * lcore id.
- *
- * @return
- * - 1 on success.
- * - Negative on error.
- */
-int rte_power_kvm_vm_freq_max(unsigned int lcore_id);
-
-/**
- * Scale down the frequency of a specific lcore to the lowest according to the
- * available frequencies.
- * It should be protected outside of this function for threadsafe.
- *
- * @param lcore_id
- * lcore id.
- *
- * @return
- * - 1 on success.
- * - Negative on error.
- */
-int rte_power_kvm_vm_freq_min(unsigned int lcore_id);
-
-/**
- * It should be protected outside of this function for threadsafe.
- *
- * @param lcore_id
- * lcore id.
- *
- * @return
- * -ENOTSUP
- */
-int rte_power_kvm_vm_turbo_status(unsigned int lcore_id);
-
-/**
- * It should be protected outside of this function for threadsafe.
- *
- * @param lcore_id
- * lcore id.
- *
- * @return
- * - 1 on success.
- * - Negative on error.
- */
-int rte_power_kvm_vm_enable_turbo(unsigned int lcore_id);
-
-/**
- * It should be protected outside of this function for threadsafe.
- *
- * @param lcore_id
- * lcore id.
- *
- * @return
- * - 1 on success.
- * - Negative on error.
- */
-int rte_power_kvm_vm_disable_turbo(unsigned int lcore_id);
-#ifdef __cplusplus
-}
-#endif
-#endif