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 <brandonkim@google.com>
Change-Id: Ie770bfcdb8bf9d5efbf90cc9d9c09daaf8447a6f
diff --git a/redfish-core/lib/processor.hpp b/redfish-core/lib/processor.hpp
index ec24735..e510768 100644
--- a/redfish-core/lib/processor.hpp
+++ b/redfish-core/lib/processor.hpp
@@ -160,16 +160,26 @@
aResp->res.jsonValue["TotalThreads"] = *value;
}
}
- else if (property.first == "Family")
+ else if (property.first == "EffectiveFamily")
{
- const std::string* value =
- std::get_if<std::string>(&property.second);
+ const uint16_t* value = std::get_if<uint16_t>(&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<uint16_t>(&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<uint64_t>(&property.second);
@@ -180,6 +190,28 @@
"0x" + intToHexString(*value);
}
}
+ else if (property.first == "Microcode")
+ {
+ const uint32_t* value = std::get_if<uint32_t>(&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<uint16_t>(&property.second);
+ if (value == nullptr)
+ {
+ messages::internalError(aResp->res);
+ return;
+ }
+ aResp->res.jsonValue["ProcessorId"]["Step"] =
+ "0x" + intToHexString(*value);
+ }
}
}