Dimm memory size support
This commit will calculate the memory size for Dimm and
populate the value with property MemorySizeinKB on dbus.
Test- Tested on simics 2s2u
Set the property with dummy value-
root@rain71bmc:/tmp# busctl introspect xyz.openbmc_project.Inventory.Manager /xyz/openbmc_project/inventory/system/chassis/motherboard/dimm0| grep -e MemorySizeInKB -e Present -e PrettyName -e Model -e PartNumber -e SerialNumber
.Model property s "327A" emits-change writable
.PartNumber property s "78P6574" emits-change writable
.SerialNumber property s "YH301T01P00G" emits-change writable
.SparePartNumber property s "" emits-change writable
.SubModel property s "" emits-change writable
.Present property b true emits-change writable
.PrettyName property s "Memory DIMM" emits-change writable
.MemorySizeInKB property u 33554432 emits-change writable
root@rain71bmc:/tmp#
Signed-off-by: Alpana Kumari <alpankum@in.ibm.com>
Change-Id: I70e5bc3f538379f9891ae0ede6cdf09a585520a4
diff --git a/ibm_vpd_app.cpp b/ibm_vpd_app.cpp
index 684b7a7..bb0088f 100644
--- a/ibm_vpd_app.cpp
+++ b/ibm_vpd_app.cpp
@@ -159,8 +159,6 @@
for (const auto& kwVal : map)
{
- vector<uint8_t> vec(kwVal.second.begin(), kwVal.second.end());
-
auto kw = kwVal.first;
if (kw[0] == '#')
@@ -171,7 +169,41 @@
{
kw = string("N_") + kw;
}
- prop.emplace(move(kw), move(vec));
+ if constexpr (is_same<T, KeywordVpdMap>::value)
+ {
+ if (get_if<Binary>(&kwVal.second))
+ {
+ Binary vec(get_if<Binary>(&kwVal.second)->begin(),
+ get_if<Binary>(&kwVal.second)->end());
+
+ prop.emplace(move(kw), move(vec));
+ }
+ else
+ {
+ if (kw == "MemorySizeInKB")
+ {
+ inventory::PropertyMap memProp;
+ auto memVal = get_if<size_t>(&kwVal.second);
+ if (memVal)
+ {
+ memProp.emplace(move(kw),
+ ((*memVal) * CONVERT_MB_TO_KB));
+ interfaces.emplace(
+ "xyz.openbmc_project.Inventory.Item.Dimm",
+ move(memProp));
+ }
+ else
+ {
+ cerr << "MemorySizeInKB value not found in vpd map\n";
+ }
+ }
+ }
+ }
+ else
+ {
+ Binary vec(kwVal.second.begin(), kwVal.second.end());
+ prop.emplace(move(kw), move(vec));
+ }
}
interfaces.emplace(preIntrStr, move(prop));
@@ -259,10 +291,22 @@
{
if (!kw.empty() && vpdMap.count(kw))
{
- auto prop =
- string(vpdMap.at(kw).begin(), vpdMap.at(kw).end());
- auto encoded = encodeKeyword(prop, encoding);
- props.emplace(busProp, encoded);
+ auto kwValue = get_if<Binary>(&vpdMap.at(kw));
+ auto uintValue = get_if<size_t>(&vpdMap.at(kw));
+
+ if (kwValue)
+ {
+ auto prop =
+ string((*kwValue).begin(), (*kwValue).end());
+
+ auto encoded = encodeKeyword(prop, encoding);
+
+ props.emplace(busProp, encoded);
+ }
+ else if (uintValue)
+ {
+ props.emplace(busProp, *uintValue);
+ }
}
}
}
@@ -1069,4 +1113,4 @@
}
return rc;
-}
+}
\ No newline at end of file