From 7b391146996da54cff9360f8817033420076f90d Mon Sep 17 00:00:00 2001 From: Xinyu Date: Tue, 25 Apr 2023 18:07:24 +0800 Subject: [PATCH 1/3] [Credo][Ycable] Resolve the issue of being unable to obtain the firmware version of the self-side when the NIC end is power off Signed-off-by: Xinyu --- sonic_y_cable/credo/y_cable_credo.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/sonic_y_cable/credo/y_cable_credo.py b/sonic_y_cable/credo/y_cable_credo.py index 9e6af58b5..9a8938d06 100644 --- a/sonic_y_cable/credo/y_cable_credo.py +++ b/sonic_y_cable/credo/y_cable_credo.py @@ -1463,14 +1463,21 @@ def get_firmware_version(self, target): if self.platform_chassis is not None: with self.rlock.acquire_timeout(RLocker.ACQUIRE_LOCK_TIMEOUT) as lock_status: if lock_status: + curr_offset = YCable.OFFSET_DETERMINE_CABLE_READ_SIDE + read_side = self.platform_chassis.get_sfp(self.port).read_eeprom(curr_offset, 1) + vsc_req_form = [None] * (YCable.VSC_CMD_ATTRIBUTE_LENGTH) vsc_req_form[YCable.VSC_BYTE_OPCODE] = YCable.VSC_OPCODE_FWUPD vsc_req_form[YCable.VSC_BYTE_OPTION] = YCable.FWUPD_OPTION_GET_INFO status = self.send_vsc(vsc_req_form) if status != YCable.MCU_EC_NO_ERROR: - self.log_error('Get firmware version error (error code:0x%04X)' % (status)) - return None + ''' should at least return local side fw version if nic is offline''' + if status == 0x1A and ((read_side[0] == 4 and target == 1) or (read_side[0] == 2 and target == 2)): + pass + else: + self.log_error('Get firmware version error (error code:0x%04X)' % (status)) + return None data = bytearray(YCable.FIRMWARE_INFO_PAYLOAD_SIZE) for byte_idx in range(0, YCable.FIRMWARE_INFO_PAYLOAD_SIZE): From 555464eba836ee5dad2535c34bca70e04070e605 Mon Sep 17 00:00:00 2001 From: Xinyu Date: Mon, 29 May 2023 11:09:41 +0800 Subject: [PATCH 2/3] [Credo][Ycable] call get_read_side() to handle exceptions Signed-off-by: Xinyu --- sonic_y_cable/credo/y_cable_credo.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/sonic_y_cable/credo/y_cable_credo.py b/sonic_y_cable/credo/y_cable_credo.py index 9a8938d06..2456b2908 100644 --- a/sonic_y_cable/credo/y_cable_credo.py +++ b/sonic_y_cable/credo/y_cable_credo.py @@ -1461,11 +1461,14 @@ def get_firmware_version(self, target): """ if self.platform_chassis is not None: + read_side = self.get_read_side() + + if read_side == YCable.EEPROM_ERROR: + self.log_error('Fail to get read side in get_firmware_version()') + return None + with self.rlock.acquire_timeout(RLocker.ACQUIRE_LOCK_TIMEOUT) as lock_status: if lock_status: - curr_offset = YCable.OFFSET_DETERMINE_CABLE_READ_SIDE - read_side = self.platform_chassis.get_sfp(self.port).read_eeprom(curr_offset, 1) - vsc_req_form = [None] * (YCable.VSC_CMD_ATTRIBUTE_LENGTH) vsc_req_form[YCable.VSC_BYTE_OPCODE] = YCable.VSC_OPCODE_FWUPD vsc_req_form[YCable.VSC_BYTE_OPTION] = YCable.FWUPD_OPTION_GET_INFO @@ -1473,7 +1476,7 @@ def get_firmware_version(self, target): if status != YCable.MCU_EC_NO_ERROR: ''' should at least return local side fw version if nic is offline''' - if status == 0x1A and ((read_side[0] == 4 and target == 1) or (read_side[0] == 2 and target == 2)): + if status == 0x1A and (read_side == target): pass else: self.log_error('Get firmware version error (error code:0x%04X)' % (status)) From 3ffe78aded08d803669bed93349fe0b512d25e78 Mon Sep 17 00:00:00 2001 From: Xinyu Date: Fri, 15 Sep 2023 09:50:05 +0800 Subject: [PATCH 3/3] [Credo][Ycable] Replace the hard-coded value with a constant variable for readability Signed-off-by: Xinyu --- sonic_y_cable/credo/y_cable_credo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonic_y_cable/credo/y_cable_credo.py b/sonic_y_cable/credo/y_cable_credo.py index 2456b2908..d6befe316 100644 --- a/sonic_y_cable/credo/y_cable_credo.py +++ b/sonic_y_cable/credo/y_cable_credo.py @@ -1476,7 +1476,7 @@ def get_firmware_version(self, target): if status != YCable.MCU_EC_NO_ERROR: ''' should at least return local side fw version if nic is offline''' - if status == 0x1A and (read_side == target): + if status == YCable.MCU_EC_FWUPD_UART_TIMEOUT and (read_side == target): pass else: self.log_error('Get firmware version error (error code:0x%04X)' % (status))