Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 63 additions & 12 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4014,6 +4014,19 @@ void PortsOrch::registerPort(Port &p)
auto wred_port_stats = generateCounterStats(wred_port_stat_ids, sai_serialize_port_stat);
wred_port_stat_manager.setCounterIdList(p.m_port_id, CounterType::PORT, wred_port_stats);
}
//Add the Queue Counters
if ((flex_counters_orch->getQueueCountersState()) || (flex_counters_orch->getQueueWatermarkCountersState()))
{
auto maxQueueNumber = static_cast<uint32_t>(p.m_queue_ids.size());
addPortBufferQueueCounters(p, 0, maxQueueNumber-1, false);
}

//Add the PG Counters
if ((flex_counters_orch->getPgCountersState()) || (flex_counters_orch->getPgWatermarkCountersState()))
{
auto maxPgNumber = static_cast<uint32_t>(p.m_priority_group_ids.size());
addPortBufferPgCounters(p, 0, maxPgNumber-1);
}

PortUpdate update = { p, true };
notify(SUBJECT_TYPE_PORT_CHANGE, static_cast<void *>(&update));
Expand Down Expand Up @@ -4062,6 +4075,20 @@ void PortsOrch::deInitPort(string alias, sai_object_id_t port_id)
/* remove port name map from counter table */
m_counterNameMapUpdater->delCounterNameMap(alias);

if((flex_counters_orch->getQueueCountersState()) || (flex_counters_orch->getQueueWatermarkCountersState()))
{
// Remove the Port Queues from COUNTERS_DB
auto maxQueueNumber = static_cast<uint32_t>(p.m_queue_ids.size());
deletePortBufferQueueCounters(p, 0, maxQueueNumber-1, false);
}

if ((flex_counters_orch->getPgCountersState()) || (flex_counters_orch->getPgWatermarkCountersState()))
{
// Remove the Priority Groups from COUNTERS_DB
auto maxPgNumber = static_cast<uint32_t>(p.m_priority_group_ids.size());
deletePortBufferPgCounters(p, 0, maxPgNumber-1);
}

/* Remove the associated port serdes attribute */
removePortSerdesAttribute(p.m_port_id);

Expand Down Expand Up @@ -8292,19 +8319,25 @@ void PortsOrch::createPortBufferQueueCounters(const Port &port, string queues, b
{
SWSS_LOG_ENTER();

/* Create the Queue map in the Counter DB */
vector<FieldValueTuple> queueVector;
vector<FieldValueTuple> queuePortVector;
vector<FieldValueTuple> queueIndexVector;
vector<FieldValueTuple> queueTypeVector;

auto toks = tokenize(queues, '-');
auto startIndex = to_uint<uint32_t>(toks[0]);
auto endIndex = startIndex;
if (toks.size() > 1)
{
endIndex = to_uint<uint32_t>(toks[1]);
}
addPortBufferQueueCounters(port, startIndex, endIndex, skip_host_tx_queue);
}

void PortsOrch::addPortBufferQueueCounters(const Port &port, uint32_t startIndex, uint32_t endIndex, bool skip_host_tx_queue)
{
SWSS_LOG_ENTER();

/* Create the Queue map in the Counter DB */
vector<FieldValueTuple> queueVector;
vector<FieldValueTuple> queuePortVector;
vector<FieldValueTuple> queueIndexVector;
vector<FieldValueTuple> queueTypeVector;

for (auto queueIndex = startIndex; queueIndex <= endIndex; queueIndex++)
{
Expand Down Expand Up @@ -8369,6 +8402,12 @@ void PortsOrch::removePortBufferQueueCounters(const Port &port, string queues, b
{
endIndex = to_uint<uint32_t>(toks[1]);
}
deletePortBufferQueueCounters(port, startIndex, endIndex, skip_host_tx_queue);
}

void PortsOrch::deletePortBufferQueueCounters(const Port &port, uint32_t startIndex, uint32_t endIndex, bool skip_host_tx_queue)
{
SWSS_LOG_ENTER();

for (auto queueIndex = startIndex; queueIndex <= endIndex; queueIndex++)
{
Expand Down Expand Up @@ -8486,19 +8525,25 @@ void PortsOrch::createPortBufferPgCounters(const Port& port, string pgs)
{
SWSS_LOG_ENTER();

/* Create the PG map in the Counter DB */
/* Add stat counters to flex_counter */
vector<FieldValueTuple> pgVector;
vector<FieldValueTuple> pgPortVector;
vector<FieldValueTuple> pgIndexVector;

auto toks = tokenize(pgs, '-');
auto startIndex = to_uint<uint32_t>(toks[0]);
auto endIndex = startIndex;
if (toks.size() > 1)
{
endIndex = to_uint<uint32_t>(toks[1]);
}
addPortBufferPgCounters(port, startIndex, endIndex);
}

void PortsOrch::addPortBufferPgCounters(const Port& port, uint32_t startIndex, uint32_t endIndex)
{
SWSS_LOG_ENTER();

/* Create the PG map in the Counter DB */
/* Add stat counters to flex_counter */
vector<FieldValueTuple> pgVector;
vector<FieldValueTuple> pgPortVector;
vector<FieldValueTuple> pgIndexVector;

for (auto pgIndex = startIndex; pgIndex <= endIndex; pgIndex++)
{
Expand Down Expand Up @@ -8654,6 +8699,12 @@ void PortsOrch::removePortBufferPgCounters(const Port& port, string pgs)
{
endIndex = to_uint<uint32_t>(toks[1]);
}
deletePortBufferPgCounters(port, startIndex, endIndex);
}

void PortsOrch::deletePortBufferPgCounters(const Port& port, uint32_t startIndex, uint32_t endIndex)
{
SWSS_LOG_ENTER();

for (auto pgIndex = startIndex; pgIndex <= endIndex; pgIndex++)
{
Expand Down
4 changes: 4 additions & 0 deletions orchagent/portsorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,15 +191,19 @@ class PortsOrch : public Orch, public Subject
void generateQueueMap(map<string, FlexCounterQueueStates> queuesStateVector);
uint32_t getNumberOfPortSupportedQueueCounters(string port);
void createPortBufferQueueCounters(const Port &port, string queues, bool skip_host_tx_queue=true);
void addPortBufferQueueCounters(const Port &port, uint32_t startIndex, uint32_t endIndex, bool skip_host_tx_queue=true);
void removePortBufferQueueCounters(const Port &port, string queues, bool skip_host_tx_queue=true);
void deletePortBufferQueueCounters(const Port &port, uint32_t startIndex, uint32_t endIndex, bool skip_host_tx_queue=true);
void addQueueFlexCounters(map<string, FlexCounterQueueStates> queuesStateVector);
void addQueueWatermarkFlexCounters(map<string, FlexCounterQueueStates> queuesStateVector);
void addWredQueueFlexCounters(map<string, FlexCounterQueueStates> queuesStateVector);

void generatePriorityGroupMap(map<string, FlexCounterPgStates> pgsStateVector);
uint32_t getNumberOfPortSupportedPgCounters(string port);
void createPortBufferPgCounters(const Port &port, string pgs);
void addPortBufferPgCounters(const Port& port, uint32_t startIndex, uint32_t endIndex);
void removePortBufferPgCounters(const Port& port, string pgs);
void deletePortBufferPgCounters(const Port& port, uint32_t startIndex, uint32_t endIndex);
void addPriorityGroupFlexCounters(map<string, FlexCounterPgStates> pgsStateVector);
void addPriorityGroupWatermarkFlexCounters(map<string, FlexCounterPgStates> pgsStateVector);

Expand Down
Loading