From 9c7a264f84fcab5577ee6a2b48f6a2d01c12da35 Mon Sep 17 00:00:00 2001 From: Dan Crowell Date: Tue, 22 Oct 2019 08:17:46 -0500 Subject: Fix fapi spd testcases Fixed a few places where the Axone path was getting skipped incorrectly, then fixed the resulting latent errors. Change-Id: I917b9a0b6f4ff1491ff384dc924e29f688548873 Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/85688 Tested-by: Jenkins Server Tested-by: Jenkins OP Build CI Tested-by: Jenkins OP HW Reviewed-by: Zachary Clark Tested-by: FSP CI Jenkins Reviewed-by: Christian R Geddes Reviewed-by: William G Hoffa --- src/usr/fapi2/test/fapi2DdimmGetEfdTest.C | 3 +- src/usr/fapi2/test/fapi2SpdTestCxx.H | 290 +++++++++++++----------------- 2 files changed, 123 insertions(+), 170 deletions(-) (limited to 'src') diff --git a/src/usr/fapi2/test/fapi2DdimmGetEfdTest.C b/src/usr/fapi2/test/fapi2DdimmGetEfdTest.C index 13f0ed87b..400ca2a59 100644 --- a/src/usr/fapi2/test/fapi2DdimmGetEfdTest.C +++ b/src/usr/fapi2/test/fapi2DdimmGetEfdTest.C @@ -111,7 +111,8 @@ fapi2DdimmGetEfdTest::fapi2DdimmGetEfdTest() { FAPI_INF(">> fapi2DdimmGetEfdTest"); - if(TARGETING::MODEL_AXONE != TARGETING::targetService().getProcessorModel()) + iv_attrModel = TARGETING::targetService().getProcessorModel(); + if(TARGETING::MODEL_AXONE != iv_attrModel) { FAPI_INF("<< fapi2DdimmGetEfdTest: This is not AXONE. " "Skipping AXONE tests."); diff --git a/src/usr/fapi2/test/fapi2SpdTestCxx.H b/src/usr/fapi2/test/fapi2SpdTestCxx.H index feb84f619..d033401e8 100644 --- a/src/usr/fapi2/test/fapi2SpdTestCxx.H +++ b/src/usr/fapi2/test/fapi2SpdTestCxx.H @@ -53,175 +53,127 @@ class SPDTest: public CxxTest::TestSuite { public: - /** - * @brief Test SPD get Interface DIMMs. - */ - void testGetSPD ( void ) - { - fapi2::ReturnCode l_rc; - size_t l_size = 0; - uint8_t * l_blobData = NULL; - - FAPI_INF( "testGetSPD - Enter" ); - - do - { - TARGETING::Target * i_pTarget = NULL; - - // Get DIMM Targets - TargetHandleList dimmList; - getDIMMTargets( dimmList ); - - // Should get atleast one - if( ( 0 == dimmList.size() ) || - ( NULL == dimmList[0] ) ) - { - FAPI_INF( "testGetSPD- No DIMMs found!"); - break; - } - - // Work on the first DIMM target - i_pTarget = dimmList[0]; - - // convert to fapi2 target - fapi2::Target fapi2_Target(i_pTarget); - - // SPD interface call with NULL blob to get size data - l_rc = fapi2::getSPD(fapi2_Target, NULL, l_size); - - // Expect to return the size or non failure - if( !l_size || (l_rc != fapi2::FAPI2_RC_SUCCESS) ) - { - TS_FAIL("testGetSPD: Failed getting the size of the mem buffer"); - break; - } - - // allocate the blob data of mem size length to hold data - l_blobData = reinterpret_cast(malloc(l_size)); - memset(l_blobData,0,l_size); - - l_rc = fapi2::getSPD(fapi2_Target,l_blobData, l_size); - if ( l_rc != fapi2::FAPI2_RC_SUCCESS ) - { - TS_FAIL( "testGetSPD- Failed to read data from DIMM with HUID= 0x%x", - TARGETING::get_huid(i_pTarget)); - break; - } - - uint8_t l_memModule = 0x0; - size_t l_memSize = sizeof(uint8_t); - - auto l_errl = deviceRead(i_pTarget, - (void *)&l_memModule, - l_memSize, - DEVICE_SPD_ADDRESS(SPD::MODULE_TYPE)); - - if ( l_errl ) - { - TS_FAIL( "testGetSPD- Failed to deviceRead with HUID= 0x%x", - TARGETING::get_huid(i_pTarget)); - break; - } - - uint8_t l_memGen = 0x0; - l_errl = deviceRead(i_pTarget, - (void *)&l_memGen, - l_memSize, - DEVICE_SPD_ADDRESS(SPD::BASIC_MEMORY_TYPE)); - - if ( l_errl ) - { - TS_FAIL( "testGetSPD- Failed to deviceRead with HUID= 0x%x", - TARGETING::get_huid(i_pTarget)); - break; - } - - auto l_chipModel = i_pTarget->getAttr(); - - if( l_chipModel == TARGETING::MODEL_AXONE ) - { - // Assumes Axone is strictly DDR4, so not taking into - // account DDR3 or any other DRAM generation - if( l_memModule == SPD::MEM_DDIMM ) - { - if ( l_size != SPD::DDIMM_DDR4_SPD_SIZE ) - { - TS_FAIL( "testGetSPD- expected size %d != actual size %d with HUID= 0x%x", - SPD::DDIMM_DDR4_SPD_SIZE, - l_size, - TARGETING::get_huid(i_pTarget)); - break; - } - } - else - { - if ( l_size != SPD::DDR4_SPD_SIZE ) - { - TS_FAIL( "testGetSPD- expected size %d != actual size %d with HUID= 0x%x", - SPD::DDR4_SPD_SIZE, - l_size, - TARGETING::get_huid(i_pTarget)); - break; - } - } - } - else if ( l_chipModel == TARGETING::MODEL_NIMBUS ) - { - // Nimbus only suppported DDR4 and SPD size was - // DIMM BASE_MODULE_TYPE agnostic. - if ( l_size != SPD::DDR4_SPD_SIZE ) - { - TS_FAIL( "testGetSPD- expected size %d != actual size %d with HUID= 0x%x", - SPD::DDR4_SPD_SIZE, - l_size, - TARGETING::get_huid(i_pTarget)); - break; - } - } - else if( l_chipModel == TARGETING::MODEL_CUMULUS ) - { - // BASE_MODULE_TYPE (RDIMM, LRDIMM, etc) isn't being - // taken into account because the SPD size isn't dependent - // on it for Cumulus. - if( l_memGen == SPD::MEM_DDR4 ) - { - if ( l_size != SPD::DDR4_SPD_SIZE ) - { - TS_FAIL( "testGetSPD- expected size %d != actual size %d with HUID= 0x%x", - SPD::DDR4_SPD_SIZE, - l_size, - TARGETING::get_huid(i_pTarget)); - break; - } - } - else - { - if ( l_size != SPD::DDR3_SPD_SIZE ) - { - TS_FAIL( "testGetSPD- expected size %d != actual size %d with HUID= 0x%x", - SPD::DDR3_SPD_SIZE, - l_size, - TARGETING::get_huid(i_pTarget)); - break; - } - } - } - - FAPI_DBG("getSPD: SPD data for DIMM with HUID=0x%.8X Size %d Blob %d", - TARGETING::get_huid(i_pTarget), - l_size, - l_blobData); - - } while(0); - - if( NULL != l_blobData ) - { - free( l_blobData ); - l_blobData = NULL; - } - - FAPI_INF( "testGetSPD - Exit" ); - } + /** + * @brief Test SPD get Interface DIMMs. + */ + void testGetSPD ( void ) + { + fapi2::ReturnCode l_rc; + size_t l_spdSize = 0; + uint8_t * l_blobData = NULL; + + FAPI_INF( "testGetSPD - Enter" ); + + // Get DIMM Targets + TargetHandleList dimmList; + getDIMMTargets( dimmList ); + + // Should get atleast one + if( ( 0 == dimmList.size() ) || + ( NULL == dimmList[0] ) ) + { + TS_FAIL( "testGetSPD- No DIMMs found!"); + } + + for( auto l_tDimm : dimmList ) + { + + // convert to fapi2 target + fapi2::Target l_fDimm(l_tDimm); + + // SPD interface call with NULL blob to get size data + l_rc = fapi2::getSPD(l_fDimm, NULL, l_spdSize); + + // Expect to return the size or non failure + if( !l_spdSize || (l_rc != fapi2::FAPI2_RC_SUCCESS) ) + { + TS_FAIL("testGetSPD: Failed getting the size of the mem buffer - Dimm %.8X", TARGETING::get_huid(l_tDimm)); + continue; + } + + // allocate the blob data of mem size length to hold data + l_blobData = reinterpret_cast(malloc(l_spdSize)); + memset(l_blobData,0,l_spdSize); + + l_rc = fapi2::getSPD(l_fDimm,l_blobData, l_spdSize); + if ( l_rc != fapi2::FAPI2_RC_SUCCESS ) + { + TS_FAIL( "testGetSPD- Failed to read data from DIMM with HUID= 0x%x", + TARGETING::get_huid(l_tDimm)); + continue; + } + + uint8_t l_memModule = 0x0; + size_t l_memSize = sizeof(uint8_t); + + auto l_errl = deviceRead(l_tDimm, + (void *)&l_memModule, + l_memSize, + DEVICE_SPD_ADDRESS(SPD::MODULE_TYPE)); + + if ( l_errl ) + { + TS_FAIL( "testGetSPD- Failed to deviceRead with HUID= 0x%x", + TARGETING::get_huid(l_tDimm)); + continue; + } + + uint8_t l_memGen = 0x0; + l_errl = deviceRead(l_tDimm, + (void *)&l_memGen, + l_memSize, + DEVICE_SPD_ADDRESS(SPD::BASIC_MEMORY_TYPE)); + + if ( l_errl ) + { + TS_FAIL( "testGetSPD- Failed to deviceRead with HUID= 0x%x", + TARGETING::get_huid(l_tDimm)); + continue; + } + + // figure out the expected size based on the memory type + size_t l_compareSize = 0; + if( (l_memModule == SPD::MEM_DDIMM) && (l_memGen == SPD::MEM_DDR4) ) + { + l_compareSize = SPD::OCMB_SPD_EFD_COMBINED_SIZE; + } + else if( (l_memModule != SPD::MEM_DDIMM) && (l_memGen == SPD::MEM_DDR4) ) + { + l_compareSize = SPD::DDR4_SPD_SIZE; + } + else if( l_memGen == SPD::MEM_DDR3 ) + { + l_compareSize = SPD::DDR3_SPD_SIZE; + } + else + { + TS_FAIL( "testGetSPD - Unknown memory type for %.8X : module=0x%X, gen=0x%X", + TARGETING::get_huid(l_tDimm), l_memModule, l_memGen ); + continue; + } + + if( l_compareSize != l_spdSize ) + { + TS_FAIL( "testGetSPD - Wrong SPD size for %.8X : module=0x%X, gen=0x%X, exp=%d, act=%d", + TARGETING::get_huid(l_tDimm), l_memModule, l_memGen, + l_compareSize, l_spdSize); + continue; + } + + FAPI_DBG("getSPD: SPD data for DIMM with HUID=0x%.8X Size %d Blob %d", + TARGETING::get_huid(l_tDimm), + l_spdSize, + l_blobData); + } + + if( NULL != l_blobData ) + { + free( l_blobData ); + l_blobData = NULL; + } + + FAPI_INF( "testGetSPD - Exit" ); + } }; -- cgit v1.2.1