Backport fabric-spgw TNA changes to v1model

Allow building fabric.p4 with custom S1U_SGW_PREFIX

Change-Id: I4fcaf3f2b56e6d024e54f8897467c280be73e001

Backport fabric-spgw TNA changes to v1model

This branch ports the SPGW pipeline of fabric-tna back to v1model to
make the tables and actions consistent across the two versions. This
consistency will allow for testing of ONOS apps on both software and
hardware targets, since the only available software target that works
with ONOS requires v1model p4 programs. Changes to the fabric testing
suite (fabric-p4test) will be pushed in parallel.

Change-Id: Iad393b27f08a4fcd29f82e59d181871475ef2b10
diff --git a/pipelines/fabric/impl/src/main/resources/include/parser.p4 b/pipelines/fabric/impl/src/main/resources/include/parser.p4
index efbb74a..de0a76b 100644
--- a/pipelines/fabric/impl/src/main/resources/include/parser.p4
+++ b/pipelines/fabric/impl/src/main/resources/include/parser.p4
@@ -185,17 +185,6 @@
 
 #ifdef WITH_SPGW
     state parse_gtpu {
-        transition select(hdr.ipv4.dst_addr[31:32-S1U_SGW_PREFIX_LEN]) {
-            // Avoid parsing GTP and inner headers if we know this GTP packet
-            // is not to be processed by this switch.
-            // FIXME: use parser value sets when support is ready in ONOS.
-            // To set the S1U_SGW_PREFIX value at runtime.
-            S1U_SGW_PREFIX[31:32-S1U_SGW_PREFIX_LEN]: do_parse_gtpu;
-            default: accept;
-        }
-    }
-
-    state do_parse_gtpu {
         packet.extract(hdr.gtpu);
         transition parse_inner_ipv4;
     }
@@ -213,14 +202,26 @@
 
     state parse_inner_udp {
         packet.extract(hdr.inner_udp);
-        fabric_metadata.l4_sport = hdr.inner_udp.sport;
-        fabric_metadata.l4_dport = hdr.inner_udp.dport;
+        fabric_metadata.inner_l4_sport = hdr.inner_udp.sport;
+        fabric_metadata.inner_l4_dport = hdr.inner_udp.dport;
 #ifdef WITH_INT
         transition parse_int;
 #else
         transition accept;
 #endif // WITH_INT
     }
+
+        state parse_inner_tcp {
+        packet.extract(hdr.inner_tcp);
+        fabric_metadata.inner_l4_sport = hdr.inner_tcp.sport;
+        fabric_metadata.inner_l4_dport = hdr.inner_tcp.dport;
+        transition accept;
+    }
+
+        state parse_inner_icmp {
+        packet.extract(hdr.inner_icmp);
+        transition accept;
+    }
 #endif // WITH_SPGW
 
 #ifdef WITH_INT
@@ -288,7 +289,7 @@
 #ifdef WITH_SPGW
         packet.emit(hdr.gtpu_ipv4);
         packet.emit(hdr.gtpu_udp);
-        packet.emit(hdr.gtpu);
+        packet.emit(hdr.outer_gtpu);
 #endif // WITH_SPGW
         packet.emit(hdr.ipv4);
 #ifdef WITH_IPV6
@@ -297,6 +298,14 @@
         packet.emit(hdr.tcp);
         packet.emit(hdr.udp);
         packet.emit(hdr.icmp);
+#ifdef WITH_SPGW
+        // if we parsed a GTPU packet but did not decap it
+        packet.emit(hdr.gtpu);
+        packet.emit(hdr.inner_ipv4);
+        packet.emit(hdr.inner_tcp);
+        packet.emit(hdr.inner_udp);
+        packet.emit(hdr.inner_icmp);
+#endif // WITH_SPGW
 #ifdef WITH_INT
         packet.emit(hdr.intl4_shim);
         packet.emit(hdr.int_header);