diff --git a/orchagent/flexcounterorch.cpp b/orchagent/flexcounterorch.cpp index 571b69c50fd8..8fae466d760f 100644 --- a/orchagent/flexcounterorch.cpp +++ b/orchagent/flexcounterorch.cpp @@ -21,6 +21,7 @@ extern BufferOrch *gBufferOrch; unordered_map flexCounterGroupMap = { {"PORT", PORT_STAT_COUNTER_FLEX_COUNTER_GROUP}, + {"PORT_BUFFER_DROP", PORT_DROP_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 12734cea3228..38259a0f2d07 100755 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -42,6 +42,7 @@ extern BufferOrch *gBufferOrch; #define DEFAULT_VLAN_ID 1 #define MAX_VALID_VLAN_ID 4094 #define PORT_FLEX_STAT_COUNTER_POLL_MSECS "1000" +#define PORT_BUFFER_DROP_STAT_POLLING_INTERVAL_MS "60000" #define QUEUE_FLEX_STAT_COUNTER_POLL_MSECS "10000" #define QUEUE_WATERMARK_FLEX_STAT_COUNTER_POLL_MSECS "10000" #define PG_WATERMARK_FLEX_STAT_COUNTER_POLL_MSECS "10000" @@ -113,6 +114,12 @@ const vector portStatIds = SAI_PORT_STAT_ETHER_IN_PKTS_128_TO_255_OCTETS, }; +static const vector port_buffer_drop_stat_ids = +{ + SAI_PORT_STAT_IN_DROPPED_PKTS, + SAI_PORT_STAT_OUT_DROPPED_PKTS +}; + static const vector queueStatIds = { SAI_QUEUE_STAT_PACKETS, @@ -188,6 +195,12 @@ PortsOrch::PortsOrch(DBConnector *db, vector &tableNames) fields.emplace_back(STATS_MODE_FIELD, STATS_MODE_READ); m_flexCounterGroupTable->set(PORT_STAT_COUNTER_FLEX_COUNTER_GROUP, fields); + fields.clear(); + fields.emplace_back(POLL_INTERVAL_FIELD, PORT_BUFFER_DROP_STAT_POLLING_INTERVAL_MS); + fields.emplace_back(STATS_MODE_FIELD, STATS_MODE_READ); + m_flexCounterGroupTable->set(PORT_DROP_STAT_COUNTER_FLEX_COUNTER_GROUP, fields); + + fields.clear(); fields.emplace_back(POLL_INTERVAL_FIELD, QUEUE_FLEX_STAT_COUNTER_POLL_MSECS); fields.emplace_back(STATS_MODE_FIELD, STATS_MODE_READ); m_flexCounterGroupTable->set(QUEUE_STAT_COUNTER_FLEX_COUNTER_GROUP, fields); @@ -1484,6 +1497,11 @@ string PortsOrch::getPortFlexCounterTableKey(string key) return string(PORT_STAT_COUNTER_FLEX_COUNTER_GROUP) + ":" + key; } +string PortsOrch::getPortBuffDropFlexCounterTableKey(string key) +{ + return string(PORT_DROP_STAT_COUNTER_FLEX_COUNTER_GROUP) + ":" + key; +} + string PortsOrch::getQueueFlexCounterTableKey(string key) { return string(QUEUE_STAT_COUNTER_FLEX_COUNTER_GROUP) + ":" + key; @@ -1547,6 +1565,19 @@ bool PortsOrch::initPort(const string &alias, const set &lane_set) m_flexCounterTable->set(key, fields); + delimiter = ""; + string port_drop_key = getPortBuffDropFlexCounterTableKey(sai_serialize_object_id(p.m_port_id)); + std::ostringstream port_buffer_drop_stream; + for (const auto& it: port_buffer_drop_stat_ids) + { + port_buffer_drop_stream << delimiter << sai_serialize_port_stat(it); + delimiter = comma; + } + + fields.clear(); + fields.emplace_back(PORT_COUNTER_ID_LIST, counters_stream.str()); + m_flexCounterTable->set(port_drop_key, fields); + PortUpdate update = {p, true }; notify(SUBJECT_TYPE_PORT_CHANGE, static_cast(&update)); diff --git a/orchagent/portsorch.h b/orchagent/portsorch.h index dbb48d21c0de..886be7f49875 100755 --- a/orchagent/portsorch.h +++ b/orchagent/portsorch.h @@ -13,6 +13,7 @@ #define FCS_LEN 4 #define VLAN_TAG_LEN 4 #define PORT_STAT_COUNTER_FLEX_COUNTER_GROUP "PORT_STAT_COUNTER" +#define PORT_DROP_STAT_COUNTER_FLEX_COUNTER_GROUP "PORT_DROP_STAT_COUNTER" #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" @@ -108,6 +109,7 @@ class PortsOrch : public Orch, public Subject std::string getQueueFlexCounterTableKey(std::string s); std::string getQueueWatermarkFlexCounterTableKey(std::string s); std::string getPortFlexCounterTableKey(std::string s); + std::string getPortBuffDropFlexCounterTableKey(std::string s); std::string getPriorityGroupWatermarkFlexCounterTableKey(std::string s); shared_ptr m_counter_db;