summaryrefslogtreecommitdiffstats
path: root/src/usr/diag/attn
diff options
context:
space:
mode:
authorSachin Gupta <sgupta2m@in.ibm.com>2014-11-17 05:01:25 -0600
committerA. Patrick Williams III <iawillia@us.ibm.com>2015-01-16 13:57:18 -0600
commit502ab08f36997744743ef03dea7dc4bc882d9af1 (patch)
treee09f50a7e40625f15ab3979822156b4e5c17b4cb /src/usr/diag/attn
parentc823e22a4b61d7db26ce7f3a744c5029b1ccf18e (diff)
downloadtalos-hostboot-502ab08f36997744743ef03dea7dc4bc882d9af1.tar.gz
talos-hostboot-502ab08f36997744743ef03dea7dc4bc882d9af1.zip
ATTN: Adding test cases for HBRT ATTN.
RTC: 118010 Change-Id: I542c8301db601b82885725e7c02b9542105acd42 Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/14514 Tested-by: Jenkins Server Reviewed-by: Zane Shelley <zshelle@us.ibm.com> Reviewed-by: Christopher T. Phan <cphan@us.ibm.com> Reviewed-by: Prem Shanker Jha <premjha2@in.ibm.com> Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/usr/diag/attn')
-rw-r--r--src/usr/diag/attn/common/attnsvc_common.C5
-rw-r--r--src/usr/diag/attn/runtime/test/attnfakeprd.C104
-rw-r--r--src/usr/diag/attn/runtime/test/attnfakeprd.H84
-rw-r--r--src/usr/diag/attn/runtime/test/attnfakereg.C98
-rw-r--r--src/usr/diag/attn/runtime/test/attnfakereg.H129
-rw-r--r--src/usr/diag/attn/runtime/test/attntestRtAttns.H195
-rw-r--r--src/usr/diag/attn/runtime/test/makefile4
7 files changed, 619 insertions, 0 deletions
diff --git a/src/usr/diag/attn/common/attnsvc_common.C b/src/usr/diag/attn/common/attnsvc_common.C
index 9acc19594..916e6123c 100644
--- a/src/usr/diag/attn/common/attnsvc_common.C
+++ b/src/usr/diag/attn/common/attnsvc_common.C
@@ -371,6 +371,8 @@ errlHndl_t ServiceCommon::handleAttentions(const TargetHandle_t i_proc)
if(err)
{
+ ATTN_ERR("procOps.resolve() returned error.HUID:0X%08X ",
+ get_huid( i_proc ));
break;
}
@@ -380,6 +382,8 @@ errlHndl_t ServiceCommon::handleAttentions(const TargetHandle_t i_proc)
if(err)
{
+ ATTN_ERR("memOps.resolve() returned error.HUID:0X%08X ",
+ get_huid( i_proc ));
break;
}
@@ -390,6 +394,7 @@ errlHndl_t ServiceCommon::handleAttentions(const TargetHandle_t i_proc)
if(err)
{
+ ATTN_ERR("callPrd() returned error." )
break;
}
#ifdef __HOSTBOOT_RUNTIME
diff --git a/src/usr/diag/attn/runtime/test/attnfakeprd.C b/src/usr/diag/attn/runtime/test/attnfakeprd.C
new file mode 100644
index 000000000..4f8fc1b45
--- /dev/null
+++ b/src/usr/diag/attn/runtime/test/attnfakeprd.C
@@ -0,0 +1,104 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/usr/diag/attn/runtime/test/attnfakeprd.C $ */
+/* */
+/* OpenPOWER HostBoot Project */
+/* */
+/* Contributors Listed Below - COPYRIGHT 2014 */
+/* [+] 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 attnfakeprd.C
+ *
+ * @brief HBATTN fake PRD class method definitions.
+ */
+
+#include "attnfakeprd.H"
+#include "diag/attn/attnreasoncodes.H"
+#include "../../common/attnops.H"
+#include "../../common/attnlist.H"
+#include "../../common/attntrace.H"
+
+using namespace PRDF;
+using namespace ERRORLOG;
+using namespace TARGETING;
+
+namespace ATTN
+{
+
+errlHndl_t FakePrd::callPrd(const AttentionList & i_attentions)
+{
+ errlHndl_t err = NULL;
+ PRDF::AttnList attns;
+ PRDF::AttnList expectedAttns;
+ int32_t rc = 0;
+
+ do
+ {
+ i_attentions.getAttnList( attns );
+ iv_expectedAttns.getAttnList( expectedAttns );
+ if( attns.size() != expectedAttns.size() )
+ {
+ ATTN_ERR("callPrd():: Test case failed. attns.size():%u, "
+ "expectedAttns.size():%u",
+ attns.size(), expectedAttns.size() );
+ rc = -1; break;
+ }
+ for( uint32_t i=0; i < attns.size(); i++ )
+ {
+ ATTN_SLOW("callPrd():: Input Attention HUID:0x%08X type:%u "
+ "Expected Attention HUID:0x%08X type:%u",
+ get_huid( attns[i].targetHndl), attns[i].attnType,
+ get_huid( expectedAttns[i].targetHndl),
+ expectedAttns[i].attnType);
+ if( (attns[i].targetHndl != expectedAttns[i].targetHndl ) ||
+ (attns[i].attnType != expectedAttns[i].attnType) )
+ {
+ ATTN_ERR("callPrd():: Test case failed as attention did "
+ " not match. ");
+ rc =-1; break;
+ }
+ }
+ }while(0);
+ if( 0 != rc )
+ {
+ /*@
+ * @errortype
+ * @reasoncode ATTN_TEST_ATTN_FAIL
+ * @severity ERRL_SEV_UNRECOVERABLE
+ * @moduleid ATTN_TEST_FAKE_CALL_PRD
+ * @userdata1 Input attention list size
+ * @userdata2 Expected attention list size
+ * @devdesc ATTN test case failed
+ */
+
+ err = new ErrlEntry(
+ ERRL_SEV_UNRECOVERABLE,
+ ATTN::ATTN_TEST_FAKE_CALL_PRD,
+ ATTN::ATTN_TEST_ATTN_FAIL,
+ attns.size(),
+ expectedAttns.size() );
+ }
+ return err;
+}
+
+void FakePrd::setExpectedAttn(AttentionList & i_expectAttns)
+{
+ iv_expectedAttns = i_expectAttns;
+}
+}
diff --git a/src/usr/diag/attn/runtime/test/attnfakeprd.H b/src/usr/diag/attn/runtime/test/attnfakeprd.H
new file mode 100644
index 000000000..317001eca
--- /dev/null
+++ b/src/usr/diag/attn/runtime/test/attnfakeprd.H
@@ -0,0 +1,84 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/usr/diag/attn/runtime/test/attnfakeprd.H $ */
+/* */
+/* OpenPOWER HostBoot Project */
+/* */
+/* Contributors Listed Below - COPYRIGHT 2014 */
+/* [+] 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_ATTNFAKEPRD_H
+#define __TEST_ATTNFAKEPRD_H
+
+/**
+ * @file attnfakeprd.H
+ *
+ * @brief HBATTN fake PRD class definitions.
+ */
+
+#include "../../common/attnprd.H"
+#include "../../common/attnlist.H"
+
+namespace ATTN
+{
+
+/**
+ * @brief FakePrd
+ *
+ * Basic PRD implementation that verifies attention list it
+ * receives with expected attention list.
+ */
+class FakePrd : public PrdImpl
+{
+ public:
+
+ /**
+ * @brief ctor
+ */
+ FakePrd(){};
+
+ /**
+ * @brief set expected attention list for test case.
+ *
+ * @param[in] i_attnList List of attentions for PRD to analyze.
+ */
+ void setExpectedAttn( AttentionList &i_attnList );
+
+ /**
+ * @brief dtor
+ */
+ ~FakePrd() {}
+
+ /**
+ * @brief callPrd Simulate a call to PRD.
+ *
+ * @param[in] i_attentions List of attentions for PRD to analyze.
+ *
+ * @return errlHndl_t Error log.
+ *
+ * @retval[0] No error occurred.
+ * @retval[!0] Unexpected error occurred.
+ */
+ errlHndl_t callPrd(const AttentionList & i_attentions);
+
+ private:
+ AttentionList iv_expectedAttns;
+
+};
+}
+#endif
diff --git a/src/usr/diag/attn/runtime/test/attnfakereg.C b/src/usr/diag/attn/runtime/test/attnfakereg.C
new file mode 100644
index 000000000..30902f070
--- /dev/null
+++ b/src/usr/diag/attn/runtime/test/attnfakereg.C
@@ -0,0 +1,98 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/usr/diag/attn/runtime/test/attnfakereg.C $ */
+/* */
+/* OpenPOWER HostBoot Project */
+/* */
+/* Contributors Listed Below - COPYRIGHT 2014 */
+/* [+] 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 attnfakereg.C
+ *
+ * @brief HBATTN fake register class method definitions.
+ */
+
+#include "../../common/attnlist.H"
+#include "../../common/attntrace.H"
+#include "../../common/attntarget.H"
+#include "attnfakereg.H"
+
+using namespace std;
+using namespace PRDF;
+using namespace TARGETING;
+
+namespace ATTN
+{
+
+errlHndl_t FakeRegSvc::putScom(
+ TargetHandle_t i_target,
+ uint64_t i_address,
+ uint64_t i_data)
+{
+
+ ATTN_DBG("FakeRegSvc::putScom: huid: 0x%08X, add: %016x, data: %016x",
+ get_huid(i_target), i_address, i_data);
+
+ iv_regs[i_target][i_address] = i_data;
+
+
+ return NULL;
+}
+
+errlHndl_t FakeRegSvc::getScom(
+ TargetHandle_t i_target,
+ uint64_t i_address,
+ uint64_t & o_data)
+{
+ o_data = iv_regs[i_target][i_address];
+
+ return NULL;
+}
+
+errlHndl_t FakeRegSvc::modifyScom(
+ TargetHandle_t i_target,
+ uint64_t i_address,
+ uint64_t i_data,
+ uint64_t & o_data,
+ ScomOp i_op)
+{
+ errlHndl_t err = 0;
+
+ uint64_t data = iv_regs[i_target][i_address];
+
+
+ uint64_t changedData = i_op == SCOM_OR
+ ? (data | i_data)
+ : (data & i_data);
+
+ bool changed = changedData != data;
+
+ if(changed)
+ {
+ putScom(
+ i_target,
+ i_address,
+ changedData);
+
+ }
+
+ return err;
+}
+}
+
diff --git a/src/usr/diag/attn/runtime/test/attnfakereg.H b/src/usr/diag/attn/runtime/test/attnfakereg.H
new file mode 100644
index 000000000..837c95b2f
--- /dev/null
+++ b/src/usr/diag/attn/runtime/test/attnfakereg.H
@@ -0,0 +1,129 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/usr/diag/attn/runtime/test/attnfakereg.H $ */
+/* */
+/* OpenPOWER HostBoot Project */
+/* */
+/* Contributors Listed Below - COPYRIGHT 2014 */
+/* [+] 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_ATTNFAKEREG_H
+#define __TEST_ATTNFAKEREG_H
+
+/**
+ * @file attnfakereg.H
+ *
+ * @brief HBATTN fake register class definition.
+ */
+
+#include "../../common/attnscom.H"
+#include <map>
+
+namespace ATTN
+{
+
+/**
+ * @brief FakeRegSvc
+ *
+ * Container that presents an interface to fake hardware
+ * implementations.
+ */
+class FakeRegSvc : public ScomImpl
+{
+ public:
+
+ /**
+ * @brief putScom Write a register using SCOM.
+ *
+ * @param[in] i_target Target to write register on.
+ * @param[in] i_address Register address to write to.
+ * @param[in] i_data Data to write to register.
+ *
+ * @retval[0] No errors.
+ * @retval[!0] Unexpected error occurred.
+ */
+ errlHndl_t putScom(
+ TARGETING::TargetHandle_t i_target,
+ uint64_t i_address,
+ uint64_t i_data);
+
+ /**
+ * @brief getScom Read a register using SCOM.
+ *
+ * @param[in] i_target Target to read register from.
+ * @param[in] i_address Register address to read from.
+ * @param[out] o_data Buffer to write register content to.
+ *
+ * @retval[0] No errors.
+ * @retval[!0] Unexpected error occurred.
+ */
+ errlHndl_t getScom(
+ TARGETING::TargetHandle_t i_target,
+ uint64_t i_address,
+ uint64_t & o_data);
+
+ /**
+ * @brief modifyScom RMW a register using SCOM.
+ *
+ * @param[in] i_target Target to update register on.
+ * @param[in] i_address Register address to update.
+ * @param[in] i_data Data to write to register.
+ * @param[out] o_data Data read from register.
+ * @param[in] i_op and/or behavior.
+ *
+ * @retval[0] No errors.
+ * @retval[!0] Unexpected error occurred.
+ */
+ errlHndl_t modifyScom(
+ TARGETING::TargetHandle_t i_target,
+ uint64_t i_address,
+ uint64_t i_data,
+ uint64_t & o_data,
+ ScomOp i_op);
+
+
+ /**
+ * @brief ctor
+ */
+ FakeRegSvc(){};
+
+ /**
+ * @brief dtor
+ */
+ virtual ~FakeRegSvc(){};
+
+ private:
+
+ /**
+ * @brief Reg Register/address association alias.
+ */
+ typedef std::map<uint64_t, uint64_t> RegAddrDataAssoc;
+
+ /**
+ * @brief Regs Registers/target association alias.
+ */
+ typedef std::map<TARGETING::TargetHandle_t, RegAddrDataAssoc> Regs;
+
+ /**
+ * @brief iv_regs Current register content.
+ */
+ Regs iv_regs;
+
+};
+}
+#endif
diff --git a/src/usr/diag/attn/runtime/test/attntestRtAttns.H b/src/usr/diag/attn/runtime/test/attntestRtAttns.H
new file mode 100644
index 000000000..b489bb262
--- /dev/null
+++ b/src/usr/diag/attn/runtime/test/attntestRtAttns.H
@@ -0,0 +1,195 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/usr/diag/attn/runtime/test/attntestRtAttns.H $ */
+/* */
+/* OpenPOWER HostBoot Project */
+/* */
+/* Contributors Listed Below - COPYRIGHT 2014 */
+/* [+] 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_ATTNTESTRTATTNS_H
+#define __TEST_ATTNTESTRTATTNS_H
+
+/**
+ * @file attntestRtAttns.H
+ *
+ * @brief Unit test for check for runtime attentions.
+ */
+
+#include "attnfakeprd.H"
+#include "attnfakereg.H"
+#include "../../common/attnproc.H"
+#include <cxxtest/TestSuite.H>
+#include "../../common/attntrace.H"
+#include "../../common/attntarget.H"
+#include <runtime/interface.h>
+#include <runtime/rt_targeting.H>
+#include <targeting/common/targetservice.H>
+
+using namespace ATTN;
+using namespace TARGETING;
+using namespace PRDF;
+
+/**
+ * @brief AttnCheckForRtAttentionsTest Unit test for the check for runtime
+ * attentions.
+ */
+class AttnCheckForRtAttentionsTest : public CxxTest::TestSuite
+{
+ public:
+
+ /**
+ * @brief testCheckForProcAttentions Unit test for the
+ * check for Proc Runtime attentions.
+ */
+ void testCheckForProcAttentions(void)
+ {
+ ATTN_SLOW(ENTER_MRK "AttnCheckForRtAttentionsTest::"
+ "testCheckForProcAttentions");
+
+ FakePrd prd;
+ prd.installPrd();
+ FakeRegSvc fakeRegs;
+ fakeRegs.installScomImpl();
+ TargetHandle_t proc = NULL;
+ do
+ {
+ TargetHandleList procList;
+ getTargetService().getAllChips( procList, TYPE_PROC );
+ // Get the first functional proc
+ if( 0 == procList.size() )
+ {
+ TS_FAIL("Not able to get Functional proc");
+ break;
+ }
+ proc = procList[0];
+
+ RT_TARG::rtChipId_t chipId = 0;
+ errlHndl_t err = RT_TARG::getRtTarget( proc, chipId );
+ if( NULL != err )
+ {
+ TS_FAIL("getRtTarget() failed for 0x%08X",
+ get_huid( proc ));
+ errlCommit(err, ATTN_COMP_ID);
+ break;
+ }
+
+ // Set the recoverable error
+ putScom( proc, 0x570F001B, 1 );
+ AttentionList expAttn;
+ PRDF::AttnData attn (proc, RECOVERABLE);
+ expAttn.add( Attention( attn,NULL));
+
+ prd.setExpectedAttn( expAttn);
+
+ runtimeInterfaces_t * rt_intf = getRuntimeInterfaces();
+ if( NULL == rt_intf )
+ {
+ TS_FAIL("Not able to get run time interface object");
+ break;
+ }
+ int32_t rc = rt_intf->handle_attns(chipId, 0, 0);
+
+ if( 0 != rc )
+ {
+ TS_FAIL("unexpected error during RT attention handling. "
+ "chipID: 0x%08X ", chipId);
+ break;
+ }
+ }while (0);
+
+ ATTN_SLOW(EXIT_MRK "AttnCheckForRtAttentionsTest::"
+ "testCheckForProcAttentions");
+ }
+
+ /**
+ * @brief testCheckForCenAttentions Unit test for the
+ * check for centaur Runtime attentions.
+ */
+ void testCheckForCenAttentions(void)
+ {
+ ATTN_SLOW(ENTER_MRK "AttnCheckForRtAttentionsTest::"
+ "testCheckForCenAttentions");
+
+ FakePrd prd;
+ prd.installPrd();
+ FakeRegSvc fakeRegs;
+ fakeRegs.installScomImpl();
+ TargetHandle_t proc = NULL;
+ TargetHandle_t mcs = NULL;
+ do
+ {
+ TargetHandleList procList;
+ getTargetService().getAllChips( procList, TYPE_PROC );
+ // Get the first functional proc
+ if( 0 != procList.size() )
+ {
+ proc = procList[0];
+ }
+ // Get 4th MCS ( random in nature. Any MCS can be used.)
+ mcs = getTargetService().getMcs(proc, 4);
+ TargetHandle_t mb = getTargetService().getMembuf(mcs);
+
+ if(( NULL == proc ) || ( NULL == mcs ) || ( NULL == mb ))
+ {
+ TS_FAIL("Not able to get Functional targets. "
+ "proc:%p mcs:%p mb:%p", proc, mcs, mb );
+ break;
+ }
+
+ RT_TARG::rtChipId_t chipId = 0;
+ errlHndl_t err = RT_TARG::getRtTarget( proc, chipId );
+ if( NULL != err )
+ {
+ TS_FAIL("getRtTarget() failed for 0x%08X",
+ get_huid( proc ));
+ errlCommit(err, ATTN_COMP_ID);
+ break;
+ }
+
+ // Set the error for 4th Centaur
+ putScom( proc, 0x2000001, 0x0010000000000000ull );
+ putScom( mcs, 0x2011840, 0x0009000000000000ull );
+
+ AttentionList expAttn;
+ PRDF::AttnData attn ( mb, RECOVERABLE );
+ expAttn.add( Attention( attn,NULL));
+
+ prd.setExpectedAttn( expAttn);
+
+ runtimeInterfaces_t * rt_intf = getRuntimeInterfaces();
+ if( NULL == rt_intf )
+ {
+ TS_FAIL("Not able to get run time interface object");
+ break;
+ }
+ int32_t rc = rt_intf->handle_attns(chipId, 0, 0);
+
+ if( 0 != rc )
+ {
+ TS_FAIL("unexpected error during RT attention handling. "
+ "chipID: 0x%08X ", chipId);
+ break;
+ }
+ }while (0);
+
+ ATTN_SLOW(EXIT_MRK "AttnCheckForRtAttentionsTest::"
+ "testCheckForCenAttentions");
+ }
+};
+#endif
diff --git a/src/usr/diag/attn/runtime/test/makefile b/src/usr/diag/attn/runtime/test/makefile
index 4636bfb05..0ad9e4845 100644
--- a/src/usr/diag/attn/runtime/test/makefile
+++ b/src/usr/diag/attn/runtime/test/makefile
@@ -28,6 +28,10 @@ HOSTBOOT_RUNTIME = 1
ROOTPATH = ../../../../../..
EXTRAINCDIR += ${ROOTPATH}/src/include/usr/diag
+CFLAGS += -iquote${ROOTPATH}/src/usr/diag/attn
+
+OBJS += attnfakeprd.o
+OBJS += attnfakereg.o
MODULE = testattn_rt
OpenPOWER on IntegriCloud