Skip to content

Commit

Permalink
[sonic_sfp] Extend sfpbase to get more info from SFP eeprom for xcvrd (
Browse files Browse the repository at this point in the history
…#22)

* extend sfp base to get more info from eeprom and provide to xcvrd

* update for handling of OSFP
  • Loading branch information
keboliu authored and lguohan committed Mar 25, 2019
1 parent 4405ec9 commit 4944a64
Show file tree
Hide file tree
Showing 3 changed files with 350 additions and 64 deletions.
90 changes: 78 additions & 12 deletions sonic_sfp/sff8436.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,15 +346,62 @@ class sff8436InterfaceId(sffbase):
'size' : 1,
'type' : 'bitmap',
'decode': {}}}

sfp_type = {
'type':
{'offset': 0,
'size': 1,
'type': 'enum',
'decode': type_of_transceiver}
}


sfp_info_bulk = {'type':
{'offset':0,
'size':1,
'type' : 'enum',
'decode' : type_of_transceiver},
'Extended Identifier':
{'offset':1,
'size':1,
'type' : 'enum',
'decode': ext_type_of_transceiver},
'Connector':
{'offset':2,
'size':1,
'type' : 'enum',
'decode': connector},
'Specification compliance':
{'offset' : 3,
'type' : 'nested',
'decode' : specification_compliance},
'EncodingCodes':
{'offset':11,
'size':1,
'type' : 'enum',
'decode' : encoding_codes},
'Nominal Bit Rate(100Mbs)':
{'offset': 12,
'size':1,
'type':'int'},
'RateIdentifier':
{'offset':13,
'size':1,
'type' : 'enum',
'decode' : rate_identifier},
'Length(km)':
{'offset':14,
'size':1,
'type':'int'},
'Length OM3(2m)':
{'offset':15,
'size':1,
'type':'int'},
'Length OM2(m)':
{'offset':16,
'size':1,
'type':'int'},
'Length OM1(m)':
{'offset':17,
'size':1,
'type':'int'},
'Length Cable Assembly(m)':
{'offset':18,
'size':1,
'type':'int'}
}

vendor_name = {
'Vendor Name':
{'offset': 0,
Expand Down Expand Up @@ -383,6 +430,20 @@ class sff8436InterfaceId(sffbase):
'type': 'str'}
}

vendor_oui = {
'Vendor OUI':
{'offset':0,
'size':3,
'type' : 'hex'}
}

vendor_date = {
'VendorDataCode(YYYY-MM-DD Lot)':
{'offset':0,
'size':8,
'type': 'date'}
}

qsfp_dom_capability = {
'Tx_power_support':
{'offset': 0,
Expand All @@ -401,7 +462,6 @@ class sff8436InterfaceId(sffbase):
'bit': 5,
'type': 'bitvalue'}
}


def __init__(self, eeprom_raw_data=None):
self.interface_data = None
Expand All @@ -416,8 +476,8 @@ def __init__(self, eeprom_raw_data=None):
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_sfp_info_bulk(self, type_raw_data, start_pos):
return sffbase.parse(self, self.sfp_info_bulk, 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 All @@ -431,6 +491,12 @@ def parse_vendor_pn(self, 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 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_qsfp_dom_capability(self, sn_raw_data, start_pos):
return sffbase.parse(self, self.qsfp_dom_capability, sn_raw_data, start_pos)

Expand Down
96 changes: 84 additions & 12 deletions sonic_sfp/sff8472.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,13 +413,65 @@ class sff8472InterfaceId(sffbase):
'type': 'date'}}

# Parser for specific values that interested by SNMP
sfp_type = {
'type':
{'offset': 0,
'size': 1,
'type': 'enum',
'decode': type_of_transceiver}
}

sfp_info_bulk = {'type':
{'offset':0,
'size':1,
'type' : 'enum',
'decode' : type_of_transceiver},
'Extended Identifier':
{'offset':1,
'size':1,
'type' : 'enum',
'decode': exttypeoftransceiver},
'Connector':
{'offset':2,
'size':1,
'type' : 'enum',
'decode': connector},
'Specification compliance':
{'offset' : 3,
'type' : 'nested',
'decode' : transceiver_codes},
'EncodingCodes':
{'offset':11,
'size':1,
'type' : 'enum',
'decode' : encoding_codes},
'NominalSignallingRate(UnitsOf100Mbd)':
{'offset': 12,
'size':1,
'type':'int'},
'RateIdentifier':
{'offset':13,
'size':1,
'type' : 'enum',
'decode' : rate_identifier},
'LengthSMFkm-UnitsOfKm':
{'offset':14,
'size':1,
'type':'int'},
'LengthSMF(UnitsOf100m)':
{'offset':15,
'size':1,
'type':'int'},
'Length50um(UnitsOf10m)':
{'offset':16,
'size':1,
'type':'int'},
'Length62.5um(UnitsOfm)':
{'offset':17,
'size':1,
'type':'int'},
'LengthCable(UnitsOfm)':
{'offset':18,
'size':1,
'type':'int'},
'LengthOM3(UnitsOf10m)':
{'offset':19,
'size':1,
'type':'int'}
}

vendor_name = {
'Vendor Name':
Expand All @@ -444,9 +496,23 @@ class sff8472InterfaceId(sffbase):

vendor_sn = {
'Vendor SN':
{'offset': 0,
'size': 16,
'type': 'str'}
{'offset': 0,
'size': 16,
'type': 'str'}
}

vendor_oui = {
'Vendor OUI':
{'offset':0,
'size':3,
'type' : 'hex'}
}

vendor_date = {
'VendorDataCode(YYYY-MM-DD Lot)':
{'offset':0,
'size':8,
'type': 'date'}
}

# Returns calibration type
Expand Down Expand Up @@ -477,8 +543,8 @@ def parse(self, eeprom_raw_data, start_pos):
return sffbase.parse(self, self.interface_id, eeprom_raw_data, start_pos)

#new parser functions for specific values that interested by SNMP
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_info_bulk(self, type_raw_data, start_pos):
return sffbase.parse(self, self.sfp_info_bulk, 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 All @@ -492,6 +558,12 @@ def parse_vendor_pn(self, 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 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 dump_pretty(self):
if self.interface_data == None:
print('Object not initialized, nothing to print')
Expand Down
Loading

0 comments on commit 4944a64

Please sign in to comment.