Skip to content

[CPO] Extend ChassisBase to support CPO ports#700

Draft
bgallagher-nexthop wants to merge 5 commits into
sonic-net:masterfrom
nexthop-ai:chassis-cpo
Draft

[CPO] Extend ChassisBase to support CPO ports#700
bgallagher-nexthop wants to merge 5 commits into
sonic-net:masterfrom
nexthop-ai:chassis-cpo

Conversation

@bgallagher-nexthop

@bgallagher-nexthop bgallagher-nexthop commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Description

The "Port Mapping for CPO" HLD proposes changes to the Chassis object for CPO hardware platforms, where a function called construct_cpo_devices is called when an cpo.json file is present for the SONiC device. The intent is for vendors to implement construct_cpo_devices and create the CPO platform API objects required for each interface on the vendor's switch.

Example usage, from the HLD:

class VendorCpoChassis(ChassisBase):
  ...
  def construct_cpo_devices(self, cpo_data):
      for interface_name, interface in cpo_data["interfaces"].items():
          associated_devices = interface["associated_devices"]
          assert len(associated_devices) == 2, \
              "We expect 2 devices per interface on this CPO hardware platform"

          # Construct OE/ELSFP objects
          oe = None
          elsfp = None
          for dvc_info in associated_devices:
              device = cpo_data["devices"][dvc_info["device_id"]]
              if device["device_type"] == "optical_engine":
                  oe = VendorOe(hardware_id=self.hw_id, bank=dvc_info["bank"])
              elif device["device_type"] == "external_laser_source":
                  elsfp = VendorElsfp(hardware_id=self.hw_id, bank=dvc_info["bank"])

          # Create a CpoBase-derived object to represent this interface
          assert oe, "No optical engine found for this interface"
          assert elsfp, "No ELSFP found for this interface"
          # VendorCpoSfp would be a subclass of CpoSfpBase here.
          self._sfp_list.append(VendorCpo(hardware_id=self.hw_id, oe=oe, els=elsfp))

This PR adds a construct_cpo_devices stub function for vendors to implement and calls this function when cpo.json is present. It also adds function to store and retrieve CpoBase objects on a Chassis object. Additionally, it changes CPO Platform objects to inherit from DeviceBase so that they adhere to the DeviceBase interface.

Note: this PR requires sonic-net/sonic-buildimage#28077 to be merged first.

Motivation and Context

This change is required to instantiate the required platform API objects (OE, ELSFP, etc) for a Chassis that models CPO hardware.

How Has This Been Tested?

Unit-tests have been added.

@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).

@bgallagher-nexthop bgallagher-nexthop changed the title [CPO] Add construct_sfp_list_for_topology hook to ChassisBase [CPO] Extend ChassisBase to support CPO ports Jun 25, 2026
@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 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.

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).

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 thread sonic_platform_base/chassis_base.py
Comment thread sonic_platform_base/chassis_base.py Outdated
Comment thread sonic_platform_base/chassis_base.py
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).

@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>
@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