From dc994b8425fb58293f6cb091f6b371f4a2fc9987 Mon Sep 17 00:00:00 2001 From: Srideep Date: Tue, 28 Jan 2020 00:28:26 -0700 Subject: [PATCH] DellEMC: Dell platform bug fixes on s5248 and s6232 (#4071) * Dynamic bus detection and loading driver for eeprom on s5248,s5232 * sfputil fix for S5248 --- .../x86_64-dellemc_s5232f_c3538-r0/plugins/eeprom.py | 12 +++++++++++- .../x86_64-dellemc_s5248f_c3538-r0/plugins/eeprom.py | 12 +++++++++++- .../plugins/sfputil.py | 2 +- .../s5232f/scripts/s5232f_platform.sh | 4 ++-- .../s5248f/scripts/s5248f_platform.sh | 4 ++-- 5 files changed, 27 insertions(+), 7 deletions(-) diff --git a/device/dell/x86_64-dellemc_s5232f_c3538-r0/plugins/eeprom.py b/device/dell/x86_64-dellemc_s5232f_c3538-r0/plugins/eeprom.py index ed10672bed..0b96b00d4e 100644 --- a/device/dell/x86_64-dellemc_s5232f_c3538-r0/plugins/eeprom.py +++ b/device/dell/x86_64-dellemc_s5232f_c3538-r0/plugins/eeprom.py @@ -9,7 +9,9 @@ # - specific encoder/decoder if there is special need ############################################################################# + try: + import os.path from sonic_eeprom import eeprom_tlvinfo except ImportError, e: raise ImportError (str(e) + "- required module not found") @@ -18,5 +20,13 @@ except ImportError, e: class board(eeprom_tlvinfo.TlvInfoDecoder): def __init__(self, name, path, cpld_root, ro): - self.eeprom_path = "/sys/class/i2c-adapter/i2c-0/0-0050/eeprom" + self.eeprom_path = None + for b in (0, 1): + f = '/sys/class/i2c-adapter/i2c-{0}/{0}-0050/eeprom'.format(b) + if os.path.exists(f): + self.eeprom_path = f + break + if self.eeprom_path is None: + return + super(board, self).__init__(self.eeprom_path, 0, '', True) diff --git a/device/dell/x86_64-dellemc_s5248f_c3538-r0/plugins/eeprom.py b/device/dell/x86_64-dellemc_s5248f_c3538-r0/plugins/eeprom.py index 5b044d0ee3..b6305a6ed6 100644 --- a/device/dell/x86_64-dellemc_s5248f_c3538-r0/plugins/eeprom.py +++ b/device/dell/x86_64-dellemc_s5248f_c3538-r0/plugins/eeprom.py @@ -9,7 +9,9 @@ # - specific encoder/decoder if there is special need ############################################################################# + try: + import os.path from sonic_eeprom import eeprom_tlvinfo except ImportError, e: raise ImportError (str(e) + "- required module not found") @@ -18,5 +20,13 @@ except ImportError, e: class board(eeprom_tlvinfo.TlvInfoDecoder): def __init__(self, name, path, cpld_root, ro): - self.eeprom_path = "/sys/class/i2c-adapter/i2c-0/0-0050/eeprom" + self.eeprom_path = None + for b in (0, 1): + f = '/sys/class/i2c-adapter/i2c-{0}/{0}-0050/eeprom'.format(b) + if os.path.exists(f): + self.eeprom_path = f + break + if self.eeprom_path is None: + return + super(board, self).__init__(self.eeprom_path, 0, '', True) diff --git a/device/dell/x86_64-dellemc_s5248f_c3538-r0/plugins/sfputil.py b/device/dell/x86_64-dellemc_s5248f_c3538-r0/plugins/sfputil.py index 911c04a0fe..4bc0745df2 100644 --- a/device/dell/x86_64-dellemc_s5248f_c3538-r0/plugins/sfputil.py +++ b/device/dell/x86_64-dellemc_s5248f_c3538-r0/plugins/sfputil.py @@ -319,7 +319,7 @@ class SfpUtil(SfpUtilBase): time.sleep(0.5) - def get_transceiver_dom_info_dict(self, port_num): + def get_transceiver_dom_info_dict(self, port_num): transceiver_dom_info_dict = {} dom_info_dict_keys = ['temperature', 'voltage', 'rx1power', diff --git a/platform/broadcom/sonic-platform-modules-dell/s5232f/scripts/s5232f_platform.sh b/platform/broadcom/sonic-platform-modules-dell/s5232f/scripts/s5232f_platform.sh index 6923c9f4b3..a419b7d22e 100755 --- a/platform/broadcom/sonic-platform-modules-dell/s5232f/scripts/s5232f_platform.sh +++ b/platform/broadcom/sonic-platform-modules-dell/s5232f/scripts/s5232f_platform.sh @@ -17,9 +17,9 @@ init_devnum() { # Attach/Detach syseeprom on CPU board sys_eeprom() { case $1 in - "new_device") echo 24c16 0x50 > /sys/bus/i2c/devices/i2c-0/$1 + "new_device") echo 24c16 0x50 > /sys/bus/i2c/devices/i2c-${devnum}/$1 ;; - "delete_device") echo 0x50 > /sys/bus/i2c/devices/i2c-0/$1 + "delete_device") echo 0x50 > /sys/bus/i2c/devices/i2c-${devnum}/$1 ;; *) echo "s5232f_platform: sys_eeprom : invalid command !" ;; diff --git a/platform/broadcom/sonic-platform-modules-dell/s5248f/scripts/s5248f_platform.sh b/platform/broadcom/sonic-platform-modules-dell/s5248f/scripts/s5248f_platform.sh index 094c88eeab..77032d6433 100755 --- a/platform/broadcom/sonic-platform-modules-dell/s5248f/scripts/s5248f_platform.sh +++ b/platform/broadcom/sonic-platform-modules-dell/s5248f/scripts/s5248f_platform.sh @@ -17,9 +17,9 @@ init_devnum() { # Attach/Detach syseeprom on CPU board sys_eeprom() { case $1 in - "new_device") echo 24c16 0x50 > /sys/bus/i2c/devices/i2c-0/$1 + "new_device") echo 24c16 0x50 > /sys/bus/i2c/devices/i2c-${devnum}/$1 ;; - "delete_device") echo 0x50 > /sys/bus/i2c/devices/i2c-0/$1 + "delete_device") echo 0x50 > /sys/bus/i2c/devices/i2c-${devnum}/$1 ;; *) echo "s5248f_platform: sys_eeprom : invalid command !" ;;