@@ -2492,12 +2492,10 @@ std::shared_ptr<SaiObj> findCurrentBestMatchForLag(
2492
2492
return c.obj ;
2493
2493
}
2494
2494
}
2495
-
2496
- break ;
2497
2495
}
2498
2496
}
2499
2497
2500
- SWSS_LOG_WARN (" failed to find best candidate for LAG using LAG member and port id" );
2498
+ SWSS_LOG_WARN (" failed to find best candidate for LAG using LAG member and port id: tmp %s " , temporaryObj-> str_object_id . c_str () );
2501
2499
2502
2500
return nullptr ;
2503
2501
}
@@ -3213,7 +3211,140 @@ std::shared_ptr<SaiObj> findCurrentBestMatchForHostifTrapGroup(
3213
3211
return nullptr ;
3214
3212
}
3215
3213
3216
- std::shared_ptr<SaiObj> findCurrentBestMatchForGenericObjectUsingHeuristic (
3214
+ std::shared_ptr<SaiObj> findCurrentBestMatchForBufferPool (
3215
+ _In_ const AsicView ¤tView,
3216
+ _In_ const AsicView &temporaryView,
3217
+ _In_ const std::shared_ptr<const SaiObj> &temporaryObj,
3218
+ _In_ const std::vector<sai_object_compare_info_t > &candidateObjects)
3219
+ {
3220
+ SWSS_LOG_ENTER ();
3221
+
3222
+ /*
3223
+ * For buffer pool using buffer profile which could be set on ingress
3224
+ * priority group or queue. Those two should be already matched.
3225
+ */
3226
+
3227
+ const auto tmpBufferProfiles = temporaryView.getNotProcessedObjectsByObjectType (SAI_OBJECT_TYPE_BUFFER_PROFILE);
3228
+
3229
+ for (auto tmpBufferProfile: tmpBufferProfiles)
3230
+ {
3231
+ auto tmpPoolIdAttr = tmpBufferProfile->tryGetSaiAttr (SAI_BUFFER_PROFILE_ATTR_POOL_ID);
3232
+
3233
+ if (tmpPoolIdAttr == nullptr )
3234
+ continue ;
3235
+
3236
+ if (tmpPoolIdAttr->getOid () != temporaryObj->getVid ())
3237
+ continue ;
3238
+
3239
+ /*
3240
+ * We have temporary buffer profile which uses this buffer pool, let's
3241
+ * find ingress priority group or queue on which it could be set.
3242
+ */
3243
+
3244
+ auto tmpQueues = temporaryView.getObjectsByObjectType (SAI_OBJECT_TYPE_QUEUE);
3245
+
3246
+ for (auto tmpQueue: tmpQueues)
3247
+ {
3248
+ auto tmpBufferProfileIdAttr = tmpQueue->tryGetSaiAttr (SAI_QUEUE_ATTR_BUFFER_PROFILE_ID);
3249
+
3250
+ if (tmpBufferProfileIdAttr == nullptr )
3251
+ continue ;
3252
+
3253
+ if (tmpBufferProfileIdAttr->getOid () != tmpBufferProfile->getVid ())
3254
+ continue ;
3255
+
3256
+ if (tmpQueue->getObjectStatus () != SAI_OBJECT_STATUS_MATCHED)
3257
+ continue ;
3258
+
3259
+ // we can use tmp VID since object is matched and both vids are the same
3260
+ auto curQueue = currentView.oOids .at (tmpQueue->getVid ());
3261
+
3262
+ auto curBufferProfileIdAttr = curQueue->tryGetSaiAttr (SAI_QUEUE_ATTR_BUFFER_PROFILE_ID);
3263
+
3264
+ if (curBufferProfileIdAttr == nullptr )
3265
+ continue ;
3266
+
3267
+ if (curBufferProfileIdAttr->getOid () == SAI_NULL_OBJECT_ID)
3268
+ continue ;
3269
+
3270
+ // we have buffer profile
3271
+
3272
+ auto curBufferProfile = currentView.oOids .at (curBufferProfileIdAttr->getOid ());
3273
+
3274
+ auto curPoolIdAttr = curBufferProfile->tryGetSaiAttr (SAI_BUFFER_PROFILE_ATTR_POOL_ID);
3275
+
3276
+ if (curPoolIdAttr == nullptr )
3277
+ continue ;
3278
+
3279
+ for (auto c: candidateObjects)
3280
+ {
3281
+ if (c.obj ->getVid () != curPoolIdAttr->getOid ())
3282
+ continue ;
3283
+
3284
+ SWSS_LOG_INFO (" found best BUFFER POOL based on buffer profile and queue %s" , c.obj ->str_object_id .c_str ());
3285
+
3286
+ return c.obj ;
3287
+ }
3288
+ }
3289
+
3290
+ /*
3291
+ * Queues didn't worked, lets try to use ingress priority groups.
3292
+ */
3293
+
3294
+ auto tmpIngressPriorityGroups = temporaryView.getObjectsByObjectType (SAI_OBJECT_TYPE_INGRESS_PRIORITY_GROUP);
3295
+
3296
+ for (auto tmpIngressPriorityGroup: tmpIngressPriorityGroups)
3297
+ {
3298
+ auto tmpBufferProfileIdAttr = tmpIngressPriorityGroup->tryGetSaiAttr (SAI_INGRESS_PRIORITY_GROUP_ATTR_BUFFER_PROFILE);
3299
+
3300
+ if (tmpBufferProfileIdAttr == nullptr )
3301
+ continue ;
3302
+
3303
+ if (tmpBufferProfileIdAttr->getOid () != tmpBufferProfile->getVid ())
3304
+ continue ;
3305
+
3306
+ if (tmpIngressPriorityGroup->getObjectStatus () != SAI_OBJECT_STATUS_MATCHED)
3307
+ continue ;
3308
+
3309
+ // we can use tmp VID since object is matched and both vids are the same
3310
+ auto curIngressPriorityGroup = currentView.oOids .at (tmpIngressPriorityGroup->getVid ());
3311
+
3312
+ auto curBufferProfileIdAttr = curIngressPriorityGroup->tryGetSaiAttr (SAI_INGRESS_PRIORITY_GROUP_ATTR_BUFFER_PROFILE);
3313
+
3314
+ if (curBufferProfileIdAttr == nullptr )
3315
+ continue ;
3316
+
3317
+ if (curBufferProfileIdAttr->getOid () == SAI_NULL_OBJECT_ID)
3318
+ continue ;
3319
+
3320
+ // we have buffer profile
3321
+
3322
+ auto curBufferProfile = currentView.oOids .at (curBufferProfileIdAttr->getOid ());
3323
+
3324
+ auto curPoolIdAttr = curBufferProfile->tryGetSaiAttr (SAI_BUFFER_PROFILE_ATTR_POOL_ID);
3325
+
3326
+ if (curPoolIdAttr == nullptr )
3327
+ continue ;
3328
+
3329
+ for (auto c: candidateObjects)
3330
+ {
3331
+ if (c.obj ->getVid () != curPoolIdAttr->getOid ())
3332
+ continue ;
3333
+
3334
+ SWSS_LOG_INFO (" found best BUFFER POOL based on buffer profile and ingress priority group %s" , c.obj ->str_object_id .c_str ());
3335
+
3336
+ return c.obj ;
3337
+ }
3338
+ }
3339
+
3340
+ }
3341
+
3342
+ SWSS_LOG_NOTICE (" failed to find best candidate for BUFFER POOL using buffer profile, ipg and queue" );
3343
+
3344
+ return nullptr ;
3345
+ }
3346
+
3347
+ std::shared_ptr<SaiObj> findCurrentBestMatchForGenericObjectUsingGraph (
3217
3348
_In_ const AsicView ¤tView,
3218
3349
_In_ const AsicView &temporaryView,
3219
3350
_In_ const std::shared_ptr<const SaiObj> &temporaryObj,
@@ -3253,10 +3384,31 @@ std::shared_ptr<SaiObj> findCurrentBestMatchForGenericObjectUsingHeuristic(
3253
3384
candidate = findCurrentBestMatchForAclTable (currentView, temporaryView, temporaryObj, candidateObjects);
3254
3385
break ;
3255
3386
3387
+ case SAI_OBJECT_TYPE_BUFFER_POOL:
3388
+ candidate = findCurrentBestMatchForBufferPool (currentView, temporaryView, temporaryObj, candidateObjects);
3389
+ break ;
3390
+
3256
3391
default :
3257
3392
break ;
3258
3393
}
3259
3394
3395
+ return candidate;
3396
+ }
3397
+
3398
+ std::shared_ptr<SaiObj> findCurrentBestMatchForGenericObjectUsingHeuristic (
3399
+ _In_ const AsicView ¤tView,
3400
+ _In_ const AsicView &temporaryView,
3401
+ _In_ const std::shared_ptr<const SaiObj> &temporaryObj,
3402
+ _In_ const std::vector<sai_object_compare_info_t > &candidateObjects)
3403
+ {
3404
+ SWSS_LOG_ENTER ();
3405
+
3406
+ std::shared_ptr<SaiObj> candidate = findCurrentBestMatchForGenericObjectUsingGraph (
3407
+ currentView,
3408
+ temporaryView,
3409
+ temporaryObj,
3410
+ candidateObjects);
3411
+
3260
3412
if (candidate != nullptr )
3261
3413
return candidate;
3262
3414
@@ -3613,6 +3765,23 @@ std::shared_ptr<SaiObj> findCurrentBestMatchForGenericObject(
3613
3765
* current view.
3614
3766
*/
3615
3767
3768
+ /*
3769
+ * But at this point also let's try find best candidate using graph paths,
3770
+ * since if some attributes are missmatched (like for example more ACLs are
3771
+ * created) this can lead to choose wrong LAG and have implications on
3772
+ * router interface and so on. So matching by graph path here could be
3773
+ * more precise.
3774
+ */
3775
+
3776
+ auto graphCandidate = findCurrentBestMatchForGenericObjectUsingGraph (
3777
+ currentView,
3778
+ temporaryView,
3779
+ temporaryObj,
3780
+ candidateObjects);
3781
+
3782
+ if (graphCandidate != nullptr )
3783
+ return graphCandidate;
3784
+
3616
3785
/*
3617
3786
* Sort candidate objects by equal attributes in descending order, we know
3618
3787
* here that we have at least 2 candidates.
@@ -6230,7 +6399,7 @@ void populateExistingObjects(
6230
6399
* objects on default existing objects, like for example buffer profile
6231
6400
* on ingress priority group. In this case buffer profile should not
6232
6401
* be considered as matched object and copied to temporary view, since
6233
- * this object was not decault existing object (on 1st cold boot) so in
6402
+ * this object was not default existing object (on 1st cold boot) so in
6234
6403
* this case it must be processed by comparison logic and matched with
6235
6404
* possible new buffer profile created in temporary view. This may
6236
6405
* happen if OA will not care what was set previously on ingress
@@ -6372,6 +6541,38 @@ void updateRedisDatabase(
6372
6541
SWSS_LOG_NOTICE (" updated redis database" );
6373
6542
}
6374
6543
6544
+ void logViewObjectCount (
6545
+ _In_ const AsicView ¤tView,
6546
+ _In_ const AsicView &temporaryView)
6547
+ {
6548
+ SWSS_LOG_ENTER ();
6549
+
6550
+ bool asic_changes = false ;
6551
+
6552
+ for (int i = SAI_OBJECT_TYPE_NULL + 1 ; i < SAI_OBJECT_TYPE_MAX; i++)
6553
+ {
6554
+ sai_object_type_t ot = (sai_object_type_t )i;
6555
+
6556
+ size_t c = currentView.getObjectsByObjectType (ot).size ();
6557
+ size_t t = temporaryView.getObjectsByObjectType (ot).size ();
6558
+
6559
+ if (c == t)
6560
+ continue ;
6561
+
6562
+ asic_changes = true ;
6563
+
6564
+ SWSS_LOG_WARN (" object count for %s on current view %zu is differnt than on temporary view: %zu" ,
6565
+ sai_serialize_object_type (ot).c_str (),
6566
+ c,
6567
+ t);
6568
+ }
6569
+
6570
+ if (asic_changes)
6571
+ {
6572
+ SWSS_LOG_WARN (" object count is differnt on both view, there will be ASIC OPERATIONS!" );
6573
+ }
6574
+ }
6575
+
6375
6576
sai_status_t syncdApplyView ()
6376
6577
{
6377
6578
SWSS_LOG_ENTER ();
@@ -6512,6 +6713,8 @@ sai_status_t syncdApplyView()
6512
6713
temp.dumpRef (" temp START" );
6513
6714
}
6514
6715
6716
+ logViewObjectCount (current, temp);
6717
+
6515
6718
applyViewTransition (current, temp);
6516
6719
6517
6720
SWSS_LOG_NOTICE (" ASIC operations to execute: %zu" , current.asicGetOperationsCount ());
0 commit comments