Skip to content

Commit

Permalink
[device/celestica-silverstone]: clean cmis init code
Browse files Browse the repository at this point in the history
  • Loading branch information
Wirut Getbamrung committed Oct 30, 2020
1 parent 8400496 commit 1c4e42f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#!/bin/bash


# Configure Innolight DR4 transceiver module into 4x100G breakout mode
# Configure transceiver module into 4x100G breakout mode
# so that each 100G ports can be operated independently

# Usage:
# ./cmis4_initial.sh $port_i2c_no
# ./cmis4_init.sh $port_i2c_no
#
port=$1

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#!/bin/bash


# Configure Innolight DR4 transceiver module into 4x100G breakout mode
# so that each 100G ports can be operated independently
# Configure transceiver module into 1x400G mode

# Usage:
# ./cmis4_initial.sh $port_i2c_no
# ./cmis4_init.sh $port_i2c_no
#
port=$1

Expand Down
17 changes: 10 additions & 7 deletions device/celestica/x86_64-cel_silverstone-r0/plugins/sfputil.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
HWSKU_KEY = 'DEVICE_METADATA.localhost.hwsku'
PLATFORM_KEY = 'DEVICE_METADATA.localhost.platform'


class QSFPDDDomPaser(qsfp_dd_Dom):

def __init__(self, eeprom_raw_data):
Expand Down Expand Up @@ -281,6 +282,7 @@ class SfpUtil(SfpUtilBase):
PORT_INFO_PATH = '/sys/class/silverstone_fpga'
QSFP_DD_DOM_OFFSET = 2304

# polling interval in seconds
POLL_INTERVAL = 1

_port_name = ""
Expand Down Expand Up @@ -453,8 +455,8 @@ def _run_command(self, cmd):
status = False
return status, result

def _bring_up_port_link(self, int_sfp, init_script):
# Workaround script to bring up port link
def _init_cmis_module(self, int_sfp, init_script):
# Workaround script for cmis module
for port_num in int_sfp:

if int_sfp[port_num] == '1':
Expand Down Expand Up @@ -490,8 +492,8 @@ def get_path_to_cmis_init_file(self):
(platform, hwsku) = self._get_platform_and_hwsku()
platform_path = "/".join([PLATFORM_ROOT_PATH, platform])
hwsku_path = "/".join([platform_path, hwsku])
port_config_file_path = "/".join([hwsku_path, "cmis-init.sh"])
return port_config_file_path
cmis_init_file_path = "/".join([hwsku_path, "cmis-init.sh"])
return cmis_init_file_path

def get_transceiver_change_event(self, timeout=0):
"""
Expand All @@ -508,21 +510,22 @@ def get_transceiver_change_event(self, timeout=0):
and status can be 'system_not_ready', 'system_become_ready', 'system_fail',
like {'-1':'system_not_ready'}.
"""
cmis_init_script = self.get_path_to_cmis_init_file()
cmis_init_script = self.get_path_to_cmis_init_file()
sfp_event = SfpEvent(self.NUM_OSFP, self.PORT_INFO_PATH)
start_milli_time = int(round(time.time() * 1000))
timeout_in_sec = timeout/1000.0
int_sfp = {}

sleep_time = min(
timeout, self.POLL_INTERVAL) if timeout != 0 else self.POLL_INTERVAL
timeout_in_sec, self.POLL_INTERVAL) if timeout_in_sec != 0 else self.POLL_INTERVAL
while True:
chk_sfp = sfp_event.check_all_port_interrupt_event()
int_sfp = sfp_event.update_port_event_object(
chk_sfp, int_sfp) if chk_sfp else int_sfp

current_milli_time = int(round(time.time() * 1000))
if int_sfp or (timeout != 0 and current_milli_time - start_milli_time > timeout):
self._bring_up_port_link(int_sfp, cmis_init_script)
self._init_cmis_module(int_sfp, cmis_init_script)
break

time.sleep(sleep_time)
Expand Down

0 comments on commit 1c4e42f

Please sign in to comment.