@@ -203,10 +203,6 @@ def _wrapper_get_sfp_type(physical_port):
203203 return sfp .sfp_type
204204 except (NotImplementedError , AttributeError ):
205205 pass
206- try :
207- return sfp .get_port_type ()
208- except (NotImplementedError , AttributeError ):
209- pass
210206 return None
211207
212208
@@ -854,6 +850,8 @@ def is_fast_reboot_enabled():
854850
855851class CmisManagerTask :
856852
853+ NUM_CHANNELS = 8
854+
857855 CMIS_STATE_UNKNOWN = 'UNKNOWN'
858856 CMIS_STATE_INSERTED = 'INSERTED'
859857 CMIS_STATE_DP_DEINIT = 'DP_DEINIT'
@@ -873,6 +871,7 @@ def __init__(self, port_mapping):
873871 self .isPortConfigDone = False
874872
875873 def dbg_print (self , message ):
874+ print ("CMIS: {}" .format (message ))
876875 helper_logger .log_notice ("CMIS: {}" .format (message ))
877876
878877 def on_port_update_event (self , port_change_event ):
@@ -953,16 +952,17 @@ def task_worker(self):
953952 if pport < 0 or speed == 0 or len (lanes ) < 1 :
954953 continue
955954
956- # Replace the physical lane id with logical lane index
957- #
958- # TODO: Add dynamic port breakout support
959- lanes_new = []
960- lanes_old = lanes .split (',' )
961- for i in range (len (lanes_old )):
962- lanes_new .append (i )
963- host_lanes = lanes_new
955+ # Desired port speed on the host side
964956 host_speed = speed
965957
958+ # Convert the physical lane id into logical lanemask
959+ #
960+ # TODO: Add dynamic port breakout support by checking the physical lane offset
961+ host_lanes = 0
962+ phys_lanes = lanes .split (',' )
963+ for i in range (len (phys_lanes )):
964+ host_lanes |= (1 << i )
965+
966966 # double-check the HW presence before moving forward
967967 sfp = platform_chassis .get_sfp (pport )
968968 if not sfp .get_presence ():
@@ -976,77 +976,92 @@ def task_worker(self):
976976 self .port_dict [lport ]['cmis_state' ] = self .CMIS_STATE_FAILED
977977 continue
978978
979- # Skip if the memory type is flat
980- if info . get ( 'memory_type' , 'flat' ) in [ 'flat' , 'FLAT' , 'Flat' ] :
979+ # Skip if it's a flat memory device
980+ if sfp . is_flat_memory () :
981981 self .port_dict [lport ]['cmis_state' ] = self .CMIS_STATE_READY
982982 continue
983983
984- self .dbg_print ("{}: {}G, {}-lanes , state={}" .format (
985- lport , int (speed / 1000 ), len ( host_lanes ) , state ))
984+ self .dbg_print ("{}: {}G, lanemask=0x{:x} , state={}" .format (
985+ lport , int (speed / 1000 ), host_lanes , state ))
986986
987987 if state == self .CMIS_STATE_INSERTED :
988988 (flag , appl ) = sfp .has_cmis_application_update (host_speed , host_lanes )
989989 if not flag :
990990 # No application updates
991991 state = self .CMIS_STATE_READY
992- self .dbg_print ("{}: {}G, {}-lanes, state={}" .format (
993- lport , int (speed / 1000 ), len (host_lanes ), state ))
992+ self .dbg_print ("{}: state={}" .format (lport , state ))
994993 self .port_dict [lport ]['cmis_state' ] = state
995994 continue
996995 self .port_dict [lport ]['cmis_apsel' ] = appl
997- sfp .set_cmis_application_stop (host_lanes )
996+
997+ # D.2.2 Software Deinitialization
998+ sfp .set_cmis_datapath_deinit (host_lanes )
999+ sfp .set_lpmode (True )
1000+ # D.1.3 Software Configuration and Initialization
1001+ sfp .tx_disable_channel (host_lanes , True )
1002+ sfp .set_lpmode (False )
1003+
9981004 self .port_dict [lport ]['cmis_state' ] = self .CMIS_STATE_DP_DEINIT
9991005 elif state == self .CMIS_STATE_DP_DEINIT :
1000- if sfp .get_module_state ( ) != 'ModuleReady' :
1006+ if sfp .get_cmis_state (). get ( 'module_state' ) != 'ModuleReady' :
10011007 continue
10021008 appl = self .port_dict [lport ]['cmis_apsel' ]
10031009 sfp .set_cmis_application_apsel (host_lanes , appl )
10041010 self .port_dict [lport ]['cmis_state' ] = self .CMIS_STATE_AP_CONF
10051011 elif state == self .CMIS_STATE_AP_CONF :
10061012 st = sfp .get_cmis_state ()['config_state' ]
10071013 done = True
1008- for lane in host_lanes :
1014+ for lane in range (self .NUM_CHANNELS ):
1015+ if (1 << lane ) & host_lanes == 0 :
1016+ continue
10091017 name = "ConfigStatusLane{}" .format (lane + 1 )
10101018 if st [name ] != 'ConfigSuccess' :
10111019 done = False
10121020 continue
10131021 if not done :
10141022 continue
1015- sfp .set_cmis_application_start (host_lanes )
1023+
1024+ sfp .set_cmis_datapath_init (host_lanes )
1025+
10161026 self .port_dict [lport ]['cmis_state' ] = self .CMIS_STATE_DP_INIT
10171027 elif state == self .CMIS_STATE_DP_INIT :
10181028 st = sfp .get_cmis_state ()['datapath_state' ]
10191029 done = True
1020- for lane in host_lanes :
1030+ for lane in range (self .NUM_CHANNELS ):
1031+ if (1 << lane ) & host_lanes == 0 :
1032+ continue
10211033 name = "DP{}State" .format (lane + 1 )
10221034 if st [name ] != 'DataPathInitialized' :
10231035 done = False
10241036 continue
10251037 if not done :
10261038 continue
1027- sfp .set_cmis_application_txon (host_lanes )
1039+
1040+ sfp .tx_disable_channel (host_lanes , False )
1041+
10281042 self .port_dict [lport ]['cmis_state' ] = self .CMIS_STATE_DP_TXON
10291043 elif state == self .CMIS_STATE_DP_TXON :
10301044 st = sfp .get_cmis_state ()['datapath_state' ]
10311045 done = True
1032- for lane in host_lanes :
1046+ for lane in range (self .NUM_CHANNELS ):
1047+ if (1 << lane ) & host_lanes == 0 :
1048+ continue
10331049 name = "DP{}State" .format (lane + 1 )
10341050 if st [name ] != 'DataPathActivated' :
10351051 done = False
10361052 continue
10371053 if not done :
10381054 continue
10391055 state = self .CMIS_STATE_READY
1040- self .dbg_print ("{}: {}G, {}-lanes, state={}" .format (
1041- lport , int (speed / 1000 ), len (host_lanes ), state ))
1056+ self .dbg_print ("{}: state={}" .format (lport , state ))
10421057 self .port_dict [lport ]['cmis_state' ] = state
10431058
10441059 except (NotImplementedError , AttributeError ):
10451060 self .port_dict [lport ]['cmis_state' ] = self .CMIS_STATE_FAILED
10461061
10471062 self .dbg_print ("Stopped" )
10481063
1049- def task_run (self , y_cable_presence ):
1064+ def task_run (self ):
10501065 if platform_chassis is None :
10511066 self .dbg_print ("Platform chassis is not available, stopping..." )
10521067 return
@@ -1758,7 +1773,7 @@ def run(self):
17581773
17591774 # Start the CMIS manager
17601775 cmis_manager = CmisManagerTask (port_mapping_data )
1761- cmis_manager .task_run (self . y_cable_presence )
1776+ cmis_manager .task_run ()
17621777
17631778 # Start the dom sensor info update thread
17641779 dom_info_update = DomInfoUpdateTask (port_mapping_data )
0 commit comments