-
Notifications
You must be signed in to change notification settings - Fork 308
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DLB: SAI switch impl for ARS profile
Summary: ARS profile manager implementation with add/remove/update APIs Reviewed By: srikrishnagopu Differential Revision: D54755165 fbshipit-source-id: 3202808dbcdd0dae9751635c2e04957835833ff1
- Loading branch information
1 parent
c144257
commit b00506d
Showing
7 changed files
with
184 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/* | ||
* Copyright (c) 2004-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
* | ||
*/ | ||
|
||
#include "fboss/agent/hw/sai/switch/SaiArsProfileManager.h" | ||
|
||
#include "fboss/agent/hw/sai/store/SaiStore.h" | ||
#include "fboss/agent/hw/sai/switch/SaiManagerTable.h" | ||
|
||
#include "fboss/agent/platforms/sai/SaiPlatform.h" | ||
|
||
namespace facebook::fboss { | ||
|
||
SaiArsProfileManager::SaiArsProfileManager( | ||
SaiStore* saiStore, | ||
SaiManagerTable* managerTable, | ||
const SaiPlatform* platform) | ||
: saiStore_(saiStore), managerTable_(managerTable), platform_(platform) { | ||
#if SAI_API_VERSION >= SAI_VERSION(1, 14, 0) | ||
arsProfileHandle_ = std::make_unique<SaiArsProfileHandle>(); | ||
#endif | ||
} | ||
|
||
#if SAI_API_VERSION >= SAI_VERSION(1, 14, 0) | ||
|
||
SaiArsProfileTraits::CreateAttributes SaiArsProfileManager::createAttributes( | ||
const std::shared_ptr<FlowletSwitchingConfig>& flowletSwitchConfig) { | ||
auto samplingInterval = flowletSwitchConfig->getDynamicSampleRate(); | ||
sai_uint32_t randomSeed = 0x5555; | ||
auto portLoadPastWeight = flowletSwitchConfig->getDynamicEgressLoadExponent(); | ||
auto portLoadFutureWeight = flowletSwitchConfig->getDynamicQueueExponent(); | ||
auto portLoadExponent = | ||
flowletSwitchConfig->getDynamicPhysicalQueueExponent(); | ||
auto loadPastMinVal = | ||
flowletSwitchConfig->getDynamicEgressMinThresholdBytes(); | ||
auto loadPastMaxVal = | ||
flowletSwitchConfig->getDynamicEgressMaxThresholdBytes(); | ||
auto loadFutureMinVal = | ||
flowletSwitchConfig->getDynamicQueueMinThresholdBytes(); | ||
auto loadFutureMaxVal = | ||
flowletSwitchConfig->getDynamicQueueMaxThresholdBytes(); | ||
// this is per ITM and should be half of newDynamicQueueMinThresholdBytes | ||
// above (as we have 2 ITMs) | ||
auto loadCurrentMinVal = | ||
flowletSwitchConfig->getDynamicQueueMinThresholdBytes() >> 1; | ||
auto loadCurrentMaxVal = | ||
flowletSwitchConfig->getDynamicQueueMaxThresholdBytes() >> 1; | ||
SaiArsProfileTraits::CreateAttributes attributes{ | ||
SAI_ARS_PROFILE_ALGO_EWMA, | ||
samplingInterval, | ||
randomSeed, | ||
false, // EnableIPv4 | ||
false, // EnableIPv6 | ||
true, | ||
portLoadPastWeight, | ||
loadPastMinVal, | ||
loadPastMaxVal, | ||
true, | ||
portLoadFutureWeight, | ||
loadFutureMinVal, | ||
loadFutureMaxVal, | ||
true, | ||
portLoadExponent, | ||
loadCurrentMinVal, | ||
loadCurrentMaxVal}; | ||
|
||
return attributes; | ||
} | ||
|
||
void SaiArsProfileManager::addArsProfile( | ||
const std::shared_ptr<FlowletSwitchingConfig>& flowletSwitchConfig) { | ||
auto attributes = createAttributes(flowletSwitchConfig); | ||
auto& store = saiStore_->get<SaiArsProfileTraits>(); | ||
arsProfileHandle_->arsProfile = store.setObject(std::monostate{}, attributes); | ||
} | ||
|
||
void SaiArsProfileManager::removeArsProfile( | ||
const std::shared_ptr<FlowletSwitchingConfig>& flowletSwitchConfig) { | ||
arsProfileHandle_.reset(); | ||
} | ||
|
||
void SaiArsProfileManager::changeArsProfile( | ||
const std::shared_ptr<FlowletSwitchingConfig>& oldFlowletSwitchConfig, | ||
const std::shared_ptr<FlowletSwitchingConfig>& newFlowletSwitchConfig) { | ||
addArsProfile(newFlowletSwitchConfig); | ||
} | ||
|
||
SaiArsProfileHandle* SaiArsProfileManager::getArsProfileHandle() { | ||
return arsProfileHandle_.get(); | ||
} | ||
#endif | ||
|
||
} // namespace facebook::fboss |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright (c) 2004-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
* | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "fboss/agent/hw/sai/api/ArsProfileApi.h" | ||
#include "fboss/agent/hw/sai/api/Types.h" | ||
#include "fboss/agent/hw/sai/store/SaiObject.h" | ||
#include "fboss/agent/state/FlowletSwitchingConfig.h" | ||
#include "fboss/agent/types.h" | ||
|
||
#include <memory> | ||
|
||
namespace facebook::fboss { | ||
|
||
class SaiManagerTable; | ||
class SaiPlatform; | ||
class SaiStore; | ||
|
||
#if SAI_API_VERSION >= SAI_VERSION(1, 14, 0) | ||
using SaiArsProfile = SaiObject<SaiArsProfileTraits>; | ||
#endif | ||
|
||
struct SaiArsProfileHandle { | ||
#if SAI_API_VERSION >= SAI_VERSION(1, 14, 0) | ||
std::shared_ptr<SaiArsProfile> arsProfile; | ||
#endif | ||
}; | ||
|
||
class SaiArsProfileManager { | ||
public: | ||
SaiArsProfileManager( | ||
SaiStore* saiStore, | ||
SaiManagerTable* managerTable, | ||
const SaiPlatform* platform); | ||
#if SAI_API_VERSION >= SAI_VERSION(1, 14, 0) | ||
void addArsProfile( | ||
const std::shared_ptr<FlowletSwitchingConfig>& flowletSwitchingConfig); | ||
void removeArsProfile( | ||
const std::shared_ptr<FlowletSwitchingConfig>& flowletSwitchingConfig); | ||
void changeArsProfile( | ||
const std::shared_ptr<FlowletSwitchingConfig>& oldFlowletSwitchingConfig, | ||
const std::shared_ptr<FlowletSwitchingConfig>& newFlowletSwitchingConfig); | ||
SaiArsProfileHandle* getArsProfileHandle(); | ||
#endif | ||
|
||
private: | ||
SaiStore* saiStore_; | ||
SaiManagerTable* managerTable_; | ||
const SaiPlatform* platform_; | ||
#if SAI_API_VERSION >= SAI_VERSION(1, 14, 0) | ||
SaiArsProfileTraits::CreateAttributes createAttributes( | ||
const std::shared_ptr<FlowletSwitchingConfig>& flowletSwitchingConfig); | ||
std::unique_ptr<SaiArsProfileHandle> arsProfileHandle_; | ||
#endif | ||
}; | ||
|
||
} // namespace facebook::fboss |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters