From 8df9624dba868c1ebba947ce3481a05e0b49f2ed Mon Sep 17 00:00:00 2001 From: Ron He Date: Thu, 21 Nov 2024 19:22:36 -0800 Subject: [PATCH] Sai switch handling new reachability group field Summary: As titled. Process reachability group list in sai switch. Also need to sort the entries - at wb GET would return sorted order. Reviewed By: jasmeetbagga Differential Revision: D66029979 fbshipit-source-id: 2ae0ca3279c8d4888d5a694ef3821de620c5c88a --- fboss/agent/hw/sai/switch/SaiSwitch.cpp | 7 +++---- fboss/agent/hw/sai/switch/SaiSwitchManager.cpp | 16 +++++++--------- fboss/agent/hw/sai/switch/SaiSwitchManager.h | 2 +- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/fboss/agent/hw/sai/switch/SaiSwitch.cpp b/fboss/agent/hw/sai/switch/SaiSwitch.cpp index 5503a2c0d22b1..470e916c2b7db 100644 --- a/fboss/agent/hw/sai/switch/SaiSwitch.cpp +++ b/fboss/agent/hw/sai/switch/SaiSwitch.cpp @@ -1338,11 +1338,10 @@ void SaiSwitch::processSwitchSettingsChangeSansDrainedEntryLocked( } { - const auto oldVal = oldSwitchSettings->getReachabilityGroupListSize(); - const auto newVal = newSwitchSettings->getReachabilityGroupListSize(); + auto oldVal = oldSwitchSettings->getReachabilityGroups(); + auto newVal = newSwitchSettings->getReachabilityGroups(); if (oldVal != newVal) { - managerTable_->switchManager().setReachabilityGroupList( - newVal.has_value() ? newVal.value() : 0); + managerTable_->switchManager().setReachabilityGroupList(newVal); } } diff --git a/fboss/agent/hw/sai/switch/SaiSwitchManager.cpp b/fboss/agent/hw/sai/switch/SaiSwitchManager.cpp index 5c936cfcdd772..4d00669d1f18f 100644 --- a/fboss/agent/hw/sai/switch/SaiSwitchManager.cpp +++ b/fboss/agent/hw/sai/switch/SaiSwitchManager.cpp @@ -1009,16 +1009,14 @@ void SaiSwitchManager::setLocalCapsuleSwitchIds( SaiSwitchTraits::Attributes::MultiStageLocalSwitchIds{values}); } -void SaiSwitchManager::setReachabilityGroupList(int reachabilityGroupListSize) { +void SaiSwitchManager::setReachabilityGroupList( + const std::vector& reachabilityGroups) { #if defined(BRCM_SAI_SDK_DNX_GTE_12_0) - if (reachabilityGroupListSize > 0) { - std::vector list; - for (int i = 0; i < reachabilityGroupListSize; i++) { - list.push_back(i + 1); - } - switch_->setOptionalAttribute( - SaiSwitchTraits::Attributes::ReachabilityGroupList{list}); - } + std::vector groupList( + reachabilityGroups.begin(), reachabilityGroups.end()); + std::sort(groupList.begin(), groupList.end()); + switch_->setOptionalAttribute( + SaiSwitchTraits::Attributes::ReachabilityGroupList{groupList}); #endif } diff --git a/fboss/agent/hw/sai/switch/SaiSwitchManager.h b/fboss/agent/hw/sai/switch/SaiSwitchManager.h index 994a78dd3b2ab..5e09cd42d0693 100644 --- a/fboss/agent/hw/sai/switch/SaiSwitchManager.h +++ b/fboss/agent/hw/sai/switch/SaiSwitchManager.h @@ -102,7 +102,7 @@ class SaiSwitchManager { } void setLocalCapsuleSwitchIds( const std::map& switchIdToNumCores); - void setReachabilityGroupList(int reachabilityGroupListSize); + void setReachabilityGroupList(const std::vector& reachabilityGroups); void setSramGlobalFreePercentXoffTh(uint8_t sramFreePercentXoffThreshold); void setSramGlobalFreePercentXonTh(uint8_t sramFreePercentXonThreshold); void setLinkFlowControlCreditTh(uint16_t linkFlowControlThreshold);