Skip to content

Commit

Permalink
sonic_xcvrd: Support for DOM Threshold values for EEPROM dump (sonic-…
Browse files Browse the repository at this point in the history
  • Loading branch information
sridhar-ravindran authored and jleveque committed Jul 2, 2019
1 parent 6618737 commit daa3fd9
Showing 1 changed file with 107 additions and 14 deletions.
121 changes: 107 additions & 14 deletions sonic-xcvrd/scripts/xcvrd
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,32 @@ def beautify_dom_info_dict(dom_info_dict):
dom_info_dict['tx3power'] = strip_unit_and_beautify(dom_info_dict['tx3power'], POWER_UNIT)
dom_info_dict['tx4power'] = strip_unit_and_beautify(dom_info_dict['tx4power'], POWER_UNIT)

def beautify_dom_threshold_info_dict(dom_info_dict):
dom_info_dict['temphighalarm'] = strip_unit_and_beautify(dom_info_dict['temphighalarm'], TEMP_UNIT)
dom_info_dict['temphighwarning'] = strip_unit_and_beautify(dom_info_dict['temphighwarning'], TEMP_UNIT)
dom_info_dict['templowalarm'] = strip_unit_and_beautify(dom_info_dict['templowalarm'], TEMP_UNIT)
dom_info_dict['templowwarning'] = strip_unit_and_beautify(dom_info_dict['templowwarning'], TEMP_UNIT)

dom_info_dict['vcchighalarm'] = strip_unit_and_beautify(dom_info_dict['vcchighalarm'], VOLT_UNIT)
dom_info_dict['vcchighwarning'] = strip_unit_and_beautify(dom_info_dict['vcchighwarning'], VOLT_UNIT)
dom_info_dict['vcclowalarm'] = strip_unit_and_beautify(dom_info_dict['vcclowalarm'], VOLT_UNIT)
dom_info_dict['vcclowwarning'] = strip_unit_and_beautify(dom_info_dict['vcclowwarning'], VOLT_UNIT)

dom_info_dict['txpowerhighalarm'] = strip_unit_and_beautify(dom_info_dict['txpowerhighalarm'], POWER_UNIT)
dom_info_dict['txpowerlowalarm'] = strip_unit_and_beautify(dom_info_dict['txpowerlowalarm'], POWER_UNIT)
dom_info_dict['txpowerhighwarning'] = strip_unit_and_beautify(dom_info_dict['txpowerhighwarning'], POWER_UNIT)
dom_info_dict['txpowerlowwarning'] = strip_unit_and_beautify(dom_info_dict['txpowerlowwarning'], POWER_UNIT)

dom_info_dict['rxpowerhighalarm'] = strip_unit_and_beautify(dom_info_dict['rxpowerhighalarm'], POWER_UNIT)
dom_info_dict['rxpowerlowalarm'] = strip_unit_and_beautify(dom_info_dict['rxpowerlowalarm'], POWER_UNIT)
dom_info_dict['rxpowerhighwarning'] = strip_unit_and_beautify(dom_info_dict['rxpowerhighwarning'], POWER_UNIT)
dom_info_dict['rxpowerlowwarning'] = strip_unit_and_beautify(dom_info_dict['rxpowerlowwarning'], POWER_UNIT)

dom_info_dict['txbiashighalarm'] = strip_unit_and_beautify(dom_info_dict['txbiashighalarm'], BIAS_UNIT)
dom_info_dict['txbiaslowalarm'] = strip_unit_and_beautify(dom_info_dict['txbiaslowalarm'], BIAS_UNIT)
dom_info_dict['txbiashighwarning'] = strip_unit_and_beautify(dom_info_dict['txbiashighwarning'], BIAS_UNIT)
dom_info_dict['txbiaslowwarning'] = strip_unit_and_beautify(dom_info_dict['txbiaslowwarning'], BIAS_UNIT)

# Update port sfp info in db
def post_port_sfp_info_to_db(logical_port_name, table, transceiver_dict,
stop_event=threading.Event()):
Expand Down Expand Up @@ -164,6 +190,66 @@ def post_port_sfp_info_to_db(logical_port_name, table, transceiver_dict,
logger.log_error("This functionality is currently not implemented for this platform")
sys.exit(NOT_IMPLEMENTED_ERROR)

# Update port dom threshold info in db
def post_port_dom_threshold_info_to_db(logical_port_name, table,
stop=threading.Event()):
ganged_port = False
ganged_member_num = 1

physical_port_list = logical_port_name_to_physical_port_list(logical_port_name)
if physical_port_list is None:
logger.log_error("No physical ports found for logical port '%s'"
% logical_port_name)
return PHYSICAL_PORT_NOT_EXIST

if len(physical_port_list) > 1:
ganged_port = True

for physical_port in physical_port_list:
if stop.is_set():
break

if not platform_sfputil.get_presence(physical_port):
continue

port_name = get_physical_port_name(logical_port_name,
ganged_member_num, ganged_port)
ganged_member_num += 1

try:
dom_info_dict = platform_sfputil.get_transceiver_dom_threshold_info_dict(physical_port)
if dom_info_dict is not None:
beautify_dom_threshold_info_dict(dom_info_dict)
fvs = swsscommon.FieldValuePairs(
[('temphighalarm', dom_info_dict['temphighalarm']),
('temphighwarning', dom_info_dict['temphighwarning']),
('templowalarm', dom_info_dict['templowalarm']),
('templowwarning', dom_info_dict['templowwarning']),
('vcchighalarm', dom_info_dict['vcchighalarm']),
('vcchighwarning', dom_info_dict['vcchighwarning']),
('vcclowalarm', dom_info_dict['vcclowalarm']),
('vcclowwarning', dom_info_dict['vcclowwarning']),
('txpowerhighalarm', dom_info_dict['txpowerhighalarm']),
('txpowerlowalarm', dom_info_dict['txpowerlowalarm']),
('txpowerhighwarning', dom_info_dict['txpowerhighwarning']),
('txpowerlowwarning', dom_info_dict['txpowerlowwarning']),
('rxpowerhighalarm', dom_info_dict['rxpowerhighalarm']),
('rxpowerlowalarm', dom_info_dict['rxpowerlowalarm']),
('rxpowerhighwarning', dom_info_dict['rxpowerhighwarning']),
('rxpowerlowwarning', dom_info_dict['rxpowerlowwarning']),
('txbiashighalarm', dom_info_dict['txbiashighalarm']),
('txbiaslowalarm', dom_info_dict['txbiaslowalarm']),
('txbiashighwarning', dom_info_dict['txbiashighwarning']),
('txbiaslowwarning', dom_info_dict['txbiaslowwarning'])
])
table.set(port_name, fvs)
else:
return SFP_EEPROM_NOT_READY

except NotImplementedError:
logger.log_error("This functionality is currently not implemented for this platform")
sys.exit(NOT_IMPLEMENTED_ERROR)

# Update port dom sensor info in db
def post_port_dom_info_to_db(logical_port_name, table, stop_event=threading.Event()):
ganged_port = False
Expand Down Expand Up @@ -191,21 +277,25 @@ def post_port_dom_info_to_db(logical_port_name, table, stop_event=threading.Even
dom_info_dict = platform_sfputil.get_transceiver_dom_info_dict(physical_port)
if dom_info_dict is not None:
beautify_dom_info_dict(dom_info_dict)
fvs = swsscommon.FieldValuePairs([('temperature', dom_info_dict['temperature']),
('voltage', dom_info_dict['voltage']),
('rx1power', dom_info_dict['rx1power']),
('rx2power', dom_info_dict['rx2power']),
('rx3power', dom_info_dict['rx3power']),
('rx4power', dom_info_dict['rx4power']),
('tx1bias', dom_info_dict['tx1bias']),
('tx2bias', dom_info_dict['tx2bias']),
('tx3bias', dom_info_dict['tx3bias']),
('tx4bias', dom_info_dict['tx4bias']),
('tx1power', dom_info_dict['tx1power']),
('tx2power', dom_info_dict['tx2power']),
('tx3power', dom_info_dict['tx3power']),
('tx4power', dom_info_dict['tx4power'])])
fvs = swsscommon.FieldValuePairs(
[('temperature', dom_info_dict['temperature']),
('voltage', dom_info_dict['voltage']),
('rx1power', dom_info_dict['rx1power']),
('rx2power', dom_info_dict['rx2power']),
('rx3power', dom_info_dict['rx3power']),
('rx4power', dom_info_dict['rx4power']),
('tx1bias', dom_info_dict['tx1bias']),
('tx2bias', dom_info_dict['tx2bias']),
('tx3bias', dom_info_dict['tx3bias']),
('tx4bias', dom_info_dict['tx4bias']),
('tx1power', dom_info_dict['tx1power']),
('tx2power', dom_info_dict['tx2power']),
('tx3power', dom_info_dict['tx3power']),
('tx4power', dom_info_dict['tx4power'])
])

table.set(port_name, fvs)

else:
return SFP_EEPROM_NOT_READY

Expand Down Expand Up @@ -233,6 +323,8 @@ def post_port_sfp_dom_info_to_db(is_warm_start, stop_event=threading.Event()):

post_port_sfp_info_to_db(logical_port_name, int_tbl, transceiver_dict, stop_event)
post_port_dom_info_to_db(logical_port_name, dom_tbl, stop_event)
post_port_dom_threshold_info_to_db(logical_port_name, dom_tbl, stop_event)

## Do not notify media settings during warm reboot to avoid dataplane traffic impact
if is_warm_start == False:
notify_media_setting(logical_port_name, transceiver_dict, app_port_tbl)
Expand Down Expand Up @@ -551,6 +643,7 @@ class sfp_state_update_task:
time.sleep(TIME_FOR_SFP_READY_SECS)
post_port_sfp_info_to_db(logical_port, int_tbl, transceiver_dict)
post_port_dom_info_to_db(logical_port, dom_tbl)
post_port_dom_threshold_info_to_db(logical_port, dom_tbl)
notify_media_setting(logical_port, transceiver_dict, app_port_tbl)
transceiver_dict.clear()
elif value == SFP_STATUS_REMOVED:
Expand Down

0 comments on commit daa3fd9

Please sign in to comment.