Matt Spinler | f1e85e2 | 2019-11-01 11:31:31 -0500 | [diff] [blame] | 1 | #include "pel_rules.hpp" |
| 2 | |
| 3 | #include "pel_types.hpp" |
| 4 | |
| 5 | #include <bitset> |
| 6 | |
| 7 | namespace openpower |
| 8 | { |
| 9 | namespace pels |
| 10 | { |
| 11 | namespace pel_rules |
| 12 | { |
| 13 | |
| 14 | std::tuple<uint16_t, uint8_t> check(uint16_t actionFlags, uint8_t eventType, |
| 15 | uint8_t severity) |
| 16 | { |
| 17 | std::bitset<16> newActionFlags{actionFlags}; |
| 18 | uint8_t newEventType = eventType; |
| 19 | auto sevType = static_cast<SeverityType>(severity & 0xF0); |
| 20 | |
| 21 | // TODO: This code covers the most common cases. The final tweaking |
| 22 | // will be done with ibm-openbmc/dev#1333. |
| 23 | |
| 24 | // Always report, unless specifically told not to |
| 25 | if (!newActionFlags.test(dontReportToHostFlagBit)) |
| 26 | { |
| 27 | newActionFlags.set(reportFlagBit); |
| 28 | } |
| 29 | else |
| 30 | { |
| 31 | newActionFlags.reset(reportFlagBit); |
| 32 | } |
| 33 | |
| 34 | // Call home by BMC not supported |
| 35 | newActionFlags.reset(spCallHomeFlagBit); |
| 36 | |
| 37 | switch (sevType) |
| 38 | { |
| 39 | case SeverityType::nonError: |
| 40 | { |
| 41 | // Informational errors never need service actions or call home. |
| 42 | newActionFlags.reset(serviceActionFlagBit); |
| 43 | newActionFlags.reset(callHomeFlagBit); |
| 44 | |
| 45 | // Ensure event type isn't 'not applicable' |
| 46 | if (newEventType == static_cast<uint8_t>(EventType::notApplicable)) |
| 47 | { |
| 48 | newEventType = |
| 49 | static_cast<uint8_t>(EventType::miscInformational); |
| 50 | } |
| 51 | |
| 52 | // The misc info and tracing event types are always hidden. |
| 53 | // For other event types, it's up to the creator. |
| 54 | if ((newEventType == |
| 55 | static_cast<uint8_t>(EventType::miscInformational)) || |
| 56 | (newEventType == static_cast<uint8_t>(EventType::tracing))) |
| 57 | { |
| 58 | newActionFlags.set(hiddenFlagBit); |
| 59 | } |
| 60 | break; |
| 61 | } |
| 62 | case SeverityType::recovered: |
| 63 | { |
| 64 | // Recovered errors are hidden, and by definition need no |
| 65 | // service action or call home. |
| 66 | newActionFlags.set(hiddenFlagBit); |
| 67 | newActionFlags.reset(serviceActionFlagBit); |
| 68 | newActionFlags.reset(callHomeFlagBit); |
| 69 | break; |
| 70 | } |
| 71 | case SeverityType::predictive: |
| 72 | case SeverityType::unrecoverable: |
| 73 | case SeverityType::critical: |
| 74 | case SeverityType::diagnostic: |
| 75 | case SeverityType::symptom: |
| 76 | { |
| 77 | // Report these others as normal errors. |
| 78 | newActionFlags.reset(hiddenFlagBit); |
| 79 | newActionFlags.set(serviceActionFlagBit); |
| 80 | newActionFlags.set(callHomeFlagBit); |
| 81 | break; |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | return {static_cast<uint16_t>(newActionFlags.to_ulong()), newEventType}; |
| 86 | } |
| 87 | |
| 88 | } // namespace pel_rules |
| 89 | } // namespace pels |
| 90 | } // namespace openpower |