Update install-p4-tools.sh to use P4Runtime v1.0
Includes also various improvements to the p4vm scripts, such as:
- Choose to build VM with Ubuntu 16.04 or 18.04 (experimental)
- Allow users to specify version of protobuf and grpc to use
- Avoid building protobuf and grpc if already installed in the system
- Install Bazel 0.22
Also:
- Remove check for invalid group member weights (now PI always returns
members with weight 1)
- Re-compiled all P4 programs and fixed missing padding in controller
packet headers
Change-Id: I0e672fcebbaba63354c749f0c774af251f3cbc6c
diff --git a/apps/p4-tutorial/pipeconf/src/main/java/org/onosproject/p4tutorial/pipeconf/PipeconfFactory.java b/apps/p4-tutorial/pipeconf/src/main/java/org/onosproject/p4tutorial/pipeconf/PipeconfFactory.java
index b216aff..31406db 100644
--- a/apps/p4-tutorial/pipeconf/src/main/java/org/onosproject/p4tutorial/pipeconf/PipeconfFactory.java
+++ b/apps/p4-tutorial/pipeconf/src/main/java/org/onosproject/p4tutorial/pipeconf/PipeconfFactory.java
@@ -16,11 +16,6 @@
package org.onosproject.p4tutorial.pipeconf;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
import org.onosproject.driver.pipeline.DefaultSingleTablePipeline;
import org.onosproject.net.behaviour.Pipeliner;
import org.onosproject.net.device.PortStatisticsDiscovery;
@@ -32,6 +27,11 @@
import org.onosproject.net.pi.service.PiPipeconfService;
import org.onosproject.p4runtime.model.P4InfoParser;
import org.onosproject.p4runtime.model.P4InfoParserException;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Deactivate;
+import org.osgi.service.component.annotations.Reference;
+import org.osgi.service.component.annotations.ReferenceCardinality;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -49,7 +49,7 @@
private final Logger log = LoggerFactory.getLogger(getClass());
public static final PiPipeconfId PIPECONF_ID = new PiPipeconfId("p4-tutorial-pipeconf");
- private static final URL P4INFO_URL = PipeconfFactory.class.getResource("/mytunnel.p4info");
+ private static final URL P4INFO_URL = PipeconfFactory.class.getResource("/mytunnel_p4info.txt");
private static final URL BMV2_JSON_URL = PipeconfFactory.class.getResource("/mytunnel.json");
@Reference(cardinality = ReferenceCardinality.MANDATORY)
diff --git a/apps/p4-tutorial/pipeconf/src/main/resources/Makefile b/apps/p4-tutorial/pipeconf/src/main/resources/Makefile
index d819ecf..8e42bda 100644
--- a/apps/p4-tutorial/pipeconf/src/main/resources/Makefile
+++ b/apps/p4-tutorial/pipeconf/src/main/resources/Makefile
@@ -2,5 +2,5 @@
mytunnel: mytunnel.p4
p4c-bm2-ss --arch v1model -o mytunnel.json \
- --p4runtime-file mytunnel.p4info --p4runtime-format text \
+ --p4runtime-files mytunnel_p4info.txt \
mytunnel.p4
diff --git a/apps/p4-tutorial/pipeconf/src/main/resources/mytunnel.json b/apps/p4-tutorial/pipeconf/src/main/resources/mytunnel.json
index 913e72e..90d34d7 100644
--- a/apps/p4-tutorial/pipeconf/src/main/resources/mytunnel.json
+++ b/apps/p4-tutorial/pipeconf/src/main/resources/mytunnel.json
@@ -4,11 +4,11 @@
"name" : "scalars_0",
"id" : 0,
"fields" : [
- ["tmp", 32, false],
+ ["tmp_0", 32, false],
["tmp_1", 32, false],
- ["tmp_0", 1, false],
- ["hasReturned_0", 1, false],
- ["_padding_2", 6, false]
+ ["tmp", 1, false],
+ ["hasReturned", 1, false],
+ ["_padding_1", 6, false]
]
},
{
@@ -36,7 +36,7 @@
["checksum_error", 1, false],
["recirculate_flag", 32, false],
["parser_error", 32, false],
- ["_padding", 5, false]
+ ["_padding_0", 5, false]
]
},
{
@@ -79,7 +79,7 @@
"id" : 5,
"fields" : [
["egress_port", 9, false],
- ["_padding_0", 7, false]
+ ["_padding", 7, false]
]
},
{
@@ -87,7 +87,7 @@
"id" : 6,
"fields" : [
["ingress_port", 9, false],
- ["_padding_1", 7, false]
+ ["_padding", 7, false]
]
}
],
@@ -316,7 +316,7 @@
"id" : 0,
"source_info" : {
"filename" : "mytunnel.p4",
- "line" : 304,
+ "line" : 306,
"column" : 8,
"source_fragment" : "c_deparser"
},
@@ -330,7 +330,7 @@
"id" : 0,
"source_info" : {
"filename" : "mytunnel.p4",
- "line" : 152,
+ "line" : 154,
"column" : 48,
"source_fragment" : "tx_port_counter"
},
@@ -342,7 +342,7 @@
"id" : 1,
"source_info" : {
"filename" : "mytunnel.p4",
- "line" : 153,
+ "line" : 155,
"column" : 48,
"source_fragment" : "rx_port_counter"
},
@@ -356,7 +356,7 @@
"binding" : "c_ingress.t_l2_fwd",
"source_info" : {
"filename" : "mytunnel.p4",
- "line" : 189,
+ "line" : 191,
"column" : 50,
"source_fragment" : "l2_fwd_counter"
}
@@ -406,7 +406,7 @@
],
"source_info" : {
"filename" : "mytunnel.p4",
- "line" : 160,
+ "line" : 162,
"column" : 8,
"source_fragment" : "hdr.packet_in.setValid()"
}
@@ -425,7 +425,7 @@
],
"source_info" : {
"filename" : "mytunnel.p4",
- "line" : 161,
+ "line" : 163,
"column" : 8,
"source_fragment" : "hdr.packet_in.ingress_port = standard_metadata.ingress_port"
}
@@ -456,7 +456,7 @@
],
"source_info" : {
"filename" : "mytunnel.p4",
- "line" : 167,
+ "line" : 169,
"column" : 8,
"source_fragment" : "standard_metadata.egress_spec = port"
}
@@ -487,7 +487,7 @@
],
"source_info" : {
"filename" : "mytunnel.p4",
- "line" : 167,
+ "line" : 169,
"column" : 8,
"source_fragment" : "standard_metadata.egress_spec = port"
}
@@ -504,7 +504,7 @@
"parameters" : [],
"source_info" : {
"filename" : "mytunnel.p4",
- "line" : 171,
+ "line" : 173,
"column" : 8,
"source_fragment" : "mark_to_drop()"
}
@@ -521,7 +521,7 @@
"parameters" : [],
"source_info" : {
"filename" : "mytunnel.p4",
- "line" : 171,
+ "line" : 173,
"column" : 8,
"source_fragment" : "mark_to_drop()"
}
@@ -538,7 +538,7 @@
"parameters" : [],
"source_info" : {
"filename" : "mytunnel.p4",
- "line" : 171,
+ "line" : 173,
"column" : 8,
"source_fragment" : "mark_to_drop()"
}
@@ -565,7 +565,7 @@
],
"source_info" : {
"filename" : "mytunnel.p4",
- "line" : 175,
+ "line" : 177,
"column" : 8,
"source_fragment" : "hdr.my_tunnel.setValid()"
}
@@ -584,7 +584,7 @@
],
"source_info" : {
"filename" : "mytunnel.p4",
- "line" : 176,
+ "line" : 178,
"column" : 8,
"source_fragment" : "hdr.my_tunnel.tun_id = tun_id"
}
@@ -603,7 +603,7 @@
],
"source_info" : {
"filename" : "mytunnel.p4",
- "line" : 177,
+ "line" : 179,
"column" : 8,
"source_fragment" : "hdr.my_tunnel.proto_id = hdr.ethernet.ether_type"
}
@@ -653,7 +653,7 @@
],
"source_info" : {
"filename" : "mytunnel.p4",
- "line" : 182,
+ "line" : 184,
"column" : 8,
"source_fragment" : "standard_metadata.egress_spec = port"
}
@@ -672,7 +672,7 @@
],
"source_info" : {
"filename" : "mytunnel.p4",
- "line" : 183,
+ "line" : 185,
"column" : 8,
"source_fragment" : "hdr.ethernet.ether_type = hdr.my_tunnel.proto_id"
}
@@ -687,7 +687,7 @@
],
"source_info" : {
"filename" : "mytunnel.p4",
- "line" : 184,
+ "line" : 186,
"column" : 8,
"source_fragment" : "hdr.my_tunnel.setInvalid()"
}
@@ -713,7 +713,7 @@
],
"source_info" : {
"filename" : "mytunnel.p4",
- "line" : 239,
+ "line" : 241,
"column" : 12,
"source_fragment" : "standard_metadata.egress_spec = hdr.packet_out.egress_port"
}
@@ -728,7 +728,7 @@
],
"source_info" : {
"filename" : "mytunnel.p4",
- "line" : 240,
+ "line" : 242,
"column" : 12,
"source_fragment" : "hdr.packet_out.setInvalid()"
}
@@ -745,7 +745,7 @@
"parameters" : [
{
"type" : "field",
- "value" : ["scalars", "tmp_0"]
+ "value" : ["scalars", "tmp"]
},
{
"type" : "expression",
@@ -775,7 +775,7 @@
"parameters" : [
{
"type" : "field",
- "value" : ["scalars", "tmp_0"]
+ "value" : ["scalars", "tmp"]
},
{
"type" : "expression",
@@ -805,7 +805,7 @@
"parameters" : [
{
"type" : "field",
- "value" : ["scalars", "hasReturned_0"]
+ "value" : ["scalars", "hasReturned"]
},
{
"type" : "expression",
@@ -824,7 +824,7 @@
],
"source_info" : {
"filename" : "mytunnel.p4",
- "line" : 248,
+ "line" : 250,
"column" : 16,
"source_fragment" : "return"
}
@@ -841,7 +841,7 @@
"parameters" : [
{
"type" : "field",
- "value" : ["scalars", "hasReturned_0"]
+ "value" : ["scalars", "hasReturned"]
},
{
"type" : "expression",
@@ -871,7 +871,7 @@
"parameters" : [
{
"type" : "field",
- "value" : ["scalars", "tmp"]
+ "value" : ["scalars", "tmp_0"]
},
{
"type" : "expression",
@@ -893,7 +893,7 @@
],
"source_info" : {
"filename" : "mytunnel.p4",
- "line" : 264,
+ "line" : 266,
"column" : 34,
"source_fragment" : "(bit<32>) standard_metadata.egress_spec"
}
@@ -907,12 +907,12 @@
},
{
"type" : "field",
- "value" : ["scalars", "tmp"]
+ "value" : ["scalars", "tmp_0"]
}
],
"source_info" : {
"filename" : "mytunnel.p4",
- "line" : 264,
+ "line" : 266,
"column" : 12,
"source_fragment" : "tx_port_counter.count((bit<32>) standard_metadata.egress_spec)"
}
@@ -951,7 +951,7 @@
],
"source_info" : {
"filename" : "mytunnel.p4",
- "line" : 267,
+ "line" : 269,
"column" : 34,
"source_fragment" : "(bit<32>) standard_metadata.ingress_port"
}
@@ -970,7 +970,7 @@
],
"source_info" : {
"filename" : "mytunnel.p4",
- "line" : 267,
+ "line" : 269,
"column" : 12,
"source_fragment" : "rx_port_counter.count((bit<32>) standard_metadata.ingress_port)"
}
@@ -984,7 +984,7 @@
"id" : 0,
"source_info" : {
"filename" : "mytunnel.p4",
- "line" : 146,
+ "line" : 148,
"column" : 8,
"source_fragment" : "c_ingress"
},
@@ -1041,7 +1041,7 @@
"id" : 2,
"source_info" : {
"filename" : "mytunnel.p4",
- "line" : 191,
+ "line" : 193,
"column" : 10,
"source_fragment" : "t_l2_fwd"
},
@@ -1165,7 +1165,7 @@
"id" : 6,
"source_info" : {
"filename" : "mytunnel.p4",
- "line" : 208,
+ "line" : 210,
"column" : 10,
"source_fragment" : "t_tunnel_ingress"
},
@@ -1202,7 +1202,7 @@
"id" : 7,
"source_info" : {
"filename" : "mytunnel.p4",
- "line" : 219,
+ "line" : 221,
"column" : 10,
"source_fragment" : "t_tunnel_fwd"
},
@@ -1289,7 +1289,7 @@
"id" : 0,
"source_info" : {
"filename" : "mytunnel.p4",
- "line" : 234,
+ "line" : 236,
"column" : 12,
"source_fragment" : "standard_metadata.ingress_port == CPU_PORT"
},
@@ -1320,7 +1320,7 @@
"left" : null,
"right" : {
"type" : "field",
- "value" : ["scalars", "tmp_0"]
+ "value" : ["scalars", "tmp"]
}
}
},
@@ -1342,7 +1342,7 @@
"left" : null,
"right" : {
"type" : "field",
- "value" : ["scalars", "hasReturned_0"]
+ "value" : ["scalars", "hasReturned"]
}
}
}
@@ -1356,7 +1356,7 @@
"id" : 3,
"source_info" : {
"filename" : "mytunnel.p4",
- "line" : 251,
+ "line" : 253,
"column" : 16,
"source_fragment" : "hdr.ipv4.isValid() && !hdr.my_tunnel.isValid()"
},
@@ -1403,7 +1403,7 @@
"id" : 4,
"source_info" : {
"filename" : "mytunnel.p4",
- "line" : 256,
+ "line" : 258,
"column" : 16,
"source_fragment" : "hdr.my_tunnel.isValid()"
},
@@ -1436,7 +1436,7 @@
"left" : null,
"right" : {
"type" : "field",
- "value" : ["scalars", "hasReturned_0"]
+ "value" : ["scalars", "hasReturned"]
}
}
}
@@ -1450,7 +1450,7 @@
"id" : 6,
"source_info" : {
"filename" : "mytunnel.p4",
- "line" : 263,
+ "line" : 265,
"column" : 12,
"source_fragment" : "standard_metadata.egress_spec < 255"
},
@@ -1476,7 +1476,7 @@
"id" : 7,
"source_info" : {
"filename" : "mytunnel.p4",
- "line" : 266,
+ "line" : 268,
"column" : 12,
"source_fragment" : "standard_metadata.ingress_port < 255"
},
@@ -1504,7 +1504,7 @@
"id" : 1,
"source_info" : {
"filename" : "mytunnel.p4",
- "line" : 276,
+ "line" : 278,
"column" : 8,
"source_fragment" : "c_egress"
},
@@ -1568,4 +1568,4 @@
"version" : [2, 18],
"compiler" : "https://github.com/p4lang/p4c"
}
-}
\ No newline at end of file
+}
diff --git a/apps/p4-tutorial/pipeconf/src/main/resources/mytunnel.p4 b/apps/p4-tutorial/pipeconf/src/main/resources/mytunnel.p4
index 36de752..f88f582 100644
--- a/apps/p4-tutorial/pipeconf/src/main/resources/mytunnel.p4
+++ b/apps/p4-tutorial/pipeconf/src/main/resources/mytunnel.p4
@@ -69,6 +69,7 @@
@controller_header("packet_in")
header packet_in_header_t {
bit<9> ingress_port;
+ bit<7> _padding;
}
// Packet-out header. Prepended to packets received by the controller and used
@@ -76,6 +77,7 @@
@controller_header("packet_out")
header packet_out_header_t {
bit<9> egress_port;
+ bit<7> _padding;
}
// For convenience we collect all headers under the same struct.
diff --git a/apps/p4-tutorial/pipeconf/src/main/resources/mytunnel.p4info b/apps/p4-tutorial/pipeconf/src/main/resources/mytunnel.txt
similarity index 93%
rename from apps/p4-tutorial/pipeconf/src/main/resources/mytunnel.p4info
rename to apps/p4-tutorial/pipeconf/src/main/resources/mytunnel.txt
index 66e8d7a..c26b14d 100644
--- a/apps/p4-tutorial/pipeconf/src/main/resources/mytunnel.p4info
+++ b/apps/p4-tutorial/pipeconf/src/main/resources/mytunnel.txt
@@ -1,3 +1,6 @@
+pkg_info {
+ arch: "v1model"
+}
tables {
preamble {
id: 33606914
@@ -42,7 +45,6 @@
}
direct_resource_ids: 318778805
size: 1024
- idle_timeout_behavior: NO_TIMEOUT
}
tables {
preamble {
@@ -63,7 +65,6 @@
id: 16808599
}
size: 1024
- idle_timeout_behavior: NO_TIMEOUT
}
tables {
preamble {
@@ -87,7 +88,6 @@
id: 16808599
}
size: 1024
- idle_timeout_behavior: NO_TIMEOUT
}
actions {
preamble {
@@ -183,6 +183,7 @@
preamble {
id: 67146229
name: "packet_in"
+ alias: "packet_in"
annotations: "@controller_header(\"packet_in\")"
}
metadata {
@@ -190,11 +191,17 @@
name: "ingress_port"
bitwidth: 9
}
+ metadata {
+ id: 2
+ name: "_padding"
+ bitwidth: 7
+ }
}
controller_packet_metadata {
preamble {
id: 67121543
name: "packet_out"
+ alias: "packet_out"
annotations: "@controller_header(\"packet_out\")"
}
metadata {
@@ -202,6 +209,11 @@
name: "egress_port"
bitwidth: 9
}
+ metadata {
+ id: 2
+ name: "_padding"
+ bitwidth: 7
+ }
}
type_info {
}