[SWDEV-451104] Update static --board + amdsmi_get_gpu_board_info()

Updates:
    * Expanded `amdsmi_get_gpu_board_info()` amdsmi_board_info_t structure size
      Updated sizes that work for retrieving relevant board
      information across AMD's ASIC products.
    * Fixed `amdsmi_get_gpu_board_info()` to no longer return junk char strings

Change-Id: Ie1553c6109d678d283d82c24e9284f8e19cd6ccc
Signed-off-by: Charis Poag <Charis.Poag@amd.com>
이 커밋은 다음에 포함됨:
Charis Poag가 2024-05-13 23:05:32 -05:00를 커밋했습니다
1 부모 437cb07db6
커밋 4295bba37f
6 파일이 변경됨
+195 -62

검색과 일치하는 파일 없음

+19 -5
파일 보기
@@ -539,6 +539,21 @@ def _make_amdsmi_bdf_from_list(bdf):
amdsmi_bdf.fields.domain_number = bdf[0]
return amdsmi_bdf
def _padHexValue(value, length):
""" Pad a hexadecimal value with a given length of zeros
:param value: A hexadecimal value to be padded with zeros
:param length: Number of zeros to pad the hexadecimal value
:param return original string string or
padded hex of confirmed hex output (using length provided)
"""
# Ensure value entered meets the minimum length and is hexadecimal
if len(value) > 2 and length > 1 and value[:2].lower() == '0x' \
and all(c in '0123456789abcdefABCDEF' for c in value[2:]):
# Pad with zeros after '0x' prefix
return '0x' + value[2:].zfill(length)
return value
def amdsmi_get_socket_handles() -> List[amdsmi_wrapper.amdsmi_socket_handle]:
"""
@@ -1585,12 +1600,12 @@ def amdsmi_get_gpu_asic_info(
)
asic_info = {
"market_name": asic_info_struct.market_name.decode("utf-8"),
"market_name": _padHexValue(asic_info_struct.market_name.decode("utf-8"), 4),
"vendor_id": asic_info_struct.vendor_id,
"vendor_name": asic_info_struct.vendor_name.decode("utf-8"),
"subvendor_id": asic_info_struct.subvendor_id,
"device_id": asic_info_struct.device_id,
"rev_id": hex(asic_info_struct.rev_id),
"rev_id": _padHexValue(hex(asic_info_struct.rev_id), 2),
"asic_serial": asic_info_struct.asic_serial.decode("utf-8"),
"oam_id": asic_info_struct.oam_id
}
@@ -1863,17 +1878,16 @@ def amdsmi_get_gpu_board_info(
)
board_info_dict = {
"model_number": board_info.model_number.decode("utf-8").strip(),
"model_number": _padHexValue(board_info.model_number.decode("utf-8").strip(), 4),
"product_serial": board_info.product_serial.decode("utf-8").strip(),
"fru_id": board_info.fru_id.decode("utf-8").strip(),
"product_name": board_info.product_name.decode("utf-8").strip(),
"product_name": _padHexValue(board_info.product_name.decode("utf-8").strip(), 4),
"manufacturer_name": board_info.manufacturer_name.decode("utf-8").strip()
}
for key, value in board_info_dict.items():
if value == "":
board_info_dict[key] = "N/A"
return board_info_dict
+4 -4
파일 보기
@@ -882,7 +882,7 @@ class struct_amdsmi_asic_info_t(Structure):
struct_amdsmi_asic_info_t._pack_ = 1 # source:False
struct_amdsmi_asic_info_t._fields_ = [
('market_name', ctypes.c_char * 64),
('market_name', ctypes.c_char * 256),
('vendor_id', ctypes.c_uint32),
('vendor_name', ctypes.c_char * 64),
('subvendor_id', ctypes.c_uint32),
@@ -961,11 +961,11 @@ class struct_amdsmi_board_info_t(Structure):
struct_amdsmi_board_info_t._pack_ = 1 # source:False
struct_amdsmi_board_info_t._fields_ = [
('model_number', ctypes.c_char * 32),
('model_number', ctypes.c_char * 256),
('product_serial', ctypes.c_char * 32),
('fru_id', ctypes.c_char * 32),
('product_name', ctypes.c_char * 128),
('manufacturer_name', ctypes.c_char * 32),
('product_name', ctypes.c_char * 256),
('manufacturer_name', ctypes.c_char * 64),
('reserved', ctypes.c_uint32 * 32),
]