aboutsummaryrefslogtreecommitdiffstats
path: root/lib/librte_power
diff options
context:
space:
mode:
authorLuca Boccassi <luca.boccassi@gmail.com>2018-02-19 11:16:57 +0000
committerLuca Boccassi <luca.boccassi@gmail.com>2018-02-19 11:17:28 +0000
commitca33590b6af032bff57d9cc70455660466a654b2 (patch)
tree0b68b090bd9b4a78a3614b62400b29279d76d553 /lib/librte_power
parent169a9de21e263aa6599cdc2d87a45ae158d9f509 (diff)
New upstream version 18.02upstream/18.02
Change-Id: I89ed24cb2a49b78fe5be6970b99dd46c1499fcc3 Signed-off-by: Luca Boccassi <luca.boccassi@gmail.com>
Diffstat (limited to 'lib/librte_power')
-rw-r--r--lib/librte_power/Makefile36
-rw-r--r--lib/librte_power/channel_commands.h33
-rw-r--r--lib/librte_power/guest_channel.c39
-rw-r--r--lib/librte_power/guest_channel.h39
-rw-r--r--lib/librte_power/meson.build9
-rw-r--r--lib/librte_power/power_acpi_cpufreq.c (renamed from lib/librte_power/rte_power_acpi_cpufreq.c)71
-rw-r--r--lib/librte_power/power_acpi_cpufreq.h (renamed from lib/librte_power/rte_power_acpi_cpufreq.h)61
-rw-r--r--lib/librte_power/power_common.h10
-rw-r--r--lib/librte_power/power_kvm_vm.c126
-rw-r--r--lib/librte_power/power_kvm_vm.h (renamed from lib/librte_power/rte_power_kvm_vm.h)61
-rw-r--r--lib/librte_power/rte_power.c95
-rw-r--r--lib/librte_power/rte_power.h45
-rw-r--r--lib/librte_power/rte_power_common.h39
-rw-r--r--lib/librte_power/rte_power_kvm_vm.c155
14 files changed, 255 insertions, 564 deletions
diff --git a/lib/librte_power/Makefile b/lib/librte_power/Makefile
index 1b1491d7..6f85e885 100644
--- a/lib/librte_power/Makefile
+++ b/lib/librte_power/Makefile
@@ -1,33 +1,5 @@
-# BSD LICENSE
-#
-# Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in
-# the documentation and/or other materials provided with the
-# distribution.
-# * Neither the name of Intel Corporation nor the names of its
-# contributors may be used to endorse or promote products derived
-# from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2010-2014 Intel Corporation
include $(RTE_SDK)/mk/rte.vars.mk
@@ -42,8 +14,8 @@ EXPORT_MAP := rte_power_version.map
LIBABIVER := 1
# all source are stored in SRCS-y
-SRCS-$(CONFIG_RTE_LIBRTE_POWER) := rte_power.c rte_power_acpi_cpufreq.c
-SRCS-$(CONFIG_RTE_LIBRTE_POWER) += rte_power_kvm_vm.c guest_channel.c
+SRCS-$(CONFIG_RTE_LIBRTE_POWER) := rte_power.c power_acpi_cpufreq.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
diff --git a/lib/librte_power/channel_commands.h b/lib/librte_power/channel_commands.h
index f0f5f0a2..5e8b4ab5 100644
--- a/lib/librte_power/channel_commands.h
+++ b/lib/librte_power/channel_commands.h
@@ -1,34 +1,5 @@
-/*-
- * BSD LICENSE
- *
- * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Intel Corporation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2014 Intel Corporation
*/
#ifndef CHANNEL_COMMANDS_H_
diff --git a/lib/librte_power/guest_channel.c b/lib/librte_power/guest_channel.c
index fa5de0f5..c17ea46b 100644
--- a/lib/librte_power/guest_channel.c
+++ b/lib/librte_power/guest_channel.c
@@ -1,34 +1,5 @@
-/*-
- * BSD LICENSE
- *
- * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Intel Corporation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2014 Intel Corporation
*/
#include <stdio.h>
@@ -51,7 +22,7 @@
static int global_fds[RTE_MAX_LCORE];
int
-guest_channel_host_connect(const char *path, unsigned lcore_id)
+guest_channel_host_connect(const char *path, unsigned int lcore_id)
{
int flags, ret;
struct channel_packet pkt;
@@ -118,7 +89,7 @@ error:
}
int
-guest_channel_send_msg(struct channel_packet *pkt, unsigned lcore_id)
+guest_channel_send_msg(struct channel_packet *pkt, unsigned int lcore_id)
{
int ret, buffer_len = sizeof(*pkt);
void *buffer = pkt;
@@ -156,7 +127,7 @@ int rte_power_guest_channel_send_msg(struct channel_packet *pkt,
void
-guest_channel_host_disconnect(unsigned lcore_id)
+guest_channel_host_disconnect(unsigned int lcore_id)
{
if (lcore_id >= RTE_MAX_LCORE) {
RTE_LOG(ERR, GUEST_CHANNEL, "Channel(%u) is out of range 0...%d\n",
diff --git a/lib/librte_power/guest_channel.h b/lib/librte_power/guest_channel.h
index 741339ca..373d3989 100644
--- a/lib/librte_power/guest_channel.h
+++ b/lib/librte_power/guest_channel.h
@@ -1,34 +1,5 @@
-/*-
- * BSD LICENSE
- *
- * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Intel Corporation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2014 Intel Corporation
*/
#ifndef _GUEST_CHANNEL_H
#define _GUEST_CHANNEL_H
@@ -53,7 +24,7 @@ extern "C" {
* - 0 on success.
* - Negative on error.
*/
-int guest_channel_host_connect(const char *path, unsigned lcore_id);
+int guest_channel_host_connect(const char *path, unsigned int lcore_id);
/**
* Disconnect from an already connected Virtio-Serial Endpoint.
@@ -63,7 +34,7 @@ int guest_channel_host_connect(const char *path, unsigned lcore_id);
* lcore_id.
*
*/
-void guest_channel_host_disconnect(unsigned lcore_id);
+void guest_channel_host_disconnect(unsigned int lcore_id);
/**
* Send a message contained in pkt over the Virtio-Serial to the host endpoint.
@@ -79,7 +50,7 @@ void guest_channel_host_disconnect(unsigned lcore_id);
* - Negative on channel not connected.
* - errno on write to channel error.
*/
-int guest_channel_send_msg(struct channel_packet *pkt, unsigned lcore_id);
+int guest_channel_send_msg(struct channel_packet *pkt, unsigned int lcore_id);
/**
* Send a message contained in pkt over the Virtio-Serial to the host endpoint.
diff --git a/lib/librte_power/meson.build b/lib/librte_power/meson.build
new file mode 100644
index 00000000..253173f2
--- /dev/null
+++ b/lib/librte_power/meson.build
@@ -0,0 +1,9 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2017 Intel Corporation
+
+if host_machine.system() != 'linux'
+ build = false
+endif
+sources = files('rte_power.c', 'power_acpi_cpufreq.c',
+ 'power_kvm_vm.c', 'guest_channel.c')
+headers = files('rte_power.h')
diff --git a/lib/librte_power/rte_power_acpi_cpufreq.c b/lib/librte_power/power_acpi_cpufreq.c
index 6b0cdb2e..bce933e9 100644
--- a/lib/librte_power/rte_power_acpi_cpufreq.c
+++ b/lib/librte_power/power_acpi_cpufreq.c
@@ -1,34 +1,5 @@
-/*-
- * BSD LICENSE
- *
- * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Intel Corporation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2014 Intel Corporation
*/
#include <stdio.h>
@@ -44,8 +15,8 @@
#include <rte_memcpy.h>
#include <rte_atomic.h>
-#include "rte_power_acpi_cpufreq.h"
-#include "rte_power_common.h"
+#include "power_acpi_cpufreq.h"
+#include "power_common.h"
#ifdef RTE_LIBRTE_POWER_DEBUG
#define POWER_DEBUG_TRACE(fmt, args...) do { \
@@ -106,7 +77,7 @@ enum power_state {
* Power info per lcore.
*/
struct rte_power_info {
- unsigned lcore_id; /**< Logical core id */
+ unsigned int lcore_id; /**< Logical core id */
uint32_t freqs[RTE_MAX_LCORE_FREQS]; /**< Frequency array */
uint32_t nb_freqs; /**< number of available freqs */
FILE *f; /**< FD of scaling_setspeed */
@@ -311,7 +282,7 @@ out:
}
int
-rte_power_acpi_cpufreq_init(unsigned lcore_id)
+power_acpi_cpufreq_init(unsigned int lcore_id)
{
struct rte_power_info *pi;
@@ -352,7 +323,7 @@ rte_power_acpi_cpufreq_init(unsigned lcore_id)
}
/* Set freq to max by default */
- if (rte_power_acpi_cpufreq_freq_max(lcore_id) < 0) {
+ if (power_acpi_cpufreq_freq_max(lcore_id) < 0) {
RTE_LOG(ERR, POWER, "Cannot set frequency of lcore %u "
"to max\n", lcore_id);
goto fail;
@@ -372,7 +343,7 @@ fail:
/**
* It is to check the governor and then set the original governor back if
- * needed by writing the the sys file.
+ * needed by writing the sys file.
*/
static int
power_set_governor_original(struct rte_power_info *pi)
@@ -419,7 +390,7 @@ out:
}
int
-rte_power_acpi_cpufreq_exit(unsigned lcore_id)
+power_acpi_cpufreq_exit(unsigned int lcore_id)
{
struct rte_power_info *pi;
@@ -461,7 +432,7 @@ fail:
}
uint32_t
-rte_power_acpi_cpufreq_freqs(unsigned lcore_id, uint32_t *freqs, uint32_t num)
+power_acpi_cpufreq_freqs(unsigned int lcore_id, uint32_t *freqs, uint32_t num)
{
struct rte_power_info *pi;
@@ -481,7 +452,7 @@ rte_power_acpi_cpufreq_freqs(unsigned lcore_id, uint32_t *freqs, uint32_t num)
}
uint32_t
-rte_power_acpi_cpufreq_get_freq(unsigned lcore_id)
+power_acpi_cpufreq_get_freq(unsigned int lcore_id)
{
if (lcore_id >= RTE_MAX_LCORE) {
RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
@@ -492,7 +463,7 @@ rte_power_acpi_cpufreq_get_freq(unsigned lcore_id)
}
int
-rte_power_acpi_cpufreq_set_freq(unsigned lcore_id, uint32_t index)
+power_acpi_cpufreq_set_freq(unsigned int lcore_id, uint32_t index)
{
if (lcore_id >= RTE_MAX_LCORE) {
RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
@@ -503,7 +474,7 @@ rte_power_acpi_cpufreq_set_freq(unsigned lcore_id, uint32_t index)
}
int
-rte_power_acpi_cpufreq_freq_down(unsigned lcore_id)
+power_acpi_cpufreq_freq_down(unsigned int lcore_id)
{
struct rte_power_info *pi;
@@ -521,7 +492,7 @@ rte_power_acpi_cpufreq_freq_down(unsigned lcore_id)
}
int
-rte_power_acpi_cpufreq_freq_up(unsigned lcore_id)
+power_acpi_cpufreq_freq_up(unsigned int lcore_id)
{
struct rte_power_info *pi;
@@ -539,7 +510,7 @@ rte_power_acpi_cpufreq_freq_up(unsigned lcore_id)
}
int
-rte_power_acpi_cpufreq_freq_max(unsigned lcore_id)
+power_acpi_cpufreq_freq_max(unsigned int lcore_id)
{
if (lcore_id >= RTE_MAX_LCORE) {
RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
@@ -561,7 +532,7 @@ rte_power_acpi_cpufreq_freq_max(unsigned lcore_id)
}
int
-rte_power_acpi_cpufreq_freq_min(unsigned lcore_id)
+power_acpi_cpufreq_freq_min(unsigned int lcore_id)
{
struct rte_power_info *pi;
@@ -578,7 +549,7 @@ rte_power_acpi_cpufreq_freq_min(unsigned lcore_id)
int
-rte_power_acpi_turbo_status(unsigned int lcore_id)
+power_acpi_turbo_status(unsigned int lcore_id)
{
struct rte_power_info *pi;
@@ -594,7 +565,7 @@ rte_power_acpi_turbo_status(unsigned int lcore_id)
int
-rte_power_acpi_enable_turbo(unsigned int lcore_id)
+power_acpi_enable_turbo(unsigned int lcore_id)
{
struct rte_power_info *pi;
@@ -616,7 +587,7 @@ rte_power_acpi_enable_turbo(unsigned int lcore_id)
}
/* Max may have changed, so call to max function */
- if (rte_power_acpi_cpufreq_freq_max(lcore_id) < 0) {
+ if (power_acpi_cpufreq_freq_max(lcore_id) < 0) {
RTE_LOG(ERR, POWER,
"Failed to set frequency of lcore %u to max\n",
lcore_id);
@@ -627,7 +598,7 @@ rte_power_acpi_enable_turbo(unsigned int lcore_id)
}
int
-rte_power_acpi_disable_turbo(unsigned int lcore_id)
+power_acpi_disable_turbo(unsigned int lcore_id)
{
struct rte_power_info *pi;
@@ -642,7 +613,7 @@ rte_power_acpi_disable_turbo(unsigned int lcore_id)
if ((pi->turbo_available) && (pi->curr_idx <= 1)) {
/* Try to set freq to max by default coming out of turbo */
- if (rte_power_acpi_cpufreq_freq_max(lcore_id) < 0) {
+ if (power_acpi_cpufreq_freq_max(lcore_id) < 0) {
RTE_LOG(ERR, POWER,
"Failed to set frequency of lcore %u to max\n",
lcore_id);
diff --git a/lib/librte_power/rte_power_acpi_cpufreq.h b/lib/librte_power/power_acpi_cpufreq.h
index bc20dfd6..edeeb27a 100644
--- a/lib/librte_power/rte_power_acpi_cpufreq.h
+++ b/lib/librte_power/power_acpi_cpufreq.h
@@ -1,38 +1,9 @@
-/*-
- * BSD LICENSE
- *
- * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Intel Corporation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2014 Intel Corporation
*/
-#ifndef _RTE_POWER_ACPI_CPUFREQ_H
-#define _RTE_POWER_ACPI_CPUFREQ_H
+#ifndef _POWER_ACPI_CPUFREQ_H
+#define _POWER_ACPI_CPUFREQ_H
/**
* @file
@@ -60,7 +31,7 @@ extern "C" {
* - 0 on success.
* - Negative on error.
*/
-int rte_power_acpi_cpufreq_init(unsigned lcore_id);
+int power_acpi_cpufreq_init(unsigned int lcore_id);
/**
* Exit power management on a specific lcore. It will set the governor to which
@@ -73,7 +44,7 @@ int rte_power_acpi_cpufreq_init(unsigned lcore_id);
* - 0 on success.
* - Negative on error.
*/
-int rte_power_acpi_cpufreq_exit(unsigned lcore_id);
+int power_acpi_cpufreq_exit(unsigned int lcore_id);
/**
* Get the available frequencies of a specific lcore. The return value will be
@@ -92,7 +63,7 @@ int rte_power_acpi_cpufreq_exit(unsigned lcore_id);
* @return
* The number of available frequencies.
*/
-uint32_t rte_power_acpi_cpufreq_freqs(unsigned lcore_id, uint32_t *freqs,
+uint32_t power_acpi_cpufreq_freqs(unsigned int lcore_id, uint32_t *freqs,
uint32_t num);
/**
@@ -106,7 +77,7 @@ uint32_t rte_power_acpi_cpufreq_freqs(unsigned lcore_id, uint32_t *freqs,
* @return
* The current index of available frequencies.
*/
-uint32_t rte_power_acpi_cpufreq_get_freq(unsigned lcore_id);
+uint32_t power_acpi_cpufreq_get_freq(unsigned int lcore_id);
/**
* Set the new frequency for a specific lcore by indicating the index of
@@ -123,7 +94,7 @@ uint32_t rte_power_acpi_cpufreq_get_freq(unsigned lcore_id);
* - 0 on success without frequency changed.
* - Negative on error.
*/
-int rte_power_acpi_cpufreq_set_freq(unsigned lcore_id, uint32_t index);
+int power_acpi_cpufreq_set_freq(unsigned int lcore_id, uint32_t index);
/**
* Scale up the frequency of a specific lcore according to the available
@@ -138,7 +109,7 @@ int rte_power_acpi_cpufreq_set_freq(unsigned lcore_id, uint32_t index);
* - 0 on success without frequency changed.
* - Negative on error.
*/
-int rte_power_acpi_cpufreq_freq_up(unsigned lcore_id);
+int power_acpi_cpufreq_freq_up(unsigned int lcore_id);
/**
* Scale down the frequency of a specific lcore according to the available
@@ -153,7 +124,7 @@ int rte_power_acpi_cpufreq_freq_up(unsigned lcore_id);
* - 0 on success without frequency changed.
* - Negative on error.
*/
-int rte_power_acpi_cpufreq_freq_down(unsigned lcore_id);
+int power_acpi_cpufreq_freq_down(unsigned int lcore_id);
/**
* Scale up the frequency of a specific lcore to the highest according to the
@@ -168,7 +139,7 @@ int rte_power_acpi_cpufreq_freq_down(unsigned lcore_id);
* - 0 on success without frequency changed.
* - Negative on error.
*/
-int rte_power_acpi_cpufreq_freq_max(unsigned lcore_id);
+int power_acpi_cpufreq_freq_max(unsigned int lcore_id);
/**
* Scale down the frequency of a specific lcore to the lowest according to the
@@ -183,7 +154,7 @@ int rte_power_acpi_cpufreq_freq_max(unsigned lcore_id);
* - 0 on success without frequency changed.
* - Negative on error.
*/
-int rte_power_acpi_cpufreq_freq_min(unsigned lcore_id);
+int power_acpi_cpufreq_freq_min(unsigned int lcore_id);
/**
* Get the turbo status of a specific lcore.
@@ -197,7 +168,7 @@ int rte_power_acpi_cpufreq_freq_min(unsigned lcore_id);
* - 0 Turbo Boost is disabled on this lcore.
* - Negative on error.
*/
-int rte_power_acpi_turbo_status(unsigned int lcore_id);
+int power_acpi_turbo_status(unsigned int lcore_id);
/**
* Enable Turbo Boost on a specific lcore.
@@ -210,7 +181,7 @@ int rte_power_acpi_turbo_status(unsigned int lcore_id);
* - 0 Turbo Boost is enabled successfully on this lcore.
* - Negative on error.
*/
-int rte_power_acpi_enable_turbo(unsigned int lcore_id);
+int power_acpi_enable_turbo(unsigned int lcore_id);
/**
* Disable Turbo Boost on a specific lcore.
@@ -223,7 +194,7 @@ int rte_power_acpi_enable_turbo(unsigned int lcore_id);
* - 0 Turbo Boost disabled successfully on this lcore.
* - Negative on error.
*/
-int rte_power_acpi_disable_turbo(unsigned int lcore_id);
+int power_acpi_disable_turbo(unsigned int lcore_id);
#ifdef __cplusplus
}
diff --git a/lib/librte_power/power_common.h b/lib/librte_power/power_common.h
new file mode 100644
index 00000000..feeb5777
--- /dev/null
+++ b/lib/librte_power/power_common.h
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2014 Intel Corporation
+ */
+
+#ifndef _POWER_COMMON_H_
+#define _POWER_COMMON_H_
+
+#define RTE_POWER_INVALID_FREQ_INDEX (~0)
+
+#endif /* _POWER_COMMON_H_ */
diff --git a/lib/librte_power/power_kvm_vm.c b/lib/librte_power/power_kvm_vm.c
new file mode 100644
index 00000000..38e9066f
--- /dev/null
+++ b/lib/librte_power/power_kvm_vm.c
@@ -0,0 +1,126 @@
+/* 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);
+}
diff --git a/lib/librte_power/rte_power_kvm_vm.h b/lib/librte_power/power_kvm_vm.h
index 9af41d64..446d6997 100644
--- a/lib/librte_power/rte_power_kvm_vm.h
+++ b/lib/librte_power/power_kvm_vm.h
@@ -1,38 +1,9 @@
-/*-
- * BSD LICENSE
- *
- * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Intel Corporation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2014 Intel Corporation
*/
-#ifndef _RTE_POWER_KVM_VM_H
-#define _RTE_POWER_KVM_VM_H
+#ifndef _POWER_KVM_VM_H
+#define _POWER_KVM_VM_H
/**
* @file
@@ -58,7 +29,7 @@ extern "C" {
* - 0 on success.
* - Negative on error.
*/
-int rte_power_kvm_vm_init(unsigned lcore_id);
+int power_kvm_vm_init(unsigned int lcore_id);
/**
* Exit power management on a specific lcore.
@@ -70,7 +41,7 @@ int rte_power_kvm_vm_init(unsigned lcore_id);
* - 0 on success.
* - Negative on error.
*/
-int rte_power_kvm_vm_exit(unsigned lcore_id);
+int power_kvm_vm_exit(unsigned int lcore_id);
/**
* Get the available frequencies of a specific lcore.
@@ -86,7 +57,7 @@ int rte_power_kvm_vm_exit(unsigned lcore_id);
* @return
* -ENOTSUP
*/
-uint32_t rte_power_kvm_vm_freqs(unsigned lcore_id, uint32_t *freqs,
+uint32_t power_kvm_vm_freqs(unsigned int lcore_id, uint32_t *freqs,
uint32_t num);
/**
@@ -99,7 +70,7 @@ uint32_t rte_power_kvm_vm_freqs(unsigned lcore_id, uint32_t *freqs,
* @return
* -ENOTSUP
*/
-uint32_t rte_power_kvm_vm_get_freq(unsigned lcore_id);
+uint32_t power_kvm_vm_get_freq(unsigned int lcore_id);
/**
* Set the new frequency for a specific lcore by indicating the index of
@@ -114,7 +85,7 @@ uint32_t rte_power_kvm_vm_get_freq(unsigned lcore_id);
* @return
* -ENOTSUP
*/
-int rte_power_kvm_vm_set_freq(unsigned lcore_id, uint32_t index);
+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
@@ -128,7 +99,7 @@ int rte_power_kvm_vm_set_freq(unsigned lcore_id, uint32_t index);
* - 1 on success.
* - Negative on error.
*/
-int rte_power_kvm_vm_freq_up(unsigned lcore_id);
+int power_kvm_vm_freq_up(unsigned int lcore_id);
/**
* Scale down the frequency of a specific lcore according to the available
@@ -142,7 +113,7 @@ int rte_power_kvm_vm_freq_up(unsigned lcore_id);
* - 1 on success.
* - Negative on error.
*/
-int rte_power_kvm_vm_freq_down(unsigned lcore_id);
+int power_kvm_vm_freq_down(unsigned int lcore_id);
/**
* Scale up the frequency of a specific lcore to the highest according to the
@@ -156,7 +127,7 @@ int rte_power_kvm_vm_freq_down(unsigned lcore_id);
* - 1 on success.
* - Negative on error.
*/
-int rte_power_kvm_vm_freq_max(unsigned lcore_id);
+int power_kvm_vm_freq_max(unsigned int lcore_id);
/**
* Scale down the frequency of a specific lcore to the lowest according to the
@@ -170,7 +141,7 @@ int rte_power_kvm_vm_freq_max(unsigned lcore_id);
* - 1 on success.
* - Negative on error.
*/
-int rte_power_kvm_vm_freq_min(unsigned lcore_id);
+int power_kvm_vm_freq_min(unsigned int lcore_id);
/**
* It should be protected outside of this function for threadsafe.
@@ -181,7 +152,7 @@ int rte_power_kvm_vm_freq_min(unsigned lcore_id);
* @return
* -ENOTSUP
*/
-int rte_power_kvm_vm_turbo_status(unsigned int lcore_id);
+int power_kvm_vm_turbo_status(unsigned int lcore_id);
/**
* It should be protected outside of this function for threadsafe.
@@ -193,7 +164,7 @@ int rte_power_kvm_vm_turbo_status(unsigned int lcore_id);
* - 1 on success.
* - Negative on error.
*/
-int rte_power_kvm_vm_enable_turbo(unsigned int lcore_id);
+int power_kvm_vm_enable_turbo(unsigned int lcore_id);
/**
* It should be protected outside of this function for threadsafe.
@@ -205,7 +176,7 @@ int rte_power_kvm_vm_enable_turbo(unsigned int lcore_id);
* - 1 on success.
* - Negative on error.
*/
-int rte_power_kvm_vm_disable_turbo(unsigned int lcore_id);
+int power_kvm_vm_disable_turbo(unsigned int lcore_id);
#ifdef __cplusplus
}
#endif
diff --git a/lib/librte_power/rte_power.c b/lib/librte_power/rte_power.c
index b327a865..6c8fb403 100644
--- a/lib/librte_power/rte_power.c
+++ b/lib/librte_power/rte_power.c
@@ -1,42 +1,13 @@
-/*-
- * BSD LICENSE
- *
- * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Intel Corporation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2014 Intel Corporation
*/
#include <rte_atomic.h>
#include "rte_power.h"
-#include "rte_power_acpi_cpufreq.h"
-#include "rte_power_kvm_vm.h"
-#include "rte_power_common.h"
+#include "power_acpi_cpufreq.h"
+#include "power_kvm_vm.h"
+#include "power_common.h"
enum power_management_env global_default_env = PM_ENV_NOT_SET;
@@ -61,27 +32,27 @@ rte_power_set_env(enum power_management_env env)
return 0;
}
if (env == PM_ENV_ACPI_CPUFREQ) {
- rte_power_freqs = rte_power_acpi_cpufreq_freqs;
- rte_power_get_freq = rte_power_acpi_cpufreq_get_freq;
- rte_power_set_freq = rte_power_acpi_cpufreq_set_freq;
- rte_power_freq_up = rte_power_acpi_cpufreq_freq_up;
- rte_power_freq_down = rte_power_acpi_cpufreq_freq_down;
- rte_power_freq_min = rte_power_acpi_cpufreq_freq_min;
- rte_power_freq_max = rte_power_acpi_cpufreq_freq_max;
- rte_power_turbo_status = rte_power_acpi_turbo_status;
- rte_power_freq_enable_turbo = rte_power_acpi_enable_turbo;
- rte_power_freq_disable_turbo = rte_power_acpi_disable_turbo;
+ rte_power_freqs = power_acpi_cpufreq_freqs;
+ rte_power_get_freq = power_acpi_cpufreq_get_freq;
+ rte_power_set_freq = power_acpi_cpufreq_set_freq;
+ rte_power_freq_up = power_acpi_cpufreq_freq_up;
+ rte_power_freq_down = power_acpi_cpufreq_freq_down;
+ rte_power_freq_min = power_acpi_cpufreq_freq_min;
+ rte_power_freq_max = power_acpi_cpufreq_freq_max;
+ rte_power_turbo_status = power_acpi_turbo_status;
+ 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);
@@ -106,27 +77,27 @@ rte_power_get_env(void) {
}
int
-rte_power_init(unsigned lcore_id)
+rte_power_init(unsigned int lcore_id)
{
int ret = -1;
if (global_default_env == PM_ENV_ACPI_CPUFREQ) {
- return rte_power_acpi_cpufreq_init(lcore_id);
+ 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 "
"management...\n");
- ret = rte_power_acpi_cpufreq_init(lcore_id);
+ ret = power_acpi_cpufreq_init(lcore_id);
if (ret == 0) {
rte_power_set_env(PM_ENV_ACPI_CPUFREQ);
goto out;
}
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;
@@ -138,12 +109,12 @@ out:
}
int
-rte_power_exit(unsigned lcore_id)
+rte_power_exit(unsigned int lcore_id)
{
if (global_default_env == PM_ENV_ACPI_CPUFREQ)
- return rte_power_acpi_cpufreq_exit(lcore_id);
+ 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");
diff --git a/lib/librte_power/rte_power.h b/lib/librte_power/rte_power.h
index b17b7a53..b4b7357b 100644
--- a/lib/librte_power/rte_power.h
+++ b/lib/librte_power/rte_power.h
@@ -1,34 +1,5 @@
-/*-
- * BSD LICENSE
- *
- * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Intel Corporation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2014 Intel Corporation
*/
#ifndef _RTE_POWER_H
@@ -91,7 +62,7 @@ enum power_management_env rte_power_get_env(void);
* - 0 on success.
* - Negative on error.
*/
-int rte_power_init(unsigned lcore_id);
+int rte_power_init(unsigned int lcore_id);
/**
* Exit power management on a specific lcore. This will call the environment
@@ -104,7 +75,7 @@ int rte_power_init(unsigned lcore_id);
* - 0 on success.
* - Negative on error.
*/
-int rte_power_exit(unsigned lcore_id);
+int rte_power_exit(unsigned int lcore_id);
/**
* Get the available frequencies of a specific lcore.
@@ -121,7 +92,7 @@ int rte_power_exit(unsigned lcore_id);
* @return
* The number of available frequencies.
*/
-typedef uint32_t (*rte_power_freqs_t)(unsigned lcore_id, uint32_t *freqs,
+typedef uint32_t (*rte_power_freqs_t)(unsigned int lcore_id, uint32_t *freqs,
uint32_t num);
extern rte_power_freqs_t rte_power_freqs;
@@ -137,7 +108,7 @@ extern rte_power_freqs_t rte_power_freqs;
* @return
* The current index of available frequencies.
*/
-typedef uint32_t (*rte_power_get_freq_t)(unsigned lcore_id);
+typedef uint32_t (*rte_power_get_freq_t)(unsigned int lcore_id);
extern rte_power_get_freq_t rte_power_get_freq;
@@ -157,7 +128,7 @@ extern rte_power_get_freq_t rte_power_get_freq;
* - 0 on success without frequency changed.
* - Negative on error.
*/
-typedef int (*rte_power_set_freq_t)(unsigned lcore_id, uint32_t index);
+typedef int (*rte_power_set_freq_t)(unsigned int lcore_id, uint32_t index);
extern rte_power_set_freq_t rte_power_set_freq;
@@ -173,7 +144,7 @@ extern rte_power_set_freq_t rte_power_set_freq;
* - 0 on success without frequency changed.
* - Negative on error.
*/
-typedef int (*rte_power_freq_change_t)(unsigned lcore_id);
+typedef int (*rte_power_freq_change_t)(unsigned int lcore_id);
/**
* Scale up the frequency of a specific lcore according to the available
diff --git a/lib/librte_power/rte_power_common.h b/lib/librte_power/rte_power_common.h
deleted file mode 100644
index 64bd168f..00000000
--- a/lib/librte_power/rte_power_common.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*-
- * BSD LICENSE
- *
- * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Intel Corporation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef RTE_POWER_COMMON_H_
-#define RTE_POWER_COMMON_H_
-
-#define RTE_POWER_INVALID_FREQ_INDEX (~0)
-
-#endif /* RTE_POWER_COMMON_H_ */
diff --git a/lib/librte_power/rte_power_kvm_vm.c b/lib/librte_power/rte_power_kvm_vm.c
deleted file mode 100644
index 99060625..00000000
--- a/lib/librte_power/rte_power_kvm_vm.c
+++ /dev/null
@@ -1,155 +0,0 @@
-/*-
- * BSD LICENSE
- *
- * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Intel Corporation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#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 "rte_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 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 lcore_id)
-{
- guest_channel_host_disconnect(lcore_id);
- return 0;
-}
-
-uint32_t
-rte_power_kvm_vm_freqs(__attribute__((unused)) unsigned 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 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 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 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 lcore_id)
-{
- return send_msg(lcore_id, CPU_POWER_SCALE_UP);
-}
-
-int
-rte_power_kvm_vm_freq_down(unsigned lcore_id)
-{
- return send_msg(lcore_id, CPU_POWER_SCALE_DOWN);
-}
-
-int
-rte_power_kvm_vm_freq_max(unsigned lcore_id)
-{
- return send_msg(lcore_id, CPU_POWER_SCALE_MAX);
-}
-
-int
-rte_power_kvm_vm_freq_min(unsigned 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);
-}