summaryrefslogtreecommitdiff
path: root/redfish-core/lib/memory.hpp
diff options
context:
space:
mode:
authorNan Zhou <nanzhoumails@gmail.com>2022-06-18 02:01:51 +0300
committerEd Tanous <ed@tanous.net>2022-06-21 17:44:02 +0300
commit76686dcc74002493e22d72e24db9d3326b3a63ed (patch)
tree37ba751f84c9c72bd1fb570b143ca3bfebc24a59 /redfish-core/lib/memory.hpp
parent9bc556993f0e13bf024a4e7cba13f8339c02c0d8 (diff)
downloadbmcweb-76686dcc74002493e22d72e24db9d3326b3a63ed.tar.xz
memory: match DIMM ID even more precisely
https://gerrit.openbmc.org/c/openbmc/bmcweb/+/53791 attemps to fix the common error #12 in memory resource. However, it's still not perfect. There is an edge case that Partition objects have wrong paths like /xyz/openbmc_project/Inventory/Item/dimm1, where this partition will still be parsed as a partition of dimm1. This commit corrects this by making path checking explicitly different for DIMM and Partition objects: one check filename, the other check filename of the parent path. Tested: 1. /redfish/v1/Systems/system/Memory/dimm0 ``` { "@odata.id": "/redfish/v1/Systems/system/Memory/dimm0", "@odata.type": "#Memory.v1_11_0.Memory", "AllowedSpeedsMHz": [], "BaseModuleType": "RDIMM", "BusWidthBits": 0, "CapacityMiB": 1024, "DataWidthBits": 0, "ErrorCorrection": "NoECC", "FirmwareRevision": "0", "Id": "dimm0", "Name": "DIMM Slot", "OperatingSpeedMhz": 0, "RankCount": 0, "Regions": [ { "MemoryClassification": "Volatile", "OffsetMiB": 0, "PassphraseEnabled": false, "RegionId": "", "SizeMiB": 1024 }, { "MemoryClassification": "Volatile", "OffsetMiB": 0, "PassphraseEnabled": false, "RegionId": "", "SizeMiB": 1024 } ], "Status": { "Health": "OK", "HealthRollup": "OK", "State": "Enabled" } } ``` 2. No validator errors on Memory Resource. Signed-off-by: Nan Zhou <nanzhoumails@gmail.com> Change-Id: Ic078b5046ac3397e398f050ed7b54ebadcb2aa32
Diffstat (limited to 'redfish-core/lib/memory.hpp')
-rw-r--r--redfish-core/lib/memory.hpp51
1 files changed, 21 insertions, 30 deletions
diff --git a/redfish-core/lib/memory.hpp b/redfish-core/lib/memory.hpp
index 209fa1bd64..8996082456 100644
--- a/redfish-core/lib/memory.hpp
+++ b/redfish-core/lib/memory.hpp
@@ -816,15 +816,6 @@ inline void getDimmPartitionData(std::shared_ptr<bmcweb::AsyncResp> aResp,
"xyz.openbmc_project.Inventory.Item.PersistentMemory.Partition");
}
-inline bool pathContainsDimmId(const std::string& path, std::string_view dimmId)
-{
- sdbusplus::message::object_path objectPath(path);
- // for /xyz/openbmc_project/Inventory/Item/Dimm1/Partition1 or
- // /xyz/openbmc_project/Inventory/Item/Dimm1
- return !dimmId.empty() && (objectPath.filename() == dimmId ||
- objectPath.parent_path().filename() == dimmId);
-}
-
inline void getDimmData(std::shared_ptr<bmcweb::AsyncResp> aResp,
const std::string& dimmId)
{
@@ -841,31 +832,31 @@ inline void getDimmData(std::shared_ptr<bmcweb::AsyncResp> aResp,
return;
}
bool found = false;
- for (const auto& [path, object] : subtree)
+ for (const auto& [rawPath, object] : subtree)
{
- if (pathContainsDimmId(path, dimmId))
+ sdbusplus::message::object_path path(rawPath);
+ for (const auto& [service, interfaces] : object)
{
- for (const auto& [service, interfaces] : object)
+ for (const auto& interface : interfaces)
{
- for (const auto& interface : interfaces)
+ if (interface ==
+ "xyz.openbmc_project.Inventory.Item.Dimm" &&
+ path.filename() == dimmId)
+ {
+ getDimmDataByService(aResp, dimmId, service, rawPath);
+ found = true;
+ }
+
+ // partitions are separate as there can be multiple
+ // per
+ // device, i.e.
+ // /xyz/openbmc_project/Inventory/Item/Dimm1/Partition1
+ // /xyz/openbmc_project/Inventory/Item/Dimm1/Partition2
+ if (interface ==
+ "xyz.openbmc_project.Inventory.Item.PersistentMemory.Partition" &&
+ path.parent_path().filename() == dimmId)
{
- if (interface ==
- "xyz.openbmc_project.Inventory.Item.Dimm")
- {
- getDimmDataByService(aResp, dimmId, service, path);
- found = true;
- }
-
- // partitions are separate as there can be multiple
- // per
- // device, i.e.
- // /xyz/openbmc_project/Inventory/Item/Dimm1/Partition1
- // /xyz/openbmc_project/Inventory/Item/Dimm1/Partition2
- if (interface ==
- "xyz.openbmc_project.Inventory.Item.PersistentMemory.Partition")
- {
- getDimmPartitionData(aResp, service, path);
- }
+ getDimmPartitionData(aResp, service, rawPath);
}
}
}