Avoid egress processing for controller packet-in/out in fabric.p4

Change-Id: If8ac129efd11a437054ed6b7178e167eff9c6e74
diff --git a/pipelines/fabric/src/main/resources/fabric.p4 b/pipelines/fabric/src/main/resources/fabric.p4
index 6153807..22ad209 100644
--- a/pipelines/fabric/src/main/resources/fabric.p4
+++ b/pipelines/fabric/src/main/resources/fabric.p4
@@ -41,7 +41,7 @@
 inout parsed_headers_t hdr,
 inout fabric_metadata_t fabric_metadata,
 inout standard_metadata_t standard_metadata) {
-    PacketIoIngress() packet_io_ingress;
+    PacketIoIngress() pkt_io_ingress;
     Filtering() filtering;
     Forwarding() forwarding;
     Next() next;
@@ -52,7 +52,7 @@
         spgw_normalizer.apply(hdr.gtpu.isValid(), hdr.gtpu_ipv4, hdr.gtpu_udp,
                               hdr.ipv4, hdr.udp, hdr.inner_ipv4, hdr.inner_udp);
 #endif // WITH_SPGW
-        packet_io_ingress.apply(hdr, fabric_metadata, standard_metadata);
+        pkt_io_ingress.apply(hdr, fabric_metadata, standard_metadata);
 #ifdef WITH_SPGW
 #ifdef WITH_SPGW_PCC_GATING
         fabric_metadata.spgw.l4_src_port = fabric_metadata.l4_src_port;
@@ -84,8 +84,8 @@
     EgressNextControl() egress_next;
 
     apply {
-        egress_next.apply(hdr, fabric_metadata, standard_metadata);
         pkt_io_egress.apply(hdr, fabric_metadata, standard_metadata);
+        egress_next.apply(hdr, fabric_metadata, standard_metadata);
 #ifdef WITH_SPGW
         spgw_egress.apply(hdr.ipv4, hdr.gtpu_ipv4, hdr.gtpu_udp, hdr.gtpu,
                           fabric_metadata.spgw, standard_metadata);
diff --git a/pipelines/fabric/src/main/resources/include/control/packetio.p4 b/pipelines/fabric/src/main/resources/include/control/packetio.p4
index fa447e7..1086dac 100644
--- a/pipelines/fabric/src/main/resources/include/control/packetio.p4
+++ b/pipelines/fabric/src/main/resources/include/control/packetio.p4
@@ -25,6 +25,7 @@
         if (hdr.packet_out.isValid()) {
             standard_metadata.egress_spec = hdr.packet_out.egress_port;
             hdr.packet_out.setInvalid();
+            fabric_metadata.is_controller_packet_out = _TRUE;
             exit;
         }
     }
@@ -39,6 +40,10 @@
         hdr.vlan_tag.setInvalid();
     }
     apply {
+        if (fabric_metadata.is_controller_packet_out == _TRUE) {
+            // No need to process through the rest of the pipeline.
+            exit;
+        }
         if (standard_metadata.egress_port == CPU_PORT) {
             if (hdr.vlan_tag.isValid() && fabric_metadata.pop_vlan_when_packet_in == _TRUE) {
                 pop_vlan();
@@ -50,6 +55,8 @@
             }
             hdr.packet_in.setValid();
             hdr.packet_in.ingress_port = standard_metadata.ingress_port;
+            // No need to process through the rest of the pipeline.
+            exit;
         }
     }
 }
diff --git a/pipelines/fabric/src/main/resources/include/header.p4 b/pipelines/fabric/src/main/resources/include/header.p4
index 25ac400..5591c11 100644
--- a/pipelines/fabric/src/main/resources/include/header.p4
+++ b/pipelines/fabric/src/main/resources/include/header.p4
@@ -269,6 +269,7 @@
     next_id_t next_id;
     _BOOL pop_vlan_when_packet_in;
     _BOOL is_multicast;
+    _BOOL is_controller_packet_out;
     _BOOL clone_to_cpu;
     bit<8> ip_proto;
     bit<16> l4_src_port;
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 8571db2..24977af 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
@@ -24,12 +24,13 @@
         ["fabric_metadata_t.next_id", 32, false],
         ["fabric_metadata_t.pop_vlan_when_packet_in", 1, false],
         ["fabric_metadata_t.is_multicast", 1, false],
+        ["fabric_metadata_t.is_controller_packet_out", 1, false],
         ["fabric_metadata_t.clone_to_cpu", 1, false],
         ["fabric_metadata_t.ip_proto", 8, false],
         ["fabric_metadata_t.l4_src_port", 16, false],
         ["fabric_metadata_t.l4_dst_port", 16, false],
         ["fabric_metadata_t.compute_checksum", 1, false],
-        ["_padding_2", 2, false]
+        ["_padding_2", 1, false]
       ]
     },
     {
@@ -4256,6 +4257,35 @@
             "column" : 12,
             "source_fragment" : "hdr.packet_out.setInvalid()"
           }
+        },
+        {
+          "op" : "assign",
+          "parameters" : [
+            {
+              "type" : "field",
+              "value" : ["scalars", "fabric_metadata_t.is_controller_packet_out"]
+            },
+            {
+              "type" : "expression",
+              "value" : {
+                "type" : "expression",
+                "value" : {
+                  "op" : "b2d",
+                  "left" : null,
+                  "right" : {
+                    "type" : "bool",
+                    "value" : true
+                  }
+                }
+              }
+            }
+          ],
+          "source_info" : {
+            "filename" : "include/control/packetio.p4",
+            "line" : 28,
+            "column" : 12,
+            "source_fragment" : "fabric_metadata.is_controller_packet_out = true"
+          }
         }
       ]
     },
@@ -11047,7 +11077,7 @@
           ],
           "source_info" : {
             "filename" : "include/control/packetio.p4",
-            "line" : 38,
+            "line" : 39,
             "column" : 8,
             "source_fragment" : "hdr.ethernet.ether_type = hdr.vlan_tag.ether_type"
           }
@@ -11062,7 +11092,7 @@
           ],
           "source_info" : {
             "filename" : "include/control/packetio.p4",
-            "line" : 39,
+            "line" : 40,
             "column" : 8,
             "source_fragment" : "hdr.vlan_tag.setInvalid()"
           }
@@ -11125,7 +11155,7 @@
           ],
           "source_info" : {
             "filename" : "include/control/packetio.p4",
-            "line" : 51,
+            "line" : 56,
             "column" : 12,
             "source_fragment" : "hdr.packet_in.setValid()"
           }
@@ -11144,7 +11174,7 @@
           ],
           "source_info" : {
             "filename" : "include/control/packetio.p4",
-            "line" : 52,
+            "line" : 57,
             "column" : 12,
             "source_fragment" : "hdr.packet_in.ingress_port = standard_metadata.ingress_port"
           }
@@ -13225,7 +13255,7 @@
       "init_table" : "node_76",
       "tables" : [
         {
-          "name" : "tbl_drop_now_0",
+          "name" : "tbl_pkt_io_egress_pop_vlan",
           "id" : 49,
           "key" : [],
           "match_type" : "exact",
@@ -13234,11 +13264,34 @@
           "with_counters" : false,
           "support_timeout" : false,
           "direct_meters" : null,
+          "action_ids" : [124],
+          "actions" : ["FabricEgress.pkt_io_egress.pop_vlan"],
+          "base_default_next" : "node_80",
+          "next_tables" : {
+            "FabricEgress.pkt_io_egress.pop_vlan" : "node_80"
+          },
+          "default_entry" : {
+            "action_id" : 124,
+            "action_const" : true,
+            "action_data" : [],
+            "action_entry_const" : true
+          }
+        },
+        {
+          "name" : "tbl_drop_now_0",
+          "id" : 50,
+          "key" : [],
+          "match_type" : "exact",
+          "type" : "simple",
+          "max_size" : 1024,
+          "with_counters" : false,
+          "support_timeout" : false,
+          "direct_meters" : null,
           "action_ids" : [80],
           "actions" : ["drop_now"],
-          "base_default_next" : "FabricEgress.egress_next.egress_vlan",
+          "base_default_next" : "tbl_act_31",
           "next_tables" : {
-            "drop_now" : "FabricEgress.egress_next.egress_vlan"
+            "drop_now" : "tbl_act_31"
           },
           "default_entry" : {
             "action_id" : 80,
@@ -13248,8 +13301,54 @@
           }
         },
         {
+          "name" : "tbl_act_31",
+          "id" : 51,
+          "key" : [],
+          "match_type" : "exact",
+          "type" : "simple",
+          "max_size" : 1024,
+          "with_counters" : false,
+          "support_timeout" : false,
+          "direct_meters" : null,
+          "action_ids" : [126],
+          "actions" : ["act_31"],
+          "base_default_next" : null,
+          "next_tables" : {
+            "act_31" : null
+          },
+          "default_entry" : {
+            "action_id" : 126,
+            "action_const" : true,
+            "action_data" : [],
+            "action_entry_const" : true
+          }
+        },
+        {
+          "name" : "tbl_drop_now_1",
+          "id" : 52,
+          "key" : [],
+          "match_type" : "exact",
+          "type" : "simple",
+          "max_size" : 1024,
+          "with_counters" : false,
+          "support_timeout" : false,
+          "direct_meters" : null,
+          "action_ids" : [81],
+          "actions" : ["drop_now"],
+          "base_default_next" : "FabricEgress.egress_next.egress_vlan",
+          "next_tables" : {
+            "drop_now" : "FabricEgress.egress_next.egress_vlan"
+          },
+          "default_entry" : {
+            "action_id" : 81,
+            "action_const" : true,
+            "action_data" : [],
+            "action_entry_const" : true
+          }
+        },
+        {
           "name" : "FabricEgress.egress_next.egress_vlan",
-          "id" : 50,
+          "id" : 53,
           "source_info" : {
             "filename" : "include/control/next.p4",
             "line" : 258,
@@ -13278,10 +13377,10 @@
           "direct_meters" : null,
           "action_ids" : [125, 79],
           "actions" : ["FabricEgress.egress_next.pop_vlan", "nop"],
-          "base_default_next" : "node_79",
+          "base_default_next" : "node_86",
           "next_tables" : {
-            "FabricEgress.egress_next.pop_vlan" : "node_79",
-            "nop" : "node_79"
+            "FabricEgress.egress_next.pop_vlan" : "node_86",
+            "nop" : "node_86"
           },
           "default_entry" : {
             "action_id" : 79,
@@ -13291,75 +13390,6 @@
           }
         },
         {
-          "name" : "tbl_pkt_io_egress_pop_vlan",
-          "id" : 51,
-          "key" : [],
-          "match_type" : "exact",
-          "type" : "simple",
-          "max_size" : 1024,
-          "with_counters" : false,
-          "support_timeout" : false,
-          "direct_meters" : null,
-          "action_ids" : [124],
-          "actions" : ["FabricEgress.pkt_io_egress.pop_vlan"],
-          "base_default_next" : "node_82",
-          "next_tables" : {
-            "FabricEgress.pkt_io_egress.pop_vlan" : "node_82"
-          },
-          "default_entry" : {
-            "action_id" : 124,
-            "action_const" : true,
-            "action_data" : [],
-            "action_entry_const" : true
-          }
-        },
-        {
-          "name" : "tbl_drop_now_1",
-          "id" : 52,
-          "key" : [],
-          "match_type" : "exact",
-          "type" : "simple",
-          "max_size" : 1024,
-          "with_counters" : false,
-          "support_timeout" : false,
-          "direct_meters" : null,
-          "action_ids" : [81],
-          "actions" : ["drop_now"],
-          "base_default_next" : "tbl_act_31",
-          "next_tables" : {
-            "drop_now" : "tbl_act_31"
-          },
-          "default_entry" : {
-            "action_id" : 81,
-            "action_const" : true,
-            "action_data" : [],
-            "action_entry_const" : true
-          }
-        },
-        {
-          "name" : "tbl_act_31",
-          "id" : 53,
-          "key" : [],
-          "match_type" : "exact",
-          "type" : "simple",
-          "max_size" : 1024,
-          "with_counters" : false,
-          "support_timeout" : false,
-          "direct_meters" : null,
-          "action_ids" : [126],
-          "actions" : ["act_31"],
-          "base_default_next" : "node_85",
-          "next_tables" : {
-            "act_31" : "node_85"
-          },
-          "default_entry" : {
-            "action_id" : 126,
-            "action_const" : true,
-            "action_data" : [],
-            "action_entry_const" : true
-          }
-        },
-        {
           "name" : "tbl_spgw_egress_gtpu_encap",
           "id" : 54,
           "key" : [],
@@ -13371,9 +13401,9 @@
           "direct_meters" : null,
           "action_ids" : [82],
           "actions" : ["FabricEgress.spgw_egress.gtpu_encap"],
-          "base_default_next" : "node_87",
+          "base_default_next" : "node_88",
           "next_tables" : {
-            "FabricEgress.spgw_egress.gtpu_encap" : "node_87"
+            "FabricEgress.spgw_egress.gtpu_encap" : "node_88"
           },
           "default_entry" : {
             "action_id" : 82,
@@ -13425,10 +13455,10 @@
           "direct_meters" : null,
           "action_ids" : [83, 74],
           "actions" : ["FabricEgress.process_int_source.int_source_dscp", "NoAction"],
-          "base_default_next" : "node_90",
+          "base_default_next" : "node_91",
           "next_tables" : {
-            "FabricEgress.process_int_source.int_source_dscp" : "node_90",
-            "NoAction" : "node_90"
+            "FabricEgress.process_int_source.int_source_dscp" : "node_91",
+            "NoAction" : "node_91"
           },
           "default_entry" : {
             "action_id" : 74,
@@ -13583,9 +13613,9 @@
           "direct_meters" : null,
           "action_ids" : [84],
           "actions" : ["FabricEgress.process_int_transit.int_update_total_hop_cnt"],
-          "base_default_next" : "node_95",
+          "base_default_next" : "node_96",
           "next_tables" : {
-            "FabricEgress.process_int_transit.int_update_total_hop_cnt" : "node_95"
+            "FabricEgress.process_int_transit.int_update_total_hop_cnt" : "node_96"
           },
           "default_entry" : {
             "action_id" : 84,
@@ -13606,9 +13636,9 @@
           "direct_meters" : null,
           "action_ids" : [118],
           "actions" : ["FabricEgress.process_int_outer_encap.int_update_ipv4"],
-          "base_default_next" : "node_97",
+          "base_default_next" : "node_98",
           "next_tables" : {
-            "FabricEgress.process_int_outer_encap.int_update_ipv4" : "node_97"
+            "FabricEgress.process_int_outer_encap.int_update_ipv4" : "node_98"
           },
           "default_entry" : {
             "action_id" : 118,
@@ -13629,9 +13659,9 @@
           "direct_meters" : null,
           "action_ids" : [119],
           "actions" : ["FabricEgress.process_int_outer_encap.int_update_udp"],
-          "base_default_next" : "node_99",
+          "base_default_next" : "node_100",
           "next_tables" : {
-            "FabricEgress.process_int_outer_encap.int_update_udp" : "node_99"
+            "FabricEgress.process_int_outer_encap.int_update_udp" : "node_100"
           },
           "default_entry" : {
             "action_id" : 119,
@@ -13652,9 +13682,9 @@
           "direct_meters" : null,
           "action_ids" : [120],
           "actions" : ["FabricEgress.process_int_outer_encap.int_update_shim"],
-          "base_default_next" : "node_101",
+          "base_default_next" : "node_102",
           "next_tables" : {
-            "FabricEgress.process_int_outer_encap.int_update_shim" : "node_101"
+            "FabricEgress.process_int_outer_encap.int_update_shim" : "node_102"
           },
           "default_entry" : {
             "action_id" : 120,
@@ -13681,10 +13711,10 @@
           "direct_meters" : null,
           "action_ids" : [121, 78],
           "actions" : ["FabricEgress.process_int_report.do_report_encapsulation", "NoAction"],
-          "base_default_next" : "node_103",
+          "base_default_next" : "node_104",
           "next_tables" : {
-            "FabricEgress.process_int_report.do_report_encapsulation" : "node_103",
-            "NoAction" : "node_103"
+            "FabricEgress.process_int_report.do_report_encapsulation" : "node_104",
+            "NoAction" : "node_104"
           },
           "default_entry" : {
             "action_id" : 78,
@@ -13746,61 +13776,41 @@
           "name" : "node_76",
           "id" : 23,
           "source_info" : {
-            "filename" : "include/control/next.p4",
-            "line" : 272,
+            "filename" : "include/control/packetio.p4",
+            "line" : 43,
             "column" : 12,
-            "source_fragment" : "fabric_metadata.is_multicast == true ..."
+            "source_fragment" : "fabric_metadata.is_controller_packet_out == true"
           },
           "expression" : {
             "type" : "expression",
             "value" : {
-              "op" : "and",
+              "op" : "==",
               "left" : {
                 "type" : "expression",
                 "value" : {
-                  "op" : "==",
-                  "left" : {
-                    "type" : "expression",
-                    "value" : {
-                      "op" : "d2b",
-                      "left" : null,
-                      "right" : {
-                        "type" : "field",
-                        "value" : ["scalars", "fabric_metadata_t.is_multicast"]
-                      }
-                    }
-                  },
+                  "op" : "d2b",
+                  "left" : null,
                   "right" : {
-                    "type" : "bool",
-                    "value" : true
+                    "type" : "field",
+                    "value" : ["scalars", "fabric_metadata_t.is_controller_packet_out"]
                   }
                 }
               },
               "right" : {
-                "type" : "expression",
-                "value" : {
-                  "op" : "==",
-                  "left" : {
-                    "type" : "field",
-                    "value" : ["standard_metadata", "ingress_port"]
-                  },
-                  "right" : {
-                    "type" : "field",
-                    "value" : ["standard_metadata", "egress_port"]
-                  }
-                }
+                "type" : "bool",
+                "value" : true
               }
             }
           },
-          "true_next" : "tbl_drop_now_0",
-          "false_next" : "FabricEgress.egress_next.egress_vlan"
+          "true_next" : null,
+          "false_next" : "node_77"
         },
         {
-          "name" : "node_79",
+          "name" : "node_77",
           "id" : 24,
           "source_info" : {
             "filename" : "include/control/packetio.p4",
-            "line" : 42,
+            "line" : 47,
             "column" : 12,
             "source_fragment" : "standard_metadata.egress_port == 255"
           },
@@ -13818,15 +13828,15 @@
               }
             }
           },
-          "true_next" : "node_80",
-          "false_next" : "node_85"
+          "true_next" : "node_78",
+          "false_next" : "node_83"
         },
         {
-          "name" : "node_80",
+          "name" : "node_78",
           "id" : 25,
           "source_info" : {
             "filename" : "include/control/packetio.p4",
-            "line" : 43,
+            "line" : 48,
             "column" : 16,
             "source_fragment" : "hdr.vlan_tag.isValid() && fabric_metadata.pop_vlan_when_packet_in == true"
           },
@@ -13869,14 +13879,14 @@
             }
           },
           "true_next" : "tbl_pkt_io_egress_pop_vlan",
-          "false_next" : "node_82"
+          "false_next" : "node_80"
         },
         {
-          "name" : "node_82",
+          "name" : "node_80",
           "id" : 26,
           "source_info" : {
             "filename" : "include/control/packetio.p4",
-            "line" : 46,
+            "line" : 51,
             "column" : 16,
             "source_fragment" : "fabric_metadata.is_multicast == true && ..."
           },
@@ -13928,13 +13938,66 @@
               }
             }
           },
-          "true_next" : "tbl_drop_now_1",
+          "true_next" : "tbl_drop_now_0",
           "false_next" : "tbl_act_31"
         },
         {
-          "name" : "node_85",
+          "name" : "node_83",
           "id" : 27,
           "source_info" : {
+            "filename" : "include/control/next.p4",
+            "line" : 272,
+            "column" : 12,
+            "source_fragment" : "fabric_metadata.is_multicast == true ..."
+          },
+          "expression" : {
+            "type" : "expression",
+            "value" : {
+              "op" : "and",
+              "left" : {
+                "type" : "expression",
+                "value" : {
+                  "op" : "==",
+                  "left" : {
+                    "type" : "expression",
+                    "value" : {
+                      "op" : "d2b",
+                      "left" : null,
+                      "right" : {
+                        "type" : "field",
+                        "value" : ["scalars", "fabric_metadata_t.is_multicast"]
+                      }
+                    }
+                  },
+                  "right" : {
+                    "type" : "bool",
+                    "value" : true
+                  }
+                }
+              },
+              "right" : {
+                "type" : "expression",
+                "value" : {
+                  "op" : "==",
+                  "left" : {
+                    "type" : "field",
+                    "value" : ["standard_metadata", "ingress_port"]
+                  },
+                  "right" : {
+                    "type" : "field",
+                    "value" : ["standard_metadata", "egress_port"]
+                  }
+                }
+              }
+            }
+          },
+          "true_next" : "tbl_drop_now_1",
+          "false_next" : "FabricEgress.egress_next.egress_vlan"
+        },
+        {
+          "name" : "node_86",
+          "id" : 28,
+          "source_info" : {
             "filename" : "include/spgw.p4",
             "line" : 221,
             "column" : 12,
@@ -13955,11 +14018,11 @@
             }
           },
           "true_next" : "tbl_spgw_egress_gtpu_encap",
-          "false_next" : "node_87"
+          "false_next" : "node_88"
         },
         {
-          "name" : "node_87",
-          "id" : 28,
+          "name" : "node_88",
+          "id" : 29,
           "source_info" : {
             "filename" : "fabric.p4",
             "line" : 94,
@@ -14035,11 +14098,11 @@
             }
           },
           "false_next" : null,
-          "true_next" : "node_88"
+          "true_next" : "node_89"
         },
         {
-          "name" : "node_88",
-          "id" : 29,
+          "name" : "node_89",
+          "id" : 30,
           "source_info" : {
             "filename" : "fabric.p4",
             "line" : 97,
@@ -14061,11 +14124,11 @@
             }
           },
           "true_next" : "FabricEgress.process_int_source.tb_int_source",
-          "false_next" : "node_90"
+          "false_next" : "node_91"
         },
         {
-          "name" : "node_90",
-          "id" : 30,
+          "name" : "node_91",
+          "id" : 31,
           "source_info" : {
             "filename" : "fabric.p4",
             "line" : 100,
@@ -14087,8 +14150,8 @@
           "true_next" : "FabricEgress.process_int_transit.tb_int_insert"
         },
         {
-          "name" : "node_95",
-          "id" : 31,
+          "name" : "node_96",
+          "id" : 32,
           "source_info" : {
             "filename" : "include/int_transit.p4",
             "line" : 314,
@@ -14107,11 +14170,11 @@
             }
           },
           "true_next" : "tbl_process_int_outer_encap_int_update_ipv4",
-          "false_next" : "node_97"
+          "false_next" : "node_98"
         },
         {
-          "name" : "node_97",
-          "id" : 32,
+          "name" : "node_98",
+          "id" : 33,
           "source_info" : {
             "filename" : "include/int_transit.p4",
             "line" : 317,
@@ -14130,11 +14193,11 @@
             }
           },
           "true_next" : "tbl_process_int_outer_encap_int_update_udp",
-          "false_next" : "node_99"
+          "false_next" : "node_100"
         },
         {
-          "name" : "node_99",
-          "id" : 33,
+          "name" : "node_100",
+          "id" : 34,
           "source_info" : {
             "filename" : "include/int_transit.p4",
             "line" : 320,
@@ -14153,11 +14216,11 @@
             }
           },
           "true_next" : "tbl_process_int_outer_encap_int_update_shim",
-          "false_next" : "node_101"
+          "false_next" : "node_102"
         },
         {
-          "name" : "node_101",
-          "id" : 34,
+          "name" : "node_102",
+          "id" : 35,
           "source_info" : {
             "filename" : "fabric.p4",
             "line" : 104,
@@ -14179,11 +14242,11 @@
             }
           },
           "true_next" : "FabricEgress.process_int_report.tb_generate_report",
-          "false_next" : "node_103"
+          "false_next" : "node_104"
         },
         {
-          "name" : "node_103",
-          "id" : 35,
+          "name" : "node_104",
+          "id" : 36,
           "source_info" : {
             "filename" : "fabric.p4",
             "line" : 108,
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 2885ebd..62d34dd 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
@@ -19,12 +19,13 @@
         ["fabric_metadata_t.next_id", 32, false],
         ["fabric_metadata_t.pop_vlan_when_packet_in", 1, false],
         ["fabric_metadata_t.is_multicast", 1, false],
+        ["fabric_metadata_t.is_controller_packet_out", 1, false],
         ["fabric_metadata_t.clone_to_cpu", 1, false],
         ["fabric_metadata_t.ip_proto", 8, false],
         ["fabric_metadata_t.l4_src_port", 16, false],
         ["fabric_metadata_t.l4_dst_port", 16, false],
         ["fabric_metadata_t.compute_checksum", 1, false],
-        ["_padding_1", 6, false]
+        ["_padding_1", 5, false]
       ]
     },
     {
@@ -3412,6 +3413,35 @@
             "column" : 12,
             "source_fragment" : "hdr.packet_out.setInvalid()"
           }
+        },
+        {
+          "op" : "assign",
+          "parameters" : [
+            {
+              "type" : "field",
+              "value" : ["scalars", "fabric_metadata_t.is_controller_packet_out"]
+            },
+            {
+              "type" : "expression",
+              "value" : {
+                "type" : "expression",
+                "value" : {
+                  "op" : "b2d",
+                  "left" : null,
+                  "right" : {
+                    "type" : "bool",
+                    "value" : true
+                  }
+                }
+              }
+            }
+          ],
+          "source_info" : {
+            "filename" : "include/control/packetio.p4",
+            "line" : 28,
+            "column" : 12,
+            "source_fragment" : "fabric_metadata.is_controller_packet_out = true"
+          }
         }
       ]
     },
@@ -9279,7 +9309,7 @@
           ],
           "source_info" : {
             "filename" : "include/control/packetio.p4",
-            "line" : 38,
+            "line" : 39,
             "column" : 8,
             "source_fragment" : "hdr.ethernet.ether_type = hdr.vlan_tag.ether_type"
           }
@@ -9294,7 +9324,7 @@
           ],
           "source_info" : {
             "filename" : "include/control/packetio.p4",
-            "line" : 39,
+            "line" : 40,
             "column" : 8,
             "source_fragment" : "hdr.vlan_tag.setInvalid()"
           }
@@ -9357,7 +9387,7 @@
           ],
           "source_info" : {
             "filename" : "include/control/packetio.p4",
-            "line" : 51,
+            "line" : 56,
             "column" : 12,
             "source_fragment" : "hdr.packet_in.setValid()"
           }
@@ -9376,7 +9406,7 @@
           ],
           "source_info" : {
             "filename" : "include/control/packetio.p4",
-            "line" : 52,
+            "line" : 57,
             "column" : 12,
             "source_fragment" : "hdr.packet_in.ingress_port = standard_metadata.ingress_port"
           }
@@ -10735,7 +10765,7 @@
       "init_table" : "node_47",
       "tables" : [
         {
-          "name" : "tbl_drop_now",
+          "name" : "tbl_pkt_io_egress_pop_vlan",
           "id" : 29,
           "key" : [],
           "match_type" : "exact",
@@ -10744,11 +10774,34 @@
           "with_counters" : false,
           "support_timeout" : false,
           "direct_meters" : null,
+          "action_ids" : [101],
+          "actions" : ["FabricEgress.pkt_io_egress.pop_vlan"],
+          "base_default_next" : "node_51",
+          "next_tables" : {
+            "FabricEgress.pkt_io_egress.pop_vlan" : "node_51"
+          },
+          "default_entry" : {
+            "action_id" : 101,
+            "action_const" : true,
+            "action_data" : [],
+            "action_entry_const" : true
+          }
+        },
+        {
+          "name" : "tbl_drop_now",
+          "id" : 30,
+          "key" : [],
+          "match_type" : "exact",
+          "type" : "simple",
+          "max_size" : 1024,
+          "with_counters" : false,
+          "support_timeout" : false,
+          "direct_meters" : null,
           "action_ids" : [58],
           "actions" : ["drop_now"],
-          "base_default_next" : "FabricEgress.egress_next.egress_vlan",
+          "base_default_next" : "tbl_act_16",
           "next_tables" : {
-            "drop_now" : "FabricEgress.egress_next.egress_vlan"
+            "drop_now" : "tbl_act_16"
           },
           "default_entry" : {
             "action_id" : 58,
@@ -10758,8 +10811,54 @@
           }
         },
         {
+          "name" : "tbl_act_16",
+          "id" : 31,
+          "key" : [],
+          "match_type" : "exact",
+          "type" : "simple",
+          "max_size" : 1024,
+          "with_counters" : false,
+          "support_timeout" : false,
+          "direct_meters" : null,
+          "action_ids" : [103],
+          "actions" : ["act_16"],
+          "base_default_next" : null,
+          "next_tables" : {
+            "act_16" : null
+          },
+          "default_entry" : {
+            "action_id" : 103,
+            "action_const" : true,
+            "action_data" : [],
+            "action_entry_const" : true
+          }
+        },
+        {
+          "name" : "tbl_drop_now_0",
+          "id" : 32,
+          "key" : [],
+          "match_type" : "exact",
+          "type" : "simple",
+          "max_size" : 1024,
+          "with_counters" : false,
+          "support_timeout" : false,
+          "direct_meters" : null,
+          "action_ids" : [59],
+          "actions" : ["drop_now"],
+          "base_default_next" : "FabricEgress.egress_next.egress_vlan",
+          "next_tables" : {
+            "drop_now" : "FabricEgress.egress_next.egress_vlan"
+          },
+          "default_entry" : {
+            "action_id" : 59,
+            "action_const" : true,
+            "action_data" : [],
+            "action_entry_const" : true
+          }
+        },
+        {
           "name" : "FabricEgress.egress_next.egress_vlan",
-          "id" : 30,
+          "id" : 33,
           "source_info" : {
             "filename" : "include/control/next.p4",
             "line" : 258,
@@ -10788,10 +10887,10 @@
           "direct_meters" : null,
           "action_ids" : [102, 57],
           "actions" : ["FabricEgress.egress_next.pop_vlan", "nop"],
-          "base_default_next" : "node_50",
+          "base_default_next" : "node_57",
           "next_tables" : {
-            "FabricEgress.egress_next.pop_vlan" : "node_50",
-            "nop" : "node_50"
+            "FabricEgress.egress_next.pop_vlan" : "node_57",
+            "nop" : "node_57"
           },
           "default_entry" : {
             "action_id" : 57,
@@ -10801,75 +10900,6 @@
           }
         },
         {
-          "name" : "tbl_pkt_io_egress_pop_vlan",
-          "id" : 31,
-          "key" : [],
-          "match_type" : "exact",
-          "type" : "simple",
-          "max_size" : 1024,
-          "with_counters" : false,
-          "support_timeout" : false,
-          "direct_meters" : null,
-          "action_ids" : [101],
-          "actions" : ["FabricEgress.pkt_io_egress.pop_vlan"],
-          "base_default_next" : "node_53",
-          "next_tables" : {
-            "FabricEgress.pkt_io_egress.pop_vlan" : "node_53"
-          },
-          "default_entry" : {
-            "action_id" : 101,
-            "action_const" : true,
-            "action_data" : [],
-            "action_entry_const" : true
-          }
-        },
-        {
-          "name" : "tbl_drop_now_0",
-          "id" : 32,
-          "key" : [],
-          "match_type" : "exact",
-          "type" : "simple",
-          "max_size" : 1024,
-          "with_counters" : false,
-          "support_timeout" : false,
-          "direct_meters" : null,
-          "action_ids" : [59],
-          "actions" : ["drop_now"],
-          "base_default_next" : "tbl_act_16",
-          "next_tables" : {
-            "drop_now" : "tbl_act_16"
-          },
-          "default_entry" : {
-            "action_id" : 59,
-            "action_const" : true,
-            "action_data" : [],
-            "action_entry_const" : true
-          }
-        },
-        {
-          "name" : "tbl_act_16",
-          "id" : 33,
-          "key" : [],
-          "match_type" : "exact",
-          "type" : "simple",
-          "max_size" : 1024,
-          "with_counters" : false,
-          "support_timeout" : false,
-          "direct_meters" : null,
-          "action_ids" : [103],
-          "actions" : ["act_16"],
-          "base_default_next" : "node_56",
-          "next_tables" : {
-            "act_16" : "node_56"
-          },
-          "default_entry" : {
-            "action_id" : 103,
-            "action_const" : true,
-            "action_data" : [],
-            "action_entry_const" : true
-          }
-        },
-        {
           "name" : "FabricEgress.process_int_source.tb_int_source",
           "id" : 34,
           "source_info" : {
@@ -10912,10 +10942,10 @@
           "direct_meters" : null,
           "action_ids" : [60, 52],
           "actions" : ["FabricEgress.process_int_source.int_source_dscp", "NoAction"],
-          "base_default_next" : "node_59",
+          "base_default_next" : "node_60",
           "next_tables" : {
-            "FabricEgress.process_int_source.int_source_dscp" : "node_59",
-            "NoAction" : "node_59"
+            "FabricEgress.process_int_source.int_source_dscp" : "node_60",
+            "NoAction" : "node_60"
           },
           "default_entry" : {
             "action_id" : 52,
@@ -11070,9 +11100,9 @@
           "direct_meters" : null,
           "action_ids" : [61],
           "actions" : ["FabricEgress.process_int_transit.int_update_total_hop_cnt"],
-          "base_default_next" : "node_64",
+          "base_default_next" : "node_65",
           "next_tables" : {
-            "FabricEgress.process_int_transit.int_update_total_hop_cnt" : "node_64"
+            "FabricEgress.process_int_transit.int_update_total_hop_cnt" : "node_65"
           },
           "default_entry" : {
             "action_id" : 61,
@@ -11093,9 +11123,9 @@
           "direct_meters" : null,
           "action_ids" : [95],
           "actions" : ["FabricEgress.process_int_outer_encap.int_update_ipv4"],
-          "base_default_next" : "node_66",
+          "base_default_next" : "node_67",
           "next_tables" : {
-            "FabricEgress.process_int_outer_encap.int_update_ipv4" : "node_66"
+            "FabricEgress.process_int_outer_encap.int_update_ipv4" : "node_67"
           },
           "default_entry" : {
             "action_id" : 95,
@@ -11116,9 +11146,9 @@
           "direct_meters" : null,
           "action_ids" : [96],
           "actions" : ["FabricEgress.process_int_outer_encap.int_update_udp"],
-          "base_default_next" : "node_68",
+          "base_default_next" : "node_69",
           "next_tables" : {
-            "FabricEgress.process_int_outer_encap.int_update_udp" : "node_68"
+            "FabricEgress.process_int_outer_encap.int_update_udp" : "node_69"
           },
           "default_entry" : {
             "action_id" : 96,
@@ -11139,9 +11169,9 @@
           "direct_meters" : null,
           "action_ids" : [97],
           "actions" : ["FabricEgress.process_int_outer_encap.int_update_shim"],
-          "base_default_next" : "node_70",
+          "base_default_next" : "node_71",
           "next_tables" : {
-            "FabricEgress.process_int_outer_encap.int_update_shim" : "node_70"
+            "FabricEgress.process_int_outer_encap.int_update_shim" : "node_71"
           },
           "default_entry" : {
             "action_id" : 97,
@@ -11168,10 +11198,10 @@
           "direct_meters" : null,
           "action_ids" : [98, 56],
           "actions" : ["FabricEgress.process_int_report.do_report_encapsulation", "NoAction"],
-          "base_default_next" : "node_72",
+          "base_default_next" : "node_73",
           "next_tables" : {
-            "FabricEgress.process_int_report.do_report_encapsulation" : "node_72",
-            "NoAction" : "node_72"
+            "FabricEgress.process_int_report.do_report_encapsulation" : "node_73",
+            "NoAction" : "node_73"
           },
           "default_entry" : {
             "action_id" : 56,
@@ -11233,61 +11263,41 @@
           "name" : "node_47",
           "id" : 14,
           "source_info" : {
-            "filename" : "include/control/next.p4",
-            "line" : 272,
+            "filename" : "include/control/packetio.p4",
+            "line" : 43,
             "column" : 12,
-            "source_fragment" : "fabric_metadata.is_multicast == true ..."
+            "source_fragment" : "fabric_metadata.is_controller_packet_out == true"
           },
           "expression" : {
             "type" : "expression",
             "value" : {
-              "op" : "and",
+              "op" : "==",
               "left" : {
                 "type" : "expression",
                 "value" : {
-                  "op" : "==",
-                  "left" : {
-                    "type" : "expression",
-                    "value" : {
-                      "op" : "d2b",
-                      "left" : null,
-                      "right" : {
-                        "type" : "field",
-                        "value" : ["scalars", "fabric_metadata_t.is_multicast"]
-                      }
-                    }
-                  },
+                  "op" : "d2b",
+                  "left" : null,
                   "right" : {
-                    "type" : "bool",
-                    "value" : true
+                    "type" : "field",
+                    "value" : ["scalars", "fabric_metadata_t.is_controller_packet_out"]
                   }
                 }
               },
               "right" : {
-                "type" : "expression",
-                "value" : {
-                  "op" : "==",
-                  "left" : {
-                    "type" : "field",
-                    "value" : ["standard_metadata", "ingress_port"]
-                  },
-                  "right" : {
-                    "type" : "field",
-                    "value" : ["standard_metadata", "egress_port"]
-                  }
-                }
+                "type" : "bool",
+                "value" : true
               }
             }
           },
-          "true_next" : "tbl_drop_now",
-          "false_next" : "FabricEgress.egress_next.egress_vlan"
+          "true_next" : null,
+          "false_next" : "node_48"
         },
         {
-          "name" : "node_50",
+          "name" : "node_48",
           "id" : 15,
           "source_info" : {
             "filename" : "include/control/packetio.p4",
-            "line" : 42,
+            "line" : 47,
             "column" : 12,
             "source_fragment" : "standard_metadata.egress_port == 255"
           },
@@ -11305,15 +11315,15 @@
               }
             }
           },
-          "true_next" : "node_51",
-          "false_next" : "node_56"
+          "true_next" : "node_49",
+          "false_next" : "node_54"
         },
         {
-          "name" : "node_51",
+          "name" : "node_49",
           "id" : 16,
           "source_info" : {
             "filename" : "include/control/packetio.p4",
-            "line" : 43,
+            "line" : 48,
             "column" : 16,
             "source_fragment" : "hdr.vlan_tag.isValid() && fabric_metadata.pop_vlan_when_packet_in == true"
           },
@@ -11356,14 +11366,14 @@
             }
           },
           "true_next" : "tbl_pkt_io_egress_pop_vlan",
-          "false_next" : "node_53"
+          "false_next" : "node_51"
         },
         {
-          "name" : "node_53",
+          "name" : "node_51",
           "id" : 17,
           "source_info" : {
             "filename" : "include/control/packetio.p4",
-            "line" : 46,
+            "line" : 51,
             "column" : 16,
             "source_fragment" : "fabric_metadata.is_multicast == true && ..."
           },
@@ -11415,13 +11425,66 @@
               }
             }
           },
-          "true_next" : "tbl_drop_now_0",
+          "true_next" : "tbl_drop_now",
           "false_next" : "tbl_act_16"
         },
         {
-          "name" : "node_56",
+          "name" : "node_54",
           "id" : 18,
           "source_info" : {
+            "filename" : "include/control/next.p4",
+            "line" : 272,
+            "column" : 12,
+            "source_fragment" : "fabric_metadata.is_multicast == true ..."
+          },
+          "expression" : {
+            "type" : "expression",
+            "value" : {
+              "op" : "and",
+              "left" : {
+                "type" : "expression",
+                "value" : {
+                  "op" : "==",
+                  "left" : {
+                    "type" : "expression",
+                    "value" : {
+                      "op" : "d2b",
+                      "left" : null,
+                      "right" : {
+                        "type" : "field",
+                        "value" : ["scalars", "fabric_metadata_t.is_multicast"]
+                      }
+                    }
+                  },
+                  "right" : {
+                    "type" : "bool",
+                    "value" : true
+                  }
+                }
+              },
+              "right" : {
+                "type" : "expression",
+                "value" : {
+                  "op" : "==",
+                  "left" : {
+                    "type" : "field",
+                    "value" : ["standard_metadata", "ingress_port"]
+                  },
+                  "right" : {
+                    "type" : "field",
+                    "value" : ["standard_metadata", "egress_port"]
+                  }
+                }
+              }
+            }
+          },
+          "true_next" : "tbl_drop_now_0",
+          "false_next" : "FabricEgress.egress_next.egress_vlan"
+        },
+        {
+          "name" : "node_57",
+          "id" : 19,
+          "source_info" : {
             "filename" : "fabric.p4",
             "line" : 94,
             "column" : 12,
@@ -11496,11 +11559,11 @@
             }
           },
           "false_next" : null,
-          "true_next" : "node_57"
+          "true_next" : "node_58"
         },
         {
-          "name" : "node_57",
-          "id" : 19,
+          "name" : "node_58",
+          "id" : 20,
           "source_info" : {
             "filename" : "fabric.p4",
             "line" : 97,
@@ -11522,11 +11585,11 @@
             }
           },
           "true_next" : "FabricEgress.process_int_source.tb_int_source",
-          "false_next" : "node_59"
+          "false_next" : "node_60"
         },
         {
-          "name" : "node_59",
-          "id" : 20,
+          "name" : "node_60",
+          "id" : 21,
           "source_info" : {
             "filename" : "fabric.p4",
             "line" : 100,
@@ -11548,8 +11611,8 @@
           "true_next" : "FabricEgress.process_int_transit.tb_int_insert"
         },
         {
-          "name" : "node_64",
-          "id" : 21,
+          "name" : "node_65",
+          "id" : 22,
           "source_info" : {
             "filename" : "include/int_transit.p4",
             "line" : 314,
@@ -11568,11 +11631,11 @@
             }
           },
           "true_next" : "tbl_process_int_outer_encap_int_update_ipv4",
-          "false_next" : "node_66"
+          "false_next" : "node_67"
         },
         {
-          "name" : "node_66",
-          "id" : 22,
+          "name" : "node_67",
+          "id" : 23,
           "source_info" : {
             "filename" : "include/int_transit.p4",
             "line" : 317,
@@ -11591,11 +11654,11 @@
             }
           },
           "true_next" : "tbl_process_int_outer_encap_int_update_udp",
-          "false_next" : "node_68"
+          "false_next" : "node_69"
         },
         {
-          "name" : "node_68",
-          "id" : 23,
+          "name" : "node_69",
+          "id" : 24,
           "source_info" : {
             "filename" : "include/int_transit.p4",
             "line" : 320,
@@ -11614,11 +11677,11 @@
             }
           },
           "true_next" : "tbl_process_int_outer_encap_int_update_shim",
-          "false_next" : "node_70"
+          "false_next" : "node_71"
         },
         {
-          "name" : "node_70",
-          "id" : 24,
+          "name" : "node_71",
+          "id" : 25,
           "source_info" : {
             "filename" : "fabric.p4",
             "line" : 104,
@@ -11640,11 +11703,11 @@
             }
           },
           "true_next" : "FabricEgress.process_int_report.tb_generate_report",
-          "false_next" : "node_72"
+          "false_next" : "node_73"
         },
         {
-          "name" : "node_72",
-          "id" : 25,
+          "name" : "node_73",
+          "id" : 26,
           "source_info" : {
             "filename" : "fabric.p4",
             "line" : 108,
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 9d273d2..2f3beb2 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
@@ -21,11 +21,12 @@
         ["fabric_metadata_t.next_id", 32, false],
         ["fabric_metadata_t.pop_vlan_when_packet_in", 1, false],
         ["fabric_metadata_t.is_multicast", 1, false],
+        ["fabric_metadata_t.is_controller_packet_out", 1, false],
         ["fabric_metadata_t.clone_to_cpu", 1, false],
         ["fabric_metadata_t.ip_proto", 8, false],
         ["fabric_metadata_t.l4_src_port", 16, false],
         ["fabric_metadata_t.l4_dst_port", 16, false],
-        ["_padding_1", 5, false]
+        ["_padding_1", 4, false]
       ]
     },
     {
@@ -3343,6 +3344,35 @@
             "column" : 12,
             "source_fragment" : "hdr.packet_out.setInvalid()"
           }
+        },
+        {
+          "op" : "assign",
+          "parameters" : [
+            {
+              "type" : "field",
+              "value" : ["scalars", "fabric_metadata_t.is_controller_packet_out"]
+            },
+            {
+              "type" : "expression",
+              "value" : {
+                "type" : "expression",
+                "value" : {
+                  "op" : "b2d",
+                  "left" : null,
+                  "right" : {
+                    "type" : "bool",
+                    "value" : true
+                  }
+                }
+              }
+            }
+          ],
+          "source_info" : {
+            "filename" : "include/control/packetio.p4",
+            "line" : 28,
+            "column" : 12,
+            "source_fragment" : "fabric_metadata.is_controller_packet_out = true"
+          }
         }
       ]
     },
@@ -4823,7 +4853,7 @@
           ],
           "source_info" : {
             "filename" : "include/control/packetio.p4",
-            "line" : 38,
+            "line" : 39,
             "column" : 8,
             "source_fragment" : "hdr.ethernet.ether_type = hdr.vlan_tag.ether_type"
           }
@@ -4838,7 +4868,7 @@
           ],
           "source_info" : {
             "filename" : "include/control/packetio.p4",
-            "line" : 39,
+            "line" : 40,
             "column" : 8,
             "source_fragment" : "hdr.vlan_tag.setInvalid()"
           }
@@ -4901,7 +4931,7 @@
           ],
           "source_info" : {
             "filename" : "include/control/packetio.p4",
-            "line" : 51,
+            "line" : 56,
             "column" : 12,
             "source_fragment" : "hdr.packet_in.setValid()"
           }
@@ -4920,7 +4950,7 @@
           ],
           "source_info" : {
             "filename" : "include/control/packetio.p4",
-            "line" : 52,
+            "line" : 57,
             "column" : 12,
             "source_fragment" : "hdr.packet_in.ingress_port = standard_metadata.ingress_port"
           }
@@ -6769,7 +6799,7 @@
       "init_table" : "node_68",
       "tables" : [
         {
-          "name" : "tbl_drop_now_0",
+          "name" : "tbl_pkt_io_egress_pop_vlan",
           "id" : 44,
           "key" : [],
           "match_type" : "exact",
@@ -6778,11 +6808,34 @@
           "with_counters" : false,
           "support_timeout" : false,
           "direct_meters" : null,
+          "action_ids" : [70],
+          "actions" : ["FabricEgress.pkt_io_egress.pop_vlan"],
+          "base_default_next" : "node_72",
+          "next_tables" : {
+            "FabricEgress.pkt_io_egress.pop_vlan" : "node_72"
+          },
+          "default_entry" : {
+            "action_id" : 70,
+            "action_const" : true,
+            "action_data" : [],
+            "action_entry_const" : true
+          }
+        },
+        {
+          "name" : "tbl_drop_now_0",
+          "id" : 45,
+          "key" : [],
+          "match_type" : "exact",
+          "type" : "simple",
+          "max_size" : 1024,
+          "with_counters" : false,
+          "support_timeout" : false,
+          "direct_meters" : null,
           "action_ids" : [67],
           "actions" : ["drop_now"],
-          "base_default_next" : "FabricEgress.egress_next.egress_vlan",
+          "base_default_next" : "tbl_act_29",
           "next_tables" : {
-            "drop_now" : "FabricEgress.egress_next.egress_vlan"
+            "drop_now" : "tbl_act_29"
           },
           "default_entry" : {
             "action_id" : 67,
@@ -6792,8 +6845,54 @@
           }
         },
         {
+          "name" : "tbl_act_29",
+          "id" : 46,
+          "key" : [],
+          "match_type" : "exact",
+          "type" : "simple",
+          "max_size" : 1024,
+          "with_counters" : false,
+          "support_timeout" : false,
+          "direct_meters" : null,
+          "action_ids" : [72],
+          "actions" : ["act_29"],
+          "base_default_next" : null,
+          "next_tables" : {
+            "act_29" : null
+          },
+          "default_entry" : {
+            "action_id" : 72,
+            "action_const" : true,
+            "action_data" : [],
+            "action_entry_const" : true
+          }
+        },
+        {
+          "name" : "tbl_drop_now_1",
+          "id" : 47,
+          "key" : [],
+          "match_type" : "exact",
+          "type" : "simple",
+          "max_size" : 1024,
+          "with_counters" : false,
+          "support_timeout" : false,
+          "direct_meters" : null,
+          "action_ids" : [68],
+          "actions" : ["drop_now"],
+          "base_default_next" : "FabricEgress.egress_next.egress_vlan",
+          "next_tables" : {
+            "drop_now" : "FabricEgress.egress_next.egress_vlan"
+          },
+          "default_entry" : {
+            "action_id" : 68,
+            "action_const" : true,
+            "action_data" : [],
+            "action_entry_const" : true
+          }
+        },
+        {
           "name" : "FabricEgress.egress_next.egress_vlan",
-          "id" : 45,
+          "id" : 48,
           "source_info" : {
             "filename" : "include/control/next.p4",
             "line" : 258,
@@ -6822,10 +6921,10 @@
           "direct_meters" : null,
           "action_ids" : [71, 66],
           "actions" : ["FabricEgress.egress_next.pop_vlan", "nop"],
-          "base_default_next" : "node_71",
+          "base_default_next" : "node_78",
           "next_tables" : {
-            "FabricEgress.egress_next.pop_vlan" : "node_71",
-            "nop" : "node_71"
+            "FabricEgress.egress_next.pop_vlan" : "node_78",
+            "nop" : "node_78"
           },
           "default_entry" : {
             "action_id" : 66,
@@ -6835,75 +6934,6 @@
           }
         },
         {
-          "name" : "tbl_pkt_io_egress_pop_vlan",
-          "id" : 46,
-          "key" : [],
-          "match_type" : "exact",
-          "type" : "simple",
-          "max_size" : 1024,
-          "with_counters" : false,
-          "support_timeout" : false,
-          "direct_meters" : null,
-          "action_ids" : [70],
-          "actions" : ["FabricEgress.pkt_io_egress.pop_vlan"],
-          "base_default_next" : "node_74",
-          "next_tables" : {
-            "FabricEgress.pkt_io_egress.pop_vlan" : "node_74"
-          },
-          "default_entry" : {
-            "action_id" : 70,
-            "action_const" : true,
-            "action_data" : [],
-            "action_entry_const" : true
-          }
-        },
-        {
-          "name" : "tbl_drop_now_1",
-          "id" : 47,
-          "key" : [],
-          "match_type" : "exact",
-          "type" : "simple",
-          "max_size" : 1024,
-          "with_counters" : false,
-          "support_timeout" : false,
-          "direct_meters" : null,
-          "action_ids" : [68],
-          "actions" : ["drop_now"],
-          "base_default_next" : "tbl_act_29",
-          "next_tables" : {
-            "drop_now" : "tbl_act_29"
-          },
-          "default_entry" : {
-            "action_id" : 68,
-            "action_const" : true,
-            "action_data" : [],
-            "action_entry_const" : true
-          }
-        },
-        {
-          "name" : "tbl_act_29",
-          "id" : 48,
-          "key" : [],
-          "match_type" : "exact",
-          "type" : "simple",
-          "max_size" : 1024,
-          "with_counters" : false,
-          "support_timeout" : false,
-          "direct_meters" : null,
-          "action_ids" : [72],
-          "actions" : ["act_29"],
-          "base_default_next" : "node_77",
-          "next_tables" : {
-            "act_29" : "node_77"
-          },
-          "default_entry" : {
-            "action_id" : 72,
-            "action_const" : true,
-            "action_data" : [],
-            "action_entry_const" : true
-          }
-        },
-        {
           "name" : "tbl_spgw_egress_gtpu_encap",
           "id" : 49,
           "key" : [],
@@ -6933,61 +6963,41 @@
           "name" : "node_68",
           "id" : 20,
           "source_info" : {
-            "filename" : "include/control/next.p4",
-            "line" : 272,
+            "filename" : "include/control/packetio.p4",
+            "line" : 43,
             "column" : 12,
-            "source_fragment" : "fabric_metadata.is_multicast == true ..."
+            "source_fragment" : "fabric_metadata.is_controller_packet_out == true"
           },
           "expression" : {
             "type" : "expression",
             "value" : {
-              "op" : "and",
+              "op" : "==",
               "left" : {
                 "type" : "expression",
                 "value" : {
-                  "op" : "==",
-                  "left" : {
-                    "type" : "expression",
-                    "value" : {
-                      "op" : "d2b",
-                      "left" : null,
-                      "right" : {
-                        "type" : "field",
-                        "value" : ["scalars", "fabric_metadata_t.is_multicast"]
-                      }
-                    }
-                  },
+                  "op" : "d2b",
+                  "left" : null,
                   "right" : {
-                    "type" : "bool",
-                    "value" : true
+                    "type" : "field",
+                    "value" : ["scalars", "fabric_metadata_t.is_controller_packet_out"]
                   }
                 }
               },
               "right" : {
-                "type" : "expression",
-                "value" : {
-                  "op" : "==",
-                  "left" : {
-                    "type" : "field",
-                    "value" : ["standard_metadata", "ingress_port"]
-                  },
-                  "right" : {
-                    "type" : "field",
-                    "value" : ["standard_metadata", "egress_port"]
-                  }
-                }
+                "type" : "bool",
+                "value" : true
               }
             }
           },
-          "true_next" : "tbl_drop_now_0",
-          "false_next" : "FabricEgress.egress_next.egress_vlan"
+          "true_next" : null,
+          "false_next" : "node_69"
         },
         {
-          "name" : "node_71",
+          "name" : "node_69",
           "id" : 21,
           "source_info" : {
             "filename" : "include/control/packetio.p4",
-            "line" : 42,
+            "line" : 47,
             "column" : 12,
             "source_fragment" : "standard_metadata.egress_port == 255"
           },
@@ -7005,15 +7015,15 @@
               }
             }
           },
-          "true_next" : "node_72",
-          "false_next" : "node_77"
+          "true_next" : "node_70",
+          "false_next" : "node_75"
         },
         {
-          "name" : "node_72",
+          "name" : "node_70",
           "id" : 22,
           "source_info" : {
             "filename" : "include/control/packetio.p4",
-            "line" : 43,
+            "line" : 48,
             "column" : 16,
             "source_fragment" : "hdr.vlan_tag.isValid() && fabric_metadata.pop_vlan_when_packet_in == true"
           },
@@ -7056,14 +7066,14 @@
             }
           },
           "true_next" : "tbl_pkt_io_egress_pop_vlan",
-          "false_next" : "node_74"
+          "false_next" : "node_72"
         },
         {
-          "name" : "node_74",
+          "name" : "node_72",
           "id" : 23,
           "source_info" : {
             "filename" : "include/control/packetio.p4",
-            "line" : 46,
+            "line" : 51,
             "column" : 16,
             "source_fragment" : "fabric_metadata.is_multicast == true && ..."
           },
@@ -7115,13 +7125,66 @@
               }
             }
           },
-          "true_next" : "tbl_drop_now_1",
+          "true_next" : "tbl_drop_now_0",
           "false_next" : "tbl_act_29"
         },
         {
-          "name" : "node_77",
+          "name" : "node_75",
           "id" : 24,
           "source_info" : {
+            "filename" : "include/control/next.p4",
+            "line" : 272,
+            "column" : 12,
+            "source_fragment" : "fabric_metadata.is_multicast == true ..."
+          },
+          "expression" : {
+            "type" : "expression",
+            "value" : {
+              "op" : "and",
+              "left" : {
+                "type" : "expression",
+                "value" : {
+                  "op" : "==",
+                  "left" : {
+                    "type" : "expression",
+                    "value" : {
+                      "op" : "d2b",
+                      "left" : null,
+                      "right" : {
+                        "type" : "field",
+                        "value" : ["scalars", "fabric_metadata_t.is_multicast"]
+                      }
+                    }
+                  },
+                  "right" : {
+                    "type" : "bool",
+                    "value" : true
+                  }
+                }
+              },
+              "right" : {
+                "type" : "expression",
+                "value" : {
+                  "op" : "==",
+                  "left" : {
+                    "type" : "field",
+                    "value" : ["standard_metadata", "ingress_port"]
+                  },
+                  "right" : {
+                    "type" : "field",
+                    "value" : ["standard_metadata", "egress_port"]
+                  }
+                }
+              }
+            }
+          },
+          "true_next" : "tbl_drop_now_1",
+          "false_next" : "FabricEgress.egress_next.egress_vlan"
+        },
+        {
+          "name" : "node_78",
+          "id" : 25,
+          "source_info" : {
             "filename" : "include/spgw.p4",
             "line" : 221,
             "column" : 12,
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 e8ad083..4dbc6e8 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
@@ -16,11 +16,11 @@
         ["fabric_metadata_t.next_id", 32, false],
         ["fabric_metadata_t.pop_vlan_when_packet_in", 1, false],
         ["fabric_metadata_t.is_multicast", 1, false],
+        ["fabric_metadata_t.is_controller_packet_out", 1, false],
         ["fabric_metadata_t.clone_to_cpu", 1, false],
         ["fabric_metadata_t.ip_proto", 8, false],
         ["fabric_metadata_t.l4_src_port", 16, false],
-        ["fabric_metadata_t.l4_dst_port", 16, false],
-        ["_padding_0", 1, false]
+        ["fabric_metadata_t.l4_dst_port", 16, false]
       ]
     },
     {
@@ -2640,6 +2640,35 @@
             "column" : 12,
             "source_fragment" : "hdr.packet_out.setInvalid()"
           }
+        },
+        {
+          "op" : "assign",
+          "parameters" : [
+            {
+              "type" : "field",
+              "value" : ["scalars", "fabric_metadata_t.is_controller_packet_out"]
+            },
+            {
+              "type" : "expression",
+              "value" : {
+                "type" : "expression",
+                "value" : {
+                  "op" : "b2d",
+                  "left" : null,
+                  "right" : {
+                    "type" : "bool",
+                    "value" : true
+                  }
+                }
+              }
+            }
+          ],
+          "source_info" : {
+            "filename" : "include/control/packetio.p4",
+            "line" : 28,
+            "column" : 12,
+            "source_fragment" : "fabric_metadata.is_controller_packet_out = true"
+          }
         }
       ]
     },
@@ -3245,7 +3274,7 @@
           ],
           "source_info" : {
             "filename" : "include/control/packetio.p4",
-            "line" : 38,
+            "line" : 39,
             "column" : 8,
             "source_fragment" : "hdr.ethernet.ether_type = hdr.vlan_tag.ether_type"
           }
@@ -3260,7 +3289,7 @@
           ],
           "source_info" : {
             "filename" : "include/control/packetio.p4",
-            "line" : 39,
+            "line" : 40,
             "column" : 8,
             "source_fragment" : "hdr.vlan_tag.setInvalid()"
           }
@@ -3323,7 +3352,7 @@
           ],
           "source_info" : {
             "filename" : "include/control/packetio.p4",
-            "line" : 51,
+            "line" : 56,
             "column" : 12,
             "source_fragment" : "hdr.packet_in.setValid()"
           }
@@ -3342,7 +3371,7 @@
           ],
           "source_info" : {
             "filename" : "include/control/packetio.p4",
-            "line" : 52,
+            "line" : 57,
             "column" : 12,
             "source_fragment" : "hdr.packet_in.ingress_port = standard_metadata.ingress_port"
           }
@@ -4578,7 +4607,7 @@
       "init_table" : "node_43",
       "tables" : [
         {
-          "name" : "tbl_drop_now",
+          "name" : "tbl_pkt_io_egress_pop_vlan",
           "id" : 26,
           "key" : [],
           "match_type" : "exact",
@@ -4587,11 +4616,34 @@
           "with_counters" : false,
           "support_timeout" : false,
           "direct_meters" : null,
+          "action_ids" : [50],
+          "actions" : ["FabricEgress.pkt_io_egress.pop_vlan"],
+          "base_default_next" : "node_47",
+          "next_tables" : {
+            "FabricEgress.pkt_io_egress.pop_vlan" : "node_47"
+          },
+          "default_entry" : {
+            "action_id" : 50,
+            "action_const" : true,
+            "action_data" : [],
+            "action_entry_const" : true
+          }
+        },
+        {
+          "name" : "tbl_drop_now",
+          "id" : 27,
+          "key" : [],
+          "match_type" : "exact",
+          "type" : "simple",
+          "max_size" : 1024,
+          "with_counters" : false,
+          "support_timeout" : false,
+          "direct_meters" : null,
           "action_ids" : [48],
           "actions" : ["drop_now"],
-          "base_default_next" : "FabricEgress.egress_next.egress_vlan",
+          "base_default_next" : "tbl_act_15",
           "next_tables" : {
-            "drop_now" : "FabricEgress.egress_next.egress_vlan"
+            "drop_now" : "tbl_act_15"
           },
           "default_entry" : {
             "action_id" : 48,
@@ -4601,8 +4653,54 @@
           }
         },
         {
+          "name" : "tbl_act_15",
+          "id" : 28,
+          "key" : [],
+          "match_type" : "exact",
+          "type" : "simple",
+          "max_size" : 1024,
+          "with_counters" : false,
+          "support_timeout" : false,
+          "direct_meters" : null,
+          "action_ids" : [52],
+          "actions" : ["act_15"],
+          "base_default_next" : null,
+          "next_tables" : {
+            "act_15" : null
+          },
+          "default_entry" : {
+            "action_id" : 52,
+            "action_const" : true,
+            "action_data" : [],
+            "action_entry_const" : true
+          }
+        },
+        {
+          "name" : "tbl_drop_now_0",
+          "id" : 29,
+          "key" : [],
+          "match_type" : "exact",
+          "type" : "simple",
+          "max_size" : 1024,
+          "with_counters" : false,
+          "support_timeout" : false,
+          "direct_meters" : null,
+          "action_ids" : [49],
+          "actions" : ["drop_now"],
+          "base_default_next" : "FabricEgress.egress_next.egress_vlan",
+          "next_tables" : {
+            "drop_now" : "FabricEgress.egress_next.egress_vlan"
+          },
+          "default_entry" : {
+            "action_id" : 49,
+            "action_const" : true,
+            "action_data" : [],
+            "action_entry_const" : true
+          }
+        },
+        {
           "name" : "FabricEgress.egress_next.egress_vlan",
-          "id" : 27,
+          "id" : 30,
           "source_info" : {
             "filename" : "include/control/next.p4",
             "line" : 258,
@@ -4631,10 +4729,10 @@
           "direct_meters" : null,
           "action_ids" : [51, 47],
           "actions" : ["FabricEgress.egress_next.pop_vlan", "nop"],
-          "base_default_next" : "node_46",
+          "base_default_next" : null,
           "next_tables" : {
-            "FabricEgress.egress_next.pop_vlan" : "node_46",
-            "nop" : "node_46"
+            "FabricEgress.egress_next.pop_vlan" : null,
+            "nop" : null
           },
           "default_entry" : {
             "action_id" : 47,
@@ -4642,75 +4740,6 @@
             "action_data" : [],
             "action_entry_const" : false
           }
-        },
-        {
-          "name" : "tbl_pkt_io_egress_pop_vlan",
-          "id" : 28,
-          "key" : [],
-          "match_type" : "exact",
-          "type" : "simple",
-          "max_size" : 1024,
-          "with_counters" : false,
-          "support_timeout" : false,
-          "direct_meters" : null,
-          "action_ids" : [50],
-          "actions" : ["FabricEgress.pkt_io_egress.pop_vlan"],
-          "base_default_next" : "node_49",
-          "next_tables" : {
-            "FabricEgress.pkt_io_egress.pop_vlan" : "node_49"
-          },
-          "default_entry" : {
-            "action_id" : 50,
-            "action_const" : true,
-            "action_data" : [],
-            "action_entry_const" : true
-          }
-        },
-        {
-          "name" : "tbl_drop_now_0",
-          "id" : 29,
-          "key" : [],
-          "match_type" : "exact",
-          "type" : "simple",
-          "max_size" : 1024,
-          "with_counters" : false,
-          "support_timeout" : false,
-          "direct_meters" : null,
-          "action_ids" : [49],
-          "actions" : ["drop_now"],
-          "base_default_next" : "tbl_act_15",
-          "next_tables" : {
-            "drop_now" : "tbl_act_15"
-          },
-          "default_entry" : {
-            "action_id" : 49,
-            "action_const" : true,
-            "action_data" : [],
-            "action_entry_const" : true
-          }
-        },
-        {
-          "name" : "tbl_act_15",
-          "id" : 30,
-          "key" : [],
-          "match_type" : "exact",
-          "type" : "simple",
-          "max_size" : 1024,
-          "with_counters" : false,
-          "support_timeout" : false,
-          "direct_meters" : null,
-          "action_ids" : [52],
-          "actions" : ["act_15"],
-          "base_default_next" : null,
-          "next_tables" : {
-            "act_15" : null
-          },
-          "default_entry" : {
-            "action_id" : 52,
-            "action_const" : true,
-            "action_data" : [],
-            "action_entry_const" : true
-          }
         }
       ],
       "action_profiles" : [],
@@ -4719,61 +4748,41 @@
           "name" : "node_43",
           "id" : 13,
           "source_info" : {
-            "filename" : "include/control/next.p4",
-            "line" : 272,
+            "filename" : "include/control/packetio.p4",
+            "line" : 43,
             "column" : 12,
-            "source_fragment" : "fabric_metadata.is_multicast == true ..."
+            "source_fragment" : "fabric_metadata.is_controller_packet_out == true"
           },
           "expression" : {
             "type" : "expression",
             "value" : {
-              "op" : "and",
+              "op" : "==",
               "left" : {
                 "type" : "expression",
                 "value" : {
-                  "op" : "==",
-                  "left" : {
-                    "type" : "expression",
-                    "value" : {
-                      "op" : "d2b",
-                      "left" : null,
-                      "right" : {
-                        "type" : "field",
-                        "value" : ["scalars", "fabric_metadata_t.is_multicast"]
-                      }
-                    }
-                  },
+                  "op" : "d2b",
+                  "left" : null,
                   "right" : {
-                    "type" : "bool",
-                    "value" : true
+                    "type" : "field",
+                    "value" : ["scalars", "fabric_metadata_t.is_controller_packet_out"]
                   }
                 }
               },
               "right" : {
-                "type" : "expression",
-                "value" : {
-                  "op" : "==",
-                  "left" : {
-                    "type" : "field",
-                    "value" : ["standard_metadata", "ingress_port"]
-                  },
-                  "right" : {
-                    "type" : "field",
-                    "value" : ["standard_metadata", "egress_port"]
-                  }
-                }
+                "type" : "bool",
+                "value" : true
               }
             }
           },
-          "true_next" : "tbl_drop_now",
-          "false_next" : "FabricEgress.egress_next.egress_vlan"
+          "true_next" : null,
+          "false_next" : "node_44"
         },
         {
-          "name" : "node_46",
+          "name" : "node_44",
           "id" : 14,
           "source_info" : {
             "filename" : "include/control/packetio.p4",
-            "line" : 42,
+            "line" : 47,
             "column" : 12,
             "source_fragment" : "standard_metadata.egress_port == 255"
           },
@@ -4791,15 +4800,15 @@
               }
             }
           },
-          "false_next" : null,
-          "true_next" : "node_47"
+          "true_next" : "node_45",
+          "false_next" : "node_50"
         },
         {
-          "name" : "node_47",
+          "name" : "node_45",
           "id" : 15,
           "source_info" : {
             "filename" : "include/control/packetio.p4",
-            "line" : 43,
+            "line" : 48,
             "column" : 16,
             "source_fragment" : "hdr.vlan_tag.isValid() && fabric_metadata.pop_vlan_when_packet_in == true"
           },
@@ -4842,14 +4851,14 @@
             }
           },
           "true_next" : "tbl_pkt_io_egress_pop_vlan",
-          "false_next" : "node_49"
+          "false_next" : "node_47"
         },
         {
-          "name" : "node_49",
+          "name" : "node_47",
           "id" : 16,
           "source_info" : {
             "filename" : "include/control/packetio.p4",
-            "line" : 46,
+            "line" : 51,
             "column" : 16,
             "source_fragment" : "fabric_metadata.is_multicast == true && ..."
           },
@@ -4901,8 +4910,61 @@
               }
             }
           },
-          "true_next" : "tbl_drop_now_0",
+          "true_next" : "tbl_drop_now",
           "false_next" : "tbl_act_15"
+        },
+        {
+          "name" : "node_50",
+          "id" : 17,
+          "source_info" : {
+            "filename" : "include/control/next.p4",
+            "line" : 272,
+            "column" : 12,
+            "source_fragment" : "fabric_metadata.is_multicast == true ..."
+          },
+          "expression" : {
+            "type" : "expression",
+            "value" : {
+              "op" : "and",
+              "left" : {
+                "type" : "expression",
+                "value" : {
+                  "op" : "==",
+                  "left" : {
+                    "type" : "expression",
+                    "value" : {
+                      "op" : "d2b",
+                      "left" : null,
+                      "right" : {
+                        "type" : "field",
+                        "value" : ["scalars", "fabric_metadata_t.is_multicast"]
+                      }
+                    }
+                  },
+                  "right" : {
+                    "type" : "bool",
+                    "value" : true
+                  }
+                }
+              },
+              "right" : {
+                "type" : "expression",
+                "value" : {
+                  "op" : "==",
+                  "left" : {
+                    "type" : "field",
+                    "value" : ["standard_metadata", "ingress_port"]
+                  },
+                  "right" : {
+                    "type" : "field",
+                    "value" : ["standard_metadata", "egress_port"]
+                  }
+                }
+              }
+            }
+          },
+          "true_next" : "tbl_drop_now_0",
+          "false_next" : "FabricEgress.egress_next.egress_vlan"
         }
       ]
     }