[RFC] power: refactor uncore power management interfaces
Checks
Commit Message
From: Sivaprasad Tummala <Sivaprasad.Tummala@amd.com>
currently the uncore power management implementation is vendor specific.
Added new vendor agnostic uncore power interface similar to rte_power
and subsequently will rename specific implementations
("rte_power_intel_uncore") to "power_intel_uncore" along with functions.
Signed-off-by: Sivaprasad Tummala <Sivaprasad.Tummala@amd.com>
---
lib/power/rte_power_uncore.h | 234 +++++++++++++++++++++++++++++++++++
1 file changed, 234 insertions(+)
create mode 100644 lib/power/rte_power_uncore.h
Comments
[AMD Official Use Only - General]
Hi Dave, Anatoly,
We are planning to implement these changes in 23.07 release.
Would like to hear your comments and any objections.
Can you please review this and share your thoughts.
Thanks & Regards,
Sivaprasad
> -----Original Message-----
> From: Tummala, Sivaprasad <Sivaprasad.Tummala@amd.com>
> Sent: Wednesday, May 3, 2023 10:34 PM
> To: david.hunt@intel.com
> Cc: dev@dpdk.org; anatoly.burakov@intel.com; Yigit, Ferruh
> <Ferruh.Yigit@amd.com>; Tummala, Sivaprasad
> <Sivaprasad.Tummala@amd.com>
> Subject: [RFC PATCH] power: refactor uncore power management interfaces
>
> From: Sivaprasad Tummala <Sivaprasad.Tummala@amd.com>
>
> currently the uncore power management implementation is vendor specific.
> Added new vendor agnostic uncore power interface similar to rte_power and
> subsequently will rename specific implementations
> ("rte_power_intel_uncore") to "power_intel_uncore" along with functions.
>
> Signed-off-by: Sivaprasad Tummala <Sivaprasad.Tummala@amd.com>
> ---
> lib/power/rte_power_uncore.h | 234
> +++++++++++++++++++++++++++++++++++
> 1 file changed, 234 insertions(+)
> create mode 100644 lib/power/rte_power_uncore.h
>
> diff --git a/lib/power/rte_power_uncore.h b/lib/power/rte_power_uncore.h new file
> mode 100644 index 0000000000..196fb9ec01
> --- /dev/null
> +++ b/lib/power/rte_power_uncore.h
> @@ -0,0 +1,234 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright(c) 2022 Intel Corporation
> + * Copyright(c) 2023 AMD Corporation
> + */
> +
> +#ifndef RTE_POWER_UNCORE_H
> +#define RTE_POWER_UNCORE_H
> +
> +/**
> + * @file
> + * RTE Uncore Frequency Management
> + */
> +
> +#include <rte_compat.h>
> +#include "rte_power.h"
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
> +/* Uncore Power Management Environment */ enum uncore_power_mgmt_env
> {
> +UNCORE_PM_ENV_NOT_SET,
> + UNCORE_PM_ENV_INTEL_UNCORE, UNCORE_PM_ENV_AMD_HSMP};
> +
> +/**
> + * Initialize uncore frequency management for specific die on a package.
> + * It will get the available frequencies and prepare to set new die frequencies.
> + *
> + * This function should NOT be called in the fast path.
> + *
> + * @param pkg
> + * Package number.
> + * Each physical CPU in a system is referred to as a package.
> + * @param die
> + * Die number.
> + * Each package can have several dies connected together via the uncore mesh.
> + *
> + * @return
> + * - 0 on success.
> + * - Negative on error.
> + */
> +__rte_experimental
> +int
> +rte_power_uncore_init(unsigned int pkg, unsigned int die);
> +
> +/**
> + * Exit uncore frequency management on a specific die on a package.
> + * It will restore uncore min and* max values to previous values
> + * before initialization of API.
> + *
> + * This function should NOT be called in the fast path.
> + *
> + * @param pkg
> + * Package number.
> + * Each physical CPU in a system is referred to as a package.
> + * @param die
> + * Die number.
> + * Each package can have several dies connected together via the uncore mesh.
> + *
> + * @return
> + * - 0 on success.
> + * - Negative on error.
> + */
> +__rte_experimental
> +int
> +rte_power_uncore_exit(unsigned int pkg, unsigned int die);
> +
> +/**
> + * Return the current index of available frequencies of a specific die on a package.
> + * It should be protected outside of this function for threadsafe.
> + *
> + * This function should NOT be called in the fast path.
> + *
> + * @param pkg
> + * Package number.
> + * Each physical CPU in a system is referred to as a package.
> + * @param die
> + * Die number.
> + * Each package can have several dies connected together via the uncore mesh.
> + *
> + * @return
> + * The current index of available frequencies.
> + * If error, it will return 'RTE_POWER_INVALID_FREQ_INDEX = (~0)'.
> + */
> +typedef uint32_t (*rte_power_get_uncore_freq_t)(unsigned int pkg,
> +unsigned int die);
> +
> +extern rte_power_get_uncore_freq_t rte_power_get_uncore_freq;
> +
> +/**
> + * Set minimum and maximum uncore frequency for specified die on a
> +package
> + * to specified index value.
> + * It should be protected outside of this function for threadsafe.
> + *
> + * This function should NOT be called in the fast path.
> + *
> + * @param pkg
> + * Package number.
> + * Each physical CPU in a system is referred to as a package.
> + * @param die
> + * Die number.
> + * Each package can have several dies connected together via the uncore mesh.
> + * @param index
> + * The index of available frequencies.
> + *
> + * @return
> + * - 1 on success with frequency changed.
> + * - 0 on success without frequency changed.
> + * - Negative on error.
> + */
> +typedef int (*rte_power_set_uncore_freq_t)(unsigned int pkg, unsigned
> +int die, uint32_t index);
> +
> +extern rte_power_set_uncore_freq_t rte_power_set_uncore_freq;
> +
> +/**
> + * Function pointer definition for generic frequency change functions.
> + *
> + * @param pkg
> + * Package number.
> + * Each physical CPU in a system is referred to as a package.
> + * @param die
> + * Die number.
> + * Each package can have several dies connected together via the uncore mesh.
> + *
> + * @return
> + * - 1 on success with frequency changed.
> + * - 0 on success without frequency changed.
> + * - Negative on error.
> + */
> +typedef int (*rte_power_uncore_freq_change_t)(unsigned int pkg,
> +unsigned int die);
> +
> +/**
> + * Set minimum and maximum uncore frequency for specified die on a
> +package
> + * to maximum value according to the available frequencies.
> + * It should be protected outside of this function for threadsafe.
> + *
> + * This function should NOT be called in the fast path.
> + *
> + * @param pkg
> + * Package number.
> + * Each physical CPU in a system is referred to as a package.
> + * @param die
> + * Die number.
> + * Each package can have several dies connected together via the uncore mesh.
> + *
> + * @return
> + * - 1 on success with frequency changed.
> + * - 0 on success without frequency changed.
> + * - Negative on error.
> + */
> +extern rte_power_uncore_freq_change_t rte_power_uncore_freq_max;
> +
> +/**
> + * Set minimum and maximum uncore frequency for specified die on a
> +package
> + * to minimum value according to the available frequencies.
> + * It should be protected outside of this function for threadsafe.
> + *
> + * This function should NOT be called in the fast path.
> + *
> + * @param pkg
> + * Package number.
> + * Each physical CPU in a system is referred to as a package.
> + * @param die
> + * Die number.
> + * Each package can have several dies connected together via the uncore mesh.
> + *
> + * @return
> + * - 1 on success with frequency changed.
> + * - 0 on success without frequency changed.
> + * - Negative on error.
> + */
> +extern rte_power_uncore_freq_change_t rte_power_uncore_freq_min;
> +
> +/**
> + * Return the list length of available frequencies in the index array.
> + *
> + * This function should NOT be called in the fast path.
> + *
> + * @param pkg
> + * Package number.
> + * Each physical CPU in a system is referred to as a package.
> + * @param die
> + * Die number.
> + * Each package can have several dies connected together via the uncore mesh.
> + * @param freqs
> + * The buffer array to save the frequencies.
> + * @param num
> + * The number of frequencies to get.
> + *
> + * @return
> + * - The number of available index's in frequency array.
> + * - Negative on error.
> + */
> +typedef int (*rte_power_uncore_freqs_t)(unsigned int pkg, unsigned int die,
> + uint32_t *freqs, uint32_t num);
> +
> +extern rte_power_uncore_freqs_t rte_power_uncore_freqs;
> +
> +/**
> + * Return the number of packages (CPUs) on a system
> + * by parsing the uncore sysfs directory.
> + *
> + * This function should NOT be called in the fast path.
> + *
> + * @return
> + * - Zero on error.
> + * - Number of package on system on success.
> + */
> +typedef unsigned int (*rte_power_uncore_get_num_pkgs_t)(void);
> +
> +extern rte_power_uncore_get_num_pkgs_t rte_power_uncore_get_num_pkgs;
> +
> +/**
> + * Return the number of dies for pakckages (CPUs) specified
> + * from parsing the uncore sysfs directory.
> + *
> + * This function should NOT be called in the fast path.
> + *
> + * @param pkg
> + * Package number.
> + * Each physical CPU in a system is referred to as a package.
> + *
> + * @return
> + * - Zero on error.
> + * - Number of dies for package on sucecss.
> + */
> +typedef unsigned int (*rte_power_uncore_get_num_pkgs_t)(unsigned int
> +pkg);
> +
> +extern rte_power_uncore_get_num_dies_t rte_power_uncore_get_num_dies;
> +
> +#ifdef __cplusplus
> +}
> +#endif
> +
> +#endif /* RTE_POWER_UNCORE_H */
> --
> 2.34.1
On 5/3/2023 6:03 PM, Sivaprasad Tummala wrote:
> From: Sivaprasad Tummala <Sivaprasad.Tummala@amd.com>
>
> currently the uncore power management implementation is vendor specific.
> Added new vendor agnostic uncore power interface similar to rte_power
> and subsequently will rename specific implementations
> ("rte_power_intel_uncore") to "power_intel_uncore" along with functions.
>
> Signed-off-by: Sivaprasad Tummala <Sivaprasad.Tummala@amd.com>
> ---
Hi,
This looks a perfectly fine refactor, so please go ahead with v1 :)
new file mode 100644
@@ -0,0 +1,234 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2022 Intel Corporation
+ * Copyright(c) 2023 AMD Corporation
+ */
+
+#ifndef RTE_POWER_UNCORE_H
+#define RTE_POWER_UNCORE_H
+
+/**
+ * @file
+ * RTE Uncore Frequency Management
+ */
+
+#include <rte_compat.h>
+#include "rte_power.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Uncore Power Management Environment */
+enum uncore_power_mgmt_env { UNCORE_PM_ENV_NOT_SET,
+ UNCORE_PM_ENV_INTEL_UNCORE, UNCORE_PM_ENV_AMD_HSMP};
+
+/**
+ * Initialize uncore frequency management for specific die on a package.
+ * It will get the available frequencies and prepare to set new die frequencies.
+ *
+ * This function should NOT be called in the fast path.
+ *
+ * @param pkg
+ * Package number.
+ * Each physical CPU in a system is referred to as a package.
+ * @param die
+ * Die number.
+ * Each package can have several dies connected together via the uncore mesh.
+ *
+ * @return
+ * - 0 on success.
+ * - Negative on error.
+ */
+__rte_experimental
+int
+rte_power_uncore_init(unsigned int pkg, unsigned int die);
+
+/**
+ * Exit uncore frequency management on a specific die on a package.
+ * It will restore uncore min and* max values to previous values
+ * before initialization of API.
+ *
+ * This function should NOT be called in the fast path.
+ *
+ * @param pkg
+ * Package number.
+ * Each physical CPU in a system is referred to as a package.
+ * @param die
+ * Die number.
+ * Each package can have several dies connected together via the uncore mesh.
+ *
+ * @return
+ * - 0 on success.
+ * - Negative on error.
+ */
+__rte_experimental
+int
+rte_power_uncore_exit(unsigned int pkg, unsigned int die);
+
+/**
+ * Return the current index of available frequencies of a specific die on a package.
+ * It should be protected outside of this function for threadsafe.
+ *
+ * This function should NOT be called in the fast path.
+ *
+ * @param pkg
+ * Package number.
+ * Each physical CPU in a system is referred to as a package.
+ * @param die
+ * Die number.
+ * Each package can have several dies connected together via the uncore mesh.
+ *
+ * @return
+ * The current index of available frequencies.
+ * If error, it will return 'RTE_POWER_INVALID_FREQ_INDEX = (~0)'.
+ */
+typedef uint32_t (*rte_power_get_uncore_freq_t)(unsigned int pkg, unsigned int die);
+
+extern rte_power_get_uncore_freq_t rte_power_get_uncore_freq;
+
+/**
+ * Set minimum and maximum uncore frequency for specified die on a package
+ * to specified index value.
+ * It should be protected outside of this function for threadsafe.
+ *
+ * This function should NOT be called in the fast path.
+ *
+ * @param pkg
+ * Package number.
+ * Each physical CPU in a system is referred to as a package.
+ * @param die
+ * Die number.
+ * Each package can have several dies connected together via the uncore mesh.
+ * @param index
+ * The index of available frequencies.
+ *
+ * @return
+ * - 1 on success with frequency changed.
+ * - 0 on success without frequency changed.
+ * - Negative on error.
+ */
+typedef int (*rte_power_set_uncore_freq_t)(unsigned int pkg, unsigned int die, uint32_t index);
+
+extern rte_power_set_uncore_freq_t rte_power_set_uncore_freq;
+
+/**
+ * Function pointer definition for generic frequency change functions.
+ *
+ * @param pkg
+ * Package number.
+ * Each physical CPU in a system is referred to as a package.
+ * @param die
+ * Die number.
+ * Each package can have several dies connected together via the uncore mesh.
+ *
+ * @return
+ * - 1 on success with frequency changed.
+ * - 0 on success without frequency changed.
+ * - Negative on error.
+ */
+typedef int (*rte_power_uncore_freq_change_t)(unsigned int pkg, unsigned int die);
+
+/**
+ * Set minimum and maximum uncore frequency for specified die on a package
+ * to maximum value according to the available frequencies.
+ * It should be protected outside of this function for threadsafe.
+ *
+ * This function should NOT be called in the fast path.
+ *
+ * @param pkg
+ * Package number.
+ * Each physical CPU in a system is referred to as a package.
+ * @param die
+ * Die number.
+ * Each package can have several dies connected together via the uncore mesh.
+ *
+ * @return
+ * - 1 on success with frequency changed.
+ * - 0 on success without frequency changed.
+ * - Negative on error.
+ */
+extern rte_power_uncore_freq_change_t rte_power_uncore_freq_max;
+
+/**
+ * Set minimum and maximum uncore frequency for specified die on a package
+ * to minimum value according to the available frequencies.
+ * It should be protected outside of this function for threadsafe.
+ *
+ * This function should NOT be called in the fast path.
+ *
+ * @param pkg
+ * Package number.
+ * Each physical CPU in a system is referred to as a package.
+ * @param die
+ * Die number.
+ * Each package can have several dies connected together via the uncore mesh.
+ *
+ * @return
+ * - 1 on success with frequency changed.
+ * - 0 on success without frequency changed.
+ * - Negative on error.
+ */
+extern rte_power_uncore_freq_change_t rte_power_uncore_freq_min;
+
+/**
+ * Return the list length of available frequencies in the index array.
+ *
+ * This function should NOT be called in the fast path.
+ *
+ * @param pkg
+ * Package number.
+ * Each physical CPU in a system is referred to as a package.
+ * @param die
+ * Die number.
+ * Each package can have several dies connected together via the uncore mesh.
+ * @param freqs
+ * The buffer array to save the frequencies.
+ * @param num
+ * The number of frequencies to get.
+ *
+ * @return
+ * - The number of available index's in frequency array.
+ * - Negative on error.
+ */
+typedef int (*rte_power_uncore_freqs_t)(unsigned int pkg, unsigned int die,
+ uint32_t *freqs, uint32_t num);
+
+extern rte_power_uncore_freqs_t rte_power_uncore_freqs;
+
+/**
+ * Return the number of packages (CPUs) on a system
+ * by parsing the uncore sysfs directory.
+ *
+ * This function should NOT be called in the fast path.
+ *
+ * @return
+ * - Zero on error.
+ * - Number of package on system on success.
+ */
+typedef unsigned int (*rte_power_uncore_get_num_pkgs_t)(void);
+
+extern rte_power_uncore_get_num_pkgs_t rte_power_uncore_get_num_pkgs;
+
+/**
+ * Return the number of dies for pakckages (CPUs) specified
+ * from parsing the uncore sysfs directory.
+ *
+ * This function should NOT be called in the fast path.
+ *
+ * @param pkg
+ * Package number.
+ * Each physical CPU in a system is referred to as a package.
+ *
+ * @return
+ * - Zero on error.
+ * - Number of dies for package on sucecss.
+ */
+typedef unsigned int (*rte_power_uncore_get_num_pkgs_t)(unsigned int pkg);
+
+extern rte_power_uncore_get_num_dies_t rte_power_uncore_get_num_dies;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* RTE_POWER_UNCORE_H */