From fb9f11a3332ea9c347d138c9757f4c569203dde1 Mon Sep 17 00:00:00 2001 From: Rodny Molina Date: Sun, 8 Oct 2017 19:45:37 -0700 Subject: [PATCH 1/2] Adjusting Seastone's sfputil plugin to cope with new SfpUtil API. There are multiple platforms that need to be transitioned to the new SfpUtilBase interface -- I'm only taking care of Celestica-Seastone in this patch. --- .../x86_64-cel_seastone-r0/plugins/sfputil.py | 61 +++++++++++++++---- 1 file changed, 48 insertions(+), 13 deletions(-) diff --git a/device/celestica/x86_64-cel_seastone-r0/plugins/sfputil.py b/device/celestica/x86_64-cel_seastone-r0/plugins/sfputil.py index f3943e734b58..4c90578e593f 100644 --- a/device/celestica/x86_64-cel_seastone-r0/plugins/sfputil.py +++ b/device/celestica/x86_64-cel_seastone-r0/plugins/sfputil.py @@ -1,25 +1,60 @@ #!/usr/bin/env python +# +# Platform-specific SFP transceiver interface for SONiC +# try: - from sonic_sfp.sfputilbase import sfputilbase -except ImportError, e: - raise ImportError (str(e) + "- required module not found") + import time + from sonic_sfp.sfputilbase import SfpUtilBase +except ImportError as e: + raise ImportError("%s - required module not found" % str(e)) -class sfputil(sfputilbase): - """Platform specific sfputil class""" +class SfpUtil(SfpUtilBase): + """Platform-specific SfpUtil class""" - port_start = 0 - port_end = 31 - ports_in_block = 32 + PORT_START = 0 + PORT_END = 31 + PORTS_IN_BLOCK = 32 - port_to_eeprom_mapping = {} +# EEPROM_OFFSET = 20 - _qsfp_ports = range(0, ports_in_block + 1) + _port_to_eeprom_mapping = {} + qsfp_ports = range(0, PORTS_IN_BLOCK + 1) - def __init__(self, port_num): + @property + def port_start(self): + return self.PORT_START + + @property + def port_end(self): + return self.PORT_END + + @property + def qsfp_ports(self): + return range(0, self.PORTS_IN_BLOCK + 1) + + @property + def port_to_eeprom_mapping(self): + return self._port_to_eeprom_mapping + + def __init__(self): # Override port_to_eeprom_mapping for class initialization eeprom_path = '/sys/bus/i2c/devices/i2c-{0}/{0}-0050/eeprom' - for x in range(self.port_start, self.port_end + 1): + + for x in range(self.PORT_START, self.PORT_END + 1): self.port_to_eeprom_mapping[x] = eeprom_path.format( x + 26 ) - sfputilbase.__init__(self, port_num) + SfpUtilBase.__init__(self) + + def get_presence(self, port_num): + raise NotImplementedError + + def get_low_power_mode(self, port_num): + raise NotImplementedError + + def set_low_power_mode(self, port_num, lpmode): + raise NotImplementedError + + def reset(self, port_num): + raise NotImplementedError + From 2994cce844ec721b1f5d2a7feffb5abd628ff237 Mon Sep 17 00:00:00 2001 From: Rodny Molina Date: Tue, 10 Oct 2017 10:32:47 -0700 Subject: [PATCH 2/2] Deleting commented line. --- device/celestica/x86_64-cel_seastone-r0/plugins/sfputil.py | 2 -- 1 file changed, 2 deletions(-) mode change 100644 => 100755 device/celestica/x86_64-cel_seastone-r0/plugins/sfputil.py diff --git a/device/celestica/x86_64-cel_seastone-r0/plugins/sfputil.py b/device/celestica/x86_64-cel_seastone-r0/plugins/sfputil.py old mode 100644 new mode 100755 index 4c90578e593f..7ff632e152b9 --- a/device/celestica/x86_64-cel_seastone-r0/plugins/sfputil.py +++ b/device/celestica/x86_64-cel_seastone-r0/plugins/sfputil.py @@ -17,8 +17,6 @@ class SfpUtil(SfpUtilBase): PORT_END = 31 PORTS_IN_BLOCK = 32 -# EEPROM_OFFSET = 20 - _port_to_eeprom_mapping = {} qsfp_ports = range(0, PORTS_IN_BLOCK + 1)