summaryrefslogtreecommitdiffstats
path: root/extensions/openpower-pels/host_notifier.hpp
diff options
context:
space:
mode:
authorMatt Spinler <spinler@us.ibm.com>2019-12-11 13:47:50 -0600
committerMatt Spinler <spinler@us.ibm.com>2020-01-27 08:06:26 -0600
commitf60ac27e3ee4aa7166065db93a3fc0ae2d9481ac (patch)
tree5c293bb43577cac4458a3a7a4e39b3fb6084ceab /extensions/openpower-pels/host_notifier.hpp
parent99196688997f16d1611229e007a443d7e1a9f760 (diff)
downloadphosphor-logging-f60ac27e3ee4aa7166065db93a3fc0ae2d9481ac.tar.gz
phosphor-logging-f60ac27e3ee4aa7166065db93a3fc0ae2d9481ac.zip
PEL: Add HostNotifier class
This class will watch for new PELs being created, and handle sending them up to the host. This first commit for this class mostly just fills in the constructor to set up the various callbacks it will use. It is only instantiated in the Manager class if the Manager constructor used is the one that passes in the HostInterface object, to allow for configurations that don't need PELs passed up. Signed-off-by: Matt Spinler <spinler@us.ibm.com> Change-Id: I0ddcf94d047979eb78209d396c2351566c634dbe
Diffstat (limited to 'extensions/openpower-pels/host_notifier.hpp')
-rw-r--r--extensions/openpower-pels/host_notifier.hpp125
1 files changed, 125 insertions, 0 deletions
diff --git a/extensions/openpower-pels/host_notifier.hpp b/extensions/openpower-pels/host_notifier.hpp
new file mode 100644
index 0000000..ee1ba0c
--- /dev/null
+++ b/extensions/openpower-pels/host_notifier.hpp
@@ -0,0 +1,125 @@
+#pragma once
+
+#include "host_interface.hpp"
+#include "pel.hpp"
+#include "repository.hpp"
+
+#include <deque>
+
+namespace openpower::pels
+{
+
+/**
+ * @class HostNotifier
+ *
+ * This class handles notifying the host firmware of new PELs.
+ */
+class HostNotifier
+{
+ public:
+ HostNotifier() = delete;
+ HostNotifier(const HostNotifier&) = delete;
+ HostNotifier& operator=(const HostNotifier&) = delete;
+ HostNotifier(HostNotifier&&) = delete;
+ HostNotifier& operator=(HostNotifier&&) = delete;
+
+ /**
+ * @brief Constructor
+ *
+ * @param[in] repo - The PEL repository object
+ * @param[in] dataIface - The data interface object
+ * @param[in] hostIface - The host interface object
+ */
+ HostNotifier(Repository& repo, DataInterfaceBase& dataIface,
+ std::unique_ptr<HostInterface> hostIface);
+
+ /**
+ * @brief Destructor
+ */
+ ~HostNotifier();
+
+ /**
+ * @brief Returns the PEL queue size.
+ *
+ * For testing.
+ *
+ * @return size_t - The queue size
+ */
+ size_t queueSize() const
+ {
+ return _pelQueue.size();
+ }
+
+ /**
+ * @brief Specifies if the PEL needs to go onto the queue to be
+ * set to the host.
+ *
+ * @param[in] id - The PEL ID
+ *
+ * @return bool - If enqueue is required
+ */
+ bool enqueueRequired(uint32_t id) const;
+
+ private:
+ /**
+ * @brief This function gets called by the Repository class
+ * when a new PEL is added to it.
+ *
+ * @param[in] pel - The new PEL
+ */
+ void newLogCallback(const PEL& pel);
+
+ /**
+ * @brief This function runs on every existing PEL at startup
+ * and puts the PEL on the queue to send if necessary.
+ *
+ * @param[in] pel - The PEL
+ *
+ * @return bool - This is an indicator to the Repository::for_each
+ * function to traverse every PEL. Always false.
+ */
+ bool addPELToQueue(const PEL& pel);
+
+ /**
+ * @brief Takes the PEL off the front of the queue and issues
+ * the PLDM send.
+ */
+ void doNewLogNotify();
+
+ /**
+ * @brief Called when the host changes state.
+ *
+ * @param[in] hostUp - The new host state
+ */
+ void hostStateChange(bool hostUp);
+
+ /**
+ * @brief The callback function invoked after the asynchronous
+ * PLDM receive function is complete.
+ *
+ * @param[in] status - The response status
+ */
+ void commandResponse(ResponseStatus status);
+
+ /**
+ * @brief The PEL repository object
+ */
+ Repository& _repo;
+
+ /**
+ * @brief The data interface object
+ */
+ DataInterfaceBase& _dataIface;
+
+ /**
+ * @brief Base class pointer for the host command interface
+ */
+ std::unique_ptr<HostInterface> _hostIface;
+
+ /**
+ * @brief The list of PEL IDs that need to be sent.
+ */
+ std::deque<uint32_t> _pelQueue;
+};
+
+} // namespace openpower::pels
OpenPOWER on IntegriCloud