From 7835026dfabb6997d856c5640d2412ab111dd1a8 Mon Sep 17 00:00:00 2001 From: Kamil Cudnik Date: Wed, 27 Nov 2024 12:42:48 +0100 Subject: [PATCH 1/7] [syncd] Introduce VendorSaiOptions class (#1472) And SaiOptions interface, for easy passing parameters over Sai objects This will simplify passing parameters over different objects that have SaiInterface. --- meta/SaiInterface.cpp | 17 +++++++++++++++ meta/SaiInterface.h | 19 +++++++++++++++++ meta/SaiOptions.h | 11 ++++++++++ syncd/HardReiniter.cpp | 9 +++----- syncd/HardReiniter.h | 5 +---- syncd/SaiDiscovery.cpp | 14 ++++++++---- syncd/SaiDiscovery.h | 3 +-- syncd/SaiSwitch.cpp | 10 ++++----- syncd/SaiSwitch.h | 5 +---- syncd/SingleReiniter.cpp | 8 +++---- syncd/SingleReiniter.h | 5 +---- syncd/Syncd.cpp | 15 +++++++++---- syncd/VendorSaiOptions.h | 17 +++++++++++++++ tests/aspell.en.pws | 1 + unittest/meta/TestSaiInterface.cpp | 34 ++++++++++++++++++++++++++++++ 15 files changed, 134 insertions(+), 39 deletions(-) create mode 100644 meta/SaiOptions.h create mode 100644 syncd/VendorSaiOptions.h diff --git a/meta/SaiInterface.cpp b/meta/SaiInterface.cpp index 3a95bc017..c91d08275 100644 --- a/meta/SaiInterface.cpp +++ b/meta/SaiInterface.cpp @@ -378,3 +378,20 @@ 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 fb78e1569..1f694c040 100644 --- a/meta/SaiInterface.h +++ b/meta/SaiInterface.h @@ -5,6 +5,12 @@ extern "C" { #include "saimetadata.h" } +#include "SaiOptions.h" + +#include +#include +#include + #define SAIREDIS_DECLARE_EVERY_ENTRY(_X) \ SAI_METADATA_DECLARE_EVERY_ENTRY(_X) @@ -340,5 +346,18 @@ 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 new file mode 100644 index 000000000..2d053c6c5 --- /dev/null +++ b/meta/SaiOptions.h @@ -0,0 +1,11 @@ +#pragma once + +namespace sairedis +{ + class SaiOptions + { + public: + + virtual ~SaiOptions() = default; + }; +} diff --git a/syncd/HardReiniter.cpp b/syncd/HardReiniter.cpp index 9b621f8b0..8c714eb23 100644 --- a/syncd/HardReiniter.cpp +++ b/syncd/HardReiniter.cpp @@ -13,13 +13,11 @@ HardReiniter::HardReiniter( _In_ std::shared_ptr client, _In_ std::shared_ptr translator, _In_ std::shared_ptr sai, - _In_ std::shared_ptr handler, - _In_ bool checkAttrVersion): + _In_ std::shared_ptr handler): m_vendorSai(sai), m_translator(translator), m_client(client), - m_handler(handler), - m_checkAttrVersion(checkAttrVersion) + m_handler(handler) { SWSS_LOG_ENTER(); @@ -101,8 +99,7 @@ std::map> HardReiniter::hardR m_handler, m_switchVidToRid.at(kvp.first), m_switchRidToVid.at(kvp.first), - kvp.second, - m_checkAttrVersion); + kvp.second); sr->hardReinit(); diff --git a/syncd/HardReiniter.h b/syncd/HardReiniter.h index 435f38f16..9a032d16e 100644 --- a/syncd/HardReiniter.h +++ b/syncd/HardReiniter.h @@ -27,8 +27,7 @@ namespace syncd _In_ std::shared_ptr client, _In_ std::shared_ptr translator, _In_ std::shared_ptr sai, - _In_ std::shared_ptr handler, - _In_ bool checkAttrVersion); + _In_ std::shared_ptr handler); virtual ~HardReiniter(); @@ -60,7 +59,5 @@ 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 43e01016a..3ba89bc98 100644 --- a/syncd/SaiDiscovery.cpp +++ b/syncd/SaiDiscovery.cpp @@ -1,4 +1,5 @@ #include "SaiDiscovery.h" +#include "VendorSaiOptions.h" #include "swss/logger.h" @@ -19,8 +20,7 @@ using namespace syncd; #define SAI_DISCOVERY_LIST_MAX_ELEMENTS 1024 SaiDiscovery::SaiDiscovery( - _In_ std::shared_ptr sai, - _In_ bool checkAttrVersion): + _In_ std::shared_ptr sai): m_sai(sai) { SWSS_LOG_ENTER(); @@ -31,10 +31,16 @@ SaiDiscovery::SaiDiscovery( if (status == SAI_STATUS_SUCCESS) { - m_attrVersionChecker.enable(checkAttrVersion); + auto vso = std::dynamic_pointer_cast(sai->getOptions(VendorSaiOptions::OPTIONS_KEY)); + + // TODO check vso for null + + m_attrVersionChecker.enable(vso->m_checkAttrVersion); m_attrVersionChecker.setSaiApiVersion(version); - SWSS_LOG_NOTICE("check attr version ENABLED, libsai api version: %lu", version); + SWSS_LOG_NOTICE("check attr version %s, libsai api version: %lu", + (vso->m_checkAttrVersion ? "ENABLED" : "DISABLED"), + version); } else { diff --git a/syncd/SaiDiscovery.h b/syncd/SaiDiscovery.h index c677a5b87..b6f8cf053 100644 --- a/syncd/SaiDiscovery.h +++ b/syncd/SaiDiscovery.h @@ -20,8 +20,7 @@ namespace syncd public: SaiDiscovery( - _In_ std::shared_ptr sai, - _In_ bool checkAttrVersion); + _In_ std::shared_ptr sai); virtual ~SaiDiscovery(); diff --git a/syncd/SaiSwitch.cpp b/syncd/SaiSwitch.cpp index 4f11dba4c..fb711db4d 100644 --- a/syncd/SaiSwitch.cpp +++ b/syncd/SaiSwitch.cpp @@ -26,14 +26,12 @@ SaiSwitch::SaiSwitch( _In_ std::shared_ptr client, _In_ std::shared_ptr translator, _In_ std::shared_ptr vendorSai, - _In_ bool warmBoot, - _In_ bool checkAttrVersion): + _In_ bool warmBoot): SaiSwitchInterface(switch_vid, switch_rid), m_vendorSai(vendorSai), m_warmBoot(warmBoot), m_translator(translator), - m_client(client), - m_checkAttrVersion(checkAttrVersion) + m_client(client) { SWSS_LOG_ENTER(); @@ -663,7 +661,7 @@ void SaiSwitch::helperDiscover() { SWSS_LOG_ENTER(); - SaiDiscovery sd(m_vendorSai, m_checkAttrVersion); + SaiDiscovery sd(m_vendorSai); m_discovered_rids = sd.discover(m_switch_rid); @@ -954,7 +952,7 @@ void SaiSwitch::onPostPortCreate( { SWSS_LOG_ENTER(); - SaiDiscovery sd(m_vendorSai, m_checkAttrVersion); + SaiDiscovery sd(m_vendorSai); auto discovered = sd.discover(port_rid); diff --git a/syncd/SaiSwitch.h b/syncd/SaiSwitch.h index 4c317678a..d6bccfeed 100644 --- a/syncd/SaiSwitch.h +++ b/syncd/SaiSwitch.h @@ -34,8 +34,7 @@ namespace syncd _In_ std::shared_ptr client, _In_ std::shared_ptr translator, _In_ std::shared_ptr vendorSai, - _In_ bool warmBoot, - _In_ bool checkAttrVersion); + _In_ bool warmBoot); virtual ~SaiSwitch() = default; @@ -354,7 +353,5 @@ 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 6844d3cf7..6f5355736 100644 --- a/syncd/SingleReiniter.cpp +++ b/syncd/SingleReiniter.cpp @@ -22,16 +22,14 @@ SingleReiniter::SingleReiniter( _In_ std::shared_ptr handler, _In_ const ObjectIdMap& vidToRidMap, _In_ const ObjectIdMap& ridToVidMap, - _In_ const std::vector& asicKeys, - _In_ bool checkAttrVersion): + _In_ const std::vector& asicKeys): m_vendorSai(sai), m_vidToRidMap(vidToRidMap), m_ridToVidMap(ridToVidMap), m_asicKeys(asicKeys), m_translator(translator), m_client(client), - m_handler(handler), - m_checkAttrVersion(checkAttrVersion) + m_handler(handler) { SWSS_LOG_ENTER(); @@ -319,7 +317,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_checkAttrVersion); + m_sw = std::make_shared(m_switch_vid, m_switch_rid, m_client, m_translator, m_vendorSai, false); /* * We processed switch. We have switch vid/rid so we can process all diff --git a/syncd/SingleReiniter.h b/syncd/SingleReiniter.h index b6a27eaab..e33b26af8 100644 --- a/syncd/SingleReiniter.h +++ b/syncd/SingleReiniter.h @@ -32,8 +32,7 @@ namespace syncd _In_ std::shared_ptr handler, _In_ const ObjectIdMap& vidToRidMap, _In_ const ObjectIdMap& ridToVidMap, - _In_ const std::vector& asicKeys, - _In_ bool checkAttrVersion); + _In_ const std::vector& asicKeys); virtual ~SingleReiniter(); @@ -137,7 +136,5 @@ 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 83f6b18ba..6c06a4fd5 100644 --- a/syncd/Syncd.cpp +++ b/syncd/Syncd.cpp @@ -12,6 +12,7 @@ #include "RedisNotificationProducer.h" #include "ZeroMQNotificationProducer.h" #include "WatchdogScope.h" +#include "VendorSaiOptions.h" #include "sairediscommon.h" @@ -109,6 +110,12 @@ 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(); @@ -3136,7 +3143,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_commandLineOptions->m_enableAttrVersionCheck); + m_switches[switchVid] = std::make_shared(switchVid, objectRid, m_client, m_translator, m_vendorSai, false); m_mdioIpcServer->setSwitchId(objectRid); @@ -4353,7 +4360,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, m_commandLineOptions->m_enableAttrVersionCheck); + HardReiniter hr(m_client, m_translator, m_vendorSai, m_handler); m_switches = hr.hardReinit(); @@ -4455,7 +4462,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_commandLineOptions->m_enableAttrVersionCheck); + m_switches[switchVid] = std::make_shared(switchVid, switchRid, m_client, m_translator, m_vendorSai, false); m_mdioIpcServer->setSwitchId(switchRid); @@ -4639,7 +4646,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, m_commandLineOptions->m_enableAttrVersionCheck); + auto sw = m_switches[switchVid] = std::make_shared(switchVid, switchRid, m_client, m_translator, m_vendorSai, true); startDiagShell(switchRid); } diff --git a/syncd/VendorSaiOptions.h b/syncd/VendorSaiOptions.h new file mode 100644 index 000000000..4c66e81d3 --- /dev/null +++ b/syncd/VendorSaiOptions.h @@ -0,0 +1,17 @@ +#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 a51e8f4c6..4a99b8dec 100644 --- a/tests/aspell.en.pws +++ b/tests/aspell.en.pws @@ -479,3 +479,4 @@ submodule Enqueue deque apiversion +vso diff --git a/unittest/meta/TestSaiInterface.cpp b/unittest/meta/TestSaiInterface.cpp index 19a095ab8..cf35fc113 100644 --- a/unittest/meta/TestSaiInterface.cpp +++ b/unittest/meta/TestSaiInterface.cpp @@ -117,3 +117,37 @@ 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); +} From 7817c3b1e421b59e90729d45cb6da3f26a70af3c Mon Sep 17 00:00:00 2001 From: Aryeh Feigin <101218333+arfeigin@users.noreply.github.com> Date: Wed, 27 Nov 2024 14:03:23 +0200 Subject: [PATCH 2/7] Use temp view also in fast-reboot (#1401) syncd_init_common.sh is checking fast-reboot by reading /proc/cmdline. However, /proc/cmdline will not change after config reload. So, consider a case like fast-reboot -> config reload. In the config reload process, syncd_init_common.sh will also treat it as fast-reboot and probably enter wrong logic. --- syncd/scripts/syncd_init_common.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/syncd/scripts/syncd_init_common.sh b/syncd/scripts/syncd_init_common.sh index db36529d2..81b94ff33 100644 --- a/syncd/scripts/syncd_init_common.sh +++ b/syncd/scripts/syncd_init_common.sh @@ -26,10 +26,8 @@ else CMD_ARGS= fi -# Use temporary view between init and apply except when in fast-reboot -if [[ "$(cat /proc/cmdline)" != *"SONIC_BOOT_TYPE=fast-reboot"* ]]; then - CMD_ARGS+=" -u" -fi +# Use temporary view between init view and apply view +CMD_ARGS+=" -u" # Create a folder for SAI failure dump files mkdir -p /var/log/sai_failure_dump/ From 8ba9448f4df94eb54185dad5c28ce96798022476 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B3=93=E5=B0=91=E9=88=BA?= <51807939+geans-pin@users.noreply.github.com> Date: Wed, 4 Dec 2024 03:13:48 +0800 Subject: [PATCH 3/7] modify syncd init script for supporting yml (#1474) * new commit * Change sai profile search path to /etc/sai.d * Update brcm_common_config_ut.sh change sai.profile search path from HWSKU to /etc/sai.d --- syncd/scripts/brcm_common_config_ut.sh | 119 +++++++++++++ syncd/scripts/syncd_init_common.sh | 238 ++++++++++++++++++------- 2 files changed, 295 insertions(+), 62 deletions(-) create mode 100644 syncd/scripts/brcm_common_config_ut.sh diff --git a/syncd/scripts/brcm_common_config_ut.sh b/syncd/scripts/brcm_common_config_ut.sh new file mode 100644 index 000000000..9f3dcb1e1 --- /dev/null +++ b/syncd/scripts/brcm_common_config_ut.sh @@ -0,0 +1,119 @@ +#!/bin/bash +###BRCM Common config UT#### +HWSKU_DIR=/usr/share/sonic/hwsku +SAI_PROFILE_DIR=/etc/sai.d +PLATFORM_COMMON_DIR=/usr/share/sonic/device/x86_64-broadcom_common +PLT_SAI_PROFILE=$(find $SAI_PROFILE_DIR -name 'sai.profile') +readline=$(grep SAI_INIT_CONFIG_FILE $PLT_SAI_PROFILE) +PLATFORM_DIR=/usr/share/sonic/platform + +PLT_CONFIG_BCM="" +PLT_CONFIG_YML="" + +if [ ${readline: -3} == "bcm" ]; then + PLT_CONFIG_BCM=${readline#*=} +elif [ ${readline: -3} == "yml" ]; then + PLT_CONFIG_YML=${readline#*=} +fi + +if [ ! -z "$PLT_CONFIG_BCM" ] && [ -f $PLATFORM_DIR/common_config_support ] ; then + CONFIG_BCM=$(find /tmp -name '*.bcm') + + #Get first three characters of chip id + readline=$(grep '0x14e4' /proc/linux-kernel-bde) + chip_id=${readline#*0x14e4:0x} + chip_id=${chip_id::3} + COMMON_CONFIG_BCM=$(find $PLATFORM_COMMON_DIR/x86_64-broadcom_${chip_id} -maxdepth 1 -name '*.bcm') + check_override=false + check_pass=false + + #Check if common config does apply to config bcm correctly + while read line + do + line=$( echo $line | xargs ) + if [ ! -z "$line" ];then + if [ "${line::1}" == '#' ];then + echo "Skip checking line starting with #" + elif [ "$line" == "[High Inheritance Precedence]" ];then + echo "Checking High Inheritance property..." + check_override=true + elif [ "$line" == "[Low Inheritance Precedence]" ];then + echo "Checking Low Inheritance property..." + check_override=false + else + if $check_override ;then + if grep -q "$line" $CONFIG_BCM ;then + check_pass=true + else + echo "Fail: Checking overwite properties not existing.." + return + fi + else + sedline=${line%=*} + if grep -q $sedline $CONFIG_BCM ;then + check_pass=true + else + echo "Fail: Checking properties not existing.." + return + fi + fi + fi + fi + done < $COMMON_CONFIG_BCM + if $check_pass ;then + echo "PASS: Checking Common config merged Success" + fi +fi + +if [ ! -z "$PLT_CONFIG_YML" ] && [ -f $PLATFORM_DIR/common_config_support ]; then + CONFIG_YML=$(find /tmp -name '*.yml') + + #Get first three characters of chip id + readline=$(grep '0:14e4' /proc/linux_ngbde) + chip_id=${readline#*0:14e4:} + chip_id=${chip_id::3} + COMMON_CONFIG_BCM=$(find $PLATFORM_COMMON_DIR/x86_64-broadcom_${chip_id} -maxdepth 1 -name '*.bcm') + check_override=false + check_pass=false + + #Check if common config does apply to config bcm correctly + while read line + do + line=$( echo $line | xargs ) + if [ ! -z "$line" ];then + if [ "${line::1}" == '#' ];then + echo "Skip checking line starting with #" + elif [ "$line" == "[High Inheritance Precedence]" ];then + echo "Checking High Inheritance property..." + check_override=true + elif [ "$line" == "[Low Inheritance Precedence]" ];then + echo "Checking Low Inheritance property..." + check_override=false + else + if $check_override ;then + if grep -q "$line" $CONFIG_YML ;then + check_pass=true + else + echo "Fail: Checking overwite properties not existing.." + check_pass=false + return + fi + else + sedline=${line%:*} + if grep -q $sedline $CONFIG_YML ;then + check_pass=true + else + echo "Fail: Checking properties not existing.." + check_pass=false + return + fi + fi + fi + fi + done < $COMMON_CONFIG_BCM + + if $check_pass ;then + echo "PASS: Checking Common config merged Success" + fi + +fi diff --git a/syncd/scripts/syncd_init_common.sh b/syncd/scripts/syncd_init_common.sh index 81b94ff33..cb72ab834 100644 --- a/syncd/scripts/syncd_init_common.sh +++ b/syncd/scripts/syncd_init_common.sh @@ -11,6 +11,7 @@ ENABLE_SAITHRIFT=0 TEMPLATES_DIR=/usr/share/sonic/templates PLATFORM_DIR=/usr/share/sonic/platform HWSKU_DIR=/usr/share/sonic/hwsku +SAI_PROFILE_DIR=/etc/sai.d VARS_FILE=$TEMPLATES_DIR/swss_vars.j2 @@ -122,74 +123,188 @@ config_syncd_cisco_8000() fi } -config_syncd_bcm() +function merge_config_bcm_files() { + to_file=$1 + from_file=$2 + message=$3 + override=false + echo "" >> $to_file + echo "# Start of $message" >> $to_file + while read line + do + line=$( echo $line | xargs ) + if [ ! -z "$line" ];then + if [ "${line::1}" == '#' ];then + echo $line >> $to_file + elif [ "$line" == "[Low Inheritance Precedence]" ];then + override=false + echo "# $line" >> $to_file + elif [ "$line" == "[High Inheritance Precedence]" ];then + override=true + echo "# $line" >> $to_file + echo "Merge properties with override $override" + else + sedline=${line%=*} + if grep -q $sedline $to_file ;then + if $override ;then + echo "Override the config $(grep $sedline $to_file) with $line in $to_file" + prop=${line:0:`expr index $line =`} + sed -i "/$prop/d" $to_file + echo $line >> $to_file + else + grepline=$(grep $sedline $to_file) + if [ "${grepline::1}" == '#' ];then + echo $line >> $to_file + else + echo "Keep the config $(grep $sedline $to_file) in $to_file" + fi + fi + else + echo $line >> $to_file + fi + fi + fi + done < $from_file + echo "# End of $message" >> $to_file + echo "Merged $from_file to $to_file" +} - if [ -f $PLATFORM_DIR/common_config_support ];then - - PLATFORM_COMMON_DIR=/usr/share/sonic/device/x86_64-broadcom_common - - cp -f $HWSKU_DIR/*.config.bcm /tmp - cp -f /etc/sai.d/sai.profile /tmp - CONFIG_BCM=$(find /tmp -name '*.bcm') - PLT_CONFIG_BCM=$(find $HWSKU_DIR -name '*.bcm') - SAI_PROFILE=$(find /tmp -name 'sai.profile') - sed -i 's+/usr/share/sonic/hwsku+/tmp+g' $SAI_PROFILE - - #Get first three characters of chip id - readline=$(grep '0x14e4' /proc/linux-kernel-bde) - chip_id=${readline#*0x14e4:0x} - chip_id=${chip_id::3} - COMMON_CONFIG_BCM=$(find $PLATFORM_COMMON_DIR/x86_64-broadcom_${chip_id} -name '*.bcm') - - if [ -f $PLATFORM_COMMON_DIR/x86_64-broadcom_${chip_id}/*.bcm ]; then - for file in $CONFIG_BCM; do - echo "" >> $file - echo "# Start of chip common properties" >> $file - while read line - do - line=$( echo $line | xargs ) - if [ ! -z "$line" ];then - if [ "${line::1}" == '#' ];then - echo $line >> $file +function merge_config_yml_files() +{ + to_file=$1 + from_file=$2 + message=$3 + override=false + merged_cnt=0 + echo "" >> $to_file + echo "# Start of $message" >> $to_file + while read line + do + line=$( echo $line | xargs ) + if [ ! -z "$line" ];then + if [ "${line::1}" == '#' ];then + echo " $line" >> $to_file + elif [ "$line" == "[Low Inheritance Precedence]" ];then + override=false + echo " # $line" >> $to_file + elif [ "$line" == "[High Inheritance Precedence]" ];then + override=true + echo " # $line" >> $to_file + echo "Merge properties with override $override" + else + sedline=${line%:*} + if grep -q $sedline $to_file ;then + if $override ;then + echo "Override the config $(grep $sedline $to_file) with $line in $to_file" + prop=${line:0:`expr index "$line" :`} + sed -i "/$prop/d" $to_file + echo " $line" >> $to_file + merged_cnt+=1 else - sedline=${line%=*} - if grep -q $sedline $file ;then - echo "Keep the config $(grep $sedline $file) in $file" - else - echo $line >> $file - fi + grepline=$(grep $sedline $to_file) + grepline="${grepline#"${grepline%%[![:space:]]*}"}" + if [ "${grepline::1}" == '#' ];then + echo " $line" >> $to_file + merged_cnt+=1 + else + echo "Keep the config $(grep $sedline $to_file) in $to_file" + fi fi - fi - done < $COMMON_CONFIG_BCM - echo "# End of chip common properties" >> $file - done - echo "Merging $PLT_CONFIG_BCM with $COMMON_CONFIG_BCM, merge files stored in $CONFIG_BCM" - fi - - #sync the file system - sync - - # copy the final config.bcm and sai.profile to the shared folder for 'show tech' - cp -f /tmp/sai.profile /var/run/sswsyncd/ - cp -f /tmp/*.bcm /var/run/sswsyncd/ - - if [ -f "/tmp/sai.profile" ]; then - CMD_ARGS+=" -p /tmp/sai.profile" - elif [ -f "/etc/sai.d/sai.profile" ]; then - CMD_ARGS+=" -p /etc/sai.d/sai.profile" - else - CMD_ARGS+=" -p $HWSKU_DIR/sai.profile" - fi + else + echo " $line" >> $to_file + merged_cnt+=1 + fi + fi + fi + done < $from_file - else + if [ $merged_cnt -gt 0 ]; then + sed -i "/# Start of/a \ global:" $to_file + sed -i "/# Start of/a \ 0:" $to_file + sed -i "/# Start of/a \bcm_device:" $to_file + sed -i "/# Start of/a \---" $to_file + fi + echo "# End of $message" >> $to_file + if [ $merged_cnt -gt 0 ]; then + sed -i "/# End of/i \..." $to_file + fi + echo "Merged $from_file to $to_file" +} - if [ -f "/etc/sai.d/sai.profile" ]; then - CMD_ARGS+=" -p /etc/sai.d/sai.profile" - else - CMD_ARGS+=" -p $HWSKU_DIR/sai.profile" - fi +config_syncd_bcm() +{ + PLATFORM_COMMON_DIR=/usr/share/sonic/device/x86_64-broadcom_common + PLT_CONFIG_BCM="" + PLT_CONFIG_YML="" + PLT_SAI_PROFILE=$(find $SAI_PROFILE_DIR -name 'sai.profile') + readline=$(grep SAI_INIT_CONFIG_FILE $PLT_SAI_PROFILE) + if [ ${readline: -3} == "bcm" ]; then + PLT_CONFIG_BCM=${readline#*=} + elif [ ${readline: -3} == "yml" ]; then + PLT_CONFIG_YML=${readline#*=} + fi + if [ ! -z "$PLT_CONFIG_BCM" ] && [ -f $PLATFORM_DIR/common_config_support ] ; then + cp -f $PLT_CONFIG_BCM /tmp + cp -f /etc/sai.d/sai.profile /tmp + CONFIG_BCM=$(find /tmp -name '*.bcm') + SAI_PROFILE=$(find /tmp -name 'sai.profile') + sed -i 's+/usr/share/sonic/hwsku+/tmp+g' $SAI_PROFILE + + #Get first three characters of chip id + readline=$(grep '0x14e4' /proc/linux-kernel-bde) + chip_id=${readline#*0x14e4:0x} + chip_id=${chip_id::3} + COMMON_CONFIG_BCM=$(find $PLATFORM_COMMON_DIR/x86_64-broadcom_${chip_id} -maxdepth 1 -name '*.bcm') + + if [ -f $PLATFORM_COMMON_DIR/x86_64-broadcom_${chip_id}/*.bcm ]; then + for file in $CONFIG_BCM; do + merge_config_bcm_files $file $COMMON_CONFIG_BCM "chip common properties" + done + echo "Merging $PLT_CONFIG_BCM with $COMMON_CONFIG_BCM, merge files stored in $CONFIG_BCM" + fi + #sync the file system + sync + + # copy the final config.bcm and sai.profile to the shared folder for 'show tech' + cp -f /tmp/sai.profile /var/run/sswsyncd/ + cp -f /tmp/*.bcm /var/run/sswsyncd/ + fi + + if [ ! -z "$PLT_CONFIG_YML" ] && [ -f $PLATFORM_DIR/common_config_support ]; then + cp -f $PLT_CONFIG_YML /tmp + cp -f /etc/sai.d/sai.profile /tmp + CONFIG_YML=$(find /tmp -name '*.yml') + SAI_PROFILE=$(find /tmp -name 'sai.profile') + sed -i 's+/usr/share/sonic/hwsku+/tmp+g' $SAI_PROFILE + + #Get first three characters of chip id + readline=$(grep '0:14e4' /proc/linux_ngbde) + chip_id=${readline#*0:14e4:} + chip_id=${chip_id::3} + COMMON_CONFIG_BCM=$(find $PLATFORM_COMMON_DIR/x86_64-broadcom_${chip_id} -maxdepth 1 -name '*.bcm') + + if [ -f $PLATFORM_COMMON_DIR/x86_64-broadcom_${chip_id}/*.bcm ]; then + for file in $CONFIG_YML; do + merge_config_yml_files $file $COMMON_CONFIG_BCM "chip common properties" + done + echo "Merging $PLT_CONFIG_YML with $COMMON_CONFIG_BCM, merge files stored in $CONFIG_YML " + fi + #sync the file system + sync + + # copy the final config.bcm and sai.profile to the shared folder for 'show tech' + cp -f /tmp/sai.profile /var/run/sswsyncd/ + cp -f /tmp/*.yml /var/run/sswsyncd/ + fi + + if [ -f "/tmp/sai.profile" ]; then + CMD_ARGS+=" -p /tmp/sai.profile" + elif [ -f "/etc/sai.d/sai.profile" ]; then + CMD_ARGS+=" -p /etc/sai.d/sai.profile" + else + CMD_ARGS+=" -p $HWSKU_DIR/sai.profile" fi if [ -f "$HWSKU_DIR/context_config.json" ]; then @@ -517,4 +632,3 @@ config_syncd() [ -r $PLATFORM_DIR/syncd.conf ] && . $PLATFORM_DIR/syncd.conf } - From 4f7eed0aac95288077fa9959dc61eacd2f3938d6 Mon Sep 17 00:00:00 2001 From: Ying Xie Date: Thu, 5 Dec 2024 17:43:41 -0800 Subject: [PATCH 4/7] Revert back to SAI version 1 15 (#1481) Need to keep master branch at SAI header version 1.15 until 202411 branch is cut. 2dbaca8 2024-12-05 | Revert "[submodule] Update SAI to lates origin master ([submodule] Update SAI to latest origin master #1466)" (HEAD -> 202411, yingfork/revert-back-to-1-15) [Ying Xie] 064a3a8 2024-12-05 | Revert "[meta] Use metadata to check port notification port_id type ([meta] Use metadata to check port notification port_id type #1469)" [Ying Xie] 0383740 2024-12-05 | Revert "[syncd] Add attribute version check feature ([syncd] Add attribute version check feature #1470)" [Ying Xie] 0901dd7 2024-12-05 | Revert "[syncd] Introduce VendorSaiOptions class ([syncd] Introduce VendorSaiOptions class #1472)" [Ying Xie] --- SAI | 2 +- meta/Meta.cpp | 86 +++----------- meta/Meta.h | 10 -- meta/SaiInterface.cpp | 17 --- meta/SaiInterface.h | 19 ---- meta/SaiOptions.h | 11 -- meta/SaiSerialize.cpp | 35 ------ meta/sai_serialize.h | 7 -- syncd/AttrVersionChecker.cpp | 107 ------------------ syncd/AttrVersionChecker.h | 40 ------- syncd/CommandLineOptions.cpp | 4 - syncd/CommandLineOptions.h | 1 - syncd/CommandLineOptionsParser.cpp | 11 +- syncd/Makefile.am | 1 - syncd/SaiDiscovery.cpp | 34 +----- syncd/SaiDiscovery.h | 4 - syncd/SaiSwitch.h | 2 +- syncd/SingleReiniter.cpp | 2 +- syncd/Syncd.cpp | 11 +- syncd/VendorSai.cpp | 64 ----------- syncd/VendorSaiOptions.h | 17 --- tests/aspell.en.pws | 2 - tests/utils.pm | 10 +- unittest/meta/TestMeta.cpp | 33 ------ unittest/meta/TestSaiInterface.cpp | 34 ------ unittest/meta/TestSaiSerialize.cpp | 11 -- unittest/syncd/Makefile.am | 1 - unittest/syncd/TestAttrVersionChecker.cpp | 132 ---------------------- unittest/syncd/TestCommandLineOptions.cpp | 4 +- unittest/syncd/TestVendorSai.cpp | 15 --- 30 files changed, 30 insertions(+), 697 deletions(-) delete mode 100644 meta/SaiOptions.h delete mode 100644 syncd/AttrVersionChecker.cpp delete mode 100644 syncd/AttrVersionChecker.h delete mode 100644 syncd/VendorSaiOptions.h delete mode 100644 unittest/syncd/TestAttrVersionChecker.cpp diff --git a/SAI b/SAI index 054085547..f214adef0 160000 --- a/SAI +++ b/SAI @@ -1 +1 @@ -Subproject commit 054085547c2042b95ab0fa1a75a44da3288b26bf +Subproject commit f214adef0f336cb991bad4461e626dc039f01878 diff --git a/meta/Meta.cpp b/meta/Meta.cpp index d632eadea..a9851d201 100644 --- a/meta/Meta.cpp +++ b/meta/Meta.cpp @@ -8,8 +8,6 @@ #include -#include - #include // TODO add validation for all oids belong to the same switch @@ -3156,25 +3154,6 @@ sai_status_t Meta::meta_sai_validate_meter_bucket_entry( return SAI_STATUS_NOT_IMPLEMENTED; } -sai_status_t Meta::meta_sai_validate_prefix_compression_entry( - _In_ const sai_prefix_compression_entry_t* prefix_compression_entry, - _In_ bool create, - _In_ bool get) -{ - SWSS_LOG_ENTER(); - - if (prefix_compression_entry == NULL) - { - SWSS_LOG_ERROR("prefix_compression_entry pointer is NULL"); - - return SAI_STATUS_INVALID_PARAMETER; - } - - // TODO FIX ME - - return SAI_STATUS_NOT_IMPLEMENTED; -} - sai_status_t Meta::meta_generic_validation_create( _In_ const sai_object_meta_key_t& meta_key, _In_ sai_object_id_t switch_id, @@ -6696,14 +6675,24 @@ void Meta::meta_sai_on_port_state_change_single( auto ot = objectTypeQuery(data.port_id); - bool valid = isPortObjectIdValid(ot); + bool valid = false; - if (!valid) + switch (ot) { - SWSS_LOG_ERROR("data.port_id %s has unexpected type: %s, expected: %s", - sai_serialize_object_id(data.port_id).c_str(), - sai_serialize_object_type(ot).c_str(), - boost::algorithm::join(getValidPortObjectTypes(), ",").c_str()); + // TODO hardcoded types, must advance SAI repository commit to get metadata for this + case SAI_OBJECT_TYPE_PORT: + case SAI_OBJECT_TYPE_BRIDGE_PORT: + case SAI_OBJECT_TYPE_LAG: + + valid = true; + break; + + default: + + SWSS_LOG_ERROR("data.port_id %s has unexpected type: %s, expected PORT, BRIDGE_PORT or LAG", + sai_serialize_object_id(data.port_id).c_str(), + sai_serialize_object_type(ot).c_str()); + break; } if (valid && !m_oids.objectReferenceExists(data.port_id)) @@ -7123,46 +7112,3 @@ void Meta::populate( } } } - -bool Meta::isPortObjectIdValid( - _In_ sai_object_type_t object_type) -{ - SWSS_LOG_ENTER(); - - auto members = sai_metadata_struct_members_sai_port_oper_status_notification_t; - - for (size_t i = 0; members[i]; i++) - { - auto* mb = members[i]; - - if (mb->membername != std::string("port_id")) - continue; - - for (size_t idx = 0; idx < mb->allowedobjecttypeslength; idx++) - { - if (mb->allowedobjecttypes[idx] == object_type) - return true; - } - - return false; - } - - SWSS_LOG_THROW("port_id member not found on sai_port_oper_status_notification"); -} - -std::vector Meta::getValidPortObjectTypes() -{ - SWSS_LOG_ENTER(); - - auto md = sai_metadata_enum_sai_object_type_t; - - std::vector v; - - for (size_t i = 0; i < md.valuescount; i++) - { - if (isPortObjectIdValid((sai_object_type_t)md.values[i])) - v.push_back(md.valuesshortnames[i]); - } - - return v; -} diff --git a/meta/Meta.h b/meta/Meta.h index aac696a68..ce8a0a2dd 100644 --- a/meta/Meta.h +++ b/meta/Meta.h @@ -315,11 +315,6 @@ namespace saimeta static bool is_ipv6_mask_valid( _In_ const uint8_t* mask); - static bool isPortObjectIdValid( - _In_ sai_object_type_t object_type); - - static std::vector getValidPortObjectTypes(); - private: // unit tests helpers bool meta_unittests_get_and_erase_set_readonly_flag( @@ -568,11 +563,6 @@ namespace saimeta _In_ bool create, _In_ bool get = false); - sai_status_t meta_sai_validate_prefix_compression_entry( - _In_ const sai_prefix_compression_entry_t* prefix_compression_entry, - _In_ bool create, - _In_ bool get = false); - public: /* 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/meta/SaiSerialize.cpp b/meta/SaiSerialize.cpp index ca528b4ff..0916cac02 100644 --- a/meta/SaiSerialize.cpp +++ b/meta/SaiSerialize.cpp @@ -975,20 +975,6 @@ std::string sai_serialize_meter_bucket_entry( return j.dump(); } -std::string sai_serialize_prefix_compression_entry( - _In_ const sai_prefix_compression_entry_t &prefix_compression_entry) -{ - SWSS_LOG_ENTER(); - - json j; - - j["switch_id"] = sai_serialize_object_id(prefix_compression_entry.switch_id); - j["prefix_table_id"] = sai_serialize_object_id(prefix_compression_entry.prefix_table_id); - j["prefix"] = sai_serialize_ip_prefix(prefix_compression_entry.prefix); - - return j.dump(); -} - std::string sai_serialize_flow_entry( _In_ const sai_flow_entry_t &flow_entry) { @@ -2684,10 +2670,6 @@ static bool sai_serialize_object_entry( key = sai_serialize_mcast_fdb_entry(key_entry.mcast_fdb_entry); return true; - case SAI_OBJECT_TYPE_PREFIX_COMPRESSION_ENTRY: - key = sai_serialize_prefix_compression_entry(key_entry.prefix_compression_entry); - return true; - default: return false; } @@ -4477,19 +4459,6 @@ void sai_deserialize_meter_bucket_entry( sai_deserialize_number(j["meter_class"], meter_bucket_entry.meter_class); } -void sai_deserialize_prefix_compression_entry( - _In_ const std::string& s, - _Out_ sai_prefix_compression_entry_t& prefix_compression_entry) -{ - SWSS_LOG_ENTER(); - - json j = json::parse(s); - - sai_deserialize_object_id(j["switch_id"], prefix_compression_entry.switch_id); - sai_deserialize_object_id(j["prefix_table_id"], prefix_compression_entry.prefix_table_id); - sai_deserialize_ip_prefix(j["prefix"], prefix_compression_entry.prefix); -} - void sai_deserialize_flow_entry( _In_ const std::string& s, _Out_ sai_flow_entry_t &flow_entry) @@ -4941,10 +4910,6 @@ bool sai_deserialize_object_entry( sai_deserialize_mcast_fdb_entry(object_id, meta_key.objectkey.key.mcast_fdb_entry); return true; - case SAI_OBJECT_TYPE_PREFIX_COMPRESSION_ENTRY: - sai_deserialize_prefix_compression_entry(object_id, meta_key.objectkey.key.prefix_compression_entry); - return true; - default: return false; } diff --git a/meta/sai_serialize.h b/meta/sai_serialize.h index b1733bf33..0ef79e9cb 100644 --- a/meta/sai_serialize.h +++ b/meta/sai_serialize.h @@ -72,9 +72,6 @@ std::string sai_serialize_fdb_entry( std::string sai_serialize_meter_bucket_entry( _In_ const sai_meter_bucket_entry_t &meter_bucket_entry); -std::string sai_serialize_prefix_compression_entry( - _In_ const sai_prefix_compression_entry_t &prefix_compression_entry); - std::string sai_serialize_flow_entry( _In_ const sai_flow_entry_t &flow_entry); @@ -446,10 +443,6 @@ void sai_deserialize_meter_bucket_entry( _In_ const std::string& s, _Out_ sai_meter_bucket_entry_t& meter_bucket_entry); -void sai_deserialize_prefix_compression_entry( - _In_ const std::string& s, - _Out_ sai_prefix_compression_entry_t& prefix_compression_entry); - void sai_deserialize_flow_entry( _In_ const std::string& s, _Out_ sai_flow_entry_t &flow_entry); diff --git a/syncd/AttrVersionChecker.cpp b/syncd/AttrVersionChecker.cpp deleted file mode 100644 index 320afcaf5..000000000 --- a/syncd/AttrVersionChecker.cpp +++ /dev/null @@ -1,107 +0,0 @@ -#include "AttrVersionChecker.h" - -#include "swss/logger.h" - -using namespace syncd; - -AttrVersionChecker::AttrVersionChecker(): - m_enabled(false), - m_saiApiVersion(SAI_VERSION(0,0,0)) -{ - SWSS_LOG_ENTER(); - - // empty -} - -void AttrVersionChecker::enable( - _In_ bool enable) -{ - SWSS_LOG_ENTER(); - - m_enabled = enable; -} - -void AttrVersionChecker::setSaiApiVersion( - _In_ sai_api_version_t version) -{ - SWSS_LOG_ENTER(); - - m_saiApiVersion = version; -} - -void AttrVersionChecker::reset() -{ - SWSS_LOG_ENTER(); - - m_visitedAttributes.clear(); -} - -bool AttrVersionChecker::isSufficientVersion( - _In_ const sai_attr_metadata_t *md) -{ - SWSS_LOG_ENTER(); - - if (md == nullptr) - { - SWSS_LOG_ERROR("md is NULL"); - - return false; - } - - if (!m_enabled) - { - return true; - } - - if (SAI_METADATA_HAVE_ATTR_VERSION == 0) - { - // metadata does not contain attr versions, no check will be preformed - return true; - } - - // check attr version if metadata have version defined - - if (m_saiApiVersion > md->apiversion) - { - // ok, SAI version is bigger than attribute release version - - return true; - } - - if (m_saiApiVersion < md->apiversion) - { - // skip, SAI version is not sufficient - - if (m_visitedAttributes.find(md->attridname) == m_visitedAttributes.end()) - { - m_visitedAttributes.insert(md->attridname); - - // log only once - - SWSS_LOG_WARN("SAI version %lu, not sufficient to discover %s", m_saiApiVersion, md->attridname); - } - - return false; - } - - // m_saiApiVersion == md->apiversion - - if (md->nextrelease == false) - { - // ok, SAI version is equal to attribute version - return true; - } - - // next release == true - - if (m_visitedAttributes.find(md->attridname) == m_visitedAttributes.end()) - { - m_visitedAttributes.insert(md->attridname); - - // warn only once - - SWSS_LOG_WARN("%s is ment for next release after %lu, will not discover", md->attridname, m_saiApiVersion); - } - - return false; -} diff --git a/syncd/AttrVersionChecker.h b/syncd/AttrVersionChecker.h deleted file mode 100644 index f2b65cddd..000000000 --- a/syncd/AttrVersionChecker.h +++ /dev/null @@ -1,40 +0,0 @@ -#pragma once - -extern "C" { -#include "sai.h" -#include "saimetadata.h" -} - -#include -#include - -namespace syncd -{ - class AttrVersionChecker - { - public: - - AttrVersionChecker(); - - public: - - void enable( - _In_ bool enable); - - void setSaiApiVersion( - _In_ sai_api_version_t version); - - void reset(); - - bool isSufficientVersion( - _In_ const sai_attr_metadata_t *md); - - private: - - bool m_enabled; - - sai_api_version_t m_saiApiVersion; - - std::set m_visitedAttributes; - }; -} diff --git a/syncd/CommandLineOptions.cpp b/syncd/CommandLineOptions.cpp index 59ef25106..0c25c8cad 100644 --- a/syncd/CommandLineOptions.cpp +++ b/syncd/CommandLineOptions.cpp @@ -44,9 +44,6 @@ CommandLineOptions::CommandLineOptions() #endif // SAITHRIFT - m_supportingBulkCounterGroups = ""; - - m_enableAttrVersionCheck = false; } std::string CommandLineOptions::getCommandLineString() const @@ -70,7 +67,6 @@ std::string CommandLineOptions::getCommandLineString() const ss << " BreakConfig=" << m_breakConfig; ss << " WatchdogWarnTimeSpan=" << m_watchdogWarnTimeSpan; ss << " SupportingBulkCounters=" << m_supportingBulkCounterGroups; - ss << " EnableAttrVersionCheck=" << (m_enableAttrVersionCheck ? "YES" : "NO"); #ifdef SAITHRIFT diff --git a/syncd/CommandLineOptions.h b/syncd/CommandLineOptions.h index 72982ea5e..99d0827d6 100644 --- a/syncd/CommandLineOptions.h +++ b/syncd/CommandLineOptions.h @@ -100,6 +100,5 @@ namespace syncd std::string m_supportingBulkCounterGroups; - bool m_enableAttrVersionCheck; }; } diff --git a/syncd/CommandLineOptionsParser.cpp b/syncd/CommandLineOptionsParser.cpp index 66c13e49c..d49624336 100644 --- a/syncd/CommandLineOptionsParser.cpp +++ b/syncd/CommandLineOptionsParser.cpp @@ -19,9 +19,9 @@ std::shared_ptr CommandLineOptionsParser::parseCommandLine( auto options = std::make_shared(); #ifdef SAITHRIFT - const char* const optstring = "dp:t:g:x:b:B:aw:uSUCsz:lrm:h"; + const char* const optstring = "dp:t:g:x:b:B:w:uSUCsz:lrm:h"; #else - const char* const optstring = "dp:t:g:x:b:B:aw:uSUCsz:lh"; + const char* const optstring = "dp:t:g:x:b:B:w:uSUCsz:lh"; #endif // SAITHRIFT while (true) @@ -43,7 +43,6 @@ std::shared_ptr CommandLineOptionsParser::parseCommandLine( { "breakConfig", required_argument, 0, 'b' }, { "watchdogWarnTimeSpan", optional_argument, 0, 'w' }, { "supportingBulkCounters", required_argument, 0, 'B' }, - { "enableAttrVersionCheck", no_argument, 0, 'a' }, #ifdef SAITHRIFT { "rpcserver", no_argument, 0, 'r' }, { "portmap", required_argument, 0, 'm' }, @@ -139,10 +138,6 @@ std::shared_ptr CommandLineOptionsParser::parseCommandLine( options->m_supportingBulkCounterGroups = std::string(optarg); break; - case 'a': - options->m_enableAttrVersionCheck = true; - break; - case 'h': printUsage(); exit(EXIT_SUCCESS); @@ -201,8 +196,6 @@ void CommandLineOptionsParser::printUsage() std::cout << " Watchdog time span (in microseconds) to watch for execution" << std::endl; std::cout << " -B --supportingBulkCounters" << std::endl; std::cout << " Counter groups those support bulk polling" << std::endl; - std::cout << " -a --enableAttrVersionCheck" << std::endl; - std::cout << " Enable attribute SAI version check when performing SAI discovery" << std::endl; #ifdef SAITHRIFT diff --git a/syncd/Makefile.am b/syncd/Makefile.am index 8c8cddaf3..3c546fb74 100644 --- a/syncd/Makefile.am +++ b/syncd/Makefile.am @@ -17,7 +17,6 @@ noinst_LIBRARIES = libSyncd.a libSyncdRequestShutdown.a libMdioIpcClient.a libSyncd_a_SOURCES = \ AsicOperation.cpp \ AsicView.cpp \ - AttrVersionChecker.cpp \ BestCandidateFinder.cpp \ BreakConfig.cpp \ BreakConfigParser.cpp \ diff --git a/syncd/SaiDiscovery.cpp b/syncd/SaiDiscovery.cpp index 3ba89bc98..8615526bb 100644 --- a/syncd/SaiDiscovery.cpp +++ b/syncd/SaiDiscovery.cpp @@ -1,5 +1,4 @@ #include "SaiDiscovery.h" -#include "VendorSaiOptions.h" #include "swss/logger.h" @@ -25,31 +24,7 @@ SaiDiscovery::SaiDiscovery( { SWSS_LOG_ENTER(); - sai_api_version_t version = SAI_VERSION(0,0,0); - - sai_status_t status = m_sai->queryApiVersion(&version); - - 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.setSaiApiVersion(version); - - SWSS_LOG_NOTICE("check attr version %s, libsai api version: %lu", - (vso->m_checkAttrVersion ? "ENABLED" : "DISABLED"), - version); - } - else - { - m_attrVersionChecker.enable(false); - m_attrVersionChecker.setSaiApiVersion(SAI_API_VERSION); - - SWSS_LOG_WARN("failed to obtain libsai api version: %s, will discover all attributes", - sai_serialize_status(status).c_str()); - } + // empty } SaiDiscovery::~SaiDiscovery() @@ -135,11 +110,6 @@ void SaiDiscovery::discover( attr.id = md->attrid; - if (!m_attrVersionChecker.isSufficientVersion(md)) - { - continue; - } - if (md->attrvaluetype == SAI_ATTR_VALUE_TYPE_OBJECT_ID) { if (md->defaultvaluetype == SAI_DEFAULT_VALUE_TYPE_CONST) @@ -289,8 +259,6 @@ std::set SaiDiscovery::discover( m_defaultOidMap.clear(); - m_attrVersionChecker.reset(); - std::set discovered_rids; { diff --git a/syncd/SaiDiscovery.h b/syncd/SaiDiscovery.h index b6f8cf053..c48372b08 100644 --- a/syncd/SaiDiscovery.h +++ b/syncd/SaiDiscovery.h @@ -2,8 +2,6 @@ #include "meta/SaiInterface.h" -#include "AttrVersionChecker.h" - #include #include #include @@ -63,7 +61,5 @@ namespace syncd std::shared_ptr m_sai; DefaultOidMap m_defaultOidMap; - - AttrVersionChecker m_attrVersionChecker; }; } diff --git a/syncd/SaiSwitch.h b/syncd/SaiSwitch.h index d6bccfeed..523e1fe1d 100644 --- a/syncd/SaiSwitch.h +++ b/syncd/SaiSwitch.h @@ -34,7 +34,7 @@ namespace syncd _In_ std::shared_ptr client, _In_ std::shared_ptr translator, _In_ std::shared_ptr vendorSai, - _In_ bool warmBoot); + _In_ bool warmBoot = false); virtual ~SaiSwitch() = default; diff --git a/syncd/SingleReiniter.cpp b/syncd/SingleReiniter.cpp index 6f5355736..f757ba515 100644 --- a/syncd/SingleReiniter.cpp +++ b/syncd/SingleReiniter.cpp @@ -317,7 +317,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); /* * We processed switch. We have switch vid/rid so we can process all diff --git a/syncd/Syncd.cpp b/syncd/Syncd.cpp index 6c06a4fd5..9c2533c3a 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); m_mdioIpcServer->setSwitchId(objectRid); @@ -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); m_mdioIpcServer->setSwitchId(switchRid); diff --git a/syncd/VendorSai.cpp b/syncd/VendorSai.cpp index bb6734256..c0cb5683a 100644 --- a/syncd/VendorSai.cpp +++ b/syncd/VendorSai.cpp @@ -1055,33 +1055,6 @@ sai_status_t VendorSai::bulkCreate( object_statuses); } -sai_status_t VendorSai::bulkCreate( - _In_ uint32_t object_count, - _In_ const sai_prefix_compression_entry_t* entries, - _In_ const uint32_t *attr_count, - _In_ const sai_attribute_t **attr_list, - _In_ sai_bulk_op_error_mode_t mode, - _Out_ sai_status_t *object_statuses) -{ - MUTEX(); - SWSS_LOG_ENTER(); - VENDOR_CHECK_API_INITIALIZED(); - - if (!m_apis.prefix_compression_api->create_prefix_compression_entries) - { - SWSS_LOG_INFO("create_prefix_compression_entries is not supported"); - return SAI_STATUS_NOT_SUPPORTED; - } - - return m_apis.prefix_compression_api->create_prefix_compression_entries( - object_count, - entries, - attr_count, - attr_list, - mode, - object_statuses); -} - // BULK REMOVE sai_status_t VendorSai::bulkRemove( @@ -1430,29 +1403,6 @@ sai_status_t VendorSai::bulkRemove( object_statuses); } -sai_status_t VendorSai::bulkRemove( - _In_ uint32_t object_count, - _In_ const sai_prefix_compression_entry_t *entries, - _In_ sai_bulk_op_error_mode_t mode, - _Out_ sai_status_t *object_statuses) -{ - MUTEX(); - SWSS_LOG_ENTER(); - VENDOR_CHECK_API_INITIALIZED(); - - if (!m_apis.prefix_compression_api->remove_prefix_compression_entries) - { - SWSS_LOG_INFO("remove_prefix_compression_entries is not supported"); - return SAI_STATUS_NOT_SUPPORTED; - } - - return m_apis.prefix_compression_api->remove_prefix_compression_entries( - object_count, - entries, - mode, - object_statuses); -} - // BULK SET sai_status_t VendorSai::bulkSet( @@ -1731,20 +1681,6 @@ sai_status_t VendorSai::bulkSet( return SAI_STATUS_NOT_SUPPORTED; } -sai_status_t VendorSai::bulkSet( - _In_ uint32_t object_count, - _In_ const sai_prefix_compression_entry_t *entries, - _In_ const sai_attribute_t *attr_list, - _In_ sai_bulk_op_error_mode_t mode, - _Out_ sai_status_t *object_statuses) -{ - MUTEX(); - SWSS_LOG_ENTER(); - VENDOR_CHECK_API_INITIALIZED(); - - return SAI_STATUS_NOT_SUPPORTED; -} - // NON QUAD API sai_status_t VendorSai::flushFdbEntries( 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..1908c5834 100644 --- a/tests/aspell.en.pws +++ b/tests/aspell.en.pws @@ -478,5 +478,3 @@ saiproxy submodule Enqueue deque -apiversion -vso diff --git a/tests/utils.pm b/tests/utils.pm index 34b120bf8..489e5bb5a 100644 --- a/tests/utils.pm +++ b/tests/utils.pm @@ -48,19 +48,19 @@ sub flush_redis sub start_syncd { print color('bright_blue') . "Starting syncd" . color('reset') . "\n"; - `./vssyncd -aSUu -p "$DIR/vsprofile.ini" @_ >/dev/null 2>/dev/null &`; + `./vssyncd -SUu -p "$DIR/vsprofile.ini" @_ >/dev/null 2>/dev/null &`; } sub start_syncd_bulk { print color('bright_blue') . "Starting syncd bulk" . color('reset') . "\n"; - `./vssyncd -aSUul -p "$DIR/vsprofile.ini" @_ >/dev/null 2>/dev/null &`; + `./vssyncd -SUul -p "$DIR/vsprofile.ini" @_ >/dev/null 2>/dev/null &`; } sub start_syncd_warm { print color('bright_blue') . "Starting syncd warm" . color('reset') . "\n"; - `./vssyncd -aSUu -t warm -p "$DIR/vsprofile.ini" >/dev/null 2>/dev/null &`; + `./vssyncd -SUu -t warm -p "$DIR/vsprofile.ini" >/dev/null 2>/dev/null &`; sleep 1; } @@ -68,13 +68,13 @@ sub start_syncd_warm sub sync_start_syncd { print color('bright_blue') . "Starting syncd" . color('reset') . "\n"; - `./vssyncd -s -aSUu -p "$DIR/vsprofile.ini" >/dev/null 2>/dev/null &`; + `./vssyncd -s -SUu -p "$DIR/vsprofile.ini" >/dev/null 2>/dev/null &`; } sub sync_start_syncd_warm { print color('bright_blue') . "Starting syncd warm" . color('reset') . "\n"; - `./vssyncd -s -aSUu -t warm -p "$DIR/vsprofile.ini" >/dev/null 2>/dev/null &`; + `./vssyncd -s -SUu -t warm -p "$DIR/vsprofile.ini" >/dev/null 2>/dev/null &`; sleep 1; } diff --git a/unittest/meta/TestMeta.cpp b/unittest/meta/TestMeta.cpp index 454f9ff85..0b0d35b25 100644 --- a/unittest/meta/TestMeta.cpp +++ b/unittest/meta/TestMeta.cpp @@ -7,8 +7,6 @@ #include -#include - #include #define VLAN_ID 2 @@ -1843,34 +1841,3 @@ TEST(Meta, remove_meter_bucket_entry) EXPECT_EQ(SAI_STATUS_INVALID_PARAMETER, sai.remove(e)); } - -TEST(Meta, remove_prefix_compression_entry) -{ - Meta sai(std::make_shared()); - - sai_prefix_compression_entry_t* e = nullptr; - - EXPECT_EQ(SAI_STATUS_INVALID_PARAMETER, sai.remove(e)); -} - -TEST(Meta, isPortObjectIdValid) -{ - EXPECT_EQ(Meta::isPortObjectIdValid(SAI_OBJECT_TYPE_PORT), true); - EXPECT_EQ(Meta::isPortObjectIdValid(SAI_OBJECT_TYPE_BRIDGE_PORT), true); - EXPECT_EQ(Meta::isPortObjectIdValid(SAI_OBJECT_TYPE_LAG), true); - - EXPECT_EQ(Meta::isPortObjectIdValid(SAI_OBJECT_TYPE_TUNNEL),false); - EXPECT_EQ(Meta::isPortObjectIdValid(SAI_OBJECT_TYPE_NULL), false); - EXPECT_EQ(Meta::isPortObjectIdValid(SAI_OBJECT_TYPE_VLAN), false); -} - -TEST(Meta, getValidPortObjectTypes) -{ - auto v = Meta::getValidPortObjectTypes(); - - EXPECT_EQ(v.size(), 3); - - auto s = boost::algorithm::join(v, ","); - - EXPECT_EQ(s, "PORT,LAG,BRIDGE_PORT"); -} 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); -} diff --git a/unittest/meta/TestSaiSerialize.cpp b/unittest/meta/TestSaiSerialize.cpp index ab7521db0..b7e0c97d6 100644 --- a/unittest/meta/TestSaiSerialize.cpp +++ b/unittest/meta/TestSaiSerialize.cpp @@ -1347,14 +1347,3 @@ TEST(SaiSerialize, serialize_number) EXPECT_EQ(sn, -0x12345678); EXPECT_EQ(u, 0x12345678); } - -TEST(SaiSerialize, sai_serialize_prefix_compression_entry) -{ - sai_prefix_compression_entry_t e; - - memset(&e, 0, sizeof(e)); - - auto s = sai_serialize_prefix_compression_entry(e); - - sai_deserialize_prefix_compression_entry(s, e); -} diff --git a/unittest/syncd/Makefile.am b/unittest/syncd/Makefile.am index 13b0a43d2..b06a3ec08 100644 --- a/unittest/syncd/Makefile.am +++ b/unittest/syncd/Makefile.am @@ -7,7 +7,6 @@ LDADD_GTEST = -L/usr/src/gtest -lgtest -lgtest_main -lgmock tests_SOURCES = main.cpp \ MockableSaiInterface.cpp \ MockHelper.cpp \ - TestAttrVersionChecker.cpp \ TestCommandLineOptions.cpp \ TestConcurrentQueue.cpp \ TestFlexCounter.cpp \ diff --git a/unittest/syncd/TestAttrVersionChecker.cpp b/unittest/syncd/TestAttrVersionChecker.cpp deleted file mode 100644 index f1bc91ab9..000000000 --- a/unittest/syncd/TestAttrVersionChecker.cpp +++ /dev/null @@ -1,132 +0,0 @@ -#include - -#include -#include -#include - -#include - -#include "AttrVersionChecker.h" -#include "swss/logger.h" - -using namespace syncd; - -TEST(AttrVersionChecker, ctr) -{ - AttrVersionChecker avc; -} - -TEST(AttrVersionChecker, enable) -{ - AttrVersionChecker avc; - - avc.enable(true); - - avc.enable(false); -} - -TEST(AttrVersionChecker, setSaiApiVersion) -{ - AttrVersionChecker avc; - - avc.setSaiApiVersion(SAI_VERSION(1,13,0)); -} - -TEST(AttrVersionChecker, reset) -{ - AttrVersionChecker avc; - - avc.reset(); -} - -#define MD(x,v,n) \ - const sai_attr_metadata_t x = {\ - .objecttype = (sai_object_type_t)SAI_OBJECT_TYPE_BRIDGE,\ - .attrid = SAI_BRIDGE_ATTR_PORT_LIST,\ - .attridname = "SAI_BRIDGE_ATTR_PORT_LIST",\ - .brief = "List of bridge ports associated to this bridge.",\ - .attrvaluetype = SAI_ATTR_VALUE_TYPE_OBJECT_LIST,\ - .flags = (sai_attr_flags_t)(SAI_ATTR_FLAGS_READ_ONLY),\ - .allowedobjecttypes = NULL,\ - .allowedobjecttypeslength = 0,\ - .allowrepetitiononlist = false,\ - .allowmixedobjecttypes = false,\ - .allowemptylist = false,\ - .allownullobjectid = false,\ - .isoidattribute = (1 > 0),\ - .defaultvaluetype = SAI_DEFAULT_VALUE_TYPE_NONE,\ - .defaultvalue = NULL,\ - .defaultvalueobjecttype = SAI_OBJECT_TYPE_NULL,\ - .defaultvalueattrid = SAI_INVALID_ATTRIBUTE_ID,\ - .storedefaultvalue = false,\ - .isenum = false,\ - .isenumlist = false,\ - .enummetadata = NULL,\ - .conditiontype = SAI_ATTR_CONDITION_TYPE_NONE,\ - .conditions = NULL,\ - .conditionslength = 0,\ - .isconditional = (0 != 0),\ - .validonlytype = SAI_ATTR_CONDITION_TYPE_NONE,\ - .validonly = NULL,\ - .validonlylength = 0,\ - .isvalidonly = (0 != 0),\ - .getsave = false,\ - .isvlan = false,\ - .isaclfield = false,\ - .isaclaction = false,\ - .isaclmask = false,\ - .ismandatoryoncreate = false,\ - .iscreateonly = false,\ - .iscreateandset = false,\ - .isreadonly = true,\ - .iskey = false,\ - .isprimitive = false,\ - .notificationtype = -1,\ - .iscallback = false,\ - .pointertype = -1,\ - .capability = NULL,\ - .capabilitylength = 0,\ - .isextensionattr = false,\ - .isresourcetype = false,\ - .isdeprecated = false,\ - .isconditionrelaxed = false,\ - .iscustom = false,\ - .apiversion = (v),\ - .nextrelease = (n),\ - };\ - - -TEST(AttrVersionChecker, isSufficientVersion) -{ - AttrVersionChecker avc; - - avc.enable(true); - EXPECT_EQ(avc.isSufficientVersion(nullptr), false); - - avc.enable(false); - avc.setSaiApiVersion(SAI_VERSION(1,10,0)); - avc.enable(true); - - MD(md,SAI_VERSION(1,9,0),false); - EXPECT_EQ(avc.isSufficientVersion(&md), true); - - MD(md1,SAI_VERSION(1,11,0),false); - EXPECT_EQ(avc.isSufficientVersion(&md1),false); - - avc.enable(false); - EXPECT_EQ(avc.isSufficientVersion(&md1),true); - - avc.enable(true); - avc.setSaiApiVersion(SAI_VERSION(1,10,0)); - EXPECT_EQ(avc.isSufficientVersion(&md1),false); - - avc.setSaiApiVersion(SAI_VERSION(1,12,0)); - EXPECT_EQ(avc.isSufficientVersion(&md1),true); - - avc.setSaiApiVersion(SAI_VERSION(1,11,0)); - EXPECT_EQ(avc.isSufficientVersion(&md1),true); - - MD(md2,SAI_VERSION(1,11,0),true); - avc.setSaiApiVersion(SAI_VERSION(1,11,0)); - EXPECT_EQ(avc.isSufficientVersion(&md2),false); -} diff --git a/unittest/syncd/TestCommandLineOptions.cpp b/unittest/syncd/TestCommandLineOptions.cpp index 0eb5aaef3..7c9088bf0 100644 --- a/unittest/syncd/TestCommandLineOptions.cpp +++ b/unittest/syncd/TestCommandLineOptions.cpp @@ -38,8 +38,6 @@ R"(Usage: syncd [-d] [-p profile] [-t type] [-u] [-S] [-U] [-C] [-s] [-z mode] [ Watchdog time span (in microseconds) to watch for execution -B --supportingBulkCounters Counter groups those support bulk polling - -a --enableAttrVersionCheck - Enable attribute SAI version check when performing SAI discovery -h --help Print out this message )"; @@ -53,7 +51,7 @@ TEST(CommandLineOptions, getCommandLineString) EXPECT_EQ(str, " EnableDiagShell=NO EnableTempView=NO DisableExitSleep=NO EnableUnittests=NO" " EnableConsistencyCheck=NO EnableSyncMode=NO RedisCommunicationMode=redis_async" " EnableSaiBulkSuport=NO StartType=cold ProfileMapFile= GlobalContext=0 ContextConfig= BreakConfig=" - " WatchdogWarnTimeSpan=30000000 SupportingBulkCounters= EnableAttrVersionCheck=NO"); + " WatchdogWarnTimeSpan=30000000 SupportingBulkCounters="); } TEST(CommandLineOptions, startTypeStringToStartType) diff --git a/unittest/syncd/TestVendorSai.cpp b/unittest/syncd/TestVendorSai.cpp index f14d280a4..63977e713 100644 --- a/unittest/syncd/TestVendorSai.cpp +++ b/unittest/syncd/TestVendorSai.cpp @@ -1543,18 +1543,3 @@ TEST(VendorSai, bulk_meter_rules) EXPECT_EQ(SAI_STATUS_SUCCESS, sai.remove((sai_object_type_t)SAI_OBJECT_TYPE_METER_POLICY, meter_policy0)); EXPECT_EQ(SAI_STATUS_SUCCESS, sai.remove((sai_object_type_t)SAI_OBJECT_TYPE_METER_POLICY, meter_policy1)); } - -TEST_F(VendorSaiTest, bulk_prefix_compression_entry) -{ - sai_prefix_compression_entry_t *e = nullptr; - - // metadata will fail - EXPECT_EQ(SAI_STATUS_INVALID_PARAMETER, - m_vsai->bulkCreate(0, e, nullptr, nullptr, SAI_BULK_OP_ERROR_MODE_STOP_ON_ERROR, nullptr)); - - EXPECT_EQ(SAI_STATUS_INVALID_PARAMETER, - m_vsai->bulkRemove(0, e, SAI_BULK_OP_ERROR_MODE_STOP_ON_ERROR, nullptr)); - - EXPECT_EQ(SAI_STATUS_NOT_SUPPORTED, - m_vsai->bulkSet(0, e, nullptr, SAI_BULK_OP_ERROR_MODE_STOP_ON_ERROR, nullptr)); -} From 92322be787a7b9e972810ba8f250700c4b8182ef Mon Sep 17 00:00:00 2001 From: Saikrishna Arcot Date: Fri, 6 Dec 2024 14:12:20 -0800 Subject: [PATCH 5/7] Update the Azure Pipeline build to use Bookworm (#1452) Update the Azure Pipeline build to build for Bookworm. Signed-off-by: Saikrishna Arcot --- .azure-pipelines/build-swss-template.yml | 2 +- .azure-pipelines/build-template.yml | 18 +- .azure-pipelines/docker-sonic-vs/Dockerfile | 13 +- .azure-pipelines/docker-sonic-vs/start.sh | 187 ++++++++++++++++++++ azure-pipelines.yml | 74 ++------ 5 files changed, 221 insertions(+), 73 deletions(-) create mode 100755 .azure-pipelines/docker-sonic-vs/start.sh diff --git a/.azure-pipelines/build-swss-template.yml b/.azure-pipelines/build-swss-template.yml index 54cd78e2c..b68c9c154 100644 --- a/.azure-pipelines/build-swss-template.yml +++ b/.azure-pipelines/build-swss-template.yml @@ -74,7 +74,7 @@ jobs: sudo perl -i.bk -ne 'print if not /SONiCFileFormat|ActionFileDefaultTemplate/' /etc/rsyslog.conf sudo sed -ie '/GLOBAL DIRECTIVES/{s/$/\n\$template SONiCFileFormat,"%TIMESTAMP%.%timestamp:::date-subseconds% %HOSTNAME% %syslogseverity-text:::uppercase% %syslogtag%%msg:::sp-if-no-1st-sp%%msg:::drop-lst-lf%\\n"\n\$ActionFileDefaultTemplate SONiCFileFormat/}' /etc/rsyslog.conf - sudo service rsyslog start + sudo rsyslogd displayName: "Install dependencies" - task: DownloadPipelineArtifact@2 diff --git a/.azure-pipelines/build-template.yml b/.azure-pipelines/build-template.yml index 006be95a1..e8d855aa1 100644 --- a/.azure-pipelines/build-template.yml +++ b/.azure-pipelines/build-template.yml @@ -73,7 +73,6 @@ jobs: set -ex sudo apt-get update sudo apt-get install -qq -y \ - qtbase5-dev \ libdbus-glib-1-dev \ libpcsclite-dev \ docbook-to-man \ @@ -86,7 +85,6 @@ jobs: libnl-nf-3-dev \ libnl-cli-3-dev \ swig4.0 \ - libzmq5 \ libzmq3-dev \ autoconf-archive @@ -167,20 +165,10 @@ jobs: displayName: "Compile sonic sairedis with coverage enabled" - script: | sudo cp azsyslog.conf /etc/rsyslog.conf - sudo killall rsyslogd + sudo pkill -F /run/rsyslogd.pid sudo rsyslogd displayName: "Update rsyslog.conf" - ${{ if eq(parameters.run_unit_test, true) }}: - - script: | - set -ex - git clone https://github.com/gcovr/gcovr.git - cd gcovr/ - git checkout 5.0 - sudo pip3 install setuptools - sudo python3 setup.py install - cd .. - sudo rm -rf gcovr - displayName: "Install gcovr 5.0" - script: | set -ex # Add SYS_TIME capability for settimeofday ok in syncd test @@ -207,9 +195,9 @@ jobs: set -ex # Install .NET CORE curl -sSL https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - - sudo apt-add-repository https://packages.microsoft.com/debian/11/prod + sudo apt-add-repository https://packages.microsoft.com/debian/12/prod sudo apt-get update - sudo apt-get install -y dotnet-sdk-7.0 + sudo apt-get install -y dotnet-sdk-8.0 displayName: "Install .NET CORE" - task: PublishCodeCoverageResults@1 inputs: diff --git a/.azure-pipelines/docker-sonic-vs/Dockerfile b/.azure-pipelines/docker-sonic-vs/Dockerfile index b10817633..e49122e84 100644 --- a/.azure-pipelines/docker-sonic-vs/Dockerfile +++ b/.azure-pipelines/docker-sonic-vs/Dockerfile @@ -9,7 +9,10 @@ COPY ["debs", "/debs"] # Docker's diff detection mechanism, where only the file size and the modification timestamp (which will remain the # same, even though contents have changed) are checked between the previous and current layer. RUN dpkg --purge libswsscommon python3-swsscommon sonic-db-cli libsaimetadata libsairedis libsaivs syncd-vs swss sonic-eventd libdashapi -RUN dpkg -i /debs/libdashapi_1.0.0_amd64.deb \ + +RUN apt-get update + +RUN apt install -y /debs/libdashapi_1.0.0_amd64.deb \ /debs/libswsscommon_1.0.0_amd64.deb \ /debs/python3-swsscommon_1.0.0_amd64.deb \ /debs/sonic-db-cli_1.0.0_amd64.deb \ @@ -19,4 +22,10 @@ RUN dpkg -i /debs/libdashapi_1.0.0_amd64.deb \ /debs/syncd-vs_1.0.0_amd64.deb \ /debs/swss_1.0.0_amd64.deb -RUN if [ "$need_dbg" = "y" ] ; then dpkg -i /debs/syncd-vs-dbgsym_1.0.0_amd64.deb ; fi +RUN if [ "$need_dbg" = "y" ] ; then dpkg -i /debs/libsairedis-dbgsym_1.0.0_amd64.deb ; fi + +COPY ["start.sh", "/usr/bin/"] + +RUN pip3 install scapy==2.5.0 + +RUN apt-get -y install software-properties-common libdatetime-perl libcapture-tiny-perl build-essential libcpanel-json-xs-perl git python3-protobuf diff --git a/.azure-pipelines/docker-sonic-vs/start.sh b/.azure-pipelines/docker-sonic-vs/start.sh new file mode 100755 index 000000000..f7dbde8dc --- /dev/null +++ b/.azure-pipelines/docker-sonic-vs/start.sh @@ -0,0 +1,187 @@ +#!/bin/bash -e + +# Generate configuration + +# NOTE: 'PLATFORM' and 'HWSKU' environment variables are set +# in the Dockerfile so that they persist for the life of the container + +ln -sf /usr/share/sonic/device/$PLATFORM /usr/share/sonic/platform +ln -sf /usr/share/sonic/device/$PLATFORM/$HWSKU /usr/share/sonic/hwsku + +SWITCH_TYPE=switch +PLATFORM_CONF=platform.json +if [[ $HWSKU == "DPU-2P" ]]; then + SWITCH_TYPE=dpu + PLATFORM_CONF=platform-dpu-2p.json +fi + +pushd /usr/share/sonic/hwsku + +# filter available front panel ports in lanemap.ini +[ -f lanemap.ini.orig ] || cp lanemap.ini lanemap.ini.orig +for p in $(ip link show | grep -oE "eth[0-9]+" | grep -v eth0); do + grep ^$p: lanemap.ini.orig +done > lanemap.ini + +# filter available sonic front panel ports in port_config.ini +[ -f port_config.ini.orig ] || cp port_config.ini port_config.ini.orig +grep ^# port_config.ini.orig > port_config.ini +for lanes in $(awk -F ':' '{print $2}' lanemap.ini); do + grep -E "\s$lanes\s" port_config.ini.orig +done >> port_config.ini + +popd + +[ -d /etc/sonic ] || mkdir -p /etc/sonic + +# Note: libswsscommon requires a dabase_config file in /var/run/redis/sonic-db/ +# Prepare this file before any dependent application, such as sonic-cfggen +mkdir -p /var/run/redis/sonic-db +cp /etc/default/sonic-db/database_config.json /var/run/redis/sonic-db/ + +SYSTEM_MAC_ADDRESS=$(ip link show eth0 | grep ether | awk '{print $2}') +sonic-cfggen -t /usr/share/sonic/templates/init_cfg.json.j2 -a "{\"system_mac\": \"$SYSTEM_MAC_ADDRESS\", \"switch_type\": \"$SWITCH_TYPE\"}" > /etc/sonic/init_cfg.json + +if [[ -f /usr/share/sonic/virtual_chassis/default_config.json ]]; then + sonic-cfggen -j /etc/sonic/init_cfg.json -j /usr/share/sonic/virtual_chassis/default_config.json --print-data > /tmp/init_cfg.json + mv /tmp/init_cfg.json /etc/sonic/init_cfg.json +fi + +if [ -f /etc/sonic/config_db.json ]; then + sonic-cfggen -j /etc/sonic/init_cfg.json -j /etc/sonic/config_db.json --print-data > /tmp/config_db.json + mv /tmp/config_db.json /etc/sonic/config_db.json +else + # generate and merge buffers configuration into config file + if [ -f /usr/share/sonic/hwsku/buffers.json.j2 ]; then + sonic-cfggen -k $HWSKU -p /usr/share/sonic/device/$PLATFORM/$PLATFORM_CONF -t /usr/share/sonic/hwsku/buffers.json.j2 > /tmp/buffers.json + buffers_cmd="-j /tmp/buffers.json" + fi + if [ -f /usr/share/sonic/hwsku/qos.json.j2 ]; then + sonic-cfggen -j /etc/sonic/init_cfg.json -t /usr/share/sonic/hwsku/qos.json.j2 > /tmp/qos.json + qos_cmd="-j /tmp/qos.json" + fi + + sonic-cfggen -p /usr/share/sonic/device/$PLATFORM/$PLATFORM_CONF -k $HWSKU --print-data > /tmp/ports.json + # change admin_status from up to down; Test cases dependent + sed -i "s/up/down/g" /tmp/ports.json + sonic-cfggen -j /etc/sonic/init_cfg.json $buffers_cmd $qos_cmd -j /tmp/ports.json --print-data > /etc/sonic/config_db.json +fi + +sonic-cfggen -t /usr/share/sonic/templates/copp_cfg.j2 > /etc/sonic/copp_cfg.json + +if [ "$HWSKU" == "Mellanox-SN2700" ]; then + cp /usr/share/sonic/hwsku/sai_mlnx.profile /usr/share/sonic/hwsku/sai.profile +elif [ "$HWSKU" == "DPU-2P" ]; then + cp /usr/share/sonic/hwsku/sai_dpu_2p.profile /usr/share/sonic/hwsku/sai.profile +fi + +mkdir -p /etc/swss/config.d/ + +rm -f /var/run/rsyslogd.pid + +supervisorctl start rsyslogd + +supervisord_cfg="/etc/supervisor/conf.d/supervisord.conf" +chassisdb_cfg_file="/usr/share/sonic/virtual_chassis/default_config.json" +chassisdb_cfg_file_default="/etc/default/sonic-db/default_chassis_cfg.json" +host_template="/usr/share/sonic/templates/hostname.j2" +db_cfg_file="/var/run/redis/sonic-db/database_config.json" +db_cfg_file_tmp="/var/run/redis/sonic-db/database_config.json.tmp" + +if [ -r "$chassisdb_cfg_file" ]; then + echo $(sonic-cfggen -j $chassisdb_cfg_file -t $host_template) >> /etc/hosts +else + chassisdb_cfg_file="$chassisdb_cfg_file_default" + echo "10.8.1.200 redis_chassis.server" >> /etc/hosts +fi + +supervisorctl start redis-server + +start_chassis_db=`sonic-cfggen -v DEVICE_METADATA.localhost.start_chassis_db -y $chassisdb_cfg_file` +if [[ "$HOSTNAME" == *"supervisor"* ]] || [ "$start_chassis_db" == "1" ]; then + supervisorctl start redis-chassis +fi + +conn_chassis_db=`sonic-cfggen -v DEVICE_METADATA.localhost.connect_to_chassis_db -y $chassisdb_cfg_file` +if [ "$start_chassis_db" != "1" ] && [ "$conn_chassis_db" != "1" ]; then + cp $db_cfg_file $db_cfg_file_tmp + update_chassisdb_config -j $db_cfg_file_tmp -d + cp $db_cfg_file_tmp $db_cfg_file +fi + +if [ "$conn_chassis_db" == "1" ]; then + if [ -f /usr/share/sonic/virtual_chassis/coreportindexmap.ini ]; then + cp /usr/share/sonic/virtual_chassis/coreportindexmap.ini /usr/share/sonic/hwsku/ + + pushd /usr/share/sonic/hwsku + + # filter available front panel ports in coreportindexmap.ini + [ -f coreportindexmap.ini.orig ] || cp coreportindexmap.ini coreportindexmap.ini.orig + for p in $(ip link show | grep -oE "eth[0-9]+" | grep -v eth0); do + grep ^$p: coreportindexmap.ini.orig + done > coreportindexmap.ini + + popd + fi +fi + +/usr/bin/configdb-load.sh + +if [ "$HWSKU" = "brcm_gearbox_vs" ]; then + supervisorctl start gbsyncd + supervisorctl start gearsyncd +fi + +supervisorctl start syncd + +supervisorctl start portsyncd + +supervisorctl start orchagent + +supervisorctl start coppmgrd + +supervisorctl start neighsyncd + +supervisorctl start fdbsyncd + +supervisorctl start teamsyncd + +supervisorctl start fpmsyncd + +supervisorctl start teammgrd + +supervisorctl start vrfmgrd + +supervisorctl start portmgrd + +supervisorctl start intfmgrd + +supervisorctl start vlanmgrd + +supervisorctl start zebra + +supervisorctl start mgmtd + +supervisorctl start staticd + +supervisorctl start buffermgrd + +supervisorctl start nbrmgrd + +supervisorctl start vxlanmgrd + +supervisorctl start sflowmgrd + +supervisorctl start natmgrd + +supervisorctl start natsyncd + +supervisorctl start tunnelmgrd + +supervisorctl start fabricmgrd + +# Start arp_update when VLAN exists +VLAN=`sonic-cfggen -d -v 'VLAN.keys() | join(" ") if VLAN'` +if [ "$VLAN" != "" ]; then + supervisorctl start arp_update +fi diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 79f3989ae..92bc9933f 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -37,7 +37,7 @@ resources: parameters: - name: debian_version type: string - default: bullseye + default: bookworm variables: - name: BUILD_BRANCH ${{ if eq(variables['Build.Reason'], 'PullRequest') }}: @@ -53,8 +53,8 @@ stages: parameters: arch: amd64 sonic_slave: sonic-slave-${{ parameters.debian_version }} - swss_common_artifact_name: sonic-swss-common - artifact_name: sonic-sairedis + swss_common_artifact_name: sonic-swss-common-${{ parameters.debian_version }} + artifact_name: sonic-sairedis-${{ parameters.debian_version }} syslog_artifact_name: sonic-sairedis.syslog run_unit_test: true archive_gcov: true @@ -67,11 +67,11 @@ stages: parameters: arch: amd64 sonic_slave: sonic-slave-${{ parameters.debian_version }} - swss_common_artifact_name: sonic-swss-common - artifact_name: sonic-sairedis-asan + swss_common_artifact_name: sonic-swss-common-${{ parameters.debian_version }} + artifact_name: sonic-sairedis-asan-${{ parameters.debian_version }} syslog_artifact_name: sonic-sairedis-asan.syslog asan: true - run_unit_test: false + run_unit_test: true archive_gcov: false debian_version: ${{ parameters.debian_version }} @@ -85,8 +85,8 @@ stages: timeout: 180 pool: sonicbld-armhf sonic_slave: sonic-slave-${{ parameters.debian_version }}-armhf - swss_common_artifact_name: sonic-swss-common.armhf - artifact_name: sonic-sairedis.armhf + swss_common_artifact_name: sonic-swss-common-${{ parameters.debian_version }}.armhf + artifact_name: sonic-sairedis-${{ parameters.debian_version }}.armhf syslog_artifact_name: sonic-sairedis.syslog.armhf debian_version: ${{ parameters.debian_version }} @@ -96,47 +96,11 @@ stages: timeout: 180 pool: sonicbld-arm64 sonic_slave: sonic-slave-${{ parameters.debian_version }}-arm64 - swss_common_artifact_name: sonic-swss-common.arm64 - artifact_name: sonic-sairedis.arm64 + swss_common_artifact_name: sonic-swss-common-${{ parameters.debian_version }}.arm64 + artifact_name: sonic-sairedis-${{ parameters.debian_version }}.arm64 syslog_artifact_name: sonic-sairedis.syslog.arm64 debian_version: ${{ parameters.debian_version }} -- stage: BuildBookworm - dependsOn: BuildArm - condition: succeeded('BuildArm') - jobs: - - template: .azure-pipelines/build-template.yml - parameters: - arch: amd64 - sonic_slave: sonic-slave-bookworm - swss_common_artifact_name: sonic-swss-common-bookworm - artifact_name: sonic-sairedis-bookworm - syslog_artifact_name: sonic-sairedis-bookworm.syslog - run_unit_test: true - debian_version: ${{ parameters.debian_version }} - - - template: .azure-pipelines/build-template.yml - parameters: - arch: armhf - timeout: 180 - pool: sonicbld-armhf - sonic_slave: sonic-slave-bookworm-armhf - swss_common_artifact_name: sonic-swss-common-bookworm.armhf - artifact_name: sonic-sairedis-bookworm.armhf - syslog_artifact_name: sonic-sairedis-bookworm.syslog.armhf - debian_version: ${{ parameters.debian_version }} - - - template: .azure-pipelines/build-template.yml - parameters: - arch: arm64 - timeout: 180 - pool: sonicbld-arm64 - sonic_slave: sonic-slave-bookworm-arm64 - swss_common_artifact_name: sonic-swss-common-bookworm.arm64 - artifact_name: sonic-sairedis-bookworm.arm64 - syslog_artifact_name: sonic-sairedis-bookworm.syslog.arm64 - debian_version: ${{ parameters.debian_version }} - - stage: BuildSwss dependsOn: Build condition: succeeded('Build') @@ -145,10 +109,10 @@ stages: parameters: arch: amd64 sonic_slave: sonic-slave-${{ parameters.debian_version }} - swss_common_artifact_name: sonic-swss-common - sairedis_artifact_name: sonic-sairedis + swss_common_artifact_name: sonic-swss-common-${{ parameters.debian_version }} + sairedis_artifact_name: sonic-sairedis-${{ parameters.debian_version }} syslog_artifact_name: sonic-swss.syslog - artifact_name: sonic-swss + artifact_name: sonic-swss-${{ parameters.debian_version }} debian_version: ${{ parameters.debian_version }} - stage: BuildDocker @@ -157,9 +121,9 @@ stages: jobs: - template: .azure-pipelines/build-docker-sonic-vs-template.yml parameters: - swss_common_artifact_name: sonic-swss-common - sairedis_artifact_name: sonic-sairedis - swss_artifact_name: sonic-swss + swss_common_artifact_name: sonic-swss-common-${{ parameters.debian_version }} + sairedis_artifact_name: sonic-sairedis-${{ parameters.debian_version }} + swss_artifact_name: sonic-swss-${{ parameters.debian_version }} artifact_name: docker-sonic-vs - stage: BuildDockerAsan @@ -170,9 +134,9 @@ stages: jobs: - template: .azure-pipelines/build-docker-sonic-vs-template.yml parameters: - swss_common_artifact_name: sonic-swss-common - sairedis_artifact_name: sonic-sairedis-asan - swss_artifact_name: sonic-swss + swss_common_artifact_name: sonic-swss-common-${{ parameters.debian_version }} + sairedis_artifact_name: sonic-sairedis-asan-${{ parameters.debian_version }} + swss_artifact_name: sonic-swss-${{ parameters.debian_version }} artifact_name: docker-sonic-vs-asan asan: true From 98bb52ebe92dd47edf0bb12321886df2388e026f Mon Sep 17 00:00:00 2001 From: Stepan Blyshchak <38952541+stepanblyschak@users.noreply.github.com> Date: Tue, 10 Dec 2024 13:24:47 +0200 Subject: [PATCH 6/7] [syncd] Implement bulk set support (#1422) Added support for bulk set SAI API for port, PG and queue objects. This allows orchagent to configure those objects in bulk improving configuration time. --- syncd/Syncd.cpp | 58 +++++++++++ syncd/Syncd.h | 7 ++ syncd/VendorSai.cpp | 33 +++++- syncd/tests/TestSyncdBrcm.cpp | 179 +++++++++++++++++++++++++++++++++ tests/BCM56850.pl | 10 +- tests/BCM56850/bulk_object.rec | 11 ++ 6 files changed, 295 insertions(+), 3 deletions(-) diff --git a/syncd/Syncd.cpp b/syncd/Syncd.cpp index 9c2533c3a..e7efff34e 100644 --- a/syncd/Syncd.cpp +++ b/syncd/Syncd.cpp @@ -2024,6 +2024,60 @@ sai_status_t Syncd::processBulkOidCreate( return status; } +sai_status_t Syncd::processBulkOidSet( + _In_ sai_object_type_t objectType, + _In_ sai_bulk_op_error_mode_t mode, + _In_ const std::vector& objectIds, + _In_ const std::vector>& attributes, + _Out_ std::vector& statuses) +{ + SWSS_LOG_ENTER(); + + sai_status_t status = SAI_STATUS_SUCCESS; + uint32_t object_count = static_cast(objectIds.size()); + + if (!object_count) + { + SWSS_LOG_ERROR("container with objectIds is empty in processBulkOidSet"); + return SAI_STATUS_FAILURE; + } + + std::vector objectVids(object_count); + std::vector objectRids(object_count); + + std::vector attr_list(object_count); + + for (size_t idx = 0; idx < object_count; idx++) + { + sai_deserialize_object_id(objectIds[idx], objectVids[idx]); + objectRids[idx] = m_translator->translateVidToRid(objectVids[idx]); + + const auto attr_count = attributes[idx]->get_attr_count(); + if (attr_count != 1) + { + SWSS_LOG_THROW("bulkSet api requires one attribute per object"); + } + + attr_list[idx] = *attributes[idx]->get_attr_list(); + } + + status = m_vendorSai->bulkSet( + objectType, + object_count, + objectRids.data(), + attr_list.data(), + mode, + statuses.data()); + + if (status == SAI_STATUS_NOT_IMPLEMENTED || status == SAI_STATUS_NOT_SUPPORTED) + { + SWSS_LOG_ERROR("bulkSet api is not implemented or not supported, object_type = %s", + sai_serialize_object_type(objectType).c_str()); + } + + return status; +} + sai_status_t Syncd::processBulkOidRemove( _In_ sai_object_type_t objectType, _In_ sai_bulk_op_error_mode_t mode, @@ -2128,6 +2182,10 @@ sai_status_t Syncd::processBulkOid( all = processBulkOidCreate(objectType, mode, objectIds, attributes, statuses); break; + case SAI_COMMON_API_BULK_SET: + all = processBulkOidSet(objectType, mode, objectIds, attributes, statuses); + break; + case SAI_COMMON_API_BULK_REMOVE: all = processBulkOidRemove(objectType, mode, objectIds, statuses); break; diff --git a/syncd/Syncd.h b/syncd/Syncd.h index 06eb84a62..7cbd0575c 100644 --- a/syncd/Syncd.h +++ b/syncd/Syncd.h @@ -242,6 +242,13 @@ namespace syncd _In_ const std::vector>& attributes, _Out_ std::vector& statuses); + sai_status_t processBulkOidSet( + _In_ sai_object_type_t objectType, + _In_ sai_bulk_op_error_mode_t mode, + _In_ const std::vector& objectIds, + _In_ const std::vector>& attributes, + _Out_ std::vector& statuses); + sai_status_t processBulkOidRemove( _In_ sai_object_type_t objectType, _In_ sai_bulk_op_error_mode_t mode, diff --git a/syncd/VendorSai.cpp b/syncd/VendorSai.cpp index c0cb5683a..4e6ee2d8b 100644 --- a/syncd/VendorSai.cpp +++ b/syncd/VendorSai.cpp @@ -606,9 +606,38 @@ sai_status_t VendorSai::bulkSet( SWSS_LOG_ENTER(); VENDOR_CHECK_API_INITIALIZED(); - SWSS_LOG_ERROR("not supported by SAI"); + sai_bulk_object_set_attribute_fn ptr; - return SAI_STATUS_NOT_SUPPORTED; + switch (object_type) + { + case SAI_OBJECT_TYPE_PORT: + ptr = m_apis.port_api->set_ports_attribute; + break; + + case SAI_OBJECT_TYPE_INGRESS_PRIORITY_GROUP: + ptr = m_apis.buffer_api->set_ingress_priority_groups_attribute; + break; + + case SAI_OBJECT_TYPE_QUEUE: + ptr = m_apis.queue_api->set_queues_attribute; + break; + + default: + SWSS_LOG_ERROR("not implemented %s, FIXME", sai_serialize_object_type(object_type).c_str()); + return SAI_STATUS_NOT_IMPLEMENTED; + } + + if (!ptr) + { + SWSS_LOG_INFO("create bulk not supported from SAI, object_type = %s", sai_serialize_object_type(object_type).c_str()); + return SAI_STATUS_NOT_SUPPORTED; + } + + return ptr(object_count, + object_id, + attr_list, + mode, + object_statuses); } sai_status_t VendorSai::bulkGet( diff --git a/syncd/tests/TestSyncdBrcm.cpp b/syncd/tests/TestSyncdBrcm.cpp index 892a3ca0e..7a6e44424 100644 --- a/syncd/tests/TestSyncdBrcm.cpp +++ b/syncd/tests/TestSyncdBrcm.cpp @@ -389,3 +389,182 @@ TEST_F(SyncdBrcmTest, neighborBulkTest) ASSERT_EQ(status, SAI_STATUS_SUCCESS); } } + +TEST_F(SyncdBrcmTest, portBufferBulkSet) +{ + sai_object_id_t switchId; + sai_attribute_t attrs[1]; + + struct + { + std::vector oids; + std::vector attrs; + std::vector statuses; + + void resize(size_t size) + { + SWSS_LOG_ENTER(); + + oids.resize(size); + attrs.resize(size); + statuses.resize(size, SAI_STATUS_NOT_EXECUTED); + } + } ports, pgs, queues; + + // init view + + attrs[0].id = SAI_REDIS_SWITCH_ATTR_NOTIFY_SYNCD; + attrs[0].value.s32 = SAI_REDIS_NOTIFY_SYNCD_INIT_VIEW; + + auto status = m_sairedis->set(SAI_OBJECT_TYPE_SWITCH, SAI_NULL_OBJECT_ID, attrs); + ASSERT_EQ(status, SAI_STATUS_SUCCESS); + + // create switch + + attrs[0].id = SAI_SWITCH_ATTR_INIT_SWITCH; + attrs[0].value.booldata = true; + + status = m_sairedis->create(SAI_OBJECT_TYPE_SWITCH, &switchId, SAI_NULL_OBJECT_ID, 1, attrs); + ASSERT_EQ(status, SAI_STATUS_SUCCESS); + + attrs[0].id = SAI_SWITCH_ATTR_PORT_NUMBER; + status = m_sairedis->get(SAI_OBJECT_TYPE_SWITCH, switchId, 1, attrs); + ASSERT_EQ(status, SAI_STATUS_SUCCESS); + + ports.resize(attrs[0].value.u32); + + ASSERT_TRUE(ports.oids.size() > 1); + + attrs[0].id = SAI_SWITCH_ATTR_PORT_LIST; + attrs[0].value.objlist.count = static_cast(ports.oids.size()); + attrs[0].value.objlist.list = ports.oids.data(); + status = m_sairedis->get(SAI_OBJECT_TYPE_SWITCH, switchId, 1, attrs); + ASSERT_EQ(status, SAI_STATUS_SUCCESS); + + // Set port admin status in bulk + + for (size_t i = 0; i < ports.oids.size(); i++) + { + ports.attrs[i].id = SAI_PORT_ATTR_ADMIN_STATE; + ports.attrs[i].value.booldata = true; + } + + status = m_sairedis->bulkSet(SAI_OBJECT_TYPE_PORT, static_cast(ports.oids.size()), ports.oids.data(), + ports.attrs.data(), SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR, ports.statuses.data()); + ASSERT_EQ(status, SAI_STATUS_SUCCESS); + + for (size_t i = 0; i < ports.oids.size(); i++) + { + ASSERT_EQ(ports.statuses[i], SAI_STATUS_SUCCESS); + } + + // Create buffer pool + + std::array buffer_pool_attrs; + sai_object_id_t buffer_pool; + + buffer_pool_attrs[0].id = SAI_BUFFER_POOL_ATTR_THRESHOLD_MODE; + buffer_pool_attrs[0].value.u32 = SAI_BUFFER_POOL_THRESHOLD_MODE_DYNAMIC; + + buffer_pool_attrs[1].id = SAI_BUFFER_POOL_ATTR_SIZE; + buffer_pool_attrs[1].value.u32 = 47218432; + + buffer_pool_attrs[2].id = SAI_BUFFER_POOL_ATTR_TYPE; + buffer_pool_attrs[2].value.u32 = SAI_BUFFER_POOL_TYPE_INGRESS; + + buffer_pool_attrs[3].id = SAI_BUFFER_POOL_ATTR_XOFF_SIZE; + buffer_pool_attrs[3].value.u32 = 17708800; + + status = m_sairedis->create(SAI_OBJECT_TYPE_BUFFER_POOL, &buffer_pool, switchId, + static_cast(buffer_pool_attrs.size()), buffer_pool_attrs.data()); + ASSERT_EQ(status, SAI_STATUS_SUCCESS); + + // Create buffer profile + + std::array buffer_profile_attrs; + sai_object_id_t buffer_profile; + + buffer_profile_attrs[0].id = SAI_BUFFER_PROFILE_ATTR_POOL_ID; + buffer_profile_attrs[0].value.oid = buffer_pool; + + buffer_profile_attrs[1].id = SAI_BUFFER_PROFILE_ATTR_THRESHOLD_MODE; + buffer_profile_attrs[1].value.u32 = SAI_BUFFER_PROFILE_THRESHOLD_MODE_DYNAMIC; + + buffer_profile_attrs[2].id = SAI_BUFFER_PROFILE_ATTR_SHARED_DYNAMIC_TH; + buffer_profile_attrs[2].value.s8 = -8; + + buffer_profile_attrs[3].id = SAI_BUFFER_PROFILE_ATTR_RESERVED_BUFFER_SIZE; + buffer_profile_attrs[3].value.u64 = 6755399441055744; + + status = m_sairedis->create(SAI_OBJECT_TYPE_BUFFER_PROFILE, &buffer_profile, switchId, + static_cast(buffer_profile_attrs.size()), buffer_profile_attrs.data()); + ASSERT_EQ(status, SAI_STATUS_SUCCESS); + + // Priority group configuration + + attrs[0].id = SAI_PORT_ATTR_NUMBER_OF_INGRESS_PRIORITY_GROUPS; + status = m_sairedis->get(SAI_OBJECT_TYPE_PORT, ports.oids[0], 1, attrs); + ASSERT_EQ(status, SAI_STATUS_SUCCESS); + + pgs.resize(attrs[0].value.u32); + + attrs[0].id = SAI_PORT_ATTR_INGRESS_PRIORITY_GROUP_LIST; + attrs[0].value.objlist.count = static_cast(pgs.oids.size()); + attrs[0].value.objlist.list = pgs.oids.data(); + + status = m_sairedis->get(SAI_OBJECT_TYPE_PORT, ports.oids[0], 1, attrs); + ASSERT_EQ(status, SAI_STATUS_SUCCESS); + + for (size_t i = 0; i < pgs.oids.size(); i++) + { + pgs.attrs[i].id = SAI_INGRESS_PRIORITY_GROUP_ATTR_BUFFER_PROFILE; + pgs.attrs[i].value.oid = buffer_profile; + } + + status = m_sairedis->bulkSet(SAI_OBJECT_TYPE_INGRESS_PRIORITY_GROUP, static_cast(pgs.oids.size()), pgs.oids.data(), + pgs.attrs.data(), SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR, pgs.statuses.data()); + ASSERT_EQ(status, SAI_STATUS_SUCCESS); + + for (size_t i = 0; i < pgs.oids.size(); i++) + { + ASSERT_EQ(pgs.statuses[i], SAI_STATUS_SUCCESS); + } + + // Queue configuration + + attrs[0].id = SAI_PORT_ATTR_QOS_NUMBER_OF_QUEUES; + status = m_sairedis->get(SAI_OBJECT_TYPE_PORT, ports.oids[0], 1, attrs); + ASSERT_EQ(status, SAI_STATUS_SUCCESS); + + queues.resize(attrs[0].value.u32); + + attrs[0].id = SAI_PORT_ATTR_QOS_QUEUE_LIST; + attrs[0].value.objlist.count = static_cast(queues.oids.size()); + attrs[0].value.objlist.list = queues.oids.data(); + + status = m_sairedis->get(SAI_OBJECT_TYPE_PORT, ports.oids[0], 1, attrs); + ASSERT_EQ(status, SAI_STATUS_SUCCESS); + + for (size_t i = 0; i < queues.oids.size(); i++) + { + queues.attrs[i].id = SAI_QUEUE_ATTR_BUFFER_PROFILE_ID; + queues.attrs[i].value.oid = buffer_profile; + } + + status = m_sairedis->bulkSet(SAI_OBJECT_TYPE_QUEUE, static_cast(queues.oids.size()), queues.oids.data(), + queues.attrs.data(), SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR, queues.statuses.data()); + ASSERT_EQ(status, SAI_STATUS_SUCCESS); + + for (size_t i = 0; i < queues.oids.size(); i++) + { + ASSERT_EQ(queues.statuses[i], SAI_STATUS_SUCCESS); + } + + // apply view + + attrs[0].id = SAI_REDIS_SWITCH_ATTR_NOTIFY_SYNCD; + attrs[0].value.s32 = SAI_REDIS_NOTIFY_SYNCD_APPLY_VIEW; + + status = m_sairedis->set(SAI_OBJECT_TYPE_SWITCH, SAI_NULL_OBJECT_ID, attrs); + ASSERT_EQ(status, SAI_STATUS_SUCCESS); +} \ No newline at end of file diff --git a/tests/BCM56850.pl b/tests/BCM56850.pl index bca5fc4ce..6b9c66c85 100755 --- a/tests/BCM56850.pl +++ b/tests/BCM56850.pl @@ -594,13 +594,20 @@ sub test_bulk_fdb play "bulk_fdb.rec" } -sub test_bulk_object +sub test_emulated_bulk_object { fresh_start; play "bulk_object.rec" } +sub test_bulk_object +{ + fresh_start_bulk; + + play "bulk_object.rec" +} + sub test_depreacated_enums { fresh_start; @@ -899,6 +906,7 @@ sub test_neighbor_next_hop test_bulk_route; test_bulk_neighbor; test_bulk_fdb; +test_emulated_bulk_object; test_bulk_object; test_brcm_config_acl; test_brcm_warm_wred_queue; diff --git a/tests/BCM56850/bulk_object.rec b/tests/BCM56850/bulk_object.rec index eacbbb9da..781c1fa28 100644 --- a/tests/BCM56850/bulk_object.rec +++ b/tests/BCM56850/bulk_object.rec @@ -2,6 +2,17 @@ 2017-06-14.01:55:46.543987|a|INIT_VIEW 2017-06-14.01:55:46.551164|A|SAI_STATUS_SUCCESS 2017-06-14.01:55:46.555975|c|SAI_OBJECT_TYPE_SWITCH:oid:0x21000000000000|SAI_SWITCH_ATTR_INIT_SWITCH=true|SAI_SWITCH_ATTR_FDB_EVENT_NOTIFY=0x417890|SAI_SWITCH_ATTR_PORT_STATE_CHANGE_NOTIFY=0x4179f0|SAI_SWITCH_ATTR_SWITCH_SHUTDOWN_REQUEST_NOTIFY=0x417b50 +2018-11-05.23:55:47.743415|g|SAI_OBJECT_TYPE_SWITCH:oid:0x21000000000000|SAI_SWITCH_ATTR_PORT_LIST=32:oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0 +2018-11-05.23:55:47.749126|G|SAI_STATUS_SUCCESS|SAI_SWITCH_ATTR_PORT_LIST=32:oid:0x1000000000002,oid:0x1000000000003,oid:0x1000000000004,oid:0x1000000000005,oid:0x1000000000006,oid:0x1000000000007,oid:0x1000000000008,oid:0x1000000000009,oid:0x100000000000a,oid:0x100000000000b,oid:0x100000000000c,oid:0x100000000000d,oid:0x100000000000e,oid:0x100000000000f,oid:0x1000000000010,oid:0x1000000000011,oid:0x1000000000012,oid:0x1000000000013,oid:0x1000000000014,oid:0x1000000000015,oid:0x1000000000016,oid:0x1000000000017,oid:0x1000000000018,oid:0x1000000000019,oid:0x100000000001a,oid:0x100000000001b,oid:0x100000000001c,oid:0x100000000001d,oid:0x100000000001e,oid:0x100000000001f,oid:0x1000000000020,oid:0x1000000000021 +2017-06-14.01:55:56.555975|S|SAI_OBJECT_TYPE_PORT||oid:0x1000000000002|SAI_PORT_ATTR_ADMIN_STATE=true||oid:0x1000000000003|SAI_PORT_ATTR_ADMIN_STATE=false||oid:0x1000000000004|SAI_PORT_ATTR_ADMIN_STATE=true +2017-06-14.01:55:56.555975|c|SAI_OBJECT_TYPE_BUFFER_POOL:oid:0x1800000000038a|SAI_BUFFER_POOL_ATTR_THRESHOLD_MODE=SAI_BUFFER_POOL_THRESHOLD_MODE_DYNAMIC|SAI_BUFFER_POOL_ATTR_SIZE=47218432|SAI_BUFFER_POOL_ATTR_TYPE=SAI_BUFFER_POOL_TYPE_INGRESS|SAI_BUFFER_POOL_ATTR_XOFF_SIZE=17708800 +2017-06-14.01:55:56.555975|c|SAI_OBJECT_TYPE_BUFFER_PROFILE:oid:0x1900000000044a|SAI_BUFFER_PROFILE_ATTR_POOL_ID=oid:0x1800000000038a|SAI_BUFFER_PROFILE_ATTR_THRESHOLD_MODE=SAI_BUFFER_PROFILE_THRESHOLD_MODE_DYNAMIC|SAI_BUFFER_PROFILE_ATTR_RESERVED_BUFFER_SIZE=6755399441055744|SAI_BUFFER_PROFILE_ATTR_SHARED_DYNAMIC_TH=-8 +2017-06-14.01:55:56.555975|g|SAI_OBJECT_TYPE_PORT:oid:0x1000000000002|SAI_PORT_ATTR_INGRESS_PRIORITY_GROUP_LIST=8:oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0 +2017-06-14.01:55:56.555975|G|SAI_STATUS_SUCCESS|SAI_PORT_ATTR_INGRESS_PRIORITY_GROUP_LIST=8:oid:0x1a00000000018a,oid:0x1a00000000018b,oid:0x1a00000000018c,oid:0x1a00000000018d,oid:0x1a00000000018e,oid:0x1a00000000018f,oid:0x1a000000000190,oid:0x1a000000000191 +2017-06-14.01:55:56.555975|S|SAI_OBJECT_TYPE_INGRESS_PRIORITY_GROUP||oid:0x1a00000000018a|SAI_INGRESS_PRIORITY_GROUP_ATTR_BUFFER_PROFILE=oid:0x1900000000044a||oid:0x1a00000000018b|SAI_INGRESS_PRIORITY_GROUP_ATTR_BUFFER_PROFILE=oid:0x1900000000044a||oid:0x1a00000000018c|SAI_INGRESS_PRIORITY_GROUP_ATTR_BUFFER_PROFILE=oid:0x1900000000044a +2017-06-14.01:55:56.555975|g|SAI_OBJECT_TYPE_PORT:oid:0x1000000000002|SAI_PORT_ATTR_QOS_QUEUE_LIST=20:oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0 +2017-06-14.01:55:56.555975|G|SAI_STATUS_SUCCESS|SAI_PORT_ATTR_QOS_QUEUE_LIST=20:oid:0x15000000000582,oid:0x15000000000583,oid:0x15000000000584,oid:0x15000000000585,oid:0x15000000000586,oid:0x15000000000587,oid:0x15000000000588,oid:0x15000000000589,oid:0x1500000000058a,oid:0x1500000000058b,oid:0x1500000000058e,oid:0x1500000000058f,oid:0x15000000000590,oid:0x15000000000591,oid:0x15000000000592,oid:0x15000000000593,oid:0x15000000000594,oid:0x15000000000595,oid:0x15000000000596,oid:0x15000000000597 +2017-06-14.01:55:56.555975|S|SAI_OBJECT_TYPE_QUEUE||oid:0x15000000000582|SAI_QUEUE_ATTR_BUFFER_PROFILE_ID=oid:0x1900000000044a||oid:0x15000000000583|SAI_QUEUE_ATTR_BUFFER_PROFILE_ID=oid:0x1900000000044a||oid:0x15000000000584|SAI_QUEUE_ATTR_BUFFER_PROFILE_ID=oid:0x1900000000044a 2017-06-14.01:55:56.555975|C|SAI_OBJECT_TYPE_NEXT_HOP_GROUP||oid:0x5000000000005|SAI_NEXT_HOP_GROUP_ATTR_TYPE=SAI_NEXT_HOP_GROUP_TYPE_DYNAMIC_UNORDERED_ECMP||oid:0x5000000000006|SAI_NEXT_HOP_GROUP_ATTR_TYPE=SAI_NEXT_HOP_GROUP_TYPE_DYNAMIC_UNORDERED_ECMP||oid:0x5000000000007|SAI_NEXT_HOP_GROUP_ATTR_TYPE=SAI_NEXT_HOP_GROUP_TYPE_DYNAMIC_UNORDERED_ECMP 2017-06-14.01:55:56.555975|S|SAI_OBJECT_TYPE_NEXT_HOP_GROUP||oid:0x5000000000005|SAI_NEXT_HOP_GROUP_ATTR_SET_SWITCHOVER=true||oid:0x5000000000006|SAI_NEXT_HOP_GROUP_ATTR_SET_SWITCHOVER=true||oid:0x5000000000007|SAI_NEXT_HOP_GROUP_ATTR_SET_SWITCHOVER=true 2017-06-14.01:55:56.555975|R|SAI_OBJECT_TYPE_NEXT_HOP_GROUP||oid:0x5000000000005||oid:0x5000000000006||oid:0x5000000000007 From 9fe90f6bf9290138e776d8b19582c01d81849d84 Mon Sep 17 00:00:00 2001 From: krismarvell <108510436+krismarvell@users.noreply.github.com> Date: Tue, 17 Dec 2024 01:19:00 +0530 Subject: [PATCH 7/7] syncd init: rename marvell to marvell-prestera (#1465) --- syncd/scripts/syncd_init_common.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/syncd/scripts/syncd_init_common.sh b/syncd/scripts/syncd_init_common.sh index cb72ab834..2b96f6219 100644 --- a/syncd/scripts/syncd_init_common.sh +++ b/syncd/scripts/syncd_init_common.sh @@ -399,7 +399,7 @@ config_syncd_cavium() done } -config_syncd_marvell() +config_syncd_marvell_prestera() { CMD_ARGS+=" -p $HWSKU_DIR/sai.profile" @@ -599,8 +599,8 @@ config_syncd() config_syncd_cavium elif [ "$SONIC_ASIC_TYPE" == "centec" ]; then config_syncd_centec - elif [ "$SONIC_ASIC_TYPE" == "marvell" ]; then - config_syncd_marvell + elif [ "$SONIC_ASIC_TYPE" == "marvell-prestera" ]; then + config_syncd_marvell_prestera elif [ "$SONIC_ASIC_TYPE" == "barefoot" ]; then config_syncd_barefoot elif [ "$SONIC_ASIC_TYPE" == "nephos" ]; then