diff options
author | Roland Veloz <rveloz@us.ibm.com> | 2018-04-04 03:05:01 -0500 |
---|---|---|
committer | Daniel M. Crowell <dcrowell@us.ibm.com> | 2018-05-07 11:50:46 -0400 |
commit | 79c2cf9d40f13300cf39bfa3f661d7472bb29bbc (patch) | |
tree | 6bed06f4f624761ecbb9b80ca35d06b519eacb91 /src/usr | |
parent | c0217d002a0a211551048766461f35d718ce1618 (diff) | |
download | talos-hostboot-79c2cf9d40f13300cf39bfa3f661d7472bb29bbc.tar.gz talos-hostboot-79c2cf9d40f13300cf39bfa3f661d7472bb29bbc.zip |
Added support, in IStep 09, to facilitate the testing of SMP wrap
Adding support, in IStep 09 to make the call to p9_io_obus_dccal and
p9_io_obus_pre_trainadv. Did a lot of refactoring of code for
the call to p9_io_xbus_dccal. For the code to train p9_io_xbus_dccal
there seemed to be a lot of repetitve code. Also did some consildation
of code for the call to p9_io_obus_dccal and p9_io_xbus_pre_trainadv.
This consildated code resides in istep09HelperFuncs.H/.C.
Change-Id: I625ee12066364db4654dde8fc2072a129f9ed004
RTC:190096
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/56716
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com>
Reviewed-by: Prachi Gupta <pragupta@us.ibm.com>
Reviewed-by: Christian R. Geddes <crgeddes@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Diffstat (limited to 'src/usr')
-rw-r--r-- | src/usr/isteps/istep09/call_fabric_io_dccal.C | 622 | ||||
-rw-r--r-- | src/usr/isteps/istep09/call_fabric_pre_trainadv.C | 190 | ||||
-rw-r--r-- | src/usr/isteps/istep09/istep09HelperFuncs.C | 374 | ||||
-rw-r--r-- | src/usr/isteps/istep09/istep09HelperFuncs.H | 183 | ||||
-rw-r--r-- | src/usr/isteps/istep09/makefile | 13 |
5 files changed, 892 insertions, 490 deletions
diff --git a/src/usr/isteps/istep09/call_fabric_io_dccal.C b/src/usr/isteps/istep09/call_fabric_io_dccal.C index 45c32fc6d..5cb2605cc 100644 --- a/src/usr/isteps/istep09/call_fabric_io_dccal.C +++ b/src/usr/isteps/istep09/call_fabric_io_dccal.C @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2015,2016 */ +/* Contributors Listed Below - COPYRIGHT 2015,2018 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -22,6 +22,7 @@ /* permissions and limitations under the License. */ /* */ /* IBM_PROLOG_END_TAG */ + /** * @file call_fabric_io_dccal.C * @@ -35,437 +36,326 @@ /******************************************************************************/ // Includes /******************************************************************************/ -#include <stdint.h> -#include <map> - -#include <trace/interface.H> -#include <initservice/taskargs.H> -#include <errl/errlentry.H> -#include <isteps/hwpisteperror.H> -#include <errl/errludtarget.H> +// Integral and component ID support +#include <stdint.h> // uint32_t +#include <hbotcompid.H> // HWPF_COMP_ID -#include <initservice/isteps_trace.H> +// Targeting support +#include <fapi2_target.H> // fapi2::Target +#include <target.H> // TARGETING::Target -#include <hwas/common/deconfigGard.H> -#include <hwas/common/hwasCommon.H> +// Error handling support +#include <errl/errlentry.H> // errlHndl_t +#include <isteps/hwpisteperror.H> // IStepError -#include <sbe/sbeif.H> +// Tracing support +#include <trace/interface.H> // TRACFCOMP +#include <initservice/isteps_trace.H> // g_trac_isteps_trace -// targeting support -#include <targeting/common/commontargeting.H> -#include <targeting/common/utilFilter.H> -#include <targeting/common/trace.H> -#include <pbusLinkSvc.H> -#include <fapi2/target.H> -#include <fapi2/plat_hwp_invoker.H> +// Pbus link service support +#include <pbusLinkSvc.H> // TargetPairs_t, PbusLinkSvc -// HWP -#include <p9_io_xbus_dccal.H> +// HWP call support +#include <istepHelperFuncs.H> // captureError +#include <istep09/istep09HelperFuncs.H> // trainBusHandler +#include <p9_io_xbus_dccal.H> // p9_io_xbus_dccal -namespace ISTEP_09 +namespace ISTEP_09 { -using namespace ISTEP; using namespace ISTEP_ERROR; -using namespace ERRORLOG; +using namespace ISTEPS_TRACE; using namespace TARGETING; -// -// Wrapper function to call fabric_io_dccal -// -void* call_fabric_io_dccal( void *io_pArgs ) +/** + * @brief + * This function actually makes the FAPI call to p9_io_xbus_dccal. + * + * @param[out] o_stepError The details of an error, if any, will be added to this + * @param[in] i_dccalMode XbusDccalMode -- selects what operation to perform + * @param[in] i_fapi2Target fapi2 target + * @param[in] i_group clock group + * @return True if NO errors occurred, false otherwise + */ +bool configureXbusConnections(IStepError &o_stepError, + const XbusDccalMode i_dccalMode, + const XBUS_TGT i_fapi2Target, + const uint8_t i_group); + +/** + * @brief This function explicitly makes the FAPI call for XbusDccalMode + * TxZcalRunBus and XbusDccalMod. This function iterates over the + * groups within the iteration of individual targets. + * + * @param[out] o_stepError The details of an error, if any, will be added to this + * @param[in] i_pbusConnections XBUS pair connections + * @return True if NO errors occurred, false otherwise + */ +bool configureXbusConnectionsRunBusMode(IStepError &o_stepError, + const EDI_EI_INITIALIZATION::TargetPairs_t &i_pbusConnections); + +/** + * @brief This function makes the FAPI call for the given XbusDccalMode. + * This function also iterates over the individual targets within + * the iteration of individual groups. + * + * @param[out] o_stepError The details of an error, if any, will be added to this + * @param[in] i_pbusConnections XBUS pair connections + * @param[in] i_dccalMode XbusDccalMode -- selects what operation to perform + * @return True if NO errors occurred, false otherwise + */ +bool configureXbusConnectionsMode(IStepError &o_stepError, + const EDI_EI_INITIALIZATION::TargetPairs_t &i_PbusConnections, + XbusDccalMode i_dccalMode); + +//****************************************************************************** +// Wrapper function to call fabric_io_dccal +//****************************************************************************** +void* call_fabric_io_dccal( void *io_pArgs ) { - errlHndl_t l_errl = NULL; - IStepError l_StepError; + errlHndl_t l_errl(nullptr); + IStepError l_stepError; // We are not running this analog procedure in VPO if (TARGETING::is_vpo()) { - TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace, - "Skip call_fabric_io_dccal in VPO!"); - return l_StepError.getErrorHandle(); + TRACFCOMP(g_trac_isteps_trace, "Skip call_fabric_io_dccal in VPO!"); + return l_stepError.getErrorHandle(); } - TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace, - "call_fabric_io_dccal entry" ); + TRACFCOMP(g_trac_isteps_trace, ENTER_MRK"call_fabric_io_dccal entry"); - EDI_EI_INITIALIZATION::TargetPairs_t l_PbusConnections; - const uint32_t MaxBusSet = 1; - TYPE busSet[MaxBusSet] = { TYPE_XBUS }; // TODO RTC:152304 - add TYPE_OBUS + EDI_EI_INITIALIZATION::TargetPairs_t l_pbusConnections; + TYPE l_busSet[] = { TYPE_XBUS, TYPE_OBUS }; + constexpr uint32_t l_maxBusSet = sizeof(l_busSet)/sizeof(TYPE); - for (uint32_t ii = 0; (!l_errl) && (ii < MaxBusSet); ii++) + for (uint32_t ii = 0; ii < l_maxBusSet; ++ii) { l_errl = EDI_EI_INITIALIZATION::PbusLinkSvc::getTheInstance(). - getPbusConnections(l_PbusConnections, busSet[ii]); + getPbusConnections(l_pbusConnections, l_busSet[ii]); if (l_errl) { - TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace, + TRACFCOMP(g_trac_isteps_trace, "ERROR 0x%.8X : getPbusConnections TYPE_%cBUS returns error", - l_errl->reasonCode(), (ii ? 'X':'O') ); + l_errl->reasonCode(), (ii ? 'O':'X') ); - // Create IStep error log and cross reference to error that occurred - l_StepError.addErrorDetails( l_errl ); - - // Commit the error log - // Log should be deleted and set to NULL in errlCommit. - errlCommit(l_errl, HWPF_COMP_ID); + // Capture error and then exit + captureError(l_errl, + l_stepError, + HWPF_COMP_ID); // Don't continue with a potential bad connection set break; } - //This HWP is broken into substeps, we want to deconfigure - //bad targets if one of the substeps fails so check this error - // between each substep. - bool l_subStepError = false; - - for (const auto & l_PbusConnection: l_PbusConnections) + if (TYPE_XBUS == l_busSet[ii]) { - bool l_firstTargetValid = true; - bool l_secondTargetValid = true; - - //Set up fapi2 targets for each end of the connections - const TARGETING::Target* l_firstPbusTarget = l_PbusConnection.first; - const TARGETING::Target* l_secondPbusTarget = l_PbusConnection.second; - - const fapi2::Target <fapi2::TARGET_TYPE_XBUS> - l_firstPbusFapi2Target( - (const_cast<TARGETING::Target*>(l_firstPbusTarget))); - const fapi2::Target <fapi2::TARGET_TYPE_XBUS> - l_secondPbusFapi2Target( - (const_cast<TARGETING::Target*>(l_secondPbusTarget))); - - // group is either 0 or 1 - std::vector<uint8_t> l_groups = {0,1}; - TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace, - "Running p9_io_xbus_dccal HWP on " - "this %cbus target %.8X on all groups", - (ii ? 'X' : 'O'), - TARGETING::get_huid(l_firstPbusTarget) ); - - FAPI_INVOKE_HWP( l_errl, - p9_io_xbus_dccal, - XbusDccalMode::TxZcalRunBus, - l_firstPbusFapi2Target, - l_groups[0] ); - - if ( l_errl ) + if (l_pbusConnections.empty()) { - // capture the target data in the elog - ErrlUserDetailsTarget(l_firstPbusFapi2Target).addToLog(l_errl); - - // Create IStep error log and cross ref error that occurred - l_StepError.addErrorDetails( l_errl ); - - // Commit Error - errlCommit( l_errl, HWPF_COMP_ID ); - l_errl = NULL; - - //Note that the first target is invalid - l_firstTargetValid = false; - //Note that this substep had an error - l_subStepError = true; - + TRACFCOMP(g_trac_isteps_trace, "Connection bus list is empty. " + "HWP call p9_io_xbus_dccal will not be called."); } - if(l_firstTargetValid) + // if any one of these returns an error then just move on to the next Bus Set + configureXbusConnectionsRunBusMode(l_stepError, + l_pbusConnections) && + configureXbusConnectionsMode(l_stepError, + l_pbusConnections, + XbusDccalMode::RxDccalStartGrp) && + configureXbusConnectionsMode(l_stepError, + l_pbusConnections, + XbusDccalMode::RxDccalCheckGrp); + } // end if (TYPE_XBUS == l_busSet[ii]) +#ifdef CONFIG_SMP_WRAP_TEST + else if (TYPE_OBUS == l_busSet[ii]) + { + // Make the FAPI call to p9_io_obus_dccal + if (!trainBusHandler(l_busSet[ii], + P9_IO_OBUS_DCCAL, + l_stepError, + HWPF_COMP_ID, + l_pbusConnections)) { - for(auto l_group : l_groups) - { - FAPI_INVOKE_HWP( l_errl, - p9_io_xbus_dccal, - XbusDccalMode::TxZcalSetGrp, - l_firstPbusFapi2Target, - l_group ); - - if ( l_errl ) - { - // capture the target data in the elog - ErrlUserDetailsTarget(l_firstPbusFapi2Target).addToLog(l_errl); - - // Create IStep error log and cross ref error that occurred - l_StepError.addErrorDetails( l_errl ); - - // Commit Error - errlCommit( l_errl, HWPF_COMP_ID ); - l_errl = NULL; - //Note that this target is invalid - l_firstTargetValid = false; - //Note that this substep had an error - l_subStepError = true; - //if any of the groups have an error just break out - break; - } - } + break; } + } // end else if (TYPE_OBUS == l_busSet[ii]) +#endif + } // end for (uint32_t ii = 0; ii < l_maxBusSet; ii++) - TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace, - "Running p9_io_xbus_dccal HWP on " - "this %cbus target %.8X on all groups", - (ii ? 'X' : 'O'), - TARGETING::get_huid(l_secondPbusTarget) ); + TRACFCOMP(g_trac_isteps_trace, EXIT_MRK"call_fabric_io_dccal exit" ); - FAPI_INVOKE_HWP( l_errl, - p9_io_xbus_dccal, - XbusDccalMode::TxZcalRunBus, - l_secondPbusFapi2Target, - l_groups[0] ); + // end task, returning any errorlogs to IStepDisp + return l_stepError.getErrorHandle(); +} - if ( l_errl ) - { - // capture the target data in the elog - ErrlUserDetailsTarget(l_secondPbusFapi2Target).addToLog(l_errl); +/** + * configureXbusConnectionsRunBusMode + */ +bool configureXbusConnectionsRunBusMode(IStepError &o_stepError, + const EDI_EI_INITIALIZATION::TargetPairs_t &i_PbusConnections) +{ + bool l_retSuccess = true; - // Create IStep error log and cross ref error that occurred - l_StepError.addErrorDetails( l_errl ); + // Group is either 0 or 1 + std::vector<uint8_t> l_groups = {0,1}; - // Commit Error - errlCommit( l_errl, HWPF_COMP_ID ); - l_errl = NULL; - // Note that the second target is invalid - l_secondTargetValid = false; - // Note that an error was detected during this substep - l_subStepError = true; + // Iterate over the connections + for (const auto & l_pbusConnection: i_PbusConnections) + { + // Put targets in a container that can be traversed + std::vector<const TARGETING::Target*> l_targets = + { l_pbusConnection.first, l_pbusConnection.second }; - } + // Iterate over the targets + for (const auto l_target: l_targets) + { + // Convert current target to a fapi2 target + const fapi2::Target <fapi2::TARGET_TYPE_XBUS> + l_pbusFapi2Target + (const_cast<TARGETING::Target*>(l_target)); - if(l_secondTargetValid) - { - for(auto l_group : l_groups) - { - FAPI_INVOKE_HWP( l_errl, - p9_io_xbus_dccal, - XbusDccalMode::TxZcalSetGrp, - l_secondPbusFapi2Target, - l_group ); + TRACFCOMP(g_trac_isteps_trace, + "Running p9_io_xbus_dccal HWP with mode = %.8X on " + "XBUS target %.8X on group %d", + XbusDccalMode::TxZcalRunBus, + TARGETING::get_huid(l_target), + l_groups[0]); - if ( l_errl ) - { - // capture the target data in the elog - ErrlUserDetailsTarget(l_secondPbusFapi2Target).addToLog(l_errl); + l_retSuccess = configureXbusConnections(o_stepError, + XbusDccalMode::TxZcalRunBus, + l_pbusFapi2Target, + l_groups[0]); - // Create IStep error log and cross ref error that occurred - l_StepError.addErrorDetails( l_errl ); + if (!l_retSuccess) break; // Don't continue if an error occurred - // Commit Error - errlCommit( l_errl, HWPF_COMP_ID ); + for (auto l_group : l_groups) + { + TRACFCOMP(g_trac_isteps_trace, + "Running p9_io_xbus_dccal HWP with mode = %.8X on " + "XBUS target %.8X on group %d", + XbusDccalMode::TxZcalSetGrp, + TARGETING::get_huid(l_target), + l_group); + + l_retSuccess = + configureXbusConnections(o_stepError, + XbusDccalMode::TxZcalSetGrp, + l_pbusFapi2Target, + l_group); + if (!l_retSuccess) break; // Don't continue if an error occurred + } - //set l_errl to null for future use - l_errl = NULL; + TRACFCOMP(g_trac_isteps_trace, + "%s : XBUS connection p9_io_xbus_dccal, target 0x%.8X", + (l_retSuccess ? "SUCCESS": "ERROR"), + TARGETING::get_huid(l_target)); - //one of the channels is bad on this target, its not valid - l_secondTargetValid = false; + if (!l_retSuccess) break; // Don't continue if an error occurred + } // for (const auto l_target: l_targets) - //if any errors were found on this substep, we will skip the remainder - l_subStepError = true; + if (!l_retSuccess) break; // Don't continue if an error occurred + } // for (const auto & l_pbusConnection: l_pbusConnections) - //if any of the groups have an error just break out - break; - } - } - } - } + // return true if call was successful, else false + return l_retSuccess; +} - if(l_subStepError) - { - //Try the next connection set - continue; - } +/** + * configureXbusConnectionsMode + */ +bool configureXbusConnectionsMode(IStepError &o_stepError, + const EDI_EI_INITIALIZATION::TargetPairs_t &i_PbusConnections, + XbusDccalMode i_dccalMode) +{ + bool l_retSuccess = true; - for (const auto & l_PbusConnection: l_PbusConnections) - { - //Initially assume both targets are valid - uint8_t l_firstTargetValid = true; - uint8_t l_secondTargetValid = true; + // Group is either 0 or 1 + std::vector<uint8_t> l_groups = {0,1}; - //Set up fapi2 targets for each end of the connections - const TARGETING::Target* l_firstPbusTarget = l_PbusConnection.first; - const TARGETING::Target* l_secondPbusTarget = l_PbusConnection.second; + // Iterate over the connections + for (const auto & l_pbusConnection: i_PbusConnections) + { + // Put targets in a container that can be traversed + std::vector<const TARGETING::Target*> l_targets = + { l_pbusConnection.first, l_pbusConnection.second }; - const fapi2::Target <fapi2::TARGET_TYPE_XBUS> - l_firstPbusFapi2Target( - (const_cast<TARGETING::Target*>(l_firstPbusTarget))); - const fapi2::Target <fapi2::TARGET_TYPE_XBUS> - l_secondPbusFapi2Target( - (const_cast<TARGETING::Target*>(l_secondPbusTarget))); - - // group is either 0 or 1 - std::vector<uint8_t> l_groups = {0,1}; - - TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace, - "Running p9_io_xbus_dccal HWP with mode = %.8X on " - "this %cbus target %.8X on all groups", - (ii ? 'X' : 'O'), - XbusDccalMode::RxDccalStartGrp, - TARGETING::get_huid(l_firstPbusTarget) ); - - TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace, - "Running p9_io_xbus_dccal HWP with mode = %.8X on " - "this %cbus target %.8X on all groups", - (ii ? 'X' : 'O'), - XbusDccalMode::RxDccalStartGrp, - TARGETING::get_huid(l_secondPbusTarget) ); - - for(auto l_group : l_groups) + // Iterate over the groups + for (auto l_group : l_groups) + { + // Iterate over targets + for (const auto l_target: l_targets) { - if(l_firstTargetValid) + // Convert current target to a fapi2 target + const fapi2::Target <fapi2::TARGET_TYPE_XBUS> + l_pbusFapi2Target + (const_cast<TARGETING::Target*>(l_target)); + + TRACFCOMP(g_trac_isteps_trace, + "Running p9_io_xbus_dccal HWP with mode = %.8X on " + "XBUS target %.8X on group %d", + i_dccalMode, + TARGETING::get_huid(l_target), + l_group); + + l_retSuccess = configureXbusConnections(o_stepError, + i_dccalMode, + l_pbusFapi2Target, + l_group); + // Ignore errors in RxDccalCheckGrp mode + if (XbusDccalMode::RxDccalCheckGrp == i_dccalMode) { - FAPI_INVOKE_HWP( l_errl, - p9_io_xbus_dccal, - XbusDccalMode::RxDccalStartGrp, - l_firstPbusFapi2Target, - l_group ); - - if ( l_errl ) - { - // capture the target data in the elog - ErrlUserDetailsTarget(l_firstPbusTarget).addToLog(l_errl); - - // Create IStep error log and cross ref error that occurred - l_StepError.addErrorDetails( l_errl ); - - // Commit Error - errlCommit( l_errl, HWPF_COMP_ID ); - l_errl = NULL; - - //Note the error on this substep - l_subStepError = true; - //Note that first target is invalid for next group - l_firstTargetValid = false; - } + l_retSuccess = true; } - if(l_secondTargetValid) - { - FAPI_INVOKE_HWP( l_errl, - p9_io_xbus_dccal, - XbusDccalMode::RxDccalStartGrp, - l_secondPbusFapi2Target, - l_group ); - - if ( l_errl ) - { - // capture the target data in the elog - ErrlUserDetailsTarget(l_secondPbusTarget).addToLog(l_errl); - - // Create IStep error log and cross ref error that occurred - l_StepError.addErrorDetails( l_errl ); - - // Commit Error - errlCommit( l_errl, HWPF_COMP_ID ); - l_errl = NULL; - - //Note the error on this substep - l_subStepError = true; - //Note that second target is invalid for next group - l_secondTargetValid = false; - } - } - } - } + TRACFCOMP(g_trac_isteps_trace, + "%s : XBUS connection p9_io_xbus_dccal, target 0x%.8X", + (l_retSuccess ? "SUCCESS" : "ERROR"), + TARGETING::get_huid(l_target)); + if (!l_retSuccess) break; // Don't continue if an error occurred + } // end for (const auto l_target: l_targets) - if(l_subStepError) - { - //Try the next connection set - continue; - } + if (!l_retSuccess) break; // Don't continue if an error occurred + } // end for (auto l_group : l_groups) - for (const auto & l_PbusConnection: l_PbusConnections) - { - //Initially assume both targets are valid - uint8_t l_firstTargetValid = true; - uint8_t l_secondTargetValid = true; + if (!l_retSuccess) break; // Don't continue if an error occurred + } // for (const auto & l_pbusConnection: l_pbusConnections) - //Set up fapi2 targets for each end of the connections - const TARGETING::Target* l_firstPbusTarget = l_PbusConnection.first; - const TARGETING::Target* l_secondPbusTarget = l_PbusConnection.second; + // return true if call was successful, else false + return l_retSuccess; +} - const fapi2::Target <fapi2::TARGET_TYPE_XBUS> - l_firstPbusFapi2Target( - (const_cast<TARGETING::Target*>(l_firstPbusTarget))); - const fapi2::Target <fapi2::TARGET_TYPE_XBUS> - l_secondPbusFapi2Target( - (const_cast<TARGETING::Target*>(l_secondPbusTarget))); - - // group is either 0 or 1 - std::vector<uint8_t> l_groups = {0,1}; - TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace, - "Running p9_io_xbus_dccal HWP with mode = %.8X on " - "this %cbus target %.8X on all groups", - (ii ? 'X' : 'O'), - XbusDccalMode::RxDccalCheckGrp, - TARGETING::get_huid(l_firstPbusFapi2Target) ); - - TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace, - "Running p9_io_xbus_dccal HWP with mode = %.8X on " - "this %cbus target %.8X on all groups", - (ii ? 'X' : 'O'), - XbusDccalMode::RxDccalCheckGrp, - TARGETING::get_huid(l_secondPbusFapi2Target) ); - - for(auto l_group : l_groups) - { - if(l_firstTargetValid) - { - FAPI_INVOKE_HWP( l_errl, - p9_io_xbus_dccal, - XbusDccalMode::RxDccalCheckGrp, - l_firstPbusFapi2Target, - l_group ); - - if ( l_errl ) - { - // capture the target data in the elog - ErrlUserDetailsTarget(l_firstPbusFapi2Target).addToLog(l_errl); - - // Create IStep error log and cross ref error that occurred - l_StepError.addErrorDetails( l_errl ); - - // Commit Error - errlCommit( l_errl, HWPF_COMP_ID ); - // We want to continue the training despite the error, so - // no break - l_errl = NULL; - //Note that first target is invalid for next group - l_firstTargetValid = false; - } - } +/** + * configureXbusConnections + */ +bool configureXbusConnections(IStepError &o_stepError, + const XbusDccalMode i_dccalMode, + const XBUS_TGT i_fapi2Target, + const uint8_t i_group) +{ + bool l_retSuccess = true; + errlHndl_t l_err = nullptr; - if(l_secondTargetValid) - { - FAPI_INVOKE_HWP( l_errl, - p9_io_xbus_dccal, - XbusDccalMode::RxDccalCheckGrp, - l_secondPbusFapi2Target, - l_group ); - - if ( l_errl ) - { - // capture the target data in the elog - ErrlUserDetailsTarget(l_secondPbusFapi2Target).addToLog(l_errl); - - // Create IStep error log and cross ref error that occurred - l_StepError.addErrorDetails( l_errl ); - - // Commit Error - errlCommit( l_errl, HWPF_COMP_ID ); - // We want to continue the training despite the error, so - // no break - l_errl = NULL; - //Note that second target is invalid for next group - l_secondTargetValid = false; - } - } - } - } - } // end of connection set loop + FAPI_INVOKE_HWP(l_err, + p9_io_xbus_dccal, + i_dccalMode, + i_fapi2Target, + i_group); - TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace, - "call_fabric_io_dccal exit" ); + if ( l_err ) + { + // Capture error and then exit + captureError(l_err, + o_stepError, + HWPF_COMP_ID, + i_fapi2Target); + + // Note that this step had an error + l_retSuccess = false; + } - // end task, returning any errorlogs to IStepDisp - return l_StepError.getErrorHandle(); + // return true if call was successful, else false + return l_retSuccess; } -}; +}; // end namespace ISTEP_09 diff --git a/src/usr/isteps/istep09/call_fabric_pre_trainadv.C b/src/usr/isteps/istep09/call_fabric_pre_trainadv.C index d3c8df3bc..bbc152ad4 100644 --- a/src/usr/isteps/istep09/call_fabric_pre_trainadv.C +++ b/src/usr/isteps/istep09/call_fabric_pre_trainadv.C @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2015,2016 */ +/* Contributors Listed Below - COPYRIGHT 2015,2018 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -35,152 +35,98 @@ /******************************************************************************/ // Includes /******************************************************************************/ -#include <stdint.h> -#include <map> -#include <trace/interface.H> -#include <initservice/taskargs.H> -#include <errl/errlentry.H> +// Integral and component ID support +#include <stdint.h> // uint32_t +#include <hbotcompid.H> // HWPF_COMP_ID -#include <isteps/hwpisteperror.H> -#include <errl/errludtarget.H> +// Tracing support +#include <trace/interface.H> // TRACFCOMP +#include <initservice/isteps_trace.H> // g_trac_isteps_trace -#include <initservice/isteps_trace.H> +// Error handling support +#include <errl/errlentry.H> // errlHndl_t +#include <isteps/hwpisteperror.H> // IStepError -#include <hwas/common/deconfigGard.H> -#include <hwas/common/hwasCommon.H> +// Pbus link service support +#include <pbusLinkSvc.H> // TargetPairs_t, PbusLinkSvc -#include <sbe/sbeif.H> - -// targeting support -#include <targeting/common/commontargeting.H> -#include <targeting/common/utilFilter.H> -#include <targeting/common/trace.H> - -#include <pbusLinkSvc.H> -#include <fapi2/target.H> -#include <fapi2/plat_hwp_invoker.H> - -// HWP -#include <p9_io_xbus_pre_trainadv.H> +// HWP call support +#include <istepHelperFuncs.H> // captureError +#include <istep09/istep09HelperFuncs.H> // trainBusHandler namespace ISTEP_09 { - - -using namespace ISTEP; using namespace ISTEP_ERROR; -using namespace ERRORLOG; +using namespace ISTEPS_TRACE; using namespace TARGETING; -using namespace HWAS; -// -// Wrapper function to call fabric_pre_trainadv -// -void* call_fabric_pre_trainadv( void *io_pArgs ) +//****************************************************************************** +// Wrapper function to call fabric_pre_trainadv +//****************************************************************************** +void* call_fabric_pre_trainadv( void *io_pArgs ) { - IStepError l_StepError; - errlHndl_t l_errl = NULL; - TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace, - "call_fabric_pre_trainadv entry" ); + errlHndl_t l_err(nullptr); + IStepError l_stepError; + + TRACFCOMP(g_trac_isteps_trace, ENTER_MRK"call_fabric_pre_trainadv entry" ); - EDI_EI_INITIALIZATION::TargetPairs_t l_PbusConnections; - const uint32_t MaxBusSet = 1; - TYPE busSet[MaxBusSet] = { TYPE_XBUS }; // TODO RTC:152304 - add TYPE_OBUS + EDI_EI_INITIALIZATION::TargetPairs_t l_pbusConnections; + TYPE l_busSet[] = { TYPE_XBUS, TYPE_OBUS }; + constexpr uint32_t l_maxBusSet = sizeof(l_busSet)/sizeof(TYPE); - for (uint32_t ii = 0; (!l_errl) && (ii < MaxBusSet); ii++) + for (uint32_t ii = 0; (!l_err) && (ii < l_maxBusSet); ii++) { - l_errl = EDI_EI_INITIALIZATION::PbusLinkSvc::getTheInstance(). - getPbusConnections(l_PbusConnections, busSet[ii]); - if (l_errl) + l_err = EDI_EI_INITIALIZATION::PbusLinkSvc::getTheInstance(). + getPbusConnections(l_pbusConnections, l_busSet[ii]); + + if (l_err) { - TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace, + TRACFCOMP(g_trac_isteps_trace, "ERROR 0x%.8X : getPbusConnections TYPE_%cBUS returns error", - l_errl->reasonCode(), (ii ? 'X':'O') ); - - // Create IStep error log and cross reference to error that occurred - l_StepError.addErrorDetails( l_errl ); + l_err->reasonCode(), (ii ? 'O':'X') ); - // Commit the error log - // Log should be deleted and set to NULL in errlCommit. - errlCommit(l_errl, HWPF_COMP_ID); + // Capture error and then exit + captureError(l_err, + l_stepError, + HWPF_COMP_ID); // Don't continue with a potential bad connection set break; } - for (const auto & l_PbusConnection: l_PbusConnections) + if (TYPE_XBUS == l_busSet[ii]) + { + // Make the FAPI call to p9_io_xbus_pre_trainadv + if (!trainBusHandler(l_busSet[ii], + P9_IO_XBUS_PRE_TRAINADV, + l_stepError, + HWPF_COMP_ID, + l_pbusConnections)) + { + break; + } + } // end if (TYPE_XBUS == l_busSet[ii]) +#ifdef CONFIG_SMP_WRAP_TEST + else if (TYPE_OBUS == l_busSet[ii]) { - const TARGETING::Target* l_thisPbusTarget = l_PbusConnection.first; - const TARGETING::Target* l_connectedPbusTarget = - l_PbusConnection.second; - - const fapi2::Target <fapi2::TARGET_TYPE_XBUS> - l_thisPbusFapi2Target( - (const_cast<TARGETING::Target*>(l_thisPbusTarget))); - - const fapi2::Target <fapi2::TARGET_TYPE_XBUS> - l_connectedPbusFapi2Target( - (const_cast<TARGETING::Target*>(l_connectedPbusTarget))); - - // group is either 0 or 1, - // need to train both groups and allow for them to differ - uint8_t l_this_group = 0; - uint8_t l_connected_group = 0; - uint8_t l_group_loop = 0; - for (l_group_loop = 0; l_group_loop < 4; l_group_loop++) + // Make the FAPI call to p9_io_obus_pre_trainadv + if (!trainBusHandler(l_busSet[ii], + P9_IO_OBUS_PRE_TRAINADV, + l_stepError, + HWPF_COMP_ID, + l_pbusConnections)) { - l_this_group = l_group_loop / 2; // 0, 0, 1, 1 - l_connected_group = l_group_loop % 2; // 0, 1, 1, 0 - - TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace, - "Running p9_io_xbus_pre_trainadv HWP on " - "this %cbus target %.8X (group %d) and connected " - "target %.8X (group %d)", - (ii ? 'X' : 'O'), - TARGETING::get_huid(l_thisPbusTarget), l_this_group, - TARGETING::get_huid(l_connectedPbusTarget), - l_connected_group ); - - FAPI_INVOKE_HWP( l_errl, p9_io_xbus_pre_trainadv, - l_thisPbusFapi2Target, l_this_group, - l_connectedPbusFapi2Target, - l_connected_group ); - - TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace, - "%s : %cbus connection p9_io_xbus_pre_trainadv " - "Target 0x%.8X using group %d, connected target 0x%.8X " - "using group %d", - (l_errl ? "ERROR" : "SUCCESS"), (ii ? 'X' : 'O'), - TARGETING::get_huid(l_thisPbusTarget), l_this_group, - TARGETING::get_huid(l_connectedPbusTarget), - l_connected_group ); - - if ( l_errl ) - { - // capture the target data in the elog - ErrlUserDetailsTarget(l_thisPbusTarget).addToLog(l_errl); - ErrlUserDetailsTarget(l_connectedPbusTarget).addToLog - (l_errl); - - // Create IStep error log and cross ref error that occurred - l_StepError.addErrorDetails( l_errl ); - - // Commit Error - errlCommit( l_errl, HWPF_COMP_ID ); - // We want to continue the training despite the error, so - // no break - l_errl = NULL; - } - - } // end of groups - } // end of connection TYPE combinations - } // end of connection set loop - - TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace, - "call_fabric_pre_trainadv exit" ); + break; + } + } // end else if (TYPE_OBUS == l_busSet[ii]) +#endif + } // end for (uint32_t ii = 0; (!l_err) && (ii < l_maxBusSet); ii++) + + TRACFCOMP(g_trac_isteps_trace, EXIT_MRK"call_fabric_pre_trainadv exit" ); // end task, returning any errorlogs to IStepDisp - return l_StepError.getErrorHandle(); + return l_stepError.getErrorHandle(); } -}; + +}; // end namespace ISTEP_09 diff --git a/src/usr/isteps/istep09/istep09HelperFuncs.C b/src/usr/isteps/istep09/istep09HelperFuncs.C new file mode 100644 index 000000000..5927dc08f --- /dev/null +++ b/src/usr/isteps/istep09/istep09HelperFuncs.C @@ -0,0 +1,374 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/usr/isteps/istep09/istep09HelperFuncs.C $ */ +/* */ +/* OpenPOWER HostBoot Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2015,2018 */ +/* [+] International Business Machines Corp. */ +/* */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); */ +/* you may not use this file except in compliance with the License. */ +/* You may obtain a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ +/* implied. See the License for the specific language governing */ +/* permissions and limitations under the License. */ +/* */ +/* IBM_PROLOG_END_TAG */ + +/******************************************************************************/ +// Includes +/******************************************************************************/ + +#include "istep09HelperFuncs.H" + +// STD support +#include <map> + +// Support for all istep common functions +#include "istepHelperFuncs.H" // captureError + +// Tracing support +#include <trace/interface.H> // TRACFCOMP +#include <initservice/isteps_trace.H> // g_trac_isteps_trace + +// Targeting support +#include <fapi2_target.H> // fapi2::Target +#include <target.H> // Target + +// Error handling support +#include <errl/errlentry.H> // errlHndl_t + +// HWP call support +#include <fapi2/plat_hwp_invoker.H> // FAPI_INVOKE_HWP +#include <p9_io_xbus_pre_trainadv.H> // p9_io_xbus_pre_trainadv +#include <p9_io_xbus_post_trainadv.H> // p9_io_xbus_post_trainadv +#include <p9_io_obus_dccal.H> // p9_io_obus_dccal +#include <p9_io_obus_pre_trainadv.H> // p9_io_obus_pre_trainadv +#include <p9_io_obus_linktrain.H> // p9_io_obus_link_train +#include <p9_io_obus_post_trainadv.H> // p9_io_obus_post_trainadv + +namespace ISTEP_09 +{ +using namespace ISTEP_ERROR; +using namespace ISTEPS_TRACE; +using namespace EDI_EI_INITIALIZATION; +using namespace TARGETING; + + /** + * hwpCallToString + */ +const char * hwpCallToString( HWP_CALL_TYPE i_hwpCall ) +{ + const static std::map<HWP_CALL_TYPE, const char*> hwpCallToStringMap = + { + { P9_IO_XBUS_PRE_TRAINADV, "p9_io_xbus_pre_trainadv" }, + { P9_IO_XBUS_POST_TRAINADV, "p9_io_xbus_post_trainadv" }, + { P9_IO_OBUS_PRE_TRAINADV, "p9_io_obus_pre_trainadv" }, + { P9_IO_OBUS_POST_TRAINADV, "p9_io_obus_post_trainadv" }, + { P9_IO_OBUS_LINKTRAIN, "p9_io_obus_linktrain" }, + { P9_IO_OBUS_DCCAL, "p9_io_obus_dccal" }, + }; + + if (hwpCallToStringMap.count(i_hwpCall) > 0) + { + return hwpCallToStringMap.at(i_hwpCall); + } + else + { + return ""; + } +} + +/** + * trainXbus + */ +uint32_t trainXbus(HWP_CALL_TYPE i_hwpCall, + IStepError &o_stepError, + compId_t i_componentId, + const Target* i_firstTarget, + const Target* i_secondTarget) +{ + // Cache the HWP call in string form + const char* l_hwpCallStr = hwpCallToString(i_hwpCall); + + TRACFCOMP(g_trac_isteps_trace, ENTER_MRK"trainXbus (%s) entry", l_hwpCallStr); + + // Make sure target values are valid + assert(nullptr != i_firstTarget, "The first target cannot be NULL"); + assert(nullptr != i_secondTarget, "The second target cannot be NULL"); + + // An error handler + errlHndl_t l_err(nullptr); + + // Enumerate the train failures that occur + uint32_t l_numberOfTrainFailures(0); + + // Create Fapi2 targets from the given targets + const fapi2::Target <fapi2::TARGET_TYPE_XBUS> + l_firstFapi2Target( + (const_cast<Target*>(i_firstTarget))); + + const fapi2::Target <fapi2::TARGET_TYPE_XBUS> + l_secondFapi2Target( + (const_cast<Target*>(i_secondTarget))); + + // group is either 0 or 1, + // need to train both groups and allow for them to differ + uint8_t l_this_group(0), l_connected_group(0); + for (uint8_t l_group_loop = 0; l_group_loop < 4; ++l_group_loop) + { + l_this_group = l_group_loop / 2; // 0, 0, 1, 1 + l_connected_group = l_group_loop % 2; // 0, 1, 1, 0 + + TRACFCOMP(g_trac_isteps_trace, + "Running %s HWP on " + "this XBUS target 0x%.8X (group %d) and connected " + "target 0x%.8X (group %d)", + l_hwpCallStr, + get_huid(i_firstTarget), + l_this_group, + get_huid(i_secondTarget), + l_connected_group ); + + if (P9_IO_XBUS_PRE_TRAINADV == i_hwpCall) + { + FAPI_INVOKE_HWP(l_err, + p9_io_xbus_pre_trainadv, + l_firstFapi2Target, + l_this_group, + l_secondFapi2Target, + l_connected_group ); + } + else if (P9_IO_XBUS_POST_TRAINADV == i_hwpCall) + { + FAPI_INVOKE_HWP(l_err, + p9_io_xbus_post_trainadv, + l_firstFapi2Target, + l_this_group, + l_secondFapi2Target, + l_connected_group ); + } + else + { + ++l_numberOfTrainFailures; + TRACFCOMP(g_trac_isteps_trace, + "ERROR: Invalid/Uknown XBUS HWP call"); + break; + } + + TRACFCOMP(g_trac_isteps_trace, + "%s : XBUS connection %s, " + "target 0x%.8X using group %d, connected target 0x%.8X " + "using group %d", + (l_err ? "ERROR" : "SUCCESS"), + l_hwpCallStr, + get_huid(i_firstTarget), + l_this_group, + get_huid(i_secondTarget), + l_connected_group ); + + if (l_err) + { + ++l_numberOfTrainFailures; + TargetHandleList l_targets = + { const_cast<TargetHandle_t>(i_firstTarget), + const_cast<TargetHandle_t>(i_secondTarget) }; + // Capture error and continue + captureError(l_err, + o_stepError, + i_componentId, + l_targets); + } + } // end for (l_group_loop = 0; l_group_loop < 4; l_group_loop++) + + TRACFCOMP(g_trac_isteps_trace, EXIT_MRK"trainXbus (%s) exit", l_hwpCallStr); + + return l_numberOfTrainFailures; +} + +/** + * trainObus + */ +uint32_t trainObus(HWP_CALL_TYPE i_hwpCall, + IStepError &o_stepError, + compId_t i_componentId, + const Target* i_firstTarget, + const Target* i_secondTarget) +{ + + // Cache the HWP call in string form + const char* l_hwpCallStr = hwpCallToString(i_hwpCall); + + TRACFCOMP(g_trac_isteps_trace, ENTER_MRK"trainObus (%s) entry", l_hwpCallStr); + + // Make sure target values are valid + assert(nullptr != i_firstTarget, "The first target cannot be NULL"); + assert(nullptr != i_secondTarget, "The second target cannot be NULL"); + + // An error handler + errlHndl_t l_err(nullptr); + + // Enumerate the train failures that occur + uint32_t l_numberOfTrainFailures(0); + + // Put targets in a container that can be traversed + std::vector<const Target*> l_targets = + { i_firstTarget, i_secondTarget }; + + // Iterate over the targets + for (const auto l_target: l_targets) + { + // Convert current target to a fapi2 target + const fapi2::Target <fapi2::TARGET_TYPE_OBUS> + l_fapi2Target + (const_cast<Target*>(l_target)); + + TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace, + "Running %s HWP on this OBUS target 0x%.8X", + l_hwpCallStr, + l_target); + + // Call the appropriate HWP method + if (P9_IO_OBUS_DCCAL == i_hwpCall) + { + // I have no idea what this value means or how it came to be this + // particular value. It was replicated from + // /fips920/src/hwsv/server/services/hwco/hwcoNodeSMP.C + uint32_t l_laneVector = 0x00FFFFFF; + FAPI_INVOKE_HWP(l_err, + p9_io_obus_dccal, + l_fapi2Target, + l_laneVector); + } + else if (P9_IO_OBUS_PRE_TRAINADV == i_hwpCall) + { + FAPI_INVOKE_HWP(l_err, + p9_io_obus_pre_trainadv, + l_fapi2Target); + } + else if (P9_IO_OBUS_LINKTRAIN == i_hwpCall) + { + FAPI_INVOKE_HWP(l_err, + p9_io_obus_linktrain, + l_fapi2Target); + } + else if (P9_IO_OBUS_POST_TRAINADV == i_hwpCall) + { + FAPI_INVOKE_HWP(l_err, + p9_io_obus_post_trainadv, + l_fapi2Target); + } + else + { + ++l_numberOfTrainFailures; + TRACFCOMP(g_trac_isteps_trace, + "ERROR: Invalid/Uknown OBUS HWP call"); + break; + } + + TRACFCOMP(g_trac_isteps_trace, + "%s : OBUS connection %s, target 0x%.8X", + (l_err ? "ERROR" : "SUCCESS"), + l_hwpCallStr, + get_huid(l_target)); + + if (l_err) + { + ++l_numberOfTrainFailures; + // Capture error and continue + captureError(l_err, + o_stepError, + HWPF_COMP_ID, + l_target); + + // Skip training of second end point if doing link train or dccal + if ( (P9_IO_OBUS_LINKTRAIN == i_hwpCall) || + (P9_IO_OBUS_DCCAL == i_hwpCall) ) break; + } + } // end for (const auto l_target: l_targets) + + TRACFCOMP(g_trac_isteps_trace, EXIT_MRK"trainObus (%s) exit", l_hwpCallStr); + + return l_numberOfTrainFailures; +} + +/** + * trainBusHandler + */ +bool trainBusHandler(TYPE i_busType, + HWP_CALL_TYPE i_hwpCall, + ISTEP_ERROR::IStepError &o_stepError, + compId_t i_componentId, + const TargetPairs_t &i_pbusConnections) +{ + bool retSuccess = true; + + if (i_pbusConnections.empty()) + { + TRACFCOMP(g_trac_isteps_trace, "Connection bus list is empty. " + "HWP call %s will not be called.", + hwpCallToString(i_hwpCall)); + } + + // Iterate over the pbus connections + for (const auto & l_pbusConnection: i_pbusConnections) + { + TRACFCOMP(g_trac_isteps_trace, "Attempting to train %s %s on " + "bus connections 0x%.8X and 0x%.8X", + (i_busType == TYPE_OBUS ? "OBUS" : (i_busType == TYPE_XBUS ? "XBUS" : "")), + hwpCallToString(i_hwpCall), + get_huid(l_pbusConnection.first), + get_huid(l_pbusConnection.second)); + + uint32_t l_numberOfTrainFailures(0); + + if (TYPE_OBUS == i_busType) + { + l_numberOfTrainFailures = trainObus(i_hwpCall, + o_stepError, + i_componentId, + l_pbusConnection.first, + l_pbusConnection.second); + } + else if (TYPE_XBUS == i_busType) + { + l_numberOfTrainFailures = trainObus(i_hwpCall, + o_stepError, + i_componentId, + l_pbusConnection.first, + l_pbusConnection.second); + } + else + { + ++l_numberOfTrainFailures; + TRACFCOMP(g_trac_isteps_trace, + "ERROR: Invalid/Uknown BUS type"); + } + + if (l_numberOfTrainFailures) + { + TRACFCOMP(g_trac_isteps_trace, + "Running %s HWP resulted in %d errors", + hwpCallToString(i_hwpCall), + l_numberOfTrainFailures); + + retSuccess = false; + // stop processing OBUS if encountered an error + break; + } + } // end for (const auto & l_pbusConnection: i_pbusConnections) + + return retSuccess; +} + + +} // end namespace ISTEP_09 + diff --git a/src/usr/isteps/istep09/istep09HelperFuncs.H b/src/usr/isteps/istep09/istep09HelperFuncs.H new file mode 100644 index 000000000..dfc6318c6 --- /dev/null +++ b/src/usr/isteps/istep09/istep09HelperFuncs.H @@ -0,0 +1,183 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/usr/isteps/istep09/istep09HelperFuncs.H $ */ +/* */ +/* OpenPOWER HostBoot Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2015,2018 */ +/* [+] International Business Machines Corp. */ +/* */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); */ +/* you may not use this file except in compliance with the License. */ +/* You may obtain a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ +/* implied. See the License for the specific language governing */ +/* permissions and limitations under the License. */ +/* */ +/* IBM_PROLOG_END_TAG */ + +#ifndef _ISTEP09_HELPER_FUNCS_H +#define _ISTEP09_HELPER_FUNCS_H + +/******************************************************************************/ +// Includes +/******************************************************************************/ +// Integral and component ID support +#include <stdint.h> // uint32_t +#include <hbotcompid.H> // HWPF_COMP_ID + +// Error handling support +#include <isteps/hwpisteperror.H> // ISTEP_ERROR::IStepError + +// TARGETING support +#include <attributeenums.H> // TARGETING::TYPE + +// Pbus link service support +#include <pbusLinkSvc.H> // TargetPairs_t + +// forward declare TARGETING::Target +namespace TARGETING +{ + class Target; +} + +namespace ISTEP_09 +{ + +/** + * @brief There seemed to be a lot of duplicated code (cut and paste) in + * different files. I provide an interface to this duplicated code and + * consolidated it here, so if the protocol ever changes there is only + * one place to make changes. + * + * @note To take advantage of this consolidation, follow these guidelines + * 1) Make sure that one of these methods will suffice for your needs + * 2) Add an enum to HWP_CALL_TYPE that is specific to your needs (in + * this .H file). This enum is the key to calling the correct HWP + * call you wish to perform. + * NOTE: Please update the LAST_VALUE with the newly added enum + * 3) Add a string representation of the HWP call to + * hwpCallToStringMap (in .C file). + * 4) Update one of the methods below to accommodate the new HWP call + * (in .C file). + * NOTE: Don't forget to update include directives as well + * 5) Finally call the method with the correct parameters in the file + * that wishes to make the HWP call + */ + +/** + * @brief Enum specifying which HWP to call + */ +enum HWP_CALL_TYPE +{ + // These enums pertain to the trainbus call + P9_IO_XBUS_PRE_TRAINADV, // XBUS pre training + P9_IO_XBUS_POST_TRAINADV, // XBUS post training + P9_IO_OBUS_DCCAL, // OBUS dccal + P9_IO_OBUS_PRE_TRAINADV, // OBUS pre training + P9_IO_OBUS_LINKTRAIN, // OBUS link training + P9_IO_OBUS_POST_TRAINADV, // OBUS post training +}; + +/** + * @brief + * Handy utility to convert an enumeration to its equivalent string. + * This is a mapping of the HWP enumeration to its string representation + * + * @param[in] i_hwpCall + * @see fapiHWPCallWrapper + * + * @return + * Returned is the string equivalent of the enumeration supplied. If the + * enumeration supplied is not valid, then an empty string is returned + * + * @note + * Do not attempt to delete the returned string, it is immutable + */ +const char * hwpCallToString( HWP_CALL_TYPE i_hwpCall ); + +/** + * @brief + * These two functions train the appropriate XBUS/OBUS based on the + * enumeration passed in. + * + * @param[in] i_hwpCall + * An enumeration that specifies which HWP will be called + * + * @param[out] o_stepError + * @param[in] i_componentId + * @see hostboot/src/usr/isteps/istepHelperFuncs.H:captureError + * + * @param[in] i_firstTarget + * @param[in] i_secondTarget + * TAREGTING::Target(s) that are converted to fapi2:Target(s) which are + * passed to HWP call that is specified by the i_hwpCall + * + * @return + * The number of errors encountered while executing the HWP call + * + * @pre + * i_hwpCall is a valid HWP_CALL_TYPE enum for an XBUS call. + * i_firstTarget and i_secondTarget are valid targets (not NULL). + * + * @post + * The HWP call, for the given i_hwpCall, is executed for the given + * targets (i_firstTarget and i_secondTarget). If any error occurs, + * the details of the error will be contained in o_stepError. + * + * @note + * If i_hwpCall is not a valid value and/or i_firstTarget/i_secondTarget + * are NULL then the code will be halted via an assert. + * + */ + +// Use this call if the fapi2 target type is TARGET_TYPE_XBUS +uint32_t trainXbus(HWP_CALL_TYPE i_hwpCall, + ISTEP_ERROR::IStepError &o_stepError, + compId_t i_componentId, + const TARGETING::Target* i_firstTarget, + const TARGETING::Target* i_secondTarget); + +// Use this call if the fapi2 target type is TARGET_TYPE_OBUS +uint32_t trainObus(HWP_CALL_TYPE i_hwpCall, + ISTEP_ERROR::IStepError &o_stepError, + compId_t i_componentId, + const TARGETING::Target* i_firstTarget, + const TARGETING::Target* i_secondTarget); + +/** + * @brief + * This functions "handles" the call to trainXbus/trainObus. If the call + * succeeds then true is returned else false is returned. If + * the call fails this function will print an error message + * stating so. + * + * This is mainly a pass-thru function call to method fapiHWPCallWrapper. + * It's main purpose is to return whether method fapiHWPCallWrapper + * succeded or failed and print an error message upon failure. + * + * @param[in] i_busType Type of the bus to process, currently XBUS or OBUS + * @param[in] i_hwpCall @see trainXbus/trainObus + * @param[out] o_stepError @see trainXbus/trainObus + * @param[in] i_componentId @see trainXbus/trainObus + * @param[in] i_targetPairs bus pair connections (XBUS or OBUS) + * + * @return true if call succeeds, false otherwise + * + */ +bool trainBusHandler(TARGETING::TYPE i_busType, + HWP_CALL_TYPE i_hwpCall, + ISTEP_ERROR::IStepError &o_stepError, + compId_t i_componentId, + const EDI_EI_INITIALIZATION::TargetPairs_t &i_targetPairs); + +}; // end namespace ISTEP_09 + +#endif diff --git a/src/usr/isteps/istep09/makefile b/src/usr/isteps/istep09/makefile index a393ce668..64dfd3700 100644 --- a/src/usr/isteps/istep09/makefile +++ b/src/usr/isteps/istep09/makefile @@ -44,6 +44,7 @@ OBJS += call_fabric_post_trainadv.o OBJS += call_proc_smp_link_layer.o OBJS += call_proc_fab_iovalid.o OBJS += call_host_fbc_eff_config_aggregate.o +OBJS += istep09HelperFuncs.o VPATH += ${PROCEDURES_PATH}/hwp/nest/ ${PROCEDURES_PATH}/hwp/io/ @@ -61,16 +62,24 @@ include ${PROCEDURES_PATH}/hwp/io/p9_io_erepairSetFailedLanesHwp.mk OBJS+= p9_io_xbus_dccal.o include ${PROCEDURES_PATH}/hwp/io/p9_io_common.mk -# fabric_pre_trainadv +# fabric_pre_trainadv: p9_io_xbus_pre_trainadv include ${PROCEDURES_PATH}/hwp/io/p9_io_xbus_pre_trainadv.mk +# fabric_pre_trainadv: p9_io_obus_pre_trainadv +include ${PROCEDURES_PATH}/hwp/io/p9_io_obus_pre_trainadv.mk + +# fabric_pre_trainadv: p9_io_obus_dccal +include ${PROCEDURES_PATH}/hwp/io/p9_io_obus_dccal.mk + # fabric_io_run_training #p9_io_xbus_linktrain.mk has includes we dont need so manually add the .o OBJS+= p9_io_xbus_linktrain.o +OBJS+= p9_io_obus_linktrain.o #Skipping p9_io_xbus_clear_firs, already included by libprdf.so -# fabric_post_trainadv +# fabric_post_trainadv: xbus & obus include ${PROCEDURES_PATH}/hwp/io/p9_io_xbus_post_trainadv.mk +include ${PROCEDURES_PATH}/hwp/io/p9_io_obus_post_trainadv.mk # proc_smp_link_layer : Start SMP link layer include ${PROCEDURES_PATH}/hwp/nest/p9_smp_link_layer.mk |