Skip to content

Commit

Permalink
Add pre match logic for lag member (#1008)
Browse files Browse the repository at this point in the history
  • Loading branch information
kcudnik authored Feb 25, 2022
1 parent b9337dc commit 418d5fb
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 1 deletion.
2 changes: 1 addition & 1 deletion syncd/BestCandidateFinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ std::shared_ptr<SaiObj> BestCandidateFinder::findCurrentBestMatchForLag(

if (lagMemberLagAttr->getSaiAttr()->value.oid == tmpLagVid)
{
SWSS_LOG_NOTICE("found temp LAG member %s which uses temp LAG %s",
SWSS_LOG_NOTICE("found temp LAG member %s which uses temp LAG member %s",
temporaryObj->m_str_object_id.c_str(),
lagMember->m_str_object_id.c_str());

Expand Down
70 changes: 70 additions & 0 deletions syncd/ComparisonLogic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2754,6 +2754,54 @@ void ComparisonLogic::createPreMatchMapForObject(
}
}

void ComparisonLogic::cretePreMatchForLagMembers(
_In_ const AsicView& cur,
_Inout_ AsicView& tmp,
_Inout_ std::set<std::string>& processed)
{
SWSS_LOG_ENTER();

// match lag members that have the same port and use that lag members
// as createPreMatchMapForObject so it will create pre match entry for LAG
// and then for acl table group

auto cLagMembers = cur.getObjectsByObjectType(SAI_OBJECT_TYPE_LAG_MEMBER);
auto tLagMembers = tmp.getObjectsByObjectType(SAI_OBJECT_TYPE_LAG_MEMBER);

for (auto& cLagMember: cLagMembers)
{
if (processed.find(cLagMember->m_str_object_id) != processed.end())
continue;

for (auto& tLagMember: tLagMembers)
{
if (processed.find(tLagMember->m_str_object_id) != processed.end())
continue;

auto cPort = cLagMember->getSaiAttr(SAI_LAG_MEMBER_ATTR_PORT_ID);
auto tPort = tLagMember->getSaiAttr(SAI_LAG_MEMBER_ATTR_PORT_ID);

if (cPort->getOid() != tPort->getOid())
{
continue;
}

// at this point current and temporary lag member share the same
// port VID, then we can assume that those objects are the same

SWSS_LOG_INFO("pre match Lag Member: cur: %s, tmp: %s",
cLagMember->m_str_object_id.c_str(),
tLagMember->m_str_object_id.c_str());

tmp.m_preMatchMap[tLagMember->getVid()] = cLagMember->getVid();

createPreMatchMapForObject(cur, tmp, cLagMember, tLagMember, processed);

break;
}
}
}

void ComparisonLogic::createPreMatchMap(
_In_ const AsicView& cur,
_Inout_ AsicView& tmp)
Expand Down Expand Up @@ -2824,6 +2872,8 @@ void ComparisonLogic::createPreMatchMap(
createPreMatchMapForObject(cur, tmp, cObj, tObj, processed);
}

cretePreMatchForLagMembers(cur, tmp, processed);

size_t count = 0;

for (auto& ok: tmp.m_soOids)
Expand Down Expand Up @@ -2947,6 +2997,26 @@ void ComparisonLogic::applyViewTransition(
* XXX this is workaround. FIXME
*/

for (auto &obj: temp.m_soAll)
{
// TODO make generic list of root objects (or meta SAI for this)

if (obj.second->getObjectType() == SAI_OBJECT_TYPE_ACL_TABLE_GROUP)
{
if (temp.m_preMatchMap.find(obj.second->getVid()) == temp.m_preMatchMap.end())
{
// object not in pre match
continue;
}

SWSS_LOG_INFO("processing explicit pre match: %s:%s",
obj.second->m_str_object_type.c_str(),
obj.second->m_str_object_id.c_str());

processObjectForViewTransition(current, temp, obj.second);
}
}

for (auto &obj: temp.m_soAll)
{
if (obj.second->getObjectType() != SAI_OBJECT_TYPE_ROUTE_ENTRY)
Expand Down
4 changes: 4 additions & 0 deletions syncd/ComparisonLogic.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ namespace syncd
_In_ std::shared_ptr<const SaiObj> tObj,
_Inout_ std::set<std::string>& processed);

void cretePreMatchForLagMembers(
_In_ const AsicView& cur,
_Inout_ AsicView& tmp,
_Inout_ std::set<std::string>& processed);

sai_object_id_t asic_translate_vid_to_rid(
_In_ const AsicView& current,
Expand Down
13 changes: 13 additions & 0 deletions tests/BCM56850.pl
Original file line number Diff line number Diff line change
Expand Up @@ -749,8 +749,21 @@ sub test_remove_port_serdes
play "test_remove_port_serdes.rec";
}

sub test_lag_member
{
fresh_start;

play "test_lag_member.rec";
play "test_lag_member.rec", 1;
play "test_lag_member.rec", 1;
play "test_lag_member.rec", 1;
play "test_lag_member.rec", 1;
play "test_lag_member.rec", 1;
}

# RUN TESTS

test_lag_member;
test_remove_port_serdes;
test_brcm_warm_new_object_port_serdes;
test_buffer_profile_get;
Expand Down
37 changes: 37 additions & 0 deletions tests/BCM56850/test_lag_member.rec
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
2022-01-14.15:46:22.474741|a|INIT_VIEW
2022-01-14.15:46:24.688492|A|SAI_STATUS_SUCCESS
2022-01-14.15:46:24.689578|c|SAI_OBJECT_TYPE_SWITCH:oid:0x21000000000000|SAI_SWITCH_ATTR_INIT_SWITCH=true
2022-01-14.15:46:25.693192|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
2022-01-14.15:46:25.695263|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
2022-01-14.15:46:27.407237|c|SAI_OBJECT_TYPE_ACL_TABLE_GROUP:oid:0xb000000000601|SAI_ACL_TABLE_GROUP_ATTR_ACL_STAGE=SAI_ACL_STAGE_INGRESS|SAI_ACL_TABLE_GROUP_ATTR_ACL_BIND_POINT_TYPE_LIST=1:SAI_ACL_BIND_POINT_TYPE_LAG|SAI_ACL_TABLE_GROUP_ATTR_TYPE=SAI_ACL_TABLE_GROUP_TYPE_PARALLEL
2022-01-14.15:46:27.408138|c|SAI_OBJECT_TYPE_ACL_TABLE_GROUP:oid:0xb000000000605|SAI_ACL_TABLE_GROUP_ATTR_ACL_STAGE=SAI_ACL_STAGE_INGRESS|SAI_ACL_TABLE_GROUP_ATTR_ACL_BIND_POINT_TYPE_LIST=1:SAI_ACL_BIND_POINT_TYPE_LAG|SAI_ACL_TABLE_GROUP_ATTR_TYPE=SAI_ACL_TABLE_GROUP_TYPE_PARALLEL
2022-01-14.15:46:27.409011|c|SAI_OBJECT_TYPE_ACL_TABLE_GROUP:oid:0xb000000000609|SAI_ACL_TABLE_GROUP_ATTR_ACL_STAGE=SAI_ACL_STAGE_INGRESS|SAI_ACL_TABLE_GROUP_ATTR_ACL_BIND_POINT_TYPE_LIST=1:SAI_ACL_BIND_POINT_TYPE_LAG|SAI_ACL_TABLE_GROUP_ATTR_TYPE=SAI_ACL_TABLE_GROUP_TYPE_PARALLEL
2022-01-14.15:46:27.409839|c|SAI_OBJECT_TYPE_ACL_TABLE_GROUP:oid:0xb00000000060d|SAI_ACL_TABLE_GROUP_ATTR_ACL_STAGE=SAI_ACL_STAGE_INGRESS|SAI_ACL_TABLE_GROUP_ATTR_ACL_BIND_POINT_TYPE_LIST=1:SAI_ACL_BIND_POINT_TYPE_LAG|SAI_ACL_TABLE_GROUP_ATTR_TYPE=SAI_ACL_TABLE_GROUP_TYPE_PARALLEL
2022-01-14.15:46:27.407328|c|SAI_OBJECT_TYPE_LAG:oid:0x2000000000600|SAI_LAG_ATTR_INGRESS_ACL=oid:0xb000000000601
2022-01-14.15:46:27.408232|c|SAI_OBJECT_TYPE_LAG:oid:0x2000000000604|SAI_LAG_ATTR_INGRESS_ACL=oid:0xb000000000605
2022-01-14.15:46:27.409063|c|SAI_OBJECT_TYPE_LAG:oid:0x2000000000608|SAI_LAG_ATTR_INGRESS_ACL=oid:0xb000000000609
2022-01-14.15:46:27.409908|c|SAI_OBJECT_TYPE_LAG:oid:0x200000000060c|SAI_LAG_ATTR_INGRESS_ACL=oid:0xb00000000060d
2022-01-14.15:46:28.283780|c|SAI_OBJECT_TYPE_LAG_MEMBER:oid:0x1b000000000613|SAI_LAG_MEMBER_ATTR_LAG_ID=oid:0x2000000000600|SAI_LAG_MEMBER_ATTR_PORT_ID=oid:0x100000000001e
2022-01-14.15:46:29.668267|c|SAI_OBJECT_TYPE_LAG_MEMBER:oid:0x1b00000000065a|SAI_LAG_MEMBER_ATTR_LAG_ID=oid:0x200000000060c|SAI_LAG_MEMBER_ATTR_PORT_ID=oid:0x1000000000021
2022-01-14.15:46:29.852460|c|SAI_OBJECT_TYPE_LAG_MEMBER:oid:0x1b00000000065d|SAI_LAG_MEMBER_ATTR_LAG_ID=oid:0x2000000000608|SAI_LAG_MEMBER_ATTR_PORT_ID=oid:0x1000000000020
2022-01-14.15:46:25.817148|a|APPLY_VIEW
2022-01-14.15:46:25.818774|A|SAI_STATUS_SUCCESS
2022-01-14.16:24:24.859833|a|INIT_VIEW
2022-01-14.16:24:29.032331|A|SAI_STATUS_SUCCESS
2022-01-14.16:24:29.036445|c|SAI_OBJECT_TYPE_SWITCH:oid:0x21000000000000|SAI_SWITCH_ATTR_INIT_SWITCH=true
2022-01-14.16:24:29.063536|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
2022-01-14.16:24:29.075991|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
2022-01-14.16:24:34.169967|c|SAI_OBJECT_TYPE_ACL_TABLE_GROUP:oid:0xb000000000755|SAI_ACL_TABLE_GROUP_ATTR_ACL_STAGE=SAI_ACL_STAGE_INGRESS|SAI_ACL_TABLE_GROUP_ATTR_ACL_BIND_POINT_TYPE_LIST=1:SAI_ACL_BIND_POINT_TYPE_LAG|SAI_ACL_TABLE_GROUP_ATTR_TYPE=SAI_ACL_TABLE_GROUP_TYPE_PARALLEL
2022-01-14.16:24:34.172823|c|SAI_OBJECT_TYPE_ACL_TABLE_GROUP:oid:0xb000000000757|SAI_ACL_TABLE_GROUP_ATTR_ACL_STAGE=SAI_ACL_STAGE_INGRESS|SAI_ACL_TABLE_GROUP_ATTR_ACL_BIND_POINT_TYPE_LIST=1:SAI_ACL_BIND_POINT_TYPE_LAG|SAI_ACL_TABLE_GROUP_ATTR_TYPE=SAI_ACL_TABLE_GROUP_TYPE_PARALLEL
2022-01-14.16:24:34.175837|c|SAI_OBJECT_TYPE_ACL_TABLE_GROUP:oid:0xb000000000759|SAI_ACL_TABLE_GROUP_ATTR_ACL_STAGE=SAI_ACL_STAGE_INGRESS|SAI_ACL_TABLE_GROUP_ATTR_ACL_BIND_POINT_TYPE_LIST=1:SAI_ACL_BIND_POINT_TYPE_LAG|SAI_ACL_TABLE_GROUP_ATTR_TYPE=SAI_ACL_TABLE_GROUP_TYPE_PARALLEL
2022-01-14.16:24:34.178329|c|SAI_OBJECT_TYPE_ACL_TABLE_GROUP:oid:0xb00000000075b|SAI_ACL_TABLE_GROUP_ATTR_ACL_STAGE=SAI_ACL_STAGE_INGRESS|SAI_ACL_TABLE_GROUP_ATTR_ACL_BIND_POINT_TYPE_LIST=1:SAI_ACL_BIND_POINT_TYPE_LAG|SAI_ACL_TABLE_GROUP_ATTR_TYPE=SAI_ACL_TABLE_GROUP_TYPE_PARALLEL
2022-01-14.16:24:34.171081|c|SAI_OBJECT_TYPE_LAG:oid:0x20000000006ee|SAI_LAG_ATTR_INGRESS_ACL=oid:0xb000000000755
2022-01-14.16:24:34.173489|c|SAI_OBJECT_TYPE_LAG:oid:0x20000000006ef|SAI_LAG_ATTR_INGRESS_ACL=oid:0xb000000000757
2022-01-14.16:24:34.176562|c|SAI_OBJECT_TYPE_LAG:oid:0x20000000006f0|SAI_LAG_ATTR_INGRESS_ACL=oid:0xb000000000759
2022-01-14.16:24:34.179006|c|SAI_OBJECT_TYPE_LAG:oid:0x20000000006f1|SAI_LAG_ATTR_INGRESS_ACL=oid:0xb00000000075b
2022-01-14.16:24:32.355500|c|SAI_OBJECT_TYPE_LAG_MEMBER:oid:0x1b0000000006f2|SAI_LAG_MEMBER_ATTR_LAG_ID=oid:0x20000000006ee|SAI_LAG_MEMBER_ATTR_PORT_ID=oid:0x100000000001e|SAI_LAG_MEMBER_ATTR_INGRESS_DISABLE=false|SAI_LAG_MEMBER_ATTR_EGRESS_DISABLE=false
2022-01-14.16:24:32.358008|c|SAI_OBJECT_TYPE_LAG_MEMBER:oid:0x1b0000000006f3|SAI_LAG_MEMBER_ATTR_LAG_ID=oid:0x20000000006ef|SAI_LAG_MEMBER_ATTR_PORT_ID=oid:0x100000000001f|SAI_LAG_MEMBER_ATTR_EGRESS_DISABLE=true|SAI_LAG_MEMBER_ATTR_INGRESS_DISABLE=true
2022-01-14.16:24:32.360583|c|SAI_OBJECT_TYPE_LAG_MEMBER:oid:0x1b0000000006f4|SAI_LAG_MEMBER_ATTR_LAG_ID=oid:0x20000000006f0|SAI_LAG_MEMBER_ATTR_PORT_ID=oid:0x1000000000020|SAI_LAG_MEMBER_ATTR_INGRESS_DISABLE=false|SAI_LAG_MEMBER_ATTR_EGRESS_DISABLE=false
2022-01-14.16:24:32.363114|c|SAI_OBJECT_TYPE_LAG_MEMBER:oid:0x1b0000000006f5|SAI_LAG_MEMBER_ATTR_LAG_ID=oid:0x20000000006f1|SAI_LAG_MEMBER_ATTR_PORT_ID=oid:0x1000000000021|SAI_LAG_MEMBER_ATTR_INGRESS_DISABLE=false|SAI_LAG_MEMBER_ATTR_EGRESS_DISABLE=false
2022-01-14.16:24:36.722522|a|APPLY_VIEW
2022-01-14.16:24:42.626612|A|SAI_STATUS_SUCCESS

0 comments on commit 418d5fb

Please sign in to comment.