Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sfputil power enable/disable command #3418

Merged
merged 19 commits into from
Jul 26, 2024
Merged

Conversation

AnoopKamath
Copy link
Contributor

@AnoopKamath AnoopKamath commented Jul 13, 2024

What I did

High-speed modules nowadays use a significant amount of power, and having the ability to control each port's optical power enables the disabling of power to ports that are not in use, thus helping to reduce overall power consumption. This feature can also assist in recovering the link in the following scenarios without the need for a physical reseat or OIR.

Issue with optics power ON sequencing (ie. AOI 40G PLR4)

A buggy optic (rendering other ports / optics inaccessible)

Link goes down following a reboot

Link CRC error

Port flaps

An optic entering into a ghost debug mode (optics vendor specific) on one platform but same optic has no issue on another platform

How I did it

Add new config interface command

sfputil power disable EthernetXX
sfputil power enable EthernetXX

How to verify it

HW team help probe the power pin and confirmed it to be disabled and enabled

Previous command output (if the output of a command-line utility has changed)

New command output (if the output of a command-line utility has changed)

config/main.py Outdated Show resolved Hide resolved
sfputil/main.py Show resolved Hide resolved
if result:
click.echo("OK")
else:
click.echo("Failed")
Copy link
Contributor

Choose a reason for hiding this comment

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

@AnoopKamath Please return result or non-zero error code to distinguish failure.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mihirpat1 : Since this only api do we need to address this comment?

Copy link
Contributor

Choose a reason for hiding this comment

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

@AnoopKamath - Yes - returning non-zero in case of an error will help the caller in knowing if the command was successful or not so that the caller can handle error scenario accordingly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mihirpat1 - The platform handler, which toggles GPIO pin sends TRUE on success. If we need a non-zero in failed case, we should come up with different ERROR codes?

Copy link
Contributor

Choose a reason for hiding this comment

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

@AnoopKamath Based on my understanding, the set_power API returns False upon error.
The result variable in the current context already has this info.
The current API can return result and the caller can return the error code to the user. You can return EXIT_FAIL to the user as well upon error and EXIT_SUCCESS upon success.

@AnoopKamath AnoopKamath changed the title Add config power enable/disable command Add sfputil power enable/disable command Jul 25, 2024
@click.argument('port_name', metavar='<port_name>')
def disable(port_name):
"""Disable power of SFP transceiver"""
set_power(port_name, False)
Copy link
Contributor

Choose a reason for hiding this comment

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

@AnoopKamath Please check for the return status of this API and handle error case accordingly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are different error handling at sfputil layer itself. Platform call just tries toggling GPIO pin and on error case there are logs printed on console. EX: power fault detected.. etc. It will still return success

@prgeor prgeor merged commit 9b24421 into sonic-net:master Jul 26, 2024
7 checks passed
@mssonicbld
Copy link
Collaborator

Cherry-pick PR to 202405: #3638

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants