fix: [SWDEV-448201] [rocm/amd_smi_lib]

Adds Add PCIE Errors

Code changes related to the following:
  * amdsmi_get_pcie_info()
  * CLI
  * examples

Change-Id: Ie0b7053e77c88fb18309c16e74bce75d862c45a9
Signed-off-by: Oliveira, Daniel <daniel.oliveira@amd.com>
This commit is contained in:
Oliveira, Daniel
2024-03-05 14:01:06 -06:00
committed by Guan Yu
parent 06fa6580c4
commit 1310c767ce
7 changed files with 200 additions and 102 deletions
+1 -1
View File
@@ -509,7 +509,7 @@ typedef struct {
struct pcie_metric_ {
uint16_t pcie_width; //!< current PCIe width
uint32_t pcie_speed; //!< current PCIe speed in MT/s
uint32_t pcie_bandwidth; //!< current PCIe bandwidth Mb/s
uint32_t pcie_bandwidth; //!< current instantaneous PCIe bandwidth in Mb/s
uint64_t pcie_replay_count; //!< total number of the replays issued on the PCIe link
uint64_t pcie_l0_to_recovery_count; //!< total number of times the PCIe link transitioned from L0 to the recovery state
uint64_t pcie_replay_roll_over_count; //!< total number of replay rollovers issued on the PCIe link
+54
View File
@@ -21,6 +21,9 @@
#ifndef AMD_SMI_INCLUDE_AMD_SMI_UTILS_H_
#define AMD_SMI_INCLUDE_AMD_SMI_UTILS_H_
#include <limits>
#include <type_traits>
#include "amd_smi/amdsmi.h"
#include "amd_smi/impl/amd_smi_gpu_device.h"
#include "rocm_smi/rocm_smi_utils.h"
@@ -45,4 +48,55 @@ amdsmi_status_t smi_amdgpu_get_pcie_speed_from_pcie_type(uint16_t pcie_type, uin
amdsmi_status_t smi_amdgpu_get_market_name_from_dev_id(uint32_t device_id, char *market_name);
amdsmi_status_t smi_amdgpu_is_gpu_power_management_enabled(amd::smi::AMDSmiGPUDevice* device, bool *enabled);
template<typename>
constexpr bool is_dependent_false_v = false;
template<typename T>
inline constexpr bool is_supported_type_v = (
std::is_same_v<std::remove_cv_t<std::remove_reference_t<T>>, std::uint8_t> ||
std::is_same_v<std::remove_cv_t<std::remove_reference_t<T>>, std::uint16_t> ||
std::is_same_v<std::remove_cv_t<std::remove_reference_t<T>>, std::uint32_t> ||
std::is_same_v<std::remove_cv_t<std::remove_reference_t<T>>, std::uint64_t>
);
template<typename T>
constexpr T get_std_num_limit()
{
if constexpr (is_supported_type_v<T>) {
return std::numeric_limits<T>::max();
}
else {
return std::numeric_limits<T>::min();
static_assert(is_dependent_false_v<T>, "Error: Type not supported...");
}
}
template<typename T>
constexpr bool is_std_num_limit(T value)
{
return (value == get_std_num_limit<T>());
}
template<typename T, typename U, typename V = T>
constexpr T translate_umax_or_assign_value(U source_value, V target_value)
{
T result{};
if constexpr (is_supported_type_v<T> && is_supported_type_v<U>) {
// If the source value is uint<U>::max(), then return is uint<T>::max()
if (is_std_num_limit(source_value)) {
result = get_std_num_limit<T>();
} else {
result = static_cast<T>(target_value);
}
return result;
}
else {
static_assert(is_dependent_false_v<T>, "Error: Type not supported...");
}
return result;
}
#endif //