From 35a7ab02dfe1231907dd39dc2a5171abeb2ab979 Mon Sep 17 00:00:00 2001 From: Sambath Kumar Balasubramanian <63021927+skbarista@users.noreply.github.com> Date: Thu, 23 Feb 2023 11:02:49 -0800 Subject: [PATCH] swss: Fix Invalid port oid messages generated because of voq counters. (#2653) * swss: Fix Invalid port oid messages generated because of voq counters. * Do not add Voq oids to CounterCheckOrch since CounterCheckOrch is not relevant for voqs. --- orchagent/portsorch.cpp | 25 ++++++++++++++++++++----- orchagent/portsorch.h | 2 +- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index 15ddd155e446..5dd63129f1ed 100755 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -6169,6 +6169,10 @@ void PortsOrch::generateQueueMapPerPort(const Port& port, FlexCounterQueueStates queueVector.emplace_back(name.str(), id); if (voq) { + // Install a flex counter for this voq to track stats. Voq counters do + // not have buffer queue config. So it does not get enabled through the + // flexcounter orch logic. Always enabled voq counters. + addQueueFlexCountersPerPortPerQueueIndex(port, queueIndex, true); queuePortVector.emplace_back(id, sai_serialize_object_id(port.m_system_port_oid)); } else @@ -6184,12 +6188,12 @@ void PortsOrch::generateQueueMapPerPort(const Port& port, FlexCounterQueueStates else { m_queueTable->set("", queueVector); + CounterCheckOrch::getInstance().addPort(port); } m_queuePortTable->set("", queuePortVector); m_queueIndexTable->set("", queueIndexVector); m_queueTypeTable->set("", queueTypeVector); - CounterCheckOrch::getInstance().addPort(port); } void PortsOrch::addQueueFlexCounters(map queuesStateVector) @@ -6230,19 +6234,30 @@ void PortsOrch::addQueueFlexCountersPerPort(const Port& port, FlexCounterQueueSt continue; } // Install a flex counter for this queue to track stats - addQueueFlexCountersPerPortPerQueueIndex(port, queueIndex); + addQueueFlexCountersPerPortPerQueueIndex(port, queueIndex, false); } } } -void PortsOrch::addQueueFlexCountersPerPortPerQueueIndex(const Port& port, size_t queueIndex) +void PortsOrch::addQueueFlexCountersPerPortPerQueueIndex(const Port& port, size_t queueIndex, bool voq) { std::unordered_set counter_stats; + std::vector queue_ids; + for (const auto& it: queue_stat_ids) { counter_stats.emplace(sai_serialize_queue_stat(it)); } - queue_stat_manager.setCounterIdList(port.m_queue_ids[queueIndex], CounterType::QUEUE, counter_stats); + if (voq) + { + queue_ids = m_port_voq_ids[port.m_alias]; + } + else + { + queue_ids = port.m_queue_ids; + } + + queue_stat_manager.setCounterIdList(queue_ids[queueIndex], CounterType::QUEUE, counter_stats); } @@ -6350,7 +6365,7 @@ void PortsOrch::createPortBufferQueueCounters(const Port &port, string queues) if (flexCounterOrch->getQueueCountersState()) { // Install a flex counter for this queue to track stats - addQueueFlexCountersPerPortPerQueueIndex(port, queueIndex); + addQueueFlexCountersPerPortPerQueueIndex(port, queueIndex, false); } if (flexCounterOrch->getQueueWatermarkCountersState()) { diff --git a/orchagent/portsorch.h b/orchagent/portsorch.h index a5982debd77a..9d376d3ae7a1 100644 --- a/orchagent/portsorch.h +++ b/orchagent/portsorch.h @@ -387,7 +387,7 @@ class PortsOrch : public Orch, public Subject void generateQueueMapPerPort(const Port& port, FlexCounterQueueStates& queuesState, bool voq); bool m_isQueueFlexCountersAdded = false; void addQueueFlexCountersPerPort(const Port& port, FlexCounterQueueStates& queuesState); - void addQueueFlexCountersPerPortPerQueueIndex(const Port& port, size_t queueIndex); + void addQueueFlexCountersPerPortPerQueueIndex(const Port& port, size_t queueIndex, bool voq); bool m_isQueueWatermarkFlexCountersAdded = false; void addQueueWatermarkFlexCountersPerPort(const Port& port, FlexCounterQueueStates& queuesState);