Skip to content

Commit

Permalink
Add support for INT postcards and general pipeline improvements (#37)
Browse files Browse the repository at this point in the history
Co-authored-by: Robert MacDavid <robertmacdavid@gmail.com>
Co-authored-by: Carmelo Cascone <carmelo@opennetworking.org>
  • Loading branch information
3 people committed Aug 17, 2020
1 parent 5e8593b commit e87824a
Show file tree
Hide file tree
Showing 86 changed files with 4,269 additions and 893,136 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# This workflow will build the pipeconf Java project with Maven

name: Java CI with Maven

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Build with Maven
run: mvn -Pci-verify -Pcoverage install
- name: Upload test coverage results
run: bash <(curl -s https://codecov.io/bash)
env:
CODECOV_TOKEN: 75f36e70-2caf-46ab-9b76-7a1b9a419ebd
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ tmp
target
.vscode
*.pyc
src/main/resources/p4c-out
.idea
*.iml
*.pcap
Expand Down
26 changes: 16 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ mvn_image := maven:3.6.1-jdk-11-slim
mvn_cache_docker_volume := mvn-cache-${curr_dir_sha}
# By default use docker volume, but allow passing a directory
MVN_CACHE ?= ${mvn_cache_docker_volume}
MVN_FLAGS ?=

onos_url := http://${ONOS_HOST}:8181/onos
onos_curl := curl --fail -sSL --user onos:rocks --noproxy localhost
Expand All @@ -24,7 +25,7 @@ p4-build := ./p4src/build.sh

build: clean $(PROFILES) pipeconf

all: fabric fabric-spgw
all: fabric fabric-spgw fabric-int fabric-spgw-int

fabric:
@${p4-build} fabric ""
Expand All @@ -36,31 +37,36 @@ fabric:
# fabric-bng:
# @${p4-build} fabric-bng "-DWITH_BNG -DWITHOUT_XCONNECT"

# fabric-int:
# @${p4-build} fabric-int "-DWITH_INT_SOURCE -DWITH_INT_TRANSIT"
fabric-int:
@${p4-build} fabric-int "-DWITH_INT"

fabric-spgw:
@${p4-build} fabric-spgw "-DWITH_SPGW"

# fabric-spgw-int:
# @${p4-build} fabric-spgw-int "-DWITH_SPGW -DWITH_INT_SOURCE -DWITH_INT_TRANSIT"
fabric-spgw-int:
@${p4-build} fabric-spgw-int "-DWITH_SPGW -DWITH_INT"

constants:
docker run -v $(curr_dir):/root -w /root \
--entrypoint ./util/gen-p4-constants.py onosproject/fabric-p4test:latest \
-o /root/src/main/java/org/stratumproject/fabric/tna/behaviour/FabricConstants.java \
fabric /root/src/main/resources/p4c-out/fabric-spgw/stratum_bf/mavericks_sde_9_2_0/p4info.txt
-o /root/src/main/java/org/stratumproject/fabric/tna/behaviour/P4InfoConstants.java \
p4info /root/src/main/resources/p4c-out/fabric-spgw-int/stratum_bf/mavericks_sde_9_2_0/p4info.txt

_mvn_package: constants
$(info *** Building ONOS app...)
@mkdir -p target
docker run --rm -v ${curr_dir}:/mvn-src -w /mvn-src \
-v ${MVN_CACHE}:/root/.m2 ${mvn_image} mvn clean install
-v ${MVN_CACHE}:/root/.m2 ${mvn_image} mvn ${MVN_FLAGS} clean install

pipeconf: _mvn_package
$(info *** ONOS pipeconf .oar package created succesfully)
@ls -1 ${curr_dir}/target/*.oar

pipeconf-test: _mvn_package
$(info *** Testing ONOS pipeconf)
docker run --rm -v $(curr_dir}:mvn-src -w /mvn-src \
-v ${MVN_CACHE}:/root/.m2 ${mvn_image} mvn test

pipeconf-install:
$(info *** Installing and activating pipeconf app in ONOS at ${ONOS_HOST}...)
${onos_curl} -X POST -HContent-Type:application/octet-stream \
Expand Down Expand Up @@ -88,8 +94,8 @@ p4i-stop:

clean:
-rm -rf src/main/resources/p4c-out

deep-clean: clean
-rm -rf tmp
-rm -rf target

deep-clean: clean
-docker volume rm ${mvn_cache_docker_volume} > /dev/null 2>&1
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ The above command will build the `fabric-tna.p4` profiles specified in the
| ------------------------|----------------------------------------------------|
| `fabric` | Basic profile |
| `fabric-bng` | With BNG user plane support (Not available) |
| `fabric-spgw` | With SPGW user plane support (Not available) |
| `fabric-int` | With INT source and transit (Not available) |
| `fabric-spgw-int` | WITH SPGW and INT support (Not available) |
| `fabric-spgw` | With SPGW user plane support |
| `fabric-int` | With INT support |
| `fabric-spgw-int` | WITH SPGW and INT support |

Check the `Makefile` for other profiles.

Expand Down
37 changes: 11 additions & 26 deletions p4src/fabric_tna.p4
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
#include "include/control/spgw.p4"
#endif // WITH_SPGW

#ifdef WITH_INT
#include "include/int/int.p4"
#endif

control FabricIngress (
/* Fabric.p4 */
inout parsed_headers_t hdr,
Expand All @@ -43,37 +47,12 @@ control FabricIngress (
#endif // WITH_SPGW
filtering.apply(hdr, fabric_md, ig_intr_md);
if (!fabric_md.skip_forwarding) {
forwarding.apply(hdr, fabric_md);
forwarding.apply(hdr, fabric_md);
}
acl.apply(hdr, fabric_md, ig_intr_md, ig_dprsr_md, ig_tm_md);
if (!fabric_md.skip_next) {
next.apply(hdr, fabric_md, ig_intr_md, ig_tm_md);
}

if (ig_tm_md.bypass_egress == 1w0) {
hdr.bridge_md.setValid();
hdr.bridge_md.is_multicast = fabric_md.is_multicast;
hdr.bridge_md.ingress_port = ig_intr_md.ingress_port;
hdr.bridge_md.ip_eth_type = fabric_md.ip_eth_type;
hdr.bridge_md.ip_proto = fabric_md.ip_proto;
hdr.bridge_md.mpls_label = fabric_md.mpls_label;
hdr.bridge_md.mpls_ttl = fabric_md.mpls_ttl;
hdr.bridge_md.vlan_id = fabric_md.vlan_id;
#ifdef WITH_DOUBLE_VLAN_TERMINATION
hdr.bridge_md.push_double_vlan = fabric_md.push_double_vlan;
hdr.bridge_md.inner_vlan_id = fabric_md.inner_vlan_id;
#endif // WITH_DOUBLE_VLAN_TERMINATION
#ifdef WITH_SPGW
hdr.bridge_md.spgw_ipv4_len = fabric_md.spgw_ipv4_len;
hdr.bridge_md.needs_gtpu_encap = fabric_md.needs_gtpu_encap;
hdr.bridge_md.skip_spgw = fabric_md.skip_spgw;
hdr.bridge_md.gtpu_teid = fabric_md.gtpu_teid;
hdr.bridge_md.gtpu_tunnel_sip = fabric_md.gtpu_tunnel_sip;
hdr.bridge_md.gtpu_tunnel_dip = fabric_md.gtpu_tunnel_dip;
hdr.bridge_md.gtpu_tunnel_sport = fabric_md.gtpu_tunnel_sport;
hdr.bridge_md.pdr_ctr_id = fabric_md.pdr_ctr_id;
#endif // WITH_SPGW
}
}
}

Expand All @@ -92,10 +71,16 @@ control FabricEgress (
#ifdef WITH_SPGW
SpgwEgress() spgw_egress;
#endif // WITH_SPGW
#ifdef WITH_INT
IntEgress() int_egress;
#endif // WITH_INT

apply {
pkt_io_egress.apply(hdr, fabric_md, eg_intr_md);
egress_next.apply(hdr, fabric_md, eg_intr_md, eg_dprsr_md);
#ifdef WITH_INT
int_egress.apply(hdr, fabric_md, eg_intr_md, eg_prsr_md);
#endif
#ifdef WITH_SPGW
spgw_egress.apply(hdr, fabric_md);
#endif // WITH_SPGW
Expand Down
32 changes: 12 additions & 20 deletions p4src/include/control/acl.p4
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,6 @@ control Acl (inout parsed_headers_t hdr,
acl_counter.count();
}

// Set mirror with session/clone id
action set_clone_session_id(bit<32> clone_id) {
fabric_md.is_mirror = true;
fabric_md.mirror_id = clone_id[9:0];
acl_counter.count();
}

action drop() {
ig_intr_md_for_dprsr.drop_ctl = 1;
fabric_md.skip_next = true;
Expand All @@ -54,25 +47,24 @@ control Acl (inout parsed_headers_t hdr,

table acl {
key = {
ig_intr_md.ingress_port: ternary @name("ig_port"); // 9
fabric_md.ip_proto: ternary @name("ip_proto"); // 8
fabric_md.l4_sport: ternary @name("l4_sport"); // 16
fabric_md.l4_dport: ternary @name("l4_dport"); // 16
hdr.ethernet.dst_addr: ternary @name("eth_dst"); // 48
hdr.ethernet.src_addr: ternary @name("eth_src"); // 48
hdr.vlan_tag.vlan_id: ternary @name("vlan_id"); // 12
hdr.eth_type.value: ternary @name("eth_type"); //16
fabric_md.ipv4_src_addr: ternary @name("ipv4_src"); // 32
fabric_md.ipv4_dst_addr: ternary @name("ipv4_dst"); // 32
hdr.icmp.icmp_type: ternary @name("icmp_type"); // 8
hdr.icmp.icmp_code: ternary @name("icmp_code"); // 8
ig_intr_md.ingress_port : ternary @name("ig_port"); // 9
fabric_md.bridged.ip_proto : ternary @name("ip_proto"); // 8
fabric_md.bridged.l4_sport : ternary @name("l4_sport"); // 16
fabric_md.bridged.l4_dport : ternary @name("l4_dport"); // 16
hdr.ethernet.dst_addr : ternary @name("eth_dst"); // 48
hdr.ethernet.src_addr : ternary @name("eth_src"); // 48
hdr.vlan_tag.vlan_id : ternary @name("vlan_id"); // 12
hdr.eth_type.value : ternary @name("eth_type"); // 16
fabric_md.ipv4_src : ternary @name("ipv4_src"); // 32
fabric_md.ipv4_dst : ternary @name("ipv4_dst"); // 32
hdr.icmp.icmp_type : ternary @name("icmp_type"); // 8
hdr.icmp.icmp_code : ternary @name("icmp_code"); // 8
}

actions = {
set_next_id_acl;
punt_to_cpu;
copy_to_cpu;
set_clone_session_id;
drop;
nop_acl;
}
Expand Down
68 changes: 63 additions & 5 deletions p4src/include/control/filtering.p4
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,10 @@ control Filtering (inout parsed_headers_t hdr,
}

action permit_with_internal_vlan(vlan_id_t vlan_id) {
fabric_md.vlan_id = vlan_id;
fabric_md.bridged.vlan_id = vlan_id;
permit();
}

// FIXME: remove the use of ternary match on inner VLAN.
// Use multi-table approach to remove ternary matching
table ingress_port_vlan {
key = {
ig_intr_md.ingress_port : exact @name("ig_port");
Expand Down Expand Up @@ -88,7 +86,7 @@ control Filtering (inout parsed_headers_t hdr,
ig_intr_md.ingress_port : exact @name("ig_port");
hdr.ethernet.dst_addr : ternary @name("eth_dst");
hdr.eth_type.value : ternary @name("eth_type");
fabric_md.ip_eth_type : exact @name("ip_eth_type");
fabric_md.bridged.ip_eth_type : exact @name("ip_eth_type");
}
actions = {
set_forwarding_type;
Expand All @@ -98,11 +96,71 @@ control Filtering (inout parsed_headers_t hdr,
size = FWD_CLASSIFIER_TABLE_SIZE;
}

#ifdef WITH_INT
// FIXME: remove tables but use if on apply block on int report flag
// Since INT reports come in from the recirculation port, we need to bridge
// metadata to carry such int report flag. We could re-use a special eth-type
// as for packet-outs when that will be ready.

@hidden
action set_recirculate_pkt_vlan(vlan_id_t vlan_id) {
fabric_md.bridged.vlan_id = vlan_id;
// make the pipeline to handle it
fabric_md.skip_forwarding = false;
fabric_md.skip_next = false;
}

@hidden
table recirc_ingress_port_vlan {
key = {
ig_intr_md.ingress_port : exact @name("ig_port");
hdr.vlan_tag.isValid() : exact @name("vlan_is_valid");
}
actions = {
set_recirculate_pkt_vlan;
}
size = 4;
const entries = {
(RECIRC_PORT_PIPE_0, false): set_recirculate_pkt_vlan(DEFAULT_VLAN_ID);
(RECIRC_PORT_PIPE_1, false): set_recirculate_pkt_vlan(DEFAULT_VLAN_ID);
(RECIRC_PORT_PIPE_2, false): set_recirculate_pkt_vlan(DEFAULT_VLAN_ID);
(RECIRC_PORT_PIPE_3, false): set_recirculate_pkt_vlan(DEFAULT_VLAN_ID);
}
}

@hidden
action recirc_set_forwarding_type(fwd_type_t fwd_type) {
fabric_md.fwd_type = fwd_type;
}

@hidden
table recirc_fwd_classifier {
key = {
ig_intr_md.ingress_port : exact @name("ig_port");
fabric_md.bridged.ip_eth_type : exact @name("ip_eth_type");
}
actions = {
recirc_set_forwarding_type;
}
size = 4;
const entries = {
(RECIRC_PORT_PIPE_0, ETHERTYPE_IPV4): recirc_set_forwarding_type(FWD_IPV4_UNICAST);
(RECIRC_PORT_PIPE_1, ETHERTYPE_IPV4): recirc_set_forwarding_type(FWD_IPV4_UNICAST);
(RECIRC_PORT_PIPE_2, ETHERTYPE_IPV4): recirc_set_forwarding_type(FWD_IPV4_UNICAST);
(RECIRC_PORT_PIPE_3, ETHERTYPE_IPV4): recirc_set_forwarding_type(FWD_IPV4_UNICAST);
}
}
#endif // WITH_INT

apply {
ingress_port_vlan.apply();
fwd_classifier.apply();
#ifdef WITH_INT
recirc_ingress_port_vlan.apply();
recirc_fwd_classifier.apply();
#endif // WITH_INT
#ifdef WTIH_DEBUG
fwd_type_counter.count(fabric_md.fwd_type);
#endif
#endif // WTIH_DEBUG
}
}
13 changes: 5 additions & 8 deletions p4src/include/control/forwarding.p4
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ control Forwarding (inout parsed_headers_t hdr,
// with a multi-table/algorithmic approach?
table bridging {
key = {
fabric_md.vlan_id : exact @name("vlan_id");
hdr.ethernet.dst_addr : ternary @name("eth_dst");
fabric_md.bridged.vlan_id : exact @name("vlan_id");
hdr.ethernet.dst_addr : ternary @name("eth_dst");
}
actions = {
set_next_id_bridging;
Expand All @@ -49,14 +49,14 @@ control Forwarding (inout parsed_headers_t hdr,
DirectCounter<bit<64>>(CounterType_t.PACKETS_AND_BYTES) mpls_counter;

action pop_mpls_and_next(next_id_t next_id) {
fabric_md.mpls_label = 0;
fabric_md.bridged.mpls_label = 0;
set_next_id(next_id);
mpls_counter.count();
}

table mpls {
key = {
fabric_md.mpls_label : exact @name("mpls_label");
fabric_md.bridged.mpls_label : exact @name("mpls_label");
}
actions = {
pop_mpls_and_next;
Expand Down Expand Up @@ -88,12 +88,9 @@ control Forwarding (inout parsed_headers_t hdr,
#endif // WITH_DEBUG
}

#ifdef _ROUTING_V4_TABLE_ANNOT
_ROUTING_V4_TABLE_ANNOT
#endif
table routing_v4 {
key = {
fabric_md.ipv4_dst_addr: lpm @name("ipv4_dst");
fabric_md.ipv4_dst: lpm @name("ipv4_dst");
}
actions = {
set_next_id_routing_v4;
Expand Down
Loading

0 comments on commit e87824a

Please sign in to comment.