SWDEV-410051 - Updates to board_info struct & CLI
Signed-off-by: Maisam Arif <maisarif@amd.com>
Change-Id: I8735d8965140ee5da0c35106b388af1dca87ec71
[ROCm/amdsmi commit: 2b4637ff9f]
这个提交包含在:
@@ -619,9 +619,11 @@ int main() {
|
|||||||
std::cout << "\tdevice [" << j
|
std::cout << "\tdevice [" << j
|
||||||
<< "]\n\t\tProduct name: " << board_info.product_name
|
<< "]\n\t\tProduct name: " << board_info.product_name
|
||||||
<< "\n"
|
<< "\n"
|
||||||
<< "\t\tProduct number: " << board_info.product_serial
|
<< "\t\tModel Number: " << board_info.model_number
|
||||||
<< "\n"
|
<< "\n"
|
||||||
<< "\t\tSerial number: " << board_info.serial_number
|
<< "\t\tBoard Serial: " << board_info.product_serial
|
||||||
|
<< "\n"
|
||||||
|
<< "\t\tManufacturer Name: " << board_info.manufacturer_name
|
||||||
<< "\n\n";
|
<< "\n\n";
|
||||||
|
|
||||||
// Get temperature
|
// Get temperature
|
||||||
|
|||||||
@@ -302,9 +302,11 @@ int main() {
|
|||||||
std::cout << "\tdevice [" << j
|
std::cout << "\tdevice [" << j
|
||||||
<< "]\n\t\tProduct name: " << board_info.product_name
|
<< "]\n\t\tProduct name: " << board_info.product_name
|
||||||
<< "\n"
|
<< "\n"
|
||||||
<< "\t\tProduct number: " << board_info.product_serial
|
<< "\t\tModel Number: " << board_info.model_number
|
||||||
<< "\n"
|
<< "\n"
|
||||||
<< "\t\tSerial number: " << board_info.serial_number
|
<< "\t\tBoard Serial: " << board_info.product_serial
|
||||||
|
<< "\n"
|
||||||
|
<< "\t\tManufacturer Name: " << board_info.manufacturer_name
|
||||||
<< "\n\n";
|
<< "\n\n";
|
||||||
|
|
||||||
// Get temperature
|
// Get temperature
|
||||||
|
|||||||
@@ -501,13 +501,12 @@ typedef struct {
|
|||||||
} amdsmi_driver_info_t;
|
} amdsmi_driver_info_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint64_t serial_number;
|
|
||||||
bool is_master;
|
bool is_master;
|
||||||
char model_number[AMDSMI_NORMAL_STRING_LENGTH];
|
char model_number[AMDSMI_NORMAL_STRING_LENGTH];
|
||||||
char product_serial[AMDSMI_NORMAL_STRING_LENGTH];
|
char product_serial[AMDSMI_NORMAL_STRING_LENGTH];
|
||||||
char fru_id[AMDSMI_NORMAL_STRING_LENGTH];
|
char fru_id[AMDSMI_NORMAL_STRING_LENGTH];
|
||||||
char product_name[AMDSMI_PRODUCT_NAME_LENGTH];
|
|
||||||
char manufacturer_name[AMDSMI_NORMAL_STRING_LENGTH];
|
char manufacturer_name[AMDSMI_NORMAL_STRING_LENGTH];
|
||||||
|
char product_name[AMDSMI_PRODUCT_NAME_LENGTH];
|
||||||
} amdsmi_board_info_t;
|
} amdsmi_board_info_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
* python 3.6 64-bit
|
* python 3.7+ 64-bit
|
||||||
* driver must be loaded for amdsmi_init() to pass
|
* driver must be loaded for amdsmi_init() to pass
|
||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
@@ -998,8 +998,10 @@ Output: Dictionary with fields correctable and uncorrectable
|
|||||||
|
|
||||||
Field | Description
|
Field | Description
|
||||||
---|---
|
---|---
|
||||||
`serial_number` | Board serial number
|
`model_number` | Board serial number
|
||||||
`product_serial` | Product serial
|
`product_serial` | Product serial
|
||||||
|
`fru_id` | FRU ID
|
||||||
|
`manufacturer_name` | Manufacturer name
|
||||||
`product_name` | Product name
|
`product_name` | Product name
|
||||||
|
|
||||||
Exceptions that can be thrown by `amdsmi_get_gpu_board_info` function:
|
Exceptions that can be thrown by `amdsmi_get_gpu_board_info` function:
|
||||||
@@ -1014,8 +1016,10 @@ Example:
|
|||||||
try:
|
try:
|
||||||
device = amdsmi_get_processor_handle_from_bdf("0000:23.00.0")
|
device = amdsmi_get_processor_handle_from_bdf("0000:23.00.0")
|
||||||
board_info = amdsmi_get_gpu_board_info(device)
|
board_info = amdsmi_get_gpu_board_info(device)
|
||||||
print(board_info["serial_number"])
|
print(board_info["model_number"])
|
||||||
print(board_info["product_serial"])
|
print(board_info["product_serial"])
|
||||||
|
print(board_info["fru_id"])
|
||||||
|
print(board_info["manufacturer_name"])
|
||||||
print(board_info["product_name"])
|
print(board_info["product_name"])
|
||||||
except AmdSmiException as e:
|
except AmdSmiException as e:
|
||||||
print(e)
|
print(e)
|
||||||
|
|||||||
@@ -1147,7 +1147,7 @@ def amdsmi_get_gpu_board_info(
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
"model_number": board_info.model_number.decode("utf-8").strip(),
|
"model_number": board_info.model_number.decode("utf-8").strip(),
|
||||||
"product_serial": board_info.serial_number,
|
"product_serial": board_info.product_serial.decode("utf-8").strip(),
|
||||||
"fru_id": board_info.fru_id.decode("utf-8").strip(),
|
"fru_id": board_info.fru_id.decode("utf-8").strip(),
|
||||||
"manufacturer_name" : board_info.manufacturer_name.decode("utf-8").strip(),
|
"manufacturer_name" : board_info.manufacturer_name.decode("utf-8").strip(),
|
||||||
"product_name": board_info.product_name.decode("utf-8").strip()
|
"product_name": board_info.product_name.decode("utf-8").strip()
|
||||||
|
|||||||
@@ -840,14 +840,12 @@ class struct_amdsmi_board_info_t(Structure):
|
|||||||
|
|
||||||
struct_amdsmi_board_info_t._pack_ = 1 # source:False
|
struct_amdsmi_board_info_t._pack_ = 1 # source:False
|
||||||
struct_amdsmi_board_info_t._fields_ = [
|
struct_amdsmi_board_info_t._fields_ = [
|
||||||
('serial_number', ctypes.c_uint64),
|
|
||||||
('is_master', ctypes.c_bool),
|
('is_master', ctypes.c_bool),
|
||||||
('model_number', ctypes.c_char * 32),
|
('model_number', ctypes.c_char * 32),
|
||||||
('product_serial', ctypes.c_char * 32),
|
('product_serial', ctypes.c_char * 32),
|
||||||
('fru_id', ctypes.c_char * 32),
|
('fru_id', ctypes.c_char * 32),
|
||||||
('product_name', ctypes.c_char * 128),
|
|
||||||
('manufacturer_name', ctypes.c_char * 32),
|
('manufacturer_name', ctypes.c_char * 32),
|
||||||
('PADDING_0', ctypes.c_ubyte * 7),
|
('product_name', ctypes.c_char * 128),
|
||||||
]
|
]
|
||||||
|
|
||||||
amdsmi_board_info_t = struct_amdsmi_board_info_t
|
amdsmi_board_info_t = struct_amdsmi_board_info_t
|
||||||
@@ -894,6 +892,16 @@ amdsmi_process_handle_t = ctypes.c_uint32
|
|||||||
class struct_amdsmi_proc_info_t(Structure):
|
class struct_amdsmi_proc_info_t(Structure):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
class struct_engine_usage_(Structure):
|
||||||
|
pass
|
||||||
|
|
||||||
|
struct_engine_usage_._pack_ = 1 # source:False
|
||||||
|
struct_engine_usage_._fields_ = [
|
||||||
|
('gfx', ctypes.c_uint64),
|
||||||
|
('enc', ctypes.c_uint64),
|
||||||
|
('reserved', ctypes.c_uint32 * 12),
|
||||||
|
]
|
||||||
|
|
||||||
class struct_memory_usage_(Structure):
|
class struct_memory_usage_(Structure):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@@ -905,16 +913,6 @@ struct_memory_usage_._fields_ = [
|
|||||||
('reserved', ctypes.c_uint32 * 10),
|
('reserved', ctypes.c_uint32 * 10),
|
||||||
]
|
]
|
||||||
|
|
||||||
class struct_engine_usage_(Structure):
|
|
||||||
pass
|
|
||||||
|
|
||||||
struct_engine_usage_._pack_ = 1 # source:False
|
|
||||||
struct_engine_usage_._fields_ = [
|
|
||||||
('gfx', ctypes.c_uint64),
|
|
||||||
('enc', ctypes.c_uint64),
|
|
||||||
('reserved', ctypes.c_uint32 * 12),
|
|
||||||
]
|
|
||||||
|
|
||||||
struct_amdsmi_proc_info_t._pack_ = 1 # source:False
|
struct_amdsmi_proc_info_t._pack_ = 1 # source:False
|
||||||
struct_amdsmi_proc_info_t._fields_ = [
|
struct_amdsmi_proc_info_t._fields_ = [
|
||||||
('name', ctypes.c_char * 32),
|
('name', ctypes.c_char * 32),
|
||||||
|
|||||||
@@ -3969,7 +3969,6 @@ rsmi_status_t rsmi_dev_serial_number_get(uint32_t dv_ind,
|
|||||||
if (ret != RSMI_STATUS_SUCCESS) {
|
if (ret != RSMI_STATUS_SUCCESS) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t ln = static_cast<uint32_t>(val_str.copy(serial_num, len));
|
uint32_t ln = static_cast<uint32_t>(val_str.copy(serial_num, len));
|
||||||
|
|
||||||
serial_num[std::min(len - 1, ln)] = '\0';
|
serial_num[std::min(len - 1, ln)] = '\0';
|
||||||
|
|||||||
@@ -466,15 +466,10 @@ amdsmi_status_t amdsmi_get_gpu_board_info(amdsmi_processor_handle processor_hand
|
|||||||
status = rsmi_wrapper(rsmi_dev_name_get, processor_handle,
|
status = rsmi_wrapper(rsmi_dev_name_get, processor_handle,
|
||||||
board_info->product_name, AMDSMI_PRODUCT_NAME_LENGTH);
|
board_info->product_name, AMDSMI_PRODUCT_NAME_LENGTH);
|
||||||
|
|
||||||
if (board_info->product_serial[0] == '\0') {
|
status = rsmi_wrapper(rsmi_dev_serial_number_get, processor_handle,
|
||||||
status = rsmi_wrapper(rsmi_dev_serial_number_get, processor_handle,
|
|
||||||
board_info->product_serial, AMDSMI_NORMAL_STRING_LENGTH);
|
board_info->product_serial, AMDSMI_NORMAL_STRING_LENGTH);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get FRU ID
|
|
||||||
// Get manufacturer name
|
|
||||||
|
|
||||||
return AMDSMI_STATUS_SUCCESS;
|
return AMDSMI_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -116,29 +116,41 @@ amdsmi_status_t smi_amdgpu_get_board_info(amd::smi::AMDSmiGPUDevice* device, amd
|
|||||||
return AMDSMI_STATUS_NOT_SUPPORTED;
|
return AMDSMI_STATUS_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
SMIGPUDEVICE_MUTEX(device->get_mutex())
|
SMIGPUDEVICE_MUTEX(device->get_mutex())
|
||||||
std::string product_name_path = "/sys/class/drm/" + device->get_gpu_path() + std::string("/device/product_name");
|
std::string model_number_path = "/sys/class/drm/" + device->get_gpu_path() + std::string("/device/product_number");
|
||||||
std::string product_number_path = "/sys/class/drm/" + device->get_gpu_path() + std::string("/device/product_number");
|
std::string product_serial_path = "/sys/class/drm/" + device->get_gpu_path() + std::string("/device/serial_number");
|
||||||
std::string serial_number_path = "/sys/class/drm/" + device->get_gpu_path() + std::string("/device/serial_number");
|
std::string fru_id_path = "/sys/class/drm/" + device->get_gpu_path() + std::string("/device/fru_id");
|
||||||
|
std::string manufacturer_name_path = "/sys/class/drm/" + device->get_gpu_path() + std::string("/device/manufacturer");
|
||||||
|
std::string product_name_path = "/sys/class/drm/" + device->get_gpu_path() + std::string("/device/product_name");
|
||||||
|
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
|
||||||
fp = fopen(product_name_path.c_str(), "rb");
|
fp = fopen(model_number_path.c_str(), "rb");
|
||||||
if (fp) {
|
|
||||||
fgets(info->product_name, sizeof(info->product_name), fp);
|
|
||||||
fclose(fp);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
fp = fopen(product_number_path.c_str(), "rb");
|
|
||||||
if (fp) {
|
if (fp) {
|
||||||
fgets(info->model_number, sizeof(info->model_number), fp);
|
fgets(info->model_number, sizeof(info->model_number), fp);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fp = fopen(product_serial_path.c_str(), "rb");
|
||||||
fp = fopen(serial_number_path.c_str(), "rb");
|
|
||||||
if (fp) {
|
if (fp) {
|
||||||
fscanf(fp, "%lx", &info->product_serial);
|
fgets(info->product_serial, sizeof(info->product_serial), fp);
|
||||||
|
fclose(fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
fp = fopen(fru_id_path.c_str(), "rb");
|
||||||
|
if (fp) {
|
||||||
|
fgets(info->fru_id, sizeof(info->fru_id), fp);
|
||||||
|
fclose(fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
fp = fopen(manufacturer_name_path.c_str(), "rb");
|
||||||
|
if (fp) {
|
||||||
|
fgets(info->manufacturer_name, sizeof(info->manufacturer_name), fp);
|
||||||
|
fclose(fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
fp = fopen(product_name_path.c_str(), "rb");
|
||||||
|
if (fp) {
|
||||||
|
fgets(info->product_name, sizeof(info->product_name), fp);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
在新工单中引用
屏蔽一个用户