Improve fabric.p4 to reduce pipeline resources and refactor pipeconf impl

This patch affects both the P4 pipeline implementation and the
Java pipeconf.

P4 PIPELINE
- Less tables and smarter use of metadata to reduce inter-tables
dependencies and favor parallel execution of tables.
- Removed unused actions / renamed existing ones to make forwarding
behavior clearer (e.g. ingress_port_vlan table)
- Remove co-existence of simple and hansed table. Hashed should be the
default one, but implementations that do not support action profiles
might compile fabric.p4 to use the simple one.
- Use @name annotations for match fields to make control plane
independent of table implementation.
- Use @hidden to avoid showing actions and table on the p4info that
cannot be controlled at runtime.
- First attempt to support double VLAN cross-connect (xconnect table).
- New design has been tested with "fabric-refactoring" branch of
fabric-p4test:
github.com/opennetworkinglab/fabric-p4test/tree/fabric-refactoring

JAVA PIPECONF
This patch brings a major refactoring that reflects the experience
gathered in the past months of working on fabric.p4 and reasoning on its
pipeconf implementation. Indeed, the FlowObjective API is
under-specified and sometimes ambiguous which makes the process of
creating and maintaining a pipeliner implementation tedious. This
refactoring brings a simplified implementation by removing unused/
unnecessary functionalities and by recognizing commonality when possible
(e.g. by means of abstract and utility classes). It also makes design
patterns more explicit and consistent. Overall, the goal is to reduce
technical debt and to make it easier to support new features as we
evolve fabric.p4

Changes include:
- Changes in pipeliner/interpreter to reflect new pipeline design.
- By default translate objective treatment to PiAction. This favors
debuggability of flow rules in ONOS.
- Support new NextObjective’s NextTreatment class.
- Remove lots of unused/unnecessary code (e.g. async callback handling
for pending objective install status in pipeliner as current
implementation was always returning success)
- Gather commonality in abstract classes and simplify implementation
for objective translator (filtering, forwarding, next)
- New implementation of ForwardingFunctionTypes (FFT) that looks at
criterion instance values along with their types (to avoid relying on
case-specific if-else conditions to recognize variants of an FFT)
- Adaptive translation of NextObjective based on presence of simple or
hashed table.
- Support DENY FilteringObjective

Also:
- Fix onos-p4-gen-constants to avoid generating conflicting
PiMatchFieldId variable names.
- Install Graphviz tools in p4vm to generate p4c graphs
- Generate p4c graphs by default when compiling fabric.p4
- Use more compact Hex string when printing PI values

Change-Id: Ife79e44054dc5bc48833f95d0551a7370150eac5
diff --git a/pipelines/fabric/src/main/resources/include/control/forwarding.p4 b/pipelines/fabric/src/main/resources/include/control/forwarding.p4
index 7c69092..e5f89cb 100644
--- a/pipelines/fabric/src/main/resources/include/control/forwarding.p4
+++ b/pipelines/fabric/src/main/resources/include/control/forwarding.p4
@@ -19,68 +19,70 @@
 
 #include "../define.p4"
 #include "../header.p4"
-#include "../action.p4"
 
 
-control Forwarding (
-    inout parsed_headers_t hdr,
-    inout fabric_metadata_t fabric_metadata,
-    inout standard_metadata_t standard_metadata) {
+control Forwarding (inout parsed_headers_t hdr,
+                    inout fabric_metadata_t fabric_metadata,
+                    inout standard_metadata_t standard_metadata) {
+
+    @hidden
+    action set_next_id(next_id_t next_id) {
+        fabric_metadata.next_id = next_id;
+    }
 
     /*
      * Bridging Table.
-     * Matches destination mac address and VLAN Id and make egress decision.
      */
     direct_counter(CounterType.packets_and_bytes) bridging_counter;
 
     action set_next_id_bridging(next_id_t next_id) {
-        fabric_metadata.next_id = next_id;
+        set_next_id(next_id);
         bridging_counter.count();
     }
 
     table bridging {
         key = {
-            hdr.vlan_tag.vlan_id: exact;
-            hdr.ethernet.dst_addr: ternary;
+            fabric_metadata.vlan_id: exact @name("vlan_id");
+            hdr.ethernet.dst_addr: ternary @name("eth_dst");
         }
-
         actions = {
             set_next_id_bridging;
+            @defaultonly nop;
         }
+        const default_action = nop();
         counters = bridging_counter;
     }
 
     /*
      * MPLS Table.
-     * Matches MPLS label and make egress decision.
      */
     direct_counter(CounterType.packets_and_bytes) mpls_counter;
 
     action pop_mpls_and_next(next_id_t next_id) {
-        hdr.mpls.setInvalid();
-        fabric_metadata.next_id = next_id;
+        fabric_metadata.mpls_label = 0;
+        set_next_id(next_id);
         mpls_counter.count();
     }
 
     table mpls {
         key = {
-            hdr.mpls.label: exact;
+            fabric_metadata.mpls_label: exact @name("mpls_label");
         }
-
         actions = {
             pop_mpls_and_next;
+            @defaultonly nop;
         }
+        const default_action = nop();
         counters = mpls_counter;
     }
 
     /*
      * IPv4 Routing Table.
-     * Matches IPv4 prefix and make egress decision.
      */
     direct_counter(CounterType.packets_and_bytes) routing_v4_counter;
 
     action set_next_id_routing_v4(next_id_t next_id) {
-        fabric_metadata.next_id = next_id;
+        set_next_id(next_id);
         routing_v4_counter.count();
     }
 
@@ -90,115 +92,47 @@
 
     table routing_v4 {
         key = {
-            hdr.ipv4.dst_addr: lpm;
+            hdr.ipv4.dst_addr: lpm @name("ipv4_dst");
         }
-
         actions = {
             set_next_id_routing_v4;
             nop_routing_v4;
+            @defaultonly nop;
         }
+        const default_action = nop();
         counters = routing_v4_counter;
     }
 
-    /*
-     * ACL Table.
-     * Make final egress decision based on general metch fields.
-     */
-    direct_counter(CounterType.packets_and_bytes) acl_counter;
-
-    action set_next_id_acl(next_id_t next_id) {
-        fabric_metadata.next_id = next_id;
-        acl_counter.count();
-    }
-
-    // Send immendiatelly to CPU - skip the rest of pipeline.
-    action punt_to_cpu() {
-        standard_metadata.egress_spec = CPU_PORT;
-        acl_counter.count();
-        exit;
-    }
-
-    action clone_to_cpu() {
-        // FIXME: works only if pkt will be replicated via PRE multicast group.
-        fabric_metadata.clone_to_cpu = _TRUE;
-        acl_counter.count();
-    }
-
-    action drop() {
-        mark_to_drop();
-        acl_counter.count();
-    }
-
-    action nop_acl() {
-        acl_counter.count();
-    }
-
-    table acl {
-        key = {
-            standard_metadata.ingress_port: ternary; // 9
-            fabric_metadata.ip_proto: ternary; // 8
-            fabric_metadata.l4_src_port: ternary; // 16
-            fabric_metadata.l4_dst_port: ternary; // 16
-
-            hdr.ethernet.dst_addr: ternary; // 48
-            hdr.ethernet.src_addr: ternary; // 48
-            hdr.vlan_tag.vlan_id: ternary; // 12
-            hdr.vlan_tag.ether_type: ternary; //16
-            hdr.ipv4.src_addr: ternary; // 32
-            hdr.ipv4.dst_addr: ternary; // 32
-            hdr.icmp.icmp_type: ternary; // 8
-            hdr.icmp.icmp_code: ternary; // 8
-        }
-
-        actions = {
-            set_next_id_acl;
-            punt_to_cpu;
-            clone_to_cpu;
-            drop;
-            nop_acl;
-        }
-
-        const default_action = nop_acl();
-        size = 128;
-        counters = acl_counter;
-    }
-
 #ifdef WITH_IPV6
     /*
      * IPv6 Routing Table.
-     * Matches IPv6 prefix and make egress decision.
      */
     direct_counter(CounterType.packets_and_bytes) routing_v6_counter;
 
     action set_next_id_routing_v6(next_id_t next_id) {
-        fabric_metadata.next_id = next_id;
+        set_next_id(next_id);
         routing_v6_counter.count();
     }
 
     table routing_v6 {
         key = {
-            hdr.ipv6.dst_addr: lpm;
+            hdr.ipv6.dst_addr: lpm @name("ipv6_dst");
         }
-
         actions = {
             set_next_id_routing_v6;
+            @defaultonly nop;
         }
+        const default_action = nop();
         counters = routing_v6_counter;
     }
 #endif // WITH_IPV6
 
     apply {
-        if(fabric_metadata.fwd_type == FWD_BRIDGING) bridging.apply();
-        else if (fabric_metadata.fwd_type == FWD_MPLS) {
-            mpls.apply();
-
-            // TODO: IPv6
-            hdr.vlan_tag.ether_type = ETHERTYPE_IPV4;
-        }
+        if (fabric_metadata.fwd_type == FWD_BRIDGING) bridging.apply();
+        else if (fabric_metadata.fwd_type == FWD_MPLS) mpls.apply();
         else if (fabric_metadata.fwd_type == FWD_IPV4_UNICAST) routing_v4.apply();
 #ifdef WITH_IPV6
         else if (fabric_metadata.fwd_type == FWD_IPV6_UNICAST) routing_v6.apply();
 #endif // WITH_IPV6
-        acl.apply();
     }
 }