From bce7668611fbe15f62c3fc312ec444f1eaacd1cb Mon Sep 17 00:00:00 2001 From: Justin Wong Date: Thu, 25 Jun 2026 17:23:23 +0000 Subject: [PATCH 1/2] Cast temp workaround for N/A counter values from 202412 Casting temp-workaround for N/A counters on management ports on 202605. This impacts all hwsku-topo combos that uses management ports (including TH5). Casting from: https://github.com/Azure/sonic-sairedis.msft/pull/69 Proper fix under review at: master: https://github.com/sonic-net/sonic-sairedis/pull/1774 202511: https://github.com/sonic-net/sonic-sairedis/pull/1862 202605: Opened soon Signed-off-by: Justin Wong --- syncd/FlexCounter.cpp | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/syncd/FlexCounter.cpp b/syncd/FlexCounter.cpp index 948c0b2b40..aae9b1108b 100644 --- a/syncd/FlexCounter.cpp +++ b/syncd/FlexCounter.cpp @@ -990,24 +990,21 @@ class CounterContext : public BaseCounterContext auto rid = rids[i]; auto vid = vids[i]; std::vector stats(counter_ids.size()); - if (collectData(rid, counter_ids, effective_stats_mode, false, stats)) { - - auto it_vid = m_objectIdsMap.find(vid); - if (it_vid != m_objectIdsMap.end()) - { - // Remove and re-add if vid already exists - m_objectIdsMap.erase(it_vid); - } - - auto counter_data = std::make_shared>(rid, counter_ids); - m_objectIdsMap.emplace(vid, counter_data); - - SWSS_LOG_INFO("Fallback to single call for object 0x%" PRIx64, vid); - } else { - SWSS_LOG_WARN("%s RID %s can't provide the statistic", m_name.c_str(), sai_serialize_object_id(rid).c_str()); + if (!collectData(rid, counter_ids, effective_stats_mode, false, stats)) + { + SWSS_LOG_INFO("counter read failed on RID 0x%x on intf 0x%x, adding to objectIdsMap regardless", rid, vid); + } + auto it_vid = m_objectIdsMap.find(vid); + if (it_vid != m_objectIdsMap.end()) + { + // Remove and re-add if vid already exists + m_objectIdsMap.erase(it_vid); } - } + auto counter_data = std::make_shared>(rid, counter_ids); + m_objectIdsMap.emplace(vid, counter_data); + SWSS_LOG_INFO("Fallback to single call for object 0x%" PRIx64, vid); + } return; } @@ -1159,10 +1156,10 @@ class CounterContext : public BaseCounterContext kv.second->getStatsMode() == SAI_STATS_MODE_READ_AND_CLEAR) ? SAI_STATS_MODE_READ_AND_CLEAR : SAI_STATS_MODE_READ; } - std::vector stats(statIds.size()); - if (!collectData(rid, statIds, effective_stats_mode, true, stats)) + std::vector stats(statIds.size(), 0); + if (!collectData(rid, statIds, effective_stats_mode, false, stats)) { - continue; + SWSS_LOG_INFO("counter read failed on RID 0x%x on intf 0x%x, filling with '0' value", rid, vid); } std::vector values; From 63008169815162c8d77d405f1f4e24b598356df4 Mon Sep 17 00:00:00 2001 From: Justin Wong Date: Wed, 1 Jul 2026 03:34:02 +0000 Subject: [PATCH 2/2] Fixed logging typing and added comments Signed-off-by: Justin Wong --- syncd/FlexCounter.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/syncd/FlexCounter.cpp b/syncd/FlexCounter.cpp index aae9b1108b..15d7d971de 100644 --- a/syncd/FlexCounter.cpp +++ b/syncd/FlexCounter.cpp @@ -992,7 +992,10 @@ class CounterContext : public BaseCounterContext std::vector stats(counter_ids.size()); if (!collectData(rid, counter_ids, effective_stats_mode, false, stats)) { - SWSS_LOG_INFO("counter read failed on RID 0x%x on intf 0x%x, adding to objectIdsMap regardless", rid, vid); + // Workaround for N/A Counters on Broadcom management ports + // Adding VIDs with unsupported counters to objectIdsMap to unblock testing + // Please see https://github.com/sonic-net/sonic-sairedis/issues/1753 for details + SWSS_LOG_INFO("counter read failed on RID 0x%" PRIx64 " on intf 0x%" PRIx64 ", adding to objectIdsMap regardless", rid, vid); } auto it_vid = m_objectIdsMap.find(vid); if (it_vid != m_objectIdsMap.end()) @@ -1156,10 +1159,13 @@ class CounterContext : public BaseCounterContext kv.second->getStatsMode() == SAI_STATS_MODE_READ_AND_CLEAR) ? SAI_STATS_MODE_READ_AND_CLEAR : SAI_STATS_MODE_READ; } + // Workaround for N/A Counters on Broadcom management ports + // Using '0' for unsupported counters to unblock testing + // Please see https://github.com/sonic-net/sonic-sairedis/issues/1753 for details std::vector stats(statIds.size(), 0); if (!collectData(rid, statIds, effective_stats_mode, false, stats)) { - SWSS_LOG_INFO("counter read failed on RID 0x%x on intf 0x%x, filling with '0' value", rid, vid); + SWSS_LOG_INFO("counter read failed on RID 0x%" PRIx64 " on intf 0x%" PRIx64 ", filling with '0' value", rid, vid); } std::vector values;