summaryrefslogtreecommitdiffstats
path: root/extensions/openpower-pels/pel_rules.cpp
blob: be5e5a21e6ffdb2b236e0de6db8c5eaa829d6787 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include "pel_rules.hpp"

#include "pel_types.hpp"

#include <bitset>

namespace openpower
{
namespace pels
{
namespace pel_rules
{

std::tuple<uint16_t, uint8_t> check(uint16_t actionFlags, uint8_t eventType,
                                    uint8_t severity)
{
    std::bitset<16> newActionFlags{actionFlags};
    uint8_t newEventType = eventType;
    auto sevType = static_cast<SeverityType>(severity & 0xF0);

    // TODO: This code covers the most common cases.  The final tweaking
    // will be done with ibm-openbmc/dev#1333.

    // Always report, unless specifically told not to
    if (!newActionFlags.test(dontReportToHostFlagBit))
    {
        newActionFlags.set(reportFlagBit);
    }
    else
    {
        newActionFlags.reset(reportFlagBit);
    }

    // Call home by BMC not supported
    newActionFlags.reset(spCallHomeFlagBit);

    switch (sevType)
    {
        case SeverityType::nonError:
        {
            // Informational errors never need service actions or call home.
            newActionFlags.reset(serviceActionFlagBit);
            newActionFlags.reset(callHomeFlagBit);

            // Ensure event type isn't 'not applicable'
            if (newEventType == static_cast<uint8_t>(EventType::notApplicable))
            {
                newEventType =
                    static_cast<uint8_t>(EventType::miscInformational);
            }

            // The misc info and tracing event types are always hidden.
            // For other event types, it's up to the creator.
            if ((newEventType ==
                 static_cast<uint8_t>(EventType::miscInformational)) ||
                (newEventType == static_cast<uint8_t>(EventType::tracing)))
            {
                newActionFlags.set(hiddenFlagBit);
            }
            break;
        }
        case SeverityType::recovered:
        {
            // Recovered errors are hidden, and by definition need no
            // service action or call home.
            newActionFlags.set(hiddenFlagBit);
            newActionFlags.reset(serviceActionFlagBit);
            newActionFlags.reset(callHomeFlagBit);
            break;
        }
        case SeverityType::predictive:
        case SeverityType::unrecoverable:
        case SeverityType::critical:
        case SeverityType::diagnostic:
        case SeverityType::symptom:
        {
            // Report these others as normal errors.
            newActionFlags.reset(hiddenFlagBit);
            newActionFlags.set(serviceActionFlagBit);
            newActionFlags.set(callHomeFlagBit);
            break;
        }
    }

    return {static_cast<uint16_t>(newActionFlags.to_ulong()), newEventType};
}

} // namespace pel_rules
} // namespace pels
} // namespace openpower
OpenPOWER on IntegriCloud