Skip to content

Commit

Permalink
Workaround getSwitchType failure due to NPU SAI not yet supporting it (
Browse files Browse the repository at this point in the history
  • Loading branch information
gechiang authored Jul 27, 2020
1 parent 4a3a568 commit c810e5f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions syncd/SaiSwitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ void SaiSwitch::getDefaultMacAddress(
sai_switch_type_t SaiSwitch::getSwitchType() const
{
SWSS_LOG_ENTER();

sai_attribute_t attr;

attr.id = SAI_SWITCH_ATTR_TYPE;
Expand All @@ -149,10 +148,12 @@ sai_switch_type_t SaiSwitch::getSwitchType() const

if (status != SAI_STATUS_SUCCESS)
{
SWSS_LOG_THROW("failed to get switch type");
SWSS_LOG_ERROR("failed to get switch type with status:0x%x. Assume default SAI_SWITCH_TYPE_NPU", status);
// Set to SAI_SWITCH_TYPE_NPU and move on
attr.value.s32 = SAI_SWITCH_TYPE_NPU;
}

SWSS_LOG_ERROR("switch type: '%s'", (attr.value.s32 == SAI_SWITCH_TYPE_NPU ? "SAI_SWITCH_TYPE_NPU" : "SAI_SWITCH_TYPE_PHY"));
SWSS_LOG_INFO("switch type: '%s'", (attr.value.s32 == SAI_SWITCH_TYPE_NPU ? "SAI_SWITCH_TYPE_NPU" : "SAI_SWITCH_TYPE_PHY"));

return (sai_switch_type_t) attr.value.s32;
}
Expand Down

0 comments on commit c810e5f

Please sign in to comment.