summaryrefslogtreecommitdiffstats
path: root/src/usr/targeting/runtime
diff options
context:
space:
mode:
authorDoug Gilbert <dgilbert@us.ibm.com>2014-03-06 14:31:57 -0600
committerA. Patrick Williams III <iawillia@us.ibm.com>2014-03-20 14:47:01 -0500
commit6c6ededed27870f024c4e46fecfcdd2b477d30ee (patch)
treeb33320cf16a12f30e5158733ff5ce92a7a7fe01d /src/usr/targeting/runtime
parentc753ba81874b631e12d42ea70dafb7ffa9a2b253 (diff)
downloadtalos-hostboot-6c6ededed27870f024c4e46fecfcdd2b477d30ee.tar.gz
talos-hostboot-6c6ededed27870f024c4e46fecfcdd2b477d30ee.zip
HBRT fapi wakeup support
RTC: 98665 Change-Id: Ib9e9f8f3656989975cc08a29304ba7faa25c59e4 Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/9364 Tested-by: Jenkins Server Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com> Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/usr/targeting/runtime')
-rw-r--r--src/usr/targeting/runtime/makefile5
-rw-r--r--src/usr/targeting/runtime/rt_targeting.C400
-rw-r--r--src/usr/targeting/runtime/test/testtargeting.H72
3 files changed, 474 insertions, 3 deletions
diff --git a/src/usr/targeting/runtime/makefile b/src/usr/targeting/runtime/makefile
index 9efa9547f..51296c71e 100644
--- a/src/usr/targeting/runtime/makefile
+++ b/src/usr/targeting/runtime/makefile
@@ -5,7 +5,7 @@
#
# IBM CONFIDENTIAL
#
-# COPYRIGHT International Business Machines Corp. 2013
+# COPYRIGHT International Business Machines Corp. 2013,2014
#
# p1
#
@@ -30,7 +30,8 @@ TARGETING_REL_PATH = ..
include ${TARGETING_REL_PATH}/hostboot_common.mk
vpath %.C ${TARGETING_REL_PATH}
-HOSTBOOT_RUNTIME_SPECIFIC_OBJS = attrrp_rt.o start_rt.o targplatutil.o
+HOSTBOOT_RUNTIME_SPECIFIC_OBJS = attrrp_rt.o start_rt.o targplatutil.o \
+ rt_targeting.o
OBJS = ${COMMON_TARGETING_OBJS} ${HOSTBOOT_RUNTIME_SPECIFIC_OBJS}
diff --git a/src/usr/targeting/runtime/rt_targeting.C b/src/usr/targeting/runtime/rt_targeting.C
new file mode 100644
index 000000000..b0aa06aca
--- /dev/null
+++ b/src/usr/targeting/runtime/rt_targeting.C
@@ -0,0 +1,400 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/usr/targeting/runtime/rt_targeting.C $ */
+/* */
+/* IBM CONFIDENTIAL */
+/* */
+/* COPYRIGHT International Business Machines Corp. 2014 */
+/* */
+/* p1 */
+/* */
+/* Object Code Only (OCO) source materials */
+/* Licensed Internal Code Source Materials */
+/* IBM HostBoot Licensed Internal Code */
+/* */
+/* The source code for this program is not published or otherwise */
+/* divested of its trade secrets, irrespective of what has been */
+/* deposited with the U.S. Copyright Office. */
+/* */
+/* Origin: 30 */
+/* */
+/* IBM_PROLOG_END_TAG */
+#include <errl/errlentry.H>
+#include <errl/errlmanager.H>
+#include <errl/errludlogregister.H>
+#include <errl/errludtarget.H>
+#include <targeting/common/targetservice.H>
+#include <targeting/common/iterators/rangefilter.H>
+#include <targeting/common/predicates/predicatepostfixexpr.H>
+#include <targeting/common/predicates/predicateattrval.H>
+#include <targeting/common/predicates/predicatectm.H>
+#include <targeting/common/utilFilter.H>
+#include <targeting/common/trace.H>
+#include <targeting/common/targreasoncodes.H>
+
+#include <runtime/rt_targeting.H>
+
+using namespace TARGETING;
+
+namespace RT_TARG
+{
+
+errlHndl_t procRtTargetError(const TARGETING::Target * i_target)
+{
+ errlHndl_t err = NULL;
+ uint32_t huid = get_huid(i_target);
+ TRACFCOMP(g_trac_targeting,ERR_MRK
+ "No proc target found for target. huid: %08x",
+ huid);
+ /*@
+ * @errortype
+ * @moduleid TARG_RT_GET_RT_TARGET
+ * @reasoncode TARG_RT_NO_PROC_TARGET
+ * @userdata1 HUID of the UNIT target
+ * @devdesc No processor target found for the UNIT
+ */
+ err =
+ new ERRORLOG::ErrlEntry(ERRORLOG::ERRL_SEV_INFORMATIONAL,
+ TARGETING::TARG_RT_GET_RT_TARGET,
+ TARGETING::TARG_RT_NO_PROC_TARGET,
+ huid,
+ 0,
+ true);
+
+ ERRORLOG::ErrlUserDetailsTarget(i_target,"Runtime Target").
+ addToLog(err);
+
+ return err;
+}
+
+
+errlHndl_t getRtTarget(const TARGETING::Target* i_target,
+ rtChipId_t &o_chipId)
+{
+ errlHndl_t err = NULL;
+
+ do
+ {
+ if(i_target == TARGETING::MASTER_PROCESSOR_CHIP_TARGET_SENTINEL)
+ {
+ TARGETING::Target* masterProcChip = NULL;
+ TARGETING::targetService().
+ masterProcChipTargetHandle(masterProcChip);
+
+ i_target = masterProcChip;
+ }
+
+ TARGETING::TYPE target_type = i_target->getAttr<TARGETING::ATTR_TYPE>();
+
+ if(target_type == TARGETING::TYPE_PROC)
+ {
+ // use 0b0000.0000.0000.0000.0000.0000.00NN.NCCC:
+ uint32_t fabId =
+ i_target->getAttr<TARGETING::ATTR_FABRIC_NODE_ID>();
+
+ uint32_t procPos =
+ i_target->getAttr<TARGETING::ATTR_FABRIC_CHIP_ID>();
+
+ o_chipId = (fabId << CHIPID_NODE_SHIFT) + procPos;
+ }
+ else if( target_type == TARGETING::TYPE_MEMBUF)
+ {
+ //MEMBUF
+ // 0b1000.0000.0000.0000.0000.00NN.NCCC.MMMM
+ // where NNN id node, CCC is chip, MMMM is memory channel
+ //
+ TARGETING::TargetHandleList targetList;
+
+ getParentAffinityTargets(targetList,
+ i_target,
+ TARGETING::CLASS_UNIT,
+ TARGETING::TYPE_MCS);
+
+ if( targetList.empty() )
+ {
+ uint32_t huid = get_huid(i_target);
+ TRACFCOMP(g_trac_targeting,ERR_MRK
+ "getRtTarget: No target found for huid: %08x",
+ huid);
+ /*@
+ * @errortype
+ * @moduleid TARG_RT_GET_RT_TARGET
+ * @reasoncode TARG_RT_UNIT_TARGET_NOT_FOUND
+ * @userdata1 HUID of given MEMBUF target
+ * @devdesc No MCS target(s) found for the
+ * given MEMBUF target
+ */
+ err =
+ new ERRORLOG::ErrlEntry
+ (ERRORLOG::ERRL_SEV_INFORMATIONAL,
+ TARGETING::TARG_RT_GET_RT_TARGET,
+ TARGETING::TARG_RT_UNIT_TARGET_NOT_FOUND,
+ huid,
+ 0,
+ true);
+
+ ERRORLOG::ErrlUserDetailsTarget(i_target,"Runtime Target").
+ addToLog(err);
+
+ break;
+ }
+
+ TARGETING::Target * target = targetList[0];
+ uint32_t pos = target->getAttr<TARGETING::ATTR_CHIP_UNIT>();
+
+ targetList.clear();
+ getParentAffinityTargets(targetList,
+ target,
+ TARGETING::CLASS_CHIP,
+ TARGETING::TYPE_PROC);
+
+ if(targetList.empty())
+ {
+ err = procRtTargetError(target);
+ break;
+ }
+
+ TARGETING::Target * proc_target = targetList[0];
+
+ err = getRtTarget(proc_target, o_chipId);
+ if(err)
+ {
+ break;
+ }
+
+ o_chipId = (o_chipId << UNIT_ID_SHIFT);
+ o_chipId += pos;
+ o_chipId |= MEMBUF_ID_TYPE;
+ }
+ else if(target_type == TARGETING::TYPE_EX ||
+ target_type == TARGETING::TYPE_CORE)
+ {
+ // EX/CORE
+ // 0b0100.0000.0000.0000.0000.00NN.NCCC.PPPP
+ // NNN is node, CCC is chip, PPPP is core
+ uint32_t pos = i_target->getAttr<TARGETING::ATTR_CHIP_UNIT>();
+
+ const TARGETING::Target * proc_target = getParentChip(i_target);
+ if(proc_target == NULL)
+ {
+ err = procRtTargetError(i_target);
+ break;
+ }
+
+ err = getRtTarget(proc_target, o_chipId);
+ if(err)
+ {
+ break;
+ }
+
+ o_chipId = (o_chipId << UNIT_ID_SHIFT);
+ o_chipId += pos;
+ o_chipId |= CORE_ID_TYPE;
+ }
+ else
+ {
+ uint32_t huid = get_huid(i_target);
+ TRACFCOMP(g_trac_targeting,ERR_MRK
+ "Runtime target type %d not supported."
+ " huid: %08x",
+ target_type,
+ huid);
+ /*@
+ * @errortype
+ * @moduleid TARG_RT_GET_RT_TARGET
+ * @reasoncode TARG_RT_TARGET_TYPE_NOT_SUPPORTED
+ * @userdata1 HUID of the target
+ * @userdata2 target_type
+ * @devdesc Target type not supported by HBRT.
+ */
+ err =
+ new ERRORLOG::ErrlEntry
+ (ERRORLOG::ERRL_SEV_INFORMATIONAL,
+ TARGETING::TARG_RT_GET_RT_TARGET,
+ TARGETING::TARG_RT_TARGET_TYPE_NOT_SUPPORTED,
+ huid,
+ target_type,
+ true);
+
+ ERRORLOG::ErrlUserDetailsTarget(i_target,"Runtime Target").
+ addToLog(err);
+ }
+ } while(0);
+
+ return err;
+}
+
+
+errlHndl_t getHbTarget(rtChipId_t i_rt_chip_id,
+ TARGETING::Target *& o_target)
+{
+ errlHndl_t err = NULL;
+ o_target = NULL;
+
+ do
+ {
+ uint64_t idType = i_rt_chip_id & CHIPID_ID_MASK;
+
+ if(0 != (idType == MEMBUF_ID_TYPE))
+ {
+ //membuf
+ uint64_t chip_id = i_rt_chip_id & UNIT_ID_MASK;
+ uint32_t unitPos = chip_id & 0x0000000f;
+ chip_id >>= UNIT_ID_SHIFT;
+ TARGETING::Target * proc = NULL;
+ TARGETING::Target * msc = NULL;
+
+ err = getHbTarget(chip_id, proc);
+ if(err)
+ {
+ break;
+ }
+
+ PredicateCTM mcsFilter(CLASS_UNIT, TYPE_MCS);
+ PredicateAttrVal<ATTR_CHIP_UNIT> unitAttr(unitPos);
+ PredicatePostfixExpr mcsUnitFilter;
+ mcsUnitFilter.push(&mcsFilter).push(&unitAttr).And();
+
+ TargetHandleList target_list;
+
+ targetService().getAssociated( target_list,
+ proc,
+ TargetService::CHILD_BY_AFFINITY,
+ TargetService::ALL,
+ &mcsUnitFilter);
+
+ // should only be one result
+ if(target_list.size())
+ {
+ msc = target_list[0];
+
+ target_list.clear();
+
+
+ getChildAffinityTargets( target_list,
+ msc,
+ TARGETING::CLASS_CHIP,
+ TARGETING::TYPE_MEMBUF);
+
+ // should only be one result
+ if(target_list.size())
+ {
+ o_target = target_list[0];
+ }
+ }
+
+ if(o_target == NULL) // no mcs and/or membuf found
+ {
+ TRACFCOMP(g_trac_targeting,ERR_MRK "getHbTarget: "
+ "MCS or MEMBUF target not found for chipId %08lx",
+ i_rt_chip_id);
+ /*@
+ * @errortype
+ * @moduleid TARGETING::TARG_RT_GET_HB_TARGET
+ * @reasoncode TARG_RT_UNIT_TARGET_NOT_FOUND
+ * @userdata1 Runtime chip Id
+ * @devdesc No MCS or MEMBUF target(s) found for the
+ * given target
+ */
+ err =
+ new ERRORLOG::ErrlEntry
+ (ERRORLOG::ERRL_SEV_INFORMATIONAL,
+ TARGETING::TARG_RT_GET_HB_TARGET,
+ TARGETING::TARG_RT_UNIT_TARGET_NOT_FOUND,
+ i_rt_chip_id,
+ 0,
+ true);
+ }
+
+ }
+ else if(0 != (idType == CORE_ID_TYPE))
+ {
+ // core/ex will alway return EX chiplet as there is no concept
+ // (yet) of a core in fapi
+ uint64_t chip_id = i_rt_chip_id & UNIT_ID_MASK;
+ uint32_t unitPos = chip_id & 0x0000000f;
+ chip_id >>= UNIT_ID_SHIFT;
+ TARGETING::Target * proc = NULL;
+
+ err = getHbTarget(chip_id, proc);
+ if(err)
+ {
+ break;
+ }
+
+ PredicateCTM exFilter(CLASS_UNIT, TYPE_EX);
+ PredicateAttrVal<ATTR_CHIP_UNIT> unitAttr(unitPos);
+ PredicatePostfixExpr exUnitFilter;
+ exUnitFilter.push(&exFilter).push(&unitAttr).And();
+
+ TargetHandleList target_list;
+
+ targetService().getAssociated( target_list,
+ proc,
+ TargetService::CHILD,
+ TargetService::ALL,
+ &exUnitFilter);
+
+ //Should only be one result
+ if(target_list.size())
+ {
+ o_target = target_list[0];
+ }
+ // o_target not found caught below..
+ }
+ else if( idType == PROC_ID_TYPE)
+ {
+ // assume processor chip
+ // chip_id = 'NNNCCC'b
+ uint32_t fabId = i_rt_chip_id >> CHIPID_NODE_SHIFT;
+ uint32_t procPos = i_rt_chip_id & 0x7;
+
+ PredicateCTM procFilter(CLASS_CHIP, TYPE_PROC);
+ PredicateAttrVal<ATTR_FABRIC_NODE_ID> nodeFilter(fabId);
+ PredicateAttrVal<ATTR_FABRIC_CHIP_ID> chipFilter(procPos);
+
+ PredicatePostfixExpr theProc, theAttrs;
+ theAttrs.push(&nodeFilter).push(&chipFilter).And();
+ theProc.push(&procFilter).push(&theAttrs).And();
+
+ TargetRangeFilter procRange(targetService().begin(),
+ targetService().end(),
+ &theProc);
+
+ if(procRange)
+ {
+ o_target = *procRange;
+ }
+ }
+
+ if(!err && o_target == NULL)
+ {
+ TRACFCOMP( g_trac_targeting,
+ ERR_MRK"Can't find HB target for chipId 0x%lx",
+ i_rt_chip_id);
+ /*@
+ * @errortype
+ * @moduleid TARGETING::TARG_RT_GET_HB_TARGET
+ * @reasoncode TARGETING::TARG_RT_TARGET_TYPE_NOT_SUPPORTED
+ * @userdata1 runtime procId
+ * @userdata2 0
+ * @devdesc Can't find HB Target for chipId provided.
+ */
+ err =
+ new ERRORLOG::ErrlEntry
+ (
+ ERRORLOG::ERRL_SEV_UNRECOVERABLE,
+ TARGETING::TARG_RT_GET_HB_TARGET,
+ TARGETING::TARG_RT_TARGET_TYPE_NOT_SUPPORTED,
+ i_rt_chip_id,
+ 0,
+ true);
+
+ }
+ } while(0);
+
+ return err;
+}
+
+}; // namespace
diff --git a/src/usr/targeting/runtime/test/testtargeting.H b/src/usr/targeting/runtime/test/testtargeting.H
index d68ade369..22d79df05 100644
--- a/src/usr/targeting/runtime/test/testtargeting.H
+++ b/src/usr/targeting/runtime/test/testtargeting.H
@@ -5,7 +5,7 @@
/* */
/* IBM CONFIDENTIAL */
/* */
-/* COPYRIGHT International Business Machines Corp. 2013 */
+/* COPYRIGHT International Business Machines Corp. 2013,2014 */
/* */
/* p1 */
/* */
@@ -22,6 +22,11 @@
/* IBM_PROLOG_END_TAG */
#include <cxxtest/TestSuite.H>
#include <targeting/common/commontargeting.H>
+#include <runtime/rt_targeting.H>
+#include <errl/errlentry.H>
+#include <errl/errlmanager.H>
+#include <targeting/common/trace.H>
+#include <targeting/common/utilFilter.H>
class TargetingTestSuite : public CxxTest::TestSuite
{
@@ -42,4 +47,69 @@ class TargetingTestSuite : public CxxTest::TestSuite
(void)l_pTarget->getAttr<ATTR_PHYS_PATH>().dump();
}
+
+ void testHBRT_targets()
+ {
+ using namespace TARGETING;
+ errlHndl_t err = NULL;
+ RT_TARG::rtChipId_t rt_chipid;
+
+ TARGETING::TargetHandleList allTargets;
+ TARGETING::TargetHandleList targetList;
+
+ getAllChips(targetList, TYPE_PROC);
+
+ allTargets.insert(allTargets.end(),
+ targetList.begin(),
+ targetList.end());
+
+ targetList.clear();
+ getAllChips(targetList,TYPE_MEMBUF);
+
+ allTargets.insert(allTargets.end(),
+ targetList.begin(),
+ targetList.end());
+
+ targetList.clear();
+ getAllChiplets(targetList, TYPE_EX);
+
+ allTargets.insert(allTargets.end(),
+ targetList.begin(),
+ targetList.end());
+
+
+ for(TargetHandleList::iterator pTarg = allTargets.begin();
+ pTarg != allTargets.end(); ++pTarg)
+ {
+ err = RT_TARG::getRtTarget(*pTarg, rt_chipid);
+ if( err )
+ {
+ TS_FAIL("getRtTarget returned error log");
+ errlCommit( err, TARG_COMP_ID);
+ err = NULL;
+ break;
+ }
+ TRACDCOMP(g_trac_targeting,"chipId = %x",rt_chipid);
+
+ TARGETING::Target * target = NULL;
+
+ err = RT_TARG::getHbTarget(rt_chipid, target);
+ if(err)
+ {
+ TS_FAIL("getRtTarget_returned error log");
+ errlCommit( err, TARG_COMP_ID);
+ err = NULL;
+ break;
+ }
+
+ if(*pTarg != target)
+ {
+ TS_FAIL("testHBRT_targets failed for rt_chipID %x"
+ "target_in %p, target_out %p",
+ rt_chipid,
+ *pTarg,
+ target);
+ }
+ }
+ }
};
OpenPOWER on IntegriCloud