Skip to content

Commit 9b1dea5

Browse files
authored
SFP(sff8472 attributes) transciever eeprom attribute support. (sonic-net#74)
1 parent dc59b10 commit 9b1dea5

File tree

2 files changed

+101
-9
lines changed

2 files changed

+101
-9
lines changed

sonic_platform_base/sonic_sfp/sff8472.py

+95-2
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ class sff8472InterfaceId(sffbase):
513513
'size':3,
514514
'type' : 'hex'}
515515
}
516-
516+
517517
vendor_date = {
518518
'VendorDataCode(YYYY-MM-DD Lot)':
519519
{'offset':0,
@@ -569,7 +569,7 @@ def parse_vendor_date(self, sn_raw_data, start_pos):
569569

570570
def parse_vendor_oui(self, sn_raw_data, start_pos):
571571
return sffbase.parse(self, self.vendor_oui, sn_raw_data, start_pos)
572-
572+
573573
def dump_pretty(self):
574574
if self.interface_data == None:
575575
print('Object not initialized, nothing to print')
@@ -1175,6 +1175,90 @@ def calc_rx_power(self, eeprom_data, offset, size):
11751175
'type': 'func',
11761176
'decode': {'func': calc_rx_power}}
11771177
}
1178+
dom_module_monitor = {
1179+
'TempHighAlarm':
1180+
{'offset':0,
1181+
'bit':7,
1182+
'type': 'bitvalue'},
1183+
'TempLowAlarm':
1184+
{'offset':0,
1185+
'bit':6,
1186+
'type': 'bitvalue'},
1187+
'TempHighWarning':
1188+
{'offset': 4,
1189+
'bit': 7,
1190+
'type': 'bitvalue'},
1191+
'TempLowWarning':
1192+
{'offset': 4,
1193+
'bit': 6,
1194+
'type': 'bitvalue'},
1195+
'VccHighAlarm':
1196+
{'offset': 0,
1197+
'bit': 5,
1198+
'type': 'bitvalue'},
1199+
'VccLowAlarm':
1200+
{'offset': 0,
1201+
'bit': 4,
1202+
'type': 'bitvalue'},
1203+
'VccHighWarning':
1204+
{'offset': 4,
1205+
'bit': 5,
1206+
'type': 'bitvalue'},
1207+
'VccLowWarning':
1208+
{'offset': 4,
1209+
'bit': 4,
1210+
'type': 'bitvalue'}}
1211+
1212+
dom_channel_thresh_monitor_params = {
1213+
'BiasHighAlarm':
1214+
{'offset':0,
1215+
'bit':3,
1216+
'type': 'bitvalue'},
1217+
'BiasLowAlarm':
1218+
{'offset':0,
1219+
'bit':2,
1220+
'type': 'bitvalue'},
1221+
'BiasHighWarning':
1222+
{'offset':4,
1223+
'bit':3,
1224+
'type': 'bitvalue'},
1225+
'BiasLowWarning':
1226+
{'offset':4,
1227+
'bit':2,
1228+
'type': 'bitvalue'},
1229+
'TxPowerHighAlarm':
1230+
{'offset':0,
1231+
'bit':1,
1232+
'type': 'bitvalue'},
1233+
'TxPowerLowAlarm':
1234+
{'offset':0,
1235+
'bit':0,
1236+
'type': 'bitvalue'},
1237+
'TxPowerHighWarning':
1238+
{'offset':4,
1239+
'bit':1,
1240+
'type': 'bitvalue'},
1241+
'TxPowerLowWarning':
1242+
{'offset':4,
1243+
'bit':0,
1244+
'type': 'bitvalue'},
1245+
'RxPowerHighAlarm':
1246+
{'offset':1,
1247+
'bit':7,
1248+
'type': 'bitvalue'},
1249+
'RxPowerLowAlarm':
1250+
{'offset':1,
1251+
'bit':6,
1252+
'type': 'bitvalue'},
1253+
'RxPowerHighWarning':
1254+
{'offset':5,
1255+
'bit':7,
1256+
'type': 'bitvalue'},
1257+
'RxPowerLowWarning':
1258+
{'offset':5,
1259+
'bit':6,
1260+
'type': 'bitvalue'}
1261+
}
11781262

11791263
def __init__(self, eeprom_raw_data=None, calibration_type=0):
11801264
self._calibration_type = calibration_type
@@ -1200,6 +1284,14 @@ def parse_channel_monitor_params(self, eeprom_raw_data, start_pos):
12001284
return sffbase.parse(self, self.dom_channel_monitor_params, eeprom_raw_data,
12011285
start_pos)
12021286

1287+
def parse_module_monitor_params(self, eeprom_raw_data, start_pos):
1288+
return sffbase.parse(self, self.dom_module_monitor, eeprom_raw_data,
1289+
start_pos)
1290+
1291+
def parse_channel_thresh_monitor_params(self, eeprom_raw_data, start_pos):
1292+
return sffbase.parse(self, self.dom_channel_thresh_monitor_params, eeprom_raw_data,
1293+
start_pos)
1294+
12031295
def parse_alarm_warning_threshold(self, eeprom_raw_data, start_pos):
12041296
return sffbase.parse(self, self.dom_aw_thresholds, eeprom_raw_data,
12051297
start_pos)
@@ -1217,3 +1309,4 @@ def get_data(self):
12171309

12181310
def get_data_pretty(self):
12191311
return sffbase.get_data_pretty(self, self.dom_data)
1312+

sonic_platform_base/sonic_sfp/sfputilbase.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,10 @@
8888
SFP_VOLT_WIDTH = 2
8989
SFP_CHANNL_MON_OFFSET = 100
9090
SFP_CHANNL_MON_WIDTH = 6
91-
SFP_MODULE_THRESHOLD_OFFSET = 0
92-
SFP_MODULE_THRESHOLD_WIDTH = 56
93-
91+
SFP_MODULE_THRESHOLD_OFFSET = 112
92+
SFP_MODULE_THRESHOLD_WIDTH = 5
93+
SFP_CHANNL_THRESHOLD_OFFSET = 112
94+
SFP_CHANNL_THRESHOLD_WIDTH = 6
9495

9596
qsfp_cable_length_tup = ('Length(km)', 'Length OM3(2m)',
9697
'Length OM2(m)', 'Length OM1(m)',
@@ -450,7 +451,6 @@ def read_porttab_mappings(self, porttabfile):
450451
print("logical to physical: " + self.logical_to_physical)
451452
print("physical to logical: " + self.physical_to_logical)
452453
"""
453-
454454
def read_phytab_mappings(self, phytabfile):
455455
logical = []
456456
phytab_mappings = {}
@@ -1045,7 +1045,6 @@ def get_transceiver_dom_info_dict(self, port_num):
10451045
sfpd_obj = sff8472Dom()
10461046
if sfpd_obj is None:
10471047
return None
1048-
10491048
dom_temperature_raw = self._read_eeprom_specific_bytes(sysfsfile_eeprom, (offset + SFP_TEMPE_OFFSET), SFP_TEMPE_WIDTH)
10501049
if dom_temperature_raw is not None:
10511050
dom_temperature_data = sfpd_obj.parse_temperature(dom_temperature_raw, 0)
@@ -1086,7 +1085,6 @@ def get_transceiver_dom_info_dict(self, port_num):
10861085
transceiver_dom_info_dict['tx4power'] = 'N/A'
10871086

10881087
return transceiver_dom_info_dict
1089-
10901088
def get_transceiver_dom_threshold_info_dict(self, port_num):
10911089
transceiver_dom_threshold_info_dict = {}
10921090

@@ -1195,7 +1193,7 @@ def get_transceiver_dom_threshold_info_dict(self, port_num):
11951193
(offset + SFP_CHANNL_THRESHOLD_OFFSET),
11961194
SFP_CHANNL_THRESHOLD_WIDTH)
11971195
if dom_channel_threshold_raw is not None:
1198-
dom_channel_threshold_data = sfpd_obj.parse_channel_monitor_params(dom_channel_threshold_raw, 0)
1196+
dom_channel_threshold_data = sfpd_obj.parse_channel_thresh_monitor_params(dom_channel_threshold_raw, 0)
11991197
else:
12001198
return None
12011199

@@ -1279,3 +1277,4 @@ def get_transceiver_change_event(self, timeout=0):
12791277
like {'-1':'system_not_ready'}.
12801278
"""
12811279
return
1280+

0 commit comments

Comments
 (0)