Skip to content

Commit

Permalink
Add attribute ATTR_EFF_RANK_GROUP_OVERRIDE
Browse files Browse the repository at this point in the history
Change-Id: Ia0d9009f88ef65dac7469ac23eb41083444375f7
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/36508
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Tested-by: Hostboot CI <hostboot-ci+hostboot@us.ibm.com>
Reviewed-by: STEPHEN GLANCY <sglancy@us.ibm.com>
Reviewed-by: Brian R. Silver <bsilver@us.ibm.com>
Reviewed-by: JACOB L. HARVEY <jlharvey@us.ibm.com>
Reviewed-by: Jennifer A. Stofer <stofer@us.ibm.com>
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/36511
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
  • Loading branch information
stermole authored and dcrowell77 committed Feb 27, 2017
1 parent 9375e99 commit e5b630d
Show file tree
Hide file tree
Showing 6 changed files with 207 additions and 14 deletions.
77 changes: 63 additions & 14 deletions src/import/chips/p9/procedures/hwp/memory/lib/dimm/rank.C
Expand Up @@ -246,7 +246,7 @@ fapi2::ReturnCode primary_ranks( const fapi2::Target<TARGET_TYPE_MCA>& i_target,
// Get the count of rank pairs for both DIMM on the port
std::vector<uint8_t> l_rank_count(MAX_DIMM_PER_PORT, 0);

for (const auto d : mss::find_targets<fapi2::TARGET_TYPE_DIMM>(i_target))
for (const auto& d : mss::find_targets<fapi2::TARGET_TYPE_DIMM>(i_target))
{
FAPI_TRY( mss::eff_num_master_ranks_per_dimm(d, l_rank_count[mss::index(d)]) );
}
Expand Down Expand Up @@ -328,7 +328,7 @@ fapi2::ReturnCode ranks( const fapi2::Target<TARGET_TYPE_MCA>& i_target, std::ve
std::vector< uint64_t > l_ranks;
o_ranks.clear();

for (const auto d : mss::find_targets<fapi2::TARGET_TYPE_DIMM>(i_target))
for (const auto& d : mss::find_targets<fapi2::TARGET_TYPE_DIMM>(i_target))
{
FAPI_TRY( ranks(d, l_ranks) );
o_ranks.insert(o_ranks.end(), l_ranks.begin(), l_ranks.end());
Expand All @@ -353,15 +353,25 @@ template<>
fapi2::ReturnCode get_rank_pair_assignments(const fapi2::Target<TARGET_TYPE_MCA>& i_target,
std::pair<uint64_t, uint64_t>& o_registers)
{
// Get the count of rank pairs for all DIMM on the port
// TODO RTC:160869 add enum for rank pair 0 when it gets created
typedef rankPairTraits<fapi2::TARGET_TYPE_MCA, 0> RPT;

std::vector<uint8_t> l_rank_count(MAX_DIMM_PER_PORT, 0);
uint16_t l_regs[RPT::NUM_RANK_PAIR_REGS] = {0};

for (const auto d : mss::find_targets<fapi2::TARGET_TYPE_DIMM>(i_target))
for (const auto& d : mss::find_targets<fapi2::TARGET_TYPE_DIMM>(i_target))
{
FAPI_TRY( mss::eff_num_master_ranks_per_dimm(d, l_rank_count[mss::index(d)]) );
}

o_registers = rank_pair_assignments[l_rank_count[1]][l_rank_count[0]];
// Get the override attribute setting
FAPI_TRY( mss::eff_rank_group_override(i_target, l_regs) );

// If the override attribute is zero, use the default assignments that correspond to the rank count.
// Need only to check the first array entry since we need a valid primary rank in RP0 due to plug rules.
o_registers = (l_regs[0] == 0) ?
rank_pair_assignments[l_rank_count[1]][l_rank_count[0]] :
std::make_pair(static_cast<uint64_t>(l_regs[0]), static_cast<uint64_t>(l_regs[1]));

FAPI_DBG("rank pair assignments for %s. [%d,%d] (0x%08llx, 0x%08llx)",
mss::c_str(i_target), l_rank_count[1], l_rank_count[0], o_registers.first, o_registers.second);
Expand Down Expand Up @@ -479,30 +489,69 @@ fapi_try_exit:
template<>
fapi2::ReturnCode get_rank_pairs(const fapi2::Target<TARGET_TYPE_MCA>& i_target, std::vector<uint64_t>& o_pairs)
{
// TODO RTC:160869 add enum for rank pair 0 when it gets created
typedef rankPairTraits<fapi2::TARGET_TYPE_MCA, 0> RPT;

uint64_t l_index = 0;
std::vector<uint64_t> l_prs;
uint16_t l_regs[RPT::NUM_RANK_PAIR_REGS] = {0};

o_pairs.clear();

// Get the count of rank pairs for both DIMM on the port
std::vector<uint8_t> l_rank_count(MAX_DIMM_PER_PORT, 0);

for (const auto d : mss::find_targets<fapi2::TARGET_TYPE_DIMM>(i_target))
for (const auto& d : mss::find_targets<fapi2::TARGET_TYPE_DIMM>(i_target))
{
FAPI_TRY( mss::eff_num_master_ranks_per_dimm(d, l_rank_count[mss::index(d)]) );
}

// Walk through rank pair table and skip empty pairs
o_pairs.clear();
l_prs = primary_rank_pairs[l_rank_count[1]][l_rank_count[0]];
// Get the override attribute setting
FAPI_TRY( mss::eff_rank_group_override(i_target, l_regs) );

// If the override attribute is zero, use the default assignments that correspond to the rank count
if (l_regs[0] == 0)
{
l_prs = primary_rank_pairs[l_rank_count[1]][l_rank_count[0]];

// Walk through rank pair table and skip empty pairs
// Can't use for (auto rp : l_prs) as rp is unused. BRS
for (auto rp_iter = l_prs.begin(); rp_iter != l_prs.end(); ++rp_iter)
{
if (*rp_iter != NO_RANK)
{
o_pairs.push_back(l_index);
}

// Can't use for (auto rp : l_prs) as rp is unused. BRS
for (auto rp_iter = l_prs.begin(); rp_iter != l_prs.end(); ++rp_iter)
l_index += 1;
}
}
// Else we have to derive the assignments from the override
else
{
if (*rp_iter != NO_RANK)
// Check RP0
if (fapi2::buffer<uint64_t>(l_regs[0]).getBit<EVEN_PRIMARY_VALID>())
{
o_pairs.push_back(0);
}

// Check RP1
if (fapi2::buffer<uint64_t>(l_regs[0]).getBit<ODD_PRIMARY_VALID>())
{
o_pairs.push_back(l_index);
o_pairs.push_back(1);
}

l_index += 1;
// Check RP2
if (fapi2::buffer<uint64_t>(l_regs[1]).getBit<EVEN_PRIMARY_VALID>())
{
o_pairs.push_back(2);
}

// Check RP3
if (fapi2::buffer<uint64_t>(l_regs[1]).getBit<ODD_PRIMARY_VALID>())
{
o_pairs.push_back(3);
}
}

fapi_try_exit:
Expand Down
Expand Up @@ -16893,6 +16893,102 @@ fapi_try_exit:
return fapi2::current_err;
}

///
/// @brief ATTR_EFF_RANK_GROUP_OVERRIDE getter
/// @param[in] const ref to the fapi2::Target<fapi2::TARGET_TYPE_DIMM>
/// @param[out] ref to the value uint16_t
/// @note Generated by gen_accessors.pl generateParameters (F)
/// @return fapi2::ReturnCode - FAPI2_RC_SUCCESS iff get is OK
/// @note Override PHY RANK_PAIR settings. First uint16 value is for RANK_PAIR0 register
/// value, and second is for RANK_PAIR1. Note that DIMM1 ranks in a dual-drop config
/// will be converted from Centaur canonical number (4,5) to correct PHY settings
/// (2,3). Set this attribute to zero to use default
/// settings.
///
inline fapi2::ReturnCode eff_rank_group_override(const fapi2::Target<fapi2::TARGET_TYPE_DIMM>& i_target,
uint16_t& o_value)
{
uint16_t l_value[2][2];
auto l_mca = i_target.getParent<fapi2::TARGET_TYPE_MCA>();
auto l_mcs = l_mca.getParent<fapi2::TARGET_TYPE_MCS>();

FAPI_TRY( FAPI_ATTR_GET(fapi2::ATTR_EFF_RANK_GROUP_OVERRIDE, l_mcs, l_value) );
o_value = l_value[mss::index(l_mca)][mss::index(i_target)];
return fapi2::current_err;

fapi_try_exit:
FAPI_ERR("failed accessing ATTR_EFF_RANK_GROUP_OVERRIDE: 0x%lx (target: %s)",
uint64_t(fapi2::current_err), mss::c_str(i_target));
return fapi2::current_err;
}

///
/// @brief ATTR_EFF_RANK_GROUP_OVERRIDE getter
/// @param[in] const ref to the fapi2::Target<fapi2::TARGET_TYPE_MCA>
/// @param[out] uint16_t* memory to store the value
/// @note Generated by gen_accessors.pl generateParameters (G)
/// @return fapi2::ReturnCode - FAPI2_RC_SUCCESS iff get is OK
/// @note Override PHY RANK_PAIR settings. First uint16 value is for RANK_PAIR0 register
/// value, and second is for RANK_PAIR1. Note that DIMM1 ranks in a dual-drop config
/// will be converted from Centaur canonical number (4,5) to correct PHY settings
/// (2,3). Set this attribute to zero to use default
/// settings.
///
inline fapi2::ReturnCode eff_rank_group_override(const fapi2::Target<fapi2::TARGET_TYPE_MCA>& i_target,
uint16_t* o_array)
{
if (o_array == nullptr)
{
FAPI_ERR("nullptr passed to attribute accessor %s", __func__);
return fapi2::FAPI2_RC_INVALID_PARAMETER;
}

uint16_t l_value[2][2];
auto l_mcs = i_target.getParent<fapi2::TARGET_TYPE_MCS>();

FAPI_TRY( FAPI_ATTR_GET(fapi2::ATTR_EFF_RANK_GROUP_OVERRIDE, l_mcs, l_value) );
memcpy(o_array, &(l_value[mss::index(i_target)][0]), 4);
return fapi2::current_err;

fapi_try_exit:
FAPI_ERR("failed accessing ATTR_EFF_RANK_GROUP_OVERRIDE: 0x%lx (target: %s)",
uint64_t(fapi2::current_err), mss::c_str(i_target));
return fapi2::current_err;
}

///
/// @brief ATTR_EFF_RANK_GROUP_OVERRIDE getter
/// @param[in] const ref to the fapi2::Target<fapi2::TARGET_TYPE_MCS>
/// @param[out] uint16_t* memory to store the value
/// @note Generated by gen_accessors.pl generateParameters (H)
/// @return fapi2::ReturnCode - FAPI2_RC_SUCCESS iff get is OK
/// @note Override PHY RANK_PAIR settings. First uint16 value is for RANK_PAIR0 register
/// value, and second is for RANK_PAIR1. Note that DIMM1 ranks in a dual-drop config
/// will be converted from Centaur canonical number (4,5) to correct PHY settings
/// (2,3). Set this attribute to zero to use default
/// settings.
///
inline fapi2::ReturnCode eff_rank_group_override(const fapi2::Target<fapi2::TARGET_TYPE_MCS>& i_target,
uint16_t* o_array)
{
if (o_array == nullptr)
{
FAPI_ERR("nullptr passed to attribute accessor %s", __func__);
return fapi2::FAPI2_RC_INVALID_PARAMETER;
}

uint16_t l_value[2][2];

FAPI_TRY( FAPI_ATTR_GET(fapi2::ATTR_EFF_RANK_GROUP_OVERRIDE, i_target, l_value) );
memcpy(o_array, &l_value, 8);
return fapi2::current_err;

fapi_try_exit:
FAPI_ERR("failed accessing ATTR_EFF_RANK_GROUP_OVERRIDE: 0x%lx (target: %s)",
uint64_t(fapi2::current_err), mss::c_str(i_target));
return fapi2::current_err;
}


///
/// @brief ATTR_EFF_DRAM_GEN getter
Expand Down
Expand Up @@ -3127,4 +3127,21 @@
<mssAccessorName>reorder_queue_setting</mssAccessorName>
</attribute>

<attribute>
<id>ATTR_EFF_RANK_GROUP_OVERRIDE</id>
<targetType>TARGET_TYPE_MCS</targetType>
<description>
Override PHY RANK_PAIR settings. First uint16 value is for RANK_PAIR0
register value, and second is for RANK_PAIR1. Note that DIMM1 ranks in
a dual-drop config will be converted from Centaur canonical number
(4,5) to correct PHY settings (2,3). Set this attribute to zero
to use default settings.
</description>
<initToZero></initToZero>
<valueType>uint16</valueType>
<writeable/>
<array> 2 2 </array>
<mssAccessorName>eff_rank_group_override</mssAccessorName>
</attribute>

</attributes>
4 changes: 4 additions & 0 deletions src/import/hwpf/fapi2/xml/attribute_info/hb_temp_defaults.xml
Expand Up @@ -112,6 +112,10 @@
<id>ATTR_IO_OBUS_TX_FFE_POSTCURSOR</id>
<default>0x0</default>
</attribute>
<attribute>
<id>ATTR_EFF_RANK_GROUP_OVERRIDE</id>
<default>0x0</default>
</attribute>
<!-- =====================================================================
End of temporary definitions
================================================================= -->
Expand Down
26 changes: 26 additions & 0 deletions src/usr/targeting/common/xmltohb/attribute_types.xml
Expand Up @@ -32923,6 +32923,32 @@ Measured in GB</description>
</hwpfToHbAttrMap>
</attribute>

<attribute>
<id>EFF_RANK_GROUP_OVERRIDE</id>
<description>

Override PHY RANK_PAIR settings. First uint16 value is for RANK_PAIR0
register value, and second is for RANK_PAIR1. Note that DIMM1 ranks in
a dual-drop config will be converted from Centaur canonical number
(4,5) to correct PHY settings (2,3). Set this attribute to zero
to use default settings.

</description>
<simpleType>
<uint16_t>
<default>0x0</default>
</uint16_t>
<array>2,2</array>
</simpleType>
<persistency>volatile-zeroed</persistency>
<readable/>
<writeable/>
<hwpfToHbAttrMap>
<id>ATTR_EFF_RANK_GROUP_OVERRIDE</id>
<macro>DIRECT</macro>
</hwpfToHbAttrMap>
</attribute>

<attribute>
<id>DISABLE_I2C_ENGINE2_PORT0_DIAG_MODE</id>
<description>
Expand Down
1 change: 1 addition & 0 deletions src/usr/targeting/common/xmltohb/target_types.xml
Expand Up @@ -1847,6 +1847,7 @@
<attribute><id>EFF_DRAM_RTT_NOM</id></attribute>
<attribute><id>EFF_DRAM_RTT_WR</id></attribute>
<attribute><id>EFF_DRAM_RTT_PARK</id></attribute>
<attribute><id>EFF_RANK_GROUP_OVERRIDE</id></attribute>
<attribute><id>MSS_VREF_DAC_NIBBLE</id></attribute>
<attribute><id>MSS_MVPD_FWMS</id></attribute>
</targetType>
Expand Down

0 comments on commit e5b630d

Please sign in to comment.