SWDEV-410230 - Added slot_type to amd-smi static --bus
Signed-off-by: Maisam Arif <maisarif@amd.com>
Change-Id: I2006a3525a8aa9091bf54501461d364f7237f00f
[ROCm/amdsmi commit: fadf1b6cc9]
Этот коммит содержится в:
коммит произвёл
Maisam Arif
родитель
a489c16044
Коммит
76d025cff0
@@ -226,27 +226,21 @@ class AMDSMICommands():
|
||||
|
||||
bus_info['max_pcie_speed'] = pcie_speed_GTs_value
|
||||
|
||||
try:
|
||||
slot_type = amdsmi_interface.amdsmi_topo_get_link_type(args.gpu, args.gpu)['type']
|
||||
except amdsmi_exception.AmdSmiLibraryException as e:
|
||||
slot_type = e.get_error_info()
|
||||
slot_type = bus_info.pop('pcie_slot_type')
|
||||
if isinstance(slot_type, int):
|
||||
slot_types = amdsmi_interface.amdsmi_wrapper.amdsmi_pcie_slot_type_t__enumvalues
|
||||
if slot_type in slot_types:
|
||||
bus_info['slot_type'] = slot_types[slot_type].replace("AMDSMI_SLOT_TYPE__", "")
|
||||
else:
|
||||
bus_info['slot_type'] = "Unknown"
|
||||
else:
|
||||
bus_info['slot_type'] = "N/A"
|
||||
|
||||
if self.logger.is_human_readable_format():
|
||||
unit ='GT/s'
|
||||
bus_info['max_pcie_speed'] = f"{bus_info['max_pcie_speed']} {unit}"
|
||||
|
||||
if bus_info['pcie_interface_version'] > 0:
|
||||
bus_info['pcie_interface_version'] = f"Gen {bus_info['pcie_interface_version']}"
|
||||
|
||||
bus_info['slot_type'] = 'XXXX'
|
||||
if isinstance(slot_type, int):
|
||||
if slot_type == amdsmi_interface.amdsmi_wrapper.AMDSMI_IOLINK_TYPE_UNDEFINED:
|
||||
bus_info['slot_type'] = "UNKNOWN"
|
||||
elif slot_type == amdsmi_interface.amdsmi_wrapper.AMDSMI_IOLINK_TYPE_PCIEXPRESS:
|
||||
bus_info['slot_type'] = "PCIE"
|
||||
elif slot_type == amdsmi_interface.amdsmi_wrapper.AMDSMI_IOLINK_TYPE_XGMI:
|
||||
bus_info['slot_type'] = "XGMI"
|
||||
|
||||
except amdsmi_exception.AmdSmiLibraryException as e:
|
||||
bus_info = "N/A"
|
||||
logging.debug("Failed to get bus info for gpu %s | %s", gpu_id, e.get_error_info())
|
||||
|
||||
@@ -379,9 +379,9 @@ int main() {
|
||||
ret = amdsmi_get_pcie_link_status(processor_handles[j], &pcie_info);
|
||||
CHK_AMDSMI_RET(ret)
|
||||
printf(" Output of amdsmi_get_pcie_link_status:\n");
|
||||
printf("\tPCIe lanes: %d\n", pcie_info.pcie_lanes);
|
||||
printf("\tPCIe speed: %d\n", pcie_info.pcie_speed);
|
||||
printf("\tPCIe Interface Version: %d\n", pcie_info.pcie_interface_version);
|
||||
printf("\tCurrent PCIe lanes: %d\n", pcie_info.pcie_lanes);
|
||||
printf("\tCurrent PCIe speed: %d\n", pcie_info.pcie_speed);
|
||||
printf("\tCurrent PCIe Interface Version: %d\n", pcie_info.pcie_interface_version);
|
||||
printf("\tPCIe slot type: %d\n\n", pcie_info.pcie_slot_type);
|
||||
|
||||
// Get PCIe caps
|
||||
|
||||
@@ -1150,6 +1150,16 @@ typedef struct {
|
||||
uint64_t reserved[2];
|
||||
} amdsmi_error_count_t;
|
||||
|
||||
/**
|
||||
* @brief This is a enum translation for pcie_slot_type
|
||||
*/
|
||||
typedef enum {
|
||||
AMDSMI_SLOT_TYPE__PCIE = 0,
|
||||
AMDSMI_SLOT_TYPE__CEM = 1,
|
||||
AMDSMI_SLOT_TYPE__OAM = 2,
|
||||
AMDSMI_SLOT_TYPE__RESERVED = 3,
|
||||
} amdsmi_pcie_slot_type_t;
|
||||
|
||||
/**
|
||||
* @brief This structure holds pcie info.
|
||||
*/
|
||||
@@ -1157,9 +1167,10 @@ typedef struct {
|
||||
uint16_t pcie_lanes;
|
||||
uint32_t pcie_speed;
|
||||
uint32_t pcie_interface_version;
|
||||
uint32_t pcie_slot_type; // 0: PCIE, 1: CEM, 2: OAM, 3: Reserved
|
||||
uint32_t reserved[5];
|
||||
amdsmi_pcie_slot_type_t pcie_slot_type; // 0: PCIE, 1: CEM, 2: OAM, 3: Reserved
|
||||
uint32_t reserved[4];
|
||||
} amdsmi_pcie_info_t;
|
||||
|
||||
/**
|
||||
* @brief This structure contains information specific to a process.
|
||||
*/
|
||||
|
||||
@@ -1424,6 +1424,19 @@ struct_amdsmi_error_count_t._fields_ = [
|
||||
]
|
||||
|
||||
amdsmi_error_count_t = struct_amdsmi_error_count_t
|
||||
|
||||
# values for enumeration 'amdsmi_pcie_slot_type_t'
|
||||
amdsmi_pcie_slot_type_t__enumvalues = {
|
||||
0: 'AMDSMI_SLOT_TYPE__PCIE',
|
||||
1: 'AMDSMI_SLOT_TYPE__CEM',
|
||||
2: 'AMDSMI_SLOT_TYPE__OAM',
|
||||
3: 'AMDSMI_SLOT_TYPE__RESERVED',
|
||||
}
|
||||
AMDSMI_SLOT_TYPE__PCIE = 0
|
||||
AMDSMI_SLOT_TYPE__CEM = 1
|
||||
AMDSMI_SLOT_TYPE__OAM = 2
|
||||
AMDSMI_SLOT_TYPE__RESERVED = 3
|
||||
amdsmi_pcie_slot_type_t = ctypes.c_uint32 # enum
|
||||
class struct_amdsmi_pcie_info_t(Structure):
|
||||
pass
|
||||
|
||||
@@ -1433,8 +1446,8 @@ struct_amdsmi_pcie_info_t._fields_ = [
|
||||
('PADDING_0', ctypes.c_ubyte * 2),
|
||||
('pcie_speed', ctypes.c_uint32),
|
||||
('pcie_interface_version', ctypes.c_uint32),
|
||||
('pcie_slot_type', ctypes.c_uint32),
|
||||
('reserved', ctypes.c_uint32 * 5),
|
||||
('pcie_slot_type', amdsmi_pcie_slot_type_t),
|
||||
('reserved', ctypes.c_uint32 * 4),
|
||||
]
|
||||
|
||||
amdsmi_pcie_info_t = struct_amdsmi_pcie_info_t
|
||||
@@ -1805,7 +1818,9 @@ __all__ = \
|
||||
'AMDSMI_RAS_ERR_STATE_INVALID', 'AMDSMI_RAS_ERR_STATE_LAST',
|
||||
'AMDSMI_RAS_ERR_STATE_MULT_UC', 'AMDSMI_RAS_ERR_STATE_NONE',
|
||||
'AMDSMI_RAS_ERR_STATE_PARITY', 'AMDSMI_RAS_ERR_STATE_POISON',
|
||||
'AMDSMI_RAS_ERR_STATE_SING_C', 'AMDSMI_STATUS_ADDRESS_FAULT',
|
||||
'AMDSMI_RAS_ERR_STATE_SING_C', 'AMDSMI_SLOT_TYPE__CEM',
|
||||
'AMDSMI_SLOT_TYPE__OAM', 'AMDSMI_SLOT_TYPE__PCIE',
|
||||
'AMDSMI_SLOT_TYPE__RESERVED', 'AMDSMI_STATUS_ADDRESS_FAULT',
|
||||
'AMDSMI_STATUS_API_FAILED', 'AMDSMI_STATUS_BUSY',
|
||||
'AMDSMI_STATUS_DRIVER_NOT_LOADED', 'AMDSMI_STATUS_DRM_ERROR',
|
||||
'AMDSMI_STATUS_FAIL_LOAD_MODULE',
|
||||
@@ -1955,8 +1970,8 @@ __all__ = \
|
||||
'amdsmi_mm_ip_t', 'amdsmi_od_vddc_point_t',
|
||||
'amdsmi_od_volt_curve_t', 'amdsmi_od_volt_freq_data_t',
|
||||
'amdsmi_pcie_bandwidth_t', 'amdsmi_pcie_info_t',
|
||||
'amdsmi_power_cap_info_t', 'amdsmi_power_info_t',
|
||||
'amdsmi_power_profile_preset_masks_t',
|
||||
'amdsmi_pcie_slot_type_t', 'amdsmi_power_cap_info_t',
|
||||
'amdsmi_power_info_t', 'amdsmi_power_profile_preset_masks_t',
|
||||
'amdsmi_power_profile_status_t', 'amdsmi_proc_info_t',
|
||||
'amdsmi_process_handle_t', 'amdsmi_process_info_t',
|
||||
'amdsmi_processor_handle', 'amdsmi_range_t',
|
||||
|
||||
@@ -1817,7 +1817,7 @@ amdsmi_get_pcie_link_status(amdsmi_processor_handle processor_handle, amdsmi_pci
|
||||
}
|
||||
|
||||
// default to PCIe
|
||||
info->pcie_slot_type = 0;
|
||||
info->pcie_slot_type = AMDSMI_SLOT_TYPE__PCIE;
|
||||
amd::smi::AMDSmiGPUDevice* gpu_device = nullptr;
|
||||
status = get_gpu_device_from_handle(
|
||||
processor_handle, &gpu_device);
|
||||
@@ -1829,7 +1829,7 @@ amdsmi_get_pcie_link_status(amdsmi_processor_handle processor_handle, amdsmi_pci
|
||||
// bits [16:17] in ids_flags field as slot type
|
||||
if (status == AMDSMI_STATUS_SUCCESS) {
|
||||
// two bits starts with index 16
|
||||
info->pcie_slot_type = (dev_info.ids_flags >> 16) & 0x03;
|
||||
info->pcie_slot_type = static_cast<amdsmi_pcie_slot_type_t>((dev_info.ids_flags >> 16) & 0x03);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1908,7 +1908,7 @@ amdsmi_status_t amdsmi_get_pcie_link_caps(amdsmi_processor_handle processor_hand
|
||||
}
|
||||
|
||||
// default to PCIe
|
||||
info->pcie_slot_type = 0;
|
||||
info->pcie_slot_type = AMDSMI_SLOT_TYPE__PCIE;
|
||||
if (gpu_device->check_if_drm_is_supported()) {
|
||||
struct drm_amdgpu_info_device dev_info = {};
|
||||
status = gpu_device->amdgpu_query_info(AMDGPU_INFO_DEV_INFO,
|
||||
@@ -1916,7 +1916,7 @@ amdsmi_status_t amdsmi_get_pcie_link_caps(amdsmi_processor_handle processor_hand
|
||||
// bits [16:17] in ids_flags field as slot type
|
||||
if (status == AMDSMI_STATUS_SUCCESS) {
|
||||
// two bits starts with index 16
|
||||
info->pcie_slot_type = (dev_info.ids_flags >> 16) & 0x03;
|
||||
info->pcie_slot_type = static_cast<amdsmi_pcie_slot_type_t>((dev_info.ids_flags >> 16) & 0x03);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user