summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarshit Aghera <haghera@nvidia.com>2025-07-24 07:08:52 +0300
committerEd Tanous <ed@tanous.net>2025-10-25 02:22:14 +0300
commit4e8d8a1ce8941a47f0531f2af565c56a5d604119 (patch)
treecc55a0893a64f9e1bc1704440482a09c57b70b8f
parent730b00f42c206bd84664b577113aedc263016877 (diff)
downloadbmcweb-4e8d8a1ce8941a47f0531f2af565c56a5d604119.tar.xz
sensor_utils: add sensor properties
Add support for ReadingBasis and Implementation sensor properties. These properties are defined on xyz.openbmc_project.Sensor.Type which will be optionally implemented by sensor. DBus Interface definition - https://gerrit.openbmc.org/c/openbmc/phosphor-dbus-interfaces/+/81658 Link to Redfish schema - https://redfish.dmtf.org/schemas/v1/Sensor.v1_11_0.yaml Tested: Build an image for gb200nvl-obmc machine with the following patches cherry picked. This patches are needed to enable the mctp stack. https://gerrit.openbmc.org/c/openbmc/openbmc/+/79422 Redfish service validator is passing. ``` > curl -s -k -u 'root:0penBmc' https://10.137.203.137/redfish/v1/Chassis/NVIDIA_GB200_1/Sensors/temperature_NVIDIA_GB200_GPU_0_TEMP_1 { "@odata.id": "/redfish/v1/Chassis/NVIDIA_GB200_1/Sensors/temperature_NVIDIA_GB200_GPU_0_TEMP_1", "@odata.type": "#Sensor.v1_2_0.Sensor", "Description": "Thermal Limit(TLIMIT) Temperature is the distance in deg C from the GPU temperature to the first throttle limit.", "Id": "temperature_NVIDIA_GB200_GPU_0_TEMP_1", "Implementation": "Synthesized", "Name": "NVIDIA GB200 GPU 0 TEMP 1", "Reading": 56.59375, "ReadingBasis": "Headroom", "ReadingRangeMax": 127.0, "ReadingRangeMin": -128.0, "ReadingType": "Temperature", "ReadingUnits": "Cel", "Status": { "Health": "OK", "State": "Enabled" } }% root@gb200nvl-obmc:~# busctl introspect xyz.openbmc_project.GpuSensor /xyz/openbmc_project/sensors/temperature/NVIDIA_GB200_GPU_0_TEMP_1 NAME TYPE SIGNATURE RESULT/VALUE FLAGS org.freedesktop.DBus.Introspectable interface - - - .Introspect method - s - org.freedesktop.DBus.Peer interface - - - .GetMachineId method - s - .Ping method - - - org.freedesktop.DBus.Properties interface - - - .Get method ss v - .GetAll method s a{sv} - .Set method ssv - - .PropertiesChanged signal sa{sv}as - - xyz.openbmc_project.Association.Definitions interface - - - .Associations property a(sss) 1 "chassis" "all_sensors" "/xyz/openb... emits-change xyz.openbmc_project.Inventory.Item interface - - - .PrettyName property s "Thermal Limit(TLIMIT) Temperature is... emits-change xyz.openbmc_project.Sensor.Type interface - - - .Implementation property s "xyz.openbmc_project.Sensor.Type.Impl... emits-change .ReadingBasis property s "xyz.openbmc_project.Sensor.Type.Read... emits-change xyz.openbmc_project.Sensor.Value interface - - - .MaxValue property d 127 emits-change .MinValue property d -128 emits-change .Unit property s "xyz.openbmc_project.Sensor.Value.Uni... emits-change .Value property d 56.6836 emits-change writable xyz.openbmc_project.Sensor.ValueMutability interface - - - .Mutable property b true emits-change xyz.openbmc_project.State.Decorator.Availability interface - - - .Available property b true emits-change writable xyz.openbmc_project.State.Decorator.OperationalStatus interface - - - .Functional property b true emits-change ``` Change-Id: I61344e8d8c8ef36d7553f33afb5f84643ce1fe4d Signed-off-by: Harshit Aghera <haghera@nvidia.com>
-rw-r--r--docs/Redfish.md2
-rw-r--r--redfish-core/include/utils/sensor_utils.hpp71
2 files changed, 71 insertions, 2 deletions
diff --git a/docs/Redfish.md b/docs/Redfish.md
index 5a2b32c6cb..1d6d34c69d 100644
--- a/docs/Redfish.md
+++ b/docs/Redfish.md
@@ -290,7 +290,9 @@ Fields common to all schemas
#### Sensor
+- Implementation
- Reading
+- ReadingBasis
- ReadingRangeMax
- ReadingRangeMin
- ReadingType
diff --git a/redfish-core/include/utils/sensor_utils.hpp b/redfish-core/include/utils/sensor_utils.hpp
index f1adafefa1..f97d93f545 100644
--- a/redfish-core/include/utils/sensor_utils.hpp
+++ b/redfish-core/include/utils/sensor_utils.hpp
@@ -417,6 +417,49 @@ inline void setLedState(nlohmann::json& sensorJson,
}
}
+inline sensor::ReadingBasisType dBusSensorReadingBasisToRedfish(
+ const std::string& readingBasis)
+{
+ if (readingBasis ==
+ "xyz.openbmc_project.Sensor.Type.ReadingBasisType.Headroom")
+ {
+ return sensor::ReadingBasisType::Headroom;
+ }
+ if (readingBasis ==
+ "xyz.openbmc_project.Sensor.Type.ReadingBasisType.Delta")
+ {
+ return sensor::ReadingBasisType::Delta;
+ }
+ if (readingBasis == "xyz.openbmc_project.Sensor.Type.ReadingBasisType.Zero")
+ {
+ return sensor::ReadingBasisType::Zero;
+ }
+
+ return sensor::ReadingBasisType::Invalid;
+}
+
+inline sensor::ImplementationType dBusSensorImplementationToRedfish(
+ const std::string& implementation)
+{
+ if (implementation ==
+ "xyz.openbmc_project.Sensor.Type.ImplementationType.Physical")
+ {
+ return sensor::ImplementationType::PhysicalSensor;
+ }
+ if (implementation ==
+ "xyz.openbmc_project.Sensor.Type.ImplementationType.Synthesized")
+ {
+ return sensor::ImplementationType::Synthesized;
+ }
+ if (implementation ==
+ "xyz.openbmc_project.Sensor.Type.ImplementationType.Reported")
+ {
+ return sensor::ImplementationType::Reported;
+ }
+
+ return sensor::ImplementationType::Invalid;
+}
+
/**
* @brief Builds a json sensor representation of a sensor.
* @param sensorName The name of the sensor to be built
@@ -474,9 +517,13 @@ inline void objectPropertiesToJson(
const bool* checkAvailable = nullptr;
bool available = true;
+ std::optional<std::string> readingBasis;
+ std::optional<std::string> implementation;
+
const bool success = sdbusplus::unpackPropertiesNoThrow(
dbus_utils::UnpackErrorPrinter(), propertiesDict, "Available",
- checkAvailable);
+ checkAvailable, "ReadingBasis", readingBasis, "Implementation",
+ implementation);
if (!success)
{
messages::internalError();
@@ -492,7 +539,7 @@ inline void objectPropertiesToJson(
if (chassisSubNode == ChassisSubNode::sensorsNode)
{
- sensorJson["@odata.type"] = "#Sensor.v1_2_0.Sensor";
+ sensorJson["@odata.type"] = "#Sensor.v1_11_0.Sensor";
sensor::ReadingType readingType =
sensors::toReadingType(sensorType);
@@ -516,6 +563,26 @@ inline void objectPropertiesToJson(
{
sensorJson["ReadingUnits"] = readingUnits;
}
+
+ if (readingBasis.has_value())
+ {
+ sensor::ReadingBasisType readingBasisOpt =
+ dBusSensorReadingBasisToRedfish(*readingBasis);
+ if (readingBasisOpt != sensor::ReadingBasisType::Invalid)
+ {
+ sensorJson["ReadingBasis"] = readingBasisOpt;
+ }
+ }
+
+ if (implementation.has_value())
+ {
+ sensor::ImplementationType implementationOpt =
+ dBusSensorImplementationToRedfish(*implementation);
+ if (implementationOpt != sensor::ImplementationType::Invalid)
+ {
+ sensorJson["Implementation"] = implementationOpt;
+ }
+ }
}
else if (sensorType == "temperature")
{