Display GPU brand name

Add support and testing for reading the brand name associated with
a specific GPU (such as mi25, mi50, mi60, etc). The brand name is
associated with the SKU of the GPU, and some brand names can be
mapped from multiple different SKUs.

Change-Id: I36eb95ca8e72efdd294ccd684841195925dfe820
Signed-off-by: Ori Messinger <Ori.Messinger@amd.com>
This commit is contained in:
Ori Messinger
2019-08-19 11:26:27 -04:00
parent aa2db48237
commit 7f2d970a80
3 ha cambiato i file con 71 aggiunte e 0 eliminazioni
+39
Vedi File
@@ -45,6 +45,7 @@
#include <errno.h>
#include <sys/utsname.h>
#include <pthread.h>
#include <string.h>
#include <sstream>
#include <algorithm>
@@ -1421,6 +1422,44 @@ rsmi_dev_name_get(uint32_t dv_ind, char *name, size_t len) {
CATCH
}
rsmi_status_t
rsmi_dev_brand_get(uint32_t dv_ind, char *brand, size_t len) {
GET_DEV_FROM_INDX
// Return 'invalid args' if arguments are invalid
if (brand == nullptr || len == 0){
return RSMI_STATUS_INVALID_ARGS;
}
std::map<std::string, std::string> brand_names =
{
{"D05121", "mi25"},
{"D05131", "mi25"},
{"D05133", "mi25"},
{"D05151", "mi25"},
{"D16304", "mi50"},
{"D16302", "mi60"}
};
std::map<std::string, std::string>::iterator it;
std::string vbios_value;
std::string sku_value;
// Retrieve vbios and store in vbios_value string
int ret = dev->readDevInfo(amd::smi::kDevVBiosVer, &vbios_value);
if (ret != 0) {
return errno_to_rsmi_status(ret);
}
if (vbios_value.length() == 16) {
sku_value = vbios_value.substr(4,6);
// Find the brand name using sku_value
it = brand_names.find(sku_value);
if (it != brand_names.end()) {
strcpy(brand, it->second.c_str());
return RSMI_STATUS_SUCCESS;
}
}
// If there is no SKU match, return marketing name instead
rsmi_dev_name_get(dv_ind, brand, len);
return RSMI_STATUS_SUCCESS;
}
rsmi_status_t
rsmi_dev_subsystem_name_get(uint32_t dv_ind, char *name, size_t len) {
rsmi_status_t ret;