Skip to content

Commit

Permalink
sync change to sonic_platform_base/sonic_sfp and create symbol link (s…
Browse files Browse the repository at this point in the history
  • Loading branch information
keboliu authored and jleveque committed Jul 31, 2019
1 parent 3bb3703 commit 4442b94
Show file tree
Hide file tree
Showing 14 changed files with 64 additions and 5,168 deletions.
12 changes: 12 additions & 0 deletions sonic_platform_base/sonic_sfp/inf8628.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

try:
from .sff8024 import type_of_transceiver # Dot module supports both Python 2 and Python 3 using explicit relative import methods
from .sff8024 import type_abbrv_name # Dot module supports both Python 2 and Python 3 using explicit relative import methods
from .sffbase import sffbase # Dot module supports both Python 2 and Python 3 using explicit relative import methods
except ImportError as e:
raise ImportError ("%s - required module not found" % e)
Expand Down Expand Up @@ -77,6 +78,14 @@ def decode_module_state(self, eeprom_data, offset, size):
'decode': type_of_transceiver}
}

sfp_type_abbrv_name = {
'type_abbrv_name':
{'offset': 0,
'size': 1,
'type': 'enum',
'decode': type_abbrv_name}
}

vendor_name = {
'Vendor Name':
{'offset': 0,
Expand Down Expand Up @@ -121,6 +130,9 @@ def parse(self, 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_sfp_type_abbrv_name(self, type_raw_data, start_pos):
return sffbase.parse(self, self.sfp_type_abbrv_name, 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)

Expand Down
30 changes: 30 additions & 0 deletions sonic_platform_base/sonic_sfp/sff8024.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,33 @@
'19': 'OSFP 8X Pluggable Transceiver',
'1a': 'SFP-DD Double Density 2X Pluggable Transceiver'
}

type_abbrv_name = {
'00': 'Unknown',
'01': 'GBIC',
'02': 'Soldered',
'03': 'SFP',
'04': 'XBI300',
'05': 'XENPAK',
'06': 'XFP',
'07': 'XFF',
'08': 'XFP-E',
'09': 'XPAK',
'0a': 'X2',
'0b': 'DWDM-SFP',
'0c': 'QSFP',
'0d': 'QSFP+',
'0e': 'CXP',
'0f': 'HD4X',
'10': 'HD8X',
'11': 'QSFP28',
'12': 'CXP2',
'13': 'CDFP-1/2',
'14': 'HD4X-Fanout',
'15': 'HD8X-Fanout',
'16': 'CDFP-3',
'17': 'MicroQSFP',
'18': 'QSFP-DD',
'19': 'OSFP-8X',
'1a': 'SFP-DD'
}
6 changes: 6 additions & 0 deletions sonic_platform_base/sonic_sfp/sff8436.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import types
from math import log10
from .sff8024 import type_of_transceiver # Dot module supports both Python 2 and Python 3 using explicit relative import methods
from .sff8024 import type_abbrv_name # Dot module supports both Python 2 and Python 3 using explicit relative import methods
from .sffbase import sffbase # Dot module supports both Python 2 and Python 3 using explicit relative import methods
except ImportError as e:
raise ImportError (str(e) + "- required module not found")
Expand Down Expand Up @@ -352,6 +353,11 @@ class sff8436InterfaceId(sffbase):
'size':1,
'type' : 'enum',
'decode' : type_of_transceiver},
'type_abbrv_name':
{'offset':0,
'size':1,
'type' : 'enum',
'decode' : type_abbrv_name},
'Extended Identifier':
{'offset':1,
'size':1,
Expand Down
6 changes: 6 additions & 0 deletions sonic_platform_base/sonic_sfp/sff8472.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import types
from math import log10
from .sff8024 import type_of_transceiver # Dot module supports both Python 2 and Python 3 using explicit relative import methods
from .sff8024 import type_abbrv_name # Dot module supports both Python 2 and Python 3 using explicit relative import methods
from .sffbase import sffbase # Dot module supports both Python 2 and Python 3 using explicit relative import methods
except ImportError as e:
raise ImportError (str(e) + "- required module not found")
Expand Down Expand Up @@ -419,6 +420,11 @@ class sff8472InterfaceId(sffbase):
'size':1,
'type' : 'enum',
'decode' : type_of_transceiver},
'type_abbrv_name':
{'offset':0,
'size':1,
'type' : 'enum',
'decode' : type_abbrv_name},
'Extended Identifier':
{'offset':1,
'size':1,
Expand Down
10 changes: 9 additions & 1 deletion sonic_platform_base/sonic_sfp/sfputilbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ def read_phytab_mappings(self, phytabfile):
def get_physical_to_logical(self, port_num):
"""Returns list of logical ports for the given physical port"""

return self.physical_to_logical[port_num]
return self.physical_to_logical.get(port_num)

def get_logical_to_physical(self, logical_port):
"""Returns list of physical ports for the given logical port"""
Expand Down Expand Up @@ -747,13 +747,20 @@ def get_transceiver_info_dict(self, port_num):
else:
return None

sfp_type_abbrv_name_raw = self._read_eeprom_specific_bytes(sysfsfile_eeprom, (offset + OSFP_TYPE_OFFSET), XCVR_TYPE_WIDTH)
if sfp_type_abbrv_name_raw is not None:
sfp_type_abbrv_name = sfpi_obj.parse_sfp_type_abbrv_name(sfp_type_abbrv_name_raw, 0)
else:
return None

try:
sysfsfile_eeprom.close()
except IOError:
print("Error: closing sysfs file %s" % file_path)
return None

transceiver_info_dict['type'] = sfp_type_data['data']['type']['value']
transceiver_info_dict['type_abbrv_name'] = sfp_type_abbrv_name['data']['type_abbrv_name']['value']
transceiver_info_dict['manufacturename'] = sfp_vendor_name_data['data']['Vendor Name']['value']
transceiver_info_dict['modelname'] = sfp_vendor_pn_data['data']['Vendor PN']['value']
transceiver_info_dict['hardwarerev'] = sfp_vendor_rev_data['data']['Vendor Rev']['value']
Expand Down Expand Up @@ -855,6 +862,7 @@ def get_transceiver_info_dict(self, port_num):
return None

transceiver_info_dict['type'] = sfp_interface_bulk_data['data']['type']['value']
transceiver_info_dict['type_abbrv_name'] = sfp_interface_bulk_data['data']['type_abbrv_name']['value']
transceiver_info_dict['manufacturename'] = sfp_vendor_name_data['data']['Vendor Name']['value']
transceiver_info_dict['modelname'] = sfp_vendor_pn_data['data']['Vendor PN']['value']
transceiver_info_dict['hardwarerev'] = sfp_vendor_rev_data['data']['Vendor Rev']['value']
Expand Down
1 change: 1 addition & 0 deletions sonic_sfp
Empty file removed sonic_sfp/__init__.py
Empty file.
Loading

0 comments on commit 4442b94

Please sign in to comment.