@@ -384,7 +384,7 @@ void BufferMgrDynamic::checkSharedBufferPoolSize()
384
384
if (m_firstTimeCalculateBufferPool)
385
385
{
386
386
// It's something like a placeholder especially for warm reboot flow
387
- // without all buffer pools created, buffer profiles are unable to be cureated ,
387
+ // without all buffer pools created, buffer profiles are unable to be created ,
388
388
// which in turn causes buffer pgs and buffer queues unable to be created,
389
389
// which prevents the port from being ready and eventually fails the warm reboot
390
390
// After the buffer pools are created for the first time, we won't touch it
@@ -435,14 +435,14 @@ void BufferMgrDynamic::updateBufferProfileToDb(const string &name, const buffer_
435
435
m_applBufferProfileTable.getTableNameSeparator () +
436
436
INGRESS_LOSSLESS_PG_POOL_NAME;
437
437
438
- fvVector.emplace_back (make_pair ( " xon" , profile.xon ) );
438
+ fvVector.emplace_back (" xon" , profile.xon );
439
439
if (!profile.xon_offset .empty ()) {
440
- fvVector.emplace_back (make_pair ( " xon_offset" , profile.xon_offset ) );
440
+ fvVector.emplace_back (" xon_offset" , profile.xon_offset );
441
441
}
442
- fvVector.emplace_back (make_pair ( " xoff" , profile.xoff ) );
443
- fvVector.emplace_back (make_pair ( " size" , profile.size ) );
444
- fvVector.emplace_back (make_pair ( " pool" , " [" + pg_pool_reference + " ]" ) );
445
- fvVector.emplace_back (make_pair ( mode, profile.threshold ) );
442
+ fvVector.emplace_back (" xoff" , profile.xoff );
443
+ fvVector.emplace_back (" size" , profile.size );
444
+ fvVector.emplace_back (" pool" , " [" + pg_pool_reference + " ]" );
445
+ fvVector.emplace_back (mode, profile.threshold );
446
446
447
447
m_applBufferProfileTable.set (name, fvVector);
448
448
m_stateBufferProfileTable.set (name, fvVector);
@@ -721,18 +721,20 @@ task_process_status BufferMgrDynamic::refreshPriorityGroupsForPort(const string
721
721
{
722
722
// Need to remove the reference to the old profile
723
723
// and create the reference to the new one
724
- m_bufferProfileLookup[oldProfile].port_pgs .erase (key);
725
724
m_bufferProfileLookup[newProfile].port_pgs .insert (key);
726
725
SWSS_LOG_INFO (" Move profile reference for %s from [%s] to [%s]" , key.c_str (), oldProfile.c_str (), newProfile.c_str ());
727
726
728
- // buffer pg needs to be updated as well
729
- portPg.running_profile_name = newProfile;
730
-
731
727
// Add the old profile to "to be removed" set
732
728
if (!oldProfile.empty ())
729
+ {
733
730
profilesToBeReleased.insert (oldProfile);
731
+ m_bufferProfileLookup[oldProfile].port_pgs .erase (key);
732
+ }
734
733
}
735
734
735
+ // buffer pg needs to be updated as well
736
+ portPg.running_profile_name = newProfile;
737
+
736
738
// appl_db Database operation: set item BUFFER_PG|<port>|<pg>
737
739
updateBufferPgToDb (key, newProfile, true );
738
740
isHeadroomUpdated = true ;
@@ -811,12 +813,6 @@ task_process_status BufferMgrDynamic::doUpdatePgTask(const string &pg_key, const
811
813
return task_process_status::task_success;
812
814
}
813
815
814
- if (bufferPg.static_configured && bufferPg.dynamic_calculated )
815
- {
816
- auto &profile = m_bufferProfileLookup[bufferPg.configured_profile_name ];
817
- profile.port_pgs .insert (pg_key);
818
- }
819
-
820
816
return task_process_status::task_success;
821
817
}
822
818
@@ -843,12 +839,6 @@ task_process_status BufferMgrDynamic::doRemovePgTask(const string &pg_key, const
843
839
SWSS_LOG_NOTICE (" try removing the original profile %s" , bufferPg.running_profile_name .c_str ());
844
840
releaseProfile (bufferPg.running_profile_name );
845
841
846
- if (bufferPg.static_configured && bufferPg.dynamic_calculated )
847
- {
848
- auto &profile = m_bufferProfileLookup[bufferPg.configured_profile_name ];
849
- profile.port_pgs .erase (pg_key);
850
- }
851
-
852
842
return task_process_status::task_success;
853
843
}
854
844
@@ -1099,15 +1089,18 @@ task_process_status BufferMgrDynamic::handlePortTable(KeyOpFieldsValuesTuple &tu
1099
1089
string &mtu = portInfo.mtu ;
1100
1090
string &speed = portInfo.speed ;
1101
1091
1102
- if (cable_length.empty () || speed.empty ())
1103
- {
1104
- SWSS_LOG_WARN (" Cable length for %s hasn't been configured yet, unable to calculate headroom" , port.c_str ());
1105
- // We don't retry here because it doesn't make sense until the cable length is configured.
1106
- return task_process_status::task_success;
1107
- }
1108
-
1109
1092
if (speed_updated || mtu_updated)
1110
1093
{
1094
+ if (cable_length.empty () || speed.empty ())
1095
+ {
1096
+ // we still need to update pool size when port with headroom override is shut down
1097
+ // even if its cable length or speed isn't configured
1098
+ // so cable length and speed isn't tested for shutdown
1099
+ SWSS_LOG_WARN (" Cable length for %s hasn't been configured yet, unable to calculate headroom" , port.c_str ());
1100
+ // We don't retry here because it doesn't make sense until the cable length is configured.
1101
+ return task_process_status::task_success;
1102
+ }
1103
+
1111
1104
SWSS_LOG_INFO (" Updating BUFFER_PG for port %s due to speed or port updated" , port.c_str ());
1112
1105
1113
1106
// Try updating the buffer information
@@ -1295,7 +1288,7 @@ task_process_status BufferMgrDynamic::handleBufferProfileTable(KeyOpFieldsValues
1295
1288
profileApp.ingress = true ;
1296
1289
}
1297
1290
}
1298
- fvVector.emplace_back (FieldValueTuple ( field, value) );
1291
+ fvVector.emplace_back (field, value);
1299
1292
SWSS_LOG_INFO (" Inserting BUFFER_PROFILE table field %s value %s" , field.c_str (), value.c_str ());
1300
1293
}
1301
1294
// don't insert dynamically calculated profiles into APPL_DB
@@ -1353,13 +1346,20 @@ task_process_status BufferMgrDynamic::handleBufferProfileTable(KeyOpFieldsValues
1353
1346
return task_process_status::task_invalid_entry;
1354
1347
}
1355
1348
}
1356
- }
1357
1349
1358
- m_applBufferProfileTable.del (profileName);
1359
- m_stateBufferProfileTable.del (profileName);
1350
+ if (!profile.static_configured || !profile.dynamic_calculated )
1351
+ {
1352
+ m_applBufferProfileTable.del (profileName);
1353
+ m_stateBufferProfileTable.del (profileName);
1354
+ }
1360
1355
1361
- m_bufferProfileLookup.erase (profileName);
1362
- m_bufferProfileIgnored.erase (profileName);
1356
+ m_bufferProfileLookup.erase (profileName);
1357
+ m_bufferProfileIgnored.erase (profileName);
1358
+ }
1359
+ else
1360
+ {
1361
+ SWSS_LOG_ERROR (" Profile %s not found while being removed" , profileName.c_str ());
1362
+ }
1363
1363
}
1364
1364
else
1365
1365
{
@@ -1387,6 +1387,12 @@ task_process_status BufferMgrDynamic::handleOneBufferPgEntry(const string &key,
1387
1387
1388
1388
bufferPg.dynamic_calculated = true ;
1389
1389
bufferPg.static_configured = false ;
1390
+ if (!bufferPg.configured_profile_name .empty ())
1391
+ {
1392
+ m_bufferProfileLookup[bufferPg.configured_profile_name ].port_pgs .erase (key);
1393
+ bufferPg.configured_profile_name = " " ;
1394
+ }
1395
+
1390
1396
for (auto i = kfvFieldsValues (tuple).begin (); i != kfvFieldsValues (tuple).end (); i++)
1391
1397
{
1392
1398
const string &field = fvField (*i);
@@ -1418,7 +1424,7 @@ task_process_status BufferMgrDynamic::handleOneBufferPgEntry(const string &key,
1418
1424
}
1419
1425
else
1420
1426
{
1421
- // In this case, we shouldn't set the dynamc calculated flat to true
1427
+ // In this case, we shouldn't set the dynamic calculated flag to true
1422
1428
// It will be updated when its profile configured.
1423
1429
bufferPg.dynamic_calculated = false ;
1424
1430
SWSS_LOG_WARN (" Profile %s hasn't been configured yet, skip" , profileName.c_str ());
@@ -1435,7 +1441,7 @@ task_process_status BufferMgrDynamic::handleOneBufferPgEntry(const string &key,
1435
1441
bufferPg.static_configured = true ;
1436
1442
bufferPg.configured_profile_name = profileName;
1437
1443
}
1438
- fvVector.emplace_back (FieldValueTuple ( field, value) );
1444
+ fvVector.emplace_back (field, value);
1439
1445
SWSS_LOG_INFO (" Inserting BUFFER_PG table field %s value %s" , field.c_str (), value.c_str ());
1440
1446
}
1441
1447
@@ -1449,6 +1455,11 @@ task_process_status BufferMgrDynamic::handleOneBufferPgEntry(const string &key,
1449
1455
if (!ignored && bufferPg.lossless )
1450
1456
{
1451
1457
doUpdatePgTask (key, port);
1458
+
1459
+ if (!bufferPg.configured_profile_name .empty ())
1460
+ {
1461
+ m_bufferProfileLookup[bufferPg.configured_profile_name ].port_pgs .insert (key);
1462
+ }
1452
1463
}
1453
1464
else
1454
1465
{
@@ -1464,6 +1475,10 @@ task_process_status BufferMgrDynamic::handleOneBufferPgEntry(const string &key,
1464
1475
string &profileName = bufferPg.running_profile_name ;
1465
1476
1466
1477
m_bufferProfileLookup[profileName].port_pgs .erase (key);
1478
+ if (!bufferPg.configured_profile_name .empty ())
1479
+ {
1480
+ m_bufferProfileLookup[bufferPg.configured_profile_name ].port_pgs .erase (key);
1481
+ }
1467
1482
1468
1483
if (bufferPg.lossless )
1469
1484
{
@@ -1589,7 +1604,7 @@ task_process_status BufferMgrDynamic::doBufferTableTask(KeyOpFieldsValuesTuple &
1589
1604
transformReference (fvValue (i));
1590
1605
if (fvField (i) == " profile_list" )
1591
1606
transformReference (fvValue (i));
1592
- fvVector.emplace_back (FieldValueTuple ( fvField (i), fvValue (i) ));
1607
+ fvVector.emplace_back (fvField (i), fvValue (i));
1593
1608
SWSS_LOG_INFO (" Inserting field %s value %s" , fvField (i).c_str (), fvValue (i).c_str ());
1594
1609
}
1595
1610
applTable.set (key, fvVector);
0 commit comments