<commit_before>/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/diag/prdf/prdfMain.C $                                */
/*                                                                        */
/* IBM CONFIDENTIAL                                                       */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 2002,2014              */
/*                                                                        */
/* p1                                                                     */
/*                                                                        */
/* Object Code Only (OCO) source materials                                */
/* Licensed Internal Code Source Materials                                */
/* IBM HostBoot Licensed Internal Code                                    */
/*                                                                        */
/* The source code for this program is not published or otherwise         */
/* divested of its trade secrets, irrespective of what has been           */
/* deposited with the U.S. Copyright Office.                              */
/*                                                                        */
/* Origin: 30                                                             */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */

/**
 * @file  prdfMain.C
 * @brief PRD code used by external components.
 *
 * This file contains code that is strictly specific to Hostboot. All code that
 * is common between FSP and Hostboot should be in the respective common file.
 */

#include <prdfMain.H>
#include <prdfCenMbaDataBundle.H>
#include <prdfExtensibleChip.H>
#include <prdfErrlUtil.H>
#include <prdfPlatServices.H>
#include <prdfMbaDomain.H>

using namespace TARGETING;
using namespace HWAS;

namespace PRDF
{

using namespace PlatServices;

//------------------------------------------------------------------------------
// Platform specific helper function for PRDF::initialize()
//------------------------------------------------------------------------------

void initPlatSpecific()
{
    // Currently no-op in Hostboot.
}

//------------------------------------------------------------------------------
// External functions - declared in prdfMain.H
//------------------------------------------------------------------------------

int32_t analyzeIplCEStats( TargetHandle_t i_mba, bool &o_calloutMade )
{
    #define PRDF_FUNC "PRDF::analyzeIplCEStats"

    PRDF_ENTER( PRDF_FUNC"(0x%08x)", getHuid(i_mba) );

    int32_t o_rc = SUCCESS;
    o_calloutMade = false;

    ExtensibleChip * mbaChip = (ExtensibleChip *)systemPtr->GetChip( i_mba );
    CenMbaDataBundle * mbadb = getMbaDataBundle( mbaChip );

    o_rc = mbadb->getIplCeStats()->analyzeStats( o_calloutMade );

    if ( SUCCESS != o_rc )
    {
        PRDF_ERR( "["PRDF_FUNC"] analyzeStats() failed");

        // Get user data
        uint64_t ud12 = PRDF_GET_UINT64_FROM_UINT32( getHuid(i_mba),      0 );
        uint64_t ud34 = PRDF_GET_UINT64_FROM_UINT32( PRDFSIG_MnfgIplFail, 0 );

        // Create error log
        errlHndl_t errl = new ERRORLOG::ErrlEntry(
                                ERRORLOG::ERRL_SEV_PREDICTIVE, // severity
                                PRDF_MNFG_IPL_CE_ANALYSIS,     // module ID
                                PRDF_DETECTED_FAIL_SOFTWARE,   // reason code
                                ud12, ud34 );                  // user data 1-4

        // Add 2nd level support
        errl->addProcedureCallout( EPUB_PRC_LVL_SUPP, SRCI_PRIORITY_HIGH );

        // Add traces
        errl->collectTrace( PRDF_COMP_NAME, 512 );

        // Commit the error log
        ERRORLOG::errlCommit( errl, PRDF_COMP_ID );
    }

    PRDF_EXIT( PRDF_FUNC"(0x%08x), o_calloutMade:%u",
               getHuid(i_mba), o_calloutMade );

    return o_rc;

    #undef PRDF_FUNC
}

//------------------------------------------------------------------------------

errlHndl_t startScrub()
{
    #define PRDF_FUNC "[PRDF::startScrub] "

    errlHndl_t o_errl = NULL;

    int32_t l_rc = SUCCESS;
    HUID nodeId = INVALID_HUID;<commit_msg>PRD: add mutex lock around MNFG IPL CE analysis code<commit_after>/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/diag/prdf/prdfMain.C $                                */
/*                                                                        */
/* IBM CONFIDENTIAL                                                       */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 2002,2014              */
/*                                                                        */
/* p1                                                                     */
/*                                                                        */
/* Object Code Only (OCO) source materials                                */
/* Licensed Internal Code Source Materials                                */
/* IBM HostBoot Licensed Internal Code                                    */
/*                                                                        */
/* The source code for this program is not published or otherwise         */
/* divested of its trade secrets, irrespective of what has been           */
/* deposited with the U.S. Copyright Office.                              */
/*                                                                        */
/* Origin: 30                                                             */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */

/**
 * @file  prdfMain.C
 * @brief PRD code used by external components.
 *
 * This file contains code that is strictly specific to Hostboot. All code that
 * is common between FSP and Hostboot should be in the respective common file.
 */

#include <prdfMain.H>
#include <prdfCenMbaDataBundle.H>
#include <prdfExtensibleChip.H>
#include <prdfErrlUtil.H>
#include <prdfPlatServices.H>
#include <prdfMbaDomain.H>
#include <sys/sync.h>

using namespace TARGETING;
using namespace HWAS;

namespace PRDF
{

using namespace PlatServices;

//------------------------------------------------------------------------------
// Platform specific helper function for PRDF::initialize()
//------------------------------------------------------------------------------

void initPlatSpecific()
{
    // Currently no-op in Hostboot.
}

//------------------------------------------------------------------------------
// External functions - declared in prdfMain.H
//------------------------------------------------------------------------------

int32_t analyzeIplCEStats( TargetHandle_t i_mba, bool &o_calloutMade )
{
    #define PRDF_FUNC "PRDF::analyzeIplCEStats"

    static mutex_t lock = MUTEX_INITIALIZER;
    mutex_lock(&lock);

    PRDF_ENTER( PRDF_FUNC"(0x%08x)", getHuid(i_mba) );

    int32_t o_rc = SUCCESS;
    o_calloutMade = false;

    ExtensibleChip * mbaChip = (ExtensibleChip *)systemPtr->GetChip( i_mba );
    CenMbaDataBundle * mbadb = getMbaDataBundle( mbaChip );

    o_rc = mbadb->getIplCeStats()->analyzeStats( o_calloutMade );

    if ( SUCCESS != o_rc )
    {
        PRDF_ERR( "["PRDF_FUNC"] analyzeStats() failed");

        // Get user data
        uint64_t ud12 = PRDF_GET_UINT64_FROM_UINT32( getHuid(i_mba),      0 );
        uint64_t ud34 = PRDF_GET_UINT64_FROM_UINT32( PRDFSIG_MnfgIplFail, 0 );

        // Create error log
        errlHndl_t errl = new ERRORLOG::ErrlEntry(
                                ERRORLOG::ERRL_SEV_PREDICTIVE, // severity
                                PRDF_MNFG_IPL_CE_ANALYSIS,     // module ID
                                PRDF_DETECTED_FAIL_SOFTWARE,   // reason code
                                ud12, ud34 );                  // user data 1-4

        // Add 2nd level support
        errl->addProcedureCallout( EPUB_PRC_LVL_SUPP, SRCI_PRIORITY_HIGH );

        // Add traces
        errl->collectTrace( PRDF_COMP_NAME, 512 );

        // Commit the error log
        ERRORLOG::errlCommit( errl, PRDF_COMP_ID );
    }

    PRDF_EXIT( PRDF_FUNC"(0x%08x), o_calloutMade:%u",
               getHuid(i_mba), o_calloutMade );

    mutex_unlock(&lock);

    return o_rc;

    #undef PRDF_FUNC
}

//------------------------------------------------------------------------------

errlHndl_t startScrub()
{
    #define PRDF_FUNC "[PRDF::startScrub] "

    errlHndl_t o_errl = NULL;

    int32_t l_rc = SUCCESS;
    HUID nodeId = INVALID_HUID;
{'fraction_non_alphanumeric': 0.1618964387153157, 'fraction_numerical': 0.011142669871094604, 'mean_word_length': 0.9786038469850875, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 74, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2107590', 'n_tokens_mistral': 2326, 'n_tokens_neox': 2160, 'n_words': 518}