| Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 1 | #pragma once | 
|  | 2 |  | 
| Zane Shelley | 9980d48 | 2022-01-28 15:21:47 -0600 | [diff] [blame] | 3 | #include <map> | 
| Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 4 | #include <string> | 
|  | 5 |  | 
|  | 6 | namespace analyzer | 
|  | 7 | { | 
|  | 8 |  | 
|  | 9 | namespace callout | 
|  | 10 | { | 
|  | 11 |  | 
|  | 12 | /** @brief All callouts will have a priority indicating when to issue the | 
|  | 13 | *         required service action. */ | 
| Zane Shelley | 9980d48 | 2022-01-28 15:21:47 -0600 | [diff] [blame] | 14 | enum class Priority | 
| Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 15 | { | 
| Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 16 | /** Serivce is mandatory. */ | 
| Zane Shelley | 9980d48 | 2022-01-28 15:21:47 -0600 | [diff] [blame] | 17 | HIGH, | 
| Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 18 |  | 
|  | 19 | /** Serivce medium priority callouts one at a time, in order, until the | 
|  | 20 | *  issue is resolved. */ | 
| Zane Shelley | 9980d48 | 2022-01-28 15:21:47 -0600 | [diff] [blame] | 21 | MED, | 
| Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 22 |  | 
|  | 23 | /** Same as MED, except replace all A's as a group. */ | 
| Zane Shelley | 9980d48 | 2022-01-28 15:21:47 -0600 | [diff] [blame] | 24 | MED_A, | 
| Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 25 |  | 
| Zane Shelley | 9980d48 | 2022-01-28 15:21:47 -0600 | [diff] [blame] | 26 | /** Same as MED, except replace all B's as a group. */ | 
|  | 27 | MED_B, | 
| Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 28 |  | 
| Zane Shelley | 9980d48 | 2022-01-28 15:21:47 -0600 | [diff] [blame] | 29 | /** Same as MED, except replace all C's as a group. */ | 
|  | 30 | MED_C, | 
| Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 31 |  | 
|  | 32 | /** If servicing all high and medium priority callouts did not resolve | 
|  | 33 | *  the issue, service low priority callouts one at a time, in order, | 
|  | 34 | *  until the issue is resolved. */ | 
| Zane Shelley | 9980d48 | 2022-01-28 15:21:47 -0600 | [diff] [blame] | 35 | LOW, | 
| Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 36 | }; | 
|  | 37 |  | 
| Zane Shelley | 9980d48 | 2022-01-28 15:21:47 -0600 | [diff] [blame] | 38 | /** @return The string representation of the priority used in callouts. */ | 
|  | 39 | inline std::string getString(Priority i_priority) | 
|  | 40 | { | 
|  | 41 | // clang-format off | 
|  | 42 | static const std::map<Priority, std::string> m = | 
|  | 43 | { | 
|  | 44 | {Priority::HIGH,  "H"}, | 
|  | 45 | {Priority::MED,   "M"}, | 
|  | 46 | {Priority::MED_A, "A"}, | 
|  | 47 | {Priority::MED_B, "B"}, | 
|  | 48 | {Priority::MED_C, "C"}, | 
|  | 49 | {Priority::LOW,   "L"}, | 
|  | 50 | }; | 
|  | 51 | // clang-format on | 
|  | 52 |  | 
|  | 53 | return m.at(i_priority); | 
|  | 54 | } | 
|  | 55 |  | 
|  | 56 | /** @return The string representation of the priority used in The callout FFDC. | 
|  | 57 | */ | 
|  | 58 | inline std::string getStringFFDC(Priority i_priority) | 
|  | 59 | { | 
|  | 60 | // clang-format off | 
|  | 61 | static const std::map<Priority, std::string> m = | 
|  | 62 | { | 
|  | 63 | {Priority::HIGH,  "high"}, | 
|  | 64 | {Priority::MED,   "medium"}, | 
|  | 65 | {Priority::MED_A, "medium_group_A"}, | 
|  | 66 | {Priority::MED_B, "medium_group_B"}, | 
|  | 67 | {Priority::MED_C, "medium_group_C"}, | 
|  | 68 | {Priority::LOW,   "low"}, | 
|  | 69 | }; | 
|  | 70 | // clang-format on | 
|  | 71 |  | 
|  | 72 | return m.at(i_priority); | 
|  | 73 | } | 
| Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 74 |  | 
| Zane Shelley | 55e7fec | 2022-01-28 15:29:44 -0600 | [diff] [blame] | 75 | /** These SRC subsystem values are defined by the PEL spec. */ | 
|  | 76 | enum class SrcSubsystem | 
|  | 77 | { | 
|  | 78 | // Can also reference `extensions/openpower-pels/pel_values.cpp` from | 
|  | 79 | // `openbmc/phosphor-logging` for the full list of these values. | 
|  | 80 |  | 
|  | 81 | PROCESSOR      = 0x10, | 
|  | 82 | PROCESSOR_UNIT = 0x13, | 
|  | 83 | PROCESSOR_BUS  = 0x14, | 
|  | 84 |  | 
|  | 85 | MEMORY      = 0x20, | 
|  | 86 | MEMORY_BUS  = 0x22, | 
|  | 87 | MEMORY_DIMM = 0x23, | 
|  | 88 |  | 
|  | 89 | PHB = 0x38, | 
|  | 90 |  | 
|  | 91 | CEC_HARDWARE = 0x50, | 
|  | 92 | CEC_CLOCKS   = 0x58, | 
|  | 93 | CEC_TOD      = 0x5A, | 
|  | 94 |  | 
|  | 95 | OTHERS = 0x70, | 
|  | 96 | }; | 
|  | 97 |  | 
| Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 98 | /** @brief Container class for procedure callout service actions. */ | 
|  | 99 | class Procedure | 
|  | 100 | { | 
|  | 101 | public: | 
|  | 102 | /** Contact next level support. */ | 
|  | 103 | static const Procedure NEXTLVL; | 
|  | 104 |  | 
|  | 105 | private: | 
|  | 106 | /** | 
|  | 107 | * @brief Constructor from components. | 
|  | 108 | * @param i_string The string representation of the procedure used for | 
|  | 109 | *                 callouts. | 
|  | 110 | */ | 
| Zane Shelley | 55e7fec | 2022-01-28 15:29:44 -0600 | [diff] [blame] | 111 | Procedure(const std::string& i_string, const SrcSubsystem i_subsystem) : | 
|  | 112 | iv_string(i_string), iv_subsystem(i_subsystem) | 
|  | 113 | {} | 
| Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 114 |  | 
|  | 115 | private: | 
|  | 116 | /** The string representation of the procedure used for callouts. */ | 
|  | 117 | const std::string iv_string; | 
|  | 118 |  | 
| Zane Shelley | 55e7fec | 2022-01-28 15:29:44 -0600 | [diff] [blame] | 119 | /** The associated SRC subsystem of the procedure. */ | 
|  | 120 | const SrcSubsystem iv_subsystem; | 
|  | 121 |  | 
| Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 122 | public: | 
|  | 123 | /** iv_string accessor */ | 
|  | 124 | std::string getString() const | 
|  | 125 | { | 
|  | 126 | return iv_string; | 
|  | 127 | } | 
| Zane Shelley | 55e7fec | 2022-01-28 15:29:44 -0600 | [diff] [blame] | 128 |  | 
|  | 129 | /** iv_subsystem accessor */ | 
|  | 130 | SrcSubsystem getSrcSubsystem() const | 
|  | 131 | { | 
|  | 132 | return iv_subsystem; | 
|  | 133 | } | 
| Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 134 | }; | 
|  | 135 |  | 
| Zane Shelley | 55e7fec | 2022-01-28 15:29:44 -0600 | [diff] [blame] | 136 | inline const Procedure Procedure::NEXTLVL{"next_level_support", | 
|  | 137 | SrcSubsystem::OTHERS}; | 
| Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 138 |  | 
| Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 139 | /** @brief Container class for bus callout service actions. */ | 
|  | 140 | class BusType | 
|  | 141 | { | 
|  | 142 | public: | 
|  | 143 | /** SMP bus (fabric A or X bus). */ | 
|  | 144 | static const BusType SMP_BUS; | 
|  | 145 |  | 
|  | 146 | /** OMI bus (memory bus). */ | 
|  | 147 | static const BusType OMI_BUS; | 
|  | 148 |  | 
|  | 149 | private: | 
|  | 150 | /** | 
|  | 151 | * @brief Constructor from components. | 
|  | 152 | * @param i_string The string representation of the procedure used for | 
|  | 153 | *                 callouts. | 
|  | 154 | */ | 
| Zane Shelley | 55e7fec | 2022-01-28 15:29:44 -0600 | [diff] [blame] | 155 | BusType(const std::string& i_string, const SrcSubsystem i_subsystem) : | 
|  | 156 | iv_string(i_string), iv_subsystem(i_subsystem) | 
|  | 157 | {} | 
| Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 158 |  | 
|  | 159 | private: | 
|  | 160 | /** The string representation of the procedure used for callouts. */ | 
|  | 161 | const std::string iv_string; | 
|  | 162 |  | 
| Zane Shelley | 55e7fec | 2022-01-28 15:29:44 -0600 | [diff] [blame] | 163 | /** The associated SRC subsystem of the bus. */ | 
|  | 164 | const SrcSubsystem iv_subsystem; | 
|  | 165 |  | 
| Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 166 | public: | 
|  | 167 | bool operator==(const BusType& r) const | 
|  | 168 | { | 
| Zane Shelley | 55e7fec | 2022-01-28 15:29:44 -0600 | [diff] [blame] | 169 | return ((this->iv_string == r.iv_string) && | 
|  | 170 | (this->iv_subsystem == r.iv_subsystem)); | 
| Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 171 | } | 
|  | 172 |  | 
|  | 173 | /** iv_string accessor */ | 
|  | 174 | std::string getString() const | 
|  | 175 | { | 
|  | 176 | return iv_string; | 
|  | 177 | } | 
| Zane Shelley | 55e7fec | 2022-01-28 15:29:44 -0600 | [diff] [blame] | 178 |  | 
|  | 179 | /** iv_subsystem accessor */ | 
|  | 180 | SrcSubsystem getSrcSubsystem() const | 
|  | 181 | { | 
|  | 182 | return iv_subsystem; | 
|  | 183 | } | 
| Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 184 | }; | 
|  | 185 |  | 
| Zane Shelley | 55e7fec | 2022-01-28 15:29:44 -0600 | [diff] [blame] | 186 | inline const BusType BusType::SMP_BUS{"SMP_BUS", SrcSubsystem::PROCESSOR_BUS}; | 
|  | 187 | inline const BusType BusType::OMI_BUS{"OMI_BUS", SrcSubsystem::MEMORY_BUS}; | 
| Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 188 |  | 
| Zane Shelley | 84721d9 | 2021-09-08 13:30:27 -0500 | [diff] [blame] | 189 | /** @brief Container class for clock callout service actions. */ | 
|  | 190 | class ClockType | 
|  | 191 | { | 
|  | 192 | public: | 
|  | 193 | /** Oscillator reference clock 0. */ | 
|  | 194 | static const ClockType OSC_REF_CLOCK_0; | 
|  | 195 |  | 
|  | 196 | /** Oscillator reference clock 1. */ | 
|  | 197 | static const ClockType OSC_REF_CLOCK_1; | 
|  | 198 |  | 
| Zane Shelley | d195b71 | 2022-01-26 13:26:34 -0600 | [diff] [blame] | 199 | /** Time of Day (TOD) clock. */ | 
|  | 200 | static const ClockType TOD_CLOCK; | 
|  | 201 |  | 
| Zane Shelley | 84721d9 | 2021-09-08 13:30:27 -0500 | [diff] [blame] | 202 | private: | 
|  | 203 | /** | 
|  | 204 | * @brief Constructor from components. | 
|  | 205 | * @param i_string The string representation of the procedure used for | 
|  | 206 | *                 callouts. | 
|  | 207 | */ | 
| Zane Shelley | 55e7fec | 2022-01-28 15:29:44 -0600 | [diff] [blame] | 208 | ClockType(const std::string& i_string, const SrcSubsystem i_subsystem) : | 
|  | 209 | iv_string(i_string), iv_subsystem(i_subsystem) | 
|  | 210 | {} | 
| Zane Shelley | 84721d9 | 2021-09-08 13:30:27 -0500 | [diff] [blame] | 211 |  | 
|  | 212 | private: | 
|  | 213 | /** The string representation of the procedure used for callouts. */ | 
|  | 214 | const std::string iv_string; | 
|  | 215 |  | 
| Zane Shelley | 55e7fec | 2022-01-28 15:29:44 -0600 | [diff] [blame] | 216 | /** The associated SRC subsystem of the clock. */ | 
|  | 217 | const SrcSubsystem iv_subsystem; | 
|  | 218 |  | 
| Zane Shelley | 84721d9 | 2021-09-08 13:30:27 -0500 | [diff] [blame] | 219 | public: | 
|  | 220 | /** iv_string accessor */ | 
|  | 221 | std::string getString() const | 
|  | 222 | { | 
|  | 223 | return iv_string; | 
|  | 224 | } | 
| Zane Shelley | 55e7fec | 2022-01-28 15:29:44 -0600 | [diff] [blame] | 225 |  | 
|  | 226 | /** iv_subsystem accessor */ | 
|  | 227 | SrcSubsystem getSrcSubsystem() const | 
|  | 228 | { | 
|  | 229 | return iv_subsystem; | 
|  | 230 | } | 
| Zane Shelley | 84721d9 | 2021-09-08 13:30:27 -0500 | [diff] [blame] | 231 | }; | 
|  | 232 |  | 
| Zane Shelley | 55e7fec | 2022-01-28 15:29:44 -0600 | [diff] [blame] | 233 | inline const ClockType ClockType::OSC_REF_CLOCK_0{"OSC_REF_CLOCK_0", | 
|  | 234 | SrcSubsystem::CEC_CLOCKS}; | 
|  | 235 | inline const ClockType ClockType::OSC_REF_CLOCK_1{"OSC_REF_CLOCK_1", | 
|  | 236 | SrcSubsystem::CEC_CLOCKS}; | 
|  | 237 | inline const ClockType ClockType::TOD_CLOCK{"TOD_CLOCK", SrcSubsystem::CEC_TOD}; | 
| Zane Shelley | 84721d9 | 2021-09-08 13:30:27 -0500 | [diff] [blame] | 238 |  | 
| Zane Shelley | a413477 | 2022-01-10 17:22:44 -0600 | [diff] [blame] | 239 | /** @brief Container class for part callout service actions. */ | 
|  | 240 | class PartType | 
|  | 241 | { | 
|  | 242 | public: | 
|  | 243 | /** The part containing the PNOR. */ | 
|  | 244 | static const PartType PNOR; | 
|  | 245 |  | 
|  | 246 | private: | 
|  | 247 | /** | 
|  | 248 | * @brief Constructor from components. | 
|  | 249 | * @param i_string The string representation of the part callout. | 
|  | 250 | */ | 
| Zane Shelley | 55e7fec | 2022-01-28 15:29:44 -0600 | [diff] [blame] | 251 | PartType(const std::string& i_string, const SrcSubsystem i_subsystem) : | 
|  | 252 | iv_string(i_string), iv_subsystem(i_subsystem) | 
|  | 253 | {} | 
| Zane Shelley | a413477 | 2022-01-10 17:22:44 -0600 | [diff] [blame] | 254 |  | 
|  | 255 | private: | 
|  | 256 | /** The string representation of the part callout. */ | 
|  | 257 | const std::string iv_string; | 
|  | 258 |  | 
| Zane Shelley | 55e7fec | 2022-01-28 15:29:44 -0600 | [diff] [blame] | 259 | /** The associated SRC subsystem of the part. */ | 
|  | 260 | const SrcSubsystem iv_subsystem; | 
|  | 261 |  | 
| Zane Shelley | a413477 | 2022-01-10 17:22:44 -0600 | [diff] [blame] | 262 | public: | 
|  | 263 | bool operator==(const PartType& r) const | 
|  | 264 | { | 
| Zane Shelley | 55e7fec | 2022-01-28 15:29:44 -0600 | [diff] [blame] | 265 | return ((this->iv_string == r.iv_string) && | 
|  | 266 | (this->iv_subsystem == r.iv_subsystem)); | 
| Zane Shelley | a413477 | 2022-01-10 17:22:44 -0600 | [diff] [blame] | 267 | } | 
|  | 268 |  | 
|  | 269 | /** iv_string accessor */ | 
|  | 270 | std::string getString() const | 
|  | 271 | { | 
|  | 272 | return iv_string; | 
|  | 273 | } | 
| Zane Shelley | 55e7fec | 2022-01-28 15:29:44 -0600 | [diff] [blame] | 274 |  | 
|  | 275 | /** iv_subsystem accessor */ | 
|  | 276 | SrcSubsystem getSrcSubsystem() const | 
|  | 277 | { | 
|  | 278 | return iv_subsystem; | 
|  | 279 | } | 
| Zane Shelley | a413477 | 2022-01-10 17:22:44 -0600 | [diff] [blame] | 280 | }; | 
|  | 281 |  | 
| Zane Shelley | 55e7fec | 2022-01-28 15:29:44 -0600 | [diff] [blame] | 282 | inline const PartType PartType::PNOR{"PNOR", SrcSubsystem::CEC_HARDWARE}; | 
| Zane Shelley | a413477 | 2022-01-10 17:22:44 -0600 | [diff] [blame] | 283 |  | 
| Zane Shelley | bf3326f | 2021-11-12 13:41:39 -0600 | [diff] [blame] | 284 | /** @brief Container class for guard service actions. */ | 
|  | 285 | class GuardType | 
|  | 286 | { | 
|  | 287 | public: | 
|  | 288 | /** Do not guard. */ | 
|  | 289 | static const GuardType NONE; | 
|  | 290 |  | 
|  | 291 | /** Guard on fatal error (cannot recover resource). */ | 
|  | 292 | static const GuardType UNRECOVERABLE; | 
|  | 293 |  | 
|  | 294 | /** Guard on non-fatal error (can recover resource). */ | 
|  | 295 | static const GuardType PREDICTIVE; | 
|  | 296 |  | 
|  | 297 | private: | 
|  | 298 | /** | 
|  | 299 | * @brief Constructor from components. | 
|  | 300 | * @param i_string The string representation of the procedure used for | 
|  | 301 | *                 callouts. | 
|  | 302 | */ | 
|  | 303 | explicit GuardType(const std::string& i_string) : iv_string(i_string) {} | 
|  | 304 |  | 
|  | 305 | private: | 
|  | 306 | /** The string representation of the procedure used for callouts. */ | 
|  | 307 | const std::string iv_string; | 
|  | 308 |  | 
|  | 309 | public: | 
|  | 310 | bool operator==(const GuardType& r) const | 
|  | 311 | { | 
|  | 312 | return this->iv_string == r.iv_string; | 
|  | 313 | } | 
|  | 314 |  | 
|  | 315 | /** iv_string accessor */ | 
|  | 316 | std::string getString() const | 
|  | 317 | { | 
|  | 318 | return iv_string; | 
|  | 319 | } | 
|  | 320 | }; | 
|  | 321 |  | 
|  | 322 | inline const GuardType GuardType::NONE{"GARD_NULL"}; | 
|  | 323 | inline const GuardType GuardType::UNRECOVERABLE{"GARD_Unrecoverable"}; | 
|  | 324 | inline const GuardType GuardType::PREDICTIVE{"GARD_Predictive"}; | 
|  | 325 |  | 
| Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 326 | } // namespace callout | 
|  | 327 |  | 
|  | 328 | } // namespace analyzer |