Add CPU dbus service for MDR V2
Add all CPU information in smbios table and provide dbus
interface for redfish to get CPU information.
Tested:
DC cycle system and waiting for BIOS entering setup page.
Check CPU information in Redfish, Redfish should show correct CPU
information.
Signed-off-by: Cheng C Yang <cheng.c.yang@linux.intel.com>
Change-Id: I8e6f803c516267de094a01fb1b1fa7d2420d2474
diff --git a/src/mdrv2.cpp b/src/mdrv2.cpp
index d940285..8452741 100644
--- a/src/mdrv2.cpp
+++ b/src/mdrv2.cpp
@@ -361,6 +361,60 @@
directoryEntries(value);
}
+void MDR_V2::systemInfoUpdate()
+{
+ cpus.clear();
+
+ int num = getTotalCpuSlot();
+ if (num == -1)
+ {
+ phosphor::logging::log<phosphor::logging::level::ERR>(
+ "get cpu total slot failed");
+ return;
+ }
+
+ for (int index = 0; index < num; index++)
+ {
+ std::string path = cpuPath + std::to_string(index);
+ cpus.emplace_back(std::make_unique<phosphor::smbios::Cpu>(
+ bus, path, index, smbiosDir.dir[smbiosDirIndex].dataStorage));
+ }
+}
+
+int MDR_V2::getTotalCpuSlot()
+{
+ uint8_t* dataIn = smbiosDir.dir[smbiosDirIndex].dataStorage;
+ int num = 0;
+
+ if (dataIn == nullptr)
+ {
+ phosphor::logging::log<phosphor::logging::level::ERR>(
+ "get cpu total slot failed - no storage data");
+ return -1;
+ }
+
+ while (1)
+ {
+ dataIn = getSMBIOSTypePtr(dataIn, processorsType);
+ if (dataIn == nullptr)
+ {
+ break;
+ }
+ num++;
+ dataIn = smbiosNextPtr(dataIn);
+ if (dataIn == nullptr)
+ {
+ break;
+ }
+ if (num >= limitEntryLen)
+ {
+ break;
+ }
+ }
+
+ return num;
+}
+
bool MDR_V2::agentSynchronizeData()
{
struct MDRSMBIOSHeader mdr2SMBIOS;
@@ -374,6 +428,7 @@
}
else
{
+ systemInfoUpdate();
smbiosDir.dir[smbiosDirIndex].common.dataVersion = mdr2SMBIOS.dirVer;
smbiosDir.dir[smbiosDirIndex].common.timestamp = mdr2SMBIOS.timestamp;
smbiosDir.dir[smbiosDirIndex].common.size = mdr2SMBIOS.dataSize;