@@ -1132,6 +1132,45 @@ def get_cmis_host_lanes_mask(self, api, appl, host_lane_count, subport):
11321132
11331133 return host_lanes_mask
11341134
1135+ def get_cmis_media_lanes_mask (self , api , appl , lport , subport ):
1136+ """
1137+ Retrieves mask of active media lanes based on appl, lport and subport
1138+
1139+ Args:
1140+ api:
1141+ XcvrApi object
1142+ appl:
1143+ Integer, the transceiver-specific application code
1144+ lport:
1145+ String, logical port name
1146+ subport:
1147+ Integer, 1-based logical port number of the physical port after breakout
1148+ 0 means port is a non-breakout port
1149+
1150+ Returns:
1151+ Integer, a mask of the active lanes on the media side
1152+ e.g. 0xf for lane 0, lane 1, lane 2 and lane 3.
1153+ """
1154+ media_lanes_mask = 0
1155+ media_lane_count = self .port_dict [lport ]['media_lane_count' ]
1156+ media_lane_assignment_option = self .port_dict [lport ]['media_lane_assignment_options' ]
1157+
1158+ if appl < 1 or media_lane_count <= 0 or subport < 0 :
1159+ self .log_error ("Invalid input to get media lane mask - appl {} media_lane_count {} "
1160+ "lport {} subport {}!" .format (appl , media_lane_count , lport , subport ))
1161+ return media_lanes_mask
1162+
1163+ media_lane_start_bit = (media_lane_count * (0 if subport == 0 else subport - 1 ))
1164+ if media_lane_assignment_option & (1 << media_lane_start_bit ):
1165+ media_lanes_mask = ((1 << media_lane_count ) - 1 ) << media_lane_start_bit
1166+ else :
1167+ self .log_error ("Unable to find starting media lane - media_lane_assignment_option {}"
1168+ " media_lane_start_bit {} media_lane_count {} lport {} subport {} appl {}!" .format (
1169+ media_lane_assignment_option , media_lane_start_bit , media_lane_count ,
1170+ lport , subport , appl ))
1171+
1172+ return media_lanes_mask
1173+
11351174 def is_cmis_application_update_required (self , api , app_new , host_lanes_mask ):
11361175 """
11371176 Check if the CMIS application update is required
@@ -1515,13 +1554,28 @@ def task_worker(self):
15151554 self .port_dict [lport ]['cmis_state' ] = self .CMIS_STATE_FAILED
15161555 continue
15171556 host_lanes_mask = self .port_dict [lport ]['host_lanes_mask' ]
1518- self .log_notice ("{}: Setting lanemask=0x{:x}" .format (lport , host_lanes_mask ))
1557+ self .log_notice ("{}: Setting host_lanemask=0x{:x}" .format (lport , host_lanes_mask ))
1558+
1559+ self .port_dict [lport ]['media_lane_count' ] = int (api .get_media_lane_count (appl ))
1560+ self .port_dict [lport ]['media_lane_assignment_options' ] = int (api .get_media_lane_assignment_option (appl ))
1561+ media_lane_count = self .port_dict [lport ]['media_lane_count' ]
1562+ media_lane_assignment_options = self .port_dict [lport ]['media_lane_assignment_options' ]
1563+ self .port_dict [lport ]['media_lanes_mask' ] = self .get_cmis_media_lanes_mask (api ,
1564+ appl , lport , subport )
1565+ if self .port_dict [lport ]['media_lanes_mask' ] <= 0 :
1566+ self .log_error ("{}: Invalid media lane mask received - media_lane_count {} "
1567+ "media_lane_assignment_options {} lport{} subport {}"
1568+ " appl {}!" .format (media_lane_count ,media_lane_assignment_options ,lport ,subport ,appl ))
1569+ self .port_dict [lport ]['cmis_state' ] = self .CMIS_STATE_FAILED
1570+ continue
1571+ media_lanes_mask = self .port_dict [lport ]['media_lanes_mask' ]
1572+ self .log_notice ("{}: Setting media_lanemask=0x{:x}" .format (lport , media_lanes_mask ))
15191573
15201574 if self .port_dict [lport ]['host_tx_ready' ] != 'true' or \
15211575 self .port_dict [lport ]['admin_status' ] != 'up' :
15221576 self .log_notice ("{} Forcing Tx laser OFF" .format (lport ))
15231577 # Force DataPath re-init
1524- api .tx_disable_channel (host_lanes_mask , True )
1578+ api .tx_disable_channel (media_lanes_mask , True )
15251579 self .port_dict [lport ]['cmis_state' ] = self .CMIS_STATE_READY
15261580 continue
15271581 # Configure the target output power if ZR module
@@ -1556,7 +1610,8 @@ def task_worker(self):
15561610 api .set_datapath_deinit (host_lanes_mask )
15571611
15581612 # D.1.3 Software Configuration and Initialization
1559- if not api .tx_disable_channel (host_lanes_mask , True ):
1613+ media_lanes_mask = self .port_dict [lport ]['media_lanes_mask' ]
1614+ if not api .tx_disable_channel (media_lanes_mask , True ):
15601615 self .log_notice ("{}: unable to turn off tx power with host_lanes_mask {}" .format (lport , host_lanes_mask ))
15611616 self .port_dict [lport ]['cmis_retries' ] = retries + 1
15621617 continue
@@ -1637,7 +1692,8 @@ def task_worker(self):
16371692 continue
16381693
16391694 # Turn ON the laser
1640- api .tx_disable_channel (host_lanes_mask , False )
1695+ media_lanes_mask = self .port_dict [lport ]['media_lanes_mask' ]
1696+ api .tx_disable_channel (media_lanes_mask , False )
16411697 self .log_notice ("{}: Turning ON tx power" .format (lport ))
16421698 self .port_dict [lport ]['cmis_state' ] = self .CMIS_STATE_DP_ACTIVATE
16431699 elif state == self .CMIS_STATE_DP_ACTIVATE :
0 commit comments