Matteo Scandolo | a229eca | 2017-08-08 13:05:28 -0700 | [diff] [blame] | 1 | |
| 2 | # Copyright 2017-present Open Networking Foundation |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
| 16 | |
Jeffrey Townsend | fdea52c | 2013-12-10 18:20:11 -0800 | [diff] [blame] | 17 | """ |
| 18 | Platform configuration file |
| 19 | platform == vpi |
| 20 | """ |
| 21 | |
| 22 | ############################################################################### |
| 23 | # |
| 24 | # This platform module allows VPI port specifications on the command line. |
| 25 | # |
| 26 | ############################################################################### |
| 27 | |
| 28 | import sys |
| 29 | import os |
| 30 | import argparse |
| 31 | import dppv |
| 32 | |
| 33 | # The port specification is passed via the "--platform-args" option to OFTest. |
| 34 | # Note that we must guard against abbreviations supported by argparse |
| 35 | if not "--platform-args" in " ".join(sys.argv): |
| 36 | raise Exception("--platform-args must be specified") |
| 37 | |
| 38 | ap = argparse.ArgumentParser("vpi") |
| 39 | ap.add_argument("--platform-args") |
| 40 | (ops, rest) = ap.parse_known_args() |
| 41 | |
| 42 | vpi_port_map = {} |
| 43 | ports = ops.platform_args.split(",") |
| 44 | for ps in ports: |
| 45 | (p, vpi) = ps.split("@") |
| 46 | vpi_port_map[int(p)] = vpi |
| 47 | |
| 48 | print vpi_port_map; |
| 49 | |
| 50 | def platform_config_update(config): |
| 51 | """ |
| 52 | Update configuration for the remote platform |
| 53 | |
| 54 | @param config The configuration dictionary to use/update |
| 55 | This routine defines the port map used for this configuration |
| 56 | """ |
| 57 | |
| 58 | global vpi_port_map |
| 59 | config["port_map"] = vpi_port_map.copy() |
| 60 | config["caps_table_idx"] = 0 |
| 61 | # |
| 62 | # The class for DataPlanePorts must be specified here: |
| 63 | # |
| 64 | config['dataplane'] = { 'portclass': dppv.DataPlanePortVPI } |
| 65 | config['allow_user'] = True |