Skip to content

Commit

Permalink
Support get SMS string from fru vpd
Browse files Browse the repository at this point in the history
Add support for UTIL::F5 and UTIL::F6
Hostboot will get F5 and F6 from BMC through PLDM and cache it to the PVPD.
Finally,F5 and F6 will be merged together and write to hdat system ipl parameter.
  • Loading branch information
lili-lilili committed Feb 25, 2023
1 parent 4899808 commit a9fd3af
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 8 deletions.
3 changes: 3 additions & 0 deletions src/include/usr/vpd/pvpdenums.H
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ namespace PVPD
VSYS = 0x01,
LXR0 = 0x02,
PSPD = 0x03,
UTIL = 0x04,
// Last Record
PVPD_LAST_RECORD,
PVPD_TEST_RECORD, // Test purposes ONLY!
Expand Down Expand Up @@ -100,6 +101,8 @@ namespace PVPD
TN = 0x28,
WN = 0x29,
pdD = 0x2A,
F5 = 0x2B,
F6 = 0x2C,

// Last Keyword
PVPD_LAST_KEYWORD,
Expand Down
96 changes: 88 additions & 8 deletions src/usr/hdat/hdatiplparms.C
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
#include <devicefw/userif.H>
#include <targeting/common/util.H>
#include <pldm/extended/pdr_manager.H>

#include <targeting/targplatutil.H>
#include <errl/errlmanager.H>

using namespace TARGETING;

Expand Down Expand Up @@ -724,18 +725,97 @@ void HdatIplParms::hdatGetSystemParamters()

this->iv_hdatIPLParams->iv_sysParms.hdatSplitCoreMode = 1;

TARGETING::ATTR_SYSTEM_BRAND_NAME_type l_systemBrandName = {0};
if(l_pSysTarget->tryGetAttr<TARGETING::ATTR_SYSTEM_BRAND_NAME>
(l_systemBrandName))
/* Read UTIL::F5 keyword (maxlen=16)*/
errlHndl_t l_err = nullptr;
size_t dataSize = 0;
char sysVendorname[sizeof(this->iv_hdatIPLParams->iv_sysParms.hdatSystemVendorName)]={0};
Target* node_tgt = UTIL::getCurrentNodeTarget();


l_err = deviceRead(node_tgt, nullptr, dataSize, DEVICE_PVPD_ADDRESS( PVPD::UTIL, PVPD::F5 ));

if (l_err)
{
strcpy(reinterpret_cast<char*>
(this->iv_hdatIPLParams->iv_sysParms.hdatSystemVendorName),
l_systemBrandName);
errlCommit( l_err, HDAT_COMP_ID );
HDAT_ERR("Read UTIL::F5 length error");
}
else
{
char f5Buffer[dataSize+1]={0};
l_err = deviceRead(node_tgt, f5Buffer, dataSize, DEVICE_PVPD_ADDRESS( PVPD::UTIL, PVPD::F5 ));
if (l_err)
{
errlCommit( l_err, HDAT_COMP_ID );
HDAT_ERR("Read UTIL::F5 data error");
}
else if((strlen(f5Buffer)+1) > sizeof(sysVendorname))
{
HDAT_ERR("Read UTIL::F5 string len override size: %d", strlen(f5Buffer));
}
else
{
HDAT_DBG("Read UTIL::F5 success len=%d str=%s", dataSize, f5Buffer);
if (strlen(f5Buffer))
{
strcat(sysVendorname, f5Buffer);
}
}
}

/* Read UTIL::F6 keyword(maxlen=16) */
dataSize = 0;
l_err = deviceRead(node_tgt, nullptr, dataSize, DEVICE_PVPD_ADDRESS( PVPD::UTIL, PVPD::F6 ));

if (l_err)
{
errlCommit( l_err, HDAT_COMP_ID );
HDAT_ERR("Read UTIL::F6 length error...");
}
else
{
HDAT_ERR("Error in getting SYSTEM_BRAND_NAME");
char f6Buffer[dataSize+1]={0};
l_err = deviceRead(node_tgt, f6Buffer, dataSize, DEVICE_PVPD_ADDRESS( PVPD::UTIL, PVPD::F6 ));
if (l_err)
{
errlCommit( l_err, HDAT_COMP_ID );
HDAT_ERR("Read UTIL::F6 data error");
}
else if((strlen(f6Buffer) + strlen(sysVendorname) + 1) > sizeof(sysVendorname))
{
HDAT_ERR("Read UTIL::F5+F6 string len override size: %d", strlen(f6Buffer) + strlen(sysVendorname));
}
else
{
HDAT_DBG("Read UTIL::F6 success len=%d str=%s", dataSize, f6Buffer);
if (strlen(f6Buffer))
{
strcat(sysVendorname, f6Buffer);
}
}
}

/* check vendor name from VPD */
if (strlen(sysVendorname))
{
strcpy(reinterpret_cast<char*>(this->iv_hdatIPLParams->iv_sysParms.hdatSystemVendorName), sysVendorname);
}
else
{
HDAT_DBG("UTIL::F5 F6 is empty, using ATTR_SYSTEM_BRAND_NAME");
TARGETING::ATTR_SYSTEM_BRAND_NAME_type l_systemBrandName = { 0 };
if(l_pSysTarget->tryGetAttr<TARGETING::ATTR_SYSTEM_BRAND_NAME>
(l_systemBrandName))
{
strcpy(reinterpret_cast<char*>
(this->iv_hdatIPLParams->iv_sysParms.hdatSystemVendorName),
l_systemBrandName);
}
else
{
HDAT_ERR("Error in getting SYSTEM_BRAND_NAME");
}
}

HDAT_DBG("after SYSTEM_BRAND_NAME");

// The next 5 fields are set to their final values in a common handler
Expand Down
1 change: 1 addition & 0 deletions src/usr/pldm/extended/hb_fru.C
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ const std::map<uint32_t, std::vector<uint16_t> > record_keyword_field_map {
{ VINI, { std::begin(valid_vini_keywords), std::end(valid_vini_keywords) } },
{ VSYS, { std::begin(valid_vsys_keywords), std::end(valid_vsys_keywords) } },
{ LXR0, { std::begin(valid_lxr0_keywords), std::end(valid_lxr0_keywords) } },
{ UTIL, { std::begin(valid_util_keywords), std::end(valid_util_keywords) } },
};

/**
Expand Down
28 changes: 28 additions & 0 deletions src/usr/pldm/extended/pldm_fru_to_ipz_mapping.H
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ enum valid_records : uint32_t
VINI = 0x56494E49,
VSYS = 0x56535953,
LXR0 = 0x4C585230,
UTIL = 0x5554494C,
};

constexpr uint8_t RT_FIELD_TYPE = 2;
Expand Down Expand Up @@ -94,6 +95,33 @@ const uint16_t valid_vsys_keywords[]
0x574E // WN
};

const uint16_t valid_util_keywords[]
{ 0xFFFF, // invalid
0xFFFF, // invalid
0x5254, // RT
0x4430, // D0
0x4431, // D1
0x4432, // D2
0x4433, // D3
0x4434, // D4
0x4435, // D5
0x4436, // D6
0x4437, // D7
0x4438, // D8
0x4439, // D9
0x4630, // F0
0x4631, // F1
0x4632, // F2
0x4633, // F3
0x4634, // F4
0x4635, // F5
0x4636, // F6
0x4637, // F7
0x4638, // F8
0x4639, // F9
0x5046, // PF
};

// Must match valid_vsys_keywords and PLDM FRU IPZ Keyword Mapping Doc
enum valid_vsys_keywords_values
{
Expand Down
3 changes: 3 additions & 0 deletions src/usr/vpd/pvpd.H
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ namespace PVPD
{ VSYS, "VSYS" },
{ LXR0, "LXR0" },
{ PSPD, "PSPD" },
{ UTIL, "UTIL" },
// -------------------------------------------------------------------
// DO NOT USE!! This is for test purposes ONLY!
{ PVPD_TEST_RECORD, "TEST" },
Expand Down Expand Up @@ -121,6 +122,8 @@ namespace PVPD
{ TN, "TN" },
{ WN, "WN" },
{ pdD, "#D" },
{ F5, "F5" },
{ F6, "F6" },

// -------------------------------------------------------------------
// DO NOT USE!! This is for test purposes ONLY!
Expand Down

0 comments on commit a9fd3af

Please sign in to comment.