1 #pragma once
2 
3 #include <map>
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. */
14 enum class Priority
15 {
16     /** Serivce is mandatory. */
17     HIGH,
18 
19     /** Serivce medium priority callouts one at a time, in order, until the
20      *  issue is resolved. */
21     MED,
22 
23     /** Same as MED, except replace all A's as a group. */
24     MED_A,
25 
26     /** Same as MED, except replace all B's as a group. */
27     MED_B,
28 
29     /** Same as MED, except replace all C's as a group. */
30     MED_C,
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. */
35     LOW,
36 };
37 
38 /** @return The string representation of the priority used in callouts. */
getString(Priority i_priority)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  */
getStringFFDC(Priority i_priority)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 }
74 
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_FRU = 0x11,
83     PROCESSOR_UNIT = 0x13,
84     PROCESSOR_BUS = 0x14,
85 
86     MEMORY_CTLR = 0x21,
87     MEMORY_BUS = 0x22,
88     MEMORY_DIMM = 0x23,
89     MEMORY_FRU = 0x24,
90 
91     PHB = 0x38,
92 
93     CEC_HARDWARE = 0x50,
94     CEC_CLOCKS = 0x58,
95     CEC_TOD = 0x5A,
96 
97     OTHERS = 0x70,
98 };
99 
100 /** @brief Container class for procedure callout service actions. */
101 class Procedure
102 {
103   public:
104     /** Contact next level support. */
105     static const Procedure NEXTLVL;
106 
107     /** An unrecoverable event occurred, look for previous errors for the
108      *  cause. */
109     static const Procedure SUE_SEEN;
110 
111   private:
112     /**
113      * @brief Constructor from components.
114      * @param i_string The string representation of the procedure used for
115      *                 callouts.
116      */
Procedure(const std::string & i_string,const SrcSubsystem i_subsystem)117     Procedure(const std::string& i_string, const SrcSubsystem i_subsystem) :
118         iv_string(i_string), iv_subsystem(i_subsystem)
119     {}
120 
121   private:
122     /** The string representation of the procedure used for callouts. */
123     const std::string iv_string;
124 
125     /** The associated SRC subsystem of the procedure. */
126     const SrcSubsystem iv_subsystem;
127 
128   public:
129     /** iv_string accessor */
getString() const130     std::string getString() const
131     {
132         return iv_string;
133     }
134 
135     /** iv_subsystem accessor */
getSrcSubsystem() const136     SrcSubsystem getSrcSubsystem() const
137     {
138         return iv_subsystem;
139     }
140 };
141 
142 inline const Procedure Procedure::NEXTLVL{"next_level_support",
143                                           SrcSubsystem::OTHERS};
144 inline const Procedure Procedure::SUE_SEEN{"find_sue_root_cause",
145                                            SrcSubsystem::OTHERS};
146 
147 /** @brief Container class for bus callout service actions. */
148 class BusType
149 {
150   public:
151     /** SMP bus (fabric A or X bus). */
152     static const BusType SMP_BUS;
153 
154     /** OMI bus (memory bus). */
155     static const BusType OMI_BUS;
156 
157   private:
158     /**
159      * @brief Constructor from components.
160      * @param i_string The string representation of the procedure used for
161      *                 callouts.
162      */
BusType(const std::string & i_string,const SrcSubsystem i_subsystem)163     BusType(const std::string& i_string, const SrcSubsystem i_subsystem) :
164         iv_string(i_string), iv_subsystem(i_subsystem)
165     {}
166 
167   private:
168     /** The string representation of the procedure used for callouts. */
169     const std::string iv_string;
170 
171     /** The associated SRC subsystem of the bus. */
172     const SrcSubsystem iv_subsystem;
173 
174   public:
operator ==(const BusType & r) const175     bool operator==(const BusType& r) const
176     {
177         return ((this->iv_string == r.iv_string) &&
178                 (this->iv_subsystem == r.iv_subsystem));
179     }
180 
181     /** iv_string accessor */
getString() const182     std::string getString() const
183     {
184         return iv_string;
185     }
186 
187     /** iv_subsystem accessor */
getSrcSubsystem() const188     SrcSubsystem getSrcSubsystem() const
189     {
190         return iv_subsystem;
191     }
192 };
193 
194 inline const BusType BusType::SMP_BUS{"SMP_BUS", SrcSubsystem::PROCESSOR_BUS};
195 inline const BusType BusType::OMI_BUS{"OMI_BUS", SrcSubsystem::MEMORY_BUS};
196 
197 /** @brief Container class for clock callout service actions. */
198 class ClockType
199 {
200   public:
201     /** Oscillator reference clock 0. */
202     static const ClockType OSC_REF_CLOCK_0;
203 
204     /** Oscillator reference clock 1. */
205     static const ClockType OSC_REF_CLOCK_1;
206 
207     /** Time of Day (TOD) clock. */
208     static const ClockType TOD_CLOCK;
209 
210   private:
211     /**
212      * @brief Constructor from components.
213      * @param i_string The string representation of the procedure used for
214      *                 callouts.
215      */
ClockType(const std::string & i_string,const SrcSubsystem i_subsystem)216     ClockType(const std::string& i_string, const SrcSubsystem i_subsystem) :
217         iv_string(i_string), iv_subsystem(i_subsystem)
218     {}
219 
220   private:
221     /** The string representation of the procedure used for callouts. */
222     const std::string iv_string;
223 
224     /** The associated SRC subsystem of the clock. */
225     const SrcSubsystem iv_subsystem;
226 
227   public:
228     /** iv_string accessor */
getString() const229     std::string getString() const
230     {
231         return iv_string;
232     }
233 
234     /** iv_subsystem accessor */
getSrcSubsystem() const235     SrcSubsystem getSrcSubsystem() const
236     {
237         return iv_subsystem;
238     }
239 };
240 
241 inline const ClockType ClockType::OSC_REF_CLOCK_0{"OSC_REF_CLOCK_0",
242                                                   SrcSubsystem::CEC_CLOCKS};
243 inline const ClockType ClockType::OSC_REF_CLOCK_1{"OSC_REF_CLOCK_1",
244                                                   SrcSubsystem::CEC_CLOCKS};
245 inline const ClockType ClockType::TOD_CLOCK{"TOD_CLOCK", SrcSubsystem::CEC_TOD};
246 
247 /** @brief Container class for part callout service actions. */
248 class PartType
249 {
250   public:
251     /** The part containing the PNOR. */
252     static const PartType PNOR;
253 
254   private:
255     /**
256      * @brief Constructor from components.
257      * @param i_string The string representation of the part callout.
258      */
PartType(const std::string & i_string,const SrcSubsystem i_subsystem)259     PartType(const std::string& i_string, const SrcSubsystem i_subsystem) :
260         iv_string(i_string), iv_subsystem(i_subsystem)
261     {}
262 
263   private:
264     /** The string representation of the part callout. */
265     const std::string iv_string;
266 
267     /** The associated SRC subsystem of the part. */
268     const SrcSubsystem iv_subsystem;
269 
270   public:
operator ==(const PartType & r) const271     bool operator==(const PartType& r) const
272     {
273         return ((this->iv_string == r.iv_string) &&
274                 (this->iv_subsystem == r.iv_subsystem));
275     }
276 
277     /** iv_string accessor */
getString() const278     std::string getString() const
279     {
280         return iv_string;
281     }
282 
283     /** iv_subsystem accessor */
getSrcSubsystem() const284     SrcSubsystem getSrcSubsystem() const
285     {
286         return iv_subsystem;
287     }
288 };
289 
290 inline const PartType PartType::PNOR{"PNOR", SrcSubsystem::CEC_HARDWARE};
291 
292 /** @brief Container class for guard service actions. */
293 class GuardType
294 {
295   public:
296     /** Do not guard. */
297     static const GuardType NONE;
298 
299     /** Guard on fatal error (cannot recover resource). */
300     static const GuardType UNRECOVERABLE;
301 
302     /** Guard on non-fatal error (can recover resource). */
303     static const GuardType PREDICTIVE;
304 
305   private:
306     /**
307      * @brief Constructor from components.
308      * @param i_string The string representation of the procedure used for
309      *                 callouts.
310      */
GuardType(const std::string & i_string)311     explicit GuardType(const std::string& i_string) : iv_string(i_string) {}
312 
313   private:
314     /** The string representation of the procedure used for callouts. */
315     const std::string iv_string;
316 
317   public:
operator ==(const GuardType & r) const318     bool operator==(const GuardType& r) const
319     {
320         return this->iv_string == r.iv_string;
321     }
322 
323     /** iv_string accessor */
getString() const324     std::string getString() const
325     {
326         return iv_string;
327     }
328 };
329 
330 inline const GuardType GuardType::NONE{"GARD_NULL"};
331 inline const GuardType GuardType::UNRECOVERABLE{"GARD_Unrecoverable"};
332 inline const GuardType GuardType::PREDICTIVE{"GARD_Predictive"};
333 
334 } // namespace callout
335 
336 } // namespace analyzer
337