Files
rocm-systems/tests/amd_smi_test/functional/id_info_read.cc
T

247 lines
9.2 KiB
C++
Raw Normal View History

2022-08-31 15:21:33 -04:00
/*
* =============================================================================
* The University of Illinois/NCSA
* Open Source License (NCSA)
*
* Copyright (c) 2022, Advanced Micro Devices, Inc.
* All rights reserved.
*
* Developed by:
*
* AMD Research and AMD ROC Software Development
*
* Advanced Micro Devices, Inc.
*
* www.amd.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal with the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimers.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimers in
* the documentation and/or other materials provided with the distribution.
* - Neither the names of <Name of Development Group, Name of Institution>,
* nor the names of its contributors may be used to endorse or promote
* products derived from this Software without specific prior written
* permission.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS WITH THE SOFTWARE.
*
*/
#include <stdint.h>
#include <stddef.h>
#include <iostream>
#include <string>
2022-11-03 13:30:16 -05:00
#include <gtest/gtest.h>
#include "amd_smi/amdsmi.h"
2022-11-03 13:30:16 -05:00
#include "id_info_read.h"
#include "../test_common.h"
2022-08-31 15:21:33 -04:00
TestIdInfoRead::TestIdInfoRead() : TestBase() {
set_title("AMDSMI ID Info Read Test");
set_description("This test verifies that ID information such as the "
"device, subsystem and vendor IDs can be read properly.");
}
TestIdInfoRead::~TestIdInfoRead(void) {
}
void TestIdInfoRead::SetUp(void) {
TestBase::SetUp();
return;
}
void TestIdInfoRead::DisplayTestInfo(void) {
TestBase::DisplayTestInfo();
}
void TestIdInfoRead::DisplayResults(void) const {
TestBase::DisplayResults();
return;
}
void TestIdInfoRead::Close() {
// This will close handles opened within rsmitst utility calls and call
// amdsmi_shut_down(), so it should be done after other hsa cleanup
TestBase::Close();
}
static const uint32_t kBufferLen = 80;
void TestIdInfoRead::Run(void) {
amdsmi_status_t err;
uint16_t id;
uint64_t val_ui64;
uint32_t drm_render_minor;
char buffer[kBufferLen];
TestBase::Run();
if (setup_failed_) {
std::cout << "** SetUp Failed for this test. Skipping.**" << std::endl;
return;
}
for (uint32_t i = 0; i < num_monitor_devs(); ++i) {
IF_VERB(STANDARD) {
std::cout << "\t*************************" << std::endl;
std::cout << "\t**Device index: " << i << std::endl;
}
// Get the device ID, name, vendor ID and vendor name for the device
2022-12-15 08:17:34 -06:00
err = amdsmi_dev_get_id(device_handles_[i], &id);
2022-08-31 15:21:33 -04:00
if (err == AMDSMI_STATUS_NOT_SUPPORTED) {
amdsmi_status_t ret;
// Verify api support checking functionality is working
2022-12-15 08:17:34 -06:00
ret = amdsmi_dev_get_id(device_handles_[i], nullptr);
2022-08-31 15:21:33 -04:00
ASSERT_EQ(ret, AMDSMI_STATUS_NOT_SUPPORTED);
} else {
CHK_ERR_ASRT(err)
IF_VERB(STANDARD) {
std::cout << "\t**Device ID: 0x" << std::hex << id << std::endl;
}
// Verify api support checking functionality is working
2022-12-15 08:17:34 -06:00
err = amdsmi_dev_get_id(device_handles_[i], nullptr);
2022-08-31 15:21:33 -04:00
ASSERT_EQ(err, AMDSMI_STATUS_INVAL);
}
// vendor_id, unique_id
amdsmi_asic_info_t asci_info;
err = amdsmi_get_asic_info(device_handles_[0], &asci_info);
CHK_ERR_ASRT(err)
// device name, brand, serial_number
amdsmi_board_info_t board_info;
err = amdsmi_get_board_info(device_handles_[0], &board_info);
CHK_ERR_ASRT(err)
2022-12-15 08:17:34 -06:00
err = amdsmi_dev_get_vram_vendor(device_handles_[i], buffer, kBufferLen);
2022-08-31 15:21:33 -04:00
if (err == AMDSMI_STATUS_NOT_SUPPORTED) {
std::cout <<
"\t**Vram Vendor string not supported on this system." << std::endl;
2022-12-15 08:17:34 -06:00
err = amdsmi_dev_get_vram_vendor(device_handles_[i], nullptr, kBufferLen);
2022-08-31 15:21:33 -04:00
ASSERT_EQ(err, AMDSMI_STATUS_NOT_SUPPORTED);
} else {
CHK_ERR_ASRT(err)
IF_VERB(STANDARD) {
std::cout << "\t**Device Vram Vendor name: " << buffer << std::endl;
}
}
2022-12-15 08:17:34 -06:00
err = amdsmi_dev_get_drm_render_minor(device_handles_[i], &drm_render_minor);
2022-08-31 15:21:33 -04:00
if (err == AMDSMI_STATUS_NOT_SUPPORTED) {
// Verify api support checking functionality is working
2022-12-15 08:17:34 -06:00
err = amdsmi_dev_get_drm_render_minor(device_handles_[i], nullptr);
2022-08-31 15:21:33 -04:00
ASSERT_EQ(err, AMDSMI_STATUS_NOT_SUPPORTED);
} else {
CHK_ERR_ASRT(err)
IF_VERB(STANDARD) {
std::cout << "\t**DRM Render Minor: " << drm_render_minor << std::endl;
}
// Verify api support checking functionality is working
2022-12-15 08:17:34 -06:00
err = amdsmi_dev_get_drm_render_minor(device_handles_[i], nullptr);
2022-08-31 15:21:33 -04:00
ASSERT_EQ(err, AMDSMI_STATUS_INVAL);
}
2022-12-15 08:17:34 -06:00
err = amdsmi_dev_get_vendor_name(device_handles_[i], buffer, kBufferLen);
2022-08-31 15:21:33 -04:00
if (err == AMDSMI_STATUS_NOT_SUPPORTED) {
std::cout << "\t**Device Vendor name string not found on this system." <<
std::endl;
// Verify api support checking functionality is working
2022-12-15 08:17:34 -06:00
err = amdsmi_dev_get_vendor_name(device_handles_[i], nullptr, kBufferLen);
2022-08-31 15:21:33 -04:00
ASSERT_EQ(err, AMDSMI_STATUS_NOT_SUPPORTED);
} else {
CHK_ERR_ASRT(err)
IF_VERB(STANDARD) {
std::cout << "\t**Device Vendor name: " << buffer << std::endl;
}
// Verify api support checking functionality is working
2022-12-15 08:17:34 -06:00
err = amdsmi_dev_get_vendor_name(device_handles_[i], nullptr, kBufferLen);
2022-08-31 15:21:33 -04:00
ASSERT_EQ(err, AMDSMI_STATUS_INVAL);
}
// Get the device ID, name, vendor ID and vendor name for the sub-device
2022-12-15 08:17:34 -06:00
err = amdsmi_dev_get_subsystem_id(device_handles_[i], &id);
2022-08-31 15:21:33 -04:00
if (err == AMDSMI_STATUS_NOT_SUPPORTED) {
// Verify api support checking functionality is working
2022-12-15 08:17:34 -06:00
err = amdsmi_dev_get_subsystem_id(device_handles_[i], nullptr);
2022-08-31 15:21:33 -04:00
ASSERT_EQ(err, AMDSMI_STATUS_NOT_SUPPORTED);
} else {
CHK_ERR_ASRT(err)
IF_VERB(STANDARD) {
std::cout << "\t**Subsystem ID: 0x" << std::hex << id << std::endl;
}
// Verify api support checking functionality is working
2022-12-15 08:17:34 -06:00
err = amdsmi_dev_get_subsystem_id(device_handles_[i], nullptr);
2022-08-31 15:21:33 -04:00
ASSERT_EQ(err, AMDSMI_STATUS_INVAL);
}
2022-12-15 08:17:34 -06:00
err = amdsmi_dev_get_subsystem_name(device_handles_[i], buffer, kBufferLen);
2022-08-31 15:21:33 -04:00
if (err == AMDSMI_STATUS_NOT_SUPPORTED) {
std::cout << "\t**Subsystem name string not found on this system." <<
std::endl;
// Verify api support checking functionality is working
2022-12-15 08:17:34 -06:00
err = amdsmi_dev_get_subsystem_name(device_handles_[i], nullptr, kBufferLen);
2022-08-31 15:21:33 -04:00
ASSERT_EQ(err, AMDSMI_STATUS_NOT_SUPPORTED);
} else {
CHK_ERR_ASRT(err)
IF_VERB(STANDARD) {
std::cout << "\t**Subsystem name: " << buffer << std::endl;
}
// Verify api support checking functionality is working
2022-12-15 08:17:34 -06:00
err = amdsmi_dev_get_subsystem_name(device_handles_[i], nullptr, kBufferLen);
2022-08-31 15:21:33 -04:00
ASSERT_EQ(err, AMDSMI_STATUS_INVAL);
}
2022-09-09 15:18:08 -04:00
IF_VERB(STANDARD) {
2022-08-31 15:21:33 -04:00
std::cout << "\t**Sub-system Vendor ID: 0x" << std::hex <<
2022-09-09 15:18:08 -04:00
asci_info.subvendor_id << std::endl;
2022-08-31 15:21:33 -04:00
}
2022-09-09 15:18:08 -04:00
2022-12-15 08:17:34 -06:00
err = amdsmi_dev_get_vendor_name(device_handles_[i], buffer, kBufferLen);
2022-08-31 15:21:33 -04:00
if (err == AMDSMI_STATUS_NOT_SUPPORTED) {
std::cout <<
"\t**Subsystem Vendor name string not found on this system." <<
std::endl;
// Verify api support checking functionality is working
2022-12-15 08:17:34 -06:00
err = amdsmi_dev_get_vendor_name(device_handles_[i], nullptr, kBufferLen);
2022-08-31 15:21:33 -04:00
ASSERT_EQ(err, AMDSMI_STATUS_NOT_SUPPORTED);
} else {
CHK_ERR_ASRT(err)
IF_VERB(STANDARD) {
std::cout << "\t**Subsystem Vendor name: " << buffer << std::endl;
}
// Verify api support checking functionality is working
2022-12-15 08:17:34 -06:00
err = amdsmi_dev_get_vendor_name(device_handles_[i], nullptr, kBufferLen);
2022-08-31 15:21:33 -04:00
ASSERT_EQ(err, AMDSMI_STATUS_INVAL);
}
2022-12-15 08:17:34 -06:00
err = amdsmi_dev_get_pci_id(device_handles_[i], &val_ui64);
2022-08-31 15:21:33 -04:00
// Don't check for AMDSMI_STATUS_NOT_SUPPORTED since this should always be
// supported. It is not based on a sysfs file.
CHK_ERR_ASRT(err)
IF_VERB(STANDARD) {
std::cout << "\t**PCI ID (BDFID): 0x" << std::hex << val_ui64;
std::cout << " (" << std::dec << val_ui64 << ")" << std::endl;
}
// Verify api support checking functionality is working
2022-12-15 08:17:34 -06:00
err = amdsmi_dev_get_pci_id(device_handles_[i], nullptr);
2022-08-31 15:21:33 -04:00
ASSERT_EQ(err, AMDSMI_STATUS_INVAL);
}
}