Skip to content

Commit

Permalink
[Xcvrd]: Fix optics insertion/removal not detected (#333)
Browse files Browse the repository at this point in the history
* [Xcvrd]: Fix optics insertion/removal not detected

* log_info() -> log_notice()
  • Loading branch information
prgeor authored Jan 19, 2023
1 parent 2211b7e commit a931d6c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
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 @@ -1926,7 +1926,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 @@ -1939,15 +1939,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_notice("{}: 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_notice("{}: 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 @@ -1962,10 +1962,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_notice("{}: 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_notice("{}: 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 @@ -1975,7 +1975,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_error("{}: Got SFP error event {}".format(logical_port, value))

error_descriptions = sfp_status_helper.fetch_generic_error_description(error_bits)

Expand All @@ -1989,7 +1989,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_notice("{}: 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 @@ -2001,7 +2001,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

0 comments on commit a931d6c

Please sign in to comment.