Skip to content

Commit

Permalink
[fastboot] Notify SAI that fastboot is done (#1396)
Browse files Browse the repository at this point in the history
Notify SAI that fastboot is done
Set SAI_SWITCH_ATTR_FAST_API_ENABLE to false when fastboot is done
  • Loading branch information
Junchao-Mellanox authored Oct 23, 2024
1 parent 952ee40 commit 40979e0
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 5 deletions.
4 changes: 4 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ AX_ADD_AM_MACRO_STATIC([])

AM_CONDITIONAL(SONIC_ASIC_PLATFORM_BAREFOOT, test x$CONFIGURED_PLATFORM = xbarefoot)
AM_CONDITIONAL(SONIC_ASIC_PLATFORM_BROADCOM, test x$CONFIGURED_PLATFORM = xbroadcom)
AM_CONDITIONAL(SONIC_ASIC_PLATFORM_MELLANOX, test x$CONFIGURED_PLATFORM = xmellanox)

AM_COND_IF([SONIC_ASIC_PLATFORM_MELLANOX],
AC_DEFINE([MELLANOX], [1], [Define to 1 on Mellanox Platform]))

AC_ARG_ENABLE(debug,
[ --enable-debug turn on debugging],
Expand Down
12 changes: 9 additions & 3 deletions syncd/Syncd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3819,9 +3819,15 @@ sai_status_t Syncd::processNotifySyncd(
m_veryFirstRun = false;

m_asicInitViewMode = false;

if (m_commandLineOptions->m_startType == SAI_START_TYPE_FASTFAST_BOOT ||
m_commandLineOptions->m_startType == SAI_START_TYPE_EXPRESS_BOOT)
#ifdef MELLANOX
bool applyViewInFastFastBoot = m_commandLineOptions->m_startType == SAI_START_TYPE_FASTFAST_BOOT ||
m_commandLineOptions->m_startType == SAI_START_TYPE_EXPRESS_BOOT ||
m_commandLineOptions->m_startType == SAI_START_TYPE_FAST_BOOT;
#else
bool applyViewInFastFastBoot = m_commandLineOptions->m_startType == SAI_START_TYPE_FASTFAST_BOOT ||
m_commandLineOptions->m_startType == SAI_START_TYPE_EXPRESS_BOOT;
#endif
if (applyViewInFastFastBoot)
{
// express/fastfast boot configuration end

Expand Down
5 changes: 3 additions & 2 deletions unittest/syncd/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ AM_CXXFLAGS = $(SAIINC) -I$(top_srcdir)/syncd -I$(top_srcdir)/lib -I$(top_srcdir

bin_PROGRAMS = tests

LDADD_GTEST = -L/usr/src/gtest -lgtest -lgtest_main
LDADD_GTEST = -L/usr/src/gtest -lgtest -lgtest_main -lgmock

tests_SOURCES = main.cpp \
MockableSaiInterface.cpp \
Expand All @@ -17,7 +17,8 @@ tests_SOURCES = main.cpp \
TestMdioIpcServer.cpp \
TestPortStateChangeHandler.cpp \
TestWorkaround.cpp \
TestVendorSai.cpp
TestVendorSai.cpp \
TestSyncd.cpp

tests_CXXFLAGS = $(DBGFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS_COMMON)
tests_LDFLAGS = -Wl,-rpath,$(top_srcdir)/lib/.libs -Wl,-rpath,$(top_srcdir)/meta/.libs
Expand Down
61 changes: 61 additions & 0 deletions unittest/syncd/TestSyncd.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#include "Syncd.h"
#include "MockableSaiInterface.h"
#include "CommandLineOptions.h"
#include "sairediscommon.h"
#include "SelectableChannel.h"
#include "swss/dbconnector.h"
#include "swss/redisreply.h"

#include <gtest/gtest.h>
#include <gmock/gmock.h>

using namespace syncd;

class MockSelectableChannel : public sairedis::SelectableChannel {
public:
MOCK_METHOD(bool, empty, (), (override));
MOCK_METHOD(void, pop, (swss::KeyOpFieldsValuesTuple& kco, bool initViewMode), (override));
MOCK_METHOD(void, set, (const std::string& key, const std::vector<swss::FieldValueTuple>& values, const std::string& op), (override));
MOCK_METHOD(int, getFd, (), (override));
MOCK_METHOD(uint64_t, readData, (), (override));
};

void clearDB()
{
SWSS_LOG_ENTER();

swss::DBConnector db("ASIC_DB", 0, true);
swss::RedisReply r(&db, "FLUSHALL", REDIS_REPLY_STATUS);

r.checkStatusOK();
}

class SyncdTest : public ::testing::Test
{
protected:
void SetUp() override
{
clearDB();
}
void TearDown() override
{
clearDB();
}
};

TEST_F(SyncdTest, processNotifySyncd)
{
auto sai = std::make_shared<MockableSaiInterface>();
auto opt = std::make_shared<syncd::CommandLineOptions>();
opt->m_enableTempView = true;
opt->m_startType = SAI_START_TYPE_FASTFAST_BOOT;
syncd::Syncd syncd_object(sai, opt, false);

MockSelectableChannel consumer;
EXPECT_CALL(consumer, empty()).WillOnce(testing::Return(true));
EXPECT_CALL(consumer, pop(testing::_, testing::_)).WillOnce(testing::Invoke([](swss::KeyOpFieldsValuesTuple& kco, bool initViewMode) {
kfvKey(kco) = SYNCD_APPLY_VIEW;
kfvOp(kco) = REDIS_ASIC_STATE_COMMAND_NOTIFY;
}));
syncd_object.processEvent(consumer);
}

0 comments on commit 40979e0

Please sign in to comment.