Skip to content

Commit

Permalink
Parse all VDM advertised fields during DOM monitoring (#486)
Browse files Browse the repository at this point in the history
Signed-off-by: Mihir Patel <patelmi@microsoft.com>
  • Loading branch information
mihirpat1 authored and mssonicbld committed Aug 1, 2024
1 parent cd6a5a4 commit 8ed735e
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 10 deletions.
37 changes: 32 additions & 5 deletions sonic_platform_base/sonic_xcvr/api/public/cmis.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,29 @@
logger = logging.getLogger(__name__)
logger.addHandler(logging.NullHandler())

CMIS_VDM_KEY_TO_DB_PREFIX_KEY_MAP = {
"eSNR Media Input [dB]" : "esnr_media_input",
"PAM4 Level Transition Parameter Media Input [dB]" : "pam4_level_transition_media_input",
"Pre-FEC BER Minimum Media Input" : "prefec_ber_min_media_input",
"Pre-FEC BER Maximum Media Input" : "prefec_ber_max_media_input",
"Pre-FEC BER Average Media Input" : "prefec_ber_avg_media_input",
"Pre-FEC BER Current Value Media Input" : "prefec_ber_curr_media_input",
"Errored Frames Minimum Media Input" : "errored_frames_min_media_input",
"Errored Frames Maximum Media Input" : "errored_frames_max_media_input",
"Errored Frames Average Media Input" : "errored_frames_avg_media_input",
"Errored Frames Current Value Media Input" : "errored_frames_curr_media_input",
"eSNR Host Input [dB]" : "esnr_host_input",
"PAM4 Level Transition Parameter Host Input [dB]" : "pam4_level_transition_host_input",
"Pre-FEC BER Minimum Host Input" : "prefec_ber_min_host_input",
"Pre-FEC BER Maximum Host Input" : "prefec_ber_max_host_input",
"Pre-FEC BER Average Host Input" : "prefec_ber_avg_host_input",
"Pre-FEC BER Current Value Host Input" : "prefec_ber_curr_host_input",
"Errored Frames Minimum Host Input" : "errored_frames_min_host_input",
"Errored Frames Maximum Host Input" : "errored_frames_max_host_input",
"Errored Frames Average Host Input" : "errored_frames_avg_host_input",
"Errored Frames Current Value Host Input" : "errored_frames_curr_host_input"
}

class CmisApi(XcvrApi):
NUM_CHANNELS = 8
LowPwrRequestSW = 4
Expand Down Expand Up @@ -233,13 +256,17 @@ def get_transceiver_bulk_status(self):
self.vdm_dict = self.get_vdm(self.vdm.VDM_REAL_VALUE)
try:
bulk_status['laser_temperature'] = laser_temp_dict['monitor value']
bulk_status['prefec_ber'] = self.vdm_dict['Pre-FEC BER Average Media Input'][1][0]
bulk_status['postfec_ber_min'] = self.vdm_dict['Errored Frames Minimum Media Input'][1][0]
bulk_status['postfec_ber_max'] = self.vdm_dict['Errored Frames Maximum Media Input'][1][0]
bulk_status['postfec_ber_avg'] = self.vdm_dict['Errored Frames Average Media Input'][1][0]
bulk_status['postfec_curr_val'] = self.vdm_dict['Errored Frames Current Value Media Input'][1][0]
except (KeyError, TypeError):
pass

for vdm_key, db_key in CMIS_VDM_KEY_TO_DB_PREFIX_KEY_MAP.items():
for lane in range(1, self.NUM_CHANNELS + 1):
try:
bulk_status_key = "%s%d" % (db_key, lane)
bulk_status[bulk_status_key] = self.vdm_dict[vdm_key][lane][0]
except (KeyError, TypeError):
pass

return bulk_status

def get_transceiver_threshold_info(self):
Expand Down
15 changes: 10 additions & 5 deletions tests/sonic_xcvr/test_cmis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1375,6 +1375,7 @@ def test_get_transceiver_info(self, mock_response, expected):
'Errored Frames Maximum Media Input':{1:[0, 1, 0, 1, 0, False, False, False, False]},
'Errored Frames Average Media Input':{1:[0, 1, 0, 1, 0, False, False, False, False]},
'Errored Frames Current Value Media Input':{1:[0, 1, 0, 1, 0, False, False, False, False]},
'Pre-FEC BER Current Value Host Input':{1: [2.66e-09, 1e-05, 0.0, 1e-06, 0.0, False, False, False, False], 2: [1.0, 1e-05, 0.0, 1e-06, 0.0, False, False, False, False], 3: [1.0, 1e-05, 0.0, 1e-06, 0.0, False, False, False, False], 4: [1.0, 1e-05, 0.0, 1e-06, 0.0, False, False, False, False]},
}
],
{
Expand All @@ -1387,11 +1388,15 @@ def test_get_transceiver_info(self, mock_response, expected):
'tx1bias': 70, 'tx2bias': 70, 'tx3bias': 70, 'tx4bias': 70,
'tx5bias': 70, 'tx6bias': 70, 'tx7bias': 70, 'tx8bias': 70,
'laser_temperature': 40,
'prefec_ber': 0.001,
'postfec_ber_min': 0,
'postfec_ber_max': 0,
'postfec_ber_avg': 0,
'postfec_curr_val': 0,
'prefec_ber_avg_media_input1': 0.001,
'errored_frames_min_media_input1': 0,
'errored_frames_max_media_input1': 0,
'errored_frames_avg_media_input1': 0,
'errored_frames_curr_media_input1': 0,
'prefec_ber_curr_host_input1': 2.66e-09,
'prefec_ber_curr_host_input2': 1.0,
'prefec_ber_curr_host_input3': 1.0,
'prefec_ber_curr_host_input4': 1.0
}
),
(
Expand Down

0 comments on commit 8ed735e

Please sign in to comment.