diff options
author | Matt Derksen <mderkse1@us.ibm.com> | 2019-05-01 12:30:54 -0500 |
---|---|---|
committer | Daniel M. Crowell <dcrowell@us.ibm.com> | 2019-06-24 10:29:27 -0500 |
commit | 2c86bbc37ee8d0a2c0da169ace605dde319c898a (patch) | |
tree | 10bb64bd91068566c077436a2785ed83f84c5288 /src | |
parent | 1ac1e9584462a41e204ffaae13f086b0a22c6cf8 (diff) | |
download | talos-hostboot-2c86bbc37ee8d0a2c0da169ace605dde319c898a.tar.gz talos-hostboot-2c86bbc37ee8d0a2c0da169ace605dde319c898a.zip |
Run exp tests in Axone and make generic Load utility
Removed CONFIG_AXONE_BRING_UP from expscomtest.H
Added common load utility for loading/unloading needed
modules for testcases. Added a mutex to avoid inband
command/response contention between testcases.
Change-Id: Ia96991983be18fab840b59b8dc7dd1383ecc4abc
RTC:201738
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/76818
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: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com>
Reviewed-by: Roland Veloz <rveloz@us.ibm.com>
Reviewed-by: Glenn Miles <milesg@ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/usr/expaccess/test/expscomtest.H | 253 | ||||
-rw-r--r-- | src/usr/expaccess/test/exptest_utils.C | 96 | ||||
-rw-r--r-- | src/usr/expaccess/test/exptest_utils.H | 62 | ||||
-rw-r--r-- | src/usr/expaccess/test/makefile | 7 | ||||
-rw-r--r-- | src/usr/expaccess/test/ocmbcommtest.H | 181 | ||||
-rw-r--r-- | src/usr/isteps/expupd/test/expupdatetest.H | 48 | ||||
-rw-r--r-- | src/usr/isteps/expupd/test/test.mk | 1 | ||||
-rw-r--r-- | src/usr/mmio/test/makefile | 1 | ||||
-rw-r--r-- | src/usr/mmio/test/mmiotest.H | 310 | ||||
-rwxr-xr-x | src/usr/targeting/common/xmltohb/attribute_types_hb.xml | 12 | ||||
-rw-r--r-- | src/usr/targeting/common/xmltohb/target_types_hb.xml | 3 |
11 files changed, 604 insertions, 370 deletions
diff --git a/src/usr/expaccess/test/expscomtest.H b/src/usr/expaccess/test/expscomtest.H index c943ca7ba..366f50ca2 100644 --- a/src/usr/expaccess/test/expscomtest.H +++ b/src/usr/expaccess/test/expscomtest.H @@ -41,6 +41,7 @@ #include <fapi2_hwp_executor.H> #include <fapi2/hw_access.H> #include <lib/shared/exp_consts.H> +#include "exptest_utils.H" extern trace_desc_t* g_trac_expscom; @@ -107,6 +108,10 @@ private: return fapi2::getScom(i_target,i_address,o_data); } + // use this to keep track of if we need to unload any + // modules loaded by this testcase + bool mss_module_loaded; + TARGETING::HB_MUTEX_SERIALIZE_TEST_LOCK_ATTR iv_serializeTestMutex; public: /** @@ -128,11 +133,12 @@ public: TargetHandleList l_explorerList; do{ -// Causing a data storage exception in c_str... -#ifdef CONFIG_AXONE_BRING_UP -TRACFCOMP( g_trac_expscom,"skipping testExpscomI2c"); -break; -#endif + if (!iv_serializeTestMutex) + { + TS_FAIL("iv_serializedTestMutex is not setup"); + break; + } + // Get the system's OCMB chips, we will use these as test targets getAllChips( l_explorerList, TYPE_OCMB_CHIP, @@ -144,7 +150,6 @@ break; break; } - // We will use the first and last targets for these scom tests auto l_firstExpChip = l_explorerList.front(); auto l_lastExpChip = l_explorerList.back(); @@ -157,6 +162,10 @@ break; auto first_ocmb_info = l_firstExpChip->getAttr<TARGETING::ATTR_SCOM_SWITCHES>(); auto last_ocmb_info = l_lastExpChip->getAttr<TARGETING::ATTR_SCOM_SWITCHES>(); + // Inband operations can't be run at the same time + // atomic section >> + mutex_lock(iv_serializeTestMutex); + // This goal of this tests is to make sure I2C scom to OCMB is working so force // scom to go over I2C path for these targets l_firstExpChip->setAttr<TARGETING::ATTR_SCOM_SWITCHES>(forceI2CScom); @@ -178,7 +187,6 @@ break; // Otherwise we know this is a native OCMB address and it is only 32 bits l_scom_buffer.insert<32,32,0,uint32_t>(l_testEntry.data); } - FAPI_INVOKE_HWP(l_err, put_scom, l_firstExpChip_fapi, l_testEntry.addr, @@ -258,6 +266,9 @@ break; // Set ATTR_SCOM_SWITCHES back to their original values l_firstExpChip->setAttr<TARGETING::ATTR_SCOM_SWITCHES>(first_ocmb_info); l_lastExpChip->setAttr<TARGETING::ATTR_SCOM_SWITCHES>(last_ocmb_info); + + // << atomic section + mutex_unlock(iv_serializeTestMutex); }while(0); TRACFCOMP( g_trac_expscom, "<< Exit testExpscomI2c"); @@ -283,12 +294,11 @@ break; TargetHandleList l_explorerList; do{ -// Causing a data storage exception in c_str... -#ifdef CONFIG_AXONE_BRING_UP -TRACFCOMP( g_trac_expscom,"skipping testExpscomI2cPlatformPlatform"); -break; -#endif - + if (!iv_serializeTestMutex) + { + TS_FAIL("iv_serializedTestMutex is not setup"); + break; + } getAllChips( l_explorerList, TYPE_OCMB_CHIP, true ); // true: return functional OCMBs @@ -296,7 +306,7 @@ break; if(l_explorerList.size() == 0 ) { - TRACFCOMP( g_trac_expscom, "No OCMB targets found, skipping testExpscomI2cPlatformPlatform"); + TRACFCOMP( g_trac_expscom, "No OCMB targets found, skipping testExpscomI2cPlatform"); break; } @@ -308,6 +318,10 @@ break; auto first_ocmb_info = l_firstExpChip->getAttr<TARGETING::ATTR_SCOM_SWITCHES>(); auto last_ocmb_info = l_lastExpChip->getAttr<TARGETING::ATTR_SCOM_SWITCHES>(); + // Inband operations can't be run at the same time + // atomic section >> + mutex_lock(iv_serializeTestMutex); + // This goal of this tests is to make sure I2C scom to OCMB is working so force // scom to go over I2C path for these targets l_firstExpChip->setAttr<TARGETING::ATTR_SCOM_SWITCHES>(forceI2CScom); @@ -316,97 +330,101 @@ break; // Loop through table for first and last OCMB targets for( uint32_t l_num=0; l_num < g_expscomAddrTableSz; l_num++) { - // Read the test entry info from the global table at the top of this file - testExpscomAddrData l_testEntry = g_expscomAddrTable[l_num]; - - if(l_testEntry.addr & mss::exp::i2c::IBM_SCOM_INDICATOR) - { - // If this is an IBM address then we expect 64 bits of data - l_scom_buffer.insert<0,64,0,uint64_t>(l_testEntry.data); - } - else - { - // Otherwise we know this is a native OCMB address and it is only 32 bits - l_scom_buffer.insert<32,32,0,uint32_t>(l_testEntry.data); - } - l_err = deviceWrite(l_firstExpChip, - &l_scom_buffer, - l_scomSize, - DEVICE_SCOM_ADDRESS( l_testEntry.addr)); - l_tests++; - if(l_err) - { - FAIL_TEST_ERRL(l_firstExpChip, + // Read the test entry info from the global table at the top of this file + testExpscomAddrData l_testEntry = g_expscomAddrTable[l_num]; + + if(l_testEntry.addr & mss::exp::i2c::IBM_SCOM_INDICATOR) + { + // If this is an IBM address then we expect 64 bits of data + l_scom_buffer.insert<0,64,0,uint64_t>(l_testEntry.data); + } + else + { + // Otherwise we know this is a native OCMB address and it is only 32 bits + l_scom_buffer.insert<32,32,0,uint32_t>(l_testEntry.data); + } + l_err = deviceWrite(l_firstExpChip, + &l_scom_buffer, + l_scomSize, + DEVICE_SCOM_ADDRESS( l_testEntry.addr)); + l_tests++; + if(l_err) + { + FAIL_TEST_ERRL(l_firstExpChip, + "testExpscomI2cPlatform>> Failed putScom writing 0x%.16X to 0x%.8X on target w/ huid 0x%.8X"); + + } + + l_err = deviceWrite(l_lastExpChip, + &l_scom_buffer, + l_scomSize, + DEVICE_SCOM_ADDRESS( l_testEntry.addr)); + l_tests++; + if(l_err) + { + FAIL_TEST_ERRL(l_firstExpChip, "testExpscomI2cPlatform>> Failed putScom writing 0x%.16X to 0x%.8X on target w/ huid 0x%.8X"); - } - - l_err = deviceWrite(l_lastExpChip, - &l_scom_buffer, - l_scomSize, - DEVICE_SCOM_ADDRESS( l_testEntry.addr)); - l_tests++; - if(l_err) - { - FAIL_TEST_ERRL(l_firstExpChip, - "testExpscomI2cPlatform>> Failed putScom writing 0x%.16X to 0x%.8X on target w/ huid 0x%.8X"); - - } - // Flush scom buffers so it doesnt mess up next test - l_scom_buffer.flush<0>(); - - // getScom to first OCMB over i2c - l_err = deviceRead(l_firstExpChip, - &l_scom_buffer(), - l_scomSize, - DEVICE_SCOM_ADDRESS( l_testEntry.addr)); - l_tests++; - if(l_err) - { - FAIL_TEST_ERRL(l_firstExpChip, - "testExpscomI2cPlatform>> Failed getScom reading 0x%.16X to 0x%.8X on target w/ huid 0x%.8X") - } - - l_tests++; - if(l_scom_buffer() != l_testEntry.data) - { - l_fails++; - TS_FAIL("testExpscomI2cPlatform>> Expected 0x%.16X but got 0x%.16X on target w/ huid 0x%.8X", - l_testEntry.data, - l_scom_buffer(), - get_huid(l_firstExpChip)); - } - - - // Flush scom buffers so it doesnt mess up next test - l_scom_buffer.flush<0>(); - - // getScom to last OCMB over i2c - l_err = deviceRead(l_lastExpChip, - &l_scom_buffer(), - l_scomSize, - DEVICE_SCOM_ADDRESS( l_testEntry.addr)); - l_tests++; - if(l_err) - { - FAIL_TEST_ERRL(l_firstExpChip, - "testExpscomI2cPlatform>> Failed getScom reading 0x%.16X to 0x%.8X on target w/ huid 0x%.8X") - } - - l_tests++; - if(l_scom_buffer() != l_testEntry.data) - { - l_fails++; - TS_FAIL("testExpscomI2cPlatform>> Expected 0x%.16X but got 0x%.16X on target w/ huid 0x%.8X", - l_testEntry.data, - l_scom_buffer(), - get_huid(l_firstExpChip)); - } + } + // Flush scom buffers so it doesnt mess up next test + l_scom_buffer.flush<0>(); + + // getScom to first OCMB over i2c + l_err = deviceRead(l_firstExpChip, + &l_scom_buffer(), + l_scomSize, + DEVICE_SCOM_ADDRESS( l_testEntry.addr)); + l_tests++; + if(l_err) + { + FAIL_TEST_ERRL(l_firstExpChip, + "testExpscomI2cPlatform>> Failed getScom reading 0x%.16X to 0x%.8X on target w/ huid 0x%.8X") + } + + l_tests++; + if(l_scom_buffer() != l_testEntry.data) + { + l_fails++; + TS_FAIL("testExpscomI2cPlatform>> Expected 0x%.16X but got 0x%.16X on target w/ huid 0x%.8X", + l_testEntry.data, + l_scom_buffer(), + get_huid(l_firstExpChip)); + } + + + // Flush scom buffers so it doesnt mess up next test + l_scom_buffer.flush<0>(); + + // getScom to last OCMB over i2c + l_err = deviceRead(l_lastExpChip, + &l_scom_buffer(), + l_scomSize, + DEVICE_SCOM_ADDRESS( l_testEntry.addr)); + l_tests++; + if(l_err) + { + FAIL_TEST_ERRL(l_firstExpChip, + "testExpscomI2cPlatform>> Failed getScom reading 0x%.16X to 0x%.8X on target w/ huid 0x%.8X") + } + + l_tests++; + if(l_scom_buffer() != l_testEntry.data) + { + l_fails++; + TS_FAIL("testExpscomI2cPlatform>> Expected 0x%.16X but got 0x%.16X on target w/ huid 0x%.8X", + l_testEntry.data, + l_scom_buffer(), + get_huid(l_firstExpChip)); + } } // Set ATTR_SCOM_SWITCHES back to their original values l_firstExpChip->setAttr<TARGETING::ATTR_SCOM_SWITCHES>(first_ocmb_info); l_lastExpChip->setAttr<TARGETING::ATTR_SCOM_SWITCHES>(last_ocmb_info); + + // << atomic section + mutex_unlock(iv_serializeTestMutex); + }while(0); TRACFCOMP( g_trac_expscom, "<< Exit testExpscomI2cPlatform"); @@ -711,6 +729,45 @@ break; // return; // } + /** + * @brief Constructor + */ + expscomTest() : CxxTest::TestSuite() + { + mss_module_loaded = false; + + // All modules are loaded by runtime, + // so testcase loading of modules is not required +#ifndef __HOSTBOOT_RUNTIME + errlHndl_t err = nullptr; + + err = exptest::loadModule(mss_module_loaded, exptest::MSS_LIBRARY_NAME); + if(err) + { + TS_FAIL("expscomTest() - Constuctor: failed to load MSS module"); + errlCommit( err, 0x10 ); + } +#endif + iv_serializeTestMutex = exptest::getTestMutex(); + }; + + + /** + * @brief Destructor + */ + ~expscomTest() + { + errlHndl_t err = nullptr; + if (mss_module_loaded) + { + err = exptest::unloadModule(exptest::MSS_LIBRARY_NAME); + if(err) + { + TS_FAIL("~expscomTest() - Destructor: failed to unload MSS module"); + errlCommit( err, 0x10 ); + } + } + }; }; diff --git a/src/usr/expaccess/test/exptest_utils.C b/src/usr/expaccess/test/exptest_utils.C new file mode 100644 index 000000000..c063a68ea --- /dev/null +++ b/src/usr/expaccess/test/exptest_utils.C @@ -0,0 +1,96 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/usr/expaccess/test/exptest_utils.C $ */ +/* */ +/* OpenPOWER HostBoot Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2019 */ +/* [+] 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 */ +#include <fapi2.H> +#include <cxxtest/TestSuite.H> +#include "exptest_utils.H" + +namespace exptest +{ + errlHndl_t loadModule(bool & o_module_loaded, const char * i_modName) + { + errlHndl_t err = NULL; + o_module_loaded = false; + + // VFS functions only compilable in non-runtime environment + #ifndef __HOSTBOOT_RUNTIME + if(!VFS::module_is_loaded(i_modName)) + { + err = VFS::module_load(i_modName); + if(err) + { + TS_FAIL("loadModule() - %s load failed", i_modName ); + } + else + { + o_module_loaded = true; + FAPI_INF("loadModule: %s loaded", i_modName); + } + } + #endif + return err; + } + + errlHndl_t unloadModule(const char * i_modName) + { + errlHndl_t err = NULL; + + // VFS function only compilable in non-runtime environment + #ifndef __HOSTBOOT_RUNTIME + err = VFS::module_unload(i_modName); + if(err) + { + TS_FAIL("unloadModule() - %s unload failed", i_modName ); + } + else + { + FAPI_INF("unloadModule: %s unloaded", i_modName); + } + #endif + return err; + } + + TARGETING::HB_MUTEX_SERIALIZE_TEST_LOCK_ATTR getTestMutex(void) + { + TARGETING::HB_MUTEX_SERIALIZE_TEST_LOCK_ATTR pMutex = nullptr; + + // Get a reference to the target service + TARGETING::TargetService& l_targetService = TARGETING::targetService(); + + // Get the system target containing the test mutex + TARGETING::Target* l_pTarget = NULL; + (void) l_targetService.getTopLevelTarget(l_pTarget); + if (l_pTarget == nullptr) + { + TS_INFO("getTestMutex: Top level target handle is NULL"); + } + else + { + // use the chip-specific mutex attribute + pMutex = l_pTarget->getHbMutexAttr + <TARGETING::ATTR_HB_MUTEX_SERIALIZE_TEST_LOCK>(); + } + return pMutex; + } +} diff --git a/src/usr/expaccess/test/exptest_utils.H b/src/usr/expaccess/test/exptest_utils.H new file mode 100644 index 000000000..e6d6de72c --- /dev/null +++ b/src/usr/expaccess/test/exptest_utils.H @@ -0,0 +1,62 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/usr/expaccess/test/exptest_utils.H $ */ +/* */ +/* OpenPOWER HostBoot Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2019 */ +/* [+] 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 EXPTEST_UTILS_H_ +#define EXPTEST_UTILS_H_ + +#ifndef __HOSTBOOT_RUNTIME +#include <vfs/vfs.H> // module_is_loaded & module_load +#endif + +namespace exptest +{ + +// Need this module for mss::c_str call in HWP failure path traces +const char MSS_LIBRARY_NAME[17] = "libisteps_mss.so"; + +/** + * @brief Generic function to load a module + * @param o_module_loaded - returns true if module is loaded by this function + * @param i_modName - module name to load + * @return error handle if module_load call fails + */ +errlHndl_t loadModule(bool & o_module_loaded, const char * i_modName); + +/** + * @brief Generic function to unload a module + * @param i_modName - module name to load + * @return error handle if module_unload call fails + * + */ +errlHndl_t unloadModule(const char * i_modName); + +/** + * @brief Get the mutex pointer for syncronizing tests + * @return pointer to mutex, nullptr if not found + */ +TARGETING::HB_MUTEX_SERIALIZE_TEST_LOCK_ATTR getTestMutex(void); + +} + +#endif diff --git a/src/usr/expaccess/test/makefile b/src/usr/expaccess/test/makefile index 461a908c8..41706b719 100644 --- a/src/usr/expaccess/test/makefile +++ b/src/usr/expaccess/test/makefile @@ -28,7 +28,8 @@ MODULE = testexpaccess include test.mk -#TODO RTC:196806 re-enable mmio communication tests when mmio works -TESTS = expscomtest.H +OBJS += exptest_utils.o -include ${ROOTPATH}/config.mk
\ No newline at end of file +TESTS = *.H + +include ${ROOTPATH}/config.mk diff --git a/src/usr/expaccess/test/ocmbcommtest.H b/src/usr/expaccess/test/ocmbcommtest.H index 94d298032..f2718b6bb 100644 --- a/src/usr/expaccess/test/ocmbcommtest.H +++ b/src/usr/expaccess/test/ocmbcommtest.H @@ -33,13 +33,13 @@ #include <errl/errlmanager.H> #include <errl/errlentry.H> #include <fapi2.H> -#ifndef __HOSTBOOT_RUNTIME -#include <vfs/vfs.H> // module_is_loaded & module_load -#endif + #include <plat_hwp_invoker.H> #include <exp_inband.H> #include <exp_data_structs.H> #include <generic/memory/lib/utils/endian_utils.H> +#include "exptest_utils.H" + // EXP_FW_ADAPTER_PROPERTIES_GET data response format #define FW_ADAPTER_MAX_FW_IMAGE 4 @@ -67,64 +67,6 @@ typedef struct } FW_ADAPTER_PROPERTIES_type; -// Need this module for mss::c_str call in HWP failure path traces -const char MSS_LIBRARY_NAME[17] = "libisteps_mss.so"; - -/** - * @brief Generic function to load a module - * @param o_module_loaded - returns true if module is loaded by this function - * @param i_modName - module name to load - * @return error handle if module_load call fails - */ -errlHndl_t loadModule(bool & o_module_loaded, const char * i_modName) -{ - errlHndl_t err = NULL; - o_module_loaded = false; - -// VFS functions only compilable in non-runtime environment -#ifndef __HOSTBOOT_RUNTIME - if(!VFS::module_is_loaded(i_modName)) - { - err = VFS::module_load(i_modName); - if(err) - { - TS_FAIL("loadModule() - %s load failed", i_modName ); - } - else - { - o_module_loaded = true; - FAPI_INF("loadModule: %s loaded", i_modName); - } - } -#endif - return err; -} - -/** - * @brief Generic function to unload a module - * @param i_modName - module name to load - * @return error handle if module_unload call fails - */ -errlHndl_t unloadModule(const char * i_modName) -{ - errlHndl_t err = NULL; - -// VFS function only compilable in non-runtime environment -#ifndef __HOSTBOOT_RUNTIME - err = VFS::module_unload(i_modName); - if(err) - { - TS_FAIL("unloadExplorerModule() - %s unload failed", i_modName ); - } - else - { - FAPI_INF("unloadModule: %s unloaded", i_modName); - } -#endif - return err; -} - - class OCMBCommTest: public CxxTest::TestSuite { public: @@ -208,58 +150,80 @@ class OCMBCommTest: public CxxTest::TestSuite // Create a non-destructive get_properties command buildPropertiesGetCmd(l_cmd); - for (auto & l_ocmb: l_chipList) + if (!iv_serializeTestMutex) { - FAPI_INF("testOcmbInbandCmdRsp: testing 0x%.8X OCMB", TARGETING::get_huid(l_ocmb)); - - fapi2::Target<fapi2::TARGET_TYPE_OCMB_CHIP>l_fapi2_target( l_ocmb ); - - // send the command - FAPI_INVOKE_HWP(l_errl, mss::exp::ib::putCMD, l_fapi2_target, - l_cmd); - if (l_errl) - { - TS_FAIL("Error from putCMD for 0x%.8X target", - TARGETING::get_huid(l_ocmb)); - break; - } - - // grab the response - FAPI_INVOKE_HWP(l_errl, mss::exp::ib::getRSP, l_fapi2_target, - l_rsp, l_rsp_data); - if (l_errl) - { - TS_FAIL("Error from getRSP for 0x%.8X target", - TARGETING::get_huid(l_ocmb)); - break; - } + TS_FAIL("iv_serializedTestMutex is not setup, unable to continue"); + } + else + { + // Inband operations can't be run at the same time + // atomic section >> + mutex_lock(iv_serializeTestMutex); - // Check for a valid data response length - if (l_rsp.response_length != sizeof(FW_ADAPTER_PROPERTIES_type)) + for (auto & l_ocmb: l_chipList) { - TS_FAIL("Unexpected response length 0x%.8X (expected 0x%.8X)", - l_rsp.response_length, sizeof(FW_ADAPTER_PROPERTIES_type)); - break; + FAPI_INF("testOcmbInbandCmdRsp: testing 0x%.8X OCMB", TARGETING::get_huid(l_ocmb)); + + fapi2::Target<fapi2::TARGET_TYPE_OCMB_CHIP>l_fapi2_target( l_ocmb ); + + TRACFBIN(g_trac_expscom, "l_cmd: ", &l_cmd, sizeof(host_fw_command_struct)); + + // send the command + FAPI_INVOKE_HWP(l_errl, mss::exp::ib::putCMD, l_fapi2_target, + l_cmd); + if (l_errl) + { + TS_FAIL("Error from putCMD for 0x%.8X target", + TARGETING::get_huid(l_ocmb)); + break; + } + + FAPI_INF("testOcmbInbandCmdRsp: reading response"); + + // grab the response + FAPI_INVOKE_HWP(l_errl, mss::exp::ib::getRSP, l_fapi2_target, + l_rsp, l_rsp_data); + if (l_errl) + { + TS_FAIL("Error from getRSP for 0x%.8X target, plid=0x%X rc=0x%X", + TARGETING::get_huid(l_ocmb), + ERRL_GETPLID_SAFE(l_errl), ERRL_GETRC_SAFE(l_errl)); + break; + } + + TRACFBIN(g_trac_expscom, "l_rsp: ", &l_rsp, sizeof(host_fw_response_struct)); + TRACFBIN(g_trac_expscom, "l_rsp_data: ", l_rsp_data.data(), l_rsp_data.size()); + + // Check for a valid data response length + if (l_rsp.response_length != sizeof(FW_ADAPTER_PROPERTIES_type)) + { + TS_FAIL("Unexpected response length 0x%.8X (expected 0x%.8X)", + l_rsp.response_length, sizeof(FW_ADAPTER_PROPERTIES_type)); + break; + } + + // Now convert the little endian response data into big endian + FW_ADAPTER_PROPERTIES_type l_fw_adapter_data; + fw_adapter_properties_struct_from_little_endian(l_fw_adapter_data, + l_rsp_data); + + // Check for some expected response values + // Simics should return 0x88 as the first byte of chip_version + if (l_fw_adapter_data.chip_version[0] != 0x88 ) + { + TS_FAIL("Expected chip_version to start with 0x88, found 0x%02X", + l_fw_adapter_data.chip_version[0]); + } } - // Now convert the little endian response data into big endian - FW_ADAPTER_PROPERTIES_type l_fw_adapter_data; - fw_adapter_properties_struct_from_little_endian(l_fw_adapter_data, - l_rsp_data); + // << atomic section + mutex_unlock(iv_serializeTestMutex); - // Check for some expected response values - // Simics should return 0x10 as the first byte of chip_version - if (l_fw_adapter_data.chip_version[0] != 0x10 ) + if (l_errl) { - TS_FAIL("Expected chip_version to start with 0x10, found 0x%02X", - l_fw_adapter_data.chip_version[0]); + errlCommit( l_errl, TARG_COMP_ID ); } } - - if (l_errl) - { - errlCommit( l_errl, TARG_COMP_ID ); - } FAPI_INF("testOcmbInbandCmdRsp: exiting"); }; @@ -275,16 +239,16 @@ class OCMBCommTest: public CxxTest::TestSuite #ifndef __HOSTBOOT_RUNTIME errlHndl_t err = nullptr; - err = loadModule(mss_module_loaded, MSS_LIBRARY_NAME); + err = exptest::loadModule(mss_module_loaded, exptest::MSS_LIBRARY_NAME); if(err) { TS_FAIL("OCMBCommTest() - Constuctor: failed to load MSS module"); errlCommit( err, TARG_COMP_ID ); } #endif + iv_serializeTestMutex = exptest::getTestMutex(); }; - /** * @brief Destructor */ @@ -293,7 +257,7 @@ class OCMBCommTest: public CxxTest::TestSuite errlHndl_t err = nullptr; if (mss_module_loaded) { - err = unloadModule(MSS_LIBRARY_NAME); + err = exptest::unloadModule(exptest::MSS_LIBRARY_NAME); if(err) { TS_FAIL("~OCMBCommTest() - Destructor: failed to unload MSS module"); @@ -307,6 +271,9 @@ class OCMBCommTest: public CxxTest::TestSuite // modules loaded by this testcase bool mss_module_loaded; + // This is used for tests that need to not run operations at the same time + TARGETING::HB_MUTEX_SERIALIZE_TEST_LOCK_ATTR iv_serializeTestMutex; + }; #endif diff --git a/src/usr/isteps/expupd/test/expupdatetest.H b/src/usr/isteps/expupd/test/expupdatetest.H index a56249ce6..1cfc919a1 100644 --- a/src/usr/isteps/expupd/test/expupdatetest.H +++ b/src/usr/isteps/expupd/test/expupdatetest.H @@ -44,6 +44,7 @@ #ifndef __HOSTBOOT_RUNTIME #include <vfs/vfs.H> // module_is_loaded & module_load #endif +#include <test/exptest_utils.H> const char MSS_LIBRARY_NAME[] = "libisteps_mss.so"; const char EXPUPD_LIBRARY_NAME[] = "libexpupd.so"; @@ -121,31 +122,44 @@ class ExpUpdateTest: public CxxTest::TestSuite // Get a list of all of the functioning ocmb chips TARGETING::getAllChips(l_chipList, TARGETING::TYPE_OCMB_CHIP, true); - for (const auto & l_ocmb: l_chipList) + TARGETING::HB_MUTEX_SERIALIZE_TEST_LOCK_ATTR l_mutex = exptest::getTestMutex(); + if (l_mutex == nullptr) { - TS_TRACE("testExpFwUpdate: updating OCMB 0x%.8X", - TARGETING::get_huid(l_ocmb)); + TS_FAIL("testExpFwUpdate: unable to get test mutex"); + } + else + { + for (const auto & l_ocmb: l_chipList) + { + fapi2::Target<fapi2::TARGET_TYPE_OCMB_CHIP>l_fapi2_target(l_ocmb); - fapi2::Target<fapi2::TARGET_TYPE_OCMB_CHIP>l_fapi2_target(l_ocmb); + // Inband operations can't be run at the same time + // atomic section >> + mutex_lock(l_mutex); - // Invoke procedure - FAPI_INVOKE_HWP(l_errl, exp_fw_update, l_fapi2_target, - l_dataBuffer, sizeof(l_dataBuffer)); - if (l_errl) - { + // Invoke procedure + FAPI_INVOKE_HWP(l_errl, exp_fw_update, l_fapi2_target, + l_dataBuffer, sizeof(l_dataBuffer)); + + // << atomic section + mutex_unlock(l_mutex); + if (l_errl) + { #if 0 // skipping exp_fw_update error until simics is changed - @fixme:RTC-209865 - TS_FAIL("Error from exp_fw_update for 0x%.8X target", - TARGETING::get_huid(l_ocmb)); + TS_FAIL("Error from exp_fw_update for 0x%.8X target", + TARGETING::get_huid(l_ocmb)); #endif - break; + break; + } } - } - if (l_errl) - { - errlCommit(l_errl, CXXTEST_COMP_ID); + if (l_errl) + { + errlCommit(l_errl, CXXTEST_COMP_ID); + } } - TS_TRACE("testExpFwUpdate: exiting"); + + TS_INFO("testExpFwUpdate: exiting"); }; /** diff --git a/src/usr/isteps/expupd/test/test.mk b/src/usr/isteps/expupd/test/test.mk index c23c8723b..aca30b7f4 100644 --- a/src/usr/isteps/expupd/test/test.mk +++ b/src/usr/isteps/expupd/test/test.mk @@ -31,4 +31,5 @@ EXTRAINCDIR += ${ROOTPATH}/src/import/chips/ocmb/explorer/procedures/hwp/memory/ EXTRAINCDIR += ${ROOTPATH}/src/import/chips/ocmb/explorer/procedures/hwp/memory/ EXTRAINCDIR += ${ROOTPATH}/src/import/chips/ocmb/explorer/common/include EXTRAINCDIR += ${ROOTPATH}/src/import +EXTRAINCDIR += ${ROOTPATH}/src/usr/expaccess diff --git a/src/usr/mmio/test/makefile b/src/usr/mmio/test/makefile index 68c11b604..3a9af5d71 100644 --- a/src/usr/mmio/test/makefile +++ b/src/usr/mmio/test/makefile @@ -28,6 +28,7 @@ MODULE = testmmio EXTRAINCDIR += ${ROOTPATH}/src/import/chips/ocmb/explorer/common/include/ EXTRAINCDIR += ${ROOTPATH}/src/import/chips/common/ +EXTRAINCDIR += ${ROOTPATH}/src/usr/expaccess/ TESTS = *.H diff --git a/src/usr/mmio/test/mmiotest.H b/src/usr/mmio/test/mmiotest.H index 30199e1a1..9987b50ee 100644 --- a/src/usr/mmio/test/mmiotest.H +++ b/src/usr/mmio/test/mmiotest.H @@ -33,6 +33,7 @@ #include <exp_oc_regs.H> #include <sys/mmio.h> #include <utils/chipids.H> +#include <test/exptest_utils.H> #define SCOM2MMIO_ADDR(_ADDR) (EXPLR_IB_MMIO_OFFSET | (_ADDR << 3)) #define CNFG2MMIO_ADDR(_ADDR) (EXPLR_IB_CONFIG_OFFSET | _ADDR) @@ -56,166 +57,185 @@ class MmioTest : public CxxTest::TestSuite */ void testExplrMMIO(void) { - TS_INFO("testExplrMMIO> Start" ); + TS_INFO("testExplrMMIO> Start" ); errlHndl_t l_err = nullptr; uint32_t regdata4 = 0; size_t op_size = 0; uint64_t l_buffer64; - // Get OCMB target, return if there is no OCMB - TARGETING::TargetHandle_t explr_target = nullptr; - TARGETING::TargetHandleList ocmb_target_list; - TARGETING::getAllChips(ocmb_target_list, TARGETING::TYPE_OCMB_CHIP); - if (ocmb_target_list.size() == 0) + // Needed since the device operations could be using inband communication in error path + TARGETING::HB_MUTEX_SERIALIZE_TEST_LOCK_ATTR l_mutex = exptest::getTestMutex(); + if (l_mutex == nullptr) { - TS_INFO("testExplrMMIO> No OCMB targets found. Exiting."); + TS_FAIL("testExplrMMIO: unable to get test mutex"); return; } - explr_target = ocmb_target_list[0]; - if(explr_target->getAttr<TARGETING::ATTR_CHIP_ID>() != - POWER_CHIPID::EXPLORER_16) - { - TS_INFO("testExplrMMIO> No explorer targets found. Exiting."); - return; - } - - // valid read from config space register - op_size = sizeof(regdata4); - l_err = DeviceFW::deviceRead( - explr_target, - ®data4, - op_size, - DEVICE_MMIO_ADDRESS( - CNFG2MMIO_ADDR(EXPLR_OC_O0MBIT_O0DID_LSB), - op_size)); - if(l_err != nullptr) - { - errlCommit(l_err, CXXTEST_COMP_ID); - TS_FAIL("testExplrMMIO> Error for config read, RC=0x%04X", - ERRL_GETRC_SAFE(l_err)); - } - - // valid write to config space register - op_size = sizeof(regdata4); - l_err = DeviceFW::deviceWrite( - explr_target, - ®data4, - op_size, - DEVICE_MMIO_ADDRESS( - CNFG2MMIO_ADDR(EXPLR_OC_O0CCD_LSB), - op_size)); - if(l_err != nullptr) - { - errlCommit(l_err, CXXTEST_COMP_ID); - TS_FAIL("testExplrMMIO> Error for config write, RC=0x%04X", - ERRL_GETRC_SAFE(l_err)); - } - - // 1st valid write to SCOM register (also sets up - // tests for forcing HW read/write failures) - // Set the PCB error bits (8:10) to binary 100, which means - // 'invalid address' - // NOTE: must byteswap to little endian before writing - uint64_t GIF2PCB_INVALID_SCOM_ADDR_ERROR = 0x0080000000000000ull; - l_buffer64 = BYTESWAP64(GIF2PCB_INVALID_SCOM_ADDR_ERROR); - op_size = sizeof(l_buffer64); - l_err = DeviceFW::deviceWrite( - explr_target, - &l_buffer64, - op_size, - DEVICE_MMIO_ADDRESS( - SCOM2MMIO_ADDR( - EXPLR_TP_MB_UNIT_TOP_GIF2PCB_ERROR_REG), - op_size)); - if(l_err != nullptr) - { - errlCommit(l_err, CXXTEST_COMP_ID); - TS_FAIL("testExplrMMIO> Error for gif2pcb write, RC=0x%04X", - ERRL_GETRC_SAFE(l_err)); - return; - } - - // 2nd valid write to SCOM register (also sets up - // tests for forcing HW read/write failures) - // This register should contain a copy of the GIF2PCB error register - // starting at bit 32 - // NOTE: must byteswap to little endian before writing data - uint64_t PIB2GIF_INVALID_SCOM_ADDR_ERROR = - 0x0000000000000000ull | - ((GIF2PCB_INVALID_SCOM_ADDR_ERROR & - 0xffffc00000000000ull) >> 32); - l_buffer64 = BYTESWAP64(PIB2GIF_INVALID_SCOM_ADDR_ERROR); - op_size = sizeof(l_buffer64); - l_err = DeviceFW::deviceWrite( - explr_target, - &l_buffer64, - op_size, - DEVICE_MMIO_ADDRESS( - SCOM2MMIO_ADDR( - EXPLR_TP_MB_UNIT_TOP_PIB2GIF_ERROR_REG), - op_size)); - if(l_err != nullptr) - { - errlCommit(l_err, CXXTEST_COMP_ID); - TS_FAIL("testExplrMMIO> Error for pib2gif write, RC=0x%04X", - ERRL_GETRC_SAFE(l_err)); - return; - } + // >> atomic section + mutex_lock(l_mutex); + + do { + + // Get OCMB target, return if there is no OCMB + TARGETING::TargetHandle_t explr_target = nullptr; + TARGETING::TargetHandleList ocmb_target_list; + TARGETING::getAllChips(ocmb_target_list, TARGETING::TYPE_OCMB_CHIP); + if (ocmb_target_list.size() == 0) + { + TS_INFO("testExplrMMIO> No OCMB targets found. Exiting."); + break; + } + explr_target = ocmb_target_list[0]; + if(explr_target->getAttr<TARGETING::ATTR_CHIP_ID>() != + POWER_CHIPID::EXPLORER_16) + { + TS_INFO("testExplrMMIO> No explorer targets found. Exiting."); + break; + } + + // valid read from config space register + op_size = sizeof(regdata4); + l_err = DeviceFW::deviceRead( + explr_target, + ®data4, + op_size, + DEVICE_MMIO_ADDRESS( + CNFG2MMIO_ADDR(EXPLR_OC_O0MBIT_O0DID_LSB), + op_size)); + + if(l_err != nullptr) + { + errlCommit(l_err, CXXTEST_COMP_ID); + TS_FAIL("testExplrMMIO> Error for config read, RC=0x%04X", + ERRL_GETRC_SAFE(l_err)); + } + + // valid write to config space register + op_size = sizeof(regdata4); + l_err = DeviceFW::deviceWrite( + explr_target, + ®data4, + op_size, + DEVICE_MMIO_ADDRESS( + CNFG2MMIO_ADDR(EXPLR_OC_O0CCD_LSB), + op_size)); + if(l_err != nullptr) + { + errlCommit(l_err, CXXTEST_COMP_ID); + TS_FAIL("testExplrMMIO> Error for config write, RC=0x%04X", + ERRL_GETRC_SAFE(l_err)); + } + + // 1st valid write to SCOM register (also sets up + // tests for forcing HW read/write failures) + // Set the PCB error bits (8:10) to binary 100, which means + // 'invalid address' + // NOTE: must byteswap to little endian before writing + uint64_t GIF2PCB_INVALID_SCOM_ADDR_ERROR = 0x0080000000000000ull; + l_buffer64 = BYTESWAP64(GIF2PCB_INVALID_SCOM_ADDR_ERROR); + op_size = sizeof(l_buffer64); + l_err = DeviceFW::deviceWrite( + explr_target, + &l_buffer64, + op_size, + DEVICE_MMIO_ADDRESS( + SCOM2MMIO_ADDR( + EXPLR_TP_MB_UNIT_TOP_GIF2PCB_ERROR_REG), + op_size)); + + if(l_err != nullptr) + { + errlCommit(l_err, CXXTEST_COMP_ID); + TS_FAIL("testExplrMMIO> Error for gif2pcb write, RC=0x%04X", + ERRL_GETRC_SAFE(l_err)); + break; + } + + // 2nd valid write to SCOM register (also sets up + // tests for forcing HW read/write failures) + // This register should contain a copy of the GIF2PCB error register + // starting at bit 32 + // NOTE: must byteswap to little endian before writing data + uint64_t PIB2GIF_INVALID_SCOM_ADDR_ERROR = + 0x0000000000000000ull | + ((GIF2PCB_INVALID_SCOM_ADDR_ERROR & + 0xffffc00000000000ull) >> 32); + l_buffer64 = BYTESWAP64(PIB2GIF_INVALID_SCOM_ADDR_ERROR); + op_size = sizeof(l_buffer64); + l_err = DeviceFW::deviceWrite( + explr_target, + &l_buffer64, + op_size, + DEVICE_MMIO_ADDRESS( + SCOM2MMIO_ADDR( + EXPLR_TP_MB_UNIT_TOP_PIB2GIF_ERROR_REG), + op_size)); + + if(l_err != nullptr) + { + errlCommit(l_err, CXXTEST_COMP_ID); + TS_FAIL("testExplrMMIO> Error for pib2gif write, RC=0x%04X", + ERRL_GETRC_SAFE(l_err)); + break; + } #if 0 //@fixme - RTC:211487 - // Write to an "invalid" scom address. Should - // return with failure (now that we've set up the error regs). - // NOTE: Also, writing MMIO_OCMB_UE_DETECTED to this register - // sets up the following read to the same register - // to fail. - l_buffer64 = MMIO_OCMB_UE_DETECTED; - op_size = sizeof(l_buffer64); - l_err = DeviceFW::deviceWrite( - explr_target, - &l_buffer64, - op_size, - DEVICE_MMIO_ADDRESS( - SCOM2MMIO_ADDR(EXPLR_INVALID_SCOM_ADDR), - op_size)); - - if(l_err == nullptr) - { - TS_FAIL("testExplrMMIO> " - "did not recieve expected failure on mmio write"); - return; - } - else - { - TS_INFO("testExplrMMIO> recieved expected failure on mmio write"); - errlCommit(l_err, CXXTEST_COMP_ID); - } + // Write to an "invalid" scom address. Should + // return with failure (now that we've set up the error regs). + // NOTE: Also, writing MMIO_OCMB_UE_DETECTED to this register + // sets up the following read to the same register + // to fail. + l_buffer64 = MMIO_OCMB_UE_DETECTED; + op_size = sizeof(l_buffer64); + l_err = DeviceFW::deviceWrite( + explr_target, + &l_buffer64, + op_size, + DEVICE_MMIO_ADDRESS( + SCOM2MMIO_ADDR(EXPLR_INVALID_SCOM_ADDR), + op_size)); + if(l_err == nullptr) + { + TS_FAIL("testExplrMMIO> " + "did not recieve expected failure on mmio write"); + break; + } + else + { + TS_INFO("testExplrMMIO> received expected failure on mmio write"); + errlCommit(l_err, CXXTEST_COMP_ID); + } + + // Read from an "invalid" scom address. Should + // return with failure (now that we've se up the error regs). + op_size = sizeof(l_buffer64); + l_err = DeviceFW::deviceRead( + explr_target, + &l_buffer64, + op_size, + DEVICE_MMIO_ADDRESS( + SCOM2MMIO_ADDR(EXPLR_INVALID_SCOM_ADDR), + op_size)); - // Read from an "invalid" scom address. Should - // return with failure (now that we've se up the error regs). - op_size = sizeof(l_buffer64); - l_err = DeviceFW::deviceRead( - explr_target, - &l_buffer64, - op_size, - DEVICE_MMIO_ADDRESS( - SCOM2MMIO_ADDR(EXPLR_INVALID_SCOM_ADDR), - op_size)); - if(l_err == nullptr) - { - TS_INFO("testExplrMMIO> data read from invalid address: 0x%016llx", - l_buffer64); - TS_FAIL("testExplrMMIO> " - "did not recieve expected failure on mmio read"); - } - else - { - TS_INFO("testExplrMMIO> recieved expected failure on mmio read"); - errlCommit(l_err, CXXTEST_COMP_ID); - } + if(l_err == nullptr) + { + TS_INFO("testExplrMMIO> data read from invalid address: 0x%016llx", + l_buffer64); + TS_FAIL("testExplrMMIO> " + "did not recieve expected failure on mmio read"); + } + else + { + TS_INFO("testExplrMMIO> received expected failure on mmio read"); + errlCommit(l_err, CXXTEST_COMP_ID); + } #endif //@fixme - RTC:211487 + } while (0); + + // << atomic section + mutex_unlock(l_mutex); TS_INFO("testExplrMMIO> Done"); }; }; diff --git a/src/usr/targeting/common/xmltohb/attribute_types_hb.xml b/src/usr/targeting/common/xmltohb/attribute_types_hb.xml index b8584c544..491e9667b 100755 --- a/src/usr/targeting/common/xmltohb/attribute_types_hb.xml +++ b/src/usr/targeting/common/xmltohb/attribute_types_hb.xml @@ -346,6 +346,18 @@ </enumerator> </enumerationType> + <attribute> + <id>HB_MUTEX_SERIALIZE_TEST_LOCK</id> + <description>Hostboot mutex for serializing certain tests</description> + <simpleType> + <hbmutex/> + </simpleType> + <persistency>volatile-zeroed</persistency> + <readable/> + <writeable/> + <hbOnly/> + </attribute> + <!-- For POD Testing --> <attribute> <id>HB_MUTEX_TEST_LOCK</id> diff --git a/src/usr/targeting/common/xmltohb/target_types_hb.xml b/src/usr/targeting/common/xmltohb/target_types_hb.xml index 93e0bf912..1f7421305 100644 --- a/src/usr/targeting/common/xmltohb/target_types_hb.xml +++ b/src/usr/targeting/common/xmltohb/target_types_hb.xml @@ -284,6 +284,9 @@ <id>HB_EXISTING_IMAGE</id> </attribute> <attribute> + <id>HB_MUTEX_SERIALIZE_TEST_LOCK</id> + </attribute> + <attribute> <id>HB_MUTEX_TEST_LOCK</id> </attribute> <attribute> |