Skip to content

Commit

Permalink
[sfp] Add parsing the dom_capability to sff8472
Browse files Browse the repository at this point in the history
* Read the diagnostic monitoring type register to get dom_capability
* Provide basic dom_capability info table as transceiver info
* Unify the name of parsing dom_capability function for both QSFP and SFP
  • Loading branch information
kuanyu99 committed Aug 14, 2020
1 parent 433dd1a commit b0de8b2
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 @@ -508,14 +508,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 @@ -521,6 +521,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 @@ -570,6 +577,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 @@ -123,6 +123,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 @@ -751,6 +757,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 @@ -835,6 +842,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 @@ -921,6 +929,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 @@ -954,6 +968,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 @@ -966,6 +985,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 @@ -1025,7 +1049,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 b0de8b2

Please sign in to comment.