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/define.p4 b/pipelines/fabric/impl/src/main/resources/include/define.p4
index 8501516..bfb7b44 100644
--- a/pipelines/fabric/impl/src/main/resources/include/define.p4
+++ b/pipelines/fabric/impl/src/main/resources/include/define.p4
@@ -97,17 +97,28 @@
 
 // SPGW types
 typedef bit<2> direction_t;
+typedef bit<8> spgw_interface_t;
 typedef bit pcc_gate_status_t;
 typedef bit<32> sdf_rule_id_t;
 typedef bit<32> pcc_rule_id_t;
 typedef bit<32> far_id_t;
-typedef bit<32> ctr_id_t;
+typedef bit<32> pdr_ctr_id_t;
 typedef bit<32> teid_t;
 
-// spgw.p4 expects uplink packets with IP dst on this subnet
-// 140.0.0.0/8
-const ipv4_addr_t S1U_SGW_PREFIX = 2348810240;
+const spgw_interface_t SPGW_IFACE_UNKNOWN = 8w0;
+const spgw_interface_t SPGW_IFACE_ACCESS = 8w1;
+const spgw_interface_t SPGW_IFACE_CORE = 8w2;
+const direction_t SPGW_DIR_UNKNOWN = 2w0;
+const direction_t SPGW_DIR_UPLINK = 2w1;
+const direction_t SPGW_DIR_DOWNLINK = 2w2;
+
+#ifndef S1U_SGW_PREFIX
+// By default spgw.p4 expects uplink packets with IP dst matching 140.0.0.0/8
+// FIXME: refactor pipeline to remove dependency on this value or allow setting it at runtime
+//  (e.g. via parser value sets)
+#define S1U_SGW_PREFIX (8w140++8w0++8w0++8w0)
 #define S1U_SGW_PREFIX_LEN 8
+#endif
 
 const bit<16> ETHERTYPE_QINQ = 0x88A8;
 const bit<16> ETHERTYPE_QINQ_NON_STD = 0x9100;
@@ -144,13 +155,7 @@
 const bit<8> DEFAULT_MPLS_TTL = 64;
 const bit<8> DEFAULT_IPV4_TTL = 64;
 
-const sdf_rule_id_t DEFAULT_SDF_RULE_ID = 0;
-const pcc_rule_id_t DEFAULT_PCC_RULE_ID = 0;
-const direction_t SPGW_DIR_UNKNOWN = 2w0;
-const direction_t SPGW_DIR_UPLINK = 2w1;
-const direction_t SPGW_DIR_DOWNLINK = 2w2;
-const pcc_gate_status_t PCC_GATE_OPEN = 1w0;
-const pcc_gate_status_t PCC_GATE_CLOSED = 1w1;
+
 
 /* indicate INT at LSB of DSCP */
 const bit<6> INT_DSCP = 0x1;