Jeffrey Townsend | fdea52c | 2013-12-10 18:20:11 -0800 | [diff] [blame^] | 1 | """ |
| 2 | Platform configuration file |
| 3 | platform == vpi |
| 4 | """ |
| 5 | |
| 6 | ############################################################################### |
| 7 | # |
| 8 | # This platform module allows VPI port specifications on the command line. |
| 9 | # |
| 10 | ############################################################################### |
| 11 | |
| 12 | import sys |
| 13 | import os |
| 14 | import argparse |
| 15 | import dppv |
| 16 | |
| 17 | # The port specification is passed via the "--platform-args" option to OFTest. |
| 18 | # Note that we must guard against abbreviations supported by argparse |
| 19 | if not "--platform-args" in " ".join(sys.argv): |
| 20 | raise Exception("--platform-args must be specified") |
| 21 | |
| 22 | ap = argparse.ArgumentParser("vpi") |
| 23 | ap.add_argument("--platform-args") |
| 24 | (ops, rest) = ap.parse_known_args() |
| 25 | |
| 26 | vpi_port_map = {} |
| 27 | ports = ops.platform_args.split(",") |
| 28 | for ps in ports: |
| 29 | (p, vpi) = ps.split("@") |
| 30 | vpi_port_map[int(p)] = vpi |
| 31 | |
| 32 | print vpi_port_map; |
| 33 | |
| 34 | def platform_config_update(config): |
| 35 | """ |
| 36 | Update configuration for the remote platform |
| 37 | |
| 38 | @param config The configuration dictionary to use/update |
| 39 | This routine defines the port map used for this configuration |
| 40 | """ |
| 41 | |
| 42 | global vpi_port_map |
| 43 | config["port_map"] = vpi_port_map.copy() |
| 44 | config["caps_table_idx"] = 0 |
| 45 | # |
| 46 | # The class for DataPlanePorts must be specified here: |
| 47 | # |
| 48 | config['dataplane'] = { 'portclass': dppv.DataPlanePortVPI } |
| 49 | config['allow_user'] = True |