Skip to content

Commit

Permalink
Merge pull request facebook#88 from eerpini/fboss_upstream_09_21_2023
Browse files Browse the repository at this point in the history
Fboss upstream 09 21 2023
  • Loading branch information
eerpini committed Sep 23, 2023
2 parents 4b5740c + 943f6d1 commit 1983de1
Show file tree
Hide file tree
Showing 217 changed files with 82,255 additions and 59,594 deletions.
11 changes: 10 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ if (SAI_BRCM_IMPL)
endif()

set(SAI_VER_MAJOR "1")
set(SAI_VER_MINOR "12")
set(SAI_VER_MINOR "13")
set(SAI_VER_RELEASE "0")

if (NOT "$ENV{SAI_SDK_VERSION}" STREQUAL "")
Expand Down Expand Up @@ -493,6 +493,14 @@ add_fbthrift_cpp_library(
led_mapping_cpp2
)

add_fbthrift_cpp_library(
led_config_cpp2
fboss/led_service/if/led_service_config.thrift
OPTIONS
json
reflection
)

add_fbthrift_cpp_library(
qsfp_cpp2
fboss/qsfp_service/if/qsfp.thrift
Expand Down Expand Up @@ -611,4 +619,5 @@ add_dependencies(fboss_platform_services
platform_manager
fw_util
weutil
led_service
)
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 1d8ab82da0d27300488a1a964ff00d29af91ac3d
Subproject commit f19dcc844c67fda832ec068968b58d5c0e08e761
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 011378a05af8d6e536d5f3ce6446e041ec69572a
Subproject commit 5e139c2dcf78c4e97d7fdd187ce43d598f1b5c86
6 changes: 3 additions & 3 deletions build/fbcode_builder/manifests/libsai
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
name = libsai

[download]
url = https://github.com/opencomputeproject/SAI/archive/v1.12.0.tar.gz
sha256 = 1e7f43599baf1dcca122bbbb2baaeb9b20e5632d2ca6aaa61a568d1d58afaa97
url = https://github.com/opencomputeproject/SAI/archive/v1.13.0.tar.gz
sha256 = bb8c5d6cb0c7897422875d0da7b903708d1a15557ad07c6d6266dff83cb8c78d

[build]
builder = nop
subdir = SAI-1.12.0
subdir = SAI-1.13.0

[install.files]
inc = include
Expand Down
5 changes: 5 additions & 0 deletions cmake/AgentHwSwitchAsics.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
# In general, libraries and binaries in fboss/foo/bar are built by
# cmake/FooBar.cmake

add_library(version_util
fboss/agent/hw/sai/impl/util.cpp
)

add_library(switch_asics
fboss/agent/hw/switch_asics/FakeAsic.h
fboss/agent/hw/switch_asics/EbroAsic.cpp
Expand All @@ -28,4 +32,5 @@ target_link_libraries(switch_asics
fboss_cpp2
phy_cpp2
switch_config_cpp2
version_util
)
18 changes: 18 additions & 0 deletions cmake/LedService.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ add_fbthrift_cpp_library(
ctrl_cpp2
)

add_library(led_config
fboss/led_service/LedConfig.cpp
)

target_link_libraries(led_config
error
led_config_cpp2
Folly::folly
FBThrift::thriftcpp2
)

add_library(led_core_lib
fboss/led_service/BspLedManager.cpp
fboss/led_service/FsdbSwitchStateSubscriber.cpp
Expand All @@ -43,22 +54,29 @@ add_library(led_core_lib
fboss/led_service/LedServiceHandler.cpp
fboss/led_service/MinipackBaseLedManager.cpp
fboss/led_service/MontblancLedManager.cpp
fboss/led_service/Meru800biaLedManager.cpp
fboss/led_service/Meru800bfaLedManager.cpp
)

target_link_libraries(led_core_lib
bsp_platform_mapping_cpp2
qsfp_bsp_core
ledIO
led_config
led_structs_types_cpp2
led_service_types_cpp2
log_thrift_call
montblanc_bsp
meru800bia_bsp
meru800bfa_bsp
darwin_platform_mapping
elbert_platform_mapping
fuji_platform_mapping
lassen_platform_mapping
minipack_platform_mapping
montblanc_platform_mapping
meru800bia_platform_mapping
meru800bfa_platform_mapping
wedge400_platform_mapping
yamp_platform_mapping
product_info
Expand Down
4 changes: 3 additions & 1 deletion fboss/agent/ApplyThriftConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -874,8 +874,10 @@ void ThriftConfigApplier::processUpdatedDsfNodes() {
node->getAsicType(),
cfg::SwitchType::VOQ,
static_cast<int64_t>(node->getSwitchId()),
0, /* dummy switchIndex*/
node->getSystemPortRange(),
mac);
mac,
std::nullopt);
};
auto processLoopbacks = [&](const std::shared_ptr<DsfNode>& node,
const HwAsic* dsfNodeAsic) {
Expand Down
1 change: 1 addition & 0 deletions fboss/agent/FabricReachabilityManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ static const PlatformMapping* FOLLY_NULLABLE getPlatformMappingForDsfNode(
return &meru800bfa;
break;
case PlatformType::PLATFORM_MERU800BIA:
*remotePortOffset = 1024;
return &meru800bia;
default:
break;
Expand Down
38 changes: 37 additions & 1 deletion fboss/agent/HwAgentMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "fboss/agent/CommonInit.h"
#include "fboss/agent/FbossInit.h"
#include "fboss/agent/HwAgent.h"
#include "fboss/agent/HwSwitch.h"
#include "fboss/agent/RestartTimeTracker.h"
#include "fboss/agent/SetupThrift.h"
#include "fboss/agent/hw/switch_asics/HwAsic.h"
Expand All @@ -29,8 +30,20 @@ DEFINE_int32(

DEFINE_int32(swswitch_port, 5959, "Port for SwSwitch");

DEFINE_bool(enable_stats_update_thread, true, "Run stats update thread");

using namespace std::chrono;

namespace {

/*
* This function is executed periodically by the UpdateStats thread.
*/
void updateStats(facebook::fboss::HwSwitch* hw) {
hw->updateStats();
}
} // namespace

namespace facebook::fboss {

void SplitHwAgentSignalHandler::signalReceived(int /*signum*/) noexcept {
Expand Down Expand Up @@ -83,6 +96,22 @@ int hwAgentMain(

thriftSyncer->start();

std::unique_ptr<folly::FunctionScheduler> fs{nullptr};
if (FLAGS_enable_stats_update_thread) {
// Start the UpdateSwitchStatsThread
fs.reset(new folly::FunctionScheduler());
fs->setThreadName("UpdateStatsThread");
// steady will help even out the interval which will especially make
// aggregated counters more accurate with less spikes and dips
fs->setSteady(true);
std::function<void()> callback(
std::bind(updateStats, hwAgent->getPlatform()->getHwSwitch()));
auto timeInterval = std::chrono::seconds(1);
fs->addFunction(callback, timeInterval, "updateStats");
fs->start();
XLOG(DBG2) << "Started background thread: UpdateStatsThread";
}

folly::EventBase eventBase;
auto server = setupThriftServer(
eventBase,
Expand All @@ -91,7 +120,14 @@ int hwAgentMain(
true /*setupSSL*/);

SplitHwAgentSignalHandler signalHandler(
&eventBase, [&thriftSyncer]() { thriftSyncer->stop(); }, hwAgent.get());
&eventBase,
[&thriftSyncer, &fs]() {
thriftSyncer->stop();
if (fs) {
fs->shutdown();
}
},
hwAgent.get());

restart_time::mark(RestartEvent::INITIALIZED);

Expand Down
7 changes: 5 additions & 2 deletions fboss/agent/HwAsicTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

namespace facebook::fboss {
HwAsicTable::HwAsicTable(
const std::map<int64_t, cfg::SwitchInfo>& switchIdToSwitchInfo) {
const std::map<int64_t, cfg::SwitchInfo>& switchIdToSwitchInfo,
std::optional<cfg::SdkVersion> sdkVersion) {
for (const auto& switchIdAndSwitchInfo : switchIdToSwitchInfo) {
folly::MacAddress mac;
if (switchIdAndSwitchInfo.second.switchMac()) {
Expand All @@ -31,8 +32,10 @@ HwAsicTable::HwAsicTable(
*switchIdAndSwitchInfo.second.asicType(),
*switchIdAndSwitchInfo.second.switchType(),
switchIdAndSwitchInfo.first,
*switchIdAndSwitchInfo.second.switchIndex(),
systemPortRange,
mac));
mac,
sdkVersion));
}
}

Expand Down
3 changes: 2 additions & 1 deletion fboss/agent/HwAsicTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ namespace facebook::fboss {
class HwAsicTable {
public:
explicit HwAsicTable(
const std::map<int64_t, cfg::SwitchInfo>& switchIdToSwitchInfo);
const std::map<int64_t, cfg::SwitchInfo>& switchIdToSwitchInfo,
std::optional<cfg::SdkVersion> sdkVersion);
const HwAsic* getHwAsicIf(SwitchID switchID) const;
HwAsic* getHwAsicIf(SwitchID switchID);
const HwAsic* getHwAsic(SwitchID switchID) const;
Expand Down
4 changes: 2 additions & 2 deletions fboss/agent/HwSwitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ void HwSwitch::switchRunStateChanged(SwitchRunState newState) {
}
}

void HwSwitch::updateStats(SwitchStats* switchStats) {
updateStatsImpl(switchStats);
void HwSwitch::updateStats() {
updateStatsImpl();
// send to normalizer
auto normalizer = Normalizer::getInstance();
if (normalizer) {
Expand Down
4 changes: 2 additions & 2 deletions fboss/agent/HwSwitch.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ class HwSwitch {
/*
* Allows hardware-specific code to record switch statistics.
*/
void updateStats(SwitchStats* switchStats);
void updateStats();

virtual folly::F14FastMap<std::string, HwPortStats> getPortStats() const = 0;
virtual CpuPortStats getCpuPortStats() const = 0;
Expand Down Expand Up @@ -380,7 +380,7 @@ class HwSwitch {
bool failHwCallsOnWarmboot) = 0;
virtual void switchRunStateChangedImpl(SwitchRunState newState) = 0;

virtual void updateStatsImpl(SwitchStats* switchStats) = 0;
virtual void updateStatsImpl() = 0;

virtual void gracefulExitImpl() = 0;

Expand Down
20 changes: 13 additions & 7 deletions fboss/agent/IPv6Handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -526,13 +526,19 @@ void IPv6Handler::handleNeighborSolicitation(

// Send the response. To reply the neighbor solicitation, we can use the
// src port of such packet to send back the neighbor advertisement.
sendNeighborAdvertisement(
vlanID,
entry->getMac(),
targetIP,
hdr.src,
hdr.ipv6->srcAddr,
srcPortDescriptor);
if (entry) {
sendNeighborAdvertisement(
vlanID,
entry->getMac(),
targetIP,
hdr.src,
hdr.ipv6->srcAddr,
srcPortDescriptor);
} else {
XLOG(DBG2) << "Dropping NS ingressing on port " << pkt->getSrcPort()
<< " on vlan " << vlanIDStr << " for " << targetIP
<< " due to missing mac ";
}
}

template <typename VlanOrIntfT>
Expand Down
9 changes: 6 additions & 3 deletions fboss/agent/MultiSwitchThriftHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ MultiSwitchThriftHandler::co_notifyLinkEvent(int64_t switchId) {
co_return true;
},
10 /* buffer size */
};
}
.setChunkTimeout(std::chrono::milliseconds(0));
}

folly::coro::Task<apache::thrift::SinkConsumer<multiswitch::FdbEvent, bool>>
Expand All @@ -83,7 +84,8 @@ MultiSwitchThriftHandler::co_notifyFdbEvent(int64_t switchId) {
co_return true;
},
10 /* buffer size */
};
}
.setChunkTimeout(std::chrono::milliseconds(0));
}

folly::coro::Task<apache::thrift::SinkConsumer<multiswitch::RxPacket, bool>>
Expand All @@ -108,7 +110,8 @@ MultiSwitchThriftHandler::co_notifyRxPacket(int64_t switchId) {
co_return true;
},
1000 /* buffer size */
};
}
.setChunkTimeout(std::chrono::milliseconds(0));
}

folly::coro::Task<apache::thrift::ServerStream<multiswitch::TxPacket>>
Expand Down
3 changes: 3 additions & 0 deletions fboss/agent/SwAgentInitializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ int SwAgentInitializer::initAgent(HwSwitchCallback* callback) {
{FLAGS_port, FLAGS_migrated_port},
true /*setupSSL*/);

server_->setStreamExpireTime(std::chrono::milliseconds(0));
server_->setIdleTimeout(std::chrono::milliseconds(0));

swHandler->setSSLPolicy(server_->getSSLPolicy());

// At this point, we are guaranteed no other agent process will initialize
Expand Down
4 changes: 3 additions & 1 deletion fboss/agent/SwSwitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,9 @@ SwSwitch::SwSwitch(
teFlowNextHopHandler_(new TeFlowNexthopHandler(this)),
dsfSubscriber_(new DsfSubscriber(this)),
switchInfoTable_(getSwitchInfoFromConfig(config)),
hwAsicTable_(new HwAsicTable(getSwitchInfoFromConfig(config))),
hwAsicTable_(new HwAsicTable(
getSwitchInfoFromConfig(config),
getSdkVersionFromConfig(config))),
scopeResolver_(
new SwitchIdScopeResolver(getSwitchInfoFromConfig(config))),
switchStatsObserver_(new SwitchStatsObserver(this)),
Expand Down
31 changes: 31 additions & 0 deletions fboss/agent/SwitchInfoUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
*
*/
#include "fboss/agent/SwitchInfoUtils.h"
#include <atomic>
#include <optional>

#include "fboss/agent/AgentConfig.h"
#include "fboss/agent/FbossError.h"
Expand Down Expand Up @@ -76,4 +78,33 @@ const std::map<int64_t, cfg::SwitchInfo> getSwitchInfoFromConfig(
auto& swConfig = config->thrift.sw().value();
return getSwitchInfoFromConfig(&swConfig);
}

const std::optional<cfg::SdkVersion> getSdkVersionFromConfigImpl(
const cfg::SwitchConfig* config) {
std::optional<cfg::SdkVersion> sdkVersion = std::nullopt;
if (config->sdkVersion().has_value()) {
sdkVersion = *config->sdkVersion();
}
return sdkVersion;
}

const std::optional<cfg::SdkVersion> getSdkVersionFromConfig() {
std::unique_ptr<AgentConfig> config;
try {
config = AgentConfig::fromDefaultFile();
} catch (const std::exception& e) {
return std::nullopt;
}
auto swConfig = config->thrift.sw();
return getSdkVersionFromConfigImpl(&(swConfig.value()));
}

const std::optional<cfg::SdkVersion> getSdkVersionFromConfig(
const AgentConfig* config) {
if (!config) {
return getSdkVersionFromConfig();
}
auto& swConfig = config->thrift.sw().value();
return getSdkVersionFromConfigImpl(&swConfig);
}
} // namespace facebook::fboss
8 changes: 8 additions & 0 deletions fboss/agent/SwitchInfoUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,12 @@ const std::map<int64_t, cfg::SwitchInfo> getSwitchInfoFromConfig(

const std::map<int64_t, cfg::SwitchInfo> getSwitchInfoFromConfig();

const std::optional<cfg::SdkVersion> getSdkVersionFromConfigImpl(
const cfg::SwitchConfig* config);

const std::optional<cfg::SdkVersion> getSdkVersionFromConfig();

const std::optional<cfg::SdkVersion> getSdkVersionFromConfig(
const AgentConfig* config);

} // namespace facebook::fboss

0 comments on commit 1983de1

Please sign in to comment.