summaryrefslogtreecommitdiffstats
path: root/fault-monitor/fru-fault-monitor.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'fault-monitor/fru-fault-monitor.hpp')
-rw-r--r--fault-monitor/fru-fault-monitor.hpp143
1 files changed, 143 insertions, 0 deletions
diff --git a/fault-monitor/fru-fault-monitor.hpp b/fault-monitor/fru-fault-monitor.hpp
new file mode 100644
index 0000000..8d5195d
--- /dev/null
+++ b/fault-monitor/fru-fault-monitor.hpp
@@ -0,0 +1,143 @@
+#pragma once
+
+#include <sdbusplus/bus.hpp>
+#include <sdbusplus/server.hpp>
+#include "config.h"
+
+namespace phosphor
+{
+namespace led
+{
+namespace fru
+{
+namespace fault
+{
+namespace monitor
+{
+
+/** @brief Assert or deassert an LED based on the input FRU
+ * @param[in] bus - The Dbus bus object
+ * @param[in] path - Inventory path of the FRU
+ * @param[in] assert - Assert if true deassert if false
+ */
+void action(sdbusplus::bus::bus& bus,
+ const std::string& path,
+ bool assert);
+
+class Remove;
+
+/** @class Add
+ * @brief Implementation of LED handling during FRU fault
+ * @details This implements methods for watching for a FRU fault
+ * being logged to assert the corresponding LED
+ */
+class Add
+{
+ public:
+ Add() = delete;
+ ~Add() = default;
+ Add(const Add&) = delete;
+ Add& operator=(const Add&) = delete;
+ Add(Add&&) = default;
+ Add& operator=(Add&&) = default;
+
+ /** @brief constructs Add a watch for FRU faults.
+ * @param[in] bus - The Dbus bus object
+ */
+ Add(sdbusplus::bus::bus& bus):
+ matchCreated(
+ bus,
+ "type='signal',"
+ "interface='org.freedesktop.DBus.ObjectManager',"
+ "member='InterfacesAdded',"
+ "path_namespace='/xyz/openbmc_project/logging'",
+ created,
+ this)
+ {
+ //Do nothing
+ }
+ private:
+
+ /** @brief sdbusplus signal match for fault created */
+ sdbusplus::server::match::match matchCreated;
+
+ std::vector<std::unique_ptr<Remove>> removeWatches;
+
+ /** @brief Callback function for fru fault created
+ * @param[in] msg - Data associated with subscribed signal
+ * @param[in] data - Pointer to this object instance
+ * @param[out] retError - Error returned
+ * @return zero on success and error code upon failure
+ */
+ static int created(sd_bus_message* msg,
+ void* data,
+ sd_bus_error* retError);
+};
+
+/** @class Remove
+ * @brief Implementation of LED handling after resolution of FRU fault
+ * @details Implement methods for watching the resolution of FRU faults
+ * and deasserting corresponding LED.
+ */
+class Remove
+{
+ public:
+ Remove() = delete;
+ ~Remove() = default;
+ Remove(const Remove&) = delete;
+ Remove& operator=(const Remove&) = delete;
+ Remove(Remove&&) = default;
+ Remove& operator=(Remove&&) = default;
+
+ /** @brief constructs Remove
+ * @param[in] bus - The Dbus bus object
+ * @param[in] path - Inventory path to fru
+ */
+ Remove(sdbusplus::bus::bus& bus, const std::string& path):
+ inventoryPath(path),
+ matchRemoved(
+ bus,
+ match(path).c_str(),
+ removed,
+ this)
+ {
+ //Do nothing
+ }
+
+ private:
+
+ /** @brief inventory path of the FRU */
+ std::string inventoryPath;
+
+ /** @brief sdbusplus signal matches for fault removed */
+ sdbusplus::server::match::match matchRemoved;
+
+ /** @brief Callback function for fru fault created
+ * @param[in] msg - Data associated with subscribed signal
+ * @param[in] data - Pointer to this object instance
+ * @param[out] retError - Error returned
+ * @return zero on success and error code upon failure
+ */
+ static int removed(sd_bus_message* msg,
+ void* data,
+ sd_bus_error* retError);
+
+ /** @brief function to create fault remove match for a fru
+ * @param[in] path - Inventory path of the faulty unit.
+ */
+ std::string match(const std::string& path)
+ {
+ std::string matchStmt =
+ "type='signal',"
+ "interface='org.freedesktop.DBus.Properties',"
+ "member='PropertiesChanged',"
+ "path='" + path +
+ "/" + CALLOUT_REV_ASSOCIATION + "'";
+ return matchStmt;
+ }
+};
+}//namespace monitor
+}//namespace fault
+}//namespace fru
+}//namespace led
+}//namespace phosphor
OpenPOWER on IntegriCloud