Add config to allow DIMM only in Location Code
This change creates an option that excludes the bank number from the
location code. This addresses issues from [1] that changed the location
format, breaking previous assumptions related to location codes.
This command was used the validate the format of the location code.
'''
$ busctl introspect "xyz.openbmc_project.Smbios.MDR_V2" /xyz/openbmc_project/inventory/system/chassis/motherboard/dimm4
...
xyz.openbmc_project.Inventory.Decorator.LocationCode interface - - -
.LocationCode property s "DIMM2" emits-change
```
[1] https://github.com/openbmc/smbios-mdr/commit/744b35aad0051084c7b71fee8898d1e496345270
Signed-off-by: John Edward Broadbent <jebr@google.com>
Change-Id: I3b1e219aabba20c0031bfe78bad17887cf05715c
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2cc888b..817b9d1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -61,6 +61,13 @@
install (FILES ${PROJECT_SOURCE_DIR}/service_files/smbios-mdrv2.service
DESTINATION /lib/systemd/system/)
+option (DIMM_ONLY_LOCATOR "Only use the DIMM number, and not the bank" OFF)
+
+if (DIMM_ONLY_LOCATOR)
+ target_compile_definitions (smbiosmdrv2app PRIVATE DIMM_ONLY_LOCATOR)
+endif ()
+
+
option (CPU_INFO "Add Cpuinfo Service" ON)
option (YOCTO "Enable Building in Yocto" OFF)
diff --git a/src/dimm.cpp b/src/dimm.cpp
index 6928c8b..9cc7ef3 100644
--- a/src/dimm.cpp
+++ b/src/dimm.cpp
@@ -26,6 +26,12 @@
namespace smbios
{
+#ifdef DIMM_ONLY_LOCATOR
+bool onlyDimmLocationCode = true;
+#else
+bool onlyDimmLocationCode = false;
+#endif
+
using DeviceType =
sdbusplus::xyz::openbmc_project::Inventory::Item::server::Dimm::DeviceType;
@@ -176,13 +182,13 @@
positionToString(bankLocatorPositionNum, structLen, dataIn);
std::string result;
- if (!bankLocator.empty())
+ if (bankLocator.empty() || onlyDimmLocationCode)
{
- result = bankLocator + " " + deviceLocator;
+ result = deviceLocator;
}
else
{
- result = deviceLocator;
+ result = bankLocator + " " + deviceLocator;
}
memoryDeviceLocator(result);