Skip to content

Conversation

Keshavg-marvell
Copy link

@Keshavg-marvell Keshavg-marvell commented Jun 3, 2025

Description

What is the Issue:

For newly created breakout ports, the NPU_SI_SETTINGS_SYNC_STATUS value is not getting set in the STATE_DB's PORT_TABLE. This is normally done during xcvrd init for all the port present in system using initialize_port_init_control_fields_in_port_table(). Due to this during SI setting programming for DPB ports, the code fails to locate the NPU_SI_SETTINGS_SYNC_STATUS key in the STATE_DB, resulting in an below syslog error.

sonic ERR pmon#chassis: Get value by key from STATE_DB: Unable to
 find key NPU_SI_SETTINGS_SYNC_STATUS state_port_table_fvs_dict
 {'host_tx_ready': 'false', 'state': 'ok', 'netdev_oper_status':
 'down', 'admin_status': 'down', 'mtu': '9100', 'supported_speeds':
 '50000,100000', 'supported_fecs': 'rs'} for lport Ethernet448

Fix:
Set the NPU_SI_SETTINGS_SYNC_STATUS to NPU_SI_SETTINGS_DEFAULT_VALUE value in State DB on the event of "port_event_helper.PortChangeEvent.PORT_ADD" in on_add_logical_port() which get trigged for newly added DPB ports.

This PR fixes below issue:
#621

Motivation and Context

To fix error seen in syslog during port breakout

How Has This Been Tested?

Verified that syslog ERR is not seen with breakout CLI
sudo config interface breakout Ethernet448 "8x100G[50G,25G]" -y -f

Back port request

  • 202012
  • 202205
  • 202305
  • 202311
  • 202405
  • 202411
  • 202505

Additional Information (Optional)

…slog error

What is the Issue:

For newly created breakout ports, the NPU_SI_SETTINGS_SYNC_STATUS
value is not getting set in the STATE_DB's PORT_TABLE. This is
normally done during xcvrd init for all the port present in system
using initialize_port_init_control_fields_in_port_table(). Due to this
during SI setting programming for DPB ports, the code fails to locate the
NPU_SI_SETTINGS_SYNC_STATUS key in the STATE_DB, resulting in an
below syslog error.

sonic ERR pmon#chassis: Get value by key from STATE_DB: Unable to
 find key NPU_SI_SETTINGS_SYNC_STATUS state_port_table_fvs_dict
 {'host_tx_ready': 'false', 'state': 'ok', 'netdev_oper_status':
 'down', 'admin_status': 'down', 'mtu': '9100', 'supported_speeds':
 '50000,100000', 'supported_fecs': 'rs'} for lport Ethernet448

Fix:
Set the NPU_SI_SETTINGS_SYNC_STATUS to NPU_SI_SETTINGS_DEFAULT_VALUE value
in State DB on the event of "port_event_helper.PortChangeEvent.PORT_ADD"
in on_add_logical_port() which get trigged for newly added DPB ports.

Signed-off-by: Keshav Gupta <[email protected]>
@Keshavg-marvell Keshavg-marvell requested a review from mihirpat1 June 4, 2025 04:19
@mihirpat1 mihirpat1 requested a review from Copilot June 5, 2025 02:08
Copy link

@Copilot 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 addresses an issue with breakout ports where the NPU_SI_SETTINGS_SYNC_STATUS field was missing in the STATE_DB PORT_TABLE, causing errors during SI setting programming. Key changes include adding initialization of NPU_SI_SETTINGS_SYNC_STATUS in the xcvrd on_add_logical_port() function and updating tests to mock the state port table.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
sonic-xcvrd/xcvrd/xcvrd.py Added logic to initialize NPU_SI_SETTINGS_SYNC_STATUS for new logical ports
sonic-xcvrd/tests/test_xcvrd.py Updated tests to include the state port table mock setup
Comments suppressed due to low confidence (1)

sonic-xcvrd/tests/test_xcvrd.py:3600

  • Consider adding explicit assertions to verify that NPU_SI_SETTINGS_SYNC_STATUS is correctly set in the state DB during the logical port addition. This would help ensure the new behavior for DPB ports is properly tested.
mock_table_helper.get_state_port_tbl = MagicMock(return_value=mock_table)

found, state_port_table_fvs = state_port_table.get(port_change_event.port_name)
if not found:
helper_logger.log_notice("Add logical port: Creating STATE_DB PORT_TABLE as unable to find for lport {}".format(port_change_event.port_name))
state_port_table_fvs = []
Copy link

Copilot AI Jun 5, 2025

Choose a reason for hiding this comment

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

Consider verifying the conversion of state_port_table_fvs to a dictionary when it may be an empty list. Adding a clarifying comment on the expected structure of state_port_table_fvs could improve maintainability.

Suggested change
state_port_table_fvs = []
state_port_table_fvs = []
# Verify the structure of state_port_table_fvs and clarify its expected format.
# Expected: A list of key-value pairs (e.g., [(key1, value1), (key2, value2)]) or an empty list.
if not isinstance(state_port_table_fvs, list) or not all(isinstance(item, tuple) and len(item) == 2 for item in state_port_table_fvs):
helper_logger.log_error("Invalid structure for state_port_table_fvs: {}".format(state_port_table_fvs))
state_port_table_fvs = []

Copilot uses AI. Check for mistakes.

@mihirpat1
Copy link
Contributor

/azpw run

@mssonicbld
Copy link
Collaborator

Only PR owner can use /azpw run

@mihirpat1
Copy link
Contributor

/azp run

Copy link

Commenter does not have sufficient privileges for PR 622 in repo sonic-net/sonic-platform-daemons

@mihirpat1
Copy link
Contributor

@Keshavg-marvell Where is the below log defined? Asking since I couldn't find it in xcvrd

sonic ERR pmon#chassis: Get value by key from STATE_DB: Unable to
 find key NPU_SI_SETTINGS_SYNC_STATUS state_port_table_fvs_dict
 {'host_tx_ready': 'false', 'state': 'ok', 'netdev_oper_status':
 'down', 'admin_status': 'down', 'mtu': '9100', 'supported_speeds':
 '50000,100000', 'supported_fecs': 'rs'} for lport Ethernet448

@Keshavg-marvell
Copy link
Author

@Keshavg-marvell Where is the below log defined? Asking since I couldn't find it in xcvrd

sonic ERR pmon#chassis: Get value by key from STATE_DB: Unable to
 find key NPU_SI_SETTINGS_SYNC_STATUS state_port_table_fvs_dict
 {'host_tx_ready': 'false', 'state': 'ok', 'netdev_oper_status':
 'down', 'admin_status': 'down', 'mtu': '9100', 'supported_speeds':
 '50000,100000', 'supported_fecs': 'rs'} for lport Ethernet448

this logs get printed in below code.

https://github.com/sonic-net/sonic-platform-daemons/blob/master/sonic-xcvrd/xcvrd/xcvrd_utilities/xcvr_table_helper.py#L216

@mihirpat1
Copy link
Contributor

@Keshavg-marvell Where is the below log defined? Asking since I couldn't find it in xcvrd

sonic ERR pmon#chassis: Get value by key from STATE_DB: Unable to
 find key NPU_SI_SETTINGS_SYNC_STATUS state_port_table_fvs_dict
 {'host_tx_ready': 'false', 'state': 'ok', 'netdev_oper_status':
 'down', 'admin_status': 'down', 'mtu': '9100', 'supported_speeds':
 '50000,100000', 'supported_fecs': 'rs'} for lport Ethernet448

this logs get printed in below code.

https://github.com/sonic-net/sonic-platform-daemons/blob/master/sonic-xcvrd/xcvrd/xcvrd_utilities/xcvr_table_helper.py#L216

@Keshavg-marvell Wondering why are we seeing chassis instead of xcvrd in the process log.
Also, the changes look good to me.

@Keshavg-marvell
Copy link
Author

@Keshavg-marvell Where is the below log defined? Asking since I couldn't find it in xcvrd

sonic ERR pmon#chassis: Get value by key from STATE_DB: Unable to
 find key NPU_SI_SETTINGS_SYNC_STATUS state_port_table_fvs_dict
 {'host_tx_ready': 'false', 'state': 'ok', 'netdev_oper_status':
 'down', 'admin_status': 'down', 'mtu': '9100', 'supported_speeds':
 '50000,100000', 'supported_fecs': 'rs'} for lport Ethernet448

this logs get printed in below code.
https://github.com/sonic-net/sonic-platform-daemons/blob/master/sonic-xcvrd/xcvrd/xcvrd_utilities/xcvr_table_helper.py#L216

@Keshavg-marvell Wondering why are we seeing chassis instead of xcvrd in the process log. Also, the changes look good to me.

@mihirpat1 I believe this chassis is appended from common syslog infra used by xcvrd. if changes looks good. Can you please review and merge this PR.

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.

LGTM. However, not sure why the PR checkers have not yet triggered for this PR.

@Keshavg-marvell
Copy link
Author

/azpw run Azure.sonic-platform-daemons

@mssonicbld
Copy link
Collaborator

/AzurePipelines run Azure.sonic-platform-daemons

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@Keshavg-marvell
Copy link
Author

Thanks @mihirpat1 for the review. I have retrigged the pipelines, and now all checks are passing. Can you please merge this PR now?

@Keshavg-marvell
Copy link
Author

@prgeor Can you please review and merge this PR?

state_port_table = self.xcvr_table_helper.get_state_port_tbl(port_change_event.asic_id)
found, state_port_table_fvs = state_port_table.get(port_change_event.port_name)
if not found:
helper_logger.log_notice("Add logical port: Creating STATE_DB PORT_TABLE as unable to find for lport {}".format(port_change_event.port_name))
Copy link
Collaborator

Choose a reason for hiding this comment

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

@Keshavg-marvell can we make it debug log?

Copy link
Author

Choose a reason for hiding this comment

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

Thanks @prgeor for the review. Same log level is there in normal port add during xcvrd init at below place. Do we change there as well to be consistent for both the cases?

self.log_notice("Port init control: Creating STATE_DB PORT_TABLE as unable to find for lport {}".format(lport))

Copy link
Collaborator

Choose a reason for hiding this comment

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

@Keshavg-marvell @mihirpat1 can we call initialize_port_init_control_fields_in_port_table() in on_add_logical_port() instead of calling it in daemon init() function? This way we dont have to handle breakout scenario differently?

if NPU_SI_SETTINGS_SYNC_STATUS_KEY not in dict(state_port_table_fvs):
state_port_table.set(port_change_event.port_name, [(NPU_SI_SETTINGS_SYNC_STATUS_KEY,
NPU_SI_SETTINGS_DEFAULT_VALUE)])
helper_logger.log_notice("Add logical port: Initialized NPU_SI_SETTINGS_SYNC_STATUS for lport {}".format(port_change_event.port_name))
Copy link
Collaborator

Choose a reason for hiding this comment

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

@Keshavg-marvell debug instaed of notice log?

Copy link
Author

Choose a reason for hiding this comment

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

Thanks @prgeor for the review. Same log level is there in normal port add during xcvrd init at below place. Do we change there as well to be consistent for both the cases?

self.log_notice("Port init control: Initialized NPU_SI_SETTINGS_SYNC_STATUS for lport {}".format(lport))

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.

4 participants