@@ -122,6 +122,13 @@ void ComparisonLogic::compareViews()
122
122
123
123
applyViewTransition (current, temp);
124
124
125
+ transferNotProcessed (current, temp);
126
+
127
+ // TODO have a method to check for not processed objects
128
+ // and maybe add them to list on processing attributes
129
+ // and move note processed objects to temporary view as well
130
+ // we need to check oid attributes as well
131
+
125
132
SWSS_LOG_NOTICE (" ASIC operations to execute: %zu" , current.asicGetOperationsCount ());
126
133
127
134
temp.checkObjectsStatus ();
@@ -183,6 +190,8 @@ void ComparisonLogic::matchOids(
183
190
{
184
191
SWSS_LOG_ENTER ();
185
192
193
+ auto coldBootDiscoveredVids = m_switch->getColdBootDiscoveredVids ();
194
+
186
195
for (const auto &temporaryIt: temporaryView.m_oOids )
187
196
{
188
197
sai_object_id_t temporaryVid = temporaryIt.first ;
@@ -211,6 +220,37 @@ void ComparisonLogic::matchOids(
211
220
currentIt->second ->m_str_object_type .c_str (),
212
221
sai_serialize_object_id (rid).c_str (),
213
222
sai_serialize_object_id (vid).c_str ());
223
+
224
+ if (coldBootDiscoveredVids.find (vid) == coldBootDiscoveredVids.end ())
225
+ {
226
+ auto ot = currentIt->second ->getObjectType ();
227
+
228
+ switch (ot)
229
+ {
230
+ case SAI_OBJECT_TYPE_INGRESS_PRIORITY_GROUP:
231
+ case SAI_OBJECT_TYPE_SCHEDULER_GROUP:
232
+ case SAI_OBJECT_TYPE_QUEUE:
233
+ case SAI_OBJECT_TYPE_PORT:
234
+ break ;
235
+
236
+ default :
237
+
238
+ // Should we also add check if also not in removed?
239
+ // This is for case of only GET:
240
+ // 1. cold boot:
241
+ // - OA assigns buffer profile to Queue
242
+ // 2. warm boot:
243
+ // - OA do GET on Queue and got previous buffer profile
244
+ // - OA assigns new buffer profile on Queue
245
+ //
246
+ // Question: what should happen to old buffer profile? should it be removed?
247
+ // No, since OA still hold's the reference to that VID and may use it later.
248
+ SWSS_LOG_INFO (" matched %s VID %s was not in cold boot, possible only GET?" ,
249
+ sai_serialize_object_id (vid).c_str (),
250
+ currentIt->second ->m_str_object_type .c_str ());
251
+ break ;
252
+ }
253
+ }
214
254
}
215
255
216
256
SWSS_LOG_NOTICE (" matched oids" );
@@ -1125,8 +1165,8 @@ void ComparisonLogic::updateObjectStatus(
1125
1165
bool ComparisonLogic::performObjectSetTransition (
1126
1166
_In_ AsicView ¤tView,
1127
1167
_In_ AsicView &temporaryView,
1128
- _In_ const std::shared_ptr<SaiObj> & currentBestMatch,
1129
- _In_ const std::shared_ptr<const SaiObj> & temporaryObj,
1168
+ _In_ const std::shared_ptr<SaiObj> currentBestMatch,
1169
+ _In_ std::shared_ptr<SaiObj> temporaryObj,
1130
1170
_In_ bool performTransition)
1131
1171
{
1132
1172
SWSS_LOG_ENTER ();
@@ -1386,6 +1426,8 @@ bool ComparisonLogic::performObjectSetTransition(
1386
1426
return false ;
1387
1427
}
1388
1428
1429
+ const bool beginTempSizeZero = temporaryObj->getAllAttributes ().size () == 0 ;
1430
+
1389
1431
/*
1390
1432
* Current best match can have more attributes than temporary object.
1391
1433
* let see if we can bring them to default value if possible.
@@ -1530,14 +1572,38 @@ bool ComparisonLogic::performObjectSetTransition(
1530
1572
continue ;
1531
1573
}
1532
1574
1533
- // SAI_QUEUE_ATTR_PARENT_SCHEDULER_NODE
1534
- // SAI_SCHEDULER_GROUP_ATTR_SCHEDULER_PROFILE_ID*
1535
- // SAI_SCHEDULER_GROUP_ATTR_PARENT_NODE
1536
- // SAI_BRIDGE_PORT_ATTR_BRIDGE_ID
1537
- //
1538
- // TODO matched by ID (MATCHED state) should always be updatable
1539
- // except those 4 above (at least for those above since they can have
1540
- // default value present after switch creation
1575
+ // current best match is MATCHED
1576
+
1577
+ // auto vid = currentBestMatch->getVid();
1578
+
1579
+ // TODO don't transfer oid attributes, we don't know how to handle this yet
1580
+ // If OA did GET on any attributes, snoop in syncd should catch that and write
1581
+ // to database so we would have some attributes here.
1582
+
1583
+ if (beginTempSizeZero && !meta->isoidattribute )
1584
+ {
1585
+ SWSS_LOG_WARN (" current attr is MoC|CaS and object is MATCHED: %s transferring %s:%s to temp object (was empty)" ,
1586
+ currentBestMatch->m_str_object_id .c_str (),
1587
+ meta->attridname ,
1588
+ currentAttr->getStrAttrValue ().c_str ());
1589
+
1590
+ std::shared_ptr<SaiAttr> transferedAttr = std::make_shared<SaiAttr>(
1591
+ currentAttr->getStrAttrId (),
1592
+ currentAttr->getStrAttrValue ());
1593
+
1594
+ temporaryObj->setAttr (transferedAttr);
1595
+
1596
+ continue ;
1597
+ }
1598
+
1599
+ // SAI_QUEUE_ATTR_PARENT_SCHEDULER_NODE
1600
+ // SAI_SCHEDULER_GROUP_ATTR_SCHEDULER_PROFILE_ID*
1601
+ // SAI_SCHEDULER_GROUP_ATTR_PARENT_NODE
1602
+ // SAI_BRIDGE_PORT_ATTR_BRIDGE_ID
1603
+ //
1604
+ // TODO matched by ID (MATCHED state) should always be updatable
1605
+ // except those 4 above (at least for those above since they can have
1606
+ // default value present after switch creation
1541
1607
1542
1608
// TODO SAI_SCHEDULER_GROUP_ATTR_SCHEDULER_PROFILE_ID is mandatory on create but also SET
1543
1609
// if attribute is set we and object is in MATCHED state then that means we are able to
@@ -1571,6 +1637,21 @@ bool ComparisonLogic::performObjectSetTransition(
1571
1637
meta->attridname ,
1572
1638
currentAttr->getStrAttrValue ().c_str ());
1573
1639
1640
+ // don't produce too much noise for queues
1641
+ if (currentAttr->getStrAttrId () != " SAI_QUEUE_ATTR_TYPE" )
1642
+ {
1643
+ SWSS_LOG_WARN (" current attr is CREATE_ONLY and object is MATCHED: %s transferring %s:%s to temp object" ,
1644
+ currentBestMatch->m_str_object_id .c_str (),
1645
+ meta->attridname ,
1646
+ currentAttr->getStrAttrValue ().c_str ());
1647
+ }
1648
+
1649
+ std::shared_ptr<SaiAttr> transferedAttr = std::make_shared<SaiAttr>(
1650
+ currentAttr->getStrAttrId (),
1651
+ currentAttr->getStrAttrValue ());
1652
+
1653
+ temporaryObj->setAttr (transferedAttr);
1654
+
1574
1655
continue ;
1575
1656
}
1576
1657
}
@@ -1709,7 +1790,7 @@ bool ComparisonLogic::performObjectSetTransition(
1709
1790
void ComparisonLogic::processObjectForViewTransition (
1710
1791
_In_ AsicView ¤tView,
1711
1792
_In_ AsicView &temporaryView,
1712
- _In_ const std::shared_ptr<SaiObj> & temporaryObj)
1793
+ _Inout_ std::shared_ptr<SaiObj> temporaryObj)
1713
1794
{
1714
1795
SWSS_LOG_ENTER ();
1715
1796
@@ -2273,6 +2354,10 @@ void ComparisonLogic::populateExistingObjects(
2273
2354
2274
2355
if (temporaryView.hasRid (rid))
2275
2356
{
2357
+ SWSS_LOG_INFO (" temporary view has existing %s RID %s" ,
2358
+ sai_serialize_object_type (m_vendorSai->objectTypeQuery (rid)).c_str (),
2359
+ sai_serialize_object_id (rid).c_str ());
2360
+
2276
2361
continue ;
2277
2362
}
2278
2363
@@ -2295,6 +2380,11 @@ void ComparisonLogic::populateExistingObjects(
2295
2380
* from current view as well.
2296
2381
*/
2297
2382
2383
+ SWSS_LOG_INFO (" object was removed in init view: %s RID %s VID %s" ,
2384
+ sai_serialize_object_type (m_vendorSai->objectTypeQuery (rid)).c_str (),
2385
+ sai_serialize_object_id (rid).c_str (),
2386
+ sai_serialize_object_id (vid).c_str ());
2387
+
2298
2388
continue ;
2299
2389
}
2300
2390
@@ -2730,6 +2820,79 @@ void ComparisonLogic::createPreMatchMap(
2730
2820
count);
2731
2821
}
2732
2822
2823
+ void ComparisonLogic::transferNotProcessed (
2824
+ _In_ AsicView& current,
2825
+ _In_ AsicView& temp)
2826
+ {
2827
+ SWSS_LOG_ENTER ();
2828
+
2829
+ SWSS_LOG_NOTICE (" calling transferNotProcessed" );
2830
+
2831
+ /*
2832
+ * It may happen that after performing view transition, some objects will
2833
+ * not be processed. This may happen is scenario where buffer pool is
2834
+ * assigned to buffer profile, and then buffer profile is assigned to
2835
+ * queue. If OA will query only for oid for that buffer profile, then
2836
+ * buffer pool will not be processed. Normally if it would be removed by
2837
+ * comparison logic. More on this issue can be found on github:
2838
+ * https://github.com/Azure/sonic-sairedis/issues/899
2839
+ *
2840
+ * So what we will do, we will transfer all not processed objects to
2841
+ * temporary view with the same RID and VID. If nothing will happen to them,
2842
+ * they will stay there until next warm boot where they will be removed.
2843
+ */
2844
+
2845
+ /*
2846
+ * We need a loop (or recursion) since not processed objects may have oid
2847
+ * attributes as well.
2848
+ */
2849
+
2850
+ while (current.getAllNotProcessedObjects ().size ())
2851
+ {
2852
+ SWSS_LOG_WARN (" we have %zu not processed objects on current view, moving to temp view" , current.getAllNotProcessedObjects ().size ());
2853
+
2854
+ for (const auto & obj: current.getAllNotProcessedObjects ())
2855
+ {
2856
+ auto vid = obj->getVid ();
2857
+
2858
+ auto rid = current.m_vidToRid .at (vid);
2859
+
2860
+ /*
2861
+ * We should have only oid objects here, since all non oid objects
2862
+ * are leafs in graph and has been removed.
2863
+ */
2864
+
2865
+ auto tmp = temp.createDummyExistingObject (rid, vid);
2866
+
2867
+ /*
2868
+ * Move both objects to matched state since match oids was already
2869
+ * called, and here we created some new objects that should be matched.
2870
+ */
2871
+
2872
+ current.m_oOids .at (vid)->setObjectStatus (SAI_OBJECT_STATUS_FINAL);
2873
+ temp.m_oOids .at (vid)->setObjectStatus (SAI_OBJECT_STATUS_FINAL);
2874
+
2875
+ SWSS_LOG_WARN (" moved %s VID %s RID %s to temporary view, and marked FINAL" ,
2876
+ obj->m_str_object_type .c_str (),
2877
+ obj->m_str_object_id .c_str (),
2878
+ sai_serialize_object_id (rid).c_str ());
2879
+
2880
+ for (auto & kvp: obj->getAllAttributes ())
2881
+ {
2882
+ auto & sh = kvp.second ;
2883
+
2884
+ auto attr = std::make_shared<SaiAttr>(sh->getStrAttrId (), sh->getStrAttrValue ());
2885
+
2886
+ tmp->setAttr (attr);
2887
+
2888
+ SWSS_LOG_WARN (" * with attr: %s: %s" ,
2889
+ sh->getStrAttrId ().c_str (),
2890
+ sh->getStrAttrValue ().c_str ());
2891
+ }
2892
+
2893
+ }
2894
+ }
2895
+ }
2733
2896
2734
2897
void ComparisonLogic::applyViewTransition (
2735
2898
_In_ AsicView ¤t,
0 commit comments