From d7eff3b30ae0b0ad87d7ab66b45063ad20b4bf66 Mon Sep 17 00:00:00 2001 From: pariwat Date: Fri, 24 Apr 2020 15:49:13 +0700 Subject: [PATCH 1/4] [device/celestica] Fixed, sysfs path miss match. --- .../sonic_platform/chassis.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/device/celestica/x86_64-cel_silverstone_dp-r0/sonic_platform/chassis.py b/device/celestica/x86_64-cel_silverstone_dp-r0/sonic_platform/chassis.py index 96a53eae194a..c0c2f2c4c0c0 100644 --- a/device/celestica/x86_64-cel_silverstone_dp-r0/sonic_platform/chassis.py +++ b/device/celestica/x86_64-cel_silverstone_dp-r0/sonic_platform/chassis.py @@ -33,8 +33,7 @@ IPMI_GET_REBOOT_CAUSE = "0x03 0x00 0x01 0x06" TLV_EEPROM_I2C_BUS = 0 TLV_EEPROM_I2C_ADDR = 56 -PATH_QSFP_SYSFS = "/sys/devices/platform/cls-xcvr/QSFP{0}/interrupt_mask" -PATH_QSFPDD_SYSFS = "/sys/devices/platform/cls-xcvr/QSFPDD{0}/interrupt_mask" + class Chassis(ChassisBase): @@ -90,7 +89,9 @@ def __initialize_components(self): self._component_list.append(component) def __initialize_interrupts(self): - # Initial Interrup MASK for QSFP, QSFPDD + # Initial Interrup MASK for QSFP, QSFPDD + PATH_QSFP_SYSFS = "/sys/devices/platform/cls-xcvr/QSFP{0}/interrupt_mask" + PATH_QSFPDD_SYSFS = "/sys/devices/platform/cls-xcvr/QSFPDD{0}/interrupt_mask" for i in range(NUM_QSFP): self._api_helper.write_hex_value(PATH_QSFP_SYSFS.format(i+1), 255) for i in range(NUM_QSFPDD): @@ -308,6 +309,8 @@ def __check_all_interrupt_event(self): interrup_device = {} QSFP_NAME = "QSFP{0}" QSFPDD_NAME = "QSFPDD{0}" + PATH_QSFP_SYSFS = "/sys/devices/platform/cls-xcvr/QSFP{0}/interrupt" + PATH_QSFPDD_SYSFS = "/sys/devices/platform/cls-xcvr/QSFPDD{0}/interrupt" for i in range(NUM_QSFP): if self._api_helper.read_txt_file(PATH_QSFP_SYSFS.format(i+1)) != '0x00': interrup_device[QSFP_NAME.format(i+1)] = 1 From 15d3e68d43caed097053e77928224b4fc5ee8b1d Mon Sep 17 00:00:00 2001 From: pariwat Date: Fri, 24 Apr 2020 16:07:10 +0700 Subject: [PATCH 2/4] [device/celestica] Added dummy event --- .../sonic_platform/chassis.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/device/celestica/x86_64-cel_silverstone_dp-r0/sonic_platform/chassis.py b/device/celestica/x86_64-cel_silverstone_dp-r0/sonic_platform/chassis.py index c0c2f2c4c0c0..9eff2b1d3588 100644 --- a/device/celestica/x86_64-cel_silverstone_dp-r0/sonic_platform/chassis.py +++ b/device/celestica/x86_64-cel_silverstone_dp-r0/sonic_platform/chassis.py @@ -20,6 +20,8 @@ except ImportError as e: raise ImportError(str(e) + "- required module not found") +DUMMY_CHANGE_EVENT = True + NUM_FAN_TRAY = 7 NUM_FAN = 2 NUM_PSU = 2 @@ -320,6 +322,8 @@ def __check_all_interrupt_event(self): return interrup_device def get_change_event(self, timeout=0): + if DUMMY_CHANGE_EVENT: + DUMMY_TIMEOUT = 120 if timeout == 0 : flag_change = True while flag_change: @@ -328,12 +332,14 @@ def get_change_event(self, timeout=0): flag_change = False else: time.sleep(0.5) + DUMMY_TIMEOUT < 0 ? flag_change = False: DUMMY_TIMEOUT -= 1 + return (True , self.__compare_event_object(interrup_device)) else: device_list_change = {} while timeout: interrup_device = self.__check_all_interrupt_event() time.sleep(1) - timeout -= 1; + timeout -= 1 device_list_change = self.__compare_event_object(interrup_device) return (True , device_list_change) \ No newline at end of file From 784e64b83260639adbe664fde356504a7b75eddf Mon Sep 17 00:00:00 2001 From: pariwat Date: Fri, 24 Apr 2020 16:14:09 +0700 Subject: [PATCH 3/4] [device/celestica] Adde json return format. --- .../sonic_platform/chassis.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/device/celestica/x86_64-cel_silverstone_dp-r0/sonic_platform/chassis.py b/device/celestica/x86_64-cel_silverstone_dp-r0/sonic_platform/chassis.py index 9eff2b1d3588..20e22318ba86 100644 --- a/device/celestica/x86_64-cel_silverstone_dp-r0/sonic_platform/chassis.py +++ b/device/celestica/x86_64-cel_silverstone_dp-r0/sonic_platform/chassis.py @@ -301,9 +301,9 @@ def __compare_event_object(self, interrup_devices): elif "QSFP" in device_name: QSFP_devices[device_name] = 1 - int(self.__check_devices_status(device_name)) self.__clear_interrupt(device_name) - if len(QSFP_devices): + # if len(QSFP_devices): json_obj['qsfp'] = QSFP_devices - if len(QSFPDD_devices): + # if len(QSFPDD_devices): json_obj['qsfp-dd'] = QSFPDD_devices return json.dumps(json_obj) @@ -332,7 +332,11 @@ def get_change_event(self, timeout=0): flag_change = False else: time.sleep(0.5) - DUMMY_TIMEOUT < 0 ? flag_change = False: DUMMY_TIMEOUT -= 1 + if DUMMY_CHANGE_EVENT: + if DUMMY_TIMEOUT < 0 : + flag_change = False + else: + DUMMY_TIMEOUT -= 1 return (True , self.__compare_event_object(interrup_device)) else: From 33995f90e82d90ba589e7259b68848cd16daba23 Mon Sep 17 00:00:00 2001 From: pariwat Date: Fri, 24 Apr 2020 16:17:09 +0700 Subject: [PATCH 4/4] [device/celestica] fixed indent --- .../x86_64-cel_silverstone_dp-r0/sonic_platform/chassis.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/device/celestica/x86_64-cel_silverstone_dp-r0/sonic_platform/chassis.py b/device/celestica/x86_64-cel_silverstone_dp-r0/sonic_platform/chassis.py index 20e22318ba86..10e3b4ab2c6c 100644 --- a/device/celestica/x86_64-cel_silverstone_dp-r0/sonic_platform/chassis.py +++ b/device/celestica/x86_64-cel_silverstone_dp-r0/sonic_platform/chassis.py @@ -302,9 +302,9 @@ def __compare_event_object(self, interrup_devices): QSFP_devices[device_name] = 1 - int(self.__check_devices_status(device_name)) self.__clear_interrupt(device_name) # if len(QSFP_devices): - json_obj['qsfp'] = QSFP_devices + json_obj['qsfp'] = QSFP_devices # if len(QSFPDD_devices): - json_obj['qsfp-dd'] = QSFPDD_devices + json_obj['qsfp-dd'] = QSFPDD_devices return json.dumps(json_obj) def __check_all_interrupt_event(self):