Sensor mutability interface
We proposed a ValueMutablity interface in
openbmc/phosphor-dbus-interfaces which was accepted here:
https://gerrit.openbmc-project.xyz/c/openbmc/phosphor-dbus-interfaces/+/36333
It follows the IPMI fashion, checking
the sensor mutability before writing sensor values. The sensor
mutability used to be hardcoded in the ipmi sensor map yaml file.
This provides feature parity with that old YAML hardcoded
"mutability: Mutability::Write|Mutability::Read" setting.
As an example of implementation within dbus-sensors, ExternalSensor
always sets Mutable to true, given its purpose of accepting sensor
writes from an external source. PwmSensor accepts the "Mutable"
parameter, from entity-manager configuration (aka JSON file). All
other sensors always set Mutable to false, but it would be
straightforward to add similar code, like what was done for
PwmSensor, when mutability is desired.
This parameter will be used by the IPMI server here:
https://gerrit.openbmc-project.xyz/c/openbmc/phosphor-host-ipmid/+/45407
There is currently no Redfish equivalent, although that would
be a welcome task for the future. This is not IPMI-specific,
as the Redfish server can also use this as a hint, as to whether
to allow read-write access, or merely to allow read-only access.
This is not to be confused with the "manufacturing mode" option, which
is designed for use during manufacturing test, hence its name. This
feature is designed for production, and is intended to allow just a
few sensors to be writable, without needing to make them all writable.
Tested:
DBus call on fan sensors with configurable tree mutability:
busctl introspect xyz.openbmc_project.FanSensor /xyz/openbmc_project/sensors/fan_pwm/fan0
NAME TYPE SIGNATURE RESULT/VALUE FLAGS
...
xyz.openbmc_project.Sensor.Value interface - - -
.MaxValue property x 100 emits-change
.MinValue property x 0 emits-change
.Unit property s "xyz.openbmc_project.Sensor.Value.Uni... emits-change
.Value property d 42.7451 emits-change writable
xyz.openbmc_project.Sensor.ValueMutability interface - - -
.Mutable property b true emits-change
...
DBus call on external sensors:
busctl introspect xyz.openbmc_project.ExternalSensor /xyz/openbmc_project/sensors/tempera
NAME TYPE SIGNATURE RESULT/VALUE FLAGS
...
xyz.openbmc_project.Sensor.Value interface - - -
.MaxValue property d 127 emits-change
.MinValue property d -128 emits-change
.Unit property s "DegreesC" emits-change
.Value property d nan emits-change writable
xyz.openbmc_project.Sensor.ValueMutability interface - - -
.Mutable property b true emits-change
...
The ValueMutability interface, with "Mutable", is correctly created.
Signed-off-by: Jie Yang <jjy@google.com>
Change-Id: Ifa1cb51bb55cd6f00d2a2f79e9064d1a51354b06
Signed-off-by: Josh Lehan <krellan@google.com>
diff --git a/include/PwmSensor.hpp b/include/PwmSensor.hpp
index d78b8e9..2c8ebe6 100644
--- a/include/PwmSensor.hpp
+++ b/include/PwmSensor.hpp
@@ -13,7 +13,7 @@
std::shared_ptr<sdbusplus::asio::connection>& conn,
sdbusplus::asio::object_server& objectServer,
const std::string& sensorConfiguration,
- const std::string& sensorType);
+ const std::string& sensorType, bool isValueMutable = false);
~PwmSensor();
private:
@@ -23,6 +23,7 @@
std::shared_ptr<sdbusplus::asio::dbus_interface> sensorInterface;
std::shared_ptr<sdbusplus::asio::dbus_interface> controlInterface;
std::shared_ptr<sdbusplus::asio::dbus_interface> association;
+ std::shared_ptr<sdbusplus::asio::dbus_interface> valueMutabilityInterface;
double pwmMax;
void setValue(uint32_t value);
uint32_t getValue(bool errThrow = true);