[xrcvd]: add media settings checker and settings for z9100 (#2713)

Modifying media settings file according to latest design
This commit is contained in:
Sudharsan D.G 2019-06-09 04:29:27 +00:00 committed by lguohan
parent fa3ea537e7
commit 3d2955a184
3 changed files with 913 additions and 0 deletions

View File

@ -0,0 +1,751 @@
{
"GLOBAL_MEDIA_SETTINGS": {
"1-32": {
"AMPHENOL-NDARHF-M201": {
"preemphasis": {
"lane0":"0x006808",
"lane1":"0x006808"
},
"idriver": {
"lane0":"0x8",
"lane1":"0x8"
}
},
"AMPHENOL-NDAAFF-M201": {
"preemphasis": {
"lane0":"0x006808",
"lane1":"0x006808",
"lane2":"0x006808",
"lane3":"0x006808"
},
"idriver": {
"lane0":"0x8",
"lane1":"0x8",
"lane2":"0x8",
"lane3":"0x8"
}
},
"MOLEX-1003461101": {
"preemphasis": {
"lane0":"0x046804",
"lane1":"0x046804"
},
"idriver": {
"lane0":"0x8",
"lane1":"0x8"
}
},
"AMPHENOL-NDARHF-M206": {
"preemphasis": {
"lane0":"0x006808",
"lane1":"0x006808"
},
"idriver": {
"lane0":"0xb",
"lane1":"0xb"
}
},
"AMPHENOL-NDAAFF-M206": {
"preemphasis": {
"lane0":"0x006808",
"lane1":"0x006808",
"lane2":"0x006808",
"lane3":"0x006808"
},
"idriver": {
"lane0":"0xb",
"lane1":"0xb",
"lane2":"0xb",
"lane3":"0xb"
}
},
"AMPHENOL-NDARHJ-M206": {
"preemphasis": {
"lane0":"0x006808",
"lane1":"0x006808"
},
"idriver": {
"lane0":"0xb",
"lane1":"0xb"
}
},
"MOLEX-1003463151": {
"preemphasis": {
"lane0":"0x006808",
"lane1":"0x006808"
},
"idriver": {
"lane0":"0xb",
"lane1":"0xb"
}
},
"AMPHENOL-NDARHJ-M202": {
"preemphasis": {
"lane0":"0x006808",
"lane1":"0x006808"
},
"idriver": {
"lane0":"0xb",
"lane1":"0xb"
}
},
"AMPHENOL-NDAAFJ-M202": {
"preemphasis": {
"lane0":"0x006808",
"lane1":"0x006808",
"lane2":"0x006808",
"lane3":"0x006808"
},
"idriver": {
"lane0":"0xb",
"lane1":"0xb",
"lane2":"0xb",
"lane3":"0xb"
}
},
"MOLEX-1003461201": {
"preemphasis": {
"lane0":"0x046408",
"lane1":"0x046408"
},
"idriver": {
"lane0":"0xb",
"lane1":"0xb"
}
},
"AMPHENOL-NDARHF-M205": {
"preemphasis": {
"lane0":"0x006808",
"lane1":"0x006808"
},
"idriver": {
"lane0":"0x8",
"lane1":"0x8"
}
},
"AMPHENOL-NDAAFF-M205": {
"preemphasis": {
"lane0":"0x006808",
"lane1":"0x006808",
"lane2":"0x006808",
"lane3":"0x006808"
},
"idriver": {
"lane0":"0x8",
"lane1":"0x8",
"lane2":"0x8",
"lane3":"0x8"
}
},
"AMPHENOL-NDARHJ-M203": {
"preemphasis": {
"lane0":"0x006808",
"lane1":"0x006808"
},
"idriver": {
"lane0":"0xe",
"lane1":"0xe"
}
},
"AMPHENOL-NDAAFJ-M203": {
"preemphasis": {
"lane0":"0x006808",
"lane1":"0x006808",
"lane2":"0x006808",
"lane3":"0x006808"
},
"idriver": {
"lane0":"0xe",
"lane1":"0xe",
"lane2":"0xe",
"lane3":"0xe"
}
},
"MOLEX-1002979024": {
"preemphasis": {
"lane0":"0x006808",
"lane1":"0x006808",
"lane2":"0x006808",
"lane3":"0x006808"
},
"idriver": {
"lane0":"0xb",
"lane1":"0xb",
"lane2":"0xb",
"lane3":"0xb"
}
},
"QSFP28-40GBASE-CR4-1M":{
"preemphasis": {
"lane0":"0x32320c",
"lane1":"0x32320c",
"lane2":"0x32320c",
"lane3":"0x32320c"
},
"idriver": {
"lane0":"0x9",
"lane1":"0x9",
"lane2":"0x9",
"lane3":"0x9"
}
},
"QSFP28-40GBASE-CR4-2M":{
"preemphasis": {
"lane0":"0x252f0c",
"lane1":"0x252f0c",
"lane2":"0x252f0c",
"lane3":"0x252f0c"
},
"idriver": {
"lane0":"0xc",
"lane1":"0xc",
"lane2":"0xc",
"lane3":"0xc"
}
},
"QSFP28-40GBASE-CR4-3M":{
"preemphasis": {
"lane0":"0x252f0c",
"lane1":"0x252f0c",
"lane2":"0x252f0c",
"lane3":"0x252f0c"
},
"idriver": {
"lane0":"0xe",
"lane1":"0xe",
"lane2":"0xe",
"lane3":"0xe"
}
},
"QSFP28-40GBASE-CR4-5M":{
"preemphasis": {
"lane0":"0x3d2f04",
"lane1":"0x3d2f04",
"lane2":"0x3d2f04",
"lane3":"0x3d2f04"
},
"idriver": {
"lane0":"0xf",
"lane1":"0xf",
"lane2":"0xf",
"lane3":"0xf"
}
}
}
},
"PORT_MEDIA_SETTINGS": {
"1": {
"Default": {
"preemphasis": {
"lane0":"0x2c4004",
"lane1":"0x2b4203",
"lane2":"0x2c4004",
"lane3":"0x2c4004"
},
"idriver": {
"lane0":"0xb",
"lane1":"0xb",
"lane2":"0xb",
"lane3":"0xb"
}
}
},
"2": {
"Default": {
"preemphasis": {
"lane0":"0x2b4203",
"lane1":"0x294403",
"lane2":"0x2b4203",
"lane3":"0x2b4203"
},
"idriver": {
"lane0":"0xb",
"lane1":"0xa",
"lane2":"0xb",
"lane3":"0xb"
}
}
},
"3": {
"Default": {
"preemphasis": {
"lane0":"0x294403",
"lane1":"0x294403",
"lane2":"0x294403",
"lane3":"0x294403"
},
"idriver": {
"lane0":"0xa",
"lane1":"0xa",
"lane2":"0xa",
"lane3":"0xa"
}
}
},
"4": {
"Default": {
"preemphasis": {
"lane0":"0x284503",
"lane1":"0x284503",
"lane2":"0x284503",
"lane3":"0x294403"
},
"idriver": {
"lane0":"0xa",
"lane1":"0xa",
"lane2":"0xb",
"lane3":"0xa"
}
}
},
"5": {
"Default": {
"preemphasis": {
"lane0":"0x284503",
"lane1":"0x284503",
"lane2":"0x264703",
"lane3":"0x284503"
},
"idriver": {
"lane0":"0xa",
"lane1":"0xa",
"lane2":"0xa",
"lane3":"0xa"
}
}
},
"6": {
"Default": {
"preemphasis": {
"lane0":"0x264703",
"lane1":"0x244903",
"lane2":"0x284503",
"lane3":"0x264703"
},
"idriver": {
"lane0":"0xa",
"lane1":"0xa",
"lane2":"0xa",
"lane3":"0xa"
}
}
},
"7": {
"Default": {
"preemphasis": {
"lane0":"0x244903",
"lane1":"0x244903",
"lane2":"0x264703",
"lane3":"0x244903"
},
"idriver": {
"lane0":"0xa",
"lane1":"0xa",
"lane2":"0xa",
"lane3":"0x9"
}
}
},
"8": {
"Default": {
"preemphasis": {
"lane0":"0x234b02",
"lane1":"0x244903",
"lane2":"0x244903",
"lane3":"0x234b02"
},
"idriver": {
"lane0":"0x9",
"lane1":"0xa",
"lane2":"0x9",
"lane3":"0x9"
}
}
},
"9": {
"Default": {
"preemphasis": {
"lane0":"0x294403",
"lane1":"0x2c4004",
"lane2":"0x2b4203",
"lane3":"0x2e3e04"
},
"idriver": {
"lane0":"0xa",
"lane1":"0xb",
"lane2":"0xb",
"lane3":"0xb"
}
}
},
"10": {
"Default": {
"preemphasis": {
"lane0":"0x294403",
"lane1":"0x294403",
"lane2":"0x294403",
"lane3":"0x294403"
},
"idriver": {
"lane0":"0xa",
"lane1":"0xa",
"lane2":"0xa",
"lane3":"0xa"
}
}
},
"11": {
"Default": {
"preemphasis": {
"lane0":"0x244903",
"lane1":"0x274603",
"lane2":"0x284503",
"lane3":"0x244903"
},
"idriver": {
"lane0":"0xa",
"lane1":"0xa",
"lane2":"0xa",
"lane3":"0xa"
}
}
},
"12": {
"Default": {
"preemphasis": {
"lane0":"0x284503",
"lane1":"0x274603",
"lane2":"0x264703",
"lane3":"0x264703"
},
"idriver": {
"lane0":"0xa",
"lane1":"0xa",
"lane2":"0xa",
"lane3":"0xa"
}
}
},
"13": {
"Default": {
"preemphasis": {
"lane0":"0x204e02",
"lane1":"0x204e02",
"lane2":"0x1f4f02",
"lane3":"0x1f4f02"
},
"idriver": {
"lane0":"0x9",
"lane1":"0x9",
"lane2":"0x8",
"lane3":"0x8"
}
}
},
"14": {
"Default": {
"preemphasis": {
"lane0":"0x1e5002",
"lane1":"0x204e02",
"lane2":"0x1e5002",
"lane3":"0x204e02"
},
"idriver": {
"lane0":"0x8",
"lane1":"0x9",
"lane2":"0x8",
"lane3":"0x9"
}
}
},
"15": {
"Default": {
"preemphasis": {
"lane0":"0x204e02",
"lane1":"0x1e5002",
"lane2":"0x1f4f02",
"lane3":"0x1f4f02"
},
"idriver": {
"lane0":"0x9",
"lane1":"0x8",
"lane2":"0x8",
"lane3":"0x8"
}
}
},
"16": {
"Default": {
"preemphasis": {
"lane0":"0x204e02",
"lane1":"0x1e5002",
"lane2":"0x204e02",
"lane3":"0x1e5002"
},
"idriver": {
"lane0":"0x9",
"lane1":"0x8",
"lane2":"0x9",
"lane3":"0x8"
}
}
},
"17": {
"Default": {
"preemphasis": {
"lane0":"0x204e02",
"lane1":"0x1e5002",
"lane2":"0x204e02",
"lane3":"0x1e5002"
},
"idriver": {
"lane0":"0x9",
"lane1":"0x8",
"lane2":"0x9",
"lane3":"0x8"
}
}
},
"18": {
"Default": {
"preemphasis": {
"lane0":"0x204e02",
"lane1":"0x1e5002",
"lane2":"0x204e02",
"lane3":"0x1e5002"
},
"idriver": {
"lane0":"0x9",
"lane1":"0x8",
"lane2":"0x9",
"lane3":"0x8"
}
}
},
"19": {
"Default": {
"preemphasis": {
"lane0":"0x1e5002",
"lane1":"0x204e02",
"lane2":"0x1e5002",
"lane3":"0x204e02"
},
"idriver": {
"lane0":"0x8",
"lane1":"0x9",
"lane2":"0x8",
"lane3":"0x9"
}
}
},
"20": {
"Default": {
"preemphasis": {
"lane0":"0x204e02",
"lane1":"0x1f4f02",
"lane2":"0x204e02",
"lane3":"0x1f4f02"
},
"idriver": {
"lane0":"0x9",
"lane1":"0x8",
"lane2":"0x9",
"lane3":"0x8"
}
}
},
"21": {
"Default": {
"preemphasis": {
"lane0":"0x244903",
"lane1":"0x244903",
"lane2":"0x244903",
"lane3":"0x244903"
},
"idriver": {
"lane0":"0xa",
"lane1":"0x9",
"lane2":"0xa",
"lane3":"0x9"
}
}
},
"22": {
"Default": {
"preemphasis": {
"lane0":"0x264703",
"lane1":"0x244903",
"lane2":"0x244903",
"lane3":"0x244903"
},
"idriver": {
"lane0":"0xa",
"lane1":"0x9",
"lane2":"0xa",
"lane3":"0xa"
}
}
},
"23": {
"Default": {
"preemphasis": {
"lane0":"0x294403",
"lane1":"0x244903",
"lane2":"0x244903",
"lane3":"0x284503"
},
"idriver": {
"lane0":"0xa",
"lane1":"0xa",
"lane2":"0xa",
"lane3":"0xa"
}
}
},
"24": {
"Default": {
"preemphasis": {
"lane0":"0x294403",
"lane1":"0x2b4203",
"lane2":"0x2c4004",
"lane3":"0x2d3f04"
},
"idriver": {
"lane0":"0xa",
"lane1":"0xb",
"lane2":"0xb",
"lane3":"0xb"
}
}
},
"25": {
"Default": {
"preemphasis": {
"lane0":"0x234b02",
"lane1":"0x234b02",
"lane2":"0x234b02",
"lane3":"0x234b02"
},
"idriver": {
"lane0":"0x9",
"lane1":"0x9",
"lane2":"0x9",
"lane3":"0x9"
}
}
},
"26": {
"Default": {
"preemphasis": {
"lane0":"0x234b02",
"lane1":"0x244903",
"lane2":"0x244903",
"lane3":"0x244903"
},
"idriver": {
"lane0":"0x9",
"lane1":"0x9",
"lane2":"0x9",
"lane3":"0x9"
}
}
},
"27": {
"Default": {
"preemphasis": {
"lane0":"0x274603",
"lane1":"0x264703",
"lane2":"0x244903",
"lane3":"0x244903"
},
"idriver": {
"lane0":"0xa",
"lane1":"0xa",
"lane2":"0x9",
"lane3":"0xa"
}
}
},
"28": {
"Default": {
"preemphasis": {
"lane0":"0x264703",
"lane1":"0x244903",
"lane2":"0x284503",
"lane3":"0x274603"
},
"idriver": {
"lane0":"0xa",
"lane1":"0xa",
"lane2":"0xa",
"lane3":"0xa"
}
}
},
"29": {
"Default": {
"preemphasis": {
"lane0":"0x294403",
"lane1":"0x294403",
"lane2":"0x294403",
"lane3":"0x284503"
},
"idriver": {
"lane0":"0xa",
"lane1":"0xa",
"lane2":"0xa",
"lane3":"0xa"
}
}
},
"30": {
"Default": {
"preemphasis": {
"lane0":"0x294403",
"lane1":"0x284503",
"lane2":"0x294403",
"lane3":"0x294403"
},
"idriver": {
"lane0":"0xa",
"lane1":"0xa",
"lane2":"0xa",
"lane3":"0xa"
}
}
},
"31": {
"Default": {
"preemphasis": {
"lane0":"0x2b4203",
"lane1":"0x294403",
"lane2":"0x2b4203",
"lane3":"0x2b4203"
},
"idriver": {
"lane0":"0xb",
"lane1":"0xa",
"lane2":"0xb",
"lane3":"0xb"
}
}
},
"32": {
"Default": {
"preemphasis": {
"lane0":"0x2b4203",
"lane1":"0x2b4203",
"lane2":"0x2c4004",
"lane3":"0x2c4004"
},
"idriver": {
"lane0":"0xb",
"lane1":"0xb",
"lane2":"0xb",
"lane3":"0xb"
}
}
}
}
}

View File

@ -8,4 +8,7 @@ test:
for f in $$(find ../../../device -name "*.config.bcm"); do
./config_checker $$f
done
for f in $$(find ../../../device -name media_settings.json); do
./media_checker $$f
done
popd

View File

@ -0,0 +1,159 @@
#!/usr/bin/env python
import re
import sys
import glob
import json
level1_keys = ["GLOBAL_MEDIA_SETTINGS","PORT_MEDIA_SETTINGS"]
setting_keys = ["preemphasis","idriver","ipredriver"]
lane_prefix = "lane"
comma_separator = ","
range_separator = "-"
def check_lane_and_value(lane_name, lane_value):
if lane_prefix in lane_name:
try:
lane_num = int(lane_name.strip()[len(lane_prefix):])
lane_val = int(lane_value.strip(), 16)
return True
except ValueError:
print "Invalid lane values " + lane_name + " " + lane_value
return False
else:
return False
def usage():
print "Usage: " + sys.argv[0] + " <media_settings_file>"
sys.exit(1)
def check_media_dict(vendor_dict):
if len(vendor_dict) == 0:
print "Expecting values for media type " + keys
return False
for vendor_key in vendor_dict:
value_dict = vendor_dict[vendor_key]
if len(value_dict) == 0:
print "Expecting settings for vendor type " + vendor_key
return False
for value_key in value_dict:
if value_key not in setting_keys:
print "Unknown media setting " + value_key
return False
lane_dict = value_dict[value_key]
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())
return True
except ValueError:
return False
def check_port_keys(port_media_dict):
for port in port_media_dict:
if not check_valid_port(port):
print "Invalid port name " + port
return False
if not check_media_dict(port_media_dict[port]):
return False
return True
def check_global_keys(global_media_dict):
for keys in global_media_dict:
if comma_separator in keys:
port_list = keys.split(comma_separator)
for port in port_list:
if range_separator in port:
range_list = port.split(range_separator)
for port_val in range_list:
if not check_valid_port(port_val):
print "Error: Unrecognized port number " + port_val
print "Invalid range " + port
return False
else:
if not check_valid_port(port):
print "Error: Unrecognized portname " + port
return False
elif range_separator in keys:
range_list = keys.split(range_separator)
for port_val in range_list:
if not check_valid_port(port_val):
print "Error: Unrecognized portname " + port_val
print "Invalid range " + keys
return False
else:
print "Invalid range " + keys
return False
if not check_media_dict(global_media_dict[keys]):
return False
return True
def check_file(media_settings_file):
try:
media_file = open(media_settings_file,"r")
media_settings = media_file.read()
media_dict = json.loads(media_settings)
#Validate keys at level1
for key_l1 in media_dict:
if key_l1 not in level1_keys:
print "Error: Unknown key " + key_l1 + " at top level"
return False
if "GLOBAL_MEDIA_SETTINGS" in media_dict:
if not check_global_keys(media_dict["GLOBAL_MEDIA_SETTINGS"]):
return False
if "PORT_MEDIA_SETTINGS" in media_dict:
if not check_port_keys(media_dict["PORT_MEDIA_SETTINGS"]):
return False
except IOError:
print "Error: Cannot open file " + media_settings_file
return False
except ValueError,e:
print "Error in parsing json file " + media_settings_file + " "
print str(e)
return False
return True
def main(argv):
if len(argv) > 0 and argv[0] == "-h":
usage()
# Load target file
if len(argv) == 0:
files = glob.glob('*.json')
else:
files = argv
all_good = True
for f in files:
good = check_file(f)
if good:
print "File " + f + " passed validity check"
else:
print "File " + f + " failed validity check"
all_good = all_good and good
if not all_good:
sys.exit(-1)
if __name__ == "__main__":
main(sys.argv[1:])