ONOS-7251 ONOS-7264 Support for clone to CPU action in fabric.p4
Clone to CPU is available only for packets processed via multicast
groups. Can be changed in the future when implementation for clone
session APIs is available in PI and P4 targets.
Also:
- compile "fabric-full" profile and generate constants from it
- use interpreter to map logical ports to data plane port IDs
Change-Id: I7db30c08dcf69ed9c870748cce8a797bbd5d6f78
diff --git a/pipelines/fabric/src/main/resources/include/control/forwarding.p4 b/pipelines/fabric/src/main/resources/include/control/forwarding.p4
index bfc180c..9d6deaa 100644
--- a/pipelines/fabric/src/main/resources/include/control/forwarding.p4
+++ b/pipelines/fabric/src/main/resources/include/control/forwarding.p4
@@ -106,9 +106,17 @@
acl_counter.count();
}
- action send_to_controller() {
+ // 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() {
@@ -135,7 +143,8 @@
actions = {
set_next_id_acl;
- send_to_controller;
+ punt_to_cpu;
+ clone_to_cpu;
drop;
@defaultonly nop;
}
diff --git a/pipelines/fabric/src/main/resources/include/control/next.p4 b/pipelines/fabric/src/main/resources/include/control/next.p4
index a9149a5..69e622b 100644
--- a/pipelines/fabric/src/main/resources/include/control/next.p4
+++ b/pipelines/fabric/src/main/resources/include/control/next.p4
@@ -200,7 +200,7 @@
action set_mcast_group(group_id_t gid) {
standard_metadata.mcast_grp = gid;
- fabric_metadata.drop_if_egress_is_ingress = _TRUE;
+ fabric_metadata.is_multicast = _TRUE;
multicast_counter.count();
}
@@ -269,7 +269,7 @@
}
apply {
- if (fabric_metadata.drop_if_egress_is_ingress == _TRUE
+ if (fabric_metadata.is_multicast == _TRUE
&& standard_metadata.ingress_port == standard_metadata.egress_port) {
drop_now();
}
diff --git a/pipelines/fabric/src/main/resources/include/control/packetio.p4 b/pipelines/fabric/src/main/resources/include/control/packetio.p4
index 9f69af1..fa447e7 100644
--- a/pipelines/fabric/src/main/resources/include/control/packetio.p4
+++ b/pipelines/fabric/src/main/resources/include/control/packetio.p4
@@ -31,9 +31,9 @@
}
control PacketIoEgress(
-inout parsed_headers_t hdr,
-inout fabric_metadata_t fabric_metadata,
-inout standard_metadata_t standard_metadata) {
+ inout parsed_headers_t hdr,
+ inout fabric_metadata_t fabric_metadata,
+ inout standard_metadata_t standard_metadata) {
action pop_vlan() {
hdr.ethernet.ether_type = hdr.vlan_tag.ether_type;
hdr.vlan_tag.setInvalid();
@@ -43,6 +43,11 @@
if (hdr.vlan_tag.isValid() && fabric_metadata.pop_vlan_when_packet_in == _TRUE) {
pop_vlan();
}
+ if (fabric_metadata.is_multicast == _TRUE &&
+ fabric_metadata.clone_to_cpu == _FALSE) {
+ // Is multicast but clone was not requested.
+ drop_now();
+ }
hdr.packet_in.setValid();
hdr.packet_in.ingress_port = standard_metadata.ingress_port;
}
diff --git a/pipelines/fabric/src/main/resources/include/header.p4 b/pipelines/fabric/src/main/resources/include/header.p4
index c81ec51..1bff3da 100644
--- a/pipelines/fabric/src/main/resources/include/header.p4
+++ b/pipelines/fabric/src/main/resources/include/header.p4
@@ -152,7 +152,8 @@
fwd_type_t fwd_type;
next_id_t next_id;
_BOOL pop_vlan_when_packet_in;
- _BOOL drop_if_egress_is_ingress;
+ _BOOL is_multicast;
+ _BOOL clone_to_cpu;
bit<8> ip_proto;
bit<16> l4_src_port;
bit<16> l4_dst_port;