summaryrefslogtreecommitdiffstats
path: root/src/usr/sbeio/test/sbe_getsbeffdctest.H
blob: 100c8254fa53fed0a0d7d614cdbf316e9579656a (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/sbeio/test/sbe_getsbeffdctest.H $                     */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2017,2019                        */
/* [+] 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                                                     */
#ifndef __SBE_GETSBEFFDCTEST_H
#define __SBE_GETSBEFFDCTEST_H

/**
 *  @file sbe_getsbeffdctest.H
 *
 *  @brief Test cases for get sbe ffdc fifo request
*/

#include <cxxtest/TestSuite.H>
#include <errl/errlentry.H>
#include <errl/errlmanager.H>
#include <targeting/common/commontargeting.H>
#include <targeting/common/utilFilter.H>
#include <targeting/common/target.H>
#include <targeting/common/targetservice.H>
#include <sbeio/sbeioif.H>
#include <sbeio/sbe_sp_intf.H>
#include <../../usr/sbeio/sbe_fifodd.H>
#include "sbe_fifo_buffer.H"

#define SBEFFDC_TRACF(printf_string,args...) \
    TRACFCOMP(g_trac_sbeio,"getSBEFFDCTest: " printf_string,##args)

extern trace_desc_t* g_trac_sbeio;

class GetSBEFFDCTest : public CxxTest::TestSuite
{
    public:

    /**
     *  @brief Test with zero data
     */
    void testgetSBEFFDC1(void)
    {
        errlHndl_t l_errl = nullptr;
        uint32_t l_responseSize = SbeFifoRespBuffer::MSG_BUFFER_SIZE;
        uint32_t *l_pFifoResponse =
            reinterpret_cast<uint32_t *>(malloc(l_responseSize));

        TS_TRACE("getSBEFFDCTest entry");

        //
        //  get a list of all functional procs in the system
        //
        TARGETING::TargetHandleList l_cpuTargetList;
        getAllChips(l_cpuTargetList,
                    TARGETING::TYPE_PROC);

        SBEFFDC_TRACF("getSBEFFDCTest: %d proc(s) in the system.",
                      l_cpuTargetList.size() );

        //
        //  get the master procs for the system
        //
        TARGETING::Target* masterProcChipTargetHandle = NULL;
        l_errl = TARGETING::targetService().
            queryMasterProcChipTargetHandle(masterProcChipTargetHandle);
        if(l_errl)
        {
            TS_FAIL("getSBEFFDCTest FAILED: query master proc, RC 0x.8X",
                    l_errl->reasonCode());

            errlCommit( l_errl, CXXTEST_COMP_ID );

        }
        else
        {
            // loop thru all the cpu's
            for (const auto & l_cpu_target: l_cpuTargetList)
            {
                // Can't do FSI with SBE for master proc
                if(l_cpu_target == masterProcChipTargetHandle)
                {
                    TS_TRACE("getSBEFFDCTest: Skipping testing for master "
                             "proc 0x%.8X",
                             TARGETING::get_huid(l_cpu_target));

                    continue;
                }

                //TODO RTC:214913 -- Need to debug errors associated with
                // this testcase being executed
                if (1)
                {
                    TS_TRACE("getSBEFFDCTest: Skipping testing because it doesn't work ");
                    continue;
                }

                l_errl = SBEIO::getFifoSBEFFDC(l_cpu_target,
                                               l_pFifoResponse,
                                               l_responseSize);

                // Check that no error log was returned
                if(l_errl != nullptr)
                {
                    TS_FAIL("getSBEFFDCTest FAILED: proc 0x%.8X, RC 0x.8X",
                            TARGETING::get_huid(l_cpu_target),
                            l_errl->reasonCode());

                    delete l_errl;
                    l_errl = nullptr;
                    break;
                }

                // Find the status header after the return data, ie, FFDC
                uint32_t l_size = 0;
                SbeFifo::ffdcHeader *l_pFfdcHeader =
                    reinterpret_cast<SbeFifo::ffdcHeader *>(l_pFifoResponse);
                uint64_t l_firstFfdcHeaderAddr =
                        reinterpret_cast<uint64_t>(l_pFfdcHeader);
                while(l_pFfdcHeader->magic == SBEIO::SbeFifo::FIFO_FFDC_MAGIC)
                {
                    l_size += l_pFfdcHeader->lengthWords / sizeof(uint32_t);
                    l_pFfdcHeader = reinterpret_cast<SbeFifo::ffdcHeader *>
                        (l_firstFfdcHeaderAddr + l_size);
                };
                SbeFifo::statusHeader *l_pStatusHeader = reinterpret_cast<
                    SbeFifo::statusHeader *>(l_firstFfdcHeaderAddr + l_size);

                // Check that status header has expected magic value
                if(l_pStatusHeader->magic != SBEIO::SbeFifo::FIFO_STATUS_MAGIC)
                {
                    TS_FAIL("getSBEFFDCTest FAILED: proc 0x%.8X with status "
                            "magic 0x%.4x, but expected 0x%.4x",
                            TARGETING::get_huid(l_cpu_target),
                            l_pStatusHeader->magic,
                            SBEIO::SbeFifo::FIFO_STATUS_MAGIC);

                    break;
                }

                // Check status header has expected command class and command
                if((l_pStatusHeader->commandClass !=
                    SBEIO::SbeFifo::SBE_FIFO_CLASS_GENERIC_MESSAGE) ||
                   (l_pStatusHeader->command !=
                    SBEIO::SbeFifo::SBE_FIFO_CMD_GET_SBE_FFDC))
                {
                    TS_FAIL("getSBEFFDCTest FAILED: proc 0x%.8X with status "
                            "command 0x%.2x%.2x, but expected 0x%.2x%.2x",
                            TARGETING::get_huid(l_cpu_target),
                            l_pStatusHeader->commandClass,
                            l_pStatusHeader->command,
                            SBEIO::SbeFifo::SBE_FIFO_CLASS_GENERIC_MESSAGE,
                            SBEIO::SbeFifo::SBE_FIFO_CMD_GET_SBE_FFDC);

                    break;
                }

                // Check if status header has allowed unsupported status
                if((l_pStatusHeader->primaryStatus == SBE_PRI_INVALID_COMMAND)
                   && (l_pStatusHeader->secondaryStatus ==
                    SBE_SEC_COMMAND_NOT_SUPPORTED))
                {
                    TS_TRACE("getSBEFFDCTest: proc 0x%.8X got response with "
                             "not supported status 0x%.4x / 0x%.4x",
                             TARGETING::get_huid(l_cpu_target),
                             l_pStatusHeader->primaryStatus,
                             l_pStatusHeader->secondaryStatus);

                    break;
                }

                // Check that status header has expected successful status
                if((l_pStatusHeader->primaryStatus !=
                    SBE_PRI_OPERATION_SUCCESSFUL) ||
                   (l_pStatusHeader->secondaryStatus !=
                    SBE_SEC_OPERATION_SUCCESSFUL))
                {
                    TS_FAIL("getSBEFFDCTest FAILED: proc 0x%.8X with status "
                            "0x%.4x / 0x%.4x, but expected 0x%.4x / 0x%.4x",
                            TARGETING::get_huid(l_cpu_target),
                            l_pStatusHeader->primaryStatus,
                            l_pStatusHeader->secondaryStatus,
                            SBE_PRI_OPERATION_SUCCESSFUL,
                            SBE_SEC_OPERATION_SUCCESSFUL);

                    break;
                }
            }
        }

        free(l_pFifoResponse);
        l_pFifoResponse = nullptr;

        TS_TRACE("getSBEFFDCTest exit");
    }
};

#endif
OpenPOWER on IntegriCloud