diff options
| author | Nick Bofferding <bofferdn@us.ibm.com> | 2016-03-15 14:10:01 -0500 |
|---|---|---|
| committer | William G. Hoffa <wghoffa@us.ibm.com> | 2016-03-29 17:13:00 -0400 |
| commit | d69021c4f1acb33cef4692ce85cead2540412862 (patch) | |
| tree | d640d2b9ff69055b3c649f5d8b977f133d99d36d /src/usr/runtime | |
| parent | 0ceb12be50b8542714a981cbaee2d41244d49507 (diff) | |
| download | blackbird-hostboot-d69021c4f1acb33cef4692ce85cead2540412862.tar.gz blackbird-hostboot-d69021c4f1acb33cef4692ce85cead2540412862.zip | |
Support runtime target translation for Phyp
- Added ordinal IDs to system XML files
- Added new HBRT_HYP_ID attribute to proc, membuf, core targets
- Removed duplicate target type extensions
- Customize HBRT_HYP_ID attributes in istep 21 based on payload type
- Updated runtime translation interfaces for simple, efficient lookup
- Added templated memoizer to speed up simple input/output functions
- Generate ordinal IDs in common attribute parser
- Added various test cases
RTC: 146153
CMVC-Coreq: 989094
Change-Id: Ic60996f3b7c3197191f8939f362c578b54475df4
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/22254
Tested-by: Jenkins Server
Tested-by: FSP CI Jenkins
Reviewed-by: Christian R. Geddes <crgeddes@us.ibm.com>
Reviewed-by: Corey V. Swenson <cswenson@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Reviewed-by: William G. Hoffa <wghoffa@us.ibm.com>
Diffstat (limited to 'src/usr/runtime')
| -rw-r--r-- | src/usr/runtime/customize_attrs_for_payload.C | 419 | ||||
| -rw-r--r-- | src/usr/runtime/makefile | 3 | ||||
| -rw-r--r-- | src/usr/runtime/test/makefile | 16 | ||||
| -rw-r--r-- | src/usr/runtime/test/test_customize_attrs_for_payload.H | 458 |
4 files changed, 892 insertions, 4 deletions
diff --git a/src/usr/runtime/customize_attrs_for_payload.C b/src/usr/runtime/customize_attrs_for_payload.C new file mode 100644 index 000000000..e1c0ddba2 --- /dev/null +++ b/src/usr/runtime/customize_attrs_for_payload.C @@ -0,0 +1,419 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/usr/runtime/customize_attrs_for_payload.C $ */ +/* */ +/* OpenPOWER HostBoot Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2012,2016 */ +/* [+] 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 */ + +/** + * @file customize_attrs_for_payload.C + * + * @brief Customize attributes in the targeting model that vary based on + * payload which are only needed for runtime operation + */ + +//#include <sys/misc.h> +#include <trace/interface.H> +#include <errl/errlentry.H> +#include <targeting/common/target.H> +#include <targeting/common/targetservice.H> +#include <targeting/common/utilFilter.H> +#include <runtime/runtime_reasoncodes.H> +#include <runtime/runtime.H> +#include <errl/errlmanager.H> +#include <runtime/rt_targeting.H> +#include <arch/pirformat.H> +#include <targeting/common/util.H> +#include <errl/errludtarget.H> +#include <runtime/customize_attrs_for_payload.H> + +extern trace_desc_t *g_trac_runtime; + +namespace RUNTIME +{ + +/** + * @brief Create procesor targeting target not found error + * @param[in] i_pTarget Targeting target which did not have a processor + * targeting target. Must not be NULL (asserts otherwise) + * @return Error log handle + * @retval !NULL New error log indicating the error + */ +errlHndl_t createProcNotFoundError( + const TARGETING::Target* const i_pTarget) +{ + assert(i_pTarget != NULL); + + errlHndl_t pError = NULL; + auto huid = TARGETING::get_huid(i_pTarget); + TRACFCOMP(g_trac_runtime, ERR_MRK + " No processor targeting target found for targeting target with " + "HUID of 0x%08X", + huid); + + // Note: the module ID below references the function that exclusively + // creates this error + /*@ + * @errortype + * @moduleid RUNTIME::MOD_CUST_COMP_NON_PHYP_RT_TARGET + * @reasoncode RUNTIME::RT_NO_PROC_TARGET + * @userdata1 Input targeting target's HUID + * @devdesc No processor targeting target was found for the given + * targeting target + */ + pError = new ERRORLOG::ErrlEntry( + ERRORLOG::ERRL_SEV_INFORMATIONAL, + RUNTIME::MOD_CUST_COMP_NON_PHYP_RT_TARGET, + RUNTIME::RT_NO_PROC_TARGET, + huid, + 0, + true); + + ERRORLOG::ErrlUserDetailsTarget(i_pTarget,"Targeting target"). + addToLog(pError); + + return pError; +} + +/** + * @brief Returns the runtime target ID for a given targeting target for all + * hypervisors other than PHyp + * @param[in] i_pTarget Targeting target, must not be NULL (asserts + * otherwise) + * @param[out] o_rtTargetId Runtime target ID which maps to the given targeting + * target + * @return Error log handle + * @retval NULL Computed a valid runtime target ID for the given input + * targeting target and returned it in the output parameter. + * @retval !NULL Failed to compute a runtime target ID for the given input + * targeting target. Ignore output parameter. + */ +errlHndl_t computeNonPhypRtTarget( + const TARGETING::Target* i_pTarget, + RT_TARG::rtChipId_t& o_rtTargetId) +{ + assert(i_pTarget != NULL); + + errlHndl_t pError = NULL; + + do + { + if(i_pTarget == TARGETING::MASTER_PROCESSOR_CHIP_TARGET_SENTINEL) + { + TARGETING::Target* masterProcChip = NULL; + TARGETING::targetService(). + masterProcChipTargetHandle(masterProcChip); + i_pTarget = masterProcChip; + } + + auto targetingTargetType = i_pTarget->getAttr<TARGETING::ATTR_TYPE>(); + + if(targetingTargetType == TARGETING::TYPE_PROC) + { + uint32_t fabId = + i_pTarget->getAttr<TARGETING::ATTR_FABRIC_GROUP_ID>(); + + uint32_t procPos = + i_pTarget->getAttr<TARGETING::ATTR_FABRIC_CHIP_ID>(); + + o_rtTargetId = PIR_t::createChipId( fabId, procPos ); + } + else if( targetingTargetType == TARGETING::TYPE_MEMBUF) + { + //MEMBUF + // 0b1000.0000.0000.0000.0000.0GGG.GCCC.MMMM + // where GGGG is group, CCC is chip, MMMM is memory channel + // + TARGETING::TargetHandleList targetList; + + getParentAffinityTargets(targetList, + i_pTarget, + TARGETING::CLASS_UNIT, + TARGETING::TYPE_MCS); + + if( targetList.empty() ) + { + auto huid = get_huid(i_pTarget); + TRACFCOMP(g_trac_runtime, ERR_MRK + "No associated MCS targeting target(s) found for MEMBUF " + "targeting target with HUID of 0x%08X", + huid); + /*@ + * @error + * @moduleid RUNTIME::MOD_CUST_COMP_NON_PHYP_RT_TARGET + * @reasoncode RUNTIME::RT_UNIT_TARGET_NOT_FOUND + * @userdata1 MEMBUF targeting target's HUID + * @devdesc No associated MCS targeting target(s) found for + * given MEMBUF targeting target + */ + pError = new ERRORLOG::ErrlEntry( + ERRORLOG::ERRL_SEV_INFORMATIONAL, + RUNTIME::MOD_CUST_COMP_NON_PHYP_RT_TARGET, + RUNTIME::RT_UNIT_TARGET_NOT_FOUND, + huid, + 0, + true); + + ERRORLOG::ErrlUserDetailsTarget(i_pTarget,"Targeting Target"). + addToLog(pError); + + break; + } + + auto target = targetList[0]; + auto pos = target->getAttr<TARGETING::ATTR_CHIP_UNIT>(); + + targetList.clear(); + getParentAffinityTargets(targetList, + target, + TARGETING::CLASS_CHIP, + TARGETING::TYPE_PROC); + + if(targetList.empty()) + { + pError = createProcNotFoundError(target); + break; + } + + auto procTarget = targetList[0]; + pError = computeNonPhypRtTarget(procTarget, o_rtTargetId); + if(pError) + { + break; + } + + o_rtTargetId = (o_rtTargetId << RT_TARG::MEMBUF_ID_SHIFT); + o_rtTargetId += pos; + o_rtTargetId |= RT_TARG::MEMBUF_TYPE; + } + else if(targetingTargetType == TARGETING::TYPE_CORE) + { + // CORE + // 0b0100.0000.0000.0000.0000.GGGG.CCCP.PPPP + // GGGG is group, CCC is chip, PPPPP is core + auto pos = i_pTarget->getAttr<TARGETING::ATTR_CHIP_UNIT>(); + const TARGETING::Target* procTarget = getParentChip(i_pTarget); + if(procTarget == NULL) + { + pError = createProcNotFoundError(i_pTarget); + break; + } + + pError = computeNonPhypRtTarget(procTarget, o_rtTargetId); + if(pError) + { + break; + } + + o_rtTargetId = PIR_t::createCoreId(o_rtTargetId,pos); + o_rtTargetId |= RT_TARG::CORE_TYPE; + } + else + { + auto huid = get_huid(i_pTarget); + TRACFCOMP(g_trac_runtime,ERR_MRK + "Targeting target type 0x%08X not supported. Cannot " + "convert targeting target with HUID of 0x%08X into a " + "runtime target ID", + targetingTargetType, + huid); + /*@ + * @errortype + * @moduleid RUNTIME::MOD_CUST_COMP_NON_PHYP_RT_TARGET + * @reasoncode RUNTIME::RT_TARGET_TYPE_NOT_SUPPORTED + * @userdata1 Targeting target's HUID + * @userdata2 Targeting target's type + * @devdesc The targeting type of the input targeting target is + * not supported by runtime code + */ + pError = new ERRORLOG::ErrlEntry( + ERRORLOG::ERRL_SEV_INFORMATIONAL, + RUNTIME::MOD_CUST_COMP_NON_PHYP_RT_TARGET, + RUNTIME::RT_TARGET_TYPE_NOT_SUPPORTED, + huid, + targetingTargetType, + true); + + ERRORLOG::ErrlUserDetailsTarget(i_pTarget,"Targeting Target"). + addToLog(pError); + } + + } while(0); + + return pError; +} + +/** + * @brief Returns the runtime target type for a given targeting target + * @param[in] i_pTarget Targeting target, must not be NULL + * (asserts otherwise) + * @param[out] o_rtType Runtime target type for given targeting target + * @return Error log handle + * @retval NULL Returned supported runtime target type for the given input + * targeting target in the output parameter. + * @retval !NULL Failed to determine runtime target type for the + * given input targeting target, ignore output parameter. + */ +errlHndl_t getRtTypeForTarget( + const TARGETING::Target* i_pTarget, + RT_TARG::rtChipId_t& o_rtType) +{ + assert(i_pTarget != NULL); + + errlHndl_t pError = NULL; + + if(i_pTarget == TARGETING::MASTER_PROCESSOR_CHIP_TARGET_SENTINEL) + { + TARGETING::Target* masterProcChip = NULL; + TARGETING::targetService(). + masterProcChipTargetHandle(masterProcChip); + i_pTarget = masterProcChip; + } + + auto found = true; + auto rtType = RT_TYPE_UNKNOWN; + auto targetingTargetType = i_pTarget->getAttr<TARGETING::ATTR_TYPE>(); + switch(targetingTargetType) + { + case TARGETING::TYPE_PROC: + rtType = RT_TARG::PROC_TYPE; + break; + case TARGETING::TYPE_MEMBUF: + rtType = RT_TARG::MEMBUF_TYPE; + break; + case TARGETING::TYPE_CORE: + rtType = RT_TARG::CORE_TYPE; + break; + default: + found = false; + break; + } + + if(!found) + { + auto huid = get_huid(i_pTarget); + TRACFCOMP(g_trac_runtime, ERR_MRK + "Input targeting target's type of 0x%08X is not supported. " + "HUID: 0x%08X", + targetingTargetType, + huid); + /*@ + * @errortype + * @moduleid RUNTIME::MOD_CUST_CONF_HBRT_HYP_IDS + * @reasoncode RUNTIME::RT_TARGET_TYPE_NOT_SUPPORTED + * @userdata1 Target's HUID + * @userdata2 Target's targeting type + * @devdesc Targeting target's type not supported by runtime code + */ + pError = new ERRORLOG::ErrlEntry( + ERRORLOG::ERRL_SEV_INFORMATIONAL, + RUNTIME::MOD_CUST_CONF_HBRT_HYP_IDS, + RUNTIME::RT_TARGET_TYPE_NOT_SUPPORTED, + huid, + targetingTargetType, + true); + + ERRORLOG::ErrlUserDetailsTarget(i_pTarget,"Targeting Target"). + addToLog(pError); + } + + o_rtType = rtType; + + return pError; +} + +errlHndl_t configureHbrtHypIds(const bool i_configForPhyp) +{ + TRACDCOMP( g_trac_runtime, ENTER_MRK "configureHbrtHypIds" ); + + errlHndl_t pError = NULL; + + TARGETING::PredicateCTM isaProc( + TARGETING::CLASS_CHIP, TARGETING::TYPE_PROC); + TARGETING::PredicateCTM isaMembuf( + TARGETING::CLASS_CHIP, TARGETING::TYPE_MEMBUF); + TARGETING::PredicateCTM isaCore( + TARGETING::CLASS_UNIT, TARGETING::TYPE_CORE); + TARGETING::PredicatePostfixExpr isaProcMembufOrCore; + isaProcMembufOrCore.push(&isaProc).push(&isaMembuf).Or() + .push(&isaCore).Or(); + TARGETING::TargetRangeFilter pIt( + TARGETING::targetService().begin(), + TARGETING::targetService().end(), + &isaProcMembufOrCore); + for (; pIt; ++pIt) + { + auto hbrtHypId = HBRT_HYP_ID_UNKNOWN; + + // Phyp is the only special case + if(i_configForPhyp) + { + auto rtType = RT_TYPE_UNKNOWN; + pError = getRtTypeForTarget(*pIt,rtType); + if(pError) + { + break; + } + + // PHyp only operates on fused cores, so all core IDs + // must match that of the parent EX + if( (*pIt)->getAttr<TARGETING::ATTR_TYPE>() + == TARGETING::TYPE_CORE) + { + auto type = TARGETING::TYPE_EX; + const TARGETING::Target* pEx = + TARGETING::getParent(*pIt,type); + + // If this fails, everything is already hosed + assert(pEx != NULL); + + hbrtHypId = + pEx->getAttr<TARGETING::ATTR_ORDINAL_ID>(); + } + else + { + hbrtHypId = (*pIt)->getAttr<TARGETING::ATTR_ORDINAL_ID>(); + } + + hbrtHypId |= rtType; + } + else + { + pError = computeNonPhypRtTarget(*pIt,hbrtHypId); + if(pError) + { + break; + } + } + + (*pIt)->setAttr<TARGETING::ATTR_HBRT_HYP_ID>(hbrtHypId); + TRACDCOMP( g_trac_runtime, "configureHbrtHypIds> " + "Set ATTR_HBRT_HYP_ID attribute to 0x%016llX on targeting target " + "with HUID of 0x%08X", + hbrtHypId,TARGETING::get_huid(*pIt)); + } + + TRACDCOMP( g_trac_runtime, EXIT_MRK "configureHbrtHypIds" ); + + return pError; +} + +}; // End namespace RUNTIME diff --git a/src/usr/runtime/makefile b/src/usr/runtime/makefile index e8ecca91c..86e2e8e80 100644 --- a/src/usr/runtime/makefile +++ b/src/usr/runtime/makefile @@ -5,7 +5,7 @@ # # OpenPOWER HostBoot Project # -# Contributors Listed Below - COPYRIGHT 2012,2015 +# Contributors Listed Below - COPYRIGHT 2012,2016 # [+] International Business Machines Corp. # # @@ -38,6 +38,7 @@ OBJS += hdatservice.o OBJS += fakepayload.o OBJS += tce.o OBJS += errlud_hdat.o +OBJS += customize_attrs_for_payload.o SUBDIRS += test.d diff --git a/src/usr/runtime/test/makefile b/src/usr/runtime/test/makefile index a0a1c5c5c..bebc21cd2 100644 --- a/src/usr/runtime/test/makefile +++ b/src/usr/runtime/test/makefile @@ -5,7 +5,7 @@ # # OpenPOWER HostBoot Project # -# Contributors Listed Below - COPYRIGHT 2012,2015 +# Contributors Listed Below - COPYRIGHT 2012,2016 # [+] International Business Machines Corp. # # @@ -25,8 +25,18 @@ ROOTPATH = ../../../.. MODULE = testruntime -TESTS += hdatservicetest.H -TESTS += tcetest.H +#@TODO RTC 132750 +#TESTS += hdatservicetest.H +#TESTS += tcetest.H +TESTS += test_customize_attrs_for_payload.H + +# The testcase depends on the following file, but it is typically only compiled +# into the runtime code. Pull it into just the test module so we can exercise +# it +OBJS += rt_targeting.o + +# Use a vpath to give access to the rt_targeting.C code +vpath %.C ../../targeting/runtime #@TODO RTC:132750 #TESTS += runtimeattrtest.H diff --git a/src/usr/runtime/test/test_customize_attrs_for_payload.H b/src/usr/runtime/test/test_customize_attrs_for_payload.H new file mode 100644 index 000000000..130d3d2d9 --- /dev/null +++ b/src/usr/runtime/test/test_customize_attrs_for_payload.H @@ -0,0 +1,458 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/usr/runtime/test/test_customize_attrs_for_payload.H $ */ +/* */ +/* OpenPOWER HostBoot Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2016 */ +/* [+] 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 __TEST_CUST_ATTRS_FOR_PAYLOAD_H +#define __TEST_CUST_ATTRS_FOR_PAYLOAD_H + +/** + * @file test_customize_attrs_for_payload.H + * + */ + +#include <cxxtest/TestSuite.H> + +#include <targeting/common/target.H> +#include <targeting/common/targetservice.H> +#include <targeting/common/utilFilter.H> +#include <attributeenums.H> +#include <errl/errlmanager.H> +#include <runtime/customize_attrs_for_payload.H> +#include <runtime/rt_targeting.H> +#include <targeting/common/attributes.H> +#include <runtime/runtime_reasoncodes.H> +#include <map> + +namespace RT_TARG +{ + // Need to use the non-memoized version for some parts of the test + // to avoid cacheing results. We don't want this prototype generally + // exported so declaring it here + errlHndl_t _getHbTarget( + const rtChipId_t i_rtTargetId, + TARGETING::Target*& o_target); +}; + +class CustomizeAttrsForPayloadTest: public CxxTest::TestSuite +{ + public: + + CustomizeAttrsForPayloadTest() : + iv_configForPhyp(false), + iv_pSys(NULL) + { + } + + void testGetHbTargetCommon(void) + { + TS_TRACE( ENTER_MRK + "testGetHbTargetCommon> start" ); + + errlHndl_t pError = NULL; + + do { + + TARGETING::Target* pTarget = NULL; + auto rtTargetId = RUNTIME::HBRT_HYP_ID_UNKNOWN; + + pError = RT_TARG::getHbTarget( + rtTargetId, + pTarget); + if(pError==NULL) + { + TS_FAIL("testGetHbTargetCommon> call to getHbTarget did not " + "return error as expected"); + break; + } + + delete pError; + pError=NULL; + + if(pTarget != NULL) + { + TS_FAIL("testGetHbTargetCommon> call to getHbTarget returned " + "error but output is not NULL"); + break; + } + + } while(0); + + if(pError) + { + errlCommit(pError,RUNTIME_COMP_ID); + } + + TS_TRACE( EXIT_MRK + "testGetHbTargetCommon> finish" ); + } + + void testGetRtTargetCommon(void) + { + TS_TRACE( ENTER_MRK + "testGetRtTargetCommon> start" ); + + errlHndl_t pError = NULL; + + do { + + TARGETING::Target* pProc = NULL; + pError = TARGETING::targetService().queryMasterProcChipTargetHandle( + pProc); + if(pError) + { + TS_FAIL("testGetRtTargetCommon> failed to get master proc chip "); + break; + } + + TARGETING::PredicateCTM isaPhb( + TARGETING::CLASS_UNIT, TARGETING::TYPE_PHB); + + TARGETING::TargetHandleList phbs; + TARGETING::targetService().getAssociated( + phbs, + pProc, + TARGETING::TargetService::CHILD, + TARGETING::TargetService::ALL, + &isaPhb); + if(phbs.empty()) + { + TS_FAIL("testGetRtTargetCommon> failed to get any phb unit "); + break; + } + + TARGETING::Target* pTarget = phbs[0]; + auto rtTargetId = RUNTIME::HBRT_HYP_ID_UNKNOWN; + + pError = RT_TARG::getRtTarget( + pTarget, + rtTargetId); + if(pError==NULL) + { + TS_FAIL("testGetRtTargetCommon> call to getRtTarget did not " + "return error as expected"); + break; + } + + delete pError; + pError=NULL; + + if(rtTargetId != RUNTIME::HBRT_HYP_ID_UNKNOWN) + { + TS_FAIL("testGetRtTargetCommon> call to getRtTarget returned " + "error but did not return the unknown value"); + break; + } + + } while(0); + + if(pError) + { + errlCommit(pError,RUNTIME_COMP_ID); + } + + TS_TRACE( EXIT_MRK + "testGetRtTargetCommon> finish" ); + } + + void testGetRtAndHbTargetPhyp(void) + { + TS_TRACE( ENTER_MRK + "testGetRtAndHbTargetPhyp> start" ); + validateGetRtAndHbTarget(true); + TS_TRACE( EXIT_MRK + "testGetRtAndHbTargetPhyp> finish" ); + } + + void testGetRtAndHbTargetNonPhyp(void) + { + TS_TRACE( ENTER_MRK + "testGetRtAndHbTargetNonPhyp> start" ); + validateGetRtAndHbTarget(false); + TS_TRACE( EXIT_MRK + "testGetRtAndHbTargetNonPhyp> finish" ); + } + + private: + + void validateGetRtAndHbTarget(const bool i_configForPhyp) + { + TS_TRACE( ENTER_MRK + "validateGetRtAndHbTarget> start (i_configForPhyp = %d)", + i_configForPhyp ); + + errlHndl_t pError = NULL; + + do { + + pError = overrideState(i_configForPhyp); + if(pError) + { + TS_FAIL("validateGetRtAndHbTarget> failed to set " + "ATTR_HBRT_HYP_IDs"); + break; + } + + do { + + std::map< RT_TARG::rtChipId_t,size_t > uniqueRtTargetIds; + + const size_t FOUND_ONE_ID = 1; + + const TARGETING::TYPE targetingTargetTypes[] = + {TARGETING::TYPE_CORE, TARGETING::TYPE_PROC, + TARGETING::TYPE_MEMBUF}; + + auto failed = false; + for(TARGETING::TYPE targetingTargetType : targetingTargetTypes) + { + failed = true; + TARGETING::TargetHandleList targets; + TARGETING::getChildAffinityTargetsByState( + targets, + iv_pSys, + TARGETING::CLASS_NA, + targetingTargetType, + TARGETING::UTIL_FILTER_ALL); + if(targets.empty()) + { + TS_TRACE("validateGetRtAndHbTarget> No targeting targets of " + "type 0x%08X found in the blueprint, skipping.", + targetingTargetType); + failed = false; + continue; + } + + for(TARGETING::TargetHandleList::const_iterator pIt = + targets.begin(); + pIt != targets.end(); + ++pIt) + { + failed = true; + TARGETING::Target* pTarget = (*pIt); + + auto rtTargetId = RUNTIME::HBRT_HYP_ID_UNKNOWN; + pError = RT_TARG::getRtTarget( + pTarget, + rtTargetId); + if(pError!=NULL) + { + TS_FAIL("validateGetRtAndHbTarget> Failed call to " + "getRtTarget for targeting target with HUID of 0x%08X", + TARGETING::get_huid(pTarget)); + break; + } + + if(rtTargetId == RUNTIME::HBRT_HYP_ID_UNKNOWN) + { + TS_FAIL("validateGetRtAndHbTarget> call to getRtTarget " + "returned unchanged runtime target ID"); + break; + } + + // Every runtime target ID better be unique. Exception: for + // PHyp payloads which operate on fused cores, there can be + // at most 2 cores having same ID + auto alreadyPresent = uniqueRtTargetIds.count(rtTargetId); + if(alreadyPresent) + { + if( (i_configForPhyp) + && (targetingTargetType==TARGETING::TYPE_CORE) + && (uniqueRtTargetIds[rtTargetId] <= FOUND_ONE_ID)) + { + uniqueRtTargetIds[rtTargetId]++; + } + else + { + TS_FAIL("Already saw runtime target ID of 0x%016llX", + rtTargetId); + break; + } + } + else + { + uniqueRtTargetIds[rtTargetId]=FOUND_ONE_ID; + } + + auto actualRtTargetId = + pTarget->getAttr<TARGETING::ATTR_HBRT_HYP_ID>(); + if(actualRtTargetId != rtTargetId) + { + TS_FAIL("validateGetRtAndHbTarget> call to getRtTarget " + "returned runtime target ID of 0x%016llX which does " + "not match the targeting target's (HUID 0x%08x) " + "ATTR_HBRT_HYP_ID attribute value of 0x%016llX", + actualRtTargetId,TARGETING::get_huid(pTarget), + rtTargetId); + break; + } + + // Call to other interface should return original target. + TARGETING::Target* pActualTarget = NULL; + // Need to bypass memoize to ensure results are not cached + pError = RT_TARG::_getHbTarget( + actualRtTargetId, + pActualTarget); + if(pError!=NULL) + { + TS_FAIL("validateGetRtAndHbTarget> Failed call to " + "_getHbTarget for runtime target ID of 0x%016llX", + actualRtTargetId); + break; + } + + if(pActualTarget == NULL) + { + TS_FAIL("validateGetRtAndHbTarget> Call to " + "_getHbTarget returned NULL target for runtime target " + "ID of 0x%016llX", + actualRtTargetId); + break; + } + + if(pActualTarget != pTarget) + { + // Since Phyp deals with fused cores, and all cores per + // EX have the same ID, it's possible to get a different + // target back than the original target. If that is the + // case, verify each core resolves to the same EX parent + auto realError = true; + if( (i_configForPhyp) + && (targetingTargetType==TARGETING::TYPE_CORE)) + { + auto exType = TARGETING::TYPE_EX; + + const TARGETING::Target* pOrigEx = + TARGETING::getParent(pTarget,exType); + assert(pOrigEx != NULL); + const TARGETING::Target* pActualEx = + TARGETING::getParent(pActualTarget,exType); + assert(pActualEx != NULL); + + if(pOrigEx == pActualEx) + { + TS_TRACE("Returned target (HUID 0x%08X) different " + "from original target (HUID 0x%08X), but this " + "is expected for PHyp payloads when all cores " + "under an ex have same ID", + TARGETING::get_huid(pActualTarget), + TARGETING::get_huid(pTarget)); + realError = false; + } + } + + if(realError) + { + TS_FAIL("validateGetRtAndHbTarget> _getHbTarget " + "returned successfully for runtime target ID of " + "0x%016llX but returned targeting target (HUID of " + "0x%08X) was not the original (HUID of 0x%08X)", + actualRtTargetId,get_huid(pActualTarget), + get_huid(pTarget)); + break; + } + } + + failed = false; + } + + if(pError || failed) + { + break; + } + + failed = false; + } + + if(pError || failed) + { + break; + } + + } while(0); + + restoreState(pError); + + } while(0); + + if(pError) + { + errlCommit(pError,RUNTIME_COMP_ID); + } + + TS_TRACE( EXIT_MRK + "validateGetRtAndHbTarget> finish" ); + } + + bool iv_configForPhyp; + TARGETING::Target* iv_pSys; + + errlHndl_t overrideState(const bool i_configForPhyp) + { + errlHndl_t pError = NULL; + + do { + + TARGETING::Target* pSys = NULL; + TARGETING::targetService().getTopLevelTarget(pSys); + assert(pSys) + iv_pSys = pSys; + iv_configForPhyp = TARGETING::is_phyp_load(); + + pError = RUNTIME::configureHbrtHypIds(i_configForPhyp); + if(pError) + { + TS_FAIL("overrideState> failed to configure ATTR_HBRT_HYP_IDs. " + "i_configForPhyp = %d",i_configForPhyp); + break; + } + + } while(0); + + return pError; + } + + void restoreState(errlHndl_t& io_pError) + { + iv_pSys = NULL; + errlHndl_t pError = RUNTIME::configureHbrtHypIds(iv_configForPhyp); + if(pError) + { + TS_FAIL("restoreState> failed to reconfigure ATTR_HBRT_HYP_IDs. " + "iv_configForPhyp = %d",iv_configForPhyp); + if(!io_pError) + { + io_pError=pError; + pError = NULL; + } + else + { + errlCommit(pError,RUNTIME_COMP_ID); + } + } + } + +}; + +#endif + |

