Made multicast support optional in fabric.p4
Change-Id: I4efc53fb3cf4270019cd0408eac9b966fa55c2ca
diff --git a/pipelines/fabric/src/main/resources/include/control/forwarding.p4 b/pipelines/fabric/src/main/resources/include/control/forwarding.p4
index de46115..f0bfd5c 100644
--- a/pipelines/fabric/src/main/resources/include/control/forwarding.p4
+++ b/pipelines/fabric/src/main/resources/include/control/forwarding.p4
@@ -30,7 +30,6 @@
direct_counter(CounterType.packets_and_bytes) bridging_counter;
direct_counter(CounterType.packets_and_bytes) mpls_counter;
direct_counter(CounterType.packets_and_bytes) unicast_v4_counter;
- direct_counter(CounterType.packets_and_bytes) multicast_v4_counter;
direct_counter(CounterType.packets_and_bytes) acl_counter;
action drop() {
@@ -84,6 +83,9 @@
counters = unicast_v4_counter;
}
+#ifdef WITH_MULTICAST
+ direct_counter(CounterType.packets_and_bytes) multicast_v4_counter;
+
table multicast_v4 {
key = {
hdr.vlan_tag.vlan_id: exact;
@@ -95,10 +97,10 @@
}
counters = multicast_v4_counter;
}
+#endif // WITH_MULTICAST
#ifdef WITH_IPV6
direct_counter(CounterType.packets_and_bytes) unicast_v6_counter;
- direct_counter(CounterType.packets_and_bytes) multicast_v6_counter;
table unicast_v6 {
key = {
@@ -111,6 +113,9 @@
counters = unicast_v6_counter;
}
+#ifdef WITH_MULTICAST
+ direct_counter(CounterType.packets_and_bytes) multicast_v6_counter;
+
table multicast_v6 {
key = {
hdr.vlan_tag.vlan_id: exact;
@@ -122,6 +127,7 @@
}
counters = multicast_v6_counter;
}
+#endif // WITH_MULTICAST
#endif // WITH_IPV6
table acl {
@@ -163,10 +169,14 @@
fabric_metadata.original_ether_type = ETHERTYPE_IPV4;
}
else if (fabric_metadata.fwd_type == FWD_IPV4_UNICAST) unicast_v4.apply();
+#ifdef WITH_MULTICAST
else if (fabric_metadata.fwd_type == FWD_IPV4_MULTICAST) multicast_v4.apply();
+#endif // WITH_MULTICAST
#ifdef WITH_IPV6
else if (fabric_metadata.fwd_type == FWD_IPV6_UNICAST) unicast_v6.apply();
+#ifdef WITH_MULTICAST
else if (fabric_metadata.fwd_type == FWD_IPV6_MULTICAST) multicast_v6.apply();
+#endif // WITH_MULTICAST
#endif // WITH_IPV6
acl.apply();
}
diff --git a/pipelines/fabric/src/main/resources/include/control/next.p4 b/pipelines/fabric/src/main/resources/include/control/next.p4
index c76fc65..7d551dd 100644
--- a/pipelines/fabric/src/main/resources/include/control/next.p4
+++ b/pipelines/fabric/src/main/resources/include/control/next.p4
@@ -27,7 +27,6 @@
action_selector(HashAlgorithm.crc16, 32w64, 32w16) ecmp_selector;
direct_counter(CounterType.packets_and_bytes) simple_counter;
direct_counter(CounterType.packets_and_bytes) hashed_counter;
- direct_counter(CounterType.packets_and_bytes) broadcast_counter;
action output(port_num_t port_num) {
standard_metadata.egress_spec = port_num;
@@ -55,11 +54,6 @@
output(port_num);
}
- action set_mcast_group(group_id_t gid, mac_addr_t smac) {
- standard_metadata.mcast_grp = gid;
- rewrite_smac(smac);
- }
-
action push_mpls (mpls_label_t label, bit<3> tc) {
// Suppose that the maximum number of label is one.
hdr.mpls.setValid();
@@ -120,18 +114,27 @@
counters = hashed_counter;
}
+#ifdef WITH_MULTICAST
/*
* Work in progress
*/
- table broadcast {
+ action set_mcast_group(group_id_t gid, mac_addr_t smac) {
+ standard_metadata.mcast_grp = gid;
+ rewrite_smac(smac);
+ }
+
+ direct_counter(CounterType.packets_and_bytes) multicast_counter;
+
+ table multicast {
key = {
fabric_metadata.next_id: exact;
}
actions = {
set_mcast_group;
}
- counters = broadcast_counter;
+ counters = multicast_counter;
}
+#endif // WITH_MULTICAST
apply {
if (simple.apply().hit) {
@@ -147,7 +150,9 @@
}
}
hashed.apply();
- broadcast.apply();
+#ifdef WITH_MULTICAST
+ multicast.apply();
+#endif // WITH_MULTICAST
}
}