xref: /openbmc/openpower-hw-diags/analyzer/resolution.cpp (revision a4134770850077cbe7171b8852a1fa1b3c1c6525)
115527a43SZane Shelley #include <analyzer/plugins/plugin.hpp>
20b8368cbSZane Shelley #include <analyzer/resolution.hpp>
3236bb730SZane Shelley #include <util/pdbg.hpp>
4236bb730SZane Shelley #include <util/trace.hpp>
50b8368cbSZane Shelley 
60b8368cbSZane Shelley namespace analyzer
70b8368cbSZane Shelley {
80b8368cbSZane Shelley 
92d114321SZane Shelley //------------------------------------------------------------------------------
102d114321SZane Shelley 
1196d5486cSZane Shelley // Helper function to get the root cause chip target from the service data.
__getRootCauseChipTarget(const ServiceData & i_sd)1296d5486cSZane Shelley pdbg_target* __getRootCauseChipTarget(const ServiceData& i_sd)
1396d5486cSZane Shelley {
1496d5486cSZane Shelley     auto target = util::pdbg::getTrgt(i_sd.getRootCause().getChip());
1596d5486cSZane Shelley     assert(nullptr != target); // This would be a really bad bug.
1696d5486cSZane Shelley     return target;
1796d5486cSZane Shelley }
1896d5486cSZane Shelley 
1996d5486cSZane Shelley //------------------------------------------------------------------------------
2096d5486cSZane Shelley 
2196d5486cSZane Shelley // Helper function to get a unit target from the given unit path, which is a
2296d5486cSZane Shelley // devtree path relative the the containing chip. An empty string indicates the
2396d5486cSZane Shelley // chip target should be returned.
__getUnitTarget(pdbg_target * i_chipTarget,const std::string & i_unitPath)2496d5486cSZane Shelley pdbg_target* __getUnitTarget(pdbg_target* i_chipTarget,
2596d5486cSZane Shelley                              const std::string& i_unitPath)
2696d5486cSZane Shelley {
2796d5486cSZane Shelley     assert(nullptr != i_chipTarget);
2896d5486cSZane Shelley 
2996d5486cSZane Shelley     auto target = i_chipTarget; // default, if i_unitPath is empty
3096d5486cSZane Shelley 
3196d5486cSZane Shelley     if (!i_unitPath.empty())
3296d5486cSZane Shelley     {
3396d5486cSZane Shelley         auto path = std::string{util::pdbg::getPath(target)} + "/" + i_unitPath;
3496d5486cSZane Shelley 
3596d5486cSZane Shelley         target = util::pdbg::getTrgt(path);
3696d5486cSZane Shelley         if (nullptr == target)
3796d5486cSZane Shelley         {
3896d5486cSZane Shelley             // Likely a bug the RAS data files.
3996d5486cSZane Shelley             throw std::logic_error("Unable to find target for " + path);
4096d5486cSZane Shelley         }
4196d5486cSZane Shelley     }
4296d5486cSZane Shelley 
4396d5486cSZane Shelley     return target;
4496d5486cSZane Shelley }
4596d5486cSZane Shelley 
4696d5486cSZane Shelley //------------------------------------------------------------------------------
4796d5486cSZane Shelley 
resolve(ServiceData & io_sd) const48236bb730SZane Shelley void HardwareCalloutResolution::resolve(ServiceData& io_sd) const
490b8368cbSZane Shelley {
5096d5486cSZane Shelley     // Get the target for the hardware callout.
5196d5486cSZane Shelley     auto target = __getUnitTarget(__getRootCauseChipTarget(io_sd), iv_unitPath);
52236bb730SZane Shelley 
5337acb289SZane Shelley     // Add the callout and the FFDC to the service data.
5437acb289SZane Shelley     io_sd.calloutTarget(target, iv_priority, iv_guard);
550b8368cbSZane Shelley }
560b8368cbSZane Shelley 
57c85716caSZane Shelley //------------------------------------------------------------------------------
58c85716caSZane Shelley 
resolve(ServiceData & io_sd) const595d63cefcSZane Shelley void ConnectedCalloutResolution::resolve(ServiceData& io_sd) const
605d63cefcSZane Shelley {
615d63cefcSZane Shelley     // Get the chip target from the root cause signature.
625d63cefcSZane Shelley     auto chipTarget = __getRootCauseChipTarget(io_sd);
635d63cefcSZane Shelley 
645d63cefcSZane Shelley     // Get the endpoint target for the receiving side of the bus.
655d63cefcSZane Shelley     auto rxTarget = __getUnitTarget(chipTarget, iv_unitPath);
665d63cefcSZane Shelley 
6737acb289SZane Shelley     // Add the callout and the FFDC to the service data.
6837acb289SZane Shelley     io_sd.calloutConnected(rxTarget, iv_busType, iv_priority, iv_guard);
695d63cefcSZane Shelley }
705d63cefcSZane Shelley 
715d63cefcSZane Shelley //------------------------------------------------------------------------------
725d63cefcSZane Shelley 
resolve(ServiceData & io_sd) const734757a7bcSZane Shelley void BusCalloutResolution::resolve(ServiceData& io_sd) const
744757a7bcSZane Shelley {
754757a7bcSZane Shelley     // Get the chip target from the root cause signature.
764757a7bcSZane Shelley     auto chipTarget = __getRootCauseChipTarget(io_sd);
774757a7bcSZane Shelley 
784757a7bcSZane Shelley     // Get the endpoint target for the receiving side of the bus.
794757a7bcSZane Shelley     auto rxTarget = __getUnitTarget(chipTarget, iv_unitPath);
804757a7bcSZane Shelley 
8137acb289SZane Shelley     // Add the callout and the FFDC to the service data.
8237acb289SZane Shelley     io_sd.calloutBus(rxTarget, iv_busType, iv_priority, iv_guard);
834757a7bcSZane Shelley }
844757a7bcSZane Shelley 
854757a7bcSZane Shelley //------------------------------------------------------------------------------
864757a7bcSZane Shelley 
resolve(ServiceData & io_sd) const8784721d90SZane Shelley void ClockCalloutResolution::resolve(ServiceData& io_sd) const
8884721d90SZane Shelley {
8937acb289SZane Shelley     // Add the callout and the FFDC to the service data.
9037acb289SZane Shelley     io_sd.calloutClock(iv_clockType, iv_priority, iv_guard);
9184721d90SZane Shelley }
9284721d90SZane Shelley 
9384721d90SZane Shelley //------------------------------------------------------------------------------
9484721d90SZane Shelley 
resolve(ServiceData & io_sd) const95c85716caSZane Shelley void ProcedureCalloutResolution::resolve(ServiceData& io_sd) const
96c85716caSZane Shelley {
9737acb289SZane Shelley     // Add the callout and the FFDC to the service data.
9837acb289SZane Shelley     io_sd.calloutProcedure(iv_procedure, iv_priority);
99c85716caSZane Shelley }
100c85716caSZane Shelley 
101c85716caSZane Shelley //------------------------------------------------------------------------------
102c85716caSZane Shelley 
resolve(ServiceData & io_sd) const103*a4134770SZane Shelley void PartCalloutResolution::resolve(ServiceData& io_sd) const
104*a4134770SZane Shelley {
105*a4134770SZane Shelley     // Add the callout and the FFDC to the service data.
106*a4134770SZane Shelley     io_sd.calloutPart(iv_part, iv_priority);
107*a4134770SZane Shelley }
108*a4134770SZane Shelley 
109*a4134770SZane Shelley //------------------------------------------------------------------------------
110*a4134770SZane Shelley 
resolve(ServiceData & io_sd) const11115527a43SZane Shelley void PluginResolution::resolve(ServiceData& io_sd) const
112e13a9f95SZane Shelley {
11315527a43SZane Shelley     // Get the plugin function and call it.
11415527a43SZane Shelley 
11515527a43SZane Shelley     auto chip = io_sd.getRootCause().getChip();
11615527a43SZane Shelley 
11715527a43SZane Shelley     auto func = PluginMap::getSingleton().get(chip.getType(), iv_name);
11815527a43SZane Shelley 
11915527a43SZane Shelley     func(iv_instance, chip, io_sd);
120e13a9f95SZane Shelley }
121e13a9f95SZane Shelley 
122e13a9f95SZane Shelley //------------------------------------------------------------------------------
123e13a9f95SZane Shelley 
1240b8368cbSZane Shelley } // namespace analyzer
125