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/nvme_manager.cpp b/nvme_manager.cpp
index cdb76b1..51b0f7d 100644
--- a/nvme_manager.cpp
+++ b/nvme_manager.cpp
@@ -617,6 +617,7 @@
: IS_PRESENT;
auto pwrGoodPinValStr =
(config.pwrGoodPin) ? getGPIOValueOfNvme(devPwrGoodPath) : POWERGD;
+ const bool isPwrGood = (pwrGoodPinValStr == POWERGD);
if (presentPinValStr != IS_PRESENT)
{
@@ -636,7 +637,7 @@
continue;
}
- if (pwrGoodPinValStr != POWERGD)
+ if (!isPwrGood)
{
// IFDET should be used to provide the final say
// in SSD's presence - IFDET showing SSD is present
@@ -672,6 +673,7 @@
// (To make thermal loop know that the sensor reading
// is invalid).
readNvmeData(config);
+ nvmes.find(config.index)->second->setSensorAvailability(isPwrGood);
}
}
} // namespace nvme
diff --git a/nvmes.cpp b/nvmes.cpp
index 7bd8c6c..2310610 100644
--- a/nvmes.cpp
+++ b/nvmes.cpp
@@ -100,5 +100,10 @@
ValueIface::value(value);
}
+void NvmeSSD::setSensorAvailability(bool avail)
+{
+ AvailabilityInterface::available(avail);
+}
+
} // namespace nvme
} // namespace phosphor
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;