summaryrefslogtreecommitdiffstats
path: root/src/usr/diag/mdia/mdiamba.C
blob: 35abedbf621efb612a99f5d5f6500f36e5dc2914 (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
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/diag/mdia/mdiamba.C $                                 */
/*                                                                        */
/* IBM CONFIDENTIAL                                                       */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 2012,2013              */
/*                                                                        */
/* 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 mdiamba.C
 * @brief mdia mba specific functions
 */

#include "mdiafwd.H"
#include "mdiaglobals.H"
#include "mdiasm.H"
#include "mdiatrace.H"
#include "targeting/common/utilFilter.H"

using namespace TARGETING;

namespace MDIA
{

errlHndl_t getMbaDiagnosticMode(
        const Globals & i_globals,
        TargetHandle_t i_mba,
        DiagMode & o_mode)
{
    o_mode = INIT_ONLY;

    if(MNFG_FLAG_BIT_MNFG_ENABLE_EXHAUSTIVE_PATTERN_TEST
            & i_globals.mfgPolicy)
    {
        o_mode = NINE_PATTERNS;
    }

    else if(MNFG_FLAG_BIT_MNFG_ENABLE_STANDARD_PATTERN_TEST
            & i_globals.mfgPolicy)
    {
        o_mode = FOUR_PATTERNS;
    }

    else if(MNFG_FLAG_BIT_MNFG_ENABLE_MINIMUM_PATTERN_TEST
            & i_globals.mfgPolicy)
    {
        o_mode = ONE_PATTERN;
    }

    // Only need to check hw changed state attributes
    // when not already set to standard or exhaustive
    if((FOUR_PATTERNS != o_mode) ||
       (NINE_PATTERNS != o_mode))
    {
        if(isHWStateChanged(i_mba))
        {
            o_mode = FOUR_PATTERNS;
        }
    }

    MDIA_FAST("getMbaDiagnosticMode: mba: %x, o_mode: 0x%x",
              get_huid(i_mba), o_mode);

    return 0;
}

errlHndl_t getMbaWorkFlow(DiagMode i_mode, WorkFlow & o_wf)
{
    // add the correct sequences for the mba based
    // on the mode

    // every mba does restore dram repairs

    o_wf.push_back(RESTORE_DRAM_REPAIRS);

    switch (i_mode) {

        case NINE_PATTERNS:

            o_wf.push_back(START_RANDOM_PATTERN);
            o_wf.push_back(START_SCRUB);
            o_wf.push_back(START_PATTERN_7);
            o_wf.push_back(START_SCRUB);
            o_wf.push_back(START_PATTERN_6);
            o_wf.push_back(START_SCRUB);
            o_wf.push_back(START_PATTERN_5);
            o_wf.push_back(START_SCRUB);
            o_wf.push_back(START_PATTERN_4);
            o_wf.push_back(START_SCRUB);

            // fall through

        case FOUR_PATTERNS:

            o_wf.push_back(START_PATTERN_3);
            o_wf.push_back(START_SCRUB);
            o_wf.push_back(START_PATTERN_2);
            o_wf.push_back(START_SCRUB);
            o_wf.push_back(START_PATTERN_1);
            o_wf.push_back(START_SCRUB);

            // fall through

        case ONE_PATTERN:

            o_wf.push_back(START_PATTERN_0);

            // fall through

        case SCRUB_ONLY:

            o_wf.push_back(START_SCRUB);
            break;

        case INIT_ONLY:

            o_wf.push_back(START_PATTERN_0);
            break;

        default:
            break;
    }

    // clear HW changed state attribute
    o_wf.push_back(CLEAR_HW_CHANGED_STATE);

    return 0;
}

/*
 *  Local helper function to return a list of Centaur
 *  DIMMs, and MCS associated with the input MBA target
 *
 *  If i_queryOnly = true (Query)
 *    - Return a list of DIMMs, Centaur, and
 *      MCS connected to this MBA
 *
 *  Else (Clear)
 *   - Return a list of DIMMs and
 *     (Centaur + MCS) if all the DIMMs behind this
 *     Centaur have hwchangedState flags cleared
 *     or about to be cleared by this MBA
 */
TargetHandleList getMemTargetsForQueryOrClear(
                    TargetHandle_t i_mba, bool i_queryOnly)
{
    #define FUNC "getMemTargetsForQueryOrClear: "
    TargetHandleList o_list;

    do
    {
        // add associated DIMMs
        TargetHandleList dimmList;
        getChildAffinityTargets(dimmList,
                                i_mba,
                                CLASS_NA,
                                TYPE_DIMM);

        if( ! dimmList.empty() )
        {
            o_list.insert(o_list.begin(), dimmList.begin(),
                          dimmList.end());
        }

        // add associated Centaur
        TargetHandleList targetList;
        getParentAffinityTargets(targetList,
                                 i_mba,
                                 CLASS_CHIP,
                                 TYPE_MEMBUF);

        if( targetList.empty() )
        {
            MDIA_FAST(FUNC"no connected centaur "
                    "for mba: %x", get_huid(i_mba));
            break;
        }

        TargetHandle_t centaur = targetList[0];

        // if query flag is not set, check to make sure
        // all of the dimms connected to this centaur
        // have cleared hw chagned state attributes
        // before adding this centaur/mcs to the list.
        // This is needed because we only clear
        // the centaur/mcs attribute when all of the
        // dimms' attributes from both mbas have cleared.
        if(false == i_queryOnly)
        {
            targetList.clear();
            getChildAffinityTargets(targetList,
                                    centaur,
                                    CLASS_NA,
                                    TYPE_DIMM);

            if( ! targetList.empty() )
            {
                TargetHandleList::iterator target;

                for(target = targetList.begin();
                    target != targetList.end(); ++target)
                {
                    // exclude dimms belong to the current mba
                    // because their attributes will be cleared
                    if(dimmList.end() !=
                             std::find(dimmList.begin(),
                                       dimmList.end(), *target))
                    {
                        continue;
                    }

                    ATTR_HWAS_STATE_CHANGED_FLAG_type hwChangeFlag;
                    hwChangeFlag =
                      (*target)->getAttr<ATTR_HWAS_STATE_CHANGED_FLAG>();

                    if(HWAS_CHANGED_BIT_MEMDIAG & hwChangeFlag)
                    {
                        MDIA_FAST(FUNC"hwChangedState is not cleared "
                                  "for dimm: %x", get_huid(*target));
                        centaur = NULL; // don't add centaur and mcs
                        break;
                    }
                }
            }
        }

        if(NULL == centaur)
        {
            break;
        }

        o_list.push_back(centaur);

        // get connected mcs target
        targetList.clear();

        getParentAffinityTargets(targetList,
                                 centaur,
                                 CLASS_UNIT,
                                 TYPE_MCS);

        if( ! targetList.empty() )
        {
            o_list.push_back(targetList[0]);
        }

    } while(0);

    MDIA_DBG(FUNC"mba: %x, size: %d",
             get_huid(i_mba), o_list.size());

    return o_list;

    #undef FUNC
}


bool isHWStateChanged(TargetHandle_t i_mba)
{
    bool hwChanged = false;
    ATTR_HWAS_STATE_CHANGED_FLAG_type hwChangeFlag;

    // Get a list of associated targets for attribute query
    TargetHandleList targetList =
        getMemTargetsForQueryOrClear(i_mba, true);

    for(TargetHandleList::iterator target = targetList.begin();
        target != targetList.end(); ++target )
    {
        hwChangeFlag =
            (*target)->getAttr<ATTR_HWAS_STATE_CHANGED_FLAG>();

        if(HWAS_CHANGED_BIT_MEMDIAG & hwChangeFlag)
        {
            MDIA_DBG("isHWStateChanged: set for target: %x",
                     get_huid(*target));
            hwChanged = true;
            break;
        }
    }

    return hwChanged;
}

void clearHWStateChanged(TargetHandle_t i_mba)
{
    TargetHandleList targetList;

    // Get a list of associated targets for attribute clearing
    targetList = getMemTargetsForQueryOrClear(i_mba, false);

    for(TargetHandleList::iterator target = targetList.begin();
        target != targetList.end(); ++target)
    {
        MDIA_DBG("clearHWStateChanged: mba: %x, target: %x",
                 get_huid(i_mba), get_huid(*target));

        clear_hwas_changed_bit( *target,
                                HWAS_CHANGED_BIT_MEMDIAG);
    }
}


}
OpenPOWER on IntegriCloud