[SWDEV-538483] Add NPM API's and CLI (#817)

* Added Python & C API's for new node devices. Currently these are functional for node 0 only.
 - amdsmi_get_node_handle
 - amdsmi_get_npm_info
* Added `amd-smi node` CLI for Node Power Management

---------

Signed-off-by: Bindhiya Kanangot Balakrishnan <Bindhiya.KanangotBalakrishnan@amd.com>
Signed-off-by: Maisam Arif <Maisam.Arif@amd.com>
Co-authored-by: Maisam Arif <Maisam.Arif@amd.com>

[ROCm/amdsmi commit: f8e4771363]
This commit is contained in:
Kanangot Balakrishnan, Bindhiya
2025-11-13 21:51:31 -06:00
committed by GitHub
parent e53645e871
commit 072daa28d5
13 changed files with 616 additions and 8 deletions
+70
View File
@@ -245,6 +245,13 @@ typedef enum {
typedef void *amdsmi_processor_handle;
typedef void *amdsmi_socket_handle;
/**
* @brief opaque handler point to underlying implementation
*
* @cond @tag{gpu_bm_linux} @tag{host} @endcond
*/
typedef void *amdsmi_node_handle;
#ifdef ENABLE_ESMI_LIB
/**
@@ -2141,6 +2148,27 @@ typedef enum {
AMDSMI_AFFINITY_SCOPE_SOCKET //!< socket affinity
} amdsmi_affinity_scope_t;
/**
* @brief NPM status
*
* @cond @tag{gpu_bm_linux} @tag{host} @endcond
*/
typedef enum {
AMDSMI_NPM_STATUS_DISABLED,
AMDSMI_NPM_STATUS_ENABLED
} amdsmi_npm_status_t;
/**
* @brief NPM info
*
* @cond @tag{gpu_bm_linux} @tag{host} @endcond
*/
typedef struct {
amdsmi_npm_status_t status; //!< NPM status (enabled/disabled).
uint64_t limit; //!< Node-level power limit in Watts.
uint64_t reserved[6];
} amdsmi_npm_info_t;
#ifdef ENABLE_ESMI_LIB
/**
@@ -2625,6 +2653,28 @@ amdsmi_status_t amdsmi_get_processor_handles(amdsmi_socket_handle socket_handle,
uint32_t *processor_count,
amdsmi_processor_handle* processor_handles);
/**
* @brief Get the node handle associated with processor handle.
*
* @ingroup tagProcDiscovery
*
* @platform{gpu_bm_linux} @platform{host}
*
* @details This function retrieves the node handle of a processor handler. The
* @p processor_handle must be provided for the processor.
* Currently, only AMD GPUs are supported.
*
* @param[in] processor_handle A pointer to a ::amdsmi_processor_handle, this
* is required to be OAM ID 0 otherwise the API will fail. OAM ID is sourced
* from amdsmi_get_gpu_asic_info API.
*
* @param[out] amdsmi_node_handle* A pointer to a block of memory where amdsmi_node_handle
* will be written.
*
* @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail
*/
amdsmi_status_t amdsmi_get_node_handle(amdsmi_processor_handle processor_handle, amdsmi_node_handle *node_handle);
#ifdef ENABLE_ESMI_LIB
/**
@@ -6220,6 +6270,25 @@ amdsmi_status_t amdsmi_get_pcie_info(amdsmi_processor_handle processor_handle, a
amdsmi_status_t amdsmi_get_gpu_xcd_counter(amdsmi_processor_handle processor_handle,
uint16_t *xcd_count);
/**
* @brief Retrieves node power management (NPM) status and power limit for the specified node.
*
* @ingroup tagNodeInfo
*
* @platform{gpu_bm_linux} @platform{host}
*
* @details This function queries the NPM controller for the given node and returns whether NPM is enabled,
* along with the current node-level power limit in Watts. The NPM status and limit are set out-of-band
* and reported via this API.
*
* @param[in] node_handle Handle to the Node to query.
* @param[out] info Pointer to amdsmi_npm_info_t structure to receive NPM status and limit.
* Must be allocated by the user.
*
* @return ::AMDSMI_STATUS_SUCCESS on success, non-zero on failure.
*/
amdsmi_status_t amdsmi_get_npm_info(amdsmi_node_handle node_handle, amdsmi_npm_info_t *info);
/** @} End tagAsicBoardInfo */
/*****************************************************************************/
@@ -6482,6 +6551,7 @@ amdsmi_get_gpu_process_list(amdsmi_processor_handle processor_handle, uint32_t *
/** @} End tagProcessInfo */
/*****************************************************************************/
/** @defgroup tagDriverControl Driver control mechanisms
* These functions provide control over the driver. Users should use with