Skip to content

Commit a931d6c

Browse files
authored
[Xcvrd]: Fix optics insertion/removal not detected (#333)
* [Xcvrd]: Fix optics insertion/removal not detected * log_info() -> log_notice()
1 parent 2211b7e commit a931d6c

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

sonic-xcvrd/setup.py

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
'License :: OSI Approved :: Apache Software License',
3838
'Natural Language :: English',
3939
'Operating System :: POSIX :: Linux',
40-
'Programming Language :: Python :: 2.7',
4140
'Programming Language :: Python :: 3.7',
4241
'Topic :: System :: Hardware',
4342
],

sonic-xcvrd/xcvrd/xcvrd.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -1926,7 +1926,7 @@ def task_worker(self, stopping_event, sfp_error_event):
19261926
self.sfp_error_dict[key] = (value, error_dict)
19271927
else:
19281928
self.sfp_error_dict.pop(key, None)
1929-
logical_port_list = self.port_mapping.get_physical_to_logical(key)
1929+
logical_port_list = self.port_mapping.get_physical_to_logical(int(key))
19301930
if logical_port_list is None:
19311931
helper_logger.log_warning("Got unknown FP port index {}, ignored".format(key))
19321932
continue
@@ -1939,15 +1939,15 @@ def task_worker(self, stopping_event, sfp_error_event):
19391939
continue
19401940

19411941
if value == sfp_status_helper.SFP_STATUS_INSERTED:
1942-
helper_logger.log_info("Got SFP inserted event")
1942+
helper_logger.log_notice("{}: Got SFP inserted event".format(logical_port))
19431943
# A plugin event will clear the error state.
19441944
update_port_transceiver_status_table_sw(
19451945
logical_port, self.xcvr_table_helper.get_status_tbl(asic_index), sfp_status_helper.SFP_STATUS_INSERTED)
1946-
helper_logger.log_info("receive plug in and update port sfp status table.")
1946+
helper_logger.log_notice("{}: received plug in and update port sfp status table.".format(logical_port))
19471947
rc = post_port_sfp_info_to_db(logical_port, self.port_mapping, self.xcvr_table_helper.get_intf_tbl(asic_index), transceiver_dict)
19481948
# If we didn't get the sfp info, assuming the eeprom is not ready, give a try again.
19491949
if rc == SFP_EEPROM_NOT_READY:
1950-
helper_logger.log_warning("SFP EEPROM is not ready. One more try...")
1950+
helper_logger.log_warning("{}: SFP EEPROM is not ready. One more try...".format(logical_port))
19511951
time.sleep(TIME_FOR_SFP_READY_SECS)
19521952
rc = post_port_sfp_info_to_db(logical_port, self.port_mapping, self.xcvr_table_helper.get_intf_tbl(asic_index), transceiver_dict)
19531953
if rc == SFP_EEPROM_NOT_READY:
@@ -1962,10 +1962,10 @@ def task_worker(self, stopping_event, sfp_error_event):
19621962
notify_media_setting(logical_port, transceiver_dict, self.xcvr_table_helper.get_app_port_tbl(asic_index), self.port_mapping)
19631963
transceiver_dict.clear()
19641964
elif value == sfp_status_helper.SFP_STATUS_REMOVED:
1965-
helper_logger.log_info("Got SFP removed event")
1965+
helper_logger.log_notice("{}: Got SFP removed event".format(logical_port))
19661966
update_port_transceiver_status_table_sw(
19671967
logical_port, self.xcvr_table_helper.get_status_tbl(asic_index), sfp_status_helper.SFP_STATUS_REMOVED)
1968-
helper_logger.log_info("receive plug out and pdate port sfp status table.")
1968+
helper_logger.log_notice("{}: received plug out and update port sfp status table.".format(logical_port))
19691969
del_port_sfp_dom_info_from_db(logical_port, self.port_mapping,
19701970
self.xcvr_table_helper.get_intf_tbl(asic_index),
19711971
self.xcvr_table_helper.get_dom_tbl(asic_index),
@@ -1975,7 +1975,7 @@ def task_worker(self, stopping_event, sfp_error_event):
19751975
else:
19761976
try:
19771977
error_bits = int(value)
1978-
helper_logger.log_info("Got SFP error event {}".format(value))
1978+
helper_logger.log_error("{}: Got SFP error event {}".format(logical_port, value))
19791979

19801980
error_descriptions = sfp_status_helper.fetch_generic_error_description(error_bits)
19811981

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

20062006
else:
20072007
next_state = STATE_EXIT

sonic-xcvrd/xcvrd/xcvrd_utilities/port_mapping.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ def get_logical_to_physical(self, port_name):
7878
port_index = self.logical_to_physical.get(port_name)
7979
return None if port_index is None else [port_index]
8080

81-
def get_physical_to_logical(self, physical_port):
81+
def get_physical_to_logical(self, physical_port: int):
82+
assert isinstance(physical_port, int), "{} is NOT integer".format(physical_port)
8283
return self.physical_to_logical.get(physical_port)
8384

8485
def logical_port_name_to_physical_port_list(self, port_name):

0 commit comments

Comments
 (0)