From b58665e77b594cd05bebbabbcde34cabc7d4a838 Mon Sep 17 00:00:00 2001 From: Maisam Arif Date: Thu, 28 Sep 2023 21:56:09 -0500 Subject: [PATCH] Adjust static --board output to be inline with Host Change-Id: Ia6dcca5be077ef9e04533b632628a62633b63556 Signed-off-by: Maisam Arif --- amdsmi_cli/amdsmi_commands.py | 17 +++++++++-------- py-interface/amdsmi_interface.py | 10 +++++----- src/amd_smi/amd_smi.cc | 5 ++++- src/amd_smi/amd_smi_utils.cc | 2 +- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/amdsmi_cli/amdsmi_commands.py b/amdsmi_cli/amdsmi_commands.py index f9f74cbf5c..9d973c688b 100644 --- a/amdsmi_cli/amdsmi_commands.py +++ b/amdsmi_cli/amdsmi_commands.py @@ -269,18 +269,19 @@ class AMDSMICommands(): if self.helpers.is_linux() and self.helpers.is_baremetal(): if args.board: + static_dict['board'] = {"model_number": "N/A", + "product_serial": "N/A", + "fru_id": "N/A", + "manufacturer_name": "N/A", + "product_name": "N/A"} try: board_info = amdsmi_interface.amdsmi_get_gpu_board_info(args.gpu) - board_info['serial_number'] = hex(board_info['serial_number']) - board_info['model_number'] = board_info['model_number'].strip() - board_info['product_name'] = board_info['product_name'].strip() - board_info['manufacturer_name'] = board_info['manufacturer_name'].strip() - board_info.pop('product_serial') - board_info.pop('manufacturer_name') - + for key, value in board_info.items(): + if isinstance(value, str): + if value.strip() == '': + board_info[key] = "N/A" static_dict['board'] = board_info except amdsmi_exception.AmdSmiLibraryException as e: - static_dict['board'] = "N/A" logging.debug("Failed to get board info for gpu %s | %s", gpu_id, e.get_error_info()) if args.limit: # Power limits diff --git a/py-interface/amdsmi_interface.py b/py-interface/amdsmi_interface.py index 74a8e23aeb..41cd01af8e 100644 --- a/py-interface/amdsmi_interface.py +++ b/py-interface/amdsmi_interface.py @@ -823,11 +823,11 @@ def amdsmi_get_gpu_board_info( ) return { - "serial_number": board_info.serial_number, - "model_number": board_info.model_number.decode("utf-8"), - "product_serial": board_info.product_serial.decode("utf-8"), - "product_name": board_info.product_name.decode("utf-8"), - "manufacturer_name" : board_info.product_name.decode("utf-8") + "model_number": board_info.model_number.decode("utf-8").strip(), + "product_serial": board_info.serial_number, + "fru_id": board_info.fru_id.decode("utf-8").strip(), + "manufacturer_name" : board_info.manufacturer_name.decode("utf-8").strip(), + "product_name": board_info.product_name.decode("utf-8").strip() } diff --git a/src/amd_smi/amd_smi.cc b/src/amd_smi/amd_smi.cc index 66daf32be0..0a94835a09 100644 --- a/src/amd_smi/amd_smi.cc +++ b/src/amd_smi/amd_smi.cc @@ -457,7 +457,7 @@ amdsmi_status_t amdsmi_get_gpu_board_info(amdsmi_processor_handle processor_hand return r; if (gpu_device->check_if_drm_is_supported()) { - // Get from sys file + // Populate product_serial, product_name, & product_number from sysfs status = smi_amdgpu_get_board_info(gpu_device, board_info); } else { @@ -472,6 +472,9 @@ amdsmi_status_t amdsmi_get_gpu_board_info(amdsmi_processor_handle processor_hand } } + // Get FRU ID + // Get manufacturer name + return AMDSMI_STATUS_SUCCESS; } diff --git a/src/amd_smi/amd_smi_utils.cc b/src/amd_smi/amd_smi_utils.cc index fbf8d8efb6..8aef5c8dc1 100644 --- a/src/amd_smi/amd_smi_utils.cc +++ b/src/amd_smi/amd_smi_utils.cc @@ -138,7 +138,7 @@ amdsmi_status_t smi_amdgpu_get_board_info(amd::smi::AMDSmiGPUDevice* device, amd fp = fopen(serial_number_path.c_str(), "rb"); if (fp) { - fscanf(fp, "%lx", &info->serial_number); + fscanf(fp, "%lx", &info->product_serial); fclose(fp); }