Use P4 port counters only for BMv2 pipeconf in fabric.p4

Change-Id: I7d13b42188368318c43606f9b97afe75adfae7dc
diff --git a/pipelines/fabric/src/main/java/org/onosproject/pipelines/fabric/PipeconfLoader.java b/pipelines/fabric/src/main/java/org/onosproject/pipelines/fabric/PipeconfLoader.java
index f808fc8..9b54dfc 100644
--- a/pipelines/fabric/src/main/java/org/onosproject/pipelines/fabric/PipeconfLoader.java
+++ b/pipelines/fabric/src/main/java/org/onosproject/pipelines/fabric/PipeconfLoader.java
@@ -173,6 +173,8 @@
             throw new FileNotFoundException(CPU_PORT_TXT);
         }
         return basePipeconfBuilder(profile, platform, p4InfoUrl, cpuPortUrl)
+                .addBehaviour(PortStatisticsDiscovery.class,
+                              FabricPortStatisticsDiscovery.class)
                 .addExtension(ExtensionType.BMV2_JSON, bmv2JsonUrl);
     }
 
@@ -218,8 +220,6 @@
                               FabricInterpreter.class)
                 .addBehaviour(Pipeliner.class,
                               FabricPipeliner.class)
-                .addBehaviour(PortStatisticsDiscovery.class,
-                              FabricPortStatisticsDiscovery.class)
                 .addExtension(ExtensionType.P4_INFO_TEXT, p4InfoUrl)
                 .addExtension(ExtensionType.CPU_PORT_TXT, cpuPortUrl);
     }
diff --git a/pipelines/fabric/src/main/resources/bmv2-compile.sh b/pipelines/fabric/src/main/resources/bmv2-compile.sh
index b0ac43e..0fede1c 100755
--- a/pipelines/fabric/src/main/resources/bmv2-compile.sh
+++ b/pipelines/fabric/src/main/resources/bmv2-compile.sh
@@ -3,7 +3,7 @@
 set -ex
 
 BMV2_CPU_PORT="255"
-BMV2_PP_FLAGS="-DTARGET_BMV2 -DCPU_PORT=${BMV2_CPU_PORT}"
+BMV2_PP_FLAGS="-DTARGET_BMV2 -DCPU_PORT=${BMV2_CPU_PORT} -DWITH_PORT_COUNTER"
 
 PROFILE=$1
 OTHER_PP_FLAGS=$2
diff --git a/pipelines/fabric/src/main/resources/fabric.p4 b/pipelines/fabric/src/main/resources/fabric.p4
index 22ad209..6ef205b 100644
--- a/pipelines/fabric/src/main/resources/fabric.p4
+++ b/pipelines/fabric/src/main/resources/fabric.p4
@@ -21,11 +21,14 @@
 #include "include/control/forwarding.p4"
 #include "include/control/next.p4"
 #include "include/control/packetio.p4"
-#include "include/control/port_counter.p4"
 #include "include/header.p4"
 #include "include/checksum.p4"
 #include "include/parser.p4"
 
+#ifdef WITH_PORT_COUNTER
+#include "include/control/port_counter.p4"
+#endif // WITH_PORT_COUNTER
+
 #ifdef WITH_SPGW
 #include "include/spgw.p4"
 #endif // WITH_SPGW
@@ -45,7 +48,9 @@
     Filtering() filtering;
     Forwarding() forwarding;
     Next() next;
+#ifdef WITH_PORT_COUNTER
     PortCountersControl() port_counters_control;
+#endif // WITH_PORT_COUNTER
 
     apply {
 #ifdef WITH_SPGW
@@ -64,7 +69,9 @@
         filtering.apply(hdr, fabric_metadata, standard_metadata);
         forwarding.apply(hdr, fabric_metadata, standard_metadata);
         next.apply(hdr, fabric_metadata, standard_metadata);
+#ifdef WITH_PORT_COUNTER
         port_counters_control.apply(hdr, fabric_metadata, standard_metadata);
+#endif // WITH_PORT_COUNTER
 #ifdef WITH_INT
         process_set_source_sink.apply(hdr, fabric_metadata, standard_metadata);
         if(fabric_metadata.int_meta.sink == 1) {
diff --git a/pipelines/fabric/src/main/resources/p4c-out/fabric-full/bmv2/default/bmv2.json b/pipelines/fabric/src/main/resources/p4c-out/fabric-full/bmv2/default/bmv2.json
index 67d1b45..40f5a60 100644
--- a/pipelines/fabric/src/main/resources/p4c-out/fabric-full/bmv2/default/bmv2.json
+++ b/pipelines/fabric/src/main/resources/p4c-out/fabric-full/bmv2/default/bmv2.json
@@ -4068,7 +4068,7 @@
           ],
           "source_info" : {
             "filename" : "fabric.p4",
-            "line" : 52,
+            "line" : 57,
             "column" : 50,
             "source_fragment" : "hdr.gtpu_ipv4"
           }
@@ -4083,7 +4083,7 @@
           ],
           "source_info" : {
             "filename" : "fabric.p4",
-            "line" : 52,
+            "line" : 57,
             "column" : 65,
             "source_fragment" : "hdr.gtpu_udp"
           }
@@ -11194,7 +11194,7 @@
       "id" : 0,
       "source_info" : {
         "filename" : "fabric.p4",
-        "line" : 40,
+        "line" : 43,
         "column" : 8,
         "source_fragment" : "FabricIngress"
       },
@@ -13227,7 +13227,7 @@
           "id" : 22,
           "source_info" : {
             "filename" : "fabric.p4",
-            "line" : 70,
+            "line" : 77,
             "column" : 11,
             "source_fragment" : "fabric_metadata.int_meta.sink == 1"
           },
@@ -13255,7 +13255,7 @@
       "id" : 1,
       "source_info" : {
         "filename" : "fabric.p4",
-        "line" : 80,
+        "line" : 87,
         "column" : 8,
         "source_fragment" : "FabricEgress"
       },
@@ -14032,7 +14032,7 @@
           "id" : 29,
           "source_info" : {
             "filename" : "fabric.p4",
-            "line" : 94,
+            "line" : 101,
             "column" : 12,
             "source_fragment" : "standard_metadata.ingress_port != 255 && ..."
           },
@@ -14112,7 +14112,7 @@
           "id" : 30,
           "source_info" : {
             "filename" : "fabric.p4",
-            "line" : 97,
+            "line" : 104,
             "column" : 16,
             "source_fragment" : "fabric_metadata.int_meta.source == 1"
           },
@@ -14138,7 +14138,7 @@
           "id" : 31,
           "source_info" : {
             "filename" : "fabric.p4",
-            "line" : 100,
+            "line" : 107,
             "column" : 15,
             "source_fragment" : "hdr.int_header.isValid()"
           },
@@ -14230,7 +14230,7 @@
           "id" : 35,
           "source_info" : {
             "filename" : "fabric.p4",
-            "line" : 104,
+            "line" : 111,
             "column" : 20,
             "source_fragment" : "standard_metadata.instance_type == 1"
           },
@@ -14256,7 +14256,7 @@
           "id" : 36,
           "source_info" : {
             "filename" : "fabric.p4",
-            "line" : 108,
+            "line" : 115,
             "column" : 20,
             "source_fragment" : "fabric_metadata.int_meta.sink == 1"
           },
diff --git a/pipelines/fabric/src/main/resources/p4c-out/fabric-int/bmv2/default/bmv2.json b/pipelines/fabric/src/main/resources/p4c-out/fabric-int/bmv2/default/bmv2.json
index 7e96c8b..f0917e4 100644
--- a/pipelines/fabric/src/main/resources/p4c-out/fabric-int/bmv2/default/bmv2.json
+++ b/pipelines/fabric/src/main/resources/p4c-out/fabric-int/bmv2/default/bmv2.json
@@ -9426,7 +9426,7 @@
       "id" : 0,
       "source_info" : {
         "filename" : "fabric.p4",
-        "line" : 40,
+        "line" : 43,
         "column" : 8,
         "source_fragment" : "FabricIngress"
       },
@@ -10737,7 +10737,7 @@
           "id" : 13,
           "source_info" : {
             "filename" : "fabric.p4",
-            "line" : 70,
+            "line" : 77,
             "column" : 11,
             "source_fragment" : "fabric_metadata.int_meta.sink == 1"
           },
@@ -10765,7 +10765,7 @@
       "id" : 1,
       "source_info" : {
         "filename" : "fabric.p4",
-        "line" : 80,
+        "line" : 87,
         "column" : 8,
         "source_fragment" : "FabricEgress"
       },
@@ -11493,7 +11493,7 @@
           "id" : 19,
           "source_info" : {
             "filename" : "fabric.p4",
-            "line" : 94,
+            "line" : 101,
             "column" : 12,
             "source_fragment" : "standard_metadata.ingress_port != 255 && ..."
           },
@@ -11573,7 +11573,7 @@
           "id" : 20,
           "source_info" : {
             "filename" : "fabric.p4",
-            "line" : 97,
+            "line" : 104,
             "column" : 16,
             "source_fragment" : "fabric_metadata.int_meta.source == 1"
           },
@@ -11599,7 +11599,7 @@
           "id" : 21,
           "source_info" : {
             "filename" : "fabric.p4",
-            "line" : 100,
+            "line" : 107,
             "column" : 15,
             "source_fragment" : "hdr.int_header.isValid()"
           },
@@ -11691,7 +11691,7 @@
           "id" : 25,
           "source_info" : {
             "filename" : "fabric.p4",
-            "line" : 104,
+            "line" : 111,
             "column" : 20,
             "source_fragment" : "standard_metadata.instance_type == 1"
           },
@@ -11717,7 +11717,7 @@
           "id" : 26,
           "source_info" : {
             "filename" : "fabric.p4",
-            "line" : 108,
+            "line" : 115,
             "column" : 20,
             "source_fragment" : "fabric_metadata.int_meta.sink == 1"
           },
diff --git a/pipelines/fabric/src/main/resources/p4c-out/fabric-spgw/bmv2/default/bmv2.json b/pipelines/fabric/src/main/resources/p4c-out/fabric-spgw/bmv2/default/bmv2.json
index a34bcfb..160814c 100644
--- a/pipelines/fabric/src/main/resources/p4c-out/fabric-spgw/bmv2/default/bmv2.json
+++ b/pipelines/fabric/src/main/resources/p4c-out/fabric-spgw/bmv2/default/bmv2.json
@@ -3155,7 +3155,7 @@
           ],
           "source_info" : {
             "filename" : "fabric.p4",
-            "line" : 52,
+            "line" : 57,
             "column" : 50,
             "source_fragment" : "hdr.gtpu_ipv4"
           }
@@ -3170,7 +3170,7 @@
           ],
           "source_info" : {
             "filename" : "fabric.p4",
-            "line" : 52,
+            "line" : 57,
             "column" : 65,
             "source_fragment" : "hdr.gtpu_udp"
           }
@@ -4970,7 +4970,7 @@
       "id" : 0,
       "source_info" : {
         "filename" : "fabric.p4",
-        "line" : 40,
+        "line" : 43,
         "column" : 8,
         "source_fragment" : "FabricIngress"
       },
@@ -6799,7 +6799,7 @@
       "id" : 1,
       "source_info" : {
         "filename" : "fabric.p4",
-        "line" : 80,
+        "line" : 87,
         "column" : 8,
         "source_fragment" : "FabricEgress"
       },
diff --git a/pipelines/fabric/src/main/resources/p4c-out/fabric/bmv2/default/bmv2.json b/pipelines/fabric/src/main/resources/p4c-out/fabric/bmv2/default/bmv2.json
index 32e5f33..e7c2981 100644
--- a/pipelines/fabric/src/main/resources/p4c-out/fabric/bmv2/default/bmv2.json
+++ b/pipelines/fabric/src/main/resources/p4c-out/fabric/bmv2/default/bmv2.json
@@ -3391,7 +3391,7 @@
       "id" : 0,
       "source_info" : {
         "filename" : "fabric.p4",
-        "line" : 40,
+        "line" : 43,
         "column" : 8,
         "source_fragment" : "FabricIngress"
       },
@@ -4607,7 +4607,7 @@
       "id" : 1,
       "source_info" : {
         "filename" : "fabric.p4",
-        "line" : 80,
+        "line" : 87,
         "column" : 8,
         "source_fragment" : "FabricEgress"
       },