Minor clean-up of fabric pipeline

Change-Id: I9ee78abf9eca1a90dd24b99f737dd1acafea1fa6
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 c7c7421..86c2908 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
@@ -46,12 +46,13 @@
 @Component(immediate = true)
 public class PipeconfLoader {
 
-    private static final PiPipeconfId FABRIC_PIPECONF_ID =
+    public static final PiPipeconfId FABRIC_PIPECONF_ID =
             new PiPipeconfId("org.onosproject.pipelines.fabric");
+
     private static final String FABRIC_JSON_PATH = "/p4c-out/bmv2/fabric.json";
     private static final String FABRIC_P4INFO_PATH = "/p4c-out/bmv2/fabric.p4info";
 
-    public static final PiPipeconf FABRIC_PIPECONF = buildFabricPipeconf();
+    private static final PiPipeconf FABRIC_PIPECONF = buildFabricPipeconf();
 
     // XXX: Use a collection to hold only one pipeconf because we might separate
     // fabric pipeconf to leaf/spine pipeconf in the future.
@@ -84,8 +85,6 @@
                 .addBehaviour(PortStatisticsDiscovery.class, FabricPortStatisticsDiscovery.class)
                 .addExtension(P4_INFO_TEXT, p4InfoUrl)
                 .addExtension(BMV2_JSON, jsonUrl)
-                // Put here other target-specific extensions,
-                // e.g. Tofino's bin and context.json.
                 .build();
     }
 
diff --git a/pipelines/fabric/src/main/resources/Makefile b/pipelines/fabric/src/main/resources/Makefile
index e82fd31..c9557ef 100644
--- a/pipelines/fabric/src/main/resources/Makefile
+++ b/pipelines/fabric/src/main/resources/Makefile
@@ -1,8 +1,8 @@
 BMV2_CPU_PORT=255
 
-BMV2_OPTIONS=-DTARGET_BMV2
+BMV2_OPTIONS=-DTARGET_BMV2 -DCPU_PORT=$(BMV2_CPU_PORT)
 
-all: bmv2
+all: bmv2 bmv2-spgw
 
 bmv2:
 	p4c -v -x p4-16 -b bmv2-ss-p4org \
@@ -18,11 +18,5 @@
     		--p4runtime-file p4c-out/bmv2/fabric-spgw.p4info \
     		--p4runtime-format text fabric.p4
 
-custom:
-	p4c -v -x p4-16 -b $(BACKEND) \
-		$(BACKEND_OPTIONS) -o p4c-out/$(BACKEND) \
-		--p4runtime-file p4c-out/$(BACKEND)/fabric.p4info \
-		--p4runtime-format text fabric.p4
-
 clean:
 	rm -rf p4c-out/*
diff --git a/pipelines/fabric/src/main/resources/include/define.p4 b/pipelines/fabric/src/main/resources/include/define.p4
index f4e5b56..163c2ab 100644
--- a/pipelines/fabric/src/main/resources/include/define.p4
+++ b/pipelines/fabric/src/main/resources/include/define.p4
@@ -46,8 +46,8 @@
 
 const bit<4> IPV4_MIN_IHL = 5;
 
-#ifndef CPU_PORT
-const port_num_t CPU_PORT = 255;
+#ifndef _PKT_OUT_HDR_ANNOT_
+#define _PKT_OUT_HDR_ANNOT_
 #endif
 
 const fwd_type_t FWD_BRIDGING = 0;
diff --git a/pipelines/fabric/src/main/resources/include/header.p4 b/pipelines/fabric/src/main/resources/include/header.p4
index 0a0814e..7b61cec 100644
--- a/pipelines/fabric/src/main/resources/include/header.p4
+++ b/pipelines/fabric/src/main/resources/include/header.p4
@@ -25,6 +25,7 @@
     bit<7> _pad;
 }
 
+_PKT_OUT_HDR_ANNOT_
 @controller_header("packet_out")
 header packet_out_header_t {
     port_num_t egress_port;
diff --git a/pipelines/fabric/src/main/resources/p4c-out/bmv2/fabric-spgw.json b/pipelines/fabric/src/main/resources/p4c-out/bmv2/fabric-spgw.json
index 81b13e5..2e38cf5 100644
--- a/pipelines/fabric/src/main/resources/p4c-out/bmv2/fabric-spgw.json
+++ b/pipelines/fabric/src/main/resources/p4c-out/bmv2/fabric-spgw.json
@@ -1856,10 +1856,10 @@
             }
           ],
           "source_info" : {
-            "filename" : "include/control/../define.p4",
+            "filename" : "include/control/forwarding.p4",
             "line" : 50,
-            "column" : 28,
-            "source_fragment" : "255; ..."
+            "column" : 8,
+            "source_fragment" : "standard_metadata.egress_spec = 255"
           }
         }
       ]
@@ -6062,7 +6062,7 @@
             "filename" : "include/control/packetio.p4",
             "line" : 38,
             "column" : 12,
-            "source_fragment" : "standard_metadata.egress_port == CPU_PORT"
+            "source_fragment" : "standard_metadata.egress_port == 255"
           },
           "expression" : {
             "type" : "expression",
diff --git a/pipelines/fabric/src/main/resources/p4c-out/bmv2/fabric.json b/pipelines/fabric/src/main/resources/p4c-out/bmv2/fabric.json
index cdaefbc..228ff23 100644
--- a/pipelines/fabric/src/main/resources/p4c-out/bmv2/fabric.json
+++ b/pipelines/fabric/src/main/resources/p4c-out/bmv2/fabric.json
@@ -71,22 +71,8 @@
       ]
     },
     {
-      "name" : "ipv6_t",
-      "id" : 5,
-      "fields" : [
-        ["version", 4, false],
-        ["traffic_class", 8, false],
-        ["flow_label", 20, false],
-        ["payload_len", 16, false],
-        ["next_hdr", 8, false],
-        ["hop_limit", 8, false],
-        ["src_addr", 128, false],
-        ["dst_addr", 128, false]
-      ]
-    },
-    {
       "name" : "arp_t",
-      "id" : 6,
+      "id" : 5,
       "fields" : [
         ["hw_type", 16, false],
         ["proto_type", 16, false],
@@ -97,7 +83,7 @@
     },
     {
       "name" : "tcp_t",
-      "id" : 7,
+      "id" : 6,
       "fields" : [
         ["src_port", 16, false],
         ["dst_port", 16, false],
@@ -114,7 +100,7 @@
     },
     {
       "name" : "udp_t",
-      "id" : 8,
+      "id" : 7,
       "fields" : [
         ["src_port", 16, false],
         ["dst_port", 16, false],
@@ -124,7 +110,7 @@
     },
     {
       "name" : "icmp_t",
-      "id" : 9,
+      "id" : 8,
       "fields" : [
         ["icmp_type", 8, false],
         ["icmp_code", 8, false],
@@ -136,7 +122,7 @@
     },
     {
       "name" : "packet_out_header_t",
-      "id" : 10,
+      "id" : 9,
       "fields" : [
         ["egress_port", 9, false],
         ["_pad", 7, false]
@@ -144,7 +130,7 @@
     },
     {
       "name" : "packet_in_header_t",
-      "id" : 11,
+      "id" : 10,
       "fields" : [
         ["ingress_port", 9, false],
         ["_pad", 7, false]
@@ -152,7 +138,7 @@
     },
     {
       "name" : "standard_metadata",
-      "id" : 12,
+      "id" : 11,
       "fields" : [
         ["ingress_port", 9, false],
         ["egress_spec", 9, false],
@@ -220,50 +206,43 @@
       "pi_omit" : true
     },
     {
-      "name" : "ipv6",
-      "id" : 6,
-      "header_type" : "ipv6_t",
-      "metadata" : false,
-      "pi_omit" : true
-    },
-    {
       "name" : "arp",
-      "id" : 7,
+      "id" : 6,
       "header_type" : "arp_t",
       "metadata" : false,
       "pi_omit" : true
     },
     {
       "name" : "tcp",
-      "id" : 8,
+      "id" : 7,
       "header_type" : "tcp_t",
       "metadata" : false,
       "pi_omit" : true
     },
     {
       "name" : "udp",
-      "id" : 9,
+      "id" : 8,
       "header_type" : "udp_t",
       "metadata" : false,
       "pi_omit" : true
     },
     {
       "name" : "icmp",
-      "id" : 10,
+      "id" : 9,
       "header_type" : "icmp_t",
       "metadata" : false,
       "pi_omit" : true
     },
     {
       "name" : "packet_out",
-      "id" : 11,
+      "id" : 10,
       "header_type" : "packet_out_header_t",
       "metadata" : false,
       "pi_omit" : true
     },
     {
       "name" : "packet_in",
-      "id" : 12,
+      "id" : 11,
       "header_type" : "packet_in_header_t",
       "metadata" : false,
       "pi_omit" : true
@@ -694,7 +673,7 @@
       "id" : 0,
       "source_info" : {
         "filename" : "include/parser.p4",
-        "line" : 166,
+        "line" : 164,
         "column" : 8,
         "source_fragment" : "FabricDeparser"
       },
@@ -1396,10 +1375,10 @@
             }
           ],
           "source_info" : {
-            "filename" : "include/control/../define.p4",
+            "filename" : "include/control/forwarding.p4",
             "line" : 50,
-            "column" : 28,
-            "source_fragment" : "255; ..."
+            "column" : 8,
+            "source_fragment" : "standard_metadata.egress_spec = 255"
           }
         }
       ]
@@ -3635,7 +3614,7 @@
       "id" : 1,
       "source_info" : {
         "filename" : "fabric.p4",
-        "line" : 60,
+        "line" : 62,
         "column" : 8,
         "source_fragment" : "FabricEgress"
       },
@@ -3674,7 +3653,7 @@
             "filename" : "include/control/packetio.p4",
             "line" : 38,
             "column" : 12,
-            "source_fragment" : "standard_metadata.egress_port == CPU_PORT"
+            "source_fragment" : "standard_metadata.egress_port == 255"
           },
           "expression" : {
             "type" : "expression",