diff options
| author | Matt Derksen <v2cibmd@us.ibm.com> | 2016-09-09 10:51:57 -0500 |
|---|---|---|
| committer | Christian R. Geddes <crgeddes@us.ibm.com> | 2016-09-16 15:24:08 -0400 |
| commit | 3023dfca018c30c87072c4376c6f69dc35aef0d3 (patch) | |
| tree | 40149cac472df14c4a3449ea00c61ae46f0e59a2 /src/usr/fapi2 | |
| parent | 48f5f0b3e5f1ec65e90d2307caed92ab000f869b (diff) | |
| download | blackbird-hostboot-3023dfca018c30c87072c4376c6f69dc35aef0d3.tar.gz blackbird-hostboot-3023dfca018c30c87072c4376c6f69dc35aef0d3.zip | |
Added CK and DQ vpd accessors
Change-Id: Ic72c985b1fe064273bc39f14bcc31595117c6a08
RTC:159347
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/29421
Tested-by: PPE CI <ppe-ci+hostboot@us.ibm.com>
Reviewed-by: Martin Gloff <mgloff@us.ibm.com>
Reviewed-by: Christian R. Geddes <crgeddes@us.ibm.com>
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Reviewed-by: Matt K. Light <mklight@us.ibm.com>
Tested-by: Hostboot CI <hostboot-ci+hostboot@us.ibm.com>
Reviewed-by: Jennifer A. Stofer <stofer@us.ibm.com>
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/29426
Reviewed-by: Hostboot Team <hostboot@us.ibm.com>
Tested-by: Christian R. Geddes <crgeddes@us.ibm.com>
Diffstat (limited to 'src/usr/fapi2')
| -rw-r--r-- | src/usr/fapi2/plat_vpd_access.C | 183 | ||||
| -rw-r--r-- | src/usr/fapi2/test/getVpdTest.C | 116 | ||||
| -rw-r--r-- | src/usr/fapi2/test/getVpdTest.H | 22 |
3 files changed, 252 insertions, 69 deletions
diff --git a/src/usr/fapi2/plat_vpd_access.C b/src/usr/fapi2/plat_vpd_access.C index 91ea92506..878441898 100644 --- a/src/usr/fapi2/plat_vpd_access.C +++ b/src/usr/fapi2/plat_vpd_access.C @@ -36,6 +36,7 @@ #include <attribute_service.H> #include <vpd/dvpdenums.H> + //The following can be uncommented for unit testing //#undef FAPI_DBG //#define FAPI_DBG(args...) FAPI_INF(args) @@ -50,7 +51,8 @@ fapi2::ReturnCode platGetVPD( { fapi2::ReturnCode l_rc = fapi2::FAPI2_RC_SUCCESS; errlHndl_t l_errl = nullptr; - keywordName_t l_keywordName = {0}; + keywordInfo_t l_keywordInfo; + // Assume that all memory keywords (MR,MT,J0..JZ,X0...XZ) are all the // same size of 255. This avoids going through the decode and asking // the vpd DD the size of the keyword. @@ -63,6 +65,7 @@ fapi2::ReturnCode platGetVPD( // null blob pointer requests blob size if ( nullptr == o_blob) // just return size { + // use a generic max blob size (DQ and CK need less) io_vpd_info.iv_size = VPD_KEYWORD_SIZE; FAPI_DBG("platGetVPD: return blob size of %d", io_vpd_info.iv_size); @@ -144,6 +147,40 @@ fapi2::ReturnCode platGetVPD( l_mapKeyword = DVPD::MR; l_keywordEnum = DVPD::J0; } + else if ( fapi2::DQ == io_vpd_info.iv_vpd_type ) + { + if (1== + l_pMcsTarget->getAttr<TARGETING::ATTR_VPD_OVERRIDE_DQ_ENABLE>() ) + { + ATTR_VPD_OVERRIDE_DQ_Type l_override={0}; + assert(l_pMcsTarget->tryGetAttr<TARGETING::ATTR_VPD_OVERRIDE_DQ> + (l_override), + "platGetVPD: getAttr ATTR_VPD_OVERRIDE_DQ failed"); + FAPI_DBG("platGetVPD: return DQ override attr"); + memcpy(o_blob,l_override,sizeof(ATTR_VPD_OVERRIDE_DQ_Type)); + break; //return with overriden keyword + } + + // not overriden, continue + l_mapKeyword = DVPD::Q0; + l_keywordEnum = DVPD::Q0; + } + else if ( fapi2::CK == io_vpd_info.iv_vpd_type ) + { + if (1== + l_pMcsTarget->getAttr<TARGETING::ATTR_VPD_OVERRIDE_CK_ENABLE>() ) + { + ATTR_VPD_OVERRIDE_CK_Type l_override={0}; + assert(l_pMcsTarget->tryGetAttr<TARGETING::ATTR_VPD_OVERRIDE_CK> + (l_override), + "platGetVPD: getAttr ATTR_VPD_OVERRIDE_CK failed"); + FAPI_DBG("platGetVPD: return CK override attr"); + memcpy(o_blob,l_override,sizeof(ATTR_VPD_OVERRIDE_CK_Type)); + break; //return with overriden keyword + } + l_mapKeyword = DVPD::CK; + l_keywordEnum = DVPD::CK; + } else { FAPI_ERR("platGetVPD: invalid type = %d", @@ -191,77 +228,105 @@ fapi2::ReturnCode platGetVPD( io_vpd_info, l_pMapping, VPD_KEYWORD_SIZE, - l_keywordName); - delete l_pMapping; + l_keywordInfo); + if (l_rc) { + delete l_pMapping; FAPI_ERR("platGetVPD: ERROR returned from p9_get_mem_vpd_keyword"); break; //return with error } FAPI_DBG("platGetVPD: keyword name = %s", - l_keywordName); + l_keywordInfo.kwName); - //Convert keyword name to keyword enumeration. - //ascii 0..9 runs from 0x30 to 0x39. - //The conversion assumes the input is valid (0..9,A..Z) - //and that the enumeration is in order and consecutive. - if ( '0' == (l_keywordName[1] & 0xf0)) //it is a digit (0..9) + // Skip grabbing CK keyword data again and just use the index provided + // by the hwp to get the specific data for this particular mcs target + if (l_mapKeyword == DVPD::CK ) { - l_keywordEnum += (l_keywordName[1] - '0'); + l_buffSize = l_keywordInfo.kwBlobSize; + + // Just a safety check so you don't copy out of bounds + if (l_buffSize <= VPD_KEYWORD_SIZE) + { + // o_blob was already checked for nullptr + // copy blob of l_buffSize past the 4 byte header + // (each indexed section is l_buffSize bytes) + memcpy(o_blob, l_pMapping + l_keywordInfo.kwBlobIndex, l_buffSize); + } + else + { + memcpy(o_blob, + l_pMapping + l_keywordInfo.kwBlobIndex, + VPD_KEYWORD_SIZE); + } + delete l_pMapping; } - else //it is a char (A..Z) + else { - l_keywordEnum += (l_keywordName[1] - 'A') + 10; - } + delete l_pMapping; - //Read vpd blob - l_buffSize = io_vpd_info.iv_size; - l_errl = deviceRead((TARGETING::Target *)l_pMcsTarget, - o_blob, - l_buffSize, - DEVICE_DVPD_ADDRESS(DVPD::MEMD, - l_keywordEnum)); - if (l_errl) - { - FAPI_ERR("platGetVPD: ERROR reading keyword"); - l_rc.setPlatDataPtr(reinterpret_cast<void *> (l_errl)); - break; //return with error - } + //Convert keyword name to keyword enumeration. + //ascii 0..9 runs from 0x30 to 0x39. + //The conversion assumes the input is valid (0..9,A..Z) + //and that the enumeration is in order and consecutive. + if ( '0' == (l_keywordInfo.kwName[1] & 0xf0)) //it is a digit (0..9) + { + l_keywordEnum += (l_keywordInfo.kwName[1] - '0'); + } + else //it is a char (A..Z) + { + l_keywordEnum += (l_keywordInfo.kwName[1] - 'A') + 10; + } - //Confirm all expected data was returned - if (VPD_KEYWORD_SIZE > l_buffSize) - { - FAPI_ERR("platGetVPD: insufficient vpd returned" - " for keyword %d;" - " %d returned, %d expected", - l_keywordEnum, - l_buffSize, - VPD_KEYWORD_SIZE); - /*@ - * @errortype - * @moduleid fapi2::MOD_FAPI2_PLAT_GET_VPD - * @reasoncode fapi2::RC_RETURNED_VPD_TOO_SMALL - * @userdata1[0:31] Returned vpd in bytes - * @userdata1[32:64] Expected number of vpd bytes - * @userdata2 Keyword - * @devdesc Less than expected number of bytes returned. - * @custdesc Firmware Error - */ - l_errl = new ERRORLOG::ErrlEntry( - ERRORLOG::ERRL_SEV_UNRECOVERABLE, - fapi2::MOD_FAPI2_PLAT_GET_VPD, - fapi2::RC_RETURNED_VPD_TOO_SMALL, - TWO_UINT32_TO_UINT64( - l_buffSize, - VPD_KEYWORD_SIZE), - l_keywordEnum); - l_errl->addHwCallout( l_pMcsTarget, - HWAS::SRCI_PRIORITY_LOW, - HWAS::NO_DECONFIG, - HWAS::GARD_NULL ); + //Read vpd blob + l_buffSize = l_keywordInfo.kwBlobSize; + l_errl = deviceRead((TARGETING::Target *)l_pMcsTarget, + o_blob, + l_buffSize, + DEVICE_DVPD_ADDRESS(DVPD::MEMD, + l_keywordEnum)); + if (l_errl) + { + FAPI_ERR("platGetVPD: ERROR reading keyword"); + l_rc.setPlatDataPtr(reinterpret_cast<void *> (l_errl)); + break; //return with error + } - l_rc.setPlatDataPtr(reinterpret_cast<void *> (l_errl)); - break; //return with error + //Confirm all expected data was returned + if (l_keywordInfo.kwBlobSize > l_buffSize) + { + FAPI_ERR("platGetVPD: insufficient vpd returned" + " for keyword %d;" + " %d returned, %d expected", + l_keywordEnum, + l_buffSize, + io_vpd_info.iv_size); + /*@ + * @errortype + * @moduleid fapi2::MOD_FAPI2_PLAT_GET_VPD + * @reasoncode fapi2::RC_RETURNED_VPD_TOO_SMALL + * @userdata1[0:31] Returned vpd in bytes + * @userdata1[32:64] Expected number of vpd bytes + * @userdata2 Keyword + * @devdesc Less than expected number of bytes returned. + * @custdesc Firmware Error + */ + l_errl = new ERRORLOG::ErrlEntry( + ERRORLOG::ERRL_SEV_UNRECOVERABLE, + fapi2::MOD_FAPI2_PLAT_GET_VPD, + fapi2::RC_RETURNED_VPD_TOO_SMALL, + TWO_UINT32_TO_UINT64( + l_buffSize, + l_keywordInfo.kwBlobSize), + l_keywordEnum); + l_errl->addHwCallout( l_pMcsTarget, + HWAS::SRCI_PRIORITY_LOW, + HWAS::NO_DECONFIG, + HWAS::GARD_NULL ); + + l_rc.setPlatDataPtr(reinterpret_cast<void *> (l_errl)); + break; //return with error + } } } while (0); diff --git a/src/usr/fapi2/test/getVpdTest.C b/src/usr/fapi2/test/getVpdTest.C index e582ab609..6005d2d0a 100644 --- a/src/usr/fapi2/test/getVpdTest.C +++ b/src/usr/fapi2/test/getVpdTest.C @@ -227,7 +227,7 @@ void testDecode_MR(void) 0}; // decode keyword - keywordName_t l_keywordName = {0}; + keywordInfo_t l_keywordInfo = {0}; numTests++; FAPI_EXEC_HWP(l_rc, @@ -236,7 +236,7 @@ void testDecode_MR(void) l_info, l_pMapping, VPD_KEYWORD_SIZE, - l_keywordName); + l_keywordInfo); if(l_rc) { TS_FAIL ("testDecode_MR:: p9_get_mem_vpd_keyword failed"); @@ -246,12 +246,12 @@ void testDecode_MR(void) // compare to expected test data numTests++; - if ( (l_keywordName[0] != 'J' ) && - (l_keywordName[1] != '3' ) ) + if ( (l_keywordInfo.kwName[0] != 'J' ) && + (l_keywordInfo.kwName[1] != '3' ) ) { TS_FAIL ("testDecode_MR:: unexpected keyword name returned" "value = %x %x expected = %x %x", - l_keywordName[0],l_keywordName[1],'J','3'); + l_keywordInfo.kwName[0],l_keywordInfo.kwName[1],'J','3'); numFails++; } @@ -307,7 +307,7 @@ void testDecode_MT(void) 0}; // decode keyword - keywordName_t l_keywordName = {0}; + keywordInfo_t l_keywordInfo = {0}; numTests++; FAPI_EXEC_HWP(l_rc, p9_get_mem_vpd_keyword, @@ -315,7 +315,7 @@ void testDecode_MT(void) l_info, l_pMapping, VPD_KEYWORD_SIZE, - l_keywordName); + l_keywordInfo); if(l_rc) { TS_FAIL ("testDecode_MT:: p9_get_mem_vpd_keyword failed"); @@ -325,12 +325,12 @@ void testDecode_MT(void) // compare to expected test data numTests++; - if ( (l_keywordName[0] != 'X' ) && - (l_keywordName[1] != '3' ) ) + if ( (l_keywordInfo.kwName[0] != 'X' ) && + (l_keywordInfo.kwName[1] != '3' ) ) { TS_FAIL ("testDecode_MT:: unexpected keyword name returned" "value = %x %x expected = %x %x", - l_keywordName[0],l_keywordName[1],'X','3'); + l_keywordInfo.kwName[0],l_keywordInfo.kwName[1],'X','3'); numFails++; } @@ -610,3 +610,99 @@ void testGetVPD_Override(void) numMRFails+numMTFails, numMRTests+numMTTests); } + +void testGetVPD_DQ(void) +{ + int numTests = 0; + int numFails = 0; + ReturnCode l_rc; + + FAPI_DBG("testGetVPD DQ start"); + + do + { + numTests++; // find MCS MEMVPD_POS + // get a MCS fapi2 target for MEMVPD_POS 0 + TARGETING::ATTR_MEMVPD_POS_type l_memVpdPos = 0; + + fapi2::Target<fapi2::TARGET_TYPE_MCS> l_fapiTarget; + TARGETING::Target * l_target; + if(!getTarget(l_memVpdPos,l_target,l_fapiTarget)) + { + TS_FAIL ("testGetVPD_DQ:: could not find MCS MEMVPD_POS=%d", + l_memVpdPos); + numFails++; + break; //Target not found + } + + // set up VPDInfo + fapi2::VPDInfo<fapi2::TARGET_TYPE_MCS> l_info(fapi2::DQ); + + l_rc = testGetVPD(l_fapiTarget, + l_info, + fapi2::DQ, + nullptr, //don't test data, just ability to access + numTests, + numFails); + if(l_rc) + { + TS_FAIL ("testGetVPD DQ:: testGetVPD decode failed"); + break; // decode failed (don't double count num tests and fails) + } + + } + while(0); + + FAPI_INF("testGetVPD DQ Test Complete, %d/%d fails", + numFails, numTests); +} + +void testGetVPD_CK(void) +{ + int numTests = 0; + int numFails = 0; + ReturnCode l_rc; + + FAPI_DBG("testGetVPD CK start"); + + do + { + numTests++; // find MCS MEMVPD_POS + + // get a MCS fapi2 target for MEMVPD_POS 0 + TARGETING::ATTR_MEMVPD_POS_type l_memVpdPos = 0; + + fapi2::Target<fapi2::TARGET_TYPE_MCS> l_fapiTarget; + TARGETING::Target * l_target; + if(!getTarget(l_memVpdPos,l_target,l_fapiTarget)) + { + TS_FAIL ("testGetVPD_DQ:: could not find MCS MEMVPD_POS=%d", + l_memVpdPos); + numFails++; + break; //Target not found + } + + // set up VPDInfo + fapi2::VPDInfo<fapi2::TARGET_TYPE_MCS> l_info(fapi2::CK); + + // modify this if the data changes (currently common for all positions) + const char testData[] = {0x80,0x40, 0}; + + l_rc = testGetVPD(l_fapiTarget, + l_info, + fapi2::CK, + testData, + numTests, + numFails); + if(l_rc) + { + TS_FAIL ("testGetVPD CK:: testGetVPD decode failed"); + break; // decode failed (don't double count num tests and fails) + } + + } + while(0); + + FAPI_INF("testGetVPD CK Test Complete, %d/%d fails", + numFails, numTests); +} diff --git a/src/usr/fapi2/test/getVpdTest.H b/src/usr/fapi2/test/getVpdTest.H index b7b67e672..bc435e1b8 100644 --- a/src/usr/fapi2/test/getVpdTest.H +++ b/src/usr/fapi2/test/getVpdTest.H @@ -76,4 +76,26 @@ void testDecode_MT(void); */ void testGetVPD_Override(void); +/** + * @brief MCS getVpd DQ tests + * + * Test the getVPD DQ interface. Based on a VPDInfo configuration, + * verify the expected direct memory vpd is returned. + * There is a dependency to update standalone simics direct memory (dvpd.dat) + * for the configuration to map to a keyword, but there is no data dependency. + * expected data. + */ +void testGetVPD_DQ(void); + +/** + * @brief MCS getVpd CK tests + * + * Test the getVPD CK interface. Based on a VPDInfo configuration, + * verify the expected direct memory vpd is returned. + * There is a dependency to update standalone simics direct memory (dvpd.dat) + * for the configuration to map to a keyword, but there is no data dependency. + * expected data. + */ +void testGetVPD_CK(void); + #endif |

