Skip to content

Commit

Permalink
Detect an SFP adapter in a QSFP port, and instantiate an SFP object i…
Browse files Browse the repository at this point in the history
…nstead of a QSFP object. (sonic-net#43)

Signed-off-by: Howard Persh Howard_Persh@dell.com

Co-authored-by: Guohan Lu <lguohan@gmail.com>
  • Loading branch information
hpersh and lguohan authored Mar 22, 2020
1 parent 9b1dea5 commit 116eeec
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions sonic_platform_base/sonic_sfp/sfputilbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,25 @@ def get_transceiver_info_dict(self, port_num):
transceiver_info_dict['nominal_bit_rate'] = 'N/A'

else:
file_path = self._get_port_eeprom_path(port_num, self.IDENTITY_EEPROM_ADDR)
if not self._sfp_eeprom_present(file_path, 0):
print("Error, file not exist %s" % file_path)
return None

try:
sysfsfile_eeprom = open(file_path, mode="rb", buffering=0)
except IOError:
print("Error: reading sysfs file %s" % file_path)
return None

if port_num in self.qsfp_ports:
# Check for QSA adapter
byte0 = self._read_eeprom_specific_bytes(sysfsfile_eeprom, 0, 1)[0]
is_qsfp = (byte0 != '03' and byte0 != '0b')
else:
is_qsfp = False

if is_qsfp:
offset = 128
vendor_rev_width = XCVR_HW_REV_WIDTH_QSFP
cable_length_width = XCVR_CABLE_LENGTH_WIDTH_QSFP
Expand All @@ -805,17 +823,6 @@ def get_transceiver_info_dict(self, port_num):
print("Error: sfp_object open failed")
return None

file_path = self._get_port_eeprom_path(port_num, self.IDENTITY_EEPROM_ADDR)
if not self._sfp_eeprom_present(file_path, 0):
print("Error, file not exist %s" % file_path)
return None

try:
sysfsfile_eeprom = open(file_path, mode="rb", buffering=0)
except IOError:
print("Error: reading sysfs file %s" % file_path)
return None

sfp_interface_bulk_raw = self._read_eeprom_specific_bytes(sysfsfile_eeprom, (offset + XCVR_INTFACE_BULK_OFFSET), interface_info_bulk_width)
if sfp_interface_bulk_raw is not None:
sfp_interface_bulk_data = sfpi_obj.parse_sfp_info_bulk(sfp_interface_bulk_raw, 0)
Expand Down

0 comments on commit 116eeec

Please sign in to comment.