Fixing packet_io and regenerating default.p4 for tofino

Change-Id: I5c2c6565f71a13b375a8ec8da864e9157b8e56ed
diff --git a/tools/test/p4src/p4-14/p4c-out/tofino/ecmp/montara/ecmp.json b/tools/test/p4src/p4-14/p4c-out/tofino/ecmp/montara/ecmp.json
index e53756f..470c7b8 100644
--- a/tools/test/p4src/p4-14/p4c-out/tofino/ecmp/montara/ecmp.json
+++ b/tools/test/p4src/p4-14/p4c-out/tofino/ecmp/montara/ecmp.json
@@ -522,45 +522,10 @@
   "learn_lists" : [],
   "actions" : [
     {
-      "name" : "add_packet_in_hdr",
+      "name" : "NoAction",
       "id" : 0,
       "runtime_data" : [],
-      "primitives" : [
-        {
-          "op" : "add_header",
-          "parameters" : [
-            {
-              "type" : "header",
-              "value" : "packet_in_hdr"
-            }
-          ],
-          "source_info" : {
-            "filename" : "include/packet_io.p4",
-            "line" : 25,
-            "column" : 4,
-            "source_fragment" : "add_header(packet_in_hdr)"
-          }
-        },
-        {
-          "op" : "assign",
-          "parameters" : [
-            {
-              "type" : "field",
-              "value" : ["packet_in_hdr", "ingress_port"]
-            },
-            {
-              "type" : "field",
-              "value" : ["ig_intr_md", "ingress_port"]
-            }
-          ],
-          "source_info" : {
-            "filename" : "include/packet_io.p4",
-            "line" : 26,
-            "column" : 4,
-            "source_fragment" : "modify_field(packet_in_hdr.ingress_port, ig_intr_md.ingress_port)"
-          }
-        }
-      ]
+      "primitives" : []
     },
     {
       "name" : "NoAction",
@@ -569,10 +534,35 @@
       "primitives" : []
     },
     {
-      "name" : "NoAction",
+      "name" : "set_egress_port",
       "id" : 2,
-      "runtime_data" : [],
-      "primitives" : []
+      "runtime_data" : [
+        {
+          "name" : "port",
+          "bitwidth" : 9
+        }
+      ],
+      "primitives" : [
+        {
+          "op" : "assign",
+          "parameters" : [
+            {
+              "type" : "field",
+              "value" : ["ig_intr_md", "egress_spec"]
+            },
+            {
+              "type" : "runtime_data",
+              "value" : 0
+            }
+          ],
+          "source_info" : {
+            "filename" : "include/actions.p4",
+            "line" : 5,
+            "column" : 23,
+            "source_fragment" : "port) { ..."
+          }
+        }
+      ]
     },
     {
       "name" : "set_egress_port",
@@ -606,39 +596,8 @@
       ]
     },
     {
-      "name" : "set_egress_port",
-      "id" : 4,
-      "runtime_data" : [
-        {
-          "name" : "port",
-          "bitwidth" : 9
-        }
-      ],
-      "primitives" : [
-        {
-          "op" : "assign",
-          "parameters" : [
-            {
-              "type" : "field",
-              "value" : ["ig_intr_md", "egress_spec"]
-            },
-            {
-              "type" : "runtime_data",
-              "value" : 0
-            }
-          ],
-          "source_info" : {
-            "filename" : "include/actions.p4",
-            "line" : 5,
-            "column" : 23,
-            "source_fragment" : "port) { ..."
-          }
-        }
-      ]
-    },
-    {
       "name" : "ecmp_group",
-      "id" : 5,
+      "id" : 4,
       "runtime_data" : [
         {
           "name" : "groupId",
@@ -696,7 +655,7 @@
     },
     {
       "name" : "send_to_cpu",
-      "id" : 6,
+      "id" : 5,
       "runtime_data" : [],
       "primitives" : [
         {
@@ -713,16 +672,50 @@
           ],
           "source_info" : {
             "filename" : "include/actions.p4",
-            "line" : 21,
+            "line" : 18,
             "column" : 4,
             "source_fragment" : "modify_field(ig_intr_md.egress_spec, 255)"
           }
+        },
+        {
+          "op" : "add_header",
+          "parameters" : [
+            {
+              "type" : "header",
+              "value" : "packet_in_hdr"
+            }
+          ],
+          "source_info" : {
+            "filename" : "include/actions.p4",
+            "line" : 19,
+            "column" : 4,
+            "source_fragment" : "add_header(packet_in_hdr)"
+          }
+        },
+        {
+          "op" : "assign",
+          "parameters" : [
+            {
+              "type" : "field",
+              "value" : ["packet_in_hdr", "ingress_port"]
+            },
+            {
+              "type" : "field",
+              "value" : ["ig_intr_md", "ingress_port"]
+            }
+          ],
+          "source_info" : {
+            "filename" : "include/actions.p4",
+            "line" : 20,
+            "column" : 4,
+            "source_fragment" : "modify_field(packet_in_hdr.ingress_port, ig_intr_md.ingress_port)"
+          }
         }
       ]
     },
     {
       "name" : "_drop",
-      "id" : 7,
+      "id" : 6,
       "runtime_data" : [],
       "primitives" : [
         {
@@ -747,8 +740,8 @@
       ]
     },
     {
-      "name" : "_packet_out",
-      "id" : 8,
+      "name" : "_process_packet_out",
+      "id" : 7,
       "runtime_data" : [],
       "primitives" : [
         {
@@ -789,7 +782,7 @@
     },
     {
       "name" : "count_egress",
-      "id" : 9,
+      "id" : 8,
       "runtime_data" : [],
       "primitives" : [
         {
@@ -841,7 +834,7 @@
     },
     {
       "name" : "count_ingress",
-      "id" : 10,
+      "id" : 9,
       "runtime_data" : [],
       "primitives" : [
         {
@@ -899,37 +892,8 @@
       "init_table" : "node_2",
       "tables" : [
         {
-          "name" : "ingress_pkt",
-          "id" : 0,
-          "source_info" : {
-            "filename" : "include/packet_io.p4",
-            "line" : 11,
-            "column" : 0,
-            "source_fragment" : "table ingress_pkt { ..."
-          },
-          "key" : [],
-          "match_type" : "exact",
-          "type" : "simple",
-          "max_size" : 1024,
-          "with_counters" : false,
-          "support_timeout" : false,
-          "direct_meters" : null,
-          "action_ids" : [8],
-          "actions" : ["_packet_out"],
-          "base_default_next" : "node_4",
-          "next_tables" : {
-            "_packet_out" : "node_4"
-          },
-          "default_entry" : {
-            "action_id" : 8,
-            "action_const" : false,
-            "action_data" : [],
-            "action_entry_const" : false
-          }
-        },
-        {
           "name" : "table0",
-          "id" : 1,
+          "id" : 0,
           "source_info" : {
             "filename" : "ecmp.p4",
             "line" : 47,
@@ -964,18 +928,18 @@
           "with_counters" : true,
           "support_timeout" : false,
           "direct_meters" : null,
-          "action_ids" : [4, 5, 6, 7, 2],
+          "action_ids" : [3, 4, 5, 6, 1],
           "actions" : ["set_egress_port", "ecmp_group", "send_to_cpu", "_drop", "NoAction"],
-          "base_default_next" : "node_7",
+          "base_default_next" : "node_5",
           "next_tables" : {
             "ecmp_group" : "ecmp_group_table",
-            "set_egress_port" : "node_7",
-            "send_to_cpu" : "node_7",
-            "_drop" : "node_7",
-            "NoAction" : "node_7"
+            "set_egress_port" : "node_5",
+            "send_to_cpu" : "node_5",
+            "_drop" : "node_5",
+            "NoAction" : "node_5"
           },
           "default_entry" : {
-            "action_id" : 2,
+            "action_id" : 1,
             "action_const" : false,
             "action_data" : [],
             "action_entry_const" : false
@@ -983,7 +947,7 @@
         },
         {
           "name" : "ecmp_group_table",
-          "id" : 2,
+          "id" : 1,
           "source_info" : {
             "filename" : "ecmp.p4",
             "line" : 63,
@@ -1008,15 +972,44 @@
           "with_counters" : true,
           "support_timeout" : false,
           "direct_meters" : null,
-          "action_ids" : [3, 1],
+          "action_ids" : [2, 0],
           "actions" : ["set_egress_port", "NoAction"],
-          "base_default_next" : "node_7",
+          "base_default_next" : "node_5",
           "next_tables" : {
-            "set_egress_port" : "node_7",
-            "NoAction" : "node_7"
+            "set_egress_port" : "node_5",
+            "NoAction" : "node_5"
           },
           "default_entry" : {
-            "action_id" : 1,
+            "action_id" : 0,
+            "action_const" : false,
+            "action_data" : [],
+            "action_entry_const" : false
+          }
+        },
+        {
+          "name" : "process_packet_out_table",
+          "id" : 2,
+          "source_info" : {
+            "filename" : "include/packet_io.p4",
+            "line" : 11,
+            "column" : 0,
+            "source_fragment" : "table process_packet_out_table { ..."
+          },
+          "key" : [],
+          "match_type" : "exact",
+          "type" : "simple",
+          "max_size" : 1024,
+          "with_counters" : false,
+          "support_timeout" : false,
+          "direct_meters" : null,
+          "action_ids" : [7],
+          "actions" : ["_process_packet_out"],
+          "base_default_next" : "node_7",
+          "next_tables" : {
+            "_process_packet_out" : "node_7"
+          },
+          "default_entry" : {
+            "action_id" : 7,
             "action_const" : false,
             "action_data" : [],
             "action_entry_const" : false
@@ -1038,14 +1031,14 @@
           "with_counters" : false,
           "support_timeout" : false,
           "direct_meters" : null,
-          "action_ids" : [10],
+          "action_ids" : [9],
           "actions" : ["count_ingress"],
           "base_default_next" : "egress_port_count_table",
           "next_tables" : {
             "count_ingress" : "egress_port_count_table"
           },
           "default_entry" : {
-            "action_id" : 10,
+            "action_id" : 9,
             "action_const" : false,
             "action_data" : [],
             "action_entry_const" : false
@@ -1067,14 +1060,14 @@
           "with_counters" : false,
           "support_timeout" : false,
           "direct_meters" : null,
-          "action_ids" : [9],
+          "action_ids" : [8],
           "actions" : ["count_egress"],
           "base_default_next" : null,
           "next_tables" : {
             "count_egress" : null
           },
           "default_entry" : {
-            "action_id" : 9,
+            "action_id" : 8,
             "action_const" : false,
             "action_data" : [],
             "action_entry_const" : false
@@ -1087,6 +1080,32 @@
           "name" : "node_2",
           "id" : 0,
           "source_info" : {
+            "filename" : "ecmp.p4",
+            "line" : 86,
+            "column" : 12,
+            "source_fragment" : "valid(packet_out_hdr)"
+          },
+          "expression" : {
+            "type" : "expression",
+            "value" : {
+              "op" : "!=",
+              "left" : {
+                "type" : "field",
+                "value" : ["packet_out_hdr", "$valid$"]
+              },
+              "right" : {
+                "type" : "hexstr",
+                "value" : "0x01"
+              }
+            }
+          },
+          "true_next" : "table0",
+          "false_next" : "node_5"
+        },
+        {
+          "name" : "node_5",
+          "id" : 1,
+          "source_info" : {
             "filename" : "include/packet_io.p4",
             "line" : 19,
             "column" : 8,
@@ -1106,33 +1125,7 @@
               }
             }
           },
-          "true_next" : "ingress_pkt",
-          "false_next" : "node_4"
-        },
-        {
-          "name" : "node_4",
-          "id" : 1,
-          "source_info" : {
-            "filename" : "ecmp.p4",
-            "line" : 87,
-            "column" : 12,
-            "source_fragment" : "valid(packet_out_hdr)"
-          },
-          "expression" : {
-            "type" : "expression",
-            "value" : {
-              "op" : "!=",
-              "left" : {
-                "type" : "field",
-                "value" : ["packet_out_hdr", "$valid$"]
-              },
-              "right" : {
-                "type" : "hexstr",
-                "value" : "0x01"
-              }
-            }
-          },
-          "true_next" : "table0",
+          "true_next" : "process_packet_out_table",
           "false_next" : "node_7"
         },
         {
@@ -1166,67 +1159,10 @@
     {
       "name" : "egress",
       "id" : 1,
-      "init_table" : "node_12",
-      "tables" : [
-        {
-          "name" : "egress_pkt",
-          "id" : 5,
-          "source_info" : {
-            "filename" : "include/packet_io.p4",
-            "line" : 29,
-            "column" : 0,
-            "source_fragment" : "table egress_pkt { ..."
-          },
-          "key" : [],
-          "match_type" : "exact",
-          "type" : "simple",
-          "max_size" : 1024,
-          "with_counters" : false,
-          "support_timeout" : false,
-          "direct_meters" : null,
-          "action_ids" : [0],
-          "actions" : ["add_packet_in_hdr"],
-          "base_default_next" : null,
-          "next_tables" : {
-            "add_packet_in_hdr" : null
-          },
-          "default_entry" : {
-            "action_id" : 0,
-            "action_const" : false,
-            "action_data" : [],
-            "action_entry_const" : false
-          }
-        }
-      ],
+      "init_table" : null,
+      "tables" : [],
       "action_profiles" : [],
-      "conditionals" : [
-        {
-          "name" : "node_12",
-          "id" : 3,
-          "source_info" : {
-            "filename" : "include/packet_io.p4",
-            "line" : 40,
-            "column" : 39,
-            "source_fragment" : "=="
-          },
-          "expression" : {
-            "type" : "expression",
-            "value" : {
-              "op" : "==",
-              "left" : {
-                "type" : "field",
-                "value" : ["ig_intr_md", "ingress_port"]
-              },
-              "right" : {
-                "type" : "hexstr",
-                "value" : "0x00ff"
-              }
-            }
-          },
-          "false_next" : null,
-          "true_next" : "egress_pkt"
-        }
-      ]
+      "conditionals" : []
     }
   ],
   "checksums" : [],