Skip to content

Commit

Permalink
Use priority attribute matching acl counter using acl entry (sonic-ne…
Browse files Browse the repository at this point in the history
  • Loading branch information
kcudnik authored Apr 8, 2022
1 parent 8037c7d commit 2ddf419
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 3 deletions.
29 changes: 26 additions & 3 deletions syncd/BestCandidateFinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,17 +283,34 @@ std::shared_ptr<SaiObj> BestCandidateFinder::findCurrentBestMatchForAclCounter(
if (tmpAclEntryActionCounterAttr->getOid() != temporaryObj->getVid())
continue; // not the counter we are looking for

// try use priority attribute first since it should be unique
// TODO we should use HASH from all non OID attribute here to have
// better chance for finding best candidate, this could be also
// used in pre match logic

std::vector<std::shared_ptr<const SaiAttr>> values;

if (tmpAclEntry->hasAttr(SAI_ACL_ENTRY_ATTR_PRIORITY))
{
values.push_back(tmpAclEntry->getSaiAttr(SAI_ACL_ENTRY_ATTR_PRIORITY));
}

for (auto&attr: tmpAclEntry->getAllAttributes())
{
auto*meta = attr.second->getAttrMetadata();
values.push_back(attr.second);
}

if (!meta->isaclfield)
for (auto&attr: values)
{
auto*meta = attr->getAttrMetadata();

if (!meta->isaclfield && meta->attrid != SAI_ACL_ENTRY_ATTR_PRIORITY)
continue; // looking only for acl fields

if (meta->isoidattribute)
continue; // only non oid fields

auto tmpValue = attr.second->getStrAttrValue();
auto tmpValue = attr->getStrAttrValue();

const auto curAclEntries = m_currentView.getObjectsByObjectType(SAI_OBJECT_TYPE_ACL_ENTRY);

Expand Down Expand Up @@ -1694,6 +1711,8 @@ std::shared_ptr<SaiObj> BestCandidateFinder::findCurrentBestMatchForGenericObjec

for (const auto &currentObj: notProcessedObjects)
{
SWSS_LOG_INFO("* examing current obj: %s", currentObj->m_str_object_id.c_str());

sai_object_compare_info_t soci = { 0, currentObj };

bool has_different_create_only_attr = false;
Expand Down Expand Up @@ -1862,6 +1881,10 @@ std::shared_ptr<SaiObj> BestCandidateFinder::findCurrentBestMatchForGenericObjec
continue;
}

SWSS_LOG_INFO("* current obj: %s has equal %lu attributes",
currentObj->m_str_object_id.c_str(),
soci.equal_attributes);

candidateObjects.push_back(soci);
}

Expand Down
13 changes: 13 additions & 0 deletions tests/BCM56971B0.pl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,19 @@ sub test_brcm_acl_limit
play "acl_limit.rec";
}

sub test_brcm_acl_prio
{
fresh_start("-b", "$utils::DIR/break.ini", "-p", "$utils::DIR/vsprofile.ini");

play "acl_prio.rec";
play "acl_prio.rec", 0;
play "acl_prio.rec", 0;
play "acl_prio.rec", 0;
play "acl_prio.rec", 0;
play "acl_prio.rec", 0;
}

test_brcm_acl_prio;
test_brcm_acl_limit;

kill_syncd;
Loading

0 comments on commit 2ddf419

Please sign in to comment.