diff --git a/orchagent/fabricportsorch.cpp b/orchagent/fabricportsorch.cpp index d61f5d13f2..689f80a056 100644 --- a/orchagent/fabricportsorch.cpp +++ b/orchagent/fabricportsorch.cpp @@ -21,6 +21,8 @@ #define FABRIC_PORT_STAT_FLEX_COUNTER_POLLING_INTERVAL_MS 10000 #define FABRIC_QUEUE_STAT_COUNTER_FLEX_COUNTER_GROUP "FABRIC_QUEUE_STAT_COUNTER" #define FABRIC_QUEUE_STAT_FLEX_COUNTER_POLLING_INTERVAL_MS 100000 +#define DEBUG_COUNTER_FLEX_COUNTER_GROUP "SWITCH_DEBUG_COUNTER" +#define SWITCH_DEBUG_COUNTER_POLLING_INTERVAL_MS 100000 #define FABRIC_DEBUG_POLLING_INTERVAL_DEFAULT (60) #define FABRIC_MONITOR_DATA "FABRIC_MONITOR_DATA" #define APPL_FABRIC_PORT_PREFIX "Fabric" @@ -37,6 +39,11 @@ #define ERROR_RATE_RX_CELLS_CFG 61035156 #define FABRIC_LINK_RATE 44316 +const vector switch_voq_counter_ids = +{ + SAI_SWITCH_STAT_PACKET_INTEGRITY_DROP +}; + extern sai_object_id_t gSwitchId; extern sai_switch_api_t *sai_switch_api; extern sai_port_api_t *sai_port_api; @@ -68,6 +75,8 @@ FabricPortsOrch::FabricPortsOrch(DBConnector *appl_db, vector(new Table(m_counter_db.get(), COUNTERS_FABRIC_QUEUE_NAME_MAP)); m_portNamePortCounterTable = unique_ptr(new Table(m_counter_db.get(), COUNTERS_FABRIC_PORT_NAME_MAP)); m_fabricCounterTable = unique_ptr
(new Table(m_counter_db.get(), COUNTERS_TABLE)); + m_counterNameToSwitchStatMap = unique_ptr
(new Table(m_counter_db.get(), COUNTERS_DEBUG_NAME_SWITCH_STAT_MAP)); m_flex_db = shared_ptr(new DBConnector("FLEX_COUNTER_DB", 0)); m_flexCounterTable = unique_ptr(new ProducerTable(m_flex_db.get(), APP_FABRIC_PORT_TABLE_NAME)); @@ -1222,5 +1232,24 @@ void FabricPortsOrch::doTask(swss::SelectableTimer &timer) updateFabricDebugCounters(); updateFabricCapacity(); } + if (!m_isSwitchStatsGenerated) + { + createSwitchVoqCounters(); + } } } + +void FabricPortsOrch::createSwitchVoqCounters(void) +{ + std::unordered_set counter_stats; + for (const auto& it: switch_voq_counter_ids) + { + counter_stats.emplace(sai_serialize_switch_stat(it)); + } + switch_drop_counter_manager.setCounterIdList(gSwitchId, CounterType::SWITCH_DEBUG, counter_stats); + + vector switchNameSwitchCounterMap; + switchNameSwitchCounterMap.emplace_back("SWITCH_ID", sai_serialize_object_id(gSwitchId)); + m_counterNameToSwitchStatMap->set("", switchNameSwitchCounterMap); + m_isSwitchStatsGenerated = true; +} diff --git a/orchagent/fabricportsorch.h b/orchagent/fabricportsorch.h index e72ae56e3c..12317f74c5 100644 --- a/orchagent/fabricportsorch.h +++ b/orchagent/fabricportsorch.h @@ -19,6 +19,7 @@ class FabricPortsOrch : public Orch, public Subject bool fabricPortStatEnabled=true, bool fabricQueueStatEnabled=true); bool allPortsReady(); void generateQueueStats(); + void createSwitchVoqCounters(void); private: bool m_fabricPortStatEnabled; @@ -37,12 +38,14 @@ class FabricPortsOrch : public Orch, public Subject unique_ptr
m_fabricCapacityTable; unique_ptr
m_applMonitorConstTable; unique_ptr m_flexCounterTable; + shared_ptr
m_counterNameToSwitchStatMap; swss::SelectableTimer *m_timer = nullptr; swss::SelectableTimer *m_debugTimer = nullptr; FlexCounterManager port_stat_manager; FlexCounterManager queue_stat_manager; + FlexCounterManager switch_drop_counter_manager; sai_uint32_t m_fabricPortCount; map m_fabricLanePortMap; @@ -52,6 +55,7 @@ class FabricPortsOrch : public Orch, public Subject bool m_getFabricPortListDone = false; bool m_isQueueStatsGenerated = false; + bool m_isSwitchStatsGenerated = false; string m_defaultPollWithErrors = "0"; string m_defaultPollWithNoErrors = "8"; diff --git a/orchagent/port/port_capabilities.h b/orchagent/port/port_capabilities.h index e937e7b943..3941615cfc 100644 --- a/orchagent/port/port_capabilities.h +++ b/orchagent/port/port_capabilities.h @@ -4,6 +4,7 @@ extern "C" { #include #include #include +#include } class PortCapabilities final diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index b946c96624..1ca523d452 100755 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -270,6 +270,11 @@ static const vector queue_stat_ids = SAI_QUEUE_STAT_DROPPED_PACKETS, SAI_QUEUE_STAT_DROPPED_BYTES, }; +static const vector voq_stat_ids = +{ + SAI_QUEUE_STAT_CREDIT_WD_DELETED_PACKETS +}; + static const vector queueWatermarkStatIds = { @@ -7011,6 +7016,10 @@ void PortsOrch::addQueueFlexCountersPerPortPerQueueIndex(const Port& port, size_ } if (voq) { + for (const auto& voq_it: voq_stat_ids) + { + counter_stats.emplace(sai_serialize_queue_stat(voq_it)); + } queue_ids = m_port_voq_ids[port.m_alias]; } else