P4 Developer Day May 2019 (#252)
* Update user-bootstrap to use latest version (#251) * p4c tests are failing in latest version. So, let's skip it during vagrant provisioning * Update tutorial to use latest version of P4 tools Modify switch.py to handle setting default_action Use --p4runtime-files instead of deprecated --p4runtime-file and --p4runtime-format flags Provide standard_metadata for mark_to_drop * Fix path for ECN exercise
@ -13,7 +13,7 @@ you get started with P4 programming, organized into several modules:
|
||||
* [P4Runtime](./exercises/p4runtime)
|
||||
|
||||
3. Monitoring and Debugging
|
||||
* [Explicit Congestion Notification](./exercises/other/ecn)
|
||||
* [Explicit Congestion Notification](./exercises/ecn)
|
||||
* [Multi-Hop Route Inspection](./exercises/mri)
|
||||
|
||||
4. Advanced Behavior
|
||||
|
@ -1,5 +1,5 @@
|
||||
BMV2_SWITCH_EXE = simple_switch_grpc
|
||||
NO_P4 = true
|
||||
P4C_ARGS = --p4runtime-file $(basename $@).p4info --p4runtime-format text
|
||||
P4C_ARGS = --p4runtime-files $(basename $@).p4.p4info.txt
|
||||
|
||||
include ../../utils/Makefile
|
||||
|
Before Width: | Height: | Size: 154 B After Width: | Height: | Size: 138 B |
@ -75,7 +75,7 @@ control MyIngress(inout headers hdr,
|
||||
inout metadata meta,
|
||||
inout standard_metadata_t standard_metadata) {
|
||||
action drop() {
|
||||
mark_to_drop();
|
||||
mark_to_drop(standard_metadata);
|
||||
}
|
||||
|
||||
action ipv4_forward(macAddr_t dstAddr, egressSpec_t port) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"target": "bmv2",
|
||||
"p4info": "build/basic.p4info",
|
||||
"p4info": "build/basic.p4.p4info.txt",
|
||||
"bmv2_json": "build/basic.json",
|
||||
"table_entries": [
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"target": "bmv2",
|
||||
"p4info": "build/basic.p4info",
|
||||
"p4info": "build/basic.p4.p4info.txt",
|
||||
"bmv2_json": "build/basic.json",
|
||||
"table_entries": [
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"target": "bmv2",
|
||||
"p4info": "build/basic.p4info",
|
||||
"p4info": "build/basic.p4.p4info.txt",
|
||||
"bmv2_json": "build/basic.json",
|
||||
"table_entries": [
|
||||
{
|
||||
|
@ -87,7 +87,7 @@ control MyIngress(inout headers hdr,
|
||||
inout metadata meta,
|
||||
inout standard_metadata_t standard_metadata) {
|
||||
action drop() {
|
||||
mark_to_drop();
|
||||
mark_to_drop(standard_metadata);
|
||||
}
|
||||
|
||||
action ipv4_forward(macAddr_t dstAddr, egressSpec_t port) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
BMV2_SWITCH_EXE = simple_switch_grpc
|
||||
NO_P4 = true
|
||||
P4C_ARGS = --p4runtime-file $(basename $@).p4info --p4runtime-format text
|
||||
P4C_ARGS = --p4runtime-files $(basename $@).p4.p4info.txt
|
||||
|
||||
include ../../utils/Makefile
|
||||
|
Before Width: | Height: | Size: 154 B After Width: | Height: | Size: 138 B |
@ -99,7 +99,7 @@ control MyIngress(inout headers hdr,
|
||||
inout metadata meta,
|
||||
inout standard_metadata_t standard_metadata) {
|
||||
action drop() {
|
||||
mark_to_drop();
|
||||
mark_to_drop(standard_metadata);
|
||||
}
|
||||
|
||||
action ipv4_forward(macAddr_t dstAddr, egressSpec_t port) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"target": "bmv2",
|
||||
"p4info": "build/basic_tunnel.p4info",
|
||||
"p4info": "build/basic_tunnel.p4.p4info.txt",
|
||||
"bmv2_json": "build/basic_tunnel.json",
|
||||
"table_entries": [
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"target": "bmv2",
|
||||
"p4info": "build/basic_tunnel.p4info",
|
||||
"p4info": "build/basic_tunnel.p4.p4info.txt",
|
||||
"bmv2_json": "build/basic_tunnel.json",
|
||||
"table_entries": [
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"target": "bmv2",
|
||||
"p4info": "build/basic_tunnel.p4info",
|
||||
"p4info": "build/basic_tunnel.p4.p4info.txt",
|
||||
"bmv2_json": "build/basic_tunnel.json",
|
||||
"table_entries": [
|
||||
{
|
||||
|
@ -103,7 +103,7 @@ control MyIngress(inout headers hdr,
|
||||
inout metadata meta,
|
||||
inout standard_metadata_t standard_metadata) {
|
||||
action drop() {
|
||||
mark_to_drop();
|
||||
mark_to_drop(standard_metadata);
|
||||
}
|
||||
|
||||
action ipv4_forward(macAddr_t dstAddr, egressSpec_t port) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
BMV2_SWITCH_EXE = simple_switch_grpc
|
||||
NO_P4 = true
|
||||
P4C_ARGS = --p4runtime-file $(basename $@).p4info --p4runtime-format text
|
||||
P4C_ARGS = --p4runtime-files $(basename $@).p4.p4info.txt
|
||||
|
||||
include ../../utils/Makefile
|
Before Width: | Height: | Size: 154 B After Width: | Height: | Size: 138 B |
@ -91,7 +91,7 @@ control MyIngress(inout headers hdr,
|
||||
inout metadata meta,
|
||||
inout standard_metadata_t standard_metadata) {
|
||||
action drop() {
|
||||
mark_to_drop();
|
||||
mark_to_drop(standard_metadata);
|
||||
}
|
||||
|
||||
action ipv4_forward(macAddr_t dstAddr, egressSpec_t port) {
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"target": "bmv2",
|
||||
"p4info": "build/ecn.p4info",
|
||||
"p4info": "build/ecn.p4.p4info.txt",
|
||||
"bmv2_json": "build/ecn.json",
|
||||
"table_entries": [
|
||||
{
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"target": "bmv2",
|
||||
"p4info": "build/ecn.p4info",
|
||||
"p4info": "build/ecn.p4.p4info.txt",
|
||||
"bmv2_json": "build/ecn.json",
|
||||
"table_entries": [
|
||||
{
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"target": "bmv2",
|
||||
"p4info": "build/ecn.p4info",
|
||||
"p4info": "build/ecn.p4.p4info.txt",
|
||||
"bmv2_json": "build/ecn.json",
|
||||
"table_entries": [
|
||||
{
|
Before Width: | Height: | Size: 221 KiB After Width: | Height: | Size: 221 KiB |
@ -89,7 +89,7 @@ control MyIngress(inout headers hdr,
|
||||
inout metadata meta,
|
||||
inout standard_metadata_t standard_metadata) {
|
||||
action drop() {
|
||||
mark_to_drop();
|
||||
mark_to_drop(standard_metadata);
|
||||
}
|
||||
|
||||
action ipv4_forward(macAddr_t dstAddr, egressSpec_t port) {
|
@ -1,5 +1,5 @@
|
||||
BMV2_SWITCH_EXE = simple_switch_grpc
|
||||
NO_P4 = true
|
||||
P4C_ARGS = --p4runtime-file $(basename $@).p4info --p4runtime-format text
|
||||
P4C_ARGS = --p4runtime-files $(basename $@).p4.p4info.txt
|
||||
|
||||
include ../../utils/Makefile
|
||||
|
Before Width: | Height: | Size: 154 B After Width: | Height: | Size: 138 B |
@ -99,7 +99,7 @@ control MyIngress(inout headers hdr,
|
||||
inout standard_metadata_t standard_metadata) {
|
||||
|
||||
action drop() {
|
||||
mark_to_drop();
|
||||
mark_to_drop(standard_metadata);
|
||||
}
|
||||
action set_ecmp_select(bit<16> ecmp_base, bit<32> ecmp_count) {
|
||||
/* TODO: hash on 5-tuple and save the hash result in meta.ecmp_select
|
||||
@ -151,7 +151,7 @@ control MyEgress(inout headers hdr,
|
||||
hdr.ethernet.srcAddr = smac;
|
||||
}
|
||||
action drop() {
|
||||
mark_to_drop();
|
||||
mark_to_drop(standard_metadata);
|
||||
}
|
||||
table send_frame {
|
||||
key = {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"target": "bmv2",
|
||||
"p4info": "build/load_balance.p4info",
|
||||
"p4info": "build/load_balance.p4.p4info.txt",
|
||||
"bmv2_json": "build/load_balance.json",
|
||||
"table_entries": [
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"target": "bmv2",
|
||||
"p4info": "build/load_balance.p4info",
|
||||
"p4info": "build/load_balance.p4.p4info.txt",
|
||||
"bmv2_json": "build/load_balance.json",
|
||||
"table_entries": [
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"target": "bmv2",
|
||||
"p4info": "build/load_balance.p4info",
|
||||
"p4info": "build/load_balance.p4.p4info.txt",
|
||||
"bmv2_json": "build/load_balance.json",
|
||||
"table_entries": [
|
||||
{
|
||||
|
@ -99,7 +99,7 @@ control MyIngress(inout headers hdr,
|
||||
inout metadata meta,
|
||||
inout standard_metadata_t standard_metadata) {
|
||||
action drop() {
|
||||
mark_to_drop();
|
||||
mark_to_drop(standard_metadata);
|
||||
}
|
||||
action set_ecmp_select(bit<16> ecmp_base, bit<32> ecmp_count) {
|
||||
hash(meta.ecmp_select,
|
||||
@ -158,7 +158,7 @@ control MyEgress(inout headers hdr,
|
||||
hdr.ethernet.srcAddr = smac;
|
||||
}
|
||||
action drop() {
|
||||
mark_to_drop();
|
||||
mark_to_drop(standard_metadata);
|
||||
}
|
||||
table send_frame {
|
||||
key = {
|
||||
|
@ -1,5 +1,5 @@
|
||||
BMV2_SWITCH_EXE = simple_switch_grpc
|
||||
NO_P4 = true
|
||||
P4C_ARGS = --p4runtime-file $(basename $@).p4info --p4runtime-format text
|
||||
P4C_ARGS = --p4runtime-files $(basename $@).p4.p4info.txt
|
||||
|
||||
include ../../utils/Makefile
|
||||
|
Before Width: | Height: | Size: 154 B After Width: | Height: | Size: 138 B |
@ -161,7 +161,7 @@ control MyIngress(inout headers hdr,
|
||||
inout metadata meta,
|
||||
inout standard_metadata_t standard_metadata) {
|
||||
action drop() {
|
||||
mark_to_drop();
|
||||
mark_to_drop(standard_metadata);
|
||||
}
|
||||
|
||||
action ipv4_forward(macAddr_t dstAddr, egressSpec_t port) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"target": "bmv2",
|
||||
"p4info": "build/mri.p4info",
|
||||
"p4info": "build/mri.p4.p4info.txt",
|
||||
"bmv2_json": "build/mri.json",
|
||||
"table_entries": [
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"target": "bmv2",
|
||||
"p4info": "build/mri.p4info",
|
||||
"p4info": "build/mri.p4.p4info.txt",
|
||||
"bmv2_json": "build/mri.json",
|
||||
"table_entries": [
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"target": "bmv2",
|
||||
"p4info": "build/mri.p4info",
|
||||
"p4info": "build/mri.p4.p4info.txt",
|
||||
"bmv2_json": "build/mri.json",
|
||||
"table_entries": [
|
||||
{
|
||||
|
@ -153,7 +153,7 @@ control MyIngress(inout headers hdr,
|
||||
inout metadata meta,
|
||||
inout standard_metadata_t standard_metadata) {
|
||||
action drop() {
|
||||
mark_to_drop();
|
||||
mark_to_drop(standard_metadata);
|
||||
}
|
||||
|
||||
action ipv4_forward(macAddr_t dstAddr, egressSpec_t port) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
BMV2_SWITCH_EXE = simple_switch_grpc
|
||||
NO_P4 = true
|
||||
P4C_ARGS = --p4runtime-file $(basename $@).p4info --p4runtime-format text
|
||||
P4C_ARGS = --p4runtime-files $(basename $@).p4.p4info.txt
|
||||
|
||||
include ../../utils/Makefile
|
||||
|
Before Width: | Height: | Size: 154 B After Width: | Height: | Size: 138 B |
@ -108,7 +108,7 @@ control MyIngress(inout headers hdr,
|
||||
counter(MAX_TUNNEL_ID, CounterType.packets_and_bytes) egressTunnelCounter;
|
||||
|
||||
action drop() {
|
||||
mark_to_drop();
|
||||
mark_to_drop(standard_metadata);
|
||||
}
|
||||
|
||||
action ipv4_forward(macAddr_t dstAddr, egressSpec_t port) {
|
||||
|
@ -190,7 +190,7 @@ if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description='P4Runtime Controller')
|
||||
parser.add_argument('--p4info', help='p4info proto in text format from p4c',
|
||||
type=str, action="store", required=False,
|
||||
default='./build/advanced_tunnel.p4info')
|
||||
default='./build/advanced_tunnel.p4.p4info.txt')
|
||||
parser.add_argument('--bmv2-json', help='BMv2 JSON file from p4c',
|
||||
type=str, action="store", required=False,
|
||||
default='./build/advanced_tunnel.json')
|
||||
|
@ -215,7 +215,7 @@ if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description='P4Runtime Controller')
|
||||
parser.add_argument('--p4info', help='p4info proto in text format from p4c',
|
||||
type=str, action="store", required=False,
|
||||
default='./build/advanced_tunnel.p4info')
|
||||
default='./build/advanced_tunnel.p4.p4info.txt')
|
||||
parser.add_argument('--bmv2-json', help='BMv2 JSON file from p4c',
|
||||
type=str, action="store", required=False,
|
||||
default='./build/advanced_tunnel.json')
|
||||
|
@ -1,5 +1,5 @@
|
||||
BMV2_SWITCH_EXE = simple_switch_grpc
|
||||
NO_P4 = true
|
||||
P4C_ARGS = --p4runtime-file $(basename $@).p4info --p4runtime-format text
|
||||
P4C_ARGS = --p4runtime-files $(basename $@).p4.p4info.txt
|
||||
|
||||
include ../../utils/Makefile
|
||||
|
Before Width: | Height: | Size: 154 B After Width: | Height: | Size: 138 B |
@ -1,6 +1,6 @@
|
||||
{
|
||||
"target": "bmv2",
|
||||
"p4info": "build/source_routing.p4info",
|
||||
"p4info": "build/source_routing.p4.p4info.txt",
|
||||
"bmv2_json": "build/source_routing.json",
|
||||
"table_entries": [ ]
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"target": "bmv2",
|
||||
"p4info": "build/source_routing.p4info",
|
||||
"p4info": "build/source_routing.p4.p4info.txt",
|
||||
"bmv2_json": "build/source_routing.json",
|
||||
"table_entries": [ ]
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"target": "bmv2",
|
||||
"p4info": "build/source_routing.p4info",
|
||||
"p4info": "build/source_routing.p4.p4info.txt",
|
||||
"bmv2_json": "build/source_routing.json",
|
||||
"table_entries": [ ]
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ control MyIngress(inout headers hdr,
|
||||
inout standard_metadata_t standard_metadata) {
|
||||
|
||||
action drop() {
|
||||
mark_to_drop();
|
||||
mark_to_drop(standard_metadata);
|
||||
}
|
||||
|
||||
action srcRoute_nhop() {
|
||||
|
@ -110,7 +110,7 @@ control MyIngress(inout headers hdr,
|
||||
inout standard_metadata_t standard_metadata) {
|
||||
|
||||
action drop() {
|
||||
mark_to_drop();
|
||||
mark_to_drop(standard_metadata);
|
||||
}
|
||||
|
||||
action srcRoute_nhop() {
|
||||
|
@ -17,7 +17,8 @@ import sys
|
||||
|
||||
from google.rpc import status_pb2, code_pb2
|
||||
import grpc
|
||||
from p4 import p4runtime_pb2
|
||||
from p4.v1 import p4runtime_pb2
|
||||
from p4.v1 import p4runtime_pb2_grpc
|
||||
|
||||
# Used to indicate that the gRPC error Status object returned by the server has
|
||||
# an incorrect format.
|
||||
|
@ -15,8 +15,8 @@
|
||||
import re
|
||||
|
||||
import google.protobuf.text_format
|
||||
from p4 import p4runtime_pb2
|
||||
from p4.config import p4info_pb2
|
||||
from p4.v1 import p4runtime_pb2
|
||||
from p4.config.v1 import p4info_pb2
|
||||
|
||||
from convert import encode
|
||||
|
||||
@ -97,10 +97,7 @@ class P4InfoHelper(object):
|
||||
p4runtime_match = p4runtime_pb2.FieldMatch()
|
||||
p4runtime_match.field_id = p4info_match.id
|
||||
match_type = p4info_match.match_type
|
||||
if match_type == p4info_pb2.MatchField.VALID:
|
||||
valid = p4runtime_match.valid
|
||||
valid.value = bool(value)
|
||||
elif match_type == p4info_pb2.MatchField.EXACT:
|
||||
if match_type == p4info_pb2.MatchField.EXACT:
|
||||
exact = p4runtime_match.exact
|
||||
exact.value = encode(value, bitwidth)
|
||||
elif match_type == p4info_pb2.MatchField.LPM:
|
||||
|
@ -17,7 +17,8 @@ from abc import abstractmethod
|
||||
from datetime import datetime
|
||||
|
||||
import grpc
|
||||
from p4 import p4runtime_pb2
|
||||
from p4.v1 import p4runtime_pb2
|
||||
from p4.v1 import p4runtime_pb2_grpc
|
||||
from p4.tmp import p4config_pb2
|
||||
|
||||
MSG_LOG_MAX_LEN = 1024
|
||||
@ -41,7 +42,7 @@ class SwitchConnection(object):
|
||||
if proto_dump_file is not None:
|
||||
interceptor = GrpcRequestLogger(proto_dump_file)
|
||||
self.channel = grpc.intercept_channel(self.channel, interceptor)
|
||||
self.client_stub = p4runtime_pb2.P4RuntimeStub(self.channel)
|
||||
self.client_stub = p4runtime_pb2_grpc.P4RuntimeStub(self.channel)
|
||||
self.requests_stream = IterableQueue()
|
||||
self.stream_msg_resp = self.client_stub.StreamChannel(iter(self.requests_stream))
|
||||
self.proto_dump_file = proto_dump_file
|
||||
@ -89,7 +90,10 @@ class SwitchConnection(object):
|
||||
request.device_id = self.device_id
|
||||
request.election_id.low = 1
|
||||
update = request.updates.add()
|
||||
update.type = p4runtime_pb2.Update.INSERT
|
||||
if table_entry.is_default_action:
|
||||
update.type = p4runtime_pb2.Update.MODIFY
|
||||
else:
|
||||
update.type = p4runtime_pb2.Update.INSERT
|
||||
update.entity.table_entry.CopyFrom(table_entry)
|
||||
if dry_run:
|
||||
print "P4Runtime Write:", request
|
||||
|
@ -5,9 +5,9 @@ set -x
|
||||
# Exit on errors.
|
||||
set -e
|
||||
|
||||
BMV2_COMMIT="7e25eeb19d01eee1a8e982dc7ee90ee438c10a05"
|
||||
PI_COMMIT="219b3d67299ec09b49f433d7341049256ab5f512"
|
||||
P4C_COMMIT="48a57a6ae4f96961b74bd13f6bdeac5add7bb815"
|
||||
BMV2_COMMIT="884e01b531c6fd078cc2438a40258ecae011a65b" # Apr 24, 2019
|
||||
PI_COMMIT="19de33e83bae7b737a3f8a1c9507c6e84173d96f" # Apr 24, 2019
|
||||
P4C_COMMIT="61409c890c58d14ec7d6790f263eb44f393e542a" # Apr 24, 2019
|
||||
PROTOBUF_COMMIT="v3.2.0"
|
||||
GRPC_COMMIT="v1.3.2"
|
||||
|
||||
@ -106,7 +106,7 @@ mkdir -p build
|
||||
cd build
|
||||
cmake ..
|
||||
make -j${NUM_CORES}
|
||||
make -j${NUM_CORES} check
|
||||
# make -j${NUM_CORES} check <- skip tests as p4c tests are failing currently
|
||||
sudo make install
|
||||
sudo ldconfig
|
||||
cd ..
|
||||
|