DCMI: Populate response buffer with power reading
Populate the IPMI response buffer with the power
value read from the total_power sensor.
Resolves openbmc/openbmc#2625
Change-Id: Ib494e40aa37aa16064a4471f79bd7f9d5c0e5c8c
Signed-off-by: Marri Devender Rao <devenrao@in.ibm.com>
diff --git a/dcmihandler.cpp b/dcmihandler.cpp
index 3c77ed5..11befdc 100644
--- a/dcmihandler.cpp
+++ b/dcmihandler.cpp
@@ -1057,10 +1057,22 @@
ipmi_data_len_t data_len, ipmi_context_t context)
{
ipmi_ret_t rc = IPMI_CC_OK;
+ auto requestData = reinterpret_cast<const dcmi::GetPowerReadingRequest*>
+ (request);
+ auto responseData = reinterpret_cast<dcmi::GetPowerReadingResponse*>
+ (response);
+
+ if (requestData->groupID != dcmi::groupExtId)
+ {
+ *data_len = 0;
+ return IPMI_CC_INVALID_FIELD_REQUEST;
+ }
+
sdbusplus::bus::bus bus{ipmid_get_sd_bus_connection()};
+ int64_t power = 0;
try
{
- getPowerReading(bus);
+ power = getPowerReading(bus);
}
catch (InternalFailure& e)
{
@@ -1069,6 +1081,19 @@
entry("PROPERTY=%s", SENSOR_VALUE_PROP));
return IPMI_CC_UNSPECIFIED_ERROR;
}
+ responseData->groupID = dcmi::groupExtId;
+
+ // TODO: openbmc/openbmc#2819
+ // Minumum, Maximum, Average power, TimeFrame, TimeStamp,
+ // PowerReadingState readings need to be populated
+ // after Telemetry changes.
+ uint16_t totalPower = static_cast<uint16_t>(power);
+ responseData->currentPower = totalPower;
+ responseData->minimumPower = totalPower;
+ responseData->maximumPower = totalPower;
+ responseData->averagePower = totalPower;
+
+ *data_len = sizeof(*responseData);
return rc;
}