summaryrefslogtreecommitdiffstats
path: root/src/usr/expaccess/test/ocmbcommtest.H
diff options
context:
space:
mode:
Diffstat (limited to 'src/usr/expaccess/test/ocmbcommtest.H')
-rw-r--r--src/usr/expaccess/test/ocmbcommtest.H289
1 files changed, 174 insertions, 115 deletions
diff --git a/src/usr/expaccess/test/ocmbcommtest.H b/src/usr/expaccess/test/ocmbcommtest.H
index 94d298032..3c5486a1b 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 <lib/inband/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:
@@ -189,11 +131,13 @@ class OCMBCommTest: public CxxTest::TestSuite
}
/**
- * @brief Test the Explorer inband command/response path
+ * @brief Send and check get_properties Explorer inband command
+ * @return Number of failures
*/
- void testOcmbInbandCmdRsp( void )
+ int sendOcmbInbandCmdRsp(bool setScomI2c)
{
errlHndl_t l_errl = nullptr;
+ uint8_t failures = 0;
// Create a vector of TARGETING::Target pointers
TARGETING::TargetHandleList l_chipList;
@@ -210,102 +154,217 @@ class OCMBCommTest: public CxxTest::TestSuite
for (auto & l_ocmb: l_chipList)
{
- FAPI_INF("testOcmbInbandCmdRsp: testing 0x%.8X OCMB", TARGETING::get_huid(l_ocmb));
-
- fapi2::Target<fapi2::TARGET_TYPE_OCMB_CHIP>l_fapi2_target( l_ocmb );
+ do
+ {
+ if (setScomI2c)
+ {
+ FAPI_INF("sendOcmbInbandCmdRsp: testing 0x%.8X OCMB using I2C", TARGETING::get_huid(l_ocmb));
+ // disable inband and use i2c when possible
+ exptest::disableInbandScomsOcmb(l_ocmb);
+ }
+ else
+ {
+ FAPI_INF("sendOcmbInbandCmdRsp: testing 0x%.8X OCMB using MMIO", TARGETING::get_huid(l_ocmb));
+ // just incase some other test disabled inband scoms
+ exptest::enableInbandScomsOcmb(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));
+ failures++;
+ break;
+ }
+
+ FAPI_INF("sendOcmbInbandCmdRsp: 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));
+ failures++;
+ 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));
+ failures++;
+ 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]);
+ failures++;
+ }
+ } while (0);
- // 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;
+ // Commit the error as this is NOT expected and
+ // needs to be investigated
+ errlCommit( l_errl, TARG_COMP_ID );
}
- // grab the response
- FAPI_INVOKE_HWP(l_errl, mss::exp::ib::getRSP, l_fapi2_target,
- l_rsp, l_rsp_data);
- if (l_errl)
+ if (setScomI2c)
{
- TS_FAIL("Error from getRSP for 0x%.8X target",
- TARGETING::get_huid(l_ocmb));
- break;
+ // Default the ocmb back to inband communication
+ exptest::enableInbandScomsOcmb(l_ocmb);
}
+ }
+
+ FAPI_INF("sendOcmbInbandCmdRsp: exiting");
+ return failures;
+ };
+
+ /**
+ * @brief Test the Explorer inband command/response path over MMIO
+ */
+ void testOcmbInbandCmdRspOverMMIO( void )
+ {
+ if (!iv_serializeTestMutex)
+ {
+ 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))
+ int failures = sendOcmbInbandCmdRsp(false);
+ if (failures)
{
- TS_FAIL("Unexpected response length 0x%.8X (expected 0x%.8X)",
- l_rsp.response_length, sizeof(FW_ADAPTER_PROPERTIES_type));
- break;
+ TS_FAIL("testOcmbInbandCmdRspOverMMIO() failed: %d", failures);
}
+ mutex_unlock(iv_serializeTestMutex);
+ }
+ }
+
+ /**
+ * @brief Test the Explorer inband command/response path over I2C
+ * using ATTR_FORCE_SRAM_MMIO_OVER_I2C
+ */
+ void testOcmbInbandCmdRspOverI2c_via_force( void )
+ {
+ FAPI_INF("testOcmbInbandCmdRspOverI2c_via_force: entering");
+ if (!iv_serializeTestMutex)
+ {
+ 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);
+
+ // Set FORCE_SRAM_MMIO_OVER_I2C to change to use I2C instead of MMIO
+ TARGETING::Target * l_sys = nullptr;
+ TARGETING::targetService().getTopLevelTarget(l_sys);
+ crit_assert(l_sys != nullptr);
- // 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);
+ l_sys->setAttr<TARGETING::ATTR_FORCE_SRAM_MMIO_OVER_I2C>(0x01);
- // 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 )
+ int failures = sendOcmbInbandCmdRsp(false);
+ if (failures)
{
- TS_FAIL("Expected chip_version to start with 0x10, found 0x%02X",
- l_fw_adapter_data.chip_version[0]);
+ TS_FAIL("testOcmbInbandCmdRspOverI2c_via_force() failed: %d", failures);
}
+
+ // Restore using MMIO instead of I2C
+ l_sys->setAttr<TARGETING::ATTR_FORCE_SRAM_MMIO_OVER_I2C>(0x00);
+
+ mutex_unlock(iv_serializeTestMutex);
}
+ FAPI_INF("testOcmbInbandCmdRspOverI2c_via_force: exiting");
+ }
- if (l_errl)
+ /**
+ * @brief Test the Explorer inband command/response path over I2C
+ * using scom setting to i2c
+ */
+ void testOcmbInbandCmdRspOverI2c_via_scom_switch( void )
+ {
+ FAPI_INF("testOcmbInbandCmdRspOverI2c_via_scom_switch: entering");
+ if (!iv_serializeTestMutex)
{
- errlCommit( l_errl, TARG_COMP_ID );
+ TS_FAIL("iv_serializedTestMutex is not setup, unable to continue");
}
- FAPI_INF("testOcmbInbandCmdRsp: exiting");
- };
+ else
+ {
+ // Inband operations can't be run at the same time
+ // atomic section >>
+ mutex_lock(iv_serializeTestMutex);
+
+ // Set SCOM_SWITCHES to use i2c instead of MMMIO when
+ // running the inband cmd/rsp operations
+ int failures = sendOcmbInbandCmdRsp(true);
+ if (failures)
+ {
+ TS_FAIL("testOcmbInbandCmdRspOverI2c_via_scom_switch() failed: %d", failures);
+ }
+
+ mutex_unlock(iv_serializeTestMutex);
+ }
+ FAPI_INF("testOcmbInbandCmdRspOverI2c_via_scom_switch: exiting");
+ }
/**
* @brief Constructor
*/
OCMBCommTest() : 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 = loadModule(mss_module_loaded, MSS_LIBRARY_NAME);
+ err = exptest::loadModule(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
*/
~OCMBCommTest()
{
- errlHndl_t err = nullptr;
- if (mss_module_loaded)
- {
- err = unloadModule(MSS_LIBRARY_NAME);
- if(err)
- {
- TS_FAIL("~OCMBCommTest() - Destructor: failed to unload MSS module");
- errlCommit( err, TARG_COMP_ID );
- }
- }
};
private:
- // use this to keep track of if we need to unload any
- // 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;
};
OpenPOWER on IntegriCloud