Media_settings.json Validator Update (#16908)

The format of the media_settings.json file was updated to support the Port SI Per Speed Enhancements. Since media_checker is the validator for the media_settings.json file, it needs to be updated to align with the new format.


How I did it
I added six new SI parameter names introduced as part of the Port SI Per Speed Enhancements. Additionally, I implemented handling for the new hierarchy level (lane_speed_key) in the updated media_settings.json format while maintaining backward compatibility with vendors whose JSON does not support port SI per speed.

How to verify it
I locally built the Debian package using 'make target/debs/bullseye/sonic-device-data_1.0-1_all.deb,' and it completed successfully. Jenkins also built the entire image, which includes the media_checker as part of its process.
This commit is contained in:
Tomer Shalvi 2023-12-01 03:18:09 +02:00 committed by Ying Xie
parent 451398f801
commit dccc5bf6cf

View File

@ -7,9 +7,12 @@ import sys
level1_keys = ["GLOBAL_MEDIA_SETTINGS","PORT_MEDIA_SETTINGS"]
setting_keys = ["preemphasis","idriver","ipredriver",\
si_param_list = ["preemphasis", "idriver", "ipredriver", \
"main", "pre1", "pre2", "pre3", \
"post1","post2","post3","attn"]
"post1", "post2", "post3", "attn", \
"ob_m2lp", "ob_alev_out", "obplev", "obnlev", \
"regn_bfm1p", "regn_bfm1n"]
lane_speed_key_prefix = 'speed:'
lane_prefix = "lane"
comma_separator = ","
range_separator = "-"
@ -46,18 +49,33 @@ def check_media_dict(vendor_dict):
print("Expecting settings for vendor type " + vendor_key)
return False
lane_speed_hierarchy_exists = None
for value_key in value_dict:
if value_key not in setting_keys:
print("Unknown media setting " + value_key)
if value_key.startswith(lane_speed_key_prefix):
if lane_speed_hierarchy_exists is False:
print("Inconsistent lane speed hierarchy levels for the same entry")
return False
lane_speed_hierarchy_exists = True
settings_dict = value_dict[value_key]
else:
if lane_speed_hierarchy_exists is True:
print("Inconsistent lane speed hierarchy levels for the same entry")
return False
lane_speed_hierarchy_exists = False
settings_dict = value_dict
for si_param in settings_dict:
if si_param not in si_param_list:
print("Unknown media setting " + si_param)
return False
lane_dict = value_dict[value_key]
lane_dict = settings_dict[si_param]
for lanes in lane_dict:
if not check_lane_and_value(lanes, lane_dict[lanes]):
return False
return True
def check_valid_port(port_name):
try:
val = int(port_name.strip())