Skip to content

Commit

Permalink
Update on_port_update_event checks and log format
Browse files Browse the repository at this point in the history
  • Loading branch information
longhuan-cisco committed Jan 8, 2024
1 parent 5515851 commit e83f9bd
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions sonic-xcvrd/xcvrd/sff_mgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class SffManagerTask(threading.Thread):
},
{
'STATE_DB': 'PORT_TABLE',
'FILTER': [HOST_TX_READY]
'FILTER': [HOST_TX_READY] # This also filters out unwanted 'admin_status' from STATE_DB.
},
]

Expand Down Expand Up @@ -107,9 +107,12 @@ def get_active_lanes_for_lport(self, lport, subport_idx, num_lanes_per_lport, nu
"""
if subport_idx < 0 or subport_idx > num_lanes_per_pport // num_lanes_per_lport:
self.log_error(
f"{lport}: Invalid subport_idx {subport_idx} "
f"for num_lanes_per_lport={num_lanes_per_lport}, "
f"num_lanes_per_pport={num_lanes_per_pport}"
"{}: Invalid subport_idx {} "
"for num_lanes_per_lport={}, "
"num_lanes_per_pport={}".format(lport,
subport_idx,
num_lanes_per_lport,
num_lanes_per_pport)
)
return None

Expand Down Expand Up @@ -159,12 +162,7 @@ def on_port_update_event(self, port_change_event):
self.port_dict[lport][self.HOST_TX_READY] = \
port_change_event.port_dict[self.HOST_TX_READY]

if self.ADMIN_STATUS in port_change_event.port_dict and \
port_change_event.db_name and \
port_change_event.db_name == 'CONFIG_DB':
# Only consider admin_status from CONFIG_DB.
# Ignore admin_status from STATE_DB, which may have
# different value.
if self.ADMIN_STATUS in port_change_event.port_dict:
self.port_dict[lport][self.ADMIN_STATUS] = \
port_change_event.port_dict[self.ADMIN_STATUS]

Expand Down Expand Up @@ -208,7 +206,7 @@ def get_admin_status(self, lport, asic_index):

def run(self):
if self.platform_chassis is None:
self.log_notice("Platform chassis is not available, stopping...")
self.log_error("Platform chassis is not available, stopping...")
return

try:
Expand Down

0 comments on commit e83f9bd

Please sign in to comment.