Skip to content

Commit 116eeec

Browse files
hpershlguohan
andauthored
Detect an SFP adapter in a QSFP port, and instantiate an SFP object instead of a QSFP object. (sonic-net#43)
Signed-off-by: Howard Persh [email protected] Co-authored-by: Guohan Lu <[email protected]>
1 parent 9b1dea5 commit 116eeec

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

sonic_platform_base/sonic_sfp/sfputilbase.py

+18-11
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,25 @@ def get_transceiver_info_dict(self, port_num):
781781
transceiver_info_dict['nominal_bit_rate'] = 'N/A'
782782

783783
else:
784+
file_path = self._get_port_eeprom_path(port_num, self.IDENTITY_EEPROM_ADDR)
785+
if not self._sfp_eeprom_present(file_path, 0):
786+
print("Error, file not exist %s" % file_path)
787+
return None
788+
789+
try:
790+
sysfsfile_eeprom = open(file_path, mode="rb", buffering=0)
791+
except IOError:
792+
print("Error: reading sysfs file %s" % file_path)
793+
return None
794+
784795
if port_num in self.qsfp_ports:
796+
# Check for QSA adapter
797+
byte0 = self._read_eeprom_specific_bytes(sysfsfile_eeprom, 0, 1)[0]
798+
is_qsfp = (byte0 != '03' and byte0 != '0b')
799+
else:
800+
is_qsfp = False
801+
802+
if is_qsfp:
785803
offset = 128
786804
vendor_rev_width = XCVR_HW_REV_WIDTH_QSFP
787805
cable_length_width = XCVR_CABLE_LENGTH_WIDTH_QSFP
@@ -805,17 +823,6 @@ def get_transceiver_info_dict(self, port_num):
805823
print("Error: sfp_object open failed")
806824
return None
807825

808-
file_path = self._get_port_eeprom_path(port_num, self.IDENTITY_EEPROM_ADDR)
809-
if not self._sfp_eeprom_present(file_path, 0):
810-
print("Error, file not exist %s" % file_path)
811-
return None
812-
813-
try:
814-
sysfsfile_eeprom = open(file_path, mode="rb", buffering=0)
815-
except IOError:
816-
print("Error: reading sysfs file %s" % file_path)
817-
return None
818-
819826
sfp_interface_bulk_raw = self._read_eeprom_specific_bytes(sysfsfile_eeprom, (offset + XCVR_INTFACE_BULK_OFFSET), interface_info_bulk_width)
820827
if sfp_interface_bulk_raw is not None:
821828
sfp_interface_bulk_data = sfpi_obj.parse_sfp_info_bulk(sfp_interface_bulk_raw, 0)

0 commit comments

Comments
 (0)