diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/include/usr/devicefw/userif.H | 18 | ||||
-rw-r--r-- | src/include/usr/fapi2/hw_access.H | 1 | ||||
-rw-r--r-- | src/include/usr/sbeio/sbe_psudd.H (renamed from src/usr/sbeio/sbe_psudd.H) | 87 | ||||
-rw-r--r-- | src/usr/devicefw/associator.C | 12 | ||||
-rw-r--r-- | src/usr/devicefw/userif.C | 18 | ||||
-rw-r--r-- | src/usr/fapi2/plat_hw_access.C | 59 | ||||
-rw-r--r-- | src/usr/fapi2/test/fapi2HwAccessTest.H | 21 | ||||
-rw-r--r-- | src/usr/fapi2/test/p9_hwtests.C | 24 | ||||
-rw-r--r-- | src/usr/fapi2/test/p9_hwtests.H | 2 | ||||
-rw-r--r-- | src/usr/sbeio/sbe_coreStateControl.C | 9 | ||||
-rw-r--r-- | src/usr/sbeio/sbe_psudd.C | 19 | ||||
-rw-r--r-- | src/usr/scan/makefile | 8 | ||||
-rw-r--r-- | src/usr/scan/scandd.C | 559 | ||||
-rw-r--r-- | src/usr/scan/scandd.H | 20 |
14 files changed, 672 insertions, 185 deletions
diff --git a/src/include/usr/devicefw/userif.H b/src/include/usr/devicefw/userif.H index 59e812d8a..50a6aa2e9 100644 --- a/src/include/usr/devicefw/userif.H +++ b/src/include/usr/devicefw/userif.H @@ -46,6 +46,7 @@ namespace DeviceFW /** @enum AccessType * @brief Access types for accessing a hardware device. */ + enum AccessType { SCOM = 0, @@ -266,11 +267,28 @@ namespace DeviceFW static_cast<uint64_t>(( i_ringlen )),\ static_cast<uint64_t>(( i_flag )) + /** + * Construct the device addressing parameters for the SCAN device ops. + * @param[in] i_ringID - ring ID + * @param[in] i_ringMode - Ring Mode + * + * @param[in] i_flag - flags + * PUT_RING_FROM_IMAGE_COMMAND - is for Put Ring from Image command + */ + + #define PUT_RING_FROM_IMAGE_COMMAND (0xFFFFFFFFFFFFFFFF) + #define DEVICE_SCAN_SBE_ADDRESS( i_ringID, i_ringMode, i_flag )\ + DeviceFW::SCAN, static_cast<uint64_t>(( i_ringID )),\ + static_cast<uint64_t>(( i_ringMode )),\ + static_cast<uint64_t>(( i_flag )),\ + static_cast<uint64_t>(PUT_RING_FROM_IMAGE_COMMAND) + /** * Construct the device addressing parameters for the LPC device ops. * @param[in] i_trans_type - LPC transaction type. * @param[in] i_address - LPC address to operate on. * Flag options are located in: src/include/usr/lpc/lpcif.H + * */ #define DEVICE_LPC_ADDRESS( i_trans_type, i_address )\ DeviceFW::LPC, static_cast<uint64_t>(( i_trans_type )),\ diff --git a/src/include/usr/fapi2/hw_access.H b/src/include/usr/fapi2/hw_access.H index 2d4444eb3..57941e752 100644 --- a/src/include/usr/fapi2/hw_access.H +++ b/src/include/usr/fapi2/hw_access.H @@ -243,6 +243,7 @@ inline ReturnCode putRing(const Target<K>& i_target, const RingID i_ringID, const RingMode i_ringMode = RING_MODE_HEADER_CHECK) { + FAPI_DBG("Entering putRing with RingID ..."); return platPutRing(i_target, i_ringID, i_ringMode); } diff --git a/src/usr/sbeio/sbe_psudd.H b/src/include/usr/sbeio/sbe_psudd.H index 9b6228d89..19182408a 100644 --- a/src/usr/sbeio/sbe_psudd.H +++ b/src/include/usr/sbeio/sbe_psudd.H @@ -1,11 +1,11 @@ /* IBM_PROLOG_BEGIN_TAG */ /* This is an automatically generated prolog. */ /* */ -/* $Source: src/usr/sbeio/sbe_psudd.H $ */ +/* $Source: src/include/usr/sbeio/sbe_psudd.H $ */ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2012,2016 */ +/* Contributors Listed Below - COPYRIGHT 2016 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -22,7 +22,6 @@ /* permissions and limitations under the License. */ /* */ /* IBM_PROLOG_END_TAG */ - #ifndef __SBE_PSUDD_H #define __SBE_PSUDD_H @@ -48,23 +47,39 @@ namespace SBEIO /** * @brief enums for SBE command class */ + + // BYTE 6 options enum psuCommandClass { SBE_PSU_CLASS_UNKNOWN = 0, SBE_PSU_CLASS_CORE_STATE = 0xD1, + SBE_PSU_PUT_RING_FROM_IMAGE_CMD = 0xD3 }; /** * @brief enums for SBE core state control commands */ + + // BYTE 7 options enum psuCoreStateControlCommands { SBE_CMD_CONTROL_DEADMAN_LOOP = 0x01, + + }; + + /** + * @brief enums for SBEPutRing From Image message commands + */ + // BYTE 7 options + enum putRingCommandFromImageCommands + { + SBE_CMD_CONTROL_PUTRING = 0x01 }; /** * @brief enums for SBE core state control commands */ + //BYTE 2 & 3, Control Flags enum psuDeadManControlFlags { SBE_DMCONTROL_START = 0x01, @@ -144,31 +159,61 @@ namespace SBEIO } PACKED; struct //controlDeadmanLoop { - uint16_t cdl_reserved; - uint16_t cdl_controlFlags; - uint16_t cdl_seqID; - uint8_t cdl_commandClass; - uint8_t cdl_command; - uint64_t cdl_waitTime ; - uint64_t cdl_mbxReg2reserved; - uint64_t cdl_mbxReg3reserved; + uint16_t cd1_ControlDeadmanLoop_Reserved; + uint16_t cd1_ControlDeadmanLoop_ControlFlags; + uint16_t cd1_ControlDeadmanLoop_SeqID; + uint8_t cd1_ControlDeadmanLoop_CommandClass; + uint8_t cd1_ControlDeadmanLoop_Command; + uint64_t cd1_ControlDeadmanLoop_WaitTime ; + uint64_t cd1_ControlDeadmanLoop_MbxReg2reserved; + uint64_t cd1_ControlDeadmanLoop_MbxReg3reserved; } PACKED; - psuCommand(uint16_t i_controlFlags, - uint8_t i_commandClass, - uint8_t i_command) : + + struct //for 'Put Ring from Image' message + { + uint16_t cd3_PutRing_Reserved; //Mbx Reg 0 + uint16_t cd3_PutRing_ControlFlags; //Mbx Reg 0 + uint16_t cd3_PutRing_SeqID; //Mbx Reg 0 + uint8_t cd3_PutRing_CommandClass; //Mbx Reg 0 + uint8_t cd3_PutRing_Command; //Mbx Reg 0 + uint16_t cd3_PutRing_TargetType; //Mbx Reg 1 + uint8_t cd3_PutRing_Reserved1; //Mbx Reg 1 + uint8_t cd3_PutRing_ChipletID; //Mbx Reg 1 + uint16_t cd3_PutRing_RingID; //Mbx Reg 1 + uint16_t cd3_PutRing_RingMode; //Mbx Reg 1 + uint64_t cd3_PutRing_ReservedMbxReg2; //Mbx Reg 2 + uint64_t cd3_PutRing_ReservedMbxReg3; //Mbx Reg 3 + }PACKED; + + psuCommand(uint16_t i_controlFlags, //Mbx Reg 0 input + uint8_t i_commandClass, //Mbx Reg 0 input + uint8_t i_command) : //Mbx Reg 0 input + + //setting BYTE 0 & 1 Mbx Reg 0 reserved (0), + //setting BYTE 2 & 3 Mbx Reg 0 controlFlags(i_controlFlags), + //setting BYTE 4 & 5 Mbx Reg 0 seqID(0), + //setting BYTE 6 Mbx Reg 0 commandClass(i_commandClass), + //setting BYTE 7 Mbx Reg 0 command(i_command), + //setting BYTE 8- Byte 11 - Mbx Reg 1 dataWord2(0), + //setting BYTE 12- Byte 15 - Mbx Reg 1 dataWord3(0), + //setting BYTE 16- Byte 19 - Mbx Reg 2 dataWord4(0), + //setting BYTE 20- Byte 23 - Mbx Reg 2 dataWord5(0), + //setting BYTE 24- Byte 27 - Mbx Reg 3 dataWord6(0), + //setting BYTE 28- Byte 31 - Mbx Reg 3 dataWord7(0) { } + }; /** @@ -234,6 +279,7 @@ namespace SBEIO respWord5 (0) { } + }; /** @@ -283,6 +329,7 @@ namespace SBEIO SBE_SEC_SBE_BUSY_TO_HANDLE_COMMAND = 0x10, }; + /** * @Brief perform SBE PSU chip-op * @@ -409,6 +456,18 @@ namespace SBEIO HOST_CLEAR_RESPONSE_WAITING = 0x7FFFFFFFFFFFFFFF, }; + + enum SBE_TARGET_TYPES { + + SBE_TARGET_TYPE_PROC = 0x00, + SBE_TARGET_TYPE_EX = 0x01, + SBE_TARGET_TYPE_PERV = 0x02, + SBE_TARGET_TYPE_MCS = 0x03, + SBE_TARGET_TYPE_TOTAL , + SBE_TARGET_TYPE_UNKNOWN = 0xFF + }; + + } #endif diff --git a/src/usr/devicefw/associator.C b/src/usr/devicefw/associator.C index 8d34d9554..088deff90 100644 --- a/src/usr/devicefw/associator.C +++ b/src/usr/devicefw/associator.C @@ -167,7 +167,9 @@ namespace DeviceFW if( NULL == i_target ) { - TRACFCOMP(g_traceBuffer, "A device driver operation was attempted on a NULL target : i_opType=%d, i_accessType=%d", i_opType, i_accessType ); + TRACFCOMP(g_traceBuffer, "associator.C: A device driver operation was" + " attempted on a NULL target : i_opType=%d, i_accessType=%d", + i_opType, i_accessType ); /*@ * @errortype * @moduleid DEVFW_MOD_ASSOCIATOR @@ -205,7 +207,10 @@ namespace DeviceFW // Call function if one was found, create error otherwise. if (NULL == l_devRoute) { - TRACFCOMP(g_traceBuffer, "A device driver operation was attempted for which no driver has been registered : i_opType=%d, i_accessType=%d, l_devType=%d", i_opType, i_accessType, l_devType ); + TRACFCOMP(g_traceBuffer, "associator.C: A device driver operation" + " was attempted for which no driver has been registered : " + "i_opType=%d, i_accessType=%d, l_devType=%d", + i_opType, i_accessType, l_devType ); /*@ * @errortype * @moduleid DEVFW_MOD_ASSOCIATOR @@ -223,13 +228,14 @@ namespace DeviceFW TO_UINT64(l_devType) ); } - else + else //This section is where the intended function is called { l_errl = (*l_devRoute)(i_opType, i_target, io_buffer, io_buflen, i_accessType, i_addr); } + return l_errl; } diff --git a/src/usr/devicefw/userif.C b/src/usr/devicefw/userif.C index 79b7b4cd6..e05a2737b 100644 --- a/src/usr/devicefw/userif.C +++ b/src/usr/devicefw/userif.C @@ -5,7 +5,9 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* COPYRIGHT International Business Machines Corp. 2011,2014 */ +/* Contributors Listed Below - COPYRIGHT 2011,2016 */ +/* [+] 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. */ @@ -26,9 +28,11 @@ #include <devicefw/userif.H> #include <util/singleton.H> +#include <trace/interface.H> #include "associator.H" + namespace DeviceFW { errlHndl_t deviceRead(TARGETING::Target* i_target, @@ -48,9 +52,16 @@ namespace DeviceFW return errl; } + /* + * Function: deviceWrite + * + * Responsible for routing generic driver requests + * to appropriate devices + * + */ errlHndl_t deviceWrite(TARGETING::Target* i_target, - void* i_buffer, size_t& io_buflen, - AccessType i_accessType, ...) + void* i_buffer, size_t& io_buflen, + AccessType i_accessType, ...) { va_list args; errlHndl_t errl; @@ -60,7 +71,6 @@ namespace DeviceFW errl = Singleton<Associator>::instance().performOp( WRITE, i_target, i_buffer, io_buflen, i_accessType, args); - va_end(args); return errl; } diff --git a/src/usr/fapi2/plat_hw_access.C b/src/usr/fapi2/plat_hw_access.C index 2a58e3eba..5626bf4d2 100644 --- a/src/usr/fapi2/plat_hw_access.C +++ b/src/usr/fapi2/plat_hw_access.C @@ -43,6 +43,7 @@ #include <scan/scanif.H> #include <hw_access_def.H> +#include <arch/ppc.H> namespace fapi2 @@ -911,17 +912,61 @@ ReturnCode platModifyRing(const Target<TARGET_TYPE_ALL>& i_target, return l_rc; } - +/// @brief passing a 'Put Ring from Image' message to SBE with RingID ReturnCode platPutRing(const Target<TARGET_TYPE_ALL>& i_target, - const RingID i_ringID, - const RingMode i_ringMode) + const RingID i_ringID, + const RingMode i_ringMode = RING_MODE_HEADER_CHECK) { - FAPI_DBG(ENTER_MRK "platPutRing with RingID"); - ReturnCode l_rc; + FAPI_DBG("Entering: platPutRing() with RingID"); + ReturnCode l_rc = FAPI2_RC_SUCCESS; + errlHndl_t l_err = NULL; + + // Note: Trace is placed here in plat code because PPE doesn't support + // trace in common fapi2_hw_access.H + bool l_traceit = platIsScanTraceEnabled(); - // TODO-RTC:132654:Use SBE to drive scans + //convert const ringID to ringID + RingID l_ringID = reinterpret_cast<RingID>(i_ringID); + + // Extract the component pointer + TARGETING::Target* l_target = + reinterpret_cast<TARGETING::Target*>(i_target.get()); + + // Grab the name of the target + TARGETING::ATTR_FAPI_NAME_type l_targName = {0}; + fapi2::toString(i_target, l_targName, sizeof(l_targName)); + + uint64_t l_flag = platGetDDScanMode(i_ringMode); + size_t l_size = (size_t) 0; + + FAPI_DBG("platPutRing l_target : %.16llX i_targetType %.16llX", + l_target, + l_target->getAttr<TARGETING::ATTR_TYPE>()); + + FAPI_DBG("platPutRing l_RingID :" + " %.16llX i_ringMode %.16llX l_flag %.16llX", + static_cast<uint64_t>(l_ringID), i_ringMode, l_flag ); + + l_err = deviceWrite(l_target, + nullptr, + l_size, + DEVICE_SCAN_SBE_ADDRESS(l_ringID,i_ringMode,l_flag)); + + if(l_err) + { + FAPI_ERR("platPutRing: deviceWrite returns error!"); + // Add the error log pointer as data to the ReturnCode + l_rc.setPlatDataPtr(reinterpret_cast<void *> (l_err)); + } + + if (l_traceit) + { + FAPI_SCAN("TRACE : PUTRING w RingID : %s : %.16llX", + l_targName, + static_cast<uint64_t>(l_ringID)); + } - FAPI_DBG(EXIT_MRK "platPutRing with RingID"); + FAPI_DBG(EXIT_MRK "platPutRing() with RingID"); return l_rc; } diff --git a/src/usr/fapi2/test/fapi2HwAccessTest.H b/src/usr/fapi2/test/fapi2HwAccessTest.H index 0773ced18..c113f5d18 100644 --- a/src/usr/fapi2/test/fapi2HwAccessTest.H +++ b/src/usr/fapi2/test/fapi2HwAccessTest.H @@ -159,6 +159,25 @@ void test_fapi2HwAccess() // a false negative on the next case (future?) } + +// this test should only be run before HOSTBOOT runtime +// otherwise it will trigger false positive test result + +#ifndef __HOSTBOOT_RUNTIME + + //this test should not be run at runtime + numTests++; + FAPI_INVOKE_HWP(l_errl, p9_platPutRingWRingID_pass); + if(l_errl) + { + TS_FAIL("Error from p9_platPutRingWRingID_pass !!"); + numFails++; + errlCommit(l_errl,FAPI2_COMP_ID); + delete l_errl; // delete unexpected error log so we dont get + // a false negative on the next case + } +#endif + numTests++; FAPI_INVOKE_HWP(l_errl, p9_ringtest_getring_fail, fapi2_procTarget); if(l_errl != NULL) @@ -171,7 +190,6 @@ void test_fapi2HwAccess() numFails++; } - numTests++; FAPI_INVOKE_HWP(l_errl, p9_opmodetest_getsetopmode); if(l_errl) @@ -255,7 +273,6 @@ void test_fapi2HwAccess() }while(0); FAPI_INF("fapi2HwAccessTest Test Complete. %d/%d fails", numFails , numTests); - } }; diff --git a/src/usr/fapi2/test/p9_hwtests.C b/src/usr/fapi2/test/p9_hwtests.C index e157092ea..fedf8582f 100644 --- a/src/usr/fapi2/test/p9_hwtests.C +++ b/src/usr/fapi2/test/p9_hwtests.C @@ -298,11 +298,33 @@ fapi2::ReturnCode p9_ringtest_modring_pass( fapi_try_exit: FAPI_INF("Exiting p9_ringtest_modring_pass..."); - return fapi2::current_err; } +fapi2::ReturnCode p9_platPutRingWRingID_pass() +{ + //every test is displayed this way via FAPI_INF + FAPI_INF("Entering p9_platPutRingWRingID_pass ..."); + // get the master proc + TARGETING::Target * l_procTest; + TARGETING::targetService().masterProcChipTargetHandle( l_procTest); + fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP> + l_fapi2CpuTarget((l_procTest)); + + fapi2::ReturnCode l_status = + fapi2::putRing(l_fapi2CpuTarget, ob0_fure, + fapi2::RING_MODE_SET_PULSE_NO_OPCG_COND); + + if(l_status!= fapi2::FAPI2_RC_SUCCESS) + { + TS_FAIL("p9_platPutRingWRingID_pass>> proc test - failed"); + } + + return l_status; +} + + fapi2::ReturnCode p9_opmodetest_getsetopmode() { FAPI_INF("Ensure that getOpMode return NORMAL initially"); diff --git a/src/usr/fapi2/test/p9_hwtests.H b/src/usr/fapi2/test/p9_hwtests.H index 06727b9d2..cdafe1b06 100644 --- a/src/usr/fapi2/test/p9_hwtests.H +++ b/src/usr/fapi2/test/p9_hwtests.H @@ -74,6 +74,8 @@ fapi2::ReturnCode p9_cfamtest_putcfam_pass( fapi2::ReturnCode p9_opmodetest_getsetopmode(); +fapi2::ReturnCode p9_platPutRingWRingID_pass(); + fapi2::ReturnCode p9_opmodetest_ignorehwerr( fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target, uint8_t fail); diff --git a/src/usr/sbeio/sbe_coreStateControl.C b/src/usr/sbeio/sbe_coreStateControl.C index 7d18d2c1a..54f86d0a6 100644 --- a/src/usr/sbeio/sbe_coreStateControl.C +++ b/src/usr/sbeio/sbe_coreStateControl.C @@ -31,13 +31,16 @@ #include <trace/interface.H> #include <errl/errlmanager.H> #include <sbeio/sbeioif.H> -#include "sbe_psudd.H" +#include <sbeio/sbe_psudd.H> extern trace_desc_t* g_trac_sbeio; #define SBE_TRACD(printf_string,args...) \ TRACDCOMP(g_trac_sbeio,"coreStateControl: " printf_string,##args) +#define SBE_TRACF(printf_string,args...) \ + TRACFCOMP(g_trac_sbeio,"coreStateControl: " printf_string,##args) + namespace SBEIO { @@ -59,11 +62,11 @@ errlHndl_t startDeadmanLoop(const uint64_t i_waitTime ) psuCommand l_psuCommand( SBE_DMCONTROL_START | SBE_DMCONTROL_RESPONSE_REQUIRED, //control flags SBE_PSU_CLASS_CORE_STATE, //command class - SBE_CMD_CONTROL_DEADMAN_LOOP); //comand + SBE_CMD_CONTROL_DEADMAN_LOOP); //command psuResponse l_psuResponse; // set up PSU command message - l_psuCommand.cdl_waitTime = i_waitTime; + l_psuCommand.cd1_ControlDeadmanLoop_WaitTime = i_waitTime; errl = performPsuChipOp(&l_psuCommand, &l_psuResponse, diff --git a/src/usr/sbeio/sbe_psudd.C b/src/usr/sbeio/sbe_psudd.C index 4f8e2015c..f206896a2 100644 --- a/src/usr/sbeio/sbe_psudd.C +++ b/src/usr/sbeio/sbe_psudd.C @@ -37,8 +37,8 @@ #include <targeting/common/target.H> #include <targeting/common/targetservice.H> #include <sbeio/sbeioreasoncodes.H> -#include "sbe_psudd.H" #include <initservice/initserviceif.H> //@todo-RTC:149454-Remove +#include <sbeio/sbe_psudd.H> trace_desc_t* g_trac_sbeio; TRAC_INIT(&g_trac_sbeio, SBEIO_COMP_NAME, 6*KILOBYTE, TRACE::BUFFER_SLOW); @@ -90,7 +90,12 @@ errlHndl_t performPsuChipOp(psuCommand * i_pPsuRequest, errl = writeRequest(l_target, i_pPsuRequest, i_reqMsgs); - if (errl) break; // return with error + if (errl)//error has been generated + { + SBE_TRACF(ERR_MRK"performPsuChipOp::" + " writeRequest returned an error"); + break; + } // read PSU response and check results errl = readResponse(l_target, @@ -98,8 +103,11 @@ errlHndl_t performPsuChipOp(psuCommand * i_pPsuRequest, o_pPsuResponse, i_timeout, i_rspMsgs); - if (errl) break; // return with error - + if (errl){ + SBE_TRACF(ERR_MRK"performPsuChipOp::" + " readResponse returned an error"); + break; // return with error + } } while (0); @@ -274,7 +282,8 @@ errlHndl_t readResponse(TARGETING::Target * i_target, (SBE_SEC_OPERATION_SUCCESSFUL != o_pPsuResponse->secondaryStatus) || (i_pPsuRequest->seqID != o_pPsuResponse->seqID) ) { - SBE_TRACF(ERR_MRK "readResponse: failing response status " + + SBE_TRACF(ERR_MRK "sbe_psudd.C :: readResponse: failing response status " " cmd=0x%08x prim=0x%08x secondary=0x%08x", " expected seqID=%d actual seqID=%d", i_pPsuRequest[1], diff --git a/src/usr/scan/makefile b/src/usr/scan/makefile index 6016f5beb..039be831a 100644 --- a/src/usr/scan/makefile +++ b/src/usr/scan/makefile @@ -5,7 +5,9 @@ # # OpenPOWER HostBoot Project # -# COPYRIGHT International Business Machines Corp. 2011,2014 +# Contributors Listed Below - COPYRIGHT 2012,2016 +# [+] 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. @@ -23,6 +25,10 @@ ROOTPATH = ../../.. MODULE = scan +EXTRAINCDIR +=${ROOTPATH}/src/import/chips/p9/utils/imageProcs +EXTRAINCDIR +=${ROOTPATH}/src/import/hwpf/fapi2/include + + OBJS += scandd.o SUBDIRS += test.d diff --git a/src/usr/scan/scandd.C b/src/usr/scan/scandd.C index 329d642cd..1f3941a36 100644 --- a/src/usr/scan/scandd.C +++ b/src/usr/scan/scandd.C @@ -5,7 +5,9 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* COPYRIGHT International Business Machines Corp. 2011,2014 */ +/* Contributors Listed Below - COPYRIGHT 2012,2016 */ +/* [+] 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. */ @@ -24,7 +26,6 @@ * @file scandd.C * * @brief Implementation of the scan device driver - * */ // ---------------------------------------------- @@ -42,6 +43,13 @@ #include <scan/scanif.H> #include "scandd.H" #include <errl/errludtarget.H> +#include <sbeio/sbe_psudd.H> +#include <targeting/common/util.H> +#include <p9_ring_id.h> +#include <hw_access_def.H> +#include <devicefw/userif.H> + + // ---------------------------------------------- // Globals @@ -60,13 +68,16 @@ TRAC_INIT( & g_trac_scanddr, SCANDD_RTRACE_BUF, KILOBYTE ); // ---------------------------------------------- // Defines // ---------------------------------------------- - +#define VIRTUAL_CHIPLET_ID_BASE_MCS_TARGET_TYPE (0x80) // ---------------------------------------------- namespace SCANDD { +using namespace SBEIO; + // Register the perform Op with the routing code for Procs. +//for "Put Ring From Image" command too DEVICE_REGISTER_ROUTE( DeviceFW::WILDCARD, DeviceFW::SCAN, TARGETING::TYPE_PROC, @@ -78,157 +89,419 @@ DEVICE_REGISTER_ROUTE( DeviceFW::WILDCARD, TARGETING::TYPE_MEMBUF, scanPerformOp ); +//for "Put Ring From Image" command +// Register the perform Op with the routing code +DEVICE_REGISTER_ROUTE( DeviceFW::WILDCARD, + DeviceFW::SCAN, + TARGETING::TYPE_EX, + scanPerformOp ); + +//for "Put Ring From Image" command +// Register the perform Op with the routing code +DEVICE_REGISTER_ROUTE( DeviceFW::WILDCARD, + DeviceFW::SCAN, + TARGETING::TYPE_PERV, + scanPerformOp ); + +//for "Put Ring From Image" command +// Register the perform Op with the routing code +DEVICE_REGISTER_ROUTE( DeviceFW::WILDCARD, + DeviceFW::SCAN, + TARGETING::TYPE_XBUS, + scanPerformOp ); + +//for "Put Ring From Image" command +// Register the perform Op with the routing code +DEVICE_REGISTER_ROUTE( DeviceFW::WILDCARD, + DeviceFW::SCAN, + TARGETING::TYPE_MCBIST, + scanPerformOp ); + +//for "Put Ring From Image" command +// Register the perform Op with the routing code +DEVICE_REGISTER_ROUTE( DeviceFW::WILDCARD, + DeviceFW::SCAN, + TARGETING::TYPE_OBUS, + scanPerformOp ); + +//for "Put Ring From Image" command +// Register the perform Op with the routing code +DEVICE_REGISTER_ROUTE( DeviceFW::WILDCARD, + DeviceFW::SCAN, + TARGETING::TYPE_PCI, + scanPerformOp ); + +//for "Put Ring From Image" command +// Register the perform Op with the routing code +DEVICE_REGISTER_ROUTE( DeviceFW::WILDCARD, + DeviceFW::SCAN, + TARGETING::TYPE_CORE, + scanPerformOp ); + +//for "Put Ring From Image" command +// Register the perform Op with the routing code +DEVICE_REGISTER_ROUTE( DeviceFW::WILDCARD, + DeviceFW::SCAN, + TARGETING::TYPE_L2, + scanPerformOp ); + +//for "Put Ring From Image" command +// Register the perform Op with the routing code +DEVICE_REGISTER_ROUTE( DeviceFW::WILDCARD, + DeviceFW::SCAN, + TARGETING::TYPE_L3, + scanPerformOp ); + +//for "Put Ring From Image" command +// Register the perform Op with the routing code +DEVICE_REGISTER_ROUTE( DeviceFW::WILDCARD, + DeviceFW::SCAN, + TARGETING::TYPE_L4, + scanPerformOp ); + +//for "Put Ring From Image" command +// Register the perform Op with the routing code +DEVICE_REGISTER_ROUTE( DeviceFW::WILDCARD, + DeviceFW::SCAN, + TARGETING::TYPE_MCS, + scanPerformOp ); + + +/// @brief translates HB target types to SBE target type groups +/// @param[in] i_hbTarget includes the HB target type +/// @return SBEIO::SBE_TARGET_TYPES returns SBE_TARGET_TYPE_UNKNOWN in error +SBE_TARGET_TYPES translateToSBETargetType(TARGETING::Target * i_hbTarget) +{ + + TRACDCOMP( g_trac_scandd, + ENTER_MRK "entering translateToSBETargetType()"); + SBE_TARGET_TYPES sbeType; + sbeType = SBE_TARGET_TYPE_UNKNOWN; + + + switch( i_hbTarget->getAttr<TARGETING::ATTR_TYPE>()){ + + case(TARGETING::TYPE_PROC): + { + sbeType = SBE_TARGET_TYPE_PROC; + break; + } + + case(TARGETING::TYPE_EX): + { + sbeType = SBE_TARGET_TYPE_EX; + break; + } + + case(TARGETING::TYPE_PERV): + case(TARGETING::TYPE_XBUS): + case(TARGETING::TYPE_MCBIST): + case(TARGETING::TYPE_OBUS): + case(TARGETING::TYPE_PCI): + case(TARGETING::TYPE_L2): + case(TARGETING::TYPE_L3): + case(TARGETING::TYPE_L4): + case(TARGETING::TYPE_CORE): + { + sbeType = SBE_TARGET_TYPE_PERV; + break; + } + case(TARGETING::TYPE_MCS): + { + sbeType = SBE_TARGET_TYPE_MCS; + break; + } + default: + TRACFCOMP( g_trac_scandd, + ERR_MRK "translateToSBETargetType:>" + " Not supported Target type =%.8X ", + i_hbTarget->getAttr<TARGETING::ATTR_TYPE>() ); + break; + } + + TRACDCOMP( g_trac_scandd, EXIT_MRK "exiting translateToSBETargetType()"); + return sbeType; +} + +/// @brief returns a ChipletID for a give target +/// @param[in] i_hbTarget includes the HB target type +/// @return: ChipletID for i_hbTarget target +uint8_t getChipletIDForSBE(TARGETING::Target * i_hbTarget) +{ + uint8_t l_chipletID = 0; + + TRACDCOMP( g_trac_scandd, ENTER_MRK "entering getChipletIDForSBE()"); + + //based on the Host to SBE Interface specification ver 0.70+ + switch( i_hbTarget->getAttr<TARGETING::ATTR_TYPE>()) + { + case(TARGETING::TYPE_PROC): + { //not all targets will have CHIPLET_IDs + l_chipletID = 0; + break; + } + //MCS has a virtual Chiplet ID + case (TARGETING::TYPE_MCS): + { + l_chipletID = VIRTUAL_CHIPLET_ID_BASE_MCS_TARGET_TYPE + + static_cast<uint8_t>(i_hbTarget-> + getAttr<TARGETING::ATTR_CHIP_UNIT>()); + break; + } + default: + { + l_chipletID = static_cast<uint8_t>(i_hbTarget-> + getAttr<TARGETING::ATTR_CHIPLET_ID>()); + break; + } + } + + TRACDCOMP( g_trac_scandd, EXIT_MRK "exiting getChipletIDForSBE()"); + return l_chipletID; +} + +/// @brief sends Put Ring from Image message to SBE via scan interface +/// @param[in] i_target target includes the target type that is needed +/// @param[in] va_list i_args contains: ringID, RingMode, flags +/// @return errlHndl_t returns non-zero value if there is error. +errlHndl_t sbeScanPerformOp(TARGETING::Target * i_target, va_list i_args) +{ + errlHndl_t l_errl = NULL; + TRACFCOMP( g_trac_scandd, ENTER_MRK "sbeScanPerformOp()"); + + psuCommand l_psuCommand( + //control flags are hardcoded here, no need to pass them into sbe function + SBE_DMCONTROL_RESPONSE_REQUIRED, + //command class + SBE_PSU_PUT_RING_FROM_IMAGE_CMD, + //command + SBE_CMD_CONTROL_PUTRING); + psuResponse l_psuResponse; + + //Ring ID for this message + RingID l_ringID = static_cast<RingID>(va_arg(i_args,uint64_t)); + //Ring Mode for this message + fapi2::RingMode l_ringMode = + static_cast<fapi2::RingMode>(va_arg(i_args,uint64_t)); + + uint64_t l_flags = va_arg(i_args,uint64_t); + TRACDCOMP( g_trac_scandd, INFO_MRK + ":: sbeScanPerformOp() does not use Control Flags :%.8X ", l_flags); + + l_psuCommand.cd3_PutRing_TargetType = translateToSBETargetType(i_target); + l_psuCommand.cd3_PutRing_Reserved1 = 0x00; + l_psuCommand.cd3_PutRing_ChipletID = getChipletIDForSBE(i_target); + l_psuCommand.cd3_PutRing_RingID = l_ringID; + l_psuCommand.cd3_PutRing_RingMode = l_ringMode; + + TRACDCOMP( g_trac_scandd, INFO_MRK" sbeScanPerformOp()" + " l_target : %.16llX i_targetType %.16llX", + i_target, + i_target->getAttr<TARGETING::ATTR_TYPE>()); + TRACDCOMP( g_trac_scandd, INFO_MRK + ":: sbeScanPerformOp() TargetType:%.8X ", + l_psuCommand.cd3_PutRing_TargetType); + TRACDCOMP( g_trac_scandd, INFO_MRK + ":: sbeScanPerformOp() Reserved1:%.8X ", + l_psuCommand.cd3_PutRing_Reserved1 ); + TRACDCOMP( g_trac_scandd, INFO_MRK + ":: sbeScanPerformOp() ChipletID:%.8X ", + l_psuCommand.cd3_PutRing_ChipletID ); + TRACDCOMP( g_trac_scandd, INFO_MRK + ":: sbeScanPerformOp() RingID:%.8X ", + l_psuCommand.cd3_PutRing_RingID ); + TRACDCOMP( g_trac_scandd, INFO_MRK + ":: sbeScanPerformOp() Control Flags :%.8X ", + l_psuCommand.cd3_PutRing_ControlFlags ); + TRACDCOMP( g_trac_scandd, INFO_MRK + ":: sbeScanPerformOp() RingMode:%.8X ", + l_psuCommand.cd3_PutRing_RingMode ); + + l_errl = performPsuChipOp(&l_psuCommand, + &l_psuResponse, + MAX_PSU_SHORT_TIMEOUT_NS, + SBE_DMCONTROL_START_REQ_USED_REGS, + SBE_DMCONTROL_START_RSP_USED_REGS); + + TRACFCOMP( g_trac_scandd, EXIT_MRK "exiting :: sbeScanPerformOp()"); + + return l_errl; +} // ------------------------------------------------------------------ // scanPerformOp // ------------------------------------------------------------------ errlHndl_t scanPerformOp( DeviceFW::OperationType i_opType, - TARGETING::Target * i_target, - void * io_buffer, - size_t & io_buflen, - int64_t i_accessType, - va_list i_args ) + TARGETING::Target * i_target, + void * io_buffer, + size_t & io_buflen, + int64_t i_accessType, + va_list i_args ) { errlHndl_t l_err = NULL; + va_list i_args_copy; + va_copy(i_args_copy, i_args); uint64_t i_ring = va_arg(i_args,uint64_t); uint64_t i_ringlength = va_arg(i_args,uint64_t); uint64_t i_flag = va_arg(i_args,uint64_t); + uint64_t i_whichFunction = va_arg(i_args,uint64_t); - do - { - // If the ringlength equals 0 - if( i_ringlength == 0x0 ) - { - TRACFCOMP( g_trac_scandd, ERR_MRK "SCAN::scanPerformOp> Invalid Ringlength for ring =%d for target =%.8X", i_ring, TARGETING::get_huid(i_target)); - /*@ - * @errortype - * @moduleid SCAN::MOD_SCANDD_DDOP - * @reasoncode SCAN::RC_INVALID_LENGTH - * @userdata1 SCAN Ring Address - * @userdata2 SCAN ring length - * @devdesc ScanDD::scanPerformOp> Invalid ringlength - * @custdesc A problem occurred during the IPL - * of the system. - */ - l_err = new ERRORLOG::ErrlEntry(ERRORLOG::ERRL_SEV_UNRECOVERABLE, - SCAN::MOD_SCANDD_DDOP, - SCAN::RC_INVALID_LENGTH, - i_ring, - i_ringlength, - true/*SW Error*/); - //Add this target to the FFDC - ERRORLOG::ErrlUserDetailsTarget(i_target,"Scan Target") - .addToLog(l_err); - - l_err->collectTrace(SCANDD_TRACE_BUF,1024); - break; - } - - // Check to see if invalid RING.. (0xFFFFFFFF - has been used as a - // test ring in fips code so checking for that as well. - if ((i_ring == 0x0) || (i_ring == 0xFFFFFFFF)) - { - TRACFCOMP( g_trac_scandd, ERR_MRK "SCAN:scanPerformOp> Invalid ring i_ring=%.8X for target =%.8X", i_ring, TARGETING::get_huid(i_target) ); - /*@ - * @errortype - * @moduleid SCAN::MOD_SCANDD_DDOP - * @reasoncode SCAN::RC_INVALID_RING_ADDRESS - * @userdata1 SCAN Ring Address - * @userdata2 TARGET - * @devdesc ScanDD::scanPerformOp> Invalid Ring Address - * @custdesc A problem occurred during the IPL - * of the system. - */ - l_err = new ERRORLOG::ErrlEntry(ERRORLOG::ERRL_SEV_UNRECOVERABLE, - SCAN::MOD_SCANDD_DDOP, - SCAN::RC_INVALID_RING_ADDRESS, - i_ring, - TARGETING::get_huid(i_target), - true/*SW Error*/); - //Add this target to the FFDC - ERRORLOG::ErrlUserDetailsTarget(i_target,"Scan Target") - .addToLog(l_err); - - l_err->collectTrace(SCANDD_TRACE_BUF,1024); - break; - } - - // Check to make sure the buflength is big enough. - // ringlength is in bits, io_buflen is in bytes - if ((i_ringlength) > io_buflen*8) - { - TRACFCOMP( g_trac_scandd, ERR_MRK "SCAN::scanPerformOp> IObuffer not big enough=ringlength = %d, iobuflen = %d for target =%.8X", i_ringlength, io_buflen,TARGETING::get_huid(i_target) ); - /*@ - * @errortype - * @moduleid SCAN::MOD_SCANDD_DDOP - * @reasoncode SCAN::RC_INVALID_BUF_SIZE - * @userdata1 SCAN IO buffer length - * @userdata2 SCAN ring length - * @devdesc ScanDD::scanPerformOp> Invalid IObuf length - * @custdesc A problem occurred during the IPL - * of the system. - */ - l_err = new ERRORLOG::ErrlEntry(ERRORLOG::ERRL_SEV_UNRECOVERABLE, - SCAN::MOD_SCANDD_DDOP, - SCAN::RC_INVALID_BUF_SIZE, - io_buflen, - i_ringlength, - true/*SW Error*/); - //Add this target to the FFDC - ERRORLOG::ErrlUserDetailsTarget(i_target,"Scan Target") - .addToLog(l_err); - - l_err->collectTrace(SCANDD_TRACE_BUF,1024); - break; - } - - // If a Scan read or Write.. do the scan op. - if(( DeviceFW::READ == i_opType ) || ( DeviceFW::WRITE == i_opType )) - { - l_err = scanDoScan( i_opType, - i_target, - io_buffer, - io_buflen, - i_ring, - i_ringlength, - i_flag ); - - if(l_err) - { - break; - } - - } - else - { - TRACFCOMP( g_trac_scandd, ERR_MRK "SCAN::scanPerformOp> Invalid Op Type = %d for target =%.8X", i_opType, TARGETING::get_huid(i_target) ); - /*@ - * @errortype - * @moduleid SCAN::MOD_SCANDD_DDOP - * @reasoncode SCAN::RC_INVALID_OPERATION - * @userdata1 SCAN Address - * @userdata2 Operation Type (i_opType) - * @devdesc ScanDD::scanPerformOp> Invalid operation type - * @custdesc A problem occurred during the IPL - * of the system. - */ - l_err = new ERRORLOG::ErrlEntry(ERRORLOG::ERRL_SEV_UNRECOVERABLE, - SCAN::MOD_SCANDD_DDOP, - SCAN::RC_INVALID_OPERATION, - i_ring, - TO_UINT64(i_opType), - true/*SW Error*/); - //Add this target to the FFDC - ERRORLOG::ErrlUserDetailsTarget(i_target,"Scan Target") - .addToLog(l_err); - l_err->collectTrace(SCANDD_TRACE_BUF,1024); - break; - } - - }while(0); - - return l_err; + do + { + + if(i_whichFunction == PUT_RING_FROM_IMAGE_COMMAND) + { + TRACFCOMP( g_trac_scandd, + ENTER_MRK " scanPerformOP 'Put Ring From Image'" + " command is being generated"); + l_err = sbeScanPerformOp(i_target, i_args_copy); + } + else + { + + // If the ringlength equals 0 + if( i_ringlength == 0x0 ) + { + TRACFCOMP( g_trac_scandd, + ERR_MRK "SCAN::scanPerformOp> Invalid Ringlength for" + " ring =%d for target =%.8X", + i_ring, TARGETING::get_huid(i_target)); + /*@ + * @errortype + * @moduleid SCAN::MOD_SCANDD_DDOP + * @reasoncode SCAN::RC_INVALID_LENGTH + * @userdata1 SCAN Ring Address + * @userdata2 SCAN ring length + * @devdesc ScanDD::scanPerformOp> Invalid ringlength + * @custdesc A problem occurred during the IPL + * of the system. + */ + l_err = new ERRORLOG::ErrlEntry( + ERRORLOG::ERRL_SEV_UNRECOVERABLE, + SCAN::MOD_SCANDD_DDOP, + SCAN::RC_INVALID_LENGTH, + i_ring, + i_ringlength, + true/*SW Error*/); + //Add this target to the FFDC + ERRORLOG::ErrlUserDetailsTarget(i_target,"Scan Target") + .addToLog(l_err); + + l_err->collectTrace(SCANDD_TRACE_BUF,1024); + break; + } + + // Check to see if invalid RING.. (0xFFFFFFFF - has been used as a + // test ring in fips code so checking for that as well. + if ((i_ring == 0x0) || (i_ring == 0xFFFFFFFF)) + { + TRACFCOMP( g_trac_scandd, ERR_MRK "SCAN:scanPerformOp> Invalid ring i_ring=%.8X for target =%.8X", i_ring, TARGETING::get_huid(i_target) ); + /*@ + * @errortype + * @moduleid SCAN::MOD_SCANDD_DDOP + * @reasoncode SCAN::RC_INVALID_RING_ADDRESS + * @userdata1 SCAN Ring Address + * @userdata2 TARGET + * @devdesc ScanDD::scanPerformOp> Invalid Ring Address + * @custdesc A problem occurred during the IPL + * of the system. + */ + l_err = new ERRORLOG::ErrlEntry( + ERRORLOG::ERRL_SEV_UNRECOVERABLE, + SCAN::MOD_SCANDD_DDOP, + SCAN::RC_INVALID_RING_ADDRESS, + i_ring, + TARGETING::get_huid(i_target), + true/*SW Error*/); + //Add this target to the FFDC + ERRORLOG::ErrlUserDetailsTarget(i_target,"Scan Target") + .addToLog(l_err); + + l_err->collectTrace(SCANDD_TRACE_BUF,1024); + break; + } + + // Check to make sure the buflength is big enough. + // ringlength is in bits, io_buflen is in bytes + if ((i_ringlength) > io_buflen*8) + { + TRACFCOMP( g_trac_scandd, ERR_MRK "SCAN::scanPerformOp> IObuffer not big enough=ringlength = %d, iobuflen = %d for target =%.8X", i_ringlength, io_buflen,TARGETING::get_huid(i_target) ); + /*@ + * @errortype + * @moduleid SCAN::MOD_SCANDD_DDOP + * @reasoncode SCAN::RC_INVALID_BUF_SIZE + * @userdata1 SCAN IO buffer length + * @userdata2 SCAN ring length + * @devdesc ScanDD::scanPerformOp> Invalid IObuf length + * @custdesc A problem occurred during the IPL + * of the system. + */ + l_err = new ERRORLOG::ErrlEntry( + ERRORLOG::ERRL_SEV_UNRECOVERABLE, + SCAN::MOD_SCANDD_DDOP, + SCAN::RC_INVALID_BUF_SIZE, + io_buflen, + i_ringlength, + true/*SW Error*/); + //Add this target to the FFDC + ERRORLOG::ErrlUserDetailsTarget(i_target,"Scan Target") + .addToLog(l_err); + + l_err->collectTrace(SCANDD_TRACE_BUF,1024); + break; + } + + // If a Scan read or Write.. do the scan op. + if((DeviceFW::READ == i_opType) || (DeviceFW::WRITE == i_opType)) + { + l_err = scanDoScan( i_opType, + i_target, + io_buffer, + io_buflen, + i_ring, + i_ringlength, + i_flag ); + + if(l_err) + { + break; + } + + } + else + { + TRACFCOMP( g_trac_scandd, ERR_MRK "SCAN::scanPerformOp> Invalid Op Type = %d for target =%.8X", i_opType, TARGETING::get_huid(i_target) ); + /*@ + * @errortype + * @moduleid SCAN::MOD_SCANDD_DDOP + * @reasoncode SCAN::RC_INVALID_OPERATION + * @userdata1 SCAN Address + * @userdata2 Operation Type (i_opType) + * @devdesc ScanDD::scanPerformOp> Invalid operation type + * @custdesc A problem occurred during the IPL + * of the system. + */ + l_err = new ERRORLOG::ErrlEntry( + ERRORLOG::ERRL_SEV_UNRECOVERABLE, + SCAN::MOD_SCANDD_DDOP, + SCAN::RC_INVALID_OPERATION, + i_ring, + TO_UINT64(i_opType), + true/*SW Error*/); + //Add this target to the FFDC + ERRORLOG::ErrlUserDetailsTarget(i_target,"Scan Target") + .addToLog(l_err); + l_err->collectTrace(SCANDD_TRACE_BUF,1024); + break; + } + + }//else case + }while(0); + + va_end(i_args_copy); // this is needed for sbeScanPerformOp function + + return l_err; } @@ -723,6 +996,4 @@ errlHndl_t scanDoScan( DeviceFW::OperationType i_opType, } - - } diff --git a/src/usr/scan/scandd.H b/src/usr/scan/scandd.H index 548de95b7..e8b410c5b 100644 --- a/src/usr/scan/scandd.H +++ b/src/usr/scan/scandd.H @@ -5,7 +5,9 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* COPYRIGHT International Business Machines Corp. 2011,2014 */ +/* Contributors Listed Below - COPYRIGHT 2012,2016 */ +/* [+] 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. */ @@ -34,6 +36,7 @@ // Includes // ---------------------------------------------- #include <errl/errlentry.H> +#include <sbeio/sbe_psudd.H> namespace SCANDD { @@ -51,6 +54,12 @@ errlHndl_t scanPerformOp( DeviceFW::OperationType i_opType, va_list i_args ); +/// @brief sends Put Ring from Image message to SBE via scan interface +/// @param[in] i_target target includes the target type that is needed +/// @param[in] va_list i_args contains: ringID, RingMode, flags +/// @return errlHndl_t returns non-zero value if there is error. +errlHndl_t sbeScanPerformOp( TARGETING::Target * i_target, va_list i_args ); + errlHndl_t scanDoScan( DeviceFW::OperationType i_opType, TARGETING::Target * i_target, void * io_buffer, @@ -59,7 +68,16 @@ errlHndl_t scanDoScan( DeviceFW::OperationType i_opType, uint64_t i_ringlength, uint64_t i_flag ); +/// @brief translates HB target types to SBE target type groups +/// @param[in] i_hbTarget includes the HB target type +/// @return SBEIO::SBE_TARGET_TYPES returns SBE_TARGET_TYPE_UNKNOWN in error +SBEIO::SBE_TARGET_TYPES + translateToSBETargetType(TARGETING::Target * i_hbTarget); +/// @brief returns a ChipletID for a give target +/// @param[in] i_hbTarget includes the HB target type +/// @return: ChipletID for i_hbTarget target +uint8_t getChipletIDForSBE(TARGETING::Target * i_hbTarget); }; // end SCAN namespace |