Skip to content

Commit

Permalink
[buffers] Add handler for create_all_available_buffers config db attr
Browse files Browse the repository at this point in the history
Signed-off-by: vadymhlushko-mlnx <vadymh@nvidia.com>
  • Loading branch information
vadymhlushko-mlnx committed Aug 29, 2023
1 parent b4fcfc9 commit b0f6e07
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 0 deletions.
40 changes: 40 additions & 0 deletions orchagent/flexcounterorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,14 @@ unordered_map<string, string> flexCounterGroupMap =
{"MACSEC_FLOW", COUNTERS_MACSEC_FLOW_GROUP},
};

static const std::string localhostStr = "localhost";

FlexCounterOrch::FlexCounterOrch(DBConnector *db, vector<string> &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)),
Expand Down Expand Up @@ -333,6 +335,25 @@ map<string, FlexCounterQueueStates> FlexCounterOrch::getQueueConfigurations()
SWSS_LOG_ENTER();

map<string, FlexCounterQueueStates> 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<std::string> portQueueKeys;
m_bufferQueueConfigTable.getKeys(portQueueKeys);

Expand Down Expand Up @@ -387,6 +408,25 @@ map<string, FlexCounterPgStates> FlexCounterOrch::getPgConfigurations()
SWSS_LOG_ENTER();

map<string, FlexCounterPgStates> 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<std::string> portPgKeys;
m_bufferPgConfigTable.getKeys(portPgKeys);

Expand Down
3 changes: 3 additions & 0 deletions orchagent/flexcounterorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ extern "C" {
#include "sai.h"
}

const std::string createAllAvailableBuffersStr = "create_all_available_buffers";

class FlexCounterQueueStates
{
public:
Expand Down Expand Up @@ -68,6 +70,7 @@ class FlexCounterOrch: public Orch
Table m_flexCounterConfigTable;
Table m_bufferQueueConfigTable;
Table m_bufferPgConfigTable;
Table m_deviceMetadataConfigTable;
};

#endif
76 changes: 76 additions & 0 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6324,6 +6324,14 @@ void PortsOrch::generateQueueMap(map<string, FlexCounterQueueStates> 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)
Expand All @@ -6332,6 +6340,10 @@ void PortsOrch::generateQueueMap(map<string, FlexCounterQueueStates> 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);
Expand All @@ -6347,6 +6359,10 @@ void PortsOrch::generateQueueMap(map<string, FlexCounterQueueStates> 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);
Expand Down Expand Up @@ -6450,6 +6466,14 @@ void PortsOrch::addQueueFlexCounters(map<string, FlexCounterQueueStates> 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)
Expand All @@ -6458,6 +6482,10 @@ void PortsOrch::addQueueFlexCounters(map<string, FlexCounterQueueStates> 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));
Expand Down Expand Up @@ -6515,6 +6543,14 @@ void PortsOrch::addQueueWatermarkFlexCounters(map<string, FlexCounterQueueStates
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)
Expand All @@ -6523,6 +6559,10 @@ void PortsOrch::addQueueWatermarkFlexCounters(map<string, FlexCounterQueueStates
{
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));
}
addQueueWatermarkFlexCountersPerPort(it.second, queuesStateVector.at(it.second.m_alias));
Expand Down Expand Up @@ -6686,6 +6726,14 @@ void PortsOrch::generatePriorityGroupMap(map<string, FlexCounterPgStates> 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)
Expand All @@ -6694,6 +6742,10 @@ void PortsOrch::generatePriorityGroupMap(map<string, FlexCounterPgStates> 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));
Expand Down Expand Up @@ -6790,6 +6842,14 @@ void PortsOrch::addPriorityGroupFlexCounters(map<string, FlexCounterPgStates> 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)
Expand All @@ -6798,6 +6858,10 @@ void PortsOrch::addPriorityGroupFlexCounters(map<string, FlexCounterPgStates> 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));
Expand Down Expand Up @@ -6847,6 +6911,14 @@ void PortsOrch::addPriorityGroupWatermarkFlexCounters(map<string, FlexCounterPgS
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)
Expand All @@ -6855,6 +6927,10 @@ void PortsOrch::addPriorityGroupWatermarkFlexCounters(map<string, FlexCounterPgS
{
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));
}
addPriorityGroupWatermarkFlexCountersPerPort(it.second, pgsStateVector.at(it.second.m_alias));
Expand Down

0 comments on commit b0f6e07

Please sign in to comment.