diff --git a/meta/SaiInterface.cpp b/meta/SaiInterface.cpp index c91d08275..3a95bc017 100644 --- a/meta/SaiInterface.cpp +++ b/meta/SaiInterface.cpp @@ -378,20 +378,3 @@ sai_status_t SaiInterface::clearStats( return SAI_STATUS_NOT_IMPLEMENTED; } - -std::shared_ptr SaiInterface::getOptions( - _In_ const std::string& key) -{ - SWSS_LOG_ENTER(); - - return m_optionsMap[key]; -} - -void SaiInterface::setOptions( - _In_ const std::string& key, - _In_ std::shared_ptr options) -{ - SWSS_LOG_ENTER(); - - m_optionsMap[key] = options; -} diff --git a/meta/SaiInterface.h b/meta/SaiInterface.h index 1f694c040..fb78e1569 100644 --- a/meta/SaiInterface.h +++ b/meta/SaiInterface.h @@ -5,12 +5,6 @@ extern "C" { #include "saimetadata.h" } -#include "SaiOptions.h" - -#include -#include -#include - #define SAIREDIS_DECLARE_EVERY_ENTRY(_X) \ SAI_METADATA_DECLARE_EVERY_ENTRY(_X) @@ -346,18 +340,5 @@ namespace sairedis virtual sai_log_level_t logGet( _In_ sai_api_t api); - - public: // non SAI API - options helper - - std::shared_ptr getOptions( - _In_ const std::string& key); - - void setOptions( - _In_ const std::string& key, - _In_ std::shared_ptr options); - - private: - - std::map> m_optionsMap; }; } diff --git a/meta/SaiOptions.h b/meta/SaiOptions.h deleted file mode 100644 index 2d053c6c5..000000000 --- a/meta/SaiOptions.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -namespace sairedis -{ - class SaiOptions - { - public: - - virtual ~SaiOptions() = default; - }; -} diff --git a/syncd/HardReiniter.cpp b/syncd/HardReiniter.cpp index 8c714eb23..9b621f8b0 100644 --- a/syncd/HardReiniter.cpp +++ b/syncd/HardReiniter.cpp @@ -13,11 +13,13 @@ HardReiniter::HardReiniter( _In_ std::shared_ptr client, _In_ std::shared_ptr translator, _In_ std::shared_ptr sai, - _In_ std::shared_ptr handler): + _In_ std::shared_ptr handler, + _In_ bool checkAttrVersion): m_vendorSai(sai), m_translator(translator), m_client(client), - m_handler(handler) + m_handler(handler), + m_checkAttrVersion(checkAttrVersion) { SWSS_LOG_ENTER(); @@ -99,7 +101,8 @@ std::map> HardReiniter::hardR m_handler, m_switchVidToRid.at(kvp.first), m_switchRidToVid.at(kvp.first), - kvp.second); + kvp.second, + m_checkAttrVersion); sr->hardReinit(); diff --git a/syncd/HardReiniter.h b/syncd/HardReiniter.h index 9a032d16e..435f38f16 100644 --- a/syncd/HardReiniter.h +++ b/syncd/HardReiniter.h @@ -27,7 +27,8 @@ namespace syncd _In_ std::shared_ptr client, _In_ std::shared_ptr translator, _In_ std::shared_ptr sai, - _In_ std::shared_ptr handler); + _In_ std::shared_ptr handler, + _In_ bool checkAttrVersion); virtual ~HardReiniter(); @@ -59,5 +60,7 @@ namespace syncd std::shared_ptr m_client; std::shared_ptr m_handler; + + bool m_checkAttrVersion; }; } diff --git a/syncd/SaiDiscovery.cpp b/syncd/SaiDiscovery.cpp index 3ba89bc98..43e01016a 100644 --- a/syncd/SaiDiscovery.cpp +++ b/syncd/SaiDiscovery.cpp @@ -1,5 +1,4 @@ #include "SaiDiscovery.h" -#include "VendorSaiOptions.h" #include "swss/logger.h" @@ -20,7 +19,8 @@ using namespace syncd; #define SAI_DISCOVERY_LIST_MAX_ELEMENTS 1024 SaiDiscovery::SaiDiscovery( - _In_ std::shared_ptr sai): + _In_ std::shared_ptr sai, + _In_ bool checkAttrVersion): m_sai(sai) { SWSS_LOG_ENTER(); @@ -31,16 +31,10 @@ SaiDiscovery::SaiDiscovery( if (status == SAI_STATUS_SUCCESS) { - auto vso = std::dynamic_pointer_cast(sai->getOptions(VendorSaiOptions::OPTIONS_KEY)); - - // TODO check vso for null - - m_attrVersionChecker.enable(vso->m_checkAttrVersion); + m_attrVersionChecker.enable(checkAttrVersion); m_attrVersionChecker.setSaiApiVersion(version); - SWSS_LOG_NOTICE("check attr version %s, libsai api version: %lu", - (vso->m_checkAttrVersion ? "ENABLED" : "DISABLED"), - version); + SWSS_LOG_NOTICE("check attr version ENABLED, libsai api version: %lu", version); } else { diff --git a/syncd/SaiDiscovery.h b/syncd/SaiDiscovery.h index b6f8cf053..c677a5b87 100644 --- a/syncd/SaiDiscovery.h +++ b/syncd/SaiDiscovery.h @@ -20,7 +20,8 @@ namespace syncd public: SaiDiscovery( - _In_ std::shared_ptr sai); + _In_ std::shared_ptr sai, + _In_ bool checkAttrVersion); virtual ~SaiDiscovery(); diff --git a/syncd/SaiSwitch.cpp b/syncd/SaiSwitch.cpp index fb711db4d..4f11dba4c 100644 --- a/syncd/SaiSwitch.cpp +++ b/syncd/SaiSwitch.cpp @@ -26,12 +26,14 @@ SaiSwitch::SaiSwitch( _In_ std::shared_ptr client, _In_ std::shared_ptr translator, _In_ std::shared_ptr vendorSai, - _In_ bool warmBoot): + _In_ bool warmBoot, + _In_ bool checkAttrVersion): SaiSwitchInterface(switch_vid, switch_rid), m_vendorSai(vendorSai), m_warmBoot(warmBoot), m_translator(translator), - m_client(client) + m_client(client), + m_checkAttrVersion(checkAttrVersion) { SWSS_LOG_ENTER(); @@ -661,7 +663,7 @@ void SaiSwitch::helperDiscover() { SWSS_LOG_ENTER(); - SaiDiscovery sd(m_vendorSai); + SaiDiscovery sd(m_vendorSai, m_checkAttrVersion); m_discovered_rids = sd.discover(m_switch_rid); @@ -952,7 +954,7 @@ void SaiSwitch::onPostPortCreate( { SWSS_LOG_ENTER(); - SaiDiscovery sd(m_vendorSai); + SaiDiscovery sd(m_vendorSai, m_checkAttrVersion); auto discovered = sd.discover(port_rid); diff --git a/syncd/SaiSwitch.h b/syncd/SaiSwitch.h index d6bccfeed..4c317678a 100644 --- a/syncd/SaiSwitch.h +++ b/syncd/SaiSwitch.h @@ -34,7 +34,8 @@ namespace syncd _In_ std::shared_ptr client, _In_ std::shared_ptr translator, _In_ std::shared_ptr vendorSai, - _In_ bool warmBoot); + _In_ bool warmBoot, + _In_ bool checkAttrVersion); virtual ~SaiSwitch() = default; @@ -353,5 +354,7 @@ namespace syncd std::shared_ptr m_translator; std::shared_ptr m_client; + + bool m_checkAttrVersion; }; } diff --git a/syncd/SingleReiniter.cpp b/syncd/SingleReiniter.cpp index 6f5355736..6844d3cf7 100644 --- a/syncd/SingleReiniter.cpp +++ b/syncd/SingleReiniter.cpp @@ -22,14 +22,16 @@ SingleReiniter::SingleReiniter( _In_ std::shared_ptr handler, _In_ const ObjectIdMap& vidToRidMap, _In_ const ObjectIdMap& ridToVidMap, - _In_ const std::vector& asicKeys): + _In_ const std::vector& asicKeys, + _In_ bool checkAttrVersion): m_vendorSai(sai), m_vidToRidMap(vidToRidMap), m_ridToVidMap(ridToVidMap), m_asicKeys(asicKeys), m_translator(translator), m_client(client), - m_handler(handler) + m_handler(handler), + m_checkAttrVersion(checkAttrVersion) { SWSS_LOG_ENTER(); @@ -317,7 +319,7 @@ void SingleReiniter::processSwitches() * object, so when doing discover we will get full default ASIC view. */ - m_sw = std::make_shared(m_switch_vid, m_switch_rid, m_client, m_translator, m_vendorSai, false); + m_sw = std::make_shared(m_switch_vid, m_switch_rid, m_client, m_translator, m_vendorSai, false, m_checkAttrVersion); /* * We processed switch. We have switch vid/rid so we can process all diff --git a/syncd/SingleReiniter.h b/syncd/SingleReiniter.h index e33b26af8..b6a27eaab 100644 --- a/syncd/SingleReiniter.h +++ b/syncd/SingleReiniter.h @@ -32,7 +32,8 @@ namespace syncd _In_ std::shared_ptr handler, _In_ const ObjectIdMap& vidToRidMap, _In_ const ObjectIdMap& ridToVidMap, - _In_ const std::vector& asicKeys); + _In_ const std::vector& asicKeys, + _In_ bool checkAttrVersion); virtual ~SingleReiniter(); @@ -136,5 +137,7 @@ namespace syncd std::shared_ptr m_client; std::shared_ptr m_handler; + + bool m_checkAttrVersion; }; } diff --git a/syncd/Syncd.cpp b/syncd/Syncd.cpp index 6c06a4fd5..83f6b18ba 100644 --- a/syncd/Syncd.cpp +++ b/syncd/Syncd.cpp @@ -12,7 +12,6 @@ #include "RedisNotificationProducer.h" #include "ZeroMQNotificationProducer.h" #include "WatchdogScope.h" -#include "VendorSaiOptions.h" #include "sairediscommon.h" @@ -110,12 +109,6 @@ Syncd::Syncd( m_enableSyncMode = true; } - auto vso = std::make_shared(); - - vso->m_checkAttrVersion = m_commandLineOptions->m_enableAttrVersionCheck; - - m_vendorSai->setOptions(VendorSaiOptions::OPTIONS_KEY, vso); - m_manager = std::make_shared(m_vendorSai, m_contextConfig->m_dbCounters, m_commandLineOptions->m_supportingBulkCounterGroups); loadProfileMap(); @@ -3143,7 +3136,7 @@ sai_status_t Syncd::processOidCreate( * constructor, like getting all queues, ports, etc. */ - m_switches[switchVid] = std::make_shared(switchVid, objectRid, m_client, m_translator, m_vendorSai, false); + m_switches[switchVid] = std::make_shared(switchVid, objectRid, m_client, m_translator, m_vendorSai, false, m_commandLineOptions->m_enableAttrVersionCheck); m_mdioIpcServer->setSwitchId(objectRid); @@ -4360,7 +4353,7 @@ void Syncd::onSyncdStart( SWSS_LOG_THROW("performing hard reinit, but there are %zu switches defined, bug!", m_switches.size()); } - HardReiniter hr(m_client, m_translator, m_vendorSai, m_handler); + HardReiniter hr(m_client, m_translator, m_vendorSai, m_handler, m_commandLineOptions->m_enableAttrVersionCheck); m_switches = hr.hardReinit(); @@ -4462,7 +4455,7 @@ void Syncd::onSwitchCreateInInitViewMode( // make switch initialization and get all default data - m_switches[switchVid] = std::make_shared(switchVid, switchRid, m_client, m_translator, m_vendorSai, false); + m_switches[switchVid] = std::make_shared(switchVid, switchRid, m_client, m_translator, m_vendorSai, false, m_commandLineOptions->m_enableAttrVersionCheck); m_mdioIpcServer->setSwitchId(switchRid); @@ -4646,7 +4639,7 @@ void Syncd::performWarmRestartSingleSwitch( // perform all get operations on existing switch - auto sw = m_switches[switchVid] = std::make_shared(switchVid, switchRid, m_client, m_translator, m_vendorSai, true); + auto sw = m_switches[switchVid] = std::make_shared(switchVid, switchRid, m_client, m_translator, m_vendorSai, true, m_commandLineOptions->m_enableAttrVersionCheck); startDiagShell(switchRid); } diff --git a/syncd/VendorSaiOptions.h b/syncd/VendorSaiOptions.h deleted file mode 100644 index 4c66e81d3..000000000 --- a/syncd/VendorSaiOptions.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -#include "meta/SaiOptions.h" - -namespace syncd -{ - class VendorSaiOptions: - public sairedis::SaiOptions - { - public: - static constexpr const char *OPTIONS_KEY = "vok"; - - public: - - bool m_checkAttrVersion = false; - }; -} diff --git a/tests/aspell.en.pws b/tests/aspell.en.pws index 4a99b8dec..a51e8f4c6 100644 --- a/tests/aspell.en.pws +++ b/tests/aspell.en.pws @@ -479,4 +479,3 @@ submodule Enqueue deque apiversion -vso diff --git a/unittest/meta/TestSaiInterface.cpp b/unittest/meta/TestSaiInterface.cpp index cf35fc113..19a095ab8 100644 --- a/unittest/meta/TestSaiInterface.cpp +++ b/unittest/meta/TestSaiInterface.cpp @@ -117,37 +117,3 @@ TEST(SaiInterface, stats_meter_bucket_entry) EXPECT_EQ(SAI_STATUS_NOT_IMPLEMENTED, s->getStatsExt(m, 0, nullptr, SAI_STATS_MODE_READ, nullptr)); EXPECT_EQ(SAI_STATUS_NOT_IMPLEMENTED, s->clearStats(m, 0, nullptr)); } - -class Opt: - public SaiOptions -{ - public: - - int i; -}; - -TEST(SaiInterface, setOptions) -{ - DummySaiInterface ds; - - ds.setOptions("key", std::make_shared()); -} - -TEST(SaiInterface, getOptions) -{ - DummySaiInterface ds; - - auto opt = std::make_shared(); - - opt->i = 42; - - ds.setOptions("key", opt); - - auto o = std::dynamic_pointer_cast(ds.getOptions("key")); - - EXPECT_NE(o, nullptr); - - EXPECT_EQ(o->i, 42); - - EXPECT_EQ(ds.getOptions("foo"), nullptr); -}