@@ -2679,38 +2679,45 @@ std::shared_ptr<SaiObj> findCurrentBestMatchForAclTableGroup(
2679
2679
2680
2680
const auto ports = temporaryView.getObjectsByObjectType (SAI_OBJECT_TYPE_PORT);
2681
2681
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
+ } ;
2686
2686
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);
2688
2692
2689
- if (inACL-> getSaiAttr ()-> value . oid != temporaryObj-> getVid () )
2690
- continue ;
2693
+ if (portAcl == nullptr )
2694
+ continue ;
2691
2695
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 ;
2694
2698
2699
+ SWSS_LOG_DEBUG (" found port candidate %s for ACL table group" ,
2700
+ port->str_object_id .c_str ());
2695
2701
2696
- auto curPort = currentView.oOids .at (port->getVid ());
2702
+ auto curPort = currentView.oOids .at (port->getVid ());
2697
2703
2698
- if (!curPort->hasAttr (SAI_PORT_ATTR_INGRESS_ACL))
2699
- continue ;
2704
+ portAcl = curPort->tryGetSaiAttr (attrId);
2700
2705
2701
- inACL = curPort->getSaiAttr (SAI_PORT_ATTR_INGRESS_ACL);
2706
+ if (portAcl == nullptr )
2707
+ continue ;
2702
2708
2703
- sai_object_id_t atgVid = inACL ->getSaiAttr ()->value .oid ;
2709
+ sai_object_id_t atgVid = portAcl ->getSaiAttr ()->value .oid ;
2704
2710
2705
- for (auto c: candidateObjects)
2706
- {
2707
- if (c.obj ->getVid () == atgVid)
2711
+ for (auto c: candidateObjects)
2708
2712
{
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 ());
2712
2718
2713
- return c.obj ;
2719
+ return c.obj ;
2720
+ }
2714
2721
}
2715
2722
}
2716
2723
}
@@ -3412,6 +3419,102 @@ std::shared_ptr<SaiObj> findCurrentBestMatchForBufferPool(
3412
3419
return nullptr ;
3413
3420
}
3414
3421
3422
+ std::shared_ptr<SaiObj> findCurrentBestMatchForBufferProfile (
3423
+ _In_ const AsicView ¤tView,
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
+
3415
3518
std::shared_ptr<SaiObj> findCurrentBestMatchForWred (
3416
3519
_In_ const AsicView ¤tView,
3417
3520
_In_ const AsicView &temporaryView,
@@ -3516,6 +3619,10 @@ std::shared_ptr<SaiObj> findCurrentBestMatchForGenericObjectUsingGraph(
3516
3619
candidate = findCurrentBestMatchForWred (currentView, temporaryView, temporaryObj, candidateObjects);
3517
3620
break ;
3518
3621
3622
+ case SAI_OBJECT_TYPE_BUFFER_PROFILE:
3623
+ candidate = findCurrentBestMatchForBufferProfile (currentView, temporaryView, temporaryObj, candidateObjects);
3624
+ break ;
3625
+
3519
3626
default :
3520
3627
break ;
3521
3628
}
0 commit comments