Skip to content

Commit c810e5f

Browse files
authored
Workaround getSwitchType failure due to NPU SAI not yet supporting it (sonic-net#647)
1 parent 4a3a568 commit c810e5f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

syncd/SaiSwitch.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ void SaiSwitch::getDefaultMacAddress(
140140
sai_switch_type_t SaiSwitch::getSwitchType() const
141141
{
142142
SWSS_LOG_ENTER();
143-
144143
sai_attribute_t attr;
145144

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

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

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

157158
return (sai_switch_type_t) attr.value.s32;
158159
}

0 commit comments

Comments
 (0)