Skip to content

Commit

Permalink
Make object list deterministic when iterating (#438)
Browse files Browse the repository at this point in the history
* Use pre match logic to match ACL TABLE

* Change log level to info

* Make object list deterministic when iterating
  • Loading branch information
kcudnik authored Apr 8, 2019
1 parent 5486f97 commit e8cb879
Show file tree
Hide file tree
Showing 3 changed files with 810 additions and 5 deletions.
67 changes: 62 additions & 5 deletions syncd/syncd_applyview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -483,8 +483,8 @@ class SaiObj
};

typedef std::unordered_map<sai_object_id_t, sai_object_id_t> ObjectIdMap;
typedef std::unordered_map<std::string, std::shared_ptr<SaiObj>> StrObjectIdToSaiObjectHash;
typedef std::unordered_map<sai_object_id_t, std::shared_ptr<SaiObj>> ObjectIdToSaiObjectHash;
typedef std::map<std::string, std::shared_ptr<SaiObj>> StrObjectIdToSaiObjectHash;
typedef std::map<sai_object_id_t, std::shared_ptr<SaiObj>> ObjectIdToSaiObjectHash;

/**
* @brief Class represents ASIC view
Expand Down Expand Up @@ -2916,7 +2916,7 @@ std::shared_ptr<SaiObj> findCurrentBestMatchForAclTable(
{
if (c.obj->getVid() == curAclTableId->getOid())
{
SWSS_LOG_INFO("found ALC table candidate %s using port %s",
SWSS_LOG_INFO("found ACL table candidate %s using port %s",
c.obj->str_object_id.c_str(),
tmpPort->str_object_id.c_str());

Expand All @@ -2927,6 +2927,53 @@ std::shared_ptr<SaiObj> findCurrentBestMatchForAclTable(
}
}

// try using pre match in this case

const auto tmpMembers = temporaryView.getNotProcessedObjectsByObjectType(SAI_OBJECT_TYPE_ACL_TABLE_GROUP_MEMBER);

for (auto tmpAclTableGroupMember: tmpMembers)
{
auto tmpAclTableIdAttr = tmpAclTableGroupMember->getSaiAttr(SAI_ACL_TABLE_GROUP_MEMBER_ATTR_ACL_TABLE_ID);

if (tmpAclTableIdAttr->getOid() != temporaryObj->getVid())
continue;

auto tmpAclTableGroupIdAttr = tmpAclTableGroupMember->getSaiAttr(SAI_ACL_TABLE_GROUP_MEMBER_ATTR_ACL_TABLE_GROUP_ID);

auto tmpAclTableGroup = temporaryView.oOids.at(tmpAclTableGroupIdAttr->getOid());

auto it = temporaryView.preMatchMap.find(tmpAclTableGroup->getVid());

if (it == temporaryView.preMatchMap.end())
continue;

auto curAclTableGroupMembers = currentView.getNotProcessedObjectsByObjectType(SAI_OBJECT_TYPE_ACL_TABLE_GROUP_MEMBER);

for (auto curAclTableGroupMember: curAclTableGroupMembers)
{
auto curAclTableGroupIdAttr = curAclTableGroupMember->getSaiAttr(SAI_ACL_TABLE_GROUP_MEMBER_ATTR_ACL_TABLE_GROUP_ID);

if (curAclTableGroupIdAttr->getOid() != it->second)
continue;

// we got acl table group member current that uses same acl table group as temporary

auto curAclTableIdAttr = curAclTableGroupMember->getSaiAttr(SAI_ACL_TABLE_GROUP_MEMBER_ATTR_ACL_TABLE_ID);

for (auto c: candidateObjects)
{
if (c.obj->getVid() == curAclTableIdAttr->getOid())
{
SWSS_LOG_INFO("found ACL table candidate %s using pre match ACL TABLE GROUP %s",
c.obj->str_object_id.c_str(),
tmpAclTableGroup->str_object_id.c_str());

return c.obj;
}
}
}
}

SWSS_LOG_NOTICE("failed to find best candidate for ACL_TABLE using port");

return nullptr;
Expand Down Expand Up @@ -6166,7 +6213,7 @@ void processObjectForViewTransition(
return;
}

SWSS_LOG_DEBUG("processing: %s:%s", temporaryObj->str_object_type.c_str(), temporaryObj->str_object_id.c_str());
SWSS_LOG_INFO("processing: %s:%s", temporaryObj->str_object_type.c_str(), temporaryObj->str_object_id.c_str());

procesObjectAttributesForViewTransition(currentView, temporaryView, temporaryObj);

Expand Down Expand Up @@ -7233,7 +7280,17 @@ void createPreMatchMap(
createPreMatchMapForObject(cur, tmp, cObj, tObj, processed);
}

SWSS_LOG_NOTICE("preMatch map size: %zu", tmp.preMatchMap.size());
size_t count = 0;

for (auto& ok: tmp.soOids)
{
if (ok.second->getObjectStatus() != SAI_OBJECT_STATUS_MATCHED)
count++;
}

SWSS_LOG_NOTICE("preMatch map size: %zu, tmp oid obj: %zu",
tmp.preMatchMap.size(),
count);
}

sai_status_t syncdApplyView()
Expand Down
10 changes: 10 additions & 0 deletions tests/brcm.pl
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,18 @@ sub test_empty_lag_buffer_acl
for (1..8) { play "empty_lag_buffer_acl.rec", 0; }
}

sub test_acl_mask
{
fresh_start;

play "acl_mask.rec";

for (1..8) { play "acl_mask.rec", 0; }
}

# RUN TESTS

test_acl_mask;
test_empty_lag_buffer_acl;
test_brcm_config_acl;
test_brcm_warm_wred_queue;
Expand Down
Loading

0 comments on commit e8cb879

Please sign in to comment.