[sonic_xcvr] Cache static CMIS support/identity fields to optimize EEPROM reads#710
Open
aditya-nexthop wants to merge 2 commits into
Open
[sonic_xcvr] Cache static CMIS support/identity fields to optimize EEPROM reads#710aditya-nexthop wants to merge 2 commits into
aditya-nexthop wants to merge 2 commits into
Conversation
Signed-off-by: Aditya Bhiday <aditya@nexthop.ai>
Collaborator
|
/azp run |
|
Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command. |
Collaborator
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
aditya-nexthop
marked this pull request as ready for review
July 14, 2026 20:59
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Cache static CMIS support/identity/capability fields so they are read from the module EEPROM once and reused, instead of being re-read on every DOM/status poll cycle.
Changes:
Cache static getters by applying the
@read_only_cached_api_returndecorator (caches until the getter returns a non-
None, non-empty value) tothe CMIS advertisement getters that expose static, read-only fields
Add a cached
_get_tx_bias_scale_raw()helper. The TX bias scalingexponent is a static per-module advertisement, but it was read from EEPROM on
every
get_tx_bias()andget_transceiver_threshold_info()call. Both pathsnow go through the cached helper.
Return
Noneon failed reads instead of freezing a default. Because thecache only stores non-
Noneresults, getters now return the rawNoneon atransient read failure so the value is re-read on the next call rather than
caching a wrong default.
Update callers for the new
get_supported_power_configcontract(
c_cmis.py):set_tx_power()andget_transceiver_info()now useself.get_supported_power_config() or (None, None)to safely unpack when the read fails.Motivation and Context
These fields (support flags, module identity/interface, and capability
advertisements) are static for the lifetime of a plugged-in module, yet they
were being re-read from the EEPROM on every DOM/status polling cycle. On a
platform with many transceivers this adds redundant I2C/EEPROM traffic and
latency to the hot polling loop.
Caching them behind
@read_only_cached_api_returnreads each field once and serves subsequent calls from memory, cutting EEPROM reads in the per-cycle DOM path. ReturningNoneon a failed read (instead of a hard-codedFalse/(None, None)) ensures a transient read failure is not cached permanently — the cache re-reads on the next call once the module responds.How Has This Been Tested?
tests/sonic_xcvr/test_cmis.pyto reflect thenew
None-on-failed-read behavior:test_get_diag_page_support: aNoneread now expectsNone(previouslyFalse).test_is_cdb_supported: aNoneread now expectsNone(previouslyFalse).tests/sonic_xcvr/test_cmis_cache.py,which validate that decorated getters are cached and can be cleared.
sonic_xcvrpytest suite run locally.Additional Information (Optional)