Skip to content

Platform Support for CPO#682

Open
bgallagher-nexthop wants to merge 11 commits into
sonic-net:masterfrom
nexthop-ai:cpo-separate-eeprom-access
Open

Platform Support for CPO#682
bgallagher-nexthop wants to merge 11 commits into
sonic-net:masterfrom
nexthop-ai:cpo-separate-eeprom-access

Conversation

@bgallagher-nexthop
Copy link
Copy Markdown
Contributor

@bgallagher-nexthop bgallagher-nexthop commented May 29, 2026

Description

This PR makes the following changes:

  • Creates mixin classes that contain EEPROM read/write functionality and optoe functionality.
  • Refactors SfpBase and SfpOptoeBase to use these mixin classes.
  • Adds CPO base classes that leverage the above EEPROM read/write classes: CpoBase, OeBase, ElsfpBase, OptoeOeBase, OptoeElsfpBase.
  • Adds a CPO API factory class that handles instantiation of the appropriate API based on the type of CPO hardware.

Motivation and Context

This change is required to implement a platform data model for CPO hardware that SONiC daemons can use.

How Has This Been Tested?

Unit-tests have been added. Later on, when vendors extend the CPO API factory code with changes for their own platforms, the unit-tests will be extended to be more useful.

Signed-off-by: Brian Gallagher <bgallagher@nexthop.ai>
Signed-off-by: Brian Gallagher <bgallagher@nexthop.ai>
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).

@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Signed-off-by: Brian Gallagher <bgallagher@nexthop.ai>
@bgallagher-nexthop bgallagher-nexthop force-pushed the cpo-separate-eeprom-access branch from e21b2ec to 025551a Compare May 29, 2026 00:34
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Comment thread sonic_platform_base/sonic_xcvr/optoe_eeprom_rw.py
Comment thread sonic_platform_base/sonic_xcvr/optoe_eeprom_rw.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).

@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Signed-off-by: Brian Gallagher <bgallagher@nexthop.ai>
@bgallagher-nexthop bgallagher-nexthop force-pushed the cpo-separate-eeprom-access branch from 7436ad6 to 76b9602 Compare May 29, 2026 20:13
@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 marked this pull request as ready for review May 29, 2026 20:40
@prgeor prgeor requested a review from Copilot June 1, 2026 17:19
Comment thread sonic_platform_base/sonic_xcvr/sfp_optoe_base.py
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 extends sonic_platform_base’s transceiver abstractions to support CPO (Co-Packaged Optics) by factoring common EEPROM read/write behavior into reusable mixins, refactoring existing SFP base classes to use them, and introducing new CPO base classes plus a factory for selecting the correct CPO API implementation.

Changes:

  • Introduces shared EEPROM helper utilities (eeprom_rw.py) and an Optoe-specific EEPROM R/W mixin (optoe_eeprom_rw.py), and reuses them from XcvrApiFactory and SfpOptoeBase.
  • Adds initial CPO base abstractions (OeBase, ElsfpBase, CpoBase, plus Optoe variants) and a CpoApiFactory scaffold.
  • Adds/updates unit tests around the Optoe helpers and the new CPO base/factory scaffolding.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
tests/sonic_xcvr/test_sfp_optoe_base.py Updates Optoe constant imports and adds tests for newly-factored Optoe EEPROM helper behavior.
tests/sonic_xcvr/test_cpo_base.py Adds tests for basic caching/initialization behavior of new CPO base classes.
tests/sonic_xcvr/test_cpo_api_factory.py Adds tests asserting current factory behavior (raising ValueError for unsupported/unimplemented selection).
sonic_platform_base/sonic_xcvr/xcvr_api_factory.py Refactors vendor/id EEPROM parsing to use new shared helper functions.
sonic_platform_base/sonic_xcvr/sfp_optoe_base.py Refactors SfpOptoeBase to use the new Optoe EEPROM R/W mixin instead of local implementations.
sonic_platform_base/sonic_xcvr/optoe_eeprom_rw.py Adds Optoe-specific EEPROM R/W mixin and related sysfs helper methods.
sonic_platform_base/sonic_xcvr/eeprom_rw.py Adds shared EEPROM helper functions and an EEPROM R/W mixin interface.
sonic_platform_base/sonic_xcvr/cpo_optoe_base.py Adds Optoe-based OE/ELSFP base classes combining CPO bases with Optoe EEPROM mixin.
sonic_platform_base/sonic_xcvr/cpo_base.py Adds initial CPO base classes (OeBase, ElsfpBase, CpoBase) with API caching hooks.
sonic_platform_base/sonic_xcvr/cpo_api_factory.py Adds CPO API factory scaffolding and hardware-id types for selecting implementations.
sonic_platform_base/sfp_base.py Refactors SfpBase to inherit the new EEPROM R/W mixin interface.

Comment thread sonic_platform_base/sonic_xcvr/optoe_eeprom_rw.py
Comment thread sonic_platform_base/sonic_xcvr/optoe_eeprom_rw.py
Comment thread sonic_platform_base/sonic_xcvr/eeprom_rw.py Outdated
Comment thread sonic_platform_base/sonic_xcvr/eeprom_rw.py Outdated
Comment thread sonic_platform_base/sonic_xcvr/eeprom_rw.py Outdated
Comment thread sonic_platform_base/sonic_xcvr/cpo_base.py Outdated
Comment thread sonic_platform_base/sonic_xcvr/cpo/cpo_api_factory.py Outdated
Comment thread sonic_platform_base/sfp_base.py Outdated
Comment thread sonic_platform_base/sonic_xcvr/cpo/cpo_base.py Outdated
Comment thread sonic_platform_base/sonic_xcvr/cpo/cpo_base.py Outdated
Comment thread sonic_platform_base/sonic_xcvr/eeprom_rw.py Outdated
Comment thread sonic_platform_base/sonic_xcvr/cpo/cpo_api_factory.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).

Comment on lines +32 to +34
def create_oe_api(self):
# if self._oe.hardware_id.oe_id == OeId.EXAMPLE:
# self._create_api(...)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What is the benefit of having _create_api take the full list of vendors? We already know the oe vendor from the platform.
For ELS, I can understand it, since it may be used across different platforms.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is primarily to keep the same consistent approach for instantiating an API between the OE and the ELSFP. It also keeps the logic for API instantiation in common, public code as opposed to hidden in vendor platform code.

The vendor will pass in the CpoHardwareId from their code, then sonic-platform-common code knows how to handle the rest.

cc @prgeor as the original suggester of this ID-based approach, in case you have any additional motivation for this approach you'd like to mention

Comment thread sonic_platform_base/sonic_xcvr/cpo/cpo_base.py Outdated
Comment thread sonic_platform_base/sonic_xcvr/cpo/cpo_api_factory.py Outdated
Comment thread sonic_platform_base/sonic_xcvr/cpo/cpo_api_factory.py Outdated
…s sharing more logic

Signed-off-by: Brian Gallagher <bgallagher@nexthop.ai>
…FP functionality are in oe.py and elsfp.py

Signed-off-by: Brian Gallagher <bgallagher@nexthop.ai>
Signed-off-by: Brian Gallagher <bgallagher@nexthop.ai>
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

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.

@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

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