diff --git a/CMakeLists.txt b/CMakeLists.txt index 4b9c9643f2..97fa12d871 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -95,6 +95,7 @@ set(SHR_MUTEX_DIR "${PROJECT_SOURCE_DIR}/third_party/shared_mutex") if(ENABLE_ESMI_LIB) if((EXISTS ${PROJECT_SOURCE_DIR}/e_smi_library/src) AND (EXISTS ${PROJECT_SOURCE_DIR}/e_smi_library/src/e_smi_plat.c)) set(ESMI_AVAILABLE TRUE) + add_definitions("-DENABLE_ESMI_LIB=1") else() message("E-smi source not found. Errors will be encountered during compilation!!!") endif() diff --git a/include/amd_smi/amdsmi.h b/include/amd_smi/amdsmi.h index 679e54aab8..529c795fa8 100644 --- a/include/amd_smi/amdsmi.h +++ b/include/amd_smi/amdsmi.h @@ -53,6 +53,10 @@ #ifdef __cplusplus extern "C" { #include +#ifdef ENABLE_ESMI_LIB + #include +#endif + #else #include #endif // __cplusplus @@ -122,16 +126,24 @@ typedef enum { //! opaque handler point to underlying implementation typedef void *amdsmi_processor_handle; typedef void *amdsmi_socket_handle; +#ifdef ENABLE_ESMI_LIB +typedef void *amdsmi_cpusocket_handle; +#endif /** - * @brief Device types detectable by AMD SMI + * @brief Processor types detectable by AMD SMI + * AMD_CPU - CPU Socket is a physical component that holds the CPU. + * AMD_CPU_CORE - CPU Cores are number of individual processing units within the CPU. + * AMD_APU - Combination of AMD_CPU and integrated GPU on single die */ typedef enum { UNKNOWN = 0, AMD_GPU, AMD_CPU, NON_AMD_GPU, - NON_AMD_CPU + NON_AMD_CPU, + AMD_CPU_CORE, + AMD_APU } processor_type_t; /** @@ -171,6 +183,17 @@ typedef enum { AMDSMI_STATUS_INSUFFICIENT_SIZE = 41, //!< Not enough resources were available for the operation AMDSMI_STATUS_UNEXPECTED_SIZE = 42, //!< An unexpected amount of data was read AMDSMI_STATUS_UNEXPECTED_DATA = 43, //!< The data read or provided to function is not what was expected + //esmi errors + AMDSMI_STATUS_NON_AMD_CPU = 44, //!< System has different cpu than AMD + AMDSMI_NO_ENERGY_DRV = 45, //!< Energy driver not found + AMDSMI_NO_MSR_DRV = 46, //!< MSR driver not found + AMDSMI_NO_HSMP_DRV = 47, //!< HSMP driver not found + AMDSMI_NO_HSMP_SUP = 48, //!< HSMP not supported + AMDSMI_NO_HSMP_MSG_SUP = 49, //!< HSMP message/feature not supported + AMDSMI_HSMP_TIMEOUT = 50, //!< HSMP message is timedout + AMDSMI_NO_DRV = 51, //!< No Energy and HSMP driver present + AMDSMI_FILE_NOT_FOUND = 52, //!< file or directory not found + AMDSMI_ARG_PTR_NULL = 53, //!< Parsed argument is invalid // General errors AMDSMI_STATUS_MAP_ERROR = 0xFFFFFFFE, //!< The internal library error did not map to a status code AMDSMI_STATUS_UNKNOWN_ERROR = 0xFFFFFFFF, //!< An unknown error occurred @@ -1099,6 +1122,76 @@ typedef struct { //! but do have monitors or sensors. #define AMDSMI_DEFAULT_VARIANT 0xFFFFFFFFFFFFFFFF +#ifdef ENABLE_ESMI_LIB +/** + * @brief This structure holds SMU Firmware version information. + */ +typedef struct { + uint8_t debug; //!< SMU fw Debug version number + uint8_t minor; //!< SMU fw Minor version number + uint8_t major; //!< SMU fw Major version number + uint8_t unused; //!< reserved fields +} amdsmi_smu_fw_version_t; + +/** + * @brief DDR bandwidth metrics. + */ +typedef struct { + uint32_t max_bw; //!< DDR Maximum theoritical bandwidth in GB/s + uint32_t utilized_bw; //!< DDR bandwidth utilization in GB/s + uint32_t utilized_pct; //!< DDR bandwidth utilization in % of theoritical max +} amdsmi_ddr_bw_metrics_t; + +/** + * @brief temperature range and refresh rate metrics of a DIMM + */ +typedef struct { + uint8_t range : 3; //!< temp range[2:0](3 bit data) + uint8_t ref_rate : 1; //!< DDR refresh rate mode[3](1 bit data) +} amdsmi_temp_range_refresh_rate_t; + +/** + * @brief DIMM Power(mW), power update rate(ms) and dimm address + */ +typedef struct { + uint16_t power : 15; //!< Dimm power consumption[31:17](15 bits data) + uint16_t update_rate : 9; //!< Time since last update[16:8](9 bit data) + uint8_t dimm_addr; //!< Dimm address[7:0](8 bit data) +} amdsmi_dimm_power_t; + +/** + * @brief DIMM temperature(°C) and update rate(ms) and dimm address + */ +typedef struct { + uint16_t sensor : 11; //!< Dimm thermal sensor[31:21](11 bit data) + uint16_t update_rate : 9; //!< Time since last update[16:8](9 bit data) + uint8_t dimm_addr; //!< Dimm address[7:0](8 bit data) + float temp; //!< temperature in degree celcius +} amdsmi_dimm_thermal_t; + +/** + * @brief LINK name and Bandwidth type Information.It contains + * link names i.e valid link names are + * "P0", "P1", "P2", "P3", "P4", "G0", "G1", "G2", "G3", "G4" + * "G5", "G6", "G7" + * Valid bandwidth types 1(Aggregate_BW), 2 (Read BW), 4 (Write BW). + */ +typedef struct { + io_bw_encoding bw_type; //!< Bandwidth Type Information [1, 2, 4] + char *link_name; //!< Link name [P0, P1, G0, G1 etc] +} amdsmi_link_id_bw_type_t; + +/** + * @brief max and min LCLK DPM level on a given NBIO ID. + * Valid max and min DPM level values are 0 - 1. + */ +typedef struct { + uint8_t max_dpm_level; //!< Max LCLK DPM level[15:8](8 bit data) + uint8_t min_dpm_level; //!< Min LCLK DPM level[7:0](8 bit data) +} amdsmi_dpm_level_t; + +#endif + /*****************************************************************************/ /** @defgroup InitShutAdmin Initialization and Shutdown * These functions are used for initialization of AMD SMI and clean up when done. @@ -1108,7 +1201,7 @@ typedef struct { /** * @brief Initialize the AMD SMI library * - * @details This function initializes the library and the internal data structures, + * @details This function initializes the library and the internal data structures, * including those corresponding to sources of information that SMI provides. * * The @p init_flags decides which type of processor @@ -1128,7 +1221,7 @@ amdsmi_status_t amdsmi_init(uint64_t init_flags); /** * @brief Shutdown the AMD SMI library * - * @details This function shuts down the library and internal data structures and + * @details This function shuts down the library and internal data structures and * performs any necessary clean ups. * * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail @@ -1172,10 +1265,39 @@ amdsmi_status_t amdsmi_shut_down(void); amdsmi_status_t amdsmi_get_socket_handles(uint32_t *socket_count, amdsmi_socket_handle* socket_handles); +#ifdef ENABLE_ESMI_LIB +/** + * @brief Get the list of cpu socket handles in the system. + * + * @details Depends on AMDSMI_INIT_AMD_CPUS flag passed to ::amdsmi_init. + * The socket handles can be used to query the processor handles in that socket, which + * will be used in other APIs to get processor detail information. + * + * @param[in,out] socket_count As input, the value passed + * through this parameter is the number of ::amdsmi_cpusocket_handle that + * may be safely written to the memory pointed to by @p socket_handles. This is the + * limit on how many socket handles will be written to @p socket_handles. On return, @p + * socket_count will contain the number of socket handles written to @p socket_handles, + * or the number of socket handles that could have been written if enough memory had been + * provided. + * If @p socket_handles is NULL, as output, @p socket_count will contain + * how many sockets are available to read in the system. + * + * @param[in,out] socket_handles A pointer to a block of memory to which the + * ::amdsmi_cpusocket_handle values will be written. This value may be NULL. + * In this case, this function can be used to query how many sockets are + * available to read in the system. + * + * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail + */ +amdsmi_status_t amdsmi_get_cpusocket_handles(uint32_t *socket_count, + amdsmi_cpusocket_handle* socket_handles); +#endif + /** * @brief Get information about the given socket * - * @details This function retrieves socket information. The @p socket_handle must + * @details This function retrieves socket information. The @p socket_handle must * be provided to retrieve the Socket ID. * * @param[in] socket_handle a socket handle @@ -1190,6 +1312,22 @@ amdsmi_status_t amdsmi_get_socket_info( amdsmi_socket_handle socket_handle, size_t len, char *name); +#ifdef ENABLE_ESMI_LIB +/** + * @brief Get information about the given cpu socket + * + * @details This function retrieves cpu socket information. The @p socket_handle must + * be provided to retrieve the Socket ID. + * + * @param[in] socket_handle a socket handle + * + * @param[out] sockid The id of the socket. + * + * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail + */ +amdsmi_status_t amdsmi_get_cpusocket_info(amdsmi_cpusocket_handle socket_handle, uint32_t sockid); +#endif + /** * @brief Get the list of the processor handles associated to a socket. * @@ -1225,6 +1363,34 @@ amdsmi_status_t amdsmi_get_processor_handles(amdsmi_socket_handle socket_handle, uint32_t *processor_count, amdsmi_processor_handle* processor_handles); +#ifdef ENABLE_ESMI_LIB +/** + * @brief Get the list of the cpu core handles associated to a cpu socket. + * + * @details This function retrieves the cpu core handles of a cpu socket. + * @param[in] socket_handle The cpu socket to query + * @param[in,out] processor_count As input, the value passed + * through this parameter is the number of ::amdsmi_processor_handle's that + * may be safely written to the memory pointed to by @p processor_handles. This is the + * limit on how many processor handles will be written to @p processor_handles. On return, @p + * processor_count will contain the number of processor handles written to @p processor_handles, + * or the number of processor handles that could have been written if enough memory had been + * provided. + * If @p processor_handles is NULL, as output, @p processor_count will contain + * how many cpu cores are available to read for the cpu socket. + * + * @param[in,out] processor_handles A pointer to a block of memory to which the + * ::amdsmi_processor_handle values will be written. This value may be NULL. + * In this case, this function can be used to query how many processors are + * available to read. + * + * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail +*/ +amdsmi_status_t amdsmi_get_cpucore_handles(amdsmi_cpusocket_handle socket_handle, + uint32_t *processor_count, + amdsmi_processor_handle* processor_handles); +#endif + /** * @brief Get the processor type of the processor_handle * @@ -1729,7 +1895,7 @@ amdsmi_get_gpu_memory_usage(amdsmi_processor_handle processor_handle, amdsmi_mem * records. * @param[in] processor_handle a processor handle * @param[out] num_pages Number of bad page records. - * @param[out] info The results will be written to the + * @param[out] info The results will be written to the * amdsmi_retired_page_record_t pointer. * * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail @@ -2063,7 +2229,7 @@ amdsmi_status_t amdsmi_get_pcie_link_caps(amdsmi_processor_handle processor_hand * * @details This function will write the ::amdsmi_dev_perf_level_t to the uint32_t * pointed to by @p perf, for a given processor handle @p processor_handle and a pointer - * to a uint32_t @p perf. + * to a uint32_t @p perf. * * @param[in] processor_handle a processor handle * @@ -3227,7 +3393,7 @@ amdsmi_get_gpu_driver_info(amdsmi_processor_handle processor_handle, amdsmi_driv /** * @brief Returns the ASIC information for the device - * + * * @details This function returns ASIC information such as the product name, * the vendor ID, the subvendor ID, the device ID, * the revision ID and the serial number. @@ -3461,6 +3627,589 @@ amdsmi_get_gpu_total_ecc_count(amdsmi_processor_handle processor_handle, amdsmi_ /** @} End eccinfo */ +#ifdef ENABLE_ESMI_LIB +/*---------------------------------------------------------------------------*/ +/** @defgroup energyinfo Energy information (RAPL MSR) */ +/*---------------------------------------------------------------------------*/ +/** @{ */ + +/** + * @brief Get the core energy for a given core. + * + * @param[in] processor_handle Cpu core which to query + * @param[in] core_ind - cpu core index + * + * @param[in,out] penergy - Input buffer to return the core energy + * + * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail + */ +amdsmi_status_t amdsmi_get_cpu_core_energy(amdsmi_processor_handle processor_handle, + uint32_t core_ind, uint64_t *penergy); + +/** + * @brief Get the socket energy for a given socket. + * + * @param[in] socket_handle Cpu socket which to query + * @param[in] sock_ind - socket index + * + * @param[in,out] penergy - Input buffer to return the socket energy + * + * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail + */ +amdsmi_status_t amdsmi_get_cpu_socket_energy(amdsmi_cpusocket_handle socket_handle, + uint32_t sock_ind, uint64_t *penergy); + +/** @} */ + +/*---------------------------------------------------------------------------*/ +/** @defgroup systemstatistics HSMP system statistics */ +/*---------------------------------------------------------------------------*/ +/** @{ */ + +/** + * @brief Get SMU Firmware Version. + * + * @param[in,out] amdsmi_smu_fw - Input buffer to return the firmware version + * + * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail + */ +amdsmi_status_t amdsmi_get_smu_fw_version(amdsmi_smu_fw_version_t *amdsmi_smu_fw); + +/** + * @brief Get HSMP protocol Version. + * + * @param[in,out] proto_ver - Input buffer to return the protocol version + * + * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail + */ +amdsmi_status_t amdsmi_get_hsmp_proto_ver(uint32_t *proto_ver); + +/** + * @brief Get normalized status of the processor's PROCHOT status. + * + * @param[in] socket_handle Cpu socket which to query + * @param[in] sock_ind - socket index + * + * @param[in,out] prochot - Input buffer to return the procohot status. + * + * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail + */ +amdsmi_status_t amdsmi_get_cpu_prochot_status(amdsmi_cpusocket_handle socket_handle, + uint32_t sock_ind, uint32_t *prochot); + +/** + * @brief Get Data fabric clock and Memory clock in MHz. + * + * @param[in] socket_handle Cpu socket which to query + * @param[in] sock_ind - socket index + * + * @param[in,out] fclk - Input buffer to return fclk + * + * @param[in,out] mclk - Input buffer to return mclk + * + * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail + */ +amdsmi_status_t amdsmi_get_cpu_fclk_mclk(amdsmi_cpusocket_handle socket_handle, + uint32_t sock_ind, uint32_t *fclk, uint32_t *mclk); + +/** + * @brief Get core clock in MHz. + * + * @param[in] socket_handle Cpu socket which to query + * @param[in] sock_ind - socket index + * + * @param[in,out] cclk - Input buffer to return core clock + * + * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail + */ +amdsmi_status_t amdsmi_get_cpu_cclk_limit(amdsmi_cpusocket_handle socket_handle, + uint32_t sock_ind, uint32_t *cclk); + +/** + * @brief Get current active frequency limit of the socket. + * + * @param[in] socket_handle Cpu socket which to query + * @param[in] sock_ind - socket index + * + * @param[in,out] freq - Input buffer to return frequency value in MHz + * + * @param[in,out] src_type - Input buffer to return frequency source name + * + * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail + */ +amdsmi_status_t amdsmi_get_cpu_socket_current_active_freq_limit(amdsmi_cpusocket_handle socket_handle, + uint32_t sock_ind, uint16_t *freq, char **src_type); + +/** + * @brief Get socket frequency range. + * + * @param[in] socket_handle Cpu socket which to query + * @param[in] sock_ind - socket index + * + * @param[in,out] fmax - Input buffer to return maximum frequency + * + * @param[in,out] fmin - Input buffer to return minimum frequency + * + * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail + */ +amdsmi_status_t amdsmi_get_cpu_socket_freq_range(amdsmi_cpusocket_handle socket_handle, + uint32_t sock_ind, uint16_t *fmax, uint16_t *fmin); + +/** + * @brief Get socket frequency limit of the core. + * + * @param[in] processor_handle Cpu core which to query + * @param[in] core_ind - core index + * + * @param[in,out] freq - Input buffer to return frequency. + * + * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail + */ +amdsmi_status_t amdsmi_get_cpu_core_current_freq_limit(amdsmi_processor_handle processor_handle, + uint32_t core_ind, uint32_t *freq); + +/** @} */ + +/*---------------------------------------------------------------------------*/ +/** @defgroup powercont Power Control */ +/*---------------------------------------------------------------------------*/ +/** @{ */ + +/** + * @brief Get the socket power. + * + * @param[in] socket_handle Cpu socket which to query + * @param[in] sock_ind - socket index + * + * @param[in,out] ppower - Input buffer to return socket power + * + * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail + */ +amdsmi_status_t amdsmi_get_cpu_socket_power(amdsmi_cpusocket_handle socket_handle, + uint32_t sock_ind, uint32_t *ppower); + +/** + * @brief Get the socket power cap. + * + * @param[in] socket_handle Cpu socket which to query + * @param[in] sock_ind - socket index + * + * @param[in,out] pcap - Input buffer to return power cap. + * + * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail + */ +amdsmi_status_t amdsmi_get_cpu_socket_power_cap(amdsmi_cpusocket_handle socket_handle, + uint32_t sock_ind, uint32_t *pcap); + +/** + * @brief Get the maximum power cap value for a given socket. + * + * @param[in] socket_handle Cpu socket which to query + * @param[in] sock_ind - socket index + * + * @param[in,out] pmax - Input buffer to return maximum power limit value + * + * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail + */ +amdsmi_status_t amdsmi_get_cpu_socket_power_cap_max(amdsmi_cpusocket_handle socket_handle, + uint32_t sock_ind, uint32_t *pmax); + +/** + * @brief Get the SVI based power telemetry for all rails. + * + * @param[in] socket_handle Cpu socket which to query + * @param[in] sock_ind - socket index + * + * @param[in,out] power - Input buffer to return svi based power value + * + * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail + */ +amdsmi_status_t amdsmi_get_cpu_pwr_svi_telemetry_all_rails(amdsmi_cpusocket_handle socket_handle, + uint32_t sock_ind, uint32_t *power); + +/** + * @brief Set the power cap value for a given socket. + * + * @param[in] socket_handle Cpu socket which to query + * @param[in] sock_ind - socket index + * + * @param[in] power - Input power limit value + * + * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail + */ +amdsmi_status_t amdsmi_set_cpu_socket_power_cap(amdsmi_cpusocket_handle socket_handle, + uint32_t sock_ind, uint32_t pcap); + +/** + * @brief Set the power efficiency profile policy. + * + * @param[in] socket_handle Cpu socket which to query + * @param[in] sock_ind - socket index + * + * @param[in] mode - mode to be set + * + * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail + */ +amdsmi_status_t amdsmi_set_cpu_pwr_efficiency_mode(amdsmi_cpusocket_handle socket_handle, + uint8_t sock_ind, uint8_t mode); + +/** @} */ + +/*---------------------------------------------------------------------------*/ +/** @defgroup perfcont Performance (Boost limit) Control */ +/*---------------------------------------------------------------------------*/ +/** @{ */ + +/** + * @brief Get the core boost limit. + * + * @param[in] processor_handle Cpu core which to query + * @param[in] core_ind - core index + * + * @param[in,out] pboostlimit - Input buffer to fill the boostlimit value + * + * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail + */ +amdsmi_status_t amdsmi_get_cpu_core_boostlimit(amdsmi_processor_handle processor_handle, + uint32_t core_ind, uint32_t *pboostlimit); + +/** + * @brief Get the socket c0 residency. + * + * @param[in] socket_handle Cpu socket which to query + * @param[in] sock_ind - socket index + * + * @param[in,out] pc0_residency - Input buffer to fill the c0 residency value + * + * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail + */ +amdsmi_status_t amdsmi_get_cpu_socket_c0_residency(amdsmi_cpusocket_handle socket_handle, + uint32_t sock_ind, uint32_t *pc0_residency); + +/** + * @brief Set the core boostlimit value. + * + * @param[in] processor_handle Cpu core which to query + * @param[in] core_ind - core index + * + * @param[in] boostlimit - boostlimit value to be set + * + * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail + */ +amdsmi_status_t amdsmi_set_cpu_core_boostlimit(amdsmi_processor_handle processor_handle, + uint32_t core_ind, uint32_t boostlimit); + +/** + * @brief Set the socket boostlimit value. + * + * @param[in] socket_handle Cpu socket which to query + * @param[in] sock_ind - socket index + * + * @param[in] boostlimit - boostlimit value to be set + * + * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail + */ +amdsmi_status_t amdsmi_set_cpu_socket_boostlimit(amdsmi_cpusocket_handle socket_handle, + uint32_t sock_ind, uint32_t boostlimit); + +/** @} */ + +/*---------------------------------------------------------------------------*/ +/** @defgroup ddrquer DDR bandwidth monitor */ +/*---------------------------------------------------------------------------*/ +/** @{ */ + +/** + * @brief Get the DDR bandwidth data. + * + * @param[in,out] ddr_bw - Input buffer to fill ddr bandwidth data + * + * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail + */ +amdsmi_status_t amdsmi_get_cpu_ddr_bw(amdsmi_ddr_bw_metrics_t *ddr_bw); + +/** @} */ + +/*---------------------------------------------------------------------------*/ +/** @defgroup tempquer Temperature Query */ +/*---------------------------------------------------------------------------*/ +/** @{ */ + +/** + * @brief Get socket temperature. + * + * @param[in] socket_handle Cpu socket which to query + * @param[in] sock_ind - socket index + * + * @param[in,out] ptmon - Input buffer to fill temperature value + * + * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail + */ +amdsmi_status_t amdsmi_get_cpu_socket_temperature(amdsmi_cpusocket_handle socket_handle, + uint32_t sock_ind, uint32_t *ptmon); + +/** @} */ + +/*---------------------------------------------------------------------------*/ +/** @defgroup dimmstatistics Dimm statistics */ +/*---------------------------------------------------------------------------*/ +/** @{ */ + +/** + * @brief Get DIMM temperature range and refresh rate. + * + * @param[in] socket_handle Cpu socket which to query + * @param[in] sock_ind - socket index + * @param[in] dimm_addr - DIMM address + * @param[in,out] rate - Input buffer to fill temperature range and refresh rate value + * + * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail + */ +amdsmi_status_t amdsmi_get_cpu_dimm_temp_range_and_refresh_rate(amdsmi_cpusocket_handle socket_handle, + uint8_t sock_ind, uint8_t dimm_addr, amdsmi_temp_range_refresh_rate_t *rate); + +/** + * @brief Get DIMM power consumption. + * + * @param[in] socket_handle Cpu socket which to query + * @param[in] sock_ind - socket index + * @param[in] dimm_addr - DIMM address + * @param[in,out] rate - Input buffer to fill power consumption value + * + * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail + */ +amdsmi_status_t amdsmi_get_cpu_dimm_power_consumption(amdsmi_cpusocket_handle socket_handle, + uint8_t sock_ind, uint8_t dimm_addr, amdsmi_dimm_power_t *dimm_pow); + +/** + * @brief Get DIMM thermal sensor value. + * + * @param[in] socket_handle Cpu socket which to query + * @param[in] sock_ind - socket index + * @param[in] dimm_addr - DIMM address + * @param[in,out] dimm_temp - Input buffer to fill temperature value + * + * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail + */ +amdsmi_status_t amdsmi_get_cpu_dimm_thermal_sensor(amdsmi_cpusocket_handle socket_handle, + uint8_t sock_ind, uint8_t dimm_addr, amdsmi_dimm_thermal_t *dimm_temp); + +/** @} */ + +/*---------------------------------------------------------------------------*/ +/** @defgroup xgmibwcont xGMI bandwidth control */ +/*---------------------------------------------------------------------------*/ +/** @{ */ + +/** + * @brief Set xgmi width. + * + * @param[in] socket_handle Cpu socket which to query + * @param[in] min - Minimum xgmi width to be set + * @param[in] max - maximum xgmi width to be set + * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail + */ +amdsmi_status_t amdsmi_set_cpu_xgmi_width(amdsmi_cpusocket_handle socket_handle, + uint8_t min, uint8_t max); + +/** @} */ + +/*---------------------------------------------------------------------------*/ +/** @defgroup gmi3widthcont GMI3 width control */ +/*---------------------------------------------------------------------------*/ +/** @{ */ + +/** + * @brief Set gmi3 link width range. + * + * @param[in] socket_handle Cpu socket which to query + * @param[in] sock_ind - socket index + * @param[in] min_link_width - minimum link width to be set. + * @param[in] max_link_width - maximum link width to be set. + * + * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail + */ +amdsmi_status_t amdsmi_set_cpu_gmi3_link_width_range(amdsmi_cpusocket_handle socket_handle, + uint8_t sock_ind, uint8_t min_link_width, uint8_t max_link_width); + +/** @} */ + +/*---------------------------------------------------------------------------*/ +/** @defgroup pstatecnt Pstate selection */ +/*---------------------------------------------------------------------------*/ +/** @{ */ + +/** + * @brief Enable APB. + * + * @param[in] socket_handle Cpu socket which to query + * @param[in] sock_ind - socket index + * + * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail + */ +amdsmi_status_t amdsmi_cpu_apb_enable(amdsmi_cpusocket_handle socket_handle, uint32_t sock_ind); + +/** + * @brief Disable APB. + * + * @param[in] socket_handle Cpu socket which to query + * @param[in] sock_ind - socket index + * + * @param[in] pstate - pstate value to be set + * + * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail + */ +amdsmi_status_t amdsmi_cpu_apb_disable(amdsmi_cpusocket_handle socket_handle, + uint32_t sock_ind, uint8_t pstate); + +/** + * @brief Set NBIO lclk dpm level value. + * + * @param[in] socket_handle Cpu socket which to query + * @param[in] sock_ind - socket index + * @param[in] nbio_id - nbio index + * @param[in] min - minimum value to be set + * @param[in] max - maximum value to be set + * + * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail + */ +amdsmi_status_t amdsmi_set_cpu_socket_lclk_dpm_level(amdsmi_cpusocket_handle socket_handle, + uint32_t sock_ind, uint8_t nbio_id, uint8_t min, uint8_t max); + +/** + * @brief Get NBIO LCLK dpm level. + * + * @param[in] socket_handle Cpu socket which to query + * @param[in] sock_ind - socket index + * @param[in] nbio_id - nbio index + * @param[in,out] nbio - Input buffer to fill lclk dpm level + * + * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail + */ +amdsmi_status_t amdsmi_get_cpu_socket_lclk_dpm_level(amdsmi_cpusocket_handle socket_handle, + uint8_t sock_ind, uint8_t nbio_id, amdsmi_dpm_level_t *nbio); + +/** + * @brief Set pcie link rate. + * + * @param[in] socket_handle Cpu socket which to query + * @param[in] sock_ind - socket index + * @param[in] rate_ctrl - rate control value to be set. + * @param[in,out] prev_mode - Input buffer to fill previous rate control value. + * + * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail + */ +amdsmi_status_t amdsmi_set_cpu_pcie_link_rate(amdsmi_cpusocket_handle socket_handle, + uint8_t sock_ind, uint8_t rate_ctrl, uint8_t *prev_mode); + +/** + * @brief Set df pstate range. + * + * @param[in] socket_handle Cpu socket which to query + * @param[in] sock_ind - socket index + * @param[in] max_pstate - maximum pstate value to be set + * @param[in] min_pstate - minimum pstate value to be set + * + * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail + */ +amdsmi_status_t amdsmi_set_cpu_df_pstate_range(amdsmi_cpusocket_handle socket_handle, + uint8_t sock_ind, uint8_t max_pstate, uint8_t min_pstate); + +/** @} */ + +/*---------------------------------------------------------------------------*/ +/** @defgroup bwquer Bandwidth monitor */ +/*---------------------------------------------------------------------------*/ +/** @{ */ + +/** + * @brief Get current input output bandwidth. + * + * @param[in] socket_handle Cpu socket which to query + * @param[in] sock_ind - socket index + * @param[in] link - link id and bw type to which io bandwidth to be obtained + * @param[in,out] io_bw - Input buffer to fill bandwidth data + * + * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail + */ +amdsmi_status_t amdsmi_get_cpu_current_io_bandwidth(amdsmi_cpusocket_handle socket_handle, + uint8_t sock_ind, amdsmi_link_id_bw_type_t link, uint32_t *io_bw); + +/** + * @brief Get current input output bandwidth. + * + * @param[in] link - link id and bw type to which xgmi bandwidth to be obtained + * @param[in,out] xgmi_bw - Input buffer to fill bandwidth data + * + * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail + */ +amdsmi_status_t amdsmi_get_cpu_current_xgmi_bw(amdsmi_link_id_bw_type_t link, uint32_t *xgmi_bw); + +/** @} */ + +/*---------------------------------------------------------------------------*/ +/** @defgroup auxiquer Auxillary functions */ +/*---------------------------------------------------------------------------*/ +/** @{ */ + +/** + * @brief Get cpu family. + * + * @param[in,out] family - Input buffer to fill family + * + * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail + */ +amdsmi_status_t amdsmi_get_cpu_family(uint32_t family); + +/** + * @brief Get cpu model. + * + * @param[in,out] family - Input buffer to fill family + * + * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail + */ +amdsmi_status_t amdsmi_get_cpu_model(uint32_t model); + +/** + * @brief Get threads per core. + * + * @param[in,out] threads - Input buffer to fill threads count. + * + * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail + */ +amdsmi_status_t amdsmi_get_cpu_threads_per_core(uint32_t threads); + +/** + * @brief Get number of cpus. + * + * @param[in,out] cpus - Input buffer to fill number of cpus. + * + * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail + */ +amdsmi_status_t amdsmi_get_number_of_cpu_cores(uint32_t cpus); + +/** + * @brief Get number of sockets + * + * @param[in,out] sockets - Input buffer to fill number of sockets. + * + * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail + */ +amdsmi_status_t amdsmi_get_number_of_cpu_sockets(uint32_t sockets); + +/** + * @brief Get first online core on socket. + * + * @param[in] sock_ind - socket index. + * + * @param[in,out] sockets - Input buffer to fill first online core on socket data + * + * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail + */ +amdsmi_status_t amdsmi_first_online_core_on_cpu_socket(uint32_t sock_ind, uint32_t *pcore_ind); + +#endif +/** @} */ #ifdef __cplusplus } #endif // __cplusplus