From fcdde2cb9eb08d23e7d76bcc9bc1d6f528ec5719 Mon Sep 17 00:00:00 2001 From: Nazarii Hnydyn Date: Fri, 19 Aug 2022 13:48:27 +0300 Subject: [PATCH] [portsorch]: Handle review comments. Signed-off-by: Nazarii Hnydyn --- orchagent/flexcounterorch.h | 4 +-- orchagent/p4orch/tests/fake_portorch.cpp | 36 +++++++++++++++------ orchagent/portsorch.cpp | 40 +++++++++++++++--------- 3 files changed, 53 insertions(+), 27 deletions(-) diff --git a/orchagent/flexcounterorch.h b/orchagent/flexcounterorch.h index 3121b9153b3..a6e7527a05c 100644 --- a/orchagent/flexcounterorch.h +++ b/orchagent/flexcounterorch.h @@ -44,8 +44,8 @@ class FlexCounterOrch: public Orch bool getPortBufferDropCountersState() const; bool getPgWatermarkCountersState() const; bool getQueueCountersState() const; - map getQueueConfigurations(); - map getPgConfigurations(); + std::map getQueueConfigurations(); + std::map getPgConfigurations(); bool getHostIfTrapCounterState() const {return m_hostif_trap_counter_enabled;} bool getRouteFlowCountersState() const {return m_route_flow_counter_enabled;} bool bake() override; diff --git a/orchagent/p4orch/tests/fake_portorch.cpp b/orchagent/p4orch/tests/fake_portorch.cpp index a21294d8dd2..5224ec55afa 100644 --- a/orchagent/p4orch/tests/fake_portorch.cpp +++ b/orchagent/p4orch/tests/fake_portorch.cpp @@ -181,11 +181,35 @@ bool PortsOrch::setPortPfc(sai_object_id_t portId, uint8_t pfc_bitmask) return true; } -void PortsOrch::generateQueueMap() +void PortsOrch::generateQueueMap(std::map queuesStateVector) { } -void PortsOrch::generatePriorityGroupMap() +void PortsOrch::generateQueueMapPerPort(const Port& port, FlexCounterQueueStates& queuesState) +{ +} + +void PortsOrch::createPortBufferQueueCounters(const Port &port, string queues) +{ +} + +void PortsOrch::removePortBufferQueueCounters(const Port &port, string queues) +{ +} + +void PortsOrch::generatePriorityGroupMap(std::map pgsStateVector) +{ +} + +void PortsOrch::generatePriorityGroupMapPerPort(const Port& port, FlexCounterPgStates& pgsState) +{ +} + +void PortsOrch::createPortBufferPgCounters(const Port& port, string pgs) +{ +} + +void PortsOrch::removePortBufferPgCounters(const Port& port, string pgs) { } @@ -582,14 +606,6 @@ bool PortsOrch::getQueueTypeAndIndex(sai_object_id_t queue_id, string &type, uin return true; } -void PortsOrch::generateQueueMapPerPort(const Port &port) -{ -} - -void PortsOrch::generatePriorityGroupMapPerPort(const Port &port) -{ -} - task_process_status PortsOrch::setPortAutoNeg(sai_object_id_t id, int an) { return task_success; diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index 69d530a7552..0d4177c6d53 100755 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -6112,19 +6112,27 @@ void PortsOrch::removePortBufferQueueCounters(const Port &port, string queues) name << port.m_alias << ":" << queueIndex; const auto id = sai_serialize_object_id(port.m_queue_ids[queueIndex]); - /* Remove watermark queue counters */ - string key = getQueueWatermarkFlexCounterTableKey(id); - m_flexCounterTable->del(key); + // Remove the queue counter from counters DB maps + m_queueTable->hdel("", name.str()); + m_queuePortTable->hdel("", id); + + string queueType; + uint8_t queueRealIndex = 0; + if (getQueueTypeAndIndex(port.m_queue_ids[queueIndex], queueType, queueRealIndex)) + { + m_queueTypeTable->hdel("", id); + m_queueIndexTable->hdel("", id); + } // Remove the flex counter for this queue queue_stat_manager.clearCounterIdList(port.m_queue_ids[queueIndex]); - // Remove the queue counter from counters DB maps - m_queueTable->hdel("", name.str()); - m_queuePortTable->hdel("", id); - m_queueIndexTable->hdel("", id); - m_queueTypeTable->hdel("", id); + // Remove watermark queue counters + string key = getQueueWatermarkFlexCounterTableKey(id); + m_flexCounterTable->del(key); } + + CounterCheckOrch::getInstance().removePort(port); } void PortsOrch::generatePriorityGroupMap(map pgsStateVector) @@ -6301,19 +6309,21 @@ void PortsOrch::removePortBufferPgCounters(const Port& port, string pgs) name << port.m_alias << ":" << pgIndex; const auto id = sai_serialize_object_id(port.m_priority_group_ids[pgIndex]); - /* Remove dropped packets counters from flex_counter */ + // Remove the pg counter from counters DB maps + m_pgTable->hdel("", name.str()); + m_pgPortTable->hdel("", id); + m_pgIndexTable->hdel("", id); + + // Remove dropped packets counters from flex_counter string key = getPriorityGroupDropPacketsFlexCounterTableKey(id); m_flexCounterTable->del(key); - /* Remove watermark counters from flex_counter */ + // Remove watermark counters from flex_counter key = getPriorityGroupWatermarkFlexCounterTableKey(id); m_flexCounterTable->del(key); - - // Remove the pg counter from counters DB maps - m_pgTable->hdel("", name.str()); - m_pgPortTable->hdel("", id); - m_pgIndexTable->hdel("", id); } + + CounterCheckOrch::getInstance().removePort(port); } void PortsOrch::generatePortCounterMap()