def initialize_sfp(self): from sonic_platform.sfp import SFP from sonic_platform.sfp import initialize_sdk_handle self.sfp_module = SFP self.sdk_handle = initialize_sdk_handle() if self.sdk_handle is None: self.sfp_module_initialized = False return # Initialize SFP list port_position_tuple = self._get_port_position_tuple_by_platform_name() self.PORT_START = port_position_tuple[0] self.QSFP_PORT_START = port_position_tuple[1] self.PORT_END = port_position_tuple[2] self.PORTS_IN_BLOCK = port_position_tuple[3] for index in range(self.PORT_START, self.PORT_END + 1): if index in range(self.QSFP_PORT_START, self.PORTS_IN_BLOCK + 1): sfp_module = SFP(index, 'QSFP', self.sdk_handle) else: sfp_module = SFP(index, 'SFP', self.sdk_handle) self._sfp_list.append(sfp_module) self.sfp_module_initialized = True
def test_sfp_index(self, mock_max_port): sfp = SFP(0) assert sfp.sdk_index == 0 assert sfp.index == 1 mock_max_port.return_value = 16 sfp = SFP(sfp_index=0, slot_id=1, linecard_port_count=16, lc_name='LINE-CARD1') assert sfp.sdk_index == 0 assert sfp.index == 1 sfp = SFP(sfp_index=5, slot_id=3, linecard_port_count=16, lc_name='LINE-CARD1') assert sfp.sdk_index == 5 assert sfp.index == 38 sfp = SFP(sfp_index=1, slot_id=1, linecard_port_count=4, lc_name='LINE-CARD1') assert sfp.sdk_index == 1 assert sfp.index == 5
def test_sfp_read_eeprom(self): mlxreg_mngr = MlxregManager("", 0, 0) offset = 644 sfp = SFP(0) assert output_sfp.y_cable_part_number == sfp.read_eeprom(offset, 16).decode() MlxregManager.read_mlxred_eeprom.assert_called_with(132, 4, 16)
def __init__(self): super(Chassis, self).__init__() # Initialize SKU name self.sku_name = self._get_sku_name() # Initialize PSU list for index in range(MLNX_NUM_PSU): psu = Psu(index, self.sku_name) self._psu_list.append(psu) # Initialize watchdog self._watchdog = get_watchdog() # Initialize FAN list multi_rotor_in_drawer = False num_of_fan, num_of_drawer = self._extract_num_of_fans_and_fan_drawers() multi_rotor_in_drawer = num_of_fan > num_of_drawer for index in range(num_of_fan): if multi_rotor_in_drawer: fan = Fan(index, index / 2) else: fan = Fan(index, index) self._fan_list.append(fan) # Initialize SFP list port_position_tuple = self._get_port_position_tuple_by_sku_name() self.PORT_START = port_position_tuple[0] self.QSFP_PORT_START = port_position_tuple[1] self.PORT_END = port_position_tuple[2] self.PORTS_IN_BLOCK = port_position_tuple[3] for index in range(self.PORT_START, self.PORT_END + 1): if index in range(self.QSFP_PORT_START, self.PORTS_IN_BLOCK + 1): sfp_module = SFP(index, 'QSFP') else: sfp_module = SFP(index, 'SFP') self._sfp_list.append(sfp_module) # Initialize thermals initialize_thermals(self.sku_name, self._thermal_list, self._psu_list) # Initialize EEPROM self.eeprom = Eeprom() # Initialize component list self._component_name_list.append(COMPONENT_BIOS) self._component_name_list.append(COMPONENT_FIRMWARE) self._component_name_list.append(COMPONENT_CPLD1) self._component_name_list.append(COMPONENT_CPLD2) # Initialize sfp-change-listening stuff self._init_sfp_change_event()
def initialize_sfp(self): from sonic_platform.sfp import SFP self.sfp_module = SFP # Initialize SFP list port_position_tuple = self._get_port_position_tuple_by_sku_name() self.PORT_START = port_position_tuple[0] self.QSFP_PORT_START = port_position_tuple[1] self.PORT_END = port_position_tuple[2] self.PORTS_IN_BLOCK = port_position_tuple[3] for index in range(self.PORT_START, self.PORT_END + 1): if index in range(self.QSFP_PORT_START, self.PORTS_IN_BLOCK + 1): sfp_module = SFP(index, 'QSFP') else: sfp_module = SFP(index, 'SFP') self._sfp_list.append(sfp_module) self.sfp_module_initialized = True
def __init__(self): ChassisBase.__init__(self) # Initialize PSU list for index in range(MLNX_NUM_PSU): psu = Psu(index) self._psu_list.append(psu) # Initialize watchdog self._watchdog = get_watchdog() # Initialize FAN list multi_rotor_in_drawer = False num_of_fan, num_of_drawer = self._extract_num_of_fans_and_fan_drawers() multi_rotor_in_drawer = num_of_fan > num_of_drawer for index in range(num_of_fan): if multi_rotor_in_drawer: fan = Fan(index, index / 2) else: fan = Fan(index, index) self._fan_list.append(fan) # Initialize SFP list port_position_tuple = self._get_port_position_tuple_by_sku_name() self.PORT_START = port_position_tuple[0] self.QSFP_PORT_START = port_position_tuple[1] self.PORT_END = port_position_tuple[2] self.PORTS_IN_BLOCK = port_position_tuple[3] for index in range(self.PORT_START, self.PORT_END + 1): if index in range(QSFP_PORT_START, self.PORTS_IN_BLOCK + 1): sfp_module = SFP(index, 'QSFP') else: sfp_module = SFP(index, 'SFP') self._psu_list.append(sfp_module)
def test_sfp_write_eeprom(self): mlxreg_mngr = MlxregManager("", 0, 0) write_buffer = bytearray([1,2,3,4]) offset = 793 sfp = SFP(0) sfp.write_eeprom(offset, 4, write_buffer) MlxregManager.write_mlxreg_eeprom.assert_called_with(4, output_sfp.write_eeprom_dword1, 153, 5) offset = 641 write_buffer = bytearray([1,2,3,4,5,6]) sfp.write_eeprom(offset, 6, write_buffer) MlxregManager.write_mlxreg_eeprom.assert_called_with(6, output_sfp.write_eeprom_dword2, 129, 4)