PEL: Print host trans state in peltool
In the UserHeader section, add an entry into peltool's JSON
output for the host transmission state.
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: Ie906a447859e30175652d291ef2f929e8a7077f6
diff --git a/.gitignore b/.gitignore
index 5a6dc5b..be5d9e2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -43,3 +43,4 @@
test/*_test_*
test/*_test
phosphor-rsyslog-config/phosphor-rsyslog-conf
+peltool
diff --git a/extensions/openpower-pels/pel_values.cpp b/extensions/openpower-pels/pel_values.cpp
index f8c877c..cb00150 100644
--- a/extensions/openpower-pels/pel_values.cpp
+++ b/extensions/openpower-pels/pel_values.cpp
@@ -265,6 +265,15 @@
{"S", "SLIC"}, {"B", "Hostboot"}, {"T", "OCC"}, {"M", "I/O Drawer"},
{"K", "Sapphire"}, {"P", "PowerNV"}};
+/**
+ * @brief Map for transmission states
+ */
+const std::map<TransmissionState, std::string> transmissionStates = {
+ {TransmissionState::newPEL, "Not Sent"},
+ {TransmissionState::badPEL, "Rejected"},
+ {TransmissionState::sent, "Sent"},
+ {TransmissionState::acked, "Acked"}};
+
std::string getValue(const uint8_t field, const pel_values::PELValues& values)
{
diff --git a/extensions/openpower-pels/pel_values.hpp b/extensions/openpower-pels/pel_values.hpp
index 9a1ed88..a52c8b3 100644
--- a/extensions/openpower-pels/pel_values.hpp
+++ b/extensions/openpower-pels/pel_values.hpp
@@ -1,5 +1,7 @@
#pragma once
+#include "pel_types.hpp"
+
#include <map>
#include <string>
#include <tuple>
@@ -105,6 +107,11 @@
*/
extern const std::map<std::string, std::string> creatorIDs;
+/**
+ * @brief Map for transmission states
+ */
+extern const std::map<TransmissionState, std::string> transmissionStates;
+
} // namespace pel_values
} // namespace pels
} // namespace openpower
diff --git a/extensions/openpower-pels/user_header.cpp b/extensions/openpower-pels/user_header.cpp
index b70da94..e29ffdf 100644
--- a/extensions/openpower-pels/user_header.cpp
+++ b/extensions/openpower-pels/user_header.cpp
@@ -143,6 +143,15 @@
eventType = pv::getValue(_eventType, pel_values::eventTypeValues);
actionFlags =
pv::getValuesBitwise(_actionFlags, pel_values::actionFlagsValues);
+
+ std::string hostState{"Invalid"};
+ auto iter = pv::transmissionStates.find(
+ static_cast<TransmissionState>(hostTransmissionState()));
+ if (iter != pv::transmissionStates.end())
+ {
+ hostState = iter->second;
+ }
+
char tmpUhVal[8];
sprintf(tmpUhVal, "%d", userHeaderVersion);
std::string uhVerStr(tmpUhVal);
@@ -160,6 +169,7 @@
jsonInsert(uh, "Event Severity", severity, 1);
jsonInsert(uh, "Event Type", eventType, 1);
jsonInsertArray(uh, "Action Flags", actionFlags, 1);
+ jsonInsert(uh, "Host Transmission", hostState, 1);
uh.erase(uh.size() - 2);
return uh;
}