diff --git a/orchagent/flexcounterorch.cpp b/orchagent/flexcounterorch.cpp index a48bd9ceb7..cba69946ac 100644 --- a/orchagent/flexcounterorch.cpp +++ b/orchagent/flexcounterorch.cpp @@ -61,12 +61,14 @@ unordered_map flexCounterGroupMap = {"MACSEC_FLOW", COUNTERS_MACSEC_FLOW_GROUP}, }; +static const std::string localhostStr = "localhost"; FlexCounterOrch::FlexCounterOrch(DBConnector *db, vector &tableNames): Orch(db, tableNames), m_flexCounterConfigTable(db, CFG_FLEX_COUNTER_TABLE_NAME), m_bufferQueueConfigTable(db, CFG_BUFFER_QUEUE_TABLE_NAME), m_bufferPgConfigTable(db, CFG_BUFFER_PG_TABLE_NAME), + m_deviceMetadataConfigTable(db, CFG_DEVICE_METADATA_TABLE_NAME), m_flexCounterDb(new DBConnector("FLEX_COUNTER_DB", 0)), m_flexCounterGroupTable(new ProducerTable(m_flexCounterDb.get(), FLEX_COUNTER_GROUP_TABLE)), m_gbflexCounterDb(new DBConnector("GB_FLEX_COUNTER_DB", 0)), @@ -333,6 +335,25 @@ map FlexCounterOrch::getQueueConfigurations() SWSS_LOG_ENTER(); map queuesStateVector; + std::string createAllAvailableBuffersValue; + + try + { + if (m_deviceMetadataConfigTable.hget(localhostStr, createAllAvailableBuffersStr, createAllAvailableBuffersValue)) + { + if (createAllAvailableBuffersValue == "true") + { + FlexCounterQueueStates flexCounterQueueState(0); + queuesStateVector.insert(make_pair(createAllAvailableBuffersStr, flexCounterQueueState)); + return queuesStateVector; + } + } + } + catch(const std::system_error& e) + { + SWSS_LOG_ERROR("System error: %s", e.what()); + } + std::vector portQueueKeys; m_bufferQueueConfigTable.getKeys(portQueueKeys); @@ -387,6 +408,25 @@ map FlexCounterOrch::getPgConfigurations() SWSS_LOG_ENTER(); map pgsStateVector; + std::string createAllAvailableBuffersValue; + + try + { + if (m_deviceMetadataConfigTable.hget(localhostStr, createAllAvailableBuffersStr, createAllAvailableBuffersValue)) + { + if (createAllAvailableBuffersValue == "true") + { + FlexCounterPgStates flexCounterPgState(0); + pgsStateVector.insert(make_pair(createAllAvailableBuffersStr, flexCounterPgState)); + return pgsStateVector; + } + } + } + catch(const std::system_error& e) + { + SWSS_LOG_ERROR("System error: %s", e.what()); + } + std::vector portPgKeys; m_bufferPgConfigTable.getKeys(portPgKeys); diff --git a/orchagent/flexcounterorch.h b/orchagent/flexcounterorch.h index 6126588261..06a1ddadbc 100644 --- a/orchagent/flexcounterorch.h +++ b/orchagent/flexcounterorch.h @@ -10,6 +10,8 @@ extern "C" { #include "sai.h" } +const std::string createAllAvailableBuffersStr = "create_all_available_buffers"; + class FlexCounterQueueStates { public: @@ -68,6 +70,7 @@ class FlexCounterOrch: public Orch Table m_flexCounterConfigTable; Table m_bufferQueueConfigTable; Table m_bufferPgConfigTable; + Table m_deviceMetadataConfigTable; }; #endif diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index db1e45d499..88ef80a141 100755 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -6324,6 +6324,14 @@ void PortsOrch::generateQueueMap(map queuesState return; } + bool isCreateAllQueues = false; + + if (queuesStateVector.count(createAllAvailableBuffersStr)) + { + isCreateAllQueues = true; + queuesStateVector.clear(); + } + for (const auto& it: m_portList) { if (it.second.m_type == Port::PHY) @@ -6332,6 +6340,10 @@ void PortsOrch::generateQueueMap(map queuesState { auto maxQueueNumber = getNumberOfPortSupportedQueueCounters(it.second.m_alias); FlexCounterQueueStates flexCounterQueueState(maxQueueNumber); + if (isCreateAllQueues) + { + flexCounterQueueState.enableQueueCounters(0, maxQueueNumber - 1); + } queuesStateVector.insert(make_pair(it.second.m_alias, flexCounterQueueState)); } generateQueueMapPerPort(it.second, queuesStateVector.at(it.second.m_alias), false); @@ -6347,6 +6359,10 @@ void PortsOrch::generateQueueMap(map queuesState { auto maxQueueNumber = getNumberOfPortSupportedQueueCounters(it.second.m_alias); FlexCounterQueueStates flexCounterQueueState(maxQueueNumber); + if (isCreateAllQueues) + { + flexCounterQueueState.enableQueueCounters(0, maxQueueNumber - 1); + } queuesStateVector.insert(make_pair(it.second.m_alias, flexCounterQueueState)); } generateQueueMapPerPort(it.second, queuesStateVector.at(it.second.m_alias), true); @@ -6450,6 +6466,14 @@ void PortsOrch::addQueueFlexCounters(map queuesS return; } + bool isCreateAllQueues = false; + + if (queuesStateVector.count(createAllAvailableBuffersStr)) + { + isCreateAllQueues = true; + queuesStateVector.clear(); + } + for (const auto& it: m_portList) { if (it.second.m_type == Port::PHY) @@ -6458,6 +6482,10 @@ void PortsOrch::addQueueFlexCounters(map queuesS { auto maxQueueNumber = getNumberOfPortSupportedQueueCounters(it.second.m_alias); FlexCounterQueueStates flexCounterQueueState(maxQueueNumber); + if (isCreateAllQueues) + { + flexCounterQueueState.enableQueueCounters(0, maxQueueNumber - 1); + } queuesStateVector.insert(make_pair(it.second.m_alias, flexCounterQueueState)); } addQueueFlexCountersPerPort(it.second, queuesStateVector.at(it.second.m_alias)); @@ -6515,6 +6543,14 @@ void PortsOrch::addQueueWatermarkFlexCounters(map pgsSta return; } + bool isCreateAllPgs = false; + + if (pgsStateVector.count(createAllAvailableBuffersStr)) + { + isCreateAllPgs = true; + pgsStateVector.clear(); + } + for (const auto& it: m_portList) { if (it.second.m_type == Port::PHY) @@ -6694,6 +6742,10 @@ void PortsOrch::generatePriorityGroupMap(map pgsSta { auto maxPgNumber = getNumberOfPortSupportedPgCounters(it.second.m_alias); FlexCounterPgStates flexCounterPgState(maxPgNumber); + if (isCreateAllPgs) + { + flexCounterPgState.enablePgCounters(0, maxPgNumber - 1); + } pgsStateVector.insert(make_pair(it.second.m_alias, flexCounterPgState)); } generatePriorityGroupMapPerPort(it.second, pgsStateVector.at(it.second.m_alias)); @@ -6790,6 +6842,14 @@ void PortsOrch::addPriorityGroupFlexCounters(map pg return; } + bool isCreateAllPgs = false; + + if (pgsStateVector.count(createAllAvailableBuffersStr)) + { + isCreateAllPgs = true; + pgsStateVector.clear(); + } + for (const auto& it: m_portList) { if (it.second.m_type == Port::PHY) @@ -6798,6 +6858,10 @@ void PortsOrch::addPriorityGroupFlexCounters(map pg { auto maxPgNumber = getNumberOfPortSupportedPgCounters(it.second.m_alias); FlexCounterPgStates flexCounterPgState(maxPgNumber); + if (isCreateAllPgs) + { + flexCounterPgState.enablePgCounters(0, maxPgNumber - 1); + } pgsStateVector.insert(make_pair(it.second.m_alias, flexCounterPgState)); } addPriorityGroupFlexCountersPerPort(it.second, pgsStateVector.at(it.second.m_alias)); @@ -6847,6 +6911,14 @@ void PortsOrch::addPriorityGroupWatermarkFlexCounters(map