summaryrefslogtreecommitdiffstats
path: root/src/usr/hwpf/hwp/dram_initialization/proc_setup_bars/proc_fab_smp.C
blob: d7844bf36fc413a57f0412243c6cd3d2de169c30 (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/hwpf/hwp/dram_initialization/proc_setup_bars/proc_fab_smp.C $ */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 2012,2014              */
/*                                                                        */
/* 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                                                     */
// $Id: proc_fab_smp.C,v 1.9 2014/01/27 05:22:07 jmcgill Exp $
// $Source: /afs/awd/projects/eclipz/KnowledgeBase/.cvsroot/eclipz/chips/p8/working/procedures/ipl/fapi/proc_fab_smp.C,v $
//------------------------------------------------------------------------------
// *|
// *! (C) Copyright International Business Machines Corp. 2011
// *! All Rights Reserved -- Property of IBM
// *! *** IBM Confidential ***
// *|
// *! TITLE       : proc_fab_smp.C
// *! DESCRIPTION : Common fabric structure defintions/utility functions (FAPI)
// *!
// *! OWNER NAME  : Joe McGill    Email: jmcgill@us.ibm.com
// *!
//------------------------------------------------------------------------------


//------------------------------------------------------------------------------
// Includes
//------------------------------------------------------------------------------
#include <proc_fab_smp.H>

extern "C" {


//------------------------------------------------------------------------------
// Function definitions
//------------------------------------------------------------------------------


//------------------------------------------------------------------------------
// function: utility function to read & return fabric node ID attribute
// parameters: i_target  => pointer to chip/chiplet target
//             o_node_id => node ID value
// returns: FAPI_RC_SUCCESS if attribute read is successful & value is valid,
//          RC_PROC_FAB_SMP_FABRIC_NODE_ID_ATTR_ERR if attribute value is
//              invalid,
//          else FAPI_ATTR_GET return code
//------------------------------------------------------------------------------
fapi::ReturnCode proc_fab_smp_get_node_id_attr(
    const fapi::Target* i_target,
    proc_fab_smp_node_id& o_node_id)
{
    // return code
    fapi::ReturnCode rc;
    // chiplet->chip target conversion
    bool use_parent = false;
    fapi::Target parent_target;
    // temporary attribute storage used to build procedure data structures
    uint8_t node_id_attr;

    // mark function entry
    FAPI_DBG("proc_fab_smp_get_node_id_attr: Start");

    do
    {
        if (i_target->getType() != fapi::TARGET_TYPE_PROC_CHIP)
        {
            use_parent = true;
            // retrieve parent target if input target is a chiplet
            rc = fapiGetParentChip(*i_target,
                                   parent_target);
            if (!rc.ok())
            {
                FAPI_ERR("proc_fab_smp_get_node_id_attr: Error from fapiGetParentChip");
                break;
            }
        }

        // retrieve node ID attribute
        rc = FAPI_ATTR_GET(ATTR_FABRIC_NODE_ID,
                           ((use_parent)?
                            (&parent_target):
                            (i_target)),
                           node_id_attr);
        if (!rc.ok())
        {
            FAPI_ERR("proc_fab_smp_get_node_id_attr: Error querying ATTR_FABRIC_NODE_ID");
            break;
        }

        // print attribute value
        FAPI_DBG("proc_fab_smp_get_node_id_attr: ATTR_FABRIC_NODE_ID = 0x%X",
                 node_id_attr);

        // translate to output value
        switch (node_id_attr)
        {
            case 0:
                o_node_id = FBC_NODE_ID_0;
                break;
            case 1:
                o_node_id = FBC_NODE_ID_1;
                break;
            case 2:
                o_node_id = FBC_NODE_ID_2;
                break;
            case 3:
                o_node_id = FBC_NODE_ID_3;
                break;
            case 4:
                o_node_id = FBC_NODE_ID_4;
                break;
            case 5:
                o_node_id = FBC_NODE_ID_5;
                break;
            case 6:
                o_node_id = FBC_NODE_ID_6;
                break;
            case 7:
                o_node_id = FBC_NODE_ID_7;
                break;
            default:
                FAPI_ERR("proc_fab_smp_get_node_id_attr: Invalid fabric node ID attribute value 0x%02X",
                         node_id_attr);
                const fapi::Target & TARGET = *i_target;
                const uint8_t& ATTR_DATA = node_id_attr;
                FAPI_SET_HWP_ERROR(rc,
                    RC_PROC_FAB_SMP_FABRIC_NODE_ID_ATTR_ERR);
                break;
        }
    } while(0);

    // mark function exit
    FAPI_DBG("proc_fab_smp_get_node_id_attr: End");
    return rc;
}


//------------------------------------------------------------------------------
// function: utility function to read & return fabric chip ID attribute
// parameters: i_target  => pointer to chip/chiplet target
//             o_chip_id => chip ID value
// returns: FAPI_RC_SUCCESS if attribute read is successful & value is valid,
//          RC_PROC_FAB_SMP_FABRIC_CHIP_ID_ATTR_ERR if attribute value is
//              invalid,
//          else FAPI_ATTR_GET return code
//------------------------------------------------------------------------------
fapi::ReturnCode proc_fab_smp_get_chip_id_attr(
    const fapi::Target* i_target,
    proc_fab_smp_chip_id& o_chip_id)
{
    // return code
    fapi::ReturnCode rc;
    // chiplet->chip target conversion
    bool use_parent = false;
    fapi::Target parent_target;
    // temporary attribute storage used to build procedure data structures
    uint8_t chip_id_attr;

    // mark function entry
    FAPI_DBG("proc_fab_smp_get_chip_id_attr: Start");

    do
    {
        if (i_target->getType() != fapi::TARGET_TYPE_PROC_CHIP)
        {
            use_parent = true;
            // retrieve parent target if input target is a chiplet
            rc = fapiGetParentChip(*i_target,
                                   parent_target);
            if (!rc.ok())
            {
                FAPI_ERR("proc_fab_smp_get_chip_id_attr: Error from fapiGetParentChip");
                break;
            }
        }

        // retrieve chip ID attribute
        rc = FAPI_ATTR_GET(ATTR_FABRIC_CHIP_ID,
                           ((use_parent)?
                            (&parent_target):
                            (i_target)),
                           chip_id_attr);
        if (!rc.ok())
        {
            FAPI_ERR("proc_fab_smp_get_chip_id_attr: Error querying ATTR_FABRIC_CHIP_ID");
            break;
        }

        // print attribute value
        FAPI_DBG("proc_fab_smp_get_chip_id_attr: ATTR_FABRIC_CHIP_ID = 0x%X",
                 chip_id_attr);

        // translate to output value
        switch (chip_id_attr)
        {
            case 0:
                o_chip_id = FBC_CHIP_ID_0;
                break;
            case 1:
                o_chip_id = FBC_CHIP_ID_1;
                break;
            case 2:
                o_chip_id = FBC_CHIP_ID_2;
                break;
            case 3:
                o_chip_id = FBC_CHIP_ID_3;
                break;
            case 4:
                o_chip_id = FBC_CHIP_ID_4;
                break;
            case 5:
                o_chip_id = FBC_CHIP_ID_5;
                break;
            case 6:
                o_chip_id = FBC_CHIP_ID_6;
                break;
            case 7:
                o_chip_id = FBC_CHIP_ID_7;
                break;
            default:
                FAPI_ERR("proc_fab_smp_get_chip_id_attr: Invalid fabric chip ID attribute value 0x%02X",
                         chip_id_attr);
                const fapi::Target & TARGET = *i_target;
                const uint8_t& ATTR_DATA = chip_id_attr;
                FAPI_SET_HWP_ERROR(rc,
                    RC_PROC_FAB_SMP_FABRIC_CHIP_ID_ATTR_ERR);
                break;
        }
    } while(0);

    // mark function exit
    FAPI_DBG("proc_fab_smp_get_chip_id_attr: End");
    return rc;
}


//------------------------------------------------------------------------------
// function: utility function to read & return PCIe/DSMP mux attribute values
// parameters: i_target          => pointer to chip target
//             o_pcie_not_f_link => vector of boolean values representing state
//                                  of PCIe/DSMP mux settings (one value per
//                                  foreign link, true=PCIe function, false=
//                                  DSMP function)
// returns: FAPI_RC_SUCCESS if attribute read is successful & value is valid,
//          RC_PROC_FAB_SMP_PCIE_NOT_F_LINK_ATTR_ERR if attribute value is
//              invalid,
//          else FAPI_ATTR_GET return code
//------------------------------------------------------------------------------
fapi::ReturnCode proc_fab_smp_get_pcie_dsmp_mux_attrs(
    const fapi::Target* i_target,
    bool o_pcie_not_f_link[PROC_FAB_SMP_NUM_F_LINKS])
{
    // return code
    fapi::ReturnCode rc;
    // temporary attribute storage used to build procedure data structures
    uint8_t pcie_not_f_link_attr[PROC_FAB_SMP_NUM_F_LINKS];

    // mark function entry
    FAPI_DBG("proc_fab_smp_get_pcie_dsmp_mux_attrs: Start");

    do
    {
        // retrieve PCIe/DSMP mux attributes
        rc = FAPI_ATTR_GET(ATTR_PROC_PCIE_NOT_F_LINK,
                           i_target,
                           pcie_not_f_link_attr);
        if (!rc.ok())
        {
            FAPI_ERR("proc_fab_smp_get_pcie_dsmp_mux_attrs: Error querying ATTR_PROC_PCIE_NOT_F_LINK");
            break;
        }

        // loop over all links
        for (uint8_t l = 0;
             l < PROC_FAB_SMP_NUM_F_LINKS;
             l++)
        {
            // print attribute value
            FAPI_DBG("proc_fab_smp_get_pcie_dsmp_mux_attrs: ATTR_PROC_PCIE_NOT_F_LINK[%d] = 0x%X",
                     l, pcie_not_f_link_attr[l]);

            // validate attribute value
            switch (pcie_not_f_link_attr[l])
            {
                case 0:
                    o_pcie_not_f_link[l] = false;
                    break;
                case 1:
                    o_pcie_not_f_link[l] = true;
                    break;
                default:
                    FAPI_ERR("proc_fab_smp_get_pcie_dsmp_mux_attrs: Invalid PCIe/DSMP mux attribute value 0x%02X",
                             pcie_not_f_link_attr[l]);
                    const fapi::Target & TARGET = *i_target;
                    const uint8_t& ATTR_DATA = pcie_not_f_link_attr[l];
                    FAPI_SET_HWP_ERROR(rc,
                        RC_PROC_FAB_SMP_PCIE_NOT_F_LINK_ATTR_ERR);
                    break;
            }
            if (!rc.ok())
            {
                break;
            }
        }
    } while(0);

    // mark function exit
    FAPI_DBG("proc_fab_smp_get_pcie_dsmp_mux_attrs: End");
    return rc;
}



} // extern "C"
OpenPOWER on IntegriCloud