summaryrefslogtreecommitdiffstats
path: root/src/usr/hwpf/hwp/dmi_training/dmi_training.C
blob: 49225dfef46c344117b90a3c511aba0158669731 (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
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
/*  IBM_PROLOG_BEGIN_TAG
 *  This is an automatically generated prolog.
 *
 *  $Source: src/usr/hwpf/hwp/dmi_training/dmi_training.C $
 *
 *  IBM CONFIDENTIAL
 *
 *  COPYRIGHT International Business Machines Corp. 2012
 *
 *  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 other-
 *  wise divested of its trade secrets, irrespective of what has
 *  been deposited with the U.S. Copyright Office.
 *
 *  Origin: 30
 *
 *  IBM_PROLOG_END_TAG
 */

/**
 *  @file dmi_training.C
 *
 *  Support file for hardware procedure:
 *      DMI Training
 *
 */

/**
 * @note    "" comments denote lines that should be built from the HWP
 *          tag block.  See the preliminary design in dmi_training.H
 *          Please save.
 */


/******************************************************************************/
// Includes
/******************************************************************************/
#include    <stdint.h>

#include    <trace/interface.H>
#include    <initservice/taskargs.H>
#include    <errl/errlentry.H>

#include    <initservice/isteps_trace.H>

//  targeting support.
#include    <targeting/common/commontargeting.H>
#include    <targeting/common/utilFilter.H>

//  fapi support
#include    <fapi.H>
#include    <fapiPlatHwpInvoker.H>

//  --  prototype   includes    --
#include    "dmi_training.H"
#include    "proc_cen_framelock.H"
#include    "dmi_io_run_training.H"
#include    "dmi_scominit.H"

namespace   DMI_TRAINING
{


using   namespace   TARGETING;
using   namespace   fapi;

//
//  Wrapper function to call 11.1   dmi_scominit
//
void    call_dmi_scominit( void *io_pArgs )
{
    errlHndl_t l_errl = NULL;

    TRACDCOMP( ISTEPS_TRACE::g_trac_isteps_trace, "call_dmi_scominit entry" );
    uint8_t l_num = 0;
   
    // Get all functional MCS chiplets
    TARGETING::TargetHandleList l_mcsTargetList;
    getAllChiplets(l_mcsTargetList, TYPE_MCS);
   
    // Invoke dmi_scominit on each one
    for (l_num = 0; l_num < l_mcsTargetList.size(); l_num++)
    {
        const TARGETING::Target* l_pTarget = l_mcsTargetList[l_num];
        const fapi::Target l_fapi_target(
            TARGET_TYPE_MCS_CHIPLET,
            reinterpret_cast<void *>
                (const_cast<TARGETING::Target*>(l_pTarget)));

        TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace, "Running dmi_scominit HWP on...");
        EntityPath l_path;
        l_path = l_pTarget->getAttr<ATTR_PHYS_PATH>();
        l_path.dump();

        FAPI_INVOKE_HWP(l_errl, dmi_scominit, l_fapi_target);
        if (l_errl)
        {
            TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace, "ERROR 0x%.8X : dmi_scominit HWP returns error",
                      l_errl->reasonCode());
            break;
        }
        else
        {
            TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace, "SUCCESS :  dmi_scominit HWP");
        }
    }

    if (!l_errl)
    {
        // Get all functional membuf chips
        TARGETING::TargetHandleList l_membufTargetList;
        getAllChips(l_membufTargetList, TYPE_MEMBUF);

        // Invoke dmi_scominit on each one
        for (l_num = 0; l_num < l_membufTargetList.size(); l_num++)
        {
            const TARGETING::Target* l_pTarget = l_membufTargetList[l_num];
            const fapi::Target l_fapi_target(
                TARGET_TYPE_MEMBUF_CHIP,
                reinterpret_cast<void *>
                    (const_cast<TARGETING::Target*>(l_pTarget)));

            TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace, "Running dmi_scominit HWP on...");
            EntityPath l_path;
            l_path = l_pTarget->getAttr<ATTR_PHYS_PATH>();
            l_path.dump();

            FAPI_INVOKE_HWP(l_errl, dmi_scominit, l_fapi_target);
            if (l_errl)
            {
                TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace, "ERROR 0x%.8X : dmi_scominit HWP returns error",
                          l_errl->reasonCode());
                break;
            }
            else
            {
                TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace, "SUCCESS :  dmi_scominit HWP");
            }
        }
    }

    TRACDCOMP( ISTEPS_TRACE::g_trac_isteps_trace, "call_dmi_scominit exit" );

    // end task, returning any errorlogs to IStepDisp
    task_end2( l_errl );
}


//
//  Wrapper function to call 11.2 :  dmi_erepair
//
void    call_dmi_erepair( void *io_pArgs )
{
    errlHndl_t l_err = NULL;
    TRACDCOMP( ISTEPS_TRACE::g_trac_isteps_trace, "call_dmi_erepair entry" );


    TRACDCOMP( ISTEPS_TRACE::g_trac_isteps_trace, "dmi_erepair exit" );

    task_end2( l_err );
}

//
//  Wrapper function to call 11.3 : dmi_io_dccal
//
void    call_dmi_io_dccal( void *io_pArgs )
{
    errlHndl_t l_err = NULL;

    TRACDCOMP( ISTEPS_TRACE::g_trac_isteps_trace, "call_dmi_io_dccal entry" );


    TRACDCOMP( ISTEPS_TRACE::g_trac_isteps_trace, "dmi_io_dccal exit" );

    task_end2( l_err );
}


//
//  Wrapper function to call 11.4 : dmi_io_run_training
//
void    call_dmi_io_run_training( void *io_pArgs )
{
    errlHndl_t l_err = NULL;

    TRACDCOMP( ISTEPS_TRACE::g_trac_isteps_trace, "dmi_io_run_training entry" );

    TARGETING::TargetHandleList l_cpuTargetList;
    getAllChips(l_cpuTargetList, TYPE_PROC);

    for ( size_t i = 0; i < l_cpuTargetList.size(); i++ )
    {
        //  make a local copy of the CPU target
        const TARGETING::Target*  l_cpu_target = l_cpuTargetList[i];

        uint8_t l_cpuNum = l_cpu_target->getAttr<ATTR_POSITION>();

        // find all MCS chiplets of the proc
        TARGETING::TargetHandleList l_mcsTargetList;
        getChildChiplets( l_mcsTargetList, l_cpu_target, TYPE_MCS );

        for ( size_t j = 0; j < l_mcsTargetList.size(); j++ )
        {
            //  make a local copy of the MCS target
            const TARGETING::Target*  l_mcs_target = l_mcsTargetList[j];
            uint8_t l_mcsNum    =   l_mcs_target->getAttr<ATTR_CHIP_UNIT>();

            //  find all the Centaurs that are associated with this MCS
            TARGETING::TargetHandleList l_memTargetList;
            getAffinityChips(l_memTargetList, l_mcs_target, TYPE_MEMBUF);

            for ( size_t k = 0; k < l_memTargetList.size(); k++ )
            {
                //  make a local copy of the MEMBUF target
                const TARGETING::Target*  l_mem_target = l_memTargetList[k];

                //  struct containing custom parameters that is fed to HWP
                //  call the HWP with each target   ( if parallel, spin off a task )
                const fapi::Target l_fapi_master_target(
                        TARGET_TYPE_MCS_CHIPLET,
                        reinterpret_cast<void *>
                ( const_cast<TARGETING::Target*>(l_mcs_target) )
                );
                const fapi::Target l_fapi_slave_target(
                        TARGET_TYPE_MEMBUF_CHIP,
                        reinterpret_cast<void *>
                (const_cast<TARGETING::Target*>(l_mem_target))
                );

                TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
                        "===== Call dmi_io_run_training HWP( cpu 0x%x, mcs 0x%x, mem 0x%x ) : ",
                        l_cpuNum,
                        l_mcsNum,
                        k );

                EntityPath l_path;
                l_path = l_cpu_target->getAttr<ATTR_PHYS_PATH>();
                l_path.dump();
                l_path  =   l_mcs_target->getAttr<ATTR_PHYS_PATH>();
                l_path.dump();
                l_path  =   l_mem_target->getAttr<ATTR_PHYS_PATH>();
                l_path.dump();
                TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace, "===== " );
                FAPI_INVOKE_HWP(l_err, dmi_io_run_training,
                                l_fapi_master_target, l_fapi_slave_target);

                if (l_err)
                {
                    TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
                            "ERROR 0x%.8X :  dmi_io_run_training HWP"
                            "( cpu 0x%x, mcs 0x%x, mem 0x%x ) ",
                            l_err->reasonCode(),
                            l_cpuNum,
                            l_mcsNum,
                            k );
                    break; // Break out mem target loop
                }
                else
                {
                    TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
                            "SUCCESS :  dmi_io_run_training HWP"
                            "( cpu 0x%x, mcs 0x%x, mem 0x%x ) ",
                            l_cpuNum,
                            l_mcsNum,
                            k );
                }

            }  //end for l_mem_target

            if (l_err)
            {
                break; // Break out l_mcs_target
            }

        }   // end for l_mcs_target

        if (l_err)
        {
            break; // Break out l_cpu_target
        }

    }   // end for l_cpu_target


    TRACDCOMP( ISTEPS_TRACE::g_trac_isteps_trace, "call_io_run_training exit" );

    task_end2( l_err );
}

//
//  Wrapper function to call 11.5 : proc_cen_framelock
//
void    call_proc_cen_framelock( void *io_pArgs )
{
    errlHndl_t l_err = NULL;
    proc_cen_framelock_args     l_args;

    TRACDCOMP( ISTEPS_TRACE::g_trac_isteps_trace, "call_proc_cen_framework entry" );

    //  get the mcs chiplets
    TARGETING::TargetHandleList l_mcsTargetList;
    getAllChiplets(l_mcsTargetList, TYPE_MCS);

    for ( size_t i = 0; i < l_mcsTargetList.size() ; ++i  )
    {
        //  make a local copy of the MCS target
        const TARGETING::Target*  l_mcs_target = l_mcsTargetList[i];

        //  find all the Centaurs that are associated with this MCS
        TARGETING::TargetHandleList l_memTargetList;
        getAffinityChips(l_memTargetList, l_mcs_target, TYPE_MEMBUF);

        for ( uint8_t k = 0, l_memNum = 0; k < l_memTargetList.size();
                                                             k++, l_memNum++ )
        {
            //  make a local copy of the MEMBUF target
            const TARGETING::Target*  l_mem_target = l_memTargetList[k];

            // fill out the args struct.
            l_args.in_error_state       =   false;
            l_args.channel_init_timeout =   CHANNEL_INIT_TIMEOUT_NO_TIMEOUT;
            l_args.frtl_auto_not_manual =   true;
            l_args.frtl_manual_pu       =   0;
            l_args.frtl_manual_mem      =   0;

            fapi::Target l_fapiMcsTarget(
                    TARGET_TYPE_MCS_CHIPLET,
                    reinterpret_cast<void *>
                      ( const_cast<TARGETING::Target*>(l_mcs_target) )
                        );
            fapi::Target l_fapiMemTarget(
                    TARGET_TYPE_MEMBUF_CHIP,
                    reinterpret_cast<void *>
                        (const_cast<TARGETING::Target*>(l_mem_target))
                    );

            EntityPath l_path;
            l_path  =   l_mcs_target->getAttr<ATTR_PHYS_PATH>();
            l_path.dump();
            l_path  =   l_mem_target->getAttr<ATTR_PHYS_PATH>();
            l_path.dump();

            FAPI_INVOKE_HWP( l_err,
                             proc_cen_framelock,
                             l_fapiMcsTarget,
                             l_fapiMemTarget,
                             l_args  );
            if ( l_err )
            {
                TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
                 "ERROR 0x%.8X : proc_cen_framelock HWP( mem %d )",
                l_err->reasonCode(), l_memNum );
                break; // break out of mem num loop
            }
            else
            {
                TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
                        "SUCCESS :  proc_cen_framelock HWP( mem %d ) ",
                        l_memNum );
            }

        }   // end mem

        if (l_err)
        {
            break; // break out of mcs loop
        }

    }   // end mcs

    TRACDCOMP( ISTEPS_TRACE::g_trac_isteps_trace, "call_proc_cen_framework exit" );

    task_end2( l_err );
}

//
//  Wrapper function to call 11.6 : host_startPRD_dmi
//
void    call_host_startPRD_dmi( void *io_pArgs )
{
    errlHndl_t l_err = NULL;
    TRACDCOMP( ISTEPS_TRACE::g_trac_isteps_trace, "call_host_startPRD_dmi entry" );


    TRACDCOMP( ISTEPS_TRACE::g_trac_isteps_trace, "host_startPRD_dmi exit" );

    task_end2( l_err );
}

//
//  Wrapper function to call 11.7 : host_attnlisten_cen
//
void    call_host_attnlisten_cen( void *io_pArgs )
{

    errlHndl_t l_err = NULL;

    TRACDCOMP( ISTEPS_TRACE::g_trac_isteps_trace, "call_host_attnlisten_cen entry" );


    TRACDCOMP( ISTEPS_TRACE::g_trac_isteps_trace, "<host_attnlisten_cen exit" );

    task_end2( l_err );
}

//
//  Wrapper function to call 11.8 : cen_set_inband_addr
//
void    call_cen_set_inband_addr( void *io_pArgs )
{
    errlHndl_t l_err = NULL;

    TRACDCOMP( ISTEPS_TRACE::g_trac_isteps_trace, "call_cen_set_inband_addr entry" );


    TRACDCOMP( ISTEPS_TRACE::g_trac_isteps_trace, "cen_set_inband_addr exit" );

    task_end2( l_err );
}


};   // end namespace

OpenPOWER on IntegriCloud