xref: /openbmc/openpower-hw-diags/analyzer/resolution.hpp (revision a0c724d3d425032213dbd48247d93cc76d61a331)
10b8368cbSZane Shelley #pragma once
20b8368cbSZane Shelley 
30b8368cbSZane Shelley #include <analyzer/service_data.hpp>
40b8368cbSZane Shelley 
50b8368cbSZane Shelley namespace analyzer
60b8368cbSZane Shelley {
70b8368cbSZane Shelley 
80b8368cbSZane Shelley /** @brief An abstract class for service event resolutions. */
90b8368cbSZane Shelley class Resolution
100b8368cbSZane Shelley {
110b8368cbSZane Shelley   public:
120b8368cbSZane Shelley     /** @brief Pure virtual destructor. */
130b8368cbSZane Shelley     virtual ~Resolution() = 0;
140b8368cbSZane Shelley 
150b8368cbSZane Shelley   public:
160b8368cbSZane Shelley     /**
170b8368cbSZane Shelley      * @brief Resolves the service actions required by this resolution.
180b8368cbSZane Shelley      * @param io_sd An object containing the service data collected during
190b8368cbSZane Shelley      *              hardware error analysis.
200b8368cbSZane Shelley      */
210b8368cbSZane Shelley     virtual void resolve(ServiceData& io_sd) const = 0;
220b8368cbSZane Shelley };
230b8368cbSZane Shelley 
240b8368cbSZane Shelley // Pure virtual destructor must be defined.
~Resolution()250b8368cbSZane Shelley inline Resolution::~Resolution() {}
260b8368cbSZane Shelley 
270b8368cbSZane Shelley /** @brief Resolves a hardware callout service event. */
280b8368cbSZane Shelley class HardwareCalloutResolution : public Resolution
290b8368cbSZane Shelley {
300b8368cbSZane Shelley   public:
310b8368cbSZane Shelley     /**
320b8368cbSZane Shelley      * @brief Constructor from components.
3396d5486cSZane Shelley      * @param i_unitPath The devtree path of a guardable unit relative to a
340b8368cbSZane Shelley      *                   chip. An empty string refers to the chip itself.
350b8368cbSZane Shelley      * @param i_priority The callout priority.
362f92130cSZane Shelley      * @param i_guard    True, if guard is required. False, otherwise.
370b8368cbSZane Shelley      */
HardwareCalloutResolution(const std::string & i_unitPath,callout::Priority i_priority,bool i_guard)3896d5486cSZane Shelley     HardwareCalloutResolution(const std::string& i_unitPath,
399980d489SZane Shelley                               callout::Priority i_priority, bool i_guard) :
40*a0c724d3SPatrick Williams         iv_unitPath(i_unitPath), iv_priority(i_priority), iv_guard(i_guard)
410b8368cbSZane Shelley     {}
420b8368cbSZane Shelley 
430b8368cbSZane Shelley   private:
440b8368cbSZane Shelley     /** The devtree path of a guardable unit relative to a chip. An empty string
450b8368cbSZane Shelley      *  refers to the chip itself. */
4696d5486cSZane Shelley     const std::string iv_unitPath;
470b8368cbSZane Shelley 
480b8368cbSZane Shelley     /** The callout priority. */
49c85716caSZane Shelley     const callout::Priority iv_priority;
500b8368cbSZane Shelley 
512f92130cSZane Shelley     /** True, if guard is required. False, otherwise. */
522f92130cSZane Shelley     const bool iv_guard;
530b8368cbSZane Shelley 
540b8368cbSZane Shelley   public:
550b8368cbSZane Shelley     void resolve(ServiceData& io_sd) const override;
560b8368cbSZane Shelley };
570b8368cbSZane Shelley 
585d63cefcSZane Shelley /** @brief Resolution to callout a connected chip/target. */
595d63cefcSZane Shelley class ConnectedCalloutResolution : public Resolution
605d63cefcSZane Shelley {
615d63cefcSZane Shelley   public:
625d63cefcSZane Shelley     /**
635d63cefcSZane Shelley      * @brief Constructor from components.
645d63cefcSZane Shelley      * @param i_busType  The bus type.
655d63cefcSZane Shelley      * @param i_unitPath The path of the chip unit that is connected to the
665d63cefcSZane Shelley      *                   other chip. An empty string refers to the chip itself,
675d63cefcSZane Shelley      *                   which generally means this chip is a child of another.
685d63cefcSZane Shelley      * @param i_priority The callout priority.
695d63cefcSZane Shelley      * @param i_guard    The guard type for this callout.
705d63cefcSZane Shelley      */
ConnectedCalloutResolution(const callout::BusType & i_busType,const std::string & i_unitPath,callout::Priority i_priority,bool i_guard)715d63cefcSZane Shelley     ConnectedCalloutResolution(const callout::BusType& i_busType,
725d63cefcSZane Shelley                                const std::string& i_unitPath,
739980d489SZane Shelley                                callout::Priority i_priority, bool i_guard) :
74*a0c724d3SPatrick Williams         iv_busType(i_busType), iv_unitPath(i_unitPath), iv_priority(i_priority),
75*a0c724d3SPatrick Williams         iv_guard(i_guard)
765d63cefcSZane Shelley     {}
775d63cefcSZane Shelley 
785d63cefcSZane Shelley   private:
795d63cefcSZane Shelley     /** The bus type. */
805d63cefcSZane Shelley     const callout::BusType iv_busType;
815d63cefcSZane Shelley 
825d63cefcSZane Shelley     /** The devtree path the chip unit that is connected to the other chip. An
835d63cefcSZane Shelley      *  empty string refers to the chip itself, which generally means this chip
845d63cefcSZane Shelley      *  is a child of the other chip. */
855d63cefcSZane Shelley     const std::string iv_unitPath;
865d63cefcSZane Shelley 
875d63cefcSZane Shelley     /** The callout priority. */
885d63cefcSZane Shelley     const callout::Priority iv_priority;
895d63cefcSZane Shelley 
905d63cefcSZane Shelley     /** True, if guard is required. False, otherwise. */
915d63cefcSZane Shelley     const bool iv_guard;
925d63cefcSZane Shelley 
935d63cefcSZane Shelley   public:
945d63cefcSZane Shelley     void resolve(ServiceData& io_sd) const override;
955d63cefcSZane Shelley };
965d63cefcSZane Shelley 
974757a7bcSZane Shelley /**
984757a7bcSZane Shelley  * @brief Resolution to callout all parts on a bus (RX/TX endpoints and
994757a7bcSZane Shelley  *         everything else in between).
1004757a7bcSZane Shelley  */
1014757a7bcSZane Shelley class BusCalloutResolution : public Resolution
1024757a7bcSZane Shelley {
1034757a7bcSZane Shelley   public:
1044757a7bcSZane Shelley     /**
1054757a7bcSZane Shelley      * @brief Constructor from components.
1064757a7bcSZane Shelley      * @param i_busType  The bus type.
1074757a7bcSZane Shelley      * @param i_unitPath The path of the chip unit that is connected to the
1084757a7bcSZane Shelley      *                   other chip. An empty string refers to the chip itself,
1094757a7bcSZane Shelley      *                   which generally means this chip is a child of another.
1104757a7bcSZane Shelley      * @param i_priority The callout priority.
1114757a7bcSZane Shelley      * @param i_guard    The guard type for this callout.
1124757a7bcSZane Shelley      */
BusCalloutResolution(const callout::BusType & i_busType,const std::string & i_unitPath,callout::Priority i_priority,bool i_guard)1134757a7bcSZane Shelley     BusCalloutResolution(const callout::BusType& i_busType,
1144757a7bcSZane Shelley                          const std::string& i_unitPath,
1159980d489SZane Shelley                          callout::Priority i_priority, bool i_guard) :
116*a0c724d3SPatrick Williams         iv_busType(i_busType), iv_unitPath(i_unitPath), iv_priority(i_priority),
117*a0c724d3SPatrick Williams         iv_guard(i_guard)
1184757a7bcSZane Shelley     {}
1194757a7bcSZane Shelley 
1204757a7bcSZane Shelley   private:
1214757a7bcSZane Shelley     /** The bus type. */
1224757a7bcSZane Shelley     const callout::BusType iv_busType;
1234757a7bcSZane Shelley 
1244757a7bcSZane Shelley     /** The devtree path the chip unit that is connected to the other chip. An
1254757a7bcSZane Shelley      *  empty string refers to the chip itself, which generally means this chip
1264757a7bcSZane Shelley      *  is a child of the other chip. */
1274757a7bcSZane Shelley     const std::string iv_unitPath;
1284757a7bcSZane Shelley 
1294757a7bcSZane Shelley     /** The callout priority. */
1304757a7bcSZane Shelley     const callout::Priority iv_priority;
1314757a7bcSZane Shelley 
1324757a7bcSZane Shelley     /** True, if guard is required. False, otherwise. */
1334757a7bcSZane Shelley     const bool iv_guard;
1344757a7bcSZane Shelley 
1354757a7bcSZane Shelley   public:
1364757a7bcSZane Shelley     void resolve(ServiceData& io_sd) const override;
1374757a7bcSZane Shelley };
1384757a7bcSZane Shelley 
13984721d90SZane Shelley /** @brief Resolves a clock callout service event. */
14084721d90SZane Shelley class ClockCalloutResolution : public Resolution
14184721d90SZane Shelley {
14284721d90SZane Shelley   public:
14384721d90SZane Shelley     /**
14484721d90SZane Shelley      * @brief Constructor from components.
14584721d90SZane Shelley      * @param i_clockType The clock type.
14684721d90SZane Shelley      * @param i_priority  The callout priority.
14784721d90SZane Shelley      * @param i_guard     The guard type for this callout.
14884721d90SZane Shelley      */
ClockCalloutResolution(const callout::ClockType & i_clockType,callout::Priority i_priority,bool i_guard)14984721d90SZane Shelley     ClockCalloutResolution(const callout::ClockType& i_clockType,
1509980d489SZane Shelley                            callout::Priority i_priority, bool i_guard) :
151*a0c724d3SPatrick Williams         iv_clockType(i_clockType), iv_priority(i_priority), iv_guard(i_guard)
15284721d90SZane Shelley     {}
15384721d90SZane Shelley 
15484721d90SZane Shelley   private:
15584721d90SZane Shelley     /** The clock type. */
15684721d90SZane Shelley     const callout::ClockType iv_clockType;
15784721d90SZane Shelley 
15884721d90SZane Shelley     /** The callout priority. */
15984721d90SZane Shelley     const callout::Priority iv_priority;
16084721d90SZane Shelley 
16184721d90SZane Shelley     /** True, if guard is required. False, otherwise. */
16284721d90SZane Shelley     const bool iv_guard;
16384721d90SZane Shelley 
16484721d90SZane Shelley   public:
16584721d90SZane Shelley     void resolve(ServiceData& io_sd) const override;
16684721d90SZane Shelley };
16784721d90SZane Shelley 
1680b8368cbSZane Shelley /** @brief Resolves a procedure callout service event. */
1690b8368cbSZane Shelley class ProcedureCalloutResolution : public Resolution
1700b8368cbSZane Shelley {
1710b8368cbSZane Shelley   public:
1720b8368cbSZane Shelley     /**
1730b8368cbSZane Shelley      * @brief Constructor from components.
1740b8368cbSZane Shelley      * @param i_procedure The procedure callout type.
1750b8368cbSZane Shelley      * @param i_priority  The callout priority.
1760b8368cbSZane Shelley      */
ProcedureCalloutResolution(const callout::Procedure & i_procedure,callout::Priority i_priority)177c85716caSZane Shelley     ProcedureCalloutResolution(const callout::Procedure& i_procedure,
1789980d489SZane Shelley                                callout::Priority i_priority) :
179*a0c724d3SPatrick Williams         iv_procedure(i_procedure), iv_priority(i_priority)
1800b8368cbSZane Shelley     {}
1810b8368cbSZane Shelley 
1820b8368cbSZane Shelley   private:
1830b8368cbSZane Shelley     /** The procedure callout type. */
184c85716caSZane Shelley     const callout::Procedure iv_procedure;
1850b8368cbSZane Shelley 
1860b8368cbSZane Shelley     /** The callout priority. */
187c85716caSZane Shelley     const callout::Priority iv_priority;
1880b8368cbSZane Shelley 
1890b8368cbSZane Shelley   public:
190c85716caSZane Shelley     void resolve(ServiceData& io_sd) const override;
1910b8368cbSZane Shelley };
1920b8368cbSZane Shelley 
193a4134770SZane Shelley /** @brief Resolves a part callout service event. */
194a4134770SZane Shelley class PartCalloutResolution : public Resolution
195a4134770SZane Shelley {
196a4134770SZane Shelley   public:
197a4134770SZane Shelley     /**
198a4134770SZane Shelley      * @brief Constructor from components.
199a4134770SZane Shelley      * @param i_part     The part callout type.
200a4134770SZane Shelley      * @param i_priority The callout priority.
201a4134770SZane Shelley      */
PartCalloutResolution(const callout::PartType & i_part,callout::Priority i_priority)202a4134770SZane Shelley     PartCalloutResolution(const callout::PartType& i_part,
2039980d489SZane Shelley                           callout::Priority i_priority) :
204*a0c724d3SPatrick Williams         iv_part(i_part), iv_priority(i_priority)
205a4134770SZane Shelley     {}
206a4134770SZane Shelley 
207a4134770SZane Shelley   private:
208a4134770SZane Shelley     /** The part callout type. */
209a4134770SZane Shelley     const callout::PartType iv_part;
210a4134770SZane Shelley 
211a4134770SZane Shelley     /** The callout priority. */
212a4134770SZane Shelley     const callout::Priority iv_priority;
213a4134770SZane Shelley 
214a4134770SZane Shelley   public:
215a4134770SZane Shelley     void resolve(ServiceData& io_sd) const override;
216a4134770SZane Shelley };
217a4134770SZane Shelley 
2180b8368cbSZane Shelley /**
219e13a9f95SZane Shelley  * @brief Some service actions cannot be contained within the RAS data files.
220e13a9f95SZane Shelley  *        This resolution class allows a predefined plugin function to be
221e13a9f95SZane Shelley  *        called to do additional service action work.
222e13a9f95SZane Shelley  */
223e13a9f95SZane Shelley class PluginResolution : public Resolution
224e13a9f95SZane Shelley {
225e13a9f95SZane Shelley   public:
226e13a9f95SZane Shelley     /**
227e13a9f95SZane Shelley      * @brief Constructor from components.
228e13a9f95SZane Shelley      * @param i_name     The name of the plugin.
229e13a9f95SZane Shelley      * @param i_instance A plugin could be defined for multiple chip
230e13a9f95SZane Shelley      *                   units/registers.
231e13a9f95SZane Shelley      */
PluginResolution(const std::string & i_name,unsigned int i_instance)232e13a9f95SZane Shelley     PluginResolution(const std::string& i_name, unsigned int i_instance) :
233e13a9f95SZane Shelley         iv_name(i_name), iv_instance(i_instance)
234e13a9f95SZane Shelley     {}
235e13a9f95SZane Shelley 
236e13a9f95SZane Shelley   private:
237e13a9f95SZane Shelley     /** The name of the plugin. */
238e13a9f95SZane Shelley     const std::string iv_name;
239e13a9f95SZane Shelley 
240e13a9f95SZane Shelley     /** Some plugins will define the same action for multiple instances of a
241e13a9f95SZane Shelley      *  register (i.e. for each core on a processor). */
242e13a9f95SZane Shelley     const unsigned int iv_instance;
243e13a9f95SZane Shelley 
244e13a9f95SZane Shelley   public:
245e13a9f95SZane Shelley     void resolve(ServiceData& io_sd) const override;
246e13a9f95SZane Shelley };
247e13a9f95SZane Shelley 
248e13a9f95SZane Shelley /**
249723fa239SZane Shelley  * @brief Contains a list of resolutions. This resolutions will be resolved the
250723fa239SZane Shelley  *        list in the order in which they were inputted into the constructor.
2510b8368cbSZane Shelley  */
252723fa239SZane Shelley class ResolutionList : public Resolution
2530b8368cbSZane Shelley {
2540b8368cbSZane Shelley   public:
255723fa239SZane Shelley     /** @brief Default constructor. */
256723fa239SZane Shelley     ResolutionList() = default;
2570b8368cbSZane Shelley 
2580b8368cbSZane Shelley   private:
259723fa239SZane Shelley     /** The resolution list. */
260723fa239SZane Shelley     std::vector<std::shared_ptr<Resolution>> iv_list;
2610b8368cbSZane Shelley 
2620b8368cbSZane Shelley   public:
263723fa239SZane Shelley     /**
264723fa239SZane Shelley      * @brief Adds a new resolution to the end of the list.
265723fa239SZane Shelley      * @param i_resolution The new resolution
266723fa239SZane Shelley      */
push(const std::shared_ptr<Resolution> & i_resolution)267723fa239SZane Shelley     void push(const std::shared_ptr<Resolution>& i_resolution)
268723fa239SZane Shelley     {
269723fa239SZane Shelley         iv_list.push_back(i_resolution);
270723fa239SZane Shelley     }
271723fa239SZane Shelley 
272723fa239SZane Shelley     // Overloaded from parent.
resolve(ServiceData & io_sd) const2730b8368cbSZane Shelley     void resolve(ServiceData& io_sd) const override
2740b8368cbSZane Shelley     {
275723fa239SZane Shelley         for (const auto& e : iv_list)
276723fa239SZane Shelley         {
277723fa239SZane Shelley             e->resolve(io_sd);
278723fa239SZane Shelley         }
2790b8368cbSZane Shelley     }
2800b8368cbSZane Shelley };
2810b8368cbSZane Shelley 
2820b8368cbSZane Shelley } // namespace analyzer
283