summaryrefslogtreecommitdiffstats
path: root/src/usr/fapi2/test/fapi2VerifyCalloutTest.C
blob: ca7238a6d83a93da9a5cbcdd40e31f03ed7341b9 (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
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/fapi2/test/fapi2VerifyCalloutTest.C $                 */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 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                                                     */
#include <fapi2.H>
#include <error_info.H>
#include <plat_hwp_invoker.H>
#include <errl/errlreasoncodes.H>
#include <targeting/common/targetservice.H>
#include <rcSupport.H>

uint32_t rcTestCalloutDeconfigGard()
{
    uint32_t l_result = 0;
    errlHndl_t l_errl = NULL;
    bool l_hw_callout_found = false;

    FAPI_INF("rcTestCalloutDeconfigGard running");

    TARGETING::TargetHandleList l_chipList;
    TARGETING::getAllChips(l_chipList, TARGETING::TYPE_PROC, false);
    TARGETING::Target * l_Proc = NULL;

    //Grab the first chip if there are multiple
    if (l_chipList.size() > 0)
    {
        l_Proc = l_chipList[0];
    }
    else
    {
        TS_FAIL("No proc chips found");
    }

    //Convert to fapi2 target for the HWP below
    fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP> fapi2_procTarget(l_Proc);

    FAPI_INVOKE_HWP(l_errl, p9_gardAndDeconfig, fapi2_procTarget);

    if(l_errl != NULL)
    {
        FAPI_INF("rcTestCalloutDeconfigGard: p9_gardAndDeconfig "
                                                    "returned errl (expected)");

        //Get the User Data fields of the errl. They are returned as
        //vector<void*>, so iterate over them.
        for( auto l_callout_raw : l_errl->
                getUDSections( ERRL_COMP_ID, ERRORLOG::ERRL_UDT_CALLOUT ) )
        {
            HWAS::callout_ud_t* l_callout_entry =
                    reinterpret_cast<HWAS::callout_ud_t*>(l_callout_raw);

            if(l_callout_entry->type == HWAS::HW_CALLOUT)
            {
                l_hw_callout_found = true;
                FAPI_INF("rcTestCalloutDeconfigGard: found hw callout");

                if(l_callout_entry->gardErrorType  == HWAS::GARD_Unrecoverable)
                {
                    FAPI_INF("rcTestCalloutDeconfigGard: "
                                                     "Gard Error Type matches");
                }
                else
                {
                    TS_FAIL("rcTestCalloutDeconfigGard: "
                    "Gard Error Type does NOT match. Expected: %x Actual: %x",
                    HWAS::GARD_Unrecoverable, l_callout_entry->gardErrorType);
                    l_result = 1;
                    break;
                }

                if(l_callout_entry->deconfigState == HWAS::DELAYED_DECONFIG)
                {
                    FAPI_INF("rcTestCalloutDeconfigGard: Target deconfigured");
                }
                else
                {
                    TS_FAIL("rcTestCalloutDeconfigGard: "
                                                  "Target is NOT deconfigured");
                    l_result = 2;
                    break;
                }
            }
        }
        if(!l_hw_callout_found)
        {
            TS_FAIL("rcTestCalloutDeconfigGard: hw callout not found");
            l_result = 3;
        }
    }
    else
    {
        TS_FAIL("rcTestCalloutDeconfigGard: No error was returned "
                                                  "from p9_gardAndDeconfig !!");
        l_result = 4;
    }

    delete l_errl;
    l_errl = NULL;

    FAPI_INF("rcTestCalloutDeconfigGard finished");
    return l_result;
}

uint32_t rcTestCalloutProcedure()
{
    uint32_t l_result = 0;
    errlHndl_t l_errl = NULL;
    bool l_procedure_found = false;

    FAPI_INF("rcTestCalloutProcedure running");

    FAPI_INVOKE_HWP(l_errl, p9_procedureCallout);

    if(l_errl != NULL)
    {
        FAPI_INF("rcTestCalloutProcedure: "
                                "p9_procedureCallout returned errl (expected)");

        //Get the User Data fields of the errl. They are returned as
        //vector<void*>, so iterate over them.
        for( auto l_callout_raw : l_errl->
                getUDSections( ERRL_COMP_ID, ERRORLOG::ERRL_UDT_CALLOUT ) )
        {
            HWAS::callout_ud_t* l_callout_entry =
                    reinterpret_cast<HWAS::callout_ud_t*>(l_callout_raw);
            if(l_callout_entry->type == HWAS::PROCEDURE_CALLOUT)
            {
                l_procedure_found = true;
                FAPI_INF("rcTestCalloutProcedure: procedure callout found");
                if(l_callout_entry->priority == HWAS::SRCI_PRIORITY_HIGH)
                {
                    FAPI_INF("rcTestCalloutProcedure: "
                                       "high priority procedure callout found");
                }
                else
                {
                    TS_FAIL("rcTestCalloutProcedure: "
                    "incorrect procedure callout priority. Expected: %x"
                    " Actual: %x",
                    HWAS::SRCI_PRIORITY_HIGH,
                    l_callout_entry->priority);
                    l_result = 1;
                    break;
                }
            }
        }
        if(!l_procedure_found)
        {
            TS_FAIL("rcTestCalloutProcedure: procedure callout NOT found");
            l_result = 2;
        }
    }
    else
    {
        TS_FAIL("rcTestCalloutProcedure: No error was returned "
                                                 "from p9_procedureCallout !!");
        l_result = 3;
    }

    delete l_errl;
    l_errl = NULL;

    FAPI_INF("rcTestCalloutProcedure finished");
    return l_result;
}

uint32_t rcTestCalloutHw()
{
    uint32_t l_result = 0;
    errlHndl_t l_errl = NULL;
    bool l_hw_callout_found = false;

    FAPI_INF("rcTestCalloutHw running");

    TARGETING::TargetHandleList l_coreList;
    TARGETING::getAllChiplets(l_coreList, TARGETING::TYPE_CORE, false);
    TARGETING::Target * l_Core = NULL;

    //Get the first core
    if(l_coreList.size() > 0)
    {
        l_Core = l_coreList[0];
    }
    else
    {
        TS_FAIL("No cores found");
    }

    //Convert to fapi2 target for HWP
    fapi2::Target<fapi2::TARGET_TYPE_CORE> fapi2_coreTarget(l_Core);

    FAPI_INVOKE_HWP(l_errl, p9_hwCallout, fapi2_coreTarget);

    if(l_errl != NULL)
    {
        FAPI_INF("rcTestCalloutHw: p9_hwCallout returned errl (expected)");

        //Get the User Data fields of the errl. They are returned as
        //vector<void*>, so iterate over them.
        for( auto l_callout_raw : l_errl->
                getUDSections( ERRL_COMP_ID, ERRORLOG::ERRL_UDT_CALLOUT ) )
        {
            HWAS::callout_ud_t* l_callout_entry =
                    reinterpret_cast<HWAS::callout_ud_t*>(l_callout_raw);
            if(l_callout_entry->type == HWAS::HW_CALLOUT)
            {
                l_hw_callout_found = true;
                FAPI_INF("rcTestCalloutHw: hw callout found");
                if(l_callout_entry->priority == HWAS::SRCI_PRIORITY_LOW)
                {
                    FAPI_INF("rcTestCalloutHw: low priority hw callout found");
                }
                else
                {
                    TS_FAIL("rcTestCalloutHw: incorrect hw callout priority."
                    " Expected: %x Actual: %x",
                    HWAS::SRCI_PRIORITY_LOW, l_callout_entry->priority);
                    l_result = 1;
                    break;
                }
            }
        }
        if(!l_hw_callout_found)
        {
            TS_FAIL("rcTestCalloutHw: hw callout NOT found");
            l_result = 2;
        }
    }
    else
    {
        TS_FAIL("rcTestCalloutHw: No error was returned from p9_hwCallout !!");
        l_result = 3;
    }

    delete l_errl;
    l_errl = NULL;

    FAPI_INF("rcTestCalloutHw finished");
    return l_result;
}

uint32_t rcTestCalloutDeconfig()
{
    uint32_t l_result = 0;
    errlHndl_t l_errl = NULL;
    bool l_hw_callout_found = false;

    FAPI_INF("rcTestCalloutDeconfig running");

    TARGETING::TargetHandleList l_dimmList;
    TARGETING::getAllLogicalCards(l_dimmList, TARGETING::TYPE_DIMM, false);
    TARGETING::Target * l_Dimm = NULL;

    //Take the first dimm
    if (l_dimmList.size() > 0)
    {
        l_Dimm = l_dimmList[0];
    }
    else
    {
        TS_FAIL("No dimms found");
    }

    //Convert to fapi2 target for the HWP below
    fapi2::Target<fapi2::TARGET_TYPE_DIMM> fapi2_dimmTarget(l_Dimm);

    FAPI_INVOKE_HWP(l_errl, p9_deconfigCallout, fapi2_dimmTarget);

    if(l_errl != NULL)
    {
        FAPI_INF("rcTestCalloutDeconfig: p9_deconfigCallout returned errl "
                                                                  "(expected)");

        //Get the User Data fields of the errl. They are returned as
        //vector<void*>, so iterate over them.
        for( auto l_callout_raw : l_errl->
                getUDSections( ERRL_COMP_ID, ERRORLOG::ERRL_UDT_CALLOUT ) )
        {
            HWAS::callout_ud_t* l_callout_entry =
                           reinterpret_cast<HWAS::callout_ud_t*>(l_callout_raw);

            if(l_callout_entry->type == HWAS::HW_CALLOUT)
            {
                l_hw_callout_found = true;
                FAPI_INF("rcTestCalloutDeconfig: hw callout found");
                if(l_callout_entry->deconfigState == HWAS::DELAYED_DECONFIG)
                {
                   FAPI_INF("rcTestCalloutDeconfig: Target is deconfigured");
                }
                else
                {
                    TS_FAIL("rcTestCalloutDeconfig: Target is NOT deconfigured");
                    l_result = 1;
                    break;
                }
            }
        }
        if(!l_hw_callout_found)
        {
            TS_FAIL("rcTestCalloutDeconfig: hw callout NOT found");
            l_result = 2;
        }
    }
    else
    {
        TS_FAIL("rcTestCalloutDeconfig: No error was returned from"
                                                      " p9_deconfigCallout !!");
        l_result = 3;
    }

    delete l_errl;
    l_errl = NULL;

    FAPI_INF("rcTestCalloutDeconfig finished");
    return l_result;
}
OpenPOWER on IntegriCloud