summaryrefslogtreecommitdiffstats
path: root/src/import/generic/memory/lib/data_engine/p9a/p9a_data_init_traits.H
blob: 9122c12da5dcf0ef7724a2e926150278a1001f9f (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
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/import/generic/memory/lib/data_engine/p9a/p9a_data_init_traits.H $ */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2018,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                                                     */
///
/// @file p9a_data_init_traits.H
/// @brief Trait class definitions for Axone pre_data_init
///
// *HWP HWP Owner: Andre Marin <aamarin@us.ibm.com>
// *HWP FW Owner: Stephen Glancy <sglancy@us.ibm.com>
// *HWP Team: Memory
// *HWP Level: 2
// *HWP Consumed by: HB:CI

#ifndef _MSS_P9A_PRE_DATA_INIT_TRAITS_H_
#define _MSS_P9A_PRE_DATA_INIT_TRAITS_H_

#include <fapi2.H>
#include <generic/memory/lib/data_engine/data_engine_traits_def.H>
#include <generic/memory/lib/data_engine/data_engine_utils.H>
#include <generic/memory/lib/spd/spd_facade.H>
#include <generic/memory/lib/mss_generic_attribute_getters.H>
#include <generic/memory/lib/mss_generic_attribute_setters.H>

namespace mss
{

///
/// @brief Traits for pre_data_engine
/// @class attrEngineTraits
/// @note pre_data_init_fields, DIMM_TYPE specialization
///
template<>
struct attrEngineTraits<pre_data_init_fields, DIMM_TYPE>
{
    using attr_type = fapi2::ATTR_MEM_EFF_DIMM_TYPE_Type;
    using attr_integral_type = std::remove_all_extents<attr_type>::type;
    static constexpr fapi2::TargetType TARGET_TYPE = fapi2::ATTR_MEM_EFF_DIMM_TYPE_TargetType;
    static constexpr generic_ffdc_codes FFDC_CODE = SET_DIMM_TYPE;

    ///
    /// @brief attribute getter
    /// @param[in] i_target the attr target
    /// @param[out] o_setting array to populate
    /// @return FAPI2_RC_SUCCESS iff okay
    ///
    static fapi2::ReturnCode get_attr(const fapi2::Target<TARGET_TYPE>& i_target,
                                      attr_type& o_setting)
    {
        return mss::attr::get_dimm_type(i_target, o_setting);
    }

    ///
    /// @brief attribute setter
    /// @param[in] i_target the attr target
    /// @param[in] i_setting array to set
    /// @return FAPI2_RC_SUCCESS iff okay
    ///
    static fapi2::ReturnCode set_attr(const fapi2::Target<TARGET_TYPE>& i_target,
                                      attr_type& i_setting)
    {
        return mss::attr::set_dimm_type(i_target, i_setting);
    }

    ///
    /// @brief Computes setting for attribute
    /// @param[in] i_spd_data SPD data
    /// @param[out] o_setting value we want to set attr with
    /// @return FAPI2_RC_SUCCESS iff okay
    ///
    static fapi2::ReturnCode get_value_to_set(const spd::facade& i_spd_data,
            attr_integral_type& o_setting)
    {
        // =========================================================
        // DDR4 SPD Document Release 4
        // Byte 3 (0x003): Key Byte / Module Type
        // =========================================================
        static const std::vector< std::pair<uint8_t, uint8_t> > BASE_MODULE_TYPE_MAP =
        {
            //{key byte, dimm type}
            {1, fapi2::ENUM_ATTR_MEM_EFF_DIMM_TYPE_RDIMM},
            {2, fapi2::ENUM_ATTR_MEM_EFF_DIMM_TYPE_UDIMM},
            {10, fapi2::ENUM_ATTR_MEM_EFF_DIMM_TYPE_DDIMM},
            // All others reserved or not supported
        };

        const auto l_dimm = i_spd_data.get_dimm_target();

        attr_integral_type l_base_module_type = 0;
        FAPI_TRY( i_spd_data.base_module(l_base_module_type),
                  "%s failed to get base module from SPD", spd::c_str(l_dimm) );

        FAPI_TRY( lookup_table_check(l_dimm, BASE_MODULE_TYPE_MAP, FFDC_CODE, l_base_module_type, o_setting),
                  "%s failed DIMM_TYPE lookup check", spd::c_str(l_dimm) );

    fapi_try_exit:
        return fapi2::current_err;
    }
};

///
/// @brief Traits for pre_data_engine
/// @class attrEngineTraits
/// @note pre_data_init_fields, DRAM_GEN specialization
///
template<>
struct attrEngineTraits<pre_data_init_fields, DRAM_GEN>
{
    using attr_type = fapi2::ATTR_MEM_EFF_DRAM_GEN_Type;
    using attr_integral_type = std::remove_all_extents<attr_type>::type;
    static constexpr fapi2::TargetType TARGET_TYPE = fapi2::ATTR_MEM_EFF_DRAM_GEN_TargetType;
    static constexpr generic_ffdc_codes FFDC_CODE = SET_DRAM_GEN;

    ///
    /// @brief attribute getter
    /// @param[in] i_target the attr target
    /// @param[out] o_setting array to populate
    /// @return FAPI2_RC_SUCCESS iff okay
    ///
    static fapi2::ReturnCode get_attr(const fapi2::Target<TARGET_TYPE>& i_target,
                                      attr_type& o_setting)
    {
        return mss::attr::get_dram_gen(i_target, o_setting);
    }

    ///
    /// @brief attribute setter
    /// @param[in] i_target the attr target
    /// @param[in] i_setting array to set
    /// @return FAPI2_RC_SUCCESS iff okay
    ///
    static fapi2::ReturnCode set_attr(const fapi2::Target<TARGET_TYPE>& i_target,
                                      attr_type& i_setting)
    {
        return mss::attr::set_dram_gen(i_target, i_setting);
    }

    ///
    /// @brief Computes setting for attribute
    /// @param[in] i_spd_data SPD data
    /// @param[out] o_setting value we want to set attr with
    /// @return FAPI2_RC_SUCCESS iff okay
    ///
    static fapi2::ReturnCode get_value_to_set(const spd::facade& i_spd_data,
            attr_integral_type& o_setting)
    {
        // =========================================================
        // DDR4 SPD Document Release 4
        // Byte 2 (0x002): Key Byte / DRAM Device Type
        // =========================================================
        static const std::vector< std::pair<uint8_t, uint8_t> > DRAM_GEN_MAP =
        {
            //{key value, dram gen}
            {0x0C, fapi2::ENUM_ATTR_MEM_EFF_DRAM_GEN_DDR4}
            // Other key bytes reserved or not supported
        };

        const auto l_dimm = i_spd_data.get_dimm_target();

        attr_integral_type l_device_type = 0;
        FAPI_TRY( i_spd_data.device_type(l_device_type),
                  "%s failed to get device type from SPD", spd::c_str(l_dimm) );

        FAPI_TRY( lookup_table_check(l_dimm, DRAM_GEN_MAP, FFDC_CODE, l_device_type, o_setting),
                  "%s failed DRAM_GEN lookup check", spd::c_str(l_dimm) );

    fapi_try_exit:
        return fapi2::current_err;
    }
};

///
/// @brief Traits for pre_data_engine
/// @class attrEngineTraits
/// @note pre_data_init_fields, HOST_TO_DDR_SPEED_RATIO specialization
///
template<>
struct attrEngineTraits<pre_data_init_fields, HOST_TO_DDR_SPEED_RATIO>
{
    using attr_type = fapi2::ATTR_MEM_EFF_HOST_TO_DDR_SPEED_RATIO_Type;
    using attr_integral_type = std::remove_all_extents<attr_type>::type;
    static constexpr fapi2::TargetType TARGET_TYPE = fapi2::ATTR_MEM_EFF_HOST_TO_DDR_SPEED_RATIO_TargetType;
    static constexpr generic_ffdc_codes FFDC_CODE = SET_HOST_TO_DDR_SPEED_RATIO;

    ///
    /// @brief attribute getter
    /// @param[in] i_target the attr target
    /// @param[out] o_setting array to populate
    /// @return FAPI2_RC_SUCCESS iff okay
    ///
    static fapi2::ReturnCode get_attr(const fapi2::Target<TARGET_TYPE>& i_target,
                                      attr_type& o_setting)
    {
        return mss::attr::get_host_to_ddr_speed_ratio(i_target, o_setting);
    }

    ///
    /// @brief attribute setter
    /// @param[in] i_target the attr target
    /// @param[in] i_setting array to set
    /// @return FAPI2_RC_SUCCESS iff okay
    ///
    static fapi2::ReturnCode set_attr(const fapi2::Target<TARGET_TYPE>& i_target,
                                      attr_type& i_setting)
    {
        return mss::attr::set_host_to_ddr_speed_ratio(i_target, i_setting);
    }

    ///
    /// @brief Computes setting for attribute
    /// @param[in] i_spd_data SPD data
    /// @param[out] o_setting value we want to set attr with
    /// @return FAPI2_RC_SUCCESS iff okay
    ///
    static fapi2::ReturnCode get_value_to_set(const spd::facade& i_spd_data,
            attr_integral_type& o_setting)
    {
        // =========================================================
        // DDR4 SPD Document Release 4
        // Byte 220 (0x0DC): Host Interface Speed to DDR Interface Speed Ratio
        // =========================================================
        static const std::vector< std::pair<uint8_t, uint8_t> > HOST_TO_DDR_SPEED_RATIO_MAP =
        {
            // {key byte, speed ratio}
            {0, fapi2::ENUM_ATTR_MEM_EFF_HOST_TO_DDR_SPEED_RATIO_1_TO_1},
            {1, fapi2::ENUM_ATTR_MEM_EFF_HOST_TO_DDR_SPEED_RATIO_2_TO_1},
            {2, fapi2::ENUM_ATTR_MEM_EFF_HOST_TO_DDR_SPEED_RATIO_4_TO_1},
            {3, fapi2::ENUM_ATTR_MEM_EFF_HOST_TO_DDR_SPEED_RATIO_8_TO_1},
            {4, fapi2::ENUM_ATTR_MEM_EFF_HOST_TO_DDR_SPEED_RATIO_16_TO_1},
            {5, fapi2::ENUM_ATTR_MEM_EFF_HOST_TO_DDR_SPEED_RATIO_32_TO_1},
            {6, fapi2::ENUM_ATTR_MEM_EFF_HOST_TO_DDR_SPEED_RATIO_64_TO_1},
            {7, fapi2::ENUM_ATTR_MEM_EFF_HOST_TO_DDR_SPEED_RATIO_128_TO_1},
            // All others reserved or not supported
        };

        const auto l_dimm = i_spd_data.get_dimm_target();

        attr_integral_type l_value = 0;
        FAPI_TRY( i_spd_data.host_to_ddr_speed_ratio(l_value),
                  "%s failed to get host to DDR speed ratio from SPD", spd::c_str(l_dimm) );

        FAPI_TRY( lookup_table_check(l_dimm, HOST_TO_DDR_SPEED_RATIO_MAP, FFDC_CODE, l_value, o_setting),
                  "%s failed HOST_TO_DDR_SPEED_RATIO lookup check", spd::c_str(l_dimm) );

    fapi_try_exit:
        return fapi2::current_err;
    }
};

///
/// @brief Traits for pre_data_engine
/// @class attrEngineTraits
/// @note pre_data_init_fields, HYBRID specialization
///
template<>
struct attrEngineTraits<pre_data_init_fields, HYBRID>
{
    using attr_type = fapi2::ATTR_MEM_EFF_HYBRID_Type;
    using attr_integral_type = std::remove_all_extents<attr_type>::type;
    static constexpr fapi2::TargetType TARGET_TYPE = fapi2::ATTR_MEM_EFF_HYBRID_TargetType;
    static constexpr generic_ffdc_codes FFDC_CODE = SET_HYBRID;

    ///
    /// @brief attribute getter
    /// @param[in] i_target the attr target
    /// @param[out] o_setting array to populate
    /// @return FAPI2_RC_SUCCESS iff okay
    ///
    static fapi2::ReturnCode get_attr(const fapi2::Target<TARGET_TYPE>& i_target,
                                      attr_type& o_setting)
    {
        return mss::attr::get_hybrid(i_target, o_setting);
    }

    ///
    /// @brief attribute setter
    /// @param[in] i_target the attr target
    /// @param[in] i_setting array to set
    /// @return FAPI2_RC_SUCCESS iff okay
    ///
    static fapi2::ReturnCode set_attr(const fapi2::Target<TARGET_TYPE>& i_target,
                                      attr_type& i_setting)
    {
        return mss::attr::set_hybrid(i_target, i_setting);
    }

    ///
    /// @brief Computes setting for attribute
    /// @param[in] i_spd_data SPD data
    /// @param[out] o_setting value we want to set attr with
    /// @return FAPI2_RC_SUCCESS iff okay
    ///
    static fapi2::ReturnCode get_value_to_set(const spd::facade& i_spd_data,
            attr_integral_type& o_setting)
    {
        // =========================================================
        // DDR4 SPD Document Release 4
        // Byte 3 (0x003): Key Byte / Module Type - Hybrid
        // =========================================================
        static const std::vector< std::pair<uint8_t, uint8_t> > HYBRID_MAP =
        {
            //{key byte, dimm type}
            {0, fapi2::ENUM_ATTR_MEM_EFF_HYBRID_NOT_HYBRID},
            {1, fapi2::ENUM_ATTR_MEM_EFF_HYBRID_IS_HYBRID},
            // All others reserved or not supported
        };

        const auto l_dimm = i_spd_data.get_dimm_target();

        attr_integral_type l_spd_hybrid_type = 0;
        FAPI_TRY(i_spd_data.hybrid(l_spd_hybrid_type),
                 "%s failed to get hybrid from SPD", spd::c_str(l_dimm) );

        FAPI_TRY(lookup_table_check(l_dimm, HYBRID_MAP, FFDC_CODE, l_spd_hybrid_type, o_setting),
                 "%s failed HYBRID lookup check", spd::c_str(l_dimm) );

    fapi_try_exit:
        return fapi2::current_err;
    }
};

///
/// @brief Traits for pre_data_engine
/// @class attrEngineTraits
/// @note pre_data_init_fields, HYBRID_MEDIA specialization
///
template<>
struct attrEngineTraits<pre_data_init_fields, HYBRID_MEDIA>
{
    using attr_type = fapi2::ATTR_MEM_EFF_HYBRID_MEMORY_TYPE_Type;
    using attr_integral_type = std::remove_all_extents<attr_type>::type;
    static constexpr fapi2::TargetType TARGET_TYPE = fapi2::ATTR_MEM_EFF_HYBRID_MEMORY_TYPE_TargetType;
    static constexpr generic_ffdc_codes FFDC_CODE = SET_HYBRID_MEDIA;

    ///
    /// @brief attribute getter
    /// @param[in] i_target the attr target
    /// @param[out] o_setting array to populate
    /// @return FAPI2_RC_SUCCESS iff okay
    ///
    static fapi2::ReturnCode get_attr(const fapi2::Target<TARGET_TYPE>& i_target,
                                      attr_type& o_setting)
    {
        return mss::attr::get_hybrid_memory_type(i_target, o_setting);
    }

    ///
    /// @brief attribute setter
    /// @param[in] i_target the attr target
    /// @param[in] i_setting array to set
    /// @return FAPI2_RC_SUCCESS iff okay
    ///
    static fapi2::ReturnCode set_attr(const fapi2::Target<TARGET_TYPE>& i_target,
                                      attr_type& i_setting)
    {
        return mss::attr::set_hybrid_memory_type(i_target, i_setting);
    }

    ///
    /// @brief Computes setting for attribute
    /// @param[in] i_spd_data SPD data
    /// @param[out] o_setting value we want to set attr with
    /// @return FAPI2_RC_SUCCESS iff okay
    ///
    static fapi2::ReturnCode get_value_to_set(const spd::facade& i_spd_data,
            attr_integral_type& o_setting)
    {
        // =========================================================
        // DDR4 SPD Document Release 4
        // Byte 3 (0x003): Key Byte / Module Type - Hybrid
        // =========================================================
        static const std::vector< std::pair<uint8_t, uint8_t> > HYBRID_MEMORY_TYPE_MAP =
        {

            //{key byte, dimm type}
            {0, fapi2::ENUM_ATTR_MEM_EFF_HYBRID_MEMORY_TYPE_NONE},
            {1, fapi2::ENUM_ATTR_MEM_EFF_HYBRID_MEMORY_TYPE_NVDIMM},
            // All others reserved or not supported
        };
        const auto l_dimm = i_spd_data.get_dimm_target();
        attr_integral_type l_spd_hybrid_media = 0;

        FAPI_TRY( i_spd_data.hybrid_media(l_spd_hybrid_media),
                  "%s failed to get hybrid media from SPD", spd::c_str(l_dimm) );

        FAPI_TRY( lookup_table_check(l_dimm, HYBRID_MEMORY_TYPE_MAP, FFDC_CODE, l_spd_hybrid_media, o_setting),
                  "%s failed HYBRID_MEMORY_TYPE lookup check", spd::c_str(l_dimm) );

    fapi_try_exit:
        return fapi2::current_err;
    }
};

///
/// @brief Traits for pre_data_engine
/// @class attrEngineTraits
/// @note pre_data_init_fields, MRANKS specialization
///
template<>
struct attrEngineTraits<pre_data_init_fields, MRANKS>
{
    using attr_type = fapi2::ATTR_MEM_EFF_NUM_MASTER_RANKS_PER_DIMM_Type;
    using attr_integral_type = std::remove_all_extents<attr_type>::type;
    static constexpr fapi2::TargetType TARGET_TYPE = fapi2::ATTR_MEM_EFF_NUM_MASTER_RANKS_PER_DIMM_TargetType;
    static constexpr generic_ffdc_codes FFDC_CODE = SET_MRANKS;

    ///
    /// @brief attribute getter
    /// @param[in] i_target the attribute associated target
    /// @param[out] o_setting array to populate
    /// @return FAPI2_RC_SUCCESS iff okay
    ///
    static fapi2::ReturnCode get_attr(const fapi2::Target<TARGET_TYPE>& i_target,
                                      attr_type& o_setting)
    {
        return mss::attr::get_num_master_ranks_per_dimm(i_target, o_setting);
    }

    ///
    /// @brief attribute setter
    /// @param[in] i_target the attribute associated target
    /// @param[in] i_setting array to set
    /// @return FAPI2_RC_SUCCESS iff okay
    ///
    static fapi2::ReturnCode set_attr(const fapi2::Target<TARGET_TYPE>& i_target,
                                      attr_type& i_setting)
    {
        return mss::attr::set_num_master_ranks_per_dimm(i_target, i_setting);
    }

    ///
    /// @brief Computes setting for attribute
    /// @param[in] i_spd_data SPD data
    /// @param[out] o_setting value we want to set attr with
    /// @return FAPI2_RC_SUCCESS iff okay
    ///
    static fapi2::ReturnCode get_value_to_set(const spd::facade& i_spd_data,
            attr_integral_type& o_setting)
    {
        // =========================================================
        // DDR4 SPD Document Release 4
        // Byte 12 (0x00C): Module Organization
        // =========================================================
        static const std::vector< std::pair<uint8_t, uint8_t> > NUM_PACKAGE_RANKS_MAP =
        {
            // {key byte, num of package ranks per DIMM (package ranks)}
            {0, fapi2::ENUM_ATTR_MEM_EFF_NUM_MASTER_RANKS_PER_DIMM_1R},
            {1, fapi2::ENUM_ATTR_MEM_EFF_NUM_MASTER_RANKS_PER_DIMM_2R},
            {3, fapi2::ENUM_ATTR_MEM_EFF_NUM_MASTER_RANKS_PER_DIMM_4R},
        };

        const auto l_dimm = i_spd_data.get_dimm_target();

        attr_integral_type l_master_ranks_spd = 0;
        FAPI_TRY( i_spd_data.num_package_ranks_per_dimm(l_master_ranks_spd),
                  "%s failed to get number of package ranks from SPD", spd::c_str(l_dimm) );

        FAPI_TRY( lookup_table_check(l_dimm, NUM_PACKAGE_RANKS_MAP, FFDC_CODE, l_master_ranks_spd, o_setting),
                  "%s failed MASTER_RANKS lookup check", spd::c_str(l_dimm) );

    fapi_try_exit:
        return fapi2::current_err;
    }
};

///
/// @brief Traits for pre_data_engine
/// @class attrEngineTraits
/// @note DIMM_RANKS_CNFG specialization
///
template<>
struct attrEngineTraits<pre_data_init_fields, DIMM_RANKS_CNFG>
{

    using attr_type = fapi2::ATTR_MEM_EFF_DIMM_RANKS_CONFIGED_Type;
    using attr_integral_type = std::remove_all_extents<attr_type>::type;
    static const fapi2::TargetType TARGET_TYPE = fapi2::ATTR_MEM_EFF_DIMM_RANKS_CONFIGED_TargetType;
    static constexpr generic_ffdc_codes FFDC_CODE = SET_DIMM_RANKS_CNFG;

    ///
    /// @brief attribute getter
    /// @param[in] i_target the fapi2 target
    /// @param[out] o_setting array to populate
    /// @return FAPI2_RC_SUCCESS iff okay
    ///
    static inline fapi2::ReturnCode get_attr(const fapi2::Target<TARGET_TYPE>& i_target,
            attr_type& o_setting)
    {
        return mss::attr::get_dimm_ranks_configed(i_target, o_setting);
    }

    ///
    /// @brief attribute setter
    /// @param[in] i_target the fapi2 target
    /// @param[in] i_setting array to set
    /// @return FAPI2_RC_SUCCESS iff okay
    ///
    static inline fapi2::ReturnCode set_attr(const fapi2::Target<TARGET_TYPE>& i_target,
            attr_type& i_setting)
    {
        return mss::attr::set_dimm_ranks_configed(i_target, i_setting);
    }

    ///
    /// @brief Computes setting for attribute
    /// @param[in] i_spd_data SPD data
    /// @param[out] o_setting value we want to set attr with
    /// @return FAPI2_RC_SUCCESS iff okay

    static fapi2::ReturnCode get_value_to_set(const spd::facade& i_spd_data,
            attr_integral_type& o_setting)
    {
        // Set configed ranks. Set the bit representing the master rank configured (0 being left most.) So,
        // a 4R DIMM would be 0b11110000 (0xF0). This is used by PRD.
        fapi2::buffer<uint8_t> l_ranks_configed;

        // Make sure the number of master ranks is setup
        uint8_t l_master_ranks = 0;
        FAPI_TRY( (attrEngineTraits<pre_data_init_fields, MRANKS>::get_value_to_set(i_spd_data, l_master_ranks)) );

        FAPI_TRY( l_ranks_configed.setBit(0, l_master_ranks),
                  "%s. Failed to setBit", spd::c_str(i_spd_data.get_dimm_target()) );

        o_setting = l_ranks_configed;

    fapi_try_exit:
        return fapi2::current_err;
    }
};

}//mss

#endif
OpenPOWER on IntegriCloud