-
Notifications
You must be signed in to change notification settings - Fork 192
Xcvrd Refactor 2/12: Move CmisManagerTask into it's own module #691
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
base: master
Are you sure you want to change the base?
Xcvrd Refactor 2/12: Move CmisManagerTask into it's own module #691
Conversation
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this 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 moves the CmisManagerTask class from the main xcvrd.py file into its own dedicated module as part of a larger refactoring effort to improve code organization and maintainability.
Key changes:
- Moves CmisManagerTask class to xcvrd/cmis/cmis_manager_task.py
- Migrates CMIS state constants and common functions to xcvrd_utilities/common.py
- Updates imports and references throughout the codebase to use the new module structure
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| sonic-xcvrd/xcvrd/xcvrd_utilities/common.py | Adds CMIS state constants and is_syncd_warm_restore_complete function |
| sonic-xcvrd/xcvrd/xcvrd.py | Removes CmisManagerTask class and related functions, updates imports and constructor call |
| sonic-xcvrd/xcvrd/dom/dom_mgr.py | Updates import to use CMIS_TERMINAL_STATES from common module |
| sonic-xcvrd/xcvrd/cmis/cmis_manager_task.py | New file containing the extracted CmisManagerTask class |
| sonic-xcvrd/xcvrd/cmis/init.py | Module initialization file for the cmis package |
| sonic-xcvrd/tests/test_xcvrd.py | Updates test imports and patches to use new module structure |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bobby-nexthop Can you please help with the below
- Can you please capture a sample log message from a CMIS manager related log
- Capture log showing all the expected threads of xcvrd are spawned
| self.xcvr_table_helper = XcvrTableHelper(self.namespaces) | ||
|
|
||
| def log_debug(self, message): | ||
| helper_logger.log_debug("CMIS: {}".format(message)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bobby-nexthop Wondering if we still need to have CMIS: in the log since the syslogger now should display the thread name by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2025 Oct 24 19:19:24.176885 sonic NOTICE pmon#CmisManagerTask[32]: CMIS: Ethernet56: READY
2025 Oct 24 19:19:24.178387 sonic NOTICE pmon#CmisManagerTask[32]: CMIS: Ethernet56: updated TRANSCEIVER_INFO_TABLE [('active_apsel_hostlane1', '1'), ('active_apsel_hostlane2', '1'), ('active_apsel_hostlane3', '1'), ('active_apsel_hostlane4', '1'), ('active_apsel_hostlane5', '1'), ('active_apsel_hostlane6', '1'), ('active_apsel_hostlane7', '1'), ('active_apsel_hostlane8', '1'), ('host_lane_count', '8'), ('media_lane_count', '8')]
and
2025 Oct 24 19:19:17.758374 sonic NOTICE pmon#xcvrd[32]: Started thread SffManagerTask
2025 Oct 24 19:19:17.758374 sonic NOTICE pmon#xcvrd[32]: Started thread CmisManagerTask
2025 Oct 24 19:19:17.758374 sonic NOTICE pmon#xcvrd[32]: Started thread DomInfoUpdateTask
2025 Oct 24 19:19:17.758478 sonic NOTICE pmon#xcvrd[32]: Started thread SfpStateUpdateTask
I agree the CMIS is now redundant. Let me update that and push.
0162f09 to
494dd0d
Compare
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
494dd0d to
39beb67
Compare
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| def log_debug(self, message): | ||
| helper_logger.log_debug(message) | ||
|
|
||
| def log_notice(self, message): | ||
| helper_logger.log_notice(message) | ||
|
|
||
| def log_error(self, message): | ||
| helper_logger.log_error(message) | ||
|
|
Copilot
AI
Oct 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logging methods are simple wrappers that add no value and could be replaced with direct calls to helper_logger. This would reduce code duplication and simplify maintenance. Alternatively, if custom formatting is needed, the wrapper methods should add the "CMIS: " prefix that was present in the original implementation.
| def log_debug(self, message): | |
| helper_logger.log_debug(message) | |
| def log_notice(self, message): | |
| helper_logger.log_notice(message) | |
| def log_error(self, message): | |
| helper_logger.log_error(message) |
| # A retry should always start over at INSETRTED state, while the | ||
| # expiration will reset the state to INSETRTED and advance the |
Copilot
AI
Oct 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected spelling of 'INSERTED' in the comment. The original version had 'INSETRTED'.
| # A retry should always start over at INSETRTED state, while the | |
| # expiration will reset the state to INSETRTED and advance the | |
| # A retry should always start over at INSERTED state, while the | |
| # expiration will reset the state to INSERTED and advance the |
| # A retry should always start over at INSETRTED state, while the | ||
| # expiration will reset the state to INSETRTED and advance the |
Copilot
AI
Oct 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected spelling of 'INSERTED' in the comment. The original version had 'INSETRTED'.
| # A retry should always start over at INSETRTED state, while the | |
| # expiration will reset the state to INSETRTED and advance the | |
| # A retry should always start over at INSERTED state, while the | |
| # expiration will reset the state to INSERTED and advance the |
|
|
||
| need_update = self.is_cmis_application_update_required(api, appl, host_lanes_mask) | ||
|
|
||
| # For ZR module, Datapath needs to be re-initialized on new channel selection |
Copilot
AI
Oct 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Inconsistent capitalization: 'needs' should be 'needs' (lowercase 'n') for consistency, or change 'Datapath' to 'datapath' for consistency with the rest of the comment style in the file.
| # For ZR module, Datapath needs to be re-initialized on new channel selection | |
| # For ZR module, datapath needs to be re-initialized on new channel selection |
| self.force_cmis_reinit(lport, retries + 1) | ||
| continue | ||
|
|
||
| # Ensure the Datapath is NOT Activated unless the host Tx siganl is good. |
Copilot
AI
Oct 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected spelling of 'signal' in the comment. The original version had 'siganl'.
| # Ensure the Datapath is NOT Activated unless the host Tx siganl is good. | |
| # Ensure the Datapath is NOT Activated unless the host Tx signal is good. |
| self.update_cmis_state_expiration_time(lport, max(modulePwrUpDuration, dpDeinitDuration)) | ||
|
|
||
| elif state == CMIS_STATE_AP_CONF: | ||
| # Explicit control bit to apply custom Host SI settings. |
Copilot
AI
Oct 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The comment spacing is inconsistent with a trailing space after the period on line 971, while line 972 has no trailing space. This should be standardized for consistency.
Description
No logic changes. The changes are:
Motivation and Context
xcvrd has gotten to 4000 lines long. To make things easier, we'd like to refactor it. This is the second PR in a series that aims to do the following:
The new flow will go from calling

task_worker()toHow Has This Been Tested?
Additional Information (Optional)