Skip to content

Commit

Permalink
[sfp] Add parsing the dom_capability to sff8472 (sonic-net#102)
Browse files Browse the repository at this point in the history
- What I did
Following SFF-8472 to read diagnostic monitoring type register.
Use that register to check if diagnostic monitoring function implemented or not.

- How I did it
Check the register position from SFF-8472 document.
Read the register value from the EEPROM.
  • Loading branch information
kuanyu99 authored Jan 19, 2021
1 parent 7fc76b9 commit 6b12b4c
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
4 changes: 2 additions & 2 deletions sonic_platform_base/sonic_sfp/sff8436.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,14 +506,14 @@ def parse_vendor_sn(self, sn_raw_data, start_pos):

def parse_vendor_date(self, sn_raw_data, start_pos):
return sffbase.parse(self, self.vendor_date, sn_raw_data, start_pos)

def parse_vendor_oui(self, sn_raw_data, start_pos):
return sffbase.parse(self, self.vendor_oui, sn_raw_data, start_pos)

def parse_ext_specification_compliance(self, sn_raw_data, start_pos):
return sffbase.parse(self, self.sfp_ext_specification_compliance, sn_raw_data, start_pos)

def parse_qsfp_dom_capability(self, sn_raw_data, start_pos):
def parse_dom_capability(self, sn_raw_data, start_pos):
return sffbase.parse(self, self.qsfp_dom_capability, sn_raw_data, start_pos)

def dump_pretty(self):
Expand Down
10 changes: 10 additions & 0 deletions sonic_platform_base/sonic_sfp/sff8472.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,13 @@ class sff8472InterfaceId(sffbase):
'type': 'date'}
}

sfp_dom_capability = {
'sff8472_dom_support':
{'offset': 0,
'bit': 6,
'type': 'bitvalue'}
}

# Returns calibration type
def _get_calibration_type(self, eeprom_data):
try:
Expand Down Expand Up @@ -568,6 +575,9 @@ def parse_vendor_date(self, sn_raw_data, start_pos):
def parse_vendor_oui(self, sn_raw_data, start_pos):
return sffbase.parse(self, self.vendor_oui, sn_raw_data, start_pos)

def parse_dom_capability(self, dom_type_raw_data, start_pos):
return sffbase.parse(self, self.sfp_dom_capability, dom_type_raw_data, start_pos)

def dump_pretty(self):
if self.interface_data == None:
print('Object not initialized, nothing to print')
Expand Down
26 changes: 25 additions & 1 deletion sonic_platform_base/sonic_sfp/sfputilbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@
'Fibre Channel link length/Transmitter Technology',
'Fibre Channel transmission media', 'Fibre Channel Speed')

qsfp_dom_capability_tup = ('Tx_power_support', 'Rx_power_support',
'Voltage_support', 'Temp_support')

# Add an EOL to prevent this being viewed as string instead of list
sfp_dom_capability_tup = ('sff8472_dom_support', 'EOL')

class SfpUtilError(Exception):
"""Base class for exceptions in this module."""
pass
Expand Down Expand Up @@ -818,6 +824,7 @@ def get_eeprom_dict(self, port_num):
def get_transceiver_info_dict(self, port_num):
transceiver_info_dict = {}
compliance_code_dict = {}
dom_capability_dict = {}

# ToDo: OSFP tranceiver info parsing not fully supported.
# in inf8628.py lack of some memory map definition
Expand Down Expand Up @@ -902,6 +909,7 @@ def get_transceiver_info_dict(self, port_num):
transceiver_info_dict['specification_compliance'] = '{}'
transceiver_info_dict['nominal_bit_rate'] = 'N/A'
transceiver_info_dict['application_advertisement'] = 'N/A'
transceiver_info_dict['dom_capability'] = '{}'

else:
file_path = self._get_port_eeprom_path(port_num, self.IDENTITY_EEPROM_ADDR)
Expand Down Expand Up @@ -988,6 +996,12 @@ def get_transceiver_info_dict(self, port_num):
else:
return None

sfp_dom_capability_raw = self._read_eeprom_specific_bytes(sysfsfile_eeprom, (offset + XCVR_DOM_CAPABILITY_OFFSET), XCVR_DOM_CAPABILITY_WIDTH)
if sfp_dom_capability_raw is not None:
sfp_dom_capability_data = sfpi_obj.parse_dom_capability(sfp_dom_capability_raw, 0)
else:
return None

try:
sysfsfile_eeprom.close()
except IOError:
Expand Down Expand Up @@ -1021,6 +1035,11 @@ def get_transceiver_info_dict(self, port_num):
compliance_code_dict[key] = sfp_interface_bulk_data['data']['Specification compliance']['value'][key]['value']
transceiver_info_dict['specification_compliance'] = str(compliance_code_dict)

for key in qsfp_dom_capability_tup:
if key in sfp_dom_capability_data['data']:
dom_capability_dict[key] = "yes" if sfp_dom_capability_data['data'][key]['value'] == 'on' else "no"
transceiver_info_dict['dom_capability'] = str(dom_capability_dict)

transceiver_info_dict['nominal_bit_rate'] = str(sfp_interface_bulk_data['data']['Nominal Bit Rate(100Mbs)']['value'])
else:
for key in sfp_cable_length_tup:
Expand All @@ -1033,6 +1052,11 @@ def get_transceiver_info_dict(self, port_num):
compliance_code_dict[key] = sfp_interface_bulk_data['data']['Specification compliance']['value'][key]['value']
transceiver_info_dict['specification_compliance'] = str(compliance_code_dict)

for key in sfp_dom_capability_tup:
if key in sfp_dom_capability_data['data']:
dom_capability_dict[key] = "yes" if sfp_dom_capability_data['data'][key]['value'] == 'on' else "no"
transceiver_info_dict['dom_capability'] = str(dom_capability_dict)

transceiver_info_dict['nominal_bit_rate'] = str(sfp_interface_bulk_data['data']['NominalSignallingRate(UnitsOf100Mbd)']['value'])

return transceiver_info_dict
Expand Down Expand Up @@ -1092,7 +1116,7 @@ def get_transceiver_dom_info_dict(self, port_num):
# in SFF-8636 dom capability definitions evolving with the versions.
qsfp_dom_capability_raw = self._read_eeprom_specific_bytes(sysfsfile_eeprom, (offset_xcvr + XCVR_DOM_CAPABILITY_OFFSET), XCVR_DOM_CAPABILITY_WIDTH)
if qsfp_dom_capability_raw is not None:
qspf_dom_capability_data = sfpi_obj.parse_qsfp_dom_capability(qsfp_dom_capability_raw, 0)
qspf_dom_capability_data = sfpi_obj.parse_dom_capability(qsfp_dom_capability_raw, 0)
else:
return None

Expand Down

0 comments on commit 6b12b4c

Please sign in to comment.