Skip to content

Commit

Permalink
Add test case for getChildTargetsForCDG
Browse files Browse the repository at this point in the history
Some changes are coming to the getChildTargetsForCDG interface in
regards to how it returns DIMM information. Get a unit test in place
for this function so the future changes can be verified.

Change-Id: I731841598f35a169c6dfbbdd873c07dc37d27273
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/59072
Reviewed-by: Martin Gloff <mgloff@us.ibm.com>
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Reviewed-by: Christian R. Geddes <crgeddes@us.ibm.com>
Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com>
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
  • Loading branch information
geissonator authored and dcrowell77 committed May 29, 2018
1 parent 4bfa55d commit fc79c53
Show file tree
Hide file tree
Showing 3 changed files with 214 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/include/usr/fapi2/hwpf_fapi2_reasoncodes.H
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ namespace fapi2
MOD_FAPI2_GET_PLL_BUCKET = 0x16,
MOD_FAPI2_GET_RING = 0x17,
MOD_FAPI2_SET_ATTR_FREQ_MCA_MHZ = 0x18,
MOD_FAPI2_PLAT_GET_PROC_TEST = 0x19,
};

/**
Expand Down
24 changes: 23 additions & 1 deletion src/include/usr/fapi2/plat_utils.H
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,33 @@ ReturnCode platSpecialWakeup( const Target<TARGET_TYPE_ALL>& i_target,
///
template<fapi2::TargetType T>
ReturnCode get_ring(fapi2::Target<T> i_target,
const RingId_t i_ringId,
const RingId_t i_ringId,
unsigned char *&o_ringData,
uint64_t &o_ringLength,
uint64_t &o_ringAddress);

///
/// @brief Returns child targets to Callout/Deconfigure/GARD
///
/// @param[i] i_parentTarget FAPI2 Parent Target
/// @param[i] i_childType FAPI2 Child Type
/// @param[i] i_childPort Child Port Number
/// For DIMMs: MBA Port Number
/// Else unused
/// @param[i] i_childNum Child Number
/// For DIMMs: DIMM Socket Number
/// For Chips: Chip Position
/// For Chiplets: Chiplet Position
/// @param[o] o_childTargets List of child targets matching input
// criteria.
///
void getChildTargetsForCDG(
const fapi2::Target<fapi2::TARGET_TYPE_ALL>& i_parentTarget,
const fapi2::TargetType i_childType,
const uint8_t i_childPort,
const uint8_t i_childNum,
TARGETING::TargetHandleList & o_childTargets);

} // End namespace fapi2


Expand Down
191 changes: 190 additions & 1 deletion src/usr/fapi2/test/fapi2GetChildrenTest.H
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <fapi2TestUtils.H>
#include <cxxtest/TestSuite.H>
#include <functional>
#include <plat_utils.H>


#include <error_scope.H>
Expand Down Expand Up @@ -59,6 +60,61 @@ public:

};

//******************************************************************************
// getProc
// Determine if cumulus or nimbus system and return pointer to first processor
// target of that type
//******************************************************************************
errlHndl_t getProc(TARGETING::Target*& o_nimbusProc,
TARGETING::Target*& o_cumulusProc)
{
errlHndl_t l_err = nullptr;
FAPI_DBG("start of getProc()");

// Create a vector of TARGETING::Target pointers
TARGETING::TargetHandleList l_chipList;

// Get a list of all of the proc chips
TARGETING::getAllChips(l_chipList, TARGETING::TYPE_PROC, false);

//Take the first NIMBUS proc and use it
for(uint32_t i = 0; i < l_chipList.size(); i++)
{
if(TARGETING::MODEL_NIMBUS ==
l_chipList[i]->getAttr<TARGETING::ATTR_MODEL>())
{
o_nimbusProc = l_chipList[i];
break;
}
if(TARGETING::MODEL_CUMULUS ==
l_chipList[i]->getAttr<TARGETING::ATTR_MODEL>())
{
o_cumulusProc = l_chipList[i];
break;
}
}
if((o_nimbusProc == nullptr) && (o_cumulusProc == nullptr))
{
// Send an errorlog because we cannot find any procs.
FAPI_ERR("getProc: could not find any procs, skipping tests");
/*@
* @errortype ERRORLOG::ERRL_SEV_UNRECOVERABLE
* @moduleid fapi2::MOD_FAPI2_PLAT_GET_PROC_TEST
* @reasoncode fapi2::RC_NO_PROCS_FOUND
* @userdata1 Model Type we looked for
* @userdata2 Other Model Type we looked for
* @devdesc Could not find any procs in system model
*/
l_err = new ERRORLOG::ErrlEntry(ERRORLOG::ERRL_SEV_UNRECOVERABLE,
fapi2::MOD_FAPI2_PLAT_GET_PROC_TEST,
fapi2::RC_NO_PROCS_FOUND,
TARGETING::MODEL_NIMBUS,
TARGETING::MODEL_CUMULUS,
true/*SW Error*/);
}
return l_err;
}

//******************************************************************************
// test_fapi2GetChildren
//******************************************************************************
Expand Down Expand Up @@ -665,7 +721,6 @@ void test_fapi2GetChildren()
FAPI_INF("fapi2GetChildrenTest:: Test Complete. %d/%d fails", numFails , numTests);
}


//******************************************************************************
// test_fapi2GetChildrenFilter
//******************************************************************************
Expand Down Expand Up @@ -843,6 +898,140 @@ void test_fapi2GetChildrenFilter()
FAPI_INF("test_fapi2GetChildrenFilter: Test Complete. %d/%d fails", numFails , numTests);
}

//******************************************************************************
// test_fapi2GetChildrenFilter
// Currently only test DIMM aspects of interface
//******************************************************************************
void test_fapi2getChildTargetsForCDG()
{
int numTests = 0;
int numFails = 0;
errlHndl_t l_err = nullptr;
TARGETING::Target * l_nimbusProc = nullptr;
TARGETING::Target * l_cumulusProc = nullptr;
TARGETING::Target * l_proc = nullptr;
size_t l_expectedDimms = 0;
do
{
FAPI_DBG("start of test_fapi2getChildTargetsForCDG()");

numTests++;
l_err = getProc(l_nimbusProc, l_cumulusProc);
if(l_err)
{
errlCommit(l_err,HWPF_COMP_ID);
numFails++;
TS_FAIL("test_fapi2getChildTargetsForCDG Fail: could not find any proc, skipping tests");
break;
}

if (l_nimbusProc != nullptr)
{
l_proc = l_nimbusProc;
l_expectedDimms = 16;

}
else if (l_cumulusProc != nullptr)
{
l_proc = l_cumulusProc;
l_expectedDimms = 8;
}
else //both are nullptr
{
// Should never get here since error should have been returned
// above
FAPI_ERR("fapi2getChildTargetsForCDG: Never Should Happen");
numFails++;
break;
}

Target<fapi2::TARGET_TYPE_PROC_CHIP> fapi2_procTarget(l_proc);
// Now get all dimms under this processor
TARGETING::TargetHandleList l_dimmList;
fapi2::getChildTargetsForCDG(fapi2_procTarget,
fapi2::TARGET_TYPE_DIMM,
0xff, // All ports
0xff, // All sockets
l_dimmList);

FAPI_INF("test_fapi2getChildTargetsForCDG: Dimms under proc 0x%.08X is %d",
TARGETING::get_huid(l_proc),l_dimmList.size());
numTests++;
if(l_dimmList.size() != l_expectedDimms)
{
FAPI_ERR("test_fapi2getChildTargetsForCDG: Dimm count %d not equal expected %d",
l_dimmList.size(),l_expectedDimms);
numFails++;
}

// All dimms under port 0
fapi2::getChildTargetsForCDG(fapi2_procTarget,
fapi2::TARGET_TYPE_DIMM,
0x0, // Port 0
0xff, // All sockets
l_dimmList);
FAPI_INF("test_fapi2getChildTargetsForCDG: Dimms under proc 0x%.08X port 0 is %d",
TARGETING::get_huid(l_proc),l_dimmList.size());
numTests++;
if(l_dimmList.size() != l_expectedDimms)
{
FAPI_ERR("test_fapi2getChildTargetsForCDG: Dimm count %d under port 0 not equal expected %d",
l_dimmList.size(),l_expectedDimms);
numFails++;
}

// All dimms under port 1
fapi2::getChildTargetsForCDG(fapi2_procTarget,
fapi2::TARGET_TYPE_DIMM,
0x1, // Port 1
0xff, // All sockets
l_dimmList);
FAPI_INF("test_fapi2getChildTargetsForCDG: Dimms under proc 0x%.08X port 1 is %d",
TARGETING::get_huid(l_proc),l_dimmList.size());
numTests++;
if(l_dimmList.size() != 0)
{
FAPI_ERR("test_fapi2getChildTargetsForCDG: Dimm count %d under port 1 not equal expected %d",
l_dimmList.size(),0);
numFails++;
}

// All dimms under socket 0
fapi2::getChildTargetsForCDG(fapi2_procTarget,
fapi2::TARGET_TYPE_DIMM,
0xff, // All ports
0x0, // Socket 0
l_dimmList);
FAPI_INF("test_fapi2getChildTargetsForCDG: Dimms under proc 0x%.08X socket 0 is %d",
TARGETING::get_huid(l_proc),l_dimmList.size());
numTests++;
if(l_dimmList.size() != l_expectedDimms)
{
FAPI_ERR("test_fapi2getChildTargetsForCDG: Dimm count %d under socket 0 not equal expected %d",
l_dimmList.size(),l_expectedDimms);
numFails++;
}

// All dimms under socket 1
fapi2::getChildTargetsForCDG(fapi2_procTarget,
fapi2::TARGET_TYPE_DIMM,
0xff, // All ports
0x1, // Socket 1
l_dimmList);
FAPI_INF("test_fapi2getChildTargetsForCDG: Dimms under proc 0x%.08X socket 1 is %d",
TARGETING::get_huid(l_proc),l_dimmList.size());
numTests++;
if(l_dimmList.size() != 0)
{
FAPI_ERR("test_fapi2getChildTargetsForCDG: Dimm count %d under socket 1 not equal expected %d",
l_dimmList.size(),0);
numFails++;
}

}while(0);

FAPI_INF("test_fapi2getChildTargetsForCDG: Test Complete. %d/%d fails", numFails , numTests);
}

};

Expand Down

0 comments on commit fc79c53

Please sign in to comment.