@@ -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" );
@@ -1121,8 +1161,8 @@ void ComparisonLogic::updateObjectStatus(
1121
1161
bool ComparisonLogic::performObjectSetTransition (
1122
1162
_In_ AsicView ¤tView,
1123
1163
_In_ AsicView &temporaryView,
1124
- _In_ const std::shared_ptr<SaiObj> & currentBestMatch,
1125
- _In_ const std::shared_ptr<const SaiObj> & temporaryObj,
1164
+ _In_ const std::shared_ptr<SaiObj> currentBestMatch,
1165
+ _In_ std::shared_ptr<SaiObj> temporaryObj,
1126
1166
_In_ bool performTransition)
1127
1167
{
1128
1168
SWSS_LOG_ENTER ();
@@ -1382,6 +1422,8 @@ bool ComparisonLogic::performObjectSetTransition(
1382
1422
return false ;
1383
1423
}
1384
1424
1425
+ const bool beginTempSizeZero = temporaryObj->getAllAttributes ().size () == 0 ;
1426
+
1385
1427
/*
1386
1428
* Current best match can have more attributes than temporary object.
1387
1429
* let see if we can bring them to default value if possible.
@@ -1526,14 +1568,38 @@ bool ComparisonLogic::performObjectSetTransition(
1526
1568
continue ;
1527
1569
}
1528
1570
1529
- // SAI_QUEUE_ATTR_PARENT_SCHEDULER_NODE
1530
- // SAI_SCHEDULER_GROUP_ATTR_SCHEDULER_PROFILE_ID*
1531
- // SAI_SCHEDULER_GROUP_ATTR_PARENT_NODE
1532
- // SAI_BRIDGE_PORT_ATTR_BRIDGE_ID
1533
- //
1534
- // TODO matched by ID (MATCHED state) should always be updatable
1535
- // except those 4 above (at least for those above since they can have
1536
- // default value present after switch creation
1571
+ // current best match is MATCHED
1572
+
1573
+ // auto vid = currentBestMatch->getVid();
1574
+
1575
+ // TODO don't transfer oid attributes, we don't know how to handle this yet
1576
+ // If OA did GET on any attributes, snoop in syncd should catch that and write
1577
+ // to database so we would have some attributes here.
1578
+
1579
+ if (beginTempSizeZero && !meta->isoidattribute )
1580
+ {
1581
+ SWSS_LOG_WARN (" current attr is MoC|CaS and object is MATCHED: %s transferring %s:%s to temp object (was empty)" ,
1582
+ currentBestMatch->m_str_object_id .c_str (),
1583
+ meta->attridname ,
1584
+ currentAttr->getStrAttrValue ().c_str ());
1585
+
1586
+ std::shared_ptr<SaiAttr> transferedAttr = std::make_shared<SaiAttr>(
1587
+ currentAttr->getStrAttrId (),
1588
+ currentAttr->getStrAttrValue ());
1589
+
1590
+ temporaryObj->setAttr (transferedAttr);
1591
+
1592
+ continue ;
1593
+ }
1594
+
1595
+ // SAI_QUEUE_ATTR_PARENT_SCHEDULER_NODE
1596
+ // SAI_SCHEDULER_GROUP_ATTR_SCHEDULER_PROFILE_ID*
1597
+ // SAI_SCHEDULER_GROUP_ATTR_PARENT_NODE
1598
+ // SAI_BRIDGE_PORT_ATTR_BRIDGE_ID
1599
+ //
1600
+ // TODO matched by ID (MATCHED state) should always be updatable
1601
+ // except those 4 above (at least for those above since they can have
1602
+ // default value present after switch creation
1537
1603
1538
1604
// TODO SAI_SCHEDULER_GROUP_ATTR_SCHEDULER_PROFILE_ID is mandatory on create but also SET
1539
1605
// if attribute is set we and object is in MATCHED state then that means we are able to
@@ -1567,6 +1633,21 @@ bool ComparisonLogic::performObjectSetTransition(
1567
1633
meta->attridname ,
1568
1634
currentAttr->getStrAttrValue ().c_str ());
1569
1635
1636
+ // don't produce too much noise for queues
1637
+ if (currentAttr->getStrAttrId () != " SAI_QUEUE_ATTR_TYPE" )
1638
+ {
1639
+ SWSS_LOG_WARN (" current attr is CREATE_ONLY and object is MATCHED: %s transferring %s:%s to temp object" ,
1640
+ currentBestMatch->m_str_object_id .c_str (),
1641
+ meta->attridname ,
1642
+ currentAttr->getStrAttrValue ().c_str ());
1643
+ }
1644
+
1645
+ std::shared_ptr<SaiAttr> transferedAttr = std::make_shared<SaiAttr>(
1646
+ currentAttr->getStrAttrId (),
1647
+ currentAttr->getStrAttrValue ());
1648
+
1649
+ temporaryObj->setAttr (transferedAttr);
1650
+
1570
1651
continue ;
1571
1652
}
1572
1653
}
@@ -1705,7 +1786,7 @@ bool ComparisonLogic::performObjectSetTransition(
1705
1786
void ComparisonLogic::processObjectForViewTransition (
1706
1787
_In_ AsicView ¤tView,
1707
1788
_In_ AsicView &temporaryView,
1708
- _In_ const std::shared_ptr<SaiObj> & temporaryObj)
1789
+ _Inout_ std::shared_ptr<SaiObj> temporaryObj)
1709
1790
{
1710
1791
SWSS_LOG_ENTER ();
1711
1792
@@ -2269,6 +2350,10 @@ void ComparisonLogic::populateExistingObjects(
2269
2350
2270
2351
if (temporaryView.hasRid (rid))
2271
2352
{
2353
+ SWSS_LOG_INFO (" temporary view has existing %s RID %s" ,
2354
+ sai_serialize_object_type (m_vendorSai->objectTypeQuery (rid)).c_str (),
2355
+ sai_serialize_object_id (rid).c_str ());
2356
+
2272
2357
continue ;
2273
2358
}
2274
2359
@@ -2291,6 +2376,11 @@ void ComparisonLogic::populateExistingObjects(
2291
2376
* from current view as well.
2292
2377
*/
2293
2378
2379
+ SWSS_LOG_INFO (" object was removed in init view: %s RID %s VID %s" ,
2380
+ sai_serialize_object_type (m_vendorSai->objectTypeQuery (rid)).c_str (),
2381
+ sai_serialize_object_id (rid).c_str (),
2382
+ sai_serialize_object_id (vid).c_str ());
2383
+
2294
2384
continue ;
2295
2385
}
2296
2386
@@ -2726,6 +2816,79 @@ void ComparisonLogic::createPreMatchMap(
2726
2816
count);
2727
2817
}
2728
2818
2819
+ void ComparisonLogic::transferNotProcessed (
2820
+ _In_ AsicView& current,
2821
+ _In_ AsicView& temp)
2822
+ {
2823
+ SWSS_LOG_ENTER ();
2824
+
2825
+ SWSS_LOG_NOTICE (" calling transferNotProcessed" );
2826
+
2827
+ /*
2828
+ * It may happen that after performing view transition, some objects will
2829
+ * not be processed. This may happen is scenario where buffer pool is
2830
+ * assigned to buffer profile, and then buffer profile is assigned to
2831
+ * queue. If OA will query only for oid for that buffer profile, then
2832
+ * buffer pool will not be processed. Normally if it would be removed by
2833
+ * comparison logic. More on this issue can be found on github:
2834
+ * https://github.com/Azure/sonic-sairedis/issues/899
2835
+ *
2836
+ * So what we will do, we will transfer all not processed objects to
2837
+ * temporary view with the same RID and VID. If nothing will happen to them,
2838
+ * they will stay there until next warm boot where they will be removed.
2839
+ */
2840
+
2841
+ /*
2842
+ * We need a loop (or recursion) since not processed objects may have oid
2843
+ * attributes as well.
2844
+ */
2845
+
2846
+ while (current.getAllNotProcessedObjects ().size ())
2847
+ {
2848
+ SWSS_LOG_WARN (" we have %zu not processed objects on current view, moving to temp view" , current.getAllNotProcessedObjects ().size ());
2849
+
2850
+ for (const auto & obj: current.getAllNotProcessedObjects ())
2851
+ {
2852
+ auto vid = obj->getVid ();
2853
+
2854
+ auto rid = current.m_vidToRid .at (vid);
2855
+
2856
+ /*
2857
+ * We should have only oid objects here, since all non oid objects
2858
+ * are leafs in graph and has been removed.
2859
+ */
2860
+
2861
+ auto tmp = temp.createDummyExistingObject (rid, vid);
2862
+
2863
+ /*
2864
+ * Move both objects to matched state since match oids was already
2865
+ * called, and here we created some new objects that should be matched.
2866
+ */
2867
+
2868
+ current.m_oOids .at (vid)->setObjectStatus (SAI_OBJECT_STATUS_FINAL);
2869
+ temp.m_oOids .at (vid)->setObjectStatus (SAI_OBJECT_STATUS_FINAL);
2870
+
2871
+ SWSS_LOG_WARN (" moved %s VID %s RID %s to temporary view, and marked FINAL" ,
2872
+ obj->m_str_object_type .c_str (),
2873
+ obj->m_str_object_id .c_str (),
2874
+ sai_serialize_object_id (rid).c_str ());
2875
+
2876
+ for (auto & kvp: obj->getAllAttributes ())
2877
+ {
2878
+ auto & sh = kvp.second ;
2879
+
2880
+ auto attr = std::make_shared<SaiAttr>(sh->getStrAttrId (), sh->getStrAttrValue ());
2881
+
2882
+ tmp->setAttr (attr);
2883
+
2884
+ SWSS_LOG_WARN (" * with attr: %s: %s" ,
2885
+ sh->getStrAttrId ().c_str (),
2886
+ sh->getStrAttrValue ().c_str ());
2887
+ }
2888
+
2889
+ }
2890
+ }
2891
+ }
2729
2892
2730
2893
void ComparisonLogic::applyViewTransition (
2731
2894
_In_ AsicView ¤t,
0 commit comments