summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDhruvaraj Subhashchandran <dhruvaraj@in.ibm.com>2017-04-13 00:19:44 -0500
committerPatrick Williams <patrick@stwcx.xyz>2017-05-23 11:02:40 +0000
commit59b86cd72075cab98470a02267c78c6e361ba11c (patch)
tree7e2bdb3dfd515f3e02eacc96319dfb8a4020b31d
parentcd569d24cd46e0d6a68654b979b1ddd00bc86cd8 (diff)
downloadphosphor-led-manager-59b86cd72075cab98470a02267c78c6e361ba11c.zip
phosphor-led-manager-59b86cd72075cab98470a02267c78c6e361ba11c.tar.gz
Add class and stub for fru fault monitor application
This application waits for new fault entries and resolution of exiting faults to assert or deassert LED for the corresponding FRUs, respectively. Change-Id: I92ead0c8d3132dd7a6740b536231d6588ac42471 Signed-off-by: Dhruvaraj Subhashchandran <dhruvaraj@in.ibm.com>
-rw-r--r--Makefile.am2
-rw-r--r--configure.ac5
-rw-r--r--fault-monitor/Makefile.am17
-rw-r--r--fault-monitor/fru-fault-monitor.cpp38
-rw-r--r--fault-monitor/fru-fault-monitor.hpp143
-rw-r--r--fault-monitor/monitor-main.cpp17
6 files changed, 220 insertions, 2 deletions
diff --git a/Makefile.am b/Makefile.am
index 75888f6..1d35716 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -19,4 +19,4 @@ phosphor_ledmanager_CFLAGS = $(SDBUSPLUS_CFLAGS) \
$(PHOSPHOR_LOGGING_CFLAGS) \
$(PHOSPHOR_DBUS_INTERFACES_CFLAGS)
-SUBDIRS = test
+SUBDIRS = test fault-monitor
diff --git a/configure.ac b/configure.ac
index 8cac302..c0fc04a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -61,6 +61,9 @@ AS_IF([test "x$YAML_PATH" == "x"], [YAML_PATH="$srcdir"])
LEDGEN="$PYTHON $srcdir/parse_led.py -i $YAML_PATH"
AC_SUBST(LEDGEN)
+AC_DEFINE(CALLOUT_FWD_ASSOCIATION, "callout", [The name of the callout's forward association.])
+AC_DEFINE(CALLOUT_REV_ASSOCIATION, "fault", [The name of the callout's reverse association.])
+
# Create configured output
-AC_CONFIG_FILES([Makefile test/Makefile])
+AC_CONFIG_FILES([Makefile test/Makefile fault-monitor/Makefile])
AC_OUTPUT
diff --git a/fault-monitor/Makefile.am b/fault-monitor/Makefile.am
new file mode 100644
index 0000000..ba7603f
--- /dev/null
+++ b/fault-monitor/Makefile.am
@@ -0,0 +1,17 @@
+AM_DEFAULT_SOURCE_EXT = .cpp
+AM_CPPFLAGS = -I$(top_srcdir)
+
+noinst_HEADERS = fru-fault-monitor.hpp
+
+sbin_PROGRAMS = phosphor-fru-fault-monitor
+
+phosphor_fru_fault_monitor_SOURCES = \
+ fru-fault-monitor.cpp \
+ monitor-main.cpp
+
+phosphor_fru_fault_monitor_LDFLAGS = $(SDBUSPLUS_LIBS) \
+ $(PHOSPHOR_LOGGING_LIBS) \
+ $(PHOSPHOR_DBUS_INTERFACES_LIBS)
+phosphor_fru_fault_monitor_CFLAGS = $(SDBUSPLUS_CFLAGS) \
+ $(PHOSPHOR_LOGGING_CFLAGS) \
+ $(PHOSPHOR_DBUS_INTERFACES_CFLAGS)
diff --git a/fault-monitor/fru-fault-monitor.cpp b/fault-monitor/fru-fault-monitor.cpp
new file mode 100644
index 0000000..1213128
--- /dev/null
+++ b/fault-monitor/fru-fault-monitor.cpp
@@ -0,0 +1,38 @@
+#include "fru-fault-monitor.hpp"
+namespace phosphor
+{
+namespace led
+{
+namespace fru
+{
+namespace fault
+{
+namespace monitor
+{
+
+void action(sdbusplus::bus::bus& bus,
+ const std::string& unit,
+ bool assert)
+{
+ return;
+}
+
+int Add::created(sd_bus_message* msg,
+ void* data,
+ sd_bus_error* retError)
+{
+ return 0;
+}
+
+int Remove::removed(sd_bus_message* msg,
+ void* data,
+ sd_bus_error* retError)
+{
+ return 0;
+}
+
+}//namespace monitor
+}//namespace fault
+}//namespace fru
+}//namespace led
+}//namespace phosphor
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
diff --git a/fault-monitor/monitor-main.cpp b/fault-monitor/monitor-main.cpp
new file mode 100644
index 0000000..0b4a5fb
--- /dev/null
+++ b/fault-monitor/monitor-main.cpp
@@ -0,0 +1,17 @@
+#include "fru-fault-monitor.hpp"
+
+int main(void)
+{
+ /** @brief Dbus constructs used by Fault Monitor */
+ sdbusplus::bus::bus bus = sdbusplus::bus::new_default();
+
+ phosphor::led::fru::fault::monitor::Add monitor(bus);
+ /** @brief Wait for client requests */
+ while (true)
+ {
+ /** @brief process dbus calls / signals discarding unhandled */
+ bus.process_discard();
+ bus.wait();
+ }
+ return 0;
+}
OpenPOWER on IntegriCloud