Skip to content

Conversation

@rajkumar1-arista
Copy link

Add feature to allow different sets of supported counters for different interfaces.

Currently, if an interface has less supported counters than other interfaces on a switch, the interface with fewer supported counters will not have their counters polled to COUNTERS_DB - it will remain as a N/A in show interface counters.

This change will allow counters to be polled successfully for those interfaces with fewer supported counters by recognizing what can be polled and what cannot be when syncd initializes.

Instead of directly modifying existing functions, parallel functions are created with the new logic that uses the new data structures std::map<sai_object_id_t, size_t> m_objectSupportedCountersGroupMap and std::vector<std::set<StatType>> m_supportedCounterGroups. This is so that in the case the new method fails initialisation, it will fallback to the old method.

The parallel methods are:

bulkAddObject -> bulkAddObjectWithCounterGroups
addObject -> addObjectWithCounterGroups
updateSupportedCounters -> updateSupportedCounterGroups

This change does not involve BulkStatContext code path. However, the data structure it relies on is no longer populated in the parallel functions. It will use the largest CounterGroup in m_supportedCounterGroups instead of m_supportedCounters.

Currently, a single, global list of counters is used to denote the supported counters for all interfaces. This is done with the assumption that all interfaces support the same counters.

However, on TH5, this is not the case. The S2 ports/MGMT ports dont support all counters that the usual ports do. This causes no counters for the MGMT ports to be stored to COUNTERS_DB.

Change the counter implementation to allow multiple groups of counter support. Each counter group is a set of supported counters to poll, and each interface will be assigned to a counter group that is representative of its capabilities. Multiple interfaces can be assigned the same counter group if they share the same support.

More detailed implemntation details can be found in the proposal:
https://docs.google.com/document/d/1m9hvmPxFFPCRz5n2uDAvS8KJe3K8Eh0kMoxd8bJlk0k
@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@rajkumar1-arista
Copy link
Author

/azp run

@azure-pipelines
Copy link

Commenter does not have sufficient privileges for PR 1645 in repo sonic-net/sonic-sairedis

@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@rajkumar1-arista rajkumar1-arista marked this pull request as draft August 22, 2025 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants