Skip to content

Commit

Permalink
Merge branch 'main' into arashpartow/update_exprtk_0.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
ArashPartow authored Nov 5, 2024
2 parents 176b871 + 95c756d commit 668f2f8
Show file tree
Hide file tree
Showing 56 changed files with 1,786 additions and 4,937 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ gh_facebook_buck2_shims_meta = git

[external_cell_gh_facebook_buck2_shims_meta]
git_origin = https://github.com/facebook/buck2-shims-meta.git
commit_hash = 461a1b10af7eb8af2f6d0eb0129009d60048e6de
commit_hash = b79235f6447a07f78644ab08261e3acfe4e12604
2 changes: 1 addition & 1 deletion build/deps/github_hashes/facebook/fb303-rev.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Subproject commit 43a8ca1e89fc3ab45abf9eff78b6c0ec4510ebdb
Subproject commit d15028627fdd473945f04124f118e17142471f81
2 changes: 1 addition & 1 deletion build/deps/github_hashes/facebook/fbthrift-rev.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Subproject commit 6c55aa9762cffed619c25abf07d273b39985e979
Subproject commit 300f4d5e79e763ef74243da9a1f3b9f649d5addd
2 changes: 1 addition & 1 deletion build/deps/github_hashes/facebook/wangle-rev.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Subproject commit 46688946ef13435ad9e873a5ba5684677783945b
Subproject commit d54405ad3588791be7146a19fe4e914af0807c28
1 change: 1 addition & 0 deletions cmake/Agent.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ target_link_libraries(switchid_scope_resolver
fboss_error
hwswitch_matcher
state
switchinfo_utils
)

add_library(hwagent
Expand Down
72 changes: 72 additions & 0 deletions fboss/agent/ApplyThriftConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ using folly::StringPiece;
using std::make_shared;
using std::shared_ptr;

using namespace facebook::fboss;
namespace {

const uint8_t kV6LinkLocalAddrMask{64};
Expand Down Expand Up @@ -148,6 +149,55 @@ std::shared_ptr<MultiMap> toMultiSwitchMap(
return multiMap;
}

bool haveParallelLinksToInterfaceNodes(
const cfg::SwitchConfig* cfg,
const std::vector<SwitchID>& localFabricSwitchIds,
const std::unordered_map<std::string, std::vector<uint32_t>>&
switchNameToSwitchIds,
SwitchIdScopeResolver& scopeResolver,
const PlatformMapping* platformMapping) {
for (const auto& fabricSwitchId : localFabricSwitchIds) {
// Determine parallel links on VD level - there are two VDs per R3 ASIC
std::unordered_map<int, std::unordered_set<std::string>> vd2VoqNeighbors;
for (const auto& port : *cfg->ports()) {
// Only process ports belonging to one switchId
if (scopeResolver.scope(port).has(SwitchID(fabricSwitchId)) &&
port.expectedNeighborReachability()->size() > 0) {
auto neighborRemoteSwitchId =
getRemoteSwitchID(cfg, port, switchNameToSwitchIds);
const auto& neighborDsfNodeIter =
cfg->dsfNodes()->find(neighborRemoteSwitchId);
CHECK(neighborDsfNodeIter != cfg->dsfNodes()->end());
if (*neighborDsfNodeIter->second.type() ==
cfg::DsfNodeType::INTERFACE_NODE) {
CHECK(port.name().has_value());
auto localVirtualDeviceId =
platformMapping->getVirtualDeviceID(*port.name());
if (!localVirtualDeviceId.has_value()) {
throw FbossError(
"Unable to find virtual device id for port: ",
*port.logicalID(),
" virtual device");
}

if (vd2VoqNeighbors.find(localVirtualDeviceId.value()) ==
vd2VoqNeighbors.end()) {
vd2VoqNeighbors.insert(
{localVirtualDeviceId.value(),
std::unordered_set<std::string>()});
}
auto& voqNeighbors = vd2VoqNeighbors[localVirtualDeviceId.value()];
const auto& [neighborName, _] = getExpectedNeighborAndPortName(port);
if (voqNeighbors.find(neighborName) != voqNeighbors.end()) {
return true;
}
voqNeighbors.insert(neighborName);
}
}
}
}
return false;
};
} // anonymous namespace

namespace facebook::fboss {
Expand Down Expand Up @@ -4532,6 +4582,28 @@ shared_ptr<SwitchSettings> ThriftConfigApplier::updateSwitchSettings(
switchSettingsChange = true;
}

std::optional<uint16_t> newLinkFlowControlCreditThreshold;
if (cfg_->switchSettings()->linkFlowControlCreditThreshold()) {
newLinkFlowControlCreditThreshold =
*cfg_->switchSettings()->linkFlowControlCreditThreshold();
}
if (newLinkFlowControlCreditThreshold !=
origSwitchSettings->getLinkFlowControlCreditThreshold()) {
newSwitchSettings->setLinkFlowControlCreditThreshold(
newLinkFlowControlCreditThreshold);
switchSettingsChange = true;
}

std::optional<uint32_t> newVoqDramBoundThreshold;
if (cfg_->switchSettings()->voqDramBoundThreshold()) {
newVoqDramBoundThreshold = *cfg_->switchSettings()->voqDramBoundThreshold();
}
if (newVoqDramBoundThreshold !=
origSwitchSettings->getVoqDramBoundThreshold()) {
newSwitchSettings->setVoqDramBoundThreshold(newVoqDramBoundThreshold);
switchSettingsChange = true;
}

if (origSwitchSettings->getSwitchDrainState() !=
*cfg_->switchSettings()->switchDrainState()) {
auto numVoqSwtitches =
Expand Down
19 changes: 18 additions & 1 deletion fboss/agent/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,22 @@ cpp_library(
],
)

cpp_library(
name = "fsdb_adapted_sub_manager",
srcs = [
"FsdbAdaptedSubManager.cpp",
],
headers = [
"FsdbAdaptedSubManager.h",
],
exported_deps = [
"//fboss/agent/state:state",
"//fboss/fsdb/client:fsdb_sub_manager",
"//fboss/fsdb/if:fsdb_model",
"//fboss/thrift_cow/storage:cow_storage",
],
)

cpp_library(
name = "core",
srcs = [
Expand All @@ -633,7 +649,6 @@ cpp_library(
"EncapIndexAllocator.cpp",
"FabricConnectivityManager.cpp",
"FibHelpers.cpp",
"FsdbAdaptedSubManager.cpp",
"FsdbSyncer.cpp",
"HwAsicTable.cpp",
"HwSwitchConnectionStatusTable.cpp",
Expand Down Expand Up @@ -721,6 +736,7 @@ cpp_library(
":fboss-error",
":fboss-event-base",
":fboss-types",
":fsdb_adapted_sub_manager",
":hw_switch_handler",
":hwswitchcallback",
":l2learn_event_observer",
Expand Down Expand Up @@ -1181,6 +1197,7 @@ cpp_library(
":fboss-error",
":fboss-types",
":hwswitch_matcher",
":switchinfo_utils",
"//fboss/agent/state:state",
],
exported_external_deps = [
Expand Down
2 changes: 1 addition & 1 deletion fboss/agent/DsfUpdateValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "fboss/agent/DsfUpdateValidator.h"
#include "fboss/agent/DsfStateUpdaterUtil.h"
#include "fboss/agent/Utils.h"
#include "fboss/agent/SwitchInfoUtils.h"
#include "fboss/agent/state/DeltaFunctions.h"
#include "fboss/agent/state/InterfaceMap.h"
#include "fboss/agent/state/StateDelta.h"
Expand Down
9 changes: 2 additions & 7 deletions fboss/agent/SwitchIdScopeResolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "fboss/agent/SwitchIdScopeResolver.h"
#include "fboss/agent/FbossError.h"
#include "fboss/agent/SwitchInfoUtils.h"
#include "fboss/agent/state/AclTableGroup.h"
#include "fboss/agent/state/AggregatePort.h"
#include "fboss/agent/state/ForwardingInformationBaseMap.h"
Expand Down Expand Up @@ -137,17 +138,11 @@ HwSwitchMatcher SwitchIdScopeResolver::scope(
}

HwSwitchMatcher SwitchIdScopeResolver::scope(SystemPortID sysPortId) const {
auto sysPortInt = static_cast<int64_t>(sysPortId);
for (const auto& [id, info] : switchIdToSwitchInfo_) {
if (!info.systemPortRange().has_value()) {
continue;
}
if (sysPortInt >= *info.systemPortRange()->minimum() &&
sysPortInt <= *info.systemPortRange()->maximum()) {
if (withinRange(*info.systemPortRanges(), sysPortId)) {
return HwSwitchMatcher(std::unordered_set<SwitchID>({SwitchID(id)}));
}
}

// This is a non local sys port. So it maps to all local voq switchIds
return voqSwitchMatcher();
}
Expand Down
33 changes: 23 additions & 10 deletions fboss/agent/SwitchInfoUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,20 @@
#include "fboss/agent/hw/switch_asics/HwAsic.h"

namespace facebook::fboss {
namespace {

bool withinRange(const cfg::SystemPortRanges& ranges, int64_t id) {
bool inRange{false};
for (const auto& sysPortRange : *ranges.systemPortRanges()) {
if (id >= *sysPortRange.minimum() && id <= *sysPortRange.maximum()) {
inRange = true;
break;
}
}
return inRange;
}
} // namespace

const std::map<int64_t, cfg::SwitchInfo> getSwitchInfoFromConfigImpl(
const cfg::SwitchConfig* config) {
std::map<int64_t, cfg::SwitchInfo> switchInfoMap;
Expand All @@ -32,16 +46,6 @@ const std::map<int64_t, cfg::SwitchInfo> getSwitchInfoFromConfigImpl(
switchInfo.portIdRange()->maximum() =
cfg::switch_config_constants::DEFAULT_PORT_ID_RANGE_MAX();
}
if (switchInfo.switchType() == cfg::SwitchType::VOQ &&
!switchInfo.systemPortRange()) {
auto dsfItr =
config->dsfNodes()->find(static_cast<int64_t>(entry.first));
if (dsfItr != config->dsfNodes()->end()) {
auto localNode = dsfItr->second;
CHECK(localNode.systemPortRange().has_value());
switchInfo.systemPortRange() = *localNode.systemPortRange();
}
}
switchInfoMap.emplace(entry.first, switchInfo);
}
}
Expand Down Expand Up @@ -106,4 +110,13 @@ const std::optional<cfg::SdkVersion> getSdkVersionFromConfig(
auto& swConfig = config->thrift.sw().value();
return getSdkVersionFromConfigImpl(&swConfig);
}

bool withinRange(const cfg::SystemPortRanges& ranges, InterfaceID intfId) {
return withinRange(ranges, static_cast<int64_t>(intfId));
}

bool withinRange(const cfg::SystemPortRanges& ranges, SystemPortID sysPortId) {
return withinRange(ranges, static_cast<int64_t>(sysPortId));
}

} // namespace facebook::fboss
3 changes: 3 additions & 0 deletions fboss/agent/SwitchInfoUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,7 @@ const std::optional<cfg::SdkVersion> getSdkVersionFromConfig();
const std::optional<cfg::SdkVersion> getSdkVersionFromConfig(
const AgentConfig* config);

bool withinRange(const cfg::SystemPortRanges& ranges, InterfaceID intfId);

bool withinRange(const cfg::SystemPortRanges& ranges, SystemPortID sysPortId);
} // namespace facebook::fboss
69 changes: 0 additions & 69 deletions fboss/agent/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "fboss/agent/AsicUtils.h"
#include "fboss/agent/FbossError.h"
#include "fboss/agent/FsdbHelper.h"
#include "fboss/agent/SwitchIdScopeResolver.h"
#include "fboss/agent/SysError.h"
#include "fboss/agent/hw/HwSwitchFb303Stats.h"
#include "fboss/agent/state/ArpEntry.h"
Expand Down Expand Up @@ -139,16 +138,6 @@ getPlatformMappingForDsfNode(const facebook::fboss::PlatformType platformType) {
return nullptr;
}

bool withinRange(const cfg::SystemPortRanges& ranges, int64_t id) {
bool inRange{false};
for (const auto& sysPortRange : *ranges.systemPortRanges()) {
if (id >= *sysPortRange.minimum() && id <= *sysPortRange.maximum()) {
inRange = true;
break;
}
}
return inRange;
}
} // namespace
//

Expand Down Expand Up @@ -501,14 +490,6 @@ SystemPortID getInbandSystemPortID(
*switchInfoItr->second.inbandPortId());
}

bool withinRange(const cfg::SystemPortRanges& ranges, InterfaceID intfId) {
return withinRange(ranges, static_cast<int64_t>(intfId));
}

bool withinRange(const cfg::SystemPortRanges& ranges, SystemPortID sysPortId) {
return withinRange(ranges, static_cast<int64_t>(sysPortId));
}

cfg::Range64 getFirstSwitchSystemPortIdRange(
const std::map<int64_t, cfg::SwitchInfo>& switchToSwitchInfo) {
for (const auto& [switchId, switchInfo] : switchToSwitchInfo) {
Expand Down Expand Up @@ -1062,56 +1043,6 @@ int getRemoteSwitchID(
return remoteSwitchId;
};

bool haveParallelLinksToInterfaceNodes(
const cfg::SwitchConfig* cfg,
const std::vector<SwitchID>& localFabricSwitchIds,
const std::unordered_map<std::string, std::vector<uint32_t>>&
switchNameToSwitchIds,
SwitchIdScopeResolver& scopeResolver,
const PlatformMapping* platformMapping) {
for (const auto& fabricSwitchId : localFabricSwitchIds) {
// Determine parallel links on VD level - there are two VDs per R3 ASIC
std::unordered_map<int, std::unordered_set<std::string>> vd2VoqNeighbors;
for (const auto& port : *cfg->ports()) {
// Only process ports belonging to one switchId
if (scopeResolver.scope(port).has(SwitchID(fabricSwitchId)) &&
port.expectedNeighborReachability()->size() > 0) {
auto neighborRemoteSwitchId =
getRemoteSwitchID(cfg, port, switchNameToSwitchIds);
const auto& neighborDsfNodeIter =
cfg->dsfNodes()->find(neighborRemoteSwitchId);
CHECK(neighborDsfNodeIter != cfg->dsfNodes()->end());
if (*neighborDsfNodeIter->second.type() ==
cfg::DsfNodeType::INTERFACE_NODE) {
CHECK(port.name().has_value());
auto localVirtualDeviceId =
platformMapping->getVirtualDeviceID(*port.name());
if (!localVirtualDeviceId.has_value()) {
throw FbossError(
"Unable to find virtual device id for port: ",
*port.logicalID(),
" virtual device");
}

if (vd2VoqNeighbors.find(localVirtualDeviceId.value()) ==
vd2VoqNeighbors.end()) {
vd2VoqNeighbors.insert(
{localVirtualDeviceId.value(),
std::unordered_set<std::string>()});
}
auto& voqNeighbors = vd2VoqNeighbors[localVirtualDeviceId.value()];
const auto& [neighborName, _] = getExpectedNeighborAndPortName(port);
if (voqNeighbors.find(neighborName) != voqNeighbors.end()) {
return true;
}
voqNeighbors.insert(neighborName);
}
}
}
}
return false;
};

CpuCosQueueId hwQueueIdToCpuCosQueueId(
uint8_t hwQueueId,
const HwAsic* asic,
Expand Down
12 changes: 0 additions & 12 deletions fboss/agent/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ inline const int kUdfAclRethDmaLenFieldSizeInBytes(2);
class SwitchState;
class Interface;
class SwitchSettings;
class SwitchIdScopeResolver;
class PlatformMapping;
struct AgentConfig;
class HwAsic;
Expand Down Expand Up @@ -276,9 +275,6 @@ std::vector<PortID> getPortsForInterface(
InterfaceID intf,
const std::shared_ptr<SwitchState>& state);

bool withinRange(const cfg::SystemPortRanges& ranges, InterfaceID intfId);

bool withinRange(const cfg::SystemPortRanges& ranges, SystemPortID sysPortId);
/*
* An NPU switch injects a broadcast message such as neighbor solicitation or
* advertisement via pipeline lookup. ASIC forwards these messages to all the
Expand Down Expand Up @@ -443,14 +439,6 @@ int getRemoteSwitchID(
const std::unordered_map<std::string, std::vector<uint32_t>>&
switchNameToSwitchIds);

bool haveParallelLinksToInterfaceNodes(
const cfg::SwitchConfig* cfg,
const std::vector<SwitchID>& localFabricSwitchIds,
const std::unordered_map<std::string, std::vector<uint32_t>>&
switchNameToSwitchIds,
SwitchIdScopeResolver& scopeResolver,
const PlatformMapping* platformMapping);

CpuCosQueueId hwQueueIdToCpuCosQueueId(
uint8_t hwQueueId,
const HwAsic* asic,
Expand Down
Loading

0 comments on commit 668f2f8

Please sign in to comment.