Skip to content

Commit dcc8688

Browse files
authored
Add more specific logic for ingress ACL and buffer profile (sonic-net#421)
* Add more specific logic for ingress ACL and buffer profile * Address comments
1 parent c0b39ea commit dcc8688

File tree

1 file changed

+128
-21
lines changed

1 file changed

+128
-21
lines changed

syncd/syncd_applyview.cpp

+128-21
Original file line numberDiff line numberDiff line change
@@ -2679,38 +2679,45 @@ std::shared_ptr<SaiObj> findCurrentBestMatchForAclTableGroup(
26792679

26802680
const auto ports = temporaryView.getObjectsByObjectType(SAI_OBJECT_TYPE_PORT);
26812681

2682-
for (auto port: ports)
2683-
{
2684-
if (!port->hasAttr(SAI_PORT_ATTR_INGRESS_ACL))
2685-
continue;
2682+
std::vector<int> aclPortAttrs = {
2683+
SAI_PORT_ATTR_INGRESS_ACL,
2684+
SAI_PORT_ATTR_EGRESS_ACL,
2685+
};
26862686

2687-
auto inACL = port->getSaiAttr(SAI_PORT_ATTR_INGRESS_ACL);
2687+
for (auto attrId: aclPortAttrs)
2688+
{
2689+
for (auto port: ports)
2690+
{
2691+
auto portAcl = port->tryGetSaiAttr(attrId);
26882692

2689-
if (inACL->getSaiAttr()->value.oid != temporaryObj->getVid())
2690-
continue;
2693+
if (portAcl == nullptr)
2694+
continue;
26912695

2692-
SWSS_LOG_DEBUG("found port candidate %s for ACL table group",
2693-
port->str_object_id.c_str());
2696+
if (portAcl ->getSaiAttr()->value.oid != temporaryObj->getVid())
2697+
continue;
26942698

2699+
SWSS_LOG_DEBUG("found port candidate %s for ACL table group",
2700+
port->str_object_id.c_str());
26952701

2696-
auto curPort = currentView.oOids.at(port->getVid());
2702+
auto curPort = currentView.oOids.at(port->getVid());
26972703

2698-
if (!curPort->hasAttr(SAI_PORT_ATTR_INGRESS_ACL))
2699-
continue;
2704+
portAcl = curPort->tryGetSaiAttr(attrId);
27002705

2701-
inACL = curPort->getSaiAttr(SAI_PORT_ATTR_INGRESS_ACL);
2706+
if (portAcl == nullptr)
2707+
continue;
27022708

2703-
sai_object_id_t atgVid = inACL->getSaiAttr()->value.oid;
2709+
sai_object_id_t atgVid = portAcl->getSaiAttr()->value.oid;
27042710

2705-
for (auto c: candidateObjects)
2706-
{
2707-
if (c.obj->getVid() == atgVid)
2711+
for (auto c: candidateObjects)
27082712
{
2709-
SWSS_LOG_INFO("found ALC table group candidate %s using port %s",
2710-
c.obj->str_object_id.c_str(),
2711-
port->str_object_id.c_str());
2713+
if (c.obj->getVid() == atgVid)
2714+
{
2715+
SWSS_LOG_INFO("found ALC table group candidate %s using port %s",
2716+
c.obj->str_object_id.c_str(),
2717+
port->str_object_id.c_str());
27122718

2713-
return c.obj;
2719+
return c.obj;
2720+
}
27142721
}
27152722
}
27162723
}
@@ -3412,6 +3419,102 @@ std::shared_ptr<SaiObj> findCurrentBestMatchForBufferPool(
34123419
return nullptr;
34133420
}
34143421

3422+
std::shared_ptr<SaiObj> findCurrentBestMatchForBufferProfile(
3423+
_In_ const AsicView &currentView,
3424+
_In_ const AsicView &temporaryView,
3425+
_In_ const std::shared_ptr<const SaiObj> &temporaryObj,
3426+
_In_ const std::vector<sai_object_compare_info_t> &candidateObjects)
3427+
{
3428+
SWSS_LOG_ENTER();
3429+
3430+
/*
3431+
* For buffer profile we will try using SAI_INGRESS_PRIORITY_GROUP_ATTR_BUFFER_PROFILE
3432+
* or SAI_QUEUE_ATTR_BUFFER_PROFILE_ID for matching.
3433+
*
3434+
* If we are here, and buffer profile has assigned buffer pool, then buffer
3435+
* pool was matched correctly or best effort. Then we have trouble matching
3436+
* buffer profile since their configuration could be the same. This search
3437+
* here should solve the issue.
3438+
*/
3439+
3440+
auto tmpQueues = temporaryView.getObjectsByObjectType(SAI_OBJECT_TYPE_QUEUE);
3441+
3442+
for (auto tmpQueue: tmpQueues)
3443+
{
3444+
auto tmpBufferProfileIdAttr = tmpQueue->tryGetSaiAttr(SAI_QUEUE_ATTR_BUFFER_PROFILE_ID);
3445+
3446+
if (tmpBufferProfileIdAttr == nullptr)
3447+
continue;
3448+
3449+
if (tmpBufferProfileIdAttr->getOid() != temporaryObj->getVid())
3450+
continue;
3451+
3452+
if (tmpQueue->getObjectStatus() != SAI_OBJECT_STATUS_MATCHED)
3453+
continue;
3454+
3455+
// we can use tmp VID since object is matched and both vids are the same
3456+
auto curQueue = currentView.oOids.at(tmpQueue->getVid());
3457+
3458+
auto curBufferProfileIdAttr = curQueue->tryGetSaiAttr(SAI_QUEUE_ATTR_BUFFER_PROFILE_ID);
3459+
3460+
if (curBufferProfileIdAttr == nullptr)
3461+
continue;
3462+
3463+
// we have buffer profile
3464+
3465+
for (auto c: candidateObjects)
3466+
{
3467+
if (c.obj->getVid() != curBufferProfileIdAttr->getOid())
3468+
continue;
3469+
3470+
SWSS_LOG_INFO("found best BUFFER PROFILE based on queues %s", c.obj->str_object_id.c_str());
3471+
3472+
return c.obj;
3473+
}
3474+
}
3475+
3476+
auto tmpIPGs = temporaryView.getObjectsByObjectType(SAI_OBJECT_TYPE_INGRESS_PRIORITY_GROUP);
3477+
3478+
for (auto tmpIPG: tmpIPGs)
3479+
{
3480+
auto tmpBufferProfileIdAttr = tmpIPG->tryGetSaiAttr(SAI_INGRESS_PRIORITY_GROUP_ATTR_BUFFER_PROFILE);
3481+
3482+
if (tmpBufferProfileIdAttr == nullptr)
3483+
continue;
3484+
3485+
if (tmpBufferProfileIdAttr->getOid() != temporaryObj->getVid())
3486+
continue;
3487+
3488+
if (tmpIPG->getObjectStatus() != SAI_OBJECT_STATUS_MATCHED)
3489+
continue;
3490+
3491+
// we can use tmp VID since object is matched and both vids are the same
3492+
auto curIPG = currentView.oOids.at(tmpIPG->getVid());
3493+
3494+
auto curBufferProfileIdAttr = curIPG->tryGetSaiAttr(SAI_INGRESS_PRIORITY_GROUP_ATTR_BUFFER_PROFILE);
3495+
3496+
if (curBufferProfileIdAttr == nullptr)
3497+
continue;
3498+
3499+
// we have buffer profile
3500+
3501+
for (auto c: candidateObjects)
3502+
{
3503+
if (c.obj->getVid() != curBufferProfileIdAttr->getOid())
3504+
continue;
3505+
3506+
SWSS_LOG_INFO("found best BUFFER PROFILE based on IPG %s", c.obj->str_object_id.c_str());
3507+
3508+
return c.obj;
3509+
}
3510+
}
3511+
3512+
SWSS_LOG_NOTICE("failed to find best candidate for BUFFER PROFILE using queues and ipgs");
3513+
3514+
return nullptr;
3515+
}
3516+
3517+
34153518
std::shared_ptr<SaiObj> findCurrentBestMatchForWred(
34163519
_In_ const AsicView &currentView,
34173520
_In_ const AsicView &temporaryView,
@@ -3516,6 +3619,10 @@ std::shared_ptr<SaiObj> findCurrentBestMatchForGenericObjectUsingGraph(
35163619
candidate = findCurrentBestMatchForWred(currentView, temporaryView, temporaryObj, candidateObjects);
35173620
break;
35183621

3622+
case SAI_OBJECT_TYPE_BUFFER_PROFILE:
3623+
candidate = findCurrentBestMatchForBufferProfile(currentView, temporaryView, temporaryObj, candidateObjects);
3624+
break;
3625+
35193626
default:
35203627
break;
35213628
}

0 commit comments

Comments
 (0)