blob: 5efea77ce440788177577e68b4c338b12cd8a587 [file] [log] [blame]
Sreeju Sreedhare3fefd92019-04-02 15:57:15 -07001
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
17"""
18Platform configuration file
19platform == vpi
20"""
21
22###############################################################################
23#
24# This platform module allows VPI port specifications on the command line.
25#
26###############################################################################
27
28import sys
29import os
30import argparse
31import 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
35if not "--platform-args" in " ".join(sys.argv):
36 raise Exception("--platform-args must be specified")
37
38ap = argparse.ArgumentParser("vpi")
39ap.add_argument("--platform-args")
40(ops, rest) = ap.parse_known_args()
41
42vpi_port_map = {}
43ports = ops.platform_args.split(",")
44for ps in ports:
45 (p, vpi) = ps.split("@")
46 vpi_port_map[int(p)] = vpi
47
48print vpi_port_map;
49
50def 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