Skip to content

Commit

Permalink
enable ROUTE_METADATA feature on J3
Browse files Browse the repository at this point in the history
Summary:
enable ROUTE_METADATA feature on J3 when flag set_classid_for_my_subnet_and_ip_routes is set. set_classid_for_my_subnet_and_ip_routes would be set for agent hw test later by D61048583. More details:

1) set routeNoImplicitMetaData=true, which will stop implicitly setting route class id from brcm sai/sdk and allow setting route class id from FBOSS
2) explicitly set my subnet route class id and my ip route class id from SaiRouteManager on J3 if flag set_classid_for_my_subnet_and_ip_routes is set
3) set set_classid_for_my_subnet_and_ip_routes=true for hw tests on J3 devices. agent hw test would be set later by D61048583.

Reviewed By: shri-khare, srikrishnagopu

Differential Revision:
D59410031

Privacy Context Container: L1125642

fbshipit-source-id: 37354210530da288a1bc0f0cbcbf7e2b6db16b71
  • Loading branch information
daiwei1983 authored and facebook-github-bot committed Aug 21, 2024
1 parent 064740f commit d5ffdda
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 16 deletions.
11 changes: 5 additions & 6 deletions fboss/agent/hw/sai/hw_test/SaiSwitchEnsemble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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<SaiSwitch*>(getHwSwitch());
diagShell_ = std::make_unique<DiagShell>(hw);
diagCmdServer_ = std::make_unique<DiagCmdServer>(hw, diagShell_.get());
Expand Down
22 changes: 20 additions & 2 deletions fboss/agent/hw/sai/switch/SaiRouteManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ std::vector<std::shared_ptr<SaiRoute>> SaiRouteManager::makeInterfaceToMeRoutes(

toMeRoutes.reserve(swInterface->getAddresses()->size());
// Compute per-address information
std::optional<SaiRouteTraits::Attributes::Metadata> metadata;
if (FLAGS_set_classid_for_my_subnet_and_ip_routes &&
platform_->getAsic()->isSupported(HwAsic::Feature::ROUTE_METADATA)) {
metadata = static_cast<uint32_t>(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
Expand All @@ -97,12 +102,17 @@ std::vector<std::shared_ptr<SaiRoute>> 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<SaiRouteTraits>();
auto route = store.setObject(entry, attributes);
Expand Down Expand Up @@ -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<uint32_t>(cfg::AclLookupClass::DST_CLASS_L3_LOCAL_2);
}
Expand Down Expand Up @@ -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<uint32_t>(cfg::AclLookupClass::DST_CLASS_L3_LOCAL_1);
}
#if SAI_API_VERSION >= SAI_VERSION(1, 10, 0)
attributes = SaiRouteTraits::CreateAttributes{
packetAction, cpuPortId, metadata, std::nullopt};
Expand Down
2 changes: 1 addition & 1 deletion fboss/agent/hw/switch_asics/Jericho3Asic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
12 changes: 11 additions & 1 deletion fboss/agent/platforms/sai/SaiPlatform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,16 @@ SaiSwitchTraits::CreateAttributes SaiPlatform::getSwitchAttributes(
voqLatencyMaxLevel2Ns = 4294967295;
#endif

std::optional<SaiSwitchTraits::Attributes::RouteNoImplicitMetaData>
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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 0 additions & 6 deletions fboss/agent/test/AgentHwTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit d5ffdda

Please sign in to comment.