Skip to content

Conversation

@bobby-nexthop
Copy link
Contributor

@bobby-nexthop bobby-nexthop commented Oct 31, 2025

Description

No logic changes. This change looks like a huge diff but its just moving all of the CMIS logic into a new function process_single_lport. This is needed to make the following diffs with logic split up more readable

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:

Task PR
1) Move functions used across multiple files in xcvrd to utils/common.py #654
2) Move CmisManagerTask into cmis/cmis_manager_task.py #691
3) Split task_worker into process_lport #701
4) Rename xcvrd/xcvrd_utilities to xcvrd/utils bobby-nexthop#3
5) Add handle_cmis_inserted_state function bobby-nexthop#4
6) Add handle_cmis_dp_pre_init_check_state function bobby-nexthop#5
7) Add handle_cmis_dpdeinit_state function bobby-nexthop#6
8) Add handle_cmis_ap_conf_state function bobby-nexthop#7
9) Add handle_cmis_dp_init_state bobby-nexthop#8
10) Add handle_cmis_txon_state bobby-nexthop#9
11) Add handle_cmis_activate_state bobby-nexthop#10

The new flow will go from calling task_worker() to
CMIS Refactor Flow

How Has This Been Tested?

  1. All unit tests pass
  2. tested on device with no issues, links all up.

Additional Information (Optional)

@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mihirpat1 mihirpat1 requested a review from Copilot November 3, 2025 22:46
Copy link
Contributor

@mihirpat1 mihirpat1 left a 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 fix the test failure?

Copy link

Copilot AI left a 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 refactors the task_worker method by extracting the per-port processing logic into a new process_single_lport method. The main change improves code organization and maintainability by separating concerns.

  • Extracted port processing logic from task_worker into a new process_single_lport method
  • Replaced all continue statements with return statements to match the new function structure
  • Moved gearbox_lanes_dict initialization from loop-level to function-level

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mihirpat1 mihirpat1 requested a review from Copilot November 13, 2025 22:54
Copilot finished reviewing on behalf of mihirpat1 November 13, 2025 22:55
if self.task_stopping_event.is_set():
break

if lport not in self.port_dict:
Copy link
Contributor

Choose a reason for hiding this comment

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

@bobby-nexthop Wondering in what scenario will self.port_dict not contain lport?

Copy link

Copilot AI left a 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 1 out of 1 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +782 to +783
# A retry should always start over at INSETRTED state, while the
# expiration will reset the state to INSETRTED and advance the
Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

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

Spelling error: "INSETRTED" should be "INSERTED".

Suggested change
# 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

Copilot uses AI. Check for mistakes.
Comment on lines +782 to +783
# A retry should always start over at INSETRTED state, while the
# expiration will reset the state to INSETRTED and advance the
Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

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

Spelling error: "INSETRTED" should be "INSERTED".

Suggested change
# 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

Copilot uses AI. Check for mistakes.
self.force_cmis_reinit(lport, retries + 1)
return

# Ensure the Datapath is NOT Activated unless the host Tx siganl is good.
Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

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

Spelling error: "siganl" should be "signal".

Suggested change
# 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.

Copilot uses AI. Check for mistakes.
if self.is_decomm_lead_lport(lport):
# Set all the DP lanes AppSel to unused(0) when non default app code needs to be configured
self.port_dict[lport]['appl'] = appl = 0
self.port_dict[lport]['host_lanes_mask'] = host_lanes_mask = self.ALL_LANES_MASK
Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

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

Variable host_lanes_mask is not used.

Suggested change
self.port_dict[lport]['host_lanes_mask'] = host_lanes_mask = self.ALL_LANES_MASK
self.port_dict[lport]['host_lanes_mask'] = self.ALL_LANES_MASK

Copilot uses AI. Check for mistakes.
@mihirpat1
Copy link
Contributor

@bobby-nexthop Can you please help to close the open comments?
Overall, the existing changes LGTM

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