forked from sonic-net/sonic-buildimage
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic OSFP support for sfputil (sonic-net#20)
Enable decode of QSFP-DD/OSFP transceivers, and vendor information.
- Loading branch information
Showing
5 changed files
with
291 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
#! /usr/bin/env python | ||
#---------------------------------------------------------------------------- | ||
# QSFP-DD 8X Transceiver (QSFP Double Density) | ||
#---------------------------------------------------------------------------- | ||
|
||
from __future__ import print_function | ||
|
||
try: | ||
from sff8024 import type_of_transceiver | ||
from sffbase import sffbase | ||
except ImportError as e: | ||
raise ImportError ("%s - required module not found" % e) | ||
|
||
class inf8628InterfaceId(sffbase): | ||
|
||
def decode_revision_compliance(self, eeprom_data, offset, size): | ||
return '%c.%c' % (eeprom_data[offset][0], eeprom_data[offset][1]) | ||
|
||
def decode_module_state(self, eeprom_data, offset, size): | ||
module_state_byte = eeprom_data[offset] | ||
module_state = int(module_state_byte, 16) & 14 | ||
if module_state == 2: | ||
return 'Low Power State' | ||
elif module_state == 4: | ||
return 'Power Up State' | ||
elif module_state == 6: | ||
return 'Ready State' | ||
elif module_state == 8: | ||
return 'Power Down State' | ||
elif module_state == 10: | ||
return 'Fault State' | ||
return 'Unknown State %s' % module_state | ||
|
||
version = '1.0' | ||
|
||
interface_id = { | ||
'Identifier': | ||
{'offset': 0, | ||
'size': 1, | ||
'type': 'enum', | ||
'decode': type_of_transceiver}, | ||
'Revision Compliance': | ||
{'offset': 1, | ||
'type': 'func', | ||
'decode': {'func': decode_revision_compliance}}, | ||
'Module State': | ||
{'offset': 3, | ||
'type': 'func', | ||
'decode': {'func': decode_module_state}}, | ||
'Interrupt Asserted': | ||
{'offset': 3, | ||
'bit': 0, | ||
'type': 'bitvalue'}, | ||
'Vendor Name': | ||
{'offset': 129, | ||
'size': 16, | ||
'type': 'str'}, | ||
'Vendor Part Number': | ||
{'offset': 148, | ||
'size': 16, | ||
'type': 'str'}, | ||
'Vendor Revision': | ||
{'offset': 164, | ||
'size': 2, | ||
'type': 'str'}, | ||
'Vendor Serial Number': | ||
{'offset': 166, | ||
'size': 16, | ||
'type': 'str'}, | ||
} | ||
|
||
sfp_type = { | ||
'type': | ||
{'offset': 0, | ||
'size': 1, | ||
'type': 'enum', | ||
'decode': type_of_transceiver} | ||
} | ||
|
||
vendor_name = { | ||
'Vendor Name': | ||
{'offset': 0, | ||
'size': 16, | ||
'type': 'str'} | ||
} | ||
|
||
vendor_pn = { | ||
'Vendor PN': | ||
{'offset': 0, | ||
'size': 16, | ||
'type': 'str'} | ||
} | ||
|
||
vendor_rev = { | ||
'Vendor Rev': | ||
{'offset': 0, | ||
'size': 2, | ||
'type': 'str'} | ||
} | ||
|
||
vendor_sn = { | ||
'Vendor SN': | ||
{'offset': 0, | ||
'size': 16, | ||
'type': 'str'} | ||
} | ||
|
||
def __init__(self, eeprom_raw_data=None): | ||
self.interface_data = None | ||
start_pos = 0 | ||
|
||
if eeprom_raw_data is not None: | ||
self.interface_data = sffbase.parse(self, | ||
self.interface_id, | ||
eeprom_raw_data, | ||
start_pos) | ||
|
||
def parse(self, eeprom_raw_data, start_pos): | ||
return sffbase.parse(self, self.interface_id, eeprom_raw_data, start_pos) | ||
|
||
def parse_sfp_type(self, type_raw_data, start_pos): | ||
return sffbase.parse(self, self.sfp_type, type_raw_data, start_pos) | ||
|
||
def parse_vendor_name(self, name_raw_data, start_pos): | ||
return sffbase.parse(self, self.vendor_name, name_raw_data, start_pos) | ||
|
||
def parse_vendor_rev(self, rev_raw_data, start_pos): | ||
return sffbase.parse(self, self.vendor_rev, rev_raw_data, start_pos) | ||
|
||
def parse_vendor_pn(self, pn_raw_data, start_pos): | ||
return sffbase.parse(self, self.vendor_pn, pn_raw_data, start_pos) | ||
|
||
def parse_vendor_sn(self, sn_raw_data, start_pos): | ||
return sffbase.parse(self, self.vendor_sn, sn_raw_data, start_pos) | ||
|
||
def dump_pretty(self): | ||
if self.interface_data is None: | ||
print('Object not initialized, nothing to print') | ||
return | ||
sffbase.dump_pretty(self, self.interface_data) | ||
|
||
def get_calibration_type(self): | ||
return self.calibration_type | ||
|
||
def get_data(self): | ||
return self.interface_data | ||
|
||
def get_data_pretty(self): | ||
return sffbase.get_data_pretty(self, self.interface_data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#! /usr/bin/env python | ||
#---------------------------------------------------------------------------- | ||
# SFF-8024 Rev 4.5 | ||
#---------------------------------------------------------------------------- | ||
|
||
from __future__ import print_function | ||
|
||
type_of_transceiver = { | ||
'00': 'Unknown or unspecified', | ||
'01': 'GBIC', | ||
'02': 'Module/connector soldered to motherboard', | ||
'03': 'SFP/SFP+/SFP28', | ||
'04': '300 pin XBI', | ||
'05': 'XENPAK', | ||
'06': 'XFP', | ||
'07': 'XFF', | ||
'08': 'XFP-E', | ||
'09': 'XPAK', | ||
'0a': 'X2', | ||
'0b': 'DWDM-SFP/SFP+', | ||
'0c': 'QSFP', | ||
'0d': 'QSFP+ or later', | ||
'0e': 'CXP or later', | ||
'0f': 'Shielded Mini Multilane HD 4X', | ||
'10': 'Shielded Mini Multilane HD 8X', | ||
'11': 'QSFP28 or later', | ||
'12': 'CXP2 (aka CXP28) or later', | ||
'13': 'CDFP (Style 1/Style2)', | ||
'14': 'Shielded Mini Multilane HD 4X Fanout Cable', | ||
'15': 'Shielded Mini Multilane HD 8X Fanout Cable', | ||
'16': 'CDFP (Style 3)', | ||
'17': 'microQSFP', | ||
'18': 'QSFP-DD Double Density 8X Pluggable Transceiver', | ||
'19': 'OSFP 8X Pluggable Transceiver', | ||
'1a': 'SFP-DD Double Density 2X Pluggable Transceiver' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.