Skip to content

[Xcvrd]: Fix optics insertion/removal not detected #333

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

Merged
merged 2 commits into from
Jan 19, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion sonic-xcvrd/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
'License :: OSI Approved :: Apache Software License',
'Natural Language :: English',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.7',
'Topic :: System :: Hardware',
],
Expand Down
18 changes: 9 additions & 9 deletions sonic-xcvrd/xcvrd/xcvrd.py
Original file line number Diff line number Diff line change
Expand Up @@ -1896,7 +1896,7 @@ def task_worker(self, stopping_event, sfp_error_event):
self.sfp_error_dict[key] = (value, error_dict)
else:
self.sfp_error_dict.pop(key, None)
logical_port_list = self.port_mapping.get_physical_to_logical(key)
logical_port_list = self.port_mapping.get_physical_to_logical(int(key))
if logical_port_list is None:
helper_logger.log_warning("Got unknown FP port index {}, ignored".format(key))
continue
Expand All @@ -1909,15 +1909,15 @@ def task_worker(self, stopping_event, sfp_error_event):
continue

if value == sfp_status_helper.SFP_STATUS_INSERTED:
helper_logger.log_info("Got SFP inserted event")
helper_logger.log_info("{}: Got SFP inserted event".format(logical_port))
# A plugin event will clear the error state.
update_port_transceiver_status_table_sw(
logical_port, self.xcvr_table_helper.get_status_tbl(asic_index), sfp_status_helper.SFP_STATUS_INSERTED)
helper_logger.log_info("receive plug in and update port sfp status table.")
helper_logger.log_info("{}: received plug in and update port sfp status table.".format(logical_port))
rc = post_port_sfp_info_to_db(logical_port, self.port_mapping, self.xcvr_table_helper.get_intf_tbl(asic_index), transceiver_dict)
# If we didn't get the sfp info, assuming the eeprom is not ready, give a try again.
if rc == SFP_EEPROM_NOT_READY:
helper_logger.log_warning("SFP EEPROM is not ready. One more try...")
helper_logger.log_warning("{}: SFP EEPROM is not ready. One more try...".format(logical_port))
time.sleep(TIME_FOR_SFP_READY_SECS)
rc = post_port_sfp_info_to_db(logical_port, self.port_mapping, self.xcvr_table_helper.get_intf_tbl(asic_index), transceiver_dict)
if rc == SFP_EEPROM_NOT_READY:
Expand All @@ -1932,10 +1932,10 @@ def task_worker(self, stopping_event, sfp_error_event):
notify_media_setting(logical_port, transceiver_dict, self.xcvr_table_helper.get_app_port_tbl(asic_index), self.port_mapping)
transceiver_dict.clear()
elif value == sfp_status_helper.SFP_STATUS_REMOVED:
helper_logger.log_info("Got SFP removed event")
helper_logger.log_info("{}: Got SFP removed event".format(logical_port))
update_port_transceiver_status_table_sw(
logical_port, self.xcvr_table_helper.get_status_tbl(asic_index), sfp_status_helper.SFP_STATUS_REMOVED)
helper_logger.log_info("receive plug out and pdate port sfp status table.")
helper_logger.log_info("{}: received plug out and update port sfp status table.".format(logical_port))
del_port_sfp_dom_info_from_db(logical_port, self.port_mapping,
self.xcvr_table_helper.get_intf_tbl(asic_index),
self.xcvr_table_helper.get_dom_tbl(asic_index),
Expand All @@ -1945,7 +1945,7 @@ def task_worker(self, stopping_event, sfp_error_event):
else:
try:
error_bits = int(value)
helper_logger.log_info("Got SFP error event {}".format(value))
helper_logger.log_info("{}: Got SFP error event {}".format(logical_port, value))

error_descriptions = sfp_status_helper.fetch_generic_error_description(error_bits)

Expand All @@ -1959,7 +1959,7 @@ def task_worker(self, stopping_event, sfp_error_event):
# Add error info to database
# Any existing error will be replaced by the new one.
update_port_transceiver_status_table_sw(logical_port, self.xcvr_table_helper.get_status_tbl(asic_index), value, '|'.join(error_descriptions))
helper_logger.log_info("Receive error update port sfp status table.")
helper_logger.log_info("{}: Receive error update port sfp status table.".format(logical_port))
# In this case EEPROM is not accessible. The DOM info will be removed since it can be out-of-date.
# The interface info remains in the DB since it is static.
if sfp_status_helper.is_error_block_eeprom_reading(error_bits):
Expand All @@ -1971,7 +1971,7 @@ def task_worker(self, stopping_event, sfp_error_event):
self.xcvr_table_helper.get_pm_tbl(asic_index))
delete_port_from_status_table_hw(logical_port, self.port_mapping, self.xcvr_table_helper.get_status_tbl(asic_index))
except (TypeError, ValueError) as e:
helper_logger.log_error("Got unrecognized event {}, ignored".format(value))
helper_logger.log_error("{}: Got unrecognized event {}, ignored".format(logical_port, value))

else:
next_state = STATE_EXIT
Expand Down
3 changes: 2 additions & 1 deletion sonic-xcvrd/xcvrd/xcvrd_utilities/port_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ def get_logical_to_physical(self, port_name):
port_index = self.logical_to_physical.get(port_name)
return None if port_index is None else [port_index]

def get_physical_to_logical(self, physical_port):
def get_physical_to_logical(self, physical_port: int):
assert isinstance(physical_port, int), "{} is NOT integer".format(physical_port)
return self.physical_to_logical.get(physical_port)

def logical_port_name_to_physical_port_list(self, port_name):
Expand Down