nvmes: add Availability interface
Add Availability interface.
When PwrGoodPin is low, Set Available property to false to indicate
this sensor is currently unavilable due to power loss.
Tested on Bletchley:
- PwrGoodPin is low
root@bletchley:~# busctl introspect xyz.openbmc_project.nvme.manager \
> /xyz/openbmc_project/sensors/temperature/nvme6 \
> xyz.openbmc_project.Sensor.Value
NAME TYPE SIGNATURE RESULT/VALUE FLAGS
.MaxValue property d 127 emits-change writable
.MinValue property d -127 emits-change writable
.Unit property s "xyz.openbmc_project.Sensor.Value.Uni... emits-change writable
.Value property d -127 emits-change writable
root@bletchley:~# busctl introspect xyz.openbmc_project.nvme.manager \
> /xyz/openbmc_project/sensors/temperature/nvme6 \
> xyz.openbmc_project.State.Decorator.Availability
NAME TYPE SIGNATURE RESULT/VALUE FLAGS
.Available property b false emits-change writable
- PwrGoodPin is high
root@bletchley:~# busctl introspect xyz.openbmc_project.nvme.manager \
> /xyz/openbmc_project/sensors/temperature/nvme6 \
> xyz.openbmc_project.Sensor.Value
NAME TYPE SIGNATURE RESULT/VALUE FLAGS
.MaxValue property d 127 emits-change writable
.MinValue property d -127 emits-change writable
.Unit property s "xyz.openbmc_project.Sensor.Value.Uni... emits-change writable
.Value property d 33 emits-change writable
root@bletchley:~# busctl introspect xyz.openbmc_project.nvme.manager \
> /xyz/openbmc_project/sensors/temperature/nvme6 \
> xyz.openbmc_project.State.Decorator.Availability
NAME TYPE SIGNATURE RESULT/VALUE FLAGS
.Available property b true emits-change writable
Signed-off-by: Potin Lai <potin.lai@quantatw.com>
Change-Id: I0b621ae619dde85607c635912c7230bbe9de22ac
diff --git a/nvmes.hpp b/nvmes.hpp
index e11c891..92dfc6f 100644
--- a/nvmes.hpp
+++ b/nvmes.hpp
@@ -4,6 +4,7 @@
#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>
+#include <xyz/openbmc_project/State/Decorator/Availability/server.hpp>
namespace phosphor
{
@@ -18,8 +19,12 @@
using WarningInterface =
sdbusplus::xyz::openbmc_project::Sensor::Threshold::server::Warning;
-using NvmeIfaces = sdbusplus::server::object_t<ValueIface, CriticalInterface,
- WarningInterface>;
+using AvailabilityInterface =
+ sdbusplus::xyz::openbmc_project::State::Decorator::server::Availability;
+
+using NvmeIfaces =
+ sdbusplus::server::object_t<ValueIface, CriticalInterface, WarningInterface,
+ AvailabilityInterface>;
class NvmeSSD : public NvmeIfaces
{
@@ -51,6 +56,8 @@
int8_t warningHigh, int8_t warningLow);
/** @brief Set Sensor Max/Min value to D-bus at beginning */
void setSensorMaxMin(int8_t maxValue, int8_t minValue);
+ /** @brief Set Sensor Availability to D-bus */
+ void setSensorAvailability(bool avail);
private:
sdbusplus::bus_t& bus;