diff --git a/orchagent/routeorch.cpp b/orchagent/routeorch.cpp index b1508656b3..803f71bb1e 100644 --- a/orchagent/routeorch.cpp +++ b/orchagent/routeorch.cpp @@ -29,6 +29,7 @@ extern FlowCounterRouteOrch *gFlowCounterRouteOrch; extern TunnelDecapOrch *gTunneldecapOrch; extern size_t gMaxBulkSize; +extern string gMySwitchType; /* Default maximum number of next hop groups */ #define DEFAULT_NUMBER_OF_ECMP_GROUPS 128 @@ -88,6 +89,37 @@ RouteOrch::RouteOrch(DBConnector *db, vector &tableNames, SWSS_LOG_NOTICE("Maximum number of ECMP groups supported is %d", m_maxNextHopGroupCount); + /* fetch the MAX_ECMP_MEMBER_COUNT and for voq platform, set it to 128 */ + attr.id = SAI_SWITCH_ATTR_MAX_ECMP_MEMBER_COUNT; + status = sai_switch_api->get_switch_attribute(gSwitchId, 1, &attr); + + if (status != SAI_STATUS_SUCCESS) + { + SWSS_LOG_WARN("Failed to get switch attribute max ECMP Group size. rv:%d", status); + } + else + { + uint32_t maxEcmpGroupSize = attr.value.u32; + SWSS_LOG_NOTICE("Switch Type: %s, Max ECMP Group Size supported: %d", gMySwitchType.c_str(), attr.value.u32); + + /*If the switch type is voq, and max Ecmp group size supported is greater or equal to 128, set it to 128 */ + if (gMySwitchType == "voq" && maxEcmpGroupSize >= 128) + { + maxEcmpGroupSize = 128; + attr.id = SAI_SWITCH_ATTR_ECMP_MEMBER_COUNT; + attr.value.s32 = maxEcmpGroupSize; + status = sai_switch_api->set_switch_attribute(gSwitchId, &attr); + if (status != SAI_STATUS_SUCCESS) + { + SWSS_LOG_ERROR("Failed to set switch attribute ECMP member count to 128. rv:%d", status); + } + else + { + SWSS_LOG_NOTICE("Set switch attribute ECMP member count to 128"); + } + } + } + m_stateDb = shared_ptr(new DBConnector("STATE_DB", 0)); m_stateDefaultRouteTb = unique_ptr(new Table(m_stateDb.get(), STATE_ROUTE_TABLE_NAME));