diff options
-rwxr-xr-x | src/include/usr/hdat/hdat.H | 8 | ||||
-rwxr-xr-x | src/usr/hdat/hdatutil.H | 12 | ||||
-rw-r--r-- | src/usr/ipmi/ipmisensor.C | 42 |
3 files changed, 43 insertions, 19 deletions
diff --git a/src/include/usr/hdat/hdat.H b/src/include/usr/hdat/hdat.H index bf005866b..0f750936c 100755 --- a/src/include/usr/hdat/hdat.H +++ b/src/include/usr/hdat/hdat.H @@ -239,6 +239,14 @@ enum hdatRhbPermType : uint8_t RHB_READ_WRITE = RHB_READ_ONLY | RHB_WRITE_ONLY, }; +/** NV Keyword header struct */ +typedef struct{ + uint32_t magic; // = "NV00" + uint8_t version; // Version of the structure = 0x01 start + uint8_t config; // Configuration specifier : redbud=0x01,sequoia=0x02 + uint8_t reserved[249]; // keyword is 255 bytes long +}__attribute__ ((packed)) hdatNVKwdStruct_t; + /* vpd constants * Defining vpd constants */ diff --git a/src/usr/hdat/hdatutil.H b/src/usr/hdat/hdatutil.H index efb492c57..5472c5ab2 100755 --- a/src/usr/hdat/hdatutil.H +++ b/src/usr/hdat/hdatutil.H @@ -147,14 +147,6 @@ struct hdatSMPLinkInfo_t }__attribute__ ((packed)); -/** NV Keyword header struct */ -typedef struct{ - uint32_t magic; // = "NV00" - uint8_t version; // Version of the structure = 0x01 start - uint8_t config; // Configuration specifier : redbud=0x01,sequoia=0x02 - uint8_t reserved[249]; // keyword is 255 bytes long -}__attribute__ ((packed)) hdatNVKwdStruct_t; - enum hdatSMPLinkUsage { HDAT_SMP_LINK_USAGE_SMP = 0, @@ -389,7 +381,7 @@ errlHndl_t hdatGetAsciiKwdForPvpd( /** * @brief Get the Full MVPD records post adding start/end tag. * We need to add the tag back, since HB is stripping them off before - * storing the vpd records in pnor cache. + * storing the vpd records in pnor cache. * * @param[in] i_target input target pointer * @param[out]o_kwdSize: keyword size @@ -410,7 +402,7 @@ errlHndl_t hdatGetMvpdFullRecord( /** * @brief Get the Full PVPD records post adding start/end tag. * We need to add the tag back, since HB is stripping them off before - * storing the vpd records in pnor cache. + * storing the vpd records in pnor cache. * @param[out]o_kwdSize: keyword size * @param[out]o_kwd: key word array * @param[in] i_fetchVpd: relevant structure to be read to fetch the VPD diff --git a/src/usr/ipmi/ipmisensor.C b/src/usr/ipmi/ipmisensor.C index 6cd03acb0..5eb850c6a 100644 --- a/src/usr/ipmi/ipmisensor.C +++ b/src/usr/ipmi/ipmisensor.C @@ -38,6 +38,7 @@ #include <endian.h> #include <vpd/pvpdenums.H> #include <devicefw/userif.H> +#include <hdat/hdat.H> extern trace_desc_t * g_trac_ipmi; @@ -1408,21 +1409,44 @@ namespace SENSOR DEVICE_PVPD_ADDRESS(l_Record,l_KeyWord)); if (!l_err) { - uint8_t l_kwd[l_nvKwdSize] = {0}; - // now read the keyword - l_err = deviceRead(l_nodeTargets[0],l_kwd,l_nvKwdSize, - DEVICE_PVPD_ADDRESS(l_Record,l_KeyWord)); - if (!l_err) + if (l_nvKwdSize == sizeof(HDAT::hdatNVKwdStruct_t)) { - uint8_t cfgID = l_kwd[l_nvKwdSize-1]; - if (cfgID < 16) // maximum setting (bits 0-15) + uint8_t l_kwd[l_nvKwdSize] = {0}; + // now read the keyword + l_err = deviceRead(l_nodeTargets[0],l_kwd,l_nvKwdSize, + DEVICE_PVPD_ADDRESS(l_Record,l_KeyWord)); + if (!l_err) + { + HDAT::hdatNVKwdStruct_t * NVptr = + reinterpret_cast<HDAT::hdatNVKwdStruct_t*>(l_kwd); + + // Valid NV keyword config has NV00 as magic header + if ( !memcmp((char*)&(NVptr->magic),"NV00", 4) ) + { + uint8_t cfgID = NVptr->config; + if (cfgID < 16) // maximum setting (bits 0-15) + { + L_NV_bits = 0x0001 << cfgID; + } + else + { + TRACFCOMP(g_trac_ipmi,"getNVCfgIDBit(): Invalid NV config 0x%02X", cfgID); + } + } + else + { + TRACFCOMP(g_trac_ipmi, "Invalid NV magic header: 0x%.8X", NVptr->magic); + TRACFBIN(g_trac_ipmi, "NV KEYWORD", l_kwd, l_nvKwdSize); + } + } + else { - L_NV_bits = 0x0001 << cfgID; + TRACFCOMP(g_trac_ipmi,ERR_MRK"%.8X Error getting VNDR record data",l_err->eid()); } } else { - TRACFCOMP(g_trac_ipmi,ERR_MRK"%.8X Error getting VNDR record data",l_err->eid()); + TRACFCOMP(g_trac_ipmi,"Invalid NV keyword size: %d, expected %d",l_nvKwdSize,sizeof(HDAT::hdatNVKwdStruct_t)); } } else |