diff options
author | Chris Cain <cjcain@us.ibm.com> | 2015-01-14 09:23:57 -0600 |
---|---|---|
committer | A. Patrick Williams III <iawillia@us.ibm.com> | 2015-01-22 17:40:08 -0600 |
commit | d84c27a1ba1c915e0fdcb2b638d729fe1bdff4fe (patch) | |
tree | 2135aa332fc89e1275934d8e2948cb2168a35dff /src/usr/htmgt | |
parent | 38cfbf78f1b0393131bb6d7772d7e9948b03096e (diff) | |
download | talos-hostboot-d84c27a1ba1c915e0fdcb2b638d729fe1bdff4fe.tar.gz talos-hostboot-d84c27a1ba1c915e0fdcb2b638d729fe1bdff4fe.zip |
Add support for linux command to set OCC state.
Change-Id: I1ac4d810e0f4509dc89c645bef183f5cb2179b1c
RTC: 115213
Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/15154
Tested-by: Jenkins Server
Reviewed-by: Douglas R. Gilbert <dgilbert@us.ibm.com>
Reviewed-by: Matt Spinler <spinler@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/usr/htmgt')
-rw-r--r-- | src/usr/htmgt/HBconfig | 6 | ||||
-rw-r--r-- | src/usr/htmgt/htmgt.C | 40 | ||||
-rw-r--r-- | src/usr/htmgt/htmgt_activate.C | 39 | ||||
-rw-r--r-- | src/usr/htmgt/htmgt_activate.H | 8 | ||||
-rw-r--r-- | src/usr/htmgt/htmgt_cfgdata.C | 21 | ||||
-rw-r--r-- | src/usr/htmgt/htmgt_occ.C | 65 | ||||
-rw-r--r-- | src/usr/htmgt/htmgt_occ.H | 28 | ||||
-rw-r--r-- | src/usr/htmgt/htmgt_occcmd.C | 50 |
8 files changed, 197 insertions, 60 deletions
diff --git a/src/usr/htmgt/HBconfig b/src/usr/htmgt/HBconfig index 61c20acea..00a3ce36f 100644 --- a/src/usr/htmgt/HBconfig +++ b/src/usr/htmgt/HBconfig @@ -8,3 +8,9 @@ config DELAY_AFTER_OCC_ACTIVATION help After OCC has been activated, wait for 30 seconds for any potential errors to be reported before continuing the IPL + +config CONSOLE_OUTPUT_OCC_COMM + default n + help + Set to output the OCC communications (command and response data) + to the console during IPL diff --git a/src/usr/htmgt/htmgt.C b/src/usr/htmgt/htmgt.C index 53a01be10..d38c1df27 100644 --- a/src/usr/htmgt/htmgt.C +++ b/src/usr/htmgt/htmgt.C @@ -1,11 +1,11 @@ /* IBM_PROLOG_BEGIN_TAG */ /* This is an automatically generated prolog. */ /* */ -/* $Source: src/usr/htmgt/tmgtutility.C $ */ +/* $Source: src/usr/htmgt/htmgt.C $ */ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2014 */ +/* Contributors Listed Below - COPYRIGHT 2014,2015 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -35,6 +35,7 @@ #include "htmgt_poll.H" #include <devicefw/userif.H> #include <config.h> +#include <console/consoleif.H> // Targeting support #include <targeting/common/commontargeting.H> @@ -74,6 +75,7 @@ namespace HTMGT { do { + // TODO: RTC 119831 - remove hardcoded delay // Delay before communication with OCCs to make sure // they are ready (since there is no initial attention) nanosleep(HTMGT_DELAY_BEFORE_COMM, 0); @@ -98,7 +100,7 @@ namespace HTMGT // Send poll to establish comm TMGT_INF("Send initial poll to all OCCs to" " establish comm"); - errlHndl_t l_err = sendOccPoll(); + l_err = sendOccPoll(); if (l_err) { // Continue even if failed (poll will be retried) @@ -109,8 +111,8 @@ namespace HTMGT // Send ALL config data sendOccConfigData(); - // Wait for all OCCs to go active - l_err = waitForOccsActive(); + // Wait for all OCCs to go to the target state + l_err = waitForOccState(); if ( l_err ) { break; @@ -196,6 +198,11 @@ namespace HTMGT if (NULL != l_err) { TMGT_ERR("OCCs not all active. System will stay in safe mode"); +#ifndef __HOSTBOOT_RUNTIME + CONSOLE::displayf(HTMGT_COMP_NAME, "OCCs are not active " + "(rc=0x%04X). System will remain in safe mode", + l_err->reasonCode()); +#endif // TODO: RTC 109066 //stopAllOccs(); @@ -250,5 +257,28 @@ namespace HTMGT } // end processOccReset() + + // Set the OCC state + errlHndl_t enableOccActuation(bool i_occActivation) + { + occStateId targetState = OCC_STATE_ACTIVE; + if (false == i_occActivation) + { + targetState = OCC_STATE_OBSERVATION; + } + + // Set state for all OCCs + errlHndl_t l_err = occMgr::instance().setOccState(targetState); + if (NULL == l_err) + { + TMGT_INF("enableOccActuation: OCC states updated to 0x%02X", + targetState); + } + + return l_err; + + } // end enableOccActuation() + + } diff --git a/src/usr/htmgt/htmgt_activate.C b/src/usr/htmgt/htmgt_activate.C index 66337bb31..2d6941ab1 100644 --- a/src/usr/htmgt/htmgt_activate.C +++ b/src/usr/htmgt/htmgt_activate.C @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2014 */ +/* Contributors Listed Below - COPYRIGHT 2014,2015 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -48,7 +48,7 @@ namespace HTMGT #endif - // Wait for all OCCs to reach active ready state + // Wait for all OCCs to reach ready state errlHndl_t waitForOccReady() { errlHndl_t l_err = NULL; @@ -60,6 +60,13 @@ namespace HTMGT size_t numPolls = 0; std::vector<Occ*> occList = occMgr::instance().getOccArray(); + // Determine which bit to check + uint8_t targetBit = OCC_STATUS_ACTIVE_READY; + if (OCC_STATE_OBSERVATION == occMgr::instance().getTargetState()) + { + targetBit = OCC_STATUS_OBS_READY; + } + do { // Poll all OCCs @@ -79,7 +86,7 @@ namespace HTMGT ++itr) { Occ * occ = (*itr); - if (false == occ->statusBitSet(OCC_STATUS_ACTIVE_READY)) + if (false == occ->statusBitSet(targetBit)) { waitingForInstance = occ->getInstance(); break; @@ -103,11 +110,12 @@ namespace HTMGT * @moduleid HTMGT_MOD_WAIT_FOR_OCC_READY * @userdata1[0-15] OCC instance * @userdata1[16-31] poll attempts - * @devdesc OCC not ready for active state + * @userdata2[0-15] target ready bit + * @devdesc OCC not ready for target state */ bldErrLog(l_err, HTMGT_MOD_WAIT_FOR_OCC_READY, HTMGT_RC_OCC_NOT_READY, - waitingForInstance, numPolls, 0, 0, + waitingForInstance, numPolls, targetBit, 0, ERRORLOG::ERRL_SEV_INFORMATIONAL); } @@ -117,32 +125,23 @@ namespace HTMGT - // Wait for all OCCs to reach active state - errlHndl_t waitForOccsActive() + // Wait for all OCCs to reach target state + errlHndl_t waitForOccState() { errlHndl_t l_err = NULL; - TMGT_INF("wait_for_occs_active called"); - // Wait for all OCCs to be ready for active state l_err = waitForOccReady(); if (NULL == l_err) { - // Send Set State (ACTIVE) to master - l_err = occMgr::instance().setOccState(OCC_STATE_ACTIVE); - if (NULL == l_err) - { - TMGT_INF("waitForOccsActive: OCCs are all active"); - } - } - else - { - TMGT_ERR("waitForOccsActive: OCC(s) are not in active ready"); + // Send Set State command to master OCC. + // The master will use the target state (default = ACTIVE) + l_err = occMgr::instance().setOccState(); } return l_err; - } // end waitForOccsActive() + } // end waitForOccState() diff --git a/src/usr/htmgt/htmgt_activate.H b/src/usr/htmgt/htmgt_activate.H index 335615aa6..405bcbd00 100644 --- a/src/usr/htmgt/htmgt_activate.H +++ b/src/usr/htmgt/htmgt_activate.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2014 */ +/* Contributors Listed Below - COPYRIGHT 2014,2015 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -39,11 +39,11 @@ namespace HTMGT { /** - * @brief Wait for all OCCs to go to active state + * @brief Wait for all OCCs to go to the target state * - * @return NULL if all OCCs reached active state, else error handle + * @return NULL if all OCCs reached target state, else error handle */ - errlHndl_t waitForOccsActive(); + errlHndl_t waitForOccState(); /** diff --git a/src/usr/htmgt/htmgt_cfgdata.C b/src/usr/htmgt/htmgt_cfgdata.C index baf4f5819..5a9dae4ef 100644 --- a/src/usr/htmgt/htmgt_cfgdata.C +++ b/src/usr/htmgt/htmgt_cfgdata.C @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2014 */ +/* Contributors Listed Below - COPYRIGHT 2014,2015 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -286,6 +286,7 @@ void getMemConfigMessageData(const TargetHandle_t i_occ, numSets++; centPos = (*centaur)->getAttr<ATTR_POSITION>(); + sensor = 0xC000 + centPos; //TODO RTC 115294 //Do the entry for the Centaur itself @@ -294,12 +295,10 @@ void getMemConfigMessageData(const TargetHandle_t i_occ, index += 4; //Hardware Sensor ID - sensor = 0; //TODO RTC 115294 memcpy(&o_data[index], &sensor, 2); index += 2; //Temperature Sensor ID - sensor = 0; //TODO RTC 115294 memcpy(&o_data[index], &sensor, 2); index += 2; @@ -339,12 +338,12 @@ void getMemConfigMessageData(const TargetHandle_t i_occ, index += 4; //Hardware Sensor ID - sensor = 0; //TODO RTC 115294 + sensor = 0xD000 + (centPos<<8) + dimmPos; //TODO RTC 115294 memcpy(&o_data[index], &sensor, 2); index += 2; //Temperature Sensor ID - sensor = 0; //TODO RTC 115294 + sensor = 0xD000 + (centPos<<8) + dimmPos; //TODO RTC 115294 memcpy(&o_data[index], &sensor, 2); index += 2; @@ -541,7 +540,7 @@ void getSystemConfigMessageData(uint8_t* o_data, uint64_t & o_size) o_data[index++] = OCC_CFGDATA_OPENPOWER_SYSTEMTYPE; //processor sensor ID - sensor = 0; //TODO all sensors - RTC 115294 + sensor = 0x1000; //TODO all sensors - RTC 115294 memcpy(&o_data[index], &sensor, 2); index += 2; @@ -549,23 +548,23 @@ void getSystemConfigMessageData(uint8_t* o_data, uint64_t & o_size) for (uint64_t core=0; core<CFGDATA_CORES; core++) { //Core Temp Sensor ID - sensor = 0; + sensor = 0x2000 + core; //TODO all sensors - RTC 115294 memcpy(&o_data[index], &sensor, 2); index += 2; //Core Frequency Sensor ID - sensor = 0; + sensor = 0x3000 + core; //TODO all sensors - RTC 115294 memcpy(&o_data[index], &sensor, 2); index += 2; } //Backplane sensor ID - sensor = 0; + sensor = 0xB000; memcpy(&o_data[index], &sensor, 2); index += 2; //APSS sensor ID - sensor = 0; + sensor = 0xA000; memcpy(&o_data[index], &sensor, 2); index += 2; @@ -724,7 +723,7 @@ void getApssMessageData(uint8_t* o_data, o_data[idx] = function[channel]; // ADC Channel assignement idx += sizeof(uint8_t); - uint16_t sensorId = 0; + uint16_t sensorId = 0xA100 + channel; //TODO all sensors - RTC 115294 memcpy(o_data+idx,&sensorId,sizeof(uint16_t)); // Sensor ID idx += sizeof(uint16_t); diff --git a/src/usr/htmgt/htmgt_occ.C b/src/usr/htmgt/htmgt_occ.C index 61cb04e71..1571076e5 100644 --- a/src/usr/htmgt/htmgt_occ.C +++ b/src/usr/htmgt/htmgt_occ.C @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2014 */ +/* Contributors Listed Below - COPYRIGHT 2014,2015 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -31,11 +31,11 @@ #include "htmgt_occ.H" #include "htmgt_poll.H" -// Targeting support #include <targeting/common/commontargeting.H> #include <targeting/common/utilFilter.H> #include <targeting/common/attributes.H> #include <targeting/common/targetservice.H> +#include <console/consoleif.H> namespace HTMGT @@ -159,7 +159,8 @@ namespace HTMGT OccManager::OccManager() :iv_configDataBuilt(false), iv_occMaster(NULL), - iv_state(OCC_STATE_UNKNOWN) + iv_state(OCC_STATE_UNKNOWN), + iv_targetState(OCC_STATE_ACTIVE) { } @@ -319,19 +320,29 @@ namespace HTMGT { errlHndl_t l_err = NULL; + occStateId requestedState = i_state; + if (OCC_STATE_NO_CHANGE == i_state) + { + // If no state was requested use the target state + requestedState = iv_targetState; + } - if ((i_state == OCC_STATE_ACTIVE) || - (i_state == OCC_STATE_OBSERVATION)) + if ((requestedState == OCC_STATE_ACTIVE) || + (requestedState == OCC_STATE_OBSERVATION)) { + // Function is only called on initial IPL and when user/mfg + // requests a new state, so we can update target here. + iv_targetState = requestedState; + if (NULL != iv_occMaster) { - TMGT_INF("_setOccState(state=0x%02X)", i_state); + TMGT_INF("_setOccState(state=0x%02X)", requestedState); const uint8_t occInstance = iv_occMaster->getInstance(); bool needsRetry = false; do { - l_err = iv_occMaster->setState(i_state); + l_err = iv_occMaster->setState(requestedState); if (NULL == l_err) { needsRetry = false; @@ -374,11 +385,12 @@ namespace HTMGT { // Send poll to query state of all OCCs // and flush any errors reported by the OCCs - errlHndl_t l_err = sendOccPoll(true); + l_err = sendOccPoll(true); if (l_err) { TMGT_ERR("_setOccState: Poll all OCCs failed"); ERRORLOG::errlCommit(l_err, HTMGT_COMP_ID); + l_err = NULL; } // Make sure all OCCs went to active state @@ -386,10 +398,10 @@ namespace HTMGT pOcc < iv_occArray.end(); pOcc++) { - if (i_state != (*pOcc)->getState()) + if (requestedState != (*pOcc)->getState()) { TMGT_ERR("_setOccState: OCC%d is not in 0x%02X state", - (*pOcc)->getInstance(), i_state); + (*pOcc)->getInstance(), requestedState); /*@ * @errortype * @moduleid HTMGT_MOD_OCCMGR_SET_STATE @@ -401,17 +413,38 @@ namespace HTMGT */ bldErrLog(l_err, HTMGT_MOD_OCCMGR_SET_STATE, HTMGT_RC_OCC_UNEXPECTED_STATE, - i_state, (*pOcc)->getState(), + requestedState, (*pOcc)->getState(), (*pOcc)->getInstance(), 0, ERRORLOG::ERRL_SEV_INFORMATIONAL); break; } } + + if (NULL == l_err) + { + TMGT_INF("_setOccState: All OCCs have reached state 0x%02X", + requestedState); + +#ifndef __HOSTBOOT_RUNTIME + if (OCC_STATE_ACTIVE == requestedState) + { + CONSOLE::displayf(HTMGT_COMP_NAME, + "OCCs are now running in ACTIVE state"); + } + else + { + CONSOLE::displayf(HTMGT_COMP_NAME, + "OCCs are now running in OBSERVATION state"); + } +#endif + } + } } else { - TMGT_ERR("_setOccState: Invalid state 0x%02X requested", i_state); + TMGT_ERR("_setOccState: Invalid state 0x%02X requested", + requestedState); /*@ * @errortype * @moduleid HTMGT_MOD_OCCMGR_SET_STATE @@ -421,7 +454,7 @@ namespace HTMGT */ bldErrLog(l_err, HTMGT_MOD_OCCMGR_SET_STATE, HTMGT_RC_INVALID_DATA, - i_state, 0, 0, 0, + requestedState, 0, 0, 0, ERRORLOG::ERRL_SEV_INFORMATIONAL); } @@ -460,6 +493,12 @@ namespace HTMGT } + occStateId OccManager::getTargetState() + { + return Singleton<OccManager>::instance()._getTargetState(); + } + + #if 0 // TODO: RTC 115296 void update_occ_data() diff --git a/src/usr/htmgt/htmgt_occ.H b/src/usr/htmgt/htmgt_occ.H index ec0216aa6..398cf928e 100644 --- a/src/usr/htmgt/htmgt_occ.H +++ b/src/usr/htmgt/htmgt_occ.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2014 */ +/* Contributors Listed Below - COPYRIGHT 2014,2015 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -278,19 +278,37 @@ namespace HTMGT /** - * @brief Set the state of the OCCs + * @brief Set the state of the OCCs. If i_state is + * not specified (NO_CHANGE), OCCs will be set + * to the target state (last requested state + * or if not requested the default is ACTIVE) * * @param[in] i_state Desired OCC state * * @return NULL on success, or error handle on failure */ - errlHndl_t setOccState(const occStateId i_state); + errlHndl_t setOccState(const occStateId i_state = + OCC_STATE_NO_CHANGE); + + + /** + * @brief Get the OCC state that should be used after the OCCs + * have been loaded or reset + * + * @note Target state will default to ACTIVE, but + * can be changed with HTMGT::enableOccActuation() + * + * @return target state + */ + static occStateId getTargetState(); + private: Occ * iv_occMaster; std::vector<Occ*> iv_occArray; occStateId iv_state; + occStateId iv_targetState; /* See buildOccs() above */ uint32_t _buildOccs(); @@ -304,6 +322,10 @@ namespace HTMGT std::vector<Occ*> _getOccArray() { return iv_occArray; }; + /* See getTargetState() above */ + occStateId _getTargetState() { return iv_targetState; }; + + /** * @brief Remove all OCC objects */ diff --git a/src/usr/htmgt/htmgt_occcmd.C b/src/usr/htmgt/htmgt_occcmd.C index 749efbdc9..0da7630bf 100644 --- a/src/usr/htmgt/htmgt_occcmd.C +++ b/src/usr/htmgt/htmgt_occcmd.C @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2014 */ +/* Contributors Listed Below - COPYRIGHT 2014,2015 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -42,7 +42,7 @@ #include <trace/interface.H> #include <errl/errlmanager.H> #include <stdio.h> - +#include <console/consoleif.H> namespace HTMGT @@ -86,6 +86,36 @@ namespace HTMGT }; +#ifdef CONFIG_CONSOLE_OUTPUT_OCC_COMM + // Dump header information and set of binary data to the console. + // NOTE: Data is dumped in groups of 16 bytes. If i_len is not a + // multiple of 16, additional data data will be dumped. + void dumpToConsole(const char * i_header, + const uint8_t * i_data, + uint16_t i_len) + { +#ifndef __HOSTBOOT_RUNTIME + if (i_header[0] != '\0') + { + CONSOLE::displayf(HTMGT_COMP_NAME, "%s", i_header); + } + uint16_t index = 0; + while (index < i_len) + { + CONSOLE::displayf(HTMGT_COMP_NAME, "%04X: %08X %08X %08X %08X", + index, + UINT32_GET(&i_data[index]), + UINT32_GET(&i_data[index+4]), + UINT32_GET(&i_data[index+8]), + UINT32_GET(&i_data[index+12])); + index += 16; + } + CONSOLE::flush(); +#endif + } +#endif + + /** * @brief Get the index of the specified command in the command table * @@ -950,14 +980,20 @@ namespace HTMGT cmdBuffer[l_send_length++] = (iv_OccCmd.checksum >> 8) & 0xFF; cmdBuffer[l_send_length++] = iv_OccCmd.checksum & 0xFF; - //@fixme-RTC:119833-this hangs HB if traces are sent out to the console -#ifndef CONFIG_CONSOLE_OUTPUT_TRACE if (G_debug_trace & DEBUG_TRACE_OCCCMD) { // Trace the command TMGT_BIN("buildOccCmdBuffer: OCC command (up to 256 bytes)", cmdBuffer, std::min(l_send_length, (uint16_t)256)); } + +#ifdef CONFIG_CONSOLE_OUTPUT_OCC_COMM + // Trace full OCC command + char header[64]; + sprintf(header, "OCC Command: %s (%d bytes)", + command_string(iv_OccCmd.cmdType), l_send_length); + dumpToConsole(header, cmdBuffer, + std::min(l_send_length,(uint16_t)256)); #endif #ifdef SIMICS_TESTING @@ -990,6 +1026,12 @@ namespace HTMGT if ((NULL != rspBuffer) && (rspLen >= OCC_RSP_HDR_LENGTH)) { +#ifdef CONFIG_CONSOLE_OUTPUT_OCC_COMM + // Trace raw OCC response + char header[64]; + sprintf(header, "OCC Response: (%d bytes)", rspLen); + dumpToConsole(header, rspBuffer, std::min(rspLen,(uint16_t)256)); +#endif iv_OccRsp.sequenceNumber = rspBuffer[l_index++]; iv_OccRsp.cmdType = (enum occCommandType)rspBuffer[l_index++]; iv_OccRsp.returnStatus = (occReturnCodes)rspBuffer[l_index++]; |