Skip to content

Commit d402386

Browse files
Update the COUNTER_DB with the new Port Object-Id when the Port is removed and created when the Port Speed is changed dynamically via GCU
Signed-off-by: saksarav <[email protected]>
1 parent 0e1558e commit d402386

File tree

2 files changed

+67
-12
lines changed

2 files changed

+67
-12
lines changed

orchagent/portsorch.cpp

Lines changed: 63 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4014,6 +4014,19 @@ void PortsOrch::registerPort(Port &p)
40144014
auto wred_port_stats = generateCounterStats(wred_port_stat_ids, sai_serialize_port_stat);
40154015
wred_port_stat_manager.setCounterIdList(p.m_port_id, CounterType::PORT, wred_port_stats);
40164016
}
4017+
//Add the Queue Counters
4018+
if ((flex_counters_orch->getQueueCountersState()) || (flex_counters_orch->getQueueWatermarkCountersState()))
4019+
{
4020+
auto maxQueueNumber = static_cast<uint32_t>(p.m_queue_ids.size());
4021+
addPortBufferQueueCounters(p, 0, maxQueueNumber-1, false);
4022+
}
4023+
4024+
//Add the PG Counters
4025+
if ((flex_counters_orch->getPgCountersState()) || (flex_counters_orch->getPgWatermarkCountersState()))
4026+
{
4027+
auto maxPgNumber = static_cast<uint32_t>(p.m_priority_group_ids.size());
4028+
addPortBufferPgCounters(p, 0, maxPgNumber-1);
4029+
}
40174030

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

4078+
if((flex_counters_orch->getQueueCountersState()) || (flex_counters_orch->getQueueWatermarkCountersState()))
4079+
{
4080+
// Remove the Port Queues from COUNTERS_DB
4081+
auto maxQueueNumber = static_cast<uint32_t>(p.m_queue_ids.size());
4082+
deletePortBufferQueueCounters(p, 0, maxQueueNumber-1, false);
4083+
}
4084+
4085+
if ((flex_counters_orch->getPgCountersState()) || (flex_counters_orch->getPgWatermarkCountersState()))
4086+
{
4087+
// Remove the Priority Groups from COUNTERS_DB
4088+
auto maxPgNumber = static_cast<uint32_t>(p.m_priority_group_ids.size());
4089+
deletePortBufferPgCounters(p, 0, maxPgNumber-1);
4090+
}
4091+
40654092
/* Remove the associated port serdes attribute */
40664093
removePortSerdesAttribute(p.m_port_id);
40674094

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

8295-
/* Create the Queue map in the Counter DB */
8296-
vector<FieldValueTuple> queueVector;
8297-
vector<FieldValueTuple> queuePortVector;
8298-
vector<FieldValueTuple> queueIndexVector;
8299-
vector<FieldValueTuple> queueTypeVector;
8300-
83018322
auto toks = tokenize(queues, '-');
83028323
auto startIndex = to_uint<uint32_t>(toks[0]);
83038324
auto endIndex = startIndex;
83048325
if (toks.size() > 1)
83058326
{
83068327
endIndex = to_uint<uint32_t>(toks[1]);
83078328
}
8329+
addPortBufferQueueCounters(port, startIndex, endIndex, skip_host_tx_queue);
8330+
}
8331+
8332+
void PortsOrch::addPortBufferQueueCounters(const Port &port, uint32_t startIndex, uint32_t endIndex, bool skip_host_tx_queue)
8333+
{
8334+
SWSS_LOG_ENTER();
8335+
8336+
/* Create the Queue map in the Counter DB */
8337+
vector<FieldValueTuple> queueVector;
8338+
vector<FieldValueTuple> queuePortVector;
8339+
vector<FieldValueTuple> queueIndexVector;
8340+
vector<FieldValueTuple> queueTypeVector;
83088341

83098342
for (auto queueIndex = startIndex; queueIndex <= endIndex; queueIndex++)
83108343
{
@@ -8369,6 +8402,12 @@ void PortsOrch::removePortBufferQueueCounters(const Port &port, string queues, b
83698402
{
83708403
endIndex = to_uint<uint32_t>(toks[1]);
83718404
}
8405+
deletePortBufferQueueCounters(port, startIndex, endIndex, skip_host_tx_queue);
8406+
}
8407+
8408+
void PortsOrch::deletePortBufferQueueCounters(const Port &port, uint32_t startIndex, uint32_t endIndex, bool skip_host_tx_queue)
8409+
{
8410+
SWSS_LOG_ENTER();
83728411

83738412
for (auto queueIndex = startIndex; queueIndex <= endIndex; queueIndex++)
83748413
{
@@ -8486,19 +8525,25 @@ void PortsOrch::createPortBufferPgCounters(const Port& port, string pgs)
84868525
{
84878526
SWSS_LOG_ENTER();
84888527

8489-
/* Create the PG map in the Counter DB */
8490-
/* Add stat counters to flex_counter */
8491-
vector<FieldValueTuple> pgVector;
8492-
vector<FieldValueTuple> pgPortVector;
8493-
vector<FieldValueTuple> pgIndexVector;
8494-
84958528
auto toks = tokenize(pgs, '-');
84968529
auto startIndex = to_uint<uint32_t>(toks[0]);
84978530
auto endIndex = startIndex;
84988531
if (toks.size() > 1)
84998532
{
85008533
endIndex = to_uint<uint32_t>(toks[1]);
85018534
}
8535+
addPortBufferPgCounters(port, startIndex, endIndex);
8536+
}
8537+
8538+
void PortsOrch::addPortBufferPgCounters(const Port& port, uint32_t startIndex, uint32_t endIndex)
8539+
{
8540+
SWSS_LOG_ENTER();
8541+
8542+
/* Create the PG map in the Counter DB */
8543+
/* Add stat counters to flex_counter */
8544+
vector<FieldValueTuple> pgVector;
8545+
vector<FieldValueTuple> pgPortVector;
8546+
vector<FieldValueTuple> pgIndexVector;
85028547

85038548
for (auto pgIndex = startIndex; pgIndex <= endIndex; pgIndex++)
85048549
{
@@ -8654,6 +8699,12 @@ void PortsOrch::removePortBufferPgCounters(const Port& port, string pgs)
86548699
{
86558700
endIndex = to_uint<uint32_t>(toks[1]);
86568701
}
8702+
deletePortBufferPgCounters(port, startIndex, endIndex);
8703+
}
8704+
8705+
void PortsOrch::deletePortBufferPgCounters(const Port& port, uint32_t startIndex, uint32_t endIndex)
8706+
{
8707+
SWSS_LOG_ENTER();
86578708

86588709
for (auto pgIndex = startIndex; pgIndex <= endIndex; pgIndex++)
86598710
{

orchagent/portsorch.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,15 +191,19 @@ class PortsOrch : public Orch, public Subject
191191
void generateQueueMap(map<string, FlexCounterQueueStates> queuesStateVector);
192192
uint32_t getNumberOfPortSupportedQueueCounters(string port);
193193
void createPortBufferQueueCounters(const Port &port, string queues, bool skip_host_tx_queue=true);
194+
void addPortBufferQueueCounters(const Port &port, uint32_t startIndex, uint32_t endIndex, bool skip_host_tx_queue=true);
194195
void removePortBufferQueueCounters(const Port &port, string queues, bool skip_host_tx_queue=true);
196+
void deletePortBufferQueueCounters(const Port &port, uint32_t startIndex, uint32_t endIndex, bool skip_host_tx_queue=true);
195197
void addQueueFlexCounters(map<string, FlexCounterQueueStates> queuesStateVector);
196198
void addQueueWatermarkFlexCounters(map<string, FlexCounterQueueStates> queuesStateVector);
197199
void addWredQueueFlexCounters(map<string, FlexCounterQueueStates> queuesStateVector);
198200

199201
void generatePriorityGroupMap(map<string, FlexCounterPgStates> pgsStateVector);
200202
uint32_t getNumberOfPortSupportedPgCounters(string port);
201203
void createPortBufferPgCounters(const Port &port, string pgs);
204+
void addPortBufferPgCounters(const Port& port, uint32_t startIndex, uint32_t endIndex);
202205
void removePortBufferPgCounters(const Port& port, string pgs);
206+
void deletePortBufferPgCounters(const Port& port, uint32_t startIndex, uint32_t endIndex);
203207
void addPriorityGroupFlexCounters(map<string, FlexCounterPgStates> pgsStateVector);
204208
void addPriorityGroupWatermarkFlexCounters(map<string, FlexCounterPgStates> pgsStateVector);
205209

0 commit comments

Comments
 (0)