예제 #1
0
    //**************************************************************************
    // FREQVOLTSVC::getSysFreq
    //**************************************************************************
    errlHndl_t getSysFreq(
          uint32_t & o_sysVPDPowerSaveMinFreqMhz,
          TARGETING::ATTR_NOMINAL_FREQ_MHZ_type & o_sysNomFreqMhz,
          TARGETING::ATTR_FREQ_CORE_MAX_type & o_sysVPDTurboMaxFreqMhz,
          TARGETING::ATTR_ULTRA_TURBO_FREQ_MHZ_type &
                                                   o_sysVPDUltraTurboMinFreqMhz)
    {
        uint32_t   l_minsysVPDTurboMaxFreqMhz = 0;
        uint32_t   l_maxsysVPDPowerSaveMinFreqMhz = 0;
        uint32_t   l_minsysVPDUltraTurboFreqMhz = 0;
        fapi::ReturnCode l_rc;
        errlHndl_t l_err = NULL;

        do
        {
            o_sysNomFreqMhz = 0;
            o_sysVPDTurboMaxFreqMhz = 0;
            o_sysVPDPowerSaveMinFreqMhz = 0;
            o_sysVPDUltraTurboMinFreqMhz = 0;

            //Get the top level (system) target  handle
            TARGETING::Target* l_pTopLevel = NULL;
            (void)TARGETING::targetService().getTopLevelTarget(l_pTopLevel);

            // Assert on failure getting system target
            assert( l_pTopLevel != NULL );

            // Retrun Fvmin as ultra turbo freq if WOF enabled.
            ATTR_WOF_ENABLED_type l_wofEnabled = l_pTopLevel->getAttr
                                           < TARGETING::ATTR_WOF_ENABLED > ();
            TRACFCOMP(g_fapiTd,"getSysFreq: WOF_ENABLED is %d ",l_wofEnabled);

            //Filter functional unit
            TARGETING::PredicateIsFunctional l_isFunctional;

            // Filter core unit
            TARGETING::PredicateCTM l_coreUnitFilter(TARGETING::CLASS_UNIT,
                                                     TARGETING::TYPE_CORE);

            //Filter functional cores
            TARGETING::PredicatePostfixExpr l_funcCoreUnitFilter;

            // core units AND functional
            l_funcCoreUnitFilter.push(&l_coreUnitFilter).push
                                                        (&l_isFunctional).And();

            // Loop through all the targets, looking for functional core units.
            TARGETING::TargetRangeFilter l_pFilter(
                                             TARGETING::targetService().begin(),
                                             TARGETING::targetService().end(),
                                             &l_funcCoreUnitFilter);
            // Assert if no functional cores are found
            assert(l_pFilter);

            bool l_copyOnce = true;

            // Loop through functional cores to get frequency
            for(; l_pFilter; ++l_pFilter )
            {
                TARGETING::Target * l_pTarget = *l_pFilter;

                fapi::voltageBucketData_t l_poundVdata = {0};

                // Get Parent Chip target
                const TARGETING::Target * l_pChipTarget =
                                                    getParentChip(l_pTarget);
                fapi::Target l_pFapiChipTarget(fapi::TARGET_TYPE_PROC_CHIP,
                            (const_cast<TARGETING::Target*>(l_pChipTarget) ));

                // Get core number for record number
                TARGETING::ATTR_CHIP_UNIT_type l_coreNum =
                        l_pTarget->getAttr<TARGETING::ATTR_CHIP_UNIT>();

                uint32_t l_record = (uint32_t) MVPD::LRP0 + l_coreNum;

                // Get #V bucket data
                l_rc = fapiGetPoundVBucketData(l_pFapiChipTarget,
                                               l_record,
                                               l_poundVdata);
                if(l_rc)
                {
                    TRACFCOMP( g_fapiTd,ERR_MRK"Error getting #V data for HUID:"
                             "0x%08X",
                             l_pTarget->getAttr<TARGETING::ATTR_HUID>());

                    // Convert fapi returnCode to Error handle
                    l_err = fapiRcToErrl(l_rc);

                    break;
                }

                uint32_t l_sysVPDPowerSaveMinFreqMhz = l_poundVdata.PSFreq;
                TARGETING::ATTR_NOMINAL_FREQ_MHZ_type l_sysNomFreqMhz =
                                l_poundVdata.nomFreq;
                TARGETING::ATTR_FREQ_CORE_MAX_type l_sysVPDTurboMaxFreqMhz =
                                l_poundVdata.turboFreq;
                // WOF defines the reserved Fvmin value as ultra turbo
                TARGETING::ATTR_ULTRA_TURBO_FREQ_MHZ_type
                             l_sysVPDUltraTurboFreqMhz = l_poundVdata.fvminFreq;
                TRACFCOMP(g_fapiTd,INFO_MRK"Nominal freq is: [0x%08X]. Turbo "
                          "freq is: [0x%08x]. PowerSave freq is: [0x%08X]."
                          " Ultra Turbo is: [0x%08x]",
                          l_sysNomFreqMhz, l_sysVPDTurboMaxFreqMhz,
                          l_sysVPDPowerSaveMinFreqMhz,
                          l_sysVPDUltraTurboFreqMhz);

                if( true == l_copyOnce)
                {
                    o_sysNomFreqMhz = l_sysNomFreqMhz;
                    l_minsysVPDTurboMaxFreqMhz = l_sysVPDTurboMaxFreqMhz;
                    l_maxsysVPDPowerSaveMinFreqMhz =
                                             l_sysVPDPowerSaveMinFreqMhz;
                    l_minsysVPDUltraTurboFreqMhz = l_sysVPDUltraTurboFreqMhz;
                    l_copyOnce = false;
                }

                // frequency is never zero so create error if it is zero.
                if( (l_sysNomFreqMhz == 0)         ||
                    (l_sysVPDTurboMaxFreqMhz == 0) ||
                    (l_sysVPDPowerSaveMinFreqMhz == 0) )
                {
                    TRACFCOMP(g_fapiTd,ERR_MRK"Frequency is zero, "
                             "nominal freq: 0x%04X,turbo freq: 0x%08X",
                             "PowerSave freq is: [0x%08X]",
                             l_sysNomFreqMhz,
                             l_sysVPDTurboMaxFreqMhz,
                             l_sysVPDPowerSaveMinFreqMhz);

                    /*@
                     * @errortype
                     * @moduleid         fapi::MOD_GET_SYS_FREQ
                     * @reasoncode       fapi::RC_INVALID_DATA
                     * @userdata1[0:31]  Proc HUID
                     * @userdata1[32:63] Nominal frequency
                     * @userdata2[0:31]  Max Turbo frequency from VPD
                     * @userdata2[32:63] Min Power Save frequency from VPD
                     * @devdesc          Either nominal, max turbo or min power
                     *                   save frequency for the processor HUID
                     *                   (userdata1) is zero
                     */
                    l_err =
                        new ERRORLOG::ErrlEntry(
                                         ERRORLOG::ERRL_SEV_UNRECOVERABLE,
                                         fapi::MOD_GET_SYS_FREQ,
                                         fapi::RC_INVALID_DATA,
                    TWO_UINT32_TO_UINT64(
                                     l_pTarget->getAttr<TARGETING::ATTR_HUID>(),
                                     l_sysNomFreqMhz),
                    TWO_UINT32_TO_UINT64(l_sysVPDTurboMaxFreqMhz,
                                         l_sysVPDPowerSaveMinFreqMhz));

                    // Callout HW as VPD data is incorrect
                    l_err->addHwCallout(l_pTarget, HWAS::SRCI_PRIORITY_HIGH,
                                         HWAS::DECONFIG, HWAS::GARD_NULL);

                    break;
                }

                // If WOF is enabled, Ultra Turbo frequency should not be zero.
                // Return 0 for ultra turbo freq
                if( (fapi::ENUM_ATTR_WOF_ENABLED_ENABLED == l_wofEnabled)  &&
                    (l_sysVPDUltraTurboFreqMhz == 0) )
                {
                    TRACFCOMP(g_fapiTd,
                              ERR_MRK"GetSysFreq: Ultra Turbo frequency is 0");

                    /*@
                     * @errortype
                     * @moduleid         fapi::MOD_GET_SYS_FREQ
                     * @reasoncode       fapi::RC_INVALID_ULTRA_TURBO_FREQ
                     * @userdata1        Proc HUID
                     * @userdata2        Invalid ultra turbo frequency
                     * @devdesc          When WOF is enabled, ultra turbo freq
                     *                   should not be 0
                     */
                    l_err =
                        new ERRORLOG::ErrlEntry(
                                     ERRORLOG::ERRL_SEV_UNRECOVERABLE,
                                     fapi::MOD_GET_SYS_FREQ,
                                     fapi::RC_INVALID_ULTRA_TURBO_FREQ,
                                     l_pTarget->getAttr<TARGETING::ATTR_HUID>(),
                                     l_sysVPDUltraTurboFreqMhz);

                    // Callout HW as VPD data is incorrect
                    l_err->addHwCallout(l_pTarget, HWAS::SRCI_PRIORITY_MED,
                                         HWAS::NO_DECONFIG, HWAS::GARD_NULL);

                    // log error and keep going
                    errlCommit(l_err,HWPF_COMP_ID);
                }

                // Validate nominal frequency. If differs,
                // create error and stop processing further.
                if( o_sysNomFreqMhz != l_sysNomFreqMhz )
                {
                    TRACFCOMP(g_fapiTd,ERR_MRK
                             "Nominal Frequency:[0x%04X] does not "
                             "match with other core nominal frequency:[0x%04X]",
                             l_sysNomFreqMhz, o_sysNomFreqMhz);

                    /*@
                     * @errortype
                     * @moduleid    fapi::MOD_GET_SYS_FREQ
                     * @reasoncode  fapi::RC_INVALID_FREQ
                     * @userdata1   Invalid frequency
                     * @userdata2   Expected frequency
                     * @devdesc     Nominal frequency(userdata1) does not match
                     *              nominal frequency(userdata2) on other cores.
                     *              Should be the same for all chips.
                     */
                    l_err =
                        new ERRORLOG::ErrlEntry(
                                         ERRORLOG::ERRL_SEV_UNRECOVERABLE,
                                         fapi::MOD_GET_SYS_FREQ,
                                         fapi::RC_INVALID_FREQ,
                                         l_sysNomFreqMhz,
                                         o_sysNomFreqMhz);

                    // Callout HW as VPD data is incorrect
                    l_err->addHwCallout(l_pTarget, HWAS::SRCI_PRIORITY_HIGH,
                                         HWAS::DECONFIG, HWAS::GARD_NULL);

                    break;
                }

                // Save the min turbo freq
                if (l_sysVPDTurboMaxFreqMhz < l_minsysVPDTurboMaxFreqMhz)
                {
                    l_minsysVPDTurboMaxFreqMhz = l_sysVPDTurboMaxFreqMhz;
                }
                // Save the max powersave freq
                if (l_sysVPDPowerSaveMinFreqMhz >
                                    l_maxsysVPDPowerSaveMinFreqMhz)
                {
                    l_maxsysVPDPowerSaveMinFreqMhz =
                                    l_sysVPDPowerSaveMinFreqMhz;
                }
                // Save the min ultra turbo freq
                // If WOF is enabled, do not expect to see a zero value. But if
                // there is a zero value, then return zero.
                if (l_sysVPDUltraTurboFreqMhz < l_minsysVPDUltraTurboFreqMhz)
                {
                    l_minsysVPDUltraTurboFreqMhz = l_sysVPDUltraTurboFreqMhz;
                }

            } // end for loop
            if (l_err != NULL)
            {
                break;
            }

            // Get min turbo freq
            o_sysVPDTurboMaxFreqMhz = l_minsysVPDTurboMaxFreqMhz;

            // Get max powersave freq
            o_sysVPDPowerSaveMinFreqMhz = l_maxsysVPDPowerSaveMinFreqMhz;

            // Get ultra turbo freq
            o_sysVPDUltraTurboMinFreqMhz = l_minsysVPDUltraTurboFreqMhz;

        } while (0);

        TRACFCOMP(g_fapiTd,EXIT_MRK"o_sysNomFreqMhz: 0x%08X, "
                  "o_sysVPDTurboMaxFreqMhz: 0x%08X, "
                  "o_sysVPDPowerSaveMinFreqMhz: 0x%08X, "
                  "o_sysVPDUltraTurboFreqMhz: 0x%08x",
                   o_sysNomFreqMhz, o_sysVPDTurboMaxFreqMhz,
                   o_sysVPDPowerSaveMinFreqMhz,
                   o_sysVPDUltraTurboMinFreqMhz );

        return l_err;
    }
예제 #2
0
    //**************************************************************************
    // FREQVOLTSVC::getSysFreq
    //**************************************************************************
    errlHndl_t getSysFreq(
            uint32_t & o_sysVPDPowerSaveMinFreqMhz,
            TARGETING::ATTR_NOMINAL_FREQ_MHZ_type & o_sysNomFreqMhz,
            TARGETING::ATTR_FREQ_CORE_MAX_type & o_sysVPDTurboMaxFreqMhz)
    {
        uint32_t   l_minsysVPDTurboMaxFreqMhz = 0;
        uint32_t   l_maxsysVPDPowerSaveMinFreqMhz = 0;
        fapi::ReturnCode l_rc;
        errlHndl_t l_err = NULL;

        do
        {
            o_sysNomFreqMhz = 0;
            o_sysVPDTurboMaxFreqMhz = 0;
            o_sysVPDPowerSaveMinFreqMhz = 0;

            //Filter functional unit
            TARGETING::PredicateIsFunctional l_isFunctional;

            // Filter core unit
            TARGETING::PredicateCTM l_coreUnitFilter(TARGETING::CLASS_UNIT,
                                                     TARGETING::TYPE_CORE);

            //Filter functional cores
            TARGETING::PredicatePostfixExpr l_funcCoreUnitFilter;

            // core units AND functional
            l_funcCoreUnitFilter.push(&l_coreUnitFilter).push
                                                        (&l_isFunctional).And();

            // Loop through all the targets, looking for functional core units.
            TARGETING::TargetRangeFilter l_pFilter(
                                             TARGETING::targetService().begin(),
                                             TARGETING::targetService().end(),
                                             &l_funcCoreUnitFilter);
            // Assert if no functional cores are found
            assert(l_pFilter);

            bool l_copyOnce = true;

            // Loop through functional cores to get frequency
            for(; l_pFilter; ++l_pFilter )
            {
                TARGETING::Target * l_pTarget = *l_pFilter;

                fapi::voltageBucketData_t l_poundVdata = {0};

                // Get Parent Chip target
                const TARGETING::Target * l_pChipTarget =
                                                    getParentChip(l_pTarget);

                // Get core number for record number
                TARGETING::ATTR_CHIP_UNIT_type l_coreNum =
                        l_pTarget->getAttr<TARGETING::ATTR_CHIP_UNIT>();

                uint32_t l_record = (uint32_t) MVPD::LRP0 + l_coreNum;

                // Get #V bucket data
                l_rc = fapiGetPoundVBucketData(l_pChipTarget,
                                               l_record,
                                               l_poundVdata);
                if(l_rc)
                {
                    TRACFCOMP( g_fapiTd,ERR_MRK"Error getting #V data for HUID:"
                             "0x%08X",
                             l_pTarget->getAttr<TARGETING::ATTR_HUID>());

                    // Convert fapi returnCode to Error handle
                    l_err = fapiRcToErrl(l_rc);

                    break;
                }

                uint32_t l_sysVPDPowerSaveMinFreqMhz = l_poundVdata.PSFreq;
                TARGETING::ATTR_NOMINAL_FREQ_MHZ_type l_sysNomFreqMhz =
                                l_poundVdata.nomFreq;
                TARGETING::ATTR_FREQ_CORE_MAX_type l_sysVPDTurboMaxFreqMhz =
                                l_poundVdata.turboFreq;
                TRACFCOMP(g_fapiTd,INFO_MRK"Nominal freq is: [0x%08X]. Turbo "
                          "freq is: [0x%08x]. PowerSave freq is: [0x%08X]",
                          l_sysNomFreqMhz, l_sysVPDTurboMaxFreqMhz,
                          l_sysVPDPowerSaveMinFreqMhz );

                if( true == l_copyOnce)
                {
                    o_sysNomFreqMhz = l_sysNomFreqMhz;
                    l_minsysVPDTurboMaxFreqMhz = l_sysVPDTurboMaxFreqMhz;
                    l_maxsysVPDPowerSaveMinFreqMhz =
                                             l_sysVPDPowerSaveMinFreqMhz;
                    l_copyOnce = false;
                }

                // frequency is never zero so create error if it is zero.
                if( (l_sysNomFreqMhz == 0)         ||
                    (l_sysVPDTurboMaxFreqMhz == 0) ||
                    (l_sysVPDPowerSaveMinFreqMhz == 0) )
                {
                    TRACFCOMP(g_fapiTd,ERR_MRK"Frequency is zero, "
                             "nominal freq: 0x%04X,turbo freq: 0x%08X",
                             "PowerSave freq is: [0x%08X]",
                             l_sysNomFreqMhz,
                             l_sysVPDTurboMaxFreqMhz,
                             l_sysVPDPowerSaveMinFreqMhz);

                    /*@
                     * @errortype
                     * @moduleid         fapi::MOD_GET_SYS_FREQ
                     * @reasoncode       fapi::RC_INVALID_DATA
                     * @userdata1[0:31]  Proc HUID
                     * @userdata1[32:63] Nominal frequency
                     * @userdata2[0:31]  Max Turbo frequency from VPD
                     * @userdata2[32:63] Min Power Save frequency from VPD
                     * @devdesc          Either nominal, max turbo or min power
                     *                   save frequency for the processor HUID
                     *                   (userdata1) is zero
                     */
                    l_err =
                        new ERRORLOG::ErrlEntry(
                                         ERRORLOG::ERRL_SEV_UNRECOVERABLE,
                                         fapi::MOD_GET_SYS_FREQ,
                                         fapi::RC_INVALID_DATA,
                    TWO_UINT32_TO_UINT64(
                                     l_pTarget->getAttr<TARGETING::ATTR_HUID>(),
                                     l_sysNomFreqMhz),
                    TWO_UINT32_TO_UINT64(l_sysVPDTurboMaxFreqMhz,
                                         l_sysVPDPowerSaveMinFreqMhz));

                    // Callout HW as VPD data is incorrect
                    l_err->addHwCallout(l_pTarget, HWAS::SRCI_PRIORITY_HIGH,
                                         HWAS::DECONFIG, HWAS::GARD_NULL);

                    break;
                }

                // Validate nominal frequency. If differs,
                // create error and stop processing further.
                if( o_sysNomFreqMhz != l_sysNomFreqMhz )
                {
                    TRACFCOMP(g_fapiTd,ERR_MRK
                             "Nominal Frequency:[0x%04X] does not "
                             "match with other core nominal frequency:[0x%04X]",
                             l_sysNomFreqMhz, o_sysNomFreqMhz);

                    /*@
                     * @errortype
                     * @moduleid    fapi::MOD_GET_SYS_FREQ
                     * @reasoncode  fapi::RC_INVALID_FREQ
                     * @userdata1   Invalid frequency
                     * @userdata2   Expected frequency
                     * @devdesc     Nominal frequency(userdata1) does not match
                     *              nominal frequency(userdata2) on other cores.
                     *              Should be the same for all chips.
                     */
                    l_err =
                        new ERRORLOG::ErrlEntry(
                                         ERRORLOG::ERRL_SEV_UNRECOVERABLE,
                                         fapi::MOD_GET_SYS_FREQ,
                                         fapi::RC_INVALID_FREQ,
                                         l_sysNomFreqMhz,
                                         o_sysNomFreqMhz);

                    // Callout HW as VPD data is incorrect
                    l_err->addHwCallout(l_pTarget, HWAS::SRCI_PRIORITY_HIGH,
                                         HWAS::DECONFIG, HWAS::GARD_NULL);

                    break;
                }

                // Save the min turbo freq
                if (l_sysVPDTurboMaxFreqMhz < l_minsysVPDTurboMaxFreqMhz)
                {
                    l_minsysVPDTurboMaxFreqMhz = l_sysVPDTurboMaxFreqMhz;
                }
                // Save the max powersave freq
                if (l_sysVPDPowerSaveMinFreqMhz >
                                    l_maxsysVPDPowerSaveMinFreqMhz)
                {
                    l_maxsysVPDPowerSaveMinFreqMhz =
                                    l_sysVPDPowerSaveMinFreqMhz;
                }

            } // end for loop
            if (l_err != NULL)
            {
                break;
            }

            // Get min turbo freq
            o_sysVPDTurboMaxFreqMhz = l_minsysVPDTurboMaxFreqMhz;

            // Get max powersave freq
            o_sysVPDPowerSaveMinFreqMhz = l_maxsysVPDPowerSaveMinFreqMhz;

        } while (0);

        TRACFCOMP(g_fapiTd,EXIT_MRK"o_sysNomFreqMhz: 0x%08X, "
                  "o_sysVPDTurboMaxFreqMhz: 0x%08X, "
                  "o_sysVPDPowerSaveMinFreqMhz: 0x%08X",
                   o_sysNomFreqMhz, o_sysVPDTurboMaxFreqMhz,
                   o_sysVPDPowerSaveMinFreqMhz );

        return l_err;
    }