From e8fdc1c11a1ee3c9406b75ebb45b619371e60182 Mon Sep 17 00:00:00 2001 From: crgeddes Date: Tue, 16 Feb 2016 15:14:03 -0600 Subject: Add getOtherEnd to fapi2::Target RTC:129517 Change-Id: I7270b194b609daf8e547313cf73a640e4adc48aa Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/21873 Tested-by: Jenkins Server Tested-by: FSP CI Jenkins Reviewed-by: Daniel M. Crowell Reviewed-by: Thi N. Tran Reviewed-by: Richard J. Knight Reviewed-by: William G. Hoffa --- src/include/usr/fapi2/hwpf_fapi2_reasoncodes.H | 5 + src/include/usr/fapi2/target.H | 149 +++++++++++++++++++++++-- 2 files changed, 146 insertions(+), 8 deletions(-) (limited to 'src/include/usr/fapi2') diff --git a/src/include/usr/fapi2/hwpf_fapi2_reasoncodes.H b/src/include/usr/fapi2/hwpf_fapi2_reasoncodes.H index c737ca692..730e809f7 100644 --- a/src/include/usr/fapi2/hwpf_fapi2_reasoncodes.H +++ b/src/include/usr/fapi2/hwpf_fapi2_reasoncodes.H @@ -48,6 +48,8 @@ namespace fapi2 MOD_FAPI2_PLAT_GET_PARENT_TEST = 0x05, MOD_FAPI2_PLAT_GET_CHILDREN_TEST = 0x06, MOD_FAPI2_VERIFYCFAMACCESSTARGET = 0x07, + MOD_FAPI2_PLAT_GET_OTHER_END_TEST = 0x08, + MOD_FAPI2_PLAT_GET_OTHER_END = 0x09, }; /** @@ -90,6 +92,9 @@ namespace fapi2 RC_SBE_NO_PROC_FOUND = FAPI2_COMP_ID | 0x21, RC_INVALID_CHILD_COUNT = FAPI2_COMP_ID | 0x22, RC_UNIT_NO_PERV_FOUND = FAPI2_COMP_ID | 0x23, + RC_INCORRECT_OTHER_END = FAPI2_COMP_ID | 0x24, + RC_FOUND_TOO_MANY_PEERS = FAPI2_COMP_ID | 0x25, + RC_FOUND_NO_PEERS = FAPI2_COMP_ID | 0x26, // HWP generated errors RC_HWP_GENERATED_ERROR = HWPF_COMP_ID | 0x0f, diff --git a/src/include/usr/fapi2/target.H b/src/include/usr/fapi2/target.H index 5f21eb3b3..068fe2586 100644 --- a/src/include/usr/fapi2/target.H +++ b/src/include/usr/fapi2/target.H @@ -39,15 +39,27 @@ #include #include #include -#include #include +#include +#include + +#include // HB platform support #include #include #include +#include #include +#include +#include + +//@TODO RTC:150675 get error info from getOtherEnd fails +//#include +//#include + + namespace PLAT_TARGET { @@ -716,10 +728,10 @@ FAPI_DBG(ENTER_MRK "getChildren. Type 0x%08x State:0x%08x", T, i_state); /// /// @brief Get the target at the other end of a bus - dimm included -/// @tparam T The type of the parent +/// @tparam T The type of the the other end /// @tparam K The type of target of which this is called /// @tparam V the type of the target's Value -/// @param[in] i_state The desired TargetState of the children +/// @param[in] i_state The desired TargetState of the other end /// @return Target a target representing the thing on the other end /// @note Can be easily changed to a vector if needed /// @@ -728,11 +740,132 @@ template inline Target Target::getOtherEnd(const TargetState i_state) const { - //@TODO RTC:129517 - // Implementation note: cast to a composite of - // bus types and the compiler will check if this is - // a good function at compile time - return Target(); + fapi2::Target l_target; + this->getOtherEnd( l_target, i_state); + + return l_target; + +} + +/// +/// @brief Get the target at the other end of a bus +/// @tparam T The type of the target on the other end +/// @param[out] o_target A target representing the thing on the other end +/// @param[in] i_state The desired TargetState of the other end +/// @return FAPI2_RC_SUCCESS if OK, platforms will return a non-success +/// ReturnCode in the event of failure +/// @note o_target is only valid if return is FAPI2_RC_SUCCESS +/// +template +template +inline fapi2::ReturnCodes +Target::getOtherEnd(fapi2::Target& o_target, + const TargetState i_state) const +{ + ReturnCodes l_rc; +// errlHndl_t l_errl = NULL; + TARGETING::TargetHandleList l_peerTargetList; + TARGETING::TYPE requiredPeerType = fapi2::convertFapi2TypeToTargeting(T); + TARGETING::CLASS targetClass = TARGETING::CLASS_NA; + + //TODO RTC:148934 add static_asserts for correct types + switch(requiredPeerType) + { + case TARGETING::TYPE_XBUS : + targetClass = TARGETING::CLASS_UNIT; break; + case TARGETING::TYPE_OBUS : + targetClass = TARGETING::CLASS_UNIT; break; + case TARGETING::TYPE_DMI : + targetClass = TARGETING::CLASS_UNIT; break; + case TARGETING::TYPE_DIMM : + targetClass = TARGETING::CLASS_LOGICAL_CARD; break; + case TARGETING::TYPE_MEMBUF : + targetClass = TARGETING::CLASS_CHIP; break; + default: + break; + } + TARGETING::PredicateCTM l_peerFilter(targetClass); + + if(i_state == TARGET_STATE_FUNCTIONAL) + { + TARGETING::PredicateIsFunctional l_funcFilter; + TARGETING::PredicatePostfixExpr l_funcAndpeerFilter; + l_funcAndpeerFilter.push(&l_peerFilter).push(&l_funcFilter).And(); + getPeerTargets( l_peerTargetList, // list of targets on other end + static_cast(this->get()),//To this target + NULL/*&l_peerFilter*/, // Don't need to filter peers + &l_funcAndpeerFilter);//filter results to be the right class & state + } + else if(i_state == TARGET_STATE_PRESENT) + { + TARGETING::PredicatePostfixExpr l_presAndpeerFilter; + l_presAndpeerFilter.push(&l_peerFilter); + + getPeerTargets( l_peerTargetList, // list of targets on other end + static_cast(this->get()), //to this target + NULL, //No need to filter peers + &l_presAndpeerFilter);//filter results to be the right class & state + } + + fapi2::Target fapi2_peerTarget = NULL; + + if(l_peerTargetList.size() == 0) + { + l_rc = FAPI2_RC_FALSE; + //@TODO RTC:150675 get error info from getOtherEnd fails +#if 0 + /*@ + * @errortype ERRORLOG::ERRL_SEV_UNRECOVERABLE + * @moduleid fapi2::MOD_FAPI2_PLAT_GET_OTHER_END + * @reasoncode fapi2::RC_FOUND_NO_PEERS + * @userdata1[0:31] Unused + * @userdata1[32:63] Unused + * @userdata2 Unused + * @devdesc Unable to resolve other end of xbus + */ + l_errl = new ERRORLOG::ErrlEntry(ERRORLOG::ERRL_SEV_UNRECOVERABLE, + fapi2::MOD_FAPI2_PLAT_GET_OTHER_END, + fapi2::RC_FOUND_NO_PEERS, + NULL, + NULL, + true/*SW Error*/); + errlCommit(l_errl,FAPI2_COMP_ID); + // Add the error log pointer as data to the ReturnCode + l_rc.setPlatDataPtr(reinterpret_cast (l_errl)); +#endif + } + else if(l_peerTargetList.size() > 1) + { + l_rc = FAPI2_RC_FALSE; + //@TODO RTC:150675 get error info from getOtherEnd fails +#if 0 + /*@ + * @errortype ERRORLOG::ERRL_SEV_UNRECOVERABLE + * @moduleid fapi2::MOD_FAPI2_PLAT_GET_OTHER_END + * @reasoncode fapi2::RC_FOUND_TOO_MANY_PEERS + * @userdata1[0:31] Unused + * @userdata1[32:63] Unused + * @userdata2 Unused + * @devdesc Unable to resolve other end of xbus + */ + l_errl = new ERRORLOG::ErrlEntry(ERRORLOG::ERRL_SEV_UNRECOVERABLE, + fapi2::MOD_FAPI2_PLAT_GET_OTHER_END, + fapi2::RC_FOUND_TOO_MANY_PEERS, + NULL, + NULL, + true/*SW Error*/); + errlCommit(l_errl,FAPI2_COMP_ID); + // Add the error log pointer as data to the ReturnCode + l_rc.setPlatDataPtr(reinterpret_cast (l_err)); +#endif + } + else + { + fapi2_peerTarget = fapi2::Target(l_peerTargetList[0]); + } + o_target = fapi2_peerTarget; + + return l_rc; } -- cgit v1.2.3