summaryrefslogtreecommitdiffstats
path: root/src/usr/isteps/istep09/call_fabric_io_dccal.C
blob: 84b0b56ddf16c78ddbef8d26401a83a16b4ab610 (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
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/isteps/istep09/call_fabric_io_dccal.C $               */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2015,2018                        */
/* [+] 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 call_fabric_io_dccal.C
 *
 *  Support file for IStep: edi_ei_initialization
 *   EDI, EI Initialization
 *
 *  HWP_IGNORE_VERSION_CHECK
 *
 */

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

//  Integral and component ID support
#include <stdint.h>                     // uint32_t
#include <hbotcompid.H>                 // HWPF_COMP_ID

//  Targeting support
#include <fapi2_target.H>               // fapi2::Target
#include <target.H>                     // TARGETING::Target

//  Error handling support
#include <errl/errlentry.H>             // errlHndl_t
#include <isteps/hwpisteperror.H>       // IStepError

//  Tracing support
#include <trace/interface.H>            // TRACFCOMP
#include <initservice/isteps_trace.H>   // g_trac_isteps_trace
#include <initservice/initserviceif.H>  // isSMPWrapConfig

//  Pbus link service support
#include <pbusLinkSvc.H>                // TargetPairs_t, PbusLinkSvc

//  HWP call support
#include <istepHelperFuncs.H>           // captureError
#include <istep09/istep09HelperFuncs.H> // trainBusHandler
#include <p9_io_xbus_dccal.H>           // p9_io_xbus_dccal

namespace ISTEP_09
{
using   namespace   ISTEP_ERROR;
using   namespace   ISTEPS_TRACE;
using   namespace   TARGETING;

/**
 *  @brief
 *     This function actually makes the FAPI call to p9_io_xbus_dccal.
 *
 *  @param[out] o_stepError   The details of an error, if any, will be added to this
 *  @param[in]  i_dccalMode   XbusDccalMode -- selects what operation to perform
 *  @param[in]  i_fapi2Target fapi2 target
 *  @param[in]  i_group       clock group
 *  @return  True if NO errors occurred, false otherwise
 */
bool configureXbusConnections(IStepError          &o_stepError,
                              const XbusDccalMode  i_dccalMode,
                              const XBUS_TGT       i_fapi2Target,
                              const uint8_t        i_group);

/**
 *  @brief This function explicitly makes the FAPI call for XbusDccalMode
 *         TxZcalRunBus and XbusDccalMod.  This function iterates over the
 *         groups within the iteration of individual targets.
 *
 *  @param[out] o_stepError   The details of an error, if any, will be added to this
 *  @param[in]  i_pbusConnections   XBUS pair connections
 *  @return  True if NO errors occurred, false otherwise
 */
bool configureXbusConnectionsRunBusMode(IStepError &o_stepError,
             const EDI_EI_INITIALIZATION::TargetPairs_t &i_pbusConnections);

/**
 *  @brief This function makes the FAPI call for the given XbusDccalMode.
 *         This function also iterates over the individual targets within
 *         the iteration of individual groups.
 *
 *  @param[out] o_stepError   The details of an error, if any, will be added to this
 *  @param[in]  i_pbusConnections   XBUS pair connections
 *  @param[in]  i_dccalMode   XbusDccalMode -- selects what operation to perform
 *  @return  True if NO errors occurred, false otherwise
 */
bool configureXbusConnectionsMode(IStepError &o_stepError,
             const EDI_EI_INITIALIZATION::TargetPairs_t &i_PbusConnections,
             XbusDccalMode i_dccalMode);

//******************************************************************************
// Wrapper function to call fabric_io_dccal
//******************************************************************************
void* call_fabric_io_dccal( void *io_pArgs )
{
    errlHndl_t  l_errl(nullptr);
    IStepError  l_stepError;

    // We are not running this analog procedure in VPO
    if (TARGETING::is_vpo())
    {
        TRACFCOMP(g_trac_isteps_trace, "Skip call_fabric_io_dccal in VPO!");
        return l_stepError.getErrorHandle();
    }

    TRACFCOMP(g_trac_isteps_trace, ENTER_MRK"call_fabric_io_dccal entry");

    EDI_EI_INITIALIZATION::TargetPairs_t l_pbusConnections;
    TYPE l_busSet[] = { TYPE_XBUS, TYPE_OBUS };
    constexpr uint32_t l_maxBusSet = sizeof(l_busSet)/sizeof(TYPE);

    for (uint32_t ii = 0; ii < l_maxBusSet; ++ii)
    {
        l_errl = EDI_EI_INITIALIZATION::PbusLinkSvc::getTheInstance().
                    getPbusConnections(l_pbusConnections, l_busSet[ii]);
        if (l_errl)
        {
            TRACFCOMP(g_trac_isteps_trace,
                "ERROR 0x%.8X : getPbusConnections TYPE_%cBUS returns error",
                l_errl->reasonCode(), (ii ? 'O':'X') );

            // Capture error and then exit
            captureError(l_errl,
                         l_stepError,
                         HWPF_COMP_ID);

            // Don't continue with a potential bad connection set
            break;
        }

        if (TYPE_XBUS == l_busSet[ii])
        {
            if (l_pbusConnections.empty())
            {
                TRACFCOMP(g_trac_isteps_trace, "Connection bus list is empty. "
                          "HWP call p9_io_xbus_dccal will not be called.");
            }

            // if any one of these returns an error then just move on to the next Bus Set
            configureXbusConnectionsRunBusMode(l_stepError,
                                               l_pbusConnections) &&
            configureXbusConnectionsMode(l_stepError,
                                         l_pbusConnections,
                                         XbusDccalMode::RxDccalStartGrp) &&
            configureXbusConnectionsMode(l_stepError,
                                         l_pbusConnections,
                                         XbusDccalMode::RxDccalCheckGrp);
        }  // end if (TYPE_XBUS == l_busSet[ii])
        else if (INITSERVICE::isSMPWrapConfig() &&
                (TYPE_OBUS == l_busSet[ii]))
        {
            // Make the FAPI call to p9_io_obus_dccal
            if (!trainBusHandler(l_busSet[ii],
                                 P9_IO_OBUS_DCCAL,
                                 l_stepError,
                                 HWPF_COMP_ID,
                                 l_pbusConnections))
            {
                break;
            }
        }  // end else if (TYPE_OBUS == l_busSet[ii])
    } // end  for (uint32_t ii = 0; ii < l_maxBusSet; ii++)

    TRACFCOMP(g_trac_isteps_trace, EXIT_MRK"call_fabric_io_dccal exit" );

    // end task, returning any errorlogs to IStepDisp
    return l_stepError.getErrorHandle();
}

/**
 *  configureXbusConnectionsRunBusMode
 */
bool configureXbusConnectionsRunBusMode(IStepError &o_stepError,
             const EDI_EI_INITIALIZATION::TargetPairs_t &i_PbusConnections)
{
    bool l_retSuccess = true;

    // Group is either 0 or 1
    std::vector<uint8_t> l_groups = {0,1};

    // Iterate over the connections
    for (const auto & l_pbusConnection: i_PbusConnections)
    {
        // Put targets in a container that can be traversed
        std::vector<const TARGETING::Target*> l_targets =
                            { l_pbusConnection.first, l_pbusConnection.second };

        // Iterate over the targets
        for (const auto l_target: l_targets)
        {
            // Convert current target to a fapi2 target
            const fapi2::Target <fapi2::TARGET_TYPE_XBUS>
                l_pbusFapi2Target
                (const_cast<TARGETING::Target*>(l_target));

            TRACFCOMP(g_trac_isteps_trace,
                      "Running p9_io_xbus_dccal HWP with mode = %.8X on "
                      "XBUS target %.8X on group %d",
                      XbusDccalMode::TxZcalRunBus,
                      TARGETING::get_huid(l_target),
                      l_groups[0]);

            l_retSuccess = configureXbusConnections(o_stepError,
                                                    XbusDccalMode::TxZcalRunBus,
                                                    l_pbusFapi2Target,
                                                    l_groups[0]);

            if (!l_retSuccess) break; // Don't continue if an error occurred

            for (auto l_group : l_groups)
            {
                TRACFCOMP(g_trac_isteps_trace,
                          "Running p9_io_xbus_dccal HWP with mode = %.8X on "
                          "XBUS target %.8X on group %d",
                          XbusDccalMode::TxZcalSetGrp,
                          TARGETING::get_huid(l_target),
                          l_group);

                l_retSuccess =
                       configureXbusConnections(o_stepError,
                                                XbusDccalMode::TxZcalSetGrp,
                                                l_pbusFapi2Target,
                                                l_group);
                if (!l_retSuccess) break; // Don't continue if an error occurred
            }

            TRACFCOMP(g_trac_isteps_trace,
                      "%s : XBUS connection p9_io_xbus_dccal, target 0x%.8X",
                      (l_retSuccess ? "SUCCESS": "ERROR"),
                      TARGETING::get_huid(l_target));

            if (!l_retSuccess) break; // Don't continue if an error occurred
        } // for (const auto l_target: l_targets)

        if (!l_retSuccess) break; // Don't continue if an error occurred
    } // for (const auto & l_pbusConnection: l_pbusConnections)

    // return true if call was successful, else false
    return l_retSuccess;
}

/**
 *  configureXbusConnectionsMode
 */
bool configureXbusConnectionsMode(IStepError &o_stepError,
             const EDI_EI_INITIALIZATION::TargetPairs_t &i_PbusConnections,
             XbusDccalMode i_dccalMode)
{
    bool l_retSuccess = true;

    // Group is either 0 or 1
    std::vector<uint8_t> l_groups = {0,1};

    // Iterate over the connections
    for (const auto & l_pbusConnection: i_PbusConnections)
    {
        // Put targets in a container that can be traversed
        std::vector<const TARGETING::Target*> l_targets =
                            { l_pbusConnection.first, l_pbusConnection.second };

        // Iterate over the groups
        for (auto l_group : l_groups)
        {
            // Iterate over targets
            for (const auto l_target: l_targets)
            {
                // Convert current target to a fapi2 target
                const fapi2::Target <fapi2::TARGET_TYPE_XBUS>
                    l_pbusFapi2Target
                    (const_cast<TARGETING::Target*>(l_target));

                TRACFCOMP(g_trac_isteps_trace,
                          "Running p9_io_xbus_dccal HWP with mode = %.8X on "
                          "XBUS target %.8X on group %d",
                          i_dccalMode,
                          TARGETING::get_huid(l_target),
                          l_group);

                l_retSuccess = configureXbusConnections(o_stepError,
                                                        i_dccalMode,
                                                        l_pbusFapi2Target,
                                                        l_group);
                // Ignore errors in RxDccalCheckGrp mode
                if (XbusDccalMode::RxDccalCheckGrp == i_dccalMode)
                {
                    l_retSuccess = true;
                }

                TRACFCOMP(g_trac_isteps_trace,
                          "%s : XBUS connection p9_io_xbus_dccal, target 0x%.8X",
                          (l_retSuccess ? "SUCCESS" : "ERROR"),
                          TARGETING::get_huid(l_target));
                if (!l_retSuccess) break; // Don't continue if an error occurred
            } // end for (const auto l_target: l_targets)

            if (!l_retSuccess) break; // Don't continue if an error occurred
        } // end for (auto l_group : l_groups)

        if (!l_retSuccess) break; // Don't continue if an error occurred
    } // for (const auto & l_pbusConnection: l_pbusConnections)

    // return true if call was successful, else false
    return l_retSuccess;
}

/**
 *  configureXbusConnections
 */
bool configureXbusConnections(IStepError          &o_stepError,
                              const XbusDccalMode  i_dccalMode,
                              const XBUS_TGT       i_fapi2Target,
                              const uint8_t        i_group)
{
    bool l_retSuccess = true;
    errlHndl_t l_err = nullptr;

    FAPI_INVOKE_HWP(l_err,
                    p9_io_xbus_dccal,
                    i_dccalMode,
                    i_fapi2Target,
                    i_group);

    if ( l_err )
    {
        // Capture error and then exit
        captureError(l_err,
                     o_stepError,
                     HWPF_COMP_ID,
                     i_fapi2Target);

        // Note that this step had an error
        l_retSuccess = false;
    }

   // return true if call was successful, else false
   return l_retSuccess;
}

};   // end namespace ISTEP_09
OpenPOWER on IntegriCloud