Translating ME Health Sensor Platform Events to Redfish Events

Following code implements parsing logic for all ME Health Sensor Platform
Events. It is built in similar manner to existing implementation of
BIOS SEL events parsing and follows the same principles:
- try to parse event, store id and params as Redfish Event on success,
- if event is unparsable - store raw IPMI frame as generic SEL event.

As there exists many events which would share exactly the same parsing
logic, some higher level function (genericMessageHook) and some helper
functions were introduced. Idea of this is that for events which are
easily parsable (like mapping byte to concrete event) should be handled
by metadata-driven algorithm. For more complex events ability to specify
lower-level parser methods was introduced.

In general flow looks like the following:
1) event is recognized as originating from ME, me::messageHook is called
2) event comes from me::HealthSensor, health_event::messageHook is called
3) based on Platform Event offset byte either fw_status or smbus_failure
   event messageHook is called
4a) for smbus_failure : simple function called

.....

4b) for fw_status: map is used, deciding further processing based on
    event.eventData2
5) map[event.eventData2] contains : MessageId and instructions on further
   processing. It might be:
   a) empty - no extra processing,
   b) map - maps eventData3 to string value and adds it to MessageParams,
   b) function - specialized parsing routines for given eventData2.

Testing:
- injected all possible events with busctl call (faking ME)
- tested on actual platform with manually triggered events by actual ME

Signed-off-by: Agnieszka Szlendak <Agnieszka.Szlendak@intel.com>
Change-Id: Ib13e4ace10b6382ea0800d34241e98a73b6626b3
diff --git a/src/ipmi_to_redfish_hooks.cpp b/src/ipmi_to_redfish_hooks.cpp
index ca71dfa..9cac813 100644
--- a/src/ipmi_to_redfish_hooks.cpp
+++ b/src/ipmi_to_redfish_hooks.cpp
@@ -14,11 +14,10 @@
 // limitations under the License.
 */
 
-#include <boost/algorithm/string/join.hpp>
 #include <boost/beast/core/span.hpp>
 #include <iomanip>
 #include <ipmi_to_redfish_hooks.hpp>
-#include <phosphor-logging/log.hpp>
+#include <me_to_redfish_hooks.hpp>
 #include <sstream>
 #include <storagecommands.hpp>
 #include <string_view>
@@ -40,29 +39,6 @@
     hexStr = stream.str();
 }
 
-static bool defaultMessageHook(const std::string& ipmiRaw)
-{
-    // Log the record as a default Redfish message instead of a SEL record
-
-    static const std::string openBMCMessageRegistryVersion("0.1");
-    std::string messageID =
-        "OpenBMC." + openBMCMessageRegistryVersion + ".SELEntryAdded";
-
-    std::vector<std::string> messageArgs;
-    messageArgs.push_back(ipmiRaw);
-
-    // Log the Redfish message to the journal with the appropriate metadata
-    std::string journalMsg = "SEL Entry Added: " + ipmiRaw;
-    std::string messageArgsString = boost::algorithm::join(messageArgs, ",");
-    phosphor::logging::log<phosphor::logging::level::INFO>(
-        journalMsg.c_str(),
-        phosphor::logging::entry("REDFISH_MESSAGE_ID=%s", messageID.c_str()),
-        phosphor::logging::entry("REDFISH_MESSAGE_ARGS=%s",
-                                 messageArgsString.c_str()));
-
-    return true;
-}
-
 // Record a BIOS message as a Redfish message instead of a SEL record
 static bool biosMessageHook(const SELData& selData, const std::string& ipmiRaw)
 {
@@ -867,6 +843,10 @@
             // Let the BIOS SMI hook handle this request
             return biosSMIMessageHook(selData, ipmiRaw);
             break;
+
+        case 0x2C: // Message from Intel ME
+            return me::messageHook(selData, ipmiRaw);
+            break;
     }
 
     // No hooks handled the request, so let it go to default