Skip to content

Commit

Permalink
DLB: SaiSwitch changes for ARS support
Browse files Browse the repository at this point in the history
Summary: SaiSwitch changes to process update for flowlet config

Reviewed By: msomasundaran

Differential Revision: D63679606

fbshipit-source-id: 59ba077026cf4316188f31ec8a8d0c9d9f31b718
  • Loading branch information
Ravi Vantipalli authored and facebook-github-bot committed Dec 17, 2024
1 parent d0ace96 commit a6b1afe
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 2 deletions.
1 change: 1 addition & 0 deletions fboss/agent/hw/sai/switch/SaiManagerTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ void SaiManagerTable::reset(bool skipSwitchManager) {
switchManager_->resetQosMaps();
samplePacketManager_.reset();

switchManager_->resetArsProfile();
arsProfileManager_.reset();
arsManager_.reset();

Expand Down
75 changes: 75 additions & 0 deletions fboss/agent/hw/sai/switch/SaiSwitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#include "fboss/agent/hw/sai/switch/ConcurrentIndices.h"
#include "fboss/agent/hw/sai/switch/SaiAclTableGroupManager.h"
#include "fboss/agent/hw/sai/switch/SaiAclTableManager.h"
#include "fboss/agent/hw/sai/switch/SaiArsManager.h"
#include "fboss/agent/hw/sai/switch/SaiArsProfileManager.h"
#include "fboss/agent/hw/sai/switch/SaiBufferManager.h"
#include "fboss/agent/hw/sai/switch/SaiCounterManager.h"
#include "fboss/agent/hw/sai/switch/SaiDebugCounterManager.h"
Expand Down Expand Up @@ -1139,6 +1141,12 @@ std::shared_ptr<SwitchState> SaiSwitch::stateChangedImplLocked(
&SaiUdfManager::removeUdfGroup);
#endif

if (FLAGS_flowletSwitchingEnable) {
if (platform_->getAsic()->isSupported(HwAsic::Feature::FLOWLET)) {
processFlowletSwitchingConfigDelta(delta, lockPolicy);
}
}

processPfcWatchdogGlobalDelta(delta, lockPolicy);

if (platform_->getAsic()->isSupported(
Expand Down Expand Up @@ -4166,6 +4174,73 @@ void SaiSwitch::processPfcWatchdogGlobalDelta(
processPfcWatchdogGlobalDeltaLocked(delta, lockPolicy.lock());
}

void SaiSwitch::processFlowletSwitchingConfigDeltaLocked(
const StateDelta& delta,
const std::lock_guard<std::mutex>& /* lock */) {
const auto flowletSwitchingDelta = delta.getFlowletSwitchingConfigDelta();
const auto& oldFlowletConfig = flowletSwitchingDelta.getOld();
const auto& newFlowletConfig = flowletSwitchingDelta.getNew();

// process change in the flowlet switching config
if (!oldFlowletConfig && !newFlowletConfig) {
XLOG(DBG5) << "Flowlet switching config is null";
return;
}

#if SAI_API_VERSION >= SAI_VERSION(1, 14, 0)
auto& switchManager = managerTable_->switchManager();
auto& arsManager = managerTable_->arsManager();
auto& arsProfileManager = managerTable_->arsProfileManager();
auto& nextHopGroupManager = managerTable_->nextHopGroupManager();

if (oldFlowletConfig && newFlowletConfig) {
if (*oldFlowletConfig == *newFlowletConfig) {
XLOG(DBG5) << "Flowlet switching config is same";
// flowlet is enabled here. lets walk through all ecmp objects to ensure
// things look ok. For most purposes, this will be a no-op
// One case this becomes useful is when a nhg went away and there are
// other nhg's waiting to get flowlet resources, this will ensure they do
// during a config update
nextHopGroupManager.updateArsModeAll(newFlowletConfig);
return;
} else {
XLOG(DBG2) << "Flowlet switching config is changed";
// FlowletSwitchingConfig has both ARS_PROFILE and ARS info
arsProfileManager.changeArsProfile(oldFlowletConfig, newFlowletConfig);
arsManager.changeArs(oldFlowletConfig, newFlowletConfig);
}
}

if (newFlowletConfig && !oldFlowletConfig) {
XLOG(DBG2) << "Flowlet switching config is added";
// create the ARS profile object and attach to switch
arsProfileManager.addArsProfile(newFlowletConfig);
auto arsProfileHandlePtr = arsProfileManager.getArsProfileHandle();
CHECK(arsProfileHandlePtr);
switchManager.setArsProfile(arsProfileHandlePtr->arsProfile->adapterKey());

// create the ARS object and attach to all ECMP groups
arsManager.addArs(newFlowletConfig);
auto arsHandlePtr = arsManager.getArsHandle();
CHECK(arsHandlePtr);
nextHopGroupManager.updateArsModeAll(newFlowletConfig);
} else if (oldFlowletConfig && !newFlowletConfig) {
XLOG(DBG2) << "Flowlet switching config is removed";
nextHopGroupManager.updateArsModeAll(newFlowletConfig);
arsManager.removeArs(newFlowletConfig);
switchManager.resetArsProfile();
arsProfileManager.removeArsProfile(oldFlowletConfig);
}
#endif
}

template <typename LockPolicyT>
void SaiSwitch::processFlowletSwitchingConfigDelta(
const StateDelta& delta,
const LockPolicyT& lockPolicy) {
processFlowletSwitchingConfigDeltaLocked(delta, lockPolicy.lock());
}

void SaiSwitch::pfcDeadlockNotificationCallback(
PortSaiId portSaiId,
uint8_t queueId,
Expand Down
8 changes: 8 additions & 0 deletions fboss/agent/hw/sai/switch/SaiSwitch.h
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,14 @@ class SaiSwitch : public HwSwitch {

void initialStateApplied() override;

template <typename LockPolicyT>
void processFlowletSwitchingConfigDelta(
const StateDelta& delta,
const LockPolicyT& lockPolicy);
void processFlowletSwitchingConfigDeltaLocked(
const StateDelta& delta,
const std::lock_guard<std::mutex>& lock);

template <typename LockPolicyT>
void processPfcWatchdogGlobalDelta(
const StateDelta& delta,
Expand Down
3 changes: 1 addition & 2 deletions fboss/agent/hw/sai/switch/SaiSwitchManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -677,8 +677,7 @@ void SaiSwitchManager::setArsProfile(

void SaiSwitchManager::resetArsProfile() {
#if SAI_API_VERSION >= SAI_VERSION(1, 14, 0)
if (FLAGS_flowletSwitchingEnable &&
platform_->getAsic()->isSupported(HwAsic::Feature::FLOWLET)) {
if (FLAGS_flowletSwitchingEnable) {
switch_->setOptionalAttribute(
SaiSwitchTraits::Attributes::ArsProfile{SAI_NULL_OBJECT_ID});
}
Expand Down

0 comments on commit a6b1afe

Please sign in to comment.