Skip to content

Commit

Permalink
Merge branch 'master' into common_config_improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
geans-pin authored Nov 8, 2024
2 parents b7f8d5c + c4aea50 commit 2b7aa8d
Show file tree
Hide file tree
Showing 16 changed files with 121 additions and 53 deletions.
2 changes: 1 addition & 1 deletion .azure-pipelines/build-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ jobs:
gcov_dirs=$(find . -path "*.libs*gcda" | xargs dirname | sort -u | cut -c"3-")
for dir in ${gcov_dirs}; do
source_dir=$(dirname $dir)
output_file="coverage-$source_dir.json"
output_file=$(echo "coverage-$source_dir.json"| tr '/' '-')
gcovr --exclude-unreachable-branches --json-pretty -o $output_file --object-directory $source_dir $dir
done
gcovr -r ./ -e ".*/SAI/.*" -e ".+/json.hpp" -e "swss/.+" -e ".*/.libs/.*" -e ".*/debian/.*" --exclude-unreachable-branches --json-pretty -o coverage-all.json
Expand Down
7 changes: 7 additions & 0 deletions debian/libsaimetadata-dev.install
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
meta/sai*.h usr/include/sai
meta/Sai*.h usr/include/sai
meta/Meta.h usr/include/sai
meta/AttrKeyMap.h usr/include/sai
meta/MetaKeyHasher.h usr/include/sai
meta/OidRefCounter.h usr/include/sai
meta/PortRelatedSet.h usr/include/sai
meta/Notification*.h usr/include/sai
meta/Globals.h usr/include/sai
SAI/meta/sai*.h usr/include/sai
usr/lib/*/libsaimetadata.so
usr/lib/*/libsaimeta.so
4 changes: 4 additions & 0 deletions pyext/pysairedis.i
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
%include "cpointer.i"
%include "carrays.i"

// These objects cause issues on Buster because of the function pointers
%ignore _sai_struct_member_info_t;
%ignore _sai_object_type_info_t;

%{
#pragma GCC optimize("no-var-tracking-assignments")

Expand Down
1 change: 1 addition & 0 deletions syncd/CommandLineOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ std::string CommandLineOptions::getCommandLineString() const
ss << " ContextConfig=" << m_contextConfig;
ss << " BreakConfig=" << m_breakConfig;
ss << " WatchdogWarnTimeSpan=" << m_watchdogWarnTimeSpan;
ss << " SupportingBulkCounters=" << m_supportingBulkCounterGroups;

#ifdef SAITHRIFT

Expand Down
2 changes: 2 additions & 0 deletions syncd/CommandLineOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,7 @@ namespace syncd
std::string m_portMapFile;
#endif // SAITHRIFT

std::string m_supportingBulkCounterGroups;

};
}
15 changes: 11 additions & 4 deletions syncd/CommandLineOptionsParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ std::shared_ptr<CommandLineOptions> CommandLineOptionsParser::parseCommandLine(
auto options = std::make_shared<CommandLineOptions>();

#ifdef SAITHRIFT
const char* const optstring = "dp:t:g:x:b:w: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:w:uSUCsz:lh";
const char* const optstring = "dp:t:g:x:b:B:w:uSUCsz:lh";
#endif // SAITHRIFT

while (true)
Expand All @@ -42,6 +42,7 @@ std::shared_ptr<CommandLineOptions> CommandLineOptionsParser::parseCommandLine(
{ "contextContig", required_argument, 0, 'x' },
{ "breakConfig", required_argument, 0, 'b' },
{ "watchdogWarnTimeSpan", optional_argument, 0, 'w' },
{ "supportingBulkCounters", required_argument, 0, 'B' },
#ifdef SAITHRIFT
{ "rpcserver", no_argument, 0, 'r' },
{ "portmap", required_argument, 0, 'm' },
Expand Down Expand Up @@ -133,6 +134,10 @@ std::shared_ptr<CommandLineOptions> CommandLineOptionsParser::parseCommandLine(
break;
#endif // SAITHRIFT

case 'B':
options->m_supportingBulkCounterGroups = std::string(optarg);
break;

case 'h':
printUsage();
exit(EXIT_SUCCESS);
Expand All @@ -156,9 +161,9 @@ void CommandLineOptionsParser::printUsage()
SWSS_LOG_ENTER();

#ifdef SAITHRIFT
std::cout << "Usage: syncd [-d] [-p profile] [-t type] [-u] [-S] [-U] [-C] [-s] [-z mode] [-l] [-g idx] [-x contextConfig] [-b breakConfig] [-r] [-m portmap] [-h]" << std::endl;
std::cout << "Usage: syncd [-d] [-p profile] [-t type] [-u] [-S] [-U] [-C] [-s] [-z mode] [-l] [-g idx] [-x contextConfig] [-b breakConfig] [-B supportingBulkCounters] [-r] [-m portmap] [-h]" << std::endl;
#else
std::cout << "Usage: syncd [-d] [-p profile] [-t type] [-u] [-S] [-U] [-C] [-s] [-z mode] [-l] [-g idx] [-x contextConfig] [-b breakConfig] [-h]" << std::endl;
std::cout << "Usage: syncd [-d] [-p profile] [-t type] [-u] [-S] [-U] [-C] [-s] [-z mode] [-l] [-g idx] [-x contextConfig] [-b breakConfig] [-B supportingBulkCounters] [-h]" << std::endl;
#endif // SAITHRIFT

std::cout << " -d --diag" << std::endl;
Expand Down Expand Up @@ -189,6 +194,8 @@ void CommandLineOptionsParser::printUsage()
std::cout << " Comparison logic 'break before make' configuration file" << std::endl;
std::cout << " -w --watchdogWarnTimeSpan" << std::endl;
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;

#ifdef SAITHRIFT

Expand Down
69 changes: 37 additions & 32 deletions syncd/FlexCounter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ static const std::string ATTR_TYPE_QUEUE = "Queue Attribute";
static const std::string ATTR_TYPE_PG = "Priority Group Attribute";
static const std::string ATTR_TYPE_MACSEC_SA = "MACSEC SA Attribute";
static const std::string ATTR_TYPE_ACL_COUNTER = "ACL Counter Attribute";
const std::map<std::string, std::string> FlexCounter::m_plugIn2CounterType = {
{QUEUE_PLUGIN_FIELD, COUNTER_TYPE_QUEUE},
{PG_PLUGIN_FIELD, COUNTER_TYPE_PG},
{PORT_PLUGIN_FIELD, COUNTER_TYPE_PORT},
{RIF_PLUGIN_FIELD, COUNTER_TYPE_RIF},
{BUFFER_POOL_PLUGIN_FIELD, COUNTER_TYPE_BUFFER_POOL},
{TUNNEL_PLUGIN_FIELD, COUNTER_TYPE_TUNNEL},
{FLOW_COUNTER_PLUGIN_FIELD, COUNTER_TYPE_FLOW}};

BaseCounterContext::BaseCounterContext(const std::string &name):
m_name(name)
Expand All @@ -57,6 +65,13 @@ void BaseCounterContext::addPlugins(
}
}

void BaseCounterContext::setNoDoubleCheckBulkCapability(
_In_ bool noDoubleCheckBulkCapability)
{
SWSS_LOG_ENTER();
no_double_check_bulk_capability = noDoubleCheckBulkCapability;
}

template <typename StatType,
typename Enable = void>
struct CounterIds
Expand Down Expand Up @@ -478,7 +493,7 @@ class CounterContext : public BaseCounterContext
}
else
{
supportBulk = checkBulkCapability(vid, rid, supportedIds);
supportBulk = no_double_check_bulk_capability || checkBulkCapability(vid, rid, supportedIds);
}

if (!supportBulk)
Expand Down Expand Up @@ -1020,12 +1035,14 @@ class AttrContext : public CounterContext<AttrType>
FlexCounter::FlexCounter(
_In_ const std::string& instanceId,
_In_ std::shared_ptr<sairedis::SaiInterface> vendorSai,
_In_ const std::string& dbCounters):
_In_ const std::string& dbCounters,
_In_ const bool noDoubleCheckBulkCapability):
m_readyToPoll(false),
m_pollInterval(0),
m_instanceId(instanceId),
m_vendorSai(vendorSai),
m_dbCounters(dbCounters)
m_dbCounters(dbCounters),
m_noDoubleCheckBulkCapability(noDoubleCheckBulkCapability)
{
SWSS_LOG_ENTER();

Expand Down Expand Up @@ -1153,37 +1170,25 @@ void FlexCounter::addCounterPlugin(
{
setStatsMode(value);
}
else if (field == QUEUE_PLUGIN_FIELD)
{
getCounterContext(COUNTER_TYPE_QUEUE)->addPlugins(shaStrings);
}
else if (field == PG_PLUGIN_FIELD)
{
getCounterContext(COUNTER_TYPE_PG)->addPlugins(shaStrings);
}
else if (field == PORT_PLUGIN_FIELD)
{
getCounterContext(COUNTER_TYPE_PORT)->addPlugins(shaStrings);
}
else if (field == RIF_PLUGIN_FIELD)
{
getCounterContext(COUNTER_TYPE_RIF)->addPlugins(shaStrings);
}
else if (field == BUFFER_POOL_PLUGIN_FIELD)
{
getCounterContext(COUNTER_TYPE_BUFFER_POOL)->addPlugins(shaStrings);
}
else if (field == TUNNEL_PLUGIN_FIELD)
{
getCounterContext(COUNTER_TYPE_TUNNEL)->addPlugins(shaStrings);
}
else if (field == FLOW_COUNTER_PLUGIN_FIELD)
{
getCounterContext(COUNTER_TYPE_FLOW)->addPlugins(shaStrings);
}
else
{
SWSS_LOG_ERROR("Field is not supported %s", field.c_str());
auto counterTypeRef = m_plugIn2CounterType.find(field);

if (counterTypeRef != m_plugIn2CounterType.end())
{
getCounterContext(counterTypeRef->second)->addPlugins(shaStrings);

if (m_noDoubleCheckBulkCapability)
{
getCounterContext(counterTypeRef->second)->setNoDoubleCheckBulkCapability(true);

SWSS_LOG_NOTICE("Do not double check bulk capability counter context %s %s", m_instanceId.c_str(), counterTypeRef->second.c_str());
}
}
else
{
SWSS_LOG_ERROR("Field is not supported %s", field.c_str());
}
}
}

Expand Down
11 changes: 10 additions & 1 deletion syncd/FlexCounter.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ namespace syncd
void addPlugins(
_In_ const std::vector<std::string>& shaStrings);

void setNoDoubleCheckBulkCapability(
_In_ bool);

bool hasPlugin() const {return !m_plugins.empty();}

void removePlugins() {m_plugins.clear();}
Expand Down Expand Up @@ -55,6 +58,7 @@ namespace syncd
bool use_sai_stats_capa_query = true;
bool use_sai_stats_ext = false;
bool double_confirm_supported_counters = false;
bool no_double_check_bulk_capability = false;
};
class FlexCounter
{
Expand All @@ -65,7 +69,8 @@ namespace syncd
FlexCounter(
_In_ const std::string& instanceId,
_In_ std::shared_ptr<sairedis::SaiInterface> vendorSai,
_In_ const std::string& dbCounters);
_In_ const std::string& dbCounters,
_In_ const bool noDoubleCheckBulkCapability=false);

virtual ~FlexCounter();

Expand Down Expand Up @@ -168,5 +173,9 @@ namespace syncd
bool m_isDiscarded;

std::map<std::string, std::shared_ptr<BaseCounterContext>> m_counterContext;

bool m_noDoubleCheckBulkCapability;

static const std::map<std::string, std::string> m_plugIn2CounterType;
};
}
9 changes: 6 additions & 3 deletions syncd/FlexCounterManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ using namespace syncd;

FlexCounterManager::FlexCounterManager(
_In_ std::shared_ptr<sairedis::SaiInterface> vendorSai,
_In_ const std::string& dbCounters):
_In_ const std::string& dbCounters,
_In_ const std::string& supportingBulkInstances):
m_vendorSai(vendorSai),
m_dbCounters(dbCounters)
m_dbCounters(dbCounters),
m_supportingBulkGroups(supportingBulkInstances)
{
SWSS_LOG_ENTER();

Expand All @@ -26,7 +28,8 @@ std::shared_ptr<FlexCounter> FlexCounterManager::getInstance(

if (m_flexCounters.count(instanceId) == 0)
{
auto counter = std::make_shared<FlexCounter>(instanceId, m_vendorSai, m_dbCounters);
bool supportingBulk = (m_supportingBulkGroups.find(instanceId) != std::string::npos);
auto counter = std::make_shared<FlexCounter>(instanceId, m_vendorSai, m_dbCounters, supportingBulk);

m_flexCounters[instanceId] = counter;
}
Expand Down
5 changes: 4 additions & 1 deletion syncd/FlexCounterManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ namespace syncd

FlexCounterManager(
_In_ std::shared_ptr<sairedis::SaiInterface> vendorSai,
_In_ const std::string& dbCounters);
_In_ const std::string& dbCounters,
_In_ const std::string& supportingBulkInstances);

virtual ~FlexCounterManager() = default;

Expand Down Expand Up @@ -50,6 +51,8 @@ namespace syncd
std::shared_ptr<sairedis::SaiInterface> m_vendorSai;

std::string m_dbCounters;

std::string m_supportingBulkGroups;
};
}

2 changes: 1 addition & 1 deletion syncd/Syncd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ Syncd::Syncd(
m_enableSyncMode = true;
}

m_manager = std::make_shared<FlexCounterManager>(m_vendorSai, m_contextConfig->m_dbCounters);
m_manager = std::make_shared<FlexCounterManager>(m_vendorSai, m_contextConfig->m_dbCounters, m_commandLineOptions->m_supportingBulkCounterGroups);

loadProfileMap();

Expand Down
5 changes: 0 additions & 5 deletions syncd/VendorSai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,6 @@ sai_status_t VendorSai::getStats(
_In_ const sai_stat_id_t *counter_ids,
_Out_ uint64_t *counters)
{
MUTEX();
SWSS_LOG_ENTER();
VENDOR_CHECK_API_INITIALIZED();

Expand Down Expand Up @@ -351,7 +350,6 @@ sai_status_t VendorSai::getStatsExt(
_In_ sai_stats_mode_t mode,
_Out_ uint64_t *counters)
{
MUTEX();
SWSS_LOG_ENTER();
VENDOR_CHECK_API_INITIALIZED();

Expand All @@ -366,7 +364,6 @@ sai_status_t VendorSai::clearStats(
_In_ uint32_t number_of_counters,
_In_ const sai_stat_id_t *counter_ids)
{
MUTEX();
SWSS_LOG_ENTER();
VENDOR_CHECK_API_INITIALIZED();

Expand All @@ -386,7 +383,6 @@ sai_status_t VendorSai::bulkGetStats(
_Inout_ sai_status_t *object_statuses,
_Out_ uint64_t *counters)
{
MUTEX();
SWSS_LOG_ENTER();
VENDOR_CHECK_API_INITIALIZED();

Expand Down Expand Up @@ -414,7 +410,6 @@ sai_status_t VendorSai::bulkClearStats(
_In_ sai_stats_mode_t mode,
_Inout_ sai_status_t *object_statuses)
{
MUTEX();
SWSS_LOG_ENTER();
VENDOR_CHECK_API_INITIALIZED();

Expand Down
25 changes: 25 additions & 0 deletions syncd/scripts/syncd_init_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ if [ "$SYNC_MODE" == "enable" ]; then
CMD_ARGS+=" -s"
fi

SUPPORTING_BULK_COUNTER_GROUPS=$(echo $SYNCD_VARS | jq -r '.supporting_bulk_counter_groups')
if [ "$SUPPORTING_BULK_COUNTER_GROUPS" != "" ]; then
CMD_ARGS+=" -B $SUPPORTING_BULK_COUNTER_GROUPS"
fi

case "$(cat /proc/cmdline)" in
*SONIC_BOOT_TYPE=fastfast*)
if [ -e /var/warmboot/warm-starting ]; then
Expand Down Expand Up @@ -451,6 +456,24 @@ config_syncd_vs()
CMD_ARGS+=" -l -p $HWSKU_DIR/sai.profile"
}

vpp_api_check()
{
VPP_API_SOCK=$1
while true
do
[ -S "$VPP_API_SOCK" ] && vpp_api_test socket-name $VPP_API_SOCK <<< "show_version" 2>/dev/null | grep "version:" && break
sleep 1
done
}

config_syncd_vpp()
{
CMD_ARGS+=" -p $HWSKU_DIR/sai.profile"
vpp_api_check "/run/vpp/api.sock"
source /etc/sonic/vpp/syncd_vpp_env
export NO_LINUX_NL
}

config_syncd_soda()
{
# Add support for SAI bulk operations
Expand Down Expand Up @@ -585,6 +608,8 @@ config_syncd()
config_syncd_nephos
elif [ "$SONIC_ASIC_TYPE" == "vs" ]; then
config_syncd_vs
elif [ "$SONIC_ASIC_TYPE" == "vpp" ]; then
config_syncd_vpp
elif [ "$SONIC_ASIC_TYPE" == "innovium" ]; then
config_syncd_innovium
elif [ "$SONIC_ASIC_TYPE" == "soda" ]; then
Expand Down
Loading

0 comments on commit 2b7aa8d

Please sign in to comment.