From 1930fbd482ad28be0c833db0035d1be180e25939 Mon Sep 17 00:00:00 2001 From: Brandon Kim Date: Tue, 14 Sep 2021 17:52:51 -0700 Subject: redfish-core: processor: Add Model, Microcode, Step Add implementation of ProcessorId from Processor DMTF Schema. "EffectiveModel", "MicrocodeInfo" and "Step" are mapped to "Model", "Microcode" and "Step" from phosphor-dbus-interfaces Tested: With some of the information redacted as XX, we can see: ``` { "@odata.id": "/redfish/v1/Systems/system/Processors/cpu0", "@odata.type": "#Processor.v1_11_0.Processor", "Id": "cpu0", "MaxSpeedMHz": 0, "Name": "Processor", "ProcessorId": { "EffectiveFamily": "X", "EffectiveModel": "XX", "MicrocodeInfo": "XXX", "Step": "X" }, "ProcessorType": "CPU", "Socket": "0", "Status": { "Health": "OK", "State": "Enabled" }, "TotalCores": XX, "TotalThreads": XXX } ``` The Redfish-Service-Validator passed for Processors: ``` *** /redfish/v1/Systems/system/Processors Type (#ProcessorCollection.ProcessorCollection), GET SUCCESS (time: 0.286532) ... ... *** /redfish/v1/Systems/system/Processors/cpu0 Type (#Processor.v1_11_0.Processor), GET SUCCESS (time: 0.434741) PASS ... ... *** /redfish/v1/JsonSchemas/Processor Type (#JsonSchemaFile.v1_0_2.JsonSchemaFile), GET SUCCESS (time: 0.134821) PASS ``` Signed-off-by: Brandon Kim Change-Id: Ie770bfcdb8bf9d5efbf90cc9d9c09daaf8447a6f --- redfish-core/lib/processor.hpp | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) (limited to 'redfish-core') diff --git a/redfish-core/lib/processor.hpp b/redfish-core/lib/processor.hpp index ec24735ba1..e510768442 100644 --- a/redfish-core/lib/processor.hpp +++ b/redfish-core/lib/processor.hpp @@ -160,16 +160,26 @@ inline void aResp->res.jsonValue["TotalThreads"] = *value; } } - else if (property.first == "Family") + else if (property.first == "EffectiveFamily") { - const std::string* value = - std::get_if(&property.second); + const uint16_t* value = std::get_if(&property.second); if (value != nullptr) { aResp->res.jsonValue["ProcessorId"]["EffectiveFamily"] = - *value; + "0x" + intToHexString(*value); } } + else if (property.first == "EffectiveModel") + { + const uint16_t* value = std::get_if(&property.second); + if (value == nullptr) + { + messages::internalError(aResp->res); + return; + } + aResp->res.jsonValue["ProcessorId"]["EffectiveModel"] = + "0x" + intToHexString(*value); + } else if (property.first == "Id") { const uint64_t* value = std::get_if(&property.second); @@ -180,6 +190,28 @@ inline void "0x" + intToHexString(*value); } } + else if (property.first == "Microcode") + { + const uint32_t* value = std::get_if(&property.second); + if (value == nullptr) + { + messages::internalError(aResp->res); + return; + } + aResp->res.jsonValue["ProcessorId"]["MicrocodeInfo"] = + "0x" + intToHexString(*value); + } + else if (property.first == "Step") + { + const uint16_t* value = std::get_if(&property.second); + if (value == nullptr) + { + messages::internalError(aResp->res); + return; + } + aResp->res.jsonValue["ProcessorId"]["Step"] = + "0x" + intToHexString(*value); + } } } -- cgit v1.2.3