SWDEV-361376 - Add python wrapper
- Add generator for python wrapper
- Add interface, exception and init files
- Add CMake custom targets
Change-Id: I63c1d94fbb587387c22f559a3db79987eb214a2e
Signed-off-by: Dejan Andjelkovic <Dejan.Andjelkovic@amd.com>
[ROCm/amdsmi commit: 6064f160a3]
This commit is contained in:
committed by
Bill(Shuzhou) Liu
parent
c68caedcbd
commit
14d9160565
@@ -45,13 +45,14 @@
|
||||
#define INCLUDE_AMD_SMI_H_
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#include <cstdint>
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#endif // __cplusplus
|
||||
|
||||
|
||||
/**
|
||||
* @brief Initialization flags
|
||||
*
|
||||
@@ -141,20 +142,20 @@ typedef enum amdsmi_status_t {
|
||||
* Clock types
|
||||
*/
|
||||
typedef enum amdsmi_clk_type {
|
||||
CLOCK_TYPE_SYS = 0x0, //!< System clock
|
||||
CLOCK_TYPE_FIRST = CLOCK_TYPE_SYS,
|
||||
CLOCK_TYPE_GFX = CLOCK_TYPE_SYS,
|
||||
CLOCK_TYPE_DF, //!< Data Fabric clock (for ASICs
|
||||
CLK_TYPE_SYS = 0x0, //!< System clock
|
||||
CLK_TYPE_FIRST = CLK_TYPE_SYS,
|
||||
CLK_TYPE_GFX = CLK_TYPE_SYS,
|
||||
CLK_TYPE_DF, //!< Data Fabric clock (for ASICs
|
||||
//!< running on a separate clock)
|
||||
CLOCK_TYPE_DCEF, //!< Display Controller Engine clock
|
||||
CLOCK_TYPE_SOC,
|
||||
CLOCK_TYPE_MEM,
|
||||
CLOCK_TYPE_PCIE,
|
||||
CLOCK_TYPE_VCLK0,
|
||||
CLOCK_TYPE_VCLK1,
|
||||
CLOCK_TYPE_DCLK0,
|
||||
CLOCK_TYPE_DCLK1,
|
||||
CLOCK_TYPE__MAX = CLOCK_TYPE_DCLK1
|
||||
CLK_TYPE_DCEF, //!< Display Controller Engine clock
|
||||
CLK_TYPE_SOC,
|
||||
CLK_TYPE_MEM,
|
||||
CLK_TYPE_PCIE,
|
||||
CLK_TYPE_VCLK0,
|
||||
CLK_TYPE_VCLK1,
|
||||
CLK_TYPE_DCLK0,
|
||||
CLK_TYPE_DCLK1,
|
||||
CLK_TYPE__MAX = CLK_TYPE_DCLK1
|
||||
} amdsmi_clk_type_t;
|
||||
/// \cond Ignore in docs.
|
||||
typedef amdsmi_clk_type_t amdsmi_clk_type;
|
||||
@@ -346,19 +347,19 @@ typedef struct amdsmi_power_limit {
|
||||
} amdsmi_power_limit_t;
|
||||
|
||||
typedef struct amdsmi_power_measure {
|
||||
uint16_t average_socket_power;
|
||||
uint32_t average_socket_power;
|
||||
uint64_t energy_accumulator; // v1 mod. (32->64)
|
||||
uint32_t voltage_gfx; // GFX voltage measurement in mV
|
||||
uint32_t voltage_soc; // SOC voltage measurement in mV
|
||||
uint32_t voltage_mem; // MEM voltage measurement in mV
|
||||
} amdsmi_power_measure_t;
|
||||
|
||||
typedef struct amdsmi_clock_measure {
|
||||
typedef struct amdsmi_clk_measure {
|
||||
uint32_t cur_clk;
|
||||
uint32_t avg_clk;
|
||||
uint32_t min_clk;
|
||||
uint32_t max_clk;
|
||||
} amdsmi_clock_measure_t;
|
||||
} amdsmi_clk_measure_t;
|
||||
|
||||
typedef struct amdsmi_engine_usage {
|
||||
uint32_t average_gfx_activity;
|
||||
@@ -1080,6 +1081,13 @@ typedef struct {
|
||||
uint64_t uncorrectable_count; //!< Accumulated uncorrectable errors
|
||||
} amdsmi_error_count_t;
|
||||
|
||||
/**
|
||||
* @brief This structure holds pcie info.
|
||||
*/
|
||||
typedef struct amdsmi_pcie_info {
|
||||
uint16_t pcie_lanes;
|
||||
uint16_t pcie_speed;
|
||||
} amdsmi_pcie_info_t;
|
||||
/**
|
||||
* @brief This structure contains information specific to a process.
|
||||
*/
|
||||
@@ -1134,8 +1142,8 @@ typedef union amd_id {
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @brief Initialize AMD SMI.
|
||||
*
|
||||
* @brief Initialize AMD SMI.
|
||||
*
|
||||
* @details When called, this initializes internal data structures,
|
||||
* including those corresponding to sources of information that SMI provides.
|
||||
*
|
||||
@@ -1164,7 +1172,7 @@ amdsmi_status_t amdsmi_shut_down(void);
|
||||
|
||||
/*****************************************************************************/
|
||||
/** @defgroup Discovery Queries
|
||||
* These functions provide discovery of the sockets.
|
||||
* These functions provide discovery of the sockets.
|
||||
* @{
|
||||
*/
|
||||
|
||||
@@ -1208,7 +1216,7 @@ amdsmi_status_t amdsmi_get_socket_handles(uint32_t *socket_count,
|
||||
* @param[in] socket_handle a socket handle
|
||||
*
|
||||
* @param[out] name The id of the socket.
|
||||
*
|
||||
*
|
||||
* @param[in] len the length of the caller provided buffer @p name.
|
||||
*
|
||||
* @retval ::AMDSMI_STATUS_SUCCESS call was successful
|
||||
@@ -1275,6 +1283,28 @@ amdsmi_status_t amdsmi_get_device_handles(amdsmi_socket_handle socket_handle,
|
||||
amdsmi_status_t amdsmi_get_device_type(amdsmi_device_handle device_handle,
|
||||
device_type_t* device_type);
|
||||
|
||||
/**
|
||||
* @brief Get device handle with the matching bdf.
|
||||
*
|
||||
* @details Given bdf info @p bdf, this function will get
|
||||
* the device handle with the matching bdf.
|
||||
*
|
||||
* @param[in] bdf The bdf to match with corresponding device handle.
|
||||
*
|
||||
* @param[in] device_handles a list of devices handles on the socket.
|
||||
*
|
||||
* @param[in] device_count a count of handles in device_handles.
|
||||
*
|
||||
* @param[out] device_handle device handle with the matching bdf.
|
||||
*
|
||||
* @retval ::AMDSMI_STATUS_SUCCESS call was successful
|
||||
* @retval ::AMDSMI_STATUS_INVAL the provided arguments are not valid
|
||||
*/
|
||||
amdsmi_status_t amdsmi_get_device_handle_from_bdf(amdsmi_bdf_t bdf,
|
||||
amdsmi_device_handle* device_handles,
|
||||
uint32_t device_count,
|
||||
amdsmi_device_handle* device_handle);
|
||||
|
||||
/** @} */ // end of Discovery
|
||||
|
||||
|
||||
@@ -1868,7 +1898,7 @@ amdsmi_get_bad_page_info(amdsmi_device_handle device_handle, uint32_t *num_pages
|
||||
*
|
||||
*/
|
||||
amdsmi_status_t
|
||||
amdsmi_get_ras_features_enabled(amdsmi_device_handle device_handle, amdsmi_gpu_block block,
|
||||
amdsmi_get_ras_block_features_enabled(amdsmi_device_handle device_handle, amdsmi_gpu_block block,
|
||||
amdsmi_ras_err_state_t *state);
|
||||
/**
|
||||
* @brief Get percentage of time any device memory is being used
|
||||
@@ -2211,6 +2241,42 @@ amdsmi_utilization_count_get(amdsmi_device_handle device_handle,
|
||||
uint32_t count,
|
||||
uint64_t *timestamp);
|
||||
|
||||
/**
|
||||
* @brief Get current PCIE info of the device with provided device handle.
|
||||
*
|
||||
* @details Given a device handle @p dev, this function returns PCIE info of the
|
||||
* given device.
|
||||
*
|
||||
* @param[in] dev a device handle
|
||||
*
|
||||
* @param[out] info amdsmi_pcie_info_t struct which will hold all the extracted PCIE info data.
|
||||
*
|
||||
* @retval ::AMDSMI_STATUS_SUCCESS call was successful
|
||||
* @retval ::AMDSMI_STATUS_NOT_SUPPORTED installed software or hardware does not
|
||||
* support this function with the given arguments
|
||||
* @retval ::AMDSMI_STATUS_INVAL the provided arguments are not valid
|
||||
*
|
||||
*/
|
||||
amdsmi_status_t amdsmi_get_pcie_link_status(amdsmi_device_handle dev, amdsmi_pcie_info_t *info);
|
||||
|
||||
/**
|
||||
* @brief Get max PCIe capabilities of the device with provided device handle.
|
||||
*
|
||||
* @details Given a device handle @p dev, this function returns PCIe caps info of the
|
||||
* given device.
|
||||
*
|
||||
* @param[in] dev a device handle
|
||||
*
|
||||
* @param[out] info amdsmi_pcie_info_t struct which will hold all the extracted PCIe caps data.
|
||||
*
|
||||
* @retval ::AMDSMI_STATUS_SUCCESS call was successful
|
||||
* @retval ::AMDSMI_STATUS_NOT_SUPPORTED installed software or hardware does not
|
||||
* support this function with the given arguments
|
||||
* @retval ::AMDSMI_STATUS_INVAL the provided arguments are not valid
|
||||
*
|
||||
*/
|
||||
amdsmi_status_t amdsmi_get_pcie_link_caps(amdsmi_device_handle dev, amdsmi_pcie_info_t *info);
|
||||
|
||||
/**
|
||||
* @brief Get the performance level of the device with provided
|
||||
* device handle.
|
||||
@@ -3447,7 +3513,7 @@ amdsmi_is_P2P_accessible(amdsmi_device_handle device_handle_src, amdsmi_device_h
|
||||
*
|
||||
* // Get the device handle via amdsmi_get_device_handles()
|
||||
* // ... ...
|
||||
*
|
||||
*
|
||||
* std::cout << "Supported AMDSMI Functions:" << std::endl; *
|
||||
* err = amdsmi_dev_supported_func_iterator_open(device, &iter_handle);
|
||||
*
|
||||
@@ -4033,7 +4099,7 @@ amdsmi_get_power_measure(amdsmi_device_handle dev, amdsmi_power_measure_t *info)
|
||||
* * -::AMDSMI_STATUS_API_FAILED - Other errors
|
||||
*/
|
||||
amdsmi_status_t
|
||||
amdsmi_get_clock_measure(amdsmi_device_handle dev, amdsmi_clk_type_t clk_type, amdsmi_clock_measure_t *info);
|
||||
amdsmi_get_clock_measure(amdsmi_device_handle dev, amdsmi_clk_type_t clk_type, amdsmi_clk_measure_t *info);
|
||||
|
||||
/**
|
||||
* \brief Returns temperature measurements of the GPU.
|
||||
|
||||
@@ -40,5 +40,6 @@ amdsmi_status_t smi_amdgpu_get_ranges(amd::smi::AMDSmiGPUDevice* device, amdsmi_
|
||||
amdsmi_status_t smi_amdgpu_get_enabled_blocks(amd::smi::AMDSmiGPUDevice* device, uint64_t *enabled_blocks);
|
||||
amdsmi_status_t smi_amdgpu_get_bad_page_info(amd::smi::AMDSmiGPUDevice* device, uint32_t *num_pages, amdsmi_retired_page_record_t *info);
|
||||
amdsmi_status_t smi_amdgpu_get_ecc_error_count(amd::smi::AMDSmiGPUDevice* device, amdsmi_error_count_t *err_cnt);
|
||||
amdsmi_status_t smi_amdgpu_get_driver_version(amd::smi::AMDSmiGPUDevice* device, int *length, char *version);
|
||||
|
||||
#endif //
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef GPUVSMI_UUID_H_
|
||||
#define GPUVSMI_UUID_H_
|
||||
|
||||
/**
|
||||
* \brief Generates uuid for device with specified parameters
|
||||
*
|
||||
* \param [out] str String buffer where to output generated uuid
|
||||
*
|
||||
* \param [in] serial Asic serial
|
||||
*
|
||||
* \param [in] did Device ID
|
||||
*
|
||||
* \param [in] idx PF/VF index
|
||||
*
|
||||
* \return SMI_RET_CODE indicating result.
|
||||
*/
|
||||
amdsmi_status_t amdsmi_uuid_gen(char *str, uint64_t serial, uint16_t did, uint8_t idx);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user