summaryrefslogtreecommitdiffstats
path: root/src/usr/diag/attn/common/attnproc.C
blob: cdd124c0bee3dafed6406ba1665b5a50007a2e57 (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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/diag/attn/common/attnproc.C $                         */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2014,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                                                     */
/**
 * @file attnproc.C
 *
 * @brief HBATTN Processor attention operations function definitions.
 */

#include <errl/errlmanager.H>
#include "common/attnproc.H"
#include "common/attnlist.H"
#include "common/attntrace.H"
#include "common/attntarget.H"
#include "common/attnmem.H"

using namespace std;
using namespace PRDF;
using namespace TARGETING;
using namespace ERRORLOG;

namespace ATTN
{

errlHndl_t ProcOps::query(AttnData & i_attnToCheck, bool & o_active)
{
    errlHndl_t err = 0;
    uint64_t address = 0, checkbits = 0, scomData = 0;
    AttnData  l_cenAttnData;
    bool      l_cenAttnFound = false;
    MemOps & memOps = getMemOps();

    GFIR::getAddress(i_attnToCheck.attnType, address);

    GFIR::getCheckbits(i_attnToCheck.attnType, checkbits);

    err = getScom(i_attnToCheck.targetHndl, address, scomData);

    ATTN_TRACE("procOpsQuery:Addr:%016llx ChkBits:%016llx Data:%016llx",
               address, checkbits, scomData);

    if (!err)
    {
        if (scomData & checkbits)
        {
            o_active = true;

            // NIMBUS has no memory buffers to look at
            TARGETING::Target   *l_MasterProcTarget = NULL;
            getTargetService().masterProcChipTargetHandle(
                                             l_MasterProcTarget);

            ATTR_MODEL_type l_model = l_MasterProcTarget->getAttr<ATTR_MODEL>();
            if ( MODEL_CUMULUS == l_model )
            {
                // Attempt resolving to Centaur
                // If we do, the attention target/type gets set.
                // Else we will leave as proc attention
                for ( uint32_t l_mc=0;
                      ((l_mc < MC::numChiplets) && (false == l_cenAttnFound));
                      l_mc++)
                {
                    if ( scomData & ((MC::firstChiplet) >> l_mc) )
                    {
                        // Will handle the first attention
                        l_cenAttnFound = memOps.resolve( i_attnToCheck, l_mc);
                        // i_attnToCheck gets altered to membuf
                        // if we found valid attention there

                    } // end if this MC chiplet is active

                } // end for on MC chiplets

            } // end if CUMULUS

        } // end if active attention
        else
        {
            o_active = false;
        }
    }

    return err;
}

errlHndl_t ProcOps::resolveIpoll(
        TargetHandle_t i_proc,
        AttentionList & o_attentions)
{
    errlHndl_t err = NULL;
    uint64_t on = 0;
    uint64_t observed = 0;
    bool active = false;
    AttnData d;

    // very unlikely, but look for any
    // supported bits on in the
    // status register, in case the other
    // thread hasn't masked it yet
    err = getScom(i_proc, IPOLL_STATUS_REG, on);

    if(err)
    {
        errlCommit(err, ATTN_COMP_ID);
    }

    // also look for any supported bits on in the
    // mask register, indicating that the other thread
    // saw the error and masked it.
    err = getScom(i_proc, IPOLL::address, observed);

    if(err)
    {
        errlCommit(err, ATTN_COMP_ID);
    }

    ATTN_TRACE("resolveIpoll: Status:%016llx  Mask:%016llx",
                 on, observed);

    for(uint64_t type = INVALID_ATTENTION_TYPE;
            type != END_ATTENTION_TYPE;
            ++type)
    {
        uint64_t supported = 0;

        if(!IPOLL::getCheckbits(type, supported))
        {
            // this object doesn't support
            // this attention type
            continue;
        }

        // analysis should be done if the bit for this
        // attention type is either on in the status reg
        // or masked in the mask reg
        if(!(supported & (on | observed)))
        {
            ATTN_TRACE("resolveIpoll: Skipping");
            continue;
        }

        d.attnType = static_cast<ATTENTION_VALUE_TYPE>(type);
        d.targetHndl = i_proc;

        // to be sure, query corresponding GFIR
        ATTN_TRACE("rslvIpoll: Qry type  :%016llx", d.attnType);
        err = query(d, active);
        if(err)
        {
            errlCommit(err, ATTN_COMP_ID);
        }
        else if(active)
        {
            o_attentions.add(Attention(d, this));
            break;
        }
    }

    return err;
}

errlHndl_t ProcOps::resolve(
        TargetHandle_t i_proc,
        uint64_t i_typeMask,
        AttentionList & o_attentions)
{
    errlHndl_t err = 0;

    bool active = false;
    AttnData d;
    d.targetHndl = i_proc;

    uint64_t ignored;

    ATTN_TRACE("procOps::resolve");
    for(uint64_t type = INVALID_ATTENTION_TYPE;
            type != END_ATTENTION_TYPE;
            ++type)
    {
        if(!enabled())
        {
            break;
        }

        ATTN_TRACE("procOps::Validate attn types");
        if(!GFIR::getCheckbits(type, ignored))
        {
            // this object doesn't support
            // this attention type

            continue;
        }

        uint64_t mask = 0;

        IPOLL::getCheckbits(type, mask);
        ATTN_TRACE("procOps::Chkbits type:%016llx mask:%016llx iMask:%016llx",
                    type, mask, i_typeMask);

        if(!(mask & ~i_typeMask))
        {
            // this attention type is masked

            continue;
        }

        d.attnType = static_cast<ATTENTION_VALUE_TYPE>(type);

        ATTN_TRACE("procOps::Query type  :%016llx", d.attnType );
        err = query(d, active);

        if(err)
        {
            errlCommit(err, ATTN_COMP_ID);
        }

        else if(active)
        {
            o_attentions.add(Attention(d, this));
            break;
        }
    }

    return err;
}
}
OpenPOWER on IntegriCloud