From 33f95c64a00cd2bb68e651a419e2b2afd9bc6112 Mon Sep 17 00:00:00 2001 From: Justin Wong Date: Thu, 25 Jun 2026 17:23:23 +0000 Subject: [PATCH] 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;