Skip to content

Commit

Permalink
Merge branch 'master' into SAI_DBG_GEN_DUMP_support
Browse files Browse the repository at this point in the history
  • Loading branch information
aviramd authored Sep 26, 2024
2 parents 9559b20 + 9b9d330 commit c6d45a0
Show file tree
Hide file tree
Showing 16 changed files with 289 additions and 115 deletions.
2 changes: 1 addition & 1 deletion .azure-pipelines/test-docker-sonic-vs-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ jobs:
params='--graceful-stop'
fi
all_tests=$(ls test_*.py)
all_tests="${all_tests} p4rt"
all_tests="${all_tests} p4rt dash"
RETRY=3
IMAGE_NAME=docker-sonic-vs:$(Build.DefinitionName).$(Build.BuildNumber).asan-${{ parameters.asan }}
echo $all_tests | xargs -n 1 | xargs -P 8 -I TEST_MODULE sudo ./run-tests.sh "$IMAGE_NAME" "$params" "TEST_MODULE" "$RETRY"
Expand Down
4 changes: 2 additions & 2 deletions meta/MetaKeyHasher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ static bool operator==(
{
// SWSS_LOG_ENTER(); // disabled for performance reasons

return a.switch_id == b.switch_id && a.eni_id == b.eni_id && a.destination == b.destination;
return a.switch_id == b.switch_id && a.destination == b.destination && a.outbound_routing_group_id == b.outbound_routing_group_id;
}

static bool operator==(
Expand Down Expand Up @@ -673,8 +673,8 @@ static inline std::size_t sai_get_hash(
// SWSS_LOG_ENTER(); // disabled for performance reasons

std::size_t hash = 0;
boost::hash_combine(hash, oe.eni_id);
boost::hash_combine(hash, sai_get_hash(oe.destination));
boost::hash_combine(hash, oe.outbound_routing_group_id);

return hash;
}
Expand Down
12 changes: 10 additions & 2 deletions meta/SaiSerialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1041,6 +1041,14 @@ std::string sai_serialize_buffer_pool_stat(
return sai_serialize_enum(counter, &sai_metadata_enum_sai_buffer_pool_stat_t);
}

std::string sai_serialize_eni_stat(
_In_ const sai_eni_stat_t counter)
{
SWSS_LOG_ENTER();

return sai_serialize_enum(counter, &sai_metadata_enum_sai_eni_stat_t);
}

std::string sai_serialize_tunnel_stat(
_In_ const sai_tunnel_stat_t counter)
{
Expand Down Expand Up @@ -1822,8 +1830,8 @@ std::string sai_serialize_outbound_routing_entry(
json j;

j["switch_id"] = sai_serialize_object_id(outbound_routing_entry.switch_id);
j["eni_id"] = sai_serialize_object_id(outbound_routing_entry.eni_id);
j["destination"] = sai_serialize_ip_prefix(outbound_routing_entry.destination);
j["outbound_routing_group_id"] = sai_serialize_object_id(outbound_routing_entry.outbound_routing_group_id);

return j.dump();
}
Expand Down Expand Up @@ -4703,8 +4711,8 @@ void sai_deserialize_outbound_routing_entry(
json j = json::parse(s);

sai_deserialize_object_id(j["switch_id"], outbound_routing_entry.switch_id);
sai_deserialize_object_id(j["eni_id"], outbound_routing_entry.eni_id);
sai_deserialize_ip_prefix(j["destination"], outbound_routing_entry.destination);
sai_deserialize_object_id(j["outbound_routing_group_id"], outbound_routing_entry.outbound_routing_group_id);
}

void sai_deserialize_outbound_ca_to_pa_entry(
Expand Down
3 changes: 3 additions & 0 deletions meta/sai_serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ std::string sai_serialize_ingress_priority_group_attr(
std::string sai_serialize_buffer_pool_stat(
_In_ const sai_buffer_pool_stat_t counter);

std::string sai_serialize_eni_stat(
_In_ const sai_eni_stat_t counter);

std::string sai_serialize_tunnel_stat(
_In_ const sai_tunnel_stat_t counter);

Expand Down
8 changes: 4 additions & 4 deletions saiplayer/SaiPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ sai_status_t SaiPlayer::handle_dash_outbound_routing(
sai_deserialize_outbound_routing_entry(str_object_id, entry);

entry.switch_id = translate_local_to_redis(entry.switch_id);
entry.eni_id = translate_local_to_redis(entry.eni_id);
entry.outbound_routing_group_id = translate_local_to_redis(entry.outbound_routing_group_id);

switch (api)
{
Expand Down Expand Up @@ -1796,7 +1796,7 @@ sai_status_t SaiPlayer::handle_bulk_entry(
sai_deserialize_outbound_routing_entry(object_ids[it], entries[it]);

entries[it].switch_id = translate_local_to_redis(entries[it].switch_id);
entries[it].eni_id = translate_local_to_redis(entries[it].eni_id);
entries[it].outbound_routing_group_id = translate_local_to_redis(entries[it].outbound_routing_group_id);
}

CALL_BULK_CREATE_API_WITH_TIMER("outbound_routing_entry");
Expand Down Expand Up @@ -1991,7 +1991,7 @@ sai_status_t SaiPlayer::handle_bulk_entry(
sai_deserialize_outbound_routing_entry(object_ids[it], entries[it]);

entries[it].switch_id = translate_local_to_redis(entries[it].switch_id);
entries[it].eni_id = translate_local_to_redis(entries[it].eni_id);
entries[it].outbound_routing_group_id = translate_local_to_redis(entries[it].outbound_routing_group_id);
}

CALL_BULK_REMOVE_API_WITH_TIMER("outbound_routing_entry");
Expand Down Expand Up @@ -2193,7 +2193,7 @@ sai_status_t SaiPlayer::handle_bulk_entry(
sai_deserialize_outbound_routing_entry(object_ids[it], entries[it]);

entries[it].switch_id = translate_local_to_redis(entries[it].switch_id);
entries[it].eni_id = translate_local_to_redis(entries[it].eni_id);
entries[it].outbound_routing_group_id = translate_local_to_redis(entries[it].outbound_routing_group_id);
}

CALL_BULK_SET_API_WITH_TIMER("outbound_routing_entry");
Expand Down
39 changes: 39 additions & 0 deletions syncd/FlexCounter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ static const std::string COUNTER_TYPE_MACSEC_SA = "MACSEC SA Counter";
static const std::string COUNTER_TYPE_FLOW = "Flow Counter";
static const std::string COUNTER_TYPE_TUNNEL = "Tunnel Counter";
static const std::string COUNTER_TYPE_BUFFER_POOL = "Buffer Pool Counter";
static const std::string COUNTER_TYPE_ENI = "DASH ENI Counter";
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";
Expand Down Expand Up @@ -219,6 +220,14 @@ std::string serializeStat(
return sai_serialize_buffer_pool_stat(stat);
}

template <>
std::string serializeStat(
_In_ const sai_eni_stat_t stat)
{
SWSS_LOG_ENTER();
return sai_serialize_eni_stat(stat);
}

template <typename StatType>
void deserializeStat(
_In_ const char* name,
Expand Down Expand Up @@ -318,6 +327,15 @@ void deserializeStat(
sai_deserialize_buffer_pool_stat(name, stat);
}

template <>
void deserializeStat(
_In_ const char* name,
_Out_ sai_eni_stat_t *stat)
{
SWSS_LOG_ENTER();
sai_deserialize_eni_stat(name, stat);
}

template <typename AttrType>
void deserializeAttr(
_In_ const std::string& name,
Expand Down Expand Up @@ -1297,6 +1315,12 @@ std::shared_ptr<BaseCounterContext> FlexCounter::createCounterContext(
context->always_check_supported_counters = true;
return context;
}
else if (context_name == COUNTER_TYPE_ENI)
{
auto context = std::make_shared<CounterContext<sai_eni_stat_t>>(context_name, (sai_object_type_t)SAI_OBJECT_TYPE_ENI, m_vendorSai.get(), m_statsMode);
context->always_check_supported_counters = true;
return context;
}
else if (context_name == ATTR_TYPE_QUEUE)
{
return std::make_shared<AttrContext<sai_queue_attr_t>>(context_name, SAI_OBJECT_TYPE_QUEUE, m_vendorSai.get(), m_statsMode);
Expand Down Expand Up @@ -1572,6 +1596,13 @@ void FlexCounter::removeCounter(
getCounterContext(COUNTER_TYPE_TUNNEL)->removeObject(vid);
}
}
else if (objectType == (sai_object_type_t)SAI_OBJECT_TYPE_ENI)
{
if (hasCounterContext(COUNTER_TYPE_ENI))
{
getCounterContext(COUNTER_TYPE_ENI)->removeObject(vid);
}
}
else if (objectType == SAI_OBJECT_TYPE_COUNTER)
{
if (hasCounterContext(COUNTER_TYPE_FLOW))
Expand Down Expand Up @@ -1730,6 +1761,14 @@ void FlexCounter::addCounter(
idStrings,
"");
}
else if (objectType == (sai_object_type_t)SAI_OBJECT_TYPE_ENI && field == ENI_COUNTER_ID_LIST)
{
getCounterContext(COUNTER_TYPE_ENI)->addObject(
vid,
rid,
idStrings,
"");
}
else
{
SWSS_LOG_ERROR("Object type and field combination is not supported, object type %s, field %s",
Expand Down
1 change: 1 addition & 0 deletions syncd/SwitchNotifications.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ namespace syncd
.on_switch_asic_sdk_health_event = &Slot<context>::onSwitchAsicSdkHealthEvent,
.on_port_host_tx_ready = &Slot<context>::onPortHostTxReady,
.on_twamp_session_event = &Slot<context>::onTwampSessionEvent,
.on_icmp_echo_session_state_change = nullptr,
.on_ha_set_event = nullptr,
.on_ha_scope_event = nullptr,
}) { }
Expand Down
4 changes: 2 additions & 2 deletions syncd/Syncd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1269,7 +1269,7 @@ sai_status_t Syncd::processBulkCreateEntry(
sai_deserialize_outbound_routing_entry(objectIds[it], entries[it]);

entries[it].switch_id = m_translator->translateVidToRid(entries[it].switch_id);
entries[it].eni_id = m_translator->translateVidToRid(entries[it].eni_id);
entries[it].outbound_routing_group_id = m_translator->translateVidToRid(entries[it].outbound_routing_group_id);
}

status = m_vendorSai->bulkCreate(
Expand Down Expand Up @@ -1555,7 +1555,7 @@ sai_status_t Syncd::processBulkRemoveEntry(
sai_deserialize_outbound_routing_entry(objectIds[it], entries[it]);

entries[it].switch_id = m_translator->translateVidToRid(entries[it].switch_id);
entries[it].eni_id = m_translator->translateVidToRid(entries[it].eni_id);
entries[it].outbound_routing_group_id = m_translator->translateVidToRid(entries[it].outbound_routing_group_id);
}

status = m_vendorSai->bulkRemove(
Expand Down
40 changes: 31 additions & 9 deletions syncd/tests/TestSyncdNvdaBf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,28 @@ void SyncdNvdaBfTest::RemoveEni(sai_object_id_t eni)
EXPECT_EQ(SAI_STATUS_SUCCESS, m_sairedis->remove((sai_object_type_t)SAI_OBJECT_TYPE_ENI, eni));
}

sai_object_id_t SyncdNvdaBfTest::CreateOutboundRoutingGroup(bool disabled)
{
SWSS_LOG_ENTER();

sai_object_id_t oid;
sai_attribute_t attr;

attr.id = SAI_OUTBOUND_ROUTING_GROUP_ATTR_DISABLED;
attr.value.booldata = disabled;

EXPECT_EQ(SAI_STATUS_SUCCESS, m_sairedis->create((sai_object_type_t)SAI_OBJECT_TYPE_OUTBOUND_ROUTING_GROUP, &oid, m_switchId, 1, &attr));

return oid;
}

void SyncdNvdaBfTest::RemoveOutboundRoutingGroup(sai_object_id_t outbound_routing_group)
{
SWSS_LOG_ENTER();

EXPECT_EQ(SAI_STATUS_SUCCESS, m_sairedis->remove((sai_object_type_t)SAI_OBJECT_TYPE_OUTBOUND_ROUTING_GROUP, outbound_routing_group));
}

TEST_F(SyncdNvdaBfTest, dashDirectionLookup)
{
sai_attribute_t attr;
Expand Down Expand Up @@ -1100,15 +1122,15 @@ TEST_F(SyncdNvdaBfTest, dashOutboundRoutingEntry)

sai_object_id_t counter = CreateCounter();
sai_object_id_t vnet = CreateVnet(101);
sai_object_id_t eni = CreateEni(vnet);
sai_object_id_t outbound_routing_group = CreateOutboundRoutingGroup(false);

sai_ip_address_t oip6;
oip6.addr_family = SAI_IP_ADDR_FAMILY_IPV6;
inet_pton(AF_INET6, "ffff::", &oip6.addr);

sai_outbound_routing_entry_t entry0;
entry0.switch_id = m_switchId;
entry0.eni_id = eni;
entry0.outbound_routing_group_id = outbound_routing_group;
entry0.destination.addr_family = SAI_IP_ADDR_FAMILY_IPV4;
inet_pton(AF_INET, "192.168.1.0", &entry0.destination.addr.ip4);
inet_pton(AF_INET, "255.255.255.0", &entry0.destination.mask.ip4);
Expand Down Expand Up @@ -1140,7 +1162,7 @@ TEST_F(SyncdNvdaBfTest, dashOutboundRoutingEntry)

EXPECT_EQ(SAI_STATUS_SUCCESS, m_sairedis->remove(&entry0));

RemoveEni(eni);
RemoveOutboundRoutingGroup(outbound_routing_group);
RemoveVnet(vnet);
RemoveCounter(counter);
}
Expand All @@ -1161,8 +1183,8 @@ TEST_F(SyncdNvdaBfTest, dashOutboundRoutingEntryBulk)

sai_object_id_t vnet0 = CreateVnet(101);
sai_object_id_t vnet1 = CreateVnet(102);
sai_object_id_t eni0 = CreateEni(vnet0);
sai_object_id_t eni1 = CreateEni(vnet1);
sai_object_id_t outbound_routing_group0 = CreateOutboundRoutingGroup(false);
sai_object_id_t outbound_routing_group1 = CreateOutboundRoutingGroup(false);

sai_ip_prefix_t dst0 = {};
sai_ip_prefix_t dst1 = {};
Expand Down Expand Up @@ -1196,8 +1218,8 @@ TEST_F(SyncdNvdaBfTest, dashOutboundRoutingEntryBulk)
sai_status_t statuses[entries_count] = {};

sai_outbound_routing_entry_t entries[entries_count] = {
{ .switch_id = m_switchId, .eni_id = eni0, .destination = dst0},
{ .switch_id = m_switchId, .eni_id = eni1, .destination = dst1},
{ .switch_id = m_switchId, .destination = dst0, .outbound_routing_group_id = outbound_routing_group0},
{ .switch_id = m_switchId, .destination = dst1, .outbound_routing_group_id = outbound_routing_group1},
};

EXPECT_EQ(SAI_STATUS_SUCCESS, m_sairedis->bulkCreate(entries_count, entries, attr_count, attr_list, SAI_BULK_OP_ERROR_MODE_STOP_ON_ERROR, statuses));
Expand All @@ -1210,8 +1232,8 @@ TEST_F(SyncdNvdaBfTest, dashOutboundRoutingEntryBulk)
EXPECT_EQ(SAI_STATUS_SUCCESS, statuses[i]);
}

RemoveEni(eni0);
RemoveEni(eni1);
RemoveOutboundRoutingGroup(outbound_routing_group0);
RemoveOutboundRoutingGroup(outbound_routing_group1);
RemoveVnet(vnet0);
RemoveVnet(vnet1);
RemoveCounter(counter0);
Expand Down
3 changes: 3 additions & 0 deletions syncd/tests/TestSyncdNvdaBf.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ class SyncdNvdaBfTest : public ::testing::Test
sai_object_id_t CreateEni(sai_object_id_t vnet);
void RemoveEni(sai_object_id_t eni);

sai_object_id_t CreateOutboundRoutingGroup(bool disabled);
void RemoveOutboundRoutingGroup(sai_object_id_t outbound_routing_group);

protected:
std::shared_ptr<std::thread> m_worker;
std::shared_ptr<sairedis::Sai> m_sairedis;
Expand Down
Loading

0 comments on commit c6d45a0

Please sign in to comment.