From 36a0294db37ce061c70b6b2e10846c597bf88682 Mon Sep 17 00:00:00 2001 From: xinyu Date: Thu, 1 Aug 2024 14:51:05 +0800 Subject: [PATCH] [CMIS] Add lane_mask parameter to set_loopback_mode() to enable setting loopback mode for individual lanes rather than the entire physical port Signed-off-by: xinyu --- sonic_platform_base/sonic_xcvr/api/public/cmis.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/sonic_platform_base/sonic_xcvr/api/public/cmis.py b/sonic_platform_base/sonic_xcvr/api/public/cmis.py index af4328afe..01f8b9f14 100644 --- a/sonic_platform_base/sonic_xcvr/api/public/cmis.py +++ b/sonic_platform_base/sonic_xcvr/api/public/cmis.py @@ -1115,15 +1115,18 @@ def get_loopback_capability(self): loopback_capability['media_side_output_loopback_supported'] = bool((allowed_loopback_result >> 0) & 0x1) return loopback_capability - def set_loopback_mode(self, loopback_mode): + def set_loopback_mode(self, loopback_mode, lane_mask = 0xff): ''' This function sets the module loopback mode. - Loopback mode has to be one of the five: + loopback_mode: Loopback mode has to be one of the five: 1. "none" (default) 2. "host-side-input" 3. "host-side-output" 4. "media-side-input" 5. "media-side-output" + lane_mask: A bitmask representing which lanes to apply the loopback mode to. + The default value of 0xFF indicates that the mode should be applied to all lanes. + The function will look at 13h:128 to check advertized loopback capabilities. Return True if the provision succeeds, False if it fails ''' @@ -1138,22 +1141,22 @@ def set_loopback_mode(self, loopback_mode): return all([status_host_input, status_host_output, status_media_input, status_media_output]) elif loopback_mode == 'host-side-input': if loopback_capability['host_side_input_loopback_supported']: - return self.xcvr_eeprom.write(consts.HOST_INPUT_LOOPBACK, 0xff) + return self.xcvr_eeprom.write(consts.HOST_INPUT_LOOPBACK, lane_mask) else: return False elif loopback_mode == 'host-side-output': if loopback_capability['host_side_output_loopback_supported']: - return self.xcvr_eeprom.write(consts.HOST_OUTPUT_LOOPBACK, 0xff) + return self.xcvr_eeprom.write(consts.HOST_OUTPUT_LOOPBACK, lane_mask) else: return False elif loopback_mode == 'media-side-input': if loopback_capability['media_side_input_loopback_supported']: - return self.xcvr_eeprom.write(consts.MEDIA_INPUT_LOOPBACK, 0xff) + return self.xcvr_eeprom.write(consts.MEDIA_INPUT_LOOPBACK, lane_mask) else: return False elif loopback_mode == 'media-side-output': if loopback_capability['media_side_output_loopback_supported']: - return self.xcvr_eeprom.write(consts.MEDIA_OUTPUT_LOOPBACK, 0xff) + return self.xcvr_eeprom.write(consts.MEDIA_OUTPUT_LOOPBACK, lane_mask) else: return False else: