Skip to content

Add CpoCmisApi - #742

Open
bgallagher-nexthop wants to merge 4 commits into
sonic-net:masterfrom
nexthop-ai:banking-aware-api
Open

Add CpoCmisApi#742
bgallagher-nexthop wants to merge 4 commits into
sonic-net:masterfrom
nexthop-ai:banking-aware-api

Conversation

@bgallagher-nexthop

@bgallagher-nexthop bgallagher-nexthop commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Description

CmisApi has aggregate functions that read multiple registers and return a dict containing logically grouped information back to xcvrd. For instance, get_transceiver_info is a good example of one of these functions.

This PR implements CPO-specific subclass of CmisApi that splits those aggregate functions into smaller functions that return banked or non-banked information. Taking get_transceiver_info for example, there will now be 3 functions:

  • get_banked_transceiver_info, which will return only bank-dependent information
  • get_non_banked_transceiver_info, which will return only bank-independent information
  • get_transceiver_info will continue to exist, but internally it will just call the two above functions and return the union of their output.

This functionality is limited to a CPO subclass since the ability to read banked and non-banked information independently is only required by CPO at this time.

Motivation and Context

For CPO, there is a desire to limit reading non-banked information from the hardware for each port because many ports may share the same device. Reading non-banked information multiple times from the same device for each port would waste i2c read bandwidth, so the functions have been split to allow xcvrd to selectively read non-banked information only as much as necessary and avoid duplicate reads.

How Has This Been Tested?

A new test class for CpoCmisApi has been introduced that will run all existing test-cases defined for CmisApi against the subclass. The subclass adds no new functionality, just exposes new functions.

…ituents

Signed-off-by: Brian Gallagher <bgallagher@nexthop.ai>
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@bgallagher-nexthop
bgallagher-nexthop marked this pull request as ready for review August 18, 2026 04:15
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors CmisApi (CMIS transceiver API) aggregate “read-many-registers then return a dict” methods to expose separate banked vs non-banked entry points, enabling xcvrd (especially for CPO/shared-device scenarios) to avoid redundant non-banked EEPROM reads while preserving the existing aggregate APIs.

Changes:

  • Split get_transceiver_info() into get_non_banked_transceiver_info() + get_banked_transceiver_info() and recompose in the original method.
  • Split DOM reads/flags and status/status-flags similarly into banked and non-banked helpers, with the original aggregate methods now merging the two parts.
  • Split the transceiver-info default dictionary into banked/non-banked subsets and keep an aggregate default dict.
Suppressed comments (1)

sonic_platform_base/sonic_xcvr/api/public/cmis.py:419

  • Avoid the explicit line continuation ("\") here; it makes the indentation misleading and is prone to style/lint issues. This assignment fits on one line cleanly.
            xcvr_info["%s%d" % ("active_apsel_hostlane", lane)] = \
            apsel_dict["%s%d" % (consts.ACTIVE_APSEL_HOSTLANE, lane)]

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread sonic_platform_base/sonic_xcvr/api/public/cmis.py Outdated
Comment thread sonic_platform_base/sonic_xcvr/api/public/cmis.py Outdated

@prgeor prgeor left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bgallagher-nexthop I was wondering if we should deal with this nuance in cpo specific CMIS api override?

@bgallagher-nexthop

Copy link
Copy Markdown
Contributor Author

@bgallagher-nexthop I was wondering if we should deal with this nuance in cpo specific CMIS api override?

I think that approach would work too:

  1. We could create a CpoCmisApi subclass of CmisApi
  2. We could re-implement the aggregate methods like get_transceiver_info in that subclass, with the banked and non-banked variants also implemented.

I think the downside is that we will have a maintenance cost of keeping CpoCmisApi up-to-date. Any update to the overriden aggregate methods in CmisApi will also require making those same changes to CpoCmisApi. Or we accept that the CpoCmisApi can become stale as time goes on.

What do you think?

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@bgallagher-nexthop bgallagher-nexthop changed the title Split CmisApi aggregate functions into banked and non-banked Add CpoCmisApi Aug 19, 2026
…class of CmisApi

Signed-off-by: Brian Gallagher <bgallagher@nexthop.ai>
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

…-banked split

Signed-off-by: Brian Gallagher <bgallagher@nexthop.ai>
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@bgallagher-nexthop

Copy link
Copy Markdown
Contributor Author

Changed the approach to use a CPO specific subclass that splits some aggregate methods into banked / non-banked constituent methods instead of modifying CmisApi directly, as suggested by reviewers. Also got rid of get_transceiver_info from this class -- it does not require the banked / non-banked methods since it is only called once upon transceiver insertion.

nh-grecs Bot pushed a commit to nexthop-ai/sonic-platform-common that referenced this pull request Aug 23, 2026
rebuild-source: sonic-net#742 @ nexthop-ai/sonic-platform-common 08a113e [case: upstream:open]
nh-grecs Bot pushed a commit to nexthop-ai/sonic-platform-common that referenced this pull request Aug 24, 2026
rebuild-source: sonic-net#742 @ nexthop-ai/sonic-platform-common 08a113e [case: upstream:open]
nh-grecs Bot pushed a commit to nexthop-ai/sonic-platform-common that referenced this pull request Aug 25, 2026
rebuild-source: sonic-net#742 @ nexthop-ai/sonic-platform-common 08a113e [case: upstream:open]
Comment thread sonic_platform_base/sonic_xcvr/cpo/cmis.py
Comment thread sonic_platform_base/sonic_xcvr/cpo/cmis.py Outdated
Comment thread sonic_platform_base/sonic_xcvr/cpo/cmis.py
Comment thread sonic_platform_base/sonic_xcvr/cpo/cmis.py Outdated
Signed-off-by: Brian Gallagher <bgallagher@nexthop.ai>
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

nh-grecs Bot pushed a commit to nexthop-ai/sonic-platform-common that referenced this pull request Aug 26, 2026
rebuild-source: sonic-net#742 @ nexthop-ai/sonic-platform-common 8d68046 [case: upstream:open]
nh-grecs Bot pushed a commit to nexthop-ai/sonic-platform-common that referenced this pull request Aug 27, 2026
rebuild-source: sonic-net#742 @ nexthop-ai/sonic-platform-common 8d68046 [case: upstream:open]
nh-grecs Bot pushed a commit to nexthop-ai/sonic-platform-common that referenced this pull request Aug 27, 2026
rebuild-source: sonic-net#742 @ nexthop-ai/sonic-platform-common 8d68046 [case: upstream:open]
nh-grecs Bot pushed a commit to nexthop-ai/sonic-platform-common that referenced this pull request Aug 28, 2026
rebuild-source: sonic-net#742 @ nexthop-ai/sonic-platform-common 8d68046 [case: upstream:open]
nh-grecs Bot pushed a commit to nexthop-ai/sonic-platform-common that referenced this pull request Aug 29, 2026
rebuild-source: sonic-net#742 @ nexthop-ai/sonic-platform-common 8d68046 [case: upstream:open]
nh-grecs Bot pushed a commit to nexthop-ai/sonic-platform-common that referenced this pull request Aug 29, 2026
rebuild-source: sonic-net#742 @ nexthop-ai/sonic-platform-common 8d68046 [case: upstream:open]
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.

5 participants