From d3b34657ebe417b3bf932f6f61dfb1c4c54d9a5d Mon Sep 17 00:00:00 2001 From: Ron He Date: Tue, 13 Aug 2024 18:20:47 -0700 Subject: [PATCH] Handle port reachability group 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 --- fboss/agent/hw/sai/api/PortApi.h | 12 +++++------- fboss/agent/hw/sai/api/tests/PortApiTest.cpp | 1 + fboss/agent/hw/sai/store/tests/PortStoreTest.cpp | 1 + fboss/agent/hw/sai/switch/npu/SaiPortManager.cpp | 11 +++++++++++ fboss/agent/hw/sai/switch/phy/SaiPortManager.cpp | 1 + fboss/agent/hw/sai/switch/tests/PortManagerTest.cpp | 1 + 6 files changed, 20 insertions(+), 7 deletions(-) diff --git a/fboss/agent/hw/sai/api/PortApi.h b/fboss/agent/hw/sai/api/PortApi.h index aea44ff5f6a5e..4e66e7de6a896 100644 --- a/fboss/agent/hw/sai/api/PortApi.h +++ b/fboss/agent/hw/sai/api/PortApi.h @@ -416,7 +416,7 @@ struct SaiPortTraits { std::optional operator()(); }; using ReachabilityGroup = - SaiExtensionAttribute; + SaiExtensionAttribute; }; using AdapterKey = PortSaiId; @@ -510,20 +510,18 @@ struct SaiPortTraits { #endif std::optional, std::optional, - std::optional + std::optional, #if SAI_API_VERSION >= SAI_VERSION(1, 10, 2) - , std::optional, - std::optional + std::optional, #endif #if SAI_API_VERSION >= SAI_VERSION(1, 14, 0) - , std::optional, std::optional, std::optional, - std::optional + std::optional, #endif - >; + std::optional>; static constexpr std::array CounterIdsToRead = { SAI_PORT_STAT_IF_IN_OCTETS, SAI_PORT_STAT_IF_IN_UCAST_PKTS, diff --git a/fboss/agent/hw/sai/api/tests/PortApiTest.cpp b/fboss/agent/hw/sai/api/tests/PortApiTest.cpp index dbcac4b5c89e2..79435c38ce5f5 100644 --- a/fboss/agent/hw/sai/api/tests/PortApiTest.cpp +++ b/fboss/agent/hw/sai/api/tests/PortApiTest.cpp @@ -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(a, 0); } diff --git a/fboss/agent/hw/sai/store/tests/PortStoreTest.cpp b/fboss/agent/hw/sai/store/tests/PortStoreTest.cpp index 83feab4578fc5..f80cdd9e062b6 100644 --- a/fboss/agent/hw/sai/store/tests/PortStoreTest.cpp +++ b/fboss/agent/hw/sai/store/tests/PortStoreTest.cpp @@ -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 }; } diff --git a/fboss/agent/hw/sai/switch/npu/SaiPortManager.cpp b/fboss/agent/hw/sai/switch/npu/SaiPortManager.cpp index df3a4f30b74fc..873bdc7301ab6 100644 --- a/fboss/agent/hw/sai/switch/npu/SaiPortManager.cpp +++ b/fboss/agent/hw/sai/switch/npu/SaiPortManager.cpp @@ -628,6 +628,15 @@ SaiPortTraits::CreateAttributes SaiPortManager::attributesFromSwPort( } #endif + std::optional + 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) @@ -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{ @@ -757,6 +767,7 @@ SaiPortTraits::CreateAttributes SaiPortManager::attributesFromSwPort( arsPortLoadPastWeight, // ARS port load past weight arsPortLoadFutureWeight, // ARS port load future weight #endif + reachabilityGroup, }; } diff --git a/fboss/agent/hw/sai/switch/phy/SaiPortManager.cpp b/fboss/agent/hw/sai/switch/phy/SaiPortManager.cpp index 20d9a2f096808..c4b8e7751b327 100644 --- a/fboss/agent/hw/sai/switch/phy/SaiPortManager.cpp +++ b/fboss/agent/hw/sai/switch/phy/SaiPortManager.cpp @@ -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 }; } diff --git a/fboss/agent/hw/sai/switch/tests/PortManagerTest.cpp b/fboss/agent/hw/sai/switch/tests/PortManagerTest.cpp index 00a588a278f60..80945a666a5d6 100644 --- a/fboss/agent/hw/sai/switch/tests/PortManagerTest.cpp +++ b/fboss/agent/hw/sai/switch/tests/PortManagerTest.cpp @@ -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(a, 0); }