Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sfp] Add parsing the dom_capability to sff8472 #102

Merged
merged 1 commit into from
Jan 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it necessary to expose this to transceiver_info_dict? My understanding is that this is only some internal flag, if DOM supported, means can get the related meaningful monitor info from the EEPROM.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a verification method for the SFP type transceiver for now.
If user buy a SFP type transceiver with DOM capability, there is no way to check DOM capability of the transceiver in SONIC currently. With this, the user can check if he/she buy a fake one or not at least.
And in the future, we can enhance this part to check more dom info according to its dom_capability.


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