Skip to content

CPO SW Control Vmodule Statistics platform changes#708

Draft
Natgerbi wants to merge 1 commit into
sonic-net:masterfrom
Natgerbi:ngerbi-vmodule-stats
Draft

CPO SW Control Vmodule Statistics platform changes#708
Natgerbi wants to merge 1 commit into
sonic-net:masterfrom
Natgerbi:ngerbi-vmodule-stats

Conversation

@Natgerbi

@Natgerbi Natgerbi commented Jul 9, 2026

Copy link
Copy Markdown

Description

Motivation and Context

How Has This Been Tested?

Additional Information (Optional)

Signed-off-by: Natanel Gerbi <ngerbi@nvidia.com>
@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

Hi, there are workflow run(s) waiting for approval, you may be first-time contributor. I will notify maintainers to help approve once PR is approved. Thanks!

---Powered by SONiC BuildBot

@bgallagher-nexthop bgallagher-nexthop 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.

There seems to be some unrelated changes possibly in this PR (e.g cmis page changes, c-cmis changes), i assume these might be old changes

NUM_ELSFP_LANES = 8


class ElsfpCmisApi(XcvrApi, CdbCapableMixin):

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.

There already exists an ElsfpApi. It does not contain some of the aggregate methods like get_transceiver_dom_real_value or have CDB support, but is designed to be easily extended to contain that type of functionality.

Could you extend that class so we have one ElsfpApi defined in the platform layer?

Comment on lines +16 to +17
def __init__(self, optical_engine_xcvr_api, external_laser_source_xcvr_api) -> None:
super().__init__(optical_engine_xcvr_api.xcvr_eeprom)

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.

I was initially thinking this approach is the best strategy for aggregating/combining OE and ELSFP data, but I think it might be simpler to just do that work in xcvrd code as opposed to the platform API layer.

The xcvr API lifecycle is complicated in this approach. The aggregate CpoApi and ELSFP API both need to be destroyed and re-built upon an ELSFP plug-in and plug-out event in order to ensure they are not stale. That means CpoBase needs its own xcvr lifecycle events with a correct implementation that destroys the ELSFP API and CpoApi in remove_xcvr_api and re-creates both in the refresh_xcvr_api functions.

Since we've already committed in xcvrd to directly use the new CPO API objects, I think we can just do the aggregation in xcvrd code.

CpoBase can provide the OE API to xcvrd by default -- this ensures backwards compatibility in CMIS state machine logic and other places:

class CpoBase(device_base.DeviceBase):
    def __init__(self, hardware_id: CpoHardwareInfo, oe: "OeBase", elsfp: "ElsfpBase"):
        self.hardware_id = hardware_id
        self.oe = oe
        self.elsfp = elsfp

    def refresh_xcvr_api(self):
        self.oe.refresh_api()
        self.elsfp.refresh_api()

    def get_xcvr_api(self):
        # We always default to the OE API for CPO. If the ELSFP API is required,
        # then that can be accessed via self.elsfp.get_api() directly.
        return self.oe.get_api()

    def remove_xcvr_api(self):
        self.oe.remove_api()
        self.elsfp.remove_api()

Then, in the CPO-specific areas of xcvrd, we can just directly interact with the OE and ELSFP APIs (and perform aggregation optionally if needed):

    def post_cpo_port_dom_sensor_info_to_db(self, logical_port_name, db_cache=None):
        asic_index = self.port_mapping.get_asic_id_for_logical_port(logical_port_name)
        if asic_index is None:
            self.logger.log_error(f"CPO: Post port dom sensor info to db failed for {logical_port_name} "
                                  "as no asic index found")
            return

        oe_result = self.post_diagnostic_values_to_db(logical_port_name,
                                                 self.xcvr_table_helper.get_dom_tbl(asic_index),
                                                 self.cpo_dom_utils.get_oe_transceiver_dom_sensor_real_value,
                                                 db_cache=db_cache,
                                                 beautify_func=self._beautify_dom_info_dict)
        elsfp_result = self.post_diagnostic_values_to_db(logical_port_name,
                                                 self.xcvr_table_helper.get_dom_tbl(asic_index),
                                                 self.cpo_dom_utils.get_elsfp_transceiver_dom_sensor_real_value,
                                                 db_cache=db_cache,
                                                 beautify_func=self._beautify_dom_info_dict)
        return oe_result and elsfp_result

This also eliminates the problem of merging the results and having to care about key collisions and such.

"Errored Frames Average Host Input" : "errored_frames_avg_host_input",
"Errored Frames Current Value Host Input" : "errored_frames_curr_host_input"
"Errored Frames Current Value Host Input" : "errored_frames_curr_host_input",
"ELS Input Power [dBm]" : "els_input_power"

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.

This would probably be better housed in some elsfp specific file, since it is not necessarily related to the regular CmisApi

2: 4
}

CONTROL_MODE = {

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.

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