Skip to content

Commit 7fcc492

Browse files
committed
Updated comments and initializing flag count to 0 if flag is clear upon xcvrd boot-up
1 parent eb76cad commit 7fcc492

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

sonic-xcvrd/xcvrd/dom_mgr.py

+3
Original file line numberDiff line numberDiff line change
@@ -363,11 +363,13 @@ def task_worker(self):
363363
self.log_warning("Got exception {} while processing transceiver status hw for port {}, ignored".format(repr(e), logical_port_name))
364364
continue
365365
if xcvrd._wrapper_is_transceiver_vdm_supported(physical_port):
366+
# Freeze VDM stats before reading VDM values
366367
with self.vdm_freeze_context(physical_port) as vdm_frozen:
367368
if not vdm_frozen:
368369
self.log_error("Failed to freeze VDM stats for port {}".format(physical_port))
369370
continue
370371
try:
372+
# Read and post VDM real values to DB
371373
self.post_port_diagnostic_values_to_db(logical_port_name, self.xcvr_table_helper.get_vdm_real_value_tbl(asic_index),
372374
xcvrd._wrapper_get_vdm_real_values, self.task_stopping_event,
373375
db_cache=vdm_real_value_cache)
@@ -376,6 +378,7 @@ def task_worker(self):
376378
self.log_warning("Got exception {} while processing vdm values for port {}, ignored".format(repr(e), logical_port_name))
377379
continue
378380
try:
381+
# Read and post VDM flags and metadata to DB
379382
xcvrd.post_port_vdm_non_real_values_to_db(logical_port_name, self.port_mapping, self.xcvr_table_helper,
380383
self.xcvr_table_helper.get_vdm_flag_tbl,
381384
xcvrd._wrapper_get_vdm_flags, stop_event=self.task_stopping_event,

sonic-xcvrd/xcvrd/xcvrd.py

+9-12
Original file line numberDiff line numberDiff line change
@@ -680,30 +680,26 @@ def update_flag_metadata_tables(logical_port_name, physical_port_name, field_nam
680680
return
681681

682682
found, db_flags_value_dict = flag_value_table.get(logical_port_name)
683+
# Table is empty, this is the first update to the metadata tables (this also means that the transceiver was detected for the first time)
684+
# Unless the flag (current_value) is set, initialize the change count to 0 and last set and clear times to 'never'
683685
if not found:
684-
# Table is empty, this is the first update to the metadata tables (this also means that the transceiver was detected for the first time)
685-
if str(current_value) == 'N/A':
686+
if str(current_value).strip() == 'N/A' or not current_value:
686687
flag_change_count_table.set(physical_port_name, swsscommon.FieldValuePairs([(field_name, '0')]))
687688
flag_last_set_time_table.set(physical_port_name, swsscommon.FieldValuePairs([(field_name, 'never')]))
688689
flag_last_clear_time_table.set(physical_port_name, swsscommon.FieldValuePairs([(field_name, 'never')]))
689-
return
690690
else:
691691
flag_change_count_table.set(physical_port_name, swsscommon.FieldValuePairs([(field_name, '1')]))
692-
if current_value:
693-
flag_last_set_time_table.set(physical_port_name, swsscommon.FieldValuePairs([(field_name, flag_values_dict_update_time)]))
694-
flag_last_clear_time_table.set(physical_port_name, swsscommon.FieldValuePairs([(field_name, 'never')]))
695-
else:
696-
flag_last_set_time_table.set(physical_port_name, swsscommon.FieldValuePairs([(field_name, 'never')]))
697-
flag_last_clear_time_table.set(physical_port_name, swsscommon.FieldValuePairs([(field_name, flag_values_dict_update_time)]))
698-
return
692+
flag_last_set_time_table.set(physical_port_name, swsscommon.FieldValuePairs([(field_name, flag_values_dict_update_time)]))
693+
flag_last_clear_time_table.set(physical_port_name, swsscommon.FieldValuePairs([(field_name, 'never')]))
694+
return
699695
else:
700696
db_flags_value_dict = dict(db_flags_value_dict)
701697

702698
# No metadata update required if the value is 'N/A'
703-
if str(current_value) == 'N/A':
699+
if str(current_value).strip() == 'N/A':
704700
return
705701

706-
# Handle the case wherein the key is already in the db and the value of flag has changed from the previous value
702+
# Update metadata if the value of flag has changed from the previous value
707703
if field_name in db_flags_value_dict and db_flags_value_dict[field_name] != str(current_value):
708704
found, db_change_count_dict = flag_change_count_table.get(physical_port_name)
709705
if not found:
@@ -1793,6 +1789,7 @@ def _post_port_sfp_info_and_dom_thr_to_db_once(self, port_mapping, xcvr_table_he
17931789
rc = post_port_sfp_info_to_db(logical_port_name, port_mapping, xcvr_table_helper.get_intf_tbl(asic_index), transceiver_dict, stop_event)
17941790
if rc != SFP_EEPROM_NOT_READY:
17951791
post_port_dom_threshold_info_to_db(logical_port_name, port_mapping, xcvr_table_helper.get_dom_threshold_tbl(asic_index), stop_event)
1792+
# Read the VDM thresholds and post them to the DB
17961793
post_port_vdm_non_real_values_to_db(logical_port_name, port_mapping, xcvr_table_helper,
17971794
xcvr_table_helper.get_vdm_threshold_tbl,
17981795
_wrapper_get_transceiver_vdm_thresholds, stop_event=stop_event)

0 commit comments

Comments
 (0)