power: refactor power management library
PATCH v3 1/5 power: refactor core power management library
In reply to Sivaprasad TummalaThis patch introduces a comprehensive refactor to the core power management library. The primary focus is on improving modularity and organization by relocating specific driver implementations from the 'lib/power' directory to dedicated directories within 'drivers/power/core/*'. The adjustment of meson.build files enables the selective activation of individual drivers.
These changes contribute to a significant enhancement in code organization, providing a clearer structure for driver implementations. The refactor aims to improve overall code clarity and boost maintainability. Additionally, it establishes a foundation for future development, allowing for more focused work on individual drivers and seamless integration of forthcoming enhancements.
v3:
- renamed rte_power_core_ops.h as rte_power_cpufreq_api.h
- re-worked on auto detection logic
v2:
- added NULL check for global_core_ops in rte_power_get_core_ops
---
drivers/meson.build | 1 +
.../power/acpi/acpi_cpufreq.c | 22 +-
.../power/acpi/acpi_cpufreq.h | 6 +-
drivers/power/acpi/meson.build | 10 +
.../power/amd_pstate/amd_pstate_cpufreq.c | 24 +-
.../power/amd_pstate/amd_pstate_cpufreq.h | 8 +-
drivers/power/amd_pstate/meson.build | 10 +
.../power/cppc/cppc_cpufreq.c | 22 +-
.../power/cppc/cppc_cpufreq.h | 8 +-
drivers/power/cppc/meson.build | 10 +
.../power/kvm_vm}/guest_channel.c | 0
.../power/kvm_vm}/guest_channel.h | 0
.../power/kvm_vm/kvm_vm.c | 22 +-
.../power/kvm_vm/kvm_vm.h | 6 +-
drivers/power/kvm_vm/meson.build | 16 +
drivers/power/meson.build | 12 +
drivers/power/pstate/meson.build | 10 +
.../power/pstate/pstate_cpufreq.c | 22 +-
.../power/pstate/pstate_cpufreq.h | 6 +-
lib/power/meson.build | 7 +-
lib/power/power_common.c | 2 +-
lib/power/power_common.h | 16 +-
lib/power/rte_power.c | 286 ++++++------------
lib/power/rte_power.h | 139 ++++++---
lib/power/rte_power_cpufreq_api.h | 208 +++++++++++++
lib/power/version.map | 14 +
26 files changed, 618 insertions(+), 269 deletions(-)
rename lib/power/power_acpi_cpufreq.c => drivers/power/acpi/acpi_cpufreq.c (95%)
rename lib/power/power_acpi_cpufreq.h => drivers/power/acpi/acpi_cpufreq.h (98%)
create mode 100644 drivers/power/acpi/meson.build
rename lib/power/power_amd_pstate_cpufreq.c => drivers/power/amd_pstate/amd_pstate_cpufreq.c (95%)
rename lib/power/power_amd_pstate_cpufreq.h => drivers/power/amd_pstate/amd_pstate_cpufreq.h (97%)
create mode 100644 drivers/power/amd_pstate/meson.build
rename lib/power/power_cppc_cpufreq.c => drivers/power/cppc/cppc_cpufreq.c (95%)
rename lib/power/power_cppc_cpufreq.h => drivers/power/cppc/cppc_cpufreq.h (97%)
create mode 100644 drivers/power/cppc/meson.build
rename {lib/power => drivers/power/kvm_vm}/guest_channel.c (100%)
rename {lib/power => drivers/power/kvm_vm}/guest_channel.h (100%)
rename lib/power/power_kvm_vm.c => drivers/power/kvm_vm/kvm_vm.c (82%)
rename lib/power/power_kvm_vm.h => drivers/power/kvm_vm/kvm_vm.h (98%)
create mode 100644 drivers/power/kvm_vm/meson.build
create mode 100644 drivers/power/meson.build
create mode 100644 drivers/power/pstate/meson.build
rename lib/power/power_pstate_cpufreq.c => drivers/power/pstate/pstate_cpufreq.c (96%)
rename lib/power/power_pstate_cpufreq.h => drivers/power/pstate/pstate_cpufreq.h (98%)
create mode 100644 lib/power/rte_power_cpufreq_api.hdrivers/meson.build +1 -0
@@ -29,6 +29,7 @@ subdirs = [ 'event', # depends on common, bus, mempool and net. 'baseband', # depends on common and bus. 'gpu', # depends on common and bus. + 'power', # depends on common (in future). ] if meson.is_cross_build()
drivers/power/acpi/acpi_cpufreq.c renamed from lib/power/power_acpi_cpufreq.c +21 -1
@@ -10,7 +10,7 @@#include <rte_stdatomic.h> #include <rte_string_fns.h> -#include "power_acpi_cpufreq.h" +#include "acpi_cpufreq.h" #include "power_common.h" #define STR_SIZE 1024
@@ -577,3 +577,23 @@ int power_acpi_get_capabilities(unsigned int lcore_id,return 0 ; } + +static struct rte_power_core_ops acpi_ops = { + .name ="acpi" , + .init = power_acpi_cpufreq_init, + .exit = power_acpi_cpufreq_exit, + .check_env_support = power_acpi_cpufreq_check_supported, + .get_avail_freqs = power_acpi_cpufreq_freqs, + .get_freq = power_acpi_cpufreq_get_freq, + .set_freq = power_acpi_cpufreq_set_freq, + .freq_down = power_acpi_cpufreq_freq_down, + .freq_up = power_acpi_cpufreq_freq_up, + .freq_max = power_acpi_cpufreq_freq_max, + .freq_min = power_acpi_cpufreq_freq_min, + .turbo_status = power_acpi_turbo_status, + .enable_turbo = power_acpi_enable_turbo, + .disable_turbo = power_acpi_disable_turbo, + .get_caps = power_acpi_get_capabilities +}; + +RTE_POWER_REGISTER_OPS (acpi_ops);
drivers/power/acpi/acpi_cpufreq.h renamed from lib/power/power_acpi_cpufreq.h +3 -3
@@ -2,15 +2,15 @@* Copyright(c) 2010-2014 Intel Corporation */ -#ifndef _POWER_ACPI_CPUFREQ_H -#define _POWER_ACPI_CPUFREQ_H +#ifndef _ACPI_CPUFREQ_H +#define _ACPI_CPUFREQ_H/** * @file * RTE Power Management via userspace ACPI cpufreq */ -#include "rte_power.h" +#include "rte_power_cpufreq_api.h" /** * Check if ACPI power management is supported.
drivers/power/acpi/meson.build new file +10 -0
@@ -0,0 +1,10 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' +endif +sources = files('acpi_cpufreq.c') + +deps += ['power']
drivers/power/amd_pstate/amd_pstate_cpufreq.c renamed from lib/power/power_amd_pstate_cpufreq.c +22 -2
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2010-2021 Intel Corporation * Copyright(c) 2021 Arm Limited -* Copyright(c) 2023 Amd Limited +* Copyright(c) 2024 Advanced Micro Devices, Inc. */ #include <stdlib.h>
@@ -9,7 +9,7 @@#include <rte_memcpy.h> #include <rte_stdatomic.h> -#include "power_amd_pstate_cpufreq.h" +#include "amd_pstate_cpufreq.h" #include "power_common.h" /* macros used for rounding frequency to nearest 1000 */
@@ -700,3 +700,23 @@ power_amd_pstate_get_capabilities(unsigned int lcore_id,return 0 ; } + +static struct rte_power_core_ops amd_pstate_ops = { + .name ="amd-pstate" , + .init = power_amd_pstate_cpufreq_init, + .exit = power_amd_pstate_cpufreq_exit, + .check_env_support = power_amd_pstate_cpufreq_check_supported, + .get_avail_freqs = power_amd_pstate_cpufreq_freqs, + .get_freq = power_amd_pstate_cpufreq_get_freq, + .set_freq = power_amd_pstate_cpufreq_set_freq, + .freq_down = power_amd_pstate_cpufreq_freq_down, + .freq_up = power_amd_pstate_cpufreq_freq_up, + .freq_max = power_amd_pstate_cpufreq_freq_max, + .freq_min = power_amd_pstate_cpufreq_freq_min, + .turbo_status = power_amd_pstate_turbo_status, + .enable_turbo = power_amd_pstate_enable_turbo, + .disable_turbo = power_amd_pstate_disable_turbo, + .get_caps = power_amd_pstate_get_capabilities +}; + +RTE_POWER_REGISTER_OPS (amd_pstate_ops);
drivers/power/amd_pstate/amd_pstate_cpufreq.h renamed from lib/power/power_amd_pstate_cpufreq.h +4 -4
@@ -1,18 +1,18 @@/* SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2010-2021 Intel Corporation * Copyright(c) 2021 Arm Limited -* Copyright(c) 2023 Amd Limited +* Copyright(c) 2024 Advanced Micro Devices, Inc. */ -#ifndef _POWER_AMD_PSTATE_CPUFREQ_H -#define _POWER_AMD_PSTATE_CPUFREQ_H +#ifndef _AMD_PSTATE_CPUFREQ_H +#define _AMD_PSTATE_CPUFREQ_H/** * @file * RTE Power Management via userspace AMD pstate cpufreq */ -#include "rte_power.h" +#include "rte_power_cpufreq_api.h" /** * Check if amd p-state power management is supported.
drivers/power/amd_pstate/meson.build new file +10 -0
@@ -0,0 +1,10 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' +endif +sources = files('amd_pstate_cpufreq.c') + +deps += ['power']
drivers/power/cppc/cppc_cpufreq.c renamed from lib/power/power_cppc_cpufreq.c +21 -1
@@ -8,7 +8,7 @@#include <rte_memcpy.h> #include <rte_stdatomic.h> -#include "power_cppc_cpufreq.h" +#include "cppc_cpufreq.h" #include "power_common.h" /* macros used for rounding frequency to nearest 100000 */
@@ -685,3 +685,23 @@ power_cppc_get_capabilities(unsigned int lcore_id,return 0 ; } + +static struct rte_power_core_ops cppc_ops = { + .name ="cppc" , + .init = power_cppc_cpufreq_init, + .exit = power_cppc_cpufreq_exit, + .check_env_support = power_cppc_cpufreq_check_supported, + .get_avail_freqs = power_cppc_cpufreq_freqs, + .get_freq = power_cppc_cpufreq_get_freq, + .set_freq = power_cppc_cpufreq_set_freq, + .freq_down = power_cppc_cpufreq_freq_down, + .freq_up = power_cppc_cpufreq_freq_up, + .freq_max = power_cppc_cpufreq_freq_max, + .freq_min = power_cppc_cpufreq_freq_min, + .turbo_status = power_cppc_turbo_status, + .enable_turbo = power_cppc_enable_turbo, + .disable_turbo = power_cppc_disable_turbo, + .get_caps = power_cppc_get_capabilities +}; + +RTE_POWER_REGISTER_OPS (cppc_ops);
drivers/power/cppc/cppc_cpufreq.h renamed from lib/power/power_cppc_cpufreq.h +4 -4
@@ -3,15 +3,15 @@* Copyright(c) 2021 Arm Limited */ -#ifndef _POWER_CPPC_CPUFREQ_H -#define _POWER_CPPC_CPUFREQ_H +#ifndef _CPPC_CPUFREQ_H +#define _CPPC_CPUFREQ_H/** * @file * RTE Power Management via userspace CPPC cpufreq */ -#include "rte_power.h" +#include "rte_power_cpufreq_api.h" /** * Check if CPPC power management is supported.
@@ -215,4 +215,4 @@ int power_cppc_disable_turbo(unsigned int lcore_id);int power_cppc_get_capabilities (unsigned int lcore_id,struct rte_power_core_capabilities *caps); -#endif /* _POWER_CPPC_CPUFREQ_H */ +#endif /* _CPPC_CPUFREQ_H */
drivers/power/cppc/meson.build new file +10 -0
@@ -0,0 +1,10 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' +endif +sources = files('cppc_cpufreq.c') + +deps += ['power']
drivers/power/kvm_vm/guest_channel.c renamed from lib/power/guest_channel.c +0 -0
drivers/power/kvm_vm/guest_channel.h renamed from lib/power/guest_channel.h +0 -0
drivers/power/kvm_vm/kvm_vm.c renamed from lib/power/power_kvm_vm.c +21 -1
@@ -9,7 +9,7 @@#include "rte_power_guest_channel.h" #include "guest_channel.h" #include "power_common.h" -#include "power_kvm_vm.h" +#include "kvm_vm.h" #define FD_PATH "/dev/virtio-ports/virtio.serial.port.poweragent"
@@ -137,3 +137,23 @@ int power_kvm_vm_get_capabilities(__rte_unused unsigned int lcore_id,POWER_LOG (ERR ,"rte_power_get_capabilities is not implemented for Virtual Machine Power Management" );return -ENOTSUP ; } + +static struct rte_power_core_ops kvm_vm_ops = { + .name ="kvm-vm" , + .init = power_kvm_vm_init, + .exit = power_kvm_vm_exit, + .check_env_support = power_kvm_vm_check_supported, + .get_avail_freqs = power_kvm_vm_freqs, + .get_freq = power_kvm_vm_get_freq, + .set_freq = power_kvm_vm_set_freq, + .freq_down = power_kvm_vm_freq_down, + .freq_up = power_kvm_vm_freq_up, + .freq_max = power_kvm_vm_freq_max, + .freq_min = power_kvm_vm_freq_min, + .turbo_status = power_kvm_vm_turbo_status, + .enable_turbo = power_kvm_vm_enable_turbo, + .disable_turbo = power_kvm_vm_disable_turbo, + .get_caps = power_kvm_vm_get_capabilities +}; + +RTE_POWER_REGISTER_OPS (kvm_vm_ops);
drivers/power/kvm_vm/kvm_vm.h renamed from lib/power/power_kvm_vm.h +3 -3
@@ -2,15 +2,15 @@* Copyright(c) 2010-2014 Intel Corporation */ -#ifndef _POWER_KVM_VM_H -#define _POWER_KVM_VM_H +#ifndef _KVM_VM_H +#define _KVM_VM_H/** * @file * RTE Power Management KVM VM */ -#include "rte_power.h" +#include "rte_power_cpufreq_api.h" /** * Check if KVM power management is supported.
drivers/power/kvm_vm/meson.build new file +16 -0
@@ -0,0 +1,16 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(C) 2024 Advanced Micro Devices, Inc. +# + +if not is_linux + build = false + reason = 'only supported on Linux' + subdir_done() +endif + +sources = files( + 'guest_channel.c', + 'kvm_vm.c', +) + +deps += ['power']
drivers/power/meson.build new file +12 -0
@@ -0,0 +1,12 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +drivers = [ + 'acpi', + 'amd_pstate', + 'cppc', + 'kvm_vm', + 'pstate' +] + +std_deps = ['power']
drivers/power/pstate/meson.build new file +10 -0
@@ -0,0 +1,10 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' +endif +sources = files('pstate_cpufreq.c') + +deps += ['power']
drivers/power/pstate/pstate_cpufreq.c renamed from lib/power/power_pstate_cpufreq.c +21 -1
@@ -15,7 +15,7 @@#include <rte_stdatomic.h> #include "rte_power_pmd_mgmt.h" -#include "power_pstate_cpufreq.h" +#include "pstate_cpufreq.h" #include "power_common.h" /* macros used for rounding frequency to nearest 100000 */
@@ -888,3 +888,23 @@ int power_pstate_get_capabilities(unsigned int lcore_id,return 0 ; } + +static struct rte_power_core_ops pstate_ops = { + .name ="pstate" , + .init = power_pstate_cpufreq_init, + .exit = power_pstate_cpufreq_exit, + .check_env_support = power_pstate_cpufreq_check_supported, + .get_avail_freqs = power_pstate_cpufreq_freqs, + .get_freq = power_pstate_cpufreq_get_freq, + .set_freq = power_pstate_cpufreq_set_freq, + .freq_down = power_pstate_cpufreq_freq_down, + .freq_up = power_pstate_cpufreq_freq_up, + .freq_max = power_pstate_cpufreq_freq_max, + .freq_min = power_pstate_cpufreq_freq_min, + .turbo_status = power_pstate_turbo_status, + .enable_turbo = power_pstate_enable_turbo, + .disable_turbo = power_pstate_disable_turbo, + .get_caps = power_pstate_get_capabilities +}; + +RTE_POWER_REGISTER_OPS (pstate_ops);
drivers/power/pstate/pstate_cpufreq.h renamed from lib/power/power_pstate_cpufreq.h +3 -3
@@ -2,15 +2,15 @@* Copyright(c) 2018 Intel Corporation */ -#ifndef _POWER_PSTATE_CPUFREQ_H -#define _POWER_PSTATE_CPUFREQ_H +#ifndef _PSTATE_CPUFREQ_H +#define _PSTATE_CPUFREQ_H/** * @file * RTE Power Management via Intel Pstate driver */ -#include "rte_power.h" +#include "rte_power_cpufreq_api.h" /** * Check if pstate power management is supported.
lib/power/meson.build +1 -6
@@ -12,20 +12,15 @@ if not is_linux reason = 'only supported on Linux' endif sources = files( - 'guest_channel.c', - 'power_acpi_cpufreq.c', - 'power_amd_pstate_cpufreq.c', 'power_common.c', - 'power_cppc_cpufreq.c', - 'power_kvm_vm.c', 'power_intel_uncore.c', - 'power_pstate_cpufreq.c', 'rte_power.c', 'rte_power_uncore.c', 'rte_power_pmd_mgmt.c', ) headers = files( 'rte_power.h', + 'rte_power_cpufreq_api.h', 'rte_power_guest_channel.h', 'rte_power_pmd_mgmt.h', 'rte_power_uncore.h',
lib/power/power_common.c +1 -1
@@ -12,7 +12,7 @@#include "power_common.h" -RTE_LOG_REGISTER_DEFAULT (power_logtype,INFO ); +RTE_LOG_REGISTER_DEFAULT (rte_power_logtype,INFO );#define POWER_SYSFILE_SCALING_DRIVER \ "/sys/devices/system/cpu/cpu%u/cpufreq/scaling_driver"
lib/power/power_common.h +14 -2
@@ -6,12 +6,13 @@#define _POWER_COMMON_H_#include <rte_common.h> +#include <rte_compat.h> #include <rte_log.h> #define RTE_POWER_INVALID_FREQ_INDEX (~0) -extern int power_logtype; -#define RTE_LOGTYPE_POWER power_logtype +extern int rte_power_logtype; +#define RTE_LOGTYPE_POWER rte_power_logtype#define POWER_LOG (level, ...) \ RTE_LOG_LINE(level, POWER, "" __VA_ARGS__)
@@ -23,13 +24,24 @@ extern int power_logtype;#endif /* check if scaling driver matches one we want */ +__rte_internal int cpufreq_check_scaling_driver(const char *driver); + +__rte_internal int power_set_governor(unsigned int lcore_id, const char *new_governor,char *orig_governor,size_t orig_governor_len); + +__rte_internal int open_core_sysfs_file(FILE **f, const char *mode, const char *format, ...) __rte_format_printf(3, 4); + +__rte_internal int read_core_sysfs_u32(FILE *f, uint32_t *val); + +__rte_internal int read_core_sysfs_s(FILE *f, char *buf, unsigned int len); + +__rte_internal int write_core_sysfs_s(FILE *f, const char *str);#endif /* _POWER_COMMON_H_ */
lib/power/rte_power.c +95 -191
342 lines not on this page · raw message
lib/power/rte_power.h +93 -46
229 lines not on this page · raw message
lib/power/rte_power_cpufreq_api.h new file +208 -0
208 lines not on this page · raw message
lib/power/version.map +14 -0
@@ -51,4 +51,18 @@ EXPERIMENTAL { rte_power_set_uncore_env; rte_power_uncore_freqs; rte_power_unset_uncore_env; + # added in 24.11 + rte_power_logtype; +}; + +INTERNAL { + global: + + rte_power_register_ops; + cpufreq_check_scaling_driver; + power_set_governor; + open_core_sysfs_file; + read_core_sysfs_u32; + read_core_sysfs_s; + write_core_sysfs_s; };
Signature · 1 line
2.34.1
PATCH v3 2/5 power: refactor uncore power management library
In reply to Sivaprasad TummalaThis patch refactors the power management library, addressing uncore power management. The primary changes involve the creation of dedicated directories for each driver within 'drivers/power/uncore/*'. The adjustment of meson.build files enables the selective activation of individual drivers.
This refactor significantly improves code organization, enhances clarity and boosts maintainability. It lays the foundation for more focused development on individual drivers and facilitates seamless integration of future enhancements, particularly the AMD uncore driver.
v3:
- fixed typo in header file inclusion
--- .../power/intel_uncore/intel_uncore.c | 18 +- .../power/intel_uncore/intel_uncore.h | 8 +- drivers/power/intel_uncore/meson.build | 6 + drivers/power/meson.build | 3 +- lib/power/meson.build | 2 +- lib/power/rte_power_uncore.c | 206 ++++++--------- lib/power/rte_power_uncore.h | 87 ++++--- lib/power/rte_power_uncore_ops.h | 239 ++++++++++++++++++ lib/power/version.map | 1 + 9 files changed, 405 insertions(+), 165 deletions(-) rename lib/power/power_intel_uncore.c => drivers/power/intel_uncore/intel_uncore.c (95%) rename lib/power/power_intel_uncore.h => drivers/power/intel_uncore/intel_uncore.h (97%) create mode 100644 drivers/power/intel_uncore/meson.build create mode 100644 lib/power/rte_power_uncore_ops.h
drivers/power/intel_uncore/intel_uncore.c renamed from lib/power/power_intel_uncore.c +17 -1
@@ -8,7 +8,7 @@#include <rte_memcpy.h> -#include "power_intel_uncore.h" +#include "intel_uncore.h" #include "power_common.h" #define MAX_NUMA_DIE 8
@@ -475,3 +475,19 @@ power_intel_uncore_get_num_dies(unsigned int pkg)return count; } + +static struct rte_power_uncore_ops intel_uncore_ops = { + .name ="intel-uncore" , + .init = power_intel_uncore_init, + .exit = power_intel_uncore_exit, + .get_avail_freqs = power_intel_uncore_freqs, + .get_num_pkgs = power_intel_uncore_get_num_pkgs, + .get_num_dies = power_intel_uncore_get_num_dies, + .get_num_freqs = power_intel_uncore_get_num_freqs, + .get_freq = power_get_intel_uncore_freq, + .set_freq = power_set_intel_uncore_freq, + .freq_max = power_intel_uncore_freq_max, + .freq_min = power_intel_uncore_freq_min, +}; + +RTE_POWER_REGISTER_UNCORE_OPS (intel_uncore_ops);
drivers/power/intel_uncore/intel_uncore.h renamed from lib/power/power_intel_uncore.h +4 -4
@@ -2,8 +2,8 @@* Copyright(c) 2022 Intel Corporation */ -#ifndef POWER_INTEL_UNCORE_H -#define POWER_INTEL_UNCORE_H +#ifndef INTEL_UNCORE_H +#define INTEL_UNCORE_H /** * @file
@@ -11,7 +11,7 @@*/ #include "rte_power.h" -#include "rte_power_uncore.h" +#include "rte_power_uncore_ops.h" #ifdef __cplusplusextern "C" {
@@ -223,4 +223,4 @@ power_intel_uncore_get_num_dies(unsigned int pkg); }#endif -#endif /* POWER_INTEL_UNCORE_H */ +#endif /* INTEL_UNCORE_H */
drivers/power/intel_uncore/meson.build new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2017 Intel Corporation +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +sources = files('intel_uncore.c') +deps += ['power']
drivers/power/meson.build +2 -1
@@ -6,7 +6,8 @@ drivers = [ 'amd_pstate', 'cppc', 'kvm_vm', - 'pstate' + 'pstate', + 'intel_uncore' ] std_deps = ['power']
lib/power/meson.build +1 -1
@@ -13,7 +13,6 @@ if not is_linux endif sources = files( 'power_common.c', - 'power_intel_uncore.c', 'rte_power.c', 'rte_power_uncore.c', 'rte_power_pmd_mgmt.c',
@@ -24,6 +23,7 @@ headers = files( 'rte_power_guest_channel.h', 'rte_power_pmd_mgmt.h', 'rte_power_uncore.h', + 'rte_power_uncore_ops.h', ) if cc.has_argument('-Wno-cast-qual') cflags += '-Wno-cast-qual'
lib/power/rte_power_uncore.c +82 -124
265 lines not on this page · raw message
lib/power/rte_power_uncore.h +53 -34
153 lines not on this page · raw message
lib/power/rte_power_uncore_ops.h new file +239 -0
239 lines not on this page · raw message
lib/power/version.map +1 -0
@@ -59,6 +59,7 @@ INTERNAL { global: rte_power_register_ops; + rte_power_register_uncore_ops; cpufreq_check_scaling_driver; power_set_governor; open_core_sysfs_file;
Signature · 1 line
2.34.1
PATCH v3 3/5 test/power: removed function pointer validations
In reply to Sivaprasad TummalaAfter refactoring the power library, power management operations are now consistently supported regardless of the operating environment, making function pointer checks unnecessary and thus removed from applications.
v2:
- removed function pointer validation in l3fwd-power app.
--- app/test/test_power.c | 95 ----------------------------------- app/test/test_power_cpufreq.c | 52 ------------------- app/test/test_power_kvm_vm.c | 36 ------------- examples/l3fwd-power/main.c | 12 ++--- 4 files changed, 4 insertions(+), 191 deletions(-)
app/test/test_power.c +0 -95
@@ -24,86 +24,6 @@ test_power(void)#include <rte_power.h> -static int -check_function_ptrs (void ) -{ -enum power_management_env env =rte_power_get_env (); - -const bool not_null_expected = !(env ==PM_ENV_NOT_SET ); - -const char *inject_not_string1 = not_null_expected ?" not" :"" ; -const char *inject_not_string2 = not_null_expected ?"" :" not" ; - -if ((rte_power_freqs ==NULL ) == not_null_expected) { -printf ("rte_power_freqs should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_get_freq ==NULL ) == not_null_expected) { -printf ("rte_power_get_freq should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_set_freq ==NULL ) == not_null_expected) { -printf ("rte_power_set_freq should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_freq_up ==NULL ) == not_null_expected) { -printf ("rte_power_freq_up should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_freq_down ==NULL ) == not_null_expected) { -printf ("rte_power_freq_down should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_freq_max ==NULL ) == not_null_expected) { -printf ("rte_power_freq_max should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_freq_min ==NULL ) == not_null_expected) { -printf ("rte_power_freq_min should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_turbo_status ==NULL ) == not_null_expected) { -printf ("rte_power_turbo_status should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_freq_enable_turbo ==NULL ) == not_null_expected) { -printf ("rte_power_freq_enable_turbo should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_freq_disable_turbo ==NULL ) == not_null_expected) { -printf ("rte_power_freq_disable_turbo should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_get_capabilities ==NULL ) == not_null_expected) { -printf ("rte_power_get_capabilities should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } - -return 0 ; -} -static int test_power (void ) {
@@ -124,10 +44,6 @@ test_power(void)return -1 ; } -/* Verify that function pointers are NULL */ -if (check_function_ptrs () <0 ) - goto fail_all; -rte_power_unset_env ();/* Perform tests for valid environments.*/
@@ -154,22 +70,11 @@ test_power(void) return -1; } -/* Verify that function pointers are NOT NULL */ -if (check_function_ptrs () <0 ) - goto fail_all; -rte_power_unset_env (); -/* Verify that function pointers are NULL */ -if (check_function_ptrs () <0 ) - goto fail_all; - }return 0 ; -fail_all: -rte_power_unset_env (); -return -1 ; }#endif
app/test/test_power_cpufreq.c +0 -52
58 lines not on this page · raw message
app/test/test_power_kvm_vm.c +0 -36
@@ -47,42 +47,6 @@ test_power_kvm_vm(void)return -1 ; } -/* verify that function pointers are not NULL */ -if (rte_power_freqs ==NULL ) { -printf ("rte_power_freqs should not be NULL, environment has not been " -"initialised\n" ); -return -1 ; - } -if (rte_power_get_freq ==NULL ) { -printf ("rte_power_get_freq should not be NULL, environment has not " -"been initialised\n" ); -return -1 ; - } -if (rte_power_set_freq ==NULL ) { -printf ("rte_power_set_freq should not be NULL, environment has not " -"been initialised\n" ); -return -1 ; - } -if (rte_power_freq_up ==NULL ) { -printf ("rte_power_freq_up should not be NULL, environment has not " -"been initialised\n" ); -return -1 ; - } -if (rte_power_freq_down ==NULL ) { -printf ("rte_power_freq_down should not be NULL, environment has not " -"been initialised\n" ); -return -1 ; - } -if (rte_power_freq_max ==NULL ) { -printf ("rte_power_freq_max should not be NULL, environment has not " -"been initialised\n" ); -return -1 ; - } -if (rte_power_freq_min ==NULL ) { -printf ("rte_power_freq_min should not be NULL, environment has not " -"been initialised\n" ); -return -1 ; - }/* Test initialisation of an out of bounds lcore */ ret =rte_power_init (TEST_POWER_VM_LCORE_OUT_OF_BOUNDS );if (ret !=-1 ) {
examples/l3fwd-power/main.c +4 -8
@@ -440,8 +440,7 @@ power_timer_cb(__rte_unused struct rte_timer *tim,* check whether need to scale down frequency a step if it sleep a lot. */ if (sleep_time_ratio >=SCALING_DOWN_TIME_RATIO_THRESHOLD ) { -if (rte_power_freq_down) -rte_power_freq_down (lcore_id); +rte_power_freq_down (lcore_id); }else if ( (unsigned )(stats[lcore_id].nb_rx_processed / stats[lcore_id].nb_iteration_looped) <MAX_PKT_BURST ) {
@@ -449,8 +448,7 @@ power_timer_cb(__rte_unused struct rte_timer *tim,* scale down a step if average packet per iteration less * than expectation. */ -if (rte_power_freq_down) -rte_power_freq_down (lcore_id); +rte_power_freq_down (lcore_id); }/**
@@ -1344,11 +1342,9 @@ main_legacy_loop(__rte_unused void *dummy) }if (lcore_scaleup_hint ==FREQ_HIGHEST ) { -if (rte_power_freq_max) -rte_power_freq_max (lcore_id); +rte_power_freq_max (lcore_id); }else if (lcore_scaleup_hint ==FREQ_HIGHER ) { -if (rte_power_freq_up) -rte_power_freq_up (lcore_id); +rte_power_freq_up (lcore_id); } }else {/**
Signature · 1 line
2.34.1
PATCH v3 4/5 power/amd_uncore: uncore support for AMD EPYC processors
In reply to Sivaprasad TummalaThis patch introduces driver support for power management of uncore components in AMD EPYC processors.
v2:
- fixed typo in comments section.
- added fabric frequency get support for legacy platforms.
--- drivers/power/amd_uncore/amd_uncore.c | 328 ++++++++++++++++++++++++++ drivers/power/amd_uncore/amd_uncore.h | 226 ++++++++++++++++++ drivers/power/amd_uncore/meson.build | 20 ++ drivers/power/meson.build | 1 + 4 files changed, 575 insertions(+) create mode 100644 drivers/power/amd_uncore/amd_uncore.c create mode 100644 drivers/power/amd_uncore/amd_uncore.h create mode 100644 drivers/power/amd_uncore/meson.build
drivers/power/amd_uncore/amd_uncore.c new file +328 -0
@@ -0,0 +1,328 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2024 Advanced Micro Devices, Inc. +*/ + +#include <errno.h> +#include <dirent.h> +#include <fnmatch.h> + +#include <rte_memcpy.h> + +#include "amd_uncore.h" +#include "power_common.h" +#include "e_smi/e_smi.h" + +#define MAX_NUMA_DIE 8 + +struct __rte_cache_aligned uncore_power_info { +unsigned int die;/* Core die id */ +unsigned int pkg;/* Package id */ +uint32_t freqs[RTE_MAX_UNCORE_FREQS ];/* Frequency array */ +uint32_t nb_freqs;/* Number of available freqs */ +uint32_t curr_idx;/* Freq index in freqs array */ +uint32_t max_freq;/* System max uncore freq */ +uint32_t min_freq;/* System min uncore freq */ +}; + +static struct uncore_power_info uncore_info[RTE_MAX_NUMA_NODES ][MAX_NUMA_DIE ]; +static int esmi_initialized; +static int hsmp_proto_ver; + +static int +set_uncore_freq_internal (struct uncore_power_info *ui,uint32_t idx) +{ +int ret; + +if (idx >=RTE_MAX_UNCORE_FREQS || idx >= ui->nb_freqs) { +POWER_LOG (DEBUG ,"Invalid uncore frequency index %u, which " +"should be less than %u" , idx, ui->nb_freqs); +return -1 ; + } + + ret =esmi_apb_disable (ui->pkg, idx); +if (ret !=ESMI_SUCCESS ) { +POWER_LOG (ERR ,"DF P-state '%u' set failed for pkg %02u" , + idx, ui->pkg); +return -1 ; + } + +POWER_DEBUG_LOG ("DF P-state '%u' to be set for pkg %02u die %02u" , + idx, ui->pkg, ui->die); + +/* write the minimum value first if the target freq is less than current max */ + ui->curr_idx = idx; + +return 0 ; +} + +static int +power_init_for_setting_uncore_freq (struct uncore_power_info *ui) +{ +switch (hsmp_proto_ver) { +case HSMP_PROTO_VER5 : + ui->max_freq =1800000 ;/* Hz */ + ui->min_freq =1200000 ;/* Hz */ +break ; +case HSMP_PROTO_VER2 : +default : + ui->max_freq =1600000 ;/* Hz */ + ui->min_freq =1200000 ;/* Hz */ + } + +return 0 ; +} + +/* +* Get the available uncore frequencies of the specific die. +*/ +static int +power_get_available_uncore_freqs (struct uncore_power_info *ui) +{ + ui->nb_freqs =3 ; +if (ui->nb_freqs >=RTE_MAX_UNCORE_FREQS ) { +POWER_LOG (ERR ,"Too many available uncore frequencies: %d" , + num_uncore_freqs); +return -1 ; + } + +/* Generate the uncore freq bucket array. */ +switch (hsmp_proto_ver) { +case HSMP_PROTO_VER5 : + ui->freqs[0 ] =1800000 ; + ui->freqs[1 ] =1440000 ; + ui->freqs[2 ] =1200000 ; +case HSMP_PROTO_VER2 : +default : + ui->freqs[0 ] =1600000 ; + ui->freqs[1 ] =1333000 ; + ui->freqs[2 ] =1200000 ; + } + +POWER_DEBUG_LOG ("%d frequency(s) of pkg %02u die %02u are available" , + ui->num_uncore_freqs, ui->pkg, ui->die); + +return 0 ; +} + +static int +check_pkg_die_values (unsigned int pkg,unsigned int die) +{ +unsigned int max_pkgs, max_dies; + max_pkgs =power_amd_uncore_get_num_pkgs (); +if (max_pkgs ==0 ) +return -1 ; +if (pkg >= max_pkgs) { +POWER_LOG (DEBUG ,"Package number %02u can not exceed %u" , + pkg, max_pkgs); +return -1 ; + } + + max_dies =power_amd_uncore_get_num_dies (pkg); +if (max_dies ==0 ) +return -1 ; +if (die >= max_dies) { +POWER_LOG (DEBUG ,"Die number %02u can not exceed %u" , + die, max_dies); +return -1 ; + } + +return 0 ; +} + +static void +power_amd_uncore_esmi_init (void ) +{ +if (esmi_init () ==ESMI_SUCCESS ) { +if (esmi_hsmp_proto_ver_get (&hsmp_proto_ver) == +ESMI_SUCCESS ) + esmi_initialized =1 ; + } +} + +int +power_amd_uncore_init (unsigned int pkg,unsigned int die) +{ +struct uncore_power_info *ui; +int ret; + +if (!esmi_initialized) { + ret =esmi_init (); +if (ret !=ESMI_SUCCESS ) { +POWER_LOG (DEBUG ,"ESMI Not initialized, drivers not found" ); +return -1 ; + } + ret =esmi_hsmp_proto_ver_get (&hsmp_proto_ver); +if (ret !=ESMI_SUCCESS ) { +POWER_LOG (DEBUG ,"HSMP Proto Version Get failed with " +"error %s" ,esmi_get_err_msg (ret)); +esmi_exit (); +return -1 ; + } + esmi_initialized =1 ; + } + + ret =check_pkg_die_values (pkg, die); +if (ret <0 ) +return -1 ; + + ui = &uncore_info[pkg][die]; + ui->die = die; + ui->pkg = pkg; + +/* Init for setting uncore die frequency */ +if (power_init_for_setting_uncore_freq (ui) <0 ) { +POWER_LOG (DEBUG ,"Cannot init for setting uncore frequency for " +"pkg %02u die %02u" , pkg, die); +return -1 ; + } + +/* Get the available frequencies */ +if (power_get_available_uncore_freqs (ui) <0 ) { +POWER_LOG (DEBUG ,"Cannot get available uncore frequencies of " +"pkg %02u die %02u" , pkg, die); +return -1 ; + } + +return 0 ; +} + +int +power_amd_uncore_exit (unsigned int pkg,unsigned int die) +{ +struct uncore_power_info *ui; + +int ret =check_pkg_die_values (pkg, die); +if (ret <0 ) +return -1 ; + + ui = &uncore_info[pkg][die]; + ui->nb_freqs =0 ; + +if (esmi_initialized) { +esmi_exit (); + esmi_initialized =0 ; + } + +return 0 ; +} + +uint32_t +power_get_amd_uncore_freq (unsigned int pkg,unsigned int die) +{ +int ret =check_pkg_die_values (pkg, die); +if (ret <0 ) +return -1 ; + +return uncore_info[pkg][die].curr_idx; +} + +int +power_set_amd_uncore_freq (unsigned int pkg,unsigned int die,uint32_t index) +{ +int ret =check_pkg_die_values (pkg, die); +if (ret <0 ) +return -1 ; + +return set_uncore_freq_internal (&(uncore_info[pkg][die]), index); +} + +int +power_amd_uncore_freq_max (unsigned int pkg,unsigned int die) +{ +int ret =check_pkg_die_values (pkg, die); +if (ret <0 ) +return -1 ; + +return set_uncore_freq_internal (&(uncore_info[pkg][die]),0 ); +} + + +int +power_amd_uncore_freq_min (unsigned int pkg,unsigned int die) +{ +int ret =check_pkg_die_values (pkg, die); +if (ret <0 ) +return -1 ; + +struct uncore_power_info *ui = &uncore_info[pkg][die]; + +return set_uncore_freq_internal (&(uncore_info[pkg][die]), ui->nb_freqs -1 ); +} + +int +power_amd_uncore_freqs (unsigned int pkg,unsigned int die,uint32_t *freqs,uint32_t num) +{ +struct uncore_power_info *ui; + +int ret =check_pkg_die_values (pkg, die); +if (ret <0 ) +return -1 ; + +if (freqs ==NULL ) { +POWER_LOG (ERR ,"NULL buffer supplied" ); +return 0 ; + } + + ui = &uncore_info[pkg][die]; +if (num < ui->nb_freqs) { +POWER_LOG (ERR ,"Buffer size is not enough" ); +return 0 ; + } +rte_memcpy (freqs, ui->freqs, ui->nb_freqs *sizeof (uint32_t )); + +return ui->nb_freqs; +} + +int +power_amd_uncore_get_num_freqs (unsigned int pkg,unsigned int die) +{ +int ret =check_pkg_die_values (pkg, die); +if (ret <0 ) +return -1 ; + +return uncore_info[pkg][die].nb_freqs; +} + +unsigned int +power_amd_uncore_get_num_pkgs (void ) +{ +uint32_t num_pkgs =0 ; +int ret; + +if (esmi_initialized) { + ret =esmi_number_of_sockets_get (&num_pkgs); +if (ret !=ESMI_SUCCESS ) { +POWER_LOG (ERR ,"Failed to get number of sockets" ); + num_pkgs =0 ; + } + } +return num_pkgs; +} + +unsigned int +power_amd_uncore_get_num_dies (unsigned int pkg) +{ +if (pkg >=power_amd_uncore_get_num_pkgs ()) { +POWER_LOG (ERR ,"Invalid package ID" ); +return 0 ; + } + +return 1 ; +} + +static struct rte_power_uncore_ops amd_uncore_ops = { + .name ="amd-hsmp" , + .cb = power_amd_uncore_esmi_init, + .init = power_amd_uncore_init, + .exit = power_amd_uncore_exit, + .get_avail_freqs = power_amd_uncore_freqs, + .get_num_pkgs = power_amd_uncore_get_num_pkgs, + .get_num_dies = power_amd_uncore_get_num_dies, + .get_num_freqs = power_amd_uncore_get_num_freqs, + .get_freq = power_get_amd_uncore_freq, + .set_freq = power_set_amd_uncore_freq, + .freq_max = power_amd_uncore_freq_max, + .freq_min = power_amd_uncore_freq_min, +}; + +RTE_POWER_REGISTER_UNCORE_OPS (amd_uncore_ops);
drivers/power/amd_uncore/amd_uncore.h new file +226 -0
226 lines not on this page · raw message
drivers/power/amd_uncore/meson.build new file +20 -0
@@ -0,0 +1,20 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' + subdir_done() +endif + +ESMI_header = '#include<e_smi/e_smi.h>' +lib = cc.find_library('e_smi64', required: false) +if not lib.found() + build = false + reason = 'missing dependency, "libe_smi"' +else + ext_deps += lib +endif + +sources = files('amd_uncore.c') +deps += ['power']
drivers/power/meson.build +1 -0
@@ -7,6 +7,7 @@ drivers = [ 'cppc', 'kvm_vm', 'pstate', + 'amd_uncore', 'intel_uncore' ]
Signature · 1 line
2.34.1
v3 cover power: refactor power management library
In reply to Sivaprasad TummalaThis patchset refactors the power management library, addressing both core and uncore power management. The primary changes involve the creation of dedicated directories for each driver within 'drivers/power/core/*' and 'drivers/power/uncore/*'.
This refactor significantly improves code organization, enhances clarity, and boosts maintainability. It lays the foundation for more focused development on individual drivers and facilitates seamless integration of future enhancements, particularly the AMD uncore driver.
Furthermore, this effort aims to streamline code maintenance by consolidating common functions for cpufreq and cppc across various core drivers, thus reducing code duplication.
Sivaprasad Tummala (5):
power: refactor core power management library
power: refactor uncore power management library test/power: removed function pointer validations power/amd_uncore: uncore support for AMD EPYC processors
maintainers: update for drivers/power
MAINTAINERS | 1 +
app/test/test_power.c | 95 -----
app/test/test_power_cpufreq.c | 52 ---
app/test/test_power_kvm_vm.c | 36 --
drivers/meson.build | 1 +
.../power/acpi/acpi_cpufreq.c | 22 +-
.../power/acpi/acpi_cpufreq.h | 6 +-
drivers/power/acpi/meson.build | 10 +
.../power/amd_pstate/amd_pstate_cpufreq.c | 24 +-
.../power/amd_pstate/amd_pstate_cpufreq.h | 8 +-
drivers/power/amd_pstate/meson.build | 10 +
drivers/power/amd_uncore/amd_uncore.c | 328 ++++++++++++++++++
drivers/power/amd_uncore/amd_uncore.h | 226 ++++++++++++
drivers/power/amd_uncore/meson.build | 20 ++
.../power/cppc/cppc_cpufreq.c | 22 +-
.../power/cppc/cppc_cpufreq.h | 8 +-
drivers/power/cppc/meson.build | 10 +
.../power/intel_uncore/intel_uncore.c | 18 +-
.../power/intel_uncore/intel_uncore.h | 8 +-
drivers/power/intel_uncore/meson.build | 6 +
.../power/kvm_vm}/guest_channel.c | 0
.../power/kvm_vm}/guest_channel.h | 0
.../power/kvm_vm/kvm_vm.c | 22 +-
.../power/kvm_vm/kvm_vm.h | 6 +-
drivers/power/kvm_vm/meson.build | 16 +
drivers/power/meson.build | 14 +
drivers/power/pstate/meson.build | 10 +
.../power/pstate/pstate_cpufreq.c | 22 +-
.../power/pstate/pstate_cpufreq.h | 6 +-
examples/l3fwd-power/main.c | 12 +-
lib/power/meson.build | 9 +-
lib/power/power_common.c | 2 +-
lib/power/power_common.h | 16 +-
lib/power/rte_power.c | 286 +++++----------
lib/power/rte_power.h | 139 +++++---
lib/power/rte_power_cpufreq_api.h | 208 +++++++++++
lib/power/rte_power_uncore.c | 206 +++++------
lib/power/rte_power_uncore.h | 87 +++--
lib/power/rte_power_uncore_ops.h | 239 +++++++++++++
lib/power/version.map | 15 +
40 files changed, 1602 insertions(+), 624 deletions(-)
rename lib/power/power_acpi_cpufreq.c => drivers/power/acpi/acpi_cpufreq.c (95%)
rename lib/power/power_acpi_cpufreq.h => drivers/power/acpi/acpi_cpufreq.h (98%)
create mode 100644 drivers/power/acpi/meson.build
rename lib/power/power_amd_pstate_cpufreq.c => drivers/power/amd_pstate/amd_pstate_cpufreq.c (95%)
rename lib/power/power_amd_pstate_cpufreq.h => drivers/power/amd_pstate/amd_pstate_cpufreq.h (97%)
create mode 100644 drivers/power/amd_pstate/meson.build
create mode 100644 drivers/power/amd_uncore/amd_uncore.c
create mode 100644 drivers/power/amd_uncore/amd_uncore.h
create mode 100644 drivers/power/amd_uncore/meson.build
rename lib/power/power_cppc_cpufreq.c => drivers/power/cppc/cppc_cpufreq.c (95%)
rename lib/power/power_cppc_cpufreq.h => drivers/power/cppc/cppc_cpufreq.h (97%)
create mode 100644 drivers/power/cppc/meson.build
rename lib/power/power_intel_uncore.c => drivers/power/intel_uncore/intel_uncore.c (95%)
rename lib/power/power_intel_uncore.h => drivers/power/intel_uncore/intel_uncore.h (97%)
create mode 100644 drivers/power/intel_uncore/meson.build
rename {lib/power => drivers/power/kvm_vm}/guest_channel.c (100%)
rename {lib/power => drivers/power/kvm_vm}/guest_channel.h (100%)
rename lib/power/power_kvm_vm.c => drivers/power/kvm_vm/kvm_vm.c (82%)
rename lib/power/power_kvm_vm.h => drivers/power/kvm_vm/kvm_vm.h (98%)
create mode 100644 drivers/power/kvm_vm/meson.build
create mode 100644 drivers/power/meson.build
create mode 100644 drivers/power/pstate/meson.build
rename lib/power/power_pstate_cpufreq.c => drivers/power/pstate/pstate_cpufreq.c (96%)
rename lib/power/power_pstate_cpufreq.h => drivers/power/pstate/pstate_cpufreq.h (98%)
create mode 100644 lib/power/rte_power_cpufreq_api.h
create mode 100644 lib/power/rte_power_uncore_ops.hSignature · 1 line
2.34.1
PATCH v3 5/5 maintainers: update for drivers/power
In reply to Sivaprasad TummalaUpdate maintainers for drivers/power/*.
--- MAINTAINERS | 1 + 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
@@ -1737,6 +1737,7 @@ M: Anatoly Burakov <[email protected]> M: David Hunt <[email protected]> M: Sivaprasad Tummala <[email protected]> F: lib/power/ +F: drivers/power/* F: doc/guides/prog_guide/power_man.rst F: app/test/test_power* F: examples/l3fwd-power/
Signature · 1 line
2.34.1
v3 cover power: refactor power management library
In reply to Sivaprasad TummalaThis patchset refactors the power management library, addressing both core and uncore power management. The primary changes involve the creation of dedicated directories for each driver within 'drivers/power/core/*' and 'drivers/power/uncore/*'.
This refactor significantly improves code organization, enhances clarity, and boosts maintainability. It lays the foundation for more focused development on individual drivers and facilitates seamless integration of future enhancements, particularly the AMD uncore driver.
Furthermore, this effort aims to streamline code maintenance by consolidating common functions for cpufreq and cppc across various core drivers, thus reducing code duplication.
Sivaprasad Tummala (5):
power: refactor core power management library
power: refactor uncore power management library test/power: removed function pointer validations power/amd_uncore: uncore support for AMD EPYC processors
maintainers: update for drivers/power
MAINTAINERS | 1 +
app/test/test_power.c | 95 -----
app/test/test_power_cpufreq.c | 52 ---
app/test/test_power_kvm_vm.c | 36 --
drivers/meson.build | 1 +
.../power/acpi/acpi_cpufreq.c | 22 +-
.../power/acpi/acpi_cpufreq.h | 6 +-
drivers/power/acpi/meson.build | 10 +
.../power/amd_pstate/amd_pstate_cpufreq.c | 24 +-
.../power/amd_pstate/amd_pstate_cpufreq.h | 8 +-
drivers/power/amd_pstate/meson.build | 10 +
drivers/power/amd_uncore/amd_uncore.c | 329 ++++++++++++++++++
drivers/power/amd_uncore/amd_uncore.h | 226 ++++++++++++
drivers/power/amd_uncore/meson.build | 20 ++
.../power/cppc/cppc_cpufreq.c | 22 +-
.../power/cppc/cppc_cpufreq.h | 8 +-
drivers/power/cppc/meson.build | 10 +
.../power/intel_uncore/intel_uncore.c | 18 +-
.../power/intel_uncore/intel_uncore.h | 8 +-
drivers/power/intel_uncore/meson.build | 6 +
.../power/kvm_vm}/guest_channel.c | 0
.../power/kvm_vm}/guest_channel.h | 0
.../power/kvm_vm/kvm_vm.c | 22 +-
.../power/kvm_vm/kvm_vm.h | 6 +-
drivers/power/kvm_vm/meson.build | 16 +
drivers/power/meson.build | 14 +
drivers/power/pstate/meson.build | 10 +
.../power/pstate/pstate_cpufreq.c | 22 +-
.../power/pstate/pstate_cpufreq.h | 6 +-
examples/l3fwd-power/main.c | 12 +-
lib/power/meson.build | 9 +-
lib/power/power_common.c | 2 +-
lib/power/power_common.h | 16 +-
lib/power/rte_power.c | 286 +++++----------
lib/power/rte_power.h | 139 +++++---
lib/power/rte_power_cpufreq_api.h | 208 +++++++++++
lib/power/rte_power_uncore.c | 206 +++++------
lib/power/rte_power_uncore.h | 87 +++--
lib/power/rte_power_uncore_ops.h | 239 +++++++++++++
lib/power/version.map | 15 +
40 files changed, 1603 insertions(+), 624 deletions(-)
rename lib/power/power_acpi_cpufreq.c => drivers/power/acpi/acpi_cpufreq.c (95%)
rename lib/power/power_acpi_cpufreq.h => drivers/power/acpi/acpi_cpufreq.h (98%)
create mode 100644 drivers/power/acpi/meson.build
rename lib/power/power_amd_pstate_cpufreq.c => drivers/power/amd_pstate/amd_pstate_cpufreq.c (95%)
rename lib/power/power_amd_pstate_cpufreq.h => drivers/power/amd_pstate/amd_pstate_cpufreq.h (97%)
create mode 100644 drivers/power/amd_pstate/meson.build
create mode 100644 drivers/power/amd_uncore/amd_uncore.c
create mode 100644 drivers/power/amd_uncore/amd_uncore.h
create mode 100644 drivers/power/amd_uncore/meson.build
rename lib/power/power_cppc_cpufreq.c => drivers/power/cppc/cppc_cpufreq.c (95%)
rename lib/power/power_cppc_cpufreq.h => drivers/power/cppc/cppc_cpufreq.h (97%)
create mode 100644 drivers/power/cppc/meson.build
rename lib/power/power_intel_uncore.c => drivers/power/intel_uncore/intel_uncore.c (95%)
rename lib/power/power_intel_uncore.h => drivers/power/intel_uncore/intel_uncore.h (97%)
create mode 100644 drivers/power/intel_uncore/meson.build
rename {lib/power => drivers/power/kvm_vm}/guest_channel.c (100%)
rename {lib/power => drivers/power/kvm_vm}/guest_channel.h (100%)
rename lib/power/power_kvm_vm.c => drivers/power/kvm_vm/kvm_vm.c (82%)
rename lib/power/power_kvm_vm.h => drivers/power/kvm_vm/kvm_vm.h (98%)
create mode 100644 drivers/power/kvm_vm/meson.build
create mode 100644 drivers/power/meson.build
create mode 100644 drivers/power/pstate/meson.build
rename lib/power/power_pstate_cpufreq.c => drivers/power/pstate/pstate_cpufreq.c (96%)
rename lib/power/power_pstate_cpufreq.h => drivers/power/pstate/pstate_cpufreq.h (98%)
create mode 100644 lib/power/rte_power_cpufreq_api.h
create mode 100644 lib/power/rte_power_uncore_ops.hSignature · 1 line
2.34.1
PATCH v3 1/5 power: refactor core power management library
This patch introduces a comprehensive refactor to the core power management library. The primary focus is on improving modularity and organization by relocating specific driver implementations from the 'lib/power' directory to dedicated directories within 'drivers/power/core/*'. The adjustment of meson.build files enables the selective activation of individual drivers.
These changes contribute to a significant enhancement in code organization, providing a clearer structure for driver implementations. The refactor aims to improve overall code clarity and boost maintainability. Additionally, it establishes a foundation for future development, allowing for more focused work on individual drivers and seamless integration of forthcoming enhancements.
v3:
- renamed rte_power_core_ops.h as rte_power_cpufreq_api.h
- re-worked on auto detection logic
v2:
- added NULL check for global_core_ops in rte_power_get_core_ops
---
drivers/meson.build | 1 +
.../power/acpi/acpi_cpufreq.c | 22 +-
.../power/acpi/acpi_cpufreq.h | 6 +-
drivers/power/acpi/meson.build | 10 +
.../power/amd_pstate/amd_pstate_cpufreq.c | 24 +-
.../power/amd_pstate/amd_pstate_cpufreq.h | 8 +-
drivers/power/amd_pstate/meson.build | 10 +
.../power/cppc/cppc_cpufreq.c | 22 +-
.../power/cppc/cppc_cpufreq.h | 8 +-
drivers/power/cppc/meson.build | 10 +
.../power/kvm_vm}/guest_channel.c | 0
.../power/kvm_vm}/guest_channel.h | 0
.../power/kvm_vm/kvm_vm.c | 22 +-
.../power/kvm_vm/kvm_vm.h | 6 +-
drivers/power/kvm_vm/meson.build | 16 +
drivers/power/meson.build | 12 +
drivers/power/pstate/meson.build | 10 +
.../power/pstate/pstate_cpufreq.c | 22 +-
.../power/pstate/pstate_cpufreq.h | 6 +-
lib/power/meson.build | 7 +-
lib/power/power_common.c | 2 +-
lib/power/power_common.h | 16 +-
lib/power/rte_power.c | 286 ++++++------------
lib/power/rte_power.h | 139 ++++++---
lib/power/rte_power_cpufreq_api.h | 208 +++++++++++++
lib/power/version.map | 14 +
26 files changed, 618 insertions(+), 269 deletions(-)
rename lib/power/power_acpi_cpufreq.c => drivers/power/acpi/acpi_cpufreq.c (95%)
rename lib/power/power_acpi_cpufreq.h => drivers/power/acpi/acpi_cpufreq.h (98%)
create mode 100644 drivers/power/acpi/meson.build
rename lib/power/power_amd_pstate_cpufreq.c => drivers/power/amd_pstate/amd_pstate_cpufreq.c (95%)
rename lib/power/power_amd_pstate_cpufreq.h => drivers/power/amd_pstate/amd_pstate_cpufreq.h (97%)
create mode 100644 drivers/power/amd_pstate/meson.build
rename lib/power/power_cppc_cpufreq.c => drivers/power/cppc/cppc_cpufreq.c (95%)
rename lib/power/power_cppc_cpufreq.h => drivers/power/cppc/cppc_cpufreq.h (97%)
create mode 100644 drivers/power/cppc/meson.build
rename {lib/power => drivers/power/kvm_vm}/guest_channel.c (100%)
rename {lib/power => drivers/power/kvm_vm}/guest_channel.h (100%)
rename lib/power/power_kvm_vm.c => drivers/power/kvm_vm/kvm_vm.c (82%)
rename lib/power/power_kvm_vm.h => drivers/power/kvm_vm/kvm_vm.h (98%)
create mode 100644 drivers/power/kvm_vm/meson.build
create mode 100644 drivers/power/meson.build
create mode 100644 drivers/power/pstate/meson.build
rename lib/power/power_pstate_cpufreq.c => drivers/power/pstate/pstate_cpufreq.c (96%)
rename lib/power/power_pstate_cpufreq.h => drivers/power/pstate/pstate_cpufreq.h (98%)
create mode 100644 lib/power/rte_power_cpufreq_api.hdrivers/meson.build +1 -0
@@ -29,6 +29,7 @@ subdirs = [ 'event', # depends on common, bus, mempool and net. 'baseband', # depends on common and bus. 'gpu', # depends on common and bus. + 'power', # depends on common (in future). ] if meson.is_cross_build()
drivers/power/acpi/acpi_cpufreq.c renamed from lib/power/power_acpi_cpufreq.c +21 -1
@@ -10,7 +10,7 @@#include <rte_stdatomic.h> #include <rte_string_fns.h> -#include "power_acpi_cpufreq.h" +#include "acpi_cpufreq.h" #include "power_common.h" #define STR_SIZE 1024
@@ -577,3 +577,23 @@ int power_acpi_get_capabilities(unsigned int lcore_id,return 0 ; } + +static struct rte_power_core_ops acpi_ops = { + .name ="acpi" , + .init = power_acpi_cpufreq_init, + .exit = power_acpi_cpufreq_exit, + .check_env_support = power_acpi_cpufreq_check_supported, + .get_avail_freqs = power_acpi_cpufreq_freqs, + .get_freq = power_acpi_cpufreq_get_freq, + .set_freq = power_acpi_cpufreq_set_freq, + .freq_down = power_acpi_cpufreq_freq_down, + .freq_up = power_acpi_cpufreq_freq_up, + .freq_max = power_acpi_cpufreq_freq_max, + .freq_min = power_acpi_cpufreq_freq_min, + .turbo_status = power_acpi_turbo_status, + .enable_turbo = power_acpi_enable_turbo, + .disable_turbo = power_acpi_disable_turbo, + .get_caps = power_acpi_get_capabilities +}; + +RTE_POWER_REGISTER_OPS (acpi_ops);
drivers/power/acpi/acpi_cpufreq.h renamed from lib/power/power_acpi_cpufreq.h +3 -3
@@ -2,15 +2,15 @@* Copyright(c) 2010-2014 Intel Corporation */ -#ifndef _POWER_ACPI_CPUFREQ_H -#define _POWER_ACPI_CPUFREQ_H +#ifndef _ACPI_CPUFREQ_H +#define _ACPI_CPUFREQ_H/** * @file * RTE Power Management via userspace ACPI cpufreq */ -#include "rte_power.h" +#include "rte_power_cpufreq_api.h" /** * Check if ACPI power management is supported.
drivers/power/acpi/meson.build new file +10 -0
@@ -0,0 +1,10 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' +endif +sources = files('acpi_cpufreq.c') + +deps += ['power']
drivers/power/amd_pstate/amd_pstate_cpufreq.c renamed from lib/power/power_amd_pstate_cpufreq.c +22 -2
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2010-2021 Intel Corporation * Copyright(c) 2021 Arm Limited -* Copyright(c) 2023 Amd Limited +* Copyright(c) 2024 Advanced Micro Devices, Inc. */ #include <stdlib.h>
@@ -9,7 +9,7 @@#include <rte_memcpy.h> #include <rte_stdatomic.h> -#include "power_amd_pstate_cpufreq.h" +#include "amd_pstate_cpufreq.h" #include "power_common.h" /* macros used for rounding frequency to nearest 1000 */
@@ -700,3 +700,23 @@ power_amd_pstate_get_capabilities(unsigned int lcore_id,return 0 ; } + +static struct rte_power_core_ops amd_pstate_ops = { + .name ="amd-pstate" , + .init = power_amd_pstate_cpufreq_init, + .exit = power_amd_pstate_cpufreq_exit, + .check_env_support = power_amd_pstate_cpufreq_check_supported, + .get_avail_freqs = power_amd_pstate_cpufreq_freqs, + .get_freq = power_amd_pstate_cpufreq_get_freq, + .set_freq = power_amd_pstate_cpufreq_set_freq, + .freq_down = power_amd_pstate_cpufreq_freq_down, + .freq_up = power_amd_pstate_cpufreq_freq_up, + .freq_max = power_amd_pstate_cpufreq_freq_max, + .freq_min = power_amd_pstate_cpufreq_freq_min, + .turbo_status = power_amd_pstate_turbo_status, + .enable_turbo = power_amd_pstate_enable_turbo, + .disable_turbo = power_amd_pstate_disable_turbo, + .get_caps = power_amd_pstate_get_capabilities +}; + +RTE_POWER_REGISTER_OPS (amd_pstate_ops);
drivers/power/amd_pstate/amd_pstate_cpufreq.h renamed from lib/power/power_amd_pstate_cpufreq.h +4 -4
@@ -1,18 +1,18 @@/* SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2010-2021 Intel Corporation * Copyright(c) 2021 Arm Limited -* Copyright(c) 2023 Amd Limited +* Copyright(c) 2024 Advanced Micro Devices, Inc. */ -#ifndef _POWER_AMD_PSTATE_CPUFREQ_H -#define _POWER_AMD_PSTATE_CPUFREQ_H +#ifndef _AMD_PSTATE_CPUFREQ_H +#define _AMD_PSTATE_CPUFREQ_H/** * @file * RTE Power Management via userspace AMD pstate cpufreq */ -#include "rte_power.h" +#include "rte_power_cpufreq_api.h" /** * Check if amd p-state power management is supported.
drivers/power/amd_pstate/meson.build new file +10 -0
@@ -0,0 +1,10 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' +endif +sources = files('amd_pstate_cpufreq.c') + +deps += ['power']
drivers/power/cppc/cppc_cpufreq.c renamed from lib/power/power_cppc_cpufreq.c +21 -1
@@ -8,7 +8,7 @@#include <rte_memcpy.h> #include <rte_stdatomic.h> -#include "power_cppc_cpufreq.h" +#include "cppc_cpufreq.h" #include "power_common.h" /* macros used for rounding frequency to nearest 100000 */
@@ -685,3 +685,23 @@ power_cppc_get_capabilities(unsigned int lcore_id,return 0 ; } + +static struct rte_power_core_ops cppc_ops = { + .name ="cppc" , + .init = power_cppc_cpufreq_init, + .exit = power_cppc_cpufreq_exit, + .check_env_support = power_cppc_cpufreq_check_supported, + .get_avail_freqs = power_cppc_cpufreq_freqs, + .get_freq = power_cppc_cpufreq_get_freq, + .set_freq = power_cppc_cpufreq_set_freq, + .freq_down = power_cppc_cpufreq_freq_down, + .freq_up = power_cppc_cpufreq_freq_up, + .freq_max = power_cppc_cpufreq_freq_max, + .freq_min = power_cppc_cpufreq_freq_min, + .turbo_status = power_cppc_turbo_status, + .enable_turbo = power_cppc_enable_turbo, + .disable_turbo = power_cppc_disable_turbo, + .get_caps = power_cppc_get_capabilities +}; + +RTE_POWER_REGISTER_OPS (cppc_ops);
drivers/power/cppc/cppc_cpufreq.h renamed from lib/power/power_cppc_cpufreq.h +4 -4
@@ -3,15 +3,15 @@* Copyright(c) 2021 Arm Limited */ -#ifndef _POWER_CPPC_CPUFREQ_H -#define _POWER_CPPC_CPUFREQ_H +#ifndef _CPPC_CPUFREQ_H +#define _CPPC_CPUFREQ_H/** * @file * RTE Power Management via userspace CPPC cpufreq */ -#include "rte_power.h" +#include "rte_power_cpufreq_api.h" /** * Check if CPPC power management is supported.
@@ -215,4 +215,4 @@ int power_cppc_disable_turbo(unsigned int lcore_id);int power_cppc_get_capabilities (unsigned int lcore_id,struct rte_power_core_capabilities *caps); -#endif /* _POWER_CPPC_CPUFREQ_H */ +#endif /* _CPPC_CPUFREQ_H */
drivers/power/cppc/meson.build new file +10 -0
@@ -0,0 +1,10 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' +endif +sources = files('cppc_cpufreq.c') + +deps += ['power']
drivers/power/kvm_vm/guest_channel.c renamed from lib/power/guest_channel.c +0 -0
drivers/power/kvm_vm/guest_channel.h renamed from lib/power/guest_channel.h +0 -0
drivers/power/kvm_vm/kvm_vm.c renamed from lib/power/power_kvm_vm.c +21 -1
@@ -9,7 +9,7 @@#include "rte_power_guest_channel.h" #include "guest_channel.h" #include "power_common.h" -#include "power_kvm_vm.h" +#include "kvm_vm.h" #define FD_PATH "/dev/virtio-ports/virtio.serial.port.poweragent"
@@ -137,3 +137,23 @@ int power_kvm_vm_get_capabilities(__rte_unused unsigned int lcore_id,POWER_LOG (ERR ,"rte_power_get_capabilities is not implemented for Virtual Machine Power Management" );return -ENOTSUP ; } + +static struct rte_power_core_ops kvm_vm_ops = { + .name ="kvm-vm" , + .init = power_kvm_vm_init, + .exit = power_kvm_vm_exit, + .check_env_support = power_kvm_vm_check_supported, + .get_avail_freqs = power_kvm_vm_freqs, + .get_freq = power_kvm_vm_get_freq, + .set_freq = power_kvm_vm_set_freq, + .freq_down = power_kvm_vm_freq_down, + .freq_up = power_kvm_vm_freq_up, + .freq_max = power_kvm_vm_freq_max, + .freq_min = power_kvm_vm_freq_min, + .turbo_status = power_kvm_vm_turbo_status, + .enable_turbo = power_kvm_vm_enable_turbo, + .disable_turbo = power_kvm_vm_disable_turbo, + .get_caps = power_kvm_vm_get_capabilities +}; + +RTE_POWER_REGISTER_OPS (kvm_vm_ops);
drivers/power/kvm_vm/kvm_vm.h renamed from lib/power/power_kvm_vm.h +3 -3
@@ -2,15 +2,15 @@* Copyright(c) 2010-2014 Intel Corporation */ -#ifndef _POWER_KVM_VM_H -#define _POWER_KVM_VM_H +#ifndef _KVM_VM_H +#define _KVM_VM_H/** * @file * RTE Power Management KVM VM */ -#include "rte_power.h" +#include "rte_power_cpufreq_api.h" /** * Check if KVM power management is supported.
drivers/power/kvm_vm/meson.build new file +16 -0
@@ -0,0 +1,16 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(C) 2024 Advanced Micro Devices, Inc. +# + +if not is_linux + build = false + reason = 'only supported on Linux' + subdir_done() +endif + +sources = files( + 'guest_channel.c', + 'kvm_vm.c', +) + +deps += ['power']
drivers/power/meson.build new file +12 -0
@@ -0,0 +1,12 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +drivers = [ + 'acpi', + 'amd_pstate', + 'cppc', + 'kvm_vm', + 'pstate' +] + +std_deps = ['power']
drivers/power/pstate/meson.build new file +10 -0
@@ -0,0 +1,10 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' +endif +sources = files('pstate_cpufreq.c') + +deps += ['power']
drivers/power/pstate/pstate_cpufreq.c renamed from lib/power/power_pstate_cpufreq.c +21 -1
@@ -15,7 +15,7 @@#include <rte_stdatomic.h> #include "rte_power_pmd_mgmt.h" -#include "power_pstate_cpufreq.h" +#include "pstate_cpufreq.h" #include "power_common.h" /* macros used for rounding frequency to nearest 100000 */
@@ -888,3 +888,23 @@ int power_pstate_get_capabilities(unsigned int lcore_id,return 0 ; } + +static struct rte_power_core_ops pstate_ops = { + .name ="pstate" , + .init = power_pstate_cpufreq_init, + .exit = power_pstate_cpufreq_exit, + .check_env_support = power_pstate_cpufreq_check_supported, + .get_avail_freqs = power_pstate_cpufreq_freqs, + .get_freq = power_pstate_cpufreq_get_freq, + .set_freq = power_pstate_cpufreq_set_freq, + .freq_down = power_pstate_cpufreq_freq_down, + .freq_up = power_pstate_cpufreq_freq_up, + .freq_max = power_pstate_cpufreq_freq_max, + .freq_min = power_pstate_cpufreq_freq_min, + .turbo_status = power_pstate_turbo_status, + .enable_turbo = power_pstate_enable_turbo, + .disable_turbo = power_pstate_disable_turbo, + .get_caps = power_pstate_get_capabilities +}; + +RTE_POWER_REGISTER_OPS (pstate_ops);
drivers/power/pstate/pstate_cpufreq.h renamed from lib/power/power_pstate_cpufreq.h +3 -3
@@ -2,15 +2,15 @@* Copyright(c) 2018 Intel Corporation */ -#ifndef _POWER_PSTATE_CPUFREQ_H -#define _POWER_PSTATE_CPUFREQ_H +#ifndef _PSTATE_CPUFREQ_H +#define _PSTATE_CPUFREQ_H/** * @file * RTE Power Management via Intel Pstate driver */ -#include "rte_power.h" +#include "rte_power_cpufreq_api.h" /** * Check if pstate power management is supported.
lib/power/meson.build +1 -6
@@ -12,20 +12,15 @@ if not is_linux reason = 'only supported on Linux' endif sources = files( - 'guest_channel.c', - 'power_acpi_cpufreq.c', - 'power_amd_pstate_cpufreq.c', 'power_common.c', - 'power_cppc_cpufreq.c', - 'power_kvm_vm.c', 'power_intel_uncore.c', - 'power_pstate_cpufreq.c', 'rte_power.c', 'rte_power_uncore.c', 'rte_power_pmd_mgmt.c', ) headers = files( 'rte_power.h', + 'rte_power_cpufreq_api.h', 'rte_power_guest_channel.h', 'rte_power_pmd_mgmt.h', 'rte_power_uncore.h',
lib/power/power_common.c +1 -1
@@ -12,7 +12,7 @@#include "power_common.h" -RTE_LOG_REGISTER_DEFAULT (power_logtype,INFO ); +RTE_LOG_REGISTER_DEFAULT (rte_power_logtype,INFO );#define POWER_SYSFILE_SCALING_DRIVER \ "/sys/devices/system/cpu/cpu%u/cpufreq/scaling_driver"
lib/power/power_common.h +14 -2
@@ -6,12 +6,13 @@#define _POWER_COMMON_H_#include <rte_common.h> +#include <rte_compat.h> #include <rte_log.h> #define RTE_POWER_INVALID_FREQ_INDEX (~0) -extern int power_logtype; -#define RTE_LOGTYPE_POWER power_logtype +extern int rte_power_logtype; +#define RTE_LOGTYPE_POWER rte_power_logtype#define POWER_LOG (level, ...) \ RTE_LOG_LINE(level, POWER, "" __VA_ARGS__)
@@ -23,13 +24,24 @@ extern int power_logtype;#endif /* check if scaling driver matches one we want */ +__rte_internal int cpufreq_check_scaling_driver(const char *driver); + +__rte_internal int power_set_governor(unsigned int lcore_id, const char *new_governor,char *orig_governor,size_t orig_governor_len); + +__rte_internal int open_core_sysfs_file(FILE **f, const char *mode, const char *format, ...) __rte_format_printf(3, 4); + +__rte_internal int read_core_sysfs_u32(FILE *f, uint32_t *val); + +__rte_internal int read_core_sysfs_s(FILE *f, char *buf, unsigned int len); + +__rte_internal int write_core_sysfs_s(FILE *f, const char *str);#endif /* _POWER_COMMON_H_ */
lib/power/rte_power.c +95 -191
342 lines not on this page · raw message
lib/power/rte_power.h +93 -46
229 lines not on this page · raw message
lib/power/rte_power_cpufreq_api.h new file +208 -0
208 lines not on this page · raw message
lib/power/version.map +14 -0
@@ -51,4 +51,18 @@ EXPERIMENTAL { rte_power_set_uncore_env; rte_power_uncore_freqs; rte_power_unset_uncore_env; + # added in 24.11 + rte_power_logtype; +}; + +INTERNAL { + global: + + rte_power_register_ops; + cpufreq_check_scaling_driver; + power_set_governor; + open_core_sysfs_file; + read_core_sysfs_u32; + read_core_sysfs_s; + write_core_sysfs_s; };
Signature · 1 line
2.34.1
PATCH v3 2/5 power: refactor uncore power management library
In reply to Sivaprasad TummalaThis patch refactors the power management library, addressing uncore power management. The primary changes involve the creation of dedicated directories for each driver within 'drivers/power/uncore/*'. The adjustment of meson.build files enables the selective activation of individual drivers.
This refactor significantly improves code organization, enhances clarity and boosts maintainability. It lays the foundation for more focused development on individual drivers and facilitates seamless integration of future enhancements, particularly the AMD uncore driver.
v3:
- fixed typo in header file inclusion
--- .../power/intel_uncore/intel_uncore.c | 18 +- .../power/intel_uncore/intel_uncore.h | 8 +- drivers/power/intel_uncore/meson.build | 6 + drivers/power/meson.build | 3 +- lib/power/meson.build | 2 +- lib/power/rte_power_uncore.c | 206 ++++++--------- lib/power/rte_power_uncore.h | 87 ++++--- lib/power/rte_power_uncore_ops.h | 239 ++++++++++++++++++ lib/power/version.map | 1 + 9 files changed, 405 insertions(+), 165 deletions(-) rename lib/power/power_intel_uncore.c => drivers/power/intel_uncore/intel_uncore.c (95%) rename lib/power/power_intel_uncore.h => drivers/power/intel_uncore/intel_uncore.h (97%) create mode 100644 drivers/power/intel_uncore/meson.build create mode 100644 lib/power/rte_power_uncore_ops.h
drivers/power/intel_uncore/intel_uncore.c renamed from lib/power/power_intel_uncore.c +17 -1
@@ -8,7 +8,7 @@#include <rte_memcpy.h> -#include "power_intel_uncore.h" +#include "intel_uncore.h" #include "power_common.h" #define MAX_NUMA_DIE 8
@@ -475,3 +475,19 @@ power_intel_uncore_get_num_dies(unsigned int pkg)return count; } + +static struct rte_power_uncore_ops intel_uncore_ops = { + .name ="intel-uncore" , + .init = power_intel_uncore_init, + .exit = power_intel_uncore_exit, + .get_avail_freqs = power_intel_uncore_freqs, + .get_num_pkgs = power_intel_uncore_get_num_pkgs, + .get_num_dies = power_intel_uncore_get_num_dies, + .get_num_freqs = power_intel_uncore_get_num_freqs, + .get_freq = power_get_intel_uncore_freq, + .set_freq = power_set_intel_uncore_freq, + .freq_max = power_intel_uncore_freq_max, + .freq_min = power_intel_uncore_freq_min, +}; + +RTE_POWER_REGISTER_UNCORE_OPS (intel_uncore_ops);
drivers/power/intel_uncore/intel_uncore.h renamed from lib/power/power_intel_uncore.h +4 -4
@@ -2,8 +2,8 @@* Copyright(c) 2022 Intel Corporation */ -#ifndef POWER_INTEL_UNCORE_H -#define POWER_INTEL_UNCORE_H +#ifndef INTEL_UNCORE_H +#define INTEL_UNCORE_H /** * @file
@@ -11,7 +11,7 @@*/ #include "rte_power.h" -#include "rte_power_uncore.h" +#include "rte_power_uncore_ops.h" #ifdef __cplusplusextern "C" {
@@ -223,4 +223,4 @@ power_intel_uncore_get_num_dies(unsigned int pkg); }#endif -#endif /* POWER_INTEL_UNCORE_H */ +#endif /* INTEL_UNCORE_H */
drivers/power/intel_uncore/meson.build new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2017 Intel Corporation +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +sources = files('intel_uncore.c') +deps += ['power']
drivers/power/meson.build +2 -1
@@ -6,7 +6,8 @@ drivers = [ 'amd_pstate', 'cppc', 'kvm_vm', - 'pstate' + 'pstate', + 'intel_uncore' ] std_deps = ['power']
lib/power/meson.build +1 -1
@@ -13,7 +13,6 @@ if not is_linux endif sources = files( 'power_common.c', - 'power_intel_uncore.c', 'rte_power.c', 'rte_power_uncore.c', 'rte_power_pmd_mgmt.c',
@@ -24,6 +23,7 @@ headers = files( 'rte_power_guest_channel.h', 'rte_power_pmd_mgmt.h', 'rte_power_uncore.h', + 'rte_power_uncore_ops.h', ) if cc.has_argument('-Wno-cast-qual') cflags += '-Wno-cast-qual'
lib/power/rte_power_uncore.c +82 -124
265 lines not on this page · raw message
lib/power/rte_power_uncore.h +53 -34
153 lines not on this page · raw message
lib/power/rte_power_uncore_ops.h new file +239 -0
239 lines not on this page · raw message
lib/power/version.map +1 -0
@@ -59,6 +59,7 @@ INTERNAL { global: rte_power_register_ops; + rte_power_register_uncore_ops; cpufreq_check_scaling_driver; power_set_governor; open_core_sysfs_file;
Signature · 1 line
2.34.1
PATCH v3 3/5 test/power: removed function pointer validations
In reply to Sivaprasad TummalaAfter refactoring the power library, power management operations are now consistently supported regardless of the operating environment, making function pointer checks unnecessary and thus removed from applications.
v2:
- removed function pointer validation in l3fwd-power app.
--- app/test/test_power.c | 95 ----------------------------------- app/test/test_power_cpufreq.c | 52 ------------------- app/test/test_power_kvm_vm.c | 36 ------------- examples/l3fwd-power/main.c | 12 ++--- 4 files changed, 4 insertions(+), 191 deletions(-)
app/test/test_power.c +0 -95
@@ -24,86 +24,6 @@ test_power(void)#include <rte_power.h> -static int -check_function_ptrs (void ) -{ -enum power_management_env env =rte_power_get_env (); - -const bool not_null_expected = !(env ==PM_ENV_NOT_SET ); - -const char *inject_not_string1 = not_null_expected ?" not" :"" ; -const char *inject_not_string2 = not_null_expected ?"" :" not" ; - -if ((rte_power_freqs ==NULL ) == not_null_expected) { -printf ("rte_power_freqs should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_get_freq ==NULL ) == not_null_expected) { -printf ("rte_power_get_freq should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_set_freq ==NULL ) == not_null_expected) { -printf ("rte_power_set_freq should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_freq_up ==NULL ) == not_null_expected) { -printf ("rte_power_freq_up should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_freq_down ==NULL ) == not_null_expected) { -printf ("rte_power_freq_down should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_freq_max ==NULL ) == not_null_expected) { -printf ("rte_power_freq_max should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_freq_min ==NULL ) == not_null_expected) { -printf ("rte_power_freq_min should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_turbo_status ==NULL ) == not_null_expected) { -printf ("rte_power_turbo_status should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_freq_enable_turbo ==NULL ) == not_null_expected) { -printf ("rte_power_freq_enable_turbo should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_freq_disable_turbo ==NULL ) == not_null_expected) { -printf ("rte_power_freq_disable_turbo should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_get_capabilities ==NULL ) == not_null_expected) { -printf ("rte_power_get_capabilities should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } - -return 0 ; -} -static int test_power (void ) {
@@ -124,10 +44,6 @@ test_power(void)return -1 ; } -/* Verify that function pointers are NULL */ -if (check_function_ptrs () <0 ) - goto fail_all; -rte_power_unset_env ();/* Perform tests for valid environments.*/
@@ -154,22 +70,11 @@ test_power(void) return -1; } -/* Verify that function pointers are NOT NULL */ -if (check_function_ptrs () <0 ) - goto fail_all; -rte_power_unset_env (); -/* Verify that function pointers are NULL */ -if (check_function_ptrs () <0 ) - goto fail_all; - }return 0 ; -fail_all: -rte_power_unset_env (); -return -1 ; }#endif
app/test/test_power_cpufreq.c +0 -52
58 lines not on this page · raw message
app/test/test_power_kvm_vm.c +0 -36
@@ -47,42 +47,6 @@ test_power_kvm_vm(void)return -1 ; } -/* verify that function pointers are not NULL */ -if (rte_power_freqs ==NULL ) { -printf ("rte_power_freqs should not be NULL, environment has not been " -"initialised\n" ); -return -1 ; - } -if (rte_power_get_freq ==NULL ) { -printf ("rte_power_get_freq should not be NULL, environment has not " -"been initialised\n" ); -return -1 ; - } -if (rte_power_set_freq ==NULL ) { -printf ("rte_power_set_freq should not be NULL, environment has not " -"been initialised\n" ); -return -1 ; - } -if (rte_power_freq_up ==NULL ) { -printf ("rte_power_freq_up should not be NULL, environment has not " -"been initialised\n" ); -return -1 ; - } -if (rte_power_freq_down ==NULL ) { -printf ("rte_power_freq_down should not be NULL, environment has not " -"been initialised\n" ); -return -1 ; - } -if (rte_power_freq_max ==NULL ) { -printf ("rte_power_freq_max should not be NULL, environment has not " -"been initialised\n" ); -return -1 ; - } -if (rte_power_freq_min ==NULL ) { -printf ("rte_power_freq_min should not be NULL, environment has not " -"been initialised\n" ); -return -1 ; - }/* Test initialisation of an out of bounds lcore */ ret =rte_power_init (TEST_POWER_VM_LCORE_OUT_OF_BOUNDS );if (ret !=-1 ) {
examples/l3fwd-power/main.c +4 -8
@@ -440,8 +440,7 @@ power_timer_cb(__rte_unused struct rte_timer *tim,* check whether need to scale down frequency a step if it sleep a lot. */ if (sleep_time_ratio >=SCALING_DOWN_TIME_RATIO_THRESHOLD ) { -if (rte_power_freq_down) -rte_power_freq_down (lcore_id); +rte_power_freq_down (lcore_id); }else if ( (unsigned )(stats[lcore_id].nb_rx_processed / stats[lcore_id].nb_iteration_looped) <MAX_PKT_BURST ) {
@@ -449,8 +448,7 @@ power_timer_cb(__rte_unused struct rte_timer *tim,* scale down a step if average packet per iteration less * than expectation. */ -if (rte_power_freq_down) -rte_power_freq_down (lcore_id); +rte_power_freq_down (lcore_id); }/**
@@ -1344,11 +1342,9 @@ main_legacy_loop(__rte_unused void *dummy) }if (lcore_scaleup_hint ==FREQ_HIGHEST ) { -if (rte_power_freq_max) -rte_power_freq_max (lcore_id); +rte_power_freq_max (lcore_id); }else if (lcore_scaleup_hint ==FREQ_HIGHER ) { -if (rte_power_freq_up) -rte_power_freq_up (lcore_id); +rte_power_freq_up (lcore_id); } }else {/**
Signature · 1 line
2.34.1
PATCH v3 4/5 power/amd_uncore: uncore support for AMD EPYC processors
In reply to Sivaprasad TummalaThis patch introduces driver support for power management of uncore components in AMD EPYC processors.
v2:
- fixed typo in comments section.
- added fabric frequency get support for legacy platforms.
--- drivers/power/amd_uncore/amd_uncore.c | 329 ++++++++++++++++++++++++++ drivers/power/amd_uncore/amd_uncore.h | 226 ++++++++++++++++++ drivers/power/amd_uncore/meson.build | 20 ++ drivers/power/meson.build | 1 + 4 files changed, 576 insertions(+) create mode 100644 drivers/power/amd_uncore/amd_uncore.c create mode 100644 drivers/power/amd_uncore/amd_uncore.h create mode 100644 drivers/power/amd_uncore/meson.build
drivers/power/amd_uncore/amd_uncore.c new file +329 -0
@@ -0,0 +1,329 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2024 Advanced Micro Devices, Inc. +*/ + +#include <errno.h> +#include <dirent.h> +#include <fnmatch.h> + +#include <rte_memcpy.h> + +#include "amd_uncore.h" +#include "power_common.h" +#include "e_smi/e_smi.h" + +#define MAX_NUMA_DIE 8 + +struct __rte_cache_aligned uncore_power_info { +unsigned int die;/* Core die id */ +unsigned int pkg;/* Package id */ +uint32_t freqs[RTE_MAX_UNCORE_FREQS ];/* Frequency array */ +uint32_t nb_freqs;/* Number of available freqs */ +uint32_t curr_idx;/* Freq index in freqs array */ +uint32_t max_freq;/* System max uncore freq */ +uint32_t min_freq;/* System min uncore freq */ +}; + +static struct uncore_power_info uncore_info[RTE_MAX_NUMA_NODES ][MAX_NUMA_DIE ]; +static int esmi_initialized; +static unsigned int hsmp_proto_ver; + +static int +set_uncore_freq_internal (struct uncore_power_info *ui,uint32_t idx) +{ +int ret; + +if (idx >=RTE_MAX_UNCORE_FREQS || idx >= ui->nb_freqs) { +POWER_LOG (DEBUG ,"Invalid uncore frequency index %u, which " +"should be less than %u" , idx, ui->nb_freqs); +return -1 ; + } + + ret =esmi_apb_disable (ui->pkg, idx); +if (ret !=ESMI_SUCCESS ) { +POWER_LOG (ERR ,"DF P-state '%u' set failed for pkg %02u" , + idx, ui->pkg); +return -1 ; + } + +POWER_DEBUG_LOG ("DF P-state '%u' to be set for pkg %02u die %02u" , + idx, ui->pkg, ui->die); + +/* write the minimum value first if the target freq is less than current max */ + ui->curr_idx = idx; + +return 0 ; +} + +static int +power_init_for_setting_uncore_freq (struct uncore_power_info *ui) +{ +switch (hsmp_proto_ver) { +case HSMP_PROTO_VER5 : + ui->max_freq =1800000 ;/* Hz */ + ui->min_freq =1200000 ;/* Hz */ +break ; +case HSMP_PROTO_VER2 : +default : + ui->max_freq =1600000 ;/* Hz */ + ui->min_freq =1200000 ;/* Hz */ + } + +return 0 ; +} + +/* +* Get the available uncore frequencies of the specific die. +*/ +static int +power_get_available_uncore_freqs (struct uncore_power_info *ui) +{ + ui->nb_freqs =3 ; +if (ui->nb_freqs >=RTE_MAX_UNCORE_FREQS ) { +POWER_LOG (ERR ,"Too many available uncore frequencies: %d" , + ui->nb_freqs); +return -1 ; + } + +/* Generate the uncore freq bucket array. */ +switch (hsmp_proto_ver) { +case HSMP_PROTO_VER5 : + ui->freqs[0 ] =1800000 ; + ui->freqs[1 ] =1440000 ; + ui->freqs[2 ] =1200000 ; +break ; +case HSMP_PROTO_VER2 : +default : + ui->freqs[0 ] =1600000 ; + ui->freqs[1 ] =1333000 ; + ui->freqs[2 ] =1200000 ; + } + +POWER_DEBUG_LOG ("%d frequency(s) of pkg %02u die %02u are available" , + ui->num_uncore_freqs, ui->pkg, ui->die); + +return 0 ; +} + +static int +check_pkg_die_values (unsigned int pkg,unsigned int die) +{ +unsigned int max_pkgs, max_dies; + max_pkgs =power_amd_uncore_get_num_pkgs (); +if (max_pkgs ==0 ) +return -1 ; +if (pkg >= max_pkgs) { +POWER_LOG (DEBUG ,"Package number %02u can not exceed %u" , + pkg, max_pkgs); +return -1 ; + } + + max_dies =power_amd_uncore_get_num_dies (pkg); +if (max_dies ==0 ) +return -1 ; +if (die >= max_dies) { +POWER_LOG (DEBUG ,"Die number %02u can not exceed %u" , + die, max_dies); +return -1 ; + } + +return 0 ; +} + +static void +power_amd_uncore_esmi_init (void ) +{ +if (esmi_init () ==ESMI_SUCCESS ) { +if (esmi_hsmp_proto_ver_get (&hsmp_proto_ver) == +ESMI_SUCCESS ) + esmi_initialized =1 ; + } +} + +int +power_amd_uncore_init (unsigned int pkg,unsigned int die) +{ +struct uncore_power_info *ui; +int ret; + +if (!esmi_initialized) { + ret =esmi_init (); +if (ret !=ESMI_SUCCESS ) { +POWER_LOG (DEBUG ,"ESMI Not initialized, drivers not found" ); +return -1 ; + } + ret =esmi_hsmp_proto_ver_get (&hsmp_proto_ver); +if (ret !=ESMI_SUCCESS ) { +POWER_LOG (DEBUG ,"HSMP Proto Version Get failed with " +"error %s" ,esmi_get_err_msg (ret)); +esmi_exit (); +return -1 ; + } + esmi_initialized =1 ; + } + + ret =check_pkg_die_values (pkg, die); +if (ret <0 ) +return -1 ; + + ui = &uncore_info[pkg][die]; + ui->die = die; + ui->pkg = pkg; + +/* Init for setting uncore die frequency */ +if (power_init_for_setting_uncore_freq (ui) <0 ) { +POWER_LOG (DEBUG ,"Cannot init for setting uncore frequency for " +"pkg %02u die %02u" , pkg, die); +return -1 ; + } + +/* Get the available frequencies */ +if (power_get_available_uncore_freqs (ui) <0 ) { +POWER_LOG (DEBUG ,"Cannot get available uncore frequencies of " +"pkg %02u die %02u" , pkg, die); +return -1 ; + } + +return 0 ; +} + +int +power_amd_uncore_exit (unsigned int pkg,unsigned int die) +{ +struct uncore_power_info *ui; + +int ret =check_pkg_die_values (pkg, die); +if (ret <0 ) +return -1 ; + + ui = &uncore_info[pkg][die]; + ui->nb_freqs =0 ; + +if (esmi_initialized) { +esmi_exit (); + esmi_initialized =0 ; + } + +return 0 ; +} + +uint32_t +power_get_amd_uncore_freq (unsigned int pkg,unsigned int die) +{ +int ret =check_pkg_die_values (pkg, die); +if (ret <0 ) +return -1 ; + +return uncore_info[pkg][die].curr_idx; +} + +int +power_set_amd_uncore_freq (unsigned int pkg,unsigned int die,uint32_t index) +{ +int ret =check_pkg_die_values (pkg, die); +if (ret <0 ) +return -1 ; + +return set_uncore_freq_internal (&(uncore_info[pkg][die]), index); +} + +int +power_amd_uncore_freq_max (unsigned int pkg,unsigned int die) +{ +int ret =check_pkg_die_values (pkg, die); +if (ret <0 ) +return -1 ; + +return set_uncore_freq_internal (&(uncore_info[pkg][die]),0 ); +} + + +int +power_amd_uncore_freq_min (unsigned int pkg,unsigned int die) +{ +int ret =check_pkg_die_values (pkg, die); +if (ret <0 ) +return -1 ; + +struct uncore_power_info *ui = &uncore_info[pkg][die]; + +return set_uncore_freq_internal (&(uncore_info[pkg][die]), ui->nb_freqs -1 ); +} + +int +power_amd_uncore_freqs (unsigned int pkg,unsigned int die,uint32_t *freqs,uint32_t num) +{ +struct uncore_power_info *ui; + +int ret =check_pkg_die_values (pkg, die); +if (ret <0 ) +return -1 ; + +if (freqs ==NULL ) { +POWER_LOG (ERR ,"NULL buffer supplied" ); +return 0 ; + } + + ui = &uncore_info[pkg][die]; +if (num < ui->nb_freqs) { +POWER_LOG (ERR ,"Buffer size is not enough" ); +return 0 ; + } +rte_memcpy (freqs, ui->freqs, ui->nb_freqs *sizeof (uint32_t )); + +return ui->nb_freqs; +} + +int +power_amd_uncore_get_num_freqs (unsigned int pkg,unsigned int die) +{ +int ret =check_pkg_die_values (pkg, die); +if (ret <0 ) +return -1 ; + +return uncore_info[pkg][die].nb_freqs; +} + +unsigned int +power_amd_uncore_get_num_pkgs (void ) +{ +uint32_t num_pkgs =0 ; +int ret; + +if (esmi_initialized) { + ret =esmi_number_of_sockets_get (&num_pkgs); +if (ret !=ESMI_SUCCESS ) { +POWER_LOG (ERR ,"Failed to get number of sockets" ); + num_pkgs =0 ; + } + } +return num_pkgs; +} + +unsigned int +power_amd_uncore_get_num_dies (unsigned int pkg) +{ +if (pkg >=power_amd_uncore_get_num_pkgs ()) { +POWER_LOG (ERR ,"Invalid package ID" ); +return 0 ; + } + +return 1 ; +} + +static struct rte_power_uncore_ops amd_uncore_ops = { + .name ="amd-hsmp" , + .cb = power_amd_uncore_esmi_init, + .init = power_amd_uncore_init, + .exit = power_amd_uncore_exit, + .get_avail_freqs = power_amd_uncore_freqs, + .get_num_pkgs = power_amd_uncore_get_num_pkgs, + .get_num_dies = power_amd_uncore_get_num_dies, + .get_num_freqs = power_amd_uncore_get_num_freqs, + .get_freq = power_get_amd_uncore_freq, + .set_freq = power_set_amd_uncore_freq, + .freq_max = power_amd_uncore_freq_max, + .freq_min = power_amd_uncore_freq_min, +}; + +RTE_POWER_REGISTER_UNCORE_OPS (amd_uncore_ops);
drivers/power/amd_uncore/amd_uncore.h new file +226 -0
226 lines not on this page · raw message
drivers/power/amd_uncore/meson.build new file +20 -0
@@ -0,0 +1,20 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' + subdir_done() +endif + +ESMI_header = '#include<e_smi/e_smi.h>' +lib = cc.find_library('e_smi64', required: false) +if not lib.found() + build = false + reason = 'missing dependency, "libe_smi"' +else + ext_deps += lib +endif + +sources = files('amd_uncore.c') +deps += ['power']
drivers/power/meson.build +1 -0
@@ -7,6 +7,7 @@ drivers = [ 'cppc', 'kvm_vm', 'pstate', + 'amd_uncore', 'intel_uncore' ]
Signature · 1 line
2.34.1
PATCH v3 5/5 maintainers: update for drivers/power
In reply to Sivaprasad TummalaUpdate maintainers for drivers/power/*.
--- MAINTAINERS | 1 + 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
@@ -1737,6 +1737,7 @@ M: Anatoly Burakov <[email protected]> M: David Hunt <[email protected]> M: Sivaprasad Tummala <[email protected]> F: lib/power/ +F: drivers/power/* F: doc/guides/prog_guide/power_man.rst F: app/test/test_power* F: examples/l3fwd-power/
Signature · 1 line
2.34.1
v3 cover power: refactor power management library
In reply to Sivaprasad TummalaThis patchset refactors the power management library, addressing both core and uncore power management. The primary changes involve the creation of dedicated directories for each driver within 'drivers/power/core/*' and 'drivers/power/uncore/*'.
This refactor significantly improves code organization, enhances clarity, and boosts maintainability. It lays the foundation for more focused development on individual drivers and facilitates seamless integration of future enhancements, particularly the AMD uncore driver.
Furthermore, this effort aims to streamline code maintenance by consolidating common functions for cpufreq and cppc across various core drivers, thus reducing code duplication.
Sivaprasad Tummala (5):
power: refactor core power management library
power: refactor uncore power management library test/power: removed function pointer validations power/amd_uncore: uncore support for AMD EPYC processors
maintainers: update for drivers/power
MAINTAINERS | 1 +
app/test/test_power.c | 95 -----
app/test/test_power_cpufreq.c | 52 ---
app/test/test_power_kvm_vm.c | 36 --
drivers/meson.build | 1 +
.../power/acpi/acpi_cpufreq.c | 22 +-
.../power/acpi/acpi_cpufreq.h | 6 +-
drivers/power/acpi/meson.build | 10 +
.../power/amd_pstate/amd_pstate_cpufreq.c | 24 +-
.../power/amd_pstate/amd_pstate_cpufreq.h | 8 +-
drivers/power/amd_pstate/meson.build | 10 +
drivers/power/amd_uncore/amd_uncore.c | 329 ++++++++++++++++++
drivers/power/amd_uncore/amd_uncore.h | 226 ++++++++++++
drivers/power/amd_uncore/meson.build | 20 ++
.../power/cppc/cppc_cpufreq.c | 22 +-
.../power/cppc/cppc_cpufreq.h | 8 +-
drivers/power/cppc/meson.build | 10 +
.../power/intel_uncore/intel_uncore.c | 18 +-
.../power/intel_uncore/intel_uncore.h | 8 +-
drivers/power/intel_uncore/meson.build | 6 +
.../power/kvm_vm}/guest_channel.c | 0
.../power/kvm_vm}/guest_channel.h | 0
.../power/kvm_vm/kvm_vm.c | 22 +-
.../power/kvm_vm/kvm_vm.h | 6 +-
drivers/power/kvm_vm/meson.build | 16 +
drivers/power/meson.build | 14 +
drivers/power/pstate/meson.build | 10 +
.../power/pstate/pstate_cpufreq.c | 22 +-
.../power/pstate/pstate_cpufreq.h | 6 +-
examples/l3fwd-power/main.c | 12 +-
lib/power/meson.build | 9 +-
lib/power/power_common.c | 2 +-
lib/power/power_common.h | 16 +-
lib/power/rte_power.c | 286 +++++----------
lib/power/rte_power.h | 139 +++++---
lib/power/rte_power_cpufreq_api.h | 208 +++++++++++
lib/power/rte_power_uncore.c | 206 +++++------
lib/power/rte_power_uncore.h | 87 +++--
lib/power/rte_power_uncore_ops.h | 239 +++++++++++++
lib/power/version.map | 15 +
40 files changed, 1603 insertions(+), 624 deletions(-)
rename lib/power/power_acpi_cpufreq.c => drivers/power/acpi/acpi_cpufreq.c (95%)
rename lib/power/power_acpi_cpufreq.h => drivers/power/acpi/acpi_cpufreq.h (98%)
create mode 100644 drivers/power/acpi/meson.build
rename lib/power/power_amd_pstate_cpufreq.c => drivers/power/amd_pstate/amd_pstate_cpufreq.c (95%)
rename lib/power/power_amd_pstate_cpufreq.h => drivers/power/amd_pstate/amd_pstate_cpufreq.h (97%)
create mode 100644 drivers/power/amd_pstate/meson.build
create mode 100644 drivers/power/amd_uncore/amd_uncore.c
create mode 100644 drivers/power/amd_uncore/amd_uncore.h
create mode 100644 drivers/power/amd_uncore/meson.build
rename lib/power/power_cppc_cpufreq.c => drivers/power/cppc/cppc_cpufreq.c (95%)
rename lib/power/power_cppc_cpufreq.h => drivers/power/cppc/cppc_cpufreq.h (97%)
create mode 100644 drivers/power/cppc/meson.build
rename lib/power/power_intel_uncore.c => drivers/power/intel_uncore/intel_uncore.c (95%)
rename lib/power/power_intel_uncore.h => drivers/power/intel_uncore/intel_uncore.h (97%)
create mode 100644 drivers/power/intel_uncore/meson.build
rename {lib/power => drivers/power/kvm_vm}/guest_channel.c (100%)
rename {lib/power => drivers/power/kvm_vm}/guest_channel.h (100%)
rename lib/power/power_kvm_vm.c => drivers/power/kvm_vm/kvm_vm.c (82%)
rename lib/power/power_kvm_vm.h => drivers/power/kvm_vm/kvm_vm.h (98%)
create mode 100644 drivers/power/kvm_vm/meson.build
create mode 100644 drivers/power/meson.build
create mode 100644 drivers/power/pstate/meson.build
rename lib/power/power_pstate_cpufreq.c => drivers/power/pstate/pstate_cpufreq.c (96%)
rename lib/power/power_pstate_cpufreq.h => drivers/power/pstate/pstate_cpufreq.h (98%)
create mode 100644 lib/power/rte_power_cpufreq_api.h
create mode 100644 lib/power/rte_power_uncore_ops.hSignature · 1 line
2.34.1
Quoted 14 lines · On Tue, 8 Oct 2024 17:43:03 +0000 Sivaprasad Tummala…
This patchset refactors the power management library, addressing both core and uncore power management. The primary changes involve the creation of dedicated directories for each driver within '
drivers/power/core/*' and 'drivers/power/uncore/*'.This refactor significantly improves code organization, enhances clarity, and boosts maintainability. It lays the foundation for more focused development on individual drivers and facilitates seamless integration of future enhancements, particularly the AMD uncore driver.
Furthermore, this effort aims to streamline code maintenance by consolidating common functions for cpufreq and cppc across various core drivers, thus reducing code duplication.
Quoted 6 lines
Sivaprasad Tummala (5):
power: refactor core power management library
power: refactor uncore power management library test/power: removed function pointer validations power/amd_uncore: uncore support for AMD EPYC processors
maintainers: update fordrivers/power
Looks good but several build failures.
It looks like the new internal function to get power ops is not in version.map.
Also while looking, if I use IWYU it shows that errno.h and rte_errno.h are included but never used.
v4 cover power: refactor power management library
In reply to Sivaprasad TummalaThis patchset refactors the power management library, addressing both core and uncore power management. The primary changes involve the creation of dedicated directories for each driver within 'drivers/power/core/*' and 'drivers/power/uncore/*'.
This refactor significantly improves code organization, enhances clarity, and boosts maintainability. It lays the foundation for more focused development on individual drivers and facilitates seamless integration of future enhancements, particularly the AMD uncore driver.
Furthermore, this effort aims to streamline code maintenance by consolidating common functions for cpufreq and cppc across various core drivers, thus reducing code duplication.
Sivaprasad Tummala (5):
power: refactor core power management library
power: refactor uncore power management library test/power: removed function pointer validations power/amd_uncore: uncore support for AMD EPYC processors
maintainers: update for drivers/power
MAINTAINERS | 1 +
app/test/test_power.c | 95 -----
app/test/test_power_cpufreq.c | 52 ---
app/test/test_power_kvm_vm.c | 36 --
drivers/meson.build | 1 +
.../power/acpi/acpi_cpufreq.c | 22 +-
.../power/acpi/acpi_cpufreq.h | 6 +-
drivers/power/acpi/meson.build | 10 +
.../power/amd_pstate/amd_pstate_cpufreq.c | 24 +-
.../power/amd_pstate/amd_pstate_cpufreq.h | 8 +-
drivers/power/amd_pstate/meson.build | 10 +
drivers/power/amd_uncore/amd_uncore.c | 329 ++++++++++++++++++
drivers/power/amd_uncore/amd_uncore.h | 226 ++++++++++++
drivers/power/amd_uncore/meson.build | 20 ++
.../power/cppc/cppc_cpufreq.c | 22 +-
.../power/cppc/cppc_cpufreq.h | 8 +-
drivers/power/cppc/meson.build | 10 +
.../power/intel_uncore/intel_uncore.c | 18 +-
.../power/intel_uncore/intel_uncore.h | 8 +-
drivers/power/intel_uncore/meson.build | 6 +
.../power/kvm_vm}/guest_channel.c | 0
.../power/kvm_vm}/guest_channel.h | 0
.../power/kvm_vm/kvm_vm.c | 22 +-
.../power/kvm_vm/kvm_vm.h | 6 +-
drivers/power/kvm_vm/meson.build | 16 +
drivers/power/meson.build | 14 +
drivers/power/pstate/meson.build | 10 +
.../power/pstate/pstate_cpufreq.c | 22 +-
.../power/pstate/pstate_cpufreq.h | 6 +-
examples/l3fwd-power/main.c | 12 +-
lib/power/meson.build | 9 +-
lib/power/power_common.c | 2 +-
lib/power/power_common.h | 16 +-
lib/power/rte_power.c | 287 +++++----------
lib/power/rte_power.h | 139 +++++---
lib/power/rte_power_cpufreq_api.h | 208 +++++++++++
lib/power/rte_power_uncore.c | 207 +++++------
lib/power/rte_power_uncore.h | 87 +++--
lib/power/rte_power_uncore_ops.h | 239 +++++++++++++
lib/power/version.map | 15 +
40 files changed, 1605 insertions(+), 624 deletions(-)
rename lib/power/power_acpi_cpufreq.c => drivers/power/acpi/acpi_cpufreq.c (95%)
rename lib/power/power_acpi_cpufreq.h => drivers/power/acpi/acpi_cpufreq.h (98%)
create mode 100644 drivers/power/acpi/meson.build
rename lib/power/power_amd_pstate_cpufreq.c => drivers/power/amd_pstate/amd_pstate_cpufreq.c (95%)
rename lib/power/power_amd_pstate_cpufreq.h => drivers/power/amd_pstate/amd_pstate_cpufreq.h (97%)
create mode 100644 drivers/power/amd_pstate/meson.build
create mode 100644 drivers/power/amd_uncore/amd_uncore.c
create mode 100644 drivers/power/amd_uncore/amd_uncore.h
create mode 100644 drivers/power/amd_uncore/meson.build
rename lib/power/power_cppc_cpufreq.c => drivers/power/cppc/cppc_cpufreq.c (95%)
rename lib/power/power_cppc_cpufreq.h => drivers/power/cppc/cppc_cpufreq.h (97%)
create mode 100644 drivers/power/cppc/meson.build
rename lib/power/power_intel_uncore.c => drivers/power/intel_uncore/intel_uncore.c (95%)
rename lib/power/power_intel_uncore.h => drivers/power/intel_uncore/intel_uncore.h (97%)
create mode 100644 drivers/power/intel_uncore/meson.build
rename {lib/power => drivers/power/kvm_vm}/guest_channel.c (100%)
rename {lib/power => drivers/power/kvm_vm}/guest_channel.h (100%)
rename lib/power/power_kvm_vm.c => drivers/power/kvm_vm/kvm_vm.c (82%)
rename lib/power/power_kvm_vm.h => drivers/power/kvm_vm/kvm_vm.h (98%)
create mode 100644 drivers/power/kvm_vm/meson.build
create mode 100644 drivers/power/meson.build
create mode 100644 drivers/power/pstate/meson.build
rename lib/power/power_pstate_cpufreq.c => drivers/power/pstate/pstate_cpufreq.c (96%)
rename lib/power/power_pstate_cpufreq.h => drivers/power/pstate/pstate_cpufreq.h (98%)
create mode 100644 lib/power/rte_power_cpufreq_api.h
create mode 100644 lib/power/rte_power_uncore_ops.hSignature · 1 line
2.34.1
PATCH v4 1/5 power: refactor core power management library
This patch introduces a comprehensive refactor to the core power management library. The primary focus is on improving modularity and organization by relocating specific driver implementations from the 'lib/power' directory to dedicated directories within 'drivers/power/core/*'. The adjustment of meson.build files enables the selective activation of individual drivers.
These changes contribute to a significant enhancement in code organization, providing a clearer structure for driver implementations. The refactor aims to improve overall code clarity and boost maintainability. Additionally, it establishes a foundation for future development, allowing for more focused work on individual drivers and seamless integration of forthcoming enhancements.
v4:
- fixed build error with RTE_ASSERT
v3:
- renamed rte_power_core_ops.h as rte_power_cpufreq_api.h
- re-worked on auto detection logic
v2:
- added NULL check for global_core_ops in rte_power_get_core_ops
---
drivers/meson.build | 1 +
.../power/acpi/acpi_cpufreq.c | 22 +-
.../power/acpi/acpi_cpufreq.h | 6 +-
drivers/power/acpi/meson.build | 10 +
.../power/amd_pstate/amd_pstate_cpufreq.c | 24 +-
.../power/amd_pstate/amd_pstate_cpufreq.h | 8 +-
drivers/power/amd_pstate/meson.build | 10 +
.../power/cppc/cppc_cpufreq.c | 22 +-
.../power/cppc/cppc_cpufreq.h | 8 +-
drivers/power/cppc/meson.build | 10 +
.../power/kvm_vm}/guest_channel.c | 0
.../power/kvm_vm}/guest_channel.h | 0
.../power/kvm_vm/kvm_vm.c | 22 +-
.../power/kvm_vm/kvm_vm.h | 6 +-
drivers/power/kvm_vm/meson.build | 16 +
drivers/power/meson.build | 12 +
drivers/power/pstate/meson.build | 10 +
.../power/pstate/pstate_cpufreq.c | 22 +-
.../power/pstate/pstate_cpufreq.h | 6 +-
lib/power/meson.build | 7 +-
lib/power/power_common.c | 2 +-
lib/power/power_common.h | 16 +-
lib/power/rte_power.c | 287 ++++++------------
lib/power/rte_power.h | 139 ++++++---
lib/power/rte_power_cpufreq_api.h | 208 +++++++++++++
lib/power/version.map | 14 +
26 files changed, 619 insertions(+), 269 deletions(-)
rename lib/power/power_acpi_cpufreq.c => drivers/power/acpi/acpi_cpufreq.c (95%)
rename lib/power/power_acpi_cpufreq.h => drivers/power/acpi/acpi_cpufreq.h (98%)
create mode 100644 drivers/power/acpi/meson.build
rename lib/power/power_amd_pstate_cpufreq.c => drivers/power/amd_pstate/amd_pstate_cpufreq.c (95%)
rename lib/power/power_amd_pstate_cpufreq.h => drivers/power/amd_pstate/amd_pstate_cpufreq.h (97%)
create mode 100644 drivers/power/amd_pstate/meson.build
rename lib/power/power_cppc_cpufreq.c => drivers/power/cppc/cppc_cpufreq.c (95%)
rename lib/power/power_cppc_cpufreq.h => drivers/power/cppc/cppc_cpufreq.h (97%)
create mode 100644 drivers/power/cppc/meson.build
rename {lib/power => drivers/power/kvm_vm}/guest_channel.c (100%)
rename {lib/power => drivers/power/kvm_vm}/guest_channel.h (100%)
rename lib/power/power_kvm_vm.c => drivers/power/kvm_vm/kvm_vm.c (82%)
rename lib/power/power_kvm_vm.h => drivers/power/kvm_vm/kvm_vm.h (98%)
create mode 100644 drivers/power/kvm_vm/meson.build
create mode 100644 drivers/power/meson.build
create mode 100644 drivers/power/pstate/meson.build
rename lib/power/power_pstate_cpufreq.c => drivers/power/pstate/pstate_cpufreq.c (96%)
rename lib/power/power_pstate_cpufreq.h => drivers/power/pstate/pstate_cpufreq.h (98%)
create mode 100644 lib/power/rte_power_cpufreq_api.hdrivers/meson.build +1 -0
@@ -29,6 +29,7 @@ subdirs = [ 'event', # depends on common, bus, mempool and net. 'baseband', # depends on common and bus. 'gpu', # depends on common and bus. + 'power', # depends on common (in future). ] if meson.is_cross_build()
drivers/power/acpi/acpi_cpufreq.c renamed from lib/power/power_acpi_cpufreq.c +21 -1
@@ -10,7 +10,7 @@#include <rte_stdatomic.h> #include <rte_string_fns.h> -#include "power_acpi_cpufreq.h" +#include "acpi_cpufreq.h" #include "power_common.h" #define STR_SIZE 1024
@@ -583,3 +583,23 @@ int power_acpi_get_capabilities(unsigned int lcore_id,return 0 ; } + +static struct rte_power_core_ops acpi_ops = { + .name ="acpi" , + .init = power_acpi_cpufreq_init, + .exit = power_acpi_cpufreq_exit, + .check_env_support = power_acpi_cpufreq_check_supported, + .get_avail_freqs = power_acpi_cpufreq_freqs, + .get_freq = power_acpi_cpufreq_get_freq, + .set_freq = power_acpi_cpufreq_set_freq, + .freq_down = power_acpi_cpufreq_freq_down, + .freq_up = power_acpi_cpufreq_freq_up, + .freq_max = power_acpi_cpufreq_freq_max, + .freq_min = power_acpi_cpufreq_freq_min, + .turbo_status = power_acpi_turbo_status, + .enable_turbo = power_acpi_enable_turbo, + .disable_turbo = power_acpi_disable_turbo, + .get_caps = power_acpi_get_capabilities +}; + +RTE_POWER_REGISTER_OPS (acpi_ops);
drivers/power/acpi/acpi_cpufreq.h renamed from lib/power/power_acpi_cpufreq.h +3 -3
@@ -2,15 +2,15 @@* Copyright(c) 2010-2014 Intel Corporation */ -#ifndef _POWER_ACPI_CPUFREQ_H -#define _POWER_ACPI_CPUFREQ_H +#ifndef _ACPI_CPUFREQ_H +#define _ACPI_CPUFREQ_H/** * @file * RTE Power Management via userspace ACPI cpufreq */ -#include "rte_power.h" +#include "rte_power_cpufreq_api.h" /** * Check if ACPI power management is supported.
drivers/power/acpi/meson.build new file +10 -0
@@ -0,0 +1,10 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' +endif +sources = files('acpi_cpufreq.c') + +deps += ['power']
drivers/power/amd_pstate/amd_pstate_cpufreq.c renamed from lib/power/power_amd_pstate_cpufreq.c +22 -2
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2010-2021 Intel Corporation * Copyright(c) 2021 Arm Limited -* Copyright(c) 2023 Amd Limited +* Copyright(c) 2024 Advanced Micro Devices, Inc. */ #include <stdlib.h>
@@ -9,7 +9,7 @@#include <rte_memcpy.h> #include <rte_stdatomic.h> -#include "power_amd_pstate_cpufreq.h" +#include "amd_pstate_cpufreq.h" #include "power_common.h" /* macros used for rounding frequency to nearest 1000 */
@@ -706,3 +706,23 @@ power_amd_pstate_get_capabilities(unsigned int lcore_id,return 0 ; } + +static struct rte_power_core_ops amd_pstate_ops = { + .name ="amd-pstate" , + .init = power_amd_pstate_cpufreq_init, + .exit = power_amd_pstate_cpufreq_exit, + .check_env_support = power_amd_pstate_cpufreq_check_supported, + .get_avail_freqs = power_amd_pstate_cpufreq_freqs, + .get_freq = power_amd_pstate_cpufreq_get_freq, + .set_freq = power_amd_pstate_cpufreq_set_freq, + .freq_down = power_amd_pstate_cpufreq_freq_down, + .freq_up = power_amd_pstate_cpufreq_freq_up, + .freq_max = power_amd_pstate_cpufreq_freq_max, + .freq_min = power_amd_pstate_cpufreq_freq_min, + .turbo_status = power_amd_pstate_turbo_status, + .enable_turbo = power_amd_pstate_enable_turbo, + .disable_turbo = power_amd_pstate_disable_turbo, + .get_caps = power_amd_pstate_get_capabilities +}; + +RTE_POWER_REGISTER_OPS (amd_pstate_ops);
drivers/power/amd_pstate/amd_pstate_cpufreq.h renamed from lib/power/power_amd_pstate_cpufreq.h +4 -4
@@ -1,18 +1,18 @@/* SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2010-2021 Intel Corporation * Copyright(c) 2021 Arm Limited -* Copyright(c) 2023 Amd Limited +* Copyright(c) 2024 Advanced Micro Devices, Inc. */ -#ifndef _POWER_AMD_PSTATE_CPUFREQ_H -#define _POWER_AMD_PSTATE_CPUFREQ_H +#ifndef _AMD_PSTATE_CPUFREQ_H +#define _AMD_PSTATE_CPUFREQ_H/** * @file * RTE Power Management via userspace AMD pstate cpufreq */ -#include "rte_power.h" +#include "rte_power_cpufreq_api.h" /** * Check if amd p-state power management is supported.
drivers/power/amd_pstate/meson.build new file +10 -0
@@ -0,0 +1,10 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' +endif +sources = files('amd_pstate_cpufreq.c') + +deps += ['power']
drivers/power/cppc/cppc_cpufreq.c renamed from lib/power/power_cppc_cpufreq.c +21 -1
@@ -8,7 +8,7 @@#include <rte_memcpy.h> #include <rte_stdatomic.h> -#include "power_cppc_cpufreq.h" +#include "cppc_cpufreq.h" #include "power_common.h" /* macros used for rounding frequency to nearest 100000 */
@@ -691,3 +691,23 @@ power_cppc_get_capabilities(unsigned int lcore_id,return 0 ; } + +static struct rte_power_core_ops cppc_ops = { + .name ="cppc" , + .init = power_cppc_cpufreq_init, + .exit = power_cppc_cpufreq_exit, + .check_env_support = power_cppc_cpufreq_check_supported, + .get_avail_freqs = power_cppc_cpufreq_freqs, + .get_freq = power_cppc_cpufreq_get_freq, + .set_freq = power_cppc_cpufreq_set_freq, + .freq_down = power_cppc_cpufreq_freq_down, + .freq_up = power_cppc_cpufreq_freq_up, + .freq_max = power_cppc_cpufreq_freq_max, + .freq_min = power_cppc_cpufreq_freq_min, + .turbo_status = power_cppc_turbo_status, + .enable_turbo = power_cppc_enable_turbo, + .disable_turbo = power_cppc_disable_turbo, + .get_caps = power_cppc_get_capabilities +}; + +RTE_POWER_REGISTER_OPS (cppc_ops);
drivers/power/cppc/cppc_cpufreq.h renamed from lib/power/power_cppc_cpufreq.h +4 -4
@@ -3,15 +3,15 @@* Copyright(c) 2021 Arm Limited */ -#ifndef _POWER_CPPC_CPUFREQ_H -#define _POWER_CPPC_CPUFREQ_H +#ifndef _CPPC_CPUFREQ_H +#define _CPPC_CPUFREQ_H/** * @file * RTE Power Management via userspace CPPC cpufreq */ -#include "rte_power.h" +#include "rte_power_cpufreq_api.h" /** * Check if CPPC power management is supported.
@@ -215,4 +215,4 @@ int power_cppc_disable_turbo(unsigned int lcore_id);int power_cppc_get_capabilities (unsigned int lcore_id,struct rte_power_core_capabilities *caps); -#endif /* _POWER_CPPC_CPUFREQ_H */ +#endif /* _CPPC_CPUFREQ_H */
drivers/power/cppc/meson.build new file +10 -0
@@ -0,0 +1,10 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' +endif +sources = files('cppc_cpufreq.c') + +deps += ['power']
drivers/power/kvm_vm/guest_channel.c renamed from lib/power/guest_channel.c +0 -0
drivers/power/kvm_vm/guest_channel.h renamed from lib/power/guest_channel.h +0 -0
drivers/power/kvm_vm/kvm_vm.c renamed from lib/power/power_kvm_vm.c +21 -1
@@ -9,7 +9,7 @@#include "rte_power_guest_channel.h" #include "guest_channel.h" #include "power_common.h" -#include "power_kvm_vm.h" +#include "kvm_vm.h" #define FD_PATH "/dev/virtio-ports/virtio.serial.port.poweragent"
@@ -137,3 +137,23 @@ int power_kvm_vm_get_capabilities(__rte_unused unsigned int lcore_id,POWER_LOG (ERR ,"rte_power_get_capabilities is not implemented for Virtual Machine Power Management" );return -ENOTSUP ; } + +static struct rte_power_core_ops kvm_vm_ops = { + .name ="kvm-vm" , + .init = power_kvm_vm_init, + .exit = power_kvm_vm_exit, + .check_env_support = power_kvm_vm_check_supported, + .get_avail_freqs = power_kvm_vm_freqs, + .get_freq = power_kvm_vm_get_freq, + .set_freq = power_kvm_vm_set_freq, + .freq_down = power_kvm_vm_freq_down, + .freq_up = power_kvm_vm_freq_up, + .freq_max = power_kvm_vm_freq_max, + .freq_min = power_kvm_vm_freq_min, + .turbo_status = power_kvm_vm_turbo_status, + .enable_turbo = power_kvm_vm_enable_turbo, + .disable_turbo = power_kvm_vm_disable_turbo, + .get_caps = power_kvm_vm_get_capabilities +}; + +RTE_POWER_REGISTER_OPS (kvm_vm_ops);
drivers/power/kvm_vm/kvm_vm.h renamed from lib/power/power_kvm_vm.h +3 -3
@@ -2,15 +2,15 @@* Copyright(c) 2010-2014 Intel Corporation */ -#ifndef _POWER_KVM_VM_H -#define _POWER_KVM_VM_H +#ifndef _KVM_VM_H +#define _KVM_VM_H/** * @file * RTE Power Management KVM VM */ -#include "rte_power.h" +#include "rte_power_cpufreq_api.h" /** * Check if KVM power management is supported.
drivers/power/kvm_vm/meson.build new file +16 -0
@@ -0,0 +1,16 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(C) 2024 Advanced Micro Devices, Inc. +# + +if not is_linux + build = false + reason = 'only supported on Linux' + subdir_done() +endif + +sources = files( + 'guest_channel.c', + 'kvm_vm.c', +) + +deps += ['power']
drivers/power/meson.build new file +12 -0
@@ -0,0 +1,12 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +drivers = [ + 'acpi', + 'amd_pstate', + 'cppc', + 'kvm_vm', + 'pstate' +] + +std_deps = ['power']
drivers/power/pstate/meson.build new file +10 -0
@@ -0,0 +1,10 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' +endif +sources = files('pstate_cpufreq.c') + +deps += ['power']
drivers/power/pstate/pstate_cpufreq.c renamed from lib/power/power_pstate_cpufreq.c +21 -1
@@ -15,7 +15,7 @@#include <rte_stdatomic.h> #include "rte_power_pmd_mgmt.h" -#include "power_pstate_cpufreq.h" +#include "pstate_cpufreq.h" #include "power_common.h" /* macros used for rounding frequency to nearest 100000 */
@@ -894,3 +894,23 @@ int power_pstate_get_capabilities(unsigned int lcore_id,return 0 ; } + +static struct rte_power_core_ops pstate_ops = { + .name ="pstate" , + .init = power_pstate_cpufreq_init, + .exit = power_pstate_cpufreq_exit, + .check_env_support = power_pstate_cpufreq_check_supported, + .get_avail_freqs = power_pstate_cpufreq_freqs, + .get_freq = power_pstate_cpufreq_get_freq, + .set_freq = power_pstate_cpufreq_set_freq, + .freq_down = power_pstate_cpufreq_freq_down, + .freq_up = power_pstate_cpufreq_freq_up, + .freq_max = power_pstate_cpufreq_freq_max, + .freq_min = power_pstate_cpufreq_freq_min, + .turbo_status = power_pstate_turbo_status, + .enable_turbo = power_pstate_enable_turbo, + .disable_turbo = power_pstate_disable_turbo, + .get_caps = power_pstate_get_capabilities +}; + +RTE_POWER_REGISTER_OPS (pstate_ops);
drivers/power/pstate/pstate_cpufreq.h renamed from lib/power/power_pstate_cpufreq.h +3 -3
@@ -2,15 +2,15 @@* Copyright(c) 2018 Intel Corporation */ -#ifndef _POWER_PSTATE_CPUFREQ_H -#define _POWER_PSTATE_CPUFREQ_H +#ifndef _PSTATE_CPUFREQ_H +#define _PSTATE_CPUFREQ_H/** * @file * RTE Power Management via Intel Pstate driver */ -#include "rte_power.h" +#include "rte_power_cpufreq_api.h" /** * Check if pstate power management is supported.
lib/power/meson.build +1 -6
@@ -12,20 +12,15 @@ if not is_linux reason = 'only supported on Linux' endif sources = files( - 'guest_channel.c', - 'power_acpi_cpufreq.c', - 'power_amd_pstate_cpufreq.c', 'power_common.c', - 'power_cppc_cpufreq.c', - 'power_kvm_vm.c', 'power_intel_uncore.c', - 'power_pstate_cpufreq.c', 'rte_power.c', 'rte_power_uncore.c', 'rte_power_pmd_mgmt.c', ) headers = files( 'rte_power.h', + 'rte_power_cpufreq_api.h', 'rte_power_guest_channel.h', 'rte_power_pmd_mgmt.h', 'rte_power_uncore.h',
lib/power/power_common.c +1 -1
@@ -12,7 +12,7 @@#include "power_common.h" -RTE_LOG_REGISTER_DEFAULT (power_logtype,INFO ); +RTE_LOG_REGISTER_DEFAULT (rte_power_logtype,INFO );#define POWER_SYSFILE_SCALING_DRIVER \ "/sys/devices/system/cpu/cpu%u/cpufreq/scaling_driver"
lib/power/power_common.h +14 -2
@@ -6,12 +6,13 @@#define _POWER_COMMON_H_#include <rte_common.h> +#include <rte_compat.h> #include <rte_log.h> #define RTE_POWER_INVALID_FREQ_INDEX (~0) -extern int power_logtype; -#define RTE_LOGTYPE_POWER power_logtype +extern int rte_power_logtype; +#define RTE_LOGTYPE_POWER rte_power_logtype#define POWER_LOG (level, ...) \ RTE_LOG_LINE(level, POWER, "" __VA_ARGS__)
@@ -23,13 +24,24 @@ extern int power_logtype;#endif /* check if scaling driver matches one we want */ +__rte_internal int cpufreq_check_scaling_driver(const char *driver); + +__rte_internal int power_set_governor(unsigned int lcore_id, const char *new_governor,char *orig_governor,size_t orig_governor_len); + +__rte_internal int open_core_sysfs_file(FILE **f, const char *mode, const char *format, ...) __rte_format_printf(3, 4); + +__rte_internal int read_core_sysfs_u32(FILE *f, uint32_t *val); + +__rte_internal int read_core_sysfs_s(FILE *f, char *buf, unsigned int len); + +__rte_internal int write_core_sysfs_s(FILE *f, const char *str);#endif /* _POWER_COMMON_H_ */
lib/power/rte_power.c +96 -191
345 lines not on this page · raw message
lib/power/rte_power.h +93 -46
229 lines not on this page · raw message
lib/power/rte_power_cpufreq_api.h new file +208 -0
208 lines not on this page · raw message
lib/power/version.map +14 -0
@@ -51,4 +51,18 @@ EXPERIMENTAL { rte_power_set_uncore_env; rte_power_uncore_freqs; rte_power_unset_uncore_env; + # added in 24.11 + rte_power_logtype; +}; + +INTERNAL { + global: + + rte_power_register_ops; + cpufreq_check_scaling_driver; + power_set_governor; + open_core_sysfs_file; + read_core_sysfs_u32; + read_core_sysfs_s; + write_core_sysfs_s; };
Signature · 1 line
2.34.1
PATCH v4 2/5 power: refactor uncore power management library
In reply to Sivaprasad TummalaThis patch refactors the power management library, addressing uncore power management. The primary changes involve the creation of dedicated directories for each driver within 'drivers/power/uncore/*'. The adjustment of meson.build files enables the selective activation of individual drivers.
This refactor significantly improves code organization, enhances clarity and boosts maintainability. It lays the foundation for more focused development on individual drivers and facilitates seamless integration of future enhancements, particularly the AMD uncore driver.
v4:
- fixed build error with RTE_ASSERT
v3:
- fixed typo in header file inclusion
--- .../power/intel_uncore/intel_uncore.c | 18 +- .../power/intel_uncore/intel_uncore.h | 8 +- drivers/power/intel_uncore/meson.build | 6 + drivers/power/meson.build | 3 +- lib/power/meson.build | 2 +- lib/power/rte_power_uncore.c | 207 ++++++--------- lib/power/rte_power_uncore.h | 87 ++++--- lib/power/rte_power_uncore_ops.h | 239 ++++++++++++++++++ lib/power/version.map | 1 + 9 files changed, 406 insertions(+), 165 deletions(-) rename lib/power/power_intel_uncore.c => drivers/power/intel_uncore/intel_uncore.c (95%) rename lib/power/power_intel_uncore.h => drivers/power/intel_uncore/intel_uncore.h (97%) create mode 100644 drivers/power/intel_uncore/meson.build create mode 100644 lib/power/rte_power_uncore_ops.h
drivers/power/intel_uncore/intel_uncore.c renamed from lib/power/power_intel_uncore.c +17 -1
@@ -8,7 +8,7 @@#include <rte_memcpy.h> -#include "power_intel_uncore.h" +#include "intel_uncore.h" #include "power_common.h" #define MAX_NUMA_DIE 8
@@ -475,3 +475,19 @@ power_intel_uncore_get_num_dies(unsigned int pkg)return count; } + +static struct rte_power_uncore_ops intel_uncore_ops = { + .name ="intel-uncore" , + .init = power_intel_uncore_init, + .exit = power_intel_uncore_exit, + .get_avail_freqs = power_intel_uncore_freqs, + .get_num_pkgs = power_intel_uncore_get_num_pkgs, + .get_num_dies = power_intel_uncore_get_num_dies, + .get_num_freqs = power_intel_uncore_get_num_freqs, + .get_freq = power_get_intel_uncore_freq, + .set_freq = power_set_intel_uncore_freq, + .freq_max = power_intel_uncore_freq_max, + .freq_min = power_intel_uncore_freq_min, +}; + +RTE_POWER_REGISTER_UNCORE_OPS (intel_uncore_ops);
drivers/power/intel_uncore/intel_uncore.h renamed from lib/power/power_intel_uncore.h +4 -4
@@ -2,8 +2,8 @@* Copyright(c) 2022 Intel Corporation */ -#ifndef POWER_INTEL_UNCORE_H -#define POWER_INTEL_UNCORE_H +#ifndef INTEL_UNCORE_H +#define INTEL_UNCORE_H /** * @file
@@ -11,7 +11,7 @@*/ #include "rte_power.h" -#include "rte_power_uncore.h" +#include "rte_power_uncore_ops.h" #ifdef __cplusplusextern "C" {
@@ -223,4 +223,4 @@ power_intel_uncore_get_num_dies(unsigned int pkg); }#endif -#endif /* POWER_INTEL_UNCORE_H */ +#endif /* INTEL_UNCORE_H */
drivers/power/intel_uncore/meson.build new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2017 Intel Corporation +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +sources = files('intel_uncore.c') +deps += ['power']
drivers/power/meson.build +2 -1
@@ -6,7 +6,8 @@ drivers = [ 'amd_pstate', 'cppc', 'kvm_vm', - 'pstate' + 'pstate', + 'intel_uncore' ] std_deps = ['power']
lib/power/meson.build +1 -1
@@ -13,7 +13,6 @@ if not is_linux endif sources = files( 'power_common.c', - 'power_intel_uncore.c', 'rte_power.c', 'rte_power_uncore.c', 'rte_power_pmd_mgmt.c',
@@ -24,6 +23,7 @@ headers = files( 'rte_power_guest_channel.h', 'rte_power_pmd_mgmt.h', 'rte_power_uncore.h', + 'rte_power_uncore_ops.h', ) if cc.has_argument('-Wno-cast-qual') cflags += '-Wno-cast-qual'
lib/power/rte_power_uncore.c +83 -124
269 lines not on this page · raw message
lib/power/rte_power_uncore.h +53 -34
153 lines not on this page · raw message
lib/power/rte_power_uncore_ops.h new file +239 -0
239 lines not on this page · raw message
lib/power/version.map +1 -0
@@ -59,6 +59,7 @@ INTERNAL { global: rte_power_register_ops; + rte_power_register_uncore_ops; cpufreq_check_scaling_driver; power_set_governor; open_core_sysfs_file;
Signature · 1 line
2.34.1
PATCH v4 3/5 test/power: removed function pointer validations
In reply to Sivaprasad TummalaAfter refactoring the power library, power management operations are now consistently supported regardless of the operating environment, making function pointer checks unnecessary and thus removed from applications.
v2:
- removed function pointer validation in l3fwd-power app.
--- app/test/test_power.c | 95 ----------------------------------- app/test/test_power_cpufreq.c | 52 ------------------- app/test/test_power_kvm_vm.c | 36 ------------- examples/l3fwd-power/main.c | 12 ++--- 4 files changed, 4 insertions(+), 191 deletions(-)
app/test/test_power.c +0 -95
@@ -24,86 +24,6 @@ test_power(void)#include <rte_power.h> -static int -check_function_ptrs (void ) -{ -enum power_management_env env =rte_power_get_env (); - -const bool not_null_expected = !(env ==PM_ENV_NOT_SET ); - -const char *inject_not_string1 = not_null_expected ?" not" :"" ; -const char *inject_not_string2 = not_null_expected ?"" :" not" ; - -if ((rte_power_freqs ==NULL ) == not_null_expected) { -printf ("rte_power_freqs should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_get_freq ==NULL ) == not_null_expected) { -printf ("rte_power_get_freq should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_set_freq ==NULL ) == not_null_expected) { -printf ("rte_power_set_freq should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_freq_up ==NULL ) == not_null_expected) { -printf ("rte_power_freq_up should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_freq_down ==NULL ) == not_null_expected) { -printf ("rte_power_freq_down should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_freq_max ==NULL ) == not_null_expected) { -printf ("rte_power_freq_max should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_freq_min ==NULL ) == not_null_expected) { -printf ("rte_power_freq_min should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_turbo_status ==NULL ) == not_null_expected) { -printf ("rte_power_turbo_status should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_freq_enable_turbo ==NULL ) == not_null_expected) { -printf ("rte_power_freq_enable_turbo should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_freq_disable_turbo ==NULL ) == not_null_expected) { -printf ("rte_power_freq_disable_turbo should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_get_capabilities ==NULL ) == not_null_expected) { -printf ("rte_power_get_capabilities should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } - -return 0 ; -} -static int test_power (void ) {
@@ -124,10 +44,6 @@ test_power(void)return -1 ; } -/* Verify that function pointers are NULL */ -if (check_function_ptrs () <0 ) - goto fail_all; -rte_power_unset_env ();/* Perform tests for valid environments.*/
@@ -154,22 +70,11 @@ test_power(void) return -1; } -/* Verify that function pointers are NOT NULL */ -if (check_function_ptrs () <0 ) - goto fail_all; -rte_power_unset_env (); -/* Verify that function pointers are NULL */ -if (check_function_ptrs () <0 ) - goto fail_all; - }return 0 ; -fail_all: -rte_power_unset_env (); -return -1 ; }#endif
app/test/test_power_cpufreq.c +0 -52
58 lines not on this page · raw message
app/test/test_power_kvm_vm.c +0 -36
@@ -47,42 +47,6 @@ test_power_kvm_vm(void)return -1 ; } -/* verify that function pointers are not NULL */ -if (rte_power_freqs ==NULL ) { -printf ("rte_power_freqs should not be NULL, environment has not been " -"initialised\n" ); -return -1 ; - } -if (rte_power_get_freq ==NULL ) { -printf ("rte_power_get_freq should not be NULL, environment has not " -"been initialised\n" ); -return -1 ; - } -if (rte_power_set_freq ==NULL ) { -printf ("rte_power_set_freq should not be NULL, environment has not " -"been initialised\n" ); -return -1 ; - } -if (rte_power_freq_up ==NULL ) { -printf ("rte_power_freq_up should not be NULL, environment has not " -"been initialised\n" ); -return -1 ; - } -if (rte_power_freq_down ==NULL ) { -printf ("rte_power_freq_down should not be NULL, environment has not " -"been initialised\n" ); -return -1 ; - } -if (rte_power_freq_max ==NULL ) { -printf ("rte_power_freq_max should not be NULL, environment has not " -"been initialised\n" ); -return -1 ; - } -if (rte_power_freq_min ==NULL ) { -printf ("rte_power_freq_min should not be NULL, environment has not " -"been initialised\n" ); -return -1 ; - }/* Test initialisation of an out of bounds lcore */ ret =rte_power_init (TEST_POWER_VM_LCORE_OUT_OF_BOUNDS );if (ret !=-1 ) {
examples/l3fwd-power/main.c +4 -8
@@ -440,8 +440,7 @@ power_timer_cb(__rte_unused struct rte_timer *tim,* check whether need to scale down frequency a step if it sleep a lot. */ if (sleep_time_ratio >=SCALING_DOWN_TIME_RATIO_THRESHOLD ) { -if (rte_power_freq_down) -rte_power_freq_down (lcore_id); +rte_power_freq_down (lcore_id); }else if ( (unsigned )(stats[lcore_id].nb_rx_processed / stats[lcore_id].nb_iteration_looped) <MAX_PKT_BURST ) {
@@ -449,8 +448,7 @@ power_timer_cb(__rte_unused struct rte_timer *tim,* scale down a step if average packet per iteration less * than expectation. */ -if (rte_power_freq_down) -rte_power_freq_down (lcore_id); +rte_power_freq_down (lcore_id); }/**
@@ -1344,11 +1342,9 @@ main_legacy_loop(__rte_unused void *dummy) }if (lcore_scaleup_hint ==FREQ_HIGHEST ) { -if (rte_power_freq_max) -rte_power_freq_max (lcore_id); +rte_power_freq_max (lcore_id); }else if (lcore_scaleup_hint ==FREQ_HIGHER ) { -if (rte_power_freq_up) -rte_power_freq_up (lcore_id); +rte_power_freq_up (lcore_id); } }else {/**
Signature · 1 line
2.34.1
PATCH v4 4/5 power/amd_uncore: uncore support for AMD EPYC processors
In reply to Sivaprasad TummalaThis patch introduces driver support for power management of uncore components in AMD EPYC processors.
v2:
- fixed typo in comments section.
- added fabric frequency get support for legacy platforms.
--- drivers/power/amd_uncore/amd_uncore.c | 329 ++++++++++++++++++++++++++ drivers/power/amd_uncore/amd_uncore.h | 226 ++++++++++++++++++ drivers/power/amd_uncore/meson.build | 20 ++ drivers/power/meson.build | 1 + 4 files changed, 576 insertions(+) create mode 100644 drivers/power/amd_uncore/amd_uncore.c create mode 100644 drivers/power/amd_uncore/amd_uncore.h create mode 100644 drivers/power/amd_uncore/meson.build
drivers/power/amd_uncore/amd_uncore.c new file +329 -0
@@ -0,0 +1,329 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2024 Advanced Micro Devices, Inc. +*/ + +#include <errno.h> +#include <dirent.h> +#include <fnmatch.h> + +#include <rte_memcpy.h> + +#include "amd_uncore.h" +#include "power_common.h" +#include "e_smi/e_smi.h" + +#define MAX_NUMA_DIE 8 + +struct __rte_cache_aligned uncore_power_info { +unsigned int die;/* Core die id */ +unsigned int pkg;/* Package id */ +uint32_t freqs[RTE_MAX_UNCORE_FREQS ];/* Frequency array */ +uint32_t nb_freqs;/* Number of available freqs */ +uint32_t curr_idx;/* Freq index in freqs array */ +uint32_t max_freq;/* System max uncore freq */ +uint32_t min_freq;/* System min uncore freq */ +}; + +static struct uncore_power_info uncore_info[RTE_MAX_NUMA_NODES ][MAX_NUMA_DIE ]; +static int esmi_initialized; +static unsigned int hsmp_proto_ver; + +static int +set_uncore_freq_internal (struct uncore_power_info *ui,uint32_t idx) +{ +int ret; + +if (idx >=RTE_MAX_UNCORE_FREQS || idx >= ui->nb_freqs) { +POWER_LOG (DEBUG ,"Invalid uncore frequency index %u, which " +"should be less than %u" , idx, ui->nb_freqs); +return -1 ; + } + + ret =esmi_apb_disable (ui->pkg, idx); +if (ret !=ESMI_SUCCESS ) { +POWER_LOG (ERR ,"DF P-state '%u' set failed for pkg %02u" , + idx, ui->pkg); +return -1 ; + } + +POWER_DEBUG_LOG ("DF P-state '%u' to be set for pkg %02u die %02u" , + idx, ui->pkg, ui->die); + +/* write the minimum value first if the target freq is less than current max */ + ui->curr_idx = idx; + +return 0 ; +} + +static int +power_init_for_setting_uncore_freq (struct uncore_power_info *ui) +{ +switch (hsmp_proto_ver) { +case HSMP_PROTO_VER5 : + ui->max_freq =1800000 ;/* Hz */ + ui->min_freq =1200000 ;/* Hz */ +break ; +case HSMP_PROTO_VER2 : +default : + ui->max_freq =1600000 ;/* Hz */ + ui->min_freq =1200000 ;/* Hz */ + } + +return 0 ; +} + +/* +* Get the available uncore frequencies of the specific die. +*/ +static int +power_get_available_uncore_freqs (struct uncore_power_info *ui) +{ + ui->nb_freqs =3 ; +if (ui->nb_freqs >=RTE_MAX_UNCORE_FREQS ) { +POWER_LOG (ERR ,"Too many available uncore frequencies: %d" , + ui->nb_freqs); +return -1 ; + } + +/* Generate the uncore freq bucket array. */ +switch (hsmp_proto_ver) { +case HSMP_PROTO_VER5 : + ui->freqs[0 ] =1800000 ; + ui->freqs[1 ] =1440000 ; + ui->freqs[2 ] =1200000 ; +break ; +case HSMP_PROTO_VER2 : +default : + ui->freqs[0 ] =1600000 ; + ui->freqs[1 ] =1333000 ; + ui->freqs[2 ] =1200000 ; + } + +POWER_DEBUG_LOG ("%d frequency(s) of pkg %02u die %02u are available" , + ui->num_uncore_freqs, ui->pkg, ui->die); + +return 0 ; +} + +static int +check_pkg_die_values (unsigned int pkg,unsigned int die) +{ +unsigned int max_pkgs, max_dies; + max_pkgs =power_amd_uncore_get_num_pkgs (); +if (max_pkgs ==0 ) +return -1 ; +if (pkg >= max_pkgs) { +POWER_LOG (DEBUG ,"Package number %02u can not exceed %u" , + pkg, max_pkgs); +return -1 ; + } + + max_dies =power_amd_uncore_get_num_dies (pkg); +if (max_dies ==0 ) +return -1 ; +if (die >= max_dies) { +POWER_LOG (DEBUG ,"Die number %02u can not exceed %u" , + die, max_dies); +return -1 ; + } + +return 0 ; +} + +static void +power_amd_uncore_esmi_init (void ) +{ +if (esmi_init () ==ESMI_SUCCESS ) { +if (esmi_hsmp_proto_ver_get (&hsmp_proto_ver) == +ESMI_SUCCESS ) + esmi_initialized =1 ; + } +} + +int +power_amd_uncore_init (unsigned int pkg,unsigned int die) +{ +struct uncore_power_info *ui; +int ret; + +if (!esmi_initialized) { + ret =esmi_init (); +if (ret !=ESMI_SUCCESS ) { +POWER_LOG (DEBUG ,"ESMI Not initialized, drivers not found" ); +return -1 ; + } + ret =esmi_hsmp_proto_ver_get (&hsmp_proto_ver); +if (ret !=ESMI_SUCCESS ) { +POWER_LOG (DEBUG ,"HSMP Proto Version Get failed with " +"error %s" ,esmi_get_err_msg (ret)); +esmi_exit (); +return -1 ; + } + esmi_initialized =1 ; + } + + ret =check_pkg_die_values (pkg, die); +if (ret <0 ) +return -1 ; + + ui = &uncore_info[pkg][die]; + ui->die = die; + ui->pkg = pkg; + +/* Init for setting uncore die frequency */ +if (power_init_for_setting_uncore_freq (ui) <0 ) { +POWER_LOG (DEBUG ,"Cannot init for setting uncore frequency for " +"pkg %02u die %02u" , pkg, die); +return -1 ; + } + +/* Get the available frequencies */ +if (power_get_available_uncore_freqs (ui) <0 ) { +POWER_LOG (DEBUG ,"Cannot get available uncore frequencies of " +"pkg %02u die %02u" , pkg, die); +return -1 ; + } + +return 0 ; +} + +int +power_amd_uncore_exit (unsigned int pkg,unsigned int die) +{ +struct uncore_power_info *ui; + +int ret =check_pkg_die_values (pkg, die); +if (ret <0 ) +return -1 ; + + ui = &uncore_info[pkg][die]; + ui->nb_freqs =0 ; + +if (esmi_initialized) { +esmi_exit (); + esmi_initialized =0 ; + } + +return 0 ; +} + +uint32_t +power_get_amd_uncore_freq (unsigned int pkg,unsigned int die) +{ +int ret =check_pkg_die_values (pkg, die); +if (ret <0 ) +return -1 ; + +return uncore_info[pkg][die].curr_idx; +} + +int +power_set_amd_uncore_freq (unsigned int pkg,unsigned int die,uint32_t index) +{ +int ret =check_pkg_die_values (pkg, die); +if (ret <0 ) +return -1 ; + +return set_uncore_freq_internal (&(uncore_info[pkg][die]), index); +} + +int +power_amd_uncore_freq_max (unsigned int pkg,unsigned int die) +{ +int ret =check_pkg_die_values (pkg, die); +if (ret <0 ) +return -1 ; + +return set_uncore_freq_internal (&(uncore_info[pkg][die]),0 ); +} + + +int +power_amd_uncore_freq_min (unsigned int pkg,unsigned int die) +{ +int ret =check_pkg_die_values (pkg, die); +if (ret <0 ) +return -1 ; + +struct uncore_power_info *ui = &uncore_info[pkg][die]; + +return set_uncore_freq_internal (&(uncore_info[pkg][die]), ui->nb_freqs -1 ); +} + +int +power_amd_uncore_freqs (unsigned int pkg,unsigned int die,uint32_t *freqs,uint32_t num) +{ +struct uncore_power_info *ui; + +int ret =check_pkg_die_values (pkg, die); +if (ret <0 ) +return -1 ; + +if (freqs ==NULL ) { +POWER_LOG (ERR ,"NULL buffer supplied" ); +return 0 ; + } + + ui = &uncore_info[pkg][die]; +if (num < ui->nb_freqs) { +POWER_LOG (ERR ,"Buffer size is not enough" ); +return 0 ; + } +rte_memcpy (freqs, ui->freqs, ui->nb_freqs *sizeof (uint32_t )); + +return ui->nb_freqs; +} + +int +power_amd_uncore_get_num_freqs (unsigned int pkg,unsigned int die) +{ +int ret =check_pkg_die_values (pkg, die); +if (ret <0 ) +return -1 ; + +return uncore_info[pkg][die].nb_freqs; +} + +unsigned int +power_amd_uncore_get_num_pkgs (void ) +{ +uint32_t num_pkgs =0 ; +int ret; + +if (esmi_initialized) { + ret =esmi_number_of_sockets_get (&num_pkgs); +if (ret !=ESMI_SUCCESS ) { +POWER_LOG (ERR ,"Failed to get number of sockets" ); + num_pkgs =0 ; + } + } +return num_pkgs; +} + +unsigned int +power_amd_uncore_get_num_dies (unsigned int pkg) +{ +if (pkg >=power_amd_uncore_get_num_pkgs ()) { +POWER_LOG (ERR ,"Invalid package ID" ); +return 0 ; + } + +return 1 ; +} + +static struct rte_power_uncore_ops amd_uncore_ops = { + .name ="amd-hsmp" , + .cb = power_amd_uncore_esmi_init, + .init = power_amd_uncore_init, + .exit = power_amd_uncore_exit, + .get_avail_freqs = power_amd_uncore_freqs, + .get_num_pkgs = power_amd_uncore_get_num_pkgs, + .get_num_dies = power_amd_uncore_get_num_dies, + .get_num_freqs = power_amd_uncore_get_num_freqs, + .get_freq = power_get_amd_uncore_freq, + .set_freq = power_set_amd_uncore_freq, + .freq_max = power_amd_uncore_freq_max, + .freq_min = power_amd_uncore_freq_min, +}; + +RTE_POWER_REGISTER_UNCORE_OPS (amd_uncore_ops);
drivers/power/amd_uncore/amd_uncore.h new file +226 -0
226 lines not on this page · raw message
drivers/power/amd_uncore/meson.build new file +20 -0
@@ -0,0 +1,20 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' + subdir_done() +endif + +ESMI_header = '#include<e_smi/e_smi.h>' +lib = cc.find_library('e_smi64', required: false) +if not lib.found() + build = false + reason = 'missing dependency, "libe_smi"' +else + ext_deps += lib +endif + +sources = files('amd_uncore.c') +deps += ['power']
drivers/power/meson.build +1 -0
@@ -7,6 +7,7 @@ drivers = [ 'cppc', 'kvm_vm', 'pstate', + 'amd_uncore', 'intel_uncore' ]
Signature · 1 line
2.34.1
PATCH v4 5/5 maintainers: update for drivers/power
In reply to Sivaprasad TummalaUpdate maintainers for drivers/power/*.
--- MAINTAINERS | 1 + 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
@@ -1744,6 +1744,7 @@ M: Anatoly Burakov <[email protected]> M: David Hunt <[email protected]> M: Sivaprasad Tummala <[email protected]> F: lib/power/ +F: drivers/power/* F: doc/guides/prog_guide/power_man.rst F: app/test/test_power* F: examples/l3fwd-power/
Signature · 1 line
2.34.1
v4 cover power: refactor power management library
In reply to Sivaprasad TummalaThis patchset refactors the power management library, addressing both core and uncore power management. The primary changes involve the creation of dedicated directories for each driver within 'drivers/power/core/*' and 'drivers/power/uncore/*'.
This refactor significantly improves code organization, enhances clarity, and boosts maintainability. It lays the foundation for more focused development on individual drivers and facilitates seamless integration of future enhancements, particularly the AMD uncore driver.
Furthermore, this effort aims to streamline code maintenance by consolidating common functions for cpufreq and cppc across various core drivers, thus reducing code duplication.
Sivaprasad Tummala (5):
power: refactor core power management library
power: refactor uncore power management library test/power: removed function pointer validations power/amd_uncore: uncore support for AMD EPYC processors
maintainers: update for drivers/power
MAINTAINERS | 1 +
app/test/test_power.c | 95 -----
app/test/test_power_cpufreq.c | 52 ---
app/test/test_power_kvm_vm.c | 36 --
drivers/meson.build | 1 +
.../power/acpi/acpi_cpufreq.c | 22 +-
.../power/acpi/acpi_cpufreq.h | 6 +-
drivers/power/acpi/meson.build | 10 +
.../power/amd_pstate/amd_pstate_cpufreq.c | 24 +-
.../power/amd_pstate/amd_pstate_cpufreq.h | 8 +-
drivers/power/amd_pstate/meson.build | 10 +
drivers/power/amd_uncore/amd_uncore.c | 329 ++++++++++++++++++
drivers/power/amd_uncore/amd_uncore.h | 226 ++++++++++++
drivers/power/amd_uncore/meson.build | 20 ++
.../power/cppc/cppc_cpufreq.c | 22 +-
.../power/cppc/cppc_cpufreq.h | 8 +-
drivers/power/cppc/meson.build | 10 +
.../power/intel_uncore/intel_uncore.c | 18 +-
.../power/intel_uncore/intel_uncore.h | 8 +-
drivers/power/intel_uncore/meson.build | 6 +
.../power/kvm_vm}/guest_channel.c | 0
.../power/kvm_vm}/guest_channel.h | 0
.../power/kvm_vm/kvm_vm.c | 22 +-
.../power/kvm_vm/kvm_vm.h | 6 +-
drivers/power/kvm_vm/meson.build | 16 +
drivers/power/meson.build | 14 +
drivers/power/pstate/meson.build | 10 +
.../power/pstate/pstate_cpufreq.c | 22 +-
.../power/pstate/pstate_cpufreq.h | 6 +-
examples/l3fwd-power/main.c | 12 +-
lib/power/meson.build | 9 +-
lib/power/power_common.c | 2 +-
lib/power/power_common.h | 16 +-
lib/power/rte_power.c | 287 +++++----------
lib/power/rte_power.h | 139 +++++---
lib/power/rte_power_cpufreq_api.h | 208 +++++++++++
lib/power/rte_power_uncore.c | 207 +++++------
lib/power/rte_power_uncore.h | 87 +++--
lib/power/rte_power_uncore_ops.h | 239 +++++++++++++
lib/power/version.map | 15 +
40 files changed, 1605 insertions(+), 624 deletions(-)
rename lib/power/power_acpi_cpufreq.c => drivers/power/acpi/acpi_cpufreq.c (95%)
rename lib/power/power_acpi_cpufreq.h => drivers/power/acpi/acpi_cpufreq.h (98%)
create mode 100644 drivers/power/acpi/meson.build
rename lib/power/power_amd_pstate_cpufreq.c => drivers/power/amd_pstate/amd_pstate_cpufreq.c (95%)
rename lib/power/power_amd_pstate_cpufreq.h => drivers/power/amd_pstate/amd_pstate_cpufreq.h (97%)
create mode 100644 drivers/power/amd_pstate/meson.build
create mode 100644 drivers/power/amd_uncore/amd_uncore.c
create mode 100644 drivers/power/amd_uncore/amd_uncore.h
create mode 100644 drivers/power/amd_uncore/meson.build
rename lib/power/power_cppc_cpufreq.c => drivers/power/cppc/cppc_cpufreq.c (95%)
rename lib/power/power_cppc_cpufreq.h => drivers/power/cppc/cppc_cpufreq.h (97%)
create mode 100644 drivers/power/cppc/meson.build
rename lib/power/power_intel_uncore.c => drivers/power/intel_uncore/intel_uncore.c (95%)
rename lib/power/power_intel_uncore.h => drivers/power/intel_uncore/intel_uncore.h (97%)
create mode 100644 drivers/power/intel_uncore/meson.build
rename {lib/power => drivers/power/kvm_vm}/guest_channel.c (100%)
rename {lib/power => drivers/power/kvm_vm}/guest_channel.h (100%)
rename lib/power/power_kvm_vm.c => drivers/power/kvm_vm/kvm_vm.c (82%)
rename lib/power/power_kvm_vm.h => drivers/power/kvm_vm/kvm_vm.h (98%)
create mode 100644 drivers/power/kvm_vm/meson.build
create mode 100644 drivers/power/meson.build
create mode 100644 drivers/power/pstate/meson.build
rename lib/power/power_pstate_cpufreq.c => drivers/power/pstate/pstate_cpufreq.c (96%)
rename lib/power/power_pstate_cpufreq.h => drivers/power/pstate/pstate_cpufreq.h (98%)
create mode 100644 lib/power/rte_power_cpufreq_api.h
create mode 100644 lib/power/rte_power_uncore_ops.hSignature · 1 line
2.34.1
Quoted 80 lines · On Tue, 15 Oct 2024 02:49:53 +0000 Sivaprasad Tummala…
This patchset refactors the power management library, addressing both core and uncore power management. The primary changes involve the creation of dedicated directories for each driver within '
drivers/power/core/*' and 'drivers/power/uncore/*'.This refactor significantly improves code organization, enhances clarity, and boosts maintainability. It lays the foundation for more focused development on individual drivers and facilitates seamless integration of future enhancements, particularly the AMD uncore driver.
Furthermore, this effort aims to streamline code maintenance by consolidating common functions for cpufreq and cppc across various core drivers, thus reducing code duplication.
Sivaprasad Tummala (5):
power: refactor core power management library
power: refactor uncore power management library test/power: removed function pointer validations power/amd_uncore: uncore support for AMD EPYC processors
maintainers: update fordrivers/powerMAINTAINERS | 1 + app/test/test_power.c | 95 ----- app/test/test_power_cpufreq.c | 52 --- app/test/test_power_kvm_vm.c | 36 -- drivers/meson.build | 1 + .../power/acpi/acpi_cpufreq.c | 22 +- .../power/acpi/acpi_cpufreq.h | 6 +- drivers/power/acpi/meson.build | 10 + .../power/amd_pstate/amd_pstate_cpufreq.c | 24 +- .../power/amd_pstate/amd_pstate_cpufreq.h | 8 +- drivers/power/amd_pstate/meson.build | 10 + drivers/power/amd_uncore/amd_uncore.c | 329 ++++++++++++++++++ drivers/power/amd_uncore/amd_uncore.h | 226 ++++++++++++ drivers/power/amd_uncore/meson.build | 20 ++ .../power/cppc/cppc_cpufreq.c | 22 +- .../power/cppc/cppc_cpufreq.h | 8 +- drivers/power/cppc/meson.build | 10 + .../power/intel_uncore/intel_uncore.c | 18 +- .../power/intel_uncore/intel_uncore.h | 8 +- drivers/power/intel_uncore/meson.build | 6 + .../power/kvm_vm}/guest_channel.c | 0 .../power/kvm_vm}/guest_channel.h | 0 .../power/kvm_vm/kvm_vm.c | 22 +- .../power/kvm_vm/kvm_vm.h | 6 +- drivers/power/kvm_vm/meson.build | 16 + drivers/power/meson.build | 14 + drivers/power/pstate/meson.build | 10 + .../power/pstate/pstate_cpufreq.c | 22 +- .../power/pstate/pstate_cpufreq.h | 6 +- examples/l3fwd-power/main.c | 12 +- lib/power/meson.build | 9 +- lib/power/power_common.c | 2 +- lib/power/power_common.h | 16 +- lib/power/rte_power.c | 287 +++++---------- lib/power/rte_power.h | 139 +++++--- lib/power/rte_power_cpufreq_api.h | 208 +++++++++++ lib/power/rte_power_uncore.c | 207 +++++------ lib/power/rte_power_uncore.h | 87 +++-- lib/power/rte_power_uncore_ops.h | 239 +++++++++++++ lib/power/version.map | 15 + 40 files changed, 1605 insertions(+), 624 deletions(-) rename lib/power/power_acpi_cpufreq.c => drivers/power/acpi/acpi_cpufreq.c (95%) rename lib/power/power_acpi_cpufreq.h => drivers/power/acpi/acpi_cpufreq.h (98%) create mode 100644 drivers/power/acpi/meson.build rename lib/power/power_amd_pstate_cpufreq.c => drivers/power/amd_pstate/amd_pstate_cpufreq.c (95%) rename lib/power/power_amd_pstate_cpufreq.h => drivers/power/amd_pstate/amd_pstate_cpufreq.h (97%) create mode 100644 drivers/power/amd_pstate/meson.build create mode 100644 drivers/power/amd_uncore/amd_uncore.c create mode 100644 drivers/power/amd_uncore/amd_uncore.h create mode 100644 drivers/power/amd_uncore/meson.build rename lib/power/power_cppc_cpufreq.c => drivers/power/cppc/cppc_cpufreq.c (95%) rename lib/power/power_cppc_cpufreq.h => drivers/power/cppc/cppc_cpufreq.h (97%) create mode 100644 drivers/power/cppc/meson.build rename lib/power/power_intel_uncore.c => drivers/power/intel_uncore/intel_uncore.c (95%) rename lib/power/power_intel_uncore.h => drivers/power/intel_uncore/intel_uncore.h (97%) create mode 100644 drivers/power/intel_uncore/meson.build rename {lib/power => drivers/power/kvm_vm}/guest_channel.c (100%) rename {lib/power => drivers/power/kvm_vm}/guest_channel.h (100%) rename lib/power/power_kvm_vm.c => drivers/power/kvm_vm/kvm_vm.c (82%)
Quoted 9 lines
rename lib/power/power_kvm_vm.h => drivers/power/kvm_vm/kvm_vm.h (98%) create mode 100644 drivers/power/kvm_vm/meson.build create mode 100644 drivers/power/meson.build create mode 100644 drivers/power/pstate/meson.build rename lib/power/power_pstate_cpufreq.c => drivers/power/pstate/pstate_cpufreq.c (96%) rename lib/power/power_pstate_cpufreq.h => drivers/power/pstate/pstate_cpufreq.h (98%) create mode 100644 lib/power/rte_power_cpufreq_api.h create mode 100644 lib/power/rte_power_uncore_ops.h
This is showing some build problems.
*Build Failed #1:
OS: RHEL94-64
Target: x86_64-native-linuxapp-gcc+shared
FAILED: app/dpdk-test
gcc -o app/dpdk-test app/dpdk-test.p/test_commands.c.o app/dpdk-test.p/test_test.c.o app/dpdk-test.p/test_packet_burst_generator.c.o app/dpdk-test.p/test_sample_packet_forward.c.o app/dpdk-test.p/test_virtual_pmd.c.o app/dpdk-test.p/test_test_acl.c.o app/dpdk-test.p/test_test_alarm.c.o app/dpdk-test.p/test_test_argparse.c.o app/dpdk-test.p/test_test_atomic.c.o app/dpdk-test.p/test_test_barrier.c.o app/dpdk-test.p/test_test_bitcount.c.o app/dpdk-test.p/test_test_bitmap.c.o app/dpdk-test.p/test_test_bitops.c.o app/dpdk-test.p/test_test_bitset.c.o app/dpdk-test.p/test_test_bitratestats.c.o app/dpdk-test.p/test_test_bpf.c.o app/dpdk-test.p/test_test_byteorder.c.o app/dpdk-test.p/test_test_cksum.c.o app/dpdk-test.p/test_test_cksum_perf.c.o app/dpdk-test.p/test_test_cmdline.c.o app/dpdk-test.p/test_test_cmdline_cirbuf.c.o app/dpdk-test.p/test_test_cmdline_etheraddr.c.o app/dpdk-test.p/test_test_cmdline_ipaddr.c.o app/dpdk-test.p/test_test_cmdline_lib.c.o app/dpdk-test.p/test_test_cmdline_
num.c.o app/dpdk-test.p/test_test_cmdline_portlist.c.o app/dpdk-test.p/test_test_cmdline_string.c.o app/dpdk-test.p/test_test_common.c.o app/dpdk-test.p/test_test_compressdev.c.o app/dpdk-test.p/test_test_cpuflags.c.o app/dpdk-test.p/test_test_crc.c.o app/dpdk-test.p/test_test_cryptodev.c.o app/dpdk-test.p/test_test_cryptodev_asym.c.o app/dpdk-test.p/test_test_cryptodev_blockcipher.c.o app/dpdk-test.p/test_test_cryptodev_crosscheck.c.o app/dpdk-test.p/test_test_cryptodev_security_ipsec.c.o app/dpdk-test.p/test_test_cryptodev_security_pdcp.c.o app/dpdk-test.p/test_test_cryptodev_security_tls_record.c.o app/dpdk-test.p/test_test_cycles.c.o app/dpdk-test.p/test_test_debug.c.o app/dpdk-test.p/test_test_devargs.c.o app/dpdk-test.p/test_test_dispatcher.c.o app/dpdk-test.p/test_test_distributor.c.o app/dpdk-test.p/test_test_distributor_perf.c.o app/dpdk-test.p/test_test_dmadev.c.o app/dpdk-test.p/test_test_dmadev_api.c.o app/dpdk-test.p/test_test_eal_flags.c.o app/dpdk-test.p/test_test_eal _fs.c.o app/dpdk-test.p/test_test_efd.c.o app/dpdk-test.p/test_test_efd_perf.c.o app/dpdk-test.p/test_test_errno.c.o app/dpdk-test.p/test_test_ethdev_api.c.o app/dpdk-test.p/test_test_ethdev_link.c.o app/dpdk-test.p/test_test_event_crypto_adapter.c.o app/dpdk-test.p/test_test_event_dma_adapter.c.o app/dpdk-test.p/test_test_event_eth_rx_adapter.c.o app/dpdk-test.p/test_test_event_eth_tx_adapter.c.o app/dpdk-test.p/test_test_event_ring.c.o app/dpdk-test.p/test_test_event_timer_adapter.c.o app/dpdk-test.p/test_test_eventdev.c.o app/dpdk-test.p/test_test_external_mem.c.o app/dpdk-test.p/test_test_fbarray.c.o app/dpdk-test.p/test_test_fib.c.o app/dpdk-test.p/test_test_fib6.c.o app/dpdk-test.p/test_test_fib6_perf.c.o app/dpdk-test.p/test_test_fib_perf.c.o app/dpdk-test.p/test_test_func_reentrancy.c.o app/dpdk-test.p/test_test_graph.c.o app/dpdk-test.p/test_test_graph_perf.c.o app/dpdk-test.p/test_test_hash.c.o app/dpdk-test.p/test_test_hash_functions.c.o app/dpdk-test.p/test_test_hash_mul tiwriter.c.o app/dpdk-test.p/test_test_hash_perf.c.o app/dpdk-test.p/test_test_hash_readwrite.c.o app/dpdk-test.p/test_test_hash_readwrite_lf_perf.c.o app/dpdk-test.p/test_test_interrupts.c.o app/dpdk-test.p/test_test_ipfrag.c.o app/dpdk-test.p/test_test_ipsec.c.o app/dpdk-test.p/test_test_ipsec_perf.c.o app/dpdk-test.p/test_test_ipsec_sad.c.o app/dpdk-test.p/test_test_kvargs.c.o app/dpdk-test.p/test_test_latencystats.c.o app/dpdk-test.p/test_test_lcores.c.o app/dpdk-test.p/test_test_link_bonding.c.o app/dpdk-test.p/test_test_link_bonding_mode4.c.o app/dpdk-test.p/test_test_link_bonding_rssconf.c.o app/dpdk-test.p/test_test_logs.c.o app/dpdk-test.p/test_test_lpm.c.o app/dpdk-test.p/test_test_lpm6.c.o app/dpdk-test.p/test_test_lpm6_perf.c.o app/dpdk-test.p/test_test_lpm_perf.c.o app/dpdk-test.p/test_test_malloc.c.o app/dpdk-test.p/test_test_malloc_perf.c.o app/dpdk-test.p/test_test_mbuf.c.o app/dpdk-test.p/test_test_mcslock.c.o app/dpdk-test.p/test_test_member.c.o app/dpdk-test.p/tes t_test_member_perf.c.o app/dpdk-test.p/test_test_memcpy.c.o app/dpdk-test.p/test_test_memcpy_perf.c.o app/dpdk-test.p/test_test_memory.c.o app/dpdk-test.p/test_test_mempool.c.o app/dpdk-test.p/test_test_mempool_perf.c.o app/dpdk-test.p/test_test_memzone.c.o app/dpdk-test.p/test_test_meter.c.o app/dpdk-test.p/test_test_metrics.c.o app/dpdk-test.p/test_test_mp_secondary.c.o app/dpdk-test.p/test_test_net_ether.c.o app/dpdk-test.p/test_test_pcapng.c.o app/dpdk-test.p/test_test_pdcp.c.o app/dpdk-test.p/test_test_pdump.c.o app/dpdk-test.p/test_test_per_lcore.c.o app/dpdk-test.p/test_test_pflock.c.o app/dpdk-test.p/test_test_pie.c.o app/dpdk-test.p/test_test_pmd_perf.c.o app/dpdk-test.p/test_test_pmd_ring.c.o app/dpdk-test.p/test_test_pmd_ring_perf.c.o app/dpdk-test.p/test_test_power.c.o app/dpdk-test.p/test_test_power_cpufreq.c.o app/dpdk-test.p/test_test_power_intel_uncore.c.o app/dpdk-test.p/test_test_power_kvm_vm.c.o app/dpdk-test.p/test_test_prefetch.c.o app/dpdk-test.p/test_test_ptr_ compress.c.o app/dpdk-test.p/test_test_rand_perf.c.o app/dpdk-test.p/test_test_rawdev.c.o app/dpdk-test.p/test_test_rcu_qsbr.c.o app/dpdk-test.p/test_test_rcu_qsbr_perf.c.o app/dpdk-test.p/test_test_reassembly_perf.c.o app/dpdk-test.p/test_test_reciprocal_division.c.o app/dpdk-test.p/test_test_reciprocal_division_perf.c.o app/dpdk-test.p/test_test_red.c.o app/dpdk-test.p/test_test_reorder.c.o app/dpdk-test.p/test_test_rib.c.o app/dpdk-test.p/test_test_rib6.c.o app/dpdk-test.p/test_test_ring.c.o app/dpdk-test.p/test_test_ring_hts_stress.c.o app/dpdk-test.p/test_test_ring_mpmc_stress.c.o app/dpdk-test.p/test_test_ring_mt_peek_stress.c.o app/dpdk-test.p/test_test_ring_mt_peek_stress_zc.c.o app/dpdk-test.p/test_test_ring_perf.c.o app/dpdk-test.p/test_test_ring_rts_stress.c.o app/dpdk-test.p/test_test_ring_st_peek_stress.c.o app/dpdk-test.p/test_test_ring_st_peek_stress_zc.c.o app/dpdk-test.p/test_test_ring_stress.c.o app/dpdk-test.p/test_test_rwlock.c.o app/dpdk-test.p/test_test_sched.c .o app/dpdk-test.p/test_test_security.c.o app/dpdk-test.p/test_test_security_inline_macsec.c.o app/dpdk-test.p/test_test_security_inline_proto.c.o app/dpdk-test.p/test_test_security_proto.c.o app/dpdk-test.p/test_test_seqlock.c.o app/dpdk-test.p/test_test_service_cores.c.o app/dpdk-test.p/test_test_spinlock.c.o app/dpdk-test.p/test_test_stack.c.o app/dpdk-test.p/test_test_stack_perf.c.o app/dpdk-test.p/test_test_string_fns.c.o app/dpdk-test.p/test_test_table.c.o app/dpdk-test.p/test_test_table_acl.c.o app/dpdk-test.p/test_test_table_combined.c.o app/dpdk-test.p/test_test_table_pipeline.c.o app/dpdk-test.p/test_test_table_ports.c.o app/dpdk-test.p/test_test_table_tables.c.o app/dpdk-test.p/test_test_tailq.c.o app/dpdk-test.p/test_test_telemetry_data.c.o app/dpdk-test.p/test_test_telemetry_json.c.o app/dpdk-test.p/test_test_thash.c.o app/dpdk-test.p/test_test_thash_perf.c.o app/dpdk-test.p/test_test_threads.c.o app/dpdk-test.p/test_test_ticketlock.c.o app/dpdk-test.p/test_test_timer.c .o app/dpdk-test.p/test_test_timer_perf.c.o app/dpdk-test.p/test_test_timer_racecond.c.o app/dpdk-test.p/test_test_timer_secondary.c.o app/dpdk-test.p/test_test_trace.c.o app/dpdk-test.p/test_test_trace_perf.c.o app/dpdk-test.p/test_test_trace_register.c.o app/dpdk-test.p/test_test_vdev.c.o app/dpdk-test.p/test_test_version.c.o -Wl,--as-needed -Wl,--no-undefined -Wl,-O1 -Wl,--no-as-needed -pthread -Wl,--start-group -lm -ldl -lnuma -lfdt '-Wl,-rpath,$ORIGIN/../lib:$ORIGIN/../drivers:XXXXXXXXXXXXXXX' -Wl,-rpath-link,/root/RHEL94-64_K5.14.0_GCC11.4.1/x86_64-native-linuxapp-gcc+shared/33487/dpdk/x86_64-native-linuxapp-gcc+shared/lib -Wl,-rpath-link,/root/RHEL94-64_K5.14.0_GCC11.4.1/x86_64-native-linuxapp-gcc+shared/33487/dpdk/x86_64-native-linuxapp-gcc+shared/drivers lib/librte_cmdline.so.25.0 lib/librte_eal.so.25.0 lib/librte_kvargs.so.25.0 lib/librte_log.so.25.0 lib/librte_telemetry.so.25.0 lib/librte_net.so.25.0 lib/librte_mbuf.so.25.0 lib/librte_mempool.so.25.0 lib/librte_ring.so.25 .0 drivers/librte_net_ring.so.25.0 lib/librte_ethdev.so.25.0 lib/librte_meter.so.25.0 drivers/librte_bus_pci.so.25.0 lib/librte_pci.so.25.0 drivers/librte_bus_vdev.so.25.0 lib/librte_acl.so.25.0 lib/librte_argparse
.so.25.0 lib/librte_hash.so.25.0 lib/librte_rcu.so.25.0 lib/librte_metrics.so.25.0 lib/librte_bitratestats.so.25.0 lib/librte_bpf.so.25.0 lib/librte_compressdev.so.25.0 lib/librte_cryptodev.so.25.0 lib/librte_security.so.25.0 lib/librte_dispatcher.so.25.0 lib/librte_eventdev.so.25.0 lib/librte_timer.so.25.0 lib/librte_dmadev.so.25.0 lib/librte_distributor.so.25.0 lib/librte_efd.so.25.0 lib/librte_fib.so.25.0 lib/librte_rib.so.25.0 lib/librte_table.so.25.0 lib/librte_port.so.25.0 lib/librte_sched.so.25.0 lib/librte_ip_frag.so.25.0 lib/librte_lpm.so.25.0 lib/librte_graph.so.25.0 lib/librte_pcapng.so.25.0 lib/librte_ipsec.so.25.0 lib/librte_latencystats.so.25.0 drivers/librte_net_bond.so.25.0 lib/librte_member.so.25.0 lib/librte_pdcp.so.25.0 lib/librte_reorder.so.25.0 lib/librte_pdump.so.25.0 lib/librte_power.so.25.0 lib/librte_rawdev.so.25.0 lib/librte_stack.so.25.0 lib/librte_pipeline.so.25.0 drivers/librte_crypto_scheduler.so.25.0 /usr/lib64/libz.so /usr/lib64/libpcap.so /usr/lib64/l
ibelf.so -Wl,--end-group/usr/bin/ld: app/dpdk-test.p/test_test_power_cpufreq.c.o: in function `test_power_caps':
test_power_cpufreq.c:(.text+0x15): undefined reference to `rte_power_get_core_ops'/usr/bin/ld: app/dpdk-test.p/test_test_power_cpufreq.c.o: in function `test_power_cpufreq':
test_power_cpufreq.c:(.text+0x48d): undefined reference to `rte_power_get_core_ops'/usr/bin/ld: test_power_cpufreq.c:(.text+0x4ac): undefined reference to `rte_power_get_core_ops'/usr/bin/ld: test_power_cpufreq.c:(.text+0x4c8): undefined reference to `rte_power_get_core_ops'/usr/bin/ld: test_power_cpufreq.c:(.text+0x4e4): undefined reference to `rte_power_get_core_ops'/usr/bin/ld: app/dpdk-test.p/test_test_power_cpufreq.c.o:test_power_cpufreq.c:(.text+0x516): more undefined references to `rte_power_get_core_ops' follow/usr/bin/ld: app/dpdk-test.p/test_test_power_intel_uncore.c.o: in function `test_power_intel_uncore':
test_power_intel_uncore.c:(.text+0x19): undefined reference to `rte_power_get_uncore_ops'/usr/bin/ld: test_power_intel_uncore.c:(.text+0x3a): undefined reference to `rte_power_get_uncore_ops'/usr/bin/ld: test_power_intel_uncore.c:(.text+0x46): undefined reference to `rte_power_get_uncore_ops'/usr/bin/ld: test_power_intel_uncore.c:(.text+0x61): undefined reference to `rte_power_get_uncore_ops'/usr/bin/ld: test_power_intel_uncore.c:(.text+0x75): undefined reference to `rte_power_get_uncore_ops'/usr/bin/ld: app/dpdk-test.p/test_test_power_intel_uncore.c.o:test_power_intel_uncore.c:(.text+0x81): more undefined references to `rte_power_get_uncore_ops' follow/usr/bin/ld: app/dpdk-test.p/test_test_power_kvm_vm.c.o: in function `test_power_kvm_vm':
test_power_kvm_vm.c:(.text+0x54): undefined reference to `rte_power_get_core_ops'/usr/bin/ld: test_power_kvm_vm.c:(.text+0x6a): undefined reference to `rte_power_get_core_ops'/usr/bin/ld: test_power_kvm_vm.c:(.text+0x80): undefined reference to `rte_power_get_core_ops'/usr/bin/ld: test_power_kvm_vm.c:(.text+0x96): undefined reference to `rte_power_get_core_ops'/usr/bin/ld: test_power_kvm_vm.c:(.text+0xac): undefined reference to `rte_power_get_core_ops'/usr/bin/ld: app/dpdk-test.p/test_test_power_kvm_vm.c.o:test_power_kvm_vm.c:(.text+0xc2): more undefined references to `rte_power_get_core_ops' follow
collect2: error: ld returned 1 exit status
ninja: build stopped
v5 cover power: refactor power management library
In reply to Sivaprasad TummalaThis patchset refactors the power management library, addressing both core and uncore power management. The primary changes involve the creation of dedicated directories for each driver within 'drivers/power/core/*' and 'drivers/power/uncore/*'.
This refactor significantly improves code organization, enhances clarity, and boosts maintainability. It lays the foundation for more focused development on individual drivers and facilitates seamless integration of future enhancements, particularly the AMD uncore driver.
Furthermore, this effort aims to streamline code maintenance by consolidating common functions for cpufreq and cppc across various core drivers, thus reducing code duplication.
Sivaprasad Tummala (5):
power: refactor core power management library
power: refactor uncore power management library test/power: removed function pointer validations drivers/power: uncore support for AMD EPYC processors
maintainers: update for drivers/power
MAINTAINERS | 1 +
app/test/test_power.c | 95 -----
app/test/test_power_cpufreq.c | 52 ---
app/test/test_power_kvm_vm.c | 36 --
drivers/meson.build | 1 +
.../power/acpi/acpi_cpufreq.c | 22 +-
.../power/acpi/acpi_cpufreq.h | 6 +-
drivers/power/acpi/meson.build | 10 +
.../power/amd_pstate/amd_pstate_cpufreq.c | 24 +-
.../power/amd_pstate/amd_pstate_cpufreq.h | 8 +-
drivers/power/amd_pstate/meson.build | 10 +
drivers/power/amd_uncore/amd_uncore.c | 329 ++++++++++++++++++
drivers/power/amd_uncore/amd_uncore.h | 226 ++++++++++++
drivers/power/amd_uncore/meson.build | 20 ++
.../power/cppc/cppc_cpufreq.c | 22 +-
.../power/cppc/cppc_cpufreq.h | 8 +-
drivers/power/cppc/meson.build | 10 +
.../power/intel_uncore/intel_uncore.c | 18 +-
.../power/intel_uncore/intel_uncore.h | 8 +-
drivers/power/intel_uncore/meson.build | 6 +
.../power/kvm_vm}/guest_channel.c | 0
.../power/kvm_vm}/guest_channel.h | 0
.../power/kvm_vm/kvm_vm.c | 22 +-
.../power/kvm_vm/kvm_vm.h | 6 +-
drivers/power/kvm_vm/meson.build | 16 +
drivers/power/meson.build | 14 +
drivers/power/pstate/meson.build | 10 +
.../power/pstate/pstate_cpufreq.c | 22 +-
.../power/pstate/pstate_cpufreq.h | 6 +-
examples/l3fwd-power/main.c | 12 +-
lib/power/meson.build | 9 +-
lib/power/power_common.c | 2 +-
lib/power/power_common.h | 16 +-
lib/power/rte_power.c | 287 +++++----------
lib/power/rte_power.h | 141 +++++---
lib/power/rte_power_cpufreq_api.h | 209 +++++++++++
lib/power/rte_power_uncore.c | 207 +++++------
lib/power/rte_power_uncore.h | 87 +++--
lib/power/rte_power_uncore_ops.h | 241 +++++++++++++
lib/power/version.map | 17 +
40 files changed, 1611 insertions(+), 625 deletions(-)
rename lib/power/power_acpi_cpufreq.c => drivers/power/acpi/acpi_cpufreq.c (95%)
rename lib/power/power_acpi_cpufreq.h => drivers/power/acpi/acpi_cpufreq.h (98%)
create mode 100644 drivers/power/acpi/meson.build
rename lib/power/power_amd_pstate_cpufreq.c => drivers/power/amd_pstate/amd_pstate_cpufreq.c (95%)
rename lib/power/power_amd_pstate_cpufreq.h => drivers/power/amd_pstate/amd_pstate_cpufreq.h (97%)
create mode 100644 drivers/power/amd_pstate/meson.build
create mode 100644 drivers/power/amd_uncore/amd_uncore.c
create mode 100644 drivers/power/amd_uncore/amd_uncore.h
create mode 100644 drivers/power/amd_uncore/meson.build
rename lib/power/power_cppc_cpufreq.c => drivers/power/cppc/cppc_cpufreq.c (95%)
rename lib/power/power_cppc_cpufreq.h => drivers/power/cppc/cppc_cpufreq.h (97%)
create mode 100644 drivers/power/cppc/meson.build
rename lib/power/power_intel_uncore.c => drivers/power/intel_uncore/intel_uncore.c (95%)
rename lib/power/power_intel_uncore.h => drivers/power/intel_uncore/intel_uncore.h (97%)
create mode 100644 drivers/power/intel_uncore/meson.build
rename {lib/power => drivers/power/kvm_vm}/guest_channel.c (100%)
rename {lib/power => drivers/power/kvm_vm}/guest_channel.h (100%)
rename lib/power/power_kvm_vm.c => drivers/power/kvm_vm/kvm_vm.c (82%)
rename lib/power/power_kvm_vm.h => drivers/power/kvm_vm/kvm_vm.h (98%)
create mode 100644 drivers/power/kvm_vm/meson.build
create mode 100644 drivers/power/meson.build
create mode 100644 drivers/power/pstate/meson.build
rename lib/power/power_pstate_cpufreq.c => drivers/power/pstate/pstate_cpufreq.c (96%)
rename lib/power/power_pstate_cpufreq.h => drivers/power/pstate/pstate_cpufreq.h (98%)
create mode 100644 lib/power/rte_power_cpufreq_api.h
create mode 100644 lib/power/rte_power_uncore_ops.hSignature · 1 line
2.34.1
PATCH v5 1/5 power: refactor core power management library
This patch introduces a comprehensive refactor to the core power management library. The primary focus is on improving modularity and organization by relocating specific driver implementations from the 'lib/power' directory to dedicated directories within 'drivers/power/core/*'. The adjustment of meson.build files enables the selective activation of individual drivers.
These changes contribute to a significant enhancement in code organization, providing a clearer structure for driver implementations. The refactor aims to improve overall code clarity and boost maintainability. Additionally, it establishes a foundation for future development, allowing for more focused work on individual drivers and seamless integration of forthcoming enhancements.
v5:
- fixed code style warning
v4:
- fixed build error with RTE_ASSERT
v3:
- renamed rte_power_core_ops.h as rte_power_cpufreq_api.h
- re-worked on auto detection logic
v2:
- added NULL check for global_core_ops in rte_power_get_core_ops
---
drivers/meson.build | 1 +
.../power/acpi/acpi_cpufreq.c | 22 +-
.../power/acpi/acpi_cpufreq.h | 6 +-
drivers/power/acpi/meson.build | 10 +
.../power/amd_pstate/amd_pstate_cpufreq.c | 24 +-
.../power/amd_pstate/amd_pstate_cpufreq.h | 8 +-
drivers/power/amd_pstate/meson.build | 10 +
.../power/cppc/cppc_cpufreq.c | 22 +-
.../power/cppc/cppc_cpufreq.h | 8 +-
drivers/power/cppc/meson.build | 10 +
.../power/kvm_vm}/guest_channel.c | 0
.../power/kvm_vm}/guest_channel.h | 0
.../power/kvm_vm/kvm_vm.c | 22 +-
.../power/kvm_vm/kvm_vm.h | 6 +-
drivers/power/kvm_vm/meson.build | 16 +
drivers/power/meson.build | 12 +
drivers/power/pstate/meson.build | 10 +
.../power/pstate/pstate_cpufreq.c | 22 +-
.../power/pstate/pstate_cpufreq.h | 6 +-
lib/power/meson.build | 7 +-
lib/power/power_common.c | 2 +-
lib/power/power_common.h | 16 +-
lib/power/rte_power.c | 287 ++++++------------
lib/power/rte_power.h | 141 ++++++---
lib/power/rte_power_cpufreq_api.h | 209 +++++++++++++
lib/power/version.map | 14 +
26 files changed, 621 insertions(+), 270 deletions(-)
rename lib/power/power_acpi_cpufreq.c => drivers/power/acpi/acpi_cpufreq.c (95%)
rename lib/power/power_acpi_cpufreq.h => drivers/power/acpi/acpi_cpufreq.h (98%)
create mode 100644 drivers/power/acpi/meson.build
rename lib/power/power_amd_pstate_cpufreq.c => drivers/power/amd_pstate/amd_pstate_cpufreq.c (95%)
rename lib/power/power_amd_pstate_cpufreq.h => drivers/power/amd_pstate/amd_pstate_cpufreq.h (97%)
create mode 100644 drivers/power/amd_pstate/meson.build
rename lib/power/power_cppc_cpufreq.c => drivers/power/cppc/cppc_cpufreq.c (95%)
rename lib/power/power_cppc_cpufreq.h => drivers/power/cppc/cppc_cpufreq.h (97%)
create mode 100644 drivers/power/cppc/meson.build
rename {lib/power => drivers/power/kvm_vm}/guest_channel.c (100%)
rename {lib/power => drivers/power/kvm_vm}/guest_channel.h (100%)
rename lib/power/power_kvm_vm.c => drivers/power/kvm_vm/kvm_vm.c (82%)
rename lib/power/power_kvm_vm.h => drivers/power/kvm_vm/kvm_vm.h (98%)
create mode 100644 drivers/power/kvm_vm/meson.build
create mode 100644 drivers/power/meson.build
create mode 100644 drivers/power/pstate/meson.build
rename lib/power/power_pstate_cpufreq.c => drivers/power/pstate/pstate_cpufreq.c (96%)
rename lib/power/power_pstate_cpufreq.h => drivers/power/pstate/pstate_cpufreq.h (98%)
create mode 100644 lib/power/rte_power_cpufreq_api.hdrivers/meson.build +1 -0
@@ -29,6 +29,7 @@ subdirs = [ 'event', # depends on common, bus, mempool and net. 'baseband', # depends on common and bus. 'gpu', # depends on common and bus. + 'power', # depends on common (in future). ] if meson.is_cross_build()
drivers/power/acpi/acpi_cpufreq.c renamed from lib/power/power_acpi_cpufreq.c +21 -1
@@ -10,7 +10,7 @@#include <rte_stdatomic.h> #include <rte_string_fns.h> -#include "power_acpi_cpufreq.h" +#include "acpi_cpufreq.h" #include "power_common.h" #define STR_SIZE 1024
@@ -583,3 +583,23 @@ int power_acpi_get_capabilities(unsigned int lcore_id,return 0 ; } + +static struct rte_power_core_ops acpi_ops = { + .name ="acpi" , + .init = power_acpi_cpufreq_init, + .exit = power_acpi_cpufreq_exit, + .check_env_support = power_acpi_cpufreq_check_supported, + .get_avail_freqs = power_acpi_cpufreq_freqs, + .get_freq = power_acpi_cpufreq_get_freq, + .set_freq = power_acpi_cpufreq_set_freq, + .freq_down = power_acpi_cpufreq_freq_down, + .freq_up = power_acpi_cpufreq_freq_up, + .freq_max = power_acpi_cpufreq_freq_max, + .freq_min = power_acpi_cpufreq_freq_min, + .turbo_status = power_acpi_turbo_status, + .enable_turbo = power_acpi_enable_turbo, + .disable_turbo = power_acpi_disable_turbo, + .get_caps = power_acpi_get_capabilities +}; + +RTE_POWER_REGISTER_OPS (acpi_ops);
drivers/power/acpi/acpi_cpufreq.h renamed from lib/power/power_acpi_cpufreq.h +3 -3
@@ -2,15 +2,15 @@* Copyright(c) 2010-2014 Intel Corporation */ -#ifndef _POWER_ACPI_CPUFREQ_H -#define _POWER_ACPI_CPUFREQ_H +#ifndef _ACPI_CPUFREQ_H +#define _ACPI_CPUFREQ_H/** * @file * RTE Power Management via userspace ACPI cpufreq */ -#include "rte_power.h" +#include "rte_power_cpufreq_api.h" /** * Check if ACPI power management is supported.
drivers/power/acpi/meson.build new file +10 -0
@@ -0,0 +1,10 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' +endif +sources = files('acpi_cpufreq.c') + +deps += ['power']
drivers/power/amd_pstate/amd_pstate_cpufreq.c renamed from lib/power/power_amd_pstate_cpufreq.c +22 -2
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2010-2021 Intel Corporation * Copyright(c) 2021 Arm Limited -* Copyright(c) 2023 Amd Limited +* Copyright(c) 2024 Advanced Micro Devices, Inc. */ #include <stdlib.h>
@@ -9,7 +9,7 @@#include <rte_memcpy.h> #include <rte_stdatomic.h> -#include "power_amd_pstate_cpufreq.h" +#include "amd_pstate_cpufreq.h" #include "power_common.h" /* macros used for rounding frequency to nearest 1000 */
@@ -706,3 +706,23 @@ power_amd_pstate_get_capabilities(unsigned int lcore_id,return 0 ; } + +static struct rte_power_core_ops amd_pstate_ops = { + .name ="amd-pstate" , + .init = power_amd_pstate_cpufreq_init, + .exit = power_amd_pstate_cpufreq_exit, + .check_env_support = power_amd_pstate_cpufreq_check_supported, + .get_avail_freqs = power_amd_pstate_cpufreq_freqs, + .get_freq = power_amd_pstate_cpufreq_get_freq, + .set_freq = power_amd_pstate_cpufreq_set_freq, + .freq_down = power_amd_pstate_cpufreq_freq_down, + .freq_up = power_amd_pstate_cpufreq_freq_up, + .freq_max = power_amd_pstate_cpufreq_freq_max, + .freq_min = power_amd_pstate_cpufreq_freq_min, + .turbo_status = power_amd_pstate_turbo_status, + .enable_turbo = power_amd_pstate_enable_turbo, + .disable_turbo = power_amd_pstate_disable_turbo, + .get_caps = power_amd_pstate_get_capabilities +}; + +RTE_POWER_REGISTER_OPS (amd_pstate_ops);
drivers/power/amd_pstate/amd_pstate_cpufreq.h renamed from lib/power/power_amd_pstate_cpufreq.h +4 -4
@@ -1,18 +1,18 @@/* SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2010-2021 Intel Corporation * Copyright(c) 2021 Arm Limited -* Copyright(c) 2023 Amd Limited +* Copyright(c) 2024 Advanced Micro Devices, Inc. */ -#ifndef _POWER_AMD_PSTATE_CPUFREQ_H -#define _POWER_AMD_PSTATE_CPUFREQ_H +#ifndef _AMD_PSTATE_CPUFREQ_H +#define _AMD_PSTATE_CPUFREQ_H/** * @file * RTE Power Management via userspace AMD pstate cpufreq */ -#include "rte_power.h" +#include "rte_power_cpufreq_api.h" /** * Check if amd p-state power management is supported.
drivers/power/amd_pstate/meson.build new file +10 -0
@@ -0,0 +1,10 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' +endif +sources = files('amd_pstate_cpufreq.c') + +deps += ['power']
drivers/power/cppc/cppc_cpufreq.c renamed from lib/power/power_cppc_cpufreq.c +21 -1
@@ -8,7 +8,7 @@#include <rte_memcpy.h> #include <rte_stdatomic.h> -#include "power_cppc_cpufreq.h" +#include "cppc_cpufreq.h" #include "power_common.h" /* macros used for rounding frequency to nearest 100000 */
@@ -691,3 +691,23 @@ power_cppc_get_capabilities(unsigned int lcore_id,return 0 ; } + +static struct rte_power_core_ops cppc_ops = { + .name ="cppc" , + .init = power_cppc_cpufreq_init, + .exit = power_cppc_cpufreq_exit, + .check_env_support = power_cppc_cpufreq_check_supported, + .get_avail_freqs = power_cppc_cpufreq_freqs, + .get_freq = power_cppc_cpufreq_get_freq, + .set_freq = power_cppc_cpufreq_set_freq, + .freq_down = power_cppc_cpufreq_freq_down, + .freq_up = power_cppc_cpufreq_freq_up, + .freq_max = power_cppc_cpufreq_freq_max, + .freq_min = power_cppc_cpufreq_freq_min, + .turbo_status = power_cppc_turbo_status, + .enable_turbo = power_cppc_enable_turbo, + .disable_turbo = power_cppc_disable_turbo, + .get_caps = power_cppc_get_capabilities +}; + +RTE_POWER_REGISTER_OPS (cppc_ops);
drivers/power/cppc/cppc_cpufreq.h renamed from lib/power/power_cppc_cpufreq.h +4 -4
@@ -3,15 +3,15 @@* Copyright(c) 2021 Arm Limited */ -#ifndef _POWER_CPPC_CPUFREQ_H -#define _POWER_CPPC_CPUFREQ_H +#ifndef _CPPC_CPUFREQ_H +#define _CPPC_CPUFREQ_H/** * @file * RTE Power Management via userspace CPPC cpufreq */ -#include "rte_power.h" +#include "rte_power_cpufreq_api.h" /** * Check if CPPC power management is supported.
@@ -215,4 +215,4 @@ int power_cppc_disable_turbo(unsigned int lcore_id);int power_cppc_get_capabilities (unsigned int lcore_id,struct rte_power_core_capabilities *caps); -#endif /* _POWER_CPPC_CPUFREQ_H */ +#endif /* _CPPC_CPUFREQ_H */
drivers/power/cppc/meson.build new file +10 -0
@@ -0,0 +1,10 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' +endif +sources = files('cppc_cpufreq.c') + +deps += ['power']
drivers/power/kvm_vm/guest_channel.c renamed from lib/power/guest_channel.c +0 -0
drivers/power/kvm_vm/guest_channel.h renamed from lib/power/guest_channel.h +0 -0
drivers/power/kvm_vm/kvm_vm.c renamed from lib/power/power_kvm_vm.c +21 -1
@@ -9,7 +9,7 @@#include "rte_power_guest_channel.h" #include "guest_channel.h" #include "power_common.h" -#include "power_kvm_vm.h" +#include "kvm_vm.h" #define FD_PATH "/dev/virtio-ports/virtio.serial.port.poweragent"
@@ -137,3 +137,23 @@ int power_kvm_vm_get_capabilities(__rte_unused unsigned int lcore_id,POWER_LOG (ERR ,"rte_power_get_capabilities is not implemented for Virtual Machine Power Management" );return -ENOTSUP ; } + +static struct rte_power_core_ops kvm_vm_ops = { + .name ="kvm-vm" , + .init = power_kvm_vm_init, + .exit = power_kvm_vm_exit, + .check_env_support = power_kvm_vm_check_supported, + .get_avail_freqs = power_kvm_vm_freqs, + .get_freq = power_kvm_vm_get_freq, + .set_freq = power_kvm_vm_set_freq, + .freq_down = power_kvm_vm_freq_down, + .freq_up = power_kvm_vm_freq_up, + .freq_max = power_kvm_vm_freq_max, + .freq_min = power_kvm_vm_freq_min, + .turbo_status = power_kvm_vm_turbo_status, + .enable_turbo = power_kvm_vm_enable_turbo, + .disable_turbo = power_kvm_vm_disable_turbo, + .get_caps = power_kvm_vm_get_capabilities +}; + +RTE_POWER_REGISTER_OPS (kvm_vm_ops);
drivers/power/kvm_vm/kvm_vm.h renamed from lib/power/power_kvm_vm.h +3 -3
@@ -2,15 +2,15 @@* Copyright(c) 2010-2014 Intel Corporation */ -#ifndef _POWER_KVM_VM_H -#define _POWER_KVM_VM_H +#ifndef _KVM_VM_H +#define _KVM_VM_H/** * @file * RTE Power Management KVM VM */ -#include "rte_power.h" +#include "rte_power_cpufreq_api.h" /** * Check if KVM power management is supported.
drivers/power/kvm_vm/meson.build new file +16 -0
@@ -0,0 +1,16 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(C) 2024 Advanced Micro Devices, Inc. +# + +if not is_linux + build = false + reason = 'only supported on Linux' + subdir_done() +endif + +sources = files( + 'guest_channel.c', + 'kvm_vm.c', +) + +deps += ['power']
drivers/power/meson.build new file +12 -0
@@ -0,0 +1,12 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +drivers = [ + 'acpi', + 'amd_pstate', + 'cppc', + 'kvm_vm', + 'pstate' +] + +std_deps = ['power']
drivers/power/pstate/meson.build new file +10 -0
@@ -0,0 +1,10 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' +endif +sources = files('pstate_cpufreq.c') + +deps += ['power']
drivers/power/pstate/pstate_cpufreq.c renamed from lib/power/power_pstate_cpufreq.c +21 -1
@@ -15,7 +15,7 @@#include <rte_stdatomic.h> #include "rte_power_pmd_mgmt.h" -#include "power_pstate_cpufreq.h" +#include "pstate_cpufreq.h" #include "power_common.h" /* macros used for rounding frequency to nearest 100000 */
@@ -894,3 +894,23 @@ int power_pstate_get_capabilities(unsigned int lcore_id,return 0 ; } + +static struct rte_power_core_ops pstate_ops = { + .name ="pstate" , + .init = power_pstate_cpufreq_init, + .exit = power_pstate_cpufreq_exit, + .check_env_support = power_pstate_cpufreq_check_supported, + .get_avail_freqs = power_pstate_cpufreq_freqs, + .get_freq = power_pstate_cpufreq_get_freq, + .set_freq = power_pstate_cpufreq_set_freq, + .freq_down = power_pstate_cpufreq_freq_down, + .freq_up = power_pstate_cpufreq_freq_up, + .freq_max = power_pstate_cpufreq_freq_max, + .freq_min = power_pstate_cpufreq_freq_min, + .turbo_status = power_pstate_turbo_status, + .enable_turbo = power_pstate_enable_turbo, + .disable_turbo = power_pstate_disable_turbo, + .get_caps = power_pstate_get_capabilities +}; + +RTE_POWER_REGISTER_OPS (pstate_ops);
drivers/power/pstate/pstate_cpufreq.h renamed from lib/power/power_pstate_cpufreq.h +3 -3
@@ -2,15 +2,15 @@* Copyright(c) 2018 Intel Corporation */ -#ifndef _POWER_PSTATE_CPUFREQ_H -#define _POWER_PSTATE_CPUFREQ_H +#ifndef _PSTATE_CPUFREQ_H +#define _PSTATE_CPUFREQ_H/** * @file * RTE Power Management via Intel Pstate driver */ -#include "rte_power.h" +#include "rte_power_cpufreq_api.h" /** * Check if pstate power management is supported.
lib/power/meson.build +1 -6
@@ -12,20 +12,15 @@ if not is_linux reason = 'only supported on Linux' endif sources = files( - 'guest_channel.c', - 'power_acpi_cpufreq.c', - 'power_amd_pstate_cpufreq.c', 'power_common.c', - 'power_cppc_cpufreq.c', - 'power_kvm_vm.c', 'power_intel_uncore.c', - 'power_pstate_cpufreq.c', 'rte_power.c', 'rte_power_uncore.c', 'rte_power_pmd_mgmt.c', ) headers = files( 'rte_power.h', + 'rte_power_cpufreq_api.h', 'rte_power_guest_channel.h', 'rte_power_pmd_mgmt.h', 'rte_power_uncore.h',
lib/power/power_common.c +1 -1
@@ -12,7 +12,7 @@#include "power_common.h" -RTE_LOG_REGISTER_DEFAULT (power_logtype,INFO ); +RTE_LOG_REGISTER_DEFAULT (rte_power_logtype,INFO );#define POWER_SYSFILE_SCALING_DRIVER \ "/sys/devices/system/cpu/cpu%u/cpufreq/scaling_driver"
lib/power/power_common.h +14 -2
@@ -6,12 +6,13 @@#define _POWER_COMMON_H_#include <rte_common.h> +#include <rte_compat.h> #include <rte_log.h> #define RTE_POWER_INVALID_FREQ_INDEX (~0) -extern int power_logtype; -#define RTE_LOGTYPE_POWER power_logtype +extern int rte_power_logtype; +#define RTE_LOGTYPE_POWER rte_power_logtype#define POWER_LOG (level, ...) \ RTE_LOG_LINE(level, POWER, "" __VA_ARGS__)
@@ -23,13 +24,24 @@ extern int power_logtype;#endif /* check if scaling driver matches one we want */ +__rte_internal int cpufreq_check_scaling_driver(const char *driver); + +__rte_internal int power_set_governor(unsigned int lcore_id, const char *new_governor,char *orig_governor,size_t orig_governor_len); + +__rte_internal int open_core_sysfs_file(FILE **f, const char *mode, const char *format, ...) __rte_format_printf(3, 4); + +__rte_internal int read_core_sysfs_u32(FILE *f, uint32_t *val); + +__rte_internal int read_core_sysfs_s(FILE *f, char *buf, unsigned int len); + +__rte_internal int write_core_sysfs_s(FILE *f, const char *str);#endif /* _POWER_COMMON_H_ */
lib/power/rte_power.c +96 -191
345 lines not on this page · raw message
lib/power/rte_power.h +94 -47
236 lines not on this page · raw message
lib/power/rte_power_cpufreq_api.h new file +209 -0
209 lines not on this page · raw message
lib/power/version.map +14 -0
@@ -51,4 +51,18 @@ EXPERIMENTAL { rte_power_set_uncore_env; rte_power_uncore_freqs; rte_power_unset_uncore_env; + # added in 24.11 + rte_power_logtype; +}; + +INTERNAL { + global: + + rte_power_register_ops; + cpufreq_check_scaling_driver; + power_set_governor; + open_core_sysfs_file; + read_core_sysfs_u32; + read_core_sysfs_s; + write_core_sysfs_s; };
Signature · 1 line
2.34.1
PATCH v5 2/5 power: refactor uncore power management library
In reply to Sivaprasad TummalaThis patch refactors the power management library, addressing uncore power management. The primary changes involve the creation of dedicated directories for each driver within 'drivers/power/uncore/*'. The adjustment of meson.build files enables the selective activation of individual drivers.
This refactor significantly improves code organization, enhances clarity and boosts maintainability. It lays the foundation for more focused development on individual drivers and facilitates seamless integration of future enhancements, particularly the AMD uncore driver.
v5:
- fixed build errors for risc-v/ppc targets
v4:
- fixed build error with RTE_ASSERT
v3:
- fixed typo in header file inclusion
--- .../power/intel_uncore/intel_uncore.c | 18 +- .../power/intel_uncore/intel_uncore.h | 8 +- drivers/power/intel_uncore/meson.build | 6 + drivers/power/meson.build | 3 +- lib/power/meson.build | 2 +- lib/power/rte_power_uncore.c | 207 ++++++--------- lib/power/rte_power_uncore.h | 87 ++++--- lib/power/rte_power_uncore_ops.h | 241 ++++++++++++++++++ lib/power/version.map | 3 + 9 files changed, 410 insertions(+), 165 deletions(-) rename lib/power/power_intel_uncore.c => drivers/power/intel_uncore/intel_uncore.c (95%) rename lib/power/power_intel_uncore.h => drivers/power/intel_uncore/intel_uncore.h (97%) create mode 100644 drivers/power/intel_uncore/meson.build create mode 100644 lib/power/rte_power_uncore_ops.h
drivers/power/intel_uncore/intel_uncore.c renamed from lib/power/power_intel_uncore.c +17 -1
@@ -8,7 +8,7 @@#include <rte_memcpy.h> -#include "power_intel_uncore.h" +#include "intel_uncore.h" #include "power_common.h" #define MAX_NUMA_DIE 8
@@ -475,3 +475,19 @@ power_intel_uncore_get_num_dies(unsigned int pkg)return count; } + +static struct rte_power_uncore_ops intel_uncore_ops = { + .name ="intel-uncore" , + .init = power_intel_uncore_init, + .exit = power_intel_uncore_exit, + .get_avail_freqs = power_intel_uncore_freqs, + .get_num_pkgs = power_intel_uncore_get_num_pkgs, + .get_num_dies = power_intel_uncore_get_num_dies, + .get_num_freqs = power_intel_uncore_get_num_freqs, + .get_freq = power_get_intel_uncore_freq, + .set_freq = power_set_intel_uncore_freq, + .freq_max = power_intel_uncore_freq_max, + .freq_min = power_intel_uncore_freq_min, +}; + +RTE_POWER_REGISTER_UNCORE_OPS (intel_uncore_ops);
drivers/power/intel_uncore/intel_uncore.h renamed from lib/power/power_intel_uncore.h +4 -4
@@ -2,8 +2,8 @@* Copyright(c) 2022 Intel Corporation */ -#ifndef POWER_INTEL_UNCORE_H -#define POWER_INTEL_UNCORE_H +#ifndef INTEL_UNCORE_H +#define INTEL_UNCORE_H /** * @file
@@ -11,7 +11,7 @@*/ #include "rte_power.h" -#include "rte_power_uncore.h" +#include "rte_power_uncore_ops.h" #ifdef __cplusplusextern "C" {
@@ -223,4 +223,4 @@ power_intel_uncore_get_num_dies(unsigned int pkg); }#endif -#endif /* POWER_INTEL_UNCORE_H */ +#endif /* INTEL_UNCORE_H */
drivers/power/intel_uncore/meson.build new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2017 Intel Corporation +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +sources = files('intel_uncore.c') +deps += ['power']
drivers/power/meson.build +2 -1
@@ -6,7 +6,8 @@ drivers = [ 'amd_pstate', 'cppc', 'kvm_vm', - 'pstate' + 'pstate', + 'intel_uncore' ] std_deps = ['power']
lib/power/meson.build +1 -1
@@ -13,7 +13,6 @@ if not is_linux endif sources = files( 'power_common.c', - 'power_intel_uncore.c', 'rte_power.c', 'rte_power_uncore.c', 'rte_power_pmd_mgmt.c',
@@ -24,6 +23,7 @@ headers = files( 'rte_power_guest_channel.h', 'rte_power_pmd_mgmt.h', 'rte_power_uncore.h', + 'rte_power_uncore_ops.h', ) if cc.has_argument('-Wno-cast-qual') cflags += '-Wno-cast-qual'
lib/power/rte_power_uncore.c +83 -124
269 lines not on this page · raw message
lib/power/rte_power_uncore.h +53 -34
153 lines not on this page · raw message
lib/power/rte_power_uncore_ops.h new file +241 -0
241 lines not on this page · raw message
lib/power/version.map +3 -0
@@ -59,6 +59,9 @@ INTERNAL { global: rte_power_register_ops; + rte_power_register_uncore_ops; + rte_power_get_core_ops; + rte_power_get_uncore_ops; cpufreq_check_scaling_driver; power_set_governor; open_core_sysfs_file;
Signature · 1 line
2.34.1
PATCH v5 3/5 test/power: removed function pointer validations
In reply to Sivaprasad TummalaAfter refactoring the power library, power management operations are now consistently supported regardless of the operating environment, making function pointer checks unnecessary and thus removed from applications.
v2:
- removed function pointer validation in l3fwd-power app.
--- app/test/test_power.c | 95 ----------------------------------- app/test/test_power_cpufreq.c | 52 ------------------- app/test/test_power_kvm_vm.c | 36 ------------- examples/l3fwd-power/main.c | 12 ++--- 4 files changed, 4 insertions(+), 191 deletions(-)
app/test/test_power.c +0 -95
@@ -24,86 +24,6 @@ test_power(void)#include <rte_power.h> -static int -check_function_ptrs (void ) -{ -enum power_management_env env =rte_power_get_env (); - -const bool not_null_expected = !(env ==PM_ENV_NOT_SET ); - -const char *inject_not_string1 = not_null_expected ?" not" :"" ; -const char *inject_not_string2 = not_null_expected ?"" :" not" ; - -if ((rte_power_freqs ==NULL ) == not_null_expected) { -printf ("rte_power_freqs should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_get_freq ==NULL ) == not_null_expected) { -printf ("rte_power_get_freq should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_set_freq ==NULL ) == not_null_expected) { -printf ("rte_power_set_freq should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_freq_up ==NULL ) == not_null_expected) { -printf ("rte_power_freq_up should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_freq_down ==NULL ) == not_null_expected) { -printf ("rte_power_freq_down should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_freq_max ==NULL ) == not_null_expected) { -printf ("rte_power_freq_max should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_freq_min ==NULL ) == not_null_expected) { -printf ("rte_power_freq_min should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_turbo_status ==NULL ) == not_null_expected) { -printf ("rte_power_turbo_status should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_freq_enable_turbo ==NULL ) == not_null_expected) { -printf ("rte_power_freq_enable_turbo should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_freq_disable_turbo ==NULL ) == not_null_expected) { -printf ("rte_power_freq_disable_turbo should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_get_capabilities ==NULL ) == not_null_expected) { -printf ("rte_power_get_capabilities should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } - -return 0 ; -} -static int test_power (void ) {
@@ -124,10 +44,6 @@ test_power(void)return -1 ; } -/* Verify that function pointers are NULL */ -if (check_function_ptrs () <0 ) - goto fail_all; -rte_power_unset_env ();/* Perform tests for valid environments.*/
@@ -154,22 +70,11 @@ test_power(void) return -1; } -/* Verify that function pointers are NOT NULL */ -if (check_function_ptrs () <0 ) - goto fail_all; -rte_power_unset_env (); -/* Verify that function pointers are NULL */ -if (check_function_ptrs () <0 ) - goto fail_all; - }return 0 ; -fail_all: -rte_power_unset_env (); -return -1 ; }#endif
app/test/test_power_cpufreq.c +0 -52
58 lines not on this page · raw message
app/test/test_power_kvm_vm.c +0 -36
@@ -47,42 +47,6 @@ test_power_kvm_vm(void)return -1 ; } -/* verify that function pointers are not NULL */ -if (rte_power_freqs ==NULL ) { -printf ("rte_power_freqs should not be NULL, environment has not been " -"initialised\n" ); -return -1 ; - } -if (rte_power_get_freq ==NULL ) { -printf ("rte_power_get_freq should not be NULL, environment has not " -"been initialised\n" ); -return -1 ; - } -if (rte_power_set_freq ==NULL ) { -printf ("rte_power_set_freq should not be NULL, environment has not " -"been initialised\n" ); -return -1 ; - } -if (rte_power_freq_up ==NULL ) { -printf ("rte_power_freq_up should not be NULL, environment has not " -"been initialised\n" ); -return -1 ; - } -if (rte_power_freq_down ==NULL ) { -printf ("rte_power_freq_down should not be NULL, environment has not " -"been initialised\n" ); -return -1 ; - } -if (rte_power_freq_max ==NULL ) { -printf ("rte_power_freq_max should not be NULL, environment has not " -"been initialised\n" ); -return -1 ; - } -if (rte_power_freq_min ==NULL ) { -printf ("rte_power_freq_min should not be NULL, environment has not " -"been initialised\n" ); -return -1 ; - }/* Test initialisation of an out of bounds lcore */ ret =rte_power_init (TEST_POWER_VM_LCORE_OUT_OF_BOUNDS );if (ret !=-1 ) {
examples/l3fwd-power/main.c +4 -8
@@ -440,8 +440,7 @@ power_timer_cb(__rte_unused struct rte_timer *tim,* check whether need to scale down frequency a step if it sleep a lot. */ if (sleep_time_ratio >=SCALING_DOWN_TIME_RATIO_THRESHOLD ) { -if (rte_power_freq_down) -rte_power_freq_down (lcore_id); +rte_power_freq_down (lcore_id); }else if ( (unsigned )(stats[lcore_id].nb_rx_processed / stats[lcore_id].nb_iteration_looped) <MAX_PKT_BURST ) {
@@ -449,8 +448,7 @@ power_timer_cb(__rte_unused struct rte_timer *tim,* scale down a step if average packet per iteration less * than expectation. */ -if (rte_power_freq_down) -rte_power_freq_down (lcore_id); +rte_power_freq_down (lcore_id); }/**
@@ -1344,11 +1342,9 @@ main_legacy_loop(__rte_unused void *dummy) }if (lcore_scaleup_hint ==FREQ_HIGHEST ) { -if (rte_power_freq_max) -rte_power_freq_max (lcore_id); +rte_power_freq_max (lcore_id); }else if (lcore_scaleup_hint ==FREQ_HIGHER ) { -if (rte_power_freq_up) -rte_power_freq_up (lcore_id); +rte_power_freq_up (lcore_id); } }else {/**
Signature · 1 line
2.34.1
PATCH v5 4/5 drivers/power: uncore support for AMD EPYC processors
In reply to Sivaprasad TummalaThis patch introduces driver support for power management of uncore components in AMD EPYC processors.
v2:
- fixed typo in comments section.
- added fabric frequency get support for legacy platforms.
--- drivers/power/amd_uncore/amd_uncore.c | 329 ++++++++++++++++++++++++++ drivers/power/amd_uncore/amd_uncore.h | 226 ++++++++++++++++++ drivers/power/amd_uncore/meson.build | 20 ++ drivers/power/meson.build | 1 + 4 files changed, 576 insertions(+) create mode 100644 drivers/power/amd_uncore/amd_uncore.c create mode 100644 drivers/power/amd_uncore/amd_uncore.h create mode 100644 drivers/power/amd_uncore/meson.build
drivers/power/amd_uncore/amd_uncore.c new file +329 -0
@@ -0,0 +1,329 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2024 Advanced Micro Devices, Inc. +*/ + +#include <errno.h> +#include <dirent.h> +#include <fnmatch.h> + +#include <rte_memcpy.h> + +#include "amd_uncore.h" +#include "power_common.h" +#include "e_smi/e_smi.h" + +#define MAX_NUMA_DIE 8 + +struct __rte_cache_aligned uncore_power_info { +unsigned int die;/* Core die id */ +unsigned int pkg;/* Package id */ +uint32_t freqs[RTE_MAX_UNCORE_FREQS ];/* Frequency array */ +uint32_t nb_freqs;/* Number of available freqs */ +uint32_t curr_idx;/* Freq index in freqs array */ +uint32_t max_freq;/* System max uncore freq */ +uint32_t min_freq;/* System min uncore freq */ +}; + +static struct uncore_power_info uncore_info[RTE_MAX_NUMA_NODES ][MAX_NUMA_DIE ]; +static int esmi_initialized; +static unsigned int hsmp_proto_ver; + +static int +set_uncore_freq_internal (struct uncore_power_info *ui,uint32_t idx) +{ +int ret; + +if (idx >=RTE_MAX_UNCORE_FREQS || idx >= ui->nb_freqs) { +POWER_LOG (DEBUG ,"Invalid uncore frequency index %u, which " +"should be less than %u" , idx, ui->nb_freqs); +return -1 ; + } + + ret =esmi_apb_disable (ui->pkg, idx); +if (ret !=ESMI_SUCCESS ) { +POWER_LOG (ERR ,"DF P-state '%u' set failed for pkg %02u" , + idx, ui->pkg); +return -1 ; + } + +POWER_DEBUG_LOG ("DF P-state '%u' to be set for pkg %02u die %02u" , + idx, ui->pkg, ui->die); + +/* write the minimum value first if the target freq is less than current max */ + ui->curr_idx = idx; + +return 0 ; +} + +static int +power_init_for_setting_uncore_freq (struct uncore_power_info *ui) +{ +switch (hsmp_proto_ver) { +case HSMP_PROTO_VER5 : + ui->max_freq =1800000 ;/* Hz */ + ui->min_freq =1200000 ;/* Hz */ +break ; +case HSMP_PROTO_VER2 : +default : + ui->max_freq =1600000 ;/* Hz */ + ui->min_freq =1200000 ;/* Hz */ + } + +return 0 ; +} + +/* +* Get the available uncore frequencies of the specific die. +*/ +static int +power_get_available_uncore_freqs (struct uncore_power_info *ui) +{ + ui->nb_freqs =3 ; +if (ui->nb_freqs >=RTE_MAX_UNCORE_FREQS ) { +POWER_LOG (ERR ,"Too many available uncore frequencies: %d" , + ui->nb_freqs); +return -1 ; + } + +/* Generate the uncore freq bucket array. */ +switch (hsmp_proto_ver) { +case HSMP_PROTO_VER5 : + ui->freqs[0 ] =1800000 ; + ui->freqs[1 ] =1440000 ; + ui->freqs[2 ] =1200000 ; +break ; +case HSMP_PROTO_VER2 : +default : + ui->freqs[0 ] =1600000 ; + ui->freqs[1 ] =1333000 ; + ui->freqs[2 ] =1200000 ; + } + +POWER_DEBUG_LOG ("%d frequency(s) of pkg %02u die %02u are available" , + ui->num_uncore_freqs, ui->pkg, ui->die); + +return 0 ; +} + +static int +check_pkg_die_values (unsigned int pkg,unsigned int die) +{ +unsigned int max_pkgs, max_dies; + max_pkgs =power_amd_uncore_get_num_pkgs (); +if (max_pkgs ==0 ) +return -1 ; +if (pkg >= max_pkgs) { +POWER_LOG (DEBUG ,"Package number %02u can not exceed %u" , + pkg, max_pkgs); +return -1 ; + } + + max_dies =power_amd_uncore_get_num_dies (pkg); +if (max_dies ==0 ) +return -1 ; +if (die >= max_dies) { +POWER_LOG (DEBUG ,"Die number %02u can not exceed %u" , + die, max_dies); +return -1 ; + } + +return 0 ; +} + +static void +power_amd_uncore_esmi_init (void ) +{ +if (esmi_init () ==ESMI_SUCCESS ) { +if (esmi_hsmp_proto_ver_get (&hsmp_proto_ver) == +ESMI_SUCCESS ) + esmi_initialized =1 ; + } +} + +int +power_amd_uncore_init (unsigned int pkg,unsigned int die) +{ +struct uncore_power_info *ui; +int ret; + +if (!esmi_initialized) { + ret =esmi_init (); +if (ret !=ESMI_SUCCESS ) { +POWER_LOG (DEBUG ,"ESMI Not initialized, drivers not found" ); +return -1 ; + } + ret =esmi_hsmp_proto_ver_get (&hsmp_proto_ver); +if (ret !=ESMI_SUCCESS ) { +POWER_LOG (DEBUG ,"HSMP Proto Version Get failed with " +"error %s" ,esmi_get_err_msg (ret)); +esmi_exit (); +return -1 ; + } + esmi_initialized =1 ; + } + + ret =check_pkg_die_values (pkg, die); +if (ret <0 ) +return -1 ; + + ui = &uncore_info[pkg][die]; + ui->die = die; + ui->pkg = pkg; + +/* Init for setting uncore die frequency */ +if (power_init_for_setting_uncore_freq (ui) <0 ) { +POWER_LOG (DEBUG ,"Cannot init for setting uncore frequency for " +"pkg %02u die %02u" , pkg, die); +return -1 ; + } + +/* Get the available frequencies */ +if (power_get_available_uncore_freqs (ui) <0 ) { +POWER_LOG (DEBUG ,"Cannot get available uncore frequencies of " +"pkg %02u die %02u" , pkg, die); +return -1 ; + } + +return 0 ; +} + +int +power_amd_uncore_exit (unsigned int pkg,unsigned int die) +{ +struct uncore_power_info *ui; + +int ret =check_pkg_die_values (pkg, die); +if (ret <0 ) +return -1 ; + + ui = &uncore_info[pkg][die]; + ui->nb_freqs =0 ; + +if (esmi_initialized) { +esmi_exit (); + esmi_initialized =0 ; + } + +return 0 ; +} + +uint32_t +power_get_amd_uncore_freq (unsigned int pkg,unsigned int die) +{ +int ret =check_pkg_die_values (pkg, die); +if (ret <0 ) +return -1 ; + +return uncore_info[pkg][die].curr_idx; +} + +int +power_set_amd_uncore_freq (unsigned int pkg,unsigned int die,uint32_t index) +{ +int ret =check_pkg_die_values (pkg, die); +if (ret <0 ) +return -1 ; + +return set_uncore_freq_internal (&(uncore_info[pkg][die]), index); +} + +int +power_amd_uncore_freq_max (unsigned int pkg,unsigned int die) +{ +int ret =check_pkg_die_values (pkg, die); +if (ret <0 ) +return -1 ; + +return set_uncore_freq_internal (&(uncore_info[pkg][die]),0 ); +} + + +int +power_amd_uncore_freq_min (unsigned int pkg,unsigned int die) +{ +int ret =check_pkg_die_values (pkg, die); +if (ret <0 ) +return -1 ; + +struct uncore_power_info *ui = &uncore_info[pkg][die]; + +return set_uncore_freq_internal (&(uncore_info[pkg][die]), ui->nb_freqs -1 ); +} + +int +power_amd_uncore_freqs (unsigned int pkg,unsigned int die,uint32_t *freqs,uint32_t num) +{ +struct uncore_power_info *ui; + +int ret =check_pkg_die_values (pkg, die); +if (ret <0 ) +return -1 ; + +if (freqs ==NULL ) { +POWER_LOG (ERR ,"NULL buffer supplied" ); +return 0 ; + } + + ui = &uncore_info[pkg][die]; +if (num < ui->nb_freqs) { +POWER_LOG (ERR ,"Buffer size is not enough" ); +return 0 ; + } +rte_memcpy (freqs, ui->freqs, ui->nb_freqs *sizeof (uint32_t )); + +return ui->nb_freqs; +} + +int +power_amd_uncore_get_num_freqs (unsigned int pkg,unsigned int die) +{ +int ret =check_pkg_die_values (pkg, die); +if (ret <0 ) +return -1 ; + +return uncore_info[pkg][die].nb_freqs; +} + +unsigned int +power_amd_uncore_get_num_pkgs (void ) +{ +uint32_t num_pkgs =0 ; +int ret; + +if (esmi_initialized) { + ret =esmi_number_of_sockets_get (&num_pkgs); +if (ret !=ESMI_SUCCESS ) { +POWER_LOG (ERR ,"Failed to get number of sockets" ); + num_pkgs =0 ; + } + } +return num_pkgs; +} + +unsigned int +power_amd_uncore_get_num_dies (unsigned int pkg) +{ +if (pkg >=power_amd_uncore_get_num_pkgs ()) { +POWER_LOG (ERR ,"Invalid package ID" ); +return 0 ; + } + +return 1 ; +} + +static struct rte_power_uncore_ops amd_uncore_ops = { + .name ="amd-hsmp" , + .cb = power_amd_uncore_esmi_init, + .init = power_amd_uncore_init, + .exit = power_amd_uncore_exit, + .get_avail_freqs = power_amd_uncore_freqs, + .get_num_pkgs = power_amd_uncore_get_num_pkgs, + .get_num_dies = power_amd_uncore_get_num_dies, + .get_num_freqs = power_amd_uncore_get_num_freqs, + .get_freq = power_get_amd_uncore_freq, + .set_freq = power_set_amd_uncore_freq, + .freq_max = power_amd_uncore_freq_max, + .freq_min = power_amd_uncore_freq_min, +}; + +RTE_POWER_REGISTER_UNCORE_OPS (amd_uncore_ops);
drivers/power/amd_uncore/amd_uncore.h new file +226 -0
226 lines not on this page · raw message
drivers/power/amd_uncore/meson.build new file +20 -0
@@ -0,0 +1,20 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' + subdir_done() +endif + +ESMI_header = '#include<e_smi/e_smi.h>' +lib = cc.find_library('e_smi64', required: false) +if not lib.found() + build = false + reason = 'missing dependency, "libe_smi"' +else + ext_deps += lib +endif + +sources = files('amd_uncore.c') +deps += ['power']
drivers/power/meson.build +1 -0
@@ -7,6 +7,7 @@ drivers = [ 'cppc', 'kvm_vm', 'pstate', + 'amd_uncore', 'intel_uncore' ]
Signature · 1 line
2.34.1
PATCH v5 5/5 maintainers: update for drivers/power
In reply to Sivaprasad TummalaUpdate maintainers for drivers/power/*.
--- MAINTAINERS | 1 + 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
@@ -1744,6 +1744,7 @@ M: Anatoly Burakov <[email protected]> M: David Hunt <[email protected]> M: Sivaprasad Tummala <[email protected]> F: lib/power/ +F: drivers/power/* F: doc/guides/prog_guide/power_man.rst F: app/test/test_power* F: examples/l3fwd-power/
Signature · 1 line
2.34.1
v5 cover power: refactor power management library
In reply to Sivaprasad TummalaThis patchset refactors the power management library, addressing both core and uncore power management. The primary changes involve the creation of dedicated directories for each driver within 'drivers/power/core/*' and 'drivers/power/uncore/*'.
This refactor significantly improves code organization, enhances clarity, and boosts maintainability. It lays the foundation for more focused development on individual drivers and facilitates seamless integration of future enhancements, particularly the AMD uncore driver.
Furthermore, this effort aims to streamline code maintenance by consolidating common functions for cpufreq and cppc across various core drivers, thus reducing code duplication.
Sivaprasad Tummala (5):
power: refactor core power management library
power: refactor uncore power management library test/power: removed function pointer validations drivers/power: uncore support for AMD EPYC processors
maintainers: update for drivers/power
MAINTAINERS | 1 +
app/test/test_power.c | 95 -----
app/test/test_power_cpufreq.c | 52 ---
app/test/test_power_kvm_vm.c | 36 --
drivers/meson.build | 1 +
.../power/acpi/acpi_cpufreq.c | 22 +-
.../power/acpi/acpi_cpufreq.h | 6 +-
drivers/power/acpi/meson.build | 10 +
.../power/amd_pstate/amd_pstate_cpufreq.c | 24 +-
.../power/amd_pstate/amd_pstate_cpufreq.h | 8 +-
drivers/power/amd_pstate/meson.build | 10 +
drivers/power/amd_uncore/amd_uncore.c | 329 ++++++++++++++++++
drivers/power/amd_uncore/amd_uncore.h | 226 ++++++++++++
drivers/power/amd_uncore/meson.build | 20 ++
.../power/cppc/cppc_cpufreq.c | 22 +-
.../power/cppc/cppc_cpufreq.h | 8 +-
drivers/power/cppc/meson.build | 10 +
.../power/intel_uncore/intel_uncore.c | 18 +-
.../power/intel_uncore/intel_uncore.h | 8 +-
drivers/power/intel_uncore/meson.build | 6 +
.../power/kvm_vm}/guest_channel.c | 0
.../power/kvm_vm}/guest_channel.h | 0
.../power/kvm_vm/kvm_vm.c | 22 +-
.../power/kvm_vm/kvm_vm.h | 6 +-
drivers/power/kvm_vm/meson.build | 16 +
drivers/power/meson.build | 14 +
drivers/power/pstate/meson.build | 10 +
.../power/pstate/pstate_cpufreq.c | 22 +-
.../power/pstate/pstate_cpufreq.h | 6 +-
examples/l3fwd-power/main.c | 12 +-
lib/power/meson.build | 9 +-
lib/power/power_common.c | 2 +-
lib/power/power_common.h | 16 +-
lib/power/rte_power.c | 287 +++++----------
lib/power/rte_power.h | 141 +++++---
lib/power/rte_power_cpufreq_api.h | 209 +++++++++++
lib/power/rte_power_uncore.c | 207 +++++------
lib/power/rte_power_uncore.h | 87 +++--
lib/power/rte_power_uncore_ops.h | 241 +++++++++++++
lib/power/version.map | 17 +
40 files changed, 1611 insertions(+), 625 deletions(-)
rename lib/power/power_acpi_cpufreq.c => drivers/power/acpi/acpi_cpufreq.c (95%)
rename lib/power/power_acpi_cpufreq.h => drivers/power/acpi/acpi_cpufreq.h (98%)
create mode 100644 drivers/power/acpi/meson.build
rename lib/power/power_amd_pstate_cpufreq.c => drivers/power/amd_pstate/amd_pstate_cpufreq.c (95%)
rename lib/power/power_amd_pstate_cpufreq.h => drivers/power/amd_pstate/amd_pstate_cpufreq.h (97%)
create mode 100644 drivers/power/amd_pstate/meson.build
create mode 100644 drivers/power/amd_uncore/amd_uncore.c
create mode 100644 drivers/power/amd_uncore/amd_uncore.h
create mode 100644 drivers/power/amd_uncore/meson.build
rename lib/power/power_cppc_cpufreq.c => drivers/power/cppc/cppc_cpufreq.c (95%)
rename lib/power/power_cppc_cpufreq.h => drivers/power/cppc/cppc_cpufreq.h (97%)
create mode 100644 drivers/power/cppc/meson.build
rename lib/power/power_intel_uncore.c => drivers/power/intel_uncore/intel_uncore.c (95%)
rename lib/power/power_intel_uncore.h => drivers/power/intel_uncore/intel_uncore.h (97%)
create mode 100644 drivers/power/intel_uncore/meson.build
rename {lib/power => drivers/power/kvm_vm}/guest_channel.c (100%)
rename {lib/power => drivers/power/kvm_vm}/guest_channel.h (100%)
rename lib/power/power_kvm_vm.c => drivers/power/kvm_vm/kvm_vm.c (82%)
rename lib/power/power_kvm_vm.h => drivers/power/kvm_vm/kvm_vm.h (98%)
create mode 100644 drivers/power/kvm_vm/meson.build
create mode 100644 drivers/power/meson.build
create mode 100644 drivers/power/pstate/meson.build
rename lib/power/power_pstate_cpufreq.c => drivers/power/pstate/pstate_cpufreq.c (96%)
rename lib/power/power_pstate_cpufreq.h => drivers/power/pstate/pstate_cpufreq.h (98%)
create mode 100644 lib/power/rte_power_cpufreq_api.h
create mode 100644 lib/power/rte_power_uncore_ops.hSignature · 1 line
2.34.1
Quoted 5 lines · On Thu, 17 Oct 2024 10:26:44 +0000 Sivaprasad Tummala…
This patchset refactors the power management library, addressing both core and uncore power management. The primary changes involve the creation of dedicated directories for each driver within '
drivers/power/core/*' and 'drivers/power/uncore/*'.
Quoted 8 lines
This refactor significantly improves code organization, enhances clarity, and boosts maintainability. It lays the foundation for more focused development on individual drivers and facilitates seamless integration of future enhancements, particularly the AMD uncore driver.
Furthermore, this effort aims to streamline code maintenance by consolidating common functions for cpufreq and cppc across various core drivers, thus reducing code duplication.
Does not build.
*Build Failed #2:
OS: RHEL94-64
Target: x86_64-native-linuxapp-gcc
FAILED: examples/dpdk-distributor.p/distributor_main.c.o
gcc -Iexamples/dpdk-distributor.p -Iexamples -I../examples -Iexamples/distributor -I../examples/distributor -I../examples/common -I. -I.. -Iconfig -I../config -Ilib/eal/include -I../lib/eal/include -Ilib/eal/linux/include -I../lib/eal/linux/include -Ilib/eal/x86/include -I../lib/eal/x86/include -Ilib/eal/common -I../lib/eal/common -Ilib/eal -I../lib/eal -Ilib/kvargs -I../lib/kvargs -Ilib/log -I../lib/log -Ilib/metrics -I../lib/metrics -Ilib/telemetry -I../lib/telemetry -Ilib/mempool -I../lib/mempool -Ilib/ring -I../lib/ring -Ilib/net -I../lib/net -Ilib/mbuf -I../lib/mbuf -Ilib/ethdev -I../lib/ethdev -Ilib/meter -I../lib/meter -Ilib/cmdline -I../lib/cmdline -Ilib/distributor -I../lib/distributor -Ilib/power -I../lib/power -Ilib/timer -I../lib/timer -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Werror -std=c11 -O3 -include rte_config.h -Wcast-qual -Wdeprecated -Wformat -Wformat-nonliteral -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wpointer-arith -Wsign-compare -Wstrict-prototypes -Wundef -Wwrite-strings -Wno-address-of-packed-member -Wno-packed-not-aligned -Wno-missing-field-initializers -Wno-zero-length-bounds -D_GNU_SOURCE -march=native -mrtm -Wno-format-truncation -DALLOW_EXPERIMENTAL_API -MD -MQ examples/dpdk-distributor.p/distributor_main.c.o -MF examples/dpdk-distributor.p/distributor_main.c.o.d -o examples/dpdk-distributor.p/distributor_main.c.o -c ../examples/distributor/main.c In file included from ../examples/distributor/main.c:20:
In function ‘rte_power_get_capabilities’,
inlined from ‘main’ at ../examples/distributor/main.c:888:4:../lib/power/rte_power.h:285:42: error: call to ‘rte_power_get_core_ops’ declared with attribute error: Symbol is not public ABI
285 | struct rte_power_core_ops *ops = rte_power_get_core_ops();
| ^~~~~~~~~~~~~~~~~~~~~~~~[2962/3118] Compiling C object examples/dpdk-fips_validation.p/fips_validation_fips_validation_hmac.c.o [2963/3118] Compiling C object examples/dpdk-bbdev_app.p/bbdev_app_main.c.o [2964/3118] Compiling C object examples/dpdk-fips_validation.p/fips_validation_fips_validation_xts.c.o [2965/3118] Compiling C object examples/dpdk-fips_validation.p/fips_validation_fips_validation_sha.c.o [2966/3118] Linking target examples/dpdk-bond
[2967/3118] Compiling C object examples/dpdk-fips_validation.p/fips_validation_main.c.o [2968/3118] Compiling C object app/dpdk-test.p/test_test_ring_perf.c.o
[2969/3118] Compiling C object app/dpdk-test.p/test_test_trace_perf.c.o
[2970/3118] Compiling C object app/dpdk-test.p/test_test_ring.c.o
ninja: build stopped
v6 cover power: refactor power management library
In reply to Sivaprasad TummalaThis patchset refactors the power management library, addressing both core and uncore power management. The primary changes involve the creation of dedicated directories for each driver within 'drivers/power/core/*' and 'drivers/power/uncore/*'.
This refactor significantly improves code organization, enhances clarity, and boosts maintainability. It lays the foundation for more focused development on individual drivers and facilitates seamless integration of future enhancements, particularly the AMD uncore driver.
Furthermore, this effort aims to streamline code maintenance by consolidating common functions for cpufreq and cppc across various core drivers, thus reducing code duplication.
Sivaprasad Tummala (5):
power: refactor core power management library
power: refactor uncore power management library test/power: removed function pointer validations drivers/power: uncore support for AMD EPYC processors
maintainers: update for drivers/power
MAINTAINERS | 1 +
app/test/test_power.c | 95 -----
app/test/test_power_cpufreq.c | 52 ---
app/test/test_power_kvm_vm.c | 36 --
drivers/meson.build | 1 +
.../power/acpi/acpi_cpufreq.c | 22 +-
.../power/acpi/acpi_cpufreq.h | 6 +-
drivers/power/acpi/meson.build | 10 +
.../power/amd_pstate/amd_pstate_cpufreq.c | 24 +-
.../power/amd_pstate/amd_pstate_cpufreq.h | 10 +-
drivers/power/amd_pstate/meson.build | 10 +
drivers/power/amd_uncore/amd_uncore.c | 329 ++++++++++++++++
drivers/power/amd_uncore/amd_uncore.h | 226 +++++++++++
drivers/power/amd_uncore/meson.build | 20 +
.../power/cppc/cppc_cpufreq.c | 22 +-
.../power/cppc/cppc_cpufreq.h | 8 +-
drivers/power/cppc/meson.build | 10 +
.../power/intel_uncore/intel_uncore.c | 18 +-
.../power/intel_uncore/intel_uncore.h | 8 +-
drivers/power/intel_uncore/meson.build | 6 +
.../power/kvm_vm}/guest_channel.c | 0
.../power/kvm_vm}/guest_channel.h | 0
.../power/kvm_vm/kvm_vm.c | 22 +-
.../power/kvm_vm/kvm_vm.h | 6 +-
drivers/power/kvm_vm/meson.build | 14 +
drivers/power/meson.build | 14 +
drivers/power/pstate/meson.build | 10 +
.../power/pstate/pstate_cpufreq.c | 22 +-
.../power/pstate/pstate_cpufreq.h | 6 +-
examples/l3fwd-power/main.c | 12 +-
lib/power/meson.build | 9 +-
lib/power/power_common.c | 2 +-
lib/power/power_common.h | 18 +-
lib/power/rte_power.c | 355 ++++++++----------
lib/power/rte_power.h | 116 +++---
lib/power/rte_power_cpufreq_api.h | 206 ++++++++++
lib/power/rte_power_uncore.c | 253 +++++++------
lib/power/rte_power_uncore.h | 61 ++-
lib/power/rte_power_uncore_ops.h | 230 ++++++++++++
lib/power/version.map | 16 +
40 files changed, 1664 insertions(+), 622 deletions(-)
rename lib/power/power_acpi_cpufreq.c => drivers/power/acpi/acpi_cpufreq.c (95%)
rename lib/power/power_acpi_cpufreq.h => drivers/power/acpi/acpi_cpufreq.h (98%)
create mode 100644 drivers/power/acpi/meson.build
rename lib/power/power_amd_pstate_cpufreq.c => drivers/power/amd_pstate/amd_pstate_cpufreq.c (95%)
rename lib/power/power_amd_pstate_cpufreq.h => drivers/power/amd_pstate/amd_pstate_cpufreq.h (96%)
create mode 100644 drivers/power/amd_pstate/meson.build
create mode 100644 drivers/power/amd_uncore/amd_uncore.c
create mode 100644 drivers/power/amd_uncore/amd_uncore.h
create mode 100644 drivers/power/amd_uncore/meson.build
rename lib/power/power_cppc_cpufreq.c => drivers/power/cppc/cppc_cpufreq.c (95%)
rename lib/power/power_cppc_cpufreq.h => drivers/power/cppc/cppc_cpufreq.h (97%)
create mode 100644 drivers/power/cppc/meson.build
rename lib/power/power_intel_uncore.c => drivers/power/intel_uncore/intel_uncore.c (95%)
rename lib/power/power_intel_uncore.h => drivers/power/intel_uncore/intel_uncore.h (97%)
create mode 100644 drivers/power/intel_uncore/meson.build
rename {lib/power => drivers/power/kvm_vm}/guest_channel.c (100%)
rename {lib/power => drivers/power/kvm_vm}/guest_channel.h (100%)
rename lib/power/power_kvm_vm.c => drivers/power/kvm_vm/kvm_vm.c (82%)
rename lib/power/power_kvm_vm.h => drivers/power/kvm_vm/kvm_vm.h (98%)
create mode 100644 drivers/power/kvm_vm/meson.build
create mode 100644 drivers/power/meson.build
create mode 100644 drivers/power/pstate/meson.build
rename lib/power/power_pstate_cpufreq.c => drivers/power/pstate/pstate_cpufreq.c (96%)
rename lib/power/power_pstate_cpufreq.h => drivers/power/pstate/pstate_cpufreq.h (98%)
create mode 100644 lib/power/rte_power_cpufreq_api.h
create mode 100644 lib/power/rte_power_uncore_ops.hSignature · 1 line
2.34.1
PATCH v6 1/5 power: refactor core power management library
This patch introduces a comprehensive refactor to the core power management library. The primary focus is on improving modularity and organization by relocating specific driver implementations from the 'lib/power' directory to dedicated directories within 'drivers/power/core/*'. The adjustment of meson.build files enables the selective activation of individual drivers.
These changes contribute to a significant enhancement in code organization, providing a clearer structure for driver implementations. The refactor aims to improve overall code clarity and boost maintainability. Additionally, it establishes a foundation for future development, allowing for more focused work on individual drivers and seamless integration of forthcoming enhancements.
v6:
- fixed compilation error with symbol export in API
- exported power_get_lcore_mapped_cpu_id as internal API to be used in drivers/power/*
v5:
- fixed code style warning
v4:
- fixed build error with RTE_ASSERT
v3:
- renamed rte_power_core_ops.h as rte_power_cpufreq_api.h
- re-worked on auto detection logic
v2:
- added NULL check for global_core_ops in rte_power_get_core_ops
---
drivers/meson.build | 1 +
.../power/acpi/acpi_cpufreq.c | 22 +-
.../power/acpi/acpi_cpufreq.h | 6 +-
drivers/power/acpi/meson.build | 10 +
.../power/amd_pstate/amd_pstate_cpufreq.c | 24 +-
.../power/amd_pstate/amd_pstate_cpufreq.h | 10 +-
drivers/power/amd_pstate/meson.build | 10 +
.../power/cppc/cppc_cpufreq.c | 22 +-
.../power/cppc/cppc_cpufreq.h | 8 +-
drivers/power/cppc/meson.build | 10 +
.../power/kvm_vm}/guest_channel.c | 0
.../power/kvm_vm}/guest_channel.h | 0
.../power/kvm_vm/kvm_vm.c | 22 +-
.../power/kvm_vm/kvm_vm.h | 6 +-
drivers/power/kvm_vm/meson.build | 14 +
drivers/power/meson.build | 12 +
drivers/power/pstate/meson.build | 10 +
.../power/pstate/pstate_cpufreq.c | 22 +-
.../power/pstate/pstate_cpufreq.h | 6 +-
lib/power/meson.build | 7 +-
lib/power/power_common.c | 2 +-
lib/power/power_common.h | 18 +-
lib/power/rte_power.c | 355 ++++++++----------
lib/power/rte_power.h | 116 +++---
lib/power/rte_power_cpufreq_api.h | 206 ++++++++++
lib/power/version.map | 15 +
26 files changed, 665 insertions(+), 269 deletions(-)
rename lib/power/power_acpi_cpufreq.c => drivers/power/acpi/acpi_cpufreq.c (95%)
rename lib/power/power_acpi_cpufreq.h => drivers/power/acpi/acpi_cpufreq.h (98%)
create mode 100644 drivers/power/acpi/meson.build
rename lib/power/power_amd_pstate_cpufreq.c => drivers/power/amd_pstate/amd_pstate_cpufreq.c (95%)
rename lib/power/power_amd_pstate_cpufreq.h => drivers/power/amd_pstate/amd_pstate_cpufreq.h (96%)
create mode 100644 drivers/power/amd_pstate/meson.build
rename lib/power/power_cppc_cpufreq.c => drivers/power/cppc/cppc_cpufreq.c (95%)
rename lib/power/power_cppc_cpufreq.h => drivers/power/cppc/cppc_cpufreq.h (97%)
create mode 100644 drivers/power/cppc/meson.build
rename {lib/power => drivers/power/kvm_vm}/guest_channel.c (100%)
rename {lib/power => drivers/power/kvm_vm}/guest_channel.h (100%)
rename lib/power/power_kvm_vm.c => drivers/power/kvm_vm/kvm_vm.c (82%)
rename lib/power/power_kvm_vm.h => drivers/power/kvm_vm/kvm_vm.h (98%)
create mode 100644 drivers/power/kvm_vm/meson.build
create mode 100644 drivers/power/meson.build
create mode 100644 drivers/power/pstate/meson.build
rename lib/power/power_pstate_cpufreq.c => drivers/power/pstate/pstate_cpufreq.c (96%)
rename lib/power/power_pstate_cpufreq.h => drivers/power/pstate/pstate_cpufreq.h (98%)
create mode 100644 lib/power/rte_power_cpufreq_api.hdrivers/meson.build +1 -0
@@ -29,6 +29,7 @@ subdirs = [ 'event', # depends on common, bus, mempool and net. 'baseband', # depends on common and bus. 'gpu', # depends on common and bus. + 'power', # depends on common (in future). ] if meson.is_cross_build()
drivers/power/acpi/acpi_cpufreq.c renamed from lib/power/power_acpi_cpufreq.c +21 -1
@@ -10,7 +10,7 @@#include <rte_stdatomic.h> #include <rte_string_fns.h> -#include "power_acpi_cpufreq.h" +#include "acpi_cpufreq.h" #include "power_common.h" #define STR_SIZE 1024
@@ -587,3 +587,23 @@ int power_acpi_get_capabilities(unsigned int lcore_id,return 0 ; } + +static struct rte_power_core_ops acpi_ops = { + .name ="acpi" , + .init = power_acpi_cpufreq_init, + .exit = power_acpi_cpufreq_exit, + .check_env_support = power_acpi_cpufreq_check_supported, + .get_avail_freqs = power_acpi_cpufreq_freqs, + .get_freq = power_acpi_cpufreq_get_freq, + .set_freq = power_acpi_cpufreq_set_freq, + .freq_down = power_acpi_cpufreq_freq_down, + .freq_up = power_acpi_cpufreq_freq_up, + .freq_max = power_acpi_cpufreq_freq_max, + .freq_min = power_acpi_cpufreq_freq_min, + .turbo_status = power_acpi_turbo_status, + .enable_turbo = power_acpi_enable_turbo, + .disable_turbo = power_acpi_disable_turbo, + .get_caps = power_acpi_get_capabilities +}; + +RTE_POWER_REGISTER_OPS (acpi_ops);
drivers/power/acpi/acpi_cpufreq.h renamed from lib/power/power_acpi_cpufreq.h +3 -3
@@ -2,15 +2,15 @@* Copyright(c) 2010-2014 Intel Corporation */ -#ifndef _POWER_ACPI_CPUFREQ_H -#define _POWER_ACPI_CPUFREQ_H +#ifndef _ACPI_CPUFREQ_H +#define _ACPI_CPUFREQ_H/** * @file * RTE Power Management via userspace ACPI cpufreq */ -#include "rte_power.h" +#include "rte_power_cpufreq_api.h" /** * Check if ACPI power management is supported.
drivers/power/acpi/meson.build new file +10 -0
@@ -0,0 +1,10 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' +endif +sources = files('acpi_cpufreq.c') + +deps += ['power']
drivers/power/amd_pstate/amd_pstate_cpufreq.c renamed from lib/power/power_amd_pstate_cpufreq.c +22 -2
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2010-2021 Intel Corporation * Copyright(c) 2021 Arm Limited -* Copyright(c) 2023 Amd Limited +* Copyright(c) 2024 Advanced Micro Devices, Inc. */ #include <stdlib.h>
@@ -9,7 +9,7 @@#include <rte_memcpy.h> #include <rte_stdatomic.h> -#include "power_amd_pstate_cpufreq.h" +#include "amd_pstate_cpufreq.h" #include "power_common.h" /* macros used for rounding frequency to nearest 1000 */
@@ -710,3 +710,23 @@ power_amd_pstate_get_capabilities(unsigned int lcore_id,return 0 ; } + +static struct rte_power_core_ops amd_pstate_ops = { + .name ="amd-pstate" , + .init = power_amd_pstate_cpufreq_init, + .exit = power_amd_pstate_cpufreq_exit, + .check_env_support = power_amd_pstate_cpufreq_check_supported, + .get_avail_freqs = power_amd_pstate_cpufreq_freqs, + .get_freq = power_amd_pstate_cpufreq_get_freq, + .set_freq = power_amd_pstate_cpufreq_set_freq, + .freq_down = power_amd_pstate_cpufreq_freq_down, + .freq_up = power_amd_pstate_cpufreq_freq_up, + .freq_max = power_amd_pstate_cpufreq_freq_max, + .freq_min = power_amd_pstate_cpufreq_freq_min, + .turbo_status = power_amd_pstate_turbo_status, + .enable_turbo = power_amd_pstate_enable_turbo, + .disable_turbo = power_amd_pstate_disable_turbo, + .get_caps = power_amd_pstate_get_capabilities +}; + +RTE_POWER_REGISTER_OPS (amd_pstate_ops);
drivers/power/amd_pstate/amd_pstate_cpufreq.h renamed from lib/power/power_amd_pstate_cpufreq.h +5 -5
@@ -1,18 +1,18 @@/* SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2010-2021 Intel Corporation * Copyright(c) 2021 Arm Limited -* Copyright(c) 2023 Amd Limited +* Copyright(c) 2024 Advanced Micro Devices, Inc. */ -#ifndef _POWER_AMD_PSTATE_CPUFREQ_H -#define _POWER_AMD_PSTATE_CPUFREQ_H +#ifndef _AMD_PSTATE_CPUFREQ_H +#define _AMD_PSTATE_CPUFREQ_H/** * @file * RTE Power Management via userspace AMD pstate cpufreq */ -#include "rte_power.h" +#include "rte_power_cpufreq_api.h" /** * Check if amd p-state power management is supported.
@@ -216,4 +216,4 @@ int power_amd_pstate_disable_turbo(unsigned int lcore_id);int power_amd_pstate_get_capabilities (unsigned int lcore_id,struct rte_power_core_capabilities *caps); -#endif /* _POWER_AMD_PSTATET_CPUFREQ_H */ +#endif /* _AMD_PSTATET_CPUFREQ_H */
drivers/power/amd_pstate/meson.build new file +10 -0
@@ -0,0 +1,10 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' +endif +sources = files('amd_pstate_cpufreq.c') + +deps += ['power']
drivers/power/cppc/cppc_cpufreq.c renamed from lib/power/power_cppc_cpufreq.c +21 -1
@@ -8,7 +8,7 @@#include <rte_memcpy.h> #include <rte_stdatomic.h> -#include "power_cppc_cpufreq.h" +#include "cppc_cpufreq.h" #include "power_common.h" /* macros used for rounding frequency to nearest 100000 */
@@ -695,3 +695,23 @@ power_cppc_get_capabilities(unsigned int lcore_id,return 0 ; } + +static struct rte_power_core_ops cppc_ops = { + .name ="cppc" , + .init = power_cppc_cpufreq_init, + .exit = power_cppc_cpufreq_exit, + .check_env_support = power_cppc_cpufreq_check_supported, + .get_avail_freqs = power_cppc_cpufreq_freqs, + .get_freq = power_cppc_cpufreq_get_freq, + .set_freq = power_cppc_cpufreq_set_freq, + .freq_down = power_cppc_cpufreq_freq_down, + .freq_up = power_cppc_cpufreq_freq_up, + .freq_max = power_cppc_cpufreq_freq_max, + .freq_min = power_cppc_cpufreq_freq_min, + .turbo_status = power_cppc_turbo_status, + .enable_turbo = power_cppc_enable_turbo, + .disable_turbo = power_cppc_disable_turbo, + .get_caps = power_cppc_get_capabilities +}; + +RTE_POWER_REGISTER_OPS (cppc_ops);
drivers/power/cppc/cppc_cpufreq.h renamed from lib/power/power_cppc_cpufreq.h +4 -4
@@ -3,15 +3,15 @@* Copyright(c) 2021 Arm Limited */ -#ifndef _POWER_CPPC_CPUFREQ_H -#define _POWER_CPPC_CPUFREQ_H +#ifndef _CPPC_CPUFREQ_H +#define _CPPC_CPUFREQ_H/** * @file * RTE Power Management via userspace CPPC cpufreq */ -#include "rte_power.h" +#include "rte_power_cpufreq_api.h" /** * Check if CPPC power management is supported.
@@ -215,4 +215,4 @@ int power_cppc_disable_turbo(unsigned int lcore_id);int power_cppc_get_capabilities (unsigned int lcore_id,struct rte_power_core_capabilities *caps); -#endif /* _POWER_CPPC_CPUFREQ_H */ +#endif /* _CPPC_CPUFREQ_H */
drivers/power/cppc/meson.build new file +10 -0
@@ -0,0 +1,10 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' +endif +sources = files('cppc_cpufreq.c') + +deps += ['power']
drivers/power/kvm_vm/guest_channel.c renamed from lib/power/guest_channel.c +0 -0
drivers/power/kvm_vm/guest_channel.h renamed from lib/power/guest_channel.h +0 -0
drivers/power/kvm_vm/kvm_vm.c renamed from lib/power/power_kvm_vm.c +21 -1
@@ -9,7 +9,7 @@#include "rte_power_guest_channel.h" #include "guest_channel.h" #include "power_common.h" -#include "power_kvm_vm.h" +#include "kvm_vm.h" #define FD_PATH "/dev/virtio-ports/virtio.serial.port.poweragent"
@@ -137,3 +137,23 @@ int power_kvm_vm_get_capabilities(__rte_unused unsigned int lcore_id,POWER_LOG (ERR ,"rte_power_get_capabilities is not implemented for Virtual Machine Power Management" );return -ENOTSUP ; } + +static struct rte_power_core_ops kvm_vm_ops = { + .name ="kvm-vm" , + .init = power_kvm_vm_init, + .exit = power_kvm_vm_exit, + .check_env_support = power_kvm_vm_check_supported, + .get_avail_freqs = power_kvm_vm_freqs, + .get_freq = power_kvm_vm_get_freq, + .set_freq = power_kvm_vm_set_freq, + .freq_down = power_kvm_vm_freq_down, + .freq_up = power_kvm_vm_freq_up, + .freq_max = power_kvm_vm_freq_max, + .freq_min = power_kvm_vm_freq_min, + .turbo_status = power_kvm_vm_turbo_status, + .enable_turbo = power_kvm_vm_enable_turbo, + .disable_turbo = power_kvm_vm_disable_turbo, + .get_caps = power_kvm_vm_get_capabilities +}; + +RTE_POWER_REGISTER_OPS (kvm_vm_ops);
drivers/power/kvm_vm/kvm_vm.h renamed from lib/power/power_kvm_vm.h +3 -3
@@ -2,15 +2,15 @@* Copyright(c) 2010-2014 Intel Corporation */ -#ifndef _POWER_KVM_VM_H -#define _POWER_KVM_VM_H +#ifndef _KVM_VM_H +#define _KVM_VM_H/** * @file * RTE Power Management KVM VM */ -#include "rte_power.h" +#include "rte_power_cpufreq_api.h" /** * Check if KVM power management is supported.
drivers/power/kvm_vm/meson.build new file +14 -0
@@ -0,0 +1,14 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' + subdir_done() +endif +sources = files( + 'guest_channel.c', + 'kvm_vm.c', +) + +deps += ['power']
drivers/power/meson.build new file +12 -0
@@ -0,0 +1,12 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +drivers = [ + 'acpi', + 'amd_pstate', + 'cppc', + 'kvm_vm', + 'pstate' +] + +std_deps = ['power']
drivers/power/pstate/meson.build new file +10 -0
@@ -0,0 +1,10 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' +endif +sources = files('pstate_cpufreq.c') + +deps += ['power']
drivers/power/pstate/pstate_cpufreq.c renamed from lib/power/power_pstate_cpufreq.c +21 -1
@@ -15,7 +15,7 @@#include <rte_stdatomic.h> #include "rte_power_pmd_mgmt.h" -#include "power_pstate_cpufreq.h" +#include "pstate_cpufreq.h" #include "power_common.h" /* macros used for rounding frequency to nearest 100000 */
@@ -898,3 +898,23 @@ int power_pstate_get_capabilities(unsigned int lcore_id,return 0 ; } + +static struct rte_power_core_ops pstate_ops = { + .name ="pstate" , + .init = power_pstate_cpufreq_init, + .exit = power_pstate_cpufreq_exit, + .check_env_support = power_pstate_cpufreq_check_supported, + .get_avail_freqs = power_pstate_cpufreq_freqs, + .get_freq = power_pstate_cpufreq_get_freq, + .set_freq = power_pstate_cpufreq_set_freq, + .freq_down = power_pstate_cpufreq_freq_down, + .freq_up = power_pstate_cpufreq_freq_up, + .freq_max = power_pstate_cpufreq_freq_max, + .freq_min = power_pstate_cpufreq_freq_min, + .turbo_status = power_pstate_turbo_status, + .enable_turbo = power_pstate_enable_turbo, + .disable_turbo = power_pstate_disable_turbo, + .get_caps = power_pstate_get_capabilities +}; + +RTE_POWER_REGISTER_OPS (pstate_ops);
drivers/power/pstate/pstate_cpufreq.h renamed from lib/power/power_pstate_cpufreq.h +3 -3
@@ -2,15 +2,15 @@* Copyright(c) 2018 Intel Corporation */ -#ifndef _POWER_PSTATE_CPUFREQ_H -#define _POWER_PSTATE_CPUFREQ_H +#ifndef _PSTATE_CPUFREQ_H +#define _PSTATE_CPUFREQ_H/** * @file * RTE Power Management via Intel Pstate driver */ -#include "rte_power.h" +#include "rte_power_cpufreq_api.h" /** * Check if pstate power management is supported.
lib/power/meson.build +1 -6
@@ -12,20 +12,15 @@ if not is_linux reason = 'only supported on Linux' endif sources = files( - 'guest_channel.c', - 'power_acpi_cpufreq.c', - 'power_amd_pstate_cpufreq.c', 'power_common.c', - 'power_cppc_cpufreq.c', - 'power_kvm_vm.c', 'power_intel_uncore.c', - 'power_pstate_cpufreq.c', 'rte_power.c', 'rte_power_uncore.c', 'rte_power_pmd_mgmt.c', ) headers = files( 'rte_power.h', + 'rte_power_cpufreq_api.h', 'rte_power_guest_channel.h', 'rte_power_pmd_mgmt.h', 'rte_power_uncore.h',
lib/power/power_common.c +1 -1
@@ -13,7 +13,7 @@#include "power_common.h" -RTE_LOG_REGISTER_DEFAULT (power_logtype,INFO ); +RTE_LOG_REGISTER_DEFAULT (rte_power_logtype,INFO );#define POWER_SYSFILE_SCALING_DRIVER \ "/sys/devices/system/cpu/cpu%u/cpufreq/scaling_driver"
lib/power/power_common.h +16 -2
@@ -6,12 +6,13 @@#define _POWER_COMMON_H_#include <rte_common.h> +#include <rte_compat.h> #include <rte_log.h> #define RTE_POWER_INVALID_FREQ_INDEX (~0) -extern int power_logtype; -#define RTE_LOGTYPE_POWER power_logtype +extern int rte_power_logtype; +#define RTE_LOGTYPE_POWER rte_power_logtype#define POWER_LOG (level, ...) \ RTE_LOG_LINE(level, POWER, "" __VA_ARGS__)
@@ -23,14 +24,27 @@ extern int power_logtype;#endif /* check if scaling driver matches one we want */ +__rte_internal int cpufreq_check_scaling_driver(const char *driver); + +__rte_internal int power_set_governor(unsigned int lcore_id, const char *new_governor,char *orig_governor,size_t orig_governor_len); + +__rte_internal int open_core_sysfs_file(FILE **f, const char *mode, const char *format, ...) __rte_format_printf(3, 4); + +__rte_internal int read_core_sysfs_u32(FILE *f, uint32_t *val); + +__rte_internal int read_core_sysfs_s(FILE *f, char *buf, unsigned int len); + +__rte_internal int write_core_sysfs_s(FILE *f, const char *str); + +__rte_internal int power_get_lcore_mapped_cpu_id(uint32_t lcore_id, uint32_t *cpu_id);#endif /* _POWER_COMMON_H_ */
lib/power/rte_power.c +164 -191
408 lines not on this page · raw message
lib/power/rte_power.h +71 -45
199 lines not on this page · raw message
lib/power/rte_power_cpufreq_api.h new file +206 -0
206 lines not on this page · raw message
lib/power/version.map +15 -0
@@ -51,4 +51,19 @@ EXPERIMENTAL { rte_power_set_uncore_env; rte_power_uncore_freqs; rte_power_unset_uncore_env; + # added in 24.11 + rte_power_logtype; +}; + +INTERNAL { + global: + + rte_power_register_ops; + cpufreq_check_scaling_driver; + power_get_lcore_mapped_cpu_id; + power_set_governor; + open_core_sysfs_file; + read_core_sysfs_u32; + read_core_sysfs_s; + write_core_sysfs_s; };
Signature · 1 line
2.34.1
PATCH v6 2/5 power: refactor uncore power management library
In reply to Sivaprasad TummalaiThis patch refactors the power management library, addressing uncore power management. The primary changes involve the creation of dedicated directories for each driver within 'drivers/power/uncore/*'. The adjustment of meson.build files enables the selective activation of individual drivers.
This refactor significantly improves code organization, enhances clarity and boosts maintainability. It lays the foundation for more focused development on individual drivers and facilitates seamless integration of future enhancements, particularly the AMD uncore driver.
v6:
- fixed compilation error with symbol export in API
v5:
- fixed build errors for risc-v/ppc targets
v4:
- fixed build error with RTE_ASSERT
v3:
- fixed typo in header file inclusion
--- .../power/intel_uncore/intel_uncore.c | 18 +- .../power/intel_uncore/intel_uncore.h | 8 +- drivers/power/intel_uncore/meson.build | 6 + drivers/power/meson.build | 3 +- lib/power/meson.build | 2 +- lib/power/rte_power_uncore.c | 253 +++++++++--------- lib/power/rte_power_uncore.h | 61 ++--- lib/power/rte_power_uncore_ops.h | 230 ++++++++++++++++ lib/power/version.map | 1 + 9 files changed, 419 insertions(+), 163 deletions(-) rename lib/power/power_intel_uncore.c => drivers/power/intel_uncore/intel_uncore.c (95%) rename lib/power/power_intel_uncore.h => drivers/power/intel_uncore/intel_uncore.h (97%) create mode 100644 drivers/power/intel_uncore/meson.build create mode 100644 lib/power/rte_power_uncore_ops.h
drivers/power/intel_uncore/intel_uncore.c renamed from lib/power/power_intel_uncore.c +17 -1
@@ -8,7 +8,7 @@#include <rte_memcpy.h> -#include "power_intel_uncore.h" +#include "intel_uncore.h" #include "power_common.h" #define MAX_NUMA_DIE 8
@@ -475,3 +475,19 @@ power_intel_uncore_get_num_dies(unsigned int pkg)return count; } + +static struct rte_power_uncore_ops intel_uncore_ops = { + .name ="intel-uncore" , + .init = power_intel_uncore_init, + .exit = power_intel_uncore_exit, + .get_avail_freqs = power_intel_uncore_freqs, + .get_num_pkgs = power_intel_uncore_get_num_pkgs, + .get_num_dies = power_intel_uncore_get_num_dies, + .get_num_freqs = power_intel_uncore_get_num_freqs, + .get_freq = power_get_intel_uncore_freq, + .set_freq = power_set_intel_uncore_freq, + .freq_max = power_intel_uncore_freq_max, + .freq_min = power_intel_uncore_freq_min, +}; + +RTE_POWER_REGISTER_UNCORE_OPS (intel_uncore_ops);
drivers/power/intel_uncore/intel_uncore.h renamed from lib/power/power_intel_uncore.h +4 -4
@@ -2,8 +2,8 @@* Copyright(c) 2022 Intel Corporation */ -#ifndef POWER_INTEL_UNCORE_H -#define POWER_INTEL_UNCORE_H +#ifndef _INTEL_UNCORE_H +#define _INTEL_UNCORE_H/** * @file
@@ -11,7 +11,7 @@*/ #include "rte_power.h" -#include "rte_power_uncore.h" +#include "rte_power_uncore_ops.h" #ifdef __cplusplusextern "C" {
@@ -223,4 +223,4 @@ power_intel_uncore_get_num_dies(unsigned int pkg); }#endif -#endif /* POWER_INTEL_UNCORE_H */ +#endif /* _INTEL_UNCORE_H */
drivers/power/intel_uncore/meson.build new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2017 Intel Corporation +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +sources = files('intel_uncore.c') +deps += ['power']
drivers/power/meson.build +2 -1
@@ -6,7 +6,8 @@ drivers = [ 'amd_pstate', 'cppc', 'kvm_vm', - 'pstate' + 'pstate', + 'intel_uncore' ] std_deps = ['power']
lib/power/meson.build +1 -1
@@ -13,7 +13,6 @@ if not is_linux endif sources = files( 'power_common.c', - 'power_intel_uncore.c', 'rte_power.c', 'rte_power_uncore.c', 'rte_power_pmd_mgmt.c',
@@ -24,6 +23,7 @@ headers = files( 'rte_power_guest_channel.h', 'rte_power_pmd_mgmt.h', 'rte_power_uncore.h', + 'rte_power_uncore_ops.h', ) deps += ['timer', 'ethdev']
lib/power/rte_power_uncore.c +130 -123
308 lines not on this page · raw message
lib/power/rte_power_uncore.h +28 -33
125 lines not on this page · raw message
lib/power/rte_power_uncore_ops.h new file +230 -0
230 lines not on this page · raw message
lib/power/version.map +1 -0
@@ -59,6 +59,7 @@ INTERNAL { global: rte_power_register_ops; + rte_power_register_uncore_ops; cpufreq_check_scaling_driver; power_get_lcore_mapped_cpu_id; power_set_governor;
Signature · 1 line
2.34.1
Re: [PATCH v6 2/5] power: refactor uncore power management library
Quoted 8 lines · On Sun, 20 Oct 2024 09:22:29 +0000 Sivaprasad Tummala…
lib/power/rte_power_uncore.c +0
-0@@ -10,100 +10,53 @@#include "power_common.h" #include "rte_power_uncore.h"
lib/power/rte_power_uncore.c line 20
Quoted 10 lines
lib/power/rte_power_uncore.c +4
-2-#include "power_intel_uncore.h" -enum rte_uncore_power_mgmt_env default_uncore_env =RTE_UNCORE_PM_ENV_NOT_SET ; +static enum rte_uncore_power_mgmt_env global_uncore_env =RTE_UNCORE_PM_ENV_NOT_SET ; +static struct rte_power_uncore_ops *global_uncore_ops;static rte_spinlock_t global_env_cfg_lock =RTE_SPINLOCK_INITIALIZER ; +static RTE_TAILQ_HEAD(, rte_power_uncore_ops) uncore_ops_list = +TAILQ_HEAD_INITIALIZER (uncore_ops_list);
Need to include rte_debug.h now?
_github build: failed_
Build URL: https://github.com/ovsrobot/dpdk/actions/runs/11425299483
Build Logs:
-----------------------Summary of failed steps----------------------- "ubuntu-22.04-gcc-ppc64le" failed at step Build and test "ubuntu-22.04-gcc-riscv64" failed at step Build and test ----------------------End summary of failed steps--------------------
-------------------------------BEGIN LOGS----------------------------
####################################################################################
#### [Begin job log] "ubuntu-22.04-gcc-ppc64le" at step Build and test
####################################################################################
[325/3576] Generating symbol file lib/librte_latencystats.so.25.0.p/librte_latencystats.so.25.0.symbols
[326/3576] Generating symbol file lib/librte_jobstats.so.25.0.p/librte_jobstats.so.25.0.symbols
[327/3576] Compiling C object lib/librte_member.a.p/member_rte_member_ht.c.o
[328/3576] Generating symbol file lib/librte_ip_frag.so.25.0.p/librte_ip_frag.so.25.0.symbols
[329/3576] Compiling C object drivers/libtmp_rte_bus_platform.a.p/bus_platform_platform_params.c.o
[330/3576] Compiling C object lib/librte_member.a.p/member_rte_member_vbf.c.o
[331/3576] Compiling C object lib/librte_power.a.p/power_power_common.c.o
[332/3576] Compiling C object lib/librte_power.a.p/power_rte_power.c.o
[333/3576] Compiling C object lib/librte_power.a.p/power_rte_power_uncore.c.o
FAILED: lib/librte_power.a.p/power_rte_power_uncore.c.o
ccache powerpc64le-linux-gnu-gcc -Ilib/librte_power.a.p -Ilib -I../lib -Ilib/power -I../lib/power -I. -I.. -Iconfig -I../config -Ilib/eal/include -I../lib/eal/include -Ilib/eal/linux/include -I../lib/eal/linux/include -Ilib/eal/ppc/include -I../lib/eal/ppc/include -Ilib/eal/common -I../lib/eal/common -Ilib/eal -I../lib/eal -Ilib/kvargs -I../lib/kvargs -Ilib/log -I../lib/log -Ilib/metrics -I../lib/metrics -Ilib/telemetry -I../lib/telemetry -Ilib/timer -I../lib/timer -Ilib/ethdev -I../lib/ethdev -Ilib/net -I../lib/net -Ilib/mbuf -I../lib/mbuf -Ilib/mempool -I../lib/mempool -Ilib/ring -I../lib/ring -Ilib/meter -I../lib/meter -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Werror -std=c11 -O2 -g -include rte_config.h -Wcast-qual -Wdeprecated -Wformat -Wformat-nonliteral -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wpointer-arith -Wsign-compare -Wstrict-prototypes -Wundef -Wwrite-strings -Wno-address-of-packed-member -Wno-packed-not-aligned -Wno-missing-field-initializers -Wno-psabi -D_GNU_SOURCE -fPIC -mcpu=power8 -mtune=power8 -DALLOW_EXPERIMENTAL_API -DALLOW_INTERNAL_API -Wno-format-truncation -DRTE_LOG_DEFAULT_LOGTYPE=lib.power -MD -MQ lib/librte_power.a.p/power_rte_power_uncore.c.o -MF lib/librte_power.a.p/power_rte_power_uncore.c.o.d -o lib/librte_power.a.p/power_rte_power_uncore.c.o -c ../lib/power/rte_power_uncore.c ../lib/power/rte_power_uncore.c: In function ‘rte_power_get_uncore_freq’:../lib/power/rte_power_uncore.c:149:9: error: implicit declaration of function ‘RTE_ASSERT’; did you mean ‘RTE_STR’? [-Werror=implicit-function-declaration]
149 | RTE_ASSERT(global_uncore_ops != NULL);
| ^~~~~~~~~~
| RTE_STR../lib/power/rte_power_uncore.c:149:9: error: nested extern declaration of ‘RTE_ASSERT’ [-Werror=nested-externs]
cc1: all warnings being treated as errors
[334/3576] Compiling C object lib/librte_member.a.p/member_rte_member_sketch.c.o
[335/3576] Generating lpm.sym_chk with a custom command (wrapped by meson to capture output) [336/3576] Compiling C object lib/librte_pcapng.a.p/pcapng_rte_pcapng.c.o
[337/3576] Compiling C object lib/librte_power.a.p/power_rte_power_pmd_mgmt.c.o
[338/3576] Generating eventdev.sym_chk with a custom command (wrapped by meson to capture output)
ninja: build stopped: subcommand failed.
##[error]Process completed with exit code 1.
####################################################################################
#### [End job log] "ubuntu-22.04-gcc-ppc64le" at step Build and test
####################################################################################
Re: [PATCH v6 2/5] power: refactor uncore power management library
In reply to Sivaprasad Tummalalib/power/rte_power_uncore.c rte_power_uncore_init(unsigned int pkg, unsigned int die) · line 149
Quoted 4 lines · On Sun, 20 Oct 2024 09:22:29 +0000 Sivaprasad Tummala…
lib/power/rte_power_uncore.c +4
-0+uint32_t +rte_power_get_uncore_freq (unsigned int pkg,unsigned int die) +{ +RTE_ASSERT (global_uncore_ops !=NULL );
All these RTE_ASSERT calls seem like a good idea, they really don't help. If RTE_ASSERT fails it prints a message and calls abort.
If you skip the RTE_ASSERT, the next line will cause a NULL dereference illegal pointer reference and crash.
So in either case it crashes, and the RTE_ASSERT() doesn't add much help.
Also RTE_ENABLE_ASSERT() is usually disabled.
PATCH v6 3/5 test/power: removed function pointer validations
In reply to Sivaprasad TummalaAfter refactoring the power library, power management operations are now consistently supported regardless of the operating environment, making function pointer checks unnecessary and thus removed from applications.
v2:
- removed function pointer validation in l3fwd-power app.
--- app/test/test_power.c | 95 ----------------------------------- app/test/test_power_cpufreq.c | 52 ------------------- app/test/test_power_kvm_vm.c | 36 ------------- examples/l3fwd-power/main.c | 12 ++--- 4 files changed, 4 insertions(+), 191 deletions(-)
app/test/test_power.c +0 -95
@@ -24,86 +24,6 @@ test_power(void)#include <rte_power.h> -static int -check_function_ptrs (void ) -{ -enum power_management_env env =rte_power_get_env (); - -const bool not_null_expected = !(env ==PM_ENV_NOT_SET ); - -const char *inject_not_string1 = not_null_expected ?" not" :"" ; -const char *inject_not_string2 = not_null_expected ?"" :" not" ; - -if ((rte_power_freqs ==NULL ) == not_null_expected) { -printf ("rte_power_freqs should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_get_freq ==NULL ) == not_null_expected) { -printf ("rte_power_get_freq should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_set_freq ==NULL ) == not_null_expected) { -printf ("rte_power_set_freq should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_freq_up ==NULL ) == not_null_expected) { -printf ("rte_power_freq_up should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_freq_down ==NULL ) == not_null_expected) { -printf ("rte_power_freq_down should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_freq_max ==NULL ) == not_null_expected) { -printf ("rte_power_freq_max should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_freq_min ==NULL ) == not_null_expected) { -printf ("rte_power_freq_min should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_turbo_status ==NULL ) == not_null_expected) { -printf ("rte_power_turbo_status should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_freq_enable_turbo ==NULL ) == not_null_expected) { -printf ("rte_power_freq_enable_turbo should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_freq_disable_turbo ==NULL ) == not_null_expected) { -printf ("rte_power_freq_disable_turbo should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_get_capabilities ==NULL ) == not_null_expected) { -printf ("rte_power_get_capabilities should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } - -return 0 ; -} -static int test_power (void ) {
@@ -124,10 +44,6 @@ test_power(void)return -1 ; } -/* Verify that function pointers are NULL */ -if (check_function_ptrs () <0 ) - goto fail_all; -rte_power_unset_env ();/* Perform tests for valid environments.*/
@@ -154,22 +70,11 @@ test_power(void) return -1; } -/* Verify that function pointers are NOT NULL */ -if (check_function_ptrs () <0 ) - goto fail_all; -rte_power_unset_env (); -/* Verify that function pointers are NULL */ -if (check_function_ptrs () <0 ) - goto fail_all; - }return 0 ; -fail_all: -rte_power_unset_env (); -return -1 ; }#endif
app/test/test_power_cpufreq.c +0 -52
58 lines not on this page · raw message
app/test/test_power_kvm_vm.c +0 -36
@@ -47,42 +47,6 @@ test_power_kvm_vm(void)return -1 ; } -/* verify that function pointers are not NULL */ -if (rte_power_freqs ==NULL ) { -printf ("rte_power_freqs should not be NULL, environment has not been " -"initialised\n" ); -return -1 ; - } -if (rte_power_get_freq ==NULL ) { -printf ("rte_power_get_freq should not be NULL, environment has not " -"been initialised\n" ); -return -1 ; - } -if (rte_power_set_freq ==NULL ) { -printf ("rte_power_set_freq should not be NULL, environment has not " -"been initialised\n" ); -return -1 ; - } -if (rte_power_freq_up ==NULL ) { -printf ("rte_power_freq_up should not be NULL, environment has not " -"been initialised\n" ); -return -1 ; - } -if (rte_power_freq_down ==NULL ) { -printf ("rte_power_freq_down should not be NULL, environment has not " -"been initialised\n" ); -return -1 ; - } -if (rte_power_freq_max ==NULL ) { -printf ("rte_power_freq_max should not be NULL, environment has not " -"been initialised\n" ); -return -1 ; - } -if (rte_power_freq_min ==NULL ) { -printf ("rte_power_freq_min should not be NULL, environment has not " -"been initialised\n" ); -return -1 ; - }/* Test initialisation of an out of bounds lcore */ ret =rte_power_init (TEST_POWER_VM_LCORE_OUT_OF_BOUNDS );if (ret !=-1 ) {
examples/l3fwd-power/main.c +4 -8
@@ -440,8 +440,7 @@ power_timer_cb(__rte_unused struct rte_timer *tim,* check whether need to scale down frequency a step if it sleep a lot. */ if (sleep_time_ratio >=SCALING_DOWN_TIME_RATIO_THRESHOLD ) { -if (rte_power_freq_down) -rte_power_freq_down (lcore_id); +rte_power_freq_down (lcore_id); }else if ( (unsigned )(stats[lcore_id].nb_rx_processed / stats[lcore_id].nb_iteration_looped) <MAX_PKT_BURST ) {
@@ -449,8 +448,7 @@ power_timer_cb(__rte_unused struct rte_timer *tim,* scale down a step if average packet per iteration less * than expectation. */ -if (rte_power_freq_down) -rte_power_freq_down (lcore_id); +rte_power_freq_down (lcore_id); }/**
@@ -1344,11 +1342,9 @@ main_legacy_loop(__rte_unused void *dummy) }if (lcore_scaleup_hint ==FREQ_HIGHEST ) { -if (rte_power_freq_max) -rte_power_freq_max (lcore_id); +rte_power_freq_max (lcore_id); }else if (lcore_scaleup_hint ==FREQ_HIGHER ) { -if (rte_power_freq_up) -rte_power_freq_up (lcore_id); +rte_power_freq_up (lcore_id); } }else {/**
Signature · 1 line
2.34.1
PATCH v6 4/5 drivers/power: uncore support for AMD EPYC processors
In reply to Sivaprasad TummalaThis patch introduces driver support for power management of uncore components in AMD EPYC processors.
v2:
- fixed typo in comments section.
- added fabric frequency get support for legacy platforms.
--- drivers/power/amd_uncore/amd_uncore.c | 329 ++++++++++++++++++++++++++ drivers/power/amd_uncore/amd_uncore.h | 226 ++++++++++++++++++ drivers/power/amd_uncore/meson.build | 20 ++ drivers/power/meson.build | 1 + 4 files changed, 576 insertions(+) create mode 100644 drivers/power/amd_uncore/amd_uncore.c create mode 100644 drivers/power/amd_uncore/amd_uncore.h create mode 100644 drivers/power/amd_uncore/meson.build
drivers/power/amd_uncore/amd_uncore.c new file +329 -0
@@ -0,0 +1,329 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2024 Advanced Micro Devices, Inc. +*/ + +#include <errno.h> +#include <dirent.h> +#include <fnmatch.h> + +#include <rte_memcpy.h> + +#include "amd_uncore.h" +#include "power_common.h" +#include "e_smi/e_smi.h" + +#define MAX_NUMA_DIE 8 + +struct __rte_cache_aligned uncore_power_info { +unsigned int die;/* Core die id */ +unsigned int pkg;/* Package id */ +uint32_t freqs[RTE_MAX_UNCORE_FREQS ];/* Frequency array */ +uint32_t nb_freqs;/* Number of available freqs */ +uint32_t curr_idx;/* Freq index in freqs array */ +uint32_t max_freq;/* System max uncore freq */ +uint32_t min_freq;/* System min uncore freq */ +}; + +static struct uncore_power_info uncore_info[RTE_MAX_NUMA_NODES ][MAX_NUMA_DIE ]; +static int esmi_initialized; +static unsigned int hsmp_proto_ver; + +static int +set_uncore_freq_internal (struct uncore_power_info *ui,uint32_t idx) +{ +int ret; + +if (idx >=RTE_MAX_UNCORE_FREQS || idx >= ui->nb_freqs) { +POWER_LOG (DEBUG ,"Invalid uncore frequency index %u, which " +"should be less than %u" , idx, ui->nb_freqs); +return -1 ; + } + + ret =esmi_apb_disable (ui->pkg, idx); +if (ret !=ESMI_SUCCESS ) { +POWER_LOG (ERR ,"DF P-state '%u' set failed for pkg %02u" , + idx, ui->pkg); +return -1 ; + } + +POWER_DEBUG_LOG ("DF P-state '%u' to be set for pkg %02u die %02u" , + idx, ui->pkg, ui->die); + +/* write the minimum value first if the target freq is less than current max */ + ui->curr_idx = idx; + +return 0 ; +} + +static int +power_init_for_setting_uncore_freq (struct uncore_power_info *ui) +{ +switch (hsmp_proto_ver) { +case HSMP_PROTO_VER5 : + ui->max_freq =1800000 ;/* Hz */ + ui->min_freq =1200000 ;/* Hz */ +break ; +case HSMP_PROTO_VER2 : +default : + ui->max_freq =1600000 ;/* Hz */ + ui->min_freq =1200000 ;/* Hz */ + } + +return 0 ; +} + +/* +* Get the available uncore frequencies of the specific die. +*/ +static int +power_get_available_uncore_freqs (struct uncore_power_info *ui) +{ + ui->nb_freqs =3 ; +if (ui->nb_freqs >=RTE_MAX_UNCORE_FREQS ) { +POWER_LOG (ERR ,"Too many available uncore frequencies: %d" , + ui->nb_freqs); +return -1 ; + } + +/* Generate the uncore freq bucket array. */ +switch (hsmp_proto_ver) { +case HSMP_PROTO_VER5 : + ui->freqs[0 ] =1800000 ; + ui->freqs[1 ] =1440000 ; + ui->freqs[2 ] =1200000 ; +break ; +case HSMP_PROTO_VER2 : +default : + ui->freqs[0 ] =1600000 ; + ui->freqs[1 ] =1333000 ; + ui->freqs[2 ] =1200000 ; + } + +POWER_DEBUG_LOG ("%d frequency(s) of pkg %02u die %02u are available" , + ui->num_uncore_freqs, ui->pkg, ui->die); + +return 0 ; +} + +static int +check_pkg_die_values (unsigned int pkg,unsigned int die) +{ +unsigned int max_pkgs, max_dies; + max_pkgs =power_amd_uncore_get_num_pkgs (); +if (max_pkgs ==0 ) +return -1 ; +if (pkg >= max_pkgs) { +POWER_LOG (DEBUG ,"Package number %02u can not exceed %u" , + pkg, max_pkgs); +return -1 ; + } + + max_dies =power_amd_uncore_get_num_dies (pkg); +if (max_dies ==0 ) +return -1 ; +if (die >= max_dies) { +POWER_LOG (DEBUG ,"Die number %02u can not exceed %u" , + die, max_dies); +return -1 ; + } + +return 0 ; +} + +static void +power_amd_uncore_esmi_init (void ) +{ +if (esmi_init () ==ESMI_SUCCESS ) { +if (esmi_hsmp_proto_ver_get (&hsmp_proto_ver) == +ESMI_SUCCESS ) + esmi_initialized =1 ; + } +} + +int +power_amd_uncore_init (unsigned int pkg,unsigned int die) +{ +struct uncore_power_info *ui; +int ret; + +if (!esmi_initialized) { + ret =esmi_init (); +if (ret !=ESMI_SUCCESS ) { +POWER_LOG (DEBUG ,"ESMI Not initialized, drivers not found" ); +return -1 ; + } + ret =esmi_hsmp_proto_ver_get (&hsmp_proto_ver); +if (ret !=ESMI_SUCCESS ) { +POWER_LOG (DEBUG ,"HSMP Proto Version Get failed with " +"error %s" ,esmi_get_err_msg (ret)); +esmi_exit (); +return -1 ; + } + esmi_initialized =1 ; + } + + ret =check_pkg_die_values (pkg, die); +if (ret <0 ) +return -1 ; + + ui = &uncore_info[pkg][die]; + ui->die = die; + ui->pkg = pkg; + +/* Init for setting uncore die frequency */ +if (power_init_for_setting_uncore_freq (ui) <0 ) { +POWER_LOG (DEBUG ,"Cannot init for setting uncore frequency for " +"pkg %02u die %02u" , pkg, die); +return -1 ; + } + +/* Get the available frequencies */ +if (power_get_available_uncore_freqs (ui) <0 ) { +POWER_LOG (DEBUG ,"Cannot get available uncore frequencies of " +"pkg %02u die %02u" , pkg, die); +return -1 ; + } + +return 0 ; +} + +int +power_amd_uncore_exit (unsigned int pkg,unsigned int die) +{ +struct uncore_power_info *ui; + +int ret =check_pkg_die_values (pkg, die); +if (ret <0 ) +return -1 ; + + ui = &uncore_info[pkg][die]; + ui->nb_freqs =0 ; + +if (esmi_initialized) { +esmi_exit (); + esmi_initialized =0 ; + } + +return 0 ; +} + +uint32_t +power_get_amd_uncore_freq (unsigned int pkg,unsigned int die) +{ +int ret =check_pkg_die_values (pkg, die); +if (ret <0 ) +return -1 ; + +return uncore_info[pkg][die].curr_idx; +} + +int +power_set_amd_uncore_freq (unsigned int pkg,unsigned int die,uint32_t index) +{ +int ret =check_pkg_die_values (pkg, die); +if (ret <0 ) +return -1 ; + +return set_uncore_freq_internal (&(uncore_info[pkg][die]), index); +} + +int +power_amd_uncore_freq_max (unsigned int pkg,unsigned int die) +{ +int ret =check_pkg_die_values (pkg, die); +if (ret <0 ) +return -1 ; + +return set_uncore_freq_internal (&(uncore_info[pkg][die]),0 ); +} + + +int +power_amd_uncore_freq_min (unsigned int pkg,unsigned int die) +{ +int ret =check_pkg_die_values (pkg, die); +if (ret <0 ) +return -1 ; + +struct uncore_power_info *ui = &uncore_info[pkg][die]; + +return set_uncore_freq_internal (&(uncore_info[pkg][die]), ui->nb_freqs -1 ); +} + +int +power_amd_uncore_freqs (unsigned int pkg,unsigned int die,uint32_t *freqs,uint32_t num) +{ +struct uncore_power_info *ui; + +int ret =check_pkg_die_values (pkg, die); +if (ret <0 ) +return -1 ; + +if (freqs ==NULL ) { +POWER_LOG (ERR ,"NULL buffer supplied" ); +return 0 ; + } + + ui = &uncore_info[pkg][die]; +if (num < ui->nb_freqs) { +POWER_LOG (ERR ,"Buffer size is not enough" ); +return 0 ; + } +rte_memcpy (freqs, ui->freqs, ui->nb_freqs *sizeof (uint32_t )); + +return ui->nb_freqs; +} + +int +power_amd_uncore_get_num_freqs (unsigned int pkg,unsigned int die) +{ +int ret =check_pkg_die_values (pkg, die); +if (ret <0 ) +return -1 ; + +return uncore_info[pkg][die].nb_freqs; +} + +unsigned int +power_amd_uncore_get_num_pkgs (void ) +{ +uint32_t num_pkgs =0 ; +int ret; + +if (esmi_initialized) { + ret =esmi_number_of_sockets_get (&num_pkgs); +if (ret !=ESMI_SUCCESS ) { +POWER_LOG (ERR ,"Failed to get number of sockets" ); + num_pkgs =0 ; + } + } +return num_pkgs; +} + +unsigned int +power_amd_uncore_get_num_dies (unsigned int pkg) +{ +if (pkg >=power_amd_uncore_get_num_pkgs ()) { +POWER_LOG (ERR ,"Invalid package ID" ); +return 0 ; + } + +return 1 ; +} + +static struct rte_power_uncore_ops amd_uncore_ops = { + .name ="amd-hsmp" , + .cb = power_amd_uncore_esmi_init, + .init = power_amd_uncore_init, + .exit = power_amd_uncore_exit, + .get_avail_freqs = power_amd_uncore_freqs, + .get_num_pkgs = power_amd_uncore_get_num_pkgs, + .get_num_dies = power_amd_uncore_get_num_dies, + .get_num_freqs = power_amd_uncore_get_num_freqs, + .get_freq = power_get_amd_uncore_freq, + .set_freq = power_set_amd_uncore_freq, + .freq_max = power_amd_uncore_freq_max, + .freq_min = power_amd_uncore_freq_min, +}; + +RTE_POWER_REGISTER_UNCORE_OPS (amd_uncore_ops);
drivers/power/amd_uncore/amd_uncore.h new file +226 -0
226 lines not on this page · raw message
drivers/power/amd_uncore/meson.build new file +20 -0
@@ -0,0 +1,20 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' + subdir_done() +endif + +ESMI_header = '#include<e_smi/e_smi.h>' +lib = cc.find_library('e_smi64', required: false) +if not lib.found() + build = false + reason = 'missing dependency, "libe_smi"' +else + ext_deps += lib +endif + +sources = files('amd_uncore.c') +deps += ['power']
drivers/power/meson.build +1 -0
@@ -7,6 +7,7 @@ drivers = [ 'cppc', 'kvm_vm', 'pstate', + 'amd_uncore', 'intel_uncore' ]
Signature · 1 line
2.34.1
PATCH v6 5/5 maintainers: update for drivers/power
In reply to Sivaprasad TummalaUpdate maintainers for drivers/power/*.
--- MAINTAINERS | 1 + 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
@@ -1744,6 +1744,7 @@ M: Anatoly Burakov <[email protected]> M: David Hunt <[email protected]> M: Sivaprasad Tummala <[email protected]> F: lib/power/ +F: drivers/power/* F: doc/guides/prog_guide/power_man.rst F: app/test/test_power* F: examples/l3fwd-power/
Signature · 1 line
2.34.1
v6 cover power: refactor power management library
In reply to Sivaprasad TummalaThis patchset refactors the power management library, addressing both core and uncore power management. The primary changes involve the creation of dedicated directories for each driver within 'drivers/power/core/*' and 'drivers/power/uncore/*'.
This refactor significantly improves code organization, enhances clarity, and boosts maintainability. It lays the foundation for more focused development on individual drivers and facilitates seamless integration of future enhancements, particularly the AMD uncore driver.
Furthermore, this effort aims to streamline code maintenance by consolidating common functions for cpufreq and cppc across various core drivers, thus reducing code duplication.
Sivaprasad Tummala (5):
power: refactor core power management library
power: refactor uncore power management library test/power: removed function pointer validations drivers/power: uncore support for AMD EPYC processors
maintainers: update for drivers/power
MAINTAINERS | 1 +
app/test/test_power.c | 95 -----
app/test/test_power_cpufreq.c | 52 ---
app/test/test_power_kvm_vm.c | 36 --
drivers/meson.build | 1 +
.../power/acpi/acpi_cpufreq.c | 22 +-
.../power/acpi/acpi_cpufreq.h | 6 +-
drivers/power/acpi/meson.build | 10 +
.../power/amd_pstate/amd_pstate_cpufreq.c | 24 +-
.../power/amd_pstate/amd_pstate_cpufreq.h | 10 +-
drivers/power/amd_pstate/meson.build | 10 +
drivers/power/amd_uncore/amd_uncore.c | 329 ++++++++++++++++
drivers/power/amd_uncore/amd_uncore.h | 226 +++++++++++
drivers/power/amd_uncore/meson.build | 20 +
.../power/cppc/cppc_cpufreq.c | 22 +-
.../power/cppc/cppc_cpufreq.h | 8 +-
drivers/power/cppc/meson.build | 10 +
.../power/intel_uncore/intel_uncore.c | 18 +-
.../power/intel_uncore/intel_uncore.h | 8 +-
drivers/power/intel_uncore/meson.build | 6 +
.../power/kvm_vm}/guest_channel.c | 0
.../power/kvm_vm}/guest_channel.h | 0
.../power/kvm_vm/kvm_vm.c | 22 +-
.../power/kvm_vm/kvm_vm.h | 6 +-
drivers/power/kvm_vm/meson.build | 14 +
drivers/power/meson.build | 14 +
drivers/power/pstate/meson.build | 10 +
.../power/pstate/pstate_cpufreq.c | 22 +-
.../power/pstate/pstate_cpufreq.h | 6 +-
examples/l3fwd-power/main.c | 12 +-
lib/power/meson.build | 9 +-
lib/power/power_common.c | 2 +-
lib/power/power_common.h | 18 +-
lib/power/rte_power.c | 355 ++++++++----------
lib/power/rte_power.h | 116 +++---
lib/power/rte_power_cpufreq_api.h | 206 ++++++++++
lib/power/rte_power_uncore.c | 253 +++++++------
lib/power/rte_power_uncore.h | 61 ++-
lib/power/rte_power_uncore_ops.h | 230 ++++++++++++
lib/power/version.map | 16 +
40 files changed, 1664 insertions(+), 622 deletions(-)
rename lib/power/power_acpi_cpufreq.c => drivers/power/acpi/acpi_cpufreq.c (95%)
rename lib/power/power_acpi_cpufreq.h => drivers/power/acpi/acpi_cpufreq.h (98%)
create mode 100644 drivers/power/acpi/meson.build
rename lib/power/power_amd_pstate_cpufreq.c => drivers/power/amd_pstate/amd_pstate_cpufreq.c (95%)
rename lib/power/power_amd_pstate_cpufreq.h => drivers/power/amd_pstate/amd_pstate_cpufreq.h (96%)
create mode 100644 drivers/power/amd_pstate/meson.build
create mode 100644 drivers/power/amd_uncore/amd_uncore.c
create mode 100644 drivers/power/amd_uncore/amd_uncore.h
create mode 100644 drivers/power/amd_uncore/meson.build
rename lib/power/power_cppc_cpufreq.c => drivers/power/cppc/cppc_cpufreq.c (95%)
rename lib/power/power_cppc_cpufreq.h => drivers/power/cppc/cppc_cpufreq.h (97%)
create mode 100644 drivers/power/cppc/meson.build
rename lib/power/power_intel_uncore.c => drivers/power/intel_uncore/intel_uncore.c (95%)
rename lib/power/power_intel_uncore.h => drivers/power/intel_uncore/intel_uncore.h (97%)
create mode 100644 drivers/power/intel_uncore/meson.build
rename {lib/power => drivers/power/kvm_vm}/guest_channel.c (100%)
rename {lib/power => drivers/power/kvm_vm}/guest_channel.h (100%)
rename lib/power/power_kvm_vm.c => drivers/power/kvm_vm/kvm_vm.c (82%)
rename lib/power/power_kvm_vm.h => drivers/power/kvm_vm/kvm_vm.h (98%)
create mode 100644 drivers/power/kvm_vm/meson.build
create mode 100644 drivers/power/meson.build
create mode 100644 drivers/power/pstate/meson.build
rename lib/power/power_pstate_cpufreq.c => drivers/power/pstate/pstate_cpufreq.c (96%)
rename lib/power/power_pstate_cpufreq.h => drivers/power/pstate/pstate_cpufreq.h (98%)
create mode 100644 lib/power/rte_power_cpufreq_api.h
create mode 100644 lib/power/rte_power_uncore_ops.hSignature · 1 line
2.34.1
v7 cover power: refactor power management library
In reply to Sivaprasad TummalaThis patchset refactors the power management library, addressing both core and uncore power management. The primary changes involve the creation of dedicated directories for each driver within 'drivers/power/core/*' and 'drivers/power/uncore/*'.
This refactor significantly improves code organization, enhances clarity, and boosts maintainability. It lays the foundation for more focused development on individual drivers and facilitates seamless integration of future enhancements, particularly the AMD uncore driver.
Furthermore, this effort aims to streamline code maintenance by consolidating common functions for cpufreq and cppc across various core drivers, thus reducing code duplication.
Sivaprasad Tummala (5):
power: refactor core power management library
power: refactor uncore power management library test/power: removed function pointer validations drivers/power: uncore support for AMD EPYC processors
maintainers: update for drivers/power
MAINTAINERS | 1 +
app/test/test_power.c | 95 -----
app/test/test_power_cpufreq.c | 52 ---
app/test/test_power_kvm_vm.c | 36 --
drivers/meson.build | 1 +
.../power/acpi/acpi_cpufreq.c | 22 +-
.../power/acpi/acpi_cpufreq.h | 6 +-
drivers/power/acpi/meson.build | 10 +
.../power/amd_pstate/amd_pstate_cpufreq.c | 24 +-
.../power/amd_pstate/amd_pstate_cpufreq.h | 10 +-
drivers/power/amd_pstate/meson.build | 10 +
drivers/power/amd_uncore/amd_uncore.c | 329 ++++++++++++++++
drivers/power/amd_uncore/amd_uncore.h | 226 +++++++++++
drivers/power/amd_uncore/meson.build | 20 +
.../power/cppc/cppc_cpufreq.c | 22 +-
.../power/cppc/cppc_cpufreq.h | 8 +-
drivers/power/cppc/meson.build | 10 +
.../power/intel_uncore/intel_uncore.c | 18 +-
.../power/intel_uncore/intel_uncore.h | 8 +-
drivers/power/intel_uncore/meson.build | 6 +
.../power/kvm_vm}/guest_channel.c | 0
.../power/kvm_vm}/guest_channel.h | 0
.../power/kvm_vm/kvm_vm.c | 22 +-
.../power/kvm_vm/kvm_vm.h | 6 +-
drivers/power/kvm_vm/meson.build | 14 +
drivers/power/meson.build | 14 +
drivers/power/pstate/meson.build | 10 +
.../power/pstate/pstate_cpufreq.c | 22 +-
.../power/pstate/pstate_cpufreq.h | 6 +-
examples/l3fwd-power/main.c | 12 +-
lib/power/meson.build | 9 +-
lib/power/power_common.c | 2 +-
lib/power/power_common.h | 18 +-
lib/power/rte_power.c | 355 ++++++++----------
lib/power/rte_power.h | 116 +++---
lib/power/rte_power_cpufreq_api.h | 206 ++++++++++
lib/power/rte_power_uncore.c | 256 +++++++------
lib/power/rte_power_uncore.h | 61 ++-
lib/power/rte_power_uncore_ops.h | 230 ++++++++++++
lib/power/version.map | 16 +
40 files changed, 1666 insertions(+), 623 deletions(-)
rename lib/power/power_acpi_cpufreq.c => drivers/power/acpi/acpi_cpufreq.c (95%)
rename lib/power/power_acpi_cpufreq.h => drivers/power/acpi/acpi_cpufreq.h (98%)
create mode 100644 drivers/power/acpi/meson.build
rename lib/power/power_amd_pstate_cpufreq.c => drivers/power/amd_pstate/amd_pstate_cpufreq.c (95%)
rename lib/power/power_amd_pstate_cpufreq.h => drivers/power/amd_pstate/amd_pstate_cpufreq.h (96%)
create mode 100644 drivers/power/amd_pstate/meson.build
create mode 100644 drivers/power/amd_uncore/amd_uncore.c
create mode 100644 drivers/power/amd_uncore/amd_uncore.h
create mode 100644 drivers/power/amd_uncore/meson.build
rename lib/power/power_cppc_cpufreq.c => drivers/power/cppc/cppc_cpufreq.c (95%)
rename lib/power/power_cppc_cpufreq.h => drivers/power/cppc/cppc_cpufreq.h (97%)
create mode 100644 drivers/power/cppc/meson.build
rename lib/power/power_intel_uncore.c => drivers/power/intel_uncore/intel_uncore.c (95%)
rename lib/power/power_intel_uncore.h => drivers/power/intel_uncore/intel_uncore.h (97%)
create mode 100644 drivers/power/intel_uncore/meson.build
rename {lib/power => drivers/power/kvm_vm}/guest_channel.c (100%)
rename {lib/power => drivers/power/kvm_vm}/guest_channel.h (100%)
rename lib/power/power_kvm_vm.c => drivers/power/kvm_vm/kvm_vm.c (82%)
rename lib/power/power_kvm_vm.h => drivers/power/kvm_vm/kvm_vm.h (98%)
create mode 100644 drivers/power/kvm_vm/meson.build
create mode 100644 drivers/power/meson.build
create mode 100644 drivers/power/pstate/meson.build
rename lib/power/power_pstate_cpufreq.c => drivers/power/pstate/pstate_cpufreq.c (96%)
rename lib/power/power_pstate_cpufreq.h => drivers/power/pstate/pstate_cpufreq.h (98%)
create mode 100644 lib/power/rte_power_cpufreq_api.h
create mode 100644 lib/power/rte_power_uncore_ops.hSignature · 1 line
2.34.1
PATCH v7 1/5 power: refactor core power management library
This patch introduces a comprehensive refactor to the core power management library. The primary focus is on improving modularity and organization by relocating specific driver implementations from the 'lib/power' directory to dedicated directories within 'drivers/power/core/*'. The adjustment of meson.build files enables the selective activation of individual drivers.
These changes contribute to a significant enhancement in code organization, providing a clearer structure for driver implementations. The refactor aims to improve overall code clarity and boost maintainability. Additionally, it establishes a foundation for future development, allowing for more focused work on individual drivers and seamless integration of forthcoming enhancements.
v6:
- fixed compilation error with symbol export in API
- exported power_get_lcore_mapped_cpu_id as internal API to be used in drivers/power/*
v5:
- fixed code style warning
v4:
- fixed build error with RTE_ASSERT
v3:
- renamed rte_power_core_ops.h as rte_power_cpufreq_api.h
- re-worked on auto detection logic
v2:
- added NULL check for global_core_ops in rte_power_get_core_ops
---
drivers/meson.build | 1 +
.../power/acpi/acpi_cpufreq.c | 22 +-
.../power/acpi/acpi_cpufreq.h | 6 +-
drivers/power/acpi/meson.build | 10 +
.../power/amd_pstate/amd_pstate_cpufreq.c | 24 +-
.../power/amd_pstate/amd_pstate_cpufreq.h | 10 +-
drivers/power/amd_pstate/meson.build | 10 +
.../power/cppc/cppc_cpufreq.c | 22 +-
.../power/cppc/cppc_cpufreq.h | 8 +-
drivers/power/cppc/meson.build | 10 +
.../power/kvm_vm}/guest_channel.c | 0
.../power/kvm_vm}/guest_channel.h | 0
.../power/kvm_vm/kvm_vm.c | 22 +-
.../power/kvm_vm/kvm_vm.h | 6 +-
drivers/power/kvm_vm/meson.build | 14 +
drivers/power/meson.build | 12 +
drivers/power/pstate/meson.build | 10 +
.../power/pstate/pstate_cpufreq.c | 22 +-
.../power/pstate/pstate_cpufreq.h | 6 +-
lib/power/meson.build | 7 +-
lib/power/power_common.c | 2 +-
lib/power/power_common.h | 18 +-
lib/power/rte_power.c | 355 ++++++++----------
lib/power/rte_power.h | 116 +++---
lib/power/rte_power_cpufreq_api.h | 206 ++++++++++
lib/power/version.map | 15 +
26 files changed, 665 insertions(+), 269 deletions(-)
rename lib/power/power_acpi_cpufreq.c => drivers/power/acpi/acpi_cpufreq.c (95%)
rename lib/power/power_acpi_cpufreq.h => drivers/power/acpi/acpi_cpufreq.h (98%)
create mode 100644 drivers/power/acpi/meson.build
rename lib/power/power_amd_pstate_cpufreq.c => drivers/power/amd_pstate/amd_pstate_cpufreq.c (95%)
rename lib/power/power_amd_pstate_cpufreq.h => drivers/power/amd_pstate/amd_pstate_cpufreq.h (96%)
create mode 100644 drivers/power/amd_pstate/meson.build
rename lib/power/power_cppc_cpufreq.c => drivers/power/cppc/cppc_cpufreq.c (95%)
rename lib/power/power_cppc_cpufreq.h => drivers/power/cppc/cppc_cpufreq.h (97%)
create mode 100644 drivers/power/cppc/meson.build
rename {lib/power => drivers/power/kvm_vm}/guest_channel.c (100%)
rename {lib/power => drivers/power/kvm_vm}/guest_channel.h (100%)
rename lib/power/power_kvm_vm.c => drivers/power/kvm_vm/kvm_vm.c (82%)
rename lib/power/power_kvm_vm.h => drivers/power/kvm_vm/kvm_vm.h (98%)
create mode 100644 drivers/power/kvm_vm/meson.build
create mode 100644 drivers/power/meson.build
create mode 100644 drivers/power/pstate/meson.build
rename lib/power/power_pstate_cpufreq.c => drivers/power/pstate/pstate_cpufreq.c (96%)
rename lib/power/power_pstate_cpufreq.h => drivers/power/pstate/pstate_cpufreq.h (98%)
create mode 100644 lib/power/rte_power_cpufreq_api.hdrivers/meson.build +1 -0
@@ -29,6 +29,7 @@ subdirs = [ 'event', # depends on common, bus, mempool and net. 'baseband', # depends on common and bus. 'gpu', # depends on common and bus. + 'power', # depends on common (in future). ] if meson.is_cross_build()
drivers/power/acpi/acpi_cpufreq.c renamed from lib/power/power_acpi_cpufreq.c +21 -1
@@ -10,7 +10,7 @@#include <rte_stdatomic.h> #include <rte_string_fns.h> -#include "power_acpi_cpufreq.h" +#include "acpi_cpufreq.h" #include "power_common.h" #define STR_SIZE 1024
@@ -587,3 +587,23 @@ int power_acpi_get_capabilities(unsigned int lcore_id,return 0 ; } + +static struct rte_power_core_ops acpi_ops = { + .name ="acpi" , + .init = power_acpi_cpufreq_init, + .exit = power_acpi_cpufreq_exit, + .check_env_support = power_acpi_cpufreq_check_supported, + .get_avail_freqs = power_acpi_cpufreq_freqs, + .get_freq = power_acpi_cpufreq_get_freq, + .set_freq = power_acpi_cpufreq_set_freq, + .freq_down = power_acpi_cpufreq_freq_down, + .freq_up = power_acpi_cpufreq_freq_up, + .freq_max = power_acpi_cpufreq_freq_max, + .freq_min = power_acpi_cpufreq_freq_min, + .turbo_status = power_acpi_turbo_status, + .enable_turbo = power_acpi_enable_turbo, + .disable_turbo = power_acpi_disable_turbo, + .get_caps = power_acpi_get_capabilities +}; + +RTE_POWER_REGISTER_OPS (acpi_ops);
drivers/power/acpi/acpi_cpufreq.h renamed from lib/power/power_acpi_cpufreq.h +3 -3
@@ -2,15 +2,15 @@* Copyright(c) 2010-2014 Intel Corporation */ -#ifndef _POWER_ACPI_CPUFREQ_H -#define _POWER_ACPI_CPUFREQ_H +#ifndef _ACPI_CPUFREQ_H +#define _ACPI_CPUFREQ_H/** * @file * RTE Power Management via userspace ACPI cpufreq */ -#include "rte_power.h" +#include "rte_power_cpufreq_api.h" /** * Check if ACPI power management is supported.
drivers/power/acpi/meson.build new file +10 -0
@@ -0,0 +1,10 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' +endif +sources = files('acpi_cpufreq.c') + +deps += ['power']
drivers/power/amd_pstate/amd_pstate_cpufreq.c renamed from lib/power/power_amd_pstate_cpufreq.c +22 -2
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2010-2021 Intel Corporation * Copyright(c) 2021 Arm Limited -* Copyright(c) 2023 Amd Limited +* Copyright(c) 2024 Advanced Micro Devices, Inc. */ #include <stdlib.h>
@@ -9,7 +9,7 @@#include <rte_memcpy.h> #include <rte_stdatomic.h> -#include "power_amd_pstate_cpufreq.h" +#include "amd_pstate_cpufreq.h" #include "power_common.h" /* macros used for rounding frequency to nearest 1000 */
@@ -710,3 +710,23 @@ power_amd_pstate_get_capabilities(unsigned int lcore_id,return 0 ; } + +static struct rte_power_core_ops amd_pstate_ops = { + .name ="amd-pstate" , + .init = power_amd_pstate_cpufreq_init, + .exit = power_amd_pstate_cpufreq_exit, + .check_env_support = power_amd_pstate_cpufreq_check_supported, + .get_avail_freqs = power_amd_pstate_cpufreq_freqs, + .get_freq = power_amd_pstate_cpufreq_get_freq, + .set_freq = power_amd_pstate_cpufreq_set_freq, + .freq_down = power_amd_pstate_cpufreq_freq_down, + .freq_up = power_amd_pstate_cpufreq_freq_up, + .freq_max = power_amd_pstate_cpufreq_freq_max, + .freq_min = power_amd_pstate_cpufreq_freq_min, + .turbo_status = power_amd_pstate_turbo_status, + .enable_turbo = power_amd_pstate_enable_turbo, + .disable_turbo = power_amd_pstate_disable_turbo, + .get_caps = power_amd_pstate_get_capabilities +}; + +RTE_POWER_REGISTER_OPS (amd_pstate_ops);
drivers/power/amd_pstate/amd_pstate_cpufreq.h renamed from lib/power/power_amd_pstate_cpufreq.h +5 -5
@@ -1,18 +1,18 @@/* SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2010-2021 Intel Corporation * Copyright(c) 2021 Arm Limited -* Copyright(c) 2023 Amd Limited +* Copyright(c) 2024 Advanced Micro Devices, Inc. */ -#ifndef _POWER_AMD_PSTATE_CPUFREQ_H -#define _POWER_AMD_PSTATE_CPUFREQ_H +#ifndef _AMD_PSTATE_CPUFREQ_H +#define _AMD_PSTATE_CPUFREQ_H/** * @file * RTE Power Management via userspace AMD pstate cpufreq */ -#include "rte_power.h" +#include "rte_power_cpufreq_api.h" /** * Check if amd p-state power management is supported.
@@ -216,4 +216,4 @@ int power_amd_pstate_disable_turbo(unsigned int lcore_id);int power_amd_pstate_get_capabilities (unsigned int lcore_id,struct rte_power_core_capabilities *caps); -#endif /* _POWER_AMD_PSTATET_CPUFREQ_H */ +#endif /* _AMD_PSTATET_CPUFREQ_H */
drivers/power/amd_pstate/meson.build new file +10 -0
@@ -0,0 +1,10 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' +endif +sources = files('amd_pstate_cpufreq.c') + +deps += ['power']
drivers/power/cppc/cppc_cpufreq.c renamed from lib/power/power_cppc_cpufreq.c +21 -1
@@ -8,7 +8,7 @@#include <rte_memcpy.h> #include <rte_stdatomic.h> -#include "power_cppc_cpufreq.h" +#include "cppc_cpufreq.h" #include "power_common.h" /* macros used for rounding frequency to nearest 100000 */
@@ -695,3 +695,23 @@ power_cppc_get_capabilities(unsigned int lcore_id,return 0 ; } + +static struct rte_power_core_ops cppc_ops = { + .name ="cppc" , + .init = power_cppc_cpufreq_init, + .exit = power_cppc_cpufreq_exit, + .check_env_support = power_cppc_cpufreq_check_supported, + .get_avail_freqs = power_cppc_cpufreq_freqs, + .get_freq = power_cppc_cpufreq_get_freq, + .set_freq = power_cppc_cpufreq_set_freq, + .freq_down = power_cppc_cpufreq_freq_down, + .freq_up = power_cppc_cpufreq_freq_up, + .freq_max = power_cppc_cpufreq_freq_max, + .freq_min = power_cppc_cpufreq_freq_min, + .turbo_status = power_cppc_turbo_status, + .enable_turbo = power_cppc_enable_turbo, + .disable_turbo = power_cppc_disable_turbo, + .get_caps = power_cppc_get_capabilities +}; + +RTE_POWER_REGISTER_OPS (cppc_ops);
drivers/power/cppc/cppc_cpufreq.h renamed from lib/power/power_cppc_cpufreq.h +4 -4
@@ -3,15 +3,15 @@* Copyright(c) 2021 Arm Limited */ -#ifndef _POWER_CPPC_CPUFREQ_H -#define _POWER_CPPC_CPUFREQ_H +#ifndef _CPPC_CPUFREQ_H +#define _CPPC_CPUFREQ_H/** * @file * RTE Power Management via userspace CPPC cpufreq */ -#include "rte_power.h" +#include "rte_power_cpufreq_api.h" /** * Check if CPPC power management is supported.
@@ -215,4 +215,4 @@ int power_cppc_disable_turbo(unsigned int lcore_id);int power_cppc_get_capabilities (unsigned int lcore_id,struct rte_power_core_capabilities *caps); -#endif /* _POWER_CPPC_CPUFREQ_H */ +#endif /* _CPPC_CPUFREQ_H */
drivers/power/cppc/meson.build new file +10 -0
@@ -0,0 +1,10 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' +endif +sources = files('cppc_cpufreq.c') + +deps += ['power']
drivers/power/kvm_vm/guest_channel.c renamed from lib/power/guest_channel.c +0 -0
drivers/power/kvm_vm/guest_channel.h renamed from lib/power/guest_channel.h +0 -0
drivers/power/kvm_vm/kvm_vm.c renamed from lib/power/power_kvm_vm.c +21 -1
@@ -9,7 +9,7 @@#include "rte_power_guest_channel.h" #include "guest_channel.h" #include "power_common.h" -#include "power_kvm_vm.h" +#include "kvm_vm.h" #define FD_PATH "/dev/virtio-ports/virtio.serial.port.poweragent"
@@ -137,3 +137,23 @@ int power_kvm_vm_get_capabilities(__rte_unused unsigned int lcore_id,POWER_LOG (ERR ,"rte_power_get_capabilities is not implemented for Virtual Machine Power Management" );return -ENOTSUP ; } + +static struct rte_power_core_ops kvm_vm_ops = { + .name ="kvm-vm" , + .init = power_kvm_vm_init, + .exit = power_kvm_vm_exit, + .check_env_support = power_kvm_vm_check_supported, + .get_avail_freqs = power_kvm_vm_freqs, + .get_freq = power_kvm_vm_get_freq, + .set_freq = power_kvm_vm_set_freq, + .freq_down = power_kvm_vm_freq_down, + .freq_up = power_kvm_vm_freq_up, + .freq_max = power_kvm_vm_freq_max, + .freq_min = power_kvm_vm_freq_min, + .turbo_status = power_kvm_vm_turbo_status, + .enable_turbo = power_kvm_vm_enable_turbo, + .disable_turbo = power_kvm_vm_disable_turbo, + .get_caps = power_kvm_vm_get_capabilities +}; + +RTE_POWER_REGISTER_OPS (kvm_vm_ops);
drivers/power/kvm_vm/kvm_vm.h renamed from lib/power/power_kvm_vm.h +3 -3
@@ -2,15 +2,15 @@* Copyright(c) 2010-2014 Intel Corporation */ -#ifndef _POWER_KVM_VM_H -#define _POWER_KVM_VM_H +#ifndef _KVM_VM_H +#define _KVM_VM_H/** * @file * RTE Power Management KVM VM */ -#include "rte_power.h" +#include "rte_power_cpufreq_api.h" /** * Check if KVM power management is supported.
drivers/power/kvm_vm/meson.build new file +14 -0
@@ -0,0 +1,14 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' + subdir_done() +endif +sources = files( + 'guest_channel.c', + 'kvm_vm.c', +) + +deps += ['power']
drivers/power/meson.build new file +12 -0
@@ -0,0 +1,12 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +drivers = [ + 'acpi', + 'amd_pstate', + 'cppc', + 'kvm_vm', + 'pstate' +] + +std_deps = ['power']
drivers/power/pstate/meson.build new file +10 -0
@@ -0,0 +1,10 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' +endif +sources = files('pstate_cpufreq.c') + +deps += ['power']
drivers/power/pstate/pstate_cpufreq.c renamed from lib/power/power_pstate_cpufreq.c +21 -1
@@ -15,7 +15,7 @@#include <rte_stdatomic.h> #include "rte_power_pmd_mgmt.h" -#include "power_pstate_cpufreq.h" +#include "pstate_cpufreq.h" #include "power_common.h" /* macros used for rounding frequency to nearest 100000 */
@@ -898,3 +898,23 @@ int power_pstate_get_capabilities(unsigned int lcore_id,return 0 ; } + +static struct rte_power_core_ops pstate_ops = { + .name ="pstate" , + .init = power_pstate_cpufreq_init, + .exit = power_pstate_cpufreq_exit, + .check_env_support = power_pstate_cpufreq_check_supported, + .get_avail_freqs = power_pstate_cpufreq_freqs, + .get_freq = power_pstate_cpufreq_get_freq, + .set_freq = power_pstate_cpufreq_set_freq, + .freq_down = power_pstate_cpufreq_freq_down, + .freq_up = power_pstate_cpufreq_freq_up, + .freq_max = power_pstate_cpufreq_freq_max, + .freq_min = power_pstate_cpufreq_freq_min, + .turbo_status = power_pstate_turbo_status, + .enable_turbo = power_pstate_enable_turbo, + .disable_turbo = power_pstate_disable_turbo, + .get_caps = power_pstate_get_capabilities +}; + +RTE_POWER_REGISTER_OPS (pstate_ops);
drivers/power/pstate/pstate_cpufreq.h renamed from lib/power/power_pstate_cpufreq.h +3 -3
@@ -2,15 +2,15 @@* Copyright(c) 2018 Intel Corporation */ -#ifndef _POWER_PSTATE_CPUFREQ_H -#define _POWER_PSTATE_CPUFREQ_H +#ifndef _PSTATE_CPUFREQ_H +#define _PSTATE_CPUFREQ_H/** * @file * RTE Power Management via Intel Pstate driver */ -#include "rte_power.h" +#include "rte_power_cpufreq_api.h" /** * Check if pstate power management is supported.
lib/power/meson.build +1 -6
@@ -12,20 +12,15 @@ if not is_linux reason = 'only supported on Linux' endif sources = files( - 'guest_channel.c', - 'power_acpi_cpufreq.c', - 'power_amd_pstate_cpufreq.c', 'power_common.c', - 'power_cppc_cpufreq.c', - 'power_kvm_vm.c', 'power_intel_uncore.c', - 'power_pstate_cpufreq.c', 'rte_power.c', 'rte_power_uncore.c', 'rte_power_pmd_mgmt.c', ) headers = files( 'rte_power.h', + 'rte_power_cpufreq_api.h', 'rte_power_guest_channel.h', 'rte_power_pmd_mgmt.h', 'rte_power_uncore.h',
lib/power/power_common.c +1 -1
@@ -13,7 +13,7 @@#include "power_common.h" -RTE_LOG_REGISTER_DEFAULT (power_logtype,INFO ); +RTE_LOG_REGISTER_DEFAULT (rte_power_logtype,INFO );#define POWER_SYSFILE_SCALING_DRIVER \ "/sys/devices/system/cpu/cpu%u/cpufreq/scaling_driver"
lib/power/power_common.h +16 -2
@@ -6,12 +6,13 @@#define _POWER_COMMON_H_#include <rte_common.h> +#include <rte_compat.h> #include <rte_log.h> #define RTE_POWER_INVALID_FREQ_INDEX (~0) -extern int power_logtype; -#define RTE_LOGTYPE_POWER power_logtype +extern int rte_power_logtype; +#define RTE_LOGTYPE_POWER rte_power_logtype#define POWER_LOG (level, ...) \ RTE_LOG_LINE(level, POWER, "" __VA_ARGS__)
@@ -23,14 +24,27 @@ extern int power_logtype;#endif /* check if scaling driver matches one we want */ +__rte_internal int cpufreq_check_scaling_driver(const char *driver); + +__rte_internal int power_set_governor(unsigned int lcore_id, const char *new_governor,char *orig_governor,size_t orig_governor_len); + +__rte_internal int open_core_sysfs_file(FILE **f, const char *mode, const char *format, ...) __rte_format_printf(3, 4); + +__rte_internal int read_core_sysfs_u32(FILE *f, uint32_t *val); + +__rte_internal int read_core_sysfs_s(FILE *f, char *buf, unsigned int len); + +__rte_internal int write_core_sysfs_s(FILE *f, const char *str); + +__rte_internal int power_get_lcore_mapped_cpu_id(uint32_t lcore_id, uint32_t *cpu_id);#endif /* _POWER_COMMON_H_ */
lib/power/rte_power.c +164 -191
408 lines not on this page · raw message
lib/power/rte_power.h +71 -45
199 lines not on this page · raw message
lib/power/rte_power_cpufreq_api.h new file +206 -0
206 lines not on this page · raw message
lib/power/version.map +15 -0
@@ -51,4 +51,19 @@ EXPERIMENTAL { rte_power_set_uncore_env; rte_power_uncore_freqs; rte_power_unset_uncore_env; + # added in 24.11 + rte_power_logtype; +}; + +INTERNAL { + global: + + rte_power_register_ops; + cpufreq_check_scaling_driver; + power_get_lcore_mapped_cpu_id; + power_set_governor; + open_core_sysfs_file; + read_core_sysfs_u32; + read_core_sysfs_s; + write_core_sysfs_s; };
Signature · 1 line
2.34.1
Re: [PATCH v7 1/5] power: refactor core power management library
lib/power/version.map EXPERIMENTAL { · line 56
Quoted 11 lines · On Mon, 21 Oct 2024 04:07:19 +0000 Sivaprasad Tummala…
lib/power/version.map +3
-0@@ -51,4 +51,19 @@ EXPERIMENTAL { rte_power_set_uncore_env; rte_power_uncore_freqs; rte_power_unset_uncore_env; + # added in 24.11 + rte_power_logtype; +};
The logtype should be kept internal, not part of public API
RE: [PATCH v7 1/5] power: refactor core power management library
[AMD Official Use Only - AMD Internal Distribution Only]
Hi Stephen,
Quoted 17 lines
-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Tuesday, October 22, 2024 6:50 AM
To: Tummala, Sivaprasad <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Yigit, Ferruh <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v7 1/5] power: refactor core power management libraryCaution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
On Mon, 21 Oct 2024 04:07:19 +0000
Sivaprasad Tummala <[email protected]> wrote:
Quoted 13 lines
lib/power/version.map EXPERIMENTAL { · line 56
Quoted 11 lines
lib/power/version.map index renamed from lib/power/version.map +0
-0
c9a226614e..016e599e90100644lib/power/version.map +3
-0@@ -51,4 +51,19 @@ EXPERIMENTAL { rte_power_set_uncore_env; rte_power_uncore_freqs; rte_power_unset_uncore_env; + # added in 24.11 + rte_power_logtype; +};The logtype should be kept internal, not part of public API
ACK!
Re: [PATCH v7 1/5] power: refactor core power management library
In reply to Sivaprasad TummalaHi Sivaprasad,
Some comments inline.
Quoted 108 lines · Sivaprasad Tummala
This patch introduces a comprehensive refactor to the core power management library. The primary focus is on improving modularity and organization by relocating specific driver implementations from the 'lib/power' directory to dedicated directories within '
drivers/power/core/*'. The adjustment of meson.build files enables the selective activation of individual drivers.These changes contribute to a significant enhancement in code organization, providing a clearer structure for driver implementations. The refactor aims to improve overall code clarity and boost maintainability. Additionally, it establishes a foundation for future development, allowing for more focused work on individual drivers and seamless integration of forthcoming enhancements.
v6:
- fixed compilation error with symbol export in API
- exportedpower_get_lcore_mapped_cpu_idas internal API to be used indrivers/power/*v5:
- fixed code style warningv4:
- fixed build error withRTE_ASSERTv3:
- renamedrte_power_core_ops.hasrte_power_cpufreq_api.h
- re-worked on auto detection logicv2:
- added NULL check forglobal_core_opsinrte_power_get_core_opsSigned-off-by Sivaprasad Tummala <[email protected]>--- drivers/meson.build | 1 + .../power/acpi/acpi_cpufreq.c | 22 +- .../power/acpi/acpi_cpufreq.h | 6 +- drivers/power/acpi/meson.build | 10 + .../power/amd_pstate/amd_pstate_cpufreq.c | 24 +- .../power/amd_pstate/amd_pstate_cpufreq.h | 10 +- drivers/power/amd_pstate/meson.build | 10 + .../power/cppc/cppc_cpufreq.c | 22 +- .../power/cppc/cppc_cpufreq.h | 8 +- drivers/power/cppc/meson.build | 10 + .../power/kvm_vm}/guest_channel.c | 0 .../power/kvm_vm}/guest_channel.h | 0 .../power/kvm_vm/kvm_vm.c | 22 +- .../power/kvm_vm/kvm_vm.h | 6 +- drivers/power/kvm_vm/meson.build | 14 + drivers/power/meson.build | 12 + drivers/power/pstate/meson.build | 10 + .../power/pstate/pstate_cpufreq.c | 22 +- .../power/pstate/pstate_cpufreq.h | 6 +- lib/power/meson.build | 7 +- lib/power/power_common.c | 2 +- lib/power/power_common.h | 18 +- lib/power/rte_power.c | 355 ++++++++---------- lib/power/rte_power.h | 116 +++--- lib/power/rte_power_cpufreq_api.h | 206 ++++++++++ lib/power/version.map | 15 + 26 files changed, 665 insertions(+), 269 deletions(-)rename
lib/power/power_acpi_cpufreq.c=>drivers/power/acpi/acpi_cpufreq.c(95%) renamelib/power/power_acpi_cpufreq.h=>drivers/power/acpi/acpi_cpufreq.h(98%) create mode 100644drivers/power/acpi/meson.build
renamelib/power/power_amd_pstate_cpufreq.c=>drivers/power/amd_pstate/amd_pstate_cpufreq.c(95%) renamelib/power/power_amd_pstate_cpufreq.h=>drivers/power/amd_pstate/amd_pstate_cpufreq.h(96%) create mode 100644drivers/power/amd_pstate/meson.build
renamelib/power/power_cppc_cpufreq.c=>drivers/power/cppc/cppc_cpufreq.c(95%) renamelib/power/power_cppc_cpufreq.h=>drivers/power/cppc/cppc_cpufreq.h(97%) create mode 100644drivers/power/cppc/meson.build
rename {lib/power =>drivers/power/kvm_vm}/guest_channel.c(100%)
rename {lib/power =>drivers/power/kvm_vm}/guest_channel.h(100%)
renamelib/power/power_kvm_vm.c=>drivers/power/kvm_vm/kvm_vm.c(82%)
renamelib/power/power_kvm_vm.h=>drivers/power/kvm_vm/kvm_vm.h(98%)
create mode 100644drivers/power/kvm_vm/meson.build
create mode 100644drivers/power/meson.build
create mode 100644drivers/power/pstate/meson.build
renamelib/power/power_pstate_cpufreq.c=>drivers/power/pstate/pstate_cpufreq.c(96%) renamelib/power/power_pstate_cpufreq.h=>drivers/power/pstate/pstate_cpufreq.h(98%) create mode 100644lib/power/rte_power_cpufreq_api.hdrivers/meson.build +1
-0@@ -29,6 +29,7 @@ subdirs = [ 'event', # depends on common, bus, mempool and net. 'baseband', # depends on common and bus. 'gpu', # depends on common and bus. + 'power', # depends on common (in future). ] if meson.is_cross_build()drivers/power/acpi/acpi_cpufreq.c renamed from lib/power/power_acpi_cpufreq.c +1
-1@@ -10,7 +10,7 @@#include <rte_stdatomic.h> #include <rte_string_fns.h> -#include "power_acpi_cpufreq.h" +#include "acpi_cpufreq.h" #include "power_common.h"
<...>
Quoted 34 lines
lib/power/power_common.c +1
-1@@ -13,7 +13,7 @@#include "power_common.h" -RTE_LOG_REGISTER_DEFAULT (power_logtype,INFO ); +RTE_LOG_REGISTER_DEFAULT (rte_power_logtype,INFO );#define POWER_SYSFILE_SCALING_DRIVER \ "/sys/devices/system/cpu/cpu%u/cpufreq/scaling_driver"lib/power/power_common.h +3
-2@@ -6,12 +6,13 @@#define _POWER_COMMON_H_#include <rte_common.h> +#include <rte_compat.h> #include <rte_log.h> #define RTE_POWER_INVALID_FREQ_INDEX (~0) -extern int power_logtype; -#define RTE_LOGTYPE_POWER power_logtype +extern int rte_power_logtype; +#define RTE_LOGTYPE_POWER rte_power_logtype#define POWER_LOG (level, ...) \ RTE_LOG_LINE(level, POWER, "" __VA_ARGS__)
lib/power/power_common.h extern int power_logtype; · line 32
Quoted 9 lines
lib/power/power_common.h +3
-0@@ -23,14 +24,27 @@ extern int power_logtype;#endif /* check if scaling driver matches one we want */ +__rte_internal int cpufreq_check_scaling_driver(const char *driver); + +__rte_internal int power_set_governor(unsigned int lcore_id, const char *new_governor,char *orig_governor,size_t orig_governor_len);
cpufreq_check_scaling_driver and power_set_governor are just used for cpufreq, they shouldn't be put in this common header file. We've come to an aggrement in patch V2 1/4.
I guess you forget it😁
suggest that move these two APIs to rte_power_cpufreq_api.h.
Quoted 69 lines
lib/power/power_common.h +10
-0+ +__rte_internal int open_core_sysfs_file(FILE **f, const char *mode, const char *format, ...) __rte_format_printf(3, 4); + +__rte_internal int read_core_sysfs_u32(FILE *f, uint32_t *val); + +__rte_internal int read_core_sysfs_s(FILE *f, char *buf, unsigned int len); + +__rte_internal int write_core_sysfs_s(FILE *f, const char *str); + +__rte_internal int power_get_lcore_mapped_cpu_id(uint32_t lcore_id, uint32_t *cpu_id);#endif /* _POWER_COMMON_H_ */ lib/power/rte_power.c +15
-22@@ -6,155 +6,88 @@#include <rte_errno.h> #include <rte_spinlock.h> +#include <rte_debug.h> #include "rte_power.h" -#include "power_acpi_cpufreq.h" -#include "power_cppc_cpufreq.h" #include "power_common.h" -#include "power_kvm_vm.h" -#include "power_pstate_cpufreq.h" -#include "power_amd_pstate_cpufreq.h" -enum power_management_env global_default_env =PM_ENV_NOT_SET ; +static enum power_management_env global_default_env =PM_ENV_NOT_SET ; +static struct rte_power_core_ops *global_power_core_ops;static rte_spinlock_t global_env_cfg_lock =RTE_SPINLOCK_INITIALIZER ; - -/* function pointers */ -rte_power_freqs_t rte_power_freqs =NULL ; -rte_power_get_freq_t rte_power_get_freq =NULL ; -rte_power_set_freq_t rte_power_set_freq =NULL ; -rte_power_freq_change_t rte_power_freq_up =NULL ; -rte_power_freq_change_t rte_power_freq_down =NULL ; -rte_power_freq_change_t rte_power_freq_max =NULL ; -rte_power_freq_change_t rte_power_freq_min =NULL ; -rte_power_freq_change_t rte_power_turbo_status; -rte_power_freq_change_t rte_power_freq_enable_turbo; -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 ) +static RTE_TAILQ_HEAD(, rte_power_core_ops) core_ops_list = +TAILQ_HEAD_INITIALIZER (core_ops_list); + +const char *power_env_str[] = { +"not set" , +"acpi" , +"kvm-vm" , +"pstate" , +"cppc" , +"amd-pstate" +}; +
<...>
Quoted 89 lines
lib/power/rte_power.c +75
-0+uint32_t +rte_power_freqs (unsigned int lcore_id,uint32_t *freqs,uint32_t n) +{ +RTE_ASSERT (global_power_core_ops !=NULL ); +return global_power_core_ops->get_avail_freqs (lcore_id, freqs, n); +} + +uint32_t +rte_power_get_freq (unsigned int lcore_id) +{ +RTE_ASSERT (global_power_core_ops !=NULL ); +return global_power_core_ops->get_freq (lcore_id); +} + +uint32_t +rte_power_set_freq (unsigned int lcore_id,uint32_t index) +{ +RTE_ASSERT (global_power_core_ops !=NULL ); +return global_power_core_ops->set_freq (lcore_id, index); +} + +int +rte_power_freq_up (unsigned int lcore_id) +{ +RTE_ASSERT (global_power_core_ops !=NULL ); +return global_power_core_ops->freq_up (lcore_id); +} + +int +rte_power_freq_down (unsigned int lcore_id) +{ +RTE_ASSERT (global_power_core_ops !=NULL ); +return global_power_core_ops->freq_down (lcore_id); +} + +int +rte_power_freq_max (unsigned int lcore_id) +{ +RTE_ASSERT (global_power_core_ops !=NULL ); +return global_power_core_ops->freq_max (lcore_id); +} + +int +rte_power_freq_min (unsigned int lcore_id) +{ +RTE_ASSERT (global_power_core_ops !=NULL ); +return global_power_core_ops->freq_min (lcore_id); +} +int +rte_power_turbo_status (unsigned int lcore_id) +{ +RTE_ASSERT (global_power_core_ops !=NULL ); +return global_power_core_ops->turbo_status (lcore_id); +} + +int +rte_power_freq_enable_turbo (unsigned int lcore_id) +{ +RTE_ASSERT (global_power_core_ops !=NULL ); +return global_power_core_ops->enable_turbo (lcore_id); +} + +int +rte_power_freq_disable_turbo (unsigned int lcore_id) +{ +RTE_ASSERT (global_power_core_ops !=NULL ); +return global_power_core_ops->disable_turbo (lcore_id); +} + +int +rte_power_get_capabilities (unsigned int lcore_id, +struct rte_power_core_capabilities *caps) +{ +RTE_ASSERT (global_power_core_ops !=NULL ); +return global_power_core_ops->get_caps (lcore_id, caps); }lib/power/rte_power.h +1
-0@@ -1,5 +1,6 @@/* SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2010-2014 Intel Corporation +* Copyright(c) 2024 Advanced Micro Devices, Inc. */ #ifndef _RTE_POWER_H
lib/power/rte_power.h line 18
Quoted 4 lines
lib/power/rte_power.h +1
-0@@ -14,14 +15,21 @@#include <rte_log.h> #include <rte_power_guest_channel.h> +#include "rte_power_cpufreq_api.h"
From the name of rte_power.c and rte_power.h, they are supposed to work for all power libraries I also proposed in previous version. But rte_power.* currently just work for cpufreq lib. If we need to put all power components togeter and create it. Now that the rte_power_cpufreq_api.h has been created for cpufreq library.
How about directly rename rte_power.c to rte_poer_cpufreq_api.c and rte_power.h to rte_power_cpufreq_api.h? There will be ABI changes, but it is allowed in this 24.11. If we plan to do it later, we'll have to wait another year.
Quoted 18 lines
lib/power/rte_power.h +9
-3+#ifdef __cplusplusextern "C" {#endif /* Power Management Environment State */ -enum power_management_env {PM_ENV_NOT_SET ,PM_ENV_ACPI_CPUFREQ ,PM_ENV_KVM_VM , -PM_ENV_PSTATE_CPUFREQ ,PM_ENV_CPPC_CPUFREQ , -PM_ENV_AMD_PSTATE_CPUFREQ }; +enum power_management_env { +PM_ENV_NOT_SET =0 , +PM_ENV_ACPI_CPUFREQ , +PM_ENV_KVM_VM , +PM_ENV_PSTATE_CPUFREQ , +PM_ENV_CPPC_CPUFREQ , +PM_ENV_AMD_PSTATE_CPUFREQ +};
<...>
RE: [PATCH v7 1/5] power: refactor core power management library
[AMD Official Use Only - AMD Internal Distribution Only]
Hi Huisong,
Please find my comments inline.
Quoted 172 lines
-----Original Message-----
From: lihuisong (C) <[email protected]>
Sent: Tuesday, October 22, 2024 8:33 AM
To: Tummala, Sivaprasad <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Yigit, Ferruh <[email protected]>
Subject: Re: [PATCH v7 1/5] power: refactor core power management libraryCaution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
Hi Sivaprasad,
Some comments inline.
Quoted 61 lines · Sivaprasad Tummala
This patch introduces a comprehensive refactor to the core power management library. The primary focus is on improving modularity and organization by relocating specific driver implementations from the 'lib/power' directory to dedicated directories within '
drivers/power/core/*'. The adjustment of meson.build files enables the selective activation of individual drivers.These changes contribute to a significant enhancement in code organization, providing a clearer structure for driver implementations. The refactor aims to improve overall code clarity and boost maintainability. Additionally, it establishes a foundation for future development, allowing for more focused work on individual drivers and seamless integration of forthcoming enhancements.
v6:
- fixed compilation error with symbol export in API
- exportedpower_get_lcore_mapped_cpu_idas internal API to be used indrivers/power/*v5:
- fixed code style warningv4:
- fixed build error withRTE_ASSERTv3:
- renamedrte_power_core_ops.hasrte_power_cpufreq_api.h
- re-worked on auto detection logicv2:
- added NULL check forglobal_core_opsinrte_power_get_core_opsSigned-off-by Sivaprasad Tummala <[email protected]>--- drivers/meson.build | 1 + .../power/acpi/acpi_cpufreq.c | 22 +- .../power/acpi/acpi_cpufreq.h | 6 +- drivers/power/acpi/meson.build | 10 + .../power/amd_pstate/amd_pstate_cpufreq.c | 24 +- .../power/amd_pstate/amd_pstate_cpufreq.h | 10 +- drivers/power/amd_pstate/meson.build | 10 + .../power/cppc/cppc_cpufreq.c | 22 +- .../power/cppc/cppc_cpufreq.h | 8 +- drivers/power/cppc/meson.build | 10 + .../power/kvm_vm}/guest_channel.c | 0 .../power/kvm_vm}/guest_channel.h | 0 .../power/kvm_vm/kvm_vm.c | 22 +- .../power/kvm_vm/kvm_vm.h | 6 +- drivers/power/kvm_vm/meson.build | 14 + drivers/power/meson.build | 12 + drivers/power/pstate/meson.build | 10 + .../power/pstate/pstate_cpufreq.c | 22 +- .../power/pstate/pstate_cpufreq.h | 6 +- lib/power/meson.build | 7 +- lib/power/power_common.c | 2 +- lib/power/power_common.h | 18 +- lib/power/rte_power.c | 355 ++++++++---------- lib/power/rte_power.h | 116 +++--- lib/power/rte_power_cpufreq_api.h | 206 ++++++++++ lib/power/version.map | 15 + 26 files changed, 665 insertions(+), 269 deletions(-)Quoted 1 line
rename
lib/power/power_acpi_cpufreq.c=>drivers/power/acpi/acpi_cpufreq.c(95%)
Quoted 1 line
rename
lib/power/power_acpi_cpufreq.h=>drivers/power/acpi/acpi_cpufreq.h(98%)
Quoted 2 lines
create mode 100644
drivers/power/acpi/meson.buildrenamelib/power/power_amd_pstate_cpufreq.c=>
drivers/power/amd_pstate/amd_pstate_cpufreq.c(95%)Quoted 1 line
rename
lib/power/power_amd_pstate_cpufreq.h=>
drivers/power/amd_pstate/amd_pstate_cpufreq.h(96%)Quoted 2 lines
create mode 100644
drivers/power/amd_pstate/meson.build
renamelib/power/power_cppc_cpufreq.c=>drivers/power/cppc/cppc_cpufreq.c(95%)
Quoted 1 line
rename
lib/power/power_cppc_cpufreq.h=>drivers/power/cppc/cppc_cpufreq.h(97%)
Quoted 9 lines
create mode 100644
drivers/power/cppc/meson.build
rename {lib/power =>drivers/power/kvm_vm}/guest_channel.c(100%) rename {lib/power =>drivers/power/kvm_vm}/guest_channel.h(100%) renamelib/power/power_kvm_vm.c=>drivers/power/kvm_vm/kvm_vm.c(82%) renamelib/power/power_kvm_vm.h=>drivers/power/kvm_vm/kvm_vm.h(98%) create mode 100644drivers/power/kvm_vm/meson.build
create mode 100644drivers/power/meson.build
create mode 100644drivers/power/pstate/meson.build
renamelib/power/power_pstate_cpufreq.c=>
drivers/power/pstate/pstate_cpufreq.c(96%)Quoted 1 line
rename
lib/power/power_pstate_cpufreq.h=>
drivers/power/pstate/pstate_cpufreq.h(98%)Quoted 29 lines
create mode 100644
lib/power/rte_power_cpufreq_api.hdrivers/meson.build index renamed from drivers/meson.build +0
-02733306698..7ef4f581a0 100644
drivers/meson.build +1
-0@@ -29,6 +29,7 @@ subdirs = [ 'event', # depends on common, bus, mempool and net. 'baseband', # depends on common and bus. 'gpu', # depends on common and bus. + 'power', # depends on common (in future). ] if meson.is_cross_build()drivers/power/acpi/acpi_cpufreq.c renamed from lib/power/power_acpi_cpufreq.c rename to +0
-0
drivers/power/acpi/acpi_cpufreq.cindexae809fbb60..974fbb7ba8100644drivers/power/acpi/acpi_cpufreq.c renamed from lib/power/power_acpi_cpufreq.c +1
-1@@ -10,7 +10,7 @@#include <rte_stdatomic.h> #include <rte_string_fns.h> -#include "power_acpi_cpufreq.h" +#include "acpi_cpufreq.h" #include "power_common.h" <...>
Quoted 36 lines
lib/power/power_common.c index renamed from lib/power/power_common.c +0
-0
b47c63a5f1..e482f71c64100644lib/power/power_common.c +1
-1@@ -13,7 +13,7 @@#include "power_common.h" -RTE_LOG_REGISTER_DEFAULT (power_logtype,INFO ); +RTE_LOG_REGISTER_DEFAULT (rte_power_logtype,INFO );#define POWER_SYSFILE_SCALING_DRIVER \ "/sys/devices/system/cpu/cpu%u/cpufreq/scaling_driver"lib/power/power_common.h index renamed from lib/power/power_common.h +0
-0
82fb94d0c0..c294f561bb100644lib/power/power_common.h +3
-2@@ -6,12 +6,13 @@#define _POWER_COMMON_H_#include <rte_common.h> +#include <rte_compat.h> #include <rte_log.h> #define RTE_POWER_INVALID_FREQ_INDEX (~0) -extern int power_logtype; -#define RTE_LOGTYPE_POWER power_logtype +extern int rte_power_logtype; +#define RTE_LOGTYPE_POWER rte_power_logtype#define POWER_LOG (level, ...) \ RTE_LOG_LINE(level, POWER, "" __VA_ARGS__)@@ -23,14 +24,27 @@ extern int power_logtype;#endif
Quoted 12 lines
lib/power/power_common.h extern int power_logtype; · line 32
Quoted 7 lines
lib/power/power_common.h +3
-0/* check if scaling driver matches one we want */ +__rte_internal int cpufreq_check_scaling_driver(const char *driver); + +__rte_internal int power_set_governor(unsigned int lcore_id, const char *new_governor,char *orig_governor,size_t orig_governor_len);
cpufreq_check_scaling_driverandpower_set_governorare just used for cpufreq, they shouldn't be put in this common header file.
We've come to an aggrement in patch V2 1/4.
I guess you forget it😁
suggest that move these two APIs torte_power_cpufreq_api.h.
OK!
Quoted 153 lines
Quoted 29 lines
lib/power/power_common.h +10
-0+ +__rte_internal int open_core_sysfs_file(FILE **f, const char *mode, const char *format, ...) __rte_format_printf(3, 4); + +__rte_internal int read_core_sysfs_u32(FILE *f, uint32_t *val); + +__rte_internal int read_core_sysfs_s(FILE *f, char *buf, unsigned int len); + +__rte_internal int write_core_sysfs_s(FILE *f, const char *str); + +__rte_internal int power_get_lcore_mapped_cpu_id(uint32_t lcore_id, uint32_t *cpu_id);#endif /* _POWER_COMMON_H_ */lib/power/rte_power.c index renamed from lib/power/rte_power.c +0
-0
36c3f3da98..416f0148a3100644lib/power/rte_power.c +1
-0@@ -6,155 +6,88 @@#include <rte_errno.h> #include <rte_spinlock.h> +#include <rte_debug.h> lib/power/rte_power.c line 14
Quoted 10 lines
lib/power/rte_power.c +1
-6#include "rte_power.h" -#include "power_acpi_cpufreq.h" -#include "power_cppc_cpufreq.h" #include "power_common.h" -#include "power_kvm_vm.h" -#include "power_pstate_cpufreq.h" -#include "power_amd_pstate_cpufreq.h" -enum power_management_env global_default_env =PM_ENV_NOT_SET ; +static enum power_management_env global_default_env =
PM_ENV_NOT_SET;Quoted 31 lines
lib/power/rte_power.c +1
-3+static struct rte_power_core_ops *global_power_core_ops;static rte_spinlock_t global_env_cfg_lock =RTE_SPINLOCK_INITIALIZER ; - -/* function pointers */ -rte_power_freqs_t rte_power_freqs =NULL ; -rte_power_get_freq_t
rte_power_get_freq= NULL; -rte_power_set_freq_trte_power_set_freq= NULL; -rte_power_freq_change_trte_power_freq_up= NULL;lib/power/rte_power.c +12
-10-rte_power_freq_change_t rte_power_freq_down =NULL ; -rte_power_freq_change_t rte_power_freq_max =NULL ; -rte_power_freq_change_t rte_power_freq_min =NULL ; -rte_power_freq_change_t rte_power_turbo_status; -rte_power_freq_change_t rte_power_freq_enable_turbo; -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 ) +static RTE_TAILQ_HEAD(, rte_power_core_ops) core_ops_list = +TAILQ_HEAD_INITIALIZER (core_ops_list); + +const char *power_env_str[] = { +"not set" , +"acpi" , +"kvm-vm" , +"pstate" , +"cppc" , +"amd-pstate" +}; +<...>
Quoted 80 lines
lib/power/rte_power.c +63
-0+uint32_t +rte_power_freqs (unsigned int lcore_id,uint32_t *freqs,uint32_t n) { +RTE_ASSERT (global_power_core_ops !=NULL ); +return global_power_core_ops->get_avail_freqs (lcore_id, freqs, +n); } + +uint32_t +rte_power_get_freq (unsigned int lcore_id) { +RTE_ASSERT (global_power_core_ops !=NULL ); +return global_power_core_ops->get_freq (lcore_id); +} + +uint32_t +rte_power_set_freq (unsigned int lcore_id,uint32_t index) { +RTE_ASSERT (global_power_core_ops !=NULL ); +return global_power_core_ops->set_freq (lcore_id, index); } + +int +rte_power_freq_up (unsigned int lcore_id) { +RTE_ASSERT (global_power_core_ops !=NULL ); +return global_power_core_ops->freq_up (lcore_id); +} + +int +rte_power_freq_down (unsigned int lcore_id) { +RTE_ASSERT (global_power_core_ops !=NULL ); +return global_power_core_ops->freq_down (lcore_id); +} + +int +rte_power_freq_max (unsigned int lcore_id) { +RTE_ASSERT (global_power_core_ops !=NULL ); +return global_power_core_ops->freq_max (lcore_id); +} + +int +rte_power_freq_min (unsigned int lcore_id) { +RTE_ASSERT (global_power_core_ops !=NULL ); +return global_power_core_ops->freq_min (lcore_id); +} +int +rte_power_turbo_status (unsigned int lcore_id) { +RTE_ASSERT (global_power_core_ops !=NULL ); +return global_power_core_ops->turbo_status (lcore_id); +} + +int +rte_power_freq_enable_turbo (unsigned int lcore_id) { +RTE_ASSERT (global_power_core_ops !=NULL ); +return global_power_core_ops->enable_turbo (lcore_id); +} + +int +rte_power_freq_disable_turbo (unsigned int lcore_id) { +RTE_ASSERT (global_power_core_ops !=NULL ); +return global_power_core_ops->disable_turbo (lcore_id); +} + +int +rte_power_get_capabilities (unsigned int lcore_id, +struct rte_power_core_capabilities *caps) { +RTE_ASSERT (global_power_core_ops !=NULL ); +return global_power_core_ops->get_caps (lcore_id, caps); }lib/power/rte_power.h index renamed from lib/power/rte_power.h +0
-0
4fa4afe399..e9a72b92ad100644lib/power/rte_power.h +1
-0@@ -1,5 +1,6 @@/* SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2010-2014 Intel Corporation +* Copyright(c) 2024 Advanced Micro Devices, Inc. */ #ifndef _RTE_POWER_H@@ -14,14 +15,21 @@#include <rte_log.h> #include <rte_power_guest_channel.h>
Quoted 10 lines
lib/power/rte_power.h line 18
Quoted 1 line
lib/power/rte_power.h +1
-0+#include "rte_power_cpufreq_api.h" From the name of
rte_power.candrte_power.h, they are supposed to work for all
power libraries I also proposed in previous version.
But rte_power.* currently just work for cpufreq lib. If we need to put all power components togeter and create it.
Now that therte_power_cpufreq_api.hhas been created for cpufreq library. How about directly renamerte_power.ctorte_poer_cpufreq_api.candrte_power.htorte_power_cpufreq_api.h?
There will be ABI changes, but it is allowed in this 24.11. If we plan to do it later, we'll have to wait another year.
Yes, I had split the rte_power.h as part of refactor to avoid exposing internal functions. Renaming rte_power.* to rte_power_cpufreq.* can be considered but not merge with rte_power_cpufreq_api.h
Quoted 19 lines
Quoted 18 lines
lib/power/rte_power.h +9
-2+ #ifdef __cplusplus extern "C" { #endif /* Power Management Environment State */ -enum power_management_env {PM_ENV_NOT_SET, PM_ENV_ACPI_CPUFREQ, PM_ENV_KVM_VM, - PM_ENV_PSTATE_CPUFREQ, PM_ENV_CPPC_CPUFREQ, - PM_ENV_AMD_PSTATE_CPUFREQ}; +enum power_management_env { + PM_ENV_NOT_SET = 0, + PM_ENV_ACPI_CPUFREQ, + PM_ENV_KVM_VM, + PM_ENV_PSTATE_CPUFREQ, + PM_ENV_CPPC_CPUFREQ, + PM_ENV_AMD_PSTATE_CPUFREQ +};<...>
Re: [PATCH v7 1/5] power: refactor core power management library
Quoted 353 lines · Sivaprasad
[AMD Official Use Only - AMD Internal Distribution Only]
Hi Huisong,
Please find my comments inline.
Quoted 172 lines
-----Original Message-----
From: lihuisong (C) <[email protected]>
Sent: Tuesday, October 22, 2024 8:33 AM
To: Tummala, Sivaprasad <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Yigit, Ferruh <[email protected]>
Subject: Re: [PATCH v7 1/5] power: refactor core power management libraryCaution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
Hi Sivaprasad,
Some comments inline.
Quoted 61 lines · Sivaprasad Tummala
This patch introduces a comprehensive refactor to the core power management library. The primary focus is on improving modularity and organization by relocating specific driver implementations from the 'lib/power' directory to dedicated directories within '
drivers/power/core/*'. The adjustment of meson.build files enables the selective activation of individual drivers.These changes contribute to a significant enhancement in code organization, providing a clearer structure for driver implementations. The refactor aims to improve overall code clarity and boost maintainability. Additionally, it establishes a foundation for future development, allowing for more focused work on individual drivers and seamless integration of forthcoming enhancements.
v6:
- fixed compilation error with symbol export in API
- exportedpower_get_lcore_mapped_cpu_idas internal API to be used indrivers/power/*v5:
- fixed code style warningv4:
- fixed build error withRTE_ASSERTv3:
- renamedrte_power_core_ops.hasrte_power_cpufreq_api.h
- re-worked on auto detection logicv2:
- added NULL check forglobal_core_opsinrte_power_get_core_opsSigned-off-by Sivaprasad Tummala <[email protected]>--- drivers/meson.build | 1 + .../power/acpi/acpi_cpufreq.c | 22 +- .../power/acpi/acpi_cpufreq.h | 6 +- drivers/power/acpi/meson.build | 10 + .../power/amd_pstate/amd_pstate_cpufreq.c | 24 +- .../power/amd_pstate/amd_pstate_cpufreq.h | 10 +- drivers/power/amd_pstate/meson.build | 10 + .../power/cppc/cppc_cpufreq.c | 22 +- .../power/cppc/cppc_cpufreq.h | 8 +- drivers/power/cppc/meson.build | 10 + .../power/kvm_vm}/guest_channel.c | 0 .../power/kvm_vm}/guest_channel.h | 0 .../power/kvm_vm/kvm_vm.c | 22 +- .../power/kvm_vm/kvm_vm.h | 6 +- drivers/power/kvm_vm/meson.build | 14 + drivers/power/meson.build | 12 + drivers/power/pstate/meson.build | 10 + .../power/pstate/pstate_cpufreq.c | 22 +- .../power/pstate/pstate_cpufreq.h | 6 +- lib/power/meson.build | 7 +- lib/power/power_common.c | 2 +- lib/power/power_common.h | 18 +- lib/power/rte_power.c | 355 ++++++++---------- lib/power/rte_power.h | 116 +++--- lib/power/rte_power_cpufreq_api.h | 206 ++++++++++ lib/power/version.map | 15 + 26 files changed, 665 insertions(+), 269 deletions(-)Quoted 1 line
rename
lib/power/power_acpi_cpufreq.c=>drivers/power/acpi/acpi_cpufreq.c(95%)
Quoted 1 line
rename
lib/power/power_acpi_cpufreq.h=>drivers/power/acpi/acpi_cpufreq.h(98%)
Quoted 2 lines
create mode 100644
drivers/power/acpi/meson.buildrenamelib/power/power_amd_pstate_cpufreq.c=>
drivers/power/amd_pstate/amd_pstate_cpufreq.c(95%)Quoted 1 line
rename
lib/power/power_amd_pstate_cpufreq.h=>
drivers/power/amd_pstate/amd_pstate_cpufreq.h(96%)Quoted 2 lines
create mode 100644
drivers/power/amd_pstate/meson.build
renamelib/power/power_cppc_cpufreq.c=>drivers/power/cppc/cppc_cpufreq.c(95%)
Quoted 1 line
rename
lib/power/power_cppc_cpufreq.h=>drivers/power/cppc/cppc_cpufreq.h(97%)
Quoted 9 lines
create mode 100644
drivers/power/cppc/meson.build
rename {lib/power =>drivers/power/kvm_vm}/guest_channel.c(100%) rename {lib/power =>drivers/power/kvm_vm}/guest_channel.h(100%) renamelib/power/power_kvm_vm.c=>drivers/power/kvm_vm/kvm_vm.c(82%) renamelib/power/power_kvm_vm.h=>drivers/power/kvm_vm/kvm_vm.h(98%) create mode 100644drivers/power/kvm_vm/meson.build
create mode 100644drivers/power/meson.build
create mode 100644drivers/power/pstate/meson.build
renamelib/power/power_pstate_cpufreq.c=>
drivers/power/pstate/pstate_cpufreq.c(96%)Quoted 1 line
rename
lib/power/power_pstate_cpufreq.h=>
drivers/power/pstate/pstate_cpufreq.h(98%)Quoted 29 lines
create mode 100644
lib/power/rte_power_cpufreq_api.hdrivers/meson.build index renamed from drivers/meson.build +0
-02733306698..7ef4f581a0 100644
drivers/meson.build +1
-0@@ -29,6 +29,7 @@ subdirs = [ 'event', # depends on common, bus, mempool and net. 'baseband', # depends on common and bus. 'gpu', # depends on common and bus. + 'power', # depends on common (in future). ] if meson.is_cross_build()drivers/power/acpi/acpi_cpufreq.c renamed from lib/power/power_acpi_cpufreq.c rename to +0
-0
drivers/power/acpi/acpi_cpufreq.cindexae809fbb60..974fbb7ba8100644drivers/power/acpi/acpi_cpufreq.c renamed from lib/power/power_acpi_cpufreq.c +1
-1@@ -10,7 +10,7 @@#include <rte_stdatomic.h> #include <rte_string_fns.h> -#include "power_acpi_cpufreq.h" +#include "acpi_cpufreq.h" #include "power_common.h" <...>
Quoted 36 lines
lib/power/power_common.c index renamed from lib/power/power_common.c +0
-0
b47c63a5f1..e482f71c64100644lib/power/power_common.c +1
-1@@ -13,7 +13,7 @@#include "power_common.h" -RTE_LOG_REGISTER_DEFAULT (power_logtype,INFO ); +RTE_LOG_REGISTER_DEFAULT (rte_power_logtype,INFO );#define POWER_SYSFILE_SCALING_DRIVER \ "/sys/devices/system/cpu/cpu%u/cpufreq/scaling_driver"lib/power/power_common.h index renamed from lib/power/power_common.h +0
-0
82fb94d0c0..c294f561bb100644lib/power/power_common.h +3
-2@@ -6,12 +6,13 @@#define _POWER_COMMON_H_#include <rte_common.h> +#include <rte_compat.h> #include <rte_log.h> #define RTE_POWER_INVALID_FREQ_INDEX (~0) -extern int power_logtype; -#define RTE_LOGTYPE_POWER power_logtype +extern int rte_power_logtype; +#define RTE_LOGTYPE_POWER rte_power_logtype#define POWER_LOG (level, ...) \ RTE_LOG_LINE(level, POWER, "" __VA_ARGS__)@@ -23,14 +24,27 @@ extern int power_logtype;#endif Quoted 12 lines
lib/power/power_common.h extern int power_logtype; · line 32
Quoted 7 lines
lib/power/power_common.h +3
-0/* check if scaling driver matches one we want */ +__rte_internal int cpufreq_check_scaling_driver(const char *driver); + +__rte_internal int power_set_governor(unsigned int lcore_id, const char *new_governor,char *orig_governor,size_t orig_governor_len);
cpufreq_check_scaling_driverandpower_set_governorare just used for cpufreq, they shouldn't be put in this common header file.
We've come to an aggrement in patch V2 1/4.
I guess you forget it😁
suggest that move these two APIs torte_power_cpufreq_api.h.OK!
Quoted 152 lines
Quoted 29 lines
lib/power/power_common.h +10
-0+ +__rte_internal int open_core_sysfs_file(FILE **f, const char *mode, const char *format, ...) __rte_format_printf(3, 4); + +__rte_internal int read_core_sysfs_u32(FILE *f, uint32_t *val); + +__rte_internal int read_core_sysfs_s(FILE *f, char *buf, unsigned int len); + +__rte_internal int write_core_sysfs_s(FILE *f, const char *str); + +__rte_internal int power_get_lcore_mapped_cpu_id(uint32_t lcore_id, uint32_t *cpu_id);#endif /* _POWER_COMMON_H_ */lib/power/rte_power.c index renamed from lib/power/rte_power.c +0
-0
36c3f3da98..416f0148a3100644lib/power/rte_power.c +1
-0@@ -6,155 +6,88 @@#include <rte_errno.h> #include <rte_spinlock.h> +#include <rte_debug.h> lib/power/rte_power.c line 14
Quoted 10 lines
lib/power/rte_power.c +1
-6#include "rte_power.h" -#include "power_acpi_cpufreq.h" -#include "power_cppc_cpufreq.h" #include "power_common.h" -#include "power_kvm_vm.h" -#include "power_pstate_cpufreq.h" -#include "power_amd_pstate_cpufreq.h" -enum power_management_env global_default_env =PM_ENV_NOT_SET ; +static enum power_management_env global_default_env =
PM_ENV_NOT_SET;Quoted 31 lines
lib/power/rte_power.c +1
-3+static struct rte_power_core_ops *global_power_core_ops;static rte_spinlock_t global_env_cfg_lock =RTE_SPINLOCK_INITIALIZER ; - -/* function pointers */ -rte_power_freqs_t rte_power_freqs =NULL ; -rte_power_get_freq_t
rte_power_get_freq= NULL; -rte_power_set_freq_trte_power_set_freq= NULL; -rte_power_freq_change_trte_power_freq_up= NULL;lib/power/rte_power.c +12
-10-rte_power_freq_change_t rte_power_freq_down =NULL ; -rte_power_freq_change_t rte_power_freq_max =NULL ; -rte_power_freq_change_t rte_power_freq_min =NULL ; -rte_power_freq_change_t rte_power_turbo_status; -rte_power_freq_change_t rte_power_freq_enable_turbo; -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 ) +static RTE_TAILQ_HEAD(, rte_power_core_ops) core_ops_list = +TAILQ_HEAD_INITIALIZER (core_ops_list); + +const char *power_env_str[] = { +"not set" , +"acpi" , +"kvm-vm" , +"pstate" , +"cppc" , +"amd-pstate" +}; +<...>
Quoted 80 lines
lib/power/rte_power.c +63
-0+uint32_t +rte_power_freqs (unsigned int lcore_id,uint32_t *freqs,uint32_t n) { +RTE_ASSERT (global_power_core_ops !=NULL ); +return global_power_core_ops->get_avail_freqs (lcore_id, freqs, +n); } + +uint32_t +rte_power_get_freq (unsigned int lcore_id) { +RTE_ASSERT (global_power_core_ops !=NULL ); +return global_power_core_ops->get_freq (lcore_id); +} + +uint32_t +rte_power_set_freq (unsigned int lcore_id,uint32_t index) { +RTE_ASSERT (global_power_core_ops !=NULL ); +return global_power_core_ops->set_freq (lcore_id, index); } + +int +rte_power_freq_up (unsigned int lcore_id) { +RTE_ASSERT (global_power_core_ops !=NULL ); +return global_power_core_ops->freq_up (lcore_id); +} + +int +rte_power_freq_down (unsigned int lcore_id) { +RTE_ASSERT (global_power_core_ops !=NULL ); +return global_power_core_ops->freq_down (lcore_id); +} + +int +rte_power_freq_max (unsigned int lcore_id) { +RTE_ASSERT (global_power_core_ops !=NULL ); +return global_power_core_ops->freq_max (lcore_id); +} + +int +rte_power_freq_min (unsigned int lcore_id) { +RTE_ASSERT (global_power_core_ops !=NULL ); +return global_power_core_ops->freq_min (lcore_id); +} +int +rte_power_turbo_status (unsigned int lcore_id) { +RTE_ASSERT (global_power_core_ops !=NULL ); +return global_power_core_ops->turbo_status (lcore_id); +} + +int +rte_power_freq_enable_turbo (unsigned int lcore_id) { +RTE_ASSERT (global_power_core_ops !=NULL ); +return global_power_core_ops->enable_turbo (lcore_id); +} + +int +rte_power_freq_disable_turbo (unsigned int lcore_id) { +RTE_ASSERT (global_power_core_ops !=NULL ); +return global_power_core_ops->disable_turbo (lcore_id); +} + +int +rte_power_get_capabilities (unsigned int lcore_id, +struct rte_power_core_capabilities *caps) { +RTE_ASSERT (global_power_core_ops !=NULL ); +return global_power_core_ops->get_caps (lcore_id, caps); }lib/power/rte_power.h index renamed from lib/power/rte_power.h +0
-0
4fa4afe399..e9a72b92ad100644lib/power/rte_power.h +1
-0@@ -1,5 +1,6 @@/* SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2010-2014 Intel Corporation +* Copyright(c) 2024 Advanced Micro Devices, Inc. */ #ifndef _RTE_POWER_H@@ -14,14 +15,21 @@#include <rte_log.h> #include <rte_power_guest_channel.h> Quoted 10 lines
lib/power/rte_power.h line 18
Quoted 1 line
lib/power/rte_power.h +1
-0+#include "rte_power_cpufreq_api.h" From the name of
rte_power.candrte_power.h, they are supposed to work for all
power libraries I also proposed in previous version.
But rte_power.* currently just work for cpufreq lib. If we need to put all power components togeter and create it.
Now that therte_power_cpufreq_api.hhas been created for cpufreq library. How about directly renamerte_power.ctorte_poer_cpufreq_api.candrte_power.htorte_power_cpufreq_api.h?
There will be ABI changes, but it is allowed in this 24.11. If we plan to do it later, we'll have to wait another year.
Quoted 2 lines
Yes, I had split the
rte_power.has part of refactor to avoid exposing internal functions. Renaming rte_power.* to rte_power_cpufreq.* can be considered but not merge withrte_power_cpufreq_api.h
What is your plan? I feel it is not very hard and just rename the file.
Quoted 19 lines
Quoted 19 lines
Quoted 18 lines
lib/power/rte_power.h +9
-2+ #ifdef __cplusplus extern "C" { #endif /* Power Management Environment State */ -enum power_management_env {PM_ENV_NOT_SET, PM_ENV_ACPI_CPUFREQ, PM_ENV_KVM_VM, - PM_ENV_PSTATE_CPUFREQ, PM_ENV_CPPC_CPUFREQ, - PM_ENV_AMD_PSTATE_CPUFREQ}; +enum power_management_env { + PM_ENV_NOT_SET = 0, + PM_ENV_ACPI_CPUFREQ, + PM_ENV_KVM_VM, + PM_ENV_PSTATE_CPUFREQ, + PM_ENV_CPPC_CPUFREQ, + PM_ENV_AMD_PSTATE_CPUFREQ +};<...>
PATCH v7 2/5 power: refactor uncore power management library
In reply to Sivaprasad TummalaiThis patch refactors the power management library, addressing uncore power management. The primary changes involve the creation of dedicated directories for each driver within 'drivers/power/uncore/*'. The adjustment of meson.build files enables the selective activation of individual drivers.
This refactor significantly improves code organization, enhances clarity and boosts maintainability. It lays the foundation for more focused development on individual drivers and facilitates seamless integration of future enhancements, particularly the AMD uncore driver.
v7:
- fixed build error with aarch32 gcc cross compilation
v6:
- fixed compilation error with symbol export in API
v5:
- fixed build errors for risc-v/ppc targets
v4:
- fixed build error with RTE_ASSERT
v3:
- fixed typo in header file inclusion
--- .../power/intel_uncore/intel_uncore.c | 18 +- .../power/intel_uncore/intel_uncore.h | 8 +- drivers/power/intel_uncore/meson.build | 6 + drivers/power/meson.build | 3 +- lib/power/meson.build | 2 +- lib/power/rte_power_uncore.c | 256 +++++++++--------- lib/power/rte_power_uncore.h | 61 ++--- lib/power/rte_power_uncore_ops.h | 230 ++++++++++++++++ lib/power/version.map | 1 + 9 files changed, 421 insertions(+), 164 deletions(-) rename lib/power/power_intel_uncore.c => drivers/power/intel_uncore/intel_uncore.c (95%) rename lib/power/power_intel_uncore.h => drivers/power/intel_uncore/intel_uncore.h (97%) create mode 100644 drivers/power/intel_uncore/meson.build create mode 100644 lib/power/rte_power_uncore_ops.h
drivers/power/intel_uncore/intel_uncore.c renamed from lib/power/power_intel_uncore.c +17 -1
@@ -8,7 +8,7 @@#include <rte_memcpy.h> -#include "power_intel_uncore.h" +#include "intel_uncore.h" #include "power_common.h" #define MAX_NUMA_DIE 8
@@ -475,3 +475,19 @@ power_intel_uncore_get_num_dies(unsigned int pkg)return count; } + +static struct rte_power_uncore_ops intel_uncore_ops = { + .name ="intel-uncore" , + .init = power_intel_uncore_init, + .exit = power_intel_uncore_exit, + .get_avail_freqs = power_intel_uncore_freqs, + .get_num_pkgs = power_intel_uncore_get_num_pkgs, + .get_num_dies = power_intel_uncore_get_num_dies, + .get_num_freqs = power_intel_uncore_get_num_freqs, + .get_freq = power_get_intel_uncore_freq, + .set_freq = power_set_intel_uncore_freq, + .freq_max = power_intel_uncore_freq_max, + .freq_min = power_intel_uncore_freq_min, +}; + +RTE_POWER_REGISTER_UNCORE_OPS (intel_uncore_ops);
drivers/power/intel_uncore/intel_uncore.h renamed from lib/power/power_intel_uncore.h +4 -4
@@ -2,8 +2,8 @@* Copyright(c) 2022 Intel Corporation */ -#ifndef POWER_INTEL_UNCORE_H -#define POWER_INTEL_UNCORE_H +#ifndef _INTEL_UNCORE_H +#define _INTEL_UNCORE_H/** * @file
@@ -11,7 +11,7 @@*/ #include "rte_power.h" -#include "rte_power_uncore.h" +#include "rte_power_uncore_ops.h" #ifdef __cplusplusextern "C" {
@@ -223,4 +223,4 @@ power_intel_uncore_get_num_dies(unsigned int pkg); }#endif -#endif /* POWER_INTEL_UNCORE_H */ +#endif /* _INTEL_UNCORE_H */
drivers/power/intel_uncore/meson.build new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2017 Intel Corporation +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +sources = files('intel_uncore.c') +deps += ['power']
drivers/power/meson.build +2 -1
@@ -6,7 +6,8 @@ drivers = [ 'amd_pstate', 'cppc', 'kvm_vm', - 'pstate' + 'pstate', + 'intel_uncore' ] std_deps = ['power']
lib/power/meson.build +1 -1
@@ -13,7 +13,6 @@ if not is_linux endif sources = files( 'power_common.c', - 'power_intel_uncore.c', 'rte_power.c', 'rte_power_uncore.c', 'rte_power_pmd_mgmt.c',
@@ -24,6 +23,7 @@ headers = files( 'rte_power_guest_channel.h', 'rte_power_pmd_mgmt.h', 'rte_power_uncore.h', + 'rte_power_uncore_ops.h', ) deps += ['timer', 'ethdev']
lib/power/rte_power_uncore.c +132 -124
313 lines not on this page · raw message
lib/power/rte_power_uncore.h +28 -33
125 lines not on this page · raw message
lib/power/rte_power_uncore_ops.h new file +230 -0
230 lines not on this page · raw message
lib/power/version.map +1 -0
@@ -59,6 +59,7 @@ INTERNAL { global: rte_power_register_ops; + rte_power_register_uncore_ops; cpufreq_check_scaling_driver; power_get_lcore_mapped_cpu_id; power_set_governor;
Signature · 1 line
2.34.1
Re: [PATCH v7 2/5] power: refactor uncore power management library
Quoted 15 lines · On Mon, 21 Oct 2024 04:07:20 +0000 Sivaprasad Tummala…
lib/power/rte_power_uncore_ops.h new file +9
-0@@ -0,0 +1,230 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2022 Intel Corporation +* Copyright(c) 2024 Advanced Micro Devices, Inc. +*/ + +#ifndef RTE_POWER_UNCORE_OPS_H +#define RTE_POWER_UNCORE_OPS_H + +/**
lib/power/rte_power_uncore_ops.h line 19
Quoted 10 lines
lib/power/rte_power_uncore_ops.h new file +10
-0+* @file +* RTE Uncore Frequency Management +*/ + +#include <rte_compat.h> +#include <rte_common.h> + +#ifdef __cplusplus +extern "C" { +#endif
Since this all internal doesn't really require C++ guards.
RE: [PATCH v7 2/5] power: refactor uncore power management library
[AMD Official Use Only - AMD Internal Distribution Only]
Hi Stephen,
Quoted 36 lines
-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Tuesday, October 22, 2024 6:49 AM
To: Tummala, Sivaprasad <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Yigit, Ferruh <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v7 2/5] power: refactor uncore power management libraryCaution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
Quoted 19 lines · On Mon, 21 Oct 2024 04:07:20 +0000 Sivaprasad Tummala…
lib/power/rte_power_uncore_ops.h new file +13
-0@@ -0,0 +1,230 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2022 Intel Corporation +* Copyright(c) 2024 Advanced Micro Devices, Inc. +*/ + +#ifndef RTE_POWER_UNCORE_OPS_H +#define RTE_POWER_UNCORE_OPS_H + +/** +* @file +* RTE Uncore Frequency Management +*/ +
Quoted 8 lines
lib/power/rte_power_uncore_ops.h line 19
Quoted 6 lines
lib/power/rte_power_uncore_ops.h new file +6
-0+#include <rte_compat.h> +#include <rte_common.h> + +#ifdef __cplusplus +extern "C" { +#endif Since this all internal doesn't really require C++ guards.
ACK!
Re: [PATCH v7 2/5] power: refactor uncore power management library
In reply to Sivaprasad TummalaLGTM except for one typo,
Quoted 1 line · Sivaprasad Tummala
iThis patch refactors the power management library, addressing uncore
iThis --> This
Quoted 24 lines
power management. The primary changes involve the creation of dedicated directories for each driver within '
drivers/power/uncore/*'. The adjustment of meson.build files enables the selective activation of individual drivers.This refactor significantly improves code organization, enhances clarity and boosts maintainability. It lays the foundation for more focused development on individual drivers and facilitates seamless integration of future enhancements, particularly the AMD uncore driver.
v7:
- fixed build error with aarch32 gcc cross compilationv6:
- fixed compilation error with symbol export in APIv5:
- fixed build errors for risc-v/ppc targetsv4:
- fixed build error withRTE_ASSERTv3:
- fixed typo in header file inclusion
<...>
RE: [PATCH v7 2/5] power: refactor uncore power management library
[AMD Official Use Only - AMD Internal Distribution Only]
Hi Huisong,
Quoted 39 lines
-----Original Message-----
From: lihuisong (C) <[email protected]>
Sent: Tuesday, October 22, 2024 8:47 AM
To: Tummala, Sivaprasad <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Yigit, Ferruh <[email protected]>; [email protected]
Subject: Re: [PATCH v7 2/5] power: refactor uncore power management libraryCaution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
LGTM except for one typo,
Acked-by Huisong Li <[email protected]>Quoted 1 line · Sivaprasad Tummala
iThis patch refactors the power management library, addressing uncore
iThis --> This
Quoted 19 lines
power management. The primary changes involve the creation of dedicated directories for each driver within '
drivers/power/uncore/*'. The adjustment of meson.build files enables the selective activation of individual drivers.This refactor significantly improves code organization, enhances clarity and boosts maintainability. It lays the foundation for more focused development on individual drivers and facilitates seamless integration of future enhancements, particularly the AMD uncore driver.
v7:
- fixed build error with aarch32 gcc cross compilationv6:
- fixed compilation error with symbol export in APIv5:
- fixed build errors for risc-v/ppc targets
Quoted 6 lines
Quoted 5 lines
v4:
- fixed build error withRTE_ASSERTv3:
- fixed typo in header file inclusion<...>
ACK! Will fix this in next version
PATCH v7 3/5 test/power: removed function pointer validations
In reply to Sivaprasad TummalaAfter refactoring the power library, power management operations are now consistently supported regardless of the operating environment, making function pointer checks unnecessary and thus removed from applications.
v2:
- removed function pointer validation in l3fwd-power app.
--- app/test/test_power.c | 95 ----------------------------------- app/test/test_power_cpufreq.c | 52 ------------------- app/test/test_power_kvm_vm.c | 36 ------------- examples/l3fwd-power/main.c | 12 ++--- 4 files changed, 4 insertions(+), 191 deletions(-)
app/test/test_power.c +0 -95
@@ -24,86 +24,6 @@ test_power(void)#include <rte_power.h> -static int -check_function_ptrs (void ) -{ -enum power_management_env env =rte_power_get_env (); - -const bool not_null_expected = !(env ==PM_ENV_NOT_SET ); - -const char *inject_not_string1 = not_null_expected ?" not" :"" ; -const char *inject_not_string2 = not_null_expected ?"" :" not" ; - -if ((rte_power_freqs ==NULL ) == not_null_expected) { -printf ("rte_power_freqs should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_get_freq ==NULL ) == not_null_expected) { -printf ("rte_power_get_freq should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_set_freq ==NULL ) == not_null_expected) { -printf ("rte_power_set_freq should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_freq_up ==NULL ) == not_null_expected) { -printf ("rte_power_freq_up should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_freq_down ==NULL ) == not_null_expected) { -printf ("rte_power_freq_down should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_freq_max ==NULL ) == not_null_expected) { -printf ("rte_power_freq_max should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_freq_min ==NULL ) == not_null_expected) { -printf ("rte_power_freq_min should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_turbo_status ==NULL ) == not_null_expected) { -printf ("rte_power_turbo_status should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_freq_enable_turbo ==NULL ) == not_null_expected) { -printf ("rte_power_freq_enable_turbo should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_freq_disable_turbo ==NULL ) == not_null_expected) { -printf ("rte_power_freq_disable_turbo should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_get_capabilities ==NULL ) == not_null_expected) { -printf ("rte_power_get_capabilities should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } - -return 0 ; -} -static int test_power (void ) {
@@ -124,10 +44,6 @@ test_power(void)return -1 ; } -/* Verify that function pointers are NULL */ -if (check_function_ptrs () <0 ) - goto fail_all; -rte_power_unset_env ();/* Perform tests for valid environments.*/
@@ -154,22 +70,11 @@ test_power(void) return -1; } -/* Verify that function pointers are NOT NULL */ -if (check_function_ptrs () <0 ) - goto fail_all; -rte_power_unset_env (); -/* Verify that function pointers are NULL */ -if (check_function_ptrs () <0 ) - goto fail_all; - }return 0 ; -fail_all: -rte_power_unset_env (); -return -1 ; }#endif
app/test/test_power_cpufreq.c +0 -52
58 lines not on this page · raw message
app/test/test_power_kvm_vm.c +0 -36
@@ -47,42 +47,6 @@ test_power_kvm_vm(void)return -1 ; } -/* verify that function pointers are not NULL */ -if (rte_power_freqs ==NULL ) { -printf ("rte_power_freqs should not be NULL, environment has not been " -"initialised\n" ); -return -1 ; - } -if (rte_power_get_freq ==NULL ) { -printf ("rte_power_get_freq should not be NULL, environment has not " -"been initialised\n" ); -return -1 ; - } -if (rte_power_set_freq ==NULL ) { -printf ("rte_power_set_freq should not be NULL, environment has not " -"been initialised\n" ); -return -1 ; - } -if (rte_power_freq_up ==NULL ) { -printf ("rte_power_freq_up should not be NULL, environment has not " -"been initialised\n" ); -return -1 ; - } -if (rte_power_freq_down ==NULL ) { -printf ("rte_power_freq_down should not be NULL, environment has not " -"been initialised\n" ); -return -1 ; - } -if (rte_power_freq_max ==NULL ) { -printf ("rte_power_freq_max should not be NULL, environment has not " -"been initialised\n" ); -return -1 ; - } -if (rte_power_freq_min ==NULL ) { -printf ("rte_power_freq_min should not be NULL, environment has not " -"been initialised\n" ); -return -1 ; - }/* Test initialisation of an out of bounds lcore */ ret =rte_power_init (TEST_POWER_VM_LCORE_OUT_OF_BOUNDS );if (ret !=-1 ) {
examples/l3fwd-power/main.c +4 -8
@@ -440,8 +440,7 @@ power_timer_cb(__rte_unused struct rte_timer *tim,* check whether need to scale down frequency a step if it sleep a lot. */ if (sleep_time_ratio >=SCALING_DOWN_TIME_RATIO_THRESHOLD ) { -if (rte_power_freq_down) -rte_power_freq_down (lcore_id); +rte_power_freq_down (lcore_id); }else if ( (unsigned )(stats[lcore_id].nb_rx_processed / stats[lcore_id].nb_iteration_looped) <MAX_PKT_BURST ) {
@@ -449,8 +448,7 @@ power_timer_cb(__rte_unused struct rte_timer *tim,* scale down a step if average packet per iteration less * than expectation. */ -if (rte_power_freq_down) -rte_power_freq_down (lcore_id); +rte_power_freq_down (lcore_id); }/**
@@ -1344,11 +1342,9 @@ main_legacy_loop(__rte_unused void *dummy) }if (lcore_scaleup_hint ==FREQ_HIGHEST ) { -if (rte_power_freq_max) -rte_power_freq_max (lcore_id); +rte_power_freq_max (lcore_id); }else if (lcore_scaleup_hint ==FREQ_HIGHER ) { -if (rte_power_freq_up) -rte_power_freq_up (lcore_id); +rte_power_freq_up (lcore_id); } }else {/**
Signature · 1 line
2.34.1
PATCH v7 4/5 drivers/power: uncore support for AMD EPYC processors
In reply to Sivaprasad TummalaThis patch introduces driver support for power management of uncore components in AMD EPYC processors.
v2:
- fixed typo in comments section.
- added fabric frequency get support for legacy platforms.
--- drivers/power/amd_uncore/amd_uncore.c | 329 ++++++++++++++++++++++++++ drivers/power/amd_uncore/amd_uncore.h | 226 ++++++++++++++++++ drivers/power/amd_uncore/meson.build | 20 ++ drivers/power/meson.build | 1 + 4 files changed, 576 insertions(+) create mode 100644 drivers/power/amd_uncore/amd_uncore.c create mode 100644 drivers/power/amd_uncore/amd_uncore.h create mode 100644 drivers/power/amd_uncore/meson.build
drivers/power/amd_uncore/amd_uncore.c new file +329 -0
@@ -0,0 +1,329 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2024 Advanced Micro Devices, Inc. +*/ + +#include <errno.h> +#include <dirent.h> +#include <fnmatch.h> + +#include <rte_memcpy.h> + +#include "amd_uncore.h" +#include "power_common.h" +#include "e_smi/e_smi.h" + +#define MAX_NUMA_DIE 8 + +struct __rte_cache_aligned uncore_power_info { +unsigned int die;/* Core die id */ +unsigned int pkg;/* Package id */ +uint32_t freqs[RTE_MAX_UNCORE_FREQS ];/* Frequency array */ +uint32_t nb_freqs;/* Number of available freqs */ +uint32_t curr_idx;/* Freq index in freqs array */ +uint32_t max_freq;/* System max uncore freq */ +uint32_t min_freq;/* System min uncore freq */ +}; + +static struct uncore_power_info uncore_info[RTE_MAX_NUMA_NODES ][MAX_NUMA_DIE ]; +static int esmi_initialized; +static unsigned int hsmp_proto_ver; + +static int +set_uncore_freq_internal (struct uncore_power_info *ui,uint32_t idx) +{ +int ret; + +if (idx >=RTE_MAX_UNCORE_FREQS || idx >= ui->nb_freqs) { +POWER_LOG (DEBUG ,"Invalid uncore frequency index %u, which " +"should be less than %u" , idx, ui->nb_freqs); +return -1 ; + } + + ret =esmi_apb_disable (ui->pkg, idx); +if (ret !=ESMI_SUCCESS ) { +POWER_LOG (ERR ,"DF P-state '%u' set failed for pkg %02u" , + idx, ui->pkg); +return -1 ; + } + +POWER_DEBUG_LOG ("DF P-state '%u' to be set for pkg %02u die %02u" , + idx, ui->pkg, ui->die); + +/* write the minimum value first if the target freq is less than current max */ + ui->curr_idx = idx; + +return 0 ; +} + +static int +power_init_for_setting_uncore_freq (struct uncore_power_info *ui) +{ +switch (hsmp_proto_ver) { +case HSMP_PROTO_VER5 : + ui->max_freq =1800000 ;/* Hz */ + ui->min_freq =1200000 ;/* Hz */ +break ; +case HSMP_PROTO_VER2 : +default : + ui->max_freq =1600000 ;/* Hz */ + ui->min_freq =1200000 ;/* Hz */ + } + +return 0 ; +} + +/* +* Get the available uncore frequencies of the specific die. +*/ +static int +power_get_available_uncore_freqs (struct uncore_power_info *ui) +{ + ui->nb_freqs =3 ; +if (ui->nb_freqs >=RTE_MAX_UNCORE_FREQS ) { +POWER_LOG (ERR ,"Too many available uncore frequencies: %d" , + ui->nb_freqs); +return -1 ; + } + +/* Generate the uncore freq bucket array. */ +switch (hsmp_proto_ver) { +case HSMP_PROTO_VER5 : + ui->freqs[0 ] =1800000 ; + ui->freqs[1 ] =1440000 ; + ui->freqs[2 ] =1200000 ; +break ; +case HSMP_PROTO_VER2 : +default : + ui->freqs[0 ] =1600000 ; + ui->freqs[1 ] =1333000 ; + ui->freqs[2 ] =1200000 ; + } + +POWER_DEBUG_LOG ("%d frequency(s) of pkg %02u die %02u are available" , + ui->num_uncore_freqs, ui->pkg, ui->die); + +return 0 ; +} + +static int +check_pkg_die_values (unsigned int pkg,unsigned int die) +{ +unsigned int max_pkgs, max_dies; + max_pkgs =power_amd_uncore_get_num_pkgs (); +if (max_pkgs ==0 ) +return -1 ; +if (pkg >= max_pkgs) { +POWER_LOG (DEBUG ,"Package number %02u can not exceed %u" , + pkg, max_pkgs); +return -1 ; + } + + max_dies =power_amd_uncore_get_num_dies (pkg); +if (max_dies ==0 ) +return -1 ; +if (die >= max_dies) { +POWER_LOG (DEBUG ,"Die number %02u can not exceed %u" , + die, max_dies); +return -1 ; + } + +return 0 ; +} + +static void +power_amd_uncore_esmi_init (void ) +{ +if (esmi_init () ==ESMI_SUCCESS ) { +if (esmi_hsmp_proto_ver_get (&hsmp_proto_ver) == +ESMI_SUCCESS ) + esmi_initialized =1 ; + } +} + +int +power_amd_uncore_init (unsigned int pkg,unsigned int die) +{ +struct uncore_power_info *ui; +int ret; + +if (!esmi_initialized) { + ret =esmi_init (); +if (ret !=ESMI_SUCCESS ) { +POWER_LOG (DEBUG ,"ESMI Not initialized, drivers not found" ); +return -1 ; + } + ret =esmi_hsmp_proto_ver_get (&hsmp_proto_ver); +if (ret !=ESMI_SUCCESS ) { +POWER_LOG (DEBUG ,"HSMP Proto Version Get failed with " +"error %s" ,esmi_get_err_msg (ret)); +esmi_exit (); +return -1 ; + } + esmi_initialized =1 ; + } + + ret =check_pkg_die_values (pkg, die); +if (ret <0 ) +return -1 ; + + ui = &uncore_info[pkg][die]; + ui->die = die; + ui->pkg = pkg; + +/* Init for setting uncore die frequency */ +if (power_init_for_setting_uncore_freq (ui) <0 ) { +POWER_LOG (DEBUG ,"Cannot init for setting uncore frequency for " +"pkg %02u die %02u" , pkg, die); +return -1 ; + } + +/* Get the available frequencies */ +if (power_get_available_uncore_freqs (ui) <0 ) { +POWER_LOG (DEBUG ,"Cannot get available uncore frequencies of " +"pkg %02u die %02u" , pkg, die); +return -1 ; + } + +return 0 ; +} + +int +power_amd_uncore_exit (unsigned int pkg,unsigned int die) +{ +struct uncore_power_info *ui; + +int ret =check_pkg_die_values (pkg, die); +if (ret <0 ) +return -1 ; + + ui = &uncore_info[pkg][die]; + ui->nb_freqs =0 ; + +if (esmi_initialized) { +esmi_exit (); + esmi_initialized =0 ; + } + +return 0 ; +} + +uint32_t +power_get_amd_uncore_freq (unsigned int pkg,unsigned int die) +{ +int ret =check_pkg_die_values (pkg, die); +if (ret <0 ) +return -1 ; + +return uncore_info[pkg][die].curr_idx; +} + +int +power_set_amd_uncore_freq (unsigned int pkg,unsigned int die,uint32_t index) +{ +int ret =check_pkg_die_values (pkg, die); +if (ret <0 ) +return -1 ; + +return set_uncore_freq_internal (&(uncore_info[pkg][die]), index); +} + +int +power_amd_uncore_freq_max (unsigned int pkg,unsigned int die) +{ +int ret =check_pkg_die_values (pkg, die); +if (ret <0 ) +return -1 ; + +return set_uncore_freq_internal (&(uncore_info[pkg][die]),0 ); +} + + +int +power_amd_uncore_freq_min (unsigned int pkg,unsigned int die) +{ +int ret =check_pkg_die_values (pkg, die); +if (ret <0 ) +return -1 ; + +struct uncore_power_info *ui = &uncore_info[pkg][die]; + +return set_uncore_freq_internal (&(uncore_info[pkg][die]), ui->nb_freqs -1 ); +} + +int +power_amd_uncore_freqs (unsigned int pkg,unsigned int die,uint32_t *freqs,uint32_t num) +{ +struct uncore_power_info *ui; + +int ret =check_pkg_die_values (pkg, die); +if (ret <0 ) +return -1 ; + +if (freqs ==NULL ) { +POWER_LOG (ERR ,"NULL buffer supplied" ); +return 0 ; + } + + ui = &uncore_info[pkg][die]; +if (num < ui->nb_freqs) { +POWER_LOG (ERR ,"Buffer size is not enough" ); +return 0 ; + } +rte_memcpy (freqs, ui->freqs, ui->nb_freqs *sizeof (uint32_t )); + +return ui->nb_freqs; +} + +int +power_amd_uncore_get_num_freqs (unsigned int pkg,unsigned int die) +{ +int ret =check_pkg_die_values (pkg, die); +if (ret <0 ) +return -1 ; + +return uncore_info[pkg][die].nb_freqs; +} + +unsigned int +power_amd_uncore_get_num_pkgs (void ) +{ +uint32_t num_pkgs =0 ; +int ret; + +if (esmi_initialized) { + ret =esmi_number_of_sockets_get (&num_pkgs); +if (ret !=ESMI_SUCCESS ) { +POWER_LOG (ERR ,"Failed to get number of sockets" ); + num_pkgs =0 ; + } + } +return num_pkgs; +} + +unsigned int +power_amd_uncore_get_num_dies (unsigned int pkg) +{ +if (pkg >=power_amd_uncore_get_num_pkgs ()) { +POWER_LOG (ERR ,"Invalid package ID" ); +return 0 ; + } + +return 1 ; +} + +static struct rte_power_uncore_ops amd_uncore_ops = { + .name ="amd-hsmp" , + .cb = power_amd_uncore_esmi_init, + .init = power_amd_uncore_init, + .exit = power_amd_uncore_exit, + .get_avail_freqs = power_amd_uncore_freqs, + .get_num_pkgs = power_amd_uncore_get_num_pkgs, + .get_num_dies = power_amd_uncore_get_num_dies, + .get_num_freqs = power_amd_uncore_get_num_freqs, + .get_freq = power_get_amd_uncore_freq, + .set_freq = power_set_amd_uncore_freq, + .freq_max = power_amd_uncore_freq_max, + .freq_min = power_amd_uncore_freq_min, +}; + +RTE_POWER_REGISTER_UNCORE_OPS (amd_uncore_ops);
drivers/power/amd_uncore/amd_uncore.h new file +226 -0
226 lines not on this page · raw message
drivers/power/amd_uncore/meson.build new file +20 -0
@@ -0,0 +1,20 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' + subdir_done() +endif + +ESMI_header = '#include<e_smi/e_smi.h>' +lib = cc.find_library('e_smi64', required: false) +if not lib.found() + build = false + reason = 'missing dependency, "libe_smi"' +else + ext_deps += lib +endif + +sources = files('amd_uncore.c') +deps += ['power']
drivers/power/meson.build +1 -0
@@ -7,6 +7,7 @@ drivers = [ 'cppc', 'kvm_vm', 'pstate', + 'amd_uncore', 'intel_uncore' ]
Signature · 1 line
2.34.1
PATCH v7 5/5 maintainers: update for drivers/power
In reply to Sivaprasad TummalaUpdate maintainers for drivers/power/*.
--- MAINTAINERS | 1 + 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
@@ -1744,6 +1744,7 @@ M: Anatoly Burakov <[email protected]> M: David Hunt <[email protected]> M: Sivaprasad Tummala <[email protected]> F: lib/power/ +F: drivers/power/* F: doc/guides/prog_guide/power_man.rst F: app/test/test_power* F: examples/l3fwd-power/
Signature · 1 line
2.34.1
v7 cover power: refactor power management library
In reply to Sivaprasad TummalaThis patchset refactors the power management library, addressing both core and uncore power management. The primary changes involve the creation of dedicated directories for each driver within 'drivers/power/core/*' and 'drivers/power/uncore/*'.
This refactor significantly improves code organization, enhances clarity, and boosts maintainability. It lays the foundation for more focused development on individual drivers and facilitates seamless integration of future enhancements, particularly the AMD uncore driver.
Furthermore, this effort aims to streamline code maintenance by consolidating common functions for cpufreq and cppc across various core drivers, thus reducing code duplication.
Sivaprasad Tummala (5):
power: refactor core power management library
power: refactor uncore power management library test/power: removed function pointer validations drivers/power: uncore support for AMD EPYC processors
maintainers: update for drivers/power
MAINTAINERS | 1 +
app/test/test_power.c | 95 -----
app/test/test_power_cpufreq.c | 52 ---
app/test/test_power_kvm_vm.c | 36 --
drivers/meson.build | 1 +
.../power/acpi/acpi_cpufreq.c | 22 +-
.../power/acpi/acpi_cpufreq.h | 6 +-
drivers/power/acpi/meson.build | 10 +
.../power/amd_pstate/amd_pstate_cpufreq.c | 24 +-
.../power/amd_pstate/amd_pstate_cpufreq.h | 10 +-
drivers/power/amd_pstate/meson.build | 10 +
drivers/power/amd_uncore/amd_uncore.c | 329 ++++++++++++++++
drivers/power/amd_uncore/amd_uncore.h | 226 +++++++++++
drivers/power/amd_uncore/meson.build | 20 +
.../power/cppc/cppc_cpufreq.c | 22 +-
.../power/cppc/cppc_cpufreq.h | 8 +-
drivers/power/cppc/meson.build | 10 +
.../power/intel_uncore/intel_uncore.c | 18 +-
.../power/intel_uncore/intel_uncore.h | 8 +-
drivers/power/intel_uncore/meson.build | 6 +
.../power/kvm_vm}/guest_channel.c | 0
.../power/kvm_vm}/guest_channel.h | 0
.../power/kvm_vm/kvm_vm.c | 22 +-
.../power/kvm_vm/kvm_vm.h | 6 +-
drivers/power/kvm_vm/meson.build | 14 +
drivers/power/meson.build | 14 +
drivers/power/pstate/meson.build | 10 +
.../power/pstate/pstate_cpufreq.c | 22 +-
.../power/pstate/pstate_cpufreq.h | 6 +-
examples/l3fwd-power/main.c | 12 +-
lib/power/meson.build | 9 +-
lib/power/power_common.c | 2 +-
lib/power/power_common.h | 18 +-
lib/power/rte_power.c | 355 ++++++++----------
lib/power/rte_power.h | 116 +++---
lib/power/rte_power_cpufreq_api.h | 206 ++++++++++
lib/power/rte_power_uncore.c | 256 +++++++------
lib/power/rte_power_uncore.h | 61 ++-
lib/power/rte_power_uncore_ops.h | 230 ++++++++++++
lib/power/version.map | 16 +
40 files changed, 1666 insertions(+), 623 deletions(-)
rename lib/power/power_acpi_cpufreq.c => drivers/power/acpi/acpi_cpufreq.c (95%)
rename lib/power/power_acpi_cpufreq.h => drivers/power/acpi/acpi_cpufreq.h (98%)
create mode 100644 drivers/power/acpi/meson.build
rename lib/power/power_amd_pstate_cpufreq.c => drivers/power/amd_pstate/amd_pstate_cpufreq.c (95%)
rename lib/power/power_amd_pstate_cpufreq.h => drivers/power/amd_pstate/amd_pstate_cpufreq.h (96%)
create mode 100644 drivers/power/amd_pstate/meson.build
create mode 100644 drivers/power/amd_uncore/amd_uncore.c
create mode 100644 drivers/power/amd_uncore/amd_uncore.h
create mode 100644 drivers/power/amd_uncore/meson.build
rename lib/power/power_cppc_cpufreq.c => drivers/power/cppc/cppc_cpufreq.c (95%)
rename lib/power/power_cppc_cpufreq.h => drivers/power/cppc/cppc_cpufreq.h (97%)
create mode 100644 drivers/power/cppc/meson.build
rename lib/power/power_intel_uncore.c => drivers/power/intel_uncore/intel_uncore.c (95%)
rename lib/power/power_intel_uncore.h => drivers/power/intel_uncore/intel_uncore.h (97%)
create mode 100644 drivers/power/intel_uncore/meson.build
rename {lib/power => drivers/power/kvm_vm}/guest_channel.c (100%)
rename {lib/power => drivers/power/kvm_vm}/guest_channel.h (100%)
rename lib/power/power_kvm_vm.c => drivers/power/kvm_vm/kvm_vm.c (82%)
rename lib/power/power_kvm_vm.h => drivers/power/kvm_vm/kvm_vm.h (98%)
create mode 100644 drivers/power/kvm_vm/meson.build
create mode 100644 drivers/power/meson.build
create mode 100644 drivers/power/pstate/meson.build
rename lib/power/power_pstate_cpufreq.c => drivers/power/pstate/pstate_cpufreq.c (96%)
rename lib/power/power_pstate_cpufreq.h => drivers/power/pstate/pstate_cpufreq.h (98%)
create mode 100644 lib/power/rte_power_cpufreq_api.h
create mode 100644 lib/power/rte_power_uncore_ops.hSignature · 1 line
2.34.1
Quoted 5 lines · On Mon, 21 Oct 2024 04:07:18 +0000 Sivaprasad Tummala…
This patchset refactors the power management library, addressing both core and uncore power management. The primary changes involve the creation of dedicated directories for each driver within '
drivers/power/core/*' and 'drivers/power/uncore/*'.
Quoted 8 lines
This refactor significantly improves code organization, enhances clarity, and boosts maintainability. It lays the foundation for more focused development on individual drivers and facilitates seamless integration of future enhancements, particularly the AMD uncore driver.
Furthermore, this effort aims to streamline code maintenance by consolidating common functions for cpufreq and cppc across various core drivers, thus reducing code duplication.
Looks good, a couple of minor things you could address later in other comments.
One other thing in the power internals would be to change:
int open_core_sysfs_file(FILE **f, const char *mode, const char *format, ...)
__rte_format_printf(3, 4);
to be similar to existing fopen()
FILE *fopen_sysfs_file(const char *mode, const char *format, ...)
__rte_format_printf(2, 3) __rte_malloc __rte_dealloc(fclose, 1)
That would catch if the file pointer was not handled correctly.
v8 cover power: refactor power management library
In reply to Sivaprasad TummalaThis patchset refactors the power management library, addressing both core and uncore power management. The primary changes involve the creation of dedicated directories for each driver within 'drivers/power/core/*' and 'drivers/power/uncore/*'.
This refactor significantly improves code organization, enhances clarity, and boosts maintainability. It lays the foundation for more focused development on individual drivers and facilitates seamless integration of future enhancements, particularly the AMD uncore driver.
Furthermore, this effort aims to streamline code maintenance by consolidating common functions for cpufreq and cppc across various core drivers, thus reducing code duplication.
Sivaprasad Tummala (6):
power: refactor core power management library
power: refactor uncore power management library test/power: removed function pointer validations drivers/power: uncore support for AMD EPYC processors
maintainers: update for drivers/power
power: rename library sources for cpu frequency management
MAINTAINERS | 1 +
app/test/test_power.c | 97 +-----
app/test/test_power_cpufreq.c | 54 +--
app/test/test_power_kvm_vm.c | 38 +-
drivers/meson.build | 1 +
.../power/acpi/acpi_cpufreq.c | 22 +-
.../power/acpi/acpi_cpufreq.h | 6 +-
drivers/power/acpi/meson.build | 10 +
.../power/amd_pstate/amd_pstate_cpufreq.c | 24 +-
.../power/amd_pstate/amd_pstate_cpufreq.h | 10 +-
drivers/power/amd_pstate/meson.build | 10 +
drivers/power/amd_uncore/amd_uncore.c | 329 ++++++++++++++++++
drivers/power/amd_uncore/amd_uncore.h | 225 ++++++++++++
drivers/power/amd_uncore/meson.build | 20 ++
.../power/cppc/cppc_cpufreq.c | 22 +-
.../power/cppc/cppc_cpufreq.h | 8 +-
drivers/power/cppc/meson.build | 10 +
.../power/intel_uncore/intel_uncore.c | 18 +-
.../power/intel_uncore/intel_uncore.h | 9 +-
drivers/power/intel_uncore/meson.build | 6 +
.../power/kvm_vm}/guest_channel.c | 2 +-
.../power/kvm_vm}/guest_channel.h | 0
.../power/kvm_vm/kvm_vm.c | 22 +-
.../power/kvm_vm/kvm_vm.h | 6 +-
drivers/power/kvm_vm/meson.build | 14 +
drivers/power/meson.build | 14 +
drivers/power/pstate/meson.build | 10 +
.../power/pstate/pstate_cpufreq.c | 22 +-
.../power/pstate/pstate_cpufreq.h | 6 +-
examples/distributor/main.c | 2 +-
examples/l3fwd-power/main.c | 14 +-
examples/l3fwd-power/perf_core.c | 2 +-
examples/vm_power_manager/channel_monitor.c | 2 +-
examples/vm_power_manager/channel_monitor.h | 2 +-
examples/vm_power_manager/guest_cli/main.c | 2 +-
.../guest_cli/vm_power_cli_guest.c | 2 +-
examples/vm_power_manager/power_manager.c | 2 +-
lib/power/meson.build | 13 +-
lib/power/power_common.c | 2 +-
lib/power/power_common.h | 18 +-
lib/power/power_cpufreq.h | 191 ++++++++++
lib/power/power_uncore_ops.h | 244 +++++++++++++
lib/power/rte_power.c | 257 --------------
lib/power/rte_power_cpufreq.c | 230 ++++++++++++
.../{rte_power.h => rte_power_cpufreq.h} | 120 ++++---
lib/power/rte_power_pmd_mgmt.h | 2 +-
lib/power/rte_power_uncore.c | 256 +++++++-------
lib/power/rte_power_uncore.h | 61 ++--
lib/power/version.map | 15 +
49 files changed, 1746 insertions(+), 707 deletions(-)
rename lib/power/power_acpi_cpufreq.c => drivers/power/acpi/acpi_cpufreq.c (95%)
rename lib/power/power_acpi_cpufreq.h => drivers/power/acpi/acpi_cpufreq.h (98%)
create mode 100644 drivers/power/acpi/meson.build
rename lib/power/power_amd_pstate_cpufreq.c => drivers/power/amd_pstate/amd_pstate_cpufreq.c (95%)
rename lib/power/power_amd_pstate_cpufreq.h => drivers/power/amd_pstate/amd_pstate_cpufreq.h (96%)
create mode 100644 drivers/power/amd_pstate/meson.build
create mode 100644 drivers/power/amd_uncore/amd_uncore.c
create mode 100644 drivers/power/amd_uncore/amd_uncore.h
create mode 100644 drivers/power/amd_uncore/meson.build
rename lib/power/power_cppc_cpufreq.c => drivers/power/cppc/cppc_cpufreq.c (95%)
rename lib/power/power_cppc_cpufreq.h => drivers/power/cppc/cppc_cpufreq.h (97%)
create mode 100644 drivers/power/cppc/meson.build
rename lib/power/power_intel_uncore.c => drivers/power/intel_uncore/intel_uncore.c (95%)
rename lib/power/power_intel_uncore.h => drivers/power/intel_uncore/intel_uncore.h (97%)
create mode 100644 drivers/power/intel_uncore/meson.build
rename {lib/power => drivers/power/kvm_vm}/guest_channel.c (99%)
rename {lib/power => drivers/power/kvm_vm}/guest_channel.h (100%)
rename lib/power/power_kvm_vm.c => drivers/power/kvm_vm/kvm_vm.c (82%)
rename lib/power/power_kvm_vm.h => drivers/power/kvm_vm/kvm_vm.h (98%)
create mode 100644 drivers/power/kvm_vm/meson.build
create mode 100644 drivers/power/meson.build
create mode 100644 drivers/power/pstate/meson.build
rename lib/power/power_pstate_cpufreq.c => drivers/power/pstate/pstate_cpufreq.c (96%)
rename lib/power/power_pstate_cpufreq.h => drivers/power/pstate/pstate_cpufreq.h (98%)
create mode 100644 lib/power/power_cpufreq.h
create mode 100644 lib/power/power_uncore_ops.h
delete mode 100644 lib/power/rte_power.c
create mode 100644 lib/power/rte_power_cpufreq.c
rename lib/power/{rte_power.h => rte_power_cpufreq.h} (73%)Signature · 1 line
2.34.1
PATCH v8 1/6 power: refactor core power management library
This patch introduces a comprehensive refactor to the core power management library. The primary focus is on improving modularity and organization by relocating specific driver implementations from the 'lib/power' directory to dedicated directories within 'drivers/power/core/*'. The adjustment of meson.build files enables the selective activation of individual drivers.
These changes contribute to a significant enhancement in code organization, providing a clearer structure for driver implementations. The refactor aims to improve overall code clarity and boost maintainability. Additionally, it establishes a foundation for future development, allowing for more focused work on individual drivers and seamless integration of forthcoming enhancements.
v8:
- marked rte_power_logtype as internal
- removed c++ guards for internal header files
- renamed rte_power_cpufreq_api.h for naming convention
- renamed rte_power_register_ops for naming convention
v6:
- fixed compilation error with symbol export in API
- exported power_get_lcore_mapped_cpu_id as internal API to be used in drivers/power/*
v5:
- fixed code style warning
v4:
- fixed build error with RTE_ASSERT
v3:
- renamed rte_power_core_ops.h as rte_power_cpufreq_api.h
- re-worked on auto detection logic
v2:
- added NULL check for global_core_ops in rte_power_get_core_ops
---
drivers/meson.build | 1 +
.../power/acpi/acpi_cpufreq.c | 22 +-
.../power/acpi/acpi_cpufreq.h | 6 +-
drivers/power/acpi/meson.build | 10 +
.../power/amd_pstate/amd_pstate_cpufreq.c | 24 +-
.../power/amd_pstate/amd_pstate_cpufreq.h | 10 +-
drivers/power/amd_pstate/meson.build | 10 +
.../power/cppc/cppc_cpufreq.c | 22 +-
.../power/cppc/cppc_cpufreq.h | 8 +-
drivers/power/cppc/meson.build | 10 +
.../power/kvm_vm}/guest_channel.c | 2 +-
.../power/kvm_vm}/guest_channel.h | 0
.../power/kvm_vm/kvm_vm.c | 22 +-
.../power/kvm_vm/kvm_vm.h | 6 +-
drivers/power/kvm_vm/meson.build | 14 +
drivers/power/meson.build | 12 +
drivers/power/pstate/meson.build | 10 +
.../power/pstate/pstate_cpufreq.c | 22 +-
.../power/pstate/pstate_cpufreq.h | 6 +-
lib/power/meson.build | 7 +-
lib/power/power_common.c | 2 +-
lib/power/power_common.h | 18 +-
lib/power/power_cpufreq.h | 191 ++++++++++
lib/power/rte_power.c | 355 ++++++++----------
lib/power/rte_power.h | 116 +++---
lib/power/version.map | 14 +
26 files changed, 650 insertions(+), 270 deletions(-)
rename lib/power/power_acpi_cpufreq.c => drivers/power/acpi/acpi_cpufreq.c (95%)
rename lib/power/power_acpi_cpufreq.h => drivers/power/acpi/acpi_cpufreq.h (98%)
create mode 100644 drivers/power/acpi/meson.build
rename lib/power/power_amd_pstate_cpufreq.c => drivers/power/amd_pstate/amd_pstate_cpufreq.c (95%)
rename lib/power/power_amd_pstate_cpufreq.h => drivers/power/amd_pstate/amd_pstate_cpufreq.h (96%)
create mode 100644 drivers/power/amd_pstate/meson.build
rename lib/power/power_cppc_cpufreq.c => drivers/power/cppc/cppc_cpufreq.c (95%)
rename lib/power/power_cppc_cpufreq.h => drivers/power/cppc/cppc_cpufreq.h (97%)
create mode 100644 drivers/power/cppc/meson.build
rename {lib/power => drivers/power/kvm_vm}/guest_channel.c (99%)
rename {lib/power => drivers/power/kvm_vm}/guest_channel.h (100%)
rename lib/power/power_kvm_vm.c => drivers/power/kvm_vm/kvm_vm.c (82%)
rename lib/power/power_kvm_vm.h => drivers/power/kvm_vm/kvm_vm.h (98%)
create mode 100644 drivers/power/kvm_vm/meson.build
create mode 100644 drivers/power/meson.build
create mode 100644 drivers/power/pstate/meson.build
rename lib/power/power_pstate_cpufreq.c => drivers/power/pstate/pstate_cpufreq.c (96%)
rename lib/power/power_pstate_cpufreq.h => drivers/power/pstate/pstate_cpufreq.h (98%)
create mode 100644 lib/power/power_cpufreq.hdrivers/meson.build +1 -0
@@ -29,6 +29,7 @@ subdirs = [ 'event', # depends on common, bus, mempool and net. 'baseband', # depends on common and bus. 'gpu', # depends on common and bus. + 'power', # depends on common (in future). ] if meson.is_cross_build()
drivers/power/acpi/acpi_cpufreq.c renamed from lib/power/power_acpi_cpufreq.c +21 -1
@@ -10,7 +10,7 @@#include <rte_stdatomic.h> #include <rte_string_fns.h> -#include "power_acpi_cpufreq.h" +#include "acpi_cpufreq.h" #include "power_common.h" #define STR_SIZE 1024
@@ -587,3 +587,23 @@ int power_acpi_get_capabilities(unsigned int lcore_id,return 0 ; } + +static struct rte_power_cpufreq_ops acpi_ops = { + .name ="acpi" , + .init = power_acpi_cpufreq_init, + .exit = power_acpi_cpufreq_exit, + .check_env_support = power_acpi_cpufreq_check_supported, + .get_avail_freqs = power_acpi_cpufreq_freqs, + .get_freq = power_acpi_cpufreq_get_freq, + .set_freq = power_acpi_cpufreq_set_freq, + .freq_down = power_acpi_cpufreq_freq_down, + .freq_up = power_acpi_cpufreq_freq_up, + .freq_max = power_acpi_cpufreq_freq_max, + .freq_min = power_acpi_cpufreq_freq_min, + .turbo_status = power_acpi_turbo_status, + .enable_turbo = power_acpi_enable_turbo, + .disable_turbo = power_acpi_disable_turbo, + .get_caps = power_acpi_get_capabilities +}; + +RTE_POWER_REGISTER_CPUFREQ_OPS (acpi_ops);
drivers/power/acpi/acpi_cpufreq.h renamed from lib/power/power_acpi_cpufreq.h +3 -3
@@ -2,15 +2,15 @@* Copyright(c) 2010-2014 Intel Corporation */ -#ifndef _POWER_ACPI_CPUFREQ_H -#define _POWER_ACPI_CPUFREQ_H +#ifndef _ACPI_CPUFREQ_H +#define _ACPI_CPUFREQ_H/** * @file * RTE Power Management via userspace ACPI cpufreq */ -#include "rte_power.h" +#include "power_cpufreq.h" /** * Check if ACPI power management is supported.
drivers/power/acpi/meson.build new file +10 -0
@@ -0,0 +1,10 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' +endif +sources = files('acpi_cpufreq.c') + +deps += ['power']
drivers/power/amd_pstate/amd_pstate_cpufreq.c renamed from lib/power/power_amd_pstate_cpufreq.c +22 -2
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2010-2021 Intel Corporation * Copyright(c) 2021 Arm Limited -* Copyright(c) 2023 Amd Limited +* Copyright(c) 2024 Advanced Micro Devices, Inc. */ #include <stdlib.h>
@@ -9,7 +9,7 @@#include <rte_memcpy.h> #include <rte_stdatomic.h> -#include "power_amd_pstate_cpufreq.h" +#include "amd_pstate_cpufreq.h" #include "power_common.h" /* macros used for rounding frequency to nearest 1000 */
@@ -710,3 +710,23 @@ power_amd_pstate_get_capabilities(unsigned int lcore_id,return 0 ; } + +static struct rte_power_cpufreq_ops amd_pstate_ops = { + .name ="amd-pstate" , + .init = power_amd_pstate_cpufreq_init, + .exit = power_amd_pstate_cpufreq_exit, + .check_env_support = power_amd_pstate_cpufreq_check_supported, + .get_avail_freqs = power_amd_pstate_cpufreq_freqs, + .get_freq = power_amd_pstate_cpufreq_get_freq, + .set_freq = power_amd_pstate_cpufreq_set_freq, + .freq_down = power_amd_pstate_cpufreq_freq_down, + .freq_up = power_amd_pstate_cpufreq_freq_up, + .freq_max = power_amd_pstate_cpufreq_freq_max, + .freq_min = power_amd_pstate_cpufreq_freq_min, + .turbo_status = power_amd_pstate_turbo_status, + .enable_turbo = power_amd_pstate_enable_turbo, + .disable_turbo = power_amd_pstate_disable_turbo, + .get_caps = power_amd_pstate_get_capabilities +}; + +RTE_POWER_REGISTER_CPUFREQ_OPS (amd_pstate_ops);
drivers/power/amd_pstate/amd_pstate_cpufreq.h renamed from lib/power/power_amd_pstate_cpufreq.h +5 -5
@@ -1,18 +1,18 @@/* SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2010-2021 Intel Corporation * Copyright(c) 2021 Arm Limited -* Copyright(c) 2023 Amd Limited +* Copyright(c) 2024 Advanced Micro Devices, Inc. */ -#ifndef _POWER_AMD_PSTATE_CPUFREQ_H -#define _POWER_AMD_PSTATE_CPUFREQ_H +#ifndef _AMD_PSTATE_CPUFREQ_H +#define _AMD_PSTATE_CPUFREQ_H/** * @file * RTE Power Management via userspace AMD pstate cpufreq */ -#include "rte_power.h" +#include "power_cpufreq.h" /** * Check if amd p-state power management is supported.
@@ -216,4 +216,4 @@ int power_amd_pstate_disable_turbo(unsigned int lcore_id);int power_amd_pstate_get_capabilities (unsigned int lcore_id,struct rte_power_core_capabilities *caps); -#endif /* _POWER_AMD_PSTATET_CPUFREQ_H */ +#endif /* _AMD_PSTATET_CPUFREQ_H */
drivers/power/amd_pstate/meson.build new file +10 -0
@@ -0,0 +1,10 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' +endif +sources = files('amd_pstate_cpufreq.c') + +deps += ['power']
drivers/power/cppc/cppc_cpufreq.c renamed from lib/power/power_cppc_cpufreq.c +21 -1
@@ -8,7 +8,7 @@#include <rte_memcpy.h> #include <rte_stdatomic.h> -#include "power_cppc_cpufreq.h" +#include "cppc_cpufreq.h" #include "power_common.h" /* macros used for rounding frequency to nearest 100000 */
@@ -695,3 +695,23 @@ power_cppc_get_capabilities(unsigned int lcore_id,return 0 ; } + +static struct rte_power_cpufreq_ops cppc_ops = { + .name ="cppc" , + .init = power_cppc_cpufreq_init, + .exit = power_cppc_cpufreq_exit, + .check_env_support = power_cppc_cpufreq_check_supported, + .get_avail_freqs = power_cppc_cpufreq_freqs, + .get_freq = power_cppc_cpufreq_get_freq, + .set_freq = power_cppc_cpufreq_set_freq, + .freq_down = power_cppc_cpufreq_freq_down, + .freq_up = power_cppc_cpufreq_freq_up, + .freq_max = power_cppc_cpufreq_freq_max, + .freq_min = power_cppc_cpufreq_freq_min, + .turbo_status = power_cppc_turbo_status, + .enable_turbo = power_cppc_enable_turbo, + .disable_turbo = power_cppc_disable_turbo, + .get_caps = power_cppc_get_capabilities +}; + +RTE_POWER_REGISTER_CPUFREQ_OPS (cppc_ops);
drivers/power/cppc/cppc_cpufreq.h renamed from lib/power/power_cppc_cpufreq.h +4 -4
@@ -3,15 +3,15 @@* Copyright(c) 2021 Arm Limited */ -#ifndef _POWER_CPPC_CPUFREQ_H -#define _POWER_CPPC_CPUFREQ_H +#ifndef _CPPC_CPUFREQ_H +#define _CPPC_CPUFREQ_H/** * @file * RTE Power Management via userspace CPPC cpufreq */ -#include "rte_power.h" +#include "power_cpufreq.h" /** * Check if CPPC power management is supported.
@@ -215,4 +215,4 @@ int power_cppc_disable_turbo(unsigned int lcore_id);int power_cppc_get_capabilities (unsigned int lcore_id,struct rte_power_core_capabilities *caps); -#endif /* _POWER_CPPC_CPUFREQ_H */ +#endif /* _CPPC_CPUFREQ_H */
drivers/power/cppc/meson.build new file +10 -0
@@ -0,0 +1,10 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' +endif +sources = files('cppc_cpufreq.c') + +deps += ['power']
drivers/power/kvm_vm/guest_channel.c renamed from lib/power/guest_channel.c +1 -1
@@ -13,7 +13,7 @@#include <rte_log.h> -#include <rte_power.h> +#include <rte_power_guest_channel.h> #include "guest_channel.h"
drivers/power/kvm_vm/guest_channel.h renamed from lib/power/guest_channel.h +0 -0
drivers/power/kvm_vm/kvm_vm.c renamed from lib/power/power_kvm_vm.c +21 -1
@@ -9,7 +9,7 @@#include "rte_power_guest_channel.h" #include "guest_channel.h" #include "power_common.h" -#include "power_kvm_vm.h" +#include "kvm_vm.h" #define FD_PATH "/dev/virtio-ports/virtio.serial.port.poweragent"
@@ -137,3 +137,23 @@ int power_kvm_vm_get_capabilities(__rte_unused unsigned int lcore_id,POWER_LOG (ERR ,"rte_power_get_capabilities is not implemented for Virtual Machine Power Management" );return -ENOTSUP ; } + +static struct rte_power_cpufreq_ops kvm_vm_ops = { + .name ="kvm-vm" , + .init = power_kvm_vm_init, + .exit = power_kvm_vm_exit, + .check_env_support = power_kvm_vm_check_supported, + .get_avail_freqs = power_kvm_vm_freqs, + .get_freq = power_kvm_vm_get_freq, + .set_freq = power_kvm_vm_set_freq, + .freq_down = power_kvm_vm_freq_down, + .freq_up = power_kvm_vm_freq_up, + .freq_max = power_kvm_vm_freq_max, + .freq_min = power_kvm_vm_freq_min, + .turbo_status = power_kvm_vm_turbo_status, + .enable_turbo = power_kvm_vm_enable_turbo, + .disable_turbo = power_kvm_vm_disable_turbo, + .get_caps = power_kvm_vm_get_capabilities +}; + +RTE_POWER_REGISTER_CPUFREQ_OPS (kvm_vm_ops);
drivers/power/kvm_vm/kvm_vm.h renamed from lib/power/power_kvm_vm.h +3 -3
@@ -2,15 +2,15 @@* Copyright(c) 2010-2014 Intel Corporation */ -#ifndef _POWER_KVM_VM_H -#define _POWER_KVM_VM_H +#ifndef _KVM_VM_H +#define _KVM_VM_H/** * @file * RTE Power Management KVM VM */ -#include "rte_power.h" +#include "power_cpufreq.h" /** * Check if KVM power management is supported.
drivers/power/kvm_vm/meson.build new file +14 -0
@@ -0,0 +1,14 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' + subdir_done() +endif +sources = files( + 'guest_channel.c', + 'kvm_vm.c', +) + +deps += ['power']
drivers/power/meson.build new file +12 -0
@@ -0,0 +1,12 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +drivers = [ + 'acpi', + 'amd_pstate', + 'cppc', + 'kvm_vm', + 'pstate' +] + +std_deps = ['power']
drivers/power/pstate/meson.build new file +10 -0
@@ -0,0 +1,10 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' +endif +sources = files('pstate_cpufreq.c') + +deps += ['power']
drivers/power/pstate/pstate_cpufreq.c renamed from lib/power/power_pstate_cpufreq.c +21 -1
@@ -15,7 +15,7 @@#include <rte_stdatomic.h> #include "rte_power_pmd_mgmt.h" -#include "power_pstate_cpufreq.h" +#include "pstate_cpufreq.h" #include "power_common.h" /* macros used for rounding frequency to nearest 100000 */
@@ -898,3 +898,23 @@ int power_pstate_get_capabilities(unsigned int lcore_id,return 0 ; } + +static struct rte_power_cpufreq_ops pstate_ops = { + .name ="pstate" , + .init = power_pstate_cpufreq_init, + .exit = power_pstate_cpufreq_exit, + .check_env_support = power_pstate_cpufreq_check_supported, + .get_avail_freqs = power_pstate_cpufreq_freqs, + .get_freq = power_pstate_cpufreq_get_freq, + .set_freq = power_pstate_cpufreq_set_freq, + .freq_down = power_pstate_cpufreq_freq_down, + .freq_up = power_pstate_cpufreq_freq_up, + .freq_max = power_pstate_cpufreq_freq_max, + .freq_min = power_pstate_cpufreq_freq_min, + .turbo_status = power_pstate_turbo_status, + .enable_turbo = power_pstate_enable_turbo, + .disable_turbo = power_pstate_disable_turbo, + .get_caps = power_pstate_get_capabilities +}; + +RTE_POWER_REGISTER_CPUFREQ_OPS (pstate_ops);
drivers/power/pstate/pstate_cpufreq.h renamed from lib/power/power_pstate_cpufreq.h +3 -3
@@ -2,15 +2,15 @@* Copyright(c) 2018 Intel Corporation */ -#ifndef _POWER_PSTATE_CPUFREQ_H -#define _POWER_PSTATE_CPUFREQ_H +#ifndef _PSTATE_CPUFREQ_H +#define _PSTATE_CPUFREQ_H/** * @file * RTE Power Management via Intel Pstate driver */ -#include "rte_power.h" +#include "power_cpufreq.h" /** * Check if pstate power management is supported.
lib/power/meson.build +1 -6
@@ -12,19 +12,14 @@ if not is_linux reason = 'only supported on Linux' endif sources = files( - 'guest_channel.c', - 'power_acpi_cpufreq.c', - 'power_amd_pstate_cpufreq.c', 'power_common.c', - 'power_cppc_cpufreq.c', - 'power_kvm_vm.c', 'power_intel_uncore.c', - 'power_pstate_cpufreq.c', 'rte_power.c', 'rte_power_uncore.c', 'rte_power_pmd_mgmt.c', ) headers = files( + 'power_cpufreq.h', 'rte_power.h', 'rte_power_guest_channel.h', 'rte_power_pmd_mgmt.h',
lib/power/power_common.c +1 -1
@@ -13,7 +13,7 @@#include "power_common.h" -RTE_LOG_REGISTER_DEFAULT (power_logtype,INFO ); +RTE_LOG_REGISTER_DEFAULT (rte_power_logtype,INFO );#define POWER_SYSFILE_SCALING_DRIVER \ "/sys/devices/system/cpu/cpu%u/cpufreq/scaling_driver"
lib/power/power_common.h +16 -2
@@ -6,12 +6,13 @@#define _POWER_COMMON_H_#include <rte_common.h> +#include <rte_compat.h> #include <rte_log.h> #define RTE_POWER_INVALID_FREQ_INDEX (~0) -extern int power_logtype; -#define RTE_LOGTYPE_POWER power_logtype +extern int rte_power_logtype; +#define RTE_LOGTYPE_POWER rte_power_logtype#define POWER_LOG (level, ...) \ RTE_LOG_LINE(level, POWER, "" __VA_ARGS__)
@@ -23,14 +24,27 @@ extern int power_logtype;#endif /* check if scaling driver matches one we want */ +__rte_internal int cpufreq_check_scaling_driver(const char *driver); + +__rte_internal int power_set_governor(unsigned int lcore_id, const char *new_governor,char *orig_governor,size_t orig_governor_len); + +__rte_internal int open_core_sysfs_file(FILE **f, const char *mode, const char *format, ...) __rte_format_printf(3, 4); + +__rte_internal int read_core_sysfs_u32(FILE *f, uint32_t *val); + +__rte_internal int read_core_sysfs_s(FILE *f, char *buf, unsigned int len); + +__rte_internal int write_core_sysfs_s(FILE *f, const char *str); + +__rte_internal int power_get_lcore_mapped_cpu_id(uint32_t lcore_id, uint32_t *cpu_id);#endif /* _POWER_COMMON_H_ */
lib/power/power_cpufreq.h new file +191 -0
191 lines not on this page · raw message
lib/power/rte_power.c +164 -191
408 lines not on this page · raw message
lib/power/rte_power.h +71 -45
199 lines not on this page · raw message
lib/power/version.map +14 -0
@@ -52,3 +52,17 @@ EXPERIMENTAL { rte_power_uncore_freqs; rte_power_unset_uncore_env; }; + +INTERNAL { + global: + + rte_power_register_cpufreq_ops; + rte_power_logtype; + cpufreq_check_scaling_driver; + power_get_lcore_mapped_cpu_id; + power_set_governor; + open_core_sysfs_file; + read_core_sysfs_u32; + read_core_sysfs_s; + write_core_sysfs_s; +};
Signature · 1 line
2.34.1
PATCH v8 2/6 power: refactor uncore power management library
In reply to Sivaprasad TummalaThis patch refactors the power management library, addressing uncore power management. The primary changes involve the creation of dedicated directories for each driver within 'drivers/power/uncore/*'. The adjustment of meson.build files enables the selective activation of individual drivers.
This refactor significantly improves code organization, enhances clarity and boosts maintainability. It lays the foundation for more focused development on individual drivers and facilitates seamless integration of future enhancements, particularly the AMD uncore driver.
v8:
- removed c++ guards for internal header files
- renamed rte_power_uncore_ops.h for naming convention
v7:
- fixed build error with aarch32 gcc cross compilation
v6:
- fixed compilation error with symbol export in API
v5:
- fixed build errors for risc-v/ppc targets
v4:
- fixed build error with RTE_ASSERT
--- .../power/intel_uncore/intel_uncore.c | 18 +- .../power/intel_uncore/intel_uncore.h | 9 +- drivers/power/intel_uncore/meson.build | 6 + drivers/power/meson.build | 3 +- lib/power/meson.build | 2 +- lib/power/power_uncore_ops.h | 244 +++++++++++++++++ lib/power/rte_power_uncore.c | 256 +++++++++--------- lib/power/rte_power_uncore.h | 61 ++--- lib/power/version.map | 1 + 9 files changed, 435 insertions(+), 165 deletions(-) rename lib/power/power_intel_uncore.c => drivers/power/intel_uncore/intel_uncore.c (95%) rename lib/power/power_intel_uncore.h => drivers/power/intel_uncore/intel_uncore.h (97%) create mode 100644 drivers/power/intel_uncore/meson.build create mode 100644 lib/power/power_uncore_ops.h
drivers/power/intel_uncore/intel_uncore.c renamed from lib/power/power_intel_uncore.c +17 -1
@@ -8,7 +8,7 @@#include <rte_memcpy.h> -#include "power_intel_uncore.h" +#include "intel_uncore.h" #include "power_common.h" #define MAX_NUMA_DIE 8
@@ -475,3 +475,19 @@ power_intel_uncore_get_num_dies(unsigned int pkg)return count; } + +static struct rte_power_uncore_ops intel_uncore_ops = { + .name ="intel-uncore" , + .init = power_intel_uncore_init, + .exit = power_intel_uncore_exit, + .get_avail_freqs = power_intel_uncore_freqs, + .get_num_pkgs = power_intel_uncore_get_num_pkgs, + .get_num_dies = power_intel_uncore_get_num_dies, + .get_num_freqs = power_intel_uncore_get_num_freqs, + .get_freq = power_get_intel_uncore_freq, + .set_freq = power_set_intel_uncore_freq, + .freq_max = power_intel_uncore_freq_max, + .freq_min = power_intel_uncore_freq_min, +}; + +RTE_POWER_REGISTER_UNCORE_OPS (intel_uncore_ops);
drivers/power/intel_uncore/intel_uncore.h renamed from lib/power/power_intel_uncore.h +4 -5
@@ -2,16 +2,15 @@* Copyright(c) 2022 Intel Corporation */ -#ifndef POWER_INTEL_UNCORE_H -#define POWER_INTEL_UNCORE_H +#ifndef _INTEL_UNCORE_H +#define _INTEL_UNCORE_H /** * @file * RTE Intel Uncore Frequency Management */ -#include "rte_power.h" -#include "rte_power_uncore.h" +#include "power_uncore_ops.h" #ifdef __cplusplus extern "C" {
@@ -223,4 +222,4 @@ power_intel_uncore_get_num_dies(unsigned int pkg); }#endif -#endif /* POWER_INTEL_UNCORE_H */ +#endif /* _INTEL_UNCORE_H */
drivers/power/intel_uncore/meson.build new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2017 Intel Corporation +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +sources = files('intel_uncore.c') +deps += ['power']
drivers/power/meson.build +2 -1
@@ -6,7 +6,8 @@ drivers = [ 'amd_pstate', 'cppc', 'kvm_vm', - 'pstate' + 'pstate', + 'intel_uncore' ] std_deps = ['power']
lib/power/meson.build +1 -1
@@ -13,13 +13,13 @@ if not is_linux endif sources = files( 'power_common.c', - 'power_intel_uncore.c', 'rte_power.c', 'rte_power_uncore.c', 'rte_power_pmd_mgmt.c', ) headers = files( 'power_cpufreq.h', + 'power_uncore_ops.h', 'rte_power.h', 'rte_power_guest_channel.h', 'rte_power_pmd_mgmt.h',
lib/power/power_uncore_ops.h new file +244 -0
244 lines not on this page · raw message
lib/power/rte_power_uncore.c +132 -124
313 lines not on this page · raw message
lib/power/rte_power_uncore.h +28 -33
125 lines not on this page · raw message
lib/power/version.map +1 -0
@@ -57,6 +57,7 @@ INTERNAL { global: rte_power_register_cpufreq_ops; + rte_power_register_uncore_ops; rte_power_logtype; cpufreq_check_scaling_driver; power_get_lcore_mapped_cpu_id;
Signature · 1 line
2.34.1
PATCH v8 3/6 test/power: removed function pointer validations
In reply to Sivaprasad TummalaAfter refactoring the power library, power management operations are now consistently supported regardless of the operating environment, making function pointer checks unnecessary and thus removed from applications.
v2:
- removed function pointer validation in l3fwd-power app.
--- app/test/test_power.c | 95 ----------------------------------- app/test/test_power_cpufreq.c | 52 ------------------- app/test/test_power_kvm_vm.c | 36 ------------- examples/l3fwd-power/main.c | 12 ++--- 4 files changed, 4 insertions(+), 191 deletions(-)
app/test/test_power.c +0 -95
@@ -24,86 +24,6 @@ test_power(void)#include <rte_power.h> -static int -check_function_ptrs (void ) -{ -enum power_management_env env =rte_power_get_env (); - -const bool not_null_expected = !(env ==PM_ENV_NOT_SET ); - -const char *inject_not_string1 = not_null_expected ?" not" :"" ; -const char *inject_not_string2 = not_null_expected ?"" :" not" ; - -if ((rte_power_freqs ==NULL ) == not_null_expected) { -printf ("rte_power_freqs should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_get_freq ==NULL ) == not_null_expected) { -printf ("rte_power_get_freq should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_set_freq ==NULL ) == not_null_expected) { -printf ("rte_power_set_freq should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_freq_up ==NULL ) == not_null_expected) { -printf ("rte_power_freq_up should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_freq_down ==NULL ) == not_null_expected) { -printf ("rte_power_freq_down should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_freq_max ==NULL ) == not_null_expected) { -printf ("rte_power_freq_max should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_freq_min ==NULL ) == not_null_expected) { -printf ("rte_power_freq_min should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_turbo_status ==NULL ) == not_null_expected) { -printf ("rte_power_turbo_status should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_freq_enable_turbo ==NULL ) == not_null_expected) { -printf ("rte_power_freq_enable_turbo should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_freq_disable_turbo ==NULL ) == not_null_expected) { -printf ("rte_power_freq_disable_turbo should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_get_capabilities ==NULL ) == not_null_expected) { -printf ("rte_power_get_capabilities should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } - -return 0 ; -} -static int test_power (void ) {
@@ -124,10 +44,6 @@ test_power(void)return -1 ; } -/* Verify that function pointers are NULL */ -if (check_function_ptrs () <0 ) - goto fail_all; -rte_power_unset_env ();/* Perform tests for valid environments.*/
@@ -154,22 +70,11 @@ test_power(void) return -1; } -/* Verify that function pointers are NOT NULL */ -if (check_function_ptrs () <0 ) - goto fail_all; -rte_power_unset_env (); -/* Verify that function pointers are NULL */ -if (check_function_ptrs () <0 ) - goto fail_all; - }return 0 ; -fail_all: -rte_power_unset_env (); -return -1 ; }#endif
app/test/test_power_cpufreq.c +0 -52
58 lines not on this page · raw message
app/test/test_power_kvm_vm.c +0 -36
@@ -47,42 +47,6 @@ test_power_kvm_vm(void)return -1 ; } -/* verify that function pointers are not NULL */ -if (rte_power_freqs ==NULL ) { -printf ("rte_power_freqs should not be NULL, environment has not been " -"initialised\n" ); -return -1 ; - } -if (rte_power_get_freq ==NULL ) { -printf ("rte_power_get_freq should not be NULL, environment has not " -"been initialised\n" ); -return -1 ; - } -if (rte_power_set_freq ==NULL ) { -printf ("rte_power_set_freq should not be NULL, environment has not " -"been initialised\n" ); -return -1 ; - } -if (rte_power_freq_up ==NULL ) { -printf ("rte_power_freq_up should not be NULL, environment has not " -"been initialised\n" ); -return -1 ; - } -if (rte_power_freq_down ==NULL ) { -printf ("rte_power_freq_down should not be NULL, environment has not " -"been initialised\n" ); -return -1 ; - } -if (rte_power_freq_max ==NULL ) { -printf ("rte_power_freq_max should not be NULL, environment has not " -"been initialised\n" ); -return -1 ; - } -if (rte_power_freq_min ==NULL ) { -printf ("rte_power_freq_min should not be NULL, environment has not " -"been initialised\n" ); -return -1 ; - }/* Test initialisation of an out of bounds lcore */ ret =rte_power_init (TEST_POWER_VM_LCORE_OUT_OF_BOUNDS );if (ret !=-1 ) {
examples/l3fwd-power/main.c +4 -8
@@ -440,8 +440,7 @@ power_timer_cb(__rte_unused struct rte_timer *tim,* check whether need to scale down frequency a step if it sleep a lot. */ if (sleep_time_ratio >=SCALING_DOWN_TIME_RATIO_THRESHOLD ) { -if (rte_power_freq_down) -rte_power_freq_down (lcore_id); +rte_power_freq_down (lcore_id); }else if ( (unsigned )(stats[lcore_id].nb_rx_processed / stats[lcore_id].nb_iteration_looped) <MAX_PKT_BURST ) {
@@ -449,8 +448,7 @@ power_timer_cb(__rte_unused struct rte_timer *tim,* scale down a step if average packet per iteration less * than expectation. */ -if (rte_power_freq_down) -rte_power_freq_down (lcore_id); +rte_power_freq_down (lcore_id); }/**
@@ -1344,11 +1342,9 @@ main_legacy_loop(__rte_unused void *dummy) }if (lcore_scaleup_hint ==FREQ_HIGHEST ) { -if (rte_power_freq_max) -rte_power_freq_max (lcore_id); +rte_power_freq_max (lcore_id); }else if (lcore_scaleup_hint ==FREQ_HIGHER ) { -if (rte_power_freq_up) -rte_power_freq_up (lcore_id); +rte_power_freq_up (lcore_id); } }else {/**
Signature · 1 line
2.34.1
PATCH v8 4/6 drivers/power: uncore support for AMD EPYC processors
In reply to Sivaprasad TummalaThis patch introduces driver support for power management of uncore components in AMD EPYC processors.
v2:
- fixed typo in comments section.
- added fabric frequency get support for legacy platforms.
--- drivers/power/amd_uncore/amd_uncore.c | 329 ++++++++++++++++++++++++++ drivers/power/amd_uncore/amd_uncore.h | 225 ++++++++++++++++++ drivers/power/amd_uncore/meson.build | 20 ++ drivers/power/meson.build | 1 + 4 files changed, 575 insertions(+) create mode 100644 drivers/power/amd_uncore/amd_uncore.c create mode 100644 drivers/power/amd_uncore/amd_uncore.h create mode 100644 drivers/power/amd_uncore/meson.build
drivers/power/amd_uncore/amd_uncore.c new file +329 -0
@@ -0,0 +1,329 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2024 Advanced Micro Devices, Inc. +*/ + +#include <errno.h> +#include <dirent.h> +#include <fnmatch.h> + +#include <rte_memcpy.h> + +#include "amd_uncore.h" +#include "power_common.h" +#include "e_smi/e_smi.h" + +#define MAX_NUMA_DIE 8 + +struct __rte_cache_aligned uncore_power_info { +unsigned int die;/* Core die id */ +unsigned int pkg;/* Package id */ +uint32_t freqs[RTE_MAX_UNCORE_FREQS ];/* Frequency array */ +uint32_t nb_freqs;/* Number of available freqs */ +uint32_t curr_idx;/* Freq index in freqs array */ +uint32_t max_freq;/* System max uncore freq */ +uint32_t min_freq;/* System min uncore freq */ +}; + +static struct uncore_power_info uncore_info[RTE_MAX_NUMA_NODES ][MAX_NUMA_DIE ]; +static int esmi_initialized; +static unsigned int hsmp_proto_ver; + +static int +set_uncore_freq_internal (struct uncore_power_info *ui,uint32_t idx) +{ +int ret; + +if (idx >=RTE_MAX_UNCORE_FREQS || idx >= ui->nb_freqs) { +POWER_LOG (DEBUG ,"Invalid uncore frequency index %u, which " +"should be less than %u" , idx, ui->nb_freqs); +return -1 ; + } + + ret =esmi_apb_disable (ui->pkg, idx); +if (ret !=ESMI_SUCCESS ) { +POWER_LOG (ERR ,"DF P-state '%u' set failed for pkg %02u" , + idx, ui->pkg); +return -1 ; + } + +POWER_DEBUG_LOG ("DF P-state '%u' to be set for pkg %02u die %02u" , + idx, ui->pkg, ui->die); + +/* write the minimum value first if the target freq is less than current max */ + ui->curr_idx = idx; + +return 0 ; +} + +static int +power_init_for_setting_uncore_freq (struct uncore_power_info *ui) +{ +switch (hsmp_proto_ver) { +case HSMP_PROTO_VER5 : + ui->max_freq =1800000 ;/* Hz */ + ui->min_freq =1200000 ;/* Hz */ +break ; +case HSMP_PROTO_VER2 : +default : + ui->max_freq =1600000 ;/* Hz */ + ui->min_freq =1200000 ;/* Hz */ + } + +return 0 ; +} + +/* +* Get the available uncore frequencies of the specific die. +*/ +static int +power_get_available_uncore_freqs (struct uncore_power_info *ui) +{ + ui->nb_freqs =3 ; +if (ui->nb_freqs >=RTE_MAX_UNCORE_FREQS ) { +POWER_LOG (ERR ,"Too many available uncore frequencies: %d" , + ui->nb_freqs); +return -1 ; + } + +/* Generate the uncore freq bucket array. */ +switch (hsmp_proto_ver) { +case HSMP_PROTO_VER5 : + ui->freqs[0 ] =1800000 ; + ui->freqs[1 ] =1440000 ; + ui->freqs[2 ] =1200000 ; +break ; +case HSMP_PROTO_VER2 : +default : + ui->freqs[0 ] =1600000 ; + ui->freqs[1 ] =1333000 ; + ui->freqs[2 ] =1200000 ; + } + +POWER_DEBUG_LOG ("%d frequency(s) of pkg %02u die %02u are available" , + ui->num_uncore_freqs, ui->pkg, ui->die); + +return 0 ; +} + +static int +check_pkg_die_values (unsigned int pkg,unsigned int die) +{ +unsigned int max_pkgs, max_dies; + max_pkgs =power_amd_uncore_get_num_pkgs (); +if (max_pkgs ==0 ) +return -1 ; +if (pkg >= max_pkgs) { +POWER_LOG (DEBUG ,"Package number %02u can not exceed %u" , + pkg, max_pkgs); +return -1 ; + } + + max_dies =power_amd_uncore_get_num_dies (pkg); +if (max_dies ==0 ) +return -1 ; +if (die >= max_dies) { +POWER_LOG (DEBUG ,"Die number %02u can not exceed %u" , + die, max_dies); +return -1 ; + } + +return 0 ; +} + +static void +power_amd_uncore_esmi_init (void ) +{ +if (esmi_init () ==ESMI_SUCCESS ) { +if (esmi_hsmp_proto_ver_get (&hsmp_proto_ver) == +ESMI_SUCCESS ) + esmi_initialized =1 ; + } +} + +int +power_amd_uncore_init (unsigned int pkg,unsigned int die) +{ +struct uncore_power_info *ui; +int ret; + +if (!esmi_initialized) { + ret =esmi_init (); +if (ret !=ESMI_SUCCESS ) { +POWER_LOG (DEBUG ,"ESMI Not initialized, drivers not found" ); +return -1 ; + } + ret =esmi_hsmp_proto_ver_get (&hsmp_proto_ver); +if (ret !=ESMI_SUCCESS ) { +POWER_LOG (DEBUG ,"HSMP Proto Version Get failed with " +"error %s" ,esmi_get_err_msg (ret)); +esmi_exit (); +return -1 ; + } + esmi_initialized =1 ; + } + + ret =check_pkg_die_values (pkg, die); +if (ret <0 ) +return -1 ; + + ui = &uncore_info[pkg][die]; + ui->die = die; + ui->pkg = pkg; + +/* Init for setting uncore die frequency */ +if (power_init_for_setting_uncore_freq (ui) <0 ) { +POWER_LOG (DEBUG ,"Cannot init for setting uncore frequency for " +"pkg %02u die %02u" , pkg, die); +return -1 ; + } + +/* Get the available frequencies */ +if (power_get_available_uncore_freqs (ui) <0 ) { +POWER_LOG (DEBUG ,"Cannot get available uncore frequencies of " +"pkg %02u die %02u" , pkg, die); +return -1 ; + } + +return 0 ; +} + +int +power_amd_uncore_exit (unsigned int pkg,unsigned int die) +{ +struct uncore_power_info *ui; + +int ret =check_pkg_die_values (pkg, die); +if (ret <0 ) +return -1 ; + + ui = &uncore_info[pkg][die]; + ui->nb_freqs =0 ; + +if (esmi_initialized) { +esmi_exit (); + esmi_initialized =0 ; + } + +return 0 ; +} + +uint32_t +power_get_amd_uncore_freq (unsigned int pkg,unsigned int die) +{ +int ret =check_pkg_die_values (pkg, die); +if (ret <0 ) +return -1 ; + +return uncore_info[pkg][die].curr_idx; +} + +int +power_set_amd_uncore_freq (unsigned int pkg,unsigned int die,uint32_t index) +{ +int ret =check_pkg_die_values (pkg, die); +if (ret <0 ) +return -1 ; + +return set_uncore_freq_internal (&(uncore_info[pkg][die]), index); +} + +int +power_amd_uncore_freq_max (unsigned int pkg,unsigned int die) +{ +int ret =check_pkg_die_values (pkg, die); +if (ret <0 ) +return -1 ; + +return set_uncore_freq_internal (&(uncore_info[pkg][die]),0 ); +} + + +int +power_amd_uncore_freq_min (unsigned int pkg,unsigned int die) +{ +int ret =check_pkg_die_values (pkg, die); +if (ret <0 ) +return -1 ; + +struct uncore_power_info *ui = &uncore_info[pkg][die]; + +return set_uncore_freq_internal (&(uncore_info[pkg][die]), ui->nb_freqs -1 ); +} + +int +power_amd_uncore_freqs (unsigned int pkg,unsigned int die,uint32_t *freqs,uint32_t num) +{ +struct uncore_power_info *ui; + +int ret =check_pkg_die_values (pkg, die); +if (ret <0 ) +return -1 ; + +if (freqs ==NULL ) { +POWER_LOG (ERR ,"NULL buffer supplied" ); +return 0 ; + } + + ui = &uncore_info[pkg][die]; +if (num < ui->nb_freqs) { +POWER_LOG (ERR ,"Buffer size is not enough" ); +return 0 ; + } +rte_memcpy (freqs, ui->freqs, ui->nb_freqs *sizeof (uint32_t )); + +return ui->nb_freqs; +} + +int +power_amd_uncore_get_num_freqs (unsigned int pkg,unsigned int die) +{ +int ret =check_pkg_die_values (pkg, die); +if (ret <0 ) +return -1 ; + +return uncore_info[pkg][die].nb_freqs; +} + +unsigned int +power_amd_uncore_get_num_pkgs (void ) +{ +uint32_t num_pkgs =0 ; +int ret; + +if (esmi_initialized) { + ret =esmi_number_of_sockets_get (&num_pkgs); +if (ret !=ESMI_SUCCESS ) { +POWER_LOG (ERR ,"Failed to get number of sockets" ); + num_pkgs =0 ; + } + } +return num_pkgs; +} + +unsigned int +power_amd_uncore_get_num_dies (unsigned int pkg) +{ +if (pkg >=power_amd_uncore_get_num_pkgs ()) { +POWER_LOG (ERR ,"Invalid package ID" ); +return 0 ; + } + +return 1 ; +} + +static struct rte_power_uncore_ops amd_uncore_ops = { + .name ="amd-hsmp" , + .cb = power_amd_uncore_esmi_init, + .init = power_amd_uncore_init, + .exit = power_amd_uncore_exit, + .get_avail_freqs = power_amd_uncore_freqs, + .get_num_pkgs = power_amd_uncore_get_num_pkgs, + .get_num_dies = power_amd_uncore_get_num_dies, + .get_num_freqs = power_amd_uncore_get_num_freqs, + .get_freq = power_get_amd_uncore_freq, + .set_freq = power_set_amd_uncore_freq, + .freq_max = power_amd_uncore_freq_max, + .freq_min = power_amd_uncore_freq_min, +}; + +RTE_POWER_REGISTER_UNCORE_OPS (amd_uncore_ops);
drivers/power/amd_uncore/amd_uncore.h new file +225 -0
225 lines not on this page · raw message
drivers/power/amd_uncore/meson.build new file +20 -0
@@ -0,0 +1,20 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' + subdir_done() +endif + +ESMI_header = '#include<e_smi/e_smi.h>' +lib = cc.find_library('e_smi64', required: false) +if not lib.found() + build = false + reason = 'missing dependency, "libe_smi"' +else + ext_deps += lib +endif + +sources = files('amd_uncore.c') +deps += ['power']
drivers/power/meson.build +1 -0
@@ -7,6 +7,7 @@ drivers = [ 'cppc', 'kvm_vm', 'pstate', + 'amd_uncore', 'intel_uncore' ]
Signature · 1 line
2.34.1
PATCH v8 5/6 maintainers: update for drivers/power
In reply to Sivaprasad TummalaUpdate maintainers for drivers/power/*.
--- MAINTAINERS | 1 + 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
@@ -1743,6 +1743,7 @@ M: Anatoly Burakov <[email protected]> M: David Hunt <[email protected]> M: Sivaprasad Tummala <[email protected]> F: lib/power/ +F: drivers/power/* F: doc/guides/prog_guide/power_man.rst F: app/test/test_power* F: examples/l3fwd-power/
Signature · 1 line
2.34.1
v8 cover power: refactor power management library
In reply to Sivaprasad TummalaThis patchset refactors the power management library, addressing both core and uncore power management. The primary changes involve the creation of dedicated directories for each driver within 'drivers/power/core/*' and 'drivers/power/uncore/*'.
This refactor significantly improves code organization, enhances clarity, and boosts maintainability. It lays the foundation for more focused development on individual drivers and facilitates seamless integration of future enhancements, particularly the AMD uncore driver.
Furthermore, this effort aims to streamline code maintenance by consolidating common functions for cpufreq and cppc across various core drivers, thus reducing code duplication.
Sivaprasad Tummala (6):
power: refactor core power management library
power: refactor uncore power management library test/power: removed function pointer validations drivers/power: uncore support for AMD EPYC processors
maintainers: update for drivers/power
power: rename library sources for cpu frequency management
MAINTAINERS | 1 +
app/test/test_power.c | 97 +-----
app/test/test_power_cpufreq.c | 54 +--
app/test/test_power_kvm_vm.c | 38 +-
drivers/meson.build | 1 +
.../power/acpi/acpi_cpufreq.c | 22 +-
.../power/acpi/acpi_cpufreq.h | 6 +-
drivers/power/acpi/meson.build | 10 +
.../power/amd_pstate/amd_pstate_cpufreq.c | 24 +-
.../power/amd_pstate/amd_pstate_cpufreq.h | 10 +-
drivers/power/amd_pstate/meson.build | 10 +
drivers/power/amd_uncore/amd_uncore.c | 329 ++++++++++++++++++
drivers/power/amd_uncore/amd_uncore.h | 225 ++++++++++++
drivers/power/amd_uncore/meson.build | 20 ++
.../power/cppc/cppc_cpufreq.c | 22 +-
.../power/cppc/cppc_cpufreq.h | 8 +-
drivers/power/cppc/meson.build | 10 +
.../power/intel_uncore/intel_uncore.c | 18 +-
.../power/intel_uncore/intel_uncore.h | 9 +-
drivers/power/intel_uncore/meson.build | 6 +
.../power/kvm_vm}/guest_channel.c | 2 +-
.../power/kvm_vm}/guest_channel.h | 0
.../power/kvm_vm/kvm_vm.c | 22 +-
.../power/kvm_vm/kvm_vm.h | 6 +-
drivers/power/kvm_vm/meson.build | 14 +
drivers/power/meson.build | 14 +
drivers/power/pstate/meson.build | 10 +
.../power/pstate/pstate_cpufreq.c | 22 +-
.../power/pstate/pstate_cpufreq.h | 6 +-
examples/distributor/main.c | 2 +-
examples/l3fwd-power/main.c | 14 +-
examples/l3fwd-power/perf_core.c | 2 +-
examples/vm_power_manager/channel_monitor.c | 2 +-
examples/vm_power_manager/channel_monitor.h | 2 +-
examples/vm_power_manager/guest_cli/main.c | 2 +-
.../guest_cli/vm_power_cli_guest.c | 2 +-
examples/vm_power_manager/power_manager.c | 2 +-
lib/power/meson.build | 13 +-
lib/power/power_common.c | 2 +-
lib/power/power_common.h | 18 +-
lib/power/power_cpufreq.h | 191 ++++++++++
lib/power/power_uncore_ops.h | 244 +++++++++++++
lib/power/rte_power.c | 257 --------------
lib/power/rte_power_cpufreq.c | 230 ++++++++++++
.../{rte_power.h => rte_power_cpufreq.h} | 120 ++++---
lib/power/rte_power_pmd_mgmt.h | 2 +-
lib/power/rte_power_uncore.c | 256 +++++++-------
lib/power/rte_power_uncore.h | 61 ++--
lib/power/version.map | 15 +
49 files changed, 1746 insertions(+), 707 deletions(-)
rename lib/power/power_acpi_cpufreq.c => drivers/power/acpi/acpi_cpufreq.c (95%)
rename lib/power/power_acpi_cpufreq.h => drivers/power/acpi/acpi_cpufreq.h (98%)
create mode 100644 drivers/power/acpi/meson.build
rename lib/power/power_amd_pstate_cpufreq.c => drivers/power/amd_pstate/amd_pstate_cpufreq.c (95%)
rename lib/power/power_amd_pstate_cpufreq.h => drivers/power/amd_pstate/amd_pstate_cpufreq.h (96%)
create mode 100644 drivers/power/amd_pstate/meson.build
create mode 100644 drivers/power/amd_uncore/amd_uncore.c
create mode 100644 drivers/power/amd_uncore/amd_uncore.h
create mode 100644 drivers/power/amd_uncore/meson.build
rename lib/power/power_cppc_cpufreq.c => drivers/power/cppc/cppc_cpufreq.c (95%)
rename lib/power/power_cppc_cpufreq.h => drivers/power/cppc/cppc_cpufreq.h (97%)
create mode 100644 drivers/power/cppc/meson.build
rename lib/power/power_intel_uncore.c => drivers/power/intel_uncore/intel_uncore.c (95%)
rename lib/power/power_intel_uncore.h => drivers/power/intel_uncore/intel_uncore.h (97%)
create mode 100644 drivers/power/intel_uncore/meson.build
rename {lib/power => drivers/power/kvm_vm}/guest_channel.c (99%)
rename {lib/power => drivers/power/kvm_vm}/guest_channel.h (100%)
rename lib/power/power_kvm_vm.c => drivers/power/kvm_vm/kvm_vm.c (82%)
rename lib/power/power_kvm_vm.h => drivers/power/kvm_vm/kvm_vm.h (98%)
create mode 100644 drivers/power/kvm_vm/meson.build
create mode 100644 drivers/power/meson.build
create mode 100644 drivers/power/pstate/meson.build
rename lib/power/power_pstate_cpufreq.c => drivers/power/pstate/pstate_cpufreq.c (96%)
rename lib/power/power_pstate_cpufreq.h => drivers/power/pstate/pstate_cpufreq.h (98%)
create mode 100644 lib/power/power_cpufreq.h
create mode 100644 lib/power/power_uncore_ops.h
delete mode 100644 lib/power/rte_power.c
create mode 100644 lib/power/rte_power_cpufreq.c
rename lib/power/{rte_power.h => rte_power_cpufreq.h} (73%)Signature · 1 line
2.34.1
PATCH v8 6/6 power: rename library sources for cpu frequency management
In reply to Sivaprasad TummalaThis patch renames the existing core power library source files from rte_power.* to rte_power_cpufreq.* for better clarity
---
app/test/test_power.c | 2 +-
app/test/test_power_cpufreq.c | 2 +-
app/test/test_power_kvm_vm.c | 2 +-
examples/distributor/main.c | 2 +-
examples/l3fwd-power/main.c | 2 +-
examples/l3fwd-power/perf_core.c | 2 +-
examples/vm_power_manager/channel_monitor.c | 2 +-
examples/vm_power_manager/channel_monitor.h | 2 +-
examples/vm_power_manager/guest_cli/main.c | 2 +-
examples/vm_power_manager/guest_cli/vm_power_cli_guest.c | 2 +-
examples/vm_power_manager/power_manager.c | 2 +-
lib/power/meson.build | 4 ++--
lib/power/{rte_power.c => rte_power_cpufreq.c} | 2 +-
lib/power/{rte_power.h => rte_power_cpufreq.h} | 4 ++--
lib/power/rte_power_pmd_mgmt.h | 2 +-
15 files changed, 17 insertions(+), 17 deletions(-)
rename lib/power/{rte_power.c => rte_power_cpufreq.c} (99%)
rename lib/power/{rte_power.h => rte_power_cpufreq.h} (99%)app/test/test_power.c +1 -1
@@ -22,7 +22,7 @@ test_power(void)#else -#include <rte_power.h> +#include <rte_power_cpufreq.h> static int test_power (void )
app/test/test_power_cpufreq.c +1 -1
@@ -30,7 +30,7 @@ test_power_caps(void) }#else -#include <rte_power.h> +#include <rte_power_cpufreq.h> #define TEST_POWER_LCORE_ID 2U#define TEST_POWER_LCORE_INVALID ((unsigned)RTE_MAX_LCORE)
app/test/test_power_kvm_vm.c +1 -1
@@ -20,7 +20,7 @@ test_power_kvm_vm(void) }#else -#include <rte_power.h> +#include <rte_power_cpufreq.h> #define TEST_POWER_VM_LCORE_ID 0U#define TEST_POWER_VM_LCORE_OUT_OF_BOUNDS (RTE_MAX_LCORE+1)
examples/distributor/main.c +1 -1
@@ -17,7 +17,7 @@#include <rte_prefetch.h> #include <rte_distributor.h> #include <rte_pause.h> -#include <rte_power.h> +#include <rte_power_cpufreq.h> #define RX_RING_SIZE 1024#define TX_RING_SIZE 1024
examples/l3fwd-power/main.c +1 -1
@@ -41,7 +41,7 @@#include <rte_udp.h> #include <rte_string_fns.h> #include <rte_timer.h> -#include <rte_power.h> +#include <rte_power_cpufreq.h> #include <rte_spinlock.h> #include <rte_metrics.h> #include <rte_telemetry.h>
examples/l3fwd-power/perf_core.c +1 -1
@@ -10,7 +10,7 @@#include <rte_common.h> #include <rte_memory.h> #include <rte_lcore.h> -#include <rte_power.h> +#include <rte_power_cpufreq.h> #include <rte_string_fns.h> #include "perf_core.h"
examples/vm_power_manager/channel_monitor.c +1 -1
@@ -31,7 +31,7 @@#ifdef RTE_NET_I40E #include <rte_pmd_i40e.h> #endif -#include <rte_power.h> +#include <rte_power_cpufreq.h> #include <libvirt/libvirt.h> #include "channel_monitor.h"
examples/vm_power_manager/channel_monitor.h +1 -1
@@ -5,7 +5,7 @@#ifndef CHANNEL_MONITOR_H_ #define CHANNEL_MONITOR_H_ -#include <rte_power.h> +#include <rte_power_cpufreq.h> #include "channel_manager.h"
examples/vm_power_manager/guest_cli/main.c +1 -1
@@ -9,7 +9,7 @@#include <string.h> #include <rte_lcore.h> -#include <rte_power.h> +#include <rte_power_cpufreq.h> #include <rte_debug.h> #include <rte_eal.h> #include <rte_log.h>
examples/vm_power_manager/guest_cli/vm_power_cli_guest.c +1 -1
@@ -18,7 +18,7 @@#include <rte_lcore.h> #include <rte_ethdev.h> -#include <rte_power.h> +#include <rte_power_cpufreq.h> #include "vm_power_cli_guest.h"
examples/vm_power_manager/power_manager.c +1 -1
@@ -15,7 +15,7 @@#include <sys/types.h> #include <rte_log.h> -#include <rte_power.h> +#include <rte_power_cpufreq.h> #include <rte_spinlock.h> #include "channel_manager.h"
lib/power/meson.build +2 -2
@@ -13,14 +13,14 @@ if not is_linux endif sources = files( 'power_common.c', - 'rte_power.c', + 'rte_power_cpufreq.c', 'rte_power_uncore.c', 'rte_power_pmd_mgmt.c', ) headers = files( 'power_cpufreq.h', 'power_uncore_ops.h', - 'rte_power.h', + 'rte_power_cpufreq.h', 'rte_power_guest_channel.h', 'rte_power_pmd_mgmt.h', 'rte_power_uncore.h',
lib/power/rte_power_cpufreq.c renamed from lib/power/rte_power.c +1 -1
@@ -8,7 +8,7 @@#include <rte_spinlock.h> #include <rte_debug.h> -#include "rte_power.h" +#include "rte_power_cpufreq.h" #include "power_common.h" static enum power_management_env global_default_env =PM_ENV_NOT_SET ;
lib/power/rte_power_cpufreq.h renamed from lib/power/rte_power.h +2 -2
@@ -3,8 +3,8 @@* Copyright(c) 2024 Advanced Micro Devices, Inc. */ -#ifndef _RTE_POWER_H -#define _RTE_POWER_H +#ifndef _RTE_POWER_CPUFREQ_H +#define _RTE_POWER_CPUFREQ_H/** * @file
lib/power/rte_power_pmd_mgmt.h +1 -1
@@ -13,7 +13,7 @@#include <stdint.h> #include <rte_log.h> -#include <rte_power.h> +#include <rte_power_cpufreq.h> #ifdef __cplusplusextern "C" {
Signature · 1 line
2.34.1
Quoted 93 lines · On Tue, 22 Oct 2024 18:41:26 +0000 Sivaprasad Tummala…
This patchset refactors the power management library, addressing both core and uncore power management. The primary changes involve the creation of dedicated directories for each driver within '
drivers/power/core/*' and 'drivers/power/uncore/*'.This refactor significantly improves code organization, enhances clarity, and boosts maintainability. It lays the foundation for more focused development on individual drivers and facilitates seamless integration of future enhancements, particularly the AMD uncore driver.
Furthermore, this effort aims to streamline code maintenance by consolidating common functions for cpufreq and cppc across various core drivers, thus reducing code duplication.
Sivaprasad Tummala (6):
power: refactor core power management library
power: refactor uncore power management library test/power: removed function pointer validationsdrivers/power: uncore support for AMD EPYC processors
maintainers: update fordrivers/power
power: rename library sources for cpu frequency managementMAINTAINERS | 1 + app/test/test_power.c | 97 +----- app/test/test_power_cpufreq.c | 54 +-- app/test/test_power_kvm_vm.c | 38 +- drivers/meson.build | 1 + .../power/acpi/acpi_cpufreq.c | 22 +- .../power/acpi/acpi_cpufreq.h | 6 +- drivers/power/acpi/meson.build | 10 + .../power/amd_pstate/amd_pstate_cpufreq.c | 24 +- .../power/amd_pstate/amd_pstate_cpufreq.h | 10 +- drivers/power/amd_pstate/meson.build | 10 + drivers/power/amd_uncore/amd_uncore.c | 329 ++++++++++++++++++ drivers/power/amd_uncore/amd_uncore.h | 225 ++++++++++++ drivers/power/amd_uncore/meson.build | 20 ++ .../power/cppc/cppc_cpufreq.c | 22 +- .../power/cppc/cppc_cpufreq.h | 8 +- drivers/power/cppc/meson.build | 10 + .../power/intel_uncore/intel_uncore.c | 18 +- .../power/intel_uncore/intel_uncore.h | 9 +- drivers/power/intel_uncore/meson.build | 6 + .../power/kvm_vm}/guest_channel.c | 2 +- .../power/kvm_vm}/guest_channel.h | 0 .../power/kvm_vm/kvm_vm.c | 22 +- .../power/kvm_vm/kvm_vm.h | 6 +- drivers/power/kvm_vm/meson.build | 14 + drivers/power/meson.build | 14 + drivers/power/pstate/meson.build | 10 + .../power/pstate/pstate_cpufreq.c | 22 +- .../power/pstate/pstate_cpufreq.h | 6 +- examples/distributor/main.c | 2 +- examples/l3fwd-power/main.c | 14 +- examples/l3fwd-power/perf_core.c | 2 +- examples/vm_power_manager/channel_monitor.c | 2 +- examples/vm_power_manager/channel_monitor.h | 2 +- examples/vm_power_manager/guest_cli/main.c | 2 +- .../guest_cli/vm_power_cli_guest.c | 2 +- examples/vm_power_manager/power_manager.c | 2 +- lib/power/meson.build | 13 +- lib/power/power_common.c | 2 +- lib/power/power_common.h | 18 +- lib/power/power_cpufreq.h | 191 ++++++++++ lib/power/power_uncore_ops.h | 244 +++++++++++++ lib/power/rte_power.c | 257 -------------- lib/power/rte_power_cpufreq.c | 230 ++++++++++++ .../{rte_power.h => rte_power_cpufreq.h} | 120 ++++--- lib/power/rte_power_pmd_mgmt.h | 2 +- lib/power/rte_power_uncore.c | 256 +++++++------- lib/power/rte_power_uncore.h | 61 ++-- lib/power/version.map | 15 + 49 files changed, 1746 insertions(+), 707 deletions(-) rename lib/power/power_acpi_cpufreq.c => drivers/power/acpi/acpi_cpufreq.c (95%) rename lib/power/power_acpi_cpufreq.h => drivers/power/acpi/acpi_cpufreq.h (98%) create mode 100644 drivers/power/acpi/meson.build rename lib/power/power_amd_pstate_cpufreq.c => drivers/power/amd_pstate/amd_pstate_cpufreq.c (95%) rename lib/power/power_amd_pstate_cpufreq.h => drivers/power/amd_pstate/amd_pstate_cpufreq.h (96%) create mode 100644 drivers/power/amd_pstate/meson.build create mode 100644 drivers/power/amd_uncore/amd_uncore.c create mode 100644 drivers/power/amd_uncore/amd_uncore.h create mode 100644 drivers/power/amd_uncore/meson.build rename lib/power/power_cppc_cpufreq.c => drivers/power/cppc/cppc_cpufreq.c (95%) rename lib/power/power_cppc_cpufreq.h => drivers/power/cppc/cppc_cpufreq.h (97%) create mode 100644 drivers/power/cppc/meson.build rename lib/power/power_intel_uncore.c => drivers/power/intel_uncore/intel_uncore.c (95%) rename lib/power/power_intel_uncore.h => drivers/power/intel_uncore/intel_uncore.h (97%) create mode 100644 drivers/power/intel_uncore/meson.build rename {lib/power => drivers/power/kvm_vm}/guest_channel.c (99%) rename {lib/power => drivers/power/kvm_vm}/guest_channel.h (100%) rename lib/power/power_kvm_vm.c => drivers/power/kvm_vm/kvm_vm.c (82%) rename lib/power/power_kvm_vm.h => drivers/power/kvm_vm/kvm_vm.h (98%) create mode 100644 drivers/power/kvm_vm/meson.build create mode 100644 drivers/power/meson.build
Quoted 9 lines
create mode 100644 drivers/power/pstate/meson.build
rename lib/power/power_pstate_cpufreq.c => drivers/power/pstate/pstate_cpufreq.c (96%)
rename lib/power/power_pstate_cpufreq.h => drivers/power/pstate/pstate_cpufreq.h (98%)
create mode 100644 lib/power/power_cpufreq.h
create mode 100644 lib/power/power_uncore_ops.h
delete mode 100644 lib/power/rte_power.c
create mode 100644 lib/power/rte_power_cpufreq.c
rename lib/power/{rte_power.h => rte_power_cpufreq.h} (73%)This has some issues with documentation.
$ ninja -C build doc ninja: Entering directory `build' [3/6] Generating doc/api/doxygen-html with a custom command /home/shemminger/DPDK/power/doc/api/doxy-api-index.md:105: warning: unable to resolve reference to 'rte_power.h' for \ref command [5/6] Running external command doc (wrapped by meson to set env) Building docs: Doxygen_API(HTML) Doxygen_API(Manpage) DTS_API_HTML HTML_Guides
v9 cover power: refactor power management library
In reply to Sivaprasad TummalaThis patchset refactors the power management library, addressing both core and uncore power management. The primary changes involve the creation of dedicated directories for each driver within 'drivers/power/core/*' and 'drivers/power/uncore/*'.
This refactor significantly improves code organization, enhances clarity, and boosts maintainability. It lays the foundation for more focused development on individual drivers and facilitates seamless integration of future enhancements, particularly the AMD uncore driver.
Furthermore, this effort aims to streamline code maintenance by consolidating common functions for cpufreq and cppc across various core drivers, thus reducing code duplication.
Sivaprasad Tummala (6):
power: refactor core power management library
power: refactor uncore power management library test/power: removed function pointer validations drivers/power: uncore support for AMD EPYC processors
maintainers: update for drivers/power
power: rename library sources for cpu frequency management
MAINTAINERS | 1 +
app/test/test_power.c | 97 +-----
app/test/test_power_cpufreq.c | 54 +--
app/test/test_power_kvm_vm.c | 38 +-
doc/api/doxy-api-index.md | 2 +-
doc/guides/prog_guide/power_man.rst | 24 +-
drivers/meson.build | 1 +
.../power/acpi/acpi_cpufreq.c | 22 +-
.../power/acpi/acpi_cpufreq.h | 6 +-
drivers/power/acpi/meson.build | 10 +
.../power/amd_pstate/amd_pstate_cpufreq.c | 24 +-
.../power/amd_pstate/amd_pstate_cpufreq.h | 10 +-
drivers/power/amd_pstate/meson.build | 10 +
drivers/power/amd_uncore/amd_uncore.c | 329 ++++++++++++++++++
drivers/power/amd_uncore/amd_uncore.h | 225 ++++++++++++
drivers/power/amd_uncore/meson.build | 20 ++
.../power/cppc/cppc_cpufreq.c | 22 +-
.../power/cppc/cppc_cpufreq.h | 8 +-
drivers/power/cppc/meson.build | 10 +
.../power/intel_uncore/intel_uncore.c | 18 +-
.../power/intel_uncore/intel_uncore.h | 9 +-
drivers/power/intel_uncore/meson.build | 6 +
.../power/kvm_vm}/guest_channel.c | 2 +-
.../power/kvm_vm}/guest_channel.h | 0
.../power/kvm_vm/kvm_vm.c | 22 +-
.../power/kvm_vm/kvm_vm.h | 6 +-
drivers/power/kvm_vm/meson.build | 14 +
drivers/power/meson.build | 14 +
drivers/power/pstate/meson.build | 10 +
.../power/pstate/pstate_cpufreq.c | 22 +-
.../power/pstate/pstate_cpufreq.h | 6 +-
examples/distributor/main.c | 2 +-
examples/l3fwd-power/main.c | 14 +-
examples/l3fwd-power/perf_core.c | 2 +-
examples/vm_power_manager/channel_monitor.c | 2 +-
examples/vm_power_manager/channel_monitor.h | 2 +-
examples/vm_power_manager/guest_cli/main.c | 2 +-
.../guest_cli/vm_power_cli_guest.c | 2 +-
examples/vm_power_manager/power_manager.c | 2 +-
lib/power/meson.build | 13 +-
lib/power/power_common.c | 2 +-
lib/power/power_common.h | 18 +-
lib/power/power_cpufreq.h | 191 ++++++++++
lib/power/power_uncore_ops.h | 244 +++++++++++++
lib/power/rte_power.c | 257 --------------
lib/power/rte_power_cpufreq.c | 230 ++++++++++++
.../{rte_power.h => rte_power_cpufreq.h} | 120 ++++---
lib/power/rte_power_pmd_mgmt.h | 2 +-
lib/power/rte_power_uncore.c | 256 +++++++-------
lib/power/rte_power_uncore.h | 61 ++--
lib/power/version.map | 15 +
51 files changed, 1766 insertions(+), 713 deletions(-)
rename lib/power/power_acpi_cpufreq.c => drivers/power/acpi/acpi_cpufreq.c (95%)
rename lib/power/power_acpi_cpufreq.h => drivers/power/acpi/acpi_cpufreq.h (98%)
create mode 100644 drivers/power/acpi/meson.build
rename lib/power/power_amd_pstate_cpufreq.c => drivers/power/amd_pstate/amd_pstate_cpufreq.c (95%)
rename lib/power/power_amd_pstate_cpufreq.h => drivers/power/amd_pstate/amd_pstate_cpufreq.h (96%)
create mode 100644 drivers/power/amd_pstate/meson.build
create mode 100644 drivers/power/amd_uncore/amd_uncore.c
create mode 100644 drivers/power/amd_uncore/amd_uncore.h
create mode 100644 drivers/power/amd_uncore/meson.build
rename lib/power/power_cppc_cpufreq.c => drivers/power/cppc/cppc_cpufreq.c (95%)
rename lib/power/power_cppc_cpufreq.h => drivers/power/cppc/cppc_cpufreq.h (97%)
create mode 100644 drivers/power/cppc/meson.build
rename lib/power/power_intel_uncore.c => drivers/power/intel_uncore/intel_uncore.c (95%)
rename lib/power/power_intel_uncore.h => drivers/power/intel_uncore/intel_uncore.h (97%)
create mode 100644 drivers/power/intel_uncore/meson.build
rename {lib/power => drivers/power/kvm_vm}/guest_channel.c (99%)
rename {lib/power => drivers/power/kvm_vm}/guest_channel.h (100%)
rename lib/power/power_kvm_vm.c => drivers/power/kvm_vm/kvm_vm.c (82%)
rename lib/power/power_kvm_vm.h => drivers/power/kvm_vm/kvm_vm.h (98%)
create mode 100644 drivers/power/kvm_vm/meson.build
create mode 100644 drivers/power/meson.build
create mode 100644 drivers/power/pstate/meson.build
rename lib/power/power_pstate_cpufreq.c => drivers/power/pstate/pstate_cpufreq.c (96%)
rename lib/power/power_pstate_cpufreq.h => drivers/power/pstate/pstate_cpufreq.h (98%)
create mode 100644 lib/power/power_cpufreq.h
create mode 100644 lib/power/power_uncore_ops.h
delete mode 100644 lib/power/rte_power.c
create mode 100644 lib/power/rte_power_cpufreq.c
rename lib/power/{rte_power.h => rte_power_cpufreq.h} (73%)Signature · 1 line
2.34.1