summaryrefslogtreecommitdiffstats
path: root/src/usr/isteps/tod/TodUtils.C
blob: a1a1ede636795aac1be7e28470d87f51e0146b29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/isteps/tod/TodUtils.C $                               */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2016,2017                        */
/* [+] 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.       */
/* You may obtain a copy of the License at                                */
/*                                                                        */
/*     http://www.apache.org/licenses/LICENSE-2.0                         */
/*                                                                        */
/* Unless required by applicable law or agreed to in writing, software    */
/* distributed under the License is distributed on an "AS IS" BASIS,      */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or        */
/* implied. See the License for the specific language governing           */
/* permissions and limitations under the License.                         */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */

// Includes
// /***********************************************************************/

#include "TodAssert.H"
#include "TodUtils.H"
#include <devicefw/userif.H>
#include <isteps/tod_init_reasoncodes.H>
#include <errl/errlentry.H>
#include <errl/errlmanager.H>

namespace TOD

{

//******************************************************************************
// isFunctional
//******************************************************************************

bool isFunctional(const TARGETING::Target* i_pTarget)
{
    //--------------------------------------------------------------------------
    // Local Variables
    //--------------------------------------------------------------------------

    errlHndl_t l_errl = NULL;
    bool l_isFunctional = false;

    //--------------------------------------------------------------------------
    // Code
    //--------------------------------------------------------------------------

    if(i_pTarget)
    {
        // For now return true if state is FUNCTIONAL else false.
        // There are total 4 HWAS functional states can exist:
        // NON FUNCTIONAL,FUNCTIONAL,CM FUNCTIONAL and DUMP FUNCTIONAL.
        // In-order to consider CM & DUMP FUNCTIONAL states we need to check
        // whether system is in CM/DUMP mode. Since the CM/DUMP mode support
        // is not available, we'll continue using FUNCTIONAL state only.
        // Later we need to check for appropriate mode and state.
        // @TODO via RTC: 69925
        l_isFunctional =
            i_pTarget->getAttr<TARGETING::ATTR_HWAS_STATE>().functional;
    }
    else
    {
        // If i_pTarget is NULL then create an error log
        TOD_ERR("Input Target handle is null");

        //Create error
        /*@
         * @errortype
         * @moduleid     TOD_FUNCTIONAL_TARGET
         * @reasoncode   TOD_INVALID_TARGET
         * @devdesc      NULL Target is supplied as an input
         * @custdesc     Service Processor Firmware encountered an internal
         *               error
         */
        l_errl = new ERRORLOG::ErrlEntry(
                     ERRORLOG::ERRL_SEV_INFORMATIONAL,
                     TOD_FUNCTIONAL_TARGET,
                     TOD_INVALID_TARGET);

        errlCommit(l_errl, TOD_COMP_ID);
    }

    return l_isFunctional;
}



//******************************************************************************
//todGetScom()
//******************************************************************************
errlHndl_t todGetScom(const TARGETING::Target * i_target,
                      const uint64_t i_address,
                      fapi2::variable_buffer & o_data)
{
    errlHndl_t l_err = NULL;

    // Perform SCOM read
    uint64_t l_data = 0;
    size_t l_size = sizeof(uint64_t);

    l_err = deviceRead((TARGETING::Target *)i_target,
                       &l_data,
                       l_size,
                       DEVICE_SCOM_ADDRESS(i_address));

    return l_err;
}


/*****************************************************************************/
// getMaxConfigParams
/*****************************************************************************/
errlHndl_t getMaxConfigParams(
                 maxConfigParamsContainer& o_maxConfigParams)
{
    TOD_ENTER("getMaxConfigParams");
    errlHndl_t l_err = NULL;

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

        // Assert on failure getting system target
        if(NULL == l_pTopLevel)
        {
            TOD_ERR_ASSERT("NULL top level target found");
            break;

        }
        // Top level target successfully retrieved. Now get attributes

        o_maxConfigParams.max_procchips_per_node = l_pTopLevel->getAttr
                        < TARGETING::ATTR_MAX_PROC_CHIPS_PER_NODE > ();

        o_maxConfigParams.max_exs_per_procchip = l_pTopLevel->getAttr
                        < TARGETING::ATTR_MAX_EXS_PER_PROC_CHIP > ();

        o_maxConfigParams.max_dimms_per_mbaport = l_pTopLevel->getAttr
                        < TARGETING::ATTR_MAX_DIMMS_PER_MBA_PORT > ();

        o_maxConfigParams.max_mbaports_per_mba = l_pTopLevel->getAttr
                        < TARGETING::ATTR_MAX_MBA_PORTS_PER_MBA > ();

        o_maxConfigParams.max_mbas_per_membuf = l_pTopLevel->getAttr
                        < TARGETING::ATTR_MAX_MBAS_PER_MEMBUF_CHIP > ();

        o_maxConfigParams.max_chiplets_per_proc = l_pTopLevel->getAttr
                        < TARGETING::ATTR_MAX_CHIPLETS_PER_PROC > ();

        o_maxConfigParams.max_mcs_per_sys = l_pTopLevel->getAttr
                        < TARGETING::ATTR_MAX_MCS_PER_SYSTEM > ();

        // TODO RTC 181481: attribute ATTR_MAX_COMPUTE_NODES_PER_SYSTEM is
        // currently not implemented as needed to do this assignment.  I was
        // assured (10/2017) that HB only supports one node, so I am defaulting
        // this to 1.  In the future HB will need to be multi-node aware and
        // TARGETING::ATTR_MAX_COMPUTE_NODES_PER_SYSTEM implemented.
        o_maxConfigParams.max_compute_nodes_per_sys = 1;
//        o_maxConfigParams.max_compute_nodes_per_sys = l_pTopLevel->getAttr
//                        < TARGETING::ATTR_MAX_COMPUTE_NODES_PER_SYSTEM > ();

    } while(0);

    TOD_EXIT();

    return l_err;
}

}//end of TOD namespace

OpenPOWER on IntegriCloud