platform-mc: sensor: Support none-telemetry base unit
As [1], The sensor D-Bus object path `/xyz/openbmc_project/sensors/` and
`xyz.openbmc_project.Sensor.Value` interface are only used for the
telemetry sensor types which are listed. The non-telemetry PLDM sensor
with the `baseUnit` type `count`, `corrected_errors`,
`uncorrected_errors` and `oemunit` are none-telemetry types and are not
belong to that list.
Those unit types are metric types which are count of somethings so the
metric D-Bus object path `/xyz/openbmc_project/metric/` and D-Bus
`xyz.openbmc_project.Metric.Value` should be used as [2]. Support
creating D-Bus object path and polling sensor values for the numeric
sensor/compact numeric sensor PDRs with the BaseUnit type is
none-telemetry.
[1] https://github.com/openbmc/phosphor-dbus-interfaces/blob/90cfce16584253a5f524c718ce5a6ae7c33f7b8c/yaml/xyz/openbmc_project/Sensor/Value.interface.yaml#L1
[2] https://github.com/openbmc/phosphor-dbus-interfaces/blob/master/yaml/xyz/openbmc_project/Sensor/Value.interface.yaml
Signed-off-by: Thu Nguyen <thu@os.amperecomputing.com>
Change-Id: Iaf8d842e6ec0cb082b139d15da1a1bd10a701acf
diff --git a/platform-mc/numeric_sensor.hpp b/platform-mc/numeric_sensor.hpp
index 92c709f..307f5e0 100644
--- a/platform-mc/numeric_sensor.hpp
+++ b/platform-mc/numeric_sensor.hpp
@@ -8,6 +8,7 @@
#include <sdbusplus/server/object.hpp>
#include <xyz/openbmc_project/Association/Definitions/server.hpp>
+#include <xyz/openbmc_project/Metric/Value/server.hpp>
#include <xyz/openbmc_project/Sensor/Threshold/Critical/server.hpp>
#include <xyz/openbmc_project/Sensor/Threshold/Warning/server.hpp>
#include <xyz/openbmc_project/Sensor/Value/server.hpp>
@@ -21,9 +22,15 @@
namespace platform_mc
{
+constexpr const char* SENSOR_VALUE_INTF = "xyz.openbmc_project.Sensor.Value";
+constexpr const char* METRIC_VALUE_INTF = "xyz.openbmc_project.Metric.Value";
+
using SensorUnit = sdbusplus::xyz::openbmc_project::Sensor::server::Value::Unit;
using ValueIntf = sdbusplus::server::object_t<
sdbusplus::xyz::openbmc_project::Sensor::server::Value>;
+using MetricUnit = sdbusplus::xyz::openbmc_project::Metric::server::Value::Unit;
+using MetricIntf = sdbusplus::server::object_t<
+ sdbusplus::xyz::openbmc_project::Metric::server::Value>;
using ThresholdWarningIntf = sdbusplus::server::object_t<
sdbusplus::xyz::openbmc_project::Sensor::Threshold::server::Warning>;
using ThresholdCriticalIntf = sdbusplus::server::object_t<
@@ -206,6 +213,7 @@
*/
void updateThresholds();
+ std::unique_ptr<MetricIntf> metricIntf = nullptr;
std::unique_ptr<ValueIntf> valueIntf = nullptr;
std::unique_ptr<ThresholdWarningIntf> thresholdWarningIntf = nullptr;
std::unique_ptr<ThresholdCriticalIntf> thresholdCriticalIntf = nullptr;
@@ -226,6 +234,7 @@
/** @brief A power-of-10 multiplier for baseUnit */
int8_t baseUnitModifier;
+ bool useMetricInterface = false;
};
} // namespace platform_mc
} // namespace pldm