Populate Memory attributes
Add support to populate MemoryMedia, Slot and Socket attribute values
to dbus attributes.
Tested:
Memory attributes MemoryMedia,Slot and Socket are populated in dbus
through busctl command
Command:
busctl introspect xyz.openbmc_project.Smbios.MDR_V2
/xyz/openbmc_project/inventory/system/chassis/motherboard/dimm0
Response:
NAME TYPE SIGNATURE RESULT/VALUE FLAGS
....
xyz.openbmc_project.Inventory.Decorator.LocationCode interface - - -
.LocationCode property s "BANK 0 CPU0_DIMM_A" emits-change writable
xyz.openbmc_project.Inventory.Item interface - - -
.Present property b true emits-change writable
.PrettyName property s "" emits-change writable
xyz.openbmc_project.Inventory.Item.Dimm interface - - -
.MemoryAttributes property u 8388610 emits-change writable
.MemoryConfiguredSpeedInMhz property q 19460 emits-change writable
.MemoryDataWidth property q 64 emits-change writable
.MemoryDeviceLocator property s "BANK 0 CPU0_DIMM_A" emits-change writable
.MemoryMedia property s "xyz.openbmc_project.Inventory.Item.D... emits-change writable
.MemorySizeInKB property u 1468006400 emits-change writable
.MemoryTotalWidth property q 0 emits-change writable
.MemoryType property s "xyz.openbmc_project.Inventory.Item.D... emits-change writable
.MemoryTypeDetail property s "SynchronousRegistered" emits-change writable
.RevisionCode property q 0 emits-change writable
xyz.openbmc_project.Inventory.Item.Dimm.MemoryLocation interface - - -
.Channel property y 0 emits-change writable
.MemoryController property y 0 emits-change writable
.Slot property y 65 emits-change writable
.Socket property y 1 emits-change writable
.....
Signed-off-by: poram srinivasa rao <poramx.srinivasa.rao@intel.com>
Signed-off-by: Jayaprakash Mutyala <mutyalax.jayaprakash@intel.com>
Change-Id: Iabc2a58642167344711550b669ed4f207fb39d45
diff --git a/src/dimm.cpp b/src/dimm.cpp
index 72f5ed3..2138886 100644
--- a/src/dimm.cpp
+++ b/src/dimm.cpp
@@ -21,6 +21,8 @@
#include <boost/algorithm/string.hpp>
#include <phosphor-logging/elog-errors.hpp>
+#include <regex>
+
namespace phosphor
{
namespace smbios
@@ -93,6 +95,7 @@
dimmSerialNum(memoryInfo->serialNum, memoryInfo->length, dataIn);
dimmPartNum(memoryInfo->partNum, memoryInfo->length, dataIn);
memoryAttributes(memoryInfo->attributes);
+ dimmMedia(memoryInfo->memoryTechnology);
memoryConfiguredSpeedInMhz(memoryInfo->confClockSpeed);
updateEccType(memoryInfo->phyArrayHandle);
@@ -202,6 +205,43 @@
memoryDeviceLocator(result);
locationCode(result);
+ const std::string substrCpu = "CPU";
+ auto cpuPos = deviceLocator.find(substrCpu);
+
+ if (cpuPos != std::string::npos)
+ {
+ std::string socketString =
+ deviceLocator.substr(cpuPos + substrCpu.length(), 1);
+ try
+ {
+ uint8_t socketNum =
+ static_cast<uint8_t>(std::stoi(socketString) + 1);
+ socket(socketNum);
+ }
+ catch (const sdbusplus::exception_t& ex)
+ {
+ phosphor::logging::log<phosphor::logging::level::ERR>(
+ "std::stoi operation failed ",
+ phosphor::logging::entry("ERROR=%s", ex.what()));
+ }
+ }
+
+ const std::string substrDimm = "DIMM";
+ auto dimmPos = deviceLocator.find(substrDimm);
+
+ if (dimmPos != std::string::npos)
+ {
+ std::string slotString =
+ deviceLocator.substr(dimmPos + substrDimm.length() + 1);
+ /* slotString is extracted from substrDimm (DIMM_A) if slotString is
+ * single alphabet like A, B , C.. then assign ASCII value of slotString
+ * to slot */
+ if ((std::regex_match(slotString, std::regex("^[A-Za-z]+$"))) &&
+ (slotString.length() == 1))
+ {
+ slot(static_cast<uint8_t>(toupper(slotString[0])));
+ }
+ }
}
std::string Dimm::memoryDeviceLocator(std::string value)
@@ -229,6 +269,26 @@
memoryType(value);
}
+void Dimm::dimmMedia(const uint8_t type)
+{
+ std::map<uint8_t, MemoryTechType>::const_iterator it =
+ dimmMemoryTechTypeMap.find(type);
+ if (it == dimmMemoryTechTypeMap.end())
+ {
+ memoryMedia(MemoryTechType::Unknown);
+ }
+ else
+ {
+ memoryMedia(it->second);
+ }
+}
+
+MemoryTechType Dimm::memoryMedia(MemoryTechType value)
+{
+ return sdbusplus::server::xyz::openbmc_project::inventory::item::Dimm::
+ memoryMedia(value);
+}
+
void Dimm::dimmTypeDetail(uint16_t detail)
{
std::string result;
@@ -325,6 +385,18 @@
memoryAttributes(value);
}
+uint8_t Dimm::slot(uint8_t value)
+{
+ return sdbusplus::server::xyz::openbmc_project::inventory::item::dimm::
+ MemoryLocation::slot(value);
+}
+
+uint8_t Dimm::socket(uint8_t value)
+{
+ return sdbusplus::server::xyz::openbmc_project::inventory::item::dimm::
+ MemoryLocation::socket(value);
+}
+
uint16_t Dimm::memoryConfiguredSpeedInMhz(uint16_t value)
{
return sdbusplus::server::xyz::openbmc_project::inventory::item::Dimm::