diff --git a/orchagent/flex_counter/flex_counter_manager.h b/orchagent/flex_counter/flex_counter_manager.h index 2724a69aed2..ae58e024bb0 100644 --- a/orchagent/flex_counter/flex_counter_manager.h +++ b/orchagent/flex_counter/flex_counter_manager.h @@ -180,14 +180,28 @@ struct CachedObjects auto counter_ids = FlexCounterManager::serializeCounterStats(pending_counter_stats); auto counter_type_it = FlexCounterManager::counter_id_field_lookup.find(pending_counter_type); - auto counter_keys = group_name + ":"; - for (const auto& oid: pending_sai_objects) + // Temporary fix for SNMP PFC counter issue: disable bulk init requests for PORT counters + // This forces each port to be processed individually, avoiding capability mismatch + // for different ports in bulk requests + if (pending_counter_type == CounterType::PORT) { - counter_keys += sai_serialize_object_id(oid) + ","; + for (const auto& oid: pending_sai_objects) + { + auto counter_key = group_name + ":" + sai_serialize_object_id(oid); + startFlexCounterPolling(pending_switch_id, counter_key, counter_ids, counter_type_it->second); + } + } + else + { + auto counter_keys = group_name + ":"; + for (const auto& oid: pending_sai_objects) + { + counter_keys += sai_serialize_object_id(oid) + ","; + } + counter_keys.pop_back(); + + startFlexCounterPolling(pending_switch_id, counter_keys, counter_ids, counter_type_it->second); } - counter_keys.pop_back(); - - startFlexCounterPolling(pending_switch_id, counter_keys, counter_ids, counter_type_it->second); /* Clear the cached stats and objects after flush */ pending_sai_objects.clear(); diff --git a/tests/mock_tests/flexcounter_ut.cpp b/tests/mock_tests/flexcounter_ut.cpp index cc88206c1aa..a2cffd6dda7 100644 --- a/tests/mock_tests/flexcounter_ut.cpp +++ b/tests/mock_tests/flexcounter_ut.cpp @@ -1064,7 +1064,9 @@ namespace flexcounter_test port_stat_manager.flush(); /* SAIREDIS channel should have been called thrice, once for port1&port2,port3,port4 */ - ASSERT_EQ(mockFlexCounterOperationCallCount, 3); + // ASSERT_EQ(mockFlexCounterOperationCallCount, 3); + // Temporary fix for SNMP PFC counter issue: disabled bulk init requests for PORT counters + ASSERT_EQ(mockFlexCounterOperationCallCount, 4); ASSERT_TRUE(checkFlexCounter(PORT_STAT_COUNTER_FLEX_COUNTER_GROUP, port1_oid, {