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/test | |
| parent | 0ceb12be50b8542714a981cbaee2d41244d49507 (diff) | |
| download | talos-hostboot-d69021c4f1acb33cef4692ce85cead2540412862.tar.gz talos-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/test')
| -rw-r--r-- | src/usr/runtime/test/makefile | 16 | ||||
| -rw-r--r-- | src/usr/runtime/test/test_customize_attrs_for_payload.H | 458 |
2 files changed, 471 insertions, 3 deletions
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 + |

