Skip to content

Commit

Permalink
Handle port reachability group
Browse files Browse the repository at this point in the history
Summary:
Program reachability group ID on port, if port has intended value.

The programming model goes as followed -
1. NOS programs switch attribute reachability group list, to indicate the total amount of reachability group.
2. For each port, program the attribute of reachability group, to indicate which group it belongs to.

Reviewed By: nivinl

Differential Revision: D60872019

fbshipit-source-id: 1a3737e870bf91ad0a12d6d3b20cb9c1e99d6201
  • Loading branch information
Ron He authored and facebook-github-bot committed Aug 14, 2024
1 parent cf21c1b commit d3b3465
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 7 deletions.
12 changes: 5 additions & 7 deletions fboss/agent/hw/sai/api/PortApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ struct SaiPortTraits {
std::optional<sai_attr_id_t> operator()();
};
using ReachabilityGroup =
SaiExtensionAttribute<bool, AttributeReachabilityGroup>;
SaiExtensionAttribute<sai_uint32_t, AttributeReachabilityGroup>;
};
using AdapterKey = PortSaiId;

Expand Down Expand Up @@ -510,20 +510,18 @@ struct SaiPortTraits {
#endif
std::optional<Attributes::LinkTrainingEnable>,
std::optional<Attributes::FdrEnable>,
std::optional<Attributes::RxLaneSquelchEnable>
std::optional<Attributes::RxLaneSquelchEnable>,
#if SAI_API_VERSION >= SAI_VERSION(1, 10, 2)
,
std::optional<Attributes::PfcTcDldInterval>,
std::optional<Attributes::PfcTcDlrInterval>
std::optional<Attributes::PfcTcDlrInterval>,
#endif
#if SAI_API_VERSION >= SAI_VERSION(1, 14, 0)
,
std::optional<Attributes::ArsEnable>,
std::optional<Attributes::ArsPortLoadScalingFactor>,
std::optional<Attributes::ArsPortLoadPastWeight>,
std::optional<Attributes::ArsPortLoadFutureWeight>
std::optional<Attributes::ArsPortLoadFutureWeight>,
#endif
>;
std::optional<Attributes::ReachabilityGroup>>;
static constexpr std::array<sai_stat_id_t, 16> CounterIdsToRead = {
SAI_PORT_STAT_IF_IN_OCTETS,
SAI_PORT_STAT_IF_IN_UCAST_PKTS,
Expand Down
1 change: 1 addition & 0 deletions fboss/agent/hw/sai/api/tests/PortApiTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class PortApiTest : public ::testing::Test {
std::nullopt, // ARS port load past weight
std::nullopt, // ARS port load future weight
#endif
std::nullopt, // Reachability Group
};
return portApi->create<SaiPortTraits>(a, 0);
}
Expand Down
1 change: 1 addition & 0 deletions fboss/agent/hw/sai/store/tests/PortStoreTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class PortStoreTest : public SaiStoreTest {
std::nullopt, // ARS port load past weight
std::nullopt, // ARS port load future weight
#endif
std::nullopt, // Reachability Group
};
}

Expand Down
11 changes: 11 additions & 0 deletions fboss/agent/hw/sai/switch/npu/SaiPortManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,15 @@ SaiPortTraits::CreateAttributes SaiPortManager::attributesFromSwPort(
}
#endif

std::optional<SaiPortTraits::Attributes::ReachabilityGroup>
reachabilityGroup{};
#if defined(BRCM_SAI_SDK_DNX_GTE_12_0)
if (auto reachabilityGroupId = swPort->getReachabilityGroupId()) {
reachabilityGroup = SaiPortTraits::Attributes::ReachabilityGroup{
reachabilityGroupId.value()};
}
#endif

if (basicAttributeOnly) {
return SaiPortTraits::CreateAttributes{
#if defined(BRCM_SAI_SDK_DNX)
Expand Down Expand Up @@ -690,6 +699,7 @@ SaiPortTraits::CreateAttributes SaiPortManager::attributesFromSwPort(
std::nullopt, // ARS port load past weight
std::nullopt, // ARS port load future weight
#endif
std::nullopt, // Reachability Group
};
}
return SaiPortTraits::CreateAttributes{
Expand Down Expand Up @@ -757,6 +767,7 @@ SaiPortTraits::CreateAttributes SaiPortManager::attributesFromSwPort(
arsPortLoadPastWeight, // ARS port load past weight
arsPortLoadFutureWeight, // ARS port load future weight
#endif
reachabilityGroup,
};
}

Expand Down
1 change: 1 addition & 0 deletions fboss/agent/hw/sai/switch/phy/SaiPortManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ SaiPortTraits::CreateAttributes SaiPortManager::attributesFromSwPort(
std::nullopt, // ARS port load past weight
std::nullopt, // ARS port load future weight
#endif
std::nullopt, // Reachability Group
};
}

Expand Down
1 change: 1 addition & 0 deletions fboss/agent/hw/sai/switch/tests/PortManagerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ class PortManagerTest : public ManagerTestBase {
std::nullopt, // ARS port load past weight
std::nullopt, // ARS port load future weight
#endif
std::nullopt, // Reachability Group
};
return portApi.create<SaiPortTraits>(a, 0);
}
Expand Down

0 comments on commit d3b3465

Please sign in to comment.