Skip to content

Commit

Permalink
Merge pull request #154 from pariwat/upstream_silverstone-dp_platform…
Browse files Browse the repository at this point in the history
…_api

Upstream silverstone dp platform api
  • Loading branch information
Wirut Getbamrung authored Apr 24, 2020
2 parents 0095e7f + 33995f9 commit d2a53fc
Showing 1 changed file with 21 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -33,8 +35,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):
Expand Down Expand Up @@ -90,7 +91,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):
Expand Down Expand Up @@ -298,16 +301,18 @@ 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):
json_obj['qsfp'] = QSFP_devices
if len(QSFPDD_devices):
json_obj['qsfp-dd'] = QSFPDD_devices
# if len(QSFP_devices):
json_obj['qsfp'] = QSFP_devices
# if len(QSFPDD_devices):
json_obj['qsfp-dd'] = QSFPDD_devices
return json.dumps(json_obj)

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
Expand All @@ -317,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:
Expand All @@ -325,12 +332,18 @@ def get_change_event(self, timeout=0):
flag_change = False
else:
time.sleep(0.5)
if DUMMY_CHANGE_EVENT:
if DUMMY_TIMEOUT < 0 :
flag_change = False
else:
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)

0 comments on commit d2a53fc

Please sign in to comment.