From 2267071c2816f24f1cfdce195b784b474831a22f Mon Sep 17 00:00:00 2001 From: Mykola F <37578614+mykolaf@users.noreply.github.com> Date: Thu, 20 Aug 2020 21:28:37 +0300 Subject: [PATCH] [portsorch] add buffer drop FC group (#1368) Signed-off-by: Mykola Faryma --- orchagent/flexcounterorch.cpp | 1 + orchagent/portsorch.cpp | 15 +++++++++++++++ orchagent/portsorch.h | 2 ++ 3 files changed, 18 insertions(+) diff --git a/orchagent/flexcounterorch.cpp b/orchagent/flexcounterorch.cpp index ac5d5749e3..549db87c93 100644 --- a/orchagent/flexcounterorch.cpp +++ b/orchagent/flexcounterorch.cpp @@ -22,6 +22,7 @@ unordered_map flexCounterGroupMap = { {"PORT", PORT_STAT_COUNTER_FLEX_COUNTER_GROUP}, {"PORT_RATES", PORT_RATE_COUNTER_FLEX_COUNTER_GROUP}, + {"PORT_BUFFER_DROP", PORT_STAT_COUNTER_FLEX_COUNTER_GROUP}, {"QUEUE", QUEUE_STAT_COUNTER_FLEX_COUNTER_GROUP}, {"PFCWD", PFC_WD_FLEX_COUNTER_GROUP}, {"QUEUE_WATERMARK", QUEUE_WATERMARK_STAT_COUNTER_FLEX_COUNTER_GROUP}, diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index 56d44b4b85..ce86371da6 100755 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -47,6 +47,7 @@ extern BufferOrch *gBufferOrch; #define MAX_VALID_VLAN_ID 4094 #define PORT_STAT_FLEX_COUNTER_POLLING_INTERVAL_MS 1000 +#define PORT_BUFFER_DROP_STAT_POLLING_INTERVAL_MS 60000 #define QUEUE_STAT_FLEX_COUNTER_POLLING_INTERVAL_MS 10000 #define QUEUE_WATERMARK_FLEX_STAT_COUNTER_POLL_MSECS "10000" #define PG_WATERMARK_FLEX_STAT_COUNTER_POLL_MSECS "10000" @@ -145,6 +146,12 @@ const vector port_stat_ids = SAI_PORT_STAT_ETHER_IN_PKTS_128_TO_255_OCTETS, }; +const vector port_buffer_drop_stat_ids = +{ + SAI_PORT_STAT_IN_DROPPED_PKTS, + SAI_PORT_STAT_OUT_DROPPED_PKTS +}; + static const vector queue_stat_ids = { SAI_QUEUE_STAT_PACKETS, @@ -187,6 +194,7 @@ static char* hostif_vlan_tag[] = { PortsOrch::PortsOrch(DBConnector *db, vector &tableNames) : Orch(db, tableNames), port_stat_manager(PORT_STAT_COUNTER_FLEX_COUNTER_GROUP, StatsMode::READ, PORT_STAT_FLEX_COUNTER_POLLING_INTERVAL_MS, true), + port_buffer_drop_stat_manager(PORT_BUFFER_DROP_STAT_FLEX_COUNTER_GROUP, StatsMode::READ, PORT_BUFFER_DROP_STAT_POLLING_INTERVAL_MS, true), queue_stat_manager(QUEUE_STAT_COUNTER_FLEX_COUNTER_GROUP, StatsMode::READ, QUEUE_STAT_FLEX_COUNTER_POLLING_INTERVAL_MS, true) { SWSS_LOG_ENTER(); @@ -1845,6 +1853,13 @@ bool PortsOrch::initPort(const string &alias, const int index, const set &l counter_stats.emplace(sai_serialize_port_stat(it)); } port_stat_manager.setCounterIdList(p.m_port_id, CounterType::PORT, counter_stats); + std::unordered_set port_buffer_drop_stats; + for (const auto& it: port_buffer_drop_stat_ids) + { + port_buffer_drop_stats.emplace(sai_serialize_port_stat(it)); + } + port_buffer_drop_stat_manager.setCounterIdList(p.m_port_id, CounterType::PORT, port_buffer_drop_stats); + PortUpdate update = { p, true }; notify(SUBJECT_TYPE_PORT_CHANGE, static_cast(&update)); diff --git a/orchagent/portsorch.h b/orchagent/portsorch.h index 61073d660a..936f1ff07e 100755 --- a/orchagent/portsorch.h +++ b/orchagent/portsorch.h @@ -18,6 +18,7 @@ #define VLAN_TAG_LEN 4 #define PORT_STAT_COUNTER_FLEX_COUNTER_GROUP "PORT_STAT_COUNTER" #define PORT_RATE_COUNTER_FLEX_COUNTER_GROUP "PORT_RATE_COUNTER" +#define PORT_BUFFER_DROP_STAT_FLEX_COUNTER_GROUP "PORT_BUFFER_DROP_STAT" #define QUEUE_STAT_COUNTER_FLEX_COUNTER_GROUP "QUEUE_STAT_COUNTER" #define QUEUE_WATERMARK_STAT_COUNTER_FLEX_COUNTER_GROUP "QUEUE_WATERMARK_STAT_COUNTER" #define PG_WATERMARK_STAT_COUNTER_FLEX_COUNTER_GROUP "PG_WATERMARK_STAT_COUNTER" @@ -149,6 +150,7 @@ class PortsOrch : public Orch, public Subject shared_ptr m_flex_db; FlexCounterManager port_stat_manager; + FlexCounterManager port_buffer_drop_stat_manager; FlexCounterManager queue_stat_manager; std::map m_portSupportedSpeeds;