blob: 3f249496bf577df16f5094f82a4bd7f0da63fe19 [file] [log] [blame]
Jeffrey Townsendfdea52c2013-12-10 18:20:11 -08001"""
2Platform configuration file
3platform == bpp
4"""
5
6###############################################################################
7#
8# This platform assumes BPP VPI specifications on the command line.
9#
10###############################################################################
11
12import sys
13import os
14import argparse
15import subprocess
16import dppv
17
18# The port specification is passed via the "--platform-args" option to OFTest.
19# Note that we must guard against abbreviations supported by argparse
20if not "--platform-args" in " ".join(sys.argv):
21 raise Exception("--platform-args must be specified")
22
23ap = argparse.ArgumentParser("bpp")
24ap.add_argument("--platform-args")
25(ops, rest) = ap.parse_known_args()
26
27if not "@" in ops.platform_args:
28 # Assume it is just a device name. Get the ports from the track database.
29 if "," in ops.platform_args:
30 (type_, d) = ops.platform_args.split(",")
31 else:
32 (type_, d) = ("udp", ops.platform_args)
33
34 trackScript = "/usr/bin/track"
35 if not os.path.exists(trackScript):
36 raise Exception("Cannot find the track script (looked at %s" % trackScript)
37
38 ports = eval("[" + subprocess.check_output([trackScript, "getports", d]) + "]")
39 ops.platform_args = type_ + "," + ",".join( "%s@%s:%s" % (p, d, p) for p in ports)
40
41 print "new platform_args: ", ops.platform_args
42 exit;
43#
44###############################################################################
45
46vpi_port_map = {}
47ports = ops.platform_args.split(",")
48bpptype = "udp"
49if ports[0] == "udp" or ports[0] == "tcp":
50 bpptype = ports.pop(0)
51
52for ps in ports:
53 (p, vpi) = ps.split("@")
54 vpi_port_map[int(p)] = "bpp|%s|%s" % (bpptype, vpi)
55
56print vpi_port_map;
57
58def platform_config_update(config):
59 """
60 Update configuration for the remote platform
61
62 @param config The configuration dictionary to use/update
63 This routine defines the port map used for this configuration
64 """
65
66 global vpi_port_map
67 config["port_map"] = vpi_port_map.copy()
68 config["caps_table_idx"] = 0
69 #
70 # The class for DataPlanePorts must be specified here:
71 #
72 config['dataplane'] = { 'portclass': dppv.DataPlanePortVPI }
73 config['allow_user'] = True