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

[sonic_sfp] Extend sfpbase to get more info from SFP eeprom for xcvrd #22

Merged
merged 4 commits into from
Mar 25, 2019
Merged
Show file tree
Hide file tree
Changes from 2 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
87 changes: 75 additions & 12 deletions sonic_sfp/sff8436.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,15 +363,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 @@ -400,6 +447,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 @@ -418,7 +479,6 @@ class sff8436InterfaceId(sffbase):
'bit': 5,
'type': 'bitvalue'}
}


def __init__(self, eeprom_raw_data=None):
self.interface_data = None
Expand All @@ -433,8 +493,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 @@ -448,6 +508,9 @@ 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_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 @@ -426,13 +426,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 @@ -457,9 +509,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 @@ -490,8 +556,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 @@ -505,6 +571,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