From 5c6eccb172e56e3c2e6a12b23f939d7d10de7c63 Mon Sep 17 00:00:00 2001 From: chiourung_huang Date: Thu, 17 Oct 2024 00:57:39 +0000 Subject: [PATCH] reset active applicatio mode when shutdown interface --- sonic-xcvrd/xcvrd/xcvrd.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/sonic-xcvrd/xcvrd/xcvrd.py b/sonic-xcvrd/xcvrd/xcvrd.py index 0c1cab6..b4ad5d7 100644 --- a/sonic-xcvrd/xcvrd/xcvrd.py +++ b/sonic-xcvrd/xcvrd/xcvrd.py @@ -1243,6 +1243,27 @@ def post_port_active_apsel_to_db(self, api, lport, host_lanes_mask): intf_tbl.set(lport, fvs) self.log_notice("{}: updated TRANSCEIVER_INFO_TABLE {}".format(lport, tuple_list)) + def reset_active_apsel_to_db(self, lport, host_lanes_mask): + tuple_list = [] + for lane in range(self.CMIS_MAX_HOST_LANES): + if ((1 << lane) & host_lanes_mask) == 0: + continue + tuple_list.append(('active_apsel_hostlane{}'.format(lane + 1), 'N/A')) + tuple_list.append(('host_lane_count', 'N/A')) + tuple_list.append(('media_lane_count', 'N/A')) + asic_index = self.port_mapping.get_asic_id_for_logical_port(lport) + intf_tbl = self.xcvr_table_helper.get_intf_tbl(asic_index) + if not intf_tbl: + helper_logger.log_warning("Active ApSel db update: TRANSCEIVER_INFO table not found for {}".format(lport)) + return + found, _ = intf_tbl.get(lport) + if not found: + helper_logger.log_warning("Active ApSel db update: {} not found in INTF_TABLE".format(lport)) + return + fvs = swsscommon.FieldValuePairs(tuple_list) + intf_tbl.set(lport, fvs) + self.log_notice("{}: updated TRANSCEIVER_INFO_TABLE {}".format(lport, tuple_list)) + def wait_for_port_config_done(self, namespace): # Connect to APPL_DB and subscribe to PORT table notifications appl_db = daemon_base.db_connect("APPL_DB", namespace=namespace) @@ -1419,6 +1440,7 @@ def task_worker(self): self.log_notice("{} Forcing Tx laser OFF".format(lport)) # Force DataPath re-init api.tx_disable_channel(media_lanes_mask, True) + self.reset_active_apsel_to_db(lport, host_lanes_mask) self.port_dict[lport]['cmis_state'] = self.CMIS_STATE_READY continue # Configure the target output power if ZR module