[Mellanox] Optimize SFP modules initialization#67
Closed
Conversation
keboliu
reviewed
Apr 27, 2021
Collaborator
keboliu
left a comment
There was a problem hiding this comment.
please add more comments to describe the two new init flags
Owner
Author
Done. |
Owner
Author
|
Unit test added. |
keboliu
approved these changes
Apr 30, 2021
Originally, SFP modules were always accessed from platform daemons, and arbitrary SFP module can be accessed in the daemon. All SFP modules were initialized in one-shot once one of the following chassis APIs called - get_all_sfps - get_sfp_numbers - get_sfp Recently, we noticed that SFP modules can also be accessed from CLI, eg. the latest refactor of sfputil. In this case, only one SFP module is accessed in the chassis object's life cycle. To initialize all SFP modules in one-shot is waste of time. The new optimized flow is: - get_sfp called, only initialize the SFP module being accessed all other elements in _sfp_list are None - get_all_sfps and get_sfp_numbers called, initialize all SFP modules as usual Signed-off-by: Stephen Sun <[email protected]>
Signed-off-by: Stephen Sun <[email protected]>
Signed-off-by: Stephen Sun <[email protected]>
871e452 to
f7c2565
Compare
stephenxs
pushed a commit
that referenced
this pull request
May 19, 2022
[sonic-linkmgrd][202012] submodule update 3d13ff2 Jing Zhang Wed May 4 10:07:14 2022 -0700 Add doc for default route related changes (#63) c703be4 Jing Zhang Mon May 2 13:27:54 2022 -0700 Reset WaitActiveUp count before switching to active (#70) 86eb727 Jing Zhang Wed Apr 27 10:35:05 2022 -0700 lower log level to warning (#69) e22c736 Jing Zhang Mon May 2 13:33:24 2022 -0700 [202012] Avoid proactively switching to active if default route is missing (#67) d4f282b Jing Zhang Thu Apr 28 18:35:11 2022 -0700 [202012] Add support to enable switchover time measurement (with link prober interval decreased to 10ms) feature (#66) sign-off: Jing Zhang [[email protected]](mailto:[email protected])
stephenxs
pushed a commit
that referenced
this pull request
Jul 3, 2023
…utomatically (sonic-net#15548) #### Why I did it src/sonic-host-services ``` * 508d642 - (HEAD -> master, origin/master, origin/HEAD) [actions] Support Semgrep by Github Actions (#67) (31 hours ago) [Mai Bui] ``` #### How I did it #### How to verify it #### Description for the changelog
stephenxs
pushed a commit
that referenced
this pull request
Jul 23, 2025
…ly (sonic-net#23161) #### Why I did it src/sonic-ztp ``` * f8fa833 - (HEAD -> master, origin/master, origin/HEAD) [ci] Upgrade agent pool from ubuntu 20.04 to latest. (#67) (22 hours ago) [Liu Shilong] ``` #### How I did it #### How to verify it #### Description for the changelog
stephenxs
pushed a commit
that referenced
this pull request
Jul 23, 2025
…ically (sonic-net#23211) #### Why I did it src/sonic-dash-ha ``` * ff1b02a - (HEAD -> master, origin/master, origin/HEAD) Implement HA-Scope actor (#73) (20 hours ago) [yue-fred-gao] * 832e67a - Implement HA-SET actor (#70) (4 days ago) [yue-fred-gao] * cadfa46 - Implement vdpu actor (#67) (5 days ago) [yue-fred-gao] ``` #### How I did it #### How to verify it #### Description for the changelog
stephenxs
pushed a commit
that referenced
this pull request
Nov 18, 2025
…ly (sonic-net#24445) #### Why I did it src/dhcprelay ``` * 8772dd5 - (HEAD -> master, origin/master, origin/HEAD) [dhcp_relay] sonic dhcp relay agent for IPv4 (#67) (20 hours ago) [Shivashankar C R] ``` #### How I did it #### How to verify it #### Description for the changelog
liat-grozovik
pushed a commit
that referenced
this pull request
Feb 17, 2026
…sonic-net#25508) #### Why I did it src/dhcpmon ``` * d78974f - (HEAD -> master, origin/master, origin/HEAD) [dhcp_mon] Add missing #include <algorithm> for std::replace (#68) (31 hours ago) [rustiqly] * d4934fa - Add .github/copilot-instructions.md for AI-assisted development (#67) (31 hours ago) [rustiqly] ``` #### How I did it #### How to verify it #### Description for the changelog
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why I did it
Originally, SFP modules were always accessed from platform daemons, and arbitrary SFP modules can be accessed in the daemon. So all SFP modules were initialized in one shot once one of the following chassis APIs called
Recently, we noticed that SFP modules can also be accessed from CLI, eg. the latest refactor of
sfputil.In this case, only one SFP module is accessed in the chassis object's life cycle.
To initialize all SFP modules in one shot is waste of time and causes the CLI to take much more time to finish.
So we would like to optimize the initialization flow by introducing a two-phase initialization approach:
chassis._sfp_listhas been initialized with proper length and all elements beingNonechassis._sfp_listare createdIf the relevant function is called,
get_sfp, only partial initialization will be done, and then the specific SFP module is initialized.get_all_sfpsorget_num_sfps, full initialization will be done, which means all SFP modules are initialized.Signed-off-by: Stephen Sun [email protected]
How I did it
How to verify it
Manually test. APIs are called in the following order:
get_sfpand thenget_all_sfps.get_all_sfpsget_num_sfpsWhich release branch to backport (provide reason below if selected)
Description for the changelog
A picture of a cute animal (not mandatory but encouraged)