diff --git a/fboss/agent/hw/sai/hw_test/SaiSwitchEnsemble.cpp b/fboss/agent/hw/sai/hw_test/SaiSwitchEnsemble.cpp index b279b58152048..22aaa707c9e36 100644 --- a/fboss/agent/hw/sai/hw_test/SaiSwitchEnsemble.cpp +++ b/fboss/agent/hw/sai/hw_test/SaiSwitchEnsemble.cpp @@ -150,9 +150,13 @@ void SaiSwitchEnsemble::init( auto platform = initSaiPlatform(std::move(agentConfig), getHwSwitchFeatures(), 0); if (platform->getAsic()->getAsicVendor() == - HwAsic::AsicVendor::ASIC_VENDOR_TAJO) { + HwAsic::AsicVendor::ASIC_VENDOR_TAJO || + platform->getAsic()->getAsicType() == cfg::AsicType::ASIC_TYPE_JERICHO3) { FLAGS_classid_for_unresolved_routes = true; } + if (platform->getAsic()->getAsicType() == cfg::AsicType::ASIC_TYPE_JERICHO3) { + FLAGS_set_classid_for_my_subnet_and_ip_routes = true; + } if (auto tcvr = info.overrideTransceiverInfo) { platform->setOverrideTransceiverInfo(*tcvr); } @@ -178,11 +182,6 @@ void SaiSwitchEnsemble::init( hwAsicTableEntry->setDefaultStreamType( getPlatform()->getAsic()->getDefaultStreamType()); getPlatform()->initLEDs(); - if (getPlatform()->getAsic()->isSupported(HwAsic::Feature::ROUTE_METADATA)) { - // TODO: enable after explicit_route_classid feature is fully - // verified - FLAGS_set_classid_for_my_subnet_and_ip_routes = false; - } auto hw = static_cast(getHwSwitch()); diagShell_ = std::make_unique(hw); diagCmdServer_ = std::make_unique(hw, diagShell_.get()); diff --git a/fboss/agent/hw/sai/switch/SaiRouteManager.cpp b/fboss/agent/hw/sai/switch/SaiRouteManager.cpp index 9c42e3ee86460..83e2832b551f4 100644 --- a/fboss/agent/hw/sai/switch/SaiRouteManager.cpp +++ b/fboss/agent/hw/sai/switch/SaiRouteManager.cpp @@ -89,6 +89,11 @@ std::vector> SaiRouteManager::makeInterfaceToMeRoutes( toMeRoutes.reserve(swInterface->getAddresses()->size()); // Compute per-address information + std::optional metadata; + if (FLAGS_set_classid_for_my_subnet_and_ip_routes && + platform_->getAsic()->isSupported(HwAsic::Feature::ROUTE_METADATA)) { + metadata = static_cast(cfg::AclLookupClass::DST_CLASS_L3_LOCAL_1); + } for (auto iter : std::as_const(*swInterface->getAddresses())) { folly::IPAddress ipAddress(iter.first); // empty next hop group -- this route will not manage the @@ -97,12 +102,17 @@ std::vector> SaiRouteManager::makeInterfaceToMeRoutes( // destination folly::CIDRNetwork destination{ipAddress, ipAddress.bitCount()}; SaiRouteTraits::RouteEntry entry{switchId, virtualRouterId, destination}; + XLOG(DBG2) << "set my interface ip route " << ipAddress.str() + << " class id to " + << (metadata.has_value() + ? std::to_string(metadata.value().value()) + : "none"); #if SAI_API_VERSION >= SAI_VERSION(1, 10, 0) SaiRouteTraits::CreateAttributes attributes{ - packetAction, cpuPortId, std::nullopt, std::nullopt}; + packetAction, cpuPortId, metadata, std::nullopt}; #else SaiRouteTraits::CreateAttributes attributes{ - packetAction, cpuPortId, std::nullopt}; + packetAction, cpuPortId, metadata}; #endif auto& store = saiStore_->get(); auto route = store.setObject(entry, attributes); @@ -240,6 +250,8 @@ void SaiRouteManager::addOrUpdateRoute( if (FLAGS_set_classid_for_my_subnet_and_ip_routes && platform_->getAsic()->isSupported( HwAsic::Feature::ROUTE_METADATA)) { + XLOG(DBG2) << "set my subnet route " << newRoute->str() + << " class id to 2"; metadata = static_cast(cfg::AclLookupClass::DST_CLASS_L3_LOCAL_2); } @@ -370,6 +382,12 @@ void SaiRouteManager::addOrUpdateRoute( } else if (fwd.getAction() == RouteForwardAction::TO_CPU) { packetAction = SAI_PACKET_ACTION_FORWARD; PortSaiId cpuPortId = managerTable_->switchManager().getCpuPort(); + if (FLAGS_set_classid_for_my_subnet_and_ip_routes && + platform_->getAsic()->isSupported(HwAsic::Feature::ROUTE_METADATA)) { + XLOG(DBG2) << "set my ip route " << newRoute->str() << " class id to 1"; + metadata = + static_cast(cfg::AclLookupClass::DST_CLASS_L3_LOCAL_1); + } #if SAI_API_VERSION >= SAI_VERSION(1, 10, 0) attributes = SaiRouteTraits::CreateAttributes{ packetAction, cpuPortId, metadata, std::nullopt}; diff --git a/fboss/agent/hw/switch_asics/Jericho3Asic.cpp b/fboss/agent/hw/switch_asics/Jericho3Asic.cpp index 13ede3b723aa1..f84ec7b8b276d 100644 --- a/fboss/agent/hw/switch_asics/Jericho3Asic.cpp +++ b/fboss/agent/hw/switch_asics/Jericho3Asic.cpp @@ -85,6 +85,7 @@ bool Jericho3Asic::isSupported(Feature feature) const { case HwAsic::Feature::EGRESS_CORE_BUFFER_WATERMARK: case HwAsic::Feature::DELETED_CREDITS_STAT: case HwAsic::Feature::INGRESS_PRIORITY_GROUP_DROPPED_PACKETS: + case HwAsic::Feature::ROUTE_METADATA: return true; // Features not expected to work on SIM case HwAsic::Feature::SHARED_INGRESS_EGRESS_BUFFER_POOL: @@ -149,7 +150,6 @@ bool Jericho3Asic::isSupported(Feature feature) const { case HwAsic::Feature::XPHY_PORT_STATE_TOGGLE: case HwAsic::Feature::SAI_PORT_GET_PMD_LANES: case HwAsic::Feature::SAI_PORT_VCO_CHANGE: - case HwAsic::Feature::ROUTE_METADATA: case HwAsic::Feature::FLOWLET: case HwAsic::Feature::P4_WARMBOOT: case HwAsic::Feature::FEC_AM_LOCK_STATUS: diff --git a/fboss/agent/platforms/sai/SaiPlatform.cpp b/fboss/agent/platforms/sai/SaiPlatform.cpp index 825bf5efb690d..5e07ee9c26ad1 100644 --- a/fboss/agent/platforms/sai/SaiPlatform.cpp +++ b/fboss/agent/platforms/sai/SaiPlatform.cpp @@ -571,6 +571,16 @@ SaiSwitchTraits::CreateAttributes SaiPlatform::getSwitchAttributes( voqLatencyMaxLevel2Ns = 4294967295; #endif + std::optional + routeNoImplicitMetaData{std::nullopt}; +#if defined(BRCM_SAI_SDK_GTE_11_0) + if (getAsic()->isSupported(HwAsic::Feature::ROUTE_METADATA) && + FLAGS_set_classid_for_my_subnet_and_ip_routes) { + XLOG(DBG2) << "Disable configuring implicit route metadata by sai adapter"; + routeNoImplicitMetaData = true; + } +#endif + return { initSwitch, hwInfo, // hardware info @@ -620,7 +630,7 @@ SaiSwitchTraits::CreateAttributes SaiPlatform::getSwitchAttributes( #endif maxCores, // Max cores std::nullopt, // PFC DLR Packet Action - std::nullopt, // route no implicit meta data + routeNoImplicitMetaData, // route no implicit meta data std::nullopt, // route allow implicit meta data std::nullopt, // multi-stage local switch ids voqLatencyMinLocalNs, // Local VoQ latency bin min diff --git a/fboss/agent/test/AgentHwTest.cpp b/fboss/agent/test/AgentHwTest.cpp index cabed0f15fc13..b9927d1366f0e 100644 --- a/fboss/agent/test/AgentHwTest.cpp +++ b/fboss/agent/test/AgentHwTest.cpp @@ -55,12 +55,6 @@ void AgentHwTest::SetUp() { HwSwitch::FeaturesDesired::LINKSCAN_DESIRED | HwSwitch::FeaturesDesired::TAM_EVENT_NOTIFY_DESIRED), failHwCallsOnWarmboot()); - - if (isSupportedOnAllAsics(HwAsic::Feature::ROUTE_METADATA)) { - // TODO: enable after set_classid_for_my_subnet_and_ip_routes feature is - // fully verified - FLAGS_set_classid_for_my_subnet_and_ip_routes = false; - } } void AgentHwTest::setCmdLineFlagOverrides() const {