[ONOS-6554] Implement BMv2-JSON-to-PiPipelineModel parser

1. Create new module incubator/bmv2/model
2. Move all bmv2 model files to incubator/bmv2/model
3. Using PI core interfaces for all bmv2 models
4. Refactor original bmv2 config parser (Bmv2PipelineModelParser)
5. Refactor original bmv2 config parser test

Change-Id: I0db07762d76ab6e2f846e9c3c9d5896f0cbea7f2
diff --git a/incubator/bmv2/model/src/test/java/org/onosproject/bmv2/model/Bmv2PipelineModelParserTest.java b/incubator/bmv2/model/src/test/java/org/onosproject/bmv2/model/Bmv2PipelineModelParserTest.java
new file mode 100644
index 0000000..f1bd683
--- /dev/null
+++ b/incubator/bmv2/model/src/test/java/org/onosproject/bmv2/model/Bmv2PipelineModelParserTest.java
@@ -0,0 +1,226 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.bmv2.model;
+
+import com.eclipsesource.json.Json;
+import com.eclipsesource.json.JsonObject;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+import com.google.common.testing.EqualsTester;
+import org.hamcrest.collection.IsIterableContainingInOrder;
+import org.junit.Before;
+import org.junit.Test;
+import org.onosproject.net.pi.model.PiHeaderFieldModel;
+import org.onosproject.net.pi.model.PiHeaderModel;
+import org.onosproject.net.pi.model.PiHeaderTypeModel;
+import org.onosproject.net.pi.model.PiMatchType;
+import org.onosproject.net.pi.model.PiTableMatchFieldModel;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.*;
+import static org.hamcrest.core.IsEqual.equalTo;
+
+/**
+ * BMv2 JSON configuration parser test.
+ */
+public class Bmv2PipelineModelParserTest {
+
+    private JsonObject json;
+    private JsonObject json2;
+
+    @Before
+    public void setUp() throws Exception {
+        json = Json.parse(new BufferedReader(new InputStreamReader(
+                this.getClass().getResourceAsStream("/default.json")))).asObject();
+        json2 = Json.parse(new BufferedReader(new InputStreamReader(
+                this.getClass().getResourceAsStream("/default.json")))).asObject();
+    }
+
+    @Test
+    public void testParse() throws Exception {
+        Bmv2PipelineModel config = Bmv2PipelineModelParser.parse(json);
+        Bmv2PipelineModel config2 = Bmv2PipelineModelParser.parse(json2);
+
+        new EqualsTester()
+                .addEqualityGroup(config, config2)
+                .testEquals();
+
+        /* Check header types */
+        Bmv2HeaderTypeModel stdMetaT =
+                (Bmv2HeaderTypeModel) config.headerType("standard_metadata").orElse(null);
+        Bmv2HeaderTypeModel ethernetT =
+                (Bmv2HeaderTypeModel) config.headerType("ethernet_t").orElse(null);
+        Bmv2HeaderTypeModel intrinsicMetaT =
+                (Bmv2HeaderTypeModel) config.headerType("intrinsic_metadata_t").orElse(null);
+
+        Bmv2HeaderTypeModel stdMetaT2 =
+                (Bmv2HeaderTypeModel) config2.headerType("standard_metadata").orElse(null);
+        Bmv2HeaderTypeModel ethernetT2 =
+                (Bmv2HeaderTypeModel) config2.headerType("ethernet_t").orElse(null);
+        Bmv2HeaderTypeModel intrinsicMetaT2 =
+                (Bmv2HeaderTypeModel) config2.headerType("intrinsic_metadata_t").orElse(null);
+
+        new EqualsTester()
+                .addEqualityGroup(stdMetaT, stdMetaT2)
+                .addEqualityGroup(ethernetT, ethernetT2)
+                .addEqualityGroup(intrinsicMetaT, intrinsicMetaT2)
+                .testEquals();
+
+        // existence
+        assertThat("Json parsed value is null", stdMetaT, notNullValue());
+        assertThat("Json parsed value is null", ethernetT, notNullValue());
+        assertThat("Json parsed value is null", intrinsicMetaT, notNullValue());
+
+        // fields size
+        assertThat("Incorrect size for header type fields",
+                   stdMetaT.fields(), hasSize(18));
+        assertThat("Incorrect size for header type fields",
+                   ethernetT.fields(), hasSize(3));
+        assertThat("Incorrect size for header type fields",
+                   intrinsicMetaT.fields(), hasSize(4));
+
+        // check that fields are in order
+        assertThat("Incorrect order for header type fields",
+                   stdMetaT.fields(), IsIterableContainingInOrder.contains(
+                        stdMetaT.field("ingress_port").get(),
+                        stdMetaT.field("egress_spec").get(),
+                        stdMetaT.field("egress_port").get(),
+                        stdMetaT.field("clone_spec").get(),
+                        stdMetaT.field("instance_type").get(),
+                        stdMetaT.field("drop").get(),
+                        stdMetaT.field("recirculate_port").get(),
+                        stdMetaT.field("packet_length").get(),
+                        stdMetaT.field("enq_timestamp").get(),
+                        stdMetaT.field("enq_qdepth").get(),
+                        stdMetaT.field("deq_timedelta").get(),
+                        stdMetaT.field("deq_qdepth").get(),
+                        stdMetaT.field("ingress_global_timestamp").get(),
+                        stdMetaT.field("lf_field_list").get(),
+                        stdMetaT.field("mcast_grp").get(),
+                        stdMetaT.field("resubmit_flag").get(),
+                        stdMetaT.field("egress_rid").get(),
+                        stdMetaT.field("_padding").get()
+                ));
+
+        /* Check actions */
+        Bmv2ActionModel noAction =
+                (Bmv2ActionModel) config.action("NoAction").orElse(null);
+        Bmv2ActionModel setEgressPortAction =
+                (Bmv2ActionModel) config.action("set_egress_port_0").orElse(null);
+        Bmv2ActionModel sendToCpuAction =
+                (Bmv2ActionModel) config.action("send_to_cpu_0").orElse(null);
+        Bmv2ActionModel dropAction =
+                (Bmv2ActionModel) config.action("_drop_0").orElse(null);
+        Bmv2ActionModel processPortCountersCountPacketAction =
+                (Bmv2ActionModel) config.action("process_port_counters_0.count_packet").orElse(null);
+
+
+        Bmv2ActionModel noAction2 =
+                (Bmv2ActionModel) config.action("NoAction").orElse(null);
+        Bmv2ActionModel setEgressPortAction2 =
+                (Bmv2ActionModel) config.action("set_egress_port_0").orElse(null);
+        Bmv2ActionModel sendToCpuAction2 =
+                (Bmv2ActionModel) config.action("send_to_cpu_0").orElse(null);
+        Bmv2ActionModel dropAction2 =
+                (Bmv2ActionModel) config.action("_drop_0").orElse(null);
+        Bmv2ActionModel processPortCountersCountPacketAction2 =
+                (Bmv2ActionModel) config.action("process_port_counters_0.count_packet").orElse(null);
+
+        new EqualsTester()
+                .addEqualityGroup(noAction, noAction2)
+                .addEqualityGroup(setEgressPortAction, setEgressPortAction2)
+                .addEqualityGroup(sendToCpuAction, sendToCpuAction2)
+                .addEqualityGroup(dropAction, dropAction2)
+                .addEqualityGroup(processPortCountersCountPacketAction, processPortCountersCountPacketAction2)
+                .testEquals();
+
+        // existence
+        assertThat("Json parsed value is null", noAction, notNullValue());
+        assertThat("Json parsed value is null", setEgressPortAction, notNullValue());
+        assertThat("Json parsed value is null", sendToCpuAction, notNullValue());
+        assertThat("Json parsed value is null", dropAction, notNullValue());
+        assertThat("Json parsed value is null", processPortCountersCountPacketAction, notNullValue());
+
+        // runtime data size
+        assertThat("Incorrect size for action runtime data",
+                   noAction.params().size(), is(equalTo(0)));
+        assertThat("Incorrect size for action runtime data",
+                   setEgressPortAction.params().size(), is(equalTo(1)));
+        assertThat("Incorrect size for action runtime data",
+                   sendToCpuAction.params().size(), is(equalTo(0)));
+        assertThat("Incorrect size for action runtime data",
+                   dropAction.params().size(), is(equalTo(0)));
+        assertThat("Incorrect size for action runtime data",
+                   processPortCountersCountPacketAction.params().size(), is(equalTo(0)));
+
+        // runtime data existence and parsing
+        assertThat("Parsed Json value is null",
+                   setEgressPortAction.param("port").orElse(null), notNullValue());
+        assertThat("Incorrect value for action runtime data bitwidth",
+                   setEgressPortAction.param("port").get().bitWidth(), is(equalTo(9)));
+
+
+        /* Check tables */
+        Bmv2TableModel table0 =
+                (Bmv2TableModel) config.table("table0").orElse(null);
+        Bmv2TableModel table02 =
+                (Bmv2TableModel) config2.table("table0").orElse(null);
+
+        new EqualsTester()
+                .addEqualityGroup(table0, table02)
+                .testEquals();
+
+        // existence
+        assertThat("Parsed Json value is null", table0, notNullValue());
+
+        // id and name correspondence
+        assertThat("Incorrect value for table name",
+                   table0.name(), is(equalTo("table0")));
+
+        Set<PiTableMatchFieldModel> matchFields = Sets.newHashSet(table0.matchFields());
+
+        // keys size
+        assertThat("Incorrect size for table keys",
+                   matchFields.size(), is(equalTo(4)));
+
+        Set<PiMatchType> matchTypes = matchFields.stream()
+                .map(PiTableMatchFieldModel::matchType)
+                .collect(Collectors.toSet());
+
+        // key match type
+        assertThat("Incorrect value for table key match type",
+                   matchTypes, containsInAnyOrder(PiMatchType.TERNARY));
+
+        Set<PiHeaderTypeModel> headerTypeModels = matchFields.stream()
+                .map(PiTableMatchFieldModel::field)
+                .map(PiHeaderFieldModel::header)
+                .map(PiHeaderModel::type)
+                .collect(Collectors.toSet());
+
+        // header type
+        assertThat("Incorrect value for table key header type",
+                   headerTypeModels, containsInAnyOrder(ethernetT, stdMetaT));
+
+    }
+}
\ No newline at end of file
diff --git a/incubator/bmv2/model/src/test/resources/default.json b/incubator/bmv2/model/src/test/resources/default.json
new file mode 100644
index 0000000..f0bcc71
--- /dev/null
+++ b/incubator/bmv2/model/src/test/resources/default.json
@@ -0,0 +1,777 @@
+{
+  "program" : "default.p4",
+  "__meta__" : null,
+  "header_types" : [
+    {
+      "name" : "scalars",
+      "id" : 0,
+      "fields" : [
+        ["tmp", 32, false],
+        ["tmp_0", 32, false]
+      ]
+    },
+    {
+      "name" : "ethernet_t",
+      "id" : 1,
+      "fields" : [
+        ["dstAddr", 48, false],
+        ["srcAddr", 48, false],
+        ["etherType", 16, false]
+      ]
+    },
+    {
+      "name" : "ipv4_t",
+      "id" : 2,
+      "fields" : [
+        ["version", 4, false],
+        ["ihl", 4, false],
+        ["diffserv", 8, false],
+        ["totalLen", 16, false],
+        ["identification", 16, false],
+        ["flags", 3, false],
+        ["fragOffset", 13, false],
+        ["ttl", 8, false],
+        ["protocol", 8, false],
+        ["hdrChecksum", 16, false],
+        ["srcAddr", 32, false],
+        ["dstAddr", 32, false]
+      ]
+    },
+    {
+      "name" : "tcp_t",
+      "id" : 3,
+      "fields" : [
+        ["srcPort", 16, false],
+        ["dstPort", 16, false],
+        ["seqNo", 32, false],
+        ["ackNo", 32, false],
+        ["dataOffset", 4, false],
+        ["res", 3, false],
+        ["ecn", 3, false],
+        ["ctrl", 6, false],
+        ["window", 16, false],
+        ["checksum", 16, false],
+        ["urgentPtr", 16, false]
+      ]
+    },
+    {
+      "name" : "udp_t",
+      "id" : 4,
+      "fields" : [
+        ["srcPort", 16, false],
+        ["dstPort", 16, false],
+        ["length_", 16, false],
+        ["checksum", 16, false]
+      ]
+    },
+    {
+      "name" : "ecmp_metadata_t",
+      "id" : 5,
+      "fields" : [
+        ["groupId", 16, false],
+        ["selector", 16, false]
+      ]
+    },
+    {
+      "name" : "wcmp_meta_t",
+      "id" : 6,
+      "fields" : [
+        ["groupId", 16, false],
+        ["numBits", 8, false],
+        ["selector", 64, false]
+      ]
+    },
+    {
+      "name" : "intrinsic_metadata_t",
+      "id" : 7,
+      "fields" : [
+        ["ingress_global_timestamp", 32, false],
+        ["lf_field_list", 32, false],
+        ["mcast_grp", 16, false],
+        ["egress_rid", 16, false]
+      ]
+    },
+    {
+      "name" : "standard_metadata",
+      "id" : 8,
+      "fields" : [
+        ["ingress_port", 9, false],
+        ["egress_spec", 9, false],
+        ["egress_port", 9, false],
+        ["clone_spec", 32, false],
+        ["instance_type", 32, false],
+        ["drop", 1, false],
+        ["recirculate_port", 16, false],
+        ["packet_length", 32, false],
+        ["enq_timestamp", 32, false],
+        ["enq_qdepth", 19, false],
+        ["deq_timedelta", 32, false],
+        ["deq_qdepth", 19, false],
+        ["ingress_global_timestamp", 48, false],
+        ["lf_field_list", 32, false],
+        ["mcast_grp", 16, false],
+        ["resubmit_flag", 1, false],
+        ["egress_rid", 16, false],
+        ["_padding", 5, false]
+      ]
+    }
+  ],
+  "headers" : [
+    {
+      "name" : "scalars",
+      "id" : 0,
+      "header_type" : "scalars",
+      "metadata" : true,
+      "pi_omit" : true
+    },
+    {
+      "name" : "standard_metadata",
+      "id" : 1,
+      "header_type" : "standard_metadata",
+      "metadata" : true,
+      "pi_omit" : true
+    },
+    {
+      "name" : "ethernet",
+      "id" : 2,
+      "header_type" : "ethernet_t",
+      "metadata" : false,
+      "pi_omit" : true
+    },
+    {
+      "name" : "ipv4",
+      "id" : 3,
+      "header_type" : "ipv4_t",
+      "metadata" : false,
+      "pi_omit" : true
+    },
+    {
+      "name" : "tcp",
+      "id" : 4,
+      "header_type" : "tcp_t",
+      "metadata" : false,
+      "pi_omit" : true
+    },
+    {
+      "name" : "udp",
+      "id" : 5,
+      "header_type" : "udp_t",
+      "metadata" : false,
+      "pi_omit" : true
+    },
+    {
+      "name" : "ecmp_metadata",
+      "id" : 6,
+      "header_type" : "ecmp_metadata_t",
+      "metadata" : true,
+      "pi_omit" : true
+    },
+    {
+      "name" : "wcmp_meta",
+      "id" : 7,
+      "header_type" : "wcmp_meta_t",
+      "metadata" : true,
+      "pi_omit" : true
+    },
+    {
+      "name" : "intrinsic_metadata",
+      "id" : 8,
+      "header_type" : "intrinsic_metadata_t",
+      "metadata" : true,
+      "pi_omit" : true
+    }
+  ],
+  "header_stacks" : [],
+  "field_lists" : [],
+  "errors" : [
+    ["NoError", 0],
+    ["PacketTooShort", 1],
+    ["NoMatch", 2],
+    ["StackOutOfBounds", 3],
+    ["HeaderTooShort", 4],
+    ["ParserTimeout", 5]
+  ],
+  "enums" : [],
+  "parsers" : [
+    {
+      "name" : "parser",
+      "id" : 0,
+      "init_state" : "start",
+      "parse_states" : [
+        {
+          "name" : "parse_ethernet",
+          "id" : 0,
+          "parser_ops" : [
+            {
+              "parameters" : [
+                {
+                  "type" : "regular",
+                  "value" : "ethernet"
+                }
+              ],
+              "op" : "extract"
+            }
+          ],
+          "transitions" : [
+            {
+              "value" : "0x0800",
+              "mask" : null,
+              "next_state" : "parse_ipv4"
+            },
+            {
+              "value" : "default",
+              "mask" : null,
+              "next_state" : null
+            }
+          ],
+          "transition_key" : [
+            {
+              "type" : "field",
+              "value" : ["ethernet", "etherType"]
+            }
+          ]
+        },
+        {
+          "name" : "parse_ipv4",
+          "id" : 1,
+          "parser_ops" : [
+            {
+              "parameters" : [
+                {
+                  "type" : "regular",
+                  "value" : "ipv4"
+                }
+              ],
+              "op" : "extract"
+            }
+          ],
+          "transitions" : [
+            {
+              "value" : "0x000006",
+              "mask" : null,
+              "next_state" : "parse_tcp"
+            },
+            {
+              "value" : "0x000011",
+              "mask" : null,
+              "next_state" : "parse_udp"
+            },
+            {
+              "value" : "default",
+              "mask" : null,
+              "next_state" : null
+            }
+          ],
+          "transition_key" : [
+            {
+              "type" : "field",
+              "value" : ["ipv4", "fragOffset"]
+            },
+            {
+              "type" : "field",
+              "value" : ["ipv4", "protocol"]
+            }
+          ]
+        },
+        {
+          "name" : "parse_tcp",
+          "id" : 2,
+          "parser_ops" : [
+            {
+              "parameters" : [
+                {
+                  "type" : "regular",
+                  "value" : "tcp"
+                }
+              ],
+              "op" : "extract"
+            }
+          ],
+          "transitions" : [
+            {
+              "value" : "default",
+              "mask" : null,
+              "next_state" : null
+            }
+          ],
+          "transition_key" : []
+        },
+        {
+          "name" : "parse_udp",
+          "id" : 3,
+          "parser_ops" : [
+            {
+              "parameters" : [
+                {
+                  "type" : "regular",
+                  "value" : "udp"
+                }
+              ],
+              "op" : "extract"
+            }
+          ],
+          "transitions" : [
+            {
+              "value" : "default",
+              "mask" : null,
+              "next_state" : null
+            }
+          ],
+          "transition_key" : []
+        },
+        {
+          "name" : "start",
+          "id" : 4,
+          "parser_ops" : [],
+          "transitions" : [
+            {
+              "value" : "default",
+              "mask" : null,
+              "next_state" : "parse_ethernet"
+            }
+          ],
+          "transition_key" : []
+        }
+      ]
+    }
+  ],
+  "deparsers" : [
+    {
+      "name" : "deparser",
+      "id" : 0,
+      "source_info" : {
+        "filename" : "./include/parsers.p4",
+        "line" : 34,
+        "column" : 8,
+        "source_fragment" : "DeparserImpl"
+      },
+      "order" : ["ethernet", "ipv4", "udp", "tcp"]
+    }
+  ],
+  "meter_arrays" : [],
+  "counter_arrays" : [
+    {
+      "name" : "process_port_counters_0.egress_port_counter",
+      "id" : 0,
+      "source_info" : {
+        "filename" : "./include/port_counters.p4",
+        "line" : 5,
+        "column" : 41,
+        "source_fragment" : "egress_port_counter"
+      },
+      "size" : 254,
+      "is_direct" : false
+    },
+    {
+      "name" : "process_port_counters_0.ingress_port_counter",
+      "id" : 1,
+      "source_info" : {
+        "filename" : "./include/port_counters.p4",
+        "line" : 6,
+        "column" : 41,
+        "source_fragment" : "ingress_port_counter"
+      },
+      "size" : 254,
+      "is_direct" : false
+    }
+  ],
+  "register_arrays" : [],
+  "calculations" : [],
+  "learn_lists" : [],
+  "actions" : [
+    {
+      "name" : "NoAction",
+      "id" : 0,
+      "runtime_data" : [],
+      "primitives" : []
+    },
+    {
+      "name" : "NoAction",
+      "id" : 1,
+      "runtime_data" : [],
+      "primitives" : []
+    },
+    {
+      "name" : "set_egress_port_0",
+      "id" : 2,
+      "runtime_data" : [
+        {
+          "name" : "port",
+          "bitwidth" : 9
+        }
+      ],
+      "primitives" : [
+        {
+          "op" : "assign",
+          "parameters" : [
+            {
+              "type" : "field",
+              "value" : ["standard_metadata", "egress_spec"]
+            },
+            {
+              "type" : "runtime_data",
+              "value" : 0
+            }
+          ],
+          "source_info" : {
+            "filename" : "default.p4",
+            "line" : 22,
+            "column" : 8,
+            "source_fragment" : "standard_metadata.egress_spec = port"
+          }
+        }
+      ]
+    },
+    {
+      "name" : "send_to_cpu_0",
+      "id" : 3,
+      "runtime_data" : [],
+      "primitives" : [
+        {
+          "op" : "assign",
+          "parameters" : [
+            {
+              "type" : "field",
+              "value" : ["standard_metadata", "egress_spec"]
+            },
+            {
+              "type" : "hexstr",
+              "value" : "0x00ff"
+            }
+          ],
+          "source_info" : {
+            "filename" : "default.p4",
+            "line" : 26,
+            "column" : 8,
+            "source_fragment" : "standard_metadata.egress_spec = 9w255"
+          }
+        }
+      ]
+    },
+    {
+      "name" : "_drop_0",
+      "id" : 4,
+      "runtime_data" : [],
+      "primitives" : [
+        {
+          "op" : "assign",
+          "parameters" : [
+            {
+              "type" : "field",
+              "value" : ["standard_metadata", "egress_spec"]
+            },
+            {
+              "type" : "hexstr",
+              "value" : "0x01ff"
+            }
+          ],
+          "source_info" : {
+            "filename" : "default.p4",
+            "line" : 30,
+            "column" : 8,
+            "source_fragment" : "standard_metadata.egress_spec = 9w511"
+          }
+        }
+      ]
+    },
+    {
+      "name" : "process_port_counters_0.count_packet",
+      "id" : 5,
+      "runtime_data" : [],
+      "primitives" : [
+        {
+          "op" : "assign",
+          "parameters" : [
+            {
+              "type" : "field",
+              "value" : ["scalars", "tmp"]
+            },
+            {
+              "type" : "expression",
+              "value" : {
+                "type" : "expression",
+                "value" : {
+                  "op" : "&",
+                  "left" : {
+                    "type" : "expression",
+                    "value" : {
+                      "op" : "&",
+                      "left" : {
+                        "type" : "field",
+                        "value" : ["standard_metadata", "ingress_port"]
+                      },
+                      "right" : {
+                        "type" : "hexstr",
+                        "value" : "0xff"
+                      }
+                    }
+                  },
+                  "right" : {
+                    "type" : "hexstr",
+                    "value" : "0xffffffff"
+                  }
+                }
+              }
+            }
+          ]
+        },
+        {
+          "op" : "count",
+          "parameters" : [
+            {
+              "type" : "counter_array",
+              "value" : "process_port_counters_0.ingress_port_counter"
+            },
+            {
+              "type" : "field",
+              "value" : ["scalars", "tmp"]
+            }
+          ],
+          "source_info" : {
+            "filename" : "./include/port_counters.p4",
+            "line" : 8,
+            "column" : 8,
+            "source_fragment" : "ingress_port_counter.count((bit<32>)(bit<8>)standard_metadata.ingress_port)"
+          }
+        },
+        {
+          "op" : "assign",
+          "parameters" : [
+            {
+              "type" : "field",
+              "value" : ["scalars", "tmp_0"]
+            },
+            {
+              "type" : "expression",
+              "value" : {
+                "type" : "expression",
+                "value" : {
+                  "op" : "&",
+                  "left" : {
+                    "type" : "expression",
+                    "value" : {
+                      "op" : "&",
+                      "left" : {
+                        "type" : "field",
+                        "value" : ["standard_metadata", "egress_spec"]
+                      },
+                      "right" : {
+                        "type" : "hexstr",
+                        "value" : "0xff"
+                      }
+                    }
+                  },
+                  "right" : {
+                    "type" : "hexstr",
+                    "value" : "0xffffffff"
+                  }
+                }
+              }
+            }
+          ]
+        },
+        {
+          "op" : "count",
+          "parameters" : [
+            {
+              "type" : "counter_array",
+              "value" : "process_port_counters_0.egress_port_counter"
+            },
+            {
+              "type" : "field",
+              "value" : ["scalars", "tmp_0"]
+            }
+          ],
+          "source_info" : {
+            "filename" : "./include/port_counters.p4",
+            "line" : 9,
+            "column" : 8,
+            "source_fragment" : "egress_port_counter.count((bit<32>)(bit<8>)standard_metadata.egress_spec)"
+          }
+        }
+      ]
+    }
+  ],
+  "pipelines" : [
+    {
+      "name" : "ingress",
+      "id" : 0,
+      "source_info" : {
+        "filename" : "default.p4",
+        "line" : 9,
+        "column" : 8,
+        "source_fragment" : "ingress"
+      },
+      "init_table" : "table0",
+      "tables" : [
+        {
+          "name" : "table0",
+          "id" : 0,
+          "source_info" : {
+            "filename" : "default.p4",
+            "line" : 32,
+            "column" : 10,
+            "source_fragment" : "table0"
+          },
+          "key" : [
+            {
+              "match_type" : "ternary",
+              "target" : ["standard_metadata", "ingress_port"],
+              "mask" : null
+            },
+            {
+              "match_type" : "ternary",
+              "target" : ["ethernet", "dstAddr"],
+              "mask" : null
+            },
+            {
+              "match_type" : "ternary",
+              "target" : ["ethernet", "srcAddr"],
+              "mask" : null
+            },
+            {
+              "match_type" : "ternary",
+              "target" : ["ethernet", "etherType"],
+              "mask" : null
+            }
+          ],
+          "match_type" : "ternary",
+          "type" : "simple",
+          "max_size" : 1024,
+          "with_counters" : false,
+          "support_timeout" : false,
+          "direct_meters" : null,
+          "action_ids" : [2, 3, 4, 0],
+          "actions" : ["set_egress_port_0", "send_to_cpu_0", "_drop_0", "NoAction"],
+          "base_default_next" : "node_3",
+          "next_tables" : {
+            "set_egress_port_0" : "node_3",
+            "send_to_cpu_0" : "node_3",
+            "_drop_0" : "node_3",
+            "NoAction" : "node_3"
+          },
+          "default_entry" : {
+            "action_id" : 0,
+            "action_const" : false,
+            "action_data" : [],
+            "action_entry_const" : false
+          }
+        },
+        {
+          "name" : "process_port_counters_0.port_count_table",
+          "id" : 1,
+          "source_info" : {
+            "filename" : "./include/port_counters.p4",
+            "line" : 11,
+            "column" : 10,
+            "source_fragment" : "port_count_table"
+          },
+          "key" : [],
+          "match_type" : "exact",
+          "type" : "simple",
+          "max_size" : 1024,
+          "with_counters" : false,
+          "support_timeout" : false,
+          "direct_meters" : null,
+          "action_ids" : [5, 1],
+          "actions" : ["process_port_counters_0.count_packet", "NoAction"],
+          "base_default_next" : null,
+          "next_tables" : {
+            "process_port_counters_0.count_packet" : null,
+            "NoAction" : null
+          },
+          "default_entry" : {
+            "action_id" : 1,
+            "action_const" : false,
+            "action_data" : [],
+            "action_entry_const" : false
+          }
+        }
+      ],
+      "action_profiles" : [],
+      "conditionals" : [
+        {
+          "name" : "node_3",
+          "id" : 0,
+          "source_info" : {
+            "filename" : "./include/port_counters.p4",
+            "line" : 17,
+            "column" : 12,
+            "source_fragment" : "standard_metadata.egress_spec < 9w254"
+          },
+          "expression" : {
+            "type" : "expression",
+            "value" : {
+              "op" : "<",
+              "left" : {
+                "type" : "field",
+                "value" : ["standard_metadata", "egress_spec"]
+              },
+              "right" : {
+                "type" : "hexstr",
+                "value" : "0x00fe"
+              }
+            }
+          },
+          "false_next" : null,
+          "true_next" : "process_port_counters_0.port_count_table"
+        }
+      ]
+    },
+    {
+      "name" : "egress",
+      "id" : 1,
+      "source_info" : {
+        "filename" : "default.p4",
+        "line" : 54,
+        "column" : 8,
+        "source_fragment" : "egress"
+      },
+      "init_table" : null,
+      "tables" : [],
+      "action_profiles" : [],
+      "conditionals" : []
+    }
+  ],
+  "checksums" : [],
+  "force_arith" : [],
+  "extern_instances" : [],
+  "field_aliases" : [
+    [
+      "queueing_metadata.enq_timestamp",
+      ["standard_metadata", "enq_timestamp"]
+    ],
+    [
+      "queueing_metadata.enq_qdepth",
+      ["standard_metadata", "enq_qdepth"]
+    ],
+    [
+      "queueing_metadata.deq_timedelta",
+      ["standard_metadata", "deq_timedelta"]
+    ],
+    [
+      "queueing_metadata.deq_qdepth",
+      ["standard_metadata", "deq_qdepth"]
+    ],
+    [
+      "intrinsic_metadata.ingress_global_timestamp",
+      ["standard_metadata", "ingress_global_timestamp"]
+    ],
+    [
+      "intrinsic_metadata.lf_field_list",
+      ["standard_metadata", "lf_field_list"]
+    ],
+    [
+      "intrinsic_metadata.mcast_grp",
+      ["standard_metadata", "mcast_grp"]
+    ],
+    [
+      "intrinsic_metadata.resubmit_flag",
+      ["standard_metadata", "resubmit_flag"]
+    ],
+    [
+      "intrinsic_metadata.egress_rid",
+      ["standard_metadata", "egress_rid"]
+    ]
+  ]
+}
\ No newline at end of file