Refactor fabric.p4 INT support to allow compilation on more P4 targets

Also use constant entries for instruction mask tables to avoid
programming them at runtime.

Change-Id: Ia1ab1ecd42a433daec171f9a30bcdba3b8484061
diff --git a/pipelines/fabric/src/main/resources/fabric.p4 b/pipelines/fabric/src/main/resources/fabric.p4
index 6ef205b..0aee32b 100644
--- a/pipelines/fabric/src/main/resources/fabric.p4
+++ b/pipelines/fabric/src/main/resources/fabric.p4
@@ -34,10 +34,7 @@
 #endif // WITH_SPGW
 
 #ifdef WITH_INT
-#include "include/int_source.p4"
-#include "include/int_transit.p4"
-#include "include/int_sink.p4"
-#include "include/int_report.p4"
+#include "include/int/int_main.p4"
 #endif // WITH_INT
 
 control FabricIngress (
@@ -70,16 +67,11 @@
         forwarding.apply(hdr, fabric_metadata, standard_metadata);
         next.apply(hdr, fabric_metadata, standard_metadata);
 #ifdef WITH_PORT_COUNTER
+        // FIXME: we're not counting pkts punted to cpu or forwarded via multicast groups.
         port_counters_control.apply(hdr, fabric_metadata, standard_metadata);
 #endif // WITH_PORT_COUNTER
-#ifdef WITH_INT
+#if defined(WITH_INT_SOURCE) || defined(WITH_INT_SINK)
         process_set_source_sink.apply(hdr, fabric_metadata, standard_metadata);
-        if(fabric_metadata.int_meta.sink == 1) {
-            // clone packet for Telemetry Report
-            #ifdef __TARGET_BMV2__
-            clone(CloneType.I2E, REPORT_MIRROR_SESSION_ID);
-            #endif
-        }
 #endif
     }
 }
@@ -98,26 +90,7 @@
                           fabric_metadata.spgw, standard_metadata);
 #endif // WITH_SPGW
 #ifdef WITH_INT
-        if (standard_metadata.ingress_port != CPU_PORT &&
-            standard_metadata.egress_port != CPU_PORT &&
-            (hdr.udp.isValid() || hdr.tcp.isValid())) {
-            if (fabric_metadata.int_meta.source == 1) {
-                process_int_source.apply(hdr, fabric_metadata, standard_metadata);
-            }
-            if(hdr.int_header.isValid()) {
-                process_int_transit.apply(hdr, fabric_metadata, standard_metadata);
-                // update underlay header based on INT information inserted
-                process_int_outer_encap.apply(hdr, fabric_metadata, standard_metadata);
-                if (standard_metadata.instance_type == PKT_INSTANCE_TYPE_INGRESS_CLONE) {
-                    /* send int report */
-                    process_int_report.apply(hdr, fabric_metadata, standard_metadata);
-                }
-                if (fabric_metadata.int_meta.sink == 1) {
-                    // int sink
-                    process_int_sink.apply(hdr, fabric_metadata, standard_metadata);
-                }
-            }
-        }
+        process_int_main.apply(hdr, fabric_metadata, standard_metadata);
 #endif
     }
 }