From df87da37e2f18fd8b19809096603f7cf3f99c565 Mon Sep 17 00:00:00 2001 From: fruffy Date: Fri, 12 Jul 2024 18:27:02 -0400 Subject: [PATCH] Reference files. Signed-off-by: fruffy --- .../pins/pins_fabric-first.p4 | 1632 ++++++++++---- .../pins/pins_fabric-frontend.p4 | 1432 ++++++++---- .../pins/pins_fabric-midend.p4 | 1988 ++++++++++++----- .../p4_16_samples_outputs/pins/pins_fabric.p4 | 1417 +++++++++--- .../pins/pins_fabric.p4-stderr | 118 +- .../pins/pins_fabric.p4.p4info.txtpb | 1708 ++++++++++---- .../pins/pins_middleblock-first.p4 | 1610 ++++++++++--- .../pins/pins_middleblock-frontend.p4 | 1422 ++++++++---- .../pins/pins_middleblock-midend.p4 | 1958 +++++++++++----- .../pins/pins_middleblock.p4 | 1431 +++++++++--- .../pins/pins_middleblock.p4-stderr | 127 +- .../pins/pins_middleblock.p4.p4info.txtpb | 1549 +++++++++---- .../pins/pins_wbb-first.p4 | 566 ++--- .../pins/pins_wbb-frontend.p4 | 586 ++--- .../pins/pins_wbb-midend.p4 | 676 ++---- .../p4_16_samples_outputs/pins/pins_wbb.p4 | 561 ++--- .../pins/pins_wbb.p4-stderr | 33 - .../pins/pins_wbb.p4.p4info.txtpb | 664 +----- 18 files changed, 12847 insertions(+), 6631 deletions(-) diff --git a/testdata/p4_16_samples_outputs/pins/pins_fabric-first.p4 b/testdata/p4_16_samples_outputs/pins/pins_fabric-first.p4 index b6f1800018..95a5f917a0 100644 --- a/testdata/p4_16_samples_outputs/pins/pins_fabric-first.p4 +++ b/testdata/p4_16_samples_outputs/pins/pins_fabric-first.p4 @@ -5,10 +5,21 @@ typedef bit<48> ethernet_addr_t; typedef bit<32> ipv4_addr_t; typedef bit<128> ipv6_addr_t; +typedef bit<12> vlan_id_t; +typedef bit<16> ether_type_t; +const vlan_id_t INTERNAL_VLAN_ID_0 = 12w0xfff; +const vlan_id_t NO_VLAN_ID_0 = 12w0x0; header ethernet_t { ethernet_addr_t dst_addr; ethernet_addr_t src_addr; - bit<16> ether_type; + ether_type_t ether_type; +} + +header vlan_t { + bit<3> priority_code_point; + bit<1> drop_eligible_indicator; + vlan_id_t vlan_id; + ether_type_t ether_type; } header ipv4_t { @@ -65,6 +76,7 @@ header icmp_t { bit<8> type; bit<8> code; bit<16> checksum; + bit<32> rest_of_header; } header arp_t { @@ -92,109 +104,220 @@ header gre_t { bit<16> protocol; } +header ipfix_t { + bit<16> version_number; + bit<16> length; + bit<32> export_time; + bit<32> sequence_number; + bit<32> observation_domain_id; +} + +header psamp_extended_t { + bit<16> template_id; + bit<16> length; + bit<64> observation_time; + bit<16> flowset; + bit<16> next_hop_index; + bit<16> epoch; + bit<16> ingress_port; + bit<16> egress_port; + bit<16> user_meta_field; + bit<8> dlb_id; + bit<8> variable_length; + bit<16> packet_sampled_length; +} + enum bit<8> PreservedFieldList { - CLONE_I2E = 8w1 + MIRROR_AND_PACKET_IN_COPY = 8w1, + RECIRCULATE = 8w2 } type bit<10> nexthop_id_t; type bit<10> tunnel_id_t; type bit<12> wcmp_group_id_t; -type bit<10> vrf_id_t; -const vrf_id_t kDefaultVrf = (vrf_id_t)10w0; +@p4runtime_translation_mappings({ { "" , 0 } , }) type bit<10> vrf_id_t; +const vrf_id_t kDefaultVrf_0 = (vrf_id_t)10w0; type bit<10> router_interface_id_t; type bit<9> port_id_t; type bit<10> mirror_session_id_t; type bit<8> qos_queue_t; typedef bit<6> route_metadata_t; +typedef bit<8> acl_metadata_t; +typedef bit<16> multicast_group_id_t; +typedef bit<16> replica_instance_t; enum bit<2> MeterColor_t { GREEN = 2w0, YELLOW = 2w1, RED = 2w2 } +@controller_header("packet_in") header packet_in_header_t { + @id(1) + port_id_t ingress_port; + @id(2) + port_id_t target_egress_port; +} + +@controller_header("packet_out") header packet_out_header_t { + @id(1) + port_id_t egress_port; + @id(2) + bit<1> submit_to_ingress; + @id(3) @padding + bit<6> unused_pad; +} + struct headers_t { - ethernet_t erspan_ethernet; - ipv4_t erspan_ipv4; - gre_t erspan_gre; - ethernet_t ethernet; - ipv6_t tunnel_encap_ipv6; - gre_t tunnel_encap_gre; - ipv4_t ipv4; - ipv6_t ipv6; - icmp_t icmp; - tcp_t tcp; - udp_t udp; - arp_t arp; + packet_out_header_t packet_out_header; + ethernet_t mirror_encap_ethernet; + vlan_t mirror_encap_vlan; + ipv6_t mirror_encap_ipv6; + udp_t mirror_encap_udp; + ipfix_t ipfix; + psamp_extended_t psamp_extended; + ethernet_t ethernet; + vlan_t vlan; + ipv6_t tunnel_encap_ipv6; + gre_t tunnel_encap_gre; + ipv4_t ipv4; + ipv6_t ipv6; + ipv4_t inner_ipv4; + ipv6_t inner_ipv6; + icmp_t icmp; + tcp_t tcp; + udp_t udp; + arp_t arp; } struct packet_rewrites_t { ethernet_addr_t src_mac; ethernet_addr_t dst_mac; + vlan_id_t vlan_id; } struct local_metadata_t { + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + bool enable_vlan_checks; + vlan_id_t vlan_id; bool admit_to_l3; vrf_id_t vrf_id; + bool enable_decrement_ttl; + bool enable_src_mac_rewrite; + bool enable_dst_mac_rewrite; + bool enable_vlan_rewrite; packet_rewrites_t packet_rewrites; bit<16> l4_src_port; bit<16> l4_dst_port; - bit<16> wcmp_selector_input; + bit<8> wcmp_selector_input; + bool apply_tunnel_decap_at_end_of_pre_ingress; bool apply_tunnel_encap_at_egress; ipv6_addr_t tunnel_encap_src_ipv6; ipv6_addr_t tunnel_encap_dst_ipv6; - bool mirror_session_id_valid; - mirror_session_id_t mirror_session_id_value; - @field_list(PreservedFieldList.CLONE_I2E) - ipv4_addr_t mirroring_src_ip; - @field_list(PreservedFieldList.CLONE_I2E) - ipv4_addr_t mirroring_dst_ip; - @field_list(PreservedFieldList.CLONE_I2E) - ethernet_addr_t mirroring_src_mac; - @field_list(PreservedFieldList.CLONE_I2E) - ethernet_addr_t mirroring_dst_mac; - @field_list(PreservedFieldList.CLONE_I2E) - bit<8> mirroring_ttl; - @field_list(PreservedFieldList.CLONE_I2E) - bit<8> mirroring_tos; + bool marked_to_copy; + bool marked_to_mirror; + mirror_session_id_t mirror_session_id; + port_id_t mirror_egress_port; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + ethernet_addr_t mirror_encap_src_mac; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + ethernet_addr_t mirror_encap_dst_mac; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + vlan_id_t mirror_encap_vlan_id; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + ipv6_addr_t mirror_encap_src_ip; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + ipv6_addr_t mirror_encap_dst_ip; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + bit<16> mirror_encap_udp_src_port; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + bit<16> mirror_encap_udp_dst_port; + @field_list(PreservedFieldList.RECIRCULATE) + bit<9> loopback_port; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + bit<9> packet_in_ingress_port; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + bit<9> packet_in_target_egress_port; MeterColor_t color; port_id_t ingress_port; route_metadata_t route_metadata; -} - -@controller_header("packet_in") header packet_in_header_t { - @id(1) - port_id_t ingress_port; - @id(2) - port_id_t target_egress_port; -} - -@controller_header("packet_out") header packet_out_header_t { - @id(1) - port_id_t egress_port; - @id(2) - bit<1> submit_to_ingress; - @id(3) - bit<7> unused_pad; + acl_metadata_t acl_metadata; + bool bypass_ingress; + bool wcmp_group_id_valid; + wcmp_group_id_t wcmp_group_id_value; + bool nexthop_id_valid; + nexthop_id_t nexthop_id_value; + bool ipmc_table_hit; + bool acl_drop; } parser packet_parser(packet_in packet, out headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { state start { + local_metadata.enable_vlan_checks = false; + local_metadata.vlan_id = 12w0; local_metadata.admit_to_l3 = false; local_metadata.vrf_id = (vrf_id_t)10w0; + local_metadata.enable_decrement_ttl = false; + local_metadata.enable_src_mac_rewrite = false; + local_metadata.enable_dst_mac_rewrite = false; + local_metadata.enable_vlan_rewrite = false; local_metadata.packet_rewrites.src_mac = 48w0; local_metadata.packet_rewrites.dst_mac = 48w0; local_metadata.l4_src_port = 16w0; local_metadata.l4_dst_port = 16w0; - local_metadata.wcmp_selector_input = 16w0; - local_metadata.mirror_session_id_valid = false; + local_metadata.wcmp_selector_input = 8w0; + local_metadata.apply_tunnel_decap_at_end_of_pre_ingress = false; + local_metadata.apply_tunnel_encap_at_egress = false; + local_metadata.tunnel_encap_src_ipv6 = 128w0; + local_metadata.tunnel_encap_dst_ipv6 = 128w0; + local_metadata.marked_to_copy = false; + local_metadata.marked_to_mirror = false; + local_metadata.mirror_session_id = (mirror_session_id_t)10w0; + local_metadata.mirror_egress_port = (port_id_t)9w0; local_metadata.color = MeterColor_t.GREEN; - local_metadata.ingress_port = (port_id_t)standard_metadata.ingress_port; local_metadata.route_metadata = 6w0; + local_metadata.bypass_ingress = false; + local_metadata.wcmp_group_id_valid = false; + local_metadata.wcmp_group_id_value = (wcmp_group_id_t)12w0; + local_metadata.nexthop_id_valid = false; + local_metadata.nexthop_id_value = (nexthop_id_t)10w0; + local_metadata.ipmc_table_hit = false; + local_metadata.acl_drop = false; + transition select(standard_metadata.instance_type == 32w4) { + true: start_true; + false: start_false; + } + } + state start_true { + local_metadata.ingress_port = (port_id_t)local_metadata.loopback_port; + transition start_join; + } + state start_false { + local_metadata.ingress_port = (port_id_t)standard_metadata.ingress_port; + transition start_join; + } + state start_join { + transition select(standard_metadata.ingress_port) { + 9w510: parse_packet_out_header; + default: parse_ethernet; + } + } + state parse_packet_out_header { + packet.extract(headers.packet_out_header); transition parse_ethernet; } state parse_ethernet { packet.extract(headers.ethernet); transition select(headers.ethernet.ether_type) { + 16w0x800: parse_ipv4; + 16w0x86dd: parse_ipv6; + 16w0x806: parse_arp; + 16w0x8100: parse_8021q_vlan; + default: accept; + } + } + state parse_8021q_vlan { + packet.extract(headers.vlan); + transition select(headers.vlan.ether_type) { 16w0x800: parse_ipv4; 16w0x86dd: parse_ipv6; 16w0x806: parse_arp; @@ -204,6 +327,17 @@ parser packet_parser(packet_in packet, out headers_t headers, inout local_metada state parse_ipv4 { packet.extract(headers.ipv4); transition select(headers.ipv4.protocol) { + 8w0x4: parse_ipv4_in_ip; + 8w0x29: parse_ipv6_in_ip; + 8w0x1: parse_icmp; + 8w0x6: parse_tcp; + 8w0x11: parse_udp; + default: accept; + } + } + state parse_ipv4_in_ip { + packet.extract(headers.inner_ipv4); + transition select(headers.inner_ipv4.protocol) { 8w0x1: parse_icmp; 8w0x6: parse_tcp; 8w0x11: parse_udp; @@ -213,6 +347,17 @@ parser packet_parser(packet_in packet, out headers_t headers, inout local_metada state parse_ipv6 { packet.extract(headers.ipv6); transition select(headers.ipv6.next_header) { + 8w0x4: parse_ipv4_in_ip; + 8w0x29: parse_ipv6_in_ip; + 8w0x3a: parse_icmp; + 8w0x6: parse_tcp; + 8w0x11: parse_udp; + default: accept; + } + } + state parse_ipv6_in_ip { + packet.extract(headers.inner_ipv6); + transition select(headers.inner_ipv6.next_header) { 8w0x3a: parse_icmp; 8w0x6: parse_tcp; 8w0x11: parse_udp; @@ -243,14 +388,21 @@ parser packet_parser(packet_in packet, out headers_t headers, inout local_metada control packet_deparser(packet_out packet, in headers_t headers) { apply { - packet.emit(headers.erspan_ethernet); - packet.emit(headers.erspan_ipv4); - packet.emit(headers.erspan_gre); + packet.emit(headers.packet_out_header); + packet.emit(headers.mirror_encap_ethernet); + packet.emit(headers.mirror_encap_vlan); + packet.emit(headers.mirror_encap_ipv6); + packet.emit(headers.mirror_encap_udp); + packet.emit(headers.ipfix); + packet.emit(headers.psamp_extended); packet.emit(headers.ethernet); + packet.emit(headers.vlan); packet.emit(headers.tunnel_encap_ipv6); packet.emit(headers.tunnel_encap_gre); packet.emit(headers.ipv4); packet.emit(headers.ipv6); + packet.emit(headers.inner_ipv4); + packet.emit(headers.inner_ipv6); packet.emit(headers.arp); packet.emit(headers.icmp); packet.emit(headers.tcp); @@ -258,181 +410,274 @@ control packet_deparser(packet_out packet, in headers_t headers) { } } -control routing(in headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { - bool wcmp_group_id_valid = false; - wcmp_group_id_t wcmp_group_id_value; - bool nexthop_id_valid = false; - nexthop_id_t nexthop_id_value; - bool router_interface_id_valid = false; - router_interface_id_t router_interface_id_value; - bool neighbor_id_valid = false; - ipv6_addr_t neighbor_id_value; - @id(0x01000001) action set_dst_mac(@id(1) @format(MAC_ADDRESS) ethernet_addr_t dst_mac) { - local_metadata.packet_rewrites.dst_mac = dst_mac; +control packet_in_encap(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control packet_out_decap(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { + apply { + if (headers.packet_out_header.isValid() && headers.packet_out_header.submit_to_ingress == 1w0) { + standard_metadata.egress_spec = (bit<9>)headers.packet_out_header.egress_port; + local_metadata.bypass_ingress = true; + } + headers.packet_out_header.setInvalid(); } - @p4runtime_role("sdn_controller") @id(0x02000040) table neighbor_table { +} + +@id(0x01000005) action set_nexthop_id(inout local_metadata_t local_metadata, @id(1) @refers_to(nexthop_table , nexthop_id) nexthop_id_t nexthop_id) { + local_metadata.nexthop_id_valid = true; + local_metadata.nexthop_id_value = nexthop_id; +} +control routing_lookup(in headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { + @id(0x01798B9E) @name("no_action") action no_action_0() { + } + @entry_restriction(" + // The VRF ID 0 (or '' in P4Runtime) encodes the default VRF, which cannot + // be read or written via this table, but is always present implicitly. + // TODO: This constraint should read `vrf_id != ''` (since + // constraints are a control plane (P4Runtime) concept), but + // p4-constraints does not currently support strings. + vrf_id != 0; + ") @p4runtime_role("sdn_controller") @id(0x0200004A) @name("vrf_table") table vrf_table_0 { key = { - router_interface_id_value: exact @id(1) @name("router_interface_id") @refers_to(router_interface_table , router_interface_id); - neighbor_id_value : exact @id(2) @format(IPV6_ADDRESS) @name("neighbor_id"); + local_metadata.vrf_id: exact @id(1) @name("vrf_id"); } actions = { - @proto_id(1) set_dst_mac(); - @defaultonly NoAction(); + @proto_id(1) no_action_0(); } - const default_action = NoAction(); - size = 1024; + const default_action = no_action_0(); + size = 64; } - @id(0x01000002) action set_port_and_src_mac(@id(1) port_id_t port, @id(2) @format(MAC_ADDRESS) ethernet_addr_t src_mac) { - standard_metadata.egress_spec = (bit<9>)port; - local_metadata.packet_rewrites.src_mac = src_mac; + @id(0x01000006) @name("drop") action drop_0() { + mark_to_drop(standard_metadata); + } + @id(0x01000004) @name("set_wcmp_group_id") action set_wcmp_group_id_0(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) wcmp_group_id_t wcmp_group_id) { + local_metadata.wcmp_group_id_valid = true; + local_metadata.wcmp_group_id_value = wcmp_group_id; + } + @id(0x01000011) @name("set_wcmp_group_id_and_metadata") action set_wcmp_group_id_and_metadata_0(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) wcmp_group_id_t wcmp_group_id, route_metadata_t route_metadata) { + set_wcmp_group_id_0(wcmp_group_id); + local_metadata.route_metadata = route_metadata; + } + @id(0x01000015) @name("set_metadata_and_drop") action set_metadata_and_drop_0(@id(1) route_metadata_t route_metadata) { + local_metadata.route_metadata = route_metadata; + mark_to_drop(standard_metadata); + } + @id(0x01000010) @name("set_nexthop_id_and_metadata") action set_nexthop_id_and_metadata_0(@id(1) @refers_to(nexthop_table , nexthop_id) nexthop_id_t nexthop_id, route_metadata_t route_metadata) { + local_metadata.nexthop_id_valid = true; + local_metadata.nexthop_id_value = nexthop_id; + local_metadata.route_metadata = route_metadata; + } + @id(0x01000018) @action_restriction(" + // Disallow 0 since it encodes 'no multicast' in V1Model. + multicast_group_id != 0; + ") @name("set_multicast_group_id") action set_multicast_group_id_0(@id(1) @refers_to(builtin : : multicast_group_table , multicast_group_id) multicast_group_id_t multicast_group_id) { + standard_metadata.mcast_grp = multicast_group_id; } - @p4runtime_role("sdn_controller") @id(0x02000041) table router_interface_table { + @p4runtime_role("sdn_controller") @id(0x02000044) @name("ipv4_table") table ipv4_table_0 { key = { - router_interface_id_value: exact @id(1) @name("router_interface_id"); + local_metadata.vrf_id: exact @id(1) @name("vrf_id") @refers_to(vrf_table , vrf_id); + headers.ipv4.dst_addr: lpm @id(2) @name("ipv4_dst") @format(IPV4_ADDRESS); } actions = { - @proto_id(1) set_port_and_src_mac(); - @defaultonly NoAction(); + @proto_id(1) drop_0(); + @proto_id(2) set_nexthop_id(local_metadata); + @proto_id(3) set_wcmp_group_id_0(); + @proto_id(5) set_nexthop_id_and_metadata_0(); + @proto_id(6) set_wcmp_group_id_and_metadata_0(); + @proto_id(7) set_metadata_and_drop_0(); } - const default_action = NoAction(); - size = 256; + const default_action = drop_0(); + size = 131072; } - @id(0x01000014) action set_ip_nexthop(@id(1) @refers_to(router_interface_table , router_interface_id) @refers_to(neighbor_table , router_interface_id) router_interface_id_t router_interface_id, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) ipv6_addr_t neighbor_id) { - router_interface_id_valid = true; - router_interface_id_value = router_interface_id; - neighbor_id_valid = true; - neighbor_id_value = neighbor_id; + @p4runtime_role("sdn_controller") @id(0x02000045) @name("ipv6_table") table ipv6_table_0 { + key = { + local_metadata.vrf_id: exact @id(1) @name("vrf_id") @refers_to(vrf_table , vrf_id); + headers.ipv6.dst_addr: lpm @id(2) @name("ipv6_dst") @format(IPV6_ADDRESS); + } + actions = { + @proto_id(1) drop_0(); + @proto_id(2) set_nexthop_id(local_metadata); + @proto_id(3) set_wcmp_group_id_0(); + @proto_id(5) set_nexthop_id_and_metadata_0(); + @proto_id(6) set_wcmp_group_id_and_metadata_0(); + @proto_id(7) set_metadata_and_drop_0(); + } + const default_action = drop_0(); + size = 17000; } - @id(0x01000003) @deprecated("Use set_ip_nexthop instead.") action set_nexthop(@id(1) @refers_to(router_interface_table , router_interface_id) @refers_to(neighbor_table , router_interface_id) router_interface_id_t router_interface_id, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) ipv6_addr_t neighbor_id) { - set_ip_nexthop(router_interface_id, neighbor_id); + @p4runtime_role("sdn_controller") @id(0x0200004E) @name("ipv4_multicast_table") table ipv4_multicast_table_0 { + key = { + local_metadata.vrf_id: exact @id(1) @name("vrf_id") @refers_to(vrf_table , vrf_id); + headers.ipv4.dst_addr: exact @id(2) @name("ipv4_dst") @format(IPV4_ADDRESS); + } + actions = { + @proto_id(1) set_multicast_group_id_0(); + @defaultonly NoAction(); + } + size = 1600; + default_action = NoAction(); } - @p4runtime_role("sdn_controller") @id(0x02000042) table nexthop_table { + @p4runtime_role("sdn_controller") @id(0x0200004F) @name("ipv6_multicast_table") table ipv6_multicast_table_0 { key = { - nexthop_id_value: exact @id(1) @name("nexthop_id"); + local_metadata.vrf_id: exact @id(1) @name("vrf_id") @refers_to(vrf_table , vrf_id); + headers.ipv6.dst_addr: exact @id(2) @name("ipv6_dst") @format(IPV6_ADDRESS); } actions = { - @proto_id(1) set_nexthop(); - @proto_id(3) set_ip_nexthop(); + @proto_id(1) set_multicast_group_id_0(); @defaultonly NoAction(); } - const default_action = NoAction(); - size = 1024; + size = 1600; + default_action = NoAction(); } - @id(0x01000005) action set_nexthop_id(@id(1) @refers_to(nexthop_table , nexthop_id) nexthop_id_t nexthop_id) { - nexthop_id_valid = true; - nexthop_id_value = nexthop_id; + apply { + mark_to_drop(standard_metadata); + vrf_table_0.apply(); + if (local_metadata.admit_to_l3) { + if (headers.ipv4.isValid()) { + ipv4_table_0.apply(); + ipv4_multicast_table_0.apply(); + local_metadata.ipmc_table_hit = standard_metadata.mcast_grp != 16w0; + } else if (headers.ipv6.isValid()) { + ipv6_table_0.apply(); + ipv6_multicast_table_0.apply(); + local_metadata.ipmc_table_hit = standard_metadata.mcast_grp != 16w0; + } + } } - @id(0x01000010) action set_nexthop_id_and_metadata(@id(1) @refers_to(nexthop_table , nexthop_id) nexthop_id_t nexthop_id, route_metadata_t route_metadata) { - nexthop_id_valid = true; - nexthop_id_value = nexthop_id; - local_metadata.route_metadata = route_metadata; +} + +control routing_resolution(in headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { + @name("tunnel_id_valid") bool tunnel_id_valid_0 = false; + @name("tunnel_id_value") tunnel_id_t tunnel_id_value_0; + @name("router_interface_id_valid") bool router_interface_id_valid_0 = false; + @name("router_interface_id_value") router_interface_id_t router_interface_id_value_0; + @name("neighbor_id_valid") bool neighbor_id_valid_0 = false; + @name("neighbor_id_value") ipv6_addr_t neighbor_id_value_0; + @id(0x01000001) @name("set_dst_mac") action set_dst_mac_0(@id(1) @format(MAC_ADDRESS) ethernet_addr_t dst_mac) { + local_metadata.packet_rewrites.dst_mac = dst_mac; } - @max_group_size(256) action_selector(HashAlgorithm.identity, 32w65536, 32w16) wcmp_group_selector; - @p4runtime_role("sdn_controller") @id(0x02000043) @oneshot table wcmp_group_table { + @p4runtime_role("sdn_controller") @id(0x02000040) @name("neighbor_table") table neighbor_table_0 { key = { - wcmp_group_id_value : exact @id(1) @name("wcmp_group_id"); - local_metadata.wcmp_selector_input: selector @name("local_metadata.wcmp_selector_input"); + router_interface_id_value_0: exact @id(1) @name("router_interface_id") @refers_to(router_interface_table , router_interface_id); + neighbor_id_value_0 : exact @id(2) @format(IPV6_ADDRESS) @name("neighbor_id"); } actions = { - @proto_id(1) set_nexthop_id(); + @proto_id(1) set_dst_mac_0(); @defaultonly NoAction(); } const default_action = NoAction(); - @id(0x11DC4EC8) implementation = wcmp_group_selector; - size = 3968; + size = 1024; + } + @id(0x0100001B) @unsupported @action_restriction(" + // Disallow reserved VLAN IDs with implementation-defined semantics. + vlan_id != 0 && vlan_id != 4095") @name("set_port_and_src_mac_and_vlan_id") action set_port_and_src_mac_and_vlan_id_0(@id(1) port_id_t port, @id(2) @format(MAC_ADDRESS) ethernet_addr_t src_mac, @id(3) vlan_id_t vlan_id) { + standard_metadata.egress_spec = (bit<9>)port; + local_metadata.packet_rewrites.src_mac = src_mac; + local_metadata.packet_rewrites.vlan_id = vlan_id; } - action no_action() { + @id(0x01000002) @name("set_port_and_src_mac") action set_port_and_src_mac_0(@id(1) port_id_t port, @id(2) @format(MAC_ADDRESS) ethernet_addr_t src_mac) { + set_port_and_src_mac_and_vlan_id_0(port, src_mac, 12w0xfff); } - @entry_restriction(" - // The VRF ID 0 (or '' in P4Runtime) encodes the default VRF, which cannot - // be read or written via this table, but is always present implicitly. - // TODO: This constraint should read `vrf_id != ''` (since - // constraints are a control plane (P4Runtime) concept), but - // p4-constraints does not currently support strings. - vrf_id != 0; - ") @p4runtime_role("sdn_controller") @id(0x0200004A) table vrf_table { + @p4runtime_role("sdn_controller") @id(0x02000041) @name("router_interface_table") table router_interface_table_0 { key = { - local_metadata.vrf_id: exact @id(1) @name("vrf_id"); + router_interface_id_value_0: exact @id(1) @name("router_interface_id"); } actions = { - @proto_id(1) no_action(); + @proto_id(1) set_port_and_src_mac_0(); + @proto_id(2) set_port_and_src_mac_and_vlan_id_0(); + @defaultonly NoAction(); } - const default_action = no_action(); - size = 64; + const default_action = NoAction(); + size = 256; } - @id(0x01000006) action drop() { - mark_to_drop(standard_metadata); + @id(0x01000017) @name("set_ip_nexthop_and_disable_rewrites") action set_ip_nexthop_and_disable_rewrites_0(@id(1) @refers_to(router_interface_table , router_interface_id) @refers_to(neighbor_table , router_interface_id) router_interface_id_t router_interface_id, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) ipv6_addr_t neighbor_id, @id(3) bit<1> disable_decrement_ttl, @id(4) bit<1> disable_src_mac_rewrite, @id(5) bit<1> disable_dst_mac_rewrite, @id(6) bit<1> disable_vlan_rewrite) { + router_interface_id_valid_0 = true; + router_interface_id_value_0 = router_interface_id; + neighbor_id_valid_0 = true; + neighbor_id_value_0 = neighbor_id; + local_metadata.enable_decrement_ttl = !(bool)disable_decrement_ttl; + local_metadata.enable_src_mac_rewrite = !(bool)disable_src_mac_rewrite; + local_metadata.enable_dst_mac_rewrite = !(bool)disable_dst_mac_rewrite; + local_metadata.enable_vlan_rewrite = !(bool)disable_vlan_rewrite; } - @id(0x01000004) action set_wcmp_group_id(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) wcmp_group_id_t wcmp_group_id) { - wcmp_group_id_valid = true; - wcmp_group_id_value = wcmp_group_id; + @id(0x01000014) @name("set_ip_nexthop") action set_ip_nexthop_0(@id(1) @refers_to(router_interface_table , router_interface_id) @refers_to(neighbor_table , router_interface_id) router_interface_id_t router_interface_id, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) ipv6_addr_t neighbor_id) { + set_ip_nexthop_and_disable_rewrites_0(router_interface_id, neighbor_id, 1w0x0, 1w0x0, 1w0x0, 1w0x0); } - @id(0x01000011) action set_wcmp_group_id_and_metadata(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) wcmp_group_id_t wcmp_group_id, route_metadata_t route_metadata) { - set_wcmp_group_id(wcmp_group_id); - local_metadata.route_metadata = route_metadata; + @id(0x01000003) @deprecated("Use set_ip_nexthop instead.") @name("set_nexthop") action set_nexthop_0(@id(1) @refers_to(router_interface_table , router_interface_id) @refers_to(neighbor_table , router_interface_id) router_interface_id_t router_interface_id, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) ipv6_addr_t neighbor_id) { + set_ip_nexthop_0(router_interface_id, neighbor_id); } - @id(0x0100000F) action trap() { - clone(CloneType.I2E, 32w1024); - mark_to_drop(standard_metadata); + @id(0x01000012) @name("set_p2p_tunnel_encap_nexthop") action set_p2p_tunnel_encap_nexthop_0(@id(1) @refers_to(tunnel_table , tunnel_id) tunnel_id_t tunnel_id) { + tunnel_id_valid_0 = true; + tunnel_id_value_0 = tunnel_id; } - @id(0x01000015) action set_metadata_and_drop(@id(1) route_metadata_t route_metadata) { - local_metadata.route_metadata = route_metadata; - mark_to_drop(standard_metadata); + @p4runtime_role("sdn_controller") @id(0x02000042) @name("nexthop_table") table nexthop_table_0 { + key = { + local_metadata.nexthop_id_value: exact @id(1) @name("nexthop_id"); + } + actions = { + @proto_id(1) set_nexthop_0(); + @proto_id(2) set_p2p_tunnel_encap_nexthop_0(); + @proto_id(3) set_ip_nexthop_0(); + @proto_id(4) set_ip_nexthop_and_disable_rewrites_0(); + @defaultonly NoAction(); + } + const default_action = NoAction(); + size = 1024; } - @p4runtime_role("sdn_controller") @id(0x02000044) table ipv4_table { + @id(0x01000013) @name("mark_for_p2p_tunnel_encap") action mark_for_p2p_tunnel_encap_0(@id(1) @format(IPV6_ADDRESS) ipv6_addr_t encap_src_ip, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) ipv6_addr_t encap_dst_ip, @id(3) @refers_to(neighbor_table , router_interface_id) @refers_to(router_interface_table , router_interface_id) router_interface_id_t router_interface_id) { + local_metadata.tunnel_encap_src_ipv6 = encap_src_ip; + local_metadata.tunnel_encap_dst_ipv6 = encap_dst_ip; + local_metadata.apply_tunnel_encap_at_egress = true; + set_ip_nexthop_0(router_interface_id, encap_dst_ip); + } + @p4runtime_role("sdn_controller") @id(0x02000050) @name("tunnel_table") table tunnel_table_0 { key = { - local_metadata.vrf_id: exact @id(1) @name("vrf_id") @refers_to(vrf_table , vrf_id); - headers.ipv4.dst_addr: lpm @format(IPV4_ADDRESS) @id(2) @name("ipv4_dst"); + tunnel_id_value_0: exact @id(1) @name("tunnel_id"); } actions = { - @proto_id(1) drop(); - @proto_id(2) set_nexthop_id(); - @proto_id(3) set_wcmp_group_id(); - @proto_id(4) trap(); - @proto_id(5) set_nexthop_id_and_metadata(); - @proto_id(6) set_wcmp_group_id_and_metadata(); - @proto_id(7) set_metadata_and_drop(); - } - const default_action = drop(); - size = 32768; - } - @p4runtime_role("sdn_controller") @id(0x02000045) table ipv6_table { + @proto_id(1) mark_for_p2p_tunnel_encap_0(); + @defaultonly NoAction(); + } + const default_action = NoAction(); + size = 2048; + } + @max_group_size(512) @id(0x11DC4EC8) @name("wcmp_group_selector") action_selector(HashAlgorithm.identity, 32w49152, 32w8) wcmp_group_selector_0; + @p4runtime_role("sdn_controller") @id(0x02000043) @oneshot @name("wcmp_group_table") table wcmp_group_table_0 { key = { - local_metadata.vrf_id: exact @id(1) @name("vrf_id") @refers_to(vrf_table , vrf_id); - headers.ipv6.dst_addr: lpm @format(IPV6_ADDRESS) @id(2) @name("ipv6_dst"); + local_metadata.wcmp_group_id_value: exact @id(1) @name("wcmp_group_id"); + local_metadata.wcmp_selector_input: selector @name("local_metadata.wcmp_selector_input"); } actions = { - @proto_id(1) drop(); - @proto_id(2) set_nexthop_id(); - @proto_id(3) set_wcmp_group_id(); - @proto_id(4) trap(); - @proto_id(5) set_nexthop_id_and_metadata(); - @proto_id(6) set_wcmp_group_id_and_metadata(); - @proto_id(7) set_metadata_and_drop(); + @proto_id(1) set_nexthop_id(local_metadata); + @defaultonly NoAction(); } - const default_action = drop(); - size = 4096; + const default_action = NoAction(); + implementation = wcmp_group_selector_0; + size = 3968; } apply { - mark_to_drop(standard_metadata); - vrf_table.apply(); if (local_metadata.admit_to_l3) { - if (headers.ipv4.isValid()) { - ipv4_table.apply(); - } else if (headers.ipv6.isValid()) { - ipv6_table.apply(); - } - if (wcmp_group_id_valid) { - wcmp_group_table.apply(); + if (local_metadata.wcmp_group_id_valid) { + wcmp_group_table_0.apply(); } - if (nexthop_id_valid) { - nexthop_table.apply(); - if (router_interface_id_valid && neighbor_id_valid) { - router_interface_table.apply(); - neighbor_table.apply(); + if (local_metadata.nexthop_id_valid) { + nexthop_table_0.apply(); + if (tunnel_id_valid_0) { + tunnel_table_0.apply(); + } + if (router_interface_id_valid_0 && neighbor_id_valid_0) { + router_interface_table_0.apply(); + neighbor_table_0.apply(); } } } + local_metadata.packet_in_target_egress_port = standard_metadata.egress_spec; + local_metadata.packet_in_ingress_port = standard_metadata.ingress_port; + if (local_metadata.acl_drop) { + mark_to_drop(standard_metadata); + } } } @@ -444,161 +689,401 @@ control verify_ipv4_checksum(inout headers_t headers, inout local_metadata_t loc control compute_ipv4_checksum(inout headers_t headers, inout local_metadata_t local_metadata) { apply { - update_checksum, bit<4>, bit<6>, bit<2>, bit<16>, bit<16>, bit<1>, bit<1>, bit<1>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>, bit<16>>(headers.erspan_ipv4.isValid(), { headers.erspan_ipv4.version, headers.erspan_ipv4.ihl, headers.erspan_ipv4.dscp, headers.erspan_ipv4.ecn, headers.erspan_ipv4.total_len, headers.erspan_ipv4.identification, headers.erspan_ipv4.reserved, headers.erspan_ipv4.do_not_fragment, headers.erspan_ipv4.more_fragments, headers.erspan_ipv4.frag_offset, headers.erspan_ipv4.ttl, headers.erspan_ipv4.protocol, headers.erspan_ipv4.src_addr, headers.erspan_ipv4.dst_addr }, headers.erspan_ipv4.header_checksum, HashAlgorithm.csum16); update_checksum, bit<4>, bit<6>, bit<2>, bit<16>, bit<16>, bit<1>, bit<1>, bit<1>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>, bit<16>>(headers.ipv4.isValid(), { headers.ipv4.version, headers.ipv4.ihl, headers.ipv4.dscp, headers.ipv4.ecn, headers.ipv4.total_len, headers.ipv4.identification, headers.ipv4.reserved, headers.ipv4.do_not_fragment, headers.ipv4.more_fragments, headers.ipv4.frag_offset, headers.ipv4.ttl, headers.ipv4.protocol, headers.ipv4.src_addr, headers.ipv4.dst_addr }, headers.ipv4.header_checksum, HashAlgorithm.csum16); } } -control mirroring_encap(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { - apply { - if (standard_metadata.instance_type == 32w1) { - headers.erspan_ethernet.setValid(); - headers.erspan_ethernet.src_addr = local_metadata.mirroring_src_mac; - headers.erspan_ethernet.dst_addr = local_metadata.mirroring_dst_mac; - headers.erspan_ethernet.ether_type = 16w0x800; - headers.erspan_ipv4.setValid(); - headers.erspan_ipv4.src_addr = local_metadata.mirroring_src_ip; - headers.erspan_ipv4.dst_addr = local_metadata.mirroring_dst_ip; - headers.erspan_ipv4.version = 4w4; - headers.erspan_ipv4.ihl = 4w5; - headers.erspan_ipv4.protocol = 8w0x2f; - headers.erspan_ipv4.ttl = local_metadata.mirroring_ttl; - headers.erspan_ipv4.dscp = local_metadata.mirroring_tos[7:2]; - headers.erspan_ipv4.ecn = local_metadata.mirroring_tos[1:0]; - headers.erspan_ipv4.total_len = 16w24 + (bit<16>)standard_metadata.packet_length; - headers.erspan_ipv4.identification = 16w0; - headers.erspan_ipv4.reserved = 1w0; - headers.erspan_ipv4.do_not_fragment = 1w1; - headers.erspan_ipv4.more_fragments = 1w0; - headers.erspan_ipv4.frag_offset = 13w0; - headers.erspan_ipv4.header_checksum = 16w0; - headers.erspan_gre.setValid(); - headers.erspan_gre.checksum_present = 1w0; - headers.erspan_gre.routing_present = 1w0; - headers.erspan_gre.key_present = 1w0; - headers.erspan_gre.sequence_present = 1w0; - headers.erspan_gre.strict_source_route = 1w0; - headers.erspan_gre.recursion_control = 3w0; - headers.erspan_gre.acknowledgement_present = 1w0; - headers.erspan_gre.flags = 4w0; - headers.erspan_gre.version = 3w0; - headers.erspan_gre.protocol = 16w0x88be; - } - } -} - -control mirroring_clone(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { - port_id_t mirror_port; - bit<32> pre_session; - @id(0x01000007) action mirror_as_ipv4_erspan(@id(1) port_id_t port, @id(2) @format(IPV4_ADDRESS) ipv4_addr_t src_ip, @id(3) @format(IPV4_ADDRESS) ipv4_addr_t dst_ip, @id(4) @format(MAC_ADDRESS) ethernet_addr_t src_mac, @id(5) @format(MAC_ADDRESS) ethernet_addr_t dst_mac, @id(6) bit<8> ttl, @id(7) bit<8> tos) { - mirror_port = port; - local_metadata.mirroring_src_ip = src_ip; - local_metadata.mirroring_dst_ip = dst_ip; - local_metadata.mirroring_src_mac = src_mac; - local_metadata.mirroring_dst_mac = dst_mac; - local_metadata.mirroring_ttl = ttl; - local_metadata.mirroring_tos = tos; - } - @p4runtime_role("sdn_controller") @id(0x02000046) table mirror_session_table { +control ingress_cloning(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { + @id(0x0100001C) @name("ingress_clone") action ingress_clone_0(@id(1) bit<32> clone_session) { + clone_preserving_field_list(CloneType.I2E, clone_session, PreservedFieldList.MIRROR_AND_PACKET_IN_COPY); + } + @unsupported @p4runtime_role("packet_replication_engine_manager") @id(0x02000051) @entry_restriction(" + // mirror_egress_port is present iff marked_to_mirror is true. + // Exact match indicating presence of mirror_egress_port. + marked_to_mirror == 1 -> mirror_egress_port::mask == -1; + // Wildcard match indicating abscence of mirror_egress_port. + marked_to_mirror == 0 -> mirror_egress_port::mask == 0; + ") @name("ingress_clone_table") table ingress_clone_table_0 { key = { - local_metadata.mirror_session_id_value: exact @id(1) @name("mirror_session_id"); + local_metadata.marked_to_copy : exact @id(1) @name("marked_to_copy"); + local_metadata.marked_to_mirror : exact @id(2) @name("marked_to_mirror"); + local_metadata.mirror_egress_port: optional @id(3) @name("mirror_egress_port"); } actions = { - @proto_id(1) mirror_as_ipv4_erspan(); + @proto_id(1) ingress_clone_0(); @defaultonly NoAction(); } - const default_action = NoAction(); - size = 2; + default_action = NoAction(); } - @id(0x01000009) action set_pre_session(bit<32> id) { - pre_session = id; + apply { + ingress_clone_table_0.apply(); + } +} + +control mirror_session_lookup(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { + @id(0x01000007) @name("mirror_as_ipv4_erspan") action mirror_as_ipv4_erspan_0(@id(1) port_id_t port, @id(2) @format(IPV4_ADDRESS) ipv4_addr_t src_ip, @id(3) @format(IPV4_ADDRESS) ipv4_addr_t dst_ip, @id(4) @format(MAC_ADDRESS) ethernet_addr_t src_mac, @id(5) @format(MAC_ADDRESS) ethernet_addr_t dst_mac, @id(6) bit<8> ttl, @id(7) bit<8> tos) { } - @p4runtime_role("packet_replication_engine_manager") @id(0x02000048) table mirror_port_to_pre_session_table { + @id(0x0100001D) @unsupported @name("mirror_with_vlan_tag_and_ipfix_encapsulation") action mirror_with_vlan_tag_and_ipfix_encapsulation_0(@id(1) port_id_t monitor_port, @id(2) port_id_t monitor_failover_port, @id(3) @format(MAC_ADDRESS) ethernet_addr_t mirror_encap_src_mac, @id(4) @format(MAC_ADDRESS) ethernet_addr_t mirror_encap_dst_mac, @id(6) vlan_id_t mirror_encap_vlan_id, @id(7) @format(IPV6_ADDRESS) ipv6_addr_t mirror_encap_dst_ip, @id(8) @format(IPV6_ADDRESS) ipv6_addr_t mirror_encap_src_ip, @id(9) bit<16> mirror_encap_udp_src_port, @id(10) bit<16> mirror_encap_udp_dst_port) { + local_metadata.mirror_egress_port = monitor_port; + local_metadata.mirror_encap_src_mac = mirror_encap_src_mac; + local_metadata.mirror_encap_dst_mac = mirror_encap_dst_mac; + local_metadata.mirror_encap_vlan_id = mirror_encap_vlan_id; + local_metadata.mirror_encap_src_ip = mirror_encap_src_ip; + local_metadata.mirror_encap_dst_ip = mirror_encap_dst_ip; + local_metadata.mirror_encap_udp_src_port = mirror_encap_udp_src_port; + local_metadata.mirror_encap_udp_dst_port = mirror_encap_udp_dst_port; + } + @p4runtime_role("sdn_controller") @id(0x02000046) @name("mirror_session_table") table mirror_session_table_0 { key = { - mirror_port: exact @id(1) @name("mirror_port"); + local_metadata.mirror_session_id: exact @id(1) @name("mirror_session_id"); } actions = { - @proto_id(1) set_pre_session(); + @proto_id(1) mirror_as_ipv4_erspan_0(); + @proto_id(2) mirror_with_vlan_tag_and_ipfix_encapsulation_0(); @defaultonly NoAction(); } const default_action = NoAction(); + size = 4; } apply { - if (local_metadata.mirror_session_id_valid) { - if (mirror_session_table.apply().hit) { - if (mirror_port_to_pre_session_table.apply().hit) { - clone_preserving_field_list(CloneType.I2E, pre_session, 8w1); - } - } + if (local_metadata.marked_to_mirror) { + mirror_session_table_0.apply(); + } + } +} + +control mirroring_encap(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { + apply { + if (standard_metadata.instance_type == 32w1 && standard_metadata.egress_rid == 16w2) { + headers.mirror_encap_ethernet.setValid(); + headers.mirror_encap_ethernet.src_addr = local_metadata.mirror_encap_src_mac; + headers.mirror_encap_ethernet.dst_addr = local_metadata.mirror_encap_dst_mac; + headers.mirror_encap_ethernet.ether_type = 16w0x8100; + headers.mirror_encap_vlan.setValid(); + headers.mirror_encap_vlan.ether_type = 16w0x86dd; + headers.mirror_encap_vlan.vlan_id = local_metadata.mirror_encap_vlan_id; + headers.mirror_encap_ipv6.setValid(); + headers.mirror_encap_ipv6.version = 4w6; + headers.mirror_encap_ipv6.dscp = 6w0; + headers.mirror_encap_ipv6.ecn = 2w0; + headers.mirror_encap_ipv6.hop_limit = 8w16; + headers.mirror_encap_ipv6.flow_label = 20w0; + headers.mirror_encap_ipv6.payload_length = (bit<16>)standard_metadata.packet_length + 16w52; + headers.mirror_encap_ipv6.next_header = 8w0x11; + headers.mirror_encap_ipv6.src_addr = local_metadata.mirror_encap_src_ip; + headers.mirror_encap_ipv6.dst_addr = local_metadata.mirror_encap_dst_ip; + headers.mirror_encap_udp.setValid(); + headers.mirror_encap_udp.src_port = local_metadata.mirror_encap_udp_src_port; + headers.mirror_encap_udp.dst_port = local_metadata.mirror_encap_udp_dst_port; + headers.mirror_encap_udp.hdr_length = headers.mirror_encap_ipv6.payload_length; + headers.mirror_encap_udp.checksum = 16w0; + headers.ipfix.setValid(); + headers.psamp_extended.setValid(); } } } control l3_admit(in headers_t headers, inout local_metadata_t local_metadata, in standard_metadata_t standard_metadata) { - @id(0x01000008) action admit_to_l3() { + @id(0x01000008) @name("admit_to_l3") action admit_to_l3_0() { local_metadata.admit_to_l3 = true; } - @p4runtime_role("sdn_controller") @id(0x02000047) table l3_admit_table { + @p4runtime_role("sdn_controller") @id(0x02000047) @name("l3_admit_table") table l3_admit_table_0 { key = { headers.ethernet.dst_addr : ternary @name("dst_mac") @id(1) @format(MAC_ADDRESS); local_metadata.ingress_port: optional @name("in_port") @id(2); } actions = { - @proto_id(1) admit_to_l3(); + @proto_id(1) admit_to_l3_0(); @defaultonly NoAction(); } const default_action = NoAction(); - size = 128; + size = 64; } apply { - l3_admit_table.apply(); + if (local_metadata.enable_vlan_checks && !(local_metadata.vlan_id == 12w0x0 || local_metadata.vlan_id == 12w0xfff)) { + local_metadata.admit_to_l3 = false; + } else { + l3_admit_table_0.apply(); + } } } -control ttl(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { +control gre_tunnel_encap(inout headers_t headers, in local_metadata_t local_metadata, in standard_metadata_t standard_metadata) { apply { - if (local_metadata.admit_to_l3) { + if (local_metadata.apply_tunnel_encap_at_egress) { + headers.tunnel_encap_gre.setValid(); + headers.tunnel_encap_gre.checksum_present = 1w0; + headers.tunnel_encap_gre.routing_present = 1w0; + headers.tunnel_encap_gre.key_present = 1w0; + headers.tunnel_encap_gre.sequence_present = 1w0; + headers.tunnel_encap_gre.strict_source_route = 1w0; + headers.tunnel_encap_gre.recursion_control = 3w0; + headers.tunnel_encap_gre.flags = 4w0; + headers.tunnel_encap_gre.version = 3w0; + headers.tunnel_encap_gre.protocol = headers.ethernet.ether_type; + headers.ethernet.ether_type = 16w0x86dd; + headers.tunnel_encap_ipv6.setValid(); + headers.tunnel_encap_ipv6.version = 4w6; + headers.tunnel_encap_ipv6.src_addr = local_metadata.tunnel_encap_src_ipv6; + headers.tunnel_encap_ipv6.dst_addr = local_metadata.tunnel_encap_dst_ipv6; + headers.tunnel_encap_ipv6.payload_length = (bit<16>)standard_metadata.packet_length + 16w65526; + headers.tunnel_encap_ipv6.next_header = 8w0x2f; if (headers.ipv4.isValid()) { - if (headers.ipv4.ttl <= 8w1) { - mark_to_drop(standard_metadata); - } else { - headers.ipv4.ttl = headers.ipv4.ttl + 8w255; - } + headers.tunnel_encap_ipv6.dscp = headers.ipv4.dscp; + headers.tunnel_encap_ipv6.ecn = headers.ipv4.ecn; + headers.tunnel_encap_ipv6.hop_limit = headers.ipv4.ttl; + } else if (headers.ipv6.isValid()) { + headers.tunnel_encap_ipv6.dscp = headers.ipv6.dscp; + headers.tunnel_encap_ipv6.ecn = headers.ipv6.ecn; + headers.tunnel_encap_ipv6.hop_limit = headers.ipv6.hop_limit; } - if (headers.ipv6.isValid()) { - if (headers.ipv6.hop_limit <= 8w1) { - mark_to_drop(standard_metadata); - } else { - headers.ipv6.hop_limit = headers.ipv6.hop_limit + 8w255; - } + } + } +} + +control vlan_untag(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { + @id(0x0100001A) @name("disable_vlan_checks") action disable_vlan_checks_0() { + local_metadata.enable_vlan_checks = false; + } + @p4runtime_role("sdn_controller") @id(0x0200004D) @entry_restriction(" + // Force the dummy_match to be wildcard. + dummy_match::mask == 0; + ") @name("disable_vlan_checks_table") table disable_vlan_checks_table_0 { + key = { + 1w1: ternary @id(1) @name("dummy_match"); + } + actions = { + @proto_id(1) disable_vlan_checks_0(); + @defaultonly NoAction(); + } + size = 1; + default_action = NoAction(); + } + apply { + if (headers.vlan.isValid()) { + local_metadata.vlan_id = headers.vlan.vlan_id; + headers.ethernet.ether_type = headers.vlan.ether_type; + headers.vlan.setInvalid(); + } else { + local_metadata.vlan_id = 12w0xfff; + } + local_metadata.enable_vlan_checks = true; + disable_vlan_checks_table_0.apply(); + } +} + +control ingress_vlan_checks(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { + apply { + if (local_metadata.enable_vlan_checks && !(local_metadata.vlan_id == 12w0x0 || local_metadata.vlan_id == 12w0xfff)) { + mark_to_drop(standard_metadata); + } + } +} + +control egress_vlan_checks(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { + apply { + if (local_metadata.enable_vlan_checks) { + if (standard_metadata.instance_type == 32w1 && standard_metadata.egress_rid == 16w2 && !(local_metadata.mirror_encap_vlan_id == 12w0x0 || local_metadata.mirror_encap_vlan_id == 12w0xfff)) { + mark_to_drop(standard_metadata); + } else if (!(standard_metadata.instance_type == 32w1 && standard_metadata.egress_rid == 16w1) && !(local_metadata.vlan_id == 12w0x0 || local_metadata.vlan_id == 12w0xfff)) { + mark_to_drop(standard_metadata); } } } } -control packet_rewrites(inout headers_t headers, in local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { +control vlan_tag(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { apply { - if (local_metadata.admit_to_l3) { + if (!(local_metadata.vlan_id == 12w0x0 || local_metadata.vlan_id == 12w0xfff) && !(standard_metadata.instance_type == 32w1 && standard_metadata.egress_rid == 16w2)) { + headers.vlan.setValid(); + headers.vlan.priority_code_point = 3w0; + headers.vlan.drop_eligible_indicator = 1w0; + headers.vlan.vlan_id = local_metadata.vlan_id; + headers.vlan.ether_type = headers.ethernet.ether_type; + headers.ethernet.ether_type = 16w0x8100; + } + } +} + +const ipv6_addr_t IPV6_MULTICAST_MASK_0 = 128w0xff000000000000000000000000000000; +const ipv6_addr_t IPV6_MULTICAST_VALUE_0 = 128w0xff000000000000000000000000000000; +const ipv6_addr_t IPV6_LOOPBACK_MASK_0 = 128w0xffffffffffffffffffffffffffffffff; +const ipv6_addr_t IPV6_LOOPBACK_VALUE_0 = 128w0x1; +const ipv4_addr_t IPV4_MULTICAST_MASK_0 = 32w0xf0000000; +const ipv4_addr_t IPV4_MULTICAST_VALUE_0 = 32w0xe0000000; +const ipv4_addr_t IPV4_BROADCAST_VALUE_0 = 32w0xffffffff; +const ipv4_addr_t IPV4_LOOPBACK_MASK_0 = 32w0xff000000; +const ipv4_addr_t IPV4_LOOPBACK_VALUE_0 = 32w0x7f000000; +const ethernet_addr_t MAC_MULTICAST_MASK_0 = 48w0x10000000000; +const ethernet_addr_t MAC_MULTICAST_VALUE_0 = 48w0x10000000000; +control drop_martians(in headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { + apply { + if (headers.ipv6.isValid() && (headers.ipv6.src_addr & 128w0xff000000000000000000000000000000 == 128w0xff000000000000000000000000000000 || headers.ipv6.dst_addr & 128w0xff000000000000000000000000000000 == 128w0xff000000000000000000000000000000 || headers.ipv6.src_addr == 128w0x1 || headers.ipv6.dst_addr == 128w0x1) || headers.ipv4.isValid() && (headers.ipv4.src_addr & 32w0xf0000000 == 32w0xe0000000 || headers.ipv4.src_addr == 32w0xffffffff || (headers.ipv4.dst_addr & 32w0xf0000000 == 32w0xe0000000 || headers.ipv4.dst_addr == 32w0xffffffff) || headers.ipv4.src_addr & 32w0xff000000 == 32w0x7f000000 || headers.ipv4.dst_addr & 32w0xff000000 == 32w0x7f000000) || headers.ethernet.isValid() && headers.ethernet.dst_addr & 48w0x10000000000 == 48w0x10000000000) { + mark_to_drop(standard_metadata); + } + } +} + +control multicast_rewrites(inout local_metadata_t local_metadata, in standard_metadata_t standard_metadata) { + @name("multicast_replica_port") port_id_t multicast_replica_port_0 = (port_id_t)standard_metadata.egress_port; + @name("multicast_replica_instance") replica_instance_t multicast_replica_instance_0 = standard_metadata.egress_rid; + @id(0x01000019) @name("set_multicast_src_mac") action set_multicast_src_mac_0(@id(1) @format(MAC_ADDRESS) ethernet_addr_t src_mac) { + local_metadata.enable_src_mac_rewrite = true; + local_metadata.packet_rewrites.src_mac = src_mac; + } + @p4runtime_role("sdn_controller") @id(0x0200004C) @name("multicast_router_interface_table") table multicast_router_interface_table_0 { + key = { + multicast_replica_port_0 : exact @referenced_by(builtin : : multicast_group_table , replica . port) @id(1) @name("multicast_replica_port"); + multicast_replica_instance_0: exact @referenced_by(builtin : : multicast_group_table , replica . instance) @id(2) @name("multicast_replica_instance"); + } + actions = { + @proto_id(1) set_multicast_src_mac_0(); + @defaultonly NoAction(); + } + size = 110; + default_action = NoAction(); + } + apply { + multicast_router_interface_table_0.apply(); + } +} + +control packet_rewrites(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { + @name("multicast_rewrites") multicast_rewrites() multicast_rewrites_inst_0; + apply { + if (standard_metadata.instance_type == 32w5) { + local_metadata.enable_decrement_ttl = true; + multicast_rewrites_inst_0.apply(local_metadata, standard_metadata); + } + if (local_metadata.enable_src_mac_rewrite) { headers.ethernet.src_addr = local_metadata.packet_rewrites.src_mac; + } + if (local_metadata.enable_dst_mac_rewrite) { headers.ethernet.dst_addr = local_metadata.packet_rewrites.dst_mac; } + if (local_metadata.enable_vlan_rewrite) { + local_metadata.vlan_id = local_metadata.packet_rewrites.vlan_id; + } + if (headers.ipv4.isValid()) { + if (headers.ipv4.ttl > 8w0 && local_metadata.enable_decrement_ttl) { + headers.ipv4.ttl = headers.ipv4.ttl + 8w255; + } + if (headers.ipv4.ttl == 8w0) { + mark_to_drop(standard_metadata); + } + } + if (headers.ipv6.isValid()) { + if (headers.ipv6.hop_limit > 8w0 && local_metadata.enable_decrement_ttl) { + headers.ipv6.hop_limit = headers.ipv6.hop_limit + 8w255; + } + if (headers.ipv6.hop_limit == 8w0) { + mark_to_drop(standard_metadata); + } + } } } -@id(0x01000109) @sai_action(SAI_PACKET_ACTION_DROP) action acl_drop(inout standard_metadata_t standard_metadata) { - mark_to_drop(standard_metadata); +control tunnel_termination_lookup(in headers_t headers, inout local_metadata_t local_metadata) { + @id(0x01000016) @name("mark_for_tunnel_decap_and_set_vrf") action mark_for_tunnel_decap_and_set_vrf_0(@refers_to(vrf_table , vrf_id) vrf_id_t vrf_id) { + local_metadata.apply_tunnel_decap_at_end_of_pre_ingress = true; + local_metadata.vrf_id = vrf_id; + } + @unsupported @p4runtime_role("sdn_controller") @id(0x0200004B) @name("ipv6_tunnel_termination_table") table ipv6_tunnel_termination_table_0 { + key = { + headers.ipv6.dst_addr: ternary @id(1) @name("dst_ipv6") @format(IPV6_ADDRESS); + headers.ipv6.src_addr: ternary @id(2) @name("src_ipv6") @format(IPV6_ADDRESS); + } + actions = { + @proto_id(1) mark_for_tunnel_decap_and_set_vrf_0(); + @defaultonly NoAction(); + } + size = 126; + default_action = NoAction(); + } + apply { + if (headers.ipv6.isValid()) { + if (headers.ipv6.next_header == 8w0x4 || headers.ipv6.next_header == 8w0x29) { + ipv6_tunnel_termination_table_0.apply(); + } + } + } +} + +control tunnel_termination_decap(inout headers_t headers, in local_metadata_t local_metadata) { + apply { + if (local_metadata.apply_tunnel_decap_at_end_of_pre_ingress) { + assert(headers.ipv6.isValid()); + assert(headers.inner_ipv4.isValid() && !headers.inner_ipv6.isValid() || !headers.inner_ipv4.isValid() && headers.inner_ipv6.isValid()); + headers.ipv6.setInvalid(); + if (headers.inner_ipv4.isValid()) { + headers.ethernet.ether_type = 16w0x800; + headers.ipv4 = headers.inner_ipv4; + headers.inner_ipv4.setInvalid(); + } + if (headers.inner_ipv6.isValid()) { + headers.ethernet.ether_type = 16w0x86dd; + headers.ipv6 = headers.inner_ipv6; + headers.inner_ipv6.setInvalid(); + } + } + } +} + +@id(0x01000109) @sai_action(SAI_PACKET_ACTION_DROP) action acl_drop(inout local_metadata_t local_metadata) { + local_metadata.acl_drop = true; } control acl_egress(in headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { - bit<6> dscp = 6w0; - bit<8> ip_protocol = 8w0; - @id(0x13000104) direct_counter(CounterType.packets_and_bytes) acl_egress_counter; + @name("dscp") bit<6> dscp_0 = 6w0; + @name("ip_protocol") bit<8> ip_protocol_0 = 8w0; + @id(0x13000104) @name("acl_egress_counter") direct_counter(CounterType.packets_and_bytes) acl_egress_counter_0; + @id(0x13000108) @name("acl_egress_dhcp_to_host_counter") direct_counter(CounterType.packets_and_bytes) acl_egress_dhcp_to_host_counter_0; + @id(0x0100010D) @sai_action(SAI_PACKET_ACTION_FORWARD) @name("acl_egress_forward") action acl_egress_forward_0() { + acl_egress_counter_0.count(); + } @p4runtime_role("sdn_controller") @id(0x02000104) @sai_acl(EGRESS) @entry_restriction(" + // Forbid using ether_type for IP packets (by convention, use is_ip* instead). ether_type != 0x0800 && ether_type != 0x86dd; dscp::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + + // Only allow IP field matches for IP packets. + ip_protocol::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + + + + + // Only allow l4_dst_port matches for TCP/UDP packets. + l4_dst_port::mask != 0 -> (ip_protocol == 6 || ip_protocol == 17); + + // Forbid illegal combinations of IP_TYPE fields. + is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0); + is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0); + is_ipv6::mask != 0 -> (is_ip::mask == 0 && is_ipv4::mask == 0); + // Forbid unsupported combinations of IP_TYPE fields. + is_ipv4::mask != 0 -> (is_ipv4 == 1); + is_ipv6::mask != 0 -> (is_ipv6 == 1); + ") @name("acl_egress_table") table acl_egress_table_0 { + key = { + headers.ethernet.ether_type : ternary @id(1) @name("ether_type") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ETHER_TYPE); + ip_protocol_0 : ternary @id(2) @name("ip_protocol") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IP_PROTOCOL); + local_metadata.l4_dst_port : ternary @id(3) @name("l4_dst_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_L4_DST_PORT); + (port_id_t)standard_metadata.egress_port : optional @id(4) @name("out_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_OUT_PORT); + headers.ipv4.isValid() || headers.ipv6.isValid(): optional @id(5) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(6) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(7) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + dscp_0 : ternary @id(8) @name("dscp") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DSCP); + } + actions = { + @proto_id(1) acl_drop(local_metadata); + @defaultonly NoAction(); + } + const default_action = NoAction(); + counters = acl_egress_counter_0; + size = 127; + } + @id(0x02000108) @sai_acl(EGRESS) @p4runtime_role("sdn_controller") @entry_restriction(" // Only allow IP field matches for IP packets. - // TODO: Enable once p4-constraints bug is fixed. - // ip_protocol::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + ip_protocol::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); // Only allow l4_dst_port matches for TCP/UDP packets. l4_dst_port::mask != 0 -> (ip_protocol == 6 || ip_protocol == 17); // Forbid illegal combinations of IP_TYPE fields. @@ -608,87 +1093,114 @@ control acl_egress(in headers_t headers, inout local_metadata_t local_metadata, // Forbid unsupported combinations of IP_TYPE fields. is_ipv4::mask != 0 -> (is_ipv4 == 1); is_ipv6::mask != 0 -> (is_ipv6 == 1); - ") table acl_egress_table { + ") @name("acl_egress_dhcp_to_host_table") table acl_egress_dhcp_to_host_table_0 { key = { - headers.ethernet.ether_type : ternary @name("ether_type") @id(1) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ETHER_TYPE); - ip_protocol : ternary @name("ip_protocol") @id(2) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IP_PROTOCOL); - local_metadata.l4_dst_port : ternary @name("l4_dst_port") @id(3) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_L4_DST_PORT); - (port_id_t)standard_metadata.egress_port : optional @name("out_port") @id(4) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_OUT_PORT); - headers.ipv4.isValid() || headers.ipv6.isValid(): optional @name("is_ip") @id(5) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); - headers.ipv4.isValid() : optional @name("is_ipv4") @id(6) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); - headers.ipv6.isValid() : optional @name("is_ipv6") @id(7) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); - dscp : ternary @name("dscp") @id(8) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DSCP); + headers.ipv4.isValid() || headers.ipv6.isValid(): optional @id(1) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(2) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(3) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + ip_protocol_0 : ternary @id(5) @name("ip_protocol") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IP_PROTOCOL); + local_metadata.l4_dst_port : ternary @id(6) @name("l4_dst_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_L4_DST_PORT); + (port_id_t)standard_metadata.egress_port : optional @id(7) @name("out_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_OUT_PORT); } actions = { - @proto_id(1) acl_drop(standard_metadata); + @proto_id(1) acl_drop(local_metadata); @defaultonly NoAction(); } const default_action = NoAction(); - counters = acl_egress_counter; - size = 128; + counters = acl_egress_dhcp_to_host_counter_0; + size = 127; } apply { if (headers.ipv4.isValid()) { - dscp = headers.ipv4.dscp; - ip_protocol = headers.ipv4.protocol; + dscp_0 = headers.ipv4.dscp; + ip_protocol_0 = headers.ipv4.protocol; } else if (headers.ipv6.isValid()) { - dscp = headers.ipv6.dscp; - ip_protocol = headers.ipv6.next_header; + dscp_0 = headers.ipv6.dscp; + ip_protocol_0 = headers.ipv6.next_header; } else { - ip_protocol = 8w0; + ip_protocol_0 = 8w0; + } + acl_egress_table_0.apply(); + if (local_metadata.acl_drop) { + mark_to_drop(standard_metadata); } - acl_egress_table.apply(); } } control acl_ingress(in headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { - bit<8> ttl = 8w0; - bit<6> dscp = 6w0; - bit<2> ecn = 2w0; - bit<8> ip_protocol = 8w0; - @id(0x15000100) direct_meter(MeterType.bytes) acl_ingress_meter; - @id(0x13000102) direct_counter(CounterType.packets_and_bytes) acl_ingress_counter; - @id(0x01000101) @sai_action(SAI_PACKET_ACTION_COPY , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_YELLOW) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_RED) action acl_copy(@sai_action_param(QOS_QUEUE) @id(1) qos_queue_t qos_queue) { - acl_ingress_counter.count(); - acl_ingress_meter.read(local_metadata.color); - clone(CloneType.I2E, 32w1024); - } - @id(0x01000102) @sai_action(SAI_PACKET_ACTION_TRAP , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_YELLOW) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED) action acl_trap(@sai_action_param(QOS_QUEUE) @id(1) qos_queue_t qos_queue) { - acl_copy(qos_queue); - mark_to_drop(standard_metadata); + @name("ttl") bit<8> ttl_0 = 8w0; + @name("dscp") bit<6> dscp_1 = 6w0; + @name("ecn") bit<2> ecn_0 = 2w0; + @name("ip_protocol") bit<8> ip_protocol_1 = 8w0; + @name("cancel_copy") bool cancel_copy_0 = false; + @id(0x15000100) @mode(single_rate_two_color) @name("acl_ingress_meter") direct_meter(MeterType.bytes) acl_ingress_meter_0; + @id(0x15000102) @mode(single_rate_two_color) @name("acl_ingress_qos_meter") direct_meter(MeterType.bytes) acl_ingress_qos_meter_0; + @id(0x13000102) @name("acl_ingress_counter") direct_counter(CounterType.packets_and_bytes) acl_ingress_counter_0; + @id(0x13000107) @name("acl_ingress_qos_counter") direct_counter(CounterType.packets_and_bytes) acl_ingress_qos_counter_0; + @id(0x13000109) @name("acl_ingress_counting_counter") direct_counter(CounterType.packets_and_bytes) acl_ingress_counting_counter_0; + @id(0x1300010A) @name("acl_ingress_security_counter") direct_counter(CounterType.packets_and_bytes) acl_ingress_security_counter_0; + @id(0x01000101) @sai_action(SAI_PACKET_ACTION_COPY , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_RED) @name("acl_copy") action acl_copy_0(@sai_action_param(QOS_QUEUE) @id(1) qos_queue_t qos_queue) { + acl_ingress_counter_0.count(); + acl_ingress_meter_0.read(local_metadata.color); + local_metadata.marked_to_copy = true; + } + @id(0x01000102) @sai_action(SAI_PACKET_ACTION_TRAP , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED) @name("acl_trap") action acl_trap_0(@sai_action_param(QOS_QUEUE) @id(1) qos_queue_t qos_queue) { + acl_copy_0(qos_queue); + local_metadata.acl_drop = true; + } + @id(0x01000103) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED) @name("acl_forward") action acl_forward_0() { + acl_ingress_meter_0.read(local_metadata.color); } - @id(0x01000199) @sai_action(SAI_PACKET_ACTION_TRAP , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_YELLOW) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED) action acl_experimental_trap(@sai_action_param(QOS_QUEUE) @id(1) qos_queue_t qos_queue) { - acl_ingress_meter.read(local_metadata.color); - acl_trap(qos_queue); + @id(0x01000105) @sai_action(SAI_PACKET_ACTION_FORWARD) @name("acl_count") action acl_count_0() { + acl_ingress_counting_counter_0.count(); } - @id(0x01000103) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_YELLOW) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED) action acl_forward() { - acl_ingress_counter.count(); - acl_ingress_meter.read(local_metadata.color); + @id(0x01000104) @sai_action(SAI_PACKET_ACTION_FORWARD) @name("acl_mirror") action acl_mirror_0(@id(1) @refers_to(mirror_session_table , mirror_session_id) @sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_MIRROR_INGRESS) mirror_session_id_t mirror_session_id) { + acl_ingress_counter_0.count(); + local_metadata.marked_to_mirror = true; + local_metadata.mirror_session_id = mirror_session_id; } - @id(0x01000104) @sai_action(SAI_PACKET_ACTION_FORWARD) action acl_mirror(@id(1) @refers_to(mirror_session_table , mirror_session_id) @sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_MIRROR_INGRESS) mirror_session_id_t mirror_session_id) { - acl_ingress_counter.count(); - local_metadata.mirror_session_id_valid = true; - local_metadata.mirror_session_id_value = mirror_session_id; + @id(0x0100010C) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_COPY_CANCEL , SAI_PACKET_COLOR_RED) @name("set_qos_queue_and_cancel_copy_above_rate_limit") action set_qos_queue_and_cancel_copy_above_rate_limit_0(@id(1) @sai_action_param(QOS_QUEUE) qos_queue_t qos_queue) { + acl_ingress_qos_meter_0.read(local_metadata.color); } - @p4runtime_role("sdn_controller") @id(0x02000100) @sai_acl(INGRESS) @entry_restriction(" + @id(0x01000111) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DENY , SAI_PACKET_COLOR_RED) @unsupported @name("set_cpu_and_multicast_queues_and_deny_above_rate_limit") action set_cpu_and_multicast_queues_and_deny_above_rate_limit_0(@id(1) @sai_action_param(QOS_QUEUE) qos_queue_t cpu_queue, @id(2) @sai_action_param(MULTICAST_QOS_QUEUE , SAI_PACKET_COLOR_GREEN) qos_queue_t green_multicast_queue, @id(3) @sai_action_param(MULTICAST_QOS_QUEUE , SAI_PACKET_COLOR_RED) qos_queue_t red_multicast_queue) { + acl_ingress_qos_meter_0.read(local_metadata.color); + } + @id(0x0100010E) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DENY , SAI_PACKET_COLOR_RED) @name("set_cpu_queue_and_deny_above_rate_limit") action set_cpu_queue_and_deny_above_rate_limit_0(@id(1) @sai_action_param(QOS_QUEUE) qos_queue_t cpu_queue) { + acl_ingress_qos_meter_0.read(local_metadata.color); + } + @id(0x01000110) @sai_action(SAI_PACKET_ACTION_FORWARD) @name("set_cpu_queue") action set_cpu_queue_0(@id(1) @sai_action_param(QOS_QUEUE) qos_queue_t cpu_queue) { + } + @id(0x0100010F) @sai_action(SAI_PACKET_ACTION_DENY) @name("acl_deny") action acl_deny_0() { + cancel_copy_0 = true; + local_metadata.acl_drop = true; + } + @p4runtime_role("sdn_controller") @id(0x02000100) @sai_acl(INGRESS) @sai_acl_priority(5) @entry_restriction(" // Forbid using ether_type for IP packets (by convention, use is_ip* instead). ether_type != 0x0800 && ether_type != 0x86dd; // Only allow IP field matches for IP packets. dst_ip::mask != 0 -> is_ipv4 == 1; + + src_ip::mask != 0 -> is_ipv4 == 1; + dst_ipv6::mask != 0 -> is_ipv6 == 1; + src_ipv6::mask != 0 -> is_ipv6 == 1; ttl::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + dscp::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); ecn::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + ip_protocol::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); // Only allow l4_dst_port and l4_src_port matches for TCP/UDP packets. + l4_src_port::mask != 0 -> (ip_protocol == 6 || ip_protocol == 17); + l4_dst_port::mask != 0 -> (ip_protocol == 6 || ip_protocol == 17); - // Only allow icmp_type matches for ICMP packets + // Only allow icmp_type matches for ICMP packets icmp_type::mask != 0 -> ip_protocol == 1; icmpv6_type::mask != 0 -> ip_protocol == 58; @@ -699,68 +1211,253 @@ control acl_ingress(in headers_t headers, inout local_metadata_t local_metadata, // Forbid unsupported combinations of IP_TYPE fields. is_ipv4::mask != 0 -> (is_ipv4 == 1); is_ipv6::mask != 0 -> (is_ipv6 == 1); - ") table acl_ingress_table { + ") @name("acl_ingress_table") table acl_ingress_table_0 { + key = { + headers.ipv4.isValid() || headers.ipv6.isValid(): optional @id(1) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(2) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(3) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + headers.ethernet.ether_type : ternary @id(4) @name("ether_type") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ETHER_TYPE); + headers.ethernet.dst_addr : ternary @id(5) @name("dst_mac") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_MAC) @format(MAC_ADDRESS); + headers.ipv4.src_addr : ternary @id(6) @name("src_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_SRC_IP) @format(IPV4_ADDRESS); + headers.ipv4.dst_addr : ternary @id(7) @name("dst_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_IP) @format(IPV4_ADDRESS); + headers.ipv6.src_addr[127:64] : ternary @id(8) @name("src_ipv6") @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_SRC_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_SRC_IPV6_WORD2 )) @format(IPV6_ADDRESS); + headers.ipv6.dst_addr[127:64] : ternary @id(9) @name("dst_ipv6") @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD2 )) @format(IPV6_ADDRESS); + ttl_0 : ternary @id(10) @name("ttl") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_TTL); + dscp_1 : ternary @id(11) @name("dscp") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DSCP); + ecn_0 : ternary @id(12) @name("ecn") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ECN); + ip_protocol_1 : ternary @id(13) @name("ip_protocol") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IP_PROTOCOL); + headers.icmp.type : ternary @id(19) @name("icmp_type") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ICMP_TYPE); + headers.icmp.type : ternary @id(14) @name("icmpv6_type") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ICMPV6_TYPE); + local_metadata.l4_src_port : ternary @id(20) @name("l4_src_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_L4_SRC_PORT); + local_metadata.l4_dst_port : ternary @id(15) @name("l4_dst_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_L4_DST_PORT); + local_metadata.ingress_port : optional @id(17) @name("in_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IN_PORT); + local_metadata.route_metadata : optional @id(18) @name("route_metadata") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ROUTE_DST_USER_META); + } + actions = { + @proto_id(1) acl_copy_0(); + @proto_id(2) acl_trap_0(); + @proto_id(3) acl_forward_0(); + @proto_id(4) acl_mirror_0(); + @proto_id(5) acl_drop(local_metadata); + @defaultonly NoAction(); + } + const default_action = NoAction(); + meters = acl_ingress_meter_0; + counters = acl_ingress_counter_0; + size = 255; + } + @id(0x02000107) @sai_acl(INGRESS) @sai_acl_priority(10) @p4runtime_role("sdn_controller") @entry_restriction(" + // Forbid using ether_type for IP packets (by convention, use is_ip* instead). + ether_type != 0x0800 && ether_type != 0x86dd; + // Only allow IP field matches for IP packets. + ttl::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + ip_protocol::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + // Only allow l4_dst_port matches for TCP/UDP packets. + l4_dst_port::mask != 0 -> (ip_protocol == 6 || ip_protocol == 17); + // Forbid illegal combinations of IP_TYPE fields. + is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0); + is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0); + is_ipv6::mask != 0 -> (is_ip::mask == 0 && is_ipv4::mask == 0); + // Forbid unsupported combinations of IP_TYPE fields. + is_ipv4::mask != 0 -> (is_ipv4 == 1); + is_ipv6::mask != 0 -> (is_ipv6 == 1); + // Only allow icmp_type matches for ICMP packets + icmpv6_type::mask != 0 -> ip_protocol == 58; + + // Only allow l4_dst_port matches for TCP/UDP packets. + l4_src_port::mask != 0 -> (ip_protocol == 6 || ip_protocol == 17); + // Only allow icmp_type matches for ICMP packets + icmp_type::mask != 0 -> ip_protocol == 1; + + + + + + ") @name("acl_ingress_qos_table") table acl_ingress_qos_table_0 { + key = { + headers.ipv4.isValid() || headers.ipv6.isValid(): optional @id(1) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(2) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(3) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + headers.ethernet.ether_type : ternary @id(4) @name("ether_type") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ETHER_TYPE); + ttl_0 : ternary @id(7) @name("ttl") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_TTL); + ip_protocol_1 : ternary @id(8) @name("ip_protocol") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IP_PROTOCOL); + headers.icmp.type : ternary @id(9) @name("icmpv6_type") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ICMPV6_TYPE); + local_metadata.l4_dst_port : ternary @id(10) @name("l4_dst_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_L4_DST_PORT); + local_metadata.l4_src_port : ternary @id(12) @name("l4_src_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_L4_SRC_PORT); + headers.icmp.type : ternary @id(14) @name("icmp_type") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ICMP_TYPE); + local_metadata.route_metadata : ternary @id(15) @name("route_metadata") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ROUTE_DST_USER_META); + } + actions = { + @proto_id(1) set_qos_queue_and_cancel_copy_above_rate_limit_0(); + @proto_id(2) set_cpu_queue_and_deny_above_rate_limit_0(); + @proto_id(3) acl_forward_0(); + @proto_id(4) acl_drop(local_metadata); + @proto_id(5) set_cpu_queue_0(); + @proto_id(6) set_cpu_and_multicast_queues_and_deny_above_rate_limit_0(); + @defaultonly NoAction(); + } + const default_action = NoAction(); + meters = acl_ingress_qos_meter_0; + counters = acl_ingress_qos_counter_0; + size = 511; + } + @p4runtime_role("sdn_controller") @id(0x02000109) @sai_acl_priority(7) @sai_acl(INGRESS) @entry_restriction(" + // Only allow IP field matches for IP packets. + dscp::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + // Forbid illegal combinations of IP_TYPE fields. + is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0); + is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0); + is_ipv6::mask != 0 -> (is_ip::mask == 0 && is_ipv4::mask == 0); + // Forbid unsupported combinations of IP_TYPE fields. + is_ipv4::mask != 0 -> (is_ipv4 == 1); + is_ipv6::mask != 0 -> (is_ipv6 == 1); + ") @name("acl_ingress_counting_table") table acl_ingress_counting_table_0 { key = { - headers.ipv4.isValid() || headers.ipv6.isValid(): optional @name("is_ip") @id(1) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); - headers.ipv4.isValid() : optional @name("is_ipv4") @id(2) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); - headers.ipv6.isValid() : optional @name("is_ipv6") @id(3) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); - headers.ethernet.ether_type : ternary @name("ether_type") @id(4) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ETHER_TYPE); - headers.ethernet.dst_addr : ternary @name("dst_mac") @id(5) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_MAC) @format(MAC_ADDRESS); - headers.ipv4.src_addr : ternary @name("src_ip") @id(6) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_SRC_IP) @format(IPV4_ADDRESS); - headers.ipv4.dst_addr : ternary @name("dst_ip") @id(7) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_IP) @format(IPV4_ADDRESS); - headers.ipv6.src_addr[127:64] : ternary @name("src_ipv6") @id(8) @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_SRC_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_SRC_IPV6_WORD2 )) @format(IPV6_ADDRESS); - headers.ipv6.dst_addr[127:64] : ternary @name("dst_ipv6") @id(9) @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD2 )) @format(IPV6_ADDRESS); - ttl : ternary @name("ttl") @id(10) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_TTL); - dscp : ternary @name("dscp") @id(11) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DSCP); - ecn : ternary @name("ecn") @id(12) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ECN); - ip_protocol : ternary @name("ip_protocol") @id(13) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IP_PROTOCOL); - headers.icmp.type : ternary @name("icmp_type") @id(19) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ICMP_TYPE); - headers.icmp.type : ternary @name("icmpv6_type") @id(14) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ICMPV6_TYPE); - local_metadata.l4_src_port : ternary @name("l4_src_port") @id(20) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_L4_SRC_PORT); - local_metadata.l4_dst_port : ternary @name("l4_dst_port") @id(15) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_L4_DST_PORT); - local_metadata.ingress_port : optional @name("in_port") @id(17) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IN_PORT); - local_metadata.route_metadata : optional @name("route_metadata") @id(18) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ROUTE_DST_USER_META); + headers.ipv4.isValid() || headers.ipv6.isValid(): optional @id(1) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(2) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(3) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + dscp_1 : ternary @id(11) @name("dscp") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DSCP); + local_metadata.route_metadata : ternary @id(18) @name("route_metadata") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ROUTE_DST_USER_META); } actions = { - @proto_id(1) acl_copy(); - @proto_id(2) acl_trap(); - @proto_id(3) acl_forward(); - @proto_id(4) acl_mirror(); - @proto_id(5) acl_drop(standard_metadata); - @proto_id(99) acl_experimental_trap(); + @proto_id(3) acl_count_0(); @defaultonly NoAction(); } const default_action = NoAction(); - meters = acl_ingress_meter; - counters = acl_ingress_counter; - size = 128; + counters = acl_ingress_counting_counter_0; + size = 255; + } + @id(0x01000112) @name("redirect_to_nexthop") action redirect_to_nexthop_0(@sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_REDIRECT) @sai_action_param_object_type(SAI_OBJECT_TYPE_NEXT_HOP) @refers_to(nexthop_table , nexthop_id) nexthop_id_t nexthop_id) { + local_metadata.nexthop_id_valid = true; + local_metadata.nexthop_id_value = nexthop_id; + local_metadata.wcmp_group_id_valid = false; + standard_metadata.mcast_grp = 16w0; + } + @id(0x01000113) @action_restriction(" + // Disallow 0 since it encodes 'no multicast' in V1Model. + multicast_group_id != 0; + ") @name("redirect_to_ipmc_group") action redirect_to_ipmc_group_0(@sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_REDIRECT) @sai_action_param_object_type(SAI_OBJECT_TYPE_IPMC_GROUP) @refers_to(builtin : : multicast_group_table , multicast_group_id) multicast_group_id_t multicast_group_id) { + standard_metadata.mcast_grp = multicast_group_id; + local_metadata.nexthop_id_valid = false; + local_metadata.wcmp_group_id_valid = false; + } + @id(0x0200010B) @sai_acl(INGRESS) @sai_acl_priority(15) @p4runtime_role("sdn_controller") @entry_restriction(" + // Only allow IP field matches for IP packets. + dst_ip::mask != 0 -> is_ipv4 == 1; + dst_ipv6::mask != 0 -> is_ipv6 == 1; + // Forbid illegal combinations of IP_TYPE fields. + is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0); + is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0); + is_ipv6::mask != 0 -> (is_ip::mask == 0 && is_ipv4::mask == 0); + // Forbid unsupported combinations of IP_TYPE fields. + is_ipv4::mask != 0 -> (is_ipv4 == 1); + is_ipv6::mask != 0 -> (is_ipv6 == 1); + ") @name("acl_ingress_mirror_and_redirect_table") table acl_ingress_mirror_and_redirect_table_0 { + key = { + headers.ipv4.isValid() || headers.ipv6.isValid(): optional @id(2) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(3) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(4) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + headers.ipv4.dst_addr : ternary @id(10) @name("dst_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_IP) @format(IPV4_ADDRESS); + headers.ipv6.dst_addr[127:64] : ternary @id(5) @name("dst_ipv6") @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD2 )) @format(IPV6_ADDRESS); + local_metadata.vrf_id : optional @id(8) @name("vrf_id") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_VRF_ID); + local_metadata.ipmc_table_hit : optional @id(9) @name("ipmc_table_hit") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IPMC_NPU_META_DST_HIT); + } + actions = { + @proto_id(4) acl_forward_0(); + @proto_id(1) acl_mirror_0(); + @proto_id(2) redirect_to_nexthop_0(); + @proto_id(3) redirect_to_ipmc_group_0(); + @defaultonly NoAction(); + } + const default_action = NoAction(); + size = 255; + } + @id(0x0200010A) @sai_acl(INGRESS) @sai_acl_priority(20) @p4runtime_role("sdn_controller") @entry_restriction(" + // Forbid using ether_type for IP packets (by convention, use is_ip* instead). + ether_type != 0x0800 && ether_type != 0x86dd; + + + + + + + // TODO: This comment is required for the preprocessor to not + // spit out nonsense. + + + + + + + + // Forbid illegal combinations of IP_TYPE fields. + is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0); + is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0); + is_ipv6::mask != 0 -> (is_ip::mask == 0 && is_ipv4::mask == 0); + // Forbid unsupported combinations of IP_TYPE fields. + is_ipv4::mask != 0 -> (is_ipv4 == 1); + is_ipv6::mask != 0 -> (is_ipv6 == 1); + ") @name("acl_ingress_security_table") table acl_ingress_security_table_0 { + key = { + headers.ipv4.isValid() || headers.ipv6.isValid(): optional @id(1) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(2) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(3) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + headers.ethernet.ether_type : ternary @id(4) @name("ether_type") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ETHER_TYPE); + } + actions = { + @proto_id(1) acl_forward_0(); + @proto_id(2) acl_drop(local_metadata); + @proto_id(3) acl_deny_0(); + @defaultonly NoAction(); + } + const default_action = NoAction(); + counters = acl_ingress_security_counter_0; + size = 255; } apply { if (headers.ipv4.isValid()) { - ttl = headers.ipv4.ttl; - dscp = headers.ipv4.dscp; - ecn = headers.ipv4.ecn; - ip_protocol = headers.ipv4.protocol; + ttl_0 = headers.ipv4.ttl; + dscp_1 = headers.ipv4.dscp; + ecn_0 = headers.ipv4.ecn; + ip_protocol_1 = headers.ipv4.protocol; } else if (headers.ipv6.isValid()) { - ttl = headers.ipv6.hop_limit; - dscp = headers.ipv6.dscp; - ecn = headers.ipv6.ecn; - ip_protocol = headers.ipv6.next_header; + ttl_0 = headers.ipv6.hop_limit; + dscp_1 = headers.ipv6.dscp; + ecn_0 = headers.ipv6.ecn; + ip_protocol_1 = headers.ipv6.next_header; + } + acl_ingress_table_0.apply(); + acl_ingress_counting_table_0.apply(); + acl_ingress_qos_table_0.apply(); + if (cancel_copy_0) { + local_metadata.marked_to_copy = false; } - acl_ingress_table.apply(); } } control acl_pre_ingress(in headers_t headers, inout local_metadata_t local_metadata, in standard_metadata_t standard_metadata) { - bit<6> dscp = 6w0; - @id(0x13000101) direct_counter(CounterType.packets_and_bytes) acl_pre_ingress_counter; - @id(0x01000100) @sai_action(SAI_PACKET_ACTION_FORWARD) action set_vrf(@sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_SET_VRF) @refers_to(vrf_table , vrf_id) @id(1) vrf_id_t vrf_id) { + @name("dscp") bit<6> dscp_2 = 6w0; + @name("ecn") bit<2> ecn_1 = 2w0; + @name("ip_protocol") bit<8> ip_protocol_2 = 8w0; + @id(0x13000101) @name("acl_pre_ingress_counter") direct_counter(CounterType.packets_and_bytes) acl_pre_ingress_counter_0; + @id(0x13000106) @name("acl_pre_ingress_vlan_counter") direct_counter(CounterType.packets_and_bytes) acl_pre_ingress_vlan_counter_0; + @id(0x13000105) @name("acl_pre_ingress_metadata_counter") direct_counter(CounterType.packets_and_bytes) acl_pre_ingress_metadata_counter_0; + @id(0x01000100) @sai_action(SAI_PACKET_ACTION_FORWARD) @name("set_vrf") action set_vrf_0(@sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_SET_VRF) @refers_to(vrf_table , vrf_id) @id(1) vrf_id_t vrf_id) { local_metadata.vrf_id = vrf_id; - acl_pre_ingress_counter.count(); + acl_pre_ingress_counter_0.count(); } - @p4runtime_role("sdn_controller") @id(0x02000101) @sai_acl(PRE_INGRESS) @entry_restriction(" + @id(0x0100010A) @sai_action(SAI_PACKET_ACTION_FORWARD) @name("set_outer_vlan_id") action set_outer_vlan_id_0(@id(1) @sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_SET_OUTER_VLAN_ID) vlan_id_t vlan_id) { + local_metadata.vlan_id = vlan_id; + acl_pre_ingress_vlan_counter_0.count(); + } + @id(0x0100010B) @sai_action(SAI_PACKET_ACTION_FORWARD) @name("set_acl_metadata") action set_acl_metadata_0(@id(1) @sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_SET_ACL_META_DATA) acl_metadata_t acl_metadata) { + local_metadata.acl_metadata = acl_metadata; + acl_pre_ingress_metadata_counter_0.count(); + } + @p4runtime_role("sdn_controller") @id(0x02000101) @sai_acl(PRE_INGRESS) @sai_acl_priority(11) @entry_restriction(" // Only allow IP field matches for IP packets. dscp::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + ecn::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); dst_ip::mask != 0 -> is_ipv4 == 1; dst_ipv6::mask != 0 -> is_ipv6 == 1; // Forbid illegal combinations of IP_TYPE fields. @@ -770,74 +1467,221 @@ control acl_pre_ingress(in headers_t headers, inout local_metadata_t local_metad // Forbid unsupported combinations of IP_TYPE fields. is_ipv4::mask != 0 -> (is_ipv4 == 1); is_ipv6::mask != 0 -> (is_ipv6 == 1); + + + + // Reserve high priorities for switch-internal use. // TODO: Remove once inband workaround is obsolete. ::priority < 0x7fffffff; - ") table acl_pre_ingress_table { + ") @name("acl_pre_ingress_table") table acl_pre_ingress_table_0 { key = { - headers.ipv4.isValid() || headers.ipv6.isValid(): optional @name("is_ip") @id(1) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); - headers.ipv4.isValid() : optional @name("is_ipv4") @id(2) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); - headers.ipv6.isValid() : optional @name("is_ipv6") @id(3) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); - headers.ethernet.src_addr : ternary @name("src_mac") @id(4) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_SRC_MAC) @format(MAC_ADDRESS); - headers.ethernet.dst_addr : ternary @name("dst_mac") @id(9) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_MAC) @format(MAC_ADDRESS); - headers.ipv4.dst_addr : ternary @name("dst_ip") @id(5) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_IP) @format(IPV4_ADDRESS); - headers.ipv6.dst_addr[127:64] : ternary @name("dst_ipv6") @id(6) @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD2 )) @format(IPV6_ADDRESS); - dscp : ternary @name("dscp") @id(7) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DSCP); - local_metadata.ingress_port : optional @name("in_port") @id(8) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IN_PORT); + headers.ipv4.isValid() || headers.ipv6.isValid(): optional @id(1) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(2) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(3) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + headers.ethernet.src_addr : ternary @id(4) @name("src_mac") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_SRC_MAC) @format(MAC_ADDRESS); + headers.ethernet.dst_addr : ternary @id(9) @name("dst_mac") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_MAC) @format(MAC_ADDRESS); + headers.ipv4.dst_addr : ternary @id(5) @name("dst_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_IP) @format(IPV4_ADDRESS); + headers.ipv6.dst_addr[127:64] : ternary @id(6) @name("dst_ipv6") @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD2 )) @format(IPV6_ADDRESS); + dscp_2 : ternary @id(7) @name("dscp") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DSCP); + ecn_1 : ternary @id(10) @name("ecn") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ECN); + local_metadata.ingress_port : optional @id(8) @name("in_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IN_PORT); } actions = { - @proto_id(1) set_vrf(); + @proto_id(1) set_vrf_0(); @defaultonly NoAction(); } const default_action = NoAction(); - counters = acl_pre_ingress_counter; - size = 255; + counters = acl_pre_ingress_counter_0; + size = 254; + } + @id(0x02000105) @sai_acl(PRE_INGRESS) @p4runtime_role("sdn_controller") @sai_acl_priority(1) @entry_restriction(" + // Forbid using ether_type for IP packets (by convention, use is_ip* instead). + ether_type != 0x0800 && ether_type != 0x86dd; + // Forbid illegal combinations of IP_TYPE fields. + is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0); + is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0); + is_ipv6::mask != 0 -> (is_ip::mask == 0 && is_ipv4::mask == 0); + // Forbid unsupported combinations of IP_TYPE fields. + is_ipv4::mask != 0 -> (is_ipv4 == 1); + is_ipv6::mask != 0 -> (is_ipv6 == 1); + // Disallow match on reserved VLAN IDs to rule out vendor specific behavior. + vlan_id::mask != 0 -> (vlan_id != 4095 && vlan_id != 0); + // TODO: Disallow setting to reserved VLAN IDs when supported. + ") @name("acl_pre_ingress_vlan_table") table acl_pre_ingress_vlan_table_0 { + key = { + headers.ipv4.isValid() || headers.ipv6.isValid(): optional @id(1) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(2) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(3) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + headers.ethernet.ether_type : ternary @id(4) @name("ether_type") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ETHER_TYPE); + local_metadata.vlan_id : ternary @id(5) @name("vlan_id") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_OUTER_VLAN_ID); + } + actions = { + @proto_id(1) set_outer_vlan_id_0(); + @defaultonly NoAction(); + } + const default_action = NoAction(); + counters = acl_pre_ingress_vlan_counter_0; + size = 254; + } + @id(0x02000106) @sai_acl(PRE_INGRESS) @p4runtime_role("sdn_controller") @sai_acl_priority(5) @entry_restriction(" + // Forbid illegal combinations of IP_TYPE fields. + is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0); + is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0); + is_ipv6::mask != 0 -> (is_ip::mask == 0 && is_ipv4::mask == 0); + // DSCP is only allowed on IP traffic. + dscp::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + ecn::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + // Forbid unsupported combinations of IP_TYPE fields. + is_ipv4::mask != 0 -> (is_ipv4 == 1); + is_ipv6::mask != 0 -> (is_ipv6 == 1); + // Only allow icmp_type matches for ICMP packets + icmpv6_type::mask != 0 -> ip_protocol == 58; + ") @name("acl_pre_ingress_metadata_table") table acl_pre_ingress_metadata_table_0 { + key = { + headers.ipv4.isValid() || headers.ipv6.isValid(): optional @id(1) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(2) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(3) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + ip_protocol_2 : ternary @id(4) @name("ip_protocol") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IP_PROTOCOL); + headers.icmp.type : ternary @id(5) @name("icmpv6_type") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ICMPV6_TYPE); + dscp_2 : ternary @id(6) @name("dscp") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DSCP); + ecn_1 : ternary @id(7) @name("ecn") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ECN); + } + actions = { + @proto_id(1) set_acl_metadata_0(); + @defaultonly NoAction(); + } + const default_action = NoAction(); + counters = acl_pre_ingress_metadata_counter_0; + size = 254; } apply { if (headers.ipv4.isValid()) { - dscp = headers.ipv4.dscp; + dscp_2 = headers.ipv4.dscp; + ecn_1 = headers.ipv4.ecn; + ip_protocol_2 = headers.ipv4.protocol; } else if (headers.ipv6.isValid()) { - dscp = headers.ipv6.dscp; + dscp_2 = headers.ipv6.dscp; + ecn_1 = headers.ipv6.ecn; + ip_protocol_2 = headers.ipv6.next_header; } - local_metadata.vrf_id = (vrf_id_t)10w0; - acl_pre_ingress_table.apply(); + acl_pre_ingress_table_0.apply(); } } control admit_google_system_mac(in headers_t headers, inout local_metadata_t local_metadata) { apply { - local_metadata.admit_to_l3 = headers.ethernet.dst_addr & 48w0x10000000000 == 48w0; + local_metadata.admit_to_l3 = headers.ethernet.dst_addr == 48w0x1a11175f80; + } +} + +control hashing(in headers_t headers, inout local_metadata_t local_metadata, in standard_metadata_t standard_metadata) { + @name("seed") bit<32> seed_0 = 32w0; + @name("offset") bit<8> offset_0 = 8w0; + @sai_hash_seed(0) @id(0x010000A) @name("select_ecmp_hash_algorithm") action select_ecmp_hash_algorithm_0() { + seed_0 = 32w0; + } + @sai_ecmp_hash(SAI_SWITCH_ATTR_ECMP_HASH_IPV4) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_SRC_IPV4) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_DST_IPV4) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_SRC_PORT) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_DST_PORT) @id(0x0100000B) @name("compute_ecmp_hash_ipv4") action compute_ecmp_hash_ipv4_0() { + hash, bit<1>, tuple, bit<32>, bit<32>, bit<16>, bit<16>>, bit<17>>(local_metadata.wcmp_selector_input, HashAlgorithm.crc32, 1w0, { seed_0, headers.ipv4.src_addr, headers.ipv4.dst_addr, local_metadata.l4_src_port, local_metadata.l4_dst_port }, 17w0x10000); + local_metadata.wcmp_selector_input = local_metadata.wcmp_selector_input >> offset_0 | local_metadata.wcmp_selector_input << 8w8 - offset_0; + } + @sai_ecmp_hash(SAI_SWITCH_ATTR_ECMP_HASH_IPV6) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_SRC_IPV6) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_DST_IPV6) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_SRC_PORT) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_DST_PORT) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_IPV6_FLOW_LABEL) @id(0x0100000C) @name("compute_ecmp_hash_ipv6") action compute_ecmp_hash_ipv6_0() { + hash, bit<1>, tuple, bit<20>, bit<128>, bit<128>, bit<16>, bit<16>>, bit<17>>(local_metadata.wcmp_selector_input, HashAlgorithm.crc32, 1w0, { seed_0, headers.ipv6.flow_label, headers.ipv6.src_addr, headers.ipv6.dst_addr, local_metadata.l4_src_port, local_metadata.l4_dst_port }, 17w0x10000); + local_metadata.wcmp_selector_input = local_metadata.wcmp_selector_input >> offset_0 | local_metadata.wcmp_selector_input << 8w8 - offset_0; + } + apply { + select_ecmp_hash_algorithm_0(); + if (headers.ipv4.isValid()) { + compute_ecmp_hash_ipv4_0(); + } else if (headers.ipv6.isValid()) { + compute_ecmp_hash_ipv6_0(); + } + } +} + +control lag_hashing_config(in headers_t headers) { + @name("lag_seed") bit<32> lag_seed_0 = 32w0; + @name("lag_offset") bit<4> lag_offset_0 = 4w0; + @sai_hash_algorithm(SAI_HASH_ALGORITHM_CRC) @sai_hash_seed(0) @sai_hash_offset(0) @name("select_lag_hash_algorithm") action select_lag_hash_algorithm_0() { + lag_seed_0 = 32w0; + lag_offset_0 = 4w0; + } + @sai_lag_hash(SAI_SWITCH_ATTR_LAG_HASH_IPV4) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_SRC_IPV4) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_DST_IPV4) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_SRC_PORT) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_DST_PORT) @id(0x0100000D) @name("compute_lag_hash_ipv4") action compute_lag_hash_ipv4_0() { + } + @sai_lag_hash(SAI_SWITCH_ATTR_LAG_HASH_IPV6) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_SRC_IPV6) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_DST_IPV6) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_SRC_PORT) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_DST_PORT) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_IPV6_FLOW_LABEL) @id(0x0100000E) @name("compute_lag_hash_ipv6") action compute_lag_hash_ipv6_0() { + } + apply { + select_lag_hash_algorithm_0(); + if (headers.ipv4.isValid()) { + compute_lag_hash_ipv4_0(); + } else if (headers.ipv6.isValid()) { + compute_lag_hash_ipv6_0(); + } } } control ingress(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { - @name("acl_pre_ingress") acl_pre_ingress() acl_pre_ingress_inst; - @name("admit_google_system_mac") admit_google_system_mac() admit_google_system_mac_inst; - @name("l3_admit") l3_admit() l3_admit_inst; - @name("routing") routing() routing_inst; - @name("acl_ingress") acl_ingress() acl_ingress_inst; - @name("ttl") ttl() ttl_inst; - @name("mirroring_clone") mirroring_clone() mirroring_clone_inst; + @name("packet_out_decap") packet_out_decap() packet_out_decap_inst_0; + @name("tunnel_termination_lookup") tunnel_termination_lookup() tunnel_termination_lookup_inst_0; + @name("vlan_untag") vlan_untag() vlan_untag_inst_0; + @name("acl_pre_ingress") acl_pre_ingress() acl_pre_ingress_inst_0; + @name("ingress_vlan_checks") ingress_vlan_checks() ingress_vlan_checks_inst_0; + @name("tunnel_termination_decap") tunnel_termination_decap() tunnel_termination_decap_inst_0; + @name("admit_google_system_mac") admit_google_system_mac() admit_google_system_mac_inst_0; + @name("l3_admit") l3_admit() l3_admit_inst_0; + @name("hashing") hashing() hashing_inst_0; + @name("lag_hashing_config") lag_hashing_config() lag_hashing_config_inst_0; + @name("routing_lookup") routing_lookup() routing_lookup_inst_0; + @name("acl_ingress") acl_ingress() acl_ingress_inst_0; + @name("routing_resolution") routing_resolution() routing_resolution_inst_0; + @name("mirror_session_lookup") mirror_session_lookup() mirror_session_lookup_inst_0; + @name("ingress_cloning") ingress_cloning() ingress_cloning_inst_0; + @name("drop_martians") drop_martians() drop_martians_inst_0; apply { - acl_pre_ingress_inst.apply(headers, local_metadata, standard_metadata); - admit_google_system_mac_inst.apply(headers, local_metadata); - l3_admit_inst.apply(headers, local_metadata, standard_metadata); - routing_inst.apply(headers, local_metadata, standard_metadata); - acl_ingress_inst.apply(headers, local_metadata, standard_metadata); - ttl_inst.apply(headers, local_metadata, standard_metadata); - mirroring_clone_inst.apply(headers, local_metadata, standard_metadata); + packet_out_decap_inst_0.apply(headers, local_metadata, standard_metadata); + if (local_metadata.bypass_ingress) { + ; + } else { + tunnel_termination_lookup_inst_0.apply(headers, local_metadata); + vlan_untag_inst_0.apply(headers, local_metadata, standard_metadata); + acl_pre_ingress_inst_0.apply(headers, local_metadata, standard_metadata); + ingress_vlan_checks_inst_0.apply(headers, local_metadata, standard_metadata); + tunnel_termination_decap_inst_0.apply(headers, local_metadata); + admit_google_system_mac_inst_0.apply(headers, local_metadata); + l3_admit_inst_0.apply(headers, local_metadata, standard_metadata); + hashing_inst_0.apply(headers, local_metadata, standard_metadata); + lag_hashing_config_inst_0.apply(headers); + routing_lookup_inst_0.apply(headers, local_metadata, standard_metadata); + acl_ingress_inst_0.apply(headers, local_metadata, standard_metadata); + routing_resolution_inst_0.apply(headers, local_metadata, standard_metadata); + mirror_session_lookup_inst_0.apply(headers, local_metadata, standard_metadata); + ingress_cloning_inst_0.apply(headers, local_metadata, standard_metadata); + drop_martians_inst_0.apply(headers, local_metadata, standard_metadata); + } } } control egress(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { - @name("packet_rewrites") packet_rewrites() packet_rewrites_inst; - @name("mirroring_encap") mirroring_encap() mirroring_encap_inst; - @name("acl_egress") acl_egress() acl_egress_inst; + @name("packet_in_encap") packet_in_encap() packet_in_encap_inst_0; + @name("packet_rewrites") packet_rewrites() packet_rewrites_inst_0; + @name("gre_tunnel_encap") gre_tunnel_encap() gre_tunnel_encap_inst_0; + @name("mirroring_encap") mirroring_encap() mirroring_encap_inst_0; + @name("egress_vlan_checks") egress_vlan_checks() egress_vlan_checks_inst_0; + @name("vlan_tag") vlan_tag() vlan_tag_inst_0; + @name("acl_egress") acl_egress() acl_egress_inst_0; apply { - packet_rewrites_inst.apply(headers, local_metadata, standard_metadata); - mirroring_encap_inst.apply(headers, local_metadata, standard_metadata); - acl_egress_inst.apply(headers, local_metadata, standard_metadata); + packet_in_encap_inst_0.apply(headers, local_metadata, standard_metadata); + if (standard_metadata.instance_type == 32w1 && standard_metadata.egress_rid == 16w1) { + ; + } else { + packet_rewrites_inst_0.apply(headers, local_metadata, standard_metadata); + gre_tunnel_encap_inst_0.apply(headers, local_metadata, standard_metadata); + mirroring_encap_inst_0.apply(headers, local_metadata, standard_metadata); + egress_vlan_checks_inst_0.apply(headers, local_metadata, standard_metadata); + vlan_tag_inst_0.apply(headers, local_metadata, standard_metadata); + acl_egress_inst_0.apply(headers, local_metadata, standard_metadata); + } } } -@pkginfo(name="fabric_border_router.p4", organization="Google") V1Switch(packet_parser(), verify_ipv4_checksum(), ingress(), egress(), compute_ipv4_checksum(), packet_deparser()) main; +@pkginfo(name="fabric_border_router.p4", organization="Google", version="1.6.1") V1Switch(packet_parser(), verify_ipv4_checksum(), ingress(), egress(), compute_ipv4_checksum(), packet_deparser()) main; diff --git a/testdata/p4_16_samples_outputs/pins/pins_fabric-frontend.p4 b/testdata/p4_16_samples_outputs/pins/pins_fabric-frontend.p4 index 8a97273ab5..f6d4553dd2 100644 --- a/testdata/p4_16_samples_outputs/pins/pins_fabric-frontend.p4 +++ b/testdata/p4_16_samples_outputs/pins/pins_fabric-frontend.p4 @@ -5,10 +5,19 @@ typedef bit<48> ethernet_addr_t; typedef bit<32> ipv4_addr_t; typedef bit<128> ipv6_addr_t; +typedef bit<12> vlan_id_t; +typedef bit<16> ether_type_t; header ethernet_t { ethernet_addr_t dst_addr; ethernet_addr_t src_addr; - bit<16> ether_type; + ether_type_t ether_type; +} + +header vlan_t { + bit<3> priority_code_point; + bit<1> drop_eligible_indicator; + vlan_id_t vlan_id; + ether_type_t ether_type; } header ipv4_t { @@ -65,6 +74,7 @@ header icmp_t { bit<8> type; bit<8> code; bit<16> checksum; + bit<32> rest_of_header; } header arp_t { @@ -92,104 +102,219 @@ header gre_t { bit<16> protocol; } +header ipfix_t { + bit<16> version_number; + bit<16> length; + bit<32> export_time; + bit<32> sequence_number; + bit<32> observation_domain_id; +} + +header psamp_extended_t { + bit<16> template_id; + bit<16> length; + bit<64> observation_time; + bit<16> flowset; + bit<16> next_hop_index; + bit<16> epoch; + bit<16> ingress_port; + bit<16> egress_port; + bit<16> user_meta_field; + bit<8> dlb_id; + bit<8> variable_length; + bit<16> packet_sampled_length; +} + enum bit<8> PreservedFieldList { - CLONE_I2E = 8w1 + MIRROR_AND_PACKET_IN_COPY = 8w1, + RECIRCULATE = 8w2 } type bit<10> nexthop_id_t; +type bit<10> tunnel_id_t; type bit<12> wcmp_group_id_t; -type bit<10> vrf_id_t; +@p4runtime_translation_mappings({ { "" , 0 } , }) type bit<10> vrf_id_t; type bit<10> router_interface_id_t; type bit<9> port_id_t; type bit<10> mirror_session_id_t; type bit<8> qos_queue_t; typedef bit<6> route_metadata_t; +typedef bit<8> acl_metadata_t; +typedef bit<16> multicast_group_id_t; +typedef bit<16> replica_instance_t; enum bit<2> MeterColor_t { GREEN = 2w0, YELLOW = 2w1, RED = 2w2 } +@controller_header("packet_in") header packet_in_header_t { + @id(1) + port_id_t ingress_port; + @id(2) + port_id_t target_egress_port; +} + +@controller_header("packet_out") header packet_out_header_t { + @id(1) + port_id_t egress_port; + @id(2) + bit<1> submit_to_ingress; + @id(3) @padding + bit<6> unused_pad; +} + struct headers_t { - ethernet_t erspan_ethernet; - ipv4_t erspan_ipv4; - gre_t erspan_gre; - ethernet_t ethernet; - ipv6_t tunnel_encap_ipv6; - gre_t tunnel_encap_gre; - ipv4_t ipv4; - ipv6_t ipv6; - icmp_t icmp; - tcp_t tcp; - udp_t udp; - arp_t arp; + packet_out_header_t packet_out_header; + ethernet_t mirror_encap_ethernet; + vlan_t mirror_encap_vlan; + ipv6_t mirror_encap_ipv6; + udp_t mirror_encap_udp; + ipfix_t ipfix; + psamp_extended_t psamp_extended; + ethernet_t ethernet; + vlan_t vlan; + ipv6_t tunnel_encap_ipv6; + gre_t tunnel_encap_gre; + ipv4_t ipv4; + ipv6_t ipv6; + ipv4_t inner_ipv4; + ipv6_t inner_ipv6; + icmp_t icmp; + tcp_t tcp; + udp_t udp; + arp_t arp; } struct packet_rewrites_t { ethernet_addr_t src_mac; ethernet_addr_t dst_mac; + vlan_id_t vlan_id; } struct local_metadata_t { + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + bool enable_vlan_checks; + vlan_id_t vlan_id; bool admit_to_l3; vrf_id_t vrf_id; + bool enable_decrement_ttl; + bool enable_src_mac_rewrite; + bool enable_dst_mac_rewrite; + bool enable_vlan_rewrite; packet_rewrites_t packet_rewrites; bit<16> l4_src_port; bit<16> l4_dst_port; - bit<16> wcmp_selector_input; + bit<8> wcmp_selector_input; + bool apply_tunnel_decap_at_end_of_pre_ingress; bool apply_tunnel_encap_at_egress; ipv6_addr_t tunnel_encap_src_ipv6; ipv6_addr_t tunnel_encap_dst_ipv6; - bool mirror_session_id_valid; - mirror_session_id_t mirror_session_id_value; - @field_list(PreservedFieldList.CLONE_I2E) - ipv4_addr_t mirroring_src_ip; - @field_list(PreservedFieldList.CLONE_I2E) - ipv4_addr_t mirroring_dst_ip; - @field_list(PreservedFieldList.CLONE_I2E) - ethernet_addr_t mirroring_src_mac; - @field_list(PreservedFieldList.CLONE_I2E) - ethernet_addr_t mirroring_dst_mac; - @field_list(PreservedFieldList.CLONE_I2E) - bit<8> mirroring_ttl; - @field_list(PreservedFieldList.CLONE_I2E) - bit<8> mirroring_tos; + bool marked_to_copy; + bool marked_to_mirror; + mirror_session_id_t mirror_session_id; + port_id_t mirror_egress_port; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + ethernet_addr_t mirror_encap_src_mac; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + ethernet_addr_t mirror_encap_dst_mac; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + vlan_id_t mirror_encap_vlan_id; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + ipv6_addr_t mirror_encap_src_ip; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + ipv6_addr_t mirror_encap_dst_ip; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + bit<16> mirror_encap_udp_src_port; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + bit<16> mirror_encap_udp_dst_port; + @field_list(PreservedFieldList.RECIRCULATE) + bit<9> loopback_port; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + bit<9> packet_in_ingress_port; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + bit<9> packet_in_target_egress_port; MeterColor_t color; port_id_t ingress_port; route_metadata_t route_metadata; -} - -@controller_header("packet_in") header packet_in_header_t { - @id(1) - port_id_t ingress_port; - @id(2) - port_id_t target_egress_port; -} - -@controller_header("packet_out") header packet_out_header_t { - @id(1) - port_id_t egress_port; - @id(2) - bit<1> submit_to_ingress; - @id(3) - bit<7> unused_pad; + acl_metadata_t acl_metadata; + bool bypass_ingress; + bool wcmp_group_id_valid; + wcmp_group_id_t wcmp_group_id_value; + bool nexthop_id_valid; + nexthop_id_t nexthop_id_value; + bool ipmc_table_hit; + bool acl_drop; } parser packet_parser(packet_in packet, out headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { state start { + local_metadata.enable_vlan_checks = false; + local_metadata.vlan_id = 12w0; local_metadata.admit_to_l3 = false; local_metadata.vrf_id = (vrf_id_t)10w0; + local_metadata.enable_decrement_ttl = false; + local_metadata.enable_src_mac_rewrite = false; + local_metadata.enable_dst_mac_rewrite = false; + local_metadata.enable_vlan_rewrite = false; local_metadata.packet_rewrites.src_mac = 48w0; local_metadata.packet_rewrites.dst_mac = 48w0; local_metadata.l4_src_port = 16w0; local_metadata.l4_dst_port = 16w0; - local_metadata.wcmp_selector_input = 16w0; - local_metadata.mirror_session_id_valid = false; + local_metadata.wcmp_selector_input = 8w0; + local_metadata.apply_tunnel_decap_at_end_of_pre_ingress = false; + local_metadata.apply_tunnel_encap_at_egress = false; + local_metadata.tunnel_encap_src_ipv6 = 128w0; + local_metadata.tunnel_encap_dst_ipv6 = 128w0; + local_metadata.marked_to_copy = false; + local_metadata.marked_to_mirror = false; + local_metadata.mirror_session_id = (mirror_session_id_t)10w0; + local_metadata.mirror_egress_port = (port_id_t)9w0; local_metadata.color = MeterColor_t.GREEN; - local_metadata.ingress_port = (port_id_t)standard_metadata.ingress_port; local_metadata.route_metadata = 6w0; + local_metadata.bypass_ingress = false; + local_metadata.wcmp_group_id_valid = false; + local_metadata.wcmp_group_id_value = (wcmp_group_id_t)12w0; + local_metadata.nexthop_id_valid = false; + local_metadata.nexthop_id_value = (nexthop_id_t)10w0; + local_metadata.ipmc_table_hit = false; + local_metadata.acl_drop = false; + transition select(standard_metadata.instance_type == 32w4) { + true: start_true; + false: start_false; + } + } + state start_true { + local_metadata.ingress_port = (port_id_t)local_metadata.loopback_port; + transition start_join; + } + state start_false { + local_metadata.ingress_port = (port_id_t)standard_metadata.ingress_port; + transition start_join; + } + state start_join { + transition select(standard_metadata.ingress_port) { + 9w510: parse_packet_out_header; + default: parse_ethernet; + } + } + state parse_packet_out_header { + packet.extract(headers.packet_out_header); + transition parse_ethernet; + } + state parse_ethernet { packet.extract(headers.ethernet); transition select(headers.ethernet.ether_type) { + 16w0x800: parse_ipv4; + 16w0x86dd: parse_ipv6; + 16w0x806: parse_arp; + 16w0x8100: parse_8021q_vlan; + default: accept; + } + } + state parse_8021q_vlan { + packet.extract(headers.vlan); + transition select(headers.vlan.ether_type) { 16w0x800: parse_ipv4; 16w0x86dd: parse_ipv6; 16w0x806: parse_arp; @@ -199,6 +324,17 @@ parser packet_parser(packet_in packet, out headers_t headers, inout local_metada state parse_ipv4 { packet.extract(headers.ipv4); transition select(headers.ipv4.protocol) { + 8w0x4: parse_ipv4_in_ip; + 8w0x29: parse_ipv6_in_ip; + 8w0x1: parse_icmp; + 8w0x6: parse_tcp; + 8w0x11: parse_udp; + default: accept; + } + } + state parse_ipv4_in_ip { + packet.extract(headers.inner_ipv4); + transition select(headers.inner_ipv4.protocol) { 8w0x1: parse_icmp; 8w0x6: parse_tcp; 8w0x11: parse_udp; @@ -208,6 +344,17 @@ parser packet_parser(packet_in packet, out headers_t headers, inout local_metada state parse_ipv6 { packet.extract(headers.ipv6); transition select(headers.ipv6.next_header) { + 8w0x4: parse_ipv4_in_ip; + 8w0x29: parse_ipv6_in_ip; + 8w0x3a: parse_icmp; + 8w0x6: parse_tcp; + 8w0x11: parse_udp; + default: accept; + } + } + state parse_ipv6_in_ip { + packet.extract(headers.inner_ipv6); + transition select(headers.inner_ipv6.next_header) { 8w0x3a: parse_icmp; 8w0x6: parse_tcp; 8w0x11: parse_udp; @@ -238,14 +385,21 @@ parser packet_parser(packet_in packet, out headers_t headers, inout local_metada control packet_deparser(packet_out packet, in headers_t headers) { apply { - packet.emit(headers.erspan_ethernet); - packet.emit(headers.erspan_ipv4); - packet.emit(headers.erspan_gre); + packet.emit(headers.packet_out_header); + packet.emit(headers.mirror_encap_ethernet); + packet.emit(headers.mirror_encap_vlan); + packet.emit(headers.mirror_encap_ipv6); + packet.emit(headers.mirror_encap_udp); + packet.emit(headers.ipfix); + packet.emit(headers.psamp_extended); packet.emit(headers.ethernet); + packet.emit(headers.vlan); packet.emit(headers.tunnel_encap_ipv6); packet.emit(headers.tunnel_encap_gre); packet.emit(headers.ipv4); packet.emit(headers.ipv6); + packet.emit(headers.inner_ipv4); + packet.emit(headers.inner_ipv6); packet.emit(headers.arp); packet.emit(headers.icmp); packet.emit(headers.tcp); @@ -261,28 +415,31 @@ control verify_ipv4_checksum(inout headers_t headers, inout local_metadata_t loc control compute_ipv4_checksum(inout headers_t headers, inout local_metadata_t local_metadata) { apply { - update_checksum, bit<4>, bit<6>, bit<2>, bit<16>, bit<16>, bit<1>, bit<1>, bit<1>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>, bit<16>>(headers.erspan_ipv4.isValid(), { headers.erspan_ipv4.version, headers.erspan_ipv4.ihl, headers.erspan_ipv4.dscp, headers.erspan_ipv4.ecn, headers.erspan_ipv4.total_len, headers.erspan_ipv4.identification, headers.erspan_ipv4.reserved, headers.erspan_ipv4.do_not_fragment, headers.erspan_ipv4.more_fragments, headers.erspan_ipv4.frag_offset, headers.erspan_ipv4.ttl, headers.erspan_ipv4.protocol, headers.erspan_ipv4.src_addr, headers.erspan_ipv4.dst_addr }, headers.erspan_ipv4.header_checksum, HashAlgorithm.csum16); update_checksum, bit<4>, bit<6>, bit<2>, bit<16>, bit<16>, bit<1>, bit<1>, bit<1>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>, bit<16>>(headers.ipv4.isValid(), { headers.ipv4.version, headers.ipv4.ihl, headers.ipv4.dscp, headers.ipv4.ecn, headers.ipv4.total_len, headers.ipv4.identification, headers.ipv4.reserved, headers.ipv4.do_not_fragment, headers.ipv4.more_fragments, headers.ipv4.frag_offset, headers.ipv4.ttl, headers.ipv4.protocol, headers.ipv4.src_addr, headers.ipv4.dst_addr }, headers.ipv4.header_checksum, HashAlgorithm.csum16); } } control ingress(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { @name("ingress.acl_pre_ingress.dscp") bit<6> acl_pre_ingress_dscp; - @name("ingress.routing.wcmp_group_id_valid") bool routing_wcmp_group_id_valid; - @name("ingress.routing.wcmp_group_id_value") wcmp_group_id_t routing_wcmp_group_id_value; - @name("ingress.routing.nexthop_id_valid") bool routing_nexthop_id_valid; - @name("ingress.routing.nexthop_id_value") nexthop_id_t routing_nexthop_id_value; - @name("ingress.routing.router_interface_id_valid") bool routing_router_interface_id_valid; - @name("ingress.routing.router_interface_id_value") router_interface_id_t routing_router_interface_id_value; - @name("ingress.routing.neighbor_id_valid") bool routing_neighbor_id_valid; - @name("ingress.routing.neighbor_id_value") ipv6_addr_t routing_neighbor_id_value; + @name("ingress.acl_pre_ingress.ecn") bit<2> acl_pre_ingress_ecn; + @name("ingress.hashing.seed") bit<32> hashing_seed; + @name("ingress.hashing.offset") bit<8> hashing_offset; @name("ingress.acl_ingress.ttl") bit<8> acl_ingress_ttl; @name("ingress.acl_ingress.dscp") bit<6> acl_ingress_dscp; @name("ingress.acl_ingress.ecn") bit<2> acl_ingress_ecn; @name("ingress.acl_ingress.ip_protocol") bit<8> acl_ingress_ip_protocol; - @name("ingress.mirroring_clone.mirror_port") port_id_t mirroring_clone_mirror_port; - @name("ingress.mirroring_clone.pre_session") bit<32> mirroring_clone_pre_session; - @name("ingress.standard_metadata") standard_metadata_t standard_metadata_0; + @name("ingress.acl_ingress.cancel_copy") bool acl_ingress_cancel_copy; + @name("ingress.routing_resolution.tunnel_id_valid") bool routing_resolution_tunnel_id_valid; + @name("ingress.routing_resolution.tunnel_id_value") tunnel_id_t routing_resolution_tunnel_id_value; + @name("ingress.routing_resolution.router_interface_id_valid") bool routing_resolution_router_interface_id_valid; + @name("ingress.routing_resolution.router_interface_id_value") router_interface_id_t routing_resolution_router_interface_id_value; + @name("ingress.routing_resolution.neighbor_id_valid") bool routing_resolution_neighbor_id_valid; + @name("ingress.routing_resolution.neighbor_id_value") ipv6_addr_t routing_resolution_neighbor_id_value; + @name("ingress.local_metadata") local_metadata_t local_metadata_0; + @name("ingress.local_metadata") local_metadata_t local_metadata_1; + @name("ingress.local_metadata") local_metadata_t local_metadata_8; + @name("ingress.local_metadata") local_metadata_t local_metadata_9; + @name("ingress.local_metadata") local_metadata_t local_metadata_10; @noWarn("unused") @name(".NoAction") action NoAction_2() { } @noWarn("unused") @name(".NoAction") action NoAction_3() { @@ -301,19 +458,92 @@ control ingress(inout headers_t headers, inout local_metadata_t local_metadata, } @noWarn("unused") @name(".NoAction") action NoAction_10() { } - @id(0x01000109) @sai_action(SAI_PACKET_ACTION_DROP) @name(".acl_drop") action acl_drop_1() { - standard_metadata_0 = standard_metadata; - mark_to_drop(standard_metadata_0); - standard_metadata = standard_metadata_0; + @noWarn("unused") @name(".NoAction") action NoAction_11() { + } + @noWarn("unused") @name(".NoAction") action NoAction_12() { + } + @noWarn("unused") @name(".NoAction") action NoAction_13() { + } + @noWarn("unused") @name(".NoAction") action NoAction_14() { + } + @noWarn("unused") @name(".NoAction") action NoAction_15() { + } + @noWarn("unused") @name(".NoAction") action NoAction_16() { + } + @noWarn("unused") @name(".NoAction") action NoAction_17() { + } + @id(0x01000005) @name(".set_nexthop_id") action set_nexthop_id_1(@id(1) @refers_to(nexthop_table , nexthop_id) @name("nexthop_id") nexthop_id_t nexthop_id) { + local_metadata_0 = local_metadata; + local_metadata_0.nexthop_id_valid = true; + local_metadata_0.nexthop_id_value = nexthop_id; + local_metadata = local_metadata_0; + } + @id(0x01000005) @name(".set_nexthop_id") action set_nexthop_id_2(@id(1) @refers_to(nexthop_table , nexthop_id) @name("nexthop_id") nexthop_id_t nexthop_id_2) { + local_metadata_1 = local_metadata; + local_metadata_1.nexthop_id_valid = true; + local_metadata_1.nexthop_id_value = nexthop_id_2; + local_metadata = local_metadata_1; + } + @id(0x01000005) @name(".set_nexthop_id") action set_nexthop_id_3(@id(1) @refers_to(nexthop_table , nexthop_id) @name("nexthop_id") nexthop_id_t nexthop_id_3) { + local_metadata_8 = local_metadata; + local_metadata_8.nexthop_id_valid = true; + local_metadata_8.nexthop_id_value = nexthop_id_3; + local_metadata = local_metadata_8; + } + @id(0x01000109) @sai_action(SAI_PACKET_ACTION_DROP) @name(".acl_drop") action acl_drop_2() { + local_metadata_9 = local_metadata; + local_metadata_9.acl_drop = true; + local_metadata = local_metadata_9; + } + @id(0x01000109) @sai_action(SAI_PACKET_ACTION_DROP) @name(".acl_drop") action acl_drop_3() { + local_metadata_10 = local_metadata; + local_metadata_10.acl_drop = true; + local_metadata = local_metadata_10; + } + @id(0x01000016) @name("ingress.tunnel_termination_lookup.mark_for_tunnel_decap_and_set_vrf") action tunnel_termination_lookup_mark_for_tunnel_decap_and_set_vrf_0(@refers_to(vrf_table , vrf_id) @name("vrf_id") vrf_id_t vrf_id_2) { + local_metadata.apply_tunnel_decap_at_end_of_pre_ingress = true; + local_metadata.vrf_id = vrf_id_2; + } + @unsupported @p4runtime_role("sdn_controller") @id(0x0200004B) @name("ingress.tunnel_termination_lookup.ipv6_tunnel_termination_table") table tunnel_termination_lookup_ipv6_tunnel_termination_table { + key = { + headers.ipv6.dst_addr: ternary @id(1) @name("dst_ipv6") @format(IPV6_ADDRESS); + headers.ipv6.src_addr: ternary @id(2) @name("src_ipv6") @format(IPV6_ADDRESS); + } + actions = { + @proto_id(1) tunnel_termination_lookup_mark_for_tunnel_decap_and_set_vrf_0(); + @defaultonly NoAction_2(); + } + size = 126; + default_action = NoAction_2(); + } + @id(0x0100001A) @name("ingress.vlan_untag.disable_vlan_checks") action vlan_untag_disable_vlan_checks_0() { + local_metadata.enable_vlan_checks = false; + } + @p4runtime_role("sdn_controller") @id(0x0200004D) @entry_restriction(" + // Force the dummy_match to be wildcard. + dummy_match::mask == 0; + ") @name("ingress.vlan_untag.disable_vlan_checks_table") table vlan_untag_disable_vlan_checks_table { + key = { + 1w1: ternary @id(1) @name("dummy_match"); + } + actions = { + @proto_id(1) vlan_untag_disable_vlan_checks_0(); + @defaultonly NoAction_3(); + } + size = 1; + default_action = NoAction_3(); } @id(0x13000101) @name("ingress.acl_pre_ingress.acl_pre_ingress_counter") direct_counter(CounterType.packets_and_bytes) acl_pre_ingress_acl_pre_ingress_counter; - @id(0x01000100) @sai_action(SAI_PACKET_ACTION_FORWARD) @name("ingress.acl_pre_ingress.set_vrf") action acl_pre_ingress_set_vrf_0(@sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_SET_VRF) @refers_to(vrf_table , vrf_id) @id(1) @name("vrf_id") vrf_id_t vrf_id_1) { - local_metadata.vrf_id = vrf_id_1; + @id(0x13000106) @name("ingress.acl_pre_ingress.acl_pre_ingress_vlan_counter") direct_counter(CounterType.packets_and_bytes) acl_pre_ingress_acl_pre_ingress_vlan_counter; + @id(0x13000105) @name("ingress.acl_pre_ingress.acl_pre_ingress_metadata_counter") direct_counter(CounterType.packets_and_bytes) acl_pre_ingress_acl_pre_ingress_metadata_counter; + @id(0x01000100) @sai_action(SAI_PACKET_ACTION_FORWARD) @name("ingress.acl_pre_ingress.set_vrf") action acl_pre_ingress_set_vrf_0(@sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_SET_VRF) @refers_to(vrf_table , vrf_id) @id(1) @name("vrf_id") vrf_id_t vrf_id_3) { + local_metadata.vrf_id = vrf_id_3; acl_pre_ingress_acl_pre_ingress_counter.count(); } - @p4runtime_role("sdn_controller") @id(0x02000101) @sai_acl(PRE_INGRESS) @entry_restriction(" + @p4runtime_role("sdn_controller") @id(0x02000101) @sai_acl(PRE_INGRESS) @sai_acl_priority(11) @entry_restriction(" // Only allow IP field matches for IP packets. dscp::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + ecn::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); dst_ip::mask != 0 -> is_ipv4 == 1; dst_ipv6::mask != 0 -> is_ipv6 == 1; // Forbid illegal combinations of IP_TYPE fields. @@ -323,28 +553,33 @@ control ingress(inout headers_t headers, inout local_metadata_t local_metadata, // Forbid unsupported combinations of IP_TYPE fields. is_ipv4::mask != 0 -> (is_ipv4 == 1); is_ipv6::mask != 0 -> (is_ipv6 == 1); + + + + // Reserve high priorities for switch-internal use. // TODO: Remove once inband workaround is obsolete. ::priority < 0x7fffffff; ") @name("ingress.acl_pre_ingress.acl_pre_ingress_table") table acl_pre_ingress_acl_pre_ingress_table { key = { - headers.ipv4.isValid() || headers.ipv6.isValid(): optional @name("is_ip") @id(1) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); - headers.ipv4.isValid() : optional @name("is_ipv4") @id(2) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); - headers.ipv6.isValid() : optional @name("is_ipv6") @id(3) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); - headers.ethernet.src_addr : ternary @name("src_mac") @id(4) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_SRC_MAC) @format(MAC_ADDRESS); - headers.ethernet.dst_addr : ternary @name("dst_mac") @id(9) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_MAC) @format(MAC_ADDRESS); - headers.ipv4.dst_addr : ternary @name("dst_ip") @id(5) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_IP) @format(IPV4_ADDRESS); - headers.ipv6.dst_addr[127:64] : ternary @name("dst_ipv6") @id(6) @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD2 )) @format(IPV6_ADDRESS); - acl_pre_ingress_dscp : ternary @name("dscp") @id(7) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DSCP); - local_metadata.ingress_port : optional @name("in_port") @id(8) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IN_PORT); + headers.ipv4.isValid() || headers.ipv6.isValid(): optional @id(1) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(2) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(3) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + headers.ethernet.src_addr : ternary @id(4) @name("src_mac") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_SRC_MAC) @format(MAC_ADDRESS); + headers.ethernet.dst_addr : ternary @id(9) @name("dst_mac") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_MAC) @format(MAC_ADDRESS); + headers.ipv4.dst_addr : ternary @id(5) @name("dst_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_IP) @format(IPV4_ADDRESS); + headers.ipv6.dst_addr[127:64] : ternary @id(6) @name("dst_ipv6") @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD2 )) @format(IPV6_ADDRESS); + acl_pre_ingress_dscp : ternary @id(7) @name("dscp") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DSCP); + acl_pre_ingress_ecn : ternary @id(10) @name("ecn") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ECN); + local_metadata.ingress_port : optional @id(8) @name("in_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IN_PORT); } actions = { @proto_id(1) acl_pre_ingress_set_vrf_0(); - @defaultonly NoAction_2(); + @defaultonly NoAction_4(); } - const default_action = NoAction_2(); + const default_action = NoAction_4(); counters = acl_pre_ingress_acl_pre_ingress_counter; - size = 255; + size = 254; } @id(0x01000008) @name("ingress.l3_admit.admit_to_l3") action l3_admit_admit_to_l3_0() { local_metadata.admit_to_l3 = true; @@ -356,104 +591,29 @@ control ingress(inout headers_t headers, inout local_metadata_t local_metadata, } actions = { @proto_id(1) l3_admit_admit_to_l3_0(); - @defaultonly NoAction_3(); - } - const default_action = NoAction_3(); - size = 128; - } - @id(0x01000001) @name("ingress.routing.set_dst_mac") action routing_set_dst_mac_0(@id(1) @format(MAC_ADDRESS) @name("dst_mac") ethernet_addr_t dst_mac_2) { - local_metadata.packet_rewrites.dst_mac = dst_mac_2; - } - @p4runtime_role("sdn_controller") @id(0x02000040) @name("ingress.routing.neighbor_table") table routing_neighbor_table { - key = { - routing_router_interface_id_value: exact @id(1) @name("router_interface_id") @refers_to(router_interface_table , router_interface_id); - routing_neighbor_id_value : exact @id(2) @format(IPV6_ADDRESS) @name("neighbor_id"); - } - actions = { - @proto_id(1) routing_set_dst_mac_0(); - @defaultonly NoAction_4(); - } - const default_action = NoAction_4(); - size = 1024; - } - @id(0x01000002) @name("ingress.routing.set_port_and_src_mac") action routing_set_port_and_src_mac_0(@id(1) @name("port") port_id_t port, @id(2) @format(MAC_ADDRESS) @name("src_mac") ethernet_addr_t src_mac_2) { - standard_metadata.egress_spec = (bit<9>)port; - local_metadata.packet_rewrites.src_mac = src_mac_2; - } - @p4runtime_role("sdn_controller") @id(0x02000041) @name("ingress.routing.router_interface_table") table routing_router_interface_table { - key = { - routing_router_interface_id_value: exact @id(1) @name("router_interface_id"); - } - actions = { - @proto_id(1) routing_set_port_and_src_mac_0(); @defaultonly NoAction_5(); } const default_action = NoAction_5(); - size = 256; + size = 64; } - @id(0x01000014) @name("ingress.routing.set_ip_nexthop") action routing_set_ip_nexthop_0(@id(1) @refers_to(router_interface_table , router_interface_id) @refers_to(neighbor_table , router_interface_id) @name("router_interface_id") router_interface_id_t router_interface_id, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) @name("neighbor_id") ipv6_addr_t neighbor_id) { - routing_router_interface_id_valid = true; - routing_router_interface_id_value = router_interface_id; - routing_neighbor_id_valid = true; - routing_neighbor_id_value = neighbor_id; + @sai_hash_seed(0) @id(0x010000A) @name("ingress.hashing.select_ecmp_hash_algorithm") action hashing_select_ecmp_hash_algorithm_0() { + hashing_seed = 32w0; } - @id(0x01000003) @deprecated("Use set_ip_nexthop instead.") @name("ingress.routing.set_nexthop") action routing_set_nexthop_0(@id(1) @refers_to(router_interface_table , router_interface_id) @refers_to(neighbor_table , router_interface_id) @name("router_interface_id") router_interface_id_t router_interface_id_2, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) @name("neighbor_id") ipv6_addr_t neighbor_id_2) { - @id(0x01000014) { - routing_router_interface_id_valid = true; - routing_router_interface_id_value = router_interface_id_2; - routing_neighbor_id_valid = true; - routing_neighbor_id_value = neighbor_id_2; - } - } - @p4runtime_role("sdn_controller") @id(0x02000042) @name("ingress.routing.nexthop_table") table routing_nexthop_table { - key = { - routing_nexthop_id_value: exact @id(1) @name("nexthop_id"); - } - actions = { - @proto_id(1) routing_set_nexthop_0(); - @proto_id(3) routing_set_ip_nexthop_0(); - @defaultonly NoAction_6(); - } - const default_action = NoAction_6(); - size = 1024; + @sai_ecmp_hash(SAI_SWITCH_ATTR_ECMP_HASH_IPV4) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_SRC_IPV4) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_DST_IPV4) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_SRC_PORT) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_DST_PORT) @id(0x0100000B) @name("ingress.hashing.compute_ecmp_hash_ipv4") action hashing_compute_ecmp_hash_ipv4_0() { + hash, bit<1>, tuple, bit<32>, bit<32>, bit<16>, bit<16>>, bit<17>>(local_metadata.wcmp_selector_input, HashAlgorithm.crc32, 1w0, { hashing_seed, headers.ipv4.src_addr, headers.ipv4.dst_addr, local_metadata.l4_src_port, local_metadata.l4_dst_port }, 17w0x10000); + local_metadata.wcmp_selector_input = local_metadata.wcmp_selector_input >> hashing_offset | local_metadata.wcmp_selector_input << 8w8 - hashing_offset; } - @id(0x01000005) @name("ingress.routing.set_nexthop_id") action routing_set_nexthop_id_0(@id(1) @refers_to(nexthop_table , nexthop_id) @name("nexthop_id") nexthop_id_t nexthop_id) { - routing_nexthop_id_valid = true; - routing_nexthop_id_value = nexthop_id; + @sai_ecmp_hash(SAI_SWITCH_ATTR_ECMP_HASH_IPV6) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_SRC_IPV6) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_DST_IPV6) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_SRC_PORT) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_DST_PORT) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_IPV6_FLOW_LABEL) @id(0x0100000C) @name("ingress.hashing.compute_ecmp_hash_ipv6") action hashing_compute_ecmp_hash_ipv6_0() { + hash, bit<1>, tuple, bit<20>, bit<128>, bit<128>, bit<16>, bit<16>>, bit<17>>(local_metadata.wcmp_selector_input, HashAlgorithm.crc32, 1w0, { hashing_seed, headers.ipv6.flow_label, headers.ipv6.src_addr, headers.ipv6.dst_addr, local_metadata.l4_src_port, local_metadata.l4_dst_port }, 17w0x10000); + local_metadata.wcmp_selector_input = local_metadata.wcmp_selector_input >> hashing_offset | local_metadata.wcmp_selector_input << 8w8 - hashing_offset; } - @id(0x01000005) @name("ingress.routing.set_nexthop_id") action routing_set_nexthop_id_1(@id(1) @refers_to(nexthop_table , nexthop_id) @name("nexthop_id") nexthop_id_t nexthop_id_2) { - routing_nexthop_id_valid = true; - routing_nexthop_id_value = nexthop_id_2; + @sai_hash_algorithm(SAI_HASH_ALGORITHM_CRC) @sai_hash_seed(0) @sai_hash_offset(0) @name("ingress.lag_hashing_config.select_lag_hash_algorithm") action lag_hashing_config_select_lag_hash_algorithm_0() { } - @id(0x01000005) @name("ingress.routing.set_nexthop_id") action routing_set_nexthop_id_2(@id(1) @refers_to(nexthop_table , nexthop_id) @name("nexthop_id") nexthop_id_t nexthop_id_3) { - routing_nexthop_id_valid = true; - routing_nexthop_id_value = nexthop_id_3; + @sai_lag_hash(SAI_SWITCH_ATTR_LAG_HASH_IPV4) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_SRC_IPV4) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_DST_IPV4) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_SRC_PORT) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_DST_PORT) @id(0x0100000D) @name("ingress.lag_hashing_config.compute_lag_hash_ipv4") action lag_hashing_config_compute_lag_hash_ipv4_0() { } - @id(0x01000010) @name("ingress.routing.set_nexthop_id_and_metadata") action routing_set_nexthop_id_and_metadata_0(@id(1) @refers_to(nexthop_table , nexthop_id) @name("nexthop_id") nexthop_id_t nexthop_id_4, @name("route_metadata") route_metadata_t route_metadata_3) { - routing_nexthop_id_valid = true; - routing_nexthop_id_value = nexthop_id_4; - local_metadata.route_metadata = route_metadata_3; + @sai_lag_hash(SAI_SWITCH_ATTR_LAG_HASH_IPV6) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_SRC_IPV6) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_DST_IPV6) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_SRC_PORT) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_DST_PORT) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_IPV6_FLOW_LABEL) @id(0x0100000E) @name("ingress.lag_hashing_config.compute_lag_hash_ipv6") action lag_hashing_config_compute_lag_hash_ipv6_0() { } - @id(0x01000010) @name("ingress.routing.set_nexthop_id_and_metadata") action routing_set_nexthop_id_and_metadata_1(@id(1) @refers_to(nexthop_table , nexthop_id) @name("nexthop_id") nexthop_id_t nexthop_id_5, @name("route_metadata") route_metadata_t route_metadata_4) { - routing_nexthop_id_valid = true; - routing_nexthop_id_value = nexthop_id_5; - local_metadata.route_metadata = route_metadata_4; - } - @max_group_size(256) @name("ingress.routing.wcmp_group_selector") action_selector(HashAlgorithm.identity, 32w65536, 32w16) routing_wcmp_group_selector; - @p4runtime_role("sdn_controller") @id(0x02000043) @oneshot @name("ingress.routing.wcmp_group_table") table routing_wcmp_group_table { - key = { - routing_wcmp_group_id_value : exact @id(1) @name("wcmp_group_id"); - local_metadata.wcmp_selector_input: selector @name("local_metadata.wcmp_selector_input"); - } - actions = { - @proto_id(1) routing_set_nexthop_id_0(); - @defaultonly NoAction_7(); - } - const default_action = NoAction_7(); - @id(0x11DC4EC8) implementation = routing_wcmp_group_selector; - size = 3968; - } - @name("ingress.routing.no_action") action routing_no_action_0() { + @id(0x01798B9E) @name("ingress.routing_lookup.no_action") action routing_lookup_no_action_0() { } @entry_restriction(" // The VRF ID 0 (or '' in P4Runtime) encodes the default VRF, which cannot @@ -462,148 +622,201 @@ control ingress(inout headers_t headers, inout local_metadata_t local_metadata, // constraints are a control plane (P4Runtime) concept), but // p4-constraints does not currently support strings. vrf_id != 0; - ") @p4runtime_role("sdn_controller") @id(0x0200004A) @name("ingress.routing.vrf_table") table routing_vrf_table { + ") @p4runtime_role("sdn_controller") @id(0x0200004A) @name("ingress.routing_lookup.vrf_table") table routing_lookup_vrf_table { key = { local_metadata.vrf_id: exact @id(1) @name("vrf_id"); } actions = { - @proto_id(1) routing_no_action_0(); + @proto_id(1) routing_lookup_no_action_0(); } - const default_action = routing_no_action_0(); + const default_action = routing_lookup_no_action_0(); size = 64; } - @id(0x01000006) @name("ingress.routing.drop") action routing_drop_0() { + @id(0x01000006) @name("ingress.routing_lookup.drop") action routing_lookup_drop_0() { mark_to_drop(standard_metadata); } - @id(0x01000006) @name("ingress.routing.drop") action routing_drop_1() { + @id(0x01000006) @name("ingress.routing_lookup.drop") action routing_lookup_drop_1() { mark_to_drop(standard_metadata); } - @id(0x01000004) @name("ingress.routing.set_wcmp_group_id") action routing_set_wcmp_group_id_0(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) @name("wcmp_group_id") wcmp_group_id_t wcmp_group_id) { - routing_wcmp_group_id_valid = true; - routing_wcmp_group_id_value = wcmp_group_id; + @id(0x01000004) @name("ingress.routing_lookup.set_wcmp_group_id") action routing_lookup_set_wcmp_group_id_0(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) @name("wcmp_group_id") wcmp_group_id_t wcmp_group_id) { + local_metadata.wcmp_group_id_valid = true; + local_metadata.wcmp_group_id_value = wcmp_group_id; } - @id(0x01000004) @name("ingress.routing.set_wcmp_group_id") action routing_set_wcmp_group_id_1(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) @name("wcmp_group_id") wcmp_group_id_t wcmp_group_id_2) { - routing_wcmp_group_id_valid = true; - routing_wcmp_group_id_value = wcmp_group_id_2; + @id(0x01000004) @name("ingress.routing_lookup.set_wcmp_group_id") action routing_lookup_set_wcmp_group_id_1(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) @name("wcmp_group_id") wcmp_group_id_t wcmp_group_id_2) { + local_metadata.wcmp_group_id_valid = true; + local_metadata.wcmp_group_id_value = wcmp_group_id_2; } - @id(0x01000011) @name("ingress.routing.set_wcmp_group_id_and_metadata") action routing_set_wcmp_group_id_and_metadata_0(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) @name("wcmp_group_id") wcmp_group_id_t wcmp_group_id_3, @name("route_metadata") route_metadata_t route_metadata_5) { + @id(0x01000011) @name("ingress.routing_lookup.set_wcmp_group_id_and_metadata") action routing_lookup_set_wcmp_group_id_and_metadata_0(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) @name("wcmp_group_id") wcmp_group_id_t wcmp_group_id_3, @name("route_metadata") route_metadata_t route_metadata_3) { @id(0x01000004) { - routing_wcmp_group_id_valid = true; - routing_wcmp_group_id_value = wcmp_group_id_3; + local_metadata.wcmp_group_id_valid = true; + local_metadata.wcmp_group_id_value = wcmp_group_id_3; } - local_metadata.route_metadata = route_metadata_5; + local_metadata.route_metadata = route_metadata_3; } - @id(0x01000011) @name("ingress.routing.set_wcmp_group_id_and_metadata") action routing_set_wcmp_group_id_and_metadata_1(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) @name("wcmp_group_id") wcmp_group_id_t wcmp_group_id_4, @name("route_metadata") route_metadata_t route_metadata_6) { + @id(0x01000011) @name("ingress.routing_lookup.set_wcmp_group_id_and_metadata") action routing_lookup_set_wcmp_group_id_and_metadata_1(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) @name("wcmp_group_id") wcmp_group_id_t wcmp_group_id_4, @name("route_metadata") route_metadata_t route_metadata_4) { @id(0x01000004) { - routing_wcmp_group_id_valid = true; - routing_wcmp_group_id_value = wcmp_group_id_4; + local_metadata.wcmp_group_id_valid = true; + local_metadata.wcmp_group_id_value = wcmp_group_id_4; } - local_metadata.route_metadata = route_metadata_6; + local_metadata.route_metadata = route_metadata_4; } - @id(0x0100000F) @name("ingress.routing.trap") action routing_trap_0() { - clone(CloneType.I2E, 32w1024); + @id(0x01000015) @name("ingress.routing_lookup.set_metadata_and_drop") action routing_lookup_set_metadata_and_drop_0(@id(1) @name("route_metadata") route_metadata_t route_metadata_5) { + local_metadata.route_metadata = route_metadata_5; mark_to_drop(standard_metadata); } - @id(0x0100000F) @name("ingress.routing.trap") action routing_trap_1() { - clone(CloneType.I2E, 32w1024); + @id(0x01000015) @name("ingress.routing_lookup.set_metadata_and_drop") action routing_lookup_set_metadata_and_drop_1(@id(1) @name("route_metadata") route_metadata_t route_metadata_6) { + local_metadata.route_metadata = route_metadata_6; mark_to_drop(standard_metadata); } - @id(0x01000015) @name("ingress.routing.set_metadata_and_drop") action routing_set_metadata_and_drop_0(@id(1) @name("route_metadata") route_metadata_t route_metadata_7) { + @id(0x01000010) @name("ingress.routing_lookup.set_nexthop_id_and_metadata") action routing_lookup_set_nexthop_id_and_metadata_0(@id(1) @refers_to(nexthop_table , nexthop_id) @name("nexthop_id") nexthop_id_t nexthop_id_4, @name("route_metadata") route_metadata_t route_metadata_7) { + local_metadata.nexthop_id_valid = true; + local_metadata.nexthop_id_value = nexthop_id_4; local_metadata.route_metadata = route_metadata_7; - mark_to_drop(standard_metadata); } - @id(0x01000015) @name("ingress.routing.set_metadata_and_drop") action routing_set_metadata_and_drop_1(@id(1) @name("route_metadata") route_metadata_t route_metadata_8) { + @id(0x01000010) @name("ingress.routing_lookup.set_nexthop_id_and_metadata") action routing_lookup_set_nexthop_id_and_metadata_1(@id(1) @refers_to(nexthop_table , nexthop_id) @name("nexthop_id") nexthop_id_t nexthop_id_5, @name("route_metadata") route_metadata_t route_metadata_8) { + local_metadata.nexthop_id_valid = true; + local_metadata.nexthop_id_value = nexthop_id_5; local_metadata.route_metadata = route_metadata_8; - mark_to_drop(standard_metadata); } - @p4runtime_role("sdn_controller") @id(0x02000044) @name("ingress.routing.ipv4_table") table routing_ipv4_table { + @id(0x01000018) @action_restriction(" + // Disallow 0 since it encodes 'no multicast' in V1Model. + multicast_group_id != 0; + ") @name("ingress.routing_lookup.set_multicast_group_id") action routing_lookup_set_multicast_group_id_0(@id(1) @refers_to(builtin : : multicast_group_table , multicast_group_id) @name("multicast_group_id") multicast_group_id_t multicast_group_id) { + standard_metadata.mcast_grp = multicast_group_id; + } + @id(0x01000018) @action_restriction(" + // Disallow 0 since it encodes 'no multicast' in V1Model. + multicast_group_id != 0; + ") @name("ingress.routing_lookup.set_multicast_group_id") action routing_lookup_set_multicast_group_id_1(@id(1) @refers_to(builtin : : multicast_group_table , multicast_group_id) @name("multicast_group_id") multicast_group_id_t multicast_group_id_1) { + standard_metadata.mcast_grp = multicast_group_id_1; + } + @p4runtime_role("sdn_controller") @id(0x02000044) @name("ingress.routing_lookup.ipv4_table") table routing_lookup_ipv4_table { + key = { + local_metadata.vrf_id: exact @id(1) @name("vrf_id") @refers_to(vrf_table , vrf_id); + headers.ipv4.dst_addr: lpm @id(2) @name("ipv4_dst") @format(IPV4_ADDRESS); + } + actions = { + @proto_id(1) routing_lookup_drop_0(); + @proto_id(2) set_nexthop_id_1(); + @proto_id(3) routing_lookup_set_wcmp_group_id_0(); + @proto_id(5) routing_lookup_set_nexthop_id_and_metadata_0(); + @proto_id(6) routing_lookup_set_wcmp_group_id_and_metadata_0(); + @proto_id(7) routing_lookup_set_metadata_and_drop_0(); + } + const default_action = routing_lookup_drop_0(); + size = 131072; + } + @p4runtime_role("sdn_controller") @id(0x02000045) @name("ingress.routing_lookup.ipv6_table") table routing_lookup_ipv6_table { + key = { + local_metadata.vrf_id: exact @id(1) @name("vrf_id") @refers_to(vrf_table , vrf_id); + headers.ipv6.dst_addr: lpm @id(2) @name("ipv6_dst") @format(IPV6_ADDRESS); + } + actions = { + @proto_id(1) routing_lookup_drop_1(); + @proto_id(2) set_nexthop_id_2(); + @proto_id(3) routing_lookup_set_wcmp_group_id_1(); + @proto_id(5) routing_lookup_set_nexthop_id_and_metadata_1(); + @proto_id(6) routing_lookup_set_wcmp_group_id_and_metadata_1(); + @proto_id(7) routing_lookup_set_metadata_and_drop_1(); + } + const default_action = routing_lookup_drop_1(); + size = 17000; + } + @p4runtime_role("sdn_controller") @id(0x0200004E) @name("ingress.routing_lookup.ipv4_multicast_table") table routing_lookup_ipv4_multicast_table { key = { local_metadata.vrf_id: exact @id(1) @name("vrf_id") @refers_to(vrf_table , vrf_id); - headers.ipv4.dst_addr: lpm @format(IPV4_ADDRESS) @id(2) @name("ipv4_dst"); + headers.ipv4.dst_addr: exact @id(2) @name("ipv4_dst") @format(IPV4_ADDRESS); } actions = { - @proto_id(1) routing_drop_0(); - @proto_id(2) routing_set_nexthop_id_1(); - @proto_id(3) routing_set_wcmp_group_id_0(); - @proto_id(4) routing_trap_0(); - @proto_id(5) routing_set_nexthop_id_and_metadata_0(); - @proto_id(6) routing_set_wcmp_group_id_and_metadata_0(); - @proto_id(7) routing_set_metadata_and_drop_0(); - } - const default_action = routing_drop_0(); - size = 32768; - } - @p4runtime_role("sdn_controller") @id(0x02000045) @name("ingress.routing.ipv6_table") table routing_ipv6_table { + @proto_id(1) routing_lookup_set_multicast_group_id_0(); + @defaultonly NoAction_6(); + } + size = 1600; + default_action = NoAction_6(); + } + @p4runtime_role("sdn_controller") @id(0x0200004F) @name("ingress.routing_lookup.ipv6_multicast_table") table routing_lookup_ipv6_multicast_table { key = { local_metadata.vrf_id: exact @id(1) @name("vrf_id") @refers_to(vrf_table , vrf_id); - headers.ipv6.dst_addr: lpm @format(IPV6_ADDRESS) @id(2) @name("ipv6_dst"); + headers.ipv6.dst_addr: exact @id(2) @name("ipv6_dst") @format(IPV6_ADDRESS); } actions = { - @proto_id(1) routing_drop_1(); - @proto_id(2) routing_set_nexthop_id_2(); - @proto_id(3) routing_set_wcmp_group_id_1(); - @proto_id(4) routing_trap_1(); - @proto_id(5) routing_set_nexthop_id_and_metadata_1(); - @proto_id(6) routing_set_wcmp_group_id_and_metadata_1(); - @proto_id(7) routing_set_metadata_and_drop_1(); - } - const default_action = routing_drop_1(); - size = 4096; - } - @id(0x15000100) @name("ingress.acl_ingress.acl_ingress_meter") direct_meter(MeterType.bytes) acl_ingress_acl_ingress_meter; + @proto_id(1) routing_lookup_set_multicast_group_id_1(); + @defaultonly NoAction_7(); + } + size = 1600; + default_action = NoAction_7(); + } + @id(0x15000100) @mode(single_rate_two_color) @name("ingress.acl_ingress.acl_ingress_meter") direct_meter(MeterType.bytes) acl_ingress_acl_ingress_meter; + @id(0x15000102) @mode(single_rate_two_color) @name("ingress.acl_ingress.acl_ingress_qos_meter") direct_meter(MeterType.bytes) acl_ingress_acl_ingress_qos_meter; @id(0x13000102) @name("ingress.acl_ingress.acl_ingress_counter") direct_counter(CounterType.packets_and_bytes) acl_ingress_acl_ingress_counter; - @id(0x01000101) @sai_action(SAI_PACKET_ACTION_COPY , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_YELLOW) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_RED) @name("ingress.acl_ingress.acl_copy") action acl_ingress_acl_copy_0(@sai_action_param(QOS_QUEUE) @id(1) @name("qos_queue") qos_queue_t qos_queue) { + @id(0x13000107) @name("ingress.acl_ingress.acl_ingress_qos_counter") direct_counter(CounterType.packets_and_bytes) acl_ingress_acl_ingress_qos_counter; + @id(0x13000109) @name("ingress.acl_ingress.acl_ingress_counting_counter") direct_counter(CounterType.packets_and_bytes) acl_ingress_acl_ingress_counting_counter; + @id(0x1300010A) @name("ingress.acl_ingress.acl_ingress_security_counter") direct_counter(CounterType.packets_and_bytes) acl_ingress_acl_ingress_security_counter; + @id(0x01000101) @sai_action(SAI_PACKET_ACTION_COPY , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_RED) @name("ingress.acl_ingress.acl_copy") action acl_ingress_acl_copy_0(@sai_action_param(QOS_QUEUE) @id(1) @name("qos_queue") qos_queue_t qos_queue) { acl_ingress_acl_ingress_counter.count(); acl_ingress_acl_ingress_meter.read(local_metadata.color); - clone(CloneType.I2E, 32w1024); + local_metadata.marked_to_copy = true; } - @id(0x01000102) @sai_action(SAI_PACKET_ACTION_TRAP , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_YELLOW) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED) @name("ingress.acl_ingress.acl_trap") action acl_ingress_acl_trap_0(@sai_action_param(QOS_QUEUE) @id(1) @name("qos_queue") qos_queue_t qos_queue_3) { - @id(0x01000101) @sai_action(SAI_PACKET_ACTION_COPY , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_YELLOW) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_RED) { + @id(0x01000102) @sai_action(SAI_PACKET_ACTION_TRAP , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED) @name("ingress.acl_ingress.acl_trap") action acl_ingress_acl_trap_0(@sai_action_param(QOS_QUEUE) @id(1) @name("qos_queue") qos_queue_t qos_queue_3) { + @id(0x01000101) @sai_action(SAI_PACKET_ACTION_COPY , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_RED) { acl_ingress_acl_ingress_counter.count(); acl_ingress_acl_ingress_meter.read(local_metadata.color); - clone(CloneType.I2E, 32w1024); + local_metadata.marked_to_copy = true; } - mark_to_drop(standard_metadata); + local_metadata.acl_drop = true; } - @id(0x01000199) @sai_action(SAI_PACKET_ACTION_TRAP , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_YELLOW) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED) @name("ingress.acl_ingress.acl_experimental_trap") action acl_ingress_acl_experimental_trap_0(@sai_action_param(QOS_QUEUE) @id(1) @name("qos_queue") qos_queue_t qos_queue_4) { + @id(0x01000103) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED) @name("ingress.acl_ingress.acl_forward") action acl_ingress_acl_forward_0() { acl_ingress_acl_ingress_meter.read(local_metadata.color); - @id(0x01000102) @sai_action(SAI_PACKET_ACTION_TRAP , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_YELLOW) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED) { - @id(0x01000101) @sai_action(SAI_PACKET_ACTION_COPY , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_YELLOW) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_RED) { - acl_ingress_acl_ingress_counter.count(); - acl_ingress_acl_ingress_meter.read(local_metadata.color); - clone(CloneType.I2E, 32w1024); - } - mark_to_drop(standard_metadata); - } } - @id(0x01000103) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_YELLOW) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED) @name("ingress.acl_ingress.acl_forward") action acl_ingress_acl_forward_0() { - acl_ingress_acl_ingress_counter.count(); + @id(0x01000103) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED) @name("ingress.acl_ingress.acl_forward") action acl_ingress_acl_forward_1() { acl_ingress_acl_ingress_meter.read(local_metadata.color); } - @id(0x01000104) @sai_action(SAI_PACKET_ACTION_FORWARD) @name("ingress.acl_ingress.acl_mirror") action acl_ingress_acl_mirror_0(@id(1) @refers_to(mirror_session_table , mirror_session_id) @sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_MIRROR_INGRESS) @name("mirror_session_id") mirror_session_id_t mirror_session_id) { + @id(0x01000105) @sai_action(SAI_PACKET_ACTION_FORWARD) @name("ingress.acl_ingress.acl_count") action acl_ingress_acl_count_0() { + acl_ingress_acl_ingress_counting_counter.count(); + } + @id(0x01000104) @sai_action(SAI_PACKET_ACTION_FORWARD) @name("ingress.acl_ingress.acl_mirror") action acl_ingress_acl_mirror_0(@id(1) @refers_to(mirror_session_table , mirror_session_id) @sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_MIRROR_INGRESS) @name("mirror_session_id") mirror_session_id_t mirror_session_id_1) { acl_ingress_acl_ingress_counter.count(); - local_metadata.mirror_session_id_valid = true; - local_metadata.mirror_session_id_value = mirror_session_id; + local_metadata.marked_to_mirror = true; + local_metadata.mirror_session_id = mirror_session_id_1; + } + @id(0x0100010C) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_COPY_CANCEL , SAI_PACKET_COLOR_RED) @name("ingress.acl_ingress.set_qos_queue_and_cancel_copy_above_rate_limit") action acl_ingress_set_qos_queue_and_cancel_copy_above_rate_limit_0(@id(1) @sai_action_param(QOS_QUEUE) @name("qos_queue") qos_queue_t qos_queue_4) { + acl_ingress_acl_ingress_qos_meter.read(local_metadata.color); + } + @id(0x01000111) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DENY , SAI_PACKET_COLOR_RED) @unsupported @name("ingress.acl_ingress.set_cpu_and_multicast_queues_and_deny_above_rate_limit") action acl_ingress_set_cpu_and_multicast_queues_and_deny_above_rate_limit_0(@id(1) @sai_action_param(QOS_QUEUE) @name("cpu_queue") qos_queue_t cpu_queue, @id(2) @sai_action_param(MULTICAST_QOS_QUEUE , SAI_PACKET_COLOR_GREEN) @name("green_multicast_queue") qos_queue_t green_multicast_queue, @id(3) @sai_action_param(MULTICAST_QOS_QUEUE , SAI_PACKET_COLOR_RED) @name("red_multicast_queue") qos_queue_t red_multicast_queue) { + acl_ingress_acl_ingress_qos_meter.read(local_metadata.color); + } + @id(0x0100010E) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DENY , SAI_PACKET_COLOR_RED) @name("ingress.acl_ingress.set_cpu_queue_and_deny_above_rate_limit") action acl_ingress_set_cpu_queue_and_deny_above_rate_limit_0(@id(1) @sai_action_param(QOS_QUEUE) @name("cpu_queue") qos_queue_t cpu_queue_3) { + acl_ingress_acl_ingress_qos_meter.read(local_metadata.color); } - @p4runtime_role("sdn_controller") @id(0x02000100) @sai_acl(INGRESS) @entry_restriction(" + @id(0x01000110) @sai_action(SAI_PACKET_ACTION_FORWARD) @name("ingress.acl_ingress.set_cpu_queue") action acl_ingress_set_cpu_queue_0(@id(1) @sai_action_param(QOS_QUEUE) @name("cpu_queue") qos_queue_t cpu_queue_4) { + } + @p4runtime_role("sdn_controller") @id(0x02000100) @sai_acl(INGRESS) @sai_acl_priority(5) @entry_restriction(" // Forbid using ether_type for IP packets (by convention, use is_ip* instead). ether_type != 0x0800 && ether_type != 0x86dd; // Only allow IP field matches for IP packets. dst_ip::mask != 0 -> is_ipv4 == 1; + + src_ip::mask != 0 -> is_ipv4 == 1; + dst_ipv6::mask != 0 -> is_ipv6 == 1; + src_ipv6::mask != 0 -> is_ipv6 == 1; ttl::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + dscp::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); ecn::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + ip_protocol::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); // Only allow l4_dst_port and l4_src_port matches for TCP/UDP packets. + l4_src_port::mask != 0 -> (ip_protocol == 6 || ip_protocol == 17); + l4_dst_port::mask != 0 -> (ip_protocol == 6 || ip_protocol == 17); - // Only allow icmp_type matches for ICMP packets + // Only allow icmp_type matches for ICMP packets icmp_type::mask != 0 -> ip_protocol == 1; icmpv6_type::mask != 0 -> ip_protocol == 58; @@ -616,170 +829,491 @@ control ingress(inout headers_t headers, inout local_metadata_t local_metadata, is_ipv6::mask != 0 -> (is_ipv6 == 1); ") @name("ingress.acl_ingress.acl_ingress_table") table acl_ingress_acl_ingress_table { key = { - headers.ipv4.isValid() || headers.ipv6.isValid(): optional @name("is_ip") @id(1) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); - headers.ipv4.isValid() : optional @name("is_ipv4") @id(2) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); - headers.ipv6.isValid() : optional @name("is_ipv6") @id(3) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); - headers.ethernet.ether_type : ternary @name("ether_type") @id(4) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ETHER_TYPE); - headers.ethernet.dst_addr : ternary @name("dst_mac") @id(5) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_MAC) @format(MAC_ADDRESS); - headers.ipv4.src_addr : ternary @name("src_ip") @id(6) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_SRC_IP) @format(IPV4_ADDRESS); - headers.ipv4.dst_addr : ternary @name("dst_ip") @id(7) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_IP) @format(IPV4_ADDRESS); - headers.ipv6.src_addr[127:64] : ternary @name("src_ipv6") @id(8) @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_SRC_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_SRC_IPV6_WORD2 )) @format(IPV6_ADDRESS); - headers.ipv6.dst_addr[127:64] : ternary @name("dst_ipv6") @id(9) @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD2 )) @format(IPV6_ADDRESS); - acl_ingress_ttl : ternary @name("ttl") @id(10) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_TTL); - acl_ingress_dscp : ternary @name("dscp") @id(11) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DSCP); - acl_ingress_ecn : ternary @name("ecn") @id(12) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ECN); - acl_ingress_ip_protocol : ternary @name("ip_protocol") @id(13) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IP_PROTOCOL); - headers.icmp.type : ternary @name("icmp_type") @id(19) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ICMP_TYPE); - headers.icmp.type : ternary @name("icmpv6_type") @id(14) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ICMPV6_TYPE); - local_metadata.l4_src_port : ternary @name("l4_src_port") @id(20) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_L4_SRC_PORT); - local_metadata.l4_dst_port : ternary @name("l4_dst_port") @id(15) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_L4_DST_PORT); - local_metadata.ingress_port : optional @name("in_port") @id(17) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IN_PORT); - local_metadata.route_metadata : optional @name("route_metadata") @id(18) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ROUTE_DST_USER_META); + headers.ipv4.isValid() || headers.ipv6.isValid(): optional @id(1) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(2) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(3) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + headers.ethernet.ether_type : ternary @id(4) @name("ether_type") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ETHER_TYPE); + headers.ethernet.dst_addr : ternary @id(5) @name("dst_mac") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_MAC) @format(MAC_ADDRESS); + headers.ipv4.src_addr : ternary @id(6) @name("src_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_SRC_IP) @format(IPV4_ADDRESS); + headers.ipv4.dst_addr : ternary @id(7) @name("dst_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_IP) @format(IPV4_ADDRESS); + headers.ipv6.src_addr[127:64] : ternary @id(8) @name("src_ipv6") @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_SRC_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_SRC_IPV6_WORD2 )) @format(IPV6_ADDRESS); + headers.ipv6.dst_addr[127:64] : ternary @id(9) @name("dst_ipv6") @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD2 )) @format(IPV6_ADDRESS); + acl_ingress_ttl : ternary @id(10) @name("ttl") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_TTL); + acl_ingress_dscp : ternary @id(11) @name("dscp") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DSCP); + acl_ingress_ecn : ternary @id(12) @name("ecn") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ECN); + acl_ingress_ip_protocol : ternary @id(13) @name("ip_protocol") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IP_PROTOCOL); + headers.icmp.type : ternary @id(19) @name("icmp_type") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ICMP_TYPE); + headers.icmp.type : ternary @id(14) @name("icmpv6_type") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ICMPV6_TYPE); + local_metadata.l4_src_port : ternary @id(20) @name("l4_src_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_L4_SRC_PORT); + local_metadata.l4_dst_port : ternary @id(15) @name("l4_dst_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_L4_DST_PORT); + local_metadata.ingress_port : optional @id(17) @name("in_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IN_PORT); + local_metadata.route_metadata : optional @id(18) @name("route_metadata") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ROUTE_DST_USER_META); } actions = { @proto_id(1) acl_ingress_acl_copy_0(); @proto_id(2) acl_ingress_acl_trap_0(); @proto_id(3) acl_ingress_acl_forward_0(); @proto_id(4) acl_ingress_acl_mirror_0(); - @proto_id(5) acl_drop_1(); - @proto_id(99) acl_ingress_acl_experimental_trap_0(); + @proto_id(5) acl_drop_2(); @defaultonly NoAction_8(); } const default_action = NoAction_8(); meters = acl_ingress_acl_ingress_meter; counters = acl_ingress_acl_ingress_counter; - size = 128; - } - @id(0x01000007) @name("ingress.mirroring_clone.mirror_as_ipv4_erspan") action mirroring_clone_mirror_as_ipv4_erspan_0(@id(1) @name("port") port_id_t port_2, @id(2) @format(IPV4_ADDRESS) @name("src_ip") ipv4_addr_t src_ip, @id(3) @format(IPV4_ADDRESS) @name("dst_ip") ipv4_addr_t dst_ip, @id(4) @format(MAC_ADDRESS) @name("src_mac") ethernet_addr_t src_mac_3, @id(5) @format(MAC_ADDRESS) @name("dst_mac") ethernet_addr_t dst_mac_3, @id(6) @name("ttl") bit<8> ttl_0, @id(7) @name("tos") bit<8> tos) { - mirroring_clone_mirror_port = port_2; - local_metadata.mirroring_src_ip = src_ip; - local_metadata.mirroring_dst_ip = dst_ip; - local_metadata.mirroring_src_mac = src_mac_3; - local_metadata.mirroring_dst_mac = dst_mac_3; - local_metadata.mirroring_ttl = ttl_0; - local_metadata.mirroring_tos = tos; - } - @p4runtime_role("sdn_controller") @id(0x02000046) @name("ingress.mirroring_clone.mirror_session_table") table mirroring_clone_mirror_session_table { + size = 255; + } + @id(0x02000107) @sai_acl(INGRESS) @sai_acl_priority(10) @p4runtime_role("sdn_controller") @entry_restriction(" + // Forbid using ether_type for IP packets (by convention, use is_ip* instead). + ether_type != 0x0800 && ether_type != 0x86dd; + // Only allow IP field matches for IP packets. + ttl::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + ip_protocol::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + // Only allow l4_dst_port matches for TCP/UDP packets. + l4_dst_port::mask != 0 -> (ip_protocol == 6 || ip_protocol == 17); + // Forbid illegal combinations of IP_TYPE fields. + is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0); + is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0); + is_ipv6::mask != 0 -> (is_ip::mask == 0 && is_ipv4::mask == 0); + // Forbid unsupported combinations of IP_TYPE fields. + is_ipv4::mask != 0 -> (is_ipv4 == 1); + is_ipv6::mask != 0 -> (is_ipv6 == 1); + // Only allow icmp_type matches for ICMP packets + icmpv6_type::mask != 0 -> ip_protocol == 58; + + // Only allow l4_dst_port matches for TCP/UDP packets. + l4_src_port::mask != 0 -> (ip_protocol == 6 || ip_protocol == 17); + // Only allow icmp_type matches for ICMP packets + icmp_type::mask != 0 -> ip_protocol == 1; + + + + + + ") @name("ingress.acl_ingress.acl_ingress_qos_table") table acl_ingress_acl_ingress_qos_table { key = { - local_metadata.mirror_session_id_value: exact @id(1) @name("mirror_session_id"); + headers.ipv4.isValid() || headers.ipv6.isValid(): optional @id(1) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(2) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(3) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + headers.ethernet.ether_type : ternary @id(4) @name("ether_type") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ETHER_TYPE); + acl_ingress_ttl : ternary @id(7) @name("ttl") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_TTL); + acl_ingress_ip_protocol : ternary @id(8) @name("ip_protocol") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IP_PROTOCOL); + headers.icmp.type : ternary @id(9) @name("icmpv6_type") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ICMPV6_TYPE); + local_metadata.l4_dst_port : ternary @id(10) @name("l4_dst_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_L4_DST_PORT); + local_metadata.l4_src_port : ternary @id(12) @name("l4_src_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_L4_SRC_PORT); + headers.icmp.type : ternary @id(14) @name("icmp_type") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ICMP_TYPE); + local_metadata.route_metadata : ternary @id(15) @name("route_metadata") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ROUTE_DST_USER_META); } actions = { - @proto_id(1) mirroring_clone_mirror_as_ipv4_erspan_0(); + @proto_id(1) acl_ingress_set_qos_queue_and_cancel_copy_above_rate_limit_0(); + @proto_id(2) acl_ingress_set_cpu_queue_and_deny_above_rate_limit_0(); + @proto_id(3) acl_ingress_acl_forward_1(); + @proto_id(4) acl_drop_3(); + @proto_id(5) acl_ingress_set_cpu_queue_0(); + @proto_id(6) acl_ingress_set_cpu_and_multicast_queues_and_deny_above_rate_limit_0(); @defaultonly NoAction_9(); } const default_action = NoAction_9(); - size = 2; + meters = acl_ingress_acl_ingress_qos_meter; + counters = acl_ingress_acl_ingress_qos_counter; + size = 511; } - @id(0x01000009) @name("ingress.mirroring_clone.set_pre_session") action mirroring_clone_set_pre_session_0(@name("id") bit<32> id) { - mirroring_clone_pre_session = id; - } - @p4runtime_role("packet_replication_engine_manager") @id(0x02000048) @name("ingress.mirroring_clone.mirror_port_to_pre_session_table") table mirroring_clone_mirror_port_to_pre_session_table { + @p4runtime_role("sdn_controller") @id(0x02000109) @sai_acl_priority(7) @sai_acl(INGRESS) @entry_restriction(" + // Only allow IP field matches for IP packets. + dscp::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + // Forbid illegal combinations of IP_TYPE fields. + is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0); + is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0); + is_ipv6::mask != 0 -> (is_ip::mask == 0 && is_ipv4::mask == 0); + // Forbid unsupported combinations of IP_TYPE fields. + is_ipv4::mask != 0 -> (is_ipv4 == 1); + is_ipv6::mask != 0 -> (is_ipv6 == 1); + ") @name("ingress.acl_ingress.acl_ingress_counting_table") table acl_ingress_acl_ingress_counting_table { key = { - mirroring_clone_mirror_port: exact @id(1) @name("mirror_port"); + headers.ipv4.isValid() || headers.ipv6.isValid(): optional @id(1) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(2) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(3) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + acl_ingress_dscp : ternary @id(11) @name("dscp") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DSCP); + local_metadata.route_metadata : ternary @id(18) @name("route_metadata") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ROUTE_DST_USER_META); } actions = { - @proto_id(1) mirroring_clone_set_pre_session_0(); + @proto_id(3) acl_ingress_acl_count_0(); @defaultonly NoAction_10(); } const default_action = NoAction_10(); + counters = acl_ingress_acl_ingress_counting_counter; + size = 255; + } + @id(0x01000001) @name("ingress.routing_resolution.set_dst_mac") action routing_resolution_set_dst_mac_0(@id(1) @format(MAC_ADDRESS) @name("dst_mac") ethernet_addr_t dst_mac_2) { + local_metadata.packet_rewrites.dst_mac = dst_mac_2; + } + @p4runtime_role("sdn_controller") @id(0x02000040) @name("ingress.routing_resolution.neighbor_table") table routing_resolution_neighbor_table { + key = { + routing_resolution_router_interface_id_value: exact @id(1) @name("router_interface_id") @refers_to(router_interface_table , router_interface_id); + routing_resolution_neighbor_id_value : exact @id(2) @format(IPV6_ADDRESS) @name("neighbor_id"); + } + actions = { + @proto_id(1) routing_resolution_set_dst_mac_0(); + @defaultonly NoAction_11(); + } + const default_action = NoAction_11(); + size = 1024; + } + @id(0x0100001B) @unsupported @action_restriction(" + // Disallow reserved VLAN IDs with implementation-defined semantics. + vlan_id != 0 && vlan_id != 4095") @name("ingress.routing_resolution.set_port_and_src_mac_and_vlan_id") action routing_resolution_set_port_and_src_mac_and_vlan_id_0(@id(1) @name("port") port_id_t port, @id(2) @format(MAC_ADDRESS) @name("src_mac") ethernet_addr_t src_mac_4, @id(3) @name("vlan_id") vlan_id_t vlan_id_1) { + standard_metadata.egress_spec = (bit<9>)port; + local_metadata.packet_rewrites.src_mac = src_mac_4; + local_metadata.packet_rewrites.vlan_id = vlan_id_1; + } + @id(0x01000002) @name("ingress.routing_resolution.set_port_and_src_mac") action routing_resolution_set_port_and_src_mac_0(@id(1) @name("port") port_id_t port_3, @id(2) @format(MAC_ADDRESS) @name("src_mac") ethernet_addr_t src_mac_5) { + @id(0x0100001B) @unsupported @action_restriction(" + // Disallow reserved VLAN IDs with implementation-defined semantics. + vlan_id != 0 && vlan_id != 4095") { + standard_metadata.egress_spec = (bit<9>)port_3; + local_metadata.packet_rewrites.src_mac = src_mac_5; + local_metadata.packet_rewrites.vlan_id = 12w0xfff; + } + } + @p4runtime_role("sdn_controller") @id(0x02000041) @name("ingress.routing_resolution.router_interface_table") table routing_resolution_router_interface_table { + key = { + routing_resolution_router_interface_id_value: exact @id(1) @name("router_interface_id"); + } + actions = { + @proto_id(1) routing_resolution_set_port_and_src_mac_0(); + @proto_id(2) routing_resolution_set_port_and_src_mac_and_vlan_id_0(); + @defaultonly NoAction_12(); + } + const default_action = NoAction_12(); + size = 256; + } + @id(0x01000017) @name("ingress.routing_resolution.set_ip_nexthop_and_disable_rewrites") action routing_resolution_set_ip_nexthop_and_disable_rewrites_0(@id(1) @refers_to(router_interface_table , router_interface_id) @refers_to(neighbor_table , router_interface_id) @name("router_interface_id") router_interface_id_t router_interface_id, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) @name("neighbor_id") ipv6_addr_t neighbor_id, @id(3) @name("disable_decrement_ttl") bit<1> disable_decrement_ttl, @id(4) @name("disable_src_mac_rewrite") bit<1> disable_src_mac_rewrite, @id(5) @name("disable_dst_mac_rewrite") bit<1> disable_dst_mac_rewrite, @id(6) @name("disable_vlan_rewrite") bit<1> disable_vlan_rewrite) { + routing_resolution_router_interface_id_valid = true; + routing_resolution_router_interface_id_value = router_interface_id; + routing_resolution_neighbor_id_valid = true; + routing_resolution_neighbor_id_value = neighbor_id; + local_metadata.enable_decrement_ttl = !(bool)disable_decrement_ttl; + local_metadata.enable_src_mac_rewrite = !(bool)disable_src_mac_rewrite; + local_metadata.enable_dst_mac_rewrite = !(bool)disable_dst_mac_rewrite; + local_metadata.enable_vlan_rewrite = !(bool)disable_vlan_rewrite; + } + @id(0x01000014) @name("ingress.routing_resolution.set_ip_nexthop") action routing_resolution_set_ip_nexthop_0(@id(1) @refers_to(router_interface_table , router_interface_id) @refers_to(neighbor_table , router_interface_id) @name("router_interface_id") router_interface_id_t router_interface_id_4, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) @name("neighbor_id") ipv6_addr_t neighbor_id_3) { + @id(0x01000017) { + routing_resolution_router_interface_id_valid = true; + routing_resolution_router_interface_id_value = router_interface_id_4; + routing_resolution_neighbor_id_valid = true; + routing_resolution_neighbor_id_value = neighbor_id_3; + local_metadata.enable_decrement_ttl = true; + local_metadata.enable_src_mac_rewrite = true; + local_metadata.enable_dst_mac_rewrite = true; + local_metadata.enable_vlan_rewrite = true; + } + } + @id(0x01000003) @deprecated("Use set_ip_nexthop instead.") @name("ingress.routing_resolution.set_nexthop") action routing_resolution_set_nexthop_0(@id(1) @refers_to(router_interface_table , router_interface_id) @refers_to(neighbor_table , router_interface_id) @name("router_interface_id") router_interface_id_t router_interface_id_5, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) @name("neighbor_id") ipv6_addr_t neighbor_id_4) { + @id(0x01000014) { + @id(0x01000017) { + routing_resolution_router_interface_id_valid = true; + routing_resolution_router_interface_id_value = router_interface_id_5; + routing_resolution_neighbor_id_valid = true; + routing_resolution_neighbor_id_value = neighbor_id_4; + local_metadata.enable_decrement_ttl = true; + local_metadata.enable_src_mac_rewrite = true; + local_metadata.enable_dst_mac_rewrite = true; + local_metadata.enable_vlan_rewrite = true; + } + } + } + @id(0x01000012) @name("ingress.routing_resolution.set_p2p_tunnel_encap_nexthop") action routing_resolution_set_p2p_tunnel_encap_nexthop_0(@id(1) @refers_to(tunnel_table , tunnel_id) @name("tunnel_id") tunnel_id_t tunnel_id) { + routing_resolution_tunnel_id_valid = true; + routing_resolution_tunnel_id_value = tunnel_id; + } + @p4runtime_role("sdn_controller") @id(0x02000042) @name("ingress.routing_resolution.nexthop_table") table routing_resolution_nexthop_table { + key = { + local_metadata.nexthop_id_value: exact @id(1) @name("nexthop_id"); + } + actions = { + @proto_id(1) routing_resolution_set_nexthop_0(); + @proto_id(2) routing_resolution_set_p2p_tunnel_encap_nexthop_0(); + @proto_id(3) routing_resolution_set_ip_nexthop_0(); + @proto_id(4) routing_resolution_set_ip_nexthop_and_disable_rewrites_0(); + @defaultonly NoAction_13(); + } + const default_action = NoAction_13(); + size = 1024; + } + @id(0x01000013) @name("ingress.routing_resolution.mark_for_p2p_tunnel_encap") action routing_resolution_mark_for_p2p_tunnel_encap_0(@id(1) @format(IPV6_ADDRESS) @name("encap_src_ip") ipv6_addr_t encap_src_ip, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) @name("encap_dst_ip") ipv6_addr_t encap_dst_ip, @id(3) @refers_to(neighbor_table , router_interface_id) @refers_to(router_interface_table , router_interface_id) @name("router_interface_id") router_interface_id_t router_interface_id_6) { + local_metadata.tunnel_encap_src_ipv6 = encap_src_ip; + local_metadata.tunnel_encap_dst_ipv6 = encap_dst_ip; + local_metadata.apply_tunnel_encap_at_egress = true; + @id(0x01000014) { + @id(0x01000017) { + routing_resolution_router_interface_id_valid = true; + routing_resolution_router_interface_id_value = router_interface_id_6; + routing_resolution_neighbor_id_valid = true; + routing_resolution_neighbor_id_value = encap_dst_ip; + local_metadata.enable_decrement_ttl = true; + local_metadata.enable_src_mac_rewrite = true; + local_metadata.enable_dst_mac_rewrite = true; + local_metadata.enable_vlan_rewrite = true; + } + } + } + @p4runtime_role("sdn_controller") @id(0x02000050) @name("ingress.routing_resolution.tunnel_table") table routing_resolution_tunnel_table { + key = { + routing_resolution_tunnel_id_value: exact @id(1) @name("tunnel_id"); + } + actions = { + @proto_id(1) routing_resolution_mark_for_p2p_tunnel_encap_0(); + @defaultonly NoAction_14(); + } + const default_action = NoAction_14(); + size = 2048; + } + @max_group_size(512) @id(0x11DC4EC8) @name("ingress.routing_resolution.wcmp_group_selector") action_selector(HashAlgorithm.identity, 32w49152, 32w8) routing_resolution_wcmp_group_selector; + @p4runtime_role("sdn_controller") @id(0x02000043) @oneshot @name("ingress.routing_resolution.wcmp_group_table") table routing_resolution_wcmp_group_table { + key = { + local_metadata.wcmp_group_id_value: exact @id(1) @name("wcmp_group_id"); + local_metadata.wcmp_selector_input: selector @name("local_metadata.wcmp_selector_input"); + } + actions = { + @proto_id(1) set_nexthop_id_3(); + @defaultonly NoAction_15(); + } + const default_action = NoAction_15(); + implementation = routing_resolution_wcmp_group_selector; + size = 3968; + } + @id(0x01000007) @name("ingress.mirror_session_lookup.mirror_as_ipv4_erspan") action mirror_session_lookup_mirror_as_ipv4_erspan_0(@id(1) @name("port") port_id_t port_4, @id(2) @format(IPV4_ADDRESS) @name("src_ip") ipv4_addr_t src_ip, @id(3) @format(IPV4_ADDRESS) @name("dst_ip") ipv4_addr_t dst_ip, @id(4) @format(MAC_ADDRESS) @name("src_mac") ethernet_addr_t src_mac_6, @id(5) @format(MAC_ADDRESS) @name("dst_mac") ethernet_addr_t dst_mac_3, @id(6) @name("ttl") bit<8> ttl_1, @id(7) @name("tos") bit<8> tos) { + } + @id(0x0100001D) @unsupported @name("ingress.mirror_session_lookup.mirror_with_vlan_tag_and_ipfix_encapsulation") action mirror_session_lookup_mirror_with_vlan_tag_and_ipfix_encapsulation_0(@id(1) @name("monitor_port") port_id_t monitor_port, @id(2) @name("monitor_failover_port") port_id_t monitor_failover_port, @id(3) @format(MAC_ADDRESS) @name("mirror_encap_src_mac") ethernet_addr_t mirror_encap_src_mac_1, @id(4) @format(MAC_ADDRESS) @name("mirror_encap_dst_mac") ethernet_addr_t mirror_encap_dst_mac_1, @id(6) @name("mirror_encap_vlan_id") vlan_id_t mirror_encap_vlan_id_1, @id(7) @format(IPV6_ADDRESS) @name("mirror_encap_dst_ip") ipv6_addr_t mirror_encap_dst_ip_1, @id(8) @format(IPV6_ADDRESS) @name("mirror_encap_src_ip") ipv6_addr_t mirror_encap_src_ip_1, @id(9) @name("mirror_encap_udp_src_port") bit<16> mirror_encap_udp_src_port_1, @id(10) @name("mirror_encap_udp_dst_port") bit<16> mirror_encap_udp_dst_port_1) { + local_metadata.mirror_egress_port = monitor_port; + local_metadata.mirror_encap_src_mac = mirror_encap_src_mac_1; + local_metadata.mirror_encap_dst_mac = mirror_encap_dst_mac_1; + local_metadata.mirror_encap_vlan_id = mirror_encap_vlan_id_1; + local_metadata.mirror_encap_src_ip = mirror_encap_src_ip_1; + local_metadata.mirror_encap_dst_ip = mirror_encap_dst_ip_1; + local_metadata.mirror_encap_udp_src_port = mirror_encap_udp_src_port_1; + local_metadata.mirror_encap_udp_dst_port = mirror_encap_udp_dst_port_1; + } + @p4runtime_role("sdn_controller") @id(0x02000046) @name("ingress.mirror_session_lookup.mirror_session_table") table mirror_session_lookup_mirror_session_table { + key = { + local_metadata.mirror_session_id: exact @id(1) @name("mirror_session_id"); + } + actions = { + @proto_id(1) mirror_session_lookup_mirror_as_ipv4_erspan_0(); + @proto_id(2) mirror_session_lookup_mirror_with_vlan_tag_and_ipfix_encapsulation_0(); + @defaultonly NoAction_16(); + } + const default_action = NoAction_16(); + size = 4; + } + @id(0x0100001C) @name("ingress.ingress_cloning.ingress_clone") action ingress_cloning_ingress_clone_0(@id(1) @name("clone_session") bit<32> clone_session) { + clone_preserving_field_list(CloneType.I2E, clone_session, PreservedFieldList.MIRROR_AND_PACKET_IN_COPY); + } + @unsupported @p4runtime_role("packet_replication_engine_manager") @id(0x02000051) @entry_restriction(" + // mirror_egress_port is present iff marked_to_mirror is true. + // Exact match indicating presence of mirror_egress_port. + marked_to_mirror == 1 -> mirror_egress_port::mask == -1; + // Wildcard match indicating abscence of mirror_egress_port. + marked_to_mirror == 0 -> mirror_egress_port::mask == 0; + ") @name("ingress.ingress_cloning.ingress_clone_table") table ingress_cloning_ingress_clone_table { + key = { + local_metadata.marked_to_copy : exact @id(1) @name("marked_to_copy"); + local_metadata.marked_to_mirror : exact @id(2) @name("marked_to_mirror"); + local_metadata.mirror_egress_port: optional @id(3) @name("mirror_egress_port"); + } + actions = { + @proto_id(1) ingress_cloning_ingress_clone_0(); + @defaultonly NoAction_17(); + } + default_action = NoAction_17(); } apply { - acl_pre_ingress_dscp = 6w0; - if (headers.ipv4.isValid()) { - acl_pre_ingress_dscp = headers.ipv4.dscp; - } else if (headers.ipv6.isValid()) { - acl_pre_ingress_dscp = headers.ipv6.dscp; + if (headers.packet_out_header.isValid() && headers.packet_out_header.submit_to_ingress == 1w0) { + standard_metadata.egress_spec = (bit<9>)headers.packet_out_header.egress_port; + local_metadata.bypass_ingress = true; } - local_metadata.vrf_id = (vrf_id_t)10w0; - acl_pre_ingress_acl_pre_ingress_table.apply(); - local_metadata.admit_to_l3 = headers.ethernet.dst_addr & 48w0x10000000000 == 48w0; - l3_admit_l3_admit_table.apply(); - routing_wcmp_group_id_valid = false; - routing_nexthop_id_valid = false; - routing_router_interface_id_valid = false; - routing_neighbor_id_valid = false; - mark_to_drop(standard_metadata); - routing_vrf_table.apply(); - if (local_metadata.admit_to_l3) { + headers.packet_out_header.setInvalid(); + if (local_metadata.bypass_ingress) { + ; + } else { + if (headers.ipv6.isValid()) { + if (headers.ipv6.next_header == 8w0x4 || headers.ipv6.next_header == 8w0x29) { + tunnel_termination_lookup_ipv6_tunnel_termination_table.apply(); + } + } + if (headers.vlan.isValid()) { + local_metadata.vlan_id = headers.vlan.vlan_id; + headers.ethernet.ether_type = headers.vlan.ether_type; + headers.vlan.setInvalid(); + } else { + local_metadata.vlan_id = 12w0xfff; + } + local_metadata.enable_vlan_checks = true; + vlan_untag_disable_vlan_checks_table.apply(); + acl_pre_ingress_dscp = 6w0; + acl_pre_ingress_ecn = 2w0; if (headers.ipv4.isValid()) { - routing_ipv4_table.apply(); + acl_pre_ingress_dscp = headers.ipv4.dscp; + acl_pre_ingress_ecn = headers.ipv4.ecn; } else if (headers.ipv6.isValid()) { - routing_ipv6_table.apply(); + acl_pre_ingress_dscp = headers.ipv6.dscp; + acl_pre_ingress_ecn = headers.ipv6.ecn; } - if (routing_wcmp_group_id_valid) { - routing_wcmp_group_table.apply(); + acl_pre_ingress_acl_pre_ingress_table.apply(); + if (local_metadata.enable_vlan_checks && !(local_metadata.vlan_id == 12w0x0 || local_metadata.vlan_id == 12w0xfff)) { + mark_to_drop(standard_metadata); } - if (routing_nexthop_id_valid) { - routing_nexthop_table.apply(); - if (routing_router_interface_id_valid && routing_neighbor_id_valid) { - routing_router_interface_table.apply(); - routing_neighbor_table.apply(); + if (local_metadata.apply_tunnel_decap_at_end_of_pre_ingress) { + assert(headers.ipv6.isValid()); + assert(headers.inner_ipv4.isValid() && !headers.inner_ipv6.isValid() || !headers.inner_ipv4.isValid() && headers.inner_ipv6.isValid()); + headers.ipv6.setInvalid(); + if (headers.inner_ipv4.isValid()) { + headers.ethernet.ether_type = 16w0x800; + headers.ipv4 = headers.inner_ipv4; + headers.inner_ipv4.setInvalid(); + } + if (headers.inner_ipv6.isValid()) { + headers.ethernet.ether_type = 16w0x86dd; + headers.ipv6 = headers.inner_ipv6; + headers.inner_ipv6.setInvalid(); } } - } - acl_ingress_ttl = 8w0; - acl_ingress_dscp = 6w0; - acl_ingress_ecn = 2w0; - acl_ingress_ip_protocol = 8w0; - if (headers.ipv4.isValid()) { - acl_ingress_ttl = headers.ipv4.ttl; - acl_ingress_dscp = headers.ipv4.dscp; - acl_ingress_ecn = headers.ipv4.ecn; - acl_ingress_ip_protocol = headers.ipv4.protocol; - } else if (headers.ipv6.isValid()) { - acl_ingress_ttl = headers.ipv6.hop_limit; - acl_ingress_dscp = headers.ipv6.dscp; - acl_ingress_ecn = headers.ipv6.ecn; - acl_ingress_ip_protocol = headers.ipv6.next_header; - } - acl_ingress_acl_ingress_table.apply(); - if (local_metadata.admit_to_l3) { + local_metadata.admit_to_l3 = headers.ethernet.dst_addr == 48w0x1a11175f80; + if (local_metadata.enable_vlan_checks && !(local_metadata.vlan_id == 12w0x0 || local_metadata.vlan_id == 12w0xfff)) { + local_metadata.admit_to_l3 = false; + } else { + l3_admit_l3_admit_table.apply(); + } + hashing_offset = 8w0; + hashing_select_ecmp_hash_algorithm_0(); if (headers.ipv4.isValid()) { - if (headers.ipv4.ttl <= 8w1) { - mark_to_drop(standard_metadata); - } else { - headers.ipv4.ttl = headers.ipv4.ttl + 8w255; - } + hashing_compute_ecmp_hash_ipv4_0(); + } else if (headers.ipv6.isValid()) { + hashing_compute_ecmp_hash_ipv6_0(); } - if (headers.ipv6.isValid()) { - if (headers.ipv6.hop_limit <= 8w1) { - mark_to_drop(standard_metadata); - } else { - headers.ipv6.hop_limit = headers.ipv6.hop_limit + 8w255; + lag_hashing_config_select_lag_hash_algorithm_0(); + if (headers.ipv4.isValid()) { + lag_hashing_config_compute_lag_hash_ipv4_0(); + } else if (headers.ipv6.isValid()) { + lag_hashing_config_compute_lag_hash_ipv6_0(); + } + mark_to_drop(standard_metadata); + routing_lookup_vrf_table.apply(); + if (local_metadata.admit_to_l3) { + if (headers.ipv4.isValid()) { + routing_lookup_ipv4_table.apply(); + routing_lookup_ipv4_multicast_table.apply(); + local_metadata.ipmc_table_hit = standard_metadata.mcast_grp != 16w0; + } else if (headers.ipv6.isValid()) { + routing_lookup_ipv6_table.apply(); + routing_lookup_ipv6_multicast_table.apply(); + local_metadata.ipmc_table_hit = standard_metadata.mcast_grp != 16w0; } } - } - if (local_metadata.mirror_session_id_valid) { - if (mirroring_clone_mirror_session_table.apply().hit) { - if (mirroring_clone_mirror_port_to_pre_session_table.apply().hit) { - clone_preserving_field_list(CloneType.I2E, mirroring_clone_pre_session, 8w1); + acl_ingress_ttl = 8w0; + acl_ingress_dscp = 6w0; + acl_ingress_ecn = 2w0; + acl_ingress_ip_protocol = 8w0; + acl_ingress_cancel_copy = false; + if (headers.ipv4.isValid()) { + acl_ingress_ttl = headers.ipv4.ttl; + acl_ingress_dscp = headers.ipv4.dscp; + acl_ingress_ecn = headers.ipv4.ecn; + acl_ingress_ip_protocol = headers.ipv4.protocol; + } else if (headers.ipv6.isValid()) { + acl_ingress_ttl = headers.ipv6.hop_limit; + acl_ingress_dscp = headers.ipv6.dscp; + acl_ingress_ecn = headers.ipv6.ecn; + acl_ingress_ip_protocol = headers.ipv6.next_header; + } + acl_ingress_acl_ingress_table.apply(); + acl_ingress_acl_ingress_counting_table.apply(); + acl_ingress_acl_ingress_qos_table.apply(); + if (acl_ingress_cancel_copy) { + local_metadata.marked_to_copy = false; + } + routing_resolution_tunnel_id_valid = false; + routing_resolution_router_interface_id_valid = false; + routing_resolution_neighbor_id_valid = false; + if (local_metadata.admit_to_l3) { + if (local_metadata.wcmp_group_id_valid) { + routing_resolution_wcmp_group_table.apply(); + } + if (local_metadata.nexthop_id_valid) { + routing_resolution_nexthop_table.apply(); + if (routing_resolution_tunnel_id_valid) { + routing_resolution_tunnel_table.apply(); + } + if (routing_resolution_router_interface_id_valid && routing_resolution_neighbor_id_valid) { + routing_resolution_router_interface_table.apply(); + routing_resolution_neighbor_table.apply(); + } } } + local_metadata.packet_in_target_egress_port = standard_metadata.egress_spec; + local_metadata.packet_in_ingress_port = standard_metadata.ingress_port; + if (local_metadata.acl_drop) { + mark_to_drop(standard_metadata); + } + if (local_metadata.marked_to_mirror) { + mirror_session_lookup_mirror_session_table.apply(); + } + ingress_cloning_ingress_clone_table.apply(); + if (headers.ipv6.isValid() && (headers.ipv6.src_addr & 128w0xff000000000000000000000000000000 == 128w0xff000000000000000000000000000000 || headers.ipv6.dst_addr & 128w0xff000000000000000000000000000000 == 128w0xff000000000000000000000000000000 || headers.ipv6.src_addr == 128w0x1 || headers.ipv6.dst_addr == 128w0x1) || headers.ipv4.isValid() && (headers.ipv4.src_addr & 32w0xf0000000 == 32w0xe0000000 || headers.ipv4.src_addr == 32w0xffffffff || (headers.ipv4.dst_addr & 32w0xf0000000 == 32w0xe0000000 || headers.ipv4.dst_addr == 32w0xffffffff) || headers.ipv4.src_addr & 32w0xff000000 == 32w0x7f000000 || headers.ipv4.dst_addr & 32w0xff000000 == 32w0x7f000000) || headers.ethernet.isValid() && headers.ethernet.dst_addr & 48w0x10000000000 == 48w0x10000000000) { + mark_to_drop(standard_metadata); + } } } } control egress(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { + @name("egress.packet_rewrites.multicast_rewrites.multicast_replica_port") port_id_t packet_rewrites_multicast_rewrites_multicast_replica_port; + @name("egress.packet_rewrites.multicast_rewrites.multicast_replica_instance") replica_instance_t packet_rewrites_multicast_rewrites_multicast_replica_instance; @name("egress.acl_egress.dscp") bit<6> acl_egress_dscp; @name("egress.acl_egress.ip_protocol") bit<8> acl_egress_ip_protocol; - @name("egress.standard_metadata") standard_metadata_t standard_metadata_3; - @id(0x01000109) @sai_action(SAI_PACKET_ACTION_DROP) @name(".acl_drop") action acl_drop_2() { - standard_metadata_3 = standard_metadata; - mark_to_drop(standard_metadata_3); - standard_metadata = standard_metadata_3; + @name("egress.local_metadata") local_metadata_t local_metadata_11; + @noWarn("unused") @name(".NoAction") action NoAction_18() { } - @noWarn("unused") @name(".NoAction") action NoAction_11() { + @noWarn("unused") @name(".NoAction") action NoAction_19() { + } + @id(0x01000109) @sai_action(SAI_PACKET_ACTION_DROP) @name(".acl_drop") action acl_drop_4() { + local_metadata_11 = local_metadata; + local_metadata_11.acl_drop = true; + local_metadata = local_metadata_11; + } + @id(0x01000019) @name("egress.packet_rewrites.multicast_rewrites.set_multicast_src_mac") action packet_rewrites_multicast_rewrites_set_multicast_src_mac_0(@id(1) @format(MAC_ADDRESS) @name("src_mac") ethernet_addr_t src_mac_7) { + local_metadata.enable_src_mac_rewrite = true; + local_metadata.packet_rewrites.src_mac = src_mac_7; + } + @p4runtime_role("sdn_controller") @id(0x0200004C) @name("egress.packet_rewrites.multicast_rewrites.multicast_router_interface_table") table packet_rewrites_multicast_rewrites_multicast_router_interface_table { + key = { + packet_rewrites_multicast_rewrites_multicast_replica_port : exact @referenced_by(builtin : : multicast_group_table , replica . port) @id(1) @name("multicast_replica_port"); + packet_rewrites_multicast_rewrites_multicast_replica_instance: exact @referenced_by(builtin : : multicast_group_table , replica . instance) @id(2) @name("multicast_replica_instance"); + } + actions = { + @proto_id(1) packet_rewrites_multicast_rewrites_set_multicast_src_mac_0(); + @defaultonly NoAction_18(); + } + size = 110; + default_action = NoAction_18(); } @id(0x13000104) @name("egress.acl_egress.acl_egress_counter") direct_counter(CounterType.packets_and_bytes) acl_egress_acl_egress_counter; + @id(0x13000108) @name("egress.acl_egress.acl_egress_dhcp_to_host_counter") direct_counter(CounterType.packets_and_bytes) acl_egress_acl_egress_dhcp_to_host_counter; @p4runtime_role("sdn_controller") @id(0x02000104) @sai_acl(EGRESS) @entry_restriction(" + // Forbid using ether_type for IP packets (by convention, use is_ip* instead). ether_type != 0x0800 && ether_type != 0x86dd; dscp::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + // Only allow IP field matches for IP packets. - // TODO: Enable once p4-constraints bug is fixed. - // ip_protocol::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + ip_protocol::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + + + + // Only allow l4_dst_port matches for TCP/UDP packets. l4_dst_port::mask != 0 -> (ip_protocol == 6 || ip_protocol == 17); + // Forbid illegal combinations of IP_TYPE fields. is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0); is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0); @@ -789,73 +1323,143 @@ control egress(inout headers_t headers, inout local_metadata_t local_metadata, i is_ipv6::mask != 0 -> (is_ipv6 == 1); ") @name("egress.acl_egress.acl_egress_table") table acl_egress_acl_egress_table { key = { - headers.ethernet.ether_type : ternary @name("ether_type") @id(1) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ETHER_TYPE); - acl_egress_ip_protocol : ternary @name("ip_protocol") @id(2) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IP_PROTOCOL); - local_metadata.l4_dst_port : ternary @name("l4_dst_port") @id(3) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_L4_DST_PORT); - (port_id_t)standard_metadata.egress_port : optional @name("out_port") @id(4) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_OUT_PORT); - headers.ipv4.isValid() || headers.ipv6.isValid(): optional @name("is_ip") @id(5) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); - headers.ipv4.isValid() : optional @name("is_ipv4") @id(6) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); - headers.ipv6.isValid() : optional @name("is_ipv6") @id(7) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); - acl_egress_dscp : ternary @name("dscp") @id(8) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DSCP); + headers.ethernet.ether_type : ternary @id(1) @name("ether_type") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ETHER_TYPE); + acl_egress_ip_protocol : ternary @id(2) @name("ip_protocol") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IP_PROTOCOL); + local_metadata.l4_dst_port : ternary @id(3) @name("l4_dst_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_L4_DST_PORT); + (port_id_t)standard_metadata.egress_port : optional @id(4) @name("out_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_OUT_PORT); + headers.ipv4.isValid() || headers.ipv6.isValid(): optional @id(5) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(6) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(7) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + acl_egress_dscp : ternary @id(8) @name("dscp") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DSCP); } actions = { - @proto_id(1) acl_drop_2(); - @defaultonly NoAction_11(); + @proto_id(1) acl_drop_4(); + @defaultonly NoAction_19(); } - const default_action = NoAction_11(); + const default_action = NoAction_19(); counters = acl_egress_acl_egress_counter; - size = 128; + size = 127; } apply { - if (local_metadata.admit_to_l3) { - headers.ethernet.src_addr = local_metadata.packet_rewrites.src_mac; - headers.ethernet.dst_addr = local_metadata.packet_rewrites.dst_mac; - } - if (standard_metadata.instance_type == 32w1) { - headers.erspan_ethernet.setValid(); - headers.erspan_ethernet.src_addr = local_metadata.mirroring_src_mac; - headers.erspan_ethernet.dst_addr = local_metadata.mirroring_dst_mac; - headers.erspan_ethernet.ether_type = 16w0x800; - headers.erspan_ipv4.setValid(); - headers.erspan_ipv4.src_addr = local_metadata.mirroring_src_ip; - headers.erspan_ipv4.dst_addr = local_metadata.mirroring_dst_ip; - headers.erspan_ipv4.version = 4w4; - headers.erspan_ipv4.ihl = 4w5; - headers.erspan_ipv4.protocol = 8w0x2f; - headers.erspan_ipv4.ttl = local_metadata.mirroring_ttl; - headers.erspan_ipv4.dscp = local_metadata.mirroring_tos[7:2]; - headers.erspan_ipv4.ecn = local_metadata.mirroring_tos[1:0]; - headers.erspan_ipv4.total_len = 16w24 + (bit<16>)standard_metadata.packet_length; - headers.erspan_ipv4.identification = 16w0; - headers.erspan_ipv4.reserved = 1w0; - headers.erspan_ipv4.do_not_fragment = 1w1; - headers.erspan_ipv4.more_fragments = 1w0; - headers.erspan_ipv4.frag_offset = 13w0; - headers.erspan_ipv4.header_checksum = 16w0; - headers.erspan_gre.setValid(); - headers.erspan_gre.checksum_present = 1w0; - headers.erspan_gre.routing_present = 1w0; - headers.erspan_gre.key_present = 1w0; - headers.erspan_gre.sequence_present = 1w0; - headers.erspan_gre.strict_source_route = 1w0; - headers.erspan_gre.recursion_control = 3w0; - headers.erspan_gre.acknowledgement_present = 1w0; - headers.erspan_gre.flags = 4w0; - headers.erspan_gre.version = 3w0; - headers.erspan_gre.protocol = 16w0x88be; - } - acl_egress_dscp = 6w0; - if (headers.ipv4.isValid()) { - acl_egress_dscp = headers.ipv4.dscp; - acl_egress_ip_protocol = headers.ipv4.protocol; - } else if (headers.ipv6.isValid()) { - acl_egress_dscp = headers.ipv6.dscp; - acl_egress_ip_protocol = headers.ipv6.next_header; + if (standard_metadata.instance_type == 32w1 && standard_metadata.egress_rid == 16w1) { + ; } else { - acl_egress_ip_protocol = 8w0; + if (standard_metadata.instance_type == 32w5) { + local_metadata.enable_decrement_ttl = true; + packet_rewrites_multicast_rewrites_multicast_replica_port = (port_id_t)standard_metadata.egress_port; + packet_rewrites_multicast_rewrites_multicast_replica_instance = standard_metadata.egress_rid; + packet_rewrites_multicast_rewrites_multicast_router_interface_table.apply(); + } + if (local_metadata.enable_src_mac_rewrite) { + headers.ethernet.src_addr = local_metadata.packet_rewrites.src_mac; + } + if (local_metadata.enable_dst_mac_rewrite) { + headers.ethernet.dst_addr = local_metadata.packet_rewrites.dst_mac; + } + if (local_metadata.enable_vlan_rewrite) { + local_metadata.vlan_id = local_metadata.packet_rewrites.vlan_id; + } + if (headers.ipv4.isValid()) { + if (headers.ipv4.ttl > 8w0 && local_metadata.enable_decrement_ttl) { + headers.ipv4.ttl = headers.ipv4.ttl + 8w255; + } + if (headers.ipv4.ttl == 8w0) { + mark_to_drop(standard_metadata); + } + } + if (headers.ipv6.isValid()) { + if (headers.ipv6.hop_limit > 8w0 && local_metadata.enable_decrement_ttl) { + headers.ipv6.hop_limit = headers.ipv6.hop_limit + 8w255; + } + if (headers.ipv6.hop_limit == 8w0) { + mark_to_drop(standard_metadata); + } + } + if (local_metadata.apply_tunnel_encap_at_egress) { + headers.tunnel_encap_gre.setValid(); + headers.tunnel_encap_gre.checksum_present = 1w0; + headers.tunnel_encap_gre.routing_present = 1w0; + headers.tunnel_encap_gre.key_present = 1w0; + headers.tunnel_encap_gre.sequence_present = 1w0; + headers.tunnel_encap_gre.strict_source_route = 1w0; + headers.tunnel_encap_gre.recursion_control = 3w0; + headers.tunnel_encap_gre.flags = 4w0; + headers.tunnel_encap_gre.version = 3w0; + headers.tunnel_encap_gre.protocol = headers.ethernet.ether_type; + headers.ethernet.ether_type = 16w0x86dd; + headers.tunnel_encap_ipv6.setValid(); + headers.tunnel_encap_ipv6.version = 4w6; + headers.tunnel_encap_ipv6.src_addr = local_metadata.tunnel_encap_src_ipv6; + headers.tunnel_encap_ipv6.dst_addr = local_metadata.tunnel_encap_dst_ipv6; + headers.tunnel_encap_ipv6.payload_length = (bit<16>)standard_metadata.packet_length + 16w65526; + headers.tunnel_encap_ipv6.next_header = 8w0x2f; + if (headers.ipv4.isValid()) { + headers.tunnel_encap_ipv6.dscp = headers.ipv4.dscp; + headers.tunnel_encap_ipv6.ecn = headers.ipv4.ecn; + headers.tunnel_encap_ipv6.hop_limit = headers.ipv4.ttl; + } else if (headers.ipv6.isValid()) { + headers.tunnel_encap_ipv6.dscp = headers.ipv6.dscp; + headers.tunnel_encap_ipv6.ecn = headers.ipv6.ecn; + headers.tunnel_encap_ipv6.hop_limit = headers.ipv6.hop_limit; + } + } + if (standard_metadata.instance_type == 32w1 && standard_metadata.egress_rid == 16w2) { + headers.mirror_encap_ethernet.setValid(); + headers.mirror_encap_ethernet.src_addr = local_metadata.mirror_encap_src_mac; + headers.mirror_encap_ethernet.dst_addr = local_metadata.mirror_encap_dst_mac; + headers.mirror_encap_ethernet.ether_type = 16w0x8100; + headers.mirror_encap_vlan.setValid(); + headers.mirror_encap_vlan.ether_type = 16w0x86dd; + headers.mirror_encap_vlan.vlan_id = local_metadata.mirror_encap_vlan_id; + headers.mirror_encap_ipv6.setValid(); + headers.mirror_encap_ipv6.version = 4w6; + headers.mirror_encap_ipv6.dscp = 6w0; + headers.mirror_encap_ipv6.ecn = 2w0; + headers.mirror_encap_ipv6.hop_limit = 8w16; + headers.mirror_encap_ipv6.flow_label = 20w0; + headers.mirror_encap_ipv6.payload_length = (bit<16>)standard_metadata.packet_length + 16w52; + headers.mirror_encap_ipv6.next_header = 8w0x11; + headers.mirror_encap_ipv6.src_addr = local_metadata.mirror_encap_src_ip; + headers.mirror_encap_ipv6.dst_addr = local_metadata.mirror_encap_dst_ip; + headers.mirror_encap_udp.setValid(); + headers.mirror_encap_udp.src_port = local_metadata.mirror_encap_udp_src_port; + headers.mirror_encap_udp.dst_port = local_metadata.mirror_encap_udp_dst_port; + headers.mirror_encap_udp.hdr_length = headers.mirror_encap_ipv6.payload_length; + headers.mirror_encap_udp.checksum = 16w0; + headers.ipfix.setValid(); + headers.psamp_extended.setValid(); + } + if (local_metadata.enable_vlan_checks) { + if (standard_metadata.instance_type == 32w1 && standard_metadata.egress_rid == 16w2 && !(local_metadata.mirror_encap_vlan_id == 12w0x0 || local_metadata.mirror_encap_vlan_id == 12w0xfff)) { + mark_to_drop(standard_metadata); + } else if (!(standard_metadata.instance_type == 32w1 && standard_metadata.egress_rid == 16w1) && !(local_metadata.vlan_id == 12w0x0 || local_metadata.vlan_id == 12w0xfff)) { + mark_to_drop(standard_metadata); + } + } + if (!(local_metadata.vlan_id == 12w0x0 || local_metadata.vlan_id == 12w0xfff) && !(standard_metadata.instance_type == 32w1 && standard_metadata.egress_rid == 16w2)) { + headers.vlan.setValid(); + headers.vlan.priority_code_point = 3w0; + headers.vlan.drop_eligible_indicator = 1w0; + headers.vlan.vlan_id = local_metadata.vlan_id; + headers.vlan.ether_type = headers.ethernet.ether_type; + headers.ethernet.ether_type = 16w0x8100; + } + acl_egress_dscp = 6w0; + if (headers.ipv4.isValid()) { + acl_egress_dscp = headers.ipv4.dscp; + acl_egress_ip_protocol = headers.ipv4.protocol; + } else if (headers.ipv6.isValid()) { + acl_egress_dscp = headers.ipv6.dscp; + acl_egress_ip_protocol = headers.ipv6.next_header; + } else { + acl_egress_ip_protocol = 8w0; + } + acl_egress_acl_egress_table.apply(); + if (local_metadata.acl_drop) { + mark_to_drop(standard_metadata); + } } - acl_egress_acl_egress_table.apply(); } } -@pkginfo(name="fabric_border_router.p4", organization="Google") V1Switch(packet_parser(), verify_ipv4_checksum(), ingress(), egress(), compute_ipv4_checksum(), packet_deparser()) main; +@pkginfo(name="fabric_border_router.p4", organization="Google", version="1.6.1") V1Switch(packet_parser(), verify_ipv4_checksum(), ingress(), egress(), compute_ipv4_checksum(), packet_deparser()) main; diff --git a/testdata/p4_16_samples_outputs/pins/pins_fabric-midend.p4 b/testdata/p4_16_samples_outputs/pins/pins_fabric-midend.p4 index abe299155e..ad18c6b7f6 100644 --- a/testdata/p4_16_samples_outputs/pins/pins_fabric-midend.p4 +++ b/testdata/p4_16_samples_outputs/pins/pins_fabric-midend.p4 @@ -8,6 +8,13 @@ header ethernet_t { bit<16> ether_type; } +header vlan_t { + bit<3> priority_code_point; + bit<1> drop_eligible_indicator; + bit<12> vlan_id; + bit<16> ether_type; +} + header ipv4_t { bit<4> version; bit<4> ihl; @@ -62,6 +69,7 @@ header icmp_t { bit<8> type; bit<8> code; bit<16> checksum; + bit<32> rest_of_header; } header arp_t { @@ -89,54 +97,27 @@ header gre_t { bit<16> protocol; } -struct headers_t { - ethernet_t erspan_ethernet; - ipv4_t erspan_ipv4; - gre_t erspan_gre; - ethernet_t ethernet; - ipv6_t tunnel_encap_ipv6; - gre_t tunnel_encap_gre; - ipv4_t ipv4; - ipv6_t ipv6; - icmp_t icmp; - tcp_t tcp; - udp_t udp; - arp_t arp; +header ipfix_t { + bit<16> version_number; + bit<16> length; + bit<32> export_time; + bit<32> sequence_number; + bit<32> observation_domain_id; } -struct packet_rewrites_t { - bit<48> src_mac; - bit<48> dst_mac; -} - -struct local_metadata_t { - bool _admit_to_l30; - bit<10> _vrf_id1; - bit<48> _packet_rewrites_src_mac2; - bit<48> _packet_rewrites_dst_mac3; - bit<16> _l4_src_port4; - bit<16> _l4_dst_port5; - bit<16> _wcmp_selector_input6; - bool _apply_tunnel_encap_at_egress7; - bit<128> _tunnel_encap_src_ipv68; - bit<128> _tunnel_encap_dst_ipv69; - bool _mirror_session_id_valid10; - bit<10> _mirror_session_id_value11; - @field_list(8w1) - bit<32> _mirroring_src_ip12; - @field_list(8w1) - bit<32> _mirroring_dst_ip13; - @field_list(8w1) - bit<48> _mirroring_src_mac14; - @field_list(8w1) - bit<48> _mirroring_dst_mac15; - @field_list(8w1) - bit<8> _mirroring_ttl16; - @field_list(8w1) - bit<8> _mirroring_tos17; - bit<2> _color18; - bit<9> _ingress_port19; - bit<6> _route_metadata20; +header psamp_extended_t { + bit<16> template_id; + bit<16> length; + bit<64> observation_time; + bit<16> flowset; + bit<16> next_hop_index; + bit<16> epoch; + bit<16> ingress_port; + bit<16> egress_port; + bit<16> user_meta_field; + bit<8> dlb_id; + bit<8> variable_length; + bit<16> packet_sampled_length; } @controller_header("packet_in") header packet_in_header_t { @@ -151,25 +132,164 @@ struct local_metadata_t { bit<9> egress_port; @id(2) bit<1> submit_to_ingress; - @id(3) - bit<7> unused_pad; + @id(3) @padding + bit<6> unused_pad; +} + +struct headers_t { + packet_out_header_t packet_out_header; + ethernet_t mirror_encap_ethernet; + vlan_t mirror_encap_vlan; + ipv6_t mirror_encap_ipv6; + udp_t mirror_encap_udp; + ipfix_t ipfix; + psamp_extended_t psamp_extended; + ethernet_t ethernet; + vlan_t vlan; + ipv6_t tunnel_encap_ipv6; + gre_t tunnel_encap_gre; + ipv4_t ipv4; + ipv6_t ipv6; + ipv4_t inner_ipv4; + ipv6_t inner_ipv6; + icmp_t icmp; + tcp_t tcp; + udp_t udp; + arp_t arp; +} + +struct packet_rewrites_t { + bit<48> src_mac; + bit<48> dst_mac; + bit<12> vlan_id; +} + +struct local_metadata_t { + @field_list(8w1) + bool _enable_vlan_checks0; + bit<12> _vlan_id1; + bool _admit_to_l32; + bit<10> _vrf_id3; + bool _enable_decrement_ttl4; + bool _enable_src_mac_rewrite5; + bool _enable_dst_mac_rewrite6; + bool _enable_vlan_rewrite7; + bit<48> _packet_rewrites_src_mac8; + bit<48> _packet_rewrites_dst_mac9; + bit<12> _packet_rewrites_vlan_id10; + bit<16> _l4_src_port11; + bit<16> _l4_dst_port12; + bit<8> _wcmp_selector_input13; + bool _apply_tunnel_decap_at_end_of_pre_ingress14; + bool _apply_tunnel_encap_at_egress15; + bit<128> _tunnel_encap_src_ipv616; + bit<128> _tunnel_encap_dst_ipv617; + bool _marked_to_copy18; + bool _marked_to_mirror19; + bit<10> _mirror_session_id20; + bit<9> _mirror_egress_port21; + @field_list(8w1) + bit<48> _mirror_encap_src_mac22; + @field_list(8w1) + bit<48> _mirror_encap_dst_mac23; + @field_list(8w1) + bit<12> _mirror_encap_vlan_id24; + @field_list(8w1) + bit<128> _mirror_encap_src_ip25; + @field_list(8w1) + bit<128> _mirror_encap_dst_ip26; + @field_list(8w1) + bit<16> _mirror_encap_udp_src_port27; + @field_list(8w1) + bit<16> _mirror_encap_udp_dst_port28; + @field_list(8w2) + bit<9> _loopback_port29; + @field_list(8w1) + bit<9> _packet_in_ingress_port30; + @field_list(8w1) + bit<9> _packet_in_target_egress_port31; + bit<2> _color32; + bit<9> _ingress_port33; + bit<6> _route_metadata34; + bit<8> _acl_metadata35; + bool _bypass_ingress36; + bool _wcmp_group_id_valid37; + bit<12> _wcmp_group_id_value38; + bool _nexthop_id_valid39; + bit<10> _nexthop_id_value40; + bool _ipmc_table_hit41; + bool _acl_drop42; } parser packet_parser(packet_in packet, out headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { state start { - local_metadata._admit_to_l30 = false; - local_metadata._vrf_id1 = 10w0; - local_metadata._packet_rewrites_src_mac2 = 48w0; - local_metadata._packet_rewrites_dst_mac3 = 48w0; - local_metadata._l4_src_port4 = 16w0; - local_metadata._l4_dst_port5 = 16w0; - local_metadata._wcmp_selector_input6 = 16w0; - local_metadata._mirror_session_id_valid10 = false; - local_metadata._color18 = 2w0; - local_metadata._ingress_port19 = standard_metadata.ingress_port; - local_metadata._route_metadata20 = 6w0; + local_metadata._enable_vlan_checks0 = false; + local_metadata._vlan_id1 = 12w0; + local_metadata._admit_to_l32 = false; + local_metadata._vrf_id3 = 10w0; + local_metadata._enable_decrement_ttl4 = false; + local_metadata._enable_src_mac_rewrite5 = false; + local_metadata._enable_dst_mac_rewrite6 = false; + local_metadata._enable_vlan_rewrite7 = false; + local_metadata._packet_rewrites_src_mac8 = 48w0; + local_metadata._packet_rewrites_dst_mac9 = 48w0; + local_metadata._l4_src_port11 = 16w0; + local_metadata._l4_dst_port12 = 16w0; + local_metadata._wcmp_selector_input13 = 8w0; + local_metadata._apply_tunnel_decap_at_end_of_pre_ingress14 = false; + local_metadata._apply_tunnel_encap_at_egress15 = false; + local_metadata._tunnel_encap_src_ipv616 = 128w0; + local_metadata._tunnel_encap_dst_ipv617 = 128w0; + local_metadata._marked_to_copy18 = false; + local_metadata._marked_to_mirror19 = false; + local_metadata._mirror_session_id20 = 10w0; + local_metadata._mirror_egress_port21 = 9w0; + local_metadata._color32 = 2w0; + local_metadata._route_metadata34 = 6w0; + local_metadata._bypass_ingress36 = false; + local_metadata._wcmp_group_id_valid37 = false; + local_metadata._wcmp_group_id_value38 = 12w0; + local_metadata._nexthop_id_valid39 = false; + local_metadata._nexthop_id_value40 = 10w0; + local_metadata._ipmc_table_hit41 = false; + local_metadata._acl_drop42 = false; + transition select((bit<1>)(standard_metadata.instance_type == 32w4)) { + 1w1: start_true; + 1w0: start_false; + default: noMatch; + } + } + state start_true { + local_metadata._ingress_port33 = local_metadata._loopback_port29; + transition start_join; + } + state start_false { + local_metadata._ingress_port33 = standard_metadata.ingress_port; + transition start_join; + } + state start_join { + transition select(standard_metadata.ingress_port) { + 9w510: parse_packet_out_header; + default: parse_ethernet; + } + } + state parse_packet_out_header { + packet.extract(headers.packet_out_header); + transition parse_ethernet; + } + state parse_ethernet { packet.extract(headers.ethernet); transition select(headers.ethernet.ether_type) { + 16w0x800: parse_ipv4; + 16w0x86dd: parse_ipv6; + 16w0x806: parse_arp; + 16w0x8100: parse_8021q_vlan; + default: accept; + } + } + state parse_8021q_vlan { + packet.extract(headers.vlan); + transition select(headers.vlan.ether_type) { 16w0x800: parse_ipv4; 16w0x86dd: parse_ipv6; 16w0x806: parse_arp; @@ -179,6 +299,17 @@ parser packet_parser(packet_in packet, out headers_t headers, inout local_metada state parse_ipv4 { packet.extract(headers.ipv4); transition select(headers.ipv4.protocol) { + 8w0x4: parse_ipv4_in_ip; + 8w0x29: parse_ipv6_in_ip; + 8w0x1: parse_icmp; + 8w0x6: parse_tcp; + 8w0x11: parse_udp; + default: accept; + } + } + state parse_ipv4_in_ip { + packet.extract(headers.inner_ipv4); + transition select(headers.inner_ipv4.protocol) { 8w0x1: parse_icmp; 8w0x6: parse_tcp; 8w0x11: parse_udp; @@ -188,6 +319,17 @@ parser packet_parser(packet_in packet, out headers_t headers, inout local_metada state parse_ipv6 { packet.extract(headers.ipv6); transition select(headers.ipv6.next_header) { + 8w0x4: parse_ipv4_in_ip; + 8w0x29: parse_ipv6_in_ip; + 8w0x3a: parse_icmp; + 8w0x6: parse_tcp; + 8w0x11: parse_udp; + default: accept; + } + } + state parse_ipv6_in_ip { + packet.extract(headers.inner_ipv6); + transition select(headers.inner_ipv6.next_header) { 8w0x3a: parse_icmp; 8w0x6: parse_tcp; 8w0x11: parse_udp; @@ -196,14 +338,14 @@ parser packet_parser(packet_in packet, out headers_t headers, inout local_metada } state parse_tcp { packet.extract(headers.tcp); - local_metadata._l4_src_port4 = headers.tcp.src_port; - local_metadata._l4_dst_port5 = headers.tcp.dst_port; + local_metadata._l4_src_port11 = headers.tcp.src_port; + local_metadata._l4_dst_port12 = headers.tcp.dst_port; transition accept; } state parse_udp { packet.extract(headers.udp); - local_metadata._l4_src_port4 = headers.udp.src_port; - local_metadata._l4_dst_port5 = headers.udp.dst_port; + local_metadata._l4_src_port11 = headers.udp.src_port; + local_metadata._l4_dst_port12 = headers.udp.dst_port; transition accept; } state parse_icmp { @@ -214,18 +356,29 @@ parser packet_parser(packet_in packet, out headers_t headers, inout local_metada packet.extract(headers.arp); transition accept; } + state noMatch { + verify(false, error.NoMatch); + transition reject; + } } control packet_deparser(packet_out packet, in headers_t headers) { apply { - packet.emit(headers.erspan_ethernet); - packet.emit(headers.erspan_ipv4); - packet.emit(headers.erspan_gre); + packet.emit(headers.packet_out_header); + packet.emit(headers.mirror_encap_ethernet); + packet.emit(headers.mirror_encap_vlan); + packet.emit(headers.mirror_encap_ipv6); + packet.emit(headers.mirror_encap_udp); + packet.emit(headers.ipfix); + packet.emit(headers.psamp_extended); packet.emit(headers.ethernet); + packet.emit(headers.vlan); packet.emit(headers.tunnel_encap_ipv6); packet.emit(headers.tunnel_encap_gre); packet.emit(headers.ipv4); packet.emit(headers.ipv6); + packet.emit(headers.inner_ipv4); + packet.emit(headers.inner_ipv6); packet.emit(headers.arp); packet.emit(headers.icmp); packet.emit(headers.tcp); @@ -258,30 +411,45 @@ control verify_ipv4_checksum(inout headers_t headers, inout local_metadata_t loc control compute_ipv4_checksum(inout headers_t headers, inout local_metadata_t local_metadata) { apply { - update_checksum>(headers.erspan_ipv4.isValid(), (tuple_0){f0 = headers.erspan_ipv4.version,f1 = headers.erspan_ipv4.ihl,f2 = headers.erspan_ipv4.dscp,f3 = headers.erspan_ipv4.ecn,f4 = headers.erspan_ipv4.total_len,f5 = headers.erspan_ipv4.identification,f6 = headers.erspan_ipv4.reserved,f7 = headers.erspan_ipv4.do_not_fragment,f8 = headers.erspan_ipv4.more_fragments,f9 = headers.erspan_ipv4.frag_offset,f10 = headers.erspan_ipv4.ttl,f11 = headers.erspan_ipv4.protocol,f12 = headers.erspan_ipv4.src_addr,f13 = headers.erspan_ipv4.dst_addr}, headers.erspan_ipv4.header_checksum, HashAlgorithm.csum16); update_checksum>(headers.ipv4.isValid(), (tuple_0){f0 = headers.ipv4.version,f1 = headers.ipv4.ihl,f2 = headers.ipv4.dscp,f3 = headers.ipv4.ecn,f4 = headers.ipv4.total_len,f5 = headers.ipv4.identification,f6 = headers.ipv4.reserved,f7 = headers.ipv4.do_not_fragment,f8 = headers.ipv4.more_fragments,f9 = headers.ipv4.frag_offset,f10 = headers.ipv4.ttl,f11 = headers.ipv4.protocol,f12 = headers.ipv4.src_addr,f13 = headers.ipv4.dst_addr}, headers.ipv4.header_checksum, HashAlgorithm.csum16); } } +struct tuple_1 { + bit<32> f0; + bit<32> f1; + bit<32> f2; + bit<16> f3; + bit<16> f4; +} + +struct tuple_2 { + bit<32> f0; + bit<20> f1; + bit<128> f2; + bit<128> f3; + bit<16> f4; + bit<16> f5; +} + control ingress(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { @name("ingress.acl_pre_ingress.dscp") bit<6> acl_pre_ingress_dscp; - @name("ingress.routing.wcmp_group_id_valid") bool routing_wcmp_group_id_valid; - @name("ingress.routing.wcmp_group_id_value") bit<12> routing_wcmp_group_id_value; - @name("ingress.routing.nexthop_id_valid") bool routing_nexthop_id_valid; - @name("ingress.routing.nexthop_id_value") bit<10> routing_nexthop_id_value; - @name("ingress.routing.router_interface_id_valid") bool routing_router_interface_id_valid; - @name("ingress.routing.router_interface_id_value") bit<10> routing_router_interface_id_value; - @name("ingress.routing.neighbor_id_valid") bool routing_neighbor_id_valid; - @name("ingress.routing.neighbor_id_value") bit<128> routing_neighbor_id_value; + @name("ingress.acl_pre_ingress.ecn") bit<2> acl_pre_ingress_ecn; @name("ingress.acl_ingress.ttl") bit<8> acl_ingress_ttl; @name("ingress.acl_ingress.dscp") bit<6> acl_ingress_dscp; @name("ingress.acl_ingress.ecn") bit<2> acl_ingress_ecn; @name("ingress.acl_ingress.ip_protocol") bit<8> acl_ingress_ip_protocol; - @name("ingress.mirroring_clone.mirror_port") bit<9> mirroring_clone_mirror_port; - @name("ingress.mirroring_clone.pre_session") bit<32> mirroring_clone_pre_session; - @name("ingress.standard_metadata") standard_metadata_t standard_metadata_0; - bool key_0; - bool key_2; + @name("ingress.routing_resolution.tunnel_id_valid") bool routing_resolution_tunnel_id_valid; + @name("ingress.routing_resolution.tunnel_id_value") bit<10> routing_resolution_tunnel_id_value; + @name("ingress.routing_resolution.router_interface_id_valid") bool routing_resolution_router_interface_id_valid; + @name("ingress.routing_resolution.router_interface_id_value") bit<10> routing_resolution_router_interface_id_value; + @name("ingress.routing_resolution.neighbor_id_valid") bool routing_resolution_neighbor_id_valid; + @name("ingress.routing_resolution.neighbor_id_value") bit<128> routing_resolution_neighbor_id_value; + bit<1> key_0; + bool key_1; + bool key_3; + bool key_6; + bool key_7; @noWarn("unused") @name(".NoAction") action NoAction_2() { } @noWarn("unused") @name(".NoAction") action NoAction_3() { @@ -300,49 +468,82 @@ control ingress(inout headers_t headers, inout local_metadata_t local_metadata, } @noWarn("unused") @name(".NoAction") action NoAction_10() { } - @id(0x01000109) @sai_action(SAI_PACKET_ACTION_DROP) @name(".acl_drop") action acl_drop_1() { - standard_metadata_0.ingress_port = standard_metadata.ingress_port; - standard_metadata_0.egress_spec = standard_metadata.egress_spec; - standard_metadata_0.egress_port = standard_metadata.egress_port; - standard_metadata_0.instance_type = standard_metadata.instance_type; - standard_metadata_0.packet_length = standard_metadata.packet_length; - standard_metadata_0.enq_timestamp = standard_metadata.enq_timestamp; - standard_metadata_0.enq_qdepth = standard_metadata.enq_qdepth; - standard_metadata_0.deq_timedelta = standard_metadata.deq_timedelta; - standard_metadata_0.deq_qdepth = standard_metadata.deq_qdepth; - standard_metadata_0.ingress_global_timestamp = standard_metadata.ingress_global_timestamp; - standard_metadata_0.egress_global_timestamp = standard_metadata.egress_global_timestamp; - standard_metadata_0.mcast_grp = standard_metadata.mcast_grp; - standard_metadata_0.egress_rid = standard_metadata.egress_rid; - standard_metadata_0.checksum_error = standard_metadata.checksum_error; - standard_metadata_0.parser_error = standard_metadata.parser_error; - standard_metadata_0.priority = standard_metadata.priority; - mark_to_drop(standard_metadata_0); - standard_metadata.ingress_port = standard_metadata_0.ingress_port; - standard_metadata.egress_spec = standard_metadata_0.egress_spec; - standard_metadata.egress_port = standard_metadata_0.egress_port; - standard_metadata.instance_type = standard_metadata_0.instance_type; - standard_metadata.packet_length = standard_metadata_0.packet_length; - standard_metadata.enq_timestamp = standard_metadata_0.enq_timestamp; - standard_metadata.enq_qdepth = standard_metadata_0.enq_qdepth; - standard_metadata.deq_timedelta = standard_metadata_0.deq_timedelta; - standard_metadata.deq_qdepth = standard_metadata_0.deq_qdepth; - standard_metadata.ingress_global_timestamp = standard_metadata_0.ingress_global_timestamp; - standard_metadata.egress_global_timestamp = standard_metadata_0.egress_global_timestamp; - standard_metadata.mcast_grp = standard_metadata_0.mcast_grp; - standard_metadata.egress_rid = standard_metadata_0.egress_rid; - standard_metadata.checksum_error = standard_metadata_0.checksum_error; - standard_metadata.parser_error = standard_metadata_0.parser_error; - standard_metadata.priority = standard_metadata_0.priority; + @noWarn("unused") @name(".NoAction") action NoAction_11() { + } + @noWarn("unused") @name(".NoAction") action NoAction_12() { + } + @noWarn("unused") @name(".NoAction") action NoAction_13() { + } + @noWarn("unused") @name(".NoAction") action NoAction_14() { + } + @noWarn("unused") @name(".NoAction") action NoAction_15() { + } + @noWarn("unused") @name(".NoAction") action NoAction_16() { + } + @noWarn("unused") @name(".NoAction") action NoAction_17() { + } + @id(0x01000005) @name(".set_nexthop_id") action set_nexthop_id_1(@id(1) @refers_to(nexthop_table , nexthop_id) @name("nexthop_id") bit<10> nexthop_id) { + local_metadata._nexthop_id_valid39 = true; + local_metadata._nexthop_id_value40 = nexthop_id; + } + @id(0x01000005) @name(".set_nexthop_id") action set_nexthop_id_2(@id(1) @refers_to(nexthop_table , nexthop_id) @name("nexthop_id") bit<10> nexthop_id_2) { + local_metadata._nexthop_id_valid39 = true; + local_metadata._nexthop_id_value40 = nexthop_id_2; + } + @id(0x01000005) @name(".set_nexthop_id") action set_nexthop_id_3(@id(1) @refers_to(nexthop_table , nexthop_id) @name("nexthop_id") bit<10> nexthop_id_3) { + local_metadata._nexthop_id_valid39 = true; + local_metadata._nexthop_id_value40 = nexthop_id_3; + } + @id(0x01000109) @sai_action(SAI_PACKET_ACTION_DROP) @name(".acl_drop") action acl_drop_2() { + local_metadata._acl_drop42 = true; + } + @id(0x01000109) @sai_action(SAI_PACKET_ACTION_DROP) @name(".acl_drop") action acl_drop_3() { + local_metadata._acl_drop42 = true; + } + @id(0x01000016) @name("ingress.tunnel_termination_lookup.mark_for_tunnel_decap_and_set_vrf") action tunnel_termination_lookup_mark_for_tunnel_decap_and_set_vrf_0(@refers_to(vrf_table , vrf_id) @name("vrf_id") bit<10> vrf_id_2) { + local_metadata._apply_tunnel_decap_at_end_of_pre_ingress14 = true; + local_metadata._vrf_id3 = vrf_id_2; + } + @unsupported @p4runtime_role("sdn_controller") @id(0x0200004B) @name("ingress.tunnel_termination_lookup.ipv6_tunnel_termination_table") table tunnel_termination_lookup_ipv6_tunnel_termination_table { + key = { + headers.ipv6.dst_addr: ternary @id(1) @name("dst_ipv6") @format(IPV6_ADDRESS); + headers.ipv6.src_addr: ternary @id(2) @name("src_ipv6") @format(IPV6_ADDRESS); + } + actions = { + @proto_id(1) tunnel_termination_lookup_mark_for_tunnel_decap_and_set_vrf_0(); + @defaultonly NoAction_2(); + } + size = 126; + default_action = NoAction_2(); + } + @id(0x0100001A) @name("ingress.vlan_untag.disable_vlan_checks") action vlan_untag_disable_vlan_checks_0() { + local_metadata._enable_vlan_checks0 = false; + } + @p4runtime_role("sdn_controller") @id(0x0200004D) @entry_restriction(" + // Force the dummy_match to be wildcard. + dummy_match::mask == 0; + ") @name("ingress.vlan_untag.disable_vlan_checks_table") table vlan_untag_disable_vlan_checks_table { + key = { + key_0: ternary @id(1) @name("dummy_match"); + } + actions = { + @proto_id(1) vlan_untag_disable_vlan_checks_0(); + @defaultonly NoAction_3(); + } + size = 1; + default_action = NoAction_3(); } @id(0x13000101) @name("ingress.acl_pre_ingress.acl_pre_ingress_counter") direct_counter(CounterType.packets_and_bytes) acl_pre_ingress_acl_pre_ingress_counter; - @id(0x01000100) @sai_action(SAI_PACKET_ACTION_FORWARD) @name("ingress.acl_pre_ingress.set_vrf") action acl_pre_ingress_set_vrf_0(@sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_SET_VRF) @refers_to(vrf_table , vrf_id) @id(1) @name("vrf_id") bit<10> vrf_id_1) { - local_metadata._vrf_id1 = vrf_id_1; + @id(0x13000106) @name("ingress.acl_pre_ingress.acl_pre_ingress_vlan_counter") direct_counter(CounterType.packets_and_bytes) acl_pre_ingress_acl_pre_ingress_vlan_counter; + @id(0x13000105) @name("ingress.acl_pre_ingress.acl_pre_ingress_metadata_counter") direct_counter(CounterType.packets_and_bytes) acl_pre_ingress_acl_pre_ingress_metadata_counter; + @id(0x01000100) @sai_action(SAI_PACKET_ACTION_FORWARD) @name("ingress.acl_pre_ingress.set_vrf") action acl_pre_ingress_set_vrf_0(@sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_SET_VRF) @refers_to(vrf_table , vrf_id) @id(1) @name("vrf_id") bit<10> vrf_id_3) { + local_metadata._vrf_id3 = vrf_id_3; acl_pre_ingress_acl_pre_ingress_counter.count(); } - @p4runtime_role("sdn_controller") @id(0x02000101) @sai_acl(PRE_INGRESS) @entry_restriction(" + @p4runtime_role("sdn_controller") @id(0x02000101) @sai_acl(PRE_INGRESS) @sai_acl_priority(11) @entry_restriction(" // Only allow IP field matches for IP packets. dscp::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + ecn::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); dst_ip::mask != 0 -> is_ipv4 == 1; dst_ipv6::mask != 0 -> is_ipv6 == 1; // Forbid illegal combinations of IP_TYPE fields. @@ -352,137 +553,66 @@ control ingress(inout headers_t headers, inout local_metadata_t local_metadata, // Forbid unsupported combinations of IP_TYPE fields. is_ipv4::mask != 0 -> (is_ipv4 == 1); is_ipv6::mask != 0 -> (is_ipv6 == 1); + + + + // Reserve high priorities for switch-internal use. // TODO: Remove once inband workaround is obsolete. ::priority < 0x7fffffff; ") @name("ingress.acl_pre_ingress.acl_pre_ingress_table") table acl_pre_ingress_acl_pre_ingress_table { key = { - key_0 : optional @name("is_ip") @id(1) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); - headers.ipv4.isValid() : optional @name("is_ipv4") @id(2) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); - headers.ipv6.isValid() : optional @name("is_ipv6") @id(3) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); - headers.ethernet.src_addr : ternary @name("src_mac") @id(4) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_SRC_MAC) @format(MAC_ADDRESS); - headers.ethernet.dst_addr : ternary @name("dst_mac") @id(9) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_MAC) @format(MAC_ADDRESS); - headers.ipv4.dst_addr : ternary @name("dst_ip") @id(5) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_IP) @format(IPV4_ADDRESS); - headers.ipv6.dst_addr[127:64] : ternary @name("dst_ipv6") @id(6) @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD2 )) @format(IPV6_ADDRESS); - acl_pre_ingress_dscp : ternary @name("dscp") @id(7) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DSCP); - local_metadata._ingress_port19: optional @name("in_port") @id(8) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IN_PORT); + key_1 : optional @id(1) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(2) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(3) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + headers.ethernet.src_addr : ternary @id(4) @name("src_mac") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_SRC_MAC) @format(MAC_ADDRESS); + headers.ethernet.dst_addr : ternary @id(9) @name("dst_mac") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_MAC) @format(MAC_ADDRESS); + headers.ipv4.dst_addr : ternary @id(5) @name("dst_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_IP) @format(IPV4_ADDRESS); + headers.ipv6.dst_addr[127:64] : ternary @id(6) @name("dst_ipv6") @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD2 )) @format(IPV6_ADDRESS); + acl_pre_ingress_dscp : ternary @id(7) @name("dscp") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DSCP); + acl_pre_ingress_ecn : ternary @id(10) @name("ecn") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ECN); + local_metadata._ingress_port33: optional @id(8) @name("in_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IN_PORT); } actions = { @proto_id(1) acl_pre_ingress_set_vrf_0(); - @defaultonly NoAction_2(); + @defaultonly NoAction_4(); } - const default_action = NoAction_2(); + const default_action = NoAction_4(); counters = acl_pre_ingress_acl_pre_ingress_counter; - size = 255; + size = 254; } @id(0x01000008) @name("ingress.l3_admit.admit_to_l3") action l3_admit_admit_to_l3_0() { - local_metadata._admit_to_l30 = true; + local_metadata._admit_to_l32 = true; } @p4runtime_role("sdn_controller") @id(0x02000047) @name("ingress.l3_admit.l3_admit_table") table l3_admit_l3_admit_table { key = { headers.ethernet.dst_addr : ternary @name("dst_mac") @id(1) @format(MAC_ADDRESS); - local_metadata._ingress_port19: optional @name("in_port") @id(2); + local_metadata._ingress_port33: optional @name("in_port") @id(2); } actions = { @proto_id(1) l3_admit_admit_to_l3_0(); - @defaultonly NoAction_3(); - } - const default_action = NoAction_3(); - size = 128; - } - @id(0x01000001) @name("ingress.routing.set_dst_mac") action routing_set_dst_mac_0(@id(1) @format(MAC_ADDRESS) @name("dst_mac") bit<48> dst_mac_2) { - local_metadata._packet_rewrites_dst_mac3 = dst_mac_2; - } - @p4runtime_role("sdn_controller") @id(0x02000040) @name("ingress.routing.neighbor_table") table routing_neighbor_table { - key = { - routing_router_interface_id_value: exact @id(1) @name("router_interface_id") @refers_to(router_interface_table , router_interface_id); - routing_neighbor_id_value : exact @id(2) @format(IPV6_ADDRESS) @name("neighbor_id"); - } - actions = { - @proto_id(1) routing_set_dst_mac_0(); - @defaultonly NoAction_4(); - } - const default_action = NoAction_4(); - size = 1024; - } - @id(0x01000002) @name("ingress.routing.set_port_and_src_mac") action routing_set_port_and_src_mac_0(@id(1) @name("port") bit<9> port, @id(2) @format(MAC_ADDRESS) @name("src_mac") bit<48> src_mac_2) { - standard_metadata.egress_spec = (bit<9>)port; - local_metadata._packet_rewrites_src_mac2 = src_mac_2; - } - @p4runtime_role("sdn_controller") @id(0x02000041) @name("ingress.routing.router_interface_table") table routing_router_interface_table { - key = { - routing_router_interface_id_value: exact @id(1) @name("router_interface_id"); - } - actions = { - @proto_id(1) routing_set_port_and_src_mac_0(); @defaultonly NoAction_5(); } const default_action = NoAction_5(); - size = 256; + size = 64; } - @id(0x01000014) @name("ingress.routing.set_ip_nexthop") action routing_set_ip_nexthop_0(@id(1) @refers_to(router_interface_table , router_interface_id) @refers_to(neighbor_table , router_interface_id) @name("router_interface_id") bit<10> router_interface_id, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) @name("neighbor_id") bit<128> neighbor_id) { - routing_router_interface_id_valid = true; - routing_router_interface_id_value = router_interface_id; - routing_neighbor_id_valid = true; - routing_neighbor_id_value = neighbor_id; + @sai_hash_seed(0) @id(0x010000A) @name("ingress.hashing.select_ecmp_hash_algorithm") action hashing_select_ecmp_hash_algorithm_0() { } - @id(0x01000003) @deprecated("Use set_ip_nexthop instead.") @name("ingress.routing.set_nexthop") action routing_set_nexthop_0(@id(1) @refers_to(router_interface_table , router_interface_id) @refers_to(neighbor_table , router_interface_id) @name("router_interface_id") bit<10> router_interface_id_2, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) @name("neighbor_id") bit<128> neighbor_id_2) { - @id(0x01000014) { - routing_router_interface_id_valid = true; - routing_router_interface_id_value = router_interface_id_2; - routing_neighbor_id_valid = true; - routing_neighbor_id_value = neighbor_id_2; - } + @sai_ecmp_hash(SAI_SWITCH_ATTR_ECMP_HASH_IPV4) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_SRC_IPV4) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_DST_IPV4) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_SRC_PORT) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_DST_PORT) @id(0x0100000B) @name("ingress.hashing.compute_ecmp_hash_ipv4") action hashing_compute_ecmp_hash_ipv4_0() { + hash, bit<1>, tuple_1, bit<17>>(local_metadata._wcmp_selector_input13, HashAlgorithm.crc32, 1w0, (tuple_1){f0 = 32w0,f1 = headers.ipv4.src_addr,f2 = headers.ipv4.dst_addr,f3 = local_metadata._l4_src_port11,f4 = local_metadata._l4_dst_port12}, 17w0x10000); + local_metadata._wcmp_selector_input13 = local_metadata._wcmp_selector_input13 | local_metadata._wcmp_selector_input13 << 8w8; } - @p4runtime_role("sdn_controller") @id(0x02000042) @name("ingress.routing.nexthop_table") table routing_nexthop_table { - key = { - routing_nexthop_id_value: exact @id(1) @name("nexthop_id"); - } - actions = { - @proto_id(1) routing_set_nexthop_0(); - @proto_id(3) routing_set_ip_nexthop_0(); - @defaultonly NoAction_6(); - } - const default_action = NoAction_6(); - size = 1024; - } - @id(0x01000005) @name("ingress.routing.set_nexthop_id") action routing_set_nexthop_id_0(@id(1) @refers_to(nexthop_table , nexthop_id) @name("nexthop_id") bit<10> nexthop_id) { - routing_nexthop_id_valid = true; - routing_nexthop_id_value = nexthop_id; + @sai_ecmp_hash(SAI_SWITCH_ATTR_ECMP_HASH_IPV6) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_SRC_IPV6) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_DST_IPV6) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_SRC_PORT) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_DST_PORT) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_IPV6_FLOW_LABEL) @id(0x0100000C) @name("ingress.hashing.compute_ecmp_hash_ipv6") action hashing_compute_ecmp_hash_ipv6_0() { + hash, bit<1>, tuple_2, bit<17>>(local_metadata._wcmp_selector_input13, HashAlgorithm.crc32, 1w0, (tuple_2){f0 = 32w0,f1 = headers.ipv6.flow_label,f2 = headers.ipv6.src_addr,f3 = headers.ipv6.dst_addr,f4 = local_metadata._l4_src_port11,f5 = local_metadata._l4_dst_port12}, 17w0x10000); + local_metadata._wcmp_selector_input13 = local_metadata._wcmp_selector_input13 | local_metadata._wcmp_selector_input13 << 8w8; } - @id(0x01000005) @name("ingress.routing.set_nexthop_id") action routing_set_nexthop_id_1(@id(1) @refers_to(nexthop_table , nexthop_id) @name("nexthop_id") bit<10> nexthop_id_2) { - routing_nexthop_id_valid = true; - routing_nexthop_id_value = nexthop_id_2; + @sai_hash_algorithm(SAI_HASH_ALGORITHM_CRC) @sai_hash_seed(0) @sai_hash_offset(0) @name("ingress.lag_hashing_config.select_lag_hash_algorithm") action lag_hashing_config_select_lag_hash_algorithm_0() { } - @id(0x01000005) @name("ingress.routing.set_nexthop_id") action routing_set_nexthop_id_2(@id(1) @refers_to(nexthop_table , nexthop_id) @name("nexthop_id") bit<10> nexthop_id_3) { - routing_nexthop_id_valid = true; - routing_nexthop_id_value = nexthop_id_3; + @sai_lag_hash(SAI_SWITCH_ATTR_LAG_HASH_IPV4) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_SRC_IPV4) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_DST_IPV4) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_SRC_PORT) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_DST_PORT) @id(0x0100000D) @name("ingress.lag_hashing_config.compute_lag_hash_ipv4") action lag_hashing_config_compute_lag_hash_ipv4_0() { } - @id(0x01000010) @name("ingress.routing.set_nexthop_id_and_metadata") action routing_set_nexthop_id_and_metadata_0(@id(1) @refers_to(nexthop_table , nexthop_id) @name("nexthop_id") bit<10> nexthop_id_4, @name("route_metadata") bit<6> route_metadata_3) { - routing_nexthop_id_valid = true; - routing_nexthop_id_value = nexthop_id_4; - local_metadata._route_metadata20 = route_metadata_3; + @sai_lag_hash(SAI_SWITCH_ATTR_LAG_HASH_IPV6) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_SRC_IPV6) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_DST_IPV6) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_SRC_PORT) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_DST_PORT) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_IPV6_FLOW_LABEL) @id(0x0100000E) @name("ingress.lag_hashing_config.compute_lag_hash_ipv6") action lag_hashing_config_compute_lag_hash_ipv6_0() { } - @id(0x01000010) @name("ingress.routing.set_nexthop_id_and_metadata") action routing_set_nexthop_id_and_metadata_1(@id(1) @refers_to(nexthop_table , nexthop_id) @name("nexthop_id") bit<10> nexthop_id_5, @name("route_metadata") bit<6> route_metadata_4) { - routing_nexthop_id_valid = true; - routing_nexthop_id_value = nexthop_id_5; - local_metadata._route_metadata20 = route_metadata_4; - } - @max_group_size(256) @name("ingress.routing.wcmp_group_selector") action_selector(HashAlgorithm.identity, 32w65536, 32w16) routing_wcmp_group_selector; - @p4runtime_role("sdn_controller") @id(0x02000043) @oneshot @name("ingress.routing.wcmp_group_table") table routing_wcmp_group_table { - key = { - routing_wcmp_group_id_value : exact @id(1) @name("wcmp_group_id"); - local_metadata._wcmp_selector_input6: selector @name("local_metadata.wcmp_selector_input"); - } - actions = { - @proto_id(1) routing_set_nexthop_id_0(); - @defaultonly NoAction_7(); - } - const default_action = NoAction_7(); - @id(0x11DC4EC8) implementation = routing_wcmp_group_selector; - size = 3968; - } - @name("ingress.routing.no_action") action routing_no_action_0() { + @id(0x01798B9E) @name("ingress.routing_lookup.no_action") action routing_lookup_no_action_0() { } @entry_restriction(" // The VRF ID 0 (or '' in P4Runtime) encodes the default VRF, which cannot @@ -491,148 +621,201 @@ control ingress(inout headers_t headers, inout local_metadata_t local_metadata, // constraints are a control plane (P4Runtime) concept), but // p4-constraints does not currently support strings. vrf_id != 0; - ") @p4runtime_role("sdn_controller") @id(0x0200004A) @name("ingress.routing.vrf_table") table routing_vrf_table { + ") @p4runtime_role("sdn_controller") @id(0x0200004A) @name("ingress.routing_lookup.vrf_table") table routing_lookup_vrf_table { key = { - local_metadata._vrf_id1: exact @id(1) @name("vrf_id"); + local_metadata._vrf_id3: exact @id(1) @name("vrf_id"); } actions = { - @proto_id(1) routing_no_action_0(); + @proto_id(1) routing_lookup_no_action_0(); } - const default_action = routing_no_action_0(); + const default_action = routing_lookup_no_action_0(); size = 64; } - @id(0x01000006) @name("ingress.routing.drop") action routing_drop_0() { + @id(0x01000006) @name("ingress.routing_lookup.drop") action routing_lookup_drop_0() { mark_to_drop(standard_metadata); } - @id(0x01000006) @name("ingress.routing.drop") action routing_drop_1() { + @id(0x01000006) @name("ingress.routing_lookup.drop") action routing_lookup_drop_1() { mark_to_drop(standard_metadata); } - @id(0x01000004) @name("ingress.routing.set_wcmp_group_id") action routing_set_wcmp_group_id_0(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) @name("wcmp_group_id") bit<12> wcmp_group_id) { - routing_wcmp_group_id_valid = true; - routing_wcmp_group_id_value = wcmp_group_id; + @id(0x01000004) @name("ingress.routing_lookup.set_wcmp_group_id") action routing_lookup_set_wcmp_group_id_0(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) @name("wcmp_group_id") bit<12> wcmp_group_id) { + local_metadata._wcmp_group_id_valid37 = true; + local_metadata._wcmp_group_id_value38 = wcmp_group_id; } - @id(0x01000004) @name("ingress.routing.set_wcmp_group_id") action routing_set_wcmp_group_id_1(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) @name("wcmp_group_id") bit<12> wcmp_group_id_2) { - routing_wcmp_group_id_valid = true; - routing_wcmp_group_id_value = wcmp_group_id_2; + @id(0x01000004) @name("ingress.routing_lookup.set_wcmp_group_id") action routing_lookup_set_wcmp_group_id_1(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) @name("wcmp_group_id") bit<12> wcmp_group_id_2) { + local_metadata._wcmp_group_id_valid37 = true; + local_metadata._wcmp_group_id_value38 = wcmp_group_id_2; } - @id(0x01000011) @name("ingress.routing.set_wcmp_group_id_and_metadata") action routing_set_wcmp_group_id_and_metadata_0(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) @name("wcmp_group_id") bit<12> wcmp_group_id_3, @name("route_metadata") bit<6> route_metadata_5) { + @id(0x01000011) @name("ingress.routing_lookup.set_wcmp_group_id_and_metadata") action routing_lookup_set_wcmp_group_id_and_metadata_0(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) @name("wcmp_group_id") bit<12> wcmp_group_id_3, @name("route_metadata") bit<6> route_metadata_3) { @id(0x01000004) { - routing_wcmp_group_id_valid = true; - routing_wcmp_group_id_value = wcmp_group_id_3; + local_metadata._wcmp_group_id_valid37 = true; + local_metadata._wcmp_group_id_value38 = wcmp_group_id_3; } - local_metadata._route_metadata20 = route_metadata_5; + local_metadata._route_metadata34 = route_metadata_3; } - @id(0x01000011) @name("ingress.routing.set_wcmp_group_id_and_metadata") action routing_set_wcmp_group_id_and_metadata_1(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) @name("wcmp_group_id") bit<12> wcmp_group_id_4, @name("route_metadata") bit<6> route_metadata_6) { + @id(0x01000011) @name("ingress.routing_lookup.set_wcmp_group_id_and_metadata") action routing_lookup_set_wcmp_group_id_and_metadata_1(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) @name("wcmp_group_id") bit<12> wcmp_group_id_4, @name("route_metadata") bit<6> route_metadata_4) { @id(0x01000004) { - routing_wcmp_group_id_valid = true; - routing_wcmp_group_id_value = wcmp_group_id_4; + local_metadata._wcmp_group_id_valid37 = true; + local_metadata._wcmp_group_id_value38 = wcmp_group_id_4; } - local_metadata._route_metadata20 = route_metadata_6; + local_metadata._route_metadata34 = route_metadata_4; } - @id(0x0100000F) @name("ingress.routing.trap") action routing_trap_0() { - clone(CloneType.I2E, 32w1024); + @id(0x01000015) @name("ingress.routing_lookup.set_metadata_and_drop") action routing_lookup_set_metadata_and_drop_0(@id(1) @name("route_metadata") bit<6> route_metadata_5) { + local_metadata._route_metadata34 = route_metadata_5; mark_to_drop(standard_metadata); } - @id(0x0100000F) @name("ingress.routing.trap") action routing_trap_1() { - clone(CloneType.I2E, 32w1024); + @id(0x01000015) @name("ingress.routing_lookup.set_metadata_and_drop") action routing_lookup_set_metadata_and_drop_1(@id(1) @name("route_metadata") bit<6> route_metadata_6) { + local_metadata._route_metadata34 = route_metadata_6; mark_to_drop(standard_metadata); } - @id(0x01000015) @name("ingress.routing.set_metadata_and_drop") action routing_set_metadata_and_drop_0(@id(1) @name("route_metadata") bit<6> route_metadata_7) { - local_metadata._route_metadata20 = route_metadata_7; - mark_to_drop(standard_metadata); + @id(0x01000010) @name("ingress.routing_lookup.set_nexthop_id_and_metadata") action routing_lookup_set_nexthop_id_and_metadata_0(@id(1) @refers_to(nexthop_table , nexthop_id) @name("nexthop_id") bit<10> nexthop_id_4, @name("route_metadata") bit<6> route_metadata_7) { + local_metadata._nexthop_id_valid39 = true; + local_metadata._nexthop_id_value40 = nexthop_id_4; + local_metadata._route_metadata34 = route_metadata_7; + } + @id(0x01000010) @name("ingress.routing_lookup.set_nexthop_id_and_metadata") action routing_lookup_set_nexthop_id_and_metadata_1(@id(1) @refers_to(nexthop_table , nexthop_id) @name("nexthop_id") bit<10> nexthop_id_5, @name("route_metadata") bit<6> route_metadata_8) { + local_metadata._nexthop_id_valid39 = true; + local_metadata._nexthop_id_value40 = nexthop_id_5; + local_metadata._route_metadata34 = route_metadata_8; + } + @id(0x01000018) @action_restriction(" + // Disallow 0 since it encodes 'no multicast' in V1Model. + multicast_group_id != 0; + ") @name("ingress.routing_lookup.set_multicast_group_id") action routing_lookup_set_multicast_group_id_0(@id(1) @refers_to(builtin : : multicast_group_table , multicast_group_id) @name("multicast_group_id") bit<16> multicast_group_id) { + standard_metadata.mcast_grp = multicast_group_id; + } + @id(0x01000018) @action_restriction(" + // Disallow 0 since it encodes 'no multicast' in V1Model. + multicast_group_id != 0; + ") @name("ingress.routing_lookup.set_multicast_group_id") action routing_lookup_set_multicast_group_id_1(@id(1) @refers_to(builtin : : multicast_group_table , multicast_group_id) @name("multicast_group_id") bit<16> multicast_group_id_1) { + standard_metadata.mcast_grp = multicast_group_id_1; + } + @p4runtime_role("sdn_controller") @id(0x02000044) @name("ingress.routing_lookup.ipv4_table") table routing_lookup_ipv4_table { + key = { + local_metadata._vrf_id3: exact @id(1) @name("vrf_id") @refers_to(vrf_table , vrf_id); + headers.ipv4.dst_addr : lpm @id(2) @name("ipv4_dst") @format(IPV4_ADDRESS); + } + actions = { + @proto_id(1) routing_lookup_drop_0(); + @proto_id(2) set_nexthop_id_1(); + @proto_id(3) routing_lookup_set_wcmp_group_id_0(); + @proto_id(5) routing_lookup_set_nexthop_id_and_metadata_0(); + @proto_id(6) routing_lookup_set_wcmp_group_id_and_metadata_0(); + @proto_id(7) routing_lookup_set_metadata_and_drop_0(); + } + const default_action = routing_lookup_drop_0(); + size = 131072; } - @id(0x01000015) @name("ingress.routing.set_metadata_and_drop") action routing_set_metadata_and_drop_1(@id(1) @name("route_metadata") bit<6> route_metadata_8) { - local_metadata._route_metadata20 = route_metadata_8; - mark_to_drop(standard_metadata); + @p4runtime_role("sdn_controller") @id(0x02000045) @name("ingress.routing_lookup.ipv6_table") table routing_lookup_ipv6_table { + key = { + local_metadata._vrf_id3: exact @id(1) @name("vrf_id") @refers_to(vrf_table , vrf_id); + headers.ipv6.dst_addr : lpm @id(2) @name("ipv6_dst") @format(IPV6_ADDRESS); + } + actions = { + @proto_id(1) routing_lookup_drop_1(); + @proto_id(2) set_nexthop_id_2(); + @proto_id(3) routing_lookup_set_wcmp_group_id_1(); + @proto_id(5) routing_lookup_set_nexthop_id_and_metadata_1(); + @proto_id(6) routing_lookup_set_wcmp_group_id_and_metadata_1(); + @proto_id(7) routing_lookup_set_metadata_and_drop_1(); + } + const default_action = routing_lookup_drop_1(); + size = 17000; } - @p4runtime_role("sdn_controller") @id(0x02000044) @name("ingress.routing.ipv4_table") table routing_ipv4_table { + @p4runtime_role("sdn_controller") @id(0x0200004E) @name("ingress.routing_lookup.ipv4_multicast_table") table routing_lookup_ipv4_multicast_table { key = { - local_metadata._vrf_id1: exact @id(1) @name("vrf_id") @refers_to(vrf_table , vrf_id); - headers.ipv4.dst_addr : lpm @format(IPV4_ADDRESS) @id(2) @name("ipv4_dst"); + local_metadata._vrf_id3: exact @id(1) @name("vrf_id") @refers_to(vrf_table , vrf_id); + headers.ipv4.dst_addr : exact @id(2) @name("ipv4_dst") @format(IPV4_ADDRESS); } actions = { - @proto_id(1) routing_drop_0(); - @proto_id(2) routing_set_nexthop_id_1(); - @proto_id(3) routing_set_wcmp_group_id_0(); - @proto_id(4) routing_trap_0(); - @proto_id(5) routing_set_nexthop_id_and_metadata_0(); - @proto_id(6) routing_set_wcmp_group_id_and_metadata_0(); - @proto_id(7) routing_set_metadata_and_drop_0(); + @proto_id(1) routing_lookup_set_multicast_group_id_0(); + @defaultonly NoAction_6(); } - const default_action = routing_drop_0(); - size = 32768; + size = 1600; + default_action = NoAction_6(); } - @p4runtime_role("sdn_controller") @id(0x02000045) @name("ingress.routing.ipv6_table") table routing_ipv6_table { + @p4runtime_role("sdn_controller") @id(0x0200004F) @name("ingress.routing_lookup.ipv6_multicast_table") table routing_lookup_ipv6_multicast_table { key = { - local_metadata._vrf_id1: exact @id(1) @name("vrf_id") @refers_to(vrf_table , vrf_id); - headers.ipv6.dst_addr : lpm @format(IPV6_ADDRESS) @id(2) @name("ipv6_dst"); + local_metadata._vrf_id3: exact @id(1) @name("vrf_id") @refers_to(vrf_table , vrf_id); + headers.ipv6.dst_addr : exact @id(2) @name("ipv6_dst") @format(IPV6_ADDRESS); } actions = { - @proto_id(1) routing_drop_1(); - @proto_id(2) routing_set_nexthop_id_2(); - @proto_id(3) routing_set_wcmp_group_id_1(); - @proto_id(4) routing_trap_1(); - @proto_id(5) routing_set_nexthop_id_and_metadata_1(); - @proto_id(6) routing_set_wcmp_group_id_and_metadata_1(); - @proto_id(7) routing_set_metadata_and_drop_1(); + @proto_id(1) routing_lookup_set_multicast_group_id_1(); + @defaultonly NoAction_7(); } - const default_action = routing_drop_1(); - size = 4096; + size = 1600; + default_action = NoAction_7(); } - @id(0x15000100) @name("ingress.acl_ingress.acl_ingress_meter") direct_meter>(MeterType.bytes) acl_ingress_acl_ingress_meter; + @id(0x15000100) @mode(single_rate_two_color) @name("ingress.acl_ingress.acl_ingress_meter") direct_meter>(MeterType.bytes) acl_ingress_acl_ingress_meter; + @id(0x15000102) @mode(single_rate_two_color) @name("ingress.acl_ingress.acl_ingress_qos_meter") direct_meter>(MeterType.bytes) acl_ingress_acl_ingress_qos_meter; @id(0x13000102) @name("ingress.acl_ingress.acl_ingress_counter") direct_counter(CounterType.packets_and_bytes) acl_ingress_acl_ingress_counter; - @id(0x01000101) @sai_action(SAI_PACKET_ACTION_COPY , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_YELLOW) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_RED) @name("ingress.acl_ingress.acl_copy") action acl_ingress_acl_copy_0(@sai_action_param(QOS_QUEUE) @id(1) @name("qos_queue") bit<8> qos_queue) { + @id(0x13000107) @name("ingress.acl_ingress.acl_ingress_qos_counter") direct_counter(CounterType.packets_and_bytes) acl_ingress_acl_ingress_qos_counter; + @id(0x13000109) @name("ingress.acl_ingress.acl_ingress_counting_counter") direct_counter(CounterType.packets_and_bytes) acl_ingress_acl_ingress_counting_counter; + @id(0x1300010A) @name("ingress.acl_ingress.acl_ingress_security_counter") direct_counter(CounterType.packets_and_bytes) acl_ingress_acl_ingress_security_counter; + @id(0x01000101) @sai_action(SAI_PACKET_ACTION_COPY , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_RED) @name("ingress.acl_ingress.acl_copy") action acl_ingress_acl_copy_0(@sai_action_param(QOS_QUEUE) @id(1) @name("qos_queue") bit<8> qos_queue) { acl_ingress_acl_ingress_counter.count(); - acl_ingress_acl_ingress_meter.read(local_metadata._color18); - clone(CloneType.I2E, 32w1024); + acl_ingress_acl_ingress_meter.read(local_metadata._color32); + local_metadata._marked_to_copy18 = true; } - @id(0x01000102) @sai_action(SAI_PACKET_ACTION_TRAP , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_YELLOW) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED) @name("ingress.acl_ingress.acl_trap") action acl_ingress_acl_trap_0(@sai_action_param(QOS_QUEUE) @id(1) @name("qos_queue") bit<8> qos_queue_3) { - @id(0x01000101) @sai_action(SAI_PACKET_ACTION_COPY , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_YELLOW) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_RED) { + @id(0x01000102) @sai_action(SAI_PACKET_ACTION_TRAP , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED) @name("ingress.acl_ingress.acl_trap") action acl_ingress_acl_trap_0(@sai_action_param(QOS_QUEUE) @id(1) @name("qos_queue") bit<8> qos_queue_3) { + @id(0x01000101) @sai_action(SAI_PACKET_ACTION_COPY , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_RED) { acl_ingress_acl_ingress_counter.count(); - acl_ingress_acl_ingress_meter.read(local_metadata._color18); - clone(CloneType.I2E, 32w1024); + acl_ingress_acl_ingress_meter.read(local_metadata._color32); + local_metadata._marked_to_copy18 = true; } - mark_to_drop(standard_metadata); + local_metadata._acl_drop42 = true; } - @id(0x01000199) @sai_action(SAI_PACKET_ACTION_TRAP , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_YELLOW) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED) @name("ingress.acl_ingress.acl_experimental_trap") action acl_ingress_acl_experimental_trap_0(@sai_action_param(QOS_QUEUE) @id(1) @name("qos_queue") bit<8> qos_queue_4) { - acl_ingress_acl_ingress_meter.read(local_metadata._color18); - @id(0x01000102) @sai_action(SAI_PACKET_ACTION_TRAP , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_YELLOW) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED) { - @id(0x01000101) @sai_action(SAI_PACKET_ACTION_COPY , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_YELLOW) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_RED) { - acl_ingress_acl_ingress_counter.count(); - acl_ingress_acl_ingress_meter.read(local_metadata._color18); - clone(CloneType.I2E, 32w1024); - } - mark_to_drop(standard_metadata); - } + @id(0x01000103) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED) @name("ingress.acl_ingress.acl_forward") action acl_ingress_acl_forward_0() { + acl_ingress_acl_ingress_meter.read(local_metadata._color32); } - @id(0x01000103) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_YELLOW) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED) @name("ingress.acl_ingress.acl_forward") action acl_ingress_acl_forward_0() { - acl_ingress_acl_ingress_counter.count(); - acl_ingress_acl_ingress_meter.read(local_metadata._color18); + @id(0x01000103) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED) @name("ingress.acl_ingress.acl_forward") action acl_ingress_acl_forward_1() { + acl_ingress_acl_ingress_meter.read(local_metadata._color32); + } + @id(0x01000105) @sai_action(SAI_PACKET_ACTION_FORWARD) @name("ingress.acl_ingress.acl_count") action acl_ingress_acl_count_0() { + acl_ingress_acl_ingress_counting_counter.count(); } - @id(0x01000104) @sai_action(SAI_PACKET_ACTION_FORWARD) @name("ingress.acl_ingress.acl_mirror") action acl_ingress_acl_mirror_0(@id(1) @refers_to(mirror_session_table , mirror_session_id) @sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_MIRROR_INGRESS) @name("mirror_session_id") bit<10> mirror_session_id) { + @id(0x01000104) @sai_action(SAI_PACKET_ACTION_FORWARD) @name("ingress.acl_ingress.acl_mirror") action acl_ingress_acl_mirror_0(@id(1) @refers_to(mirror_session_table , mirror_session_id) @sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_MIRROR_INGRESS) @name("mirror_session_id") bit<10> mirror_session_id_1) { acl_ingress_acl_ingress_counter.count(); - local_metadata._mirror_session_id_valid10 = true; - local_metadata._mirror_session_id_value11 = mirror_session_id; + local_metadata._marked_to_mirror19 = true; + local_metadata._mirror_session_id20 = mirror_session_id_1; + } + @id(0x0100010C) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_COPY_CANCEL , SAI_PACKET_COLOR_RED) @name("ingress.acl_ingress.set_qos_queue_and_cancel_copy_above_rate_limit") action acl_ingress_set_qos_queue_and_cancel_copy_above_rate_limit_0(@id(1) @sai_action_param(QOS_QUEUE) @name("qos_queue") bit<8> qos_queue_4) { + acl_ingress_acl_ingress_qos_meter.read(local_metadata._color32); } - @p4runtime_role("sdn_controller") @id(0x02000100) @sai_acl(INGRESS) @entry_restriction(" + @id(0x01000111) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DENY , SAI_PACKET_COLOR_RED) @unsupported @name("ingress.acl_ingress.set_cpu_and_multicast_queues_and_deny_above_rate_limit") action acl_ingress_set_cpu_and_multicast_queues_and_deny_above_rate_limit_0(@id(1) @sai_action_param(QOS_QUEUE) @name("cpu_queue") bit<8> cpu_queue, @id(2) @sai_action_param(MULTICAST_QOS_QUEUE , SAI_PACKET_COLOR_GREEN) @name("green_multicast_queue") bit<8> green_multicast_queue, @id(3) @sai_action_param(MULTICAST_QOS_QUEUE , SAI_PACKET_COLOR_RED) @name("red_multicast_queue") bit<8> red_multicast_queue) { + acl_ingress_acl_ingress_qos_meter.read(local_metadata._color32); + } + @id(0x0100010E) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DENY , SAI_PACKET_COLOR_RED) @name("ingress.acl_ingress.set_cpu_queue_and_deny_above_rate_limit") action acl_ingress_set_cpu_queue_and_deny_above_rate_limit_0(@id(1) @sai_action_param(QOS_QUEUE) @name("cpu_queue") bit<8> cpu_queue_3) { + acl_ingress_acl_ingress_qos_meter.read(local_metadata._color32); + } + @id(0x01000110) @sai_action(SAI_PACKET_ACTION_FORWARD) @name("ingress.acl_ingress.set_cpu_queue") action acl_ingress_set_cpu_queue_0(@id(1) @sai_action_param(QOS_QUEUE) @name("cpu_queue") bit<8> cpu_queue_4) { + } + @p4runtime_role("sdn_controller") @id(0x02000100) @sai_acl(INGRESS) @sai_acl_priority(5) @entry_restriction(" // Forbid using ether_type for IP packets (by convention, use is_ip* instead). ether_type != 0x0800 && ether_type != 0x86dd; // Only allow IP field matches for IP packets. dst_ip::mask != 0 -> is_ipv4 == 1; + + src_ip::mask != 0 -> is_ipv4 == 1; + dst_ipv6::mask != 0 -> is_ipv6 == 1; + src_ipv6::mask != 0 -> is_ipv6 == 1; ttl::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + dscp::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); ecn::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + ip_protocol::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); // Only allow l4_dst_port and l4_src_port matches for TCP/UDP packets. + l4_src_port::mask != 0 -> (ip_protocol == 6 || ip_protocol == 17); + l4_dst_port::mask != 0 -> (ip_protocol == 6 || ip_protocol == 17); - // Only allow icmp_type matches for ICMP packets + // Only allow icmp_type matches for ICMP packets icmp_type::mask != 0 -> ip_protocol == 1; icmpv6_type::mask != 0 -> ip_protocol == 58; @@ -645,215 +828,538 @@ control ingress(inout headers_t headers, inout local_metadata_t local_metadata, is_ipv6::mask != 0 -> (is_ipv6 == 1); ") @name("ingress.acl_ingress.acl_ingress_table") table acl_ingress_acl_ingress_table { key = { - key_2 : optional @name("is_ip") @id(1) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); - headers.ipv4.isValid() : optional @name("is_ipv4") @id(2) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); - headers.ipv6.isValid() : optional @name("is_ipv6") @id(3) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); - headers.ethernet.ether_type : ternary @name("ether_type") @id(4) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ETHER_TYPE); - headers.ethernet.dst_addr : ternary @name("dst_mac") @id(5) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_MAC) @format(MAC_ADDRESS); - headers.ipv4.src_addr : ternary @name("src_ip") @id(6) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_SRC_IP) @format(IPV4_ADDRESS); - headers.ipv4.dst_addr : ternary @name("dst_ip") @id(7) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_IP) @format(IPV4_ADDRESS); - headers.ipv6.src_addr[127:64] : ternary @name("src_ipv6") @id(8) @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_SRC_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_SRC_IPV6_WORD2 )) @format(IPV6_ADDRESS); - headers.ipv6.dst_addr[127:64] : ternary @name("dst_ipv6") @id(9) @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD2 )) @format(IPV6_ADDRESS); - acl_ingress_ttl : ternary @name("ttl") @id(10) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_TTL); - acl_ingress_dscp : ternary @name("dscp") @id(11) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DSCP); - acl_ingress_ecn : ternary @name("ecn") @id(12) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ECN); - acl_ingress_ip_protocol : ternary @name("ip_protocol") @id(13) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IP_PROTOCOL); - headers.icmp.type : ternary @name("icmp_type") @id(19) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ICMP_TYPE); - headers.icmp.type : ternary @name("icmpv6_type") @id(14) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ICMPV6_TYPE); - local_metadata._l4_src_port4 : ternary @name("l4_src_port") @id(20) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_L4_SRC_PORT); - local_metadata._l4_dst_port5 : ternary @name("l4_dst_port") @id(15) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_L4_DST_PORT); - local_metadata._ingress_port19 : optional @name("in_port") @id(17) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IN_PORT); - local_metadata._route_metadata20: optional @name("route_metadata") @id(18) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ROUTE_DST_USER_META); + key_3 : optional @id(1) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(2) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(3) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + headers.ethernet.ether_type : ternary @id(4) @name("ether_type") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ETHER_TYPE); + headers.ethernet.dst_addr : ternary @id(5) @name("dst_mac") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_MAC) @format(MAC_ADDRESS); + headers.ipv4.src_addr : ternary @id(6) @name("src_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_SRC_IP) @format(IPV4_ADDRESS); + headers.ipv4.dst_addr : ternary @id(7) @name("dst_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_IP) @format(IPV4_ADDRESS); + headers.ipv6.src_addr[127:64] : ternary @id(8) @name("src_ipv6") @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_SRC_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_SRC_IPV6_WORD2 )) @format(IPV6_ADDRESS); + headers.ipv6.dst_addr[127:64] : ternary @id(9) @name("dst_ipv6") @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD2 )) @format(IPV6_ADDRESS); + acl_ingress_ttl : ternary @id(10) @name("ttl") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_TTL); + acl_ingress_dscp : ternary @id(11) @name("dscp") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DSCP); + acl_ingress_ecn : ternary @id(12) @name("ecn") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ECN); + acl_ingress_ip_protocol : ternary @id(13) @name("ip_protocol") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IP_PROTOCOL); + headers.icmp.type : ternary @id(19) @name("icmp_type") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ICMP_TYPE); + headers.icmp.type : ternary @id(14) @name("icmpv6_type") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ICMPV6_TYPE); + local_metadata._l4_src_port11 : ternary @id(20) @name("l4_src_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_L4_SRC_PORT); + local_metadata._l4_dst_port12 : ternary @id(15) @name("l4_dst_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_L4_DST_PORT); + local_metadata._ingress_port33 : optional @id(17) @name("in_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IN_PORT); + local_metadata._route_metadata34: optional @id(18) @name("route_metadata") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ROUTE_DST_USER_META); } actions = { @proto_id(1) acl_ingress_acl_copy_0(); @proto_id(2) acl_ingress_acl_trap_0(); @proto_id(3) acl_ingress_acl_forward_0(); @proto_id(4) acl_ingress_acl_mirror_0(); - @proto_id(5) acl_drop_1(); - @proto_id(99) acl_ingress_acl_experimental_trap_0(); + @proto_id(5) acl_drop_2(); @defaultonly NoAction_8(); } const default_action = NoAction_8(); meters = acl_ingress_acl_ingress_meter; counters = acl_ingress_acl_ingress_counter; - size = 128; - } - @id(0x01000007) @name("ingress.mirroring_clone.mirror_as_ipv4_erspan") action mirroring_clone_mirror_as_ipv4_erspan_0(@id(1) @name("port") bit<9> port_2, @id(2) @format(IPV4_ADDRESS) @name("src_ip") bit<32> src_ip, @id(3) @format(IPV4_ADDRESS) @name("dst_ip") bit<32> dst_ip, @id(4) @format(MAC_ADDRESS) @name("src_mac") bit<48> src_mac_3, @id(5) @format(MAC_ADDRESS) @name("dst_mac") bit<48> dst_mac_3, @id(6) @name("ttl") bit<8> ttl_0, @id(7) @name("tos") bit<8> tos) { - mirroring_clone_mirror_port = port_2; - local_metadata._mirroring_src_ip12 = src_ip; - local_metadata._mirroring_dst_ip13 = dst_ip; - local_metadata._mirroring_src_mac14 = src_mac_3; - local_metadata._mirroring_dst_mac15 = dst_mac_3; - local_metadata._mirroring_ttl16 = ttl_0; - local_metadata._mirroring_tos17 = tos; - } - @p4runtime_role("sdn_controller") @id(0x02000046) @name("ingress.mirroring_clone.mirror_session_table") table mirroring_clone_mirror_session_table { + size = 255; + } + @id(0x02000107) @sai_acl(INGRESS) @sai_acl_priority(10) @p4runtime_role("sdn_controller") @entry_restriction(" + // Forbid using ether_type for IP packets (by convention, use is_ip* instead). + ether_type != 0x0800 && ether_type != 0x86dd; + // Only allow IP field matches for IP packets. + ttl::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + ip_protocol::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + // Only allow l4_dst_port matches for TCP/UDP packets. + l4_dst_port::mask != 0 -> (ip_protocol == 6 || ip_protocol == 17); + // Forbid illegal combinations of IP_TYPE fields. + is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0); + is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0); + is_ipv6::mask != 0 -> (is_ip::mask == 0 && is_ipv4::mask == 0); + // Forbid unsupported combinations of IP_TYPE fields. + is_ipv4::mask != 0 -> (is_ipv4 == 1); + is_ipv6::mask != 0 -> (is_ipv6 == 1); + // Only allow icmp_type matches for ICMP packets + icmpv6_type::mask != 0 -> ip_protocol == 58; + + // Only allow l4_dst_port matches for TCP/UDP packets. + l4_src_port::mask != 0 -> (ip_protocol == 6 || ip_protocol == 17); + // Only allow icmp_type matches for ICMP packets + icmp_type::mask != 0 -> ip_protocol == 1; + + + + + + ") @name("ingress.acl_ingress.acl_ingress_qos_table") table acl_ingress_acl_ingress_qos_table { key = { - local_metadata._mirror_session_id_value11: exact @id(1) @name("mirror_session_id"); + key_6 : optional @id(1) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(2) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(3) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + headers.ethernet.ether_type : ternary @id(4) @name("ether_type") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ETHER_TYPE); + acl_ingress_ttl : ternary @id(7) @name("ttl") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_TTL); + acl_ingress_ip_protocol : ternary @id(8) @name("ip_protocol") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IP_PROTOCOL); + headers.icmp.type : ternary @id(9) @name("icmpv6_type") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ICMPV6_TYPE); + local_metadata._l4_dst_port12 : ternary @id(10) @name("l4_dst_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_L4_DST_PORT); + local_metadata._l4_src_port11 : ternary @id(12) @name("l4_src_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_L4_SRC_PORT); + headers.icmp.type : ternary @id(14) @name("icmp_type") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ICMP_TYPE); + local_metadata._route_metadata34: ternary @id(15) @name("route_metadata") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ROUTE_DST_USER_META); } actions = { - @proto_id(1) mirroring_clone_mirror_as_ipv4_erspan_0(); + @proto_id(1) acl_ingress_set_qos_queue_and_cancel_copy_above_rate_limit_0(); + @proto_id(2) acl_ingress_set_cpu_queue_and_deny_above_rate_limit_0(); + @proto_id(3) acl_ingress_acl_forward_1(); + @proto_id(4) acl_drop_3(); + @proto_id(5) acl_ingress_set_cpu_queue_0(); + @proto_id(6) acl_ingress_set_cpu_and_multicast_queues_and_deny_above_rate_limit_0(); @defaultonly NoAction_9(); } const default_action = NoAction_9(); - size = 2; - } - @id(0x01000009) @name("ingress.mirroring_clone.set_pre_session") action mirroring_clone_set_pre_session_0(@name("id") bit<32> id) { - mirroring_clone_pre_session = id; + meters = acl_ingress_acl_ingress_qos_meter; + counters = acl_ingress_acl_ingress_qos_counter; + size = 511; } - @p4runtime_role("packet_replication_engine_manager") @id(0x02000048) @name("ingress.mirroring_clone.mirror_port_to_pre_session_table") table mirroring_clone_mirror_port_to_pre_session_table { + @p4runtime_role("sdn_controller") @id(0x02000109) @sai_acl_priority(7) @sai_acl(INGRESS) @entry_restriction(" + // Only allow IP field matches for IP packets. + dscp::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + // Forbid illegal combinations of IP_TYPE fields. + is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0); + is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0); + is_ipv6::mask != 0 -> (is_ip::mask == 0 && is_ipv4::mask == 0); + // Forbid unsupported combinations of IP_TYPE fields. + is_ipv4::mask != 0 -> (is_ipv4 == 1); + is_ipv6::mask != 0 -> (is_ipv6 == 1); + ") @name("ingress.acl_ingress.acl_ingress_counting_table") table acl_ingress_acl_ingress_counting_table { key = { - mirroring_clone_mirror_port: exact @id(1) @name("mirror_port"); + key_7 : optional @id(1) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(2) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(3) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + acl_ingress_dscp : ternary @id(11) @name("dscp") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DSCP); + local_metadata._route_metadata34: ternary @id(18) @name("route_metadata") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ROUTE_DST_USER_META); } actions = { - @proto_id(1) mirroring_clone_set_pre_session_0(); + @proto_id(3) acl_ingress_acl_count_0(); @defaultonly NoAction_10(); } const default_action = NoAction_10(); + counters = acl_ingress_acl_ingress_counting_counter; + size = 255; + } + @id(0x01000001) @name("ingress.routing_resolution.set_dst_mac") action routing_resolution_set_dst_mac_0(@id(1) @format(MAC_ADDRESS) @name("dst_mac") bit<48> dst_mac_2) { + local_metadata._packet_rewrites_dst_mac9 = dst_mac_2; + } + @p4runtime_role("sdn_controller") @id(0x02000040) @name("ingress.routing_resolution.neighbor_table") table routing_resolution_neighbor_table { + key = { + routing_resolution_router_interface_id_value: exact @id(1) @name("router_interface_id") @refers_to(router_interface_table , router_interface_id); + routing_resolution_neighbor_id_value : exact @id(2) @format(IPV6_ADDRESS) @name("neighbor_id"); + } + actions = { + @proto_id(1) routing_resolution_set_dst_mac_0(); + @defaultonly NoAction_11(); + } + const default_action = NoAction_11(); + size = 1024; + } + @id(0x0100001B) @unsupported @action_restriction(" + // Disallow reserved VLAN IDs with implementation-defined semantics. + vlan_id != 0 && vlan_id != 4095") @name("ingress.routing_resolution.set_port_and_src_mac_and_vlan_id") action routing_resolution_set_port_and_src_mac_and_vlan_id_0(@id(1) @name("port") bit<9> port, @id(2) @format(MAC_ADDRESS) @name("src_mac") bit<48> src_mac_4, @id(3) @name("vlan_id") bit<12> vlan_id_1) { + standard_metadata.egress_spec = (bit<9>)port; + local_metadata._packet_rewrites_src_mac8 = src_mac_4; + local_metadata._packet_rewrites_vlan_id10 = vlan_id_1; + } + @id(0x01000002) @name("ingress.routing_resolution.set_port_and_src_mac") action routing_resolution_set_port_and_src_mac_0(@id(1) @name("port") bit<9> port_3, @id(2) @format(MAC_ADDRESS) @name("src_mac") bit<48> src_mac_5) { + @id(0x0100001B) @unsupported @action_restriction(" + // Disallow reserved VLAN IDs with implementation-defined semantics. + vlan_id != 0 && vlan_id != 4095") { + standard_metadata.egress_spec = (bit<9>)port_3; + local_metadata._packet_rewrites_src_mac8 = src_mac_5; + local_metadata._packet_rewrites_vlan_id10 = 12w0xfff; + } + } + @p4runtime_role("sdn_controller") @id(0x02000041) @name("ingress.routing_resolution.router_interface_table") table routing_resolution_router_interface_table { + key = { + routing_resolution_router_interface_id_value: exact @id(1) @name("router_interface_id"); + } + actions = { + @proto_id(1) routing_resolution_set_port_and_src_mac_0(); + @proto_id(2) routing_resolution_set_port_and_src_mac_and_vlan_id_0(); + @defaultonly NoAction_12(); + } + const default_action = NoAction_12(); + size = 256; + } + @id(0x01000017) @name("ingress.routing_resolution.set_ip_nexthop_and_disable_rewrites") action routing_resolution_set_ip_nexthop_and_disable_rewrites_0(@id(1) @refers_to(router_interface_table , router_interface_id) @refers_to(neighbor_table , router_interface_id) @name("router_interface_id") bit<10> router_interface_id, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) @name("neighbor_id") bit<128> neighbor_id, @id(3) @name("disable_decrement_ttl") bit<1> disable_decrement_ttl, @id(4) @name("disable_src_mac_rewrite") bit<1> disable_src_mac_rewrite, @id(5) @name("disable_dst_mac_rewrite") bit<1> disable_dst_mac_rewrite, @id(6) @name("disable_vlan_rewrite") bit<1> disable_vlan_rewrite) { + routing_resolution_router_interface_id_valid = true; + routing_resolution_router_interface_id_value = router_interface_id; + routing_resolution_neighbor_id_valid = true; + routing_resolution_neighbor_id_value = neighbor_id; + local_metadata._enable_decrement_ttl4 = !(bool)disable_decrement_ttl; + local_metadata._enable_src_mac_rewrite5 = !(bool)disable_src_mac_rewrite; + local_metadata._enable_dst_mac_rewrite6 = !(bool)disable_dst_mac_rewrite; + local_metadata._enable_vlan_rewrite7 = !(bool)disable_vlan_rewrite; + } + @id(0x01000014) @name("ingress.routing_resolution.set_ip_nexthop") action routing_resolution_set_ip_nexthop_0(@id(1) @refers_to(router_interface_table , router_interface_id) @refers_to(neighbor_table , router_interface_id) @name("router_interface_id") bit<10> router_interface_id_4, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) @name("neighbor_id") bit<128> neighbor_id_3) { + @id(0x01000017) { + routing_resolution_router_interface_id_valid = true; + routing_resolution_router_interface_id_value = router_interface_id_4; + routing_resolution_neighbor_id_valid = true; + routing_resolution_neighbor_id_value = neighbor_id_3; + local_metadata._enable_decrement_ttl4 = true; + local_metadata._enable_src_mac_rewrite5 = true; + local_metadata._enable_dst_mac_rewrite6 = true; + local_metadata._enable_vlan_rewrite7 = true; + } + } + @id(0x01000003) @deprecated("Use set_ip_nexthop instead.") @name("ingress.routing_resolution.set_nexthop") action routing_resolution_set_nexthop_0(@id(1) @refers_to(router_interface_table , router_interface_id) @refers_to(neighbor_table , router_interface_id) @name("router_interface_id") bit<10> router_interface_id_5, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) @name("neighbor_id") bit<128> neighbor_id_4) { + @id(0x01000014) { + @id(0x01000017) { + routing_resolution_router_interface_id_valid = true; + routing_resolution_router_interface_id_value = router_interface_id_5; + routing_resolution_neighbor_id_valid = true; + routing_resolution_neighbor_id_value = neighbor_id_4; + local_metadata._enable_decrement_ttl4 = true; + local_metadata._enable_src_mac_rewrite5 = true; + local_metadata._enable_dst_mac_rewrite6 = true; + local_metadata._enable_vlan_rewrite7 = true; + } + } + } + @id(0x01000012) @name("ingress.routing_resolution.set_p2p_tunnel_encap_nexthop") action routing_resolution_set_p2p_tunnel_encap_nexthop_0(@id(1) @refers_to(tunnel_table , tunnel_id) @name("tunnel_id") bit<10> tunnel_id) { + routing_resolution_tunnel_id_valid = true; + routing_resolution_tunnel_id_value = tunnel_id; + } + @p4runtime_role("sdn_controller") @id(0x02000042) @name("ingress.routing_resolution.nexthop_table") table routing_resolution_nexthop_table { + key = { + local_metadata._nexthop_id_value40: exact @id(1) @name("nexthop_id"); + } + actions = { + @proto_id(1) routing_resolution_set_nexthop_0(); + @proto_id(2) routing_resolution_set_p2p_tunnel_encap_nexthop_0(); + @proto_id(3) routing_resolution_set_ip_nexthop_0(); + @proto_id(4) routing_resolution_set_ip_nexthop_and_disable_rewrites_0(); + @defaultonly NoAction_13(); + } + const default_action = NoAction_13(); + size = 1024; + } + @id(0x01000013) @name("ingress.routing_resolution.mark_for_p2p_tunnel_encap") action routing_resolution_mark_for_p2p_tunnel_encap_0(@id(1) @format(IPV6_ADDRESS) @name("encap_src_ip") bit<128> encap_src_ip, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) @name("encap_dst_ip") bit<128> encap_dst_ip, @id(3) @refers_to(neighbor_table , router_interface_id) @refers_to(router_interface_table , router_interface_id) @name("router_interface_id") bit<10> router_interface_id_6) { + local_metadata._tunnel_encap_src_ipv616 = encap_src_ip; + local_metadata._tunnel_encap_dst_ipv617 = encap_dst_ip; + local_metadata._apply_tunnel_encap_at_egress15 = true; + @id(0x01000014) { + @id(0x01000017) { + routing_resolution_router_interface_id_valid = true; + routing_resolution_router_interface_id_value = router_interface_id_6; + routing_resolution_neighbor_id_valid = true; + routing_resolution_neighbor_id_value = encap_dst_ip; + local_metadata._enable_decrement_ttl4 = true; + local_metadata._enable_src_mac_rewrite5 = true; + local_metadata._enable_dst_mac_rewrite6 = true; + local_metadata._enable_vlan_rewrite7 = true; + } + } + } + @p4runtime_role("sdn_controller") @id(0x02000050) @name("ingress.routing_resolution.tunnel_table") table routing_resolution_tunnel_table { + key = { + routing_resolution_tunnel_id_value: exact @id(1) @name("tunnel_id"); + } + actions = { + @proto_id(1) routing_resolution_mark_for_p2p_tunnel_encap_0(); + @defaultonly NoAction_14(); + } + const default_action = NoAction_14(); + size = 2048; + } + @max_group_size(512) @id(0x11DC4EC8) @name("ingress.routing_resolution.wcmp_group_selector") action_selector(HashAlgorithm.identity, 32w49152, 32w8) routing_resolution_wcmp_group_selector; + @p4runtime_role("sdn_controller") @id(0x02000043) @oneshot @name("ingress.routing_resolution.wcmp_group_table") table routing_resolution_wcmp_group_table { + key = { + local_metadata._wcmp_group_id_value38: exact @id(1) @name("wcmp_group_id"); + local_metadata._wcmp_selector_input13: selector @name("local_metadata.wcmp_selector_input"); + } + actions = { + @proto_id(1) set_nexthop_id_3(); + @defaultonly NoAction_15(); + } + const default_action = NoAction_15(); + implementation = routing_resolution_wcmp_group_selector; + size = 3968; + } + @id(0x01000007) @name("ingress.mirror_session_lookup.mirror_as_ipv4_erspan") action mirror_session_lookup_mirror_as_ipv4_erspan_0(@id(1) @name("port") bit<9> port_4, @id(2) @format(IPV4_ADDRESS) @name("src_ip") bit<32> src_ip, @id(3) @format(IPV4_ADDRESS) @name("dst_ip") bit<32> dst_ip, @id(4) @format(MAC_ADDRESS) @name("src_mac") bit<48> src_mac_6, @id(5) @format(MAC_ADDRESS) @name("dst_mac") bit<48> dst_mac_3, @id(6) @name("ttl") bit<8> ttl_1, @id(7) @name("tos") bit<8> tos) { + } + @id(0x0100001D) @unsupported @name("ingress.mirror_session_lookup.mirror_with_vlan_tag_and_ipfix_encapsulation") action mirror_session_lookup_mirror_with_vlan_tag_and_ipfix_encapsulation_0(@id(1) @name("monitor_port") bit<9> monitor_port, @id(2) @name("monitor_failover_port") bit<9> monitor_failover_port, @id(3) @format(MAC_ADDRESS) @name("mirror_encap_src_mac") bit<48> mirror_encap_src_mac_1, @id(4) @format(MAC_ADDRESS) @name("mirror_encap_dst_mac") bit<48> mirror_encap_dst_mac_1, @id(6) @name("mirror_encap_vlan_id") bit<12> mirror_encap_vlan_id_1, @id(7) @format(IPV6_ADDRESS) @name("mirror_encap_dst_ip") bit<128> mirror_encap_dst_ip_1, @id(8) @format(IPV6_ADDRESS) @name("mirror_encap_src_ip") bit<128> mirror_encap_src_ip_1, @id(9) @name("mirror_encap_udp_src_port") bit<16> mirror_encap_udp_src_port_1, @id(10) @name("mirror_encap_udp_dst_port") bit<16> mirror_encap_udp_dst_port_1) { + local_metadata._mirror_egress_port21 = monitor_port; + local_metadata._mirror_encap_src_mac22 = mirror_encap_src_mac_1; + local_metadata._mirror_encap_dst_mac23 = mirror_encap_dst_mac_1; + local_metadata._mirror_encap_vlan_id24 = mirror_encap_vlan_id_1; + local_metadata._mirror_encap_src_ip25 = mirror_encap_src_ip_1; + local_metadata._mirror_encap_dst_ip26 = mirror_encap_dst_ip_1; + local_metadata._mirror_encap_udp_src_port27 = mirror_encap_udp_src_port_1; + local_metadata._mirror_encap_udp_dst_port28 = mirror_encap_udp_dst_port_1; + } + @p4runtime_role("sdn_controller") @id(0x02000046) @name("ingress.mirror_session_lookup.mirror_session_table") table mirror_session_lookup_mirror_session_table { + key = { + local_metadata._mirror_session_id20: exact @id(1) @name("mirror_session_id"); + } + actions = { + @proto_id(1) mirror_session_lookup_mirror_as_ipv4_erspan_0(); + @proto_id(2) mirror_session_lookup_mirror_with_vlan_tag_and_ipfix_encapsulation_0(); + @defaultonly NoAction_16(); + } + const default_action = NoAction_16(); + size = 4; + } + @id(0x0100001C) @name("ingress.ingress_cloning.ingress_clone") action ingress_cloning_ingress_clone_0(@id(1) @name("clone_session") bit<32> clone_session) { + clone_preserving_field_list(CloneType.I2E, clone_session, 8w1); + } + @unsupported @p4runtime_role("packet_replication_engine_manager") @id(0x02000051) @entry_restriction(" + // mirror_egress_port is present iff marked_to_mirror is true. + // Exact match indicating presence of mirror_egress_port. + marked_to_mirror == 1 -> mirror_egress_port::mask == -1; + // Wildcard match indicating abscence of mirror_egress_port. + marked_to_mirror == 0 -> mirror_egress_port::mask == 0; + ") @name("ingress.ingress_cloning.ingress_clone_table") table ingress_cloning_ingress_clone_table { + key = { + local_metadata._marked_to_copy18 : exact @id(1) @name("marked_to_copy"); + local_metadata._marked_to_mirror19 : exact @id(2) @name("marked_to_mirror"); + local_metadata._mirror_egress_port21: optional @id(3) @name("mirror_egress_port"); + } + actions = { + @proto_id(1) ingress_cloning_ingress_clone_0(); + @defaultonly NoAction_17(); + } + default_action = NoAction_17(); + } + @hidden action pins_fabric420() { + standard_metadata.egress_spec = (bit<9>)headers.packet_out_header.egress_port; + local_metadata._bypass_ingress36 = true; + } + @hidden action pins_fabric855() { + local_metadata._vlan_id1 = headers.vlan.vlan_id; + headers.ethernet.ether_type = headers.vlan.ether_type; + headers.vlan.setInvalid(); } - @hidden action pins_fabric798() { + @hidden action pins_fabric859() { + local_metadata._vlan_id1 = 12w0xfff; + } + @hidden action pins_fabric846() { + local_metadata._enable_vlan_checks0 = true; + key_0 = 1w1; + } + @hidden action pins_fabric1546() { acl_pre_ingress_dscp = headers.ipv4.dscp; + acl_pre_ingress_ecn = headers.ipv4.ecn; } - @hidden action pins_fabric800() { + @hidden action pins_fabric1550() { acl_pre_ingress_dscp = headers.ipv6.dscp; + acl_pre_ingress_ecn = headers.ipv6.ecn; } - @hidden action pins_fabric755() { + @hidden action pins_fabric1425() { acl_pre_ingress_dscp = 6w0; + acl_pre_ingress_ecn = 2w0; + } + @hidden action pins_fabric1465() { + key_1 = headers.ipv4.isValid() || headers.ipv6.isValid(); + } + @hidden action pins_fabric869() { + mark_to_drop(standard_metadata); + } + @hidden action pins_fabric1005() { + headers.ethernet.ether_type = 16w0x800; + headers.ipv4 = headers.inner_ipv4; + headers.inner_ipv4.setInvalid(); + } + @hidden action pins_fabric1001() { + assert(headers.ipv6.isValid()); + assert(headers.inner_ipv4.isValid() && !headers.inner_ipv6.isValid() || !headers.inner_ipv4.isValid() && headers.inner_ipv6.isValid()); + headers.ipv6.setInvalid(); + } + @hidden action pins_fabric1010() { + headers.ethernet.ether_type = 16w0x86dd; + headers.ipv6 = headers.inner_ipv6; + headers.inner_ipv6.setInvalid(); } - @hidden action pins_fabric778() { - local_metadata._vrf_id1 = 10w0; - key_0 = headers.ipv4.isValid() || headers.ipv6.isValid(); + @hidden action pins_fabric797() { + local_metadata._admit_to_l32 = false; } - @hidden action pins_fabric809() { - local_metadata._admit_to_l30 = headers.ethernet.dst_addr & 48w0x10000000000 == 48w0; + @hidden action pins_fabric1560() { + local_metadata._admit_to_l32 = headers.ethernet.dst_addr == 48w0x1a11175f80; } - @hidden action pins_fabric262() { - routing_wcmp_group_id_valid = false; - routing_nexthop_id_valid = false; - routing_router_interface_id_valid = false; - routing_neighbor_id_valid = false; + @hidden action pins_fabric530() { mark_to_drop(standard_metadata); } - @hidden action pins_fabric740() { + @hidden action pins_fabric536() { + local_metadata._ipmc_table_hit41 = standard_metadata.mcast_grp != 16w0; + } + @hidden action pins_fabric540() { + local_metadata._ipmc_table_hit41 = standard_metadata.mcast_grp != 16w0; + } + @hidden action pins_fabric1405() { acl_ingress_ttl = headers.ipv4.ttl; acl_ingress_dscp = headers.ipv4.dscp; acl_ingress_ecn = headers.ipv4.ecn; acl_ingress_ip_protocol = headers.ipv4.protocol; } - @hidden action pins_fabric745() { + @hidden action pins_fabric1410() { acl_ingress_ttl = headers.ipv6.hop_limit; acl_ingress_dscp = headers.ipv6.dscp; acl_ingress_ecn = headers.ipv6.ecn; acl_ingress_ip_protocol = headers.ipv6.next_header; } - @hidden action pins_fabric645() { + @hidden action pins_fabric1117() { acl_ingress_ttl = 8w0; acl_ingress_dscp = 6w0; acl_ingress_ecn = 2w0; acl_ingress_ip_protocol = 8w0; } - @hidden action pins_fabric704() { - key_2 = headers.ipv4.isValid() || headers.ipv6.isValid(); + @hidden action pins_fabric1202() { + key_3 = headers.ipv4.isValid() || headers.ipv6.isValid(); + } + @hidden action pins_fabric1302() { + key_7 = headers.ipv4.isValid() || headers.ipv6.isValid(); } - @hidden action pins_fabric563() { + @hidden action pins_fabric1264() { + key_6 = headers.ipv4.isValid() || headers.ipv6.isValid(); + } + @hidden action pins_fabric547() { + routing_resolution_tunnel_id_valid = false; + routing_resolution_router_interface_id_valid = false; + routing_resolution_neighbor_id_valid = false; + } + @hidden action pins_fabric674() { mark_to_drop(standard_metadata); } - @hidden action pins_fabric565() { - headers.ipv4.ttl = headers.ipv4.ttl + 8w255; + @hidden action pins_fabric671() { + local_metadata._packet_in_target_egress_port31 = standard_metadata.egress_spec; + local_metadata._packet_in_ingress_port30 = standard_metadata.ingress_port; } - @hidden action pins_fabric570() { + @hidden action pins_fabric913() { mark_to_drop(standard_metadata); } - @hidden action pins_fabric572() { - headers.ipv6.hop_limit = headers.ipv6.hop_limit + 8w255; + @hidden action pins_fabric423() { + headers.packet_out_header.setInvalid(); } - @hidden action pins_fabric530() { - clone_preserving_field_list(CloneType.I2E, mirroring_clone_pre_session, 8w1); + @hidden table tbl_pins_fabric420 { + actions = { + pins_fabric420(); + } + const default_action = pins_fabric420(); + } + @hidden table tbl_pins_fabric423 { + actions = { + pins_fabric423(); + } + const default_action = pins_fabric423(); } - @hidden table tbl_pins_fabric755 { + @hidden table tbl_pins_fabric855 { actions = { - pins_fabric755(); + pins_fabric855(); } - const default_action = pins_fabric755(); + const default_action = pins_fabric855(); } - @hidden table tbl_pins_fabric798 { + @hidden table tbl_pins_fabric859 { actions = { - pins_fabric798(); + pins_fabric859(); } - const default_action = pins_fabric798(); + const default_action = pins_fabric859(); } - @hidden table tbl_pins_fabric800 { + @hidden table tbl_pins_fabric846 { actions = { - pins_fabric800(); + pins_fabric846(); } - const default_action = pins_fabric800(); + const default_action = pins_fabric846(); } - @hidden table tbl_pins_fabric778 { + @hidden table tbl_pins_fabric1425 { actions = { - pins_fabric778(); + pins_fabric1425(); } - const default_action = pins_fabric778(); + const default_action = pins_fabric1425(); } - @hidden table tbl_pins_fabric809 { + @hidden table tbl_pins_fabric1546 { actions = { - pins_fabric809(); + pins_fabric1546(); } - const default_action = pins_fabric809(); + const default_action = pins_fabric1546(); } - @hidden table tbl_pins_fabric262 { + @hidden table tbl_pins_fabric1550 { actions = { - pins_fabric262(); + pins_fabric1550(); } - const default_action = pins_fabric262(); + const default_action = pins_fabric1550(); } - @hidden table tbl_pins_fabric645 { + @hidden table tbl_pins_fabric1465 { actions = { - pins_fabric645(); + pins_fabric1465(); } - const default_action = pins_fabric645(); + const default_action = pins_fabric1465(); } - @hidden table tbl_pins_fabric740 { + @hidden table tbl_pins_fabric869 { actions = { - pins_fabric740(); + pins_fabric869(); } - const default_action = pins_fabric740(); + const default_action = pins_fabric869(); } - @hidden table tbl_pins_fabric745 { + @hidden table tbl_pins_fabric1001 { actions = { - pins_fabric745(); + pins_fabric1001(); } - const default_action = pins_fabric745(); + const default_action = pins_fabric1001(); } - @hidden table tbl_pins_fabric704 { + @hidden table tbl_pins_fabric1005 { actions = { - pins_fabric704(); + pins_fabric1005(); } - const default_action = pins_fabric704(); + const default_action = pins_fabric1005(); } - @hidden table tbl_pins_fabric563 { + @hidden table tbl_pins_fabric1010 { actions = { - pins_fabric563(); + pins_fabric1010(); } - const default_action = pins_fabric563(); + const default_action = pins_fabric1010(); } - @hidden table tbl_pins_fabric565 { + @hidden table tbl_pins_fabric1560 { actions = { - pins_fabric565(); + pins_fabric1560(); } - const default_action = pins_fabric565(); + const default_action = pins_fabric1560(); } - @hidden table tbl_pins_fabric570 { + @hidden table tbl_pins_fabric797 { actions = { - pins_fabric570(); + pins_fabric797(); } - const default_action = pins_fabric570(); + const default_action = pins_fabric797(); } - @hidden table tbl_pins_fabric572 { + @hidden table tbl_hashing_select_ecmp_hash_algorithm { actions = { - pins_fabric572(); + hashing_select_ecmp_hash_algorithm_0(); } - const default_action = pins_fabric572(); + const default_action = hashing_select_ecmp_hash_algorithm_0(); + } + @hidden table tbl_hashing_compute_ecmp_hash_ipv4 { + actions = { + hashing_compute_ecmp_hash_ipv4_0(); + } + const default_action = hashing_compute_ecmp_hash_ipv4_0(); + } + @hidden table tbl_hashing_compute_ecmp_hash_ipv6 { + actions = { + hashing_compute_ecmp_hash_ipv6_0(); + } + const default_action = hashing_compute_ecmp_hash_ipv6_0(); + } + @hidden table tbl_lag_hashing_config_select_lag_hash_algorithm { + actions = { + lag_hashing_config_select_lag_hash_algorithm_0(); + } + const default_action = lag_hashing_config_select_lag_hash_algorithm_0(); + } + @hidden table tbl_lag_hashing_config_compute_lag_hash_ipv4 { + actions = { + lag_hashing_config_compute_lag_hash_ipv4_0(); + } + const default_action = lag_hashing_config_compute_lag_hash_ipv4_0(); + } + @hidden table tbl_lag_hashing_config_compute_lag_hash_ipv6 { + actions = { + lag_hashing_config_compute_lag_hash_ipv6_0(); + } + const default_action = lag_hashing_config_compute_lag_hash_ipv6_0(); } @hidden table tbl_pins_fabric530 { actions = { @@ -861,66 +1367,188 @@ control ingress(inout headers_t headers, inout local_metadata_t local_metadata, } const default_action = pins_fabric530(); } + @hidden table tbl_pins_fabric536 { + actions = { + pins_fabric536(); + } + const default_action = pins_fabric536(); + } + @hidden table tbl_pins_fabric540 { + actions = { + pins_fabric540(); + } + const default_action = pins_fabric540(); + } + @hidden table tbl_pins_fabric1117 { + actions = { + pins_fabric1117(); + } + const default_action = pins_fabric1117(); + } + @hidden table tbl_pins_fabric1405 { + actions = { + pins_fabric1405(); + } + const default_action = pins_fabric1405(); + } + @hidden table tbl_pins_fabric1410 { + actions = { + pins_fabric1410(); + } + const default_action = pins_fabric1410(); + } + @hidden table tbl_pins_fabric1202 { + actions = { + pins_fabric1202(); + } + const default_action = pins_fabric1202(); + } + @hidden table tbl_pins_fabric1302 { + actions = { + pins_fabric1302(); + } + const default_action = pins_fabric1302(); + } + @hidden table tbl_pins_fabric1264 { + actions = { + pins_fabric1264(); + } + const default_action = pins_fabric1264(); + } + @hidden table tbl_pins_fabric547 { + actions = { + pins_fabric547(); + } + const default_action = pins_fabric547(); + } + @hidden table tbl_pins_fabric671 { + actions = { + pins_fabric671(); + } + const default_action = pins_fabric671(); + } + @hidden table tbl_pins_fabric674 { + actions = { + pins_fabric674(); + } + const default_action = pins_fabric674(); + } + @hidden table tbl_pins_fabric913 { + actions = { + pins_fabric913(); + } + const default_action = pins_fabric913(); + } apply { - tbl_pins_fabric755.apply(); - if (headers.ipv4.isValid()) { - tbl_pins_fabric798.apply(); - } else if (headers.ipv6.isValid()) { - tbl_pins_fabric800.apply(); - } - tbl_pins_fabric778.apply(); - acl_pre_ingress_acl_pre_ingress_table.apply(); - tbl_pins_fabric809.apply(); - l3_admit_l3_admit_table.apply(); - tbl_pins_fabric262.apply(); - routing_vrf_table.apply(); - if (local_metadata._admit_to_l30) { + if (headers.packet_out_header.isValid() && headers.packet_out_header.submit_to_ingress == 1w0) { + tbl_pins_fabric420.apply(); + } + tbl_pins_fabric423.apply(); + if (local_metadata._bypass_ingress36) { + ; + } else { + if (headers.ipv6.isValid()) { + if (headers.ipv6.next_header == 8w0x4 || headers.ipv6.next_header == 8w0x29) { + tunnel_termination_lookup_ipv6_tunnel_termination_table.apply(); + } + } + if (headers.vlan.isValid()) { + tbl_pins_fabric855.apply(); + } else { + tbl_pins_fabric859.apply(); + } + tbl_pins_fabric846.apply(); + vlan_untag_disable_vlan_checks_table.apply(); + tbl_pins_fabric1425.apply(); if (headers.ipv4.isValid()) { - routing_ipv4_table.apply(); + tbl_pins_fabric1546.apply(); } else if (headers.ipv6.isValid()) { - routing_ipv6_table.apply(); + tbl_pins_fabric1550.apply(); } - if (routing_wcmp_group_id_valid) { - routing_wcmp_group_table.apply(); + tbl_pins_fabric1465.apply(); + acl_pre_ingress_acl_pre_ingress_table.apply(); + if (local_metadata._enable_vlan_checks0 && !(local_metadata._vlan_id1 == 12w0x0 || local_metadata._vlan_id1 == 12w0xfff)) { + tbl_pins_fabric869.apply(); } - if (routing_nexthop_id_valid) { - routing_nexthop_table.apply(); - if (routing_router_interface_id_valid && routing_neighbor_id_valid) { - routing_router_interface_table.apply(); - routing_neighbor_table.apply(); + if (local_metadata._apply_tunnel_decap_at_end_of_pre_ingress14) { + tbl_pins_fabric1001.apply(); + if (headers.inner_ipv4.isValid()) { + tbl_pins_fabric1005.apply(); + } + if (headers.inner_ipv6.isValid()) { + tbl_pins_fabric1010.apply(); } } - } - tbl_pins_fabric645.apply(); - if (headers.ipv4.isValid()) { - tbl_pins_fabric740.apply(); - } else if (headers.ipv6.isValid()) { - tbl_pins_fabric745.apply(); - } - tbl_pins_fabric704.apply(); - acl_ingress_acl_ingress_table.apply(); - if (local_metadata._admit_to_l30) { + tbl_pins_fabric1560.apply(); + if (local_metadata._enable_vlan_checks0 && !(local_metadata._vlan_id1 == 12w0x0 || local_metadata._vlan_id1 == 12w0xfff)) { + tbl_pins_fabric797.apply(); + } else { + l3_admit_l3_admit_table.apply(); + } + tbl_hashing_select_ecmp_hash_algorithm.apply(); if (headers.ipv4.isValid()) { - if (headers.ipv4.ttl <= 8w1) { - tbl_pins_fabric563.apply(); - } else { - tbl_pins_fabric565.apply(); - } + tbl_hashing_compute_ecmp_hash_ipv4.apply(); + } else if (headers.ipv6.isValid()) { + tbl_hashing_compute_ecmp_hash_ipv6.apply(); } - if (headers.ipv6.isValid()) { - if (headers.ipv6.hop_limit <= 8w1) { - tbl_pins_fabric570.apply(); - } else { - tbl_pins_fabric572.apply(); + tbl_lag_hashing_config_select_lag_hash_algorithm.apply(); + if (headers.ipv4.isValid()) { + tbl_lag_hashing_config_compute_lag_hash_ipv4.apply(); + } else if (headers.ipv6.isValid()) { + tbl_lag_hashing_config_compute_lag_hash_ipv6.apply(); + } + tbl_pins_fabric530.apply(); + routing_lookup_vrf_table.apply(); + if (local_metadata._admit_to_l32) { + if (headers.ipv4.isValid()) { + routing_lookup_ipv4_table.apply(); + routing_lookup_ipv4_multicast_table.apply(); + tbl_pins_fabric536.apply(); + } else if (headers.ipv6.isValid()) { + routing_lookup_ipv6_table.apply(); + routing_lookup_ipv6_multicast_table.apply(); + tbl_pins_fabric540.apply(); } } - } - if (local_metadata._mirror_session_id_valid10) { - if (mirroring_clone_mirror_session_table.apply().hit) { - if (mirroring_clone_mirror_port_to_pre_session_table.apply().hit) { - tbl_pins_fabric530.apply(); + tbl_pins_fabric1117.apply(); + if (headers.ipv4.isValid()) { + tbl_pins_fabric1405.apply(); + } else if (headers.ipv6.isValid()) { + tbl_pins_fabric1410.apply(); + } + tbl_pins_fabric1202.apply(); + acl_ingress_acl_ingress_table.apply(); + tbl_pins_fabric1302.apply(); + acl_ingress_acl_ingress_counting_table.apply(); + tbl_pins_fabric1264.apply(); + acl_ingress_acl_ingress_qos_table.apply(); + tbl_pins_fabric547.apply(); + if (local_metadata._admit_to_l32) { + if (local_metadata._wcmp_group_id_valid37) { + routing_resolution_wcmp_group_table.apply(); + } + if (local_metadata._nexthop_id_valid39) { + routing_resolution_nexthop_table.apply(); + if (routing_resolution_tunnel_id_valid) { + routing_resolution_tunnel_table.apply(); + } + if (routing_resolution_router_interface_id_valid && routing_resolution_neighbor_id_valid) { + routing_resolution_router_interface_table.apply(); + routing_resolution_neighbor_table.apply(); + } } } + tbl_pins_fabric671.apply(); + if (local_metadata._acl_drop42) { + tbl_pins_fabric674.apply(); + } + if (local_metadata._marked_to_mirror19) { + mirror_session_lookup_mirror_session_table.apply(); + } + ingress_cloning_ingress_clone_table.apply(); + if (headers.ipv6.isValid() && (headers.ipv6.src_addr & 128w0xff000000000000000000000000000000 == 128w0xff000000000000000000000000000000 || headers.ipv6.dst_addr & 128w0xff000000000000000000000000000000 == 128w0xff000000000000000000000000000000 || headers.ipv6.src_addr == 128w0x1 || headers.ipv6.dst_addr == 128w0x1) || headers.ipv4.isValid() && (headers.ipv4.src_addr & 32w0xf0000000 == 32w0xe0000000 || headers.ipv4.src_addr == 32w0xffffffff || (headers.ipv4.dst_addr & 32w0xf0000000 == 32w0xe0000000 || headers.ipv4.dst_addr == 32w0xffffffff) || headers.ipv4.src_addr & 32w0xff000000 == 32w0x7f000000 || headers.ipv4.dst_addr & 32w0xff000000 == 32w0x7f000000) || headers.ethernet.isValid() && headers.ethernet.dst_addr & 48w0x10000000000 == 48w0x10000000000) { + tbl_pins_fabric913.apply(); + } } } } @@ -928,55 +1556,47 @@ control ingress(inout headers_t headers, inout local_metadata_t local_metadata, control egress(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { @name("egress.acl_egress.dscp") bit<6> acl_egress_dscp; @name("egress.acl_egress.ip_protocol") bit<8> acl_egress_ip_protocol; - @name("egress.standard_metadata") standard_metadata_t standard_metadata_3; - bool key_5; - @id(0x01000109) @sai_action(SAI_PACKET_ACTION_DROP) @name(".acl_drop") action acl_drop_2() { - standard_metadata_3.ingress_port = standard_metadata.ingress_port; - standard_metadata_3.egress_spec = standard_metadata.egress_spec; - standard_metadata_3.egress_port = standard_metadata.egress_port; - standard_metadata_3.instance_type = standard_metadata.instance_type; - standard_metadata_3.packet_length = standard_metadata.packet_length; - standard_metadata_3.enq_timestamp = standard_metadata.enq_timestamp; - standard_metadata_3.enq_qdepth = standard_metadata.enq_qdepth; - standard_metadata_3.deq_timedelta = standard_metadata.deq_timedelta; - standard_metadata_3.deq_qdepth = standard_metadata.deq_qdepth; - standard_metadata_3.ingress_global_timestamp = standard_metadata.ingress_global_timestamp; - standard_metadata_3.egress_global_timestamp = standard_metadata.egress_global_timestamp; - standard_metadata_3.mcast_grp = standard_metadata.mcast_grp; - standard_metadata_3.egress_rid = standard_metadata.egress_rid; - standard_metadata_3.checksum_error = standard_metadata.checksum_error; - standard_metadata_3.parser_error = standard_metadata.parser_error; - standard_metadata_3.priority = standard_metadata.priority; - mark_to_drop(standard_metadata_3); - standard_metadata.ingress_port = standard_metadata_3.ingress_port; - standard_metadata.egress_spec = standard_metadata_3.egress_spec; - standard_metadata.egress_port = standard_metadata_3.egress_port; - standard_metadata.instance_type = standard_metadata_3.instance_type; - standard_metadata.packet_length = standard_metadata_3.packet_length; - standard_metadata.enq_timestamp = standard_metadata_3.enq_timestamp; - standard_metadata.enq_qdepth = standard_metadata_3.enq_qdepth; - standard_metadata.deq_timedelta = standard_metadata_3.deq_timedelta; - standard_metadata.deq_qdepth = standard_metadata_3.deq_qdepth; - standard_metadata.ingress_global_timestamp = standard_metadata_3.ingress_global_timestamp; - standard_metadata.egress_global_timestamp = standard_metadata_3.egress_global_timestamp; - standard_metadata.mcast_grp = standard_metadata_3.mcast_grp; - standard_metadata.egress_rid = standard_metadata_3.egress_rid; - standard_metadata.checksum_error = standard_metadata_3.checksum_error; - standard_metadata.parser_error = standard_metadata_3.parser_error; - standard_metadata.priority = standard_metadata_3.priority; + bool key_8; + @noWarn("unused") @name(".NoAction") action NoAction_18() { } - @noWarn("unused") @name(".NoAction") action NoAction_11() { + @noWarn("unused") @name(".NoAction") action NoAction_19() { + } + @id(0x01000109) @sai_action(SAI_PACKET_ACTION_DROP) @name(".acl_drop") action acl_drop_4() { + local_metadata._acl_drop42 = true; + } + @id(0x01000019) @name("egress.packet_rewrites.multicast_rewrites.set_multicast_src_mac") action packet_rewrites_multicast_rewrites_set_multicast_src_mac_0(@id(1) @format(MAC_ADDRESS) @name("src_mac") bit<48> src_mac_7) { + local_metadata._enable_src_mac_rewrite5 = true; + local_metadata._packet_rewrites_src_mac8 = src_mac_7; + } + @p4runtime_role("sdn_controller") @id(0x0200004C) @name("egress.packet_rewrites.multicast_rewrites.multicast_router_interface_table") table packet_rewrites_multicast_rewrites_multicast_router_interface_table { + key = { + standard_metadata.egress_port: exact @referenced_by(builtin : : multicast_group_table , replica . port) @id(1) @name("multicast_replica_port"); + standard_metadata.egress_rid : exact @referenced_by(builtin : : multicast_group_table , replica . instance) @id(2) @name("multicast_replica_instance"); + } + actions = { + @proto_id(1) packet_rewrites_multicast_rewrites_set_multicast_src_mac_0(); + @defaultonly NoAction_18(); + } + size = 110; + default_action = NoAction_18(); } @id(0x13000104) @name("egress.acl_egress.acl_egress_counter") direct_counter(CounterType.packets_and_bytes) acl_egress_acl_egress_counter; + @id(0x13000108) @name("egress.acl_egress.acl_egress_dhcp_to_host_counter") direct_counter(CounterType.packets_and_bytes) acl_egress_acl_egress_dhcp_to_host_counter; @p4runtime_role("sdn_controller") @id(0x02000104) @sai_acl(EGRESS) @entry_restriction(" + // Forbid using ether_type for IP packets (by convention, use is_ip* instead). ether_type != 0x0800 && ether_type != 0x86dd; dscp::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + // Only allow IP field matches for IP packets. - // TODO: Enable once p4-constraints bug is fixed. - // ip_protocol::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + ip_protocol::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + + + + // Only allow l4_dst_port matches for TCP/UDP packets. l4_dst_port::mask != 0 -> (ip_protocol == 6 || ip_protocol == 17); + // Forbid illegal combinations of IP_TYPE fields. is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0); is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0); @@ -986,137 +1606,331 @@ control egress(inout headers_t headers, inout local_metadata_t local_metadata, i is_ipv6::mask != 0 -> (is_ipv6 == 1); ") @name("egress.acl_egress.acl_egress_table") table acl_egress_acl_egress_table { key = { - headers.ethernet.ether_type : ternary @name("ether_type") @id(1) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ETHER_TYPE); - acl_egress_ip_protocol : ternary @name("ip_protocol") @id(2) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IP_PROTOCOL); - local_metadata._l4_dst_port5 : ternary @name("l4_dst_port") @id(3) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_L4_DST_PORT); - standard_metadata.egress_port: optional @name("out_port") @id(4) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_OUT_PORT); - key_5 : optional @name("is_ip") @id(5) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); - headers.ipv4.isValid() : optional @name("is_ipv4") @id(6) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); - headers.ipv6.isValid() : optional @name("is_ipv6") @id(7) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); - acl_egress_dscp : ternary @name("dscp") @id(8) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DSCP); + headers.ethernet.ether_type : ternary @id(1) @name("ether_type") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ETHER_TYPE); + acl_egress_ip_protocol : ternary @id(2) @name("ip_protocol") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IP_PROTOCOL); + local_metadata._l4_dst_port12: ternary @id(3) @name("l4_dst_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_L4_DST_PORT); + standard_metadata.egress_port: optional @id(4) @name("out_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_OUT_PORT); + key_8 : optional @id(5) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(6) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(7) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + acl_egress_dscp : ternary @id(8) @name("dscp") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DSCP); } actions = { - @proto_id(1) acl_drop_2(); - @defaultonly NoAction_11(); + @proto_id(1) acl_drop_4(); + @defaultonly NoAction_19(); } - const default_action = NoAction_11(); + const default_action = NoAction_19(); counters = acl_egress_acl_egress_counter; - size = 128; - } - @hidden action pins_fabric582() { - headers.ethernet.src_addr = local_metadata._packet_rewrites_src_mac2; - headers.ethernet.dst_addr = local_metadata._packet_rewrites_dst_mac3; - } - @hidden action pins_fabric455() { - headers.erspan_ethernet.setValid(); - headers.erspan_ethernet.src_addr = local_metadata._mirroring_src_mac14; - headers.erspan_ethernet.dst_addr = local_metadata._mirroring_dst_mac15; - headers.erspan_ethernet.ether_type = 16w0x800; - headers.erspan_ipv4.setValid(); - headers.erspan_ipv4.src_addr = local_metadata._mirroring_src_ip12; - headers.erspan_ipv4.dst_addr = local_metadata._mirroring_dst_ip13; - headers.erspan_ipv4.version = 4w4; - headers.erspan_ipv4.ihl = 4w5; - headers.erspan_ipv4.protocol = 8w0x2f; - headers.erspan_ipv4.ttl = local_metadata._mirroring_ttl16; - headers.erspan_ipv4.dscp = local_metadata._mirroring_tos17[7:2]; - headers.erspan_ipv4.ecn = local_metadata._mirroring_tos17[1:0]; - headers.erspan_ipv4.total_len = 16w24 + (bit<16>)standard_metadata.packet_length; - headers.erspan_ipv4.identification = 16w0; - headers.erspan_ipv4.reserved = 1w0; - headers.erspan_ipv4.do_not_fragment = 1w1; - headers.erspan_ipv4.more_fragments = 1w0; - headers.erspan_ipv4.frag_offset = 13w0; - headers.erspan_ipv4.header_checksum = 16w0; - headers.erspan_gre.setValid(); - headers.erspan_gre.checksum_present = 1w0; - headers.erspan_gre.routing_present = 1w0; - headers.erspan_gre.key_present = 1w0; - headers.erspan_gre.sequence_present = 1w0; - headers.erspan_gre.strict_source_route = 1w0; - headers.erspan_gre.recursion_control = 3w0; - headers.erspan_gre.acknowledgement_present = 1w0; - headers.erspan_gre.flags = 4w0; - headers.erspan_gre.version = 3w0; - headers.erspan_gre.protocol = 16w0x88be; - } - @hidden action pins_fabric632() { + size = 127; + } + @hidden action pins_fabric943() { + local_metadata._enable_decrement_ttl4 = true; + } + @hidden action pins_fabric947() { + headers.ethernet.src_addr = local_metadata._packet_rewrites_src_mac8; + } + @hidden action pins_fabric950() { + headers.ethernet.dst_addr = local_metadata._packet_rewrites_dst_mac9; + } + @hidden action pins_fabric953() { + local_metadata._vlan_id1 = local_metadata._packet_rewrites_vlan_id10; + } + @hidden action pins_fabric957() { + headers.ipv4.ttl = headers.ipv4.ttl + 8w255; + } + @hidden action pins_fabric960() { + mark_to_drop(standard_metadata); + } + @hidden action pins_fabric965() { + headers.ipv6.hop_limit = headers.ipv6.hop_limit + 8w255; + } + @hidden action pins_fabric968() { + mark_to_drop(standard_metadata); + } + @hidden action pins_fabric825() { + headers.tunnel_encap_ipv6.dscp = headers.ipv4.dscp; + headers.tunnel_encap_ipv6.ecn = headers.ipv4.ecn; + headers.tunnel_encap_ipv6.hop_limit = headers.ipv4.ttl; + } + @hidden action pins_fabric829() { + headers.tunnel_encap_ipv6.dscp = headers.ipv6.dscp; + headers.tunnel_encap_ipv6.ecn = headers.ipv6.ecn; + headers.tunnel_encap_ipv6.hop_limit = headers.ipv6.hop_limit; + } + @hidden action pins_fabric807() { + headers.tunnel_encap_gre.setValid(); + headers.tunnel_encap_gre.checksum_present = 1w0; + headers.tunnel_encap_gre.routing_present = 1w0; + headers.tunnel_encap_gre.key_present = 1w0; + headers.tunnel_encap_gre.sequence_present = 1w0; + headers.tunnel_encap_gre.strict_source_route = 1w0; + headers.tunnel_encap_gre.recursion_control = 3w0; + headers.tunnel_encap_gre.flags = 4w0; + headers.tunnel_encap_gre.version = 3w0; + headers.tunnel_encap_gre.protocol = headers.ethernet.ether_type; + headers.ethernet.ether_type = 16w0x86dd; + headers.tunnel_encap_ipv6.setValid(); + headers.tunnel_encap_ipv6.version = 4w6; + headers.tunnel_encap_ipv6.src_addr = local_metadata._tunnel_encap_src_ipv616; + headers.tunnel_encap_ipv6.dst_addr = local_metadata._tunnel_encap_dst_ipv617; + headers.tunnel_encap_ipv6.payload_length = (bit<16>)standard_metadata.packet_length + 16w65526; + headers.tunnel_encap_ipv6.next_header = 8w0x2f; + } + @hidden action pins_fabric751() { + headers.mirror_encap_ethernet.setValid(); + headers.mirror_encap_ethernet.src_addr = local_metadata._mirror_encap_src_mac22; + headers.mirror_encap_ethernet.dst_addr = local_metadata._mirror_encap_dst_mac23; + headers.mirror_encap_ethernet.ether_type = 16w0x8100; + headers.mirror_encap_vlan.setValid(); + headers.mirror_encap_vlan.ether_type = 16w0x86dd; + headers.mirror_encap_vlan.vlan_id = local_metadata._mirror_encap_vlan_id24; + headers.mirror_encap_ipv6.setValid(); + headers.mirror_encap_ipv6.version = 4w6; + headers.mirror_encap_ipv6.dscp = 6w0; + headers.mirror_encap_ipv6.ecn = 2w0; + headers.mirror_encap_ipv6.hop_limit = 8w16; + headers.mirror_encap_ipv6.flow_label = 20w0; + headers.mirror_encap_ipv6.payload_length = (bit<16>)standard_metadata.packet_length + 16w52; + headers.mirror_encap_ipv6.next_header = 8w0x11; + headers.mirror_encap_ipv6.src_addr = local_metadata._mirror_encap_src_ip25; + headers.mirror_encap_ipv6.dst_addr = local_metadata._mirror_encap_dst_ip26; + headers.mirror_encap_udp.setValid(); + headers.mirror_encap_udp.src_port = local_metadata._mirror_encap_udp_src_port27; + headers.mirror_encap_udp.dst_port = local_metadata._mirror_encap_udp_dst_port28; + headers.mirror_encap_udp.hdr_length = (bit<16>)standard_metadata.packet_length + 16w52; + headers.mirror_encap_udp.checksum = 16w0; + headers.ipfix.setValid(); + headers.psamp_extended.setValid(); + } + @hidden action pins_fabric878() { + mark_to_drop(standard_metadata); + } + @hidden action pins_fabric880() { + mark_to_drop(standard_metadata); + } + @hidden action pins_fabric889() { + headers.vlan.setValid(); + headers.vlan.priority_code_point = 3w0; + headers.vlan.drop_eligible_indicator = 1w0; + headers.vlan.vlan_id = local_metadata._vlan_id1; + headers.vlan.ether_type = headers.ethernet.ether_type; + headers.ethernet.ether_type = 16w0x8100; + } + @hidden action pins_fabric1101() { acl_egress_dscp = headers.ipv4.dscp; acl_egress_ip_protocol = headers.ipv4.protocol; } - @hidden action pins_fabric635() { + @hidden action pins_fabric1104() { acl_egress_dscp = headers.ipv6.dscp; acl_egress_ip_protocol = headers.ipv6.next_header; } - @hidden action pins_fabric638() { + @hidden action pins_fabric1107() { acl_egress_ip_protocol = 8w0; } - @hidden action pins_fabric592() { + @hidden action pins_fabric1022() { acl_egress_dscp = 6w0; } - @hidden action pins_fabric617() { - key_5 = headers.ipv4.isValid() || headers.ipv6.isValid(); + @hidden action pins_fabric1057() { + key_8 = headers.ipv4.isValid() || headers.ipv6.isValid(); + } + @hidden action pins_fabric1111() { + mark_to_drop(standard_metadata); + } + @hidden table tbl_pins_fabric943 { + actions = { + pins_fabric943(); + } + const default_action = pins_fabric943(); } - @hidden table tbl_pins_fabric582 { + @hidden table tbl_pins_fabric947 { actions = { - pins_fabric582(); + pins_fabric947(); } - const default_action = pins_fabric582(); + const default_action = pins_fabric947(); } - @hidden table tbl_pins_fabric455 { + @hidden table tbl_pins_fabric950 { actions = { - pins_fabric455(); + pins_fabric950(); } - const default_action = pins_fabric455(); + const default_action = pins_fabric950(); } - @hidden table tbl_pins_fabric592 { + @hidden table tbl_pins_fabric953 { actions = { - pins_fabric592(); + pins_fabric953(); } - const default_action = pins_fabric592(); + const default_action = pins_fabric953(); } - @hidden table tbl_pins_fabric632 { + @hidden table tbl_pins_fabric957 { actions = { - pins_fabric632(); + pins_fabric957(); } - const default_action = pins_fabric632(); + const default_action = pins_fabric957(); } - @hidden table tbl_pins_fabric635 { + @hidden table tbl_pins_fabric960 { actions = { - pins_fabric635(); + pins_fabric960(); } - const default_action = pins_fabric635(); + const default_action = pins_fabric960(); } - @hidden table tbl_pins_fabric638 { + @hidden table tbl_pins_fabric965 { actions = { - pins_fabric638(); + pins_fabric965(); } - const default_action = pins_fabric638(); + const default_action = pins_fabric965(); } - @hidden table tbl_pins_fabric617 { + @hidden table tbl_pins_fabric968 { actions = { - pins_fabric617(); + pins_fabric968(); } - const default_action = pins_fabric617(); + const default_action = pins_fabric968(); } - apply { - if (local_metadata._admit_to_l30) { - tbl_pins_fabric582.apply(); + @hidden table tbl_pins_fabric807 { + actions = { + pins_fabric807(); + } + const default_action = pins_fabric807(); + } + @hidden table tbl_pins_fabric825 { + actions = { + pins_fabric825(); + } + const default_action = pins_fabric825(); + } + @hidden table tbl_pins_fabric829 { + actions = { + pins_fabric829(); } - if (standard_metadata.instance_type == 32w1) { - tbl_pins_fabric455.apply(); + const default_action = pins_fabric829(); + } + @hidden table tbl_pins_fabric751 { + actions = { + pins_fabric751(); + } + const default_action = pins_fabric751(); + } + @hidden table tbl_pins_fabric878 { + actions = { + pins_fabric878(); + } + const default_action = pins_fabric878(); + } + @hidden table tbl_pins_fabric880 { + actions = { + pins_fabric880(); + } + const default_action = pins_fabric880(); + } + @hidden table tbl_pins_fabric889 { + actions = { + pins_fabric889(); } - tbl_pins_fabric592.apply(); - if (headers.ipv4.isValid()) { - tbl_pins_fabric632.apply(); - } else if (headers.ipv6.isValid()) { - tbl_pins_fabric635.apply(); + const default_action = pins_fabric889(); + } + @hidden table tbl_pins_fabric1022 { + actions = { + pins_fabric1022(); + } + const default_action = pins_fabric1022(); + } + @hidden table tbl_pins_fabric1101 { + actions = { + pins_fabric1101(); + } + const default_action = pins_fabric1101(); + } + @hidden table tbl_pins_fabric1104 { + actions = { + pins_fabric1104(); + } + const default_action = pins_fabric1104(); + } + @hidden table tbl_pins_fabric1107 { + actions = { + pins_fabric1107(); + } + const default_action = pins_fabric1107(); + } + @hidden table tbl_pins_fabric1057 { + actions = { + pins_fabric1057(); + } + const default_action = pins_fabric1057(); + } + @hidden table tbl_pins_fabric1111 { + actions = { + pins_fabric1111(); + } + const default_action = pins_fabric1111(); + } + apply { + if (standard_metadata.instance_type == 32w1 && standard_metadata.egress_rid == 16w1) { + ; } else { - tbl_pins_fabric638.apply(); + if (standard_metadata.instance_type == 32w5) { + tbl_pins_fabric943.apply(); + packet_rewrites_multicast_rewrites_multicast_router_interface_table.apply(); + } + if (local_metadata._enable_src_mac_rewrite5) { + tbl_pins_fabric947.apply(); + } + if (local_metadata._enable_dst_mac_rewrite6) { + tbl_pins_fabric950.apply(); + } + if (local_metadata._enable_vlan_rewrite7) { + tbl_pins_fabric953.apply(); + } + if (headers.ipv4.isValid()) { + if (headers.ipv4.ttl > 8w0 && local_metadata._enable_decrement_ttl4) { + tbl_pins_fabric957.apply(); + } + if (headers.ipv4.ttl == 8w0) { + tbl_pins_fabric960.apply(); + } + } + if (headers.ipv6.isValid()) { + if (headers.ipv6.hop_limit > 8w0 && local_metadata._enable_decrement_ttl4) { + tbl_pins_fabric965.apply(); + } + if (headers.ipv6.hop_limit == 8w0) { + tbl_pins_fabric968.apply(); + } + } + if (local_metadata._apply_tunnel_encap_at_egress15) { + tbl_pins_fabric807.apply(); + if (headers.ipv4.isValid()) { + tbl_pins_fabric825.apply(); + } else if (headers.ipv6.isValid()) { + tbl_pins_fabric829.apply(); + } + } + if (standard_metadata.instance_type == 32w1 && standard_metadata.egress_rid == 16w2) { + tbl_pins_fabric751.apply(); + } + if (local_metadata._enable_vlan_checks0) { + if (standard_metadata.instance_type == 32w1 && standard_metadata.egress_rid == 16w2 && !(local_metadata._mirror_encap_vlan_id24 == 12w0x0 || local_metadata._mirror_encap_vlan_id24 == 12w0xfff)) { + tbl_pins_fabric878.apply(); + } else if (!(standard_metadata.instance_type == 32w1 && standard_metadata.egress_rid == 16w1) && !(local_metadata._vlan_id1 == 12w0x0 || local_metadata._vlan_id1 == 12w0xfff)) { + tbl_pins_fabric880.apply(); + } + } + if (!(local_metadata._vlan_id1 == 12w0x0 || local_metadata._vlan_id1 == 12w0xfff) && !(standard_metadata.instance_type == 32w1 && standard_metadata.egress_rid == 16w2)) { + tbl_pins_fabric889.apply(); + } + tbl_pins_fabric1022.apply(); + if (headers.ipv4.isValid()) { + tbl_pins_fabric1101.apply(); + } else if (headers.ipv6.isValid()) { + tbl_pins_fabric1104.apply(); + } else { + tbl_pins_fabric1107.apply(); + } + tbl_pins_fabric1057.apply(); + acl_egress_acl_egress_table.apply(); + if (local_metadata._acl_drop42) { + tbl_pins_fabric1111.apply(); + } } - tbl_pins_fabric617.apply(); - acl_egress_acl_egress_table.apply(); } } -@pkginfo(name="fabric_border_router.p4", organization="Google") V1Switch(packet_parser(), verify_ipv4_checksum(), ingress(), egress(), compute_ipv4_checksum(), packet_deparser()) main; +@pkginfo(name="fabric_border_router.p4", organization="Google", version="1.6.1") V1Switch(packet_parser(), verify_ipv4_checksum(), ingress(), egress(), compute_ipv4_checksum(), packet_deparser()) main; diff --git a/testdata/p4_16_samples_outputs/pins/pins_fabric.p4 b/testdata/p4_16_samples_outputs/pins/pins_fabric.p4 index b9dd63ab65..739bd90794 100644 --- a/testdata/p4_16_samples_outputs/pins/pins_fabric.p4 +++ b/testdata/p4_16_samples_outputs/pins/pins_fabric.p4 @@ -5,10 +5,21 @@ typedef bit<48> ethernet_addr_t; typedef bit<32> ipv4_addr_t; typedef bit<128> ipv6_addr_t; +typedef bit<12> vlan_id_t; +typedef bit<16> ether_type_t; +const vlan_id_t INTERNAL_VLAN_ID = 0xfff; +const vlan_id_t NO_VLAN_ID = 0x0; header ethernet_t { ethernet_addr_t dst_addr; ethernet_addr_t src_addr; - bit<16> ether_type; + ether_type_t ether_type; +} + +header vlan_t { + bit<3> priority_code_point; + bit<1> drop_eligible_indicator; + vlan_id_t vlan_id; + ether_type_t ether_type; } header ipv4_t { @@ -65,6 +76,7 @@ header icmp_t { bit<8> type; bit<8> code; bit<16> checksum; + bit<32> rest_of_header; } header arp_t { @@ -92,109 +104,211 @@ header gre_t { bit<16> protocol; } +header ipfix_t { + bit<16> version_number; + bit<16> length; + bit<32> export_time; + bit<32> sequence_number; + bit<32> observation_domain_id; +} + +header psamp_extended_t { + bit<16> template_id; + bit<16> length; + bit<64> observation_time; + bit<16> flowset; + bit<16> next_hop_index; + bit<16> epoch; + bit<16> ingress_port; + bit<16> egress_port; + bit<16> user_meta_field; + bit<8> dlb_id; + bit<8> variable_length; + bit<16> packet_sampled_length; +} + enum bit<8> PreservedFieldList { - CLONE_I2E = 8w1 + MIRROR_AND_PACKET_IN_COPY = 8w1, + RECIRCULATE = 8w2 } type bit<10> nexthop_id_t; type bit<10> tunnel_id_t; type bit<12> wcmp_group_id_t; -type bit<10> vrf_id_t; +@p4runtime_translation_mappings({ { "" , 0 } , }) type bit<10> vrf_id_t; const vrf_id_t kDefaultVrf = 0; type bit<10> router_interface_id_t; type bit<9> port_id_t; type bit<10> mirror_session_id_t; type bit<8> qos_queue_t; typedef bit<6> route_metadata_t; +typedef bit<8> acl_metadata_t; +typedef bit<16> multicast_group_id_t; +typedef bit<16> replica_instance_t; enum bit<2> MeterColor_t { GREEN = 0, YELLOW = 1, RED = 2 } +@controller_header("packet_in") header packet_in_header_t { + @id(1) + port_id_t ingress_port; + @id(2) + port_id_t target_egress_port; +} + +@controller_header("packet_out") header packet_out_header_t { + @id(1) + port_id_t egress_port; + @id(2) + bit<1> submit_to_ingress; + @id(3) @padding + bit<6> unused_pad; +} + struct headers_t { - ethernet_t erspan_ethernet; - ipv4_t erspan_ipv4; - gre_t erspan_gre; - ethernet_t ethernet; - ipv6_t tunnel_encap_ipv6; - gre_t tunnel_encap_gre; - ipv4_t ipv4; - ipv6_t ipv6; - icmp_t icmp; - tcp_t tcp; - udp_t udp; - arp_t arp; + packet_out_header_t packet_out_header; + ethernet_t mirror_encap_ethernet; + vlan_t mirror_encap_vlan; + ipv6_t mirror_encap_ipv6; + udp_t mirror_encap_udp; + ipfix_t ipfix; + psamp_extended_t psamp_extended; + ethernet_t ethernet; + vlan_t vlan; + ipv6_t tunnel_encap_ipv6; + gre_t tunnel_encap_gre; + ipv4_t ipv4; + ipv6_t ipv6; + ipv4_t inner_ipv4; + ipv6_t inner_ipv6; + icmp_t icmp; + tcp_t tcp; + udp_t udp; + arp_t arp; } struct packet_rewrites_t { ethernet_addr_t src_mac; ethernet_addr_t dst_mac; + vlan_id_t vlan_id; } struct local_metadata_t { + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + bool enable_vlan_checks; + vlan_id_t vlan_id; bool admit_to_l3; vrf_id_t vrf_id; + bool enable_decrement_ttl; + bool enable_src_mac_rewrite; + bool enable_dst_mac_rewrite; + bool enable_vlan_rewrite; packet_rewrites_t packet_rewrites; bit<16> l4_src_port; bit<16> l4_dst_port; - bit<16> wcmp_selector_input; + bit<8> wcmp_selector_input; + bool apply_tunnel_decap_at_end_of_pre_ingress; bool apply_tunnel_encap_at_egress; ipv6_addr_t tunnel_encap_src_ipv6; ipv6_addr_t tunnel_encap_dst_ipv6; - bool mirror_session_id_valid; - mirror_session_id_t mirror_session_id_value; - @field_list(PreservedFieldList.CLONE_I2E) - ipv4_addr_t mirroring_src_ip; - @field_list(PreservedFieldList.CLONE_I2E) - ipv4_addr_t mirroring_dst_ip; - @field_list(PreservedFieldList.CLONE_I2E) - ethernet_addr_t mirroring_src_mac; - @field_list(PreservedFieldList.CLONE_I2E) - ethernet_addr_t mirroring_dst_mac; - @field_list(PreservedFieldList.CLONE_I2E) - bit<8> mirroring_ttl; - @field_list(PreservedFieldList.CLONE_I2E) - bit<8> mirroring_tos; + bool marked_to_copy; + bool marked_to_mirror; + mirror_session_id_t mirror_session_id; + port_id_t mirror_egress_port; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + ethernet_addr_t mirror_encap_src_mac; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + ethernet_addr_t mirror_encap_dst_mac; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + vlan_id_t mirror_encap_vlan_id; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + ipv6_addr_t mirror_encap_src_ip; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + ipv6_addr_t mirror_encap_dst_ip; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + bit<16> mirror_encap_udp_src_port; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + bit<16> mirror_encap_udp_dst_port; + @field_list(PreservedFieldList.RECIRCULATE) + bit<9> loopback_port; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + bit<9> packet_in_ingress_port; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + bit<9> packet_in_target_egress_port; MeterColor_t color; port_id_t ingress_port; route_metadata_t route_metadata; -} - -@controller_header("packet_in") header packet_in_header_t { - @id(1) - port_id_t ingress_port; - @id(2) - port_id_t target_egress_port; -} - -@controller_header("packet_out") header packet_out_header_t { - @id(1) - port_id_t egress_port; - @id(2) - bit<1> submit_to_ingress; - @id(3) - bit<7> unused_pad; + acl_metadata_t acl_metadata; + bool bypass_ingress; + bool wcmp_group_id_valid; + wcmp_group_id_t wcmp_group_id_value; + bool nexthop_id_valid; + nexthop_id_t nexthop_id_value; + bool ipmc_table_hit; + bool acl_drop; } parser packet_parser(packet_in packet, out headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { state start { + local_metadata.enable_vlan_checks = false; + local_metadata.vlan_id = 0; local_metadata.admit_to_l3 = false; local_metadata.vrf_id = kDefaultVrf; + local_metadata.enable_decrement_ttl = false; + local_metadata.enable_src_mac_rewrite = false; + local_metadata.enable_dst_mac_rewrite = false; + local_metadata.enable_vlan_rewrite = false; local_metadata.packet_rewrites.src_mac = 0; local_metadata.packet_rewrites.dst_mac = 0; local_metadata.l4_src_port = 0; local_metadata.l4_dst_port = 0; local_metadata.wcmp_selector_input = 0; - local_metadata.mirror_session_id_valid = false; + local_metadata.apply_tunnel_decap_at_end_of_pre_ingress = false; + local_metadata.apply_tunnel_encap_at_egress = false; + local_metadata.tunnel_encap_src_ipv6 = 0; + local_metadata.tunnel_encap_dst_ipv6 = 0; + local_metadata.marked_to_copy = false; + local_metadata.marked_to_mirror = false; + local_metadata.mirror_session_id = 0; + local_metadata.mirror_egress_port = 0; local_metadata.color = MeterColor_t.GREEN; - local_metadata.ingress_port = (port_id_t)standard_metadata.ingress_port; local_metadata.route_metadata = 0; + local_metadata.bypass_ingress = false; + local_metadata.wcmp_group_id_valid = false; + local_metadata.wcmp_group_id_value = 0; + local_metadata.nexthop_id_valid = false; + local_metadata.nexthop_id_value = 0; + local_metadata.ipmc_table_hit = false; + local_metadata.acl_drop = false; + if (standard_metadata.instance_type == 4) { + local_metadata.ingress_port = (port_id_t)local_metadata.loopback_port; + } else { + local_metadata.ingress_port = (port_id_t)standard_metadata.ingress_port; + } + transition select(standard_metadata.ingress_port) { + 510: parse_packet_out_header; + default: parse_ethernet; + } + } + state parse_packet_out_header { + packet.extract(headers.packet_out_header); transition parse_ethernet; } state parse_ethernet { packet.extract(headers.ethernet); transition select(headers.ethernet.ether_type) { + 0x800: parse_ipv4; + 0x86dd: parse_ipv6; + 0x806: parse_arp; + 0x8100: parse_8021q_vlan; + default: accept; + } + } + state parse_8021q_vlan { + packet.extract(headers.vlan); + transition select(headers.vlan.ether_type) { 0x800: parse_ipv4; 0x86dd: parse_ipv6; 0x806: parse_arp; @@ -204,6 +318,17 @@ parser packet_parser(packet_in packet, out headers_t headers, inout local_metada state parse_ipv4 { packet.extract(headers.ipv4); transition select(headers.ipv4.protocol) { + 0x4: parse_ipv4_in_ip; + 0x29: parse_ipv6_in_ip; + 0x1: parse_icmp; + 0x6: parse_tcp; + 0x11: parse_udp; + default: accept; + } + } + state parse_ipv4_in_ip { + packet.extract(headers.inner_ipv4); + transition select(headers.inner_ipv4.protocol) { 0x1: parse_icmp; 0x6: parse_tcp; 0x11: parse_udp; @@ -213,6 +338,17 @@ parser packet_parser(packet_in packet, out headers_t headers, inout local_metada state parse_ipv6 { packet.extract(headers.ipv6); transition select(headers.ipv6.next_header) { + 0x4: parse_ipv4_in_ip; + 0x29: parse_ipv6_in_ip; + 0x3a: parse_icmp; + 0x6: parse_tcp; + 0x11: parse_udp; + default: accept; + } + } + state parse_ipv6_in_ip { + packet.extract(headers.inner_ipv6); + transition select(headers.inner_ipv6.next_header) { 0x3a: parse_icmp; 0x6: parse_tcp; 0x11: parse_udp; @@ -243,14 +379,21 @@ parser packet_parser(packet_in packet, out headers_t headers, inout local_metada control packet_deparser(packet_out packet, in headers_t headers) { apply { - packet.emit(headers.erspan_ethernet); - packet.emit(headers.erspan_ipv4); - packet.emit(headers.erspan_gre); + packet.emit(headers.packet_out_header); + packet.emit(headers.mirror_encap_ethernet); + packet.emit(headers.mirror_encap_vlan); + packet.emit(headers.mirror_encap_ipv6); + packet.emit(headers.mirror_encap_udp); + packet.emit(headers.ipfix); + packet.emit(headers.psamp_extended); packet.emit(headers.ethernet); + packet.emit(headers.vlan); packet.emit(headers.tunnel_encap_ipv6); packet.emit(headers.tunnel_encap_gre); packet.emit(headers.ipv4); packet.emit(headers.ipv6); + packet.emit(headers.inner_ipv4); + packet.emit(headers.inner_ipv6); packet.emit(headers.arp); packet.emit(headers.icmp); packet.emit(headers.tcp); @@ -258,90 +401,27 @@ control packet_deparser(packet_out packet, in headers_t headers) { } } -control routing(in headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { - bool wcmp_group_id_valid = false; - wcmp_group_id_t wcmp_group_id_value; - bool nexthop_id_valid = false; - nexthop_id_t nexthop_id_value; - bool router_interface_id_valid = false; - router_interface_id_t router_interface_id_value; - bool neighbor_id_valid = false; - ipv6_addr_t neighbor_id_value; - @id(0x01000001) action set_dst_mac(@id(1) @format(MAC_ADDRESS) ethernet_addr_t dst_mac) { - local_metadata.packet_rewrites.dst_mac = dst_mac; - } - @p4runtime_role("sdn_controller") @id(0x02000040) table neighbor_table { - key = { - router_interface_id_value: exact @id(1) @name("router_interface_id") @refers_to(router_interface_table , router_interface_id); - neighbor_id_value : exact @id(2) @format(IPV6_ADDRESS) @name("neighbor_id"); - } - actions = { - @proto_id(1) set_dst_mac; - @defaultonly NoAction; - } - const default_action = NoAction; - size = 1024; - } - @id(0x01000002) action set_port_and_src_mac(@id(1) port_id_t port, @id(2) @format(MAC_ADDRESS) ethernet_addr_t src_mac) { - standard_metadata.egress_spec = (bit<9>)port; - local_metadata.packet_rewrites.src_mac = src_mac; - } - @p4runtime_role("sdn_controller") @id(0x02000041) table router_interface_table { - key = { - router_interface_id_value: exact @id(1) @name("router_interface_id"); - } - actions = { - @proto_id(1) set_port_and_src_mac; - @defaultonly NoAction; - } - const default_action = NoAction; - size = 256; - } - @id(0x01000014) action set_ip_nexthop(@id(1) @refers_to(router_interface_table , router_interface_id) @refers_to(neighbor_table , router_interface_id) router_interface_id_t router_interface_id, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) ipv6_addr_t neighbor_id) { - router_interface_id_valid = true; - router_interface_id_value = router_interface_id; - neighbor_id_valid = true; - neighbor_id_value = neighbor_id; - } - @id(0x01000003) @deprecated("Use set_ip_nexthop instead.") action set_nexthop(@id(1) @refers_to(router_interface_table , router_interface_id) @refers_to(neighbor_table , router_interface_id) router_interface_id_t router_interface_id, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) ipv6_addr_t neighbor_id) { - set_ip_nexthop(router_interface_id, neighbor_id); - } - @p4runtime_role("sdn_controller") @id(0x02000042) table nexthop_table { - key = { - nexthop_id_value: exact @id(1) @name("nexthop_id"); - } - actions = { - @proto_id(1) set_nexthop; - @proto_id(3) set_ip_nexthop; - @defaultonly NoAction; - } - const default_action = NoAction; - size = 1024; - } - @id(0x01000005) action set_nexthop_id(@id(1) @refers_to(nexthop_table , nexthop_id) nexthop_id_t nexthop_id) { - nexthop_id_valid = true; - nexthop_id_value = nexthop_id; - } - @id(0x01000010) action set_nexthop_id_and_metadata(@id(1) @refers_to(nexthop_table , nexthop_id) nexthop_id_t nexthop_id, route_metadata_t route_metadata) { - nexthop_id_valid = true; - nexthop_id_value = nexthop_id; - local_metadata.route_metadata = route_metadata; +control packet_in_encap(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { + apply { } - @max_group_size(256) action_selector(HashAlgorithm.identity, 65536, 16) wcmp_group_selector; - @p4runtime_role("sdn_controller") @id(0x02000043) @oneshot table wcmp_group_table { - key = { - wcmp_group_id_value : exact @id(1) @name("wcmp_group_id"); - local_metadata.wcmp_selector_input: selector; - } - actions = { - @proto_id(1) set_nexthop_id; - @defaultonly NoAction; +} + +control packet_out_decap(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { + apply { + if (headers.packet_out_header.isValid() && headers.packet_out_header.submit_to_ingress == 0) { + standard_metadata.egress_spec = (bit<9>)headers.packet_out_header.egress_port; + local_metadata.bypass_ingress = true; } - const default_action = NoAction; - @id(0x11DC4EC8) implementation = wcmp_group_selector; - size = 3968; + headers.packet_out_header.setInvalid(); } - action no_action() { +} + +@id(0x01000005) action set_nexthop_id(inout local_metadata_t local_metadata, @id(1) @refers_to(nexthop_table , nexthop_id) nexthop_id_t nexthop_id) { + local_metadata.nexthop_id_valid = true; + local_metadata.nexthop_id_value = nexthop_id; +} +control routing_lookup(in headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { + @id(0x01798B9E) action no_action() { } @entry_restriction(" // The VRF ID 0 (or '' in P4Runtime) encodes the default VRF, which cannot @@ -364,54 +444,79 @@ control routing(in headers_t headers, inout local_metadata_t local_metadata, ino mark_to_drop(standard_metadata); } @id(0x01000004) action set_wcmp_group_id(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) wcmp_group_id_t wcmp_group_id) { - wcmp_group_id_valid = true; - wcmp_group_id_value = wcmp_group_id; + local_metadata.wcmp_group_id_valid = true; + local_metadata.wcmp_group_id_value = wcmp_group_id; } @id(0x01000011) action set_wcmp_group_id_and_metadata(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) wcmp_group_id_t wcmp_group_id, route_metadata_t route_metadata) { set_wcmp_group_id(wcmp_group_id); local_metadata.route_metadata = route_metadata; } - @id(0x0100000F) action trap() { - clone(CloneType.I2E, 1024); - mark_to_drop(standard_metadata); - } @id(0x01000015) action set_metadata_and_drop(@id(1) route_metadata_t route_metadata) { local_metadata.route_metadata = route_metadata; mark_to_drop(standard_metadata); } + @id(0x01000010) action set_nexthop_id_and_metadata(@id(1) @refers_to(nexthop_table , nexthop_id) nexthop_id_t nexthop_id, route_metadata_t route_metadata) { + local_metadata.nexthop_id_valid = true; + local_metadata.nexthop_id_value = nexthop_id; + local_metadata.route_metadata = route_metadata; + } + @id(0x01000018) @action_restriction(" + // Disallow 0 since it encodes 'no multicast' in V1Model. + multicast_group_id != 0; + ") action set_multicast_group_id(@id(1) @refers_to(builtin : : multicast_group_table , multicast_group_id) multicast_group_id_t multicast_group_id) { + standard_metadata.mcast_grp = multicast_group_id; + } @p4runtime_role("sdn_controller") @id(0x02000044) table ipv4_table { key = { local_metadata.vrf_id: exact @id(1) @name("vrf_id") @refers_to(vrf_table , vrf_id); - headers.ipv4.dst_addr: lpm @format(IPV4_ADDRESS) @id(2) @name("ipv4_dst"); + headers.ipv4.dst_addr: lpm @id(2) @name("ipv4_dst") @format(IPV4_ADDRESS); } actions = { @proto_id(1) drop; - @proto_id(2) set_nexthop_id; + @proto_id(2) set_nexthop_id(local_metadata); @proto_id(3) set_wcmp_group_id; - @proto_id(4) trap; @proto_id(5) set_nexthop_id_and_metadata; @proto_id(6) set_wcmp_group_id_and_metadata; @proto_id(7) set_metadata_and_drop; } const default_action = drop; - size = 32768; + size = 131072; } @p4runtime_role("sdn_controller") @id(0x02000045) table ipv6_table { key = { local_metadata.vrf_id: exact @id(1) @name("vrf_id") @refers_to(vrf_table , vrf_id); - headers.ipv6.dst_addr: lpm @format(IPV6_ADDRESS) @id(2) @name("ipv6_dst"); + headers.ipv6.dst_addr: lpm @id(2) @name("ipv6_dst") @format(IPV6_ADDRESS); } actions = { @proto_id(1) drop; - @proto_id(2) set_nexthop_id; + @proto_id(2) set_nexthop_id(local_metadata); @proto_id(3) set_wcmp_group_id; - @proto_id(4) trap; @proto_id(5) set_nexthop_id_and_metadata; @proto_id(6) set_wcmp_group_id_and_metadata; @proto_id(7) set_metadata_and_drop; } const default_action = drop; - size = 4096; + size = 17000; + } + @p4runtime_role("sdn_controller") @id(0x0200004E) table ipv4_multicast_table { + key = { + local_metadata.vrf_id: exact @id(1) @name("vrf_id") @refers_to(vrf_table , vrf_id); + headers.ipv4.dst_addr: exact @id(2) @name("ipv4_dst") @format(IPV4_ADDRESS); + } + actions = { + @proto_id(1) set_multicast_group_id; + } + size = 1600; + } + @p4runtime_role("sdn_controller") @id(0x0200004F) table ipv6_multicast_table { + key = { + local_metadata.vrf_id: exact @id(1) @name("vrf_id") @refers_to(vrf_table , vrf_id); + headers.ipv6.dst_addr: exact @id(2) @name("ipv6_dst") @format(IPV6_ADDRESS); + } + actions = { + @proto_id(1) set_multicast_group_id; + } + size = 1600; } apply { mark_to_drop(standard_metadata); @@ -419,20 +524,147 @@ control routing(in headers_t headers, inout local_metadata_t local_metadata, ino if (local_metadata.admit_to_l3) { if (headers.ipv4.isValid()) { ipv4_table.apply(); + ipv4_multicast_table.apply(); + local_metadata.ipmc_table_hit = standard_metadata.mcast_grp != 0; } else if (headers.ipv6.isValid()) { ipv6_table.apply(); + ipv6_multicast_table.apply(); + local_metadata.ipmc_table_hit = standard_metadata.mcast_grp != 0; } - if (wcmp_group_id_valid) { + } + } +} + +control routing_resolution(in headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { + bool tunnel_id_valid = false; + tunnel_id_t tunnel_id_value; + bool router_interface_id_valid = false; + router_interface_id_t router_interface_id_value; + bool neighbor_id_valid = false; + ipv6_addr_t neighbor_id_value; + @id(0x01000001) action set_dst_mac(@id(1) @format(MAC_ADDRESS) ethernet_addr_t dst_mac) { + local_metadata.packet_rewrites.dst_mac = dst_mac; + } + @p4runtime_role("sdn_controller") @id(0x02000040) table neighbor_table { + key = { + router_interface_id_value: exact @id(1) @name("router_interface_id") @refers_to(router_interface_table , router_interface_id); + neighbor_id_value : exact @id(2) @format(IPV6_ADDRESS) @name("neighbor_id"); + } + actions = { + @proto_id(1) set_dst_mac; + @defaultonly NoAction; + } + const default_action = NoAction; + size = 1024; + } + @id(0x0100001B) @unsupported @action_restriction(" + // Disallow reserved VLAN IDs with implementation-defined semantics. + vlan_id != 0 && vlan_id != 4095") action set_port_and_src_mac_and_vlan_id(@id(1) port_id_t port, @id(2) @format(MAC_ADDRESS) ethernet_addr_t src_mac, @id(3) vlan_id_t vlan_id) { + standard_metadata.egress_spec = (bit<9>)port; + local_metadata.packet_rewrites.src_mac = src_mac; + local_metadata.packet_rewrites.vlan_id = vlan_id; + } + @id(0x01000002) action set_port_and_src_mac(@id(1) port_id_t port, @id(2) @format(MAC_ADDRESS) ethernet_addr_t src_mac) { + set_port_and_src_mac_and_vlan_id(port, src_mac, INTERNAL_VLAN_ID); + } + @p4runtime_role("sdn_controller") @id(0x02000041) table router_interface_table { + key = { + router_interface_id_value: exact @id(1) @name("router_interface_id"); + } + actions = { + @proto_id(1) set_port_and_src_mac; + @proto_id(2) set_port_and_src_mac_and_vlan_id; + @defaultonly NoAction; + } + const default_action = NoAction; + size = 256; + } + @id(0x01000017) action set_ip_nexthop_and_disable_rewrites(@id(1) @refers_to(router_interface_table , router_interface_id) @refers_to(neighbor_table , router_interface_id) router_interface_id_t router_interface_id, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) ipv6_addr_t neighbor_id, @id(3) bit<1> disable_decrement_ttl, @id(4) bit<1> disable_src_mac_rewrite, @id(5) bit<1> disable_dst_mac_rewrite, @id(6) bit<1> disable_vlan_rewrite) { + router_interface_id_valid = true; + router_interface_id_value = router_interface_id; + neighbor_id_valid = true; + neighbor_id_value = neighbor_id; + local_metadata.enable_decrement_ttl = !(bool)disable_decrement_ttl; + local_metadata.enable_src_mac_rewrite = !(bool)disable_src_mac_rewrite; + local_metadata.enable_dst_mac_rewrite = !(bool)disable_dst_mac_rewrite; + local_metadata.enable_vlan_rewrite = !(bool)disable_vlan_rewrite; + } + @id(0x01000014) action set_ip_nexthop(@id(1) @refers_to(router_interface_table , router_interface_id) @refers_to(neighbor_table , router_interface_id) router_interface_id_t router_interface_id, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) ipv6_addr_t neighbor_id) { + set_ip_nexthop_and_disable_rewrites(router_interface_id, neighbor_id, 0x0, 0x0, 0x0, 0x0); + } + @id(0x01000003) @deprecated("Use set_ip_nexthop instead.") action set_nexthop(@id(1) @refers_to(router_interface_table , router_interface_id) @refers_to(neighbor_table , router_interface_id) router_interface_id_t router_interface_id, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) ipv6_addr_t neighbor_id) { + set_ip_nexthop(router_interface_id, neighbor_id); + } + @id(0x01000012) action set_p2p_tunnel_encap_nexthop(@id(1) @refers_to(tunnel_table , tunnel_id) tunnel_id_t tunnel_id) { + tunnel_id_valid = true; + tunnel_id_value = tunnel_id; + } + @p4runtime_role("sdn_controller") @id(0x02000042) table nexthop_table { + key = { + local_metadata.nexthop_id_value: exact @id(1) @name("nexthop_id"); + } + actions = { + @proto_id(1) set_nexthop; + @proto_id(2) set_p2p_tunnel_encap_nexthop; + @proto_id(3) set_ip_nexthop; + @proto_id(4) set_ip_nexthop_and_disable_rewrites; + @defaultonly NoAction; + } + const default_action = NoAction; + size = 1024; + } + @id(0x01000013) action mark_for_p2p_tunnel_encap(@id(1) @format(IPV6_ADDRESS) ipv6_addr_t encap_src_ip, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) ipv6_addr_t encap_dst_ip, @id(3) @refers_to(neighbor_table , router_interface_id) @refers_to(router_interface_table , router_interface_id) router_interface_id_t router_interface_id) { + local_metadata.tunnel_encap_src_ipv6 = encap_src_ip; + local_metadata.tunnel_encap_dst_ipv6 = encap_dst_ip; + local_metadata.apply_tunnel_encap_at_egress = true; + set_ip_nexthop(router_interface_id, encap_dst_ip); + } + @p4runtime_role("sdn_controller") @id(0x02000050) table tunnel_table { + key = { + tunnel_id_value: exact @id(1) @name("tunnel_id"); + } + actions = { + @proto_id(1) mark_for_p2p_tunnel_encap; + @defaultonly NoAction; + } + const default_action = NoAction; + size = 2048; + } + @max_group_size(512) @id(0x11DC4EC8) action_selector(HashAlgorithm.identity, 49152, 8) wcmp_group_selector; + @p4runtime_role("sdn_controller") @id(0x02000043) @oneshot table wcmp_group_table { + key = { + local_metadata.wcmp_group_id_value: exact @id(1) @name("wcmp_group_id"); + local_metadata.wcmp_selector_input: selector; + } + actions = { + @proto_id(1) set_nexthop_id(local_metadata); + @defaultonly NoAction; + } + const default_action = NoAction; + implementation = wcmp_group_selector; + size = 3968; + } + apply { + if (local_metadata.admit_to_l3) { + if (local_metadata.wcmp_group_id_valid) { wcmp_group_table.apply(); } - if (nexthop_id_valid) { + if (local_metadata.nexthop_id_valid) { nexthop_table.apply(); + if (tunnel_id_valid) { + tunnel_table.apply(); + } if (router_interface_id_valid && neighbor_id_valid) { router_interface_table.apply(); neighbor_table.apply(); } } } + local_metadata.packet_in_target_egress_port = standard_metadata.egress_spec; + local_metadata.packet_in_ingress_port = standard_metadata.ingress_port; + if (local_metadata.acl_drop) { + mark_to_drop(standard_metadata); + } } } @@ -444,92 +676,94 @@ control verify_ipv4_checksum(inout headers_t headers, inout local_metadata_t loc control compute_ipv4_checksum(inout headers_t headers, inout local_metadata_t local_metadata) { apply { - update_checksum(headers.erspan_ipv4.isValid(), { headers.erspan_ipv4.version, headers.erspan_ipv4.ihl, headers.erspan_ipv4.dscp, headers.erspan_ipv4.ecn, headers.erspan_ipv4.total_len, headers.erspan_ipv4.identification, headers.erspan_ipv4.reserved, headers.erspan_ipv4.do_not_fragment, headers.erspan_ipv4.more_fragments, headers.erspan_ipv4.frag_offset, headers.erspan_ipv4.ttl, headers.erspan_ipv4.protocol, headers.erspan_ipv4.src_addr, headers.erspan_ipv4.dst_addr }, headers.erspan_ipv4.header_checksum, HashAlgorithm.csum16); update_checksum(headers.ipv4.isValid(), { headers.ipv4.version, headers.ipv4.ihl, headers.ipv4.dscp, headers.ipv4.ecn, headers.ipv4.total_len, headers.ipv4.identification, headers.ipv4.reserved, headers.ipv4.do_not_fragment, headers.ipv4.more_fragments, headers.ipv4.frag_offset, headers.ipv4.ttl, headers.ipv4.protocol, headers.ipv4.src_addr, headers.ipv4.dst_addr }, headers.ipv4.header_checksum, HashAlgorithm.csum16); } } -control mirroring_encap(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { - apply { - if (standard_metadata.instance_type == 1) { - headers.erspan_ethernet.setValid(); - headers.erspan_ethernet.src_addr = local_metadata.mirroring_src_mac; - headers.erspan_ethernet.dst_addr = local_metadata.mirroring_dst_mac; - headers.erspan_ethernet.ether_type = 0x800; - headers.erspan_ipv4.setValid(); - headers.erspan_ipv4.src_addr = local_metadata.mirroring_src_ip; - headers.erspan_ipv4.dst_addr = local_metadata.mirroring_dst_ip; - headers.erspan_ipv4.version = 4w4; - headers.erspan_ipv4.ihl = 4w5; - headers.erspan_ipv4.protocol = 0x2f; - headers.erspan_ipv4.ttl = local_metadata.mirroring_ttl; - headers.erspan_ipv4.dscp = local_metadata.mirroring_tos[7:2]; - headers.erspan_ipv4.ecn = local_metadata.mirroring_tos[1:0]; - headers.erspan_ipv4.total_len = 20 + 4 + (bit<16>)standard_metadata.packet_length; - headers.erspan_ipv4.identification = 0; - headers.erspan_ipv4.reserved = 0; - headers.erspan_ipv4.do_not_fragment = 1; - headers.erspan_ipv4.more_fragments = 0; - headers.erspan_ipv4.frag_offset = 0; - headers.erspan_ipv4.header_checksum = 0; - headers.erspan_gre.setValid(); - headers.erspan_gre.checksum_present = 0; - headers.erspan_gre.routing_present = 0; - headers.erspan_gre.key_present = 0; - headers.erspan_gre.sequence_present = 0; - headers.erspan_gre.strict_source_route = 0; - headers.erspan_gre.recursion_control = 0; - headers.erspan_gre.acknowledgement_present = 0; - headers.erspan_gre.flags = 0; - headers.erspan_gre.version = 0; - headers.erspan_gre.protocol = 0x88be; - } - } -} - -control mirroring_clone(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { - port_id_t mirror_port; - bit<32> pre_session; - @id(0x01000007) action mirror_as_ipv4_erspan(@id(1) port_id_t port, @id(2) @format(IPV4_ADDRESS) ipv4_addr_t src_ip, @id(3) @format(IPV4_ADDRESS) ipv4_addr_t dst_ip, @id(4) @format(MAC_ADDRESS) ethernet_addr_t src_mac, @id(5) @format(MAC_ADDRESS) ethernet_addr_t dst_mac, @id(6) bit<8> ttl, @id(7) bit<8> tos) { - mirror_port = port; - local_metadata.mirroring_src_ip = src_ip; - local_metadata.mirroring_dst_ip = dst_ip; - local_metadata.mirroring_src_mac = src_mac; - local_metadata.mirroring_dst_mac = dst_mac; - local_metadata.mirroring_ttl = ttl; - local_metadata.mirroring_tos = tos; +control ingress_cloning(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { + @id(0x0100001C) action ingress_clone(@id(1) bit<32> clone_session) { + clone_preserving_field_list(CloneType.I2E, clone_session, PreservedFieldList.MIRROR_AND_PACKET_IN_COPY); } - @p4runtime_role("sdn_controller") @id(0x02000046) table mirror_session_table { + @unsupported @p4runtime_role("packet_replication_engine_manager") @id(0x02000051) @entry_restriction(" + // mirror_egress_port is present iff marked_to_mirror is true. + // Exact match indicating presence of mirror_egress_port. + marked_to_mirror == 1 -> mirror_egress_port::mask == -1; + // Wildcard match indicating abscence of mirror_egress_port. + marked_to_mirror == 0 -> mirror_egress_port::mask == 0; + ") table ingress_clone_table { key = { - local_metadata.mirror_session_id_value: exact @id(1) @name("mirror_session_id"); + local_metadata.marked_to_copy : exact @id(1) @name("marked_to_copy"); + local_metadata.marked_to_mirror : exact @id(2) @name("marked_to_mirror"); + local_metadata.mirror_egress_port: optional @id(3) @name("mirror_egress_port"); } actions = { - @proto_id(1) mirror_as_ipv4_erspan; - @defaultonly NoAction; + @proto_id(1) ingress_clone; } - const default_action = NoAction; - size = 2; } - @id(0x01000009) action set_pre_session(bit<32> id) { - pre_session = id; + apply { + ingress_clone_table.apply(); + } +} + +control mirror_session_lookup(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { + @id(0x01000007) action mirror_as_ipv4_erspan(@id(1) port_id_t port, @id(2) @format(IPV4_ADDRESS) ipv4_addr_t src_ip, @id(3) @format(IPV4_ADDRESS) ipv4_addr_t dst_ip, @id(4) @format(MAC_ADDRESS) ethernet_addr_t src_mac, @id(5) @format(MAC_ADDRESS) ethernet_addr_t dst_mac, @id(6) bit<8> ttl, @id(7) bit<8> tos) { + } + @id(0x0100001D) @unsupported action mirror_with_vlan_tag_and_ipfix_encapsulation(@id(1) port_id_t monitor_port, @id(2) port_id_t monitor_failover_port, @id(3) @format(MAC_ADDRESS) ethernet_addr_t mirror_encap_src_mac, @id(4) @format(MAC_ADDRESS) ethernet_addr_t mirror_encap_dst_mac, @id(6) vlan_id_t mirror_encap_vlan_id, @id(7) @format(IPV6_ADDRESS) ipv6_addr_t mirror_encap_dst_ip, @id(8) @format(IPV6_ADDRESS) ipv6_addr_t mirror_encap_src_ip, @id(9) bit<16> mirror_encap_udp_src_port, @id(10) bit<16> mirror_encap_udp_dst_port) { + local_metadata.mirror_egress_port = monitor_port; + local_metadata.mirror_encap_src_mac = mirror_encap_src_mac; + local_metadata.mirror_encap_dst_mac = mirror_encap_dst_mac; + local_metadata.mirror_encap_vlan_id = mirror_encap_vlan_id; + local_metadata.mirror_encap_src_ip = mirror_encap_src_ip; + local_metadata.mirror_encap_dst_ip = mirror_encap_dst_ip; + local_metadata.mirror_encap_udp_src_port = mirror_encap_udp_src_port; + local_metadata.mirror_encap_udp_dst_port = mirror_encap_udp_dst_port; } - @p4runtime_role("packet_replication_engine_manager") @id(0x02000048) table mirror_port_to_pre_session_table { + @p4runtime_role("sdn_controller") @id(0x02000046) table mirror_session_table { key = { - mirror_port: exact @id(1); + local_metadata.mirror_session_id: exact @id(1) @name("mirror_session_id"); } actions = { - @proto_id(1) set_pre_session; + @proto_id(1) mirror_as_ipv4_erspan; + @proto_id(2) mirror_with_vlan_tag_and_ipfix_encapsulation; @defaultonly NoAction; } const default_action = NoAction; + size = 4; } apply { - if (local_metadata.mirror_session_id_valid) { - if (mirror_session_table.apply().hit) { - if (mirror_port_to_pre_session_table.apply().hit) { - clone_preserving_field_list(CloneType.I2E, pre_session, (bit<8>)PreservedFieldList.CLONE_I2E); - } - } + if (local_metadata.marked_to_mirror) { + mirror_session_table.apply(); + } + } +} + +control mirroring_encap(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { + apply { + if (standard_metadata.instance_type == 1 && standard_metadata.egress_rid == 2) { + headers.mirror_encap_ethernet.setValid(); + headers.mirror_encap_ethernet.src_addr = local_metadata.mirror_encap_src_mac; + headers.mirror_encap_ethernet.dst_addr = local_metadata.mirror_encap_dst_mac; + headers.mirror_encap_ethernet.ether_type = 0x8100; + headers.mirror_encap_vlan.setValid(); + headers.mirror_encap_vlan.ether_type = 0x86dd; + headers.mirror_encap_vlan.vlan_id = local_metadata.mirror_encap_vlan_id; + headers.mirror_encap_ipv6.setValid(); + headers.mirror_encap_ipv6.version = 4w6; + headers.mirror_encap_ipv6.dscp = 0; + headers.mirror_encap_ipv6.ecn = 0; + headers.mirror_encap_ipv6.hop_limit = 16; + headers.mirror_encap_ipv6.flow_label = 0; + headers.mirror_encap_ipv6.payload_length = (bit<16>)standard_metadata.packet_length + 8 + 16 + 28; + headers.mirror_encap_ipv6.next_header = 0x11; + headers.mirror_encap_ipv6.src_addr = local_metadata.mirror_encap_src_ip; + headers.mirror_encap_ipv6.dst_addr = local_metadata.mirror_encap_dst_ip; + headers.mirror_encap_udp.setValid(); + headers.mirror_encap_udp.src_port = local_metadata.mirror_encap_udp_src_port; + headers.mirror_encap_udp.dst_port = local_metadata.mirror_encap_udp_dst_port; + headers.mirror_encap_udp.hdr_length = headers.mirror_encap_ipv6.payload_length; + headers.mirror_encap_udp.checksum = 0; + headers.ipfix.setValid(); + headers.psamp_extended.setValid(); } } } @@ -548,59 +782,257 @@ control l3_admit(in headers_t headers, inout local_metadata_t local_metadata, in @defaultonly NoAction; } const default_action = NoAction; - size = 128; + size = 64; } apply { - l3_admit_table.apply(); + if (local_metadata.enable_vlan_checks && !(local_metadata.vlan_id == NO_VLAN_ID || local_metadata.vlan_id == INTERNAL_VLAN_ID)) { + local_metadata.admit_to_l3 = false; + } else { + l3_admit_table.apply(); + } } } -control ttl(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { +control gre_tunnel_encap(inout headers_t headers, in local_metadata_t local_metadata, in standard_metadata_t standard_metadata) { apply { - if (local_metadata.admit_to_l3) { + if (local_metadata.apply_tunnel_encap_at_egress) { + headers.tunnel_encap_gre.setValid(); + headers.tunnel_encap_gre.checksum_present = 0; + headers.tunnel_encap_gre.routing_present = 0; + headers.tunnel_encap_gre.key_present = 0; + headers.tunnel_encap_gre.sequence_present = 0; + headers.tunnel_encap_gre.strict_source_route = 0; + headers.tunnel_encap_gre.recursion_control = 0; + headers.tunnel_encap_gre.flags = 0; + headers.tunnel_encap_gre.version = 0; + headers.tunnel_encap_gre.protocol = headers.ethernet.ether_type; + headers.ethernet.ether_type = 0x86dd; + headers.tunnel_encap_ipv6.setValid(); + headers.tunnel_encap_ipv6.version = 4w6; + headers.tunnel_encap_ipv6.src_addr = local_metadata.tunnel_encap_src_ipv6; + headers.tunnel_encap_ipv6.dst_addr = local_metadata.tunnel_encap_dst_ipv6; + headers.tunnel_encap_ipv6.payload_length = (bit<16>)standard_metadata.packet_length + 4 - 14; + headers.tunnel_encap_ipv6.next_header = 0x2f; if (headers.ipv4.isValid()) { - if (headers.ipv4.ttl <= 1) { - mark_to_drop(standard_metadata); - } else { - headers.ipv4.ttl = headers.ipv4.ttl - 1; - } + headers.tunnel_encap_ipv6.dscp = headers.ipv4.dscp; + headers.tunnel_encap_ipv6.ecn = headers.ipv4.ecn; + headers.tunnel_encap_ipv6.hop_limit = headers.ipv4.ttl; + } else if (headers.ipv6.isValid()) { + headers.tunnel_encap_ipv6.dscp = headers.ipv6.dscp; + headers.tunnel_encap_ipv6.ecn = headers.ipv6.ecn; + headers.tunnel_encap_ipv6.hop_limit = headers.ipv6.hop_limit; } - if (headers.ipv6.isValid()) { - if (headers.ipv6.hop_limit <= 1) { - mark_to_drop(standard_metadata); - } else { - headers.ipv6.hop_limit = headers.ipv6.hop_limit - 1; - } + } + } +} + +control vlan_untag(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { + @id(0x0100001A) action disable_vlan_checks() { + local_metadata.enable_vlan_checks = false; + } + @p4runtime_role("sdn_controller") @id(0x0200004D) @entry_restriction(" + // Force the dummy_match to be wildcard. + dummy_match::mask == 0; + ") table disable_vlan_checks_table { + key = { + 1w1: ternary @id(1) @name("dummy_match"); + } + actions = { + @proto_id(1) disable_vlan_checks; + } + size = 1; + } + apply { + if (headers.vlan.isValid()) { + local_metadata.vlan_id = headers.vlan.vlan_id; + headers.ethernet.ether_type = headers.vlan.ether_type; + headers.vlan.setInvalid(); + } else { + local_metadata.vlan_id = INTERNAL_VLAN_ID; + } + local_metadata.enable_vlan_checks = true; + disable_vlan_checks_table.apply(); + } +} + +control ingress_vlan_checks(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { + apply { + if (local_metadata.enable_vlan_checks && !(local_metadata.vlan_id == NO_VLAN_ID || local_metadata.vlan_id == INTERNAL_VLAN_ID)) { + mark_to_drop(standard_metadata); + } + } +} + +control egress_vlan_checks(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { + apply { + if (local_metadata.enable_vlan_checks) { + if (standard_metadata.instance_type == 1 && standard_metadata.egress_rid == 2 && !(local_metadata.mirror_encap_vlan_id == NO_VLAN_ID || local_metadata.mirror_encap_vlan_id == INTERNAL_VLAN_ID)) { + mark_to_drop(standard_metadata); + } else if (!(standard_metadata.instance_type == 1 && standard_metadata.egress_rid == 1) && !(local_metadata.vlan_id == NO_VLAN_ID || local_metadata.vlan_id == INTERNAL_VLAN_ID)) { + mark_to_drop(standard_metadata); } } } } -control packet_rewrites(inout headers_t headers, in local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { +control vlan_tag(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { apply { - if (local_metadata.admit_to_l3) { + if (!(local_metadata.vlan_id == NO_VLAN_ID || local_metadata.vlan_id == INTERNAL_VLAN_ID) && !(standard_metadata.instance_type == 1 && standard_metadata.egress_rid == 2)) { + headers.vlan.setValid(); + headers.vlan.priority_code_point = 0; + headers.vlan.drop_eligible_indicator = 0; + headers.vlan.vlan_id = local_metadata.vlan_id; + headers.vlan.ether_type = headers.ethernet.ether_type; + headers.ethernet.ether_type = 0x8100; + } + } +} + +const ipv6_addr_t IPV6_MULTICAST_MASK = 0xff000000000000000000000000000000; +const ipv6_addr_t IPV6_MULTICAST_VALUE = 0xff000000000000000000000000000000; +const ipv6_addr_t IPV6_LOOPBACK_MASK = 0xffffffffffffffffffffffffffffffff; +const ipv6_addr_t IPV6_LOOPBACK_VALUE = 0x1; +const ipv4_addr_t IPV4_MULTICAST_MASK = 0xf0000000; +const ipv4_addr_t IPV4_MULTICAST_VALUE = 0xe0000000; +const ipv4_addr_t IPV4_BROADCAST_VALUE = 0xffffffff; +const ipv4_addr_t IPV4_LOOPBACK_MASK = 0xff000000; +const ipv4_addr_t IPV4_LOOPBACK_VALUE = 0x7f000000; +const ethernet_addr_t MAC_MULTICAST_MASK = 0x10000000000; +const ethernet_addr_t MAC_MULTICAST_VALUE = 0x10000000000; +control drop_martians(in headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { + apply { + if (headers.ipv6.isValid() && (headers.ipv6.src_addr & IPV6_MULTICAST_MASK == IPV6_MULTICAST_VALUE || headers.ipv6.dst_addr & IPV6_MULTICAST_MASK == IPV6_MULTICAST_VALUE || headers.ipv6.src_addr & IPV6_LOOPBACK_MASK == IPV6_LOOPBACK_VALUE || headers.ipv6.dst_addr & IPV6_LOOPBACK_MASK == IPV6_LOOPBACK_VALUE) || headers.ipv4.isValid() && (headers.ipv4.src_addr & IPV4_MULTICAST_MASK == IPV4_MULTICAST_VALUE || headers.ipv4.src_addr == IPV4_BROADCAST_VALUE || (headers.ipv4.dst_addr & IPV4_MULTICAST_MASK == IPV4_MULTICAST_VALUE || headers.ipv4.dst_addr == IPV4_BROADCAST_VALUE) || headers.ipv4.src_addr & IPV4_LOOPBACK_MASK == IPV4_LOOPBACK_VALUE || headers.ipv4.dst_addr & IPV4_LOOPBACK_MASK == IPV4_LOOPBACK_VALUE) || headers.ethernet.isValid() && headers.ethernet.dst_addr & MAC_MULTICAST_MASK == MAC_MULTICAST_VALUE) { + mark_to_drop(standard_metadata); + } + } +} + +control multicast_rewrites(inout local_metadata_t local_metadata, in standard_metadata_t standard_metadata) { + port_id_t multicast_replica_port = (port_id_t)standard_metadata.egress_port; + replica_instance_t multicast_replica_instance = standard_metadata.egress_rid; + @id(0x01000019) action set_multicast_src_mac(@id(1) @format(MAC_ADDRESS) ethernet_addr_t src_mac) { + local_metadata.enable_src_mac_rewrite = true; + local_metadata.packet_rewrites.src_mac = src_mac; + } + @p4runtime_role("sdn_controller") @id(0x0200004C) table multicast_router_interface_table { + key = { + multicast_replica_port : exact @referenced_by(builtin : : multicast_group_table , replica . port) @id(1); + multicast_replica_instance: exact @referenced_by(builtin : : multicast_group_table , replica . instance) @id(2); + } + actions = { + @proto_id(1) set_multicast_src_mac; + } + size = 110; + } + apply { + multicast_router_interface_table.apply(); + } +} + +control packet_rewrites(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { + apply { + if (standard_metadata.instance_type == 5) { + local_metadata.enable_decrement_ttl = true; + multicast_rewrites.apply(local_metadata, standard_metadata); + } + if (local_metadata.enable_src_mac_rewrite) { headers.ethernet.src_addr = local_metadata.packet_rewrites.src_mac; + } + if (local_metadata.enable_dst_mac_rewrite) { headers.ethernet.dst_addr = local_metadata.packet_rewrites.dst_mac; } + if (local_metadata.enable_vlan_rewrite) { + local_metadata.vlan_id = local_metadata.packet_rewrites.vlan_id; + } + if (headers.ipv4.isValid()) { + if (headers.ipv4.ttl > 0 && local_metadata.enable_decrement_ttl) { + headers.ipv4.ttl = headers.ipv4.ttl - 1; + } + if (headers.ipv4.ttl == 0) { + mark_to_drop(standard_metadata); + } + } + if (headers.ipv6.isValid()) { + if (headers.ipv6.hop_limit > 0 && local_metadata.enable_decrement_ttl) { + headers.ipv6.hop_limit = headers.ipv6.hop_limit - 1; + } + if (headers.ipv6.hop_limit == 0) { + mark_to_drop(standard_metadata); + } + } + } +} + +control tunnel_termination_lookup(in headers_t headers, inout local_metadata_t local_metadata) { + @id(0x01000016) action mark_for_tunnel_decap_and_set_vrf(@refers_to(vrf_table , vrf_id) vrf_id_t vrf_id) { + local_metadata.apply_tunnel_decap_at_end_of_pre_ingress = true; + local_metadata.vrf_id = vrf_id; + } + @unsupported @p4runtime_role("sdn_controller") @id(0x0200004B) table ipv6_tunnel_termination_table { + key = { + headers.ipv6.dst_addr: ternary @id(1) @name("dst_ipv6") @format(IPV6_ADDRESS); + headers.ipv6.src_addr: ternary @id(2) @name("src_ipv6") @format(IPV6_ADDRESS); + } + actions = { + @proto_id(1) mark_for_tunnel_decap_and_set_vrf; + } + size = 126; + } + apply { + if (headers.ipv6.isValid()) { + if (headers.ipv6.next_header == 0x4 || headers.ipv6.next_header == 0x29) { + ipv6_tunnel_termination_table.apply(); + } + } + } +} + +control tunnel_termination_decap(inout headers_t headers, in local_metadata_t local_metadata) { + apply { + if (local_metadata.apply_tunnel_decap_at_end_of_pre_ingress) { + assert(headers.ipv6.isValid()); + assert(headers.inner_ipv4.isValid() && !headers.inner_ipv6.isValid() || !headers.inner_ipv4.isValid() && headers.inner_ipv6.isValid()); + headers.ipv6.setInvalid(); + if (headers.inner_ipv4.isValid()) { + headers.ethernet.ether_type = 0x800; + headers.ipv4 = headers.inner_ipv4; + headers.inner_ipv4.setInvalid(); + } + if (headers.inner_ipv6.isValid()) { + headers.ethernet.ether_type = 0x86dd; + headers.ipv6 = headers.inner_ipv6; + headers.inner_ipv6.setInvalid(); + } + } } } -@id(0x01000109) @sai_action(SAI_PACKET_ACTION_DROP) action acl_drop(inout standard_metadata_t standard_metadata) { - mark_to_drop(standard_metadata); +@id(0x01000109) @sai_action(SAI_PACKET_ACTION_DROP) action acl_drop(inout local_metadata_t local_metadata) { + local_metadata.acl_drop = true; } control acl_egress(in headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { bit<6> dscp = 0; bit<8> ip_protocol = 0; @id(0x13000104) direct_counter(CounterType.packets_and_bytes) acl_egress_counter; + @id(0x13000108) direct_counter(CounterType.packets_and_bytes) acl_egress_dhcp_to_host_counter; + @id(0x0100010D) @sai_action(SAI_PACKET_ACTION_FORWARD) action acl_egress_forward() { + acl_egress_counter.count(); + } @p4runtime_role("sdn_controller") @id(0x02000104) @sai_acl(EGRESS) @entry_restriction(" + // Forbid using ether_type for IP packets (by convention, use is_ip* instead). ether_type != 0x0800 && ether_type != 0x86dd; dscp::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + // Only allow IP field matches for IP packets. - // TODO: Enable once p4-constraints bug is fixed. - // ip_protocol::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + ip_protocol::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + + + + // Only allow l4_dst_port matches for TCP/UDP packets. l4_dst_port::mask != 0 -> (ip_protocol == 6 || ip_protocol == 17); + // Forbid illegal combinations of IP_TYPE fields. is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0); is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0); @@ -610,22 +1042,51 @@ control acl_egress(in headers_t headers, inout local_metadata_t local_metadata, is_ipv6::mask != 0 -> (is_ipv6 == 1); ") table acl_egress_table { key = { - headers.ethernet.ether_type : ternary @name("ether_type") @id(1) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ETHER_TYPE); - ip_protocol : ternary @name("ip_protocol") @id(2) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IP_PROTOCOL); - local_metadata.l4_dst_port : ternary @name("l4_dst_port") @id(3) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_L4_DST_PORT); - (port_id_t)standard_metadata.egress_port : optional @name("out_port") @id(4) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_OUT_PORT); - headers.ipv4.isValid() || headers.ipv6.isValid(): optional @name("is_ip") @id(5) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); - headers.ipv4.isValid() : optional @name("is_ipv4") @id(6) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); - headers.ipv6.isValid() : optional @name("is_ipv6") @id(7) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); - dscp : ternary @name("dscp") @id(8) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DSCP); + headers.ethernet.ether_type : ternary @id(1) @name("ether_type") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ETHER_TYPE); + ip_protocol : ternary @id(2) @name("ip_protocol") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IP_PROTOCOL); + local_metadata.l4_dst_port : ternary @id(3) @name("l4_dst_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_L4_DST_PORT); + (port_id_t)standard_metadata.egress_port : optional @id(4) @name("out_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_OUT_PORT); + headers.ipv4.isValid() || headers.ipv6.isValid(): optional @id(5) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(6) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(7) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + dscp : ternary @id(8) @name("dscp") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DSCP); } actions = { - @proto_id(1) acl_drop(standard_metadata); + @proto_id(1) acl_drop(local_metadata); @defaultonly NoAction; } const default_action = NoAction; counters = acl_egress_counter; - size = 128; + size = 127; + } + @id(0x02000108) @sai_acl(EGRESS) @p4runtime_role("sdn_controller") @entry_restriction(" + // Only allow IP field matches for IP packets. + ip_protocol::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + // Only allow l4_dst_port matches for TCP/UDP packets. + l4_dst_port::mask != 0 -> (ip_protocol == 6 || ip_protocol == 17); + // Forbid illegal combinations of IP_TYPE fields. + is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0); + is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0); + is_ipv6::mask != 0 -> (is_ip::mask == 0 && is_ipv4::mask == 0); + // Forbid unsupported combinations of IP_TYPE fields. + is_ipv4::mask != 0 -> (is_ipv4 == 1); + is_ipv6::mask != 0 -> (is_ipv6 == 1); + ") table acl_egress_dhcp_to_host_table { + key = { + headers.ipv4.isValid() || headers.ipv6.isValid(): optional @id(1) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(2) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(3) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + ip_protocol : ternary @id(5) @name("ip_protocol") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IP_PROTOCOL); + local_metadata.l4_dst_port : ternary @id(6) @name("l4_dst_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_L4_DST_PORT); + (port_id_t)standard_metadata.egress_port : optional @id(7) @name("out_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_OUT_PORT); + } + actions = { + @proto_id(1) acl_drop(local_metadata); + @defaultonly NoAction; + } + const default_action = NoAction; + counters = acl_egress_dhcp_to_host_counter; + size = 127; } apply { if (headers.ipv4.isValid()) { @@ -638,6 +1099,9 @@ control acl_egress(in headers_t headers, inout local_metadata_t local_metadata, ip_protocol = 0; } acl_egress_table.apply(); + if (local_metadata.acl_drop) { + mark_to_drop(standard_metadata); + } } } @@ -646,49 +1110,75 @@ control acl_ingress(in headers_t headers, inout local_metadata_t local_metadata, bit<6> dscp = 0; bit<2> ecn = 0; bit<8> ip_protocol = 0; - @id(0x15000100) direct_meter(MeterType.bytes) acl_ingress_meter; + bool cancel_copy = false; + @id(0x15000100) @mode(single_rate_two_color) direct_meter(MeterType.bytes) acl_ingress_meter; + @id(0x15000102) @mode(single_rate_two_color) direct_meter(MeterType.bytes) acl_ingress_qos_meter; @id(0x13000102) direct_counter(CounterType.packets_and_bytes) acl_ingress_counter; - @id(0x01000101) @sai_action(SAI_PACKET_ACTION_COPY , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_YELLOW) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_RED) action acl_copy(@sai_action_param(QOS_QUEUE) @id(1) qos_queue_t qos_queue) { + @id(0x13000107) direct_counter(CounterType.packets_and_bytes) acl_ingress_qos_counter; + @id(0x13000109) direct_counter(CounterType.packets_and_bytes) acl_ingress_counting_counter; + @id(0x1300010A) direct_counter(CounterType.packets_and_bytes) acl_ingress_security_counter; + @id(0x01000101) @sai_action(SAI_PACKET_ACTION_COPY , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_RED) action acl_copy(@sai_action_param(QOS_QUEUE) @id(1) qos_queue_t qos_queue) { acl_ingress_counter.count(); acl_ingress_meter.read(local_metadata.color); - clone(CloneType.I2E, 1024); + local_metadata.marked_to_copy = true; } - @id(0x01000102) @sai_action(SAI_PACKET_ACTION_TRAP , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_YELLOW) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED) action acl_trap(@sai_action_param(QOS_QUEUE) @id(1) qos_queue_t qos_queue) { + @id(0x01000102) @sai_action(SAI_PACKET_ACTION_TRAP , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED) action acl_trap(@sai_action_param(QOS_QUEUE) @id(1) qos_queue_t qos_queue) { acl_copy(qos_queue); - mark_to_drop(standard_metadata); + local_metadata.acl_drop = true; } - @id(0x01000199) @sai_action(SAI_PACKET_ACTION_TRAP , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_YELLOW) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED) action acl_experimental_trap(@sai_action_param(QOS_QUEUE) @id(1) qos_queue_t qos_queue) { + @id(0x01000103) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED) action acl_forward() { acl_ingress_meter.read(local_metadata.color); - acl_trap(qos_queue); } - @id(0x01000103) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_YELLOW) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED) action acl_forward() { - acl_ingress_counter.count(); - acl_ingress_meter.read(local_metadata.color); + @id(0x01000105) @sai_action(SAI_PACKET_ACTION_FORWARD) action acl_count() { + acl_ingress_counting_counter.count(); } @id(0x01000104) @sai_action(SAI_PACKET_ACTION_FORWARD) action acl_mirror(@id(1) @refers_to(mirror_session_table , mirror_session_id) @sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_MIRROR_INGRESS) mirror_session_id_t mirror_session_id) { acl_ingress_counter.count(); - local_metadata.mirror_session_id_valid = true; - local_metadata.mirror_session_id_value = mirror_session_id; + local_metadata.marked_to_mirror = true; + local_metadata.mirror_session_id = mirror_session_id; + } + @id(0x0100010C) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_COPY_CANCEL , SAI_PACKET_COLOR_RED) action set_qos_queue_and_cancel_copy_above_rate_limit(@id(1) @sai_action_param(QOS_QUEUE) qos_queue_t qos_queue) { + acl_ingress_qos_meter.read(local_metadata.color); + } + @id(0x01000111) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DENY , SAI_PACKET_COLOR_RED) @unsupported action set_cpu_and_multicast_queues_and_deny_above_rate_limit(@id(1) @sai_action_param(QOS_QUEUE) qos_queue_t cpu_queue, @id(2) @sai_action_param(MULTICAST_QOS_QUEUE , SAI_PACKET_COLOR_GREEN) qos_queue_t green_multicast_queue, @id(3) @sai_action_param(MULTICAST_QOS_QUEUE , SAI_PACKET_COLOR_RED) qos_queue_t red_multicast_queue) { + acl_ingress_qos_meter.read(local_metadata.color); + } + @id(0x0100010E) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DENY , SAI_PACKET_COLOR_RED) action set_cpu_queue_and_deny_above_rate_limit(@id(1) @sai_action_param(QOS_QUEUE) qos_queue_t cpu_queue) { + acl_ingress_qos_meter.read(local_metadata.color); } - @p4runtime_role("sdn_controller") @id(0x02000100) @sai_acl(INGRESS) @entry_restriction(" + @id(0x01000110) @sai_action(SAI_PACKET_ACTION_FORWARD) action set_cpu_queue(@id(1) @sai_action_param(QOS_QUEUE) qos_queue_t cpu_queue) { + } + @id(0x0100010F) @sai_action(SAI_PACKET_ACTION_DENY) action acl_deny() { + cancel_copy = true; + local_metadata.acl_drop = true; + } + @p4runtime_role("sdn_controller") @id(0x02000100) @sai_acl(INGRESS) @sai_acl_priority(5) @entry_restriction(" // Forbid using ether_type for IP packets (by convention, use is_ip* instead). ether_type != 0x0800 && ether_type != 0x86dd; // Only allow IP field matches for IP packets. dst_ip::mask != 0 -> is_ipv4 == 1; + + src_ip::mask != 0 -> is_ipv4 == 1; + dst_ipv6::mask != 0 -> is_ipv6 == 1; + src_ipv6::mask != 0 -> is_ipv6 == 1; ttl::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + dscp::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); ecn::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + ip_protocol::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); // Only allow l4_dst_port and l4_src_port matches for TCP/UDP packets. + l4_src_port::mask != 0 -> (ip_protocol == 6 || ip_protocol == 17); + l4_dst_port::mask != 0 -> (ip_protocol == 6 || ip_protocol == 17); - // Only allow icmp_type matches for ICMP packets + // Only allow icmp_type matches for ICMP packets icmp_type::mask != 0 -> ip_protocol == 1; icmpv6_type::mask != 0 -> ip_protocol == 58; @@ -701,39 +1191,206 @@ control acl_ingress(in headers_t headers, inout local_metadata_t local_metadata, is_ipv6::mask != 0 -> (is_ipv6 == 1); ") table acl_ingress_table { key = { - headers.ipv4.isValid() || headers.ipv6.isValid(): optional @name("is_ip") @id(1) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); - headers.ipv4.isValid() : optional @name("is_ipv4") @id(2) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); - headers.ipv6.isValid() : optional @name("is_ipv6") @id(3) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); - headers.ethernet.ether_type : ternary @name("ether_type") @id(4) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ETHER_TYPE); - headers.ethernet.dst_addr : ternary @name("dst_mac") @id(5) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_MAC) @format(MAC_ADDRESS); - headers.ipv4.src_addr : ternary @name("src_ip") @id(6) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_SRC_IP) @format(IPV4_ADDRESS); - headers.ipv4.dst_addr : ternary @name("dst_ip") @id(7) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_IP) @format(IPV4_ADDRESS); - headers.ipv6.src_addr[127:64] : ternary @name("src_ipv6") @id(8) @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_SRC_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_SRC_IPV6_WORD2 )) @format(IPV6_ADDRESS); - headers.ipv6.dst_addr[127:64] : ternary @name("dst_ipv6") @id(9) @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD2 )) @format(IPV6_ADDRESS); - ttl : ternary @name("ttl") @id(10) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_TTL); - dscp : ternary @name("dscp") @id(11) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DSCP); - ecn : ternary @name("ecn") @id(12) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ECN); - ip_protocol : ternary @name("ip_protocol") @id(13) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IP_PROTOCOL); - headers.icmp.type : ternary @name("icmp_type") @id(19) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ICMP_TYPE); - headers.icmp.type : ternary @name("icmpv6_type") @id(14) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ICMPV6_TYPE); - local_metadata.l4_src_port : ternary @name("l4_src_port") @id(20) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_L4_SRC_PORT); - local_metadata.l4_dst_port : ternary @name("l4_dst_port") @id(15) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_L4_DST_PORT); - local_metadata.ingress_port : optional @name("in_port") @id(17) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IN_PORT); - local_metadata.route_metadata : optional @name("route_metadata") @id(18) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ROUTE_DST_USER_META); + headers.ipv4.isValid() || headers.ipv6.isValid(): optional @id(1) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(2) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(3) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + headers.ethernet.ether_type : ternary @id(4) @name("ether_type") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ETHER_TYPE); + headers.ethernet.dst_addr : ternary @id(5) @name("dst_mac") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_MAC) @format(MAC_ADDRESS); + headers.ipv4.src_addr : ternary @id(6) @name("src_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_SRC_IP) @format(IPV4_ADDRESS); + headers.ipv4.dst_addr : ternary @id(7) @name("dst_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_IP) @format(IPV4_ADDRESS); + headers.ipv6.src_addr[127:64] : ternary @id(8) @name("src_ipv6") @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_SRC_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_SRC_IPV6_WORD2 )) @format(IPV6_ADDRESS); + headers.ipv6.dst_addr[127:64] : ternary @id(9) @name("dst_ipv6") @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD2 )) @format(IPV6_ADDRESS); + ttl : ternary @id(10) @name("ttl") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_TTL); + dscp : ternary @id(11) @name("dscp") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DSCP); + ecn : ternary @id(12) @name("ecn") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ECN); + ip_protocol : ternary @id(13) @name("ip_protocol") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IP_PROTOCOL); + headers.icmp.type : ternary @id(19) @name("icmp_type") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ICMP_TYPE); + headers.icmp.type : ternary @id(14) @name("icmpv6_type") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ICMPV6_TYPE); + local_metadata.l4_src_port : ternary @id(20) @name("l4_src_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_L4_SRC_PORT); + local_metadata.l4_dst_port : ternary @id(15) @name("l4_dst_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_L4_DST_PORT); + local_metadata.ingress_port : optional @id(17) @name("in_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IN_PORT); + local_metadata.route_metadata : optional @id(18) @name("route_metadata") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ROUTE_DST_USER_META); } actions = { @proto_id(1) acl_copy(); @proto_id(2) acl_trap(); @proto_id(3) acl_forward(); @proto_id(4) acl_mirror(); - @proto_id(5) acl_drop(standard_metadata); - @proto_id(99) acl_experimental_trap(); + @proto_id(5) acl_drop(local_metadata); @defaultonly NoAction; } const default_action = NoAction; meters = acl_ingress_meter; counters = acl_ingress_counter; - size = 128; + size = 255; + } + @id(0x02000107) @sai_acl(INGRESS) @sai_acl_priority(10) @p4runtime_role("sdn_controller") @entry_restriction(" + // Forbid using ether_type for IP packets (by convention, use is_ip* instead). + ether_type != 0x0800 && ether_type != 0x86dd; + // Only allow IP field matches for IP packets. + ttl::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + ip_protocol::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + // Only allow l4_dst_port matches for TCP/UDP packets. + l4_dst_port::mask != 0 -> (ip_protocol == 6 || ip_protocol == 17); + // Forbid illegal combinations of IP_TYPE fields. + is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0); + is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0); + is_ipv6::mask != 0 -> (is_ip::mask == 0 && is_ipv4::mask == 0); + // Forbid unsupported combinations of IP_TYPE fields. + is_ipv4::mask != 0 -> (is_ipv4 == 1); + is_ipv6::mask != 0 -> (is_ipv6 == 1); + // Only allow icmp_type matches for ICMP packets + icmpv6_type::mask != 0 -> ip_protocol == 58; + + // Only allow l4_dst_port matches for TCP/UDP packets. + l4_src_port::mask != 0 -> (ip_protocol == 6 || ip_protocol == 17); + // Only allow icmp_type matches for ICMP packets + icmp_type::mask != 0 -> ip_protocol == 1; + + + + + + ") table acl_ingress_qos_table { + key = { + headers.ipv4.isValid() || headers.ipv6.isValid(): optional @id(1) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(2) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(3) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + headers.ethernet.ether_type : ternary @id(4) @name("ether_type") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ETHER_TYPE); + ttl : ternary @id(7) @name("ttl") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_TTL); + ip_protocol : ternary @id(8) @name("ip_protocol") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IP_PROTOCOL); + headers.icmp.type : ternary @id(9) @name("icmpv6_type") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ICMPV6_TYPE); + local_metadata.l4_dst_port : ternary @id(10) @name("l4_dst_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_L4_DST_PORT); + local_metadata.l4_src_port : ternary @id(12) @name("l4_src_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_L4_SRC_PORT); + headers.icmp.type : ternary @id(14) @name("icmp_type") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ICMP_TYPE); + local_metadata.route_metadata : ternary @id(15) @name("route_metadata") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ROUTE_DST_USER_META); + } + actions = { + @proto_id(1) set_qos_queue_and_cancel_copy_above_rate_limit(); + @proto_id(2) set_cpu_queue_and_deny_above_rate_limit(); + @proto_id(3) acl_forward(); + @proto_id(4) acl_drop(local_metadata); + @proto_id(5) set_cpu_queue(); + @proto_id(6) set_cpu_and_multicast_queues_and_deny_above_rate_limit(); + @defaultonly NoAction; + } + const default_action = NoAction; + meters = acl_ingress_qos_meter; + counters = acl_ingress_qos_counter; + size = 511; + } + @p4runtime_role("sdn_controller") @id(0x02000109) @sai_acl_priority(7) @sai_acl(INGRESS) @entry_restriction(" + // Only allow IP field matches for IP packets. + dscp::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + // Forbid illegal combinations of IP_TYPE fields. + is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0); + is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0); + is_ipv6::mask != 0 -> (is_ip::mask == 0 && is_ipv4::mask == 0); + // Forbid unsupported combinations of IP_TYPE fields. + is_ipv4::mask != 0 -> (is_ipv4 == 1); + is_ipv6::mask != 0 -> (is_ipv6 == 1); + ") table acl_ingress_counting_table { + key = { + headers.ipv4.isValid() || headers.ipv6.isValid(): optional @id(1) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(2) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(3) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + dscp : ternary @id(11) @name("dscp") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DSCP); + local_metadata.route_metadata : ternary @id(18) @name("route_metadata") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ROUTE_DST_USER_META); + } + actions = { + @proto_id(3) acl_count(); + @defaultonly NoAction; + } + const default_action = NoAction; + counters = acl_ingress_counting_counter; + size = 255; + } + @id(0x01000112) action redirect_to_nexthop(@sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_REDIRECT) @sai_action_param_object_type(SAI_OBJECT_TYPE_NEXT_HOP) @refers_to(nexthop_table , nexthop_id) nexthop_id_t nexthop_id) { + local_metadata.nexthop_id_valid = true; + local_metadata.nexthop_id_value = nexthop_id; + local_metadata.wcmp_group_id_valid = false; + standard_metadata.mcast_grp = 0; + } + @id(0x01000113) @action_restriction(" + // Disallow 0 since it encodes 'no multicast' in V1Model. + multicast_group_id != 0; + ") action redirect_to_ipmc_group(@sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_REDIRECT) @sai_action_param_object_type(SAI_OBJECT_TYPE_IPMC_GROUP) @refers_to(builtin : : multicast_group_table , multicast_group_id) multicast_group_id_t multicast_group_id) { + standard_metadata.mcast_grp = multicast_group_id; + local_metadata.nexthop_id_valid = false; + local_metadata.wcmp_group_id_valid = false; + } + @id(0x0200010B) @sai_acl(INGRESS) @sai_acl_priority(15) @p4runtime_role("sdn_controller") @entry_restriction(" + // Only allow IP field matches for IP packets. + dst_ip::mask != 0 -> is_ipv4 == 1; + dst_ipv6::mask != 0 -> is_ipv6 == 1; + // Forbid illegal combinations of IP_TYPE fields. + is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0); + is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0); + is_ipv6::mask != 0 -> (is_ip::mask == 0 && is_ipv4::mask == 0); + // Forbid unsupported combinations of IP_TYPE fields. + is_ipv4::mask != 0 -> (is_ipv4 == 1); + is_ipv6::mask != 0 -> (is_ipv6 == 1); + ") table acl_ingress_mirror_and_redirect_table { + key = { + headers.ipv4.isValid() || headers.ipv6.isValid(): optional @id(2) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(3) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(4) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + headers.ipv4.dst_addr : ternary @id(10) @name("dst_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_IP) @format(IPV4_ADDRESS); + headers.ipv6.dst_addr[127:64] : ternary @id(5) @name("dst_ipv6") @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD2 )) @format(IPV6_ADDRESS); + local_metadata.vrf_id : optional @id(8) @name("vrf_id") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_VRF_ID); + local_metadata.ipmc_table_hit : optional @id(9) @name("ipmc_table_hit") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IPMC_NPU_META_DST_HIT); + } + actions = { + @proto_id(4) acl_forward(); + @proto_id(1) acl_mirror(); + @proto_id(2) redirect_to_nexthop(); + @proto_id(3) redirect_to_ipmc_group(); + @defaultonly NoAction; + } + const default_action = NoAction; + size = 255; + } + @id(0x0200010A) @sai_acl(INGRESS) @sai_acl_priority(20) @p4runtime_role("sdn_controller") @entry_restriction(" + // Forbid using ether_type for IP packets (by convention, use is_ip* instead). + ether_type != 0x0800 && ether_type != 0x86dd; + + + + + + + // TODO: This comment is required for the preprocessor to not + // spit out nonsense. + + + + + + + + // Forbid illegal combinations of IP_TYPE fields. + is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0); + is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0); + is_ipv6::mask != 0 -> (is_ip::mask == 0 && is_ipv4::mask == 0); + // Forbid unsupported combinations of IP_TYPE fields. + is_ipv4::mask != 0 -> (is_ipv4 == 1); + is_ipv6::mask != 0 -> (is_ipv6 == 1); + ") table acl_ingress_security_table { + key = { + headers.ipv4.isValid() || headers.ipv6.isValid(): optional @id(1) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(2) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(3) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + headers.ethernet.ether_type : ternary @id(4) @name("ether_type") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ETHER_TYPE); + } + actions = { + @proto_id(1) acl_forward(); + @proto_id(2) acl_drop(local_metadata); + @proto_id(3) acl_deny(); + @defaultonly NoAction; + } + const default_action = NoAction; + counters = acl_ingress_security_counter; + size = 255; } apply { if (headers.ipv4.isValid()) { @@ -748,19 +1405,37 @@ control acl_ingress(in headers_t headers, inout local_metadata_t local_metadata, ip_protocol = headers.ipv6.next_header; } acl_ingress_table.apply(); + acl_ingress_counting_table.apply(); + acl_ingress_qos_table.apply(); + if (cancel_copy) { + local_metadata.marked_to_copy = false; + } } } control acl_pre_ingress(in headers_t headers, inout local_metadata_t local_metadata, in standard_metadata_t standard_metadata) { bit<6> dscp = 0; + bit<2> ecn = 0; + bit<8> ip_protocol = 0; @id(0x13000101) direct_counter(CounterType.packets_and_bytes) acl_pre_ingress_counter; + @id(0x13000106) direct_counter(CounterType.packets_and_bytes) acl_pre_ingress_vlan_counter; + @id(0x13000105) direct_counter(CounterType.packets_and_bytes) acl_pre_ingress_metadata_counter; @id(0x01000100) @sai_action(SAI_PACKET_ACTION_FORWARD) action set_vrf(@sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_SET_VRF) @refers_to(vrf_table , vrf_id) @id(1) vrf_id_t vrf_id) { local_metadata.vrf_id = vrf_id; acl_pre_ingress_counter.count(); } - @p4runtime_role("sdn_controller") @id(0x02000101) @sai_acl(PRE_INGRESS) @entry_restriction(" + @id(0x0100010A) @sai_action(SAI_PACKET_ACTION_FORWARD) action set_outer_vlan_id(@id(1) @sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_SET_OUTER_VLAN_ID) vlan_id_t vlan_id) { + local_metadata.vlan_id = vlan_id; + acl_pre_ingress_vlan_counter.count(); + } + @id(0x0100010B) @sai_action(SAI_PACKET_ACTION_FORWARD) action set_acl_metadata(@id(1) @sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_SET_ACL_META_DATA) acl_metadata_t acl_metadata) { + local_metadata.acl_metadata = acl_metadata; + acl_pre_ingress_metadata_counter.count(); + } + @p4runtime_role("sdn_controller") @id(0x02000101) @sai_acl(PRE_INGRESS) @sai_acl_priority(11) @entry_restriction(" // Only allow IP field matches for IP packets. dscp::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + ecn::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); dst_ip::mask != 0 -> is_ipv4 == 1; dst_ipv6::mask != 0 -> is_ipv6 == 1; // Forbid illegal combinations of IP_TYPE fields. @@ -770,20 +1445,25 @@ control acl_pre_ingress(in headers_t headers, inout local_metadata_t local_metad // Forbid unsupported combinations of IP_TYPE fields. is_ipv4::mask != 0 -> (is_ipv4 == 1); is_ipv6::mask != 0 -> (is_ipv6 == 1); + + + + // Reserve high priorities for switch-internal use. // TODO: Remove once inband workaround is obsolete. ::priority < 0x7fffffff; ") table acl_pre_ingress_table { key = { - headers.ipv4.isValid() || headers.ipv6.isValid(): optional @name("is_ip") @id(1) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); - headers.ipv4.isValid() : optional @name("is_ipv4") @id(2) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); - headers.ipv6.isValid() : optional @name("is_ipv6") @id(3) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); - headers.ethernet.src_addr : ternary @name("src_mac") @id(4) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_SRC_MAC) @format(MAC_ADDRESS); - headers.ethernet.dst_addr : ternary @name("dst_mac") @id(9) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_MAC) @format(MAC_ADDRESS); - headers.ipv4.dst_addr : ternary @name("dst_ip") @id(5) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_IP) @format(IPV4_ADDRESS); - headers.ipv6.dst_addr[127:64] : ternary @name("dst_ipv6") @id(6) @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD2 )) @format(IPV6_ADDRESS); - dscp : ternary @name("dscp") @id(7) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DSCP); - local_metadata.ingress_port : optional @name("in_port") @id(8) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IN_PORT); + headers.ipv4.isValid() || headers.ipv6.isValid(): optional @id(1) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(2) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(3) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + headers.ethernet.src_addr : ternary @id(4) @name("src_mac") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_SRC_MAC) @format(MAC_ADDRESS); + headers.ethernet.dst_addr : ternary @id(9) @name("dst_mac") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_MAC) @format(MAC_ADDRESS); + headers.ipv4.dst_addr : ternary @id(5) @name("dst_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_IP) @format(IPV4_ADDRESS); + headers.ipv6.dst_addr[127:64] : ternary @id(6) @name("dst_ipv6") @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD2 )) @format(IPV6_ADDRESS); + dscp : ternary @id(7) @name("dscp") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DSCP); + ecn : ternary @id(10) @name("ecn") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ECN); + local_metadata.ingress_port : optional @id(8) @name("in_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IN_PORT); } actions = { @proto_id(1) set_vrf; @@ -791,43 +1471,168 @@ control acl_pre_ingress(in headers_t headers, inout local_metadata_t local_metad } const default_action = NoAction; counters = acl_pre_ingress_counter; - size = 255; + size = 254; + } + @id(0x02000105) @sai_acl(PRE_INGRESS) @p4runtime_role("sdn_controller") @sai_acl_priority(1) @entry_restriction(" + // Forbid using ether_type for IP packets (by convention, use is_ip* instead). + ether_type != 0x0800 && ether_type != 0x86dd; + // Forbid illegal combinations of IP_TYPE fields. + is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0); + is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0); + is_ipv6::mask != 0 -> (is_ip::mask == 0 && is_ipv4::mask == 0); + // Forbid unsupported combinations of IP_TYPE fields. + is_ipv4::mask != 0 -> (is_ipv4 == 1); + is_ipv6::mask != 0 -> (is_ipv6 == 1); + // Disallow match on reserved VLAN IDs to rule out vendor specific behavior. + vlan_id::mask != 0 -> (vlan_id != 4095 && vlan_id != 0); + // TODO: Disallow setting to reserved VLAN IDs when supported. + ") table acl_pre_ingress_vlan_table { + key = { + headers.ipv4.isValid() || headers.ipv6.isValid(): optional @id(1) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(2) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(3) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + headers.ethernet.ether_type : ternary @id(4) @name("ether_type") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ETHER_TYPE); + local_metadata.vlan_id : ternary @id(5) @name("vlan_id") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_OUTER_VLAN_ID); + } + actions = { + @proto_id(1) set_outer_vlan_id; + @defaultonly NoAction; + } + const default_action = NoAction; + counters = acl_pre_ingress_vlan_counter; + size = 254; + } + @id(0x02000106) @sai_acl(PRE_INGRESS) @p4runtime_role("sdn_controller") @sai_acl_priority(5) @entry_restriction(" + // Forbid illegal combinations of IP_TYPE fields. + is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0); + is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0); + is_ipv6::mask != 0 -> (is_ip::mask == 0 && is_ipv4::mask == 0); + // DSCP is only allowed on IP traffic. + dscp::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + ecn::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + // Forbid unsupported combinations of IP_TYPE fields. + is_ipv4::mask != 0 -> (is_ipv4 == 1); + is_ipv6::mask != 0 -> (is_ipv6 == 1); + // Only allow icmp_type matches for ICMP packets + icmpv6_type::mask != 0 -> ip_protocol == 58; + ") table acl_pre_ingress_metadata_table { + key = { + headers.ipv4.isValid() || headers.ipv6.isValid(): optional @id(1) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(2) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(3) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + ip_protocol : ternary @id(4) @name("ip_protocol") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IP_PROTOCOL); + headers.icmp.type : ternary @id(5) @name("icmpv6_type") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ICMPV6_TYPE); + dscp : ternary @id(6) @name("dscp") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DSCP); + ecn : ternary @id(7) @name("ecn") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ECN); + } + actions = { + @proto_id(1) set_acl_metadata; + @defaultonly NoAction; + } + const default_action = NoAction; + counters = acl_pre_ingress_metadata_counter; + size = 254; } apply { if (headers.ipv4.isValid()) { dscp = headers.ipv4.dscp; + ecn = headers.ipv4.ecn; + ip_protocol = headers.ipv4.protocol; } else if (headers.ipv6.isValid()) { dscp = headers.ipv6.dscp; + ecn = headers.ipv6.ecn; + ip_protocol = headers.ipv6.next_header; } - local_metadata.vrf_id = kDefaultVrf; acl_pre_ingress_table.apply(); } } control admit_google_system_mac(in headers_t headers, inout local_metadata_t local_metadata) { apply { - local_metadata.admit_to_l3 = headers.ethernet.dst_addr & 0x10000000000 == 0; + local_metadata.admit_to_l3 = headers.ethernet.dst_addr == 0x1a11175f80; + } +} + +control hashing(in headers_t headers, inout local_metadata_t local_metadata, in standard_metadata_t standard_metadata) { + bit<32> seed = 0; + bit<8> offset = 0; + @sai_hash_seed(0) @id(0x010000A) action select_ecmp_hash_algorithm() { + seed = 0; + } + @sai_ecmp_hash(SAI_SWITCH_ATTR_ECMP_HASH_IPV4) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_SRC_IPV4) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_DST_IPV4) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_SRC_PORT) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_DST_PORT) @id(0x0100000B) action compute_ecmp_hash_ipv4() { + hash(local_metadata.wcmp_selector_input, HashAlgorithm.crc32, 1w0, { seed, headers.ipv4.src_addr, headers.ipv4.dst_addr, local_metadata.l4_src_port, local_metadata.l4_dst_port }, 17w0x10000); + local_metadata.wcmp_selector_input = local_metadata.wcmp_selector_input >> offset | local_metadata.wcmp_selector_input << 8 - offset; + } + @sai_ecmp_hash(SAI_SWITCH_ATTR_ECMP_HASH_IPV6) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_SRC_IPV6) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_DST_IPV6) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_SRC_PORT) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_DST_PORT) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_IPV6_FLOW_LABEL) @id(0x0100000C) action compute_ecmp_hash_ipv6() { + hash(local_metadata.wcmp_selector_input, HashAlgorithm.crc32, 1w0, { seed, headers.ipv6.flow_label, headers.ipv6.src_addr, headers.ipv6.dst_addr, local_metadata.l4_src_port, local_metadata.l4_dst_port }, 17w0x10000); + local_metadata.wcmp_selector_input = local_metadata.wcmp_selector_input >> offset | local_metadata.wcmp_selector_input << 8 - offset; + } + apply { + select_ecmp_hash_algorithm(); + if (headers.ipv4.isValid()) { + compute_ecmp_hash_ipv4(); + } else if (headers.ipv6.isValid()) { + compute_ecmp_hash_ipv6(); + } + } +} + +control lag_hashing_config(in headers_t headers) { + bit<32> lag_seed = 0; + bit<4> lag_offset = 0; + @sai_hash_algorithm(SAI_HASH_ALGORITHM_CRC) @sai_hash_seed(0) @sai_hash_offset(0) action select_lag_hash_algorithm() { + lag_seed = 0; + lag_offset = 0; + } + @sai_lag_hash(SAI_SWITCH_ATTR_LAG_HASH_IPV4) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_SRC_IPV4) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_DST_IPV4) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_SRC_PORT) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_DST_PORT) @id(0x0100000D) action compute_lag_hash_ipv4() { + } + @sai_lag_hash(SAI_SWITCH_ATTR_LAG_HASH_IPV6) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_SRC_IPV6) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_DST_IPV6) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_SRC_PORT) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_DST_PORT) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_IPV6_FLOW_LABEL) @id(0x0100000E) action compute_lag_hash_ipv6() { + } + apply { + select_lag_hash_algorithm(); + if (headers.ipv4.isValid()) { + compute_lag_hash_ipv4(); + } else if (headers.ipv6.isValid()) { + compute_lag_hash_ipv6(); + } } } control ingress(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { apply { - acl_pre_ingress.apply(headers, local_metadata, standard_metadata); - admit_google_system_mac.apply(headers, local_metadata); - l3_admit.apply(headers, local_metadata, standard_metadata); - routing.apply(headers, local_metadata, standard_metadata); - acl_ingress.apply(headers, local_metadata, standard_metadata); - ttl.apply(headers, local_metadata, standard_metadata); - mirroring_clone.apply(headers, local_metadata, standard_metadata); + packet_out_decap.apply(headers, local_metadata, standard_metadata); + if (!local_metadata.bypass_ingress) { + tunnel_termination_lookup.apply(headers, local_metadata); + vlan_untag.apply(headers, local_metadata, standard_metadata); + acl_pre_ingress.apply(headers, local_metadata, standard_metadata); + ingress_vlan_checks.apply(headers, local_metadata, standard_metadata); + tunnel_termination_decap.apply(headers, local_metadata); + admit_google_system_mac.apply(headers, local_metadata); + l3_admit.apply(headers, local_metadata, standard_metadata); + hashing.apply(headers, local_metadata, standard_metadata); + lag_hashing_config.apply(headers); + routing_lookup.apply(headers, local_metadata, standard_metadata); + acl_ingress.apply(headers, local_metadata, standard_metadata); + routing_resolution.apply(headers, local_metadata, standard_metadata); + mirror_session_lookup.apply(headers, local_metadata, standard_metadata); + ingress_cloning.apply(headers, local_metadata, standard_metadata); + drop_martians.apply(headers, local_metadata, standard_metadata); + } } } control egress(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { apply { - packet_rewrites.apply(headers, local_metadata, standard_metadata); - mirroring_encap.apply(headers, local_metadata, standard_metadata); - acl_egress.apply(headers, local_metadata, standard_metadata); + packet_in_encap.apply(headers, local_metadata, standard_metadata); + if (!(standard_metadata.instance_type == 1 && standard_metadata.egress_rid == 1)) { + packet_rewrites.apply(headers, local_metadata, standard_metadata); + gre_tunnel_encap.apply(headers, local_metadata, standard_metadata); + mirroring_encap.apply(headers, local_metadata, standard_metadata); + egress_vlan_checks.apply(headers, local_metadata, standard_metadata); + vlan_tag.apply(headers, local_metadata, standard_metadata); + acl_egress.apply(headers, local_metadata, standard_metadata); + } } } -@pkginfo(name="fabric_border_router.p4", organization="Google") V1Switch(packet_parser(), verify_ipv4_checksum(), ingress(), egress(), compute_ipv4_checksum(), packet_deparser()) main; +@pkginfo(name="fabric_border_router.p4", organization="Google", version="1.6.1") V1Switch(packet_parser(), verify_ipv4_checksum(), ingress(), egress(), compute_ipv4_checksum(), packet_deparser()) main; diff --git a/testdata/p4_16_samples_outputs/pins/pins_fabric.p4-stderr b/testdata/p4_16_samples_outputs/pins/pins_fabric.p4-stderr index 9483c7c584..965963a073 100644 --- a/testdata/p4_16_samples_outputs/pins/pins_fabric.p4-stderr +++ b/testdata/p4_16_samples_outputs/pins/pins_fabric.p4-stderr @@ -1,36 +1,102 @@ -pins_fabric.p4(645): [--Wwarn=shadow] warning: 'ttl' shadows 'control ttl' - bit<8> ttl = 0; - ^^^^^^^^^^^^^^ -pins_fabric.p4(558) -control ttl(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { - ^^^ -pins_fabric.p4(314): [--Wwarn=deprecated] warning: set_nexthop: Using deprecated feature set_nexthop. Use set_ip_nexthop instead. +pins_fabric.p4(615): [--Wwarn=deprecated] warning: set_nexthop: Using deprecated feature set_nexthop. Use set_ip_nexthop instead. @proto_id(1) set_nexthop; ^^^^^^^^^^^ -pins_fabric.p4(306) +pins_fabric.p4(603) @id(0x01000003) @deprecated("Use set_ip_nexthop instead.") action set_nexthop(@id(1) @refers_to(router_interface_table , router_interface_id) @refers_to(neighbor_table , router_interface_id) router_interface_id_t router_interface_id, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) ipv6_addr_t neighbor_id) { ^^^^^^^^^^^ -pins_fabric.p4(651): [--Wwarn=unused] warning: 'qos_queue' is unused - @id(0x01000101) @sai_action(SAI_PACKET_ACTION_COPY , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_YELLOW) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_RED) action acl_copy(@sai_action_param(QOS_QUEUE) @id(1) qos_queue_t qos_queue) { - ^^^^^^^^^ -pins_fabric.p4(333): [--Wwarn=uninitialized_use] warning: wcmp_group_id_value may not be completely initialized - wcmp_group_id_value : exact @id(1) @name("wcmp_group_id"); - ^^^^^^^^^^^^^^^^^^^ -pins_fabric.p4(311): [--Wwarn=uninitialized_use] warning: nexthop_id_value may not be completely initialized - nexthop_id_value: exact @id(1) @name("nexthop_id"); - ^^^^^^^^^^^^^^^^ -pins_fabric.p4(291): [--Wwarn=uninitialized_use] warning: router_interface_id_value may not be completely initialized +pins_fabric.p4(846): [--Wwarn=ignore-prop] warning: KeyElement: constant key element + 1w1: ternary @id(1) @name("dummy_match"); + ^^^ +pins_fabric.p4(717): [--Wwarn=unused] warning: 'port' is unused + @id(0x01000007) action mirror_as_ipv4_erspan(@id(1) port_id_t port, @id(2) @format(IPV4_ADDRESS) ipv4_addr_t src_ip, @id(3) @format(IPV4_ADDRESS) ipv4_addr_t dst_ip, @id(4) @format(MAC_ADDRESS) ethernet_addr_t src_mac, @id(5) @format(MAC_ADDRESS) ethernet_addr_t dst_mac, @id(6) bit<8> ttl, @id(7) bit<8> tos) { + ^^^^ +pins_fabric.p4(717): [--Wwarn=unused] warning: 'src_ip' is unused + @id(0x01000007) action mirror_as_ipv4_erspan(@id(1) port_id_t port, @id(2) @format(IPV4_ADDRESS) ipv4_addr_t src_ip, @id(3) @format(IPV4_ADDRESS) ipv4_addr_t dst_ip, @id(4) @format(MAC_ADDRESS) ethernet_addr_t src_mac, @id(5) @format(MAC_ADDRESS) ethernet_addr_t dst_mac, @id(6) bit<8> ttl, @id(7) bit<8> tos) { + ^^^^^^ +pins_fabric.p4(717): [--Wwarn=unused] warning: 'dst_ip' is unused + @id(0x01000007) action mirror_as_ipv4_erspan(@id(1) port_id_t port, @id(2) @format(IPV4_ADDRESS) ipv4_addr_t src_ip, @id(3) @format(IPV4_ADDRESS) ipv4_addr_t dst_ip, @id(4) @format(MAC_ADDRESS) ethernet_addr_t src_mac, @id(5) @format(MAC_ADDRESS) ethernet_addr_t dst_mac, @id(6) bit<8> ttl, @id(7) bit<8> tos) { + ^^^^^^ +pins_fabric.p4(717): [--Wwarn=unused] warning: 'src_mac' is unused + @id(0x01000007) action mirror_as_ipv4_erspan(@id(1) port_id_t port, @id(2) @format(IPV4_ADDRESS) ipv4_addr_t src_ip, @id(3) @format(IPV4_ADDRESS) ipv4_addr_t dst_ip, @id(4) @format(MAC_ADDRESS) ethernet_addr_t src_mac, @id(5) @format(MAC_ADDRESS) ethernet_addr_t dst_mac, @id(6) bit<8> ttl, @id(7) bit<8> tos) { + ^^^^^^^ +pins_fabric.p4(717): [--Wwarn=unused] warning: 'dst_mac' is unused + @id(0x01000007) action mirror_as_ipv4_erspan(@id(1) port_id_t port, @id(2) @format(IPV4_ADDRESS) ipv4_addr_t src_ip, @id(3) @format(IPV4_ADDRESS) ipv4_addr_t dst_ip, @id(4) @format(MAC_ADDRESS) ethernet_addr_t src_mac, @id(5) @format(MAC_ADDRESS) ethernet_addr_t dst_mac, @id(6) bit<8> ttl, @id(7) bit<8> tos) { + ^^^^^^^ +pins_fabric.p4(717): [--Wwarn=unused] warning: 'ttl' is unused + @id(0x01000007) action mirror_as_ipv4_erspan(@id(1) port_id_t port, @id(2) @format(IPV4_ADDRESS) ipv4_addr_t src_ip, @id(3) @format(IPV4_ADDRESS) ipv4_addr_t dst_ip, @id(4) @format(MAC_ADDRESS) ethernet_addr_t src_mac, @id(5) @format(MAC_ADDRESS) ethernet_addr_t dst_mac, @id(6) bit<8> ttl, @id(7) bit<8> tos) { + ^^^ +pins_fabric.p4(717): [--Wwarn=unused] warning: 'tos' is unused + @id(0x01000007) action mirror_as_ipv4_erspan(@id(1) port_id_t port, @id(2) @format(IPV4_ADDRESS) ipv4_addr_t src_ip, @id(3) @format(IPV4_ADDRESS) ipv4_addr_t dst_ip, @id(4) @format(MAC_ADDRESS) ethernet_addr_t src_mac, @id(5) @format(MAC_ADDRESS) ethernet_addr_t dst_mac, @id(6) bit<8> ttl, @id(7) bit<8> tos) { + ^^^ +pins_fabric.p4(719): [--Wwarn=unused] warning: 'monitor_failover_port' is unused + @id(0x0100001D) @unsupported action mirror_with_vlan_tag_and_ipfix_encapsulation(@id(1) port_id_t monitor_port, @id(2) port_id_t monitor_failover_port, @id(3) @format(MAC_ADDRESS) ethernet_addr_t mirror_encap_src_mac, @id(4) @format(MAC_ADDRESS) ethernet_addr_t mirror_encap_dst_mac, @id(6) vlan_id_t mirror_encap_vlan_id, @id(7) @format(IPV6_ADDRESS) ipv6_addr_t mirror_encap_dst_ip, @id(8) @format(IPV6_ADDRESS) ipv6_addr_t mirror_encap_src_ip, @id(9) bit<16> mirror_encap_udp_src_port, @id(10) bit<16> mirror_encap_udp_dst_port) { + ^^^^^^^^^^^^^^^^^^^^^ +pins_fabric.p4(1082): [--Wwarn=unused] warning: Table acl_egress_dhcp_to_host_table is not used; removing + ") table acl_egress_dhcp_to_host_table { + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +pins_fabric.p4(1128): [--Wwarn=unused] warning: 'qos_queue' is unused + @id(0x01000101) @sai_action(SAI_PACKET_ACTION_COPY , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_RED) action acl_copy(@sai_action_param(QOS_QUEUE) @id(1) qos_queue_t qos_queue) { + ^^^^^^^^^ +pins_fabric.p4(1148): [--Wwarn=unused] warning: 'qos_queue' is unused + @id(0x0100010C) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_COPY_CANCEL , SAI_PACKET_COLOR_RED) action set_qos_queue_and_cancel_copy_above_rate_limit(@id(1) @sai_action_param(QOS_QUEUE) qos_queue_t qos_queue) { + ^^^^^^^^^ +pins_fabric.p4(1151): [--Wwarn=unused] warning: 'cpu_queue' is unused + @id(0x01000111) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DENY , SAI_PACKET_COLOR_RED) @unsupported action set_cpu_and_multicast_queues_and_deny_above_rate_limit(@id(1) @sai_action_param(QOS_QUEUE) qos_queue_t cpu_queue, @id(2) @sai_action_param(MULTICAST_QOS_QUEUE , SAI_PACKET_COLOR_GREEN) qos_queue_t green_multicast_queue, @id(3) @sai_action_param(MULTICAST_QOS_QUEUE , SAI_PACKET_COLOR_RED) qos_queue_t red_multicast_queue) { + ^^^^^^^^^ +pins_fabric.p4(1151): [--Wwarn=unused] warning: 'green_multicast_queue' is unused + @id(0x01000111) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DENY , SAI_PACKET_COLOR_RED) @unsupported action set_cpu_and_multicast_queues_and_deny_above_rate_limit(@id(1) @sai_action_param(QOS_QUEUE) qos_queue_t cpu_queue, @id(2) @sai_action_param(MULTICAST_QOS_QUEUE , SAI_PACKET_COLOR_GREEN) qos_queue_t green_multicast_queue, @id(3) @sai_action_param(MULTICAST_QOS_QUEUE , SAI_PACKET_COLOR_RED) qos_queue_t red_multicast_queue) { + ^^^^^^^^^^^^^^^^^^^^^ +pins_fabric.p4(1151): [--Wwarn=unused] warning: 'red_multicast_queue' is unused + @id(0x01000111) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DENY , SAI_PACKET_COLOR_RED) @unsupported action set_cpu_and_multicast_queues_and_deny_above_rate_limit(@id(1) @sai_action_param(QOS_QUEUE) qos_queue_t cpu_queue, @id(2) @sai_action_param(MULTICAST_QOS_QUEUE , SAI_PACKET_COLOR_GREEN) qos_queue_t green_multicast_queue, @id(3) @sai_action_param(MULTICAST_QOS_QUEUE , SAI_PACKET_COLOR_RED) qos_queue_t red_multicast_queue) { + ^^^^^^^^^^^^^^^^^^^ +pins_fabric.p4(1154): [--Wwarn=unused] warning: 'cpu_queue' is unused + @id(0x0100010E) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DENY , SAI_PACKET_COLOR_RED) action set_cpu_queue_and_deny_above_rate_limit(@id(1) @sai_action_param(QOS_QUEUE) qos_queue_t cpu_queue) { + ^^^^^^^^^ +pins_fabric.p4(1157): [--Wwarn=unused] warning: 'cpu_queue' is unused + @id(0x01000110) @sai_action(SAI_PACKET_ACTION_FORWARD) action set_cpu_queue(@id(1) @sai_action_param(QOS_QUEUE) qos_queue_t cpu_queue) { + ^^^^^^^^^ +pins_fabric.p4(1341): [--Wwarn=unused] warning: Table acl_ingress_mirror_and_redirect_table is not used; removing + ") table acl_ingress_mirror_and_redirect_table { + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +pins_fabric.p4(1386): [--Wwarn=unused] warning: Table acl_ingress_security_table is not used; removing + ") table acl_ingress_security_table { + ^^^^^^^^^^^^^^^^^^^^^^^^^^ +pins_fabric.p4(1497): [--Wwarn=unused] warning: Table acl_pre_ingress_vlan_table is not used; removing + ") table acl_pre_ingress_vlan_table { + ^^^^^^^^^^^^^^^^^^^^^^^^^^ +pins_fabric.p4(1526): [--Wwarn=unused] warning: Table acl_pre_ingress_metadata_table is not used; removing + ") table acl_pre_ingress_metadata_table { + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +pins_fabric.p4(1025): [--Wwarn=unused] warning: acl_egress_dhcp_to_host_counter: unused instance + @id(0x13000108) direct_counter(CounterType.packets_and_bytes) acl_egress_dhcp_to_host_counter; + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +pins_fabric.p4(1127): [--Wwarn=unused] warning: acl_ingress_security_counter: unused instance + @id(0x1300010A) direct_counter(CounterType.packets_and_bytes) acl_ingress_security_counter; + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +pins_fabric.p4(1429): [--Wwarn=unused] warning: acl_pre_ingress_vlan_counter: unused instance + @id(0x13000106) direct_counter(CounterType.packets_and_bytes) acl_pre_ingress_vlan_counter; + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +pins_fabric.p4(1430): [--Wwarn=unused] warning: acl_pre_ingress_metadata_counter: unused instance + @id(0x13000105) direct_counter(CounterType.packets_and_bytes) acl_pre_ingress_metadata_counter; + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +pins_fabric.p4(632): [--Wwarn=uninitialized_use] warning: tunnel_id_value may not be completely initialized + tunnel_id_value: exact @id(1) @name("tunnel_id"); + ^^^^^^^^^^^^^^^ +pins_fabric.p4(580): [--Wwarn=uninitialized_use] warning: router_interface_id_value may not be completely initialized router_interface_id_value: exact @id(1) @name("router_interface_id"); ^^^^^^^^^^^^^^^^^^^^^^^^^ -pins_fabric.p4(275): [--Wwarn=uninitialized_use] warning: router_interface_id_value may not be completely initialized +pins_fabric.p4(558): [--Wwarn=uninitialized_use] warning: router_interface_id_value may not be completely initialized router_interface_id_value: exact @id(1) @name("router_interface_id") @refers_to(router_interface_table , router_interface_id); ^^^^^^^^^^^^^^^^^^^^^^^^^ -pins_fabric.p4(276): [--Wwarn=uninitialized_use] warning: neighbor_id_value may be uninitialized +pins_fabric.p4(559): [--Wwarn=uninitialized_use] warning: neighbor_id_value may be uninitialized neighbor_id_value : exact @id(2) @format(IPV6_ADDRESS) @name("neighbor_id"); ^^^^^^^^^^^^^^^^^ -pins_fabric.p4(518): [--Wwarn=uninitialized_use] warning: mirror_port may not be completely initialized - mirror_port: exact @id(1); - ^^^^^^^^^^^ -pins_fabric.p4(530): [--Wwarn=uninitialized_use] warning: pre_session may be uninitialized - clone_preserving_field_list(CloneType.I2E, pre_session, (bit<8>)PreservedFieldList.CLONE_I2E); - ^^^^^^^^^^^ +pins_fabric.p4(846): [--Wwarn=mismatch] warning: 1w1: Constant key field + 1w1: ternary @id(1) @name("dummy_match"); + ^^^ +pins_fabric.p4(1572): [--Wwarn=overflow] warning: local_metadata._wcmp_selector_input13 << 8: shifting value with 8 bits by 8 + local_metadata.wcmp_selector_input = local_metadata.wcmp_selector_input >> offset | local_metadata.wcmp_selector_input << 8 - offset; + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +pins_fabric.p4(1576): [--Wwarn=overflow] warning: local_metadata._wcmp_selector_input13 << 8: shifting value with 8 bits by 8 + local_metadata.wcmp_selector_input = local_metadata.wcmp_selector_input >> offset | local_metadata.wcmp_selector_input << 8 - offset; + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/testdata/p4_16_samples_outputs/pins/pins_fabric.p4.p4info.txtpb b/testdata/p4_16_samples_outputs/pins/pins_fabric.p4.p4info.txtpb index dafd050fb7..5dee71f377 100644 --- a/testdata/p4_16_samples_outputs/pins/pins_fabric.p4.p4info.txtpb +++ b/testdata/p4_16_samples_outputs/pins/pins_fabric.p4.p4info.txtpb @@ -3,9 +3,68 @@ pkg_info { name: "fabric_border_router.p4" + version: "1.6.1" arch: "v1model" organization: "Google" } +tables { + preamble { + id: 33554507 + name: "ingress.tunnel_termination_lookup.ipv6_tunnel_termination_table" + alias: "ipv6_tunnel_termination_table" + annotations: "@unsupported" + annotations: "@p4runtime_role(\"sdn_controller\")" + } + match_fields { + id: 1 + name: "dst_ipv6" + annotations: "@format(IPV6_ADDRESS)" + bitwidth: 128 + match_type: TERNARY + } + match_fields { + id: 2 + name: "src_ipv6" + annotations: "@format(IPV6_ADDRESS)" + bitwidth: 128 + match_type: TERNARY + } + action_refs { + id: 16777238 + annotations: "@proto_id(1)" + } + action_refs { + id: 21257015 + annotations: "@defaultonly" + scope: DEFAULT_ONLY + } + size: 126 +} +tables { + preamble { + id: 33554509 + name: "ingress.vlan_untag.disable_vlan_checks_table" + alias: "disable_vlan_checks_table" + annotations: "@p4runtime_role(\"sdn_controller\")" + annotations: "@entry_restriction(\"\n // Force the dummy_match to be wildcard.\n dummy_match::mask == 0;\n \")" + } + match_fields { + id: 1 + name: "dummy_match" + bitwidth: 1 + match_type: TERNARY + } + action_refs { + id: 16777242 + annotations: "@proto_id(1)" + } + action_refs { + id: 21257015 + annotations: "@defaultonly" + scope: DEFAULT_ONLY + } + size: 1 +} tables { preamble { id: 33554689 @@ -13,7 +72,8 @@ tables { alias: "acl_pre_ingress_table" annotations: "@p4runtime_role(\"sdn_controller\")" annotations: "@sai_acl(PRE_INGRESS)" - annotations: "@entry_restriction(\"\n // Only allow IP field matches for IP packets.\n dscp::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1);\n dst_ip::mask != 0 -> is_ipv4 == 1;\n dst_ipv6::mask != 0 -> is_ipv6 == 1;\n // Forbid illegal combinations of IP_TYPE fields.\n is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0);\n is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0);\n is_ipv6::mask != 0 -> (is_ip::mask == 0 && is_ipv4::mask == 0);\n // Forbid unsupported combinations of IP_TYPE fields.\n is_ipv4::mask != 0 -> (is_ipv4 == 1);\n is_ipv6::mask != 0 -> (is_ipv6 == 1);\n // Reserve high priorities for switch-internal use.\n // TODO: Remove once inband workaround is obsolete.\n ::priority < 0x7fffffff;\n \")" + annotations: "@sai_acl_priority(11)" + annotations: "@entry_restriction(\"\n // Only allow IP field matches for IP packets.\n dscp::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1);\n ecn::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1);\n dst_ip::mask != 0 -> is_ipv4 == 1;\n dst_ipv6::mask != 0 -> is_ipv6 == 1;\n // Forbid illegal combinations of IP_TYPE fields.\n is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0);\n is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0);\n is_ipv6::mask != 0 -> (is_ip::mask == 0 && is_ipv4::mask == 0);\n // Forbid unsupported combinations of IP_TYPE fields.\n is_ipv4::mask != 0 -> (is_ipv4 == 1);\n is_ipv6::mask != 0 -> (is_ipv6 == 1);\n\n\n\n\n // Reserve high priorities for switch-internal use.\n // TODO: Remove once inband workaround is obsolete.\n ::priority < 0x7fffffff;\n \")" } match_fields { id: 1 @@ -75,6 +135,13 @@ tables { bitwidth: 6 match_type: TERNARY } + match_fields { + id: 10 + name: "ecn" + annotations: "@sai_field(SAI_ACL_TABLE_ATTR_FIELD_ECN)" + bitwidth: 2 + match_type: TERNARY + } match_fields { id: 8 name: "in_port" @@ -96,7 +163,7 @@ tables { } const_default_action_id: 21257015 direct_resource_ids: 318767361 - size: 255 + size: 254 } tables { preamble { @@ -131,138 +198,12 @@ tables { scope: DEFAULT_ONLY } const_default_action_id: 21257015 - size: 128 -} -tables { - preamble { - id: 33554496 - name: "ingress.routing.neighbor_table" - alias: "neighbor_table" - annotations: "@p4runtime_role(\"sdn_controller\")" - } - match_fields { - id: 1 - name: "router_interface_id" - annotations: "@refers_to(router_interface_table , router_interface_id)" - bitwidth: 10 - match_type: EXACT - type_name { - name: "router_interface_id_t" - } - } - match_fields { - id: 2 - name: "neighbor_id" - annotations: "@format(IPV6_ADDRESS)" - bitwidth: 128 - match_type: EXACT - } - action_refs { - id: 16777217 - annotations: "@proto_id(1)" - } - action_refs { - id: 21257015 - annotations: "@defaultonly" - scope: DEFAULT_ONLY - } - const_default_action_id: 21257015 - size: 1024 -} -tables { - preamble { - id: 33554497 - name: "ingress.routing.router_interface_table" - alias: "router_interface_table" - annotations: "@p4runtime_role(\"sdn_controller\")" - } - match_fields { - id: 1 - name: "router_interface_id" - bitwidth: 10 - match_type: EXACT - type_name { - name: "router_interface_id_t" - } - } - action_refs { - id: 16777218 - annotations: "@proto_id(1)" - } - action_refs { - id: 21257015 - annotations: "@defaultonly" - scope: DEFAULT_ONLY - } - const_default_action_id: 21257015 - size: 256 -} -tables { - preamble { - id: 33554498 - name: "ingress.routing.nexthop_table" - alias: "nexthop_table" - annotations: "@p4runtime_role(\"sdn_controller\")" - } - match_fields { - id: 1 - name: "nexthop_id" - bitwidth: 10 - match_type: EXACT - type_name { - name: "nexthop_id_t" - } - } - action_refs { - id: 16777219 - annotations: "@proto_id(1)" - } - action_refs { - id: 16777236 - annotations: "@proto_id(3)" - } - action_refs { - id: 21257015 - annotations: "@defaultonly" - scope: DEFAULT_ONLY - } - const_default_action_id: 21257015 - size: 1024 -} -tables { - preamble { - id: 33554499 - name: "ingress.routing.wcmp_group_table" - alias: "wcmp_group_table" - annotations: "@p4runtime_role(\"sdn_controller\")" - annotations: "@oneshot" - } - match_fields { - id: 1 - name: "wcmp_group_id" - bitwidth: 12 - match_type: EXACT - type_name { - name: "wcmp_group_id_t" - } - } - action_refs { - id: 16777221 - annotations: "@proto_id(1)" - } - action_refs { - id: 21257015 - annotations: "@defaultonly" - scope: DEFAULT_ONLY - } - const_default_action_id: 21257015 - implementation_id: 299650760 - size: 3968 + size: 64 } tables { preamble { id: 33554506 - name: "ingress.routing.vrf_table" + name: "ingress.routing_lookup.vrf_table" alias: "vrf_table" annotations: "@entry_restriction(\"\n // The VRF ID 0 (or \'\' in P4Runtime) encodes the default VRF, which cannot\n // be read or written via this table, but is always present implicitly.\n // TODO: This constraint should read `vrf_id != \'\'` (since\n // constraints are a control plane (P4Runtime) concept), but\n // p4-constraints does not currently support strings.\n vrf_id != 0;\n \")" annotations: "@p4runtime_role(\"sdn_controller\")" @@ -286,7 +227,7 @@ tables { tables { preamble { id: 33554500 - name: "ingress.routing.ipv4_table" + name: "ingress.routing_lookup.ipv4_table" alias: "ipv4_table" annotations: "@p4runtime_role(\"sdn_controller\")" } @@ -319,10 +260,6 @@ tables { id: 16777220 annotations: "@proto_id(3)" } - action_refs { - id: 16777231 - annotations: "@proto_id(4)" - } action_refs { id: 16777232 annotations: "@proto_id(5)" @@ -336,12 +273,12 @@ tables { annotations: "@proto_id(7)" } const_default_action_id: 16777222 - size: 32768 + size: 131072 } tables { preamble { id: 33554501 - name: "ingress.routing.ipv6_table" + name: "ingress.routing_lookup.ipv6_table" alias: "ipv6_table" annotations: "@p4runtime_role(\"sdn_controller\")" } @@ -374,10 +311,6 @@ tables { id: 16777220 annotations: "@proto_id(3)" } - action_refs { - id: 16777231 - annotations: "@proto_id(4)" - } action_refs { id: 16777232 annotations: "@proto_id(5)" @@ -391,7 +324,77 @@ tables { annotations: "@proto_id(7)" } const_default_action_id: 16777222 - size: 4096 + size: 17000 +} +tables { + preamble { + id: 33554510 + name: "ingress.routing_lookup.ipv4_multicast_table" + alias: "ipv4_multicast_table" + annotations: "@p4runtime_role(\"sdn_controller\")" + } + match_fields { + id: 1 + name: "vrf_id" + annotations: "@refers_to(vrf_table , vrf_id)" + bitwidth: 10 + match_type: EXACT + type_name { + name: "vrf_id_t" + } + } + match_fields { + id: 2 + name: "ipv4_dst" + annotations: "@format(IPV4_ADDRESS)" + bitwidth: 32 + match_type: EXACT + } + action_refs { + id: 16777240 + annotations: "@proto_id(1)" + } + action_refs { + id: 21257015 + annotations: "@defaultonly" + scope: DEFAULT_ONLY + } + size: 1600 +} +tables { + preamble { + id: 33554511 + name: "ingress.routing_lookup.ipv6_multicast_table" + alias: "ipv6_multicast_table" + annotations: "@p4runtime_role(\"sdn_controller\")" + } + match_fields { + id: 1 + name: "vrf_id" + annotations: "@refers_to(vrf_table , vrf_id)" + bitwidth: 10 + match_type: EXACT + type_name { + name: "vrf_id_t" + } + } + match_fields { + id: 2 + name: "ipv6_dst" + annotations: "@format(IPV6_ADDRESS)" + bitwidth: 128 + match_type: EXACT + } + action_refs { + id: 16777240 + annotations: "@proto_id(1)" + } + action_refs { + id: 21257015 + annotations: "@defaultonly" + scope: DEFAULT_ONLY + } + size: 1600 } tables { preamble { @@ -400,7 +403,8 @@ tables { alias: "acl_ingress_table" annotations: "@p4runtime_role(\"sdn_controller\")" annotations: "@sai_acl(INGRESS)" - annotations: "@entry_restriction(\"\n // Forbid using ether_type for IP packets (by convention, use is_ip* instead).\n ether_type != 0x0800 && ether_type != 0x86dd;\n // Only allow IP field matches for IP packets.\n dst_ip::mask != 0 -> is_ipv4 == 1;\n dst_ipv6::mask != 0 -> is_ipv6 == 1;\n ttl::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1);\n dscp::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1);\n ecn::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1);\n ip_protocol::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1);\n // Only allow l4_dst_port and l4_src_port matches for TCP/UDP packets.\n l4_src_port::mask != 0 -> (ip_protocol == 6 || ip_protocol == 17);\n l4_dst_port::mask != 0 -> (ip_protocol == 6 || ip_protocol == 17);\n\n\n\n\n // Only allow icmp_type matches for ICMP packets\n\n icmp_type::mask != 0 -> ip_protocol == 1;\n\n icmpv6_type::mask != 0 -> ip_protocol == 58;\n // Forbid illegal combinations of IP_TYPE fields.\n is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0);\n is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0);\n is_ipv6::mask != 0 -> (is_ip::mask == 0 && is_ipv4::mask == 0);\n // Forbid unsupported combinations of IP_TYPE fields.\n is_ipv4::mask != 0 -> (is_ipv4 == 1);\n is_ipv6::mask != 0 -> (is_ipv6 == 1);\n \")" + annotations: "@sai_acl_priority(5)" + annotations: "@entry_restriction(\"\n // Forbid using ether_type for IP packets (by convention, use is_ip* instead).\n ether_type != 0x0800 && ether_type != 0x86dd;\n // Only allow IP field matches for IP packets.\n dst_ip::mask != 0 -> is_ipv4 == 1;\n\n src_ip::mask != 0 -> is_ipv4 == 1;\n\n dst_ipv6::mask != 0 -> is_ipv6 == 1;\n src_ipv6::mask != 0 -> is_ipv6 == 1;\n ttl::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1);\n\n dscp::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1);\n ecn::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1);\n\n ip_protocol::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1);\n // Only allow l4_dst_port and l4_src_port matches for TCP/UDP packets.\n\n l4_src_port::mask != 0 -> (ip_protocol == 6 || ip_protocol == 17);\n\n l4_dst_port::mask != 0 -> (ip_protocol == 6 || ip_protocol == 17);\n\n\n\n\n\n // Only allow icmp_type matches for ICMP packets\n icmp_type::mask != 0 -> ip_protocol == 1;\n\n icmpv6_type::mask != 0 -> ip_protocol == 58;\n // Forbid illegal combinations of IP_TYPE fields.\n is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0);\n is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0);\n is_ipv6::mask != 0 -> (is_ip::mask == 0 && is_ipv4::mask == 0);\n // Forbid unsupported combinations of IP_TYPE fields.\n is_ipv4::mask != 0 -> (is_ipv4 == 1);\n is_ipv6::mask != 0 -> (is_ipv6 == 1);\n \")" } match_fields { id: 1 @@ -563,10 +567,6 @@ tables { id: 16777481 annotations: "@proto_id(5)" } - action_refs { - id: 16777625 - annotations: "@proto_id(99)" - } action_refs { id: 21257015 annotations: "@defaultonly" @@ -575,135 +575,177 @@ tables { const_default_action_id: 21257015 direct_resource_ids: 318767362 direct_resource_ids: 352321792 - size: 128 + size: 255 } tables { preamble { - id: 33554502 - name: "ingress.mirroring_clone.mirror_session_table" - alias: "mirror_session_table" + id: 33554695 + name: "ingress.acl_ingress.acl_ingress_qos_table" + alias: "acl_ingress_qos_table" + annotations: "@sai_acl(INGRESS)" + annotations: "@sai_acl_priority(10)" annotations: "@p4runtime_role(\"sdn_controller\")" + annotations: "@entry_restriction(\"\n // Forbid using ether_type for IP packets (by convention, use is_ip* instead).\n ether_type != 0x0800 && ether_type != 0x86dd;\n // Only allow IP field matches for IP packets.\n ttl::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1);\n ip_protocol::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1);\n // Only allow l4_dst_port matches for TCP/UDP packets.\n l4_dst_port::mask != 0 -> (ip_protocol == 6 || ip_protocol == 17);\n // Forbid illegal combinations of IP_TYPE fields.\n is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0);\n is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0);\n is_ipv6::mask != 0 -> (is_ip::mask == 0 && is_ipv4::mask == 0);\n // Forbid unsupported combinations of IP_TYPE fields.\n is_ipv4::mask != 0 -> (is_ipv4 == 1);\n is_ipv6::mask != 0 -> (is_ipv6 == 1);\n // Only allow icmp_type matches for ICMP packets\n icmpv6_type::mask != 0 -> ip_protocol == 58;\n\n // Only allow l4_dst_port matches for TCP/UDP packets.\n l4_src_port::mask != 0 -> (ip_protocol == 6 || ip_protocol == 17);\n // Only allow icmp_type matches for ICMP packets\n icmp_type::mask != 0 -> ip_protocol == 1;\n\n\n\n\n\n \")" } match_fields { id: 1 - name: "mirror_session_id" - bitwidth: 10 - match_type: EXACT - type_name { - name: "mirror_session_id_t" - } - } - action_refs { - id: 16777223 - annotations: "@proto_id(1)" - } - action_refs { - id: 21257015 - annotations: "@defaultonly" - scope: DEFAULT_ONLY - } - const_default_action_id: 21257015 - size: 2 -} -tables { - preamble { - id: 33554504 - name: "ingress.mirroring_clone.mirror_port_to_pre_session_table" - alias: "mirror_port_to_pre_session_table" - annotations: "@p4runtime_role(\"packet_replication_engine_manager\")" + name: "is_ip" + annotations: "@sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP)" + bitwidth: 1 + match_type: OPTIONAL } match_fields { - id: 1 - name: "mirror_port" - bitwidth: 9 - match_type: EXACT - type_name { - name: "port_id_t" - } - } - action_refs { - id: 16777225 - annotations: "@proto_id(1)" - } - action_refs { - id: 21257015 - annotations: "@defaultonly" - scope: DEFAULT_ONLY + id: 2 + name: "is_ipv4" + annotations: "@sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY)" + bitwidth: 1 + match_type: OPTIONAL } - const_default_action_id: 21257015 - size: 1024 -} -tables { - preamble { - id: 33554692 - name: "egress.acl_egress.acl_egress_table" - alias: "acl_egress_table" - annotations: "@p4runtime_role(\"sdn_controller\")" - annotations: "@sai_acl(EGRESS)" - annotations: "@entry_restriction(\"\n // Forbid using ether_type for IP packets (by convention, use is_ip* instead).\n ether_type != 0x0800 && ether_type != 0x86dd;\n dscp::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1);\n // Only allow IP field matches for IP packets.\n // TODO: Enable once p4-constraints bug is fixed.\n // ip_protocol::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1);\n // Only allow l4_dst_port matches for TCP/UDP packets.\n l4_dst_port::mask != 0 -> (ip_protocol == 6 || ip_protocol == 17);\n // Forbid illegal combinations of IP_TYPE fields.\n is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0);\n is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0);\n is_ipv6::mask != 0 -> (is_ip::mask == 0 && is_ipv4::mask == 0);\n // Forbid unsupported combinations of IP_TYPE fields.\n is_ipv4::mask != 0 -> (is_ipv4 == 1);\n is_ipv6::mask != 0 -> (is_ipv6 == 1);\n \")" + match_fields { + id: 3 + name: "is_ipv6" + annotations: "@sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY)" + bitwidth: 1 + match_type: OPTIONAL } match_fields { - id: 1 + id: 4 name: "ether_type" annotations: "@sai_field(SAI_ACL_TABLE_ATTR_FIELD_ETHER_TYPE)" bitwidth: 16 match_type: TERNARY } match_fields { - id: 2 + id: 7 + name: "ttl" + annotations: "@sai_field(SAI_ACL_TABLE_ATTR_FIELD_TTL)" + bitwidth: 8 + match_type: TERNARY + } + match_fields { + id: 8 name: "ip_protocol" annotations: "@sai_field(SAI_ACL_TABLE_ATTR_FIELD_IP_PROTOCOL)" bitwidth: 8 match_type: TERNARY } match_fields { - id: 3 + id: 9 + name: "icmpv6_type" + annotations: "@sai_field(SAI_ACL_TABLE_ATTR_FIELD_ICMPV6_TYPE)" + bitwidth: 8 + match_type: TERNARY + } + match_fields { + id: 10 name: "l4_dst_port" annotations: "@sai_field(SAI_ACL_TABLE_ATTR_FIELD_L4_DST_PORT)" bitwidth: 16 match_type: TERNARY } match_fields { - id: 4 - name: "out_port" - annotations: "@sai_field(SAI_ACL_TABLE_ATTR_FIELD_OUT_PORT)" - bitwidth: 9 - match_type: OPTIONAL - type_name { - name: "port_id_t" - } + id: 12 + name: "l4_src_port" + annotations: "@sai_field(SAI_ACL_TABLE_ATTR_FIELD_L4_SRC_PORT)" + bitwidth: 16 + match_type: TERNARY } match_fields { - id: 5 + id: 14 + name: "icmp_type" + annotations: "@sai_field(SAI_ACL_TABLE_ATTR_FIELD_ICMP_TYPE)" + bitwidth: 8 + match_type: TERNARY + } + match_fields { + id: 15 + name: "route_metadata" + annotations: "@sai_field(SAI_ACL_TABLE_ATTR_FIELD_ROUTE_DST_USER_META)" + bitwidth: 6 + match_type: TERNARY + } + action_refs { + id: 16777484 + annotations: "@proto_id(1)" + } + action_refs { + id: 16777486 + annotations: "@proto_id(2)" + } + action_refs { + id: 16777475 + annotations: "@proto_id(3)" + } + action_refs { + id: 16777481 + annotations: "@proto_id(4)" + } + action_refs { + id: 16777488 + annotations: "@proto_id(5)" + } + action_refs { + id: 16777489 + annotations: "@proto_id(6)" + } + action_refs { + id: 21257015 + annotations: "@defaultonly" + scope: DEFAULT_ONLY + } + const_default_action_id: 21257015 + direct_resource_ids: 318767367 + direct_resource_ids: 352321794 + size: 511 +} +tables { + preamble { + id: 33554697 + name: "ingress.acl_ingress.acl_ingress_counting_table" + alias: "acl_ingress_counting_table" + annotations: "@p4runtime_role(\"sdn_controller\")" + annotations: "@sai_acl_priority(7)" + annotations: "@sai_acl(INGRESS)" + annotations: "@entry_restriction(\"\n // Only allow IP field matches for IP packets.\n dscp::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1);\n // Forbid illegal combinations of IP_TYPE fields.\n is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0);\n is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0);\n is_ipv6::mask != 0 -> (is_ip::mask == 0 && is_ipv4::mask == 0);\n // Forbid unsupported combinations of IP_TYPE fields.\n is_ipv4::mask != 0 -> (is_ipv4 == 1);\n is_ipv6::mask != 0 -> (is_ipv6 == 1);\n \")" + } + match_fields { + id: 1 name: "is_ip" annotations: "@sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP)" bitwidth: 1 match_type: OPTIONAL } match_fields { - id: 6 + id: 2 name: "is_ipv4" annotations: "@sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY)" bitwidth: 1 match_type: OPTIONAL } match_fields { - id: 7 + id: 3 name: "is_ipv6" annotations: "@sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY)" bitwidth: 1 match_type: OPTIONAL } match_fields { - id: 8 + id: 11 name: "dscp" annotations: "@sai_field(SAI_ACL_TABLE_ATTR_FIELD_DSCP)" bitwidth: 6 match_type: TERNARY } + match_fields { + id: 18 + name: "route_metadata" + annotations: "@sai_field(SAI_ACL_TABLE_ATTR_FIELD_ROUTE_DST_USER_META)" + bitwidth: 6 + match_type: TERNARY + } action_refs { - id: 16777481 - annotations: "@proto_id(1)" + id: 16777477 + annotations: "@proto_id(3)" } action_refs { id: 21257015 @@ -711,88 +753,881 @@ tables { scope: DEFAULT_ONLY } const_default_action_id: 21257015 - direct_resource_ids: 318767364 - size: 128 + direct_resource_ids: 318767369 + size: 255 } -actions { +tables { preamble { - id: 21257015 - name: "NoAction" - alias: "NoAction" - annotations: "@noWarn(\"unused\")" + id: 33554496 + name: "ingress.routing_resolution.neighbor_table" + alias: "neighbor_table" + annotations: "@p4runtime_role(\"sdn_controller\")" } -} -actions { - preamble { - id: 16777481 - name: "acl_drop" - alias: "acl_drop" - annotations: "@sai_action(SAI_PACKET_ACTION_DROP)" + match_fields { + id: 1 + name: "router_interface_id" + annotations: "@refers_to(router_interface_table , router_interface_id)" + bitwidth: 10 + match_type: EXACT + type_name { + name: "router_interface_id_t" + } + } + match_fields { + id: 2 + name: "neighbor_id" + annotations: "@format(IPV6_ADDRESS)" + bitwidth: 128 + match_type: EXACT + } + action_refs { + id: 16777217 + annotations: "@proto_id(1)" + } + action_refs { + id: 21257015 + annotations: "@defaultonly" + scope: DEFAULT_ONLY } + const_default_action_id: 21257015 + size: 1024 } -actions { +tables { preamble { - id: 16777472 - name: "ingress.acl_pre_ingress.set_vrf" - alias: "set_vrf" - annotations: "@sai_action(SAI_PACKET_ACTION_FORWARD)" + id: 33554497 + name: "ingress.routing_resolution.router_interface_table" + alias: "router_interface_table" + annotations: "@p4runtime_role(\"sdn_controller\")" } - params { + match_fields { id: 1 - name: "vrf_id" - annotations: "@sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_SET_VRF)" - annotations: "@refers_to(vrf_table , vrf_id)" + name: "router_interface_id" bitwidth: 10 + match_type: EXACT type_name { - name: "vrf_id_t" + name: "router_interface_id_t" } } -} -actions { - preamble { - id: 16777224 - name: "ingress.l3_admit.admit_to_l3" - alias: "admit_to_l3" + action_refs { + id: 16777218 + annotations: "@proto_id(1)" } -} -actions { - preamble { - id: 16777217 - name: "ingress.routing.set_dst_mac" - alias: "set_dst_mac" + action_refs { + id: 16777243 + annotations: "@proto_id(2)" } - params { - id: 1 - name: "dst_mac" - annotations: "@format(MAC_ADDRESS)" - bitwidth: 48 + action_refs { + id: 21257015 + annotations: "@defaultonly" + scope: DEFAULT_ONLY } + const_default_action_id: 21257015 + size: 256 } -actions { +tables { preamble { - id: 16777218 - name: "ingress.routing.set_port_and_src_mac" - alias: "set_port_and_src_mac" + id: 33554498 + name: "ingress.routing_resolution.nexthop_table" + alias: "nexthop_table" + annotations: "@p4runtime_role(\"sdn_controller\")" } - params { + match_fields { id: 1 - name: "port" - bitwidth: 9 + name: "nexthop_id" + bitwidth: 10 + match_type: EXACT type_name { - name: "port_id_t" + name: "nexthop_id_t" } } + action_refs { + id: 16777219 + annotations: "@proto_id(1)" + } + action_refs { + id: 16777234 + annotations: "@proto_id(2)" + } + action_refs { + id: 16777236 + annotations: "@proto_id(3)" + } + action_refs { + id: 16777239 + annotations: "@proto_id(4)" + } + action_refs { + id: 21257015 + annotations: "@defaultonly" + scope: DEFAULT_ONLY + } + const_default_action_id: 21257015 + size: 1024 +} +tables { + preamble { + id: 33554512 + name: "ingress.routing_resolution.tunnel_table" + alias: "tunnel_table" + annotations: "@p4runtime_role(\"sdn_controller\")" + } + match_fields { + id: 1 + name: "tunnel_id" + bitwidth: 10 + match_type: EXACT + type_name { + name: "tunnel_id_t" + } + } + action_refs { + id: 16777235 + annotations: "@proto_id(1)" + } + action_refs { + id: 21257015 + annotations: "@defaultonly" + scope: DEFAULT_ONLY + } + const_default_action_id: 21257015 + size: 2048 +} +tables { + preamble { + id: 33554499 + name: "ingress.routing_resolution.wcmp_group_table" + alias: "wcmp_group_table" + annotations: "@p4runtime_role(\"sdn_controller\")" + annotations: "@oneshot" + } + match_fields { + id: 1 + name: "wcmp_group_id" + bitwidth: 12 + match_type: EXACT + type_name { + name: "wcmp_group_id_t" + } + } + action_refs { + id: 16777221 + annotations: "@proto_id(1)" + } + action_refs { + id: 21257015 + annotations: "@defaultonly" + scope: DEFAULT_ONLY + } + const_default_action_id: 21257015 + implementation_id: 299650760 + size: 3968 +} +tables { + preamble { + id: 33554502 + name: "ingress.mirror_session_lookup.mirror_session_table" + alias: "mirror_session_table" + annotations: "@p4runtime_role(\"sdn_controller\")" + } + match_fields { + id: 1 + name: "mirror_session_id" + bitwidth: 10 + match_type: EXACT + type_name { + name: "mirror_session_id_t" + } + } + action_refs { + id: 16777223 + annotations: "@proto_id(1)" + } + action_refs { + id: 16777245 + annotations: "@proto_id(2)" + } + action_refs { + id: 21257015 + annotations: "@defaultonly" + scope: DEFAULT_ONLY + } + const_default_action_id: 21257015 + size: 4 +} +tables { + preamble { + id: 33554513 + name: "ingress.ingress_cloning.ingress_clone_table" + alias: "ingress_clone_table" + annotations: "@unsupported" + annotations: "@p4runtime_role(\"packet_replication_engine_manager\")" + annotations: "@entry_restriction(\"\n // mirror_egress_port is present iff marked_to_mirror is true.\n // Exact match indicating presence of mirror_egress_port.\n marked_to_mirror == 1 -> mirror_egress_port::mask == -1;\n // Wildcard match indicating abscence of mirror_egress_port.\n marked_to_mirror == 0 -> mirror_egress_port::mask == 0;\n \")" + } + match_fields { + id: 1 + name: "marked_to_copy" + bitwidth: 1 + match_type: EXACT + } + match_fields { + id: 2 + name: "marked_to_mirror" + bitwidth: 1 + match_type: EXACT + } + match_fields { + id: 3 + name: "mirror_egress_port" + bitwidth: 9 + match_type: OPTIONAL + type_name { + name: "port_id_t" + } + } + action_refs { + id: 16777244 + annotations: "@proto_id(1)" + } + action_refs { + id: 21257015 + annotations: "@defaultonly" + scope: DEFAULT_ONLY + } + size: 1024 +} +tables { + preamble { + id: 33554508 + name: "egress.packet_rewrites.multicast_rewrites.multicast_router_interface_table" + alias: "multicast_router_interface_table" + annotations: "@p4runtime_role(\"sdn_controller\")" + } + match_fields { + id: 1 + name: "multicast_replica_port" + annotations: "@referenced_by(builtin : : multicast_group_table , replica . port)" + bitwidth: 9 + match_type: EXACT + type_name { + name: "port_id_t" + } + } + match_fields { + id: 2 + name: "multicast_replica_instance" + annotations: "@referenced_by(builtin : : multicast_group_table , replica . instance)" + bitwidth: 16 + match_type: EXACT + } + action_refs { + id: 16777241 + annotations: "@proto_id(1)" + } + action_refs { + id: 21257015 + annotations: "@defaultonly" + scope: DEFAULT_ONLY + } + size: 110 +} +tables { + preamble { + id: 33554692 + name: "egress.acl_egress.acl_egress_table" + alias: "acl_egress_table" + annotations: "@p4runtime_role(\"sdn_controller\")" + annotations: "@sai_acl(EGRESS)" + annotations: "@entry_restriction(\"\n\n // Forbid using ether_type for IP packets (by convention, use is_ip* instead).\n ether_type != 0x0800 && ether_type != 0x86dd;\n dscp::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1);\n\n // Only allow IP field matches for IP packets.\n ip_protocol::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1);\n\n\n\n\n // Only allow l4_dst_port matches for TCP/UDP packets.\n l4_dst_port::mask != 0 -> (ip_protocol == 6 || ip_protocol == 17);\n\n // Forbid illegal combinations of IP_TYPE fields.\n is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0);\n is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0);\n is_ipv6::mask != 0 -> (is_ip::mask == 0 && is_ipv4::mask == 0);\n // Forbid unsupported combinations of IP_TYPE fields.\n is_ipv4::mask != 0 -> (is_ipv4 == 1);\n is_ipv6::mask != 0 -> (is_ipv6 == 1);\n \")" + } + match_fields { + id: 1 + name: "ether_type" + annotations: "@sai_field(SAI_ACL_TABLE_ATTR_FIELD_ETHER_TYPE)" + bitwidth: 16 + match_type: TERNARY + } + match_fields { + id: 2 + name: "ip_protocol" + annotations: "@sai_field(SAI_ACL_TABLE_ATTR_FIELD_IP_PROTOCOL)" + bitwidth: 8 + match_type: TERNARY + } + match_fields { + id: 3 + name: "l4_dst_port" + annotations: "@sai_field(SAI_ACL_TABLE_ATTR_FIELD_L4_DST_PORT)" + bitwidth: 16 + match_type: TERNARY + } + match_fields { + id: 4 + name: "out_port" + annotations: "@sai_field(SAI_ACL_TABLE_ATTR_FIELD_OUT_PORT)" + bitwidth: 9 + match_type: OPTIONAL + type_name { + name: "port_id_t" + } + } + match_fields { + id: 5 + name: "is_ip" + annotations: "@sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP)" + bitwidth: 1 + match_type: OPTIONAL + } + match_fields { + id: 6 + name: "is_ipv4" + annotations: "@sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY)" + bitwidth: 1 + match_type: OPTIONAL + } + match_fields { + id: 7 + name: "is_ipv6" + annotations: "@sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY)" + bitwidth: 1 + match_type: OPTIONAL + } + match_fields { + id: 8 + name: "dscp" + annotations: "@sai_field(SAI_ACL_TABLE_ATTR_FIELD_DSCP)" + bitwidth: 6 + match_type: TERNARY + } + action_refs { + id: 16777481 + annotations: "@proto_id(1)" + } + action_refs { + id: 21257015 + annotations: "@defaultonly" + scope: DEFAULT_ONLY + } + const_default_action_id: 21257015 + direct_resource_ids: 318767364 + size: 127 +} +actions { + preamble { + id: 21257015 + name: "NoAction" + alias: "NoAction" + annotations: "@noWarn(\"unused\")" + } +} +actions { + preamble { + id: 16777221 + name: "set_nexthop_id" + alias: "set_nexthop_id" + } + params { + id: 1 + name: "nexthop_id" + annotations: "@refers_to(nexthop_table , nexthop_id)" + bitwidth: 10 + type_name { + name: "nexthop_id_t" + } + } +} +actions { + preamble { + id: 16777481 + name: "acl_drop" + alias: "acl_drop" + annotations: "@sai_action(SAI_PACKET_ACTION_DROP)" + } +} +actions { + preamble { + id: 16777238 + name: "ingress.tunnel_termination_lookup.mark_for_tunnel_decap_and_set_vrf" + alias: "mark_for_tunnel_decap_and_set_vrf" + } + params { + id: 1 + name: "vrf_id" + annotations: "@refers_to(vrf_table , vrf_id)" + bitwidth: 10 + type_name { + name: "vrf_id_t" + } + } +} +actions { + preamble { + id: 16777242 + name: "ingress.vlan_untag.disable_vlan_checks" + alias: "disable_vlan_checks" + } +} +actions { + preamble { + id: 16777472 + name: "ingress.acl_pre_ingress.set_vrf" + alias: "set_vrf" + annotations: "@sai_action(SAI_PACKET_ACTION_FORWARD)" + } + params { + id: 1 + name: "vrf_id" + annotations: "@sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_SET_VRF)" + annotations: "@refers_to(vrf_table , vrf_id)" + bitwidth: 10 + type_name { + name: "vrf_id_t" + } + } +} +actions { + preamble { + id: 16777224 + name: "ingress.l3_admit.admit_to_l3" + alias: "admit_to_l3" + } +} +actions { + preamble { + id: 17825802 + name: "ingress.hashing.select_ecmp_hash_algorithm" + alias: "select_ecmp_hash_algorithm" + annotations: "@sai_hash_seed(0)" + } +} +actions { + preamble { + id: 16777227 + name: "ingress.hashing.compute_ecmp_hash_ipv4" + alias: "compute_ecmp_hash_ipv4" + annotations: "@sai_ecmp_hash(SAI_SWITCH_ATTR_ECMP_HASH_IPV4)" + annotations: "@sai_native_hash_field(SAI_NATIVE_HASH_FIELD_SRC_IPV4)" + annotations: "@sai_native_hash_field(SAI_NATIVE_HASH_FIELD_DST_IPV4)" + annotations: "@sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_SRC_PORT)" + annotations: "@sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_DST_PORT)" + } +} +actions { + preamble { + id: 16777228 + name: "ingress.hashing.compute_ecmp_hash_ipv6" + alias: "compute_ecmp_hash_ipv6" + annotations: "@sai_ecmp_hash(SAI_SWITCH_ATTR_ECMP_HASH_IPV6)" + annotations: "@sai_native_hash_field(SAI_NATIVE_HASH_FIELD_SRC_IPV6)" + annotations: "@sai_native_hash_field(SAI_NATIVE_HASH_FIELD_DST_IPV6)" + annotations: "@sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_SRC_PORT)" + annotations: "@sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_DST_PORT)" + annotations: "@sai_native_hash_field(SAI_NATIVE_HASH_FIELD_IPV6_FLOW_LABEL)" + } +} +actions { + preamble { + id: 19711398 + name: "ingress.lag_hashing_config.select_lag_hash_algorithm" + alias: "select_lag_hash_algorithm" + annotations: "@sai_hash_algorithm(SAI_HASH_ALGORITHM_CRC)" + annotations: "@sai_hash_seed(0)" + annotations: "@sai_hash_offset(0)" + } +} +actions { + preamble { + id: 16777229 + name: "ingress.lag_hashing_config.compute_lag_hash_ipv4" + alias: "compute_lag_hash_ipv4" + annotations: "@sai_lag_hash(SAI_SWITCH_ATTR_LAG_HASH_IPV4)" + annotations: "@sai_native_hash_field(SAI_NATIVE_HASH_FIELD_SRC_IPV4)" + annotations: "@sai_native_hash_field(SAI_NATIVE_HASH_FIELD_DST_IPV4)" + annotations: "@sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_SRC_PORT)" + annotations: "@sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_DST_PORT)" + } +} +actions { + preamble { + id: 16777230 + name: "ingress.lag_hashing_config.compute_lag_hash_ipv6" + alias: "compute_lag_hash_ipv6" + annotations: "@sai_lag_hash(SAI_SWITCH_ATTR_LAG_HASH_IPV6)" + annotations: "@sai_native_hash_field(SAI_NATIVE_HASH_FIELD_SRC_IPV6)" + annotations: "@sai_native_hash_field(SAI_NATIVE_HASH_FIELD_DST_IPV6)" + annotations: "@sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_SRC_PORT)" + annotations: "@sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_DST_PORT)" + annotations: "@sai_native_hash_field(SAI_NATIVE_HASH_FIELD_IPV6_FLOW_LABEL)" + } +} +actions { + preamble { + id: 24742814 + name: "ingress.routing_lookup.no_action" + alias: "no_action" + } +} +actions { + preamble { + id: 16777222 + name: "ingress.routing_lookup.drop" + alias: "drop" + } +} +actions { + preamble { + id: 16777220 + name: "ingress.routing_lookup.set_wcmp_group_id" + alias: "set_wcmp_group_id" + } + params { + id: 1 + name: "wcmp_group_id" + annotations: "@refers_to(wcmp_group_table , wcmp_group_id)" + bitwidth: 12 + type_name { + name: "wcmp_group_id_t" + } + } +} +actions { + preamble { + id: 16777233 + name: "ingress.routing_lookup.set_wcmp_group_id_and_metadata" + alias: "set_wcmp_group_id_and_metadata" + } + params { + id: 1 + name: "wcmp_group_id" + annotations: "@refers_to(wcmp_group_table , wcmp_group_id)" + bitwidth: 12 + type_name { + name: "wcmp_group_id_t" + } + } + params { + id: 2 + name: "route_metadata" + bitwidth: 6 + } +} +actions { + preamble { + id: 16777237 + name: "ingress.routing_lookup.set_metadata_and_drop" + alias: "set_metadata_and_drop" + } + params { + id: 1 + name: "route_metadata" + bitwidth: 6 + } +} +actions { + preamble { + id: 16777232 + name: "ingress.routing_lookup.set_nexthop_id_and_metadata" + alias: "set_nexthop_id_and_metadata" + } + params { + id: 1 + name: "nexthop_id" + annotations: "@refers_to(nexthop_table , nexthop_id)" + bitwidth: 10 + type_name { + name: "nexthop_id_t" + } + } + params { + id: 2 + name: "route_metadata" + bitwidth: 6 + } +} +actions { + preamble { + id: 16777240 + name: "ingress.routing_lookup.set_multicast_group_id" + alias: "set_multicast_group_id" + annotations: "@action_restriction(\"\n // Disallow 0 since it encodes \'no multicast\' in V1Model.\n multicast_group_id != 0;\n \")" + } + params { + id: 1 + name: "multicast_group_id" + annotations: "@refers_to(builtin : : multicast_group_table , multicast_group_id)" + bitwidth: 16 + } +} +actions { + preamble { + id: 16777473 + name: "ingress.acl_ingress.acl_copy" + alias: "acl_copy" + annotations: "@sai_action(SAI_PACKET_ACTION_COPY , SAI_PACKET_COLOR_GREEN)" + annotations: "@sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_RED)" + } + params { + id: 1 + name: "qos_queue" + annotations: "@sai_action_param(QOS_QUEUE)" + bitwidth: 8 + type_name { + name: "qos_queue_t" + } + } +} +actions { + preamble { + id: 16777474 + name: "ingress.acl_ingress.acl_trap" + alias: "acl_trap" + annotations: "@sai_action(SAI_PACKET_ACTION_TRAP , SAI_PACKET_COLOR_GREEN)" + annotations: "@sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED)" + } + params { + id: 1 + name: "qos_queue" + annotations: "@sai_action_param(QOS_QUEUE)" + bitwidth: 8 + type_name { + name: "qos_queue_t" + } + } +} +actions { + preamble { + id: 16777475 + name: "ingress.acl_ingress.acl_forward" + alias: "acl_forward" + annotations: "@sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_GREEN)" + annotations: "@sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED)" + } +} +actions { + preamble { + id: 16777477 + name: "ingress.acl_ingress.acl_count" + alias: "acl_count" + annotations: "@sai_action(SAI_PACKET_ACTION_FORWARD)" + } +} +actions { + preamble { + id: 16777476 + name: "ingress.acl_ingress.acl_mirror" + alias: "acl_mirror" + annotations: "@sai_action(SAI_PACKET_ACTION_FORWARD)" + } + params { + id: 1 + name: "mirror_session_id" + annotations: "@refers_to(mirror_session_table , mirror_session_id)" + annotations: "@sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_MIRROR_INGRESS)" + bitwidth: 10 + type_name { + name: "mirror_session_id_t" + } + } +} +actions { + preamble { + id: 16777484 + name: "ingress.acl_ingress.set_qos_queue_and_cancel_copy_above_rate_limit" + alias: "set_qos_queue_and_cancel_copy_above_rate_limit" + annotations: "@sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_GREEN)" + annotations: "@sai_action(SAI_PACKET_ACTION_COPY_CANCEL , SAI_PACKET_COLOR_RED)" + } + params { + id: 1 + name: "qos_queue" + annotations: "@sai_action_param(QOS_QUEUE)" + bitwidth: 8 + type_name { + name: "qos_queue_t" + } + } +} +actions { + preamble { + id: 16777489 + name: "ingress.acl_ingress.set_cpu_and_multicast_queues_and_deny_above_rate_limit" + alias: "set_cpu_and_multicast_queues_and_deny_above_rate_limit" + annotations: "@sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_GREEN)" + annotations: "@sai_action(SAI_PACKET_ACTION_DENY , SAI_PACKET_COLOR_RED)" + annotations: "@unsupported" + } + params { + id: 1 + name: "cpu_queue" + annotations: "@sai_action_param(QOS_QUEUE)" + bitwidth: 8 + type_name { + name: "qos_queue_t" + } + } + params { + id: 2 + name: "green_multicast_queue" + annotations: "@sai_action_param(MULTICAST_QOS_QUEUE , SAI_PACKET_COLOR_GREEN)" + bitwidth: 8 + type_name { + name: "qos_queue_t" + } + } + params { + id: 3 + name: "red_multicast_queue" + annotations: "@sai_action_param(MULTICAST_QOS_QUEUE , SAI_PACKET_COLOR_RED)" + bitwidth: 8 + type_name { + name: "qos_queue_t" + } + } +} +actions { + preamble { + id: 16777486 + name: "ingress.acl_ingress.set_cpu_queue_and_deny_above_rate_limit" + alias: "set_cpu_queue_and_deny_above_rate_limit" + annotations: "@sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_GREEN)" + annotations: "@sai_action(SAI_PACKET_ACTION_DENY , SAI_PACKET_COLOR_RED)" + } + params { + id: 1 + name: "cpu_queue" + annotations: "@sai_action_param(QOS_QUEUE)" + bitwidth: 8 + type_name { + name: "qos_queue_t" + } + } +} +actions { + preamble { + id: 16777488 + name: "ingress.acl_ingress.set_cpu_queue" + alias: "set_cpu_queue" + annotations: "@sai_action(SAI_PACKET_ACTION_FORWARD)" + } + params { + id: 1 + name: "cpu_queue" + annotations: "@sai_action_param(QOS_QUEUE)" + bitwidth: 8 + type_name { + name: "qos_queue_t" + } + } +} +actions { + preamble { + id: 16777217 + name: "ingress.routing_resolution.set_dst_mac" + alias: "set_dst_mac" + } + params { + id: 1 + name: "dst_mac" + annotations: "@format(MAC_ADDRESS)" + bitwidth: 48 + } +} +actions { + preamble { + id: 16777243 + name: "ingress.routing_resolution.set_port_and_src_mac_and_vlan_id" + alias: "set_port_and_src_mac_and_vlan_id" + annotations: "@unsupported" + annotations: "@action_restriction(\"\n // Disallow reserved VLAN IDs with implementation-defined semantics.\n vlan_id != 0 && vlan_id != 4095\")" + } + params { + id: 1 + name: "port" + bitwidth: 9 + type_name { + name: "port_id_t" + } + } + params { + id: 2 + name: "src_mac" + annotations: "@format(MAC_ADDRESS)" + bitwidth: 48 + } + params { + id: 3 + name: "vlan_id" + bitwidth: 12 + } +} +actions { + preamble { + id: 16777218 + name: "ingress.routing_resolution.set_port_and_src_mac" + alias: "set_port_and_src_mac" + } + params { + id: 1 + name: "port" + bitwidth: 9 + type_name { + name: "port_id_t" + } + } + params { + id: 2 + name: "src_mac" + annotations: "@format(MAC_ADDRESS)" + bitwidth: 48 + } +} +actions { + preamble { + id: 16777239 + name: "ingress.routing_resolution.set_ip_nexthop_and_disable_rewrites" + alias: "set_ip_nexthop_and_disable_rewrites" + } + params { + id: 1 + name: "router_interface_id" + annotations: "@refers_to(router_interface_table , router_interface_id)" + annotations: "@refers_to(neighbor_table , router_interface_id)" + bitwidth: 10 + type_name { + name: "router_interface_id_t" + } + } + params { + id: 2 + name: "neighbor_id" + annotations: "@format(IPV6_ADDRESS)" + annotations: "@refers_to(neighbor_table , neighbor_id)" + bitwidth: 128 + } + params { + id: 3 + name: "disable_decrement_ttl" + bitwidth: 1 + } + params { + id: 4 + name: "disable_src_mac_rewrite" + bitwidth: 1 + } params { - id: 2 - name: "src_mac" - annotations: "@format(MAC_ADDRESS)" - bitwidth: 48 + id: 5 + name: "disable_dst_mac_rewrite" + bitwidth: 1 + } + params { + id: 6 + name: "disable_vlan_rewrite" + bitwidth: 1 } } actions { preamble { id: 16777236 - name: "ingress.routing.set_ip_nexthop" + name: "ingress.routing_resolution.set_ip_nexthop" alias: "set_ip_nexthop" } params { @@ -816,7 +1651,7 @@ actions { actions { preamble { id: 16777219 - name: "ingress.routing.set_nexthop" + name: "ingress.routing_resolution.set_nexthop" alias: "set_nexthop" annotations: "@deprecated(\"Use set_ip_nexthop instead.\")" } @@ -840,267 +1675,197 @@ actions { } actions { preamble { - id: 16777221 - name: "ingress.routing.set_nexthop_id" - alias: "set_nexthop_id" + id: 16777234 + name: "ingress.routing_resolution.set_p2p_tunnel_encap_nexthop" + alias: "set_p2p_tunnel_encap_nexthop" } params { id: 1 - name: "nexthop_id" - annotations: "@refers_to(nexthop_table , nexthop_id)" + name: "tunnel_id" + annotations: "@refers_to(tunnel_table , tunnel_id)" bitwidth: 10 type_name { - name: "nexthop_id_t" + name: "tunnel_id_t" } } } actions { preamble { - id: 16777232 - name: "ingress.routing.set_nexthop_id_and_metadata" - alias: "set_nexthop_id_and_metadata" + id: 16777235 + name: "ingress.routing_resolution.mark_for_p2p_tunnel_encap" + alias: "mark_for_p2p_tunnel_encap" } params { id: 1 - name: "nexthop_id" - annotations: "@refers_to(nexthop_table , nexthop_id)" - bitwidth: 10 - type_name { - name: "nexthop_id_t" - } + name: "encap_src_ip" + annotations: "@format(IPV6_ADDRESS)" + bitwidth: 128 } params { id: 2 - name: "route_metadata" - bitwidth: 6 - } -} -actions { - preamble { - id: 24742814 - name: "ingress.routing.no_action" - alias: "no_action" - } -} -actions { - preamble { - id: 16777222 - name: "ingress.routing.drop" - alias: "drop" - } -} -actions { - preamble { - id: 16777220 - name: "ingress.routing.set_wcmp_group_id" - alias: "set_wcmp_group_id" + name: "encap_dst_ip" + annotations: "@format(IPV6_ADDRESS)" + annotations: "@refers_to(neighbor_table , neighbor_id)" + bitwidth: 128 } params { - id: 1 - name: "wcmp_group_id" - annotations: "@refers_to(wcmp_group_table , wcmp_group_id)" - bitwidth: 12 + id: 3 + name: "router_interface_id" + annotations: "@refers_to(neighbor_table , router_interface_id)" + annotations: "@refers_to(router_interface_table , router_interface_id)" + bitwidth: 10 type_name { - name: "wcmp_group_id_t" + name: "router_interface_id_t" } } } actions { preamble { - id: 16777233 - name: "ingress.routing.set_wcmp_group_id_and_metadata" - alias: "set_wcmp_group_id_and_metadata" + id: 16777223 + name: "ingress.mirror_session_lookup.mirror_as_ipv4_erspan" + alias: "mirror_as_ipv4_erspan" } params { id: 1 - name: "wcmp_group_id" - annotations: "@refers_to(wcmp_group_table , wcmp_group_id)" - bitwidth: 12 + name: "port" + bitwidth: 9 type_name { - name: "wcmp_group_id_t" + name: "port_id_t" } } params { id: 2 - name: "route_metadata" - bitwidth: 6 - } -} -actions { - preamble { - id: 16777231 - name: "ingress.routing.trap" - alias: "trap" - } -} -actions { - preamble { - id: 16777237 - name: "ingress.routing.set_metadata_and_drop" - alias: "set_metadata_and_drop" + name: "src_ip" + annotations: "@format(IPV4_ADDRESS)" + bitwidth: 32 } params { - id: 1 - name: "route_metadata" - bitwidth: 6 - } -} -actions { - preamble { - id: 16777473 - name: "ingress.acl_ingress.acl_copy" - alias: "acl_copy" - annotations: "@sai_action(SAI_PACKET_ACTION_COPY , SAI_PACKET_COLOR_GREEN)" - annotations: "@sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_YELLOW)" - annotations: "@sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_RED)" + id: 3 + name: "dst_ip" + annotations: "@format(IPV4_ADDRESS)" + bitwidth: 32 } params { - id: 1 - name: "qos_queue" - annotations: "@sai_action_param(QOS_QUEUE)" - bitwidth: 8 - type_name { - name: "qos_queue_t" - } + id: 4 + name: "src_mac" + annotations: "@format(MAC_ADDRESS)" + bitwidth: 48 } -} -actions { - preamble { - id: 16777474 - name: "ingress.acl_ingress.acl_trap" - alias: "acl_trap" - annotations: "@sai_action(SAI_PACKET_ACTION_TRAP , SAI_PACKET_COLOR_GREEN)" - annotations: "@sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_YELLOW)" - annotations: "@sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED)" + params { + id: 5 + name: "dst_mac" + annotations: "@format(MAC_ADDRESS)" + bitwidth: 48 } params { - id: 1 - name: "qos_queue" - annotations: "@sai_action_param(QOS_QUEUE)" + id: 6 + name: "ttl" bitwidth: 8 - type_name { - name: "qos_queue_t" - } - } -} -actions { - preamble { - id: 16777625 - name: "ingress.acl_ingress.acl_experimental_trap" - alias: "acl_experimental_trap" - annotations: "@sai_action(SAI_PACKET_ACTION_TRAP , SAI_PACKET_COLOR_GREEN)" - annotations: "@sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_YELLOW)" - annotations: "@sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED)" } params { - id: 1 - name: "qos_queue" - annotations: "@sai_action_param(QOS_QUEUE)" + id: 7 + name: "tos" bitwidth: 8 - type_name { - name: "qos_queue_t" - } - } -} -actions { - preamble { - id: 16777475 - name: "ingress.acl_ingress.acl_forward" - alias: "acl_forward" - annotations: "@sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_GREEN)" - annotations: "@sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_YELLOW)" - annotations: "@sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED)" } } actions { preamble { - id: 16777476 - name: "ingress.acl_ingress.acl_mirror" - alias: "acl_mirror" - annotations: "@sai_action(SAI_PACKET_ACTION_FORWARD)" + id: 16777245 + name: "ingress.mirror_session_lookup.mirror_with_vlan_tag_and_ipfix_encapsulation" + alias: "mirror_with_vlan_tag_and_ipfix_encapsulation" + annotations: "@unsupported" } params { id: 1 - name: "mirror_session_id" - annotations: "@refers_to(mirror_session_table , mirror_session_id)" - annotations: "@sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_MIRROR_INGRESS)" - bitwidth: 10 + name: "monitor_port" + bitwidth: 9 type_name { - name: "mirror_session_id_t" + name: "port_id_t" } } -} -actions { - preamble { - id: 16777223 - name: "ingress.mirroring_clone.mirror_as_ipv4_erspan" - alias: "mirror_as_ipv4_erspan" - } params { - id: 1 - name: "port" + id: 2 + name: "monitor_failover_port" bitwidth: 9 type_name { name: "port_id_t" } } - params { - id: 2 - name: "src_ip" - annotations: "@format(IPV4_ADDRESS)" - bitwidth: 32 - } params { id: 3 - name: "dst_ip" - annotations: "@format(IPV4_ADDRESS)" - bitwidth: 32 - } - params { - id: 4 - name: "src_mac" + name: "mirror_encap_src_mac" annotations: "@format(MAC_ADDRESS)" bitwidth: 48 } params { - id: 5 - name: "dst_mac" + id: 4 + name: "mirror_encap_dst_mac" annotations: "@format(MAC_ADDRESS)" bitwidth: 48 } params { id: 6 - name: "ttl" - bitwidth: 8 + name: "mirror_encap_vlan_id" + bitwidth: 12 } params { id: 7 - name: "tos" - bitwidth: 8 + name: "mirror_encap_dst_ip" + annotations: "@format(IPV6_ADDRESS)" + bitwidth: 128 + } + params { + id: 8 + name: "mirror_encap_src_ip" + annotations: "@format(IPV6_ADDRESS)" + bitwidth: 128 + } + params { + id: 9 + name: "mirror_encap_udp_src_port" + bitwidth: 16 + } + params { + id: 10 + name: "mirror_encap_udp_dst_port" + bitwidth: 16 } } actions { preamble { - id: 16777225 - name: "ingress.mirroring_clone.set_pre_session" - alias: "set_pre_session" + id: 16777244 + name: "ingress.ingress_cloning.ingress_clone" + alias: "ingress_clone" } params { id: 1 - name: "id" + name: "clone_session" bitwidth: 32 } } +actions { + preamble { + id: 16777241 + name: "egress.packet_rewrites.multicast_rewrites.set_multicast_src_mac" + alias: "set_multicast_src_mac" + } + params { + id: 1 + name: "src_mac" + annotations: "@format(MAC_ADDRESS)" + bitwidth: 48 + } +} action_profiles { preamble { id: 299650760 - name: "ingress.routing.wcmp_group_selector" + name: "ingress.routing_resolution.wcmp_group_selector" alias: "wcmp_group_selector" } table_ids: 33554499 with_selector: true - size: 65536 - max_group_size: 256 + size: 49152 + max_group_size: 512 } direct_counters { preamble { @@ -1124,6 +1889,28 @@ direct_counters { } direct_table_id: 33554688 } +direct_counters { + preamble { + id: 318767367 + name: "ingress.acl_ingress.acl_ingress_qos_counter" + alias: "acl_ingress_qos_counter" + } + spec { + unit: BOTH + } + direct_table_id: 33554695 +} +direct_counters { + preamble { + id: 318767369 + name: "ingress.acl_ingress.acl_ingress_counting_counter" + alias: "acl_ingress_counting_counter" + } + spec { + unit: BOTH + } + direct_table_id: 33554697 +} direct_counters { preamble { id: 318767364 @@ -1140,12 +1927,25 @@ direct_meters { id: 352321792 name: "ingress.acl_ingress.acl_ingress_meter" alias: "acl_ingress_meter" + annotations: "@mode(single_rate_two_color)" } spec { unit: BYTES } direct_table_id: 33554688 } +direct_meters { + preamble { + id: 352321794 + name: "ingress.acl_ingress.acl_ingress_qos_meter" + alias: "acl_ingress_qos_meter" + annotations: "@mode(single_rate_two_color)" + } + spec { + unit: BYTES + } + direct_table_id: 33554695 +} controller_packet_metadata { preamble { id: 81826293 @@ -1193,7 +1993,8 @@ controller_packet_metadata { metadata { id: 3 name: "unused_pad" - bitwidth: 7 + annotations: "@padding" + bitwidth: 6 } } type_info { @@ -1257,6 +2058,18 @@ type_info { } } } + new_types { + key: "tunnel_id_t" + value { + original_type { + bitstring { + bit { + bitwidth: 10 + } + } + } + } + } new_types { key: "vrf_id_t" value { @@ -1267,6 +2080,7 @@ type_info { } } } + annotations: "@p4runtime_translation_mappings({ { \"\" , 0 } , })" } } new_types { diff --git a/testdata/p4_16_samples_outputs/pins/pins_middleblock-first.p4 b/testdata/p4_16_samples_outputs/pins/pins_middleblock-first.p4 index 0239813a93..c2ce74b395 100644 --- a/testdata/p4_16_samples_outputs/pins/pins_middleblock-first.p4 +++ b/testdata/p4_16_samples_outputs/pins/pins_middleblock-first.p4 @@ -5,10 +5,21 @@ typedef bit<48> ethernet_addr_t; typedef bit<32> ipv4_addr_t; typedef bit<128> ipv6_addr_t; +typedef bit<12> vlan_id_t; +typedef bit<16> ether_type_t; +const vlan_id_t INTERNAL_VLAN_ID_0 = 12w0xfff; +const vlan_id_t NO_VLAN_ID_0 = 12w0x0; header ethernet_t { ethernet_addr_t dst_addr; ethernet_addr_t src_addr; - bit<16> ether_type; + ether_type_t ether_type; +} + +header vlan_t { + bit<3> priority_code_point; + bit<1> drop_eligible_indicator; + vlan_id_t vlan_id; + ether_type_t ether_type; } header ipv4_t { @@ -65,6 +76,7 @@ header icmp_t { bit<8> type; bit<8> code; bit<16> checksum; + bit<32> rest_of_header; } header arp_t { @@ -92,109 +104,220 @@ header gre_t { bit<16> protocol; } +header ipfix_t { + bit<16> version_number; + bit<16> length; + bit<32> export_time; + bit<32> sequence_number; + bit<32> observation_domain_id; +} + +header psamp_extended_t { + bit<16> template_id; + bit<16> length; + bit<64> observation_time; + bit<16> flowset; + bit<16> next_hop_index; + bit<16> epoch; + bit<16> ingress_port; + bit<16> egress_port; + bit<16> user_meta_field; + bit<8> dlb_id; + bit<8> variable_length; + bit<16> packet_sampled_length; +} + enum bit<8> PreservedFieldList { - CLONE_I2E = 8w1 + MIRROR_AND_PACKET_IN_COPY = 8w1, + RECIRCULATE = 8w2 } type bit<10> nexthop_id_t; type bit<10> tunnel_id_t; type bit<12> wcmp_group_id_t; -type bit<10> vrf_id_t; -const vrf_id_t kDefaultVrf = (vrf_id_t)10w0; +@p4runtime_translation_mappings({ { "" , 0 } , }) type bit<10> vrf_id_t; +const vrf_id_t kDefaultVrf_0 = (vrf_id_t)10w0; type bit<10> router_interface_id_t; type bit<9> port_id_t; type bit<10> mirror_session_id_t; type bit<8> qos_queue_t; typedef bit<6> route_metadata_t; +typedef bit<8> acl_metadata_t; +typedef bit<16> multicast_group_id_t; +typedef bit<16> replica_instance_t; enum bit<2> MeterColor_t { GREEN = 2w0, YELLOW = 2w1, RED = 2w2 } +@controller_header("packet_in") header packet_in_header_t { + @id(1) + port_id_t ingress_port; + @id(2) + port_id_t target_egress_port; +} + +@controller_header("packet_out") header packet_out_header_t { + @id(1) + port_id_t egress_port; + @id(2) + bit<1> submit_to_ingress; + @id(3) @padding + bit<6> unused_pad; +} + struct headers_t { - ethernet_t erspan_ethernet; - ipv4_t erspan_ipv4; - gre_t erspan_gre; - ethernet_t ethernet; - ipv6_t tunnel_encap_ipv6; - gre_t tunnel_encap_gre; - ipv4_t ipv4; - ipv6_t ipv6; - icmp_t icmp; - tcp_t tcp; - udp_t udp; - arp_t arp; + packet_out_header_t packet_out_header; + ethernet_t mirror_encap_ethernet; + vlan_t mirror_encap_vlan; + ipv6_t mirror_encap_ipv6; + udp_t mirror_encap_udp; + ipfix_t ipfix; + psamp_extended_t psamp_extended; + ethernet_t ethernet; + vlan_t vlan; + ipv6_t tunnel_encap_ipv6; + gre_t tunnel_encap_gre; + ipv4_t ipv4; + ipv6_t ipv6; + ipv4_t inner_ipv4; + ipv6_t inner_ipv6; + icmp_t icmp; + tcp_t tcp; + udp_t udp; + arp_t arp; } struct packet_rewrites_t { ethernet_addr_t src_mac; ethernet_addr_t dst_mac; + vlan_id_t vlan_id; } struct local_metadata_t { + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + bool enable_vlan_checks; + vlan_id_t vlan_id; bool admit_to_l3; vrf_id_t vrf_id; + bool enable_decrement_ttl; + bool enable_src_mac_rewrite; + bool enable_dst_mac_rewrite; + bool enable_vlan_rewrite; packet_rewrites_t packet_rewrites; bit<16> l4_src_port; bit<16> l4_dst_port; - bit<16> wcmp_selector_input; + bit<8> wcmp_selector_input; + bool apply_tunnel_decap_at_end_of_pre_ingress; bool apply_tunnel_encap_at_egress; ipv6_addr_t tunnel_encap_src_ipv6; ipv6_addr_t tunnel_encap_dst_ipv6; - bool mirror_session_id_valid; - mirror_session_id_t mirror_session_id_value; - @field_list(PreservedFieldList.CLONE_I2E) - ipv4_addr_t mirroring_src_ip; - @field_list(PreservedFieldList.CLONE_I2E) - ipv4_addr_t mirroring_dst_ip; - @field_list(PreservedFieldList.CLONE_I2E) - ethernet_addr_t mirroring_src_mac; - @field_list(PreservedFieldList.CLONE_I2E) - ethernet_addr_t mirroring_dst_mac; - @field_list(PreservedFieldList.CLONE_I2E) - bit<8> mirroring_ttl; - @field_list(PreservedFieldList.CLONE_I2E) - bit<8> mirroring_tos; + bool marked_to_copy; + bool marked_to_mirror; + mirror_session_id_t mirror_session_id; + port_id_t mirror_egress_port; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + ethernet_addr_t mirror_encap_src_mac; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + ethernet_addr_t mirror_encap_dst_mac; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + vlan_id_t mirror_encap_vlan_id; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + ipv6_addr_t mirror_encap_src_ip; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + ipv6_addr_t mirror_encap_dst_ip; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + bit<16> mirror_encap_udp_src_port; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + bit<16> mirror_encap_udp_dst_port; + @field_list(PreservedFieldList.RECIRCULATE) + bit<9> loopback_port; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + bit<9> packet_in_ingress_port; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + bit<9> packet_in_target_egress_port; MeterColor_t color; port_id_t ingress_port; route_metadata_t route_metadata; -} - -@controller_header("packet_in") header packet_in_header_t { - @id(1) - port_id_t ingress_port; - @id(2) - port_id_t target_egress_port; -} - -@controller_header("packet_out") header packet_out_header_t { - @id(1) - port_id_t egress_port; - @id(2) - bit<1> submit_to_ingress; - @id(3) - bit<7> unused_pad; + acl_metadata_t acl_metadata; + bool bypass_ingress; + bool wcmp_group_id_valid; + wcmp_group_id_t wcmp_group_id_value; + bool nexthop_id_valid; + nexthop_id_t nexthop_id_value; + bool ipmc_table_hit; + bool acl_drop; } parser packet_parser(packet_in packet, out headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { state start { + local_metadata.enable_vlan_checks = false; + local_metadata.vlan_id = 12w0; local_metadata.admit_to_l3 = false; local_metadata.vrf_id = (vrf_id_t)10w0; + local_metadata.enable_decrement_ttl = false; + local_metadata.enable_src_mac_rewrite = false; + local_metadata.enable_dst_mac_rewrite = false; + local_metadata.enable_vlan_rewrite = false; local_metadata.packet_rewrites.src_mac = 48w0; local_metadata.packet_rewrites.dst_mac = 48w0; local_metadata.l4_src_port = 16w0; local_metadata.l4_dst_port = 16w0; - local_metadata.wcmp_selector_input = 16w0; - local_metadata.mirror_session_id_valid = false; + local_metadata.wcmp_selector_input = 8w0; + local_metadata.apply_tunnel_decap_at_end_of_pre_ingress = false; + local_metadata.apply_tunnel_encap_at_egress = false; + local_metadata.tunnel_encap_src_ipv6 = 128w0; + local_metadata.tunnel_encap_dst_ipv6 = 128w0; + local_metadata.marked_to_copy = false; + local_metadata.marked_to_mirror = false; + local_metadata.mirror_session_id = (mirror_session_id_t)10w0; + local_metadata.mirror_egress_port = (port_id_t)9w0; local_metadata.color = MeterColor_t.GREEN; - local_metadata.ingress_port = (port_id_t)standard_metadata.ingress_port; local_metadata.route_metadata = 6w0; + local_metadata.bypass_ingress = false; + local_metadata.wcmp_group_id_valid = false; + local_metadata.wcmp_group_id_value = (wcmp_group_id_t)12w0; + local_metadata.nexthop_id_valid = false; + local_metadata.nexthop_id_value = (nexthop_id_t)10w0; + local_metadata.ipmc_table_hit = false; + local_metadata.acl_drop = false; + transition select(standard_metadata.instance_type == 32w4) { + true: start_true; + false: start_false; + } + } + state start_true { + local_metadata.ingress_port = (port_id_t)local_metadata.loopback_port; + transition start_join; + } + state start_false { + local_metadata.ingress_port = (port_id_t)standard_metadata.ingress_port; + transition start_join; + } + state start_join { + transition select(standard_metadata.ingress_port) { + 9w510: parse_packet_out_header; + default: parse_ethernet; + } + } + state parse_packet_out_header { + packet.extract(headers.packet_out_header); transition parse_ethernet; } state parse_ethernet { packet.extract(headers.ethernet); transition select(headers.ethernet.ether_type) { + 16w0x800: parse_ipv4; + 16w0x86dd: parse_ipv6; + 16w0x806: parse_arp; + 16w0x8100: parse_8021q_vlan; + default: accept; + } + } + state parse_8021q_vlan { + packet.extract(headers.vlan); + transition select(headers.vlan.ether_type) { 16w0x800: parse_ipv4; 16w0x86dd: parse_ipv6; 16w0x806: parse_arp; @@ -204,6 +327,17 @@ parser packet_parser(packet_in packet, out headers_t headers, inout local_metada state parse_ipv4 { packet.extract(headers.ipv4); transition select(headers.ipv4.protocol) { + 8w0x4: parse_ipv4_in_ip; + 8w0x29: parse_ipv6_in_ip; + 8w0x1: parse_icmp; + 8w0x6: parse_tcp; + 8w0x11: parse_udp; + default: accept; + } + } + state parse_ipv4_in_ip { + packet.extract(headers.inner_ipv4); + transition select(headers.inner_ipv4.protocol) { 8w0x1: parse_icmp; 8w0x6: parse_tcp; 8w0x11: parse_udp; @@ -213,6 +347,17 @@ parser packet_parser(packet_in packet, out headers_t headers, inout local_metada state parse_ipv6 { packet.extract(headers.ipv6); transition select(headers.ipv6.next_header) { + 8w0x4: parse_ipv4_in_ip; + 8w0x29: parse_ipv6_in_ip; + 8w0x3a: parse_icmp; + 8w0x6: parse_tcp; + 8w0x11: parse_udp; + default: accept; + } + } + state parse_ipv6_in_ip { + packet.extract(headers.inner_ipv6); + transition select(headers.inner_ipv6.next_header) { 8w0x3a: parse_icmp; 8w0x6: parse_tcp; 8w0x11: parse_udp; @@ -243,14 +388,21 @@ parser packet_parser(packet_in packet, out headers_t headers, inout local_metada control packet_deparser(packet_out packet, in headers_t headers) { apply { - packet.emit(headers.erspan_ethernet); - packet.emit(headers.erspan_ipv4); - packet.emit(headers.erspan_gre); + packet.emit(headers.packet_out_header); + packet.emit(headers.mirror_encap_ethernet); + packet.emit(headers.mirror_encap_vlan); + packet.emit(headers.mirror_encap_ipv6); + packet.emit(headers.mirror_encap_udp); + packet.emit(headers.ipfix); + packet.emit(headers.psamp_extended); packet.emit(headers.ethernet); + packet.emit(headers.vlan); packet.emit(headers.tunnel_encap_ipv6); packet.emit(headers.tunnel_encap_gre); packet.emit(headers.ipv4); packet.emit(headers.ipv6); + packet.emit(headers.inner_ipv4); + packet.emit(headers.inner_ipv6); packet.emit(headers.arp); packet.emit(headers.icmp); packet.emit(headers.tcp); @@ -258,175 +410,274 @@ control packet_deparser(packet_out packet, in headers_t headers) { } } -control routing(in headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { - bool wcmp_group_id_valid = false; - wcmp_group_id_t wcmp_group_id_value; - bool nexthop_id_valid = false; - nexthop_id_t nexthop_id_value; - bool router_interface_id_valid = false; - router_interface_id_t router_interface_id_value; - bool neighbor_id_valid = false; - ipv6_addr_t neighbor_id_value; - @id(0x01000001) action set_dst_mac(@id(1) @format(MAC_ADDRESS) ethernet_addr_t dst_mac) { - local_metadata.packet_rewrites.dst_mac = dst_mac; +control packet_in_encap(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { + apply { } - @p4runtime_role("sdn_controller") @id(0x02000040) table neighbor_table { +} + +control packet_out_decap(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { + apply { + if (headers.packet_out_header.isValid() && headers.packet_out_header.submit_to_ingress == 1w0) { + standard_metadata.egress_spec = (bit<9>)headers.packet_out_header.egress_port; + local_metadata.bypass_ingress = true; + } + headers.packet_out_header.setInvalid(); + } +} + +@id(0x01000005) action set_nexthop_id(inout local_metadata_t local_metadata, @id(1) @refers_to(nexthop_table , nexthop_id) nexthop_id_t nexthop_id) { + local_metadata.nexthop_id_valid = true; + local_metadata.nexthop_id_value = nexthop_id; +} +control routing_lookup(in headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { + @id(0x01798B9E) @name("no_action") action no_action_0() { + } + @entry_restriction(" + // The VRF ID 0 (or '' in P4Runtime) encodes the default VRF, which cannot + // be read or written via this table, but is always present implicitly. + // TODO: This constraint should read `vrf_id != ''` (since + // constraints are a control plane (P4Runtime) concept), but + // p4-constraints does not currently support strings. + vrf_id != 0; + ") @p4runtime_role("sdn_controller") @id(0x0200004A) @name("vrf_table") table vrf_table_0 { key = { - router_interface_id_value: exact @id(1) @name("router_interface_id") @refers_to(router_interface_table , router_interface_id); - neighbor_id_value : exact @id(2) @format(IPV6_ADDRESS) @name("neighbor_id"); + local_metadata.vrf_id: exact @id(1) @name("vrf_id"); } actions = { - @proto_id(1) set_dst_mac(); - @defaultonly NoAction(); + @proto_id(1) no_action_0(); } - const default_action = NoAction(); - size = 1024; + const default_action = no_action_0(); + size = 64; } - @id(0x01000002) action set_port_and_src_mac(@id(1) port_id_t port, @id(2) @format(MAC_ADDRESS) ethernet_addr_t src_mac) { - standard_metadata.egress_spec = (bit<9>)port; - local_metadata.packet_rewrites.src_mac = src_mac; + @id(0x01000006) @name("drop") action drop_0() { + mark_to_drop(standard_metadata); } - @p4runtime_role("sdn_controller") @id(0x02000041) table router_interface_table { + @id(0x01000004) @name("set_wcmp_group_id") action set_wcmp_group_id_0(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) wcmp_group_id_t wcmp_group_id) { + local_metadata.wcmp_group_id_valid = true; + local_metadata.wcmp_group_id_value = wcmp_group_id; + } + @id(0x01000011) @name("set_wcmp_group_id_and_metadata") action set_wcmp_group_id_and_metadata_0(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) wcmp_group_id_t wcmp_group_id, route_metadata_t route_metadata) { + set_wcmp_group_id_0(wcmp_group_id); + local_metadata.route_metadata = route_metadata; + } + @id(0x01000015) @name("set_metadata_and_drop") action set_metadata_and_drop_0(@id(1) route_metadata_t route_metadata) { + local_metadata.route_metadata = route_metadata; + mark_to_drop(standard_metadata); + } + @id(0x01000010) @name("set_nexthop_id_and_metadata") action set_nexthop_id_and_metadata_0(@id(1) @refers_to(nexthop_table , nexthop_id) nexthop_id_t nexthop_id, route_metadata_t route_metadata) { + local_metadata.nexthop_id_valid = true; + local_metadata.nexthop_id_value = nexthop_id; + local_metadata.route_metadata = route_metadata; + } + @id(0x01000018) @action_restriction(" + // Disallow 0 since it encodes 'no multicast' in V1Model. + multicast_group_id != 0; + ") @name("set_multicast_group_id") action set_multicast_group_id_0(@id(1) @refers_to(builtin : : multicast_group_table , multicast_group_id) multicast_group_id_t multicast_group_id) { + standard_metadata.mcast_grp = multicast_group_id; + } + @p4runtime_role("sdn_controller") @id(0x02000044) @name("ipv4_table") table ipv4_table_0 { key = { - router_interface_id_value: exact @id(1) @name("router_interface_id"); + local_metadata.vrf_id: exact @id(1) @name("vrf_id") @refers_to(vrf_table , vrf_id); + headers.ipv4.dst_addr: lpm @id(2) @name("ipv4_dst") @format(IPV4_ADDRESS); } actions = { - @proto_id(1) set_port_and_src_mac(); - @defaultonly NoAction(); + @proto_id(1) drop_0(); + @proto_id(2) set_nexthop_id(local_metadata); + @proto_id(3) set_wcmp_group_id_0(); + @proto_id(5) set_nexthop_id_and_metadata_0(); + @proto_id(6) set_wcmp_group_id_and_metadata_0(); + @proto_id(7) set_metadata_and_drop_0(); } - const default_action = NoAction(); - size = 256; + const default_action = drop_0(); + size = 131072; } - @id(0x01000014) action set_ip_nexthop(@id(1) @refers_to(router_interface_table , router_interface_id) @refers_to(neighbor_table , router_interface_id) router_interface_id_t router_interface_id, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) ipv6_addr_t neighbor_id) { - router_interface_id_valid = true; - router_interface_id_value = router_interface_id; - neighbor_id_valid = true; - neighbor_id_value = neighbor_id; + @p4runtime_role("sdn_controller") @id(0x02000045) @name("ipv6_table") table ipv6_table_0 { + key = { + local_metadata.vrf_id: exact @id(1) @name("vrf_id") @refers_to(vrf_table , vrf_id); + headers.ipv6.dst_addr: lpm @id(2) @name("ipv6_dst") @format(IPV6_ADDRESS); + } + actions = { + @proto_id(1) drop_0(); + @proto_id(2) set_nexthop_id(local_metadata); + @proto_id(3) set_wcmp_group_id_0(); + @proto_id(5) set_nexthop_id_and_metadata_0(); + @proto_id(6) set_wcmp_group_id_and_metadata_0(); + @proto_id(7) set_metadata_and_drop_0(); + } + const default_action = drop_0(); + size = 17000; } - @id(0x01000003) @deprecated("Use set_ip_nexthop instead.") action set_nexthop(@id(1) @refers_to(router_interface_table , router_interface_id) @refers_to(neighbor_table , router_interface_id) router_interface_id_t router_interface_id, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) ipv6_addr_t neighbor_id) { - set_ip_nexthop(router_interface_id, neighbor_id); + @p4runtime_role("sdn_controller") @id(0x0200004E) @name("ipv4_multicast_table") table ipv4_multicast_table_0 { + key = { + local_metadata.vrf_id: exact @id(1) @name("vrf_id") @refers_to(vrf_table , vrf_id); + headers.ipv4.dst_addr: exact @id(2) @name("ipv4_dst") @format(IPV4_ADDRESS); + } + actions = { + @proto_id(1) set_multicast_group_id_0(); + @defaultonly NoAction(); + } + size = 1600; + default_action = NoAction(); } - @p4runtime_role("sdn_controller") @id(0x02000042) table nexthop_table { + @p4runtime_role("sdn_controller") @id(0x0200004F) @name("ipv6_multicast_table") table ipv6_multicast_table_0 { key = { - nexthop_id_value: exact @id(1) @name("nexthop_id"); + local_metadata.vrf_id: exact @id(1) @name("vrf_id") @refers_to(vrf_table , vrf_id); + headers.ipv6.dst_addr: exact @id(2) @name("ipv6_dst") @format(IPV6_ADDRESS); } actions = { - @proto_id(1) set_nexthop(); - @proto_id(3) set_ip_nexthop(); + @proto_id(1) set_multicast_group_id_0(); @defaultonly NoAction(); } - const default_action = NoAction(); - size = 1024; + size = 1600; + default_action = NoAction(); } - @id(0x01000005) action set_nexthop_id(@id(1) @refers_to(nexthop_table , nexthop_id) nexthop_id_t nexthop_id) { - nexthop_id_valid = true; - nexthop_id_value = nexthop_id; + apply { + mark_to_drop(standard_metadata); + vrf_table_0.apply(); + if (local_metadata.admit_to_l3) { + if (headers.ipv4.isValid()) { + ipv4_table_0.apply(); + ipv4_multicast_table_0.apply(); + local_metadata.ipmc_table_hit = standard_metadata.mcast_grp != 16w0; + } else if (headers.ipv6.isValid()) { + ipv6_table_0.apply(); + ipv6_multicast_table_0.apply(); + local_metadata.ipmc_table_hit = standard_metadata.mcast_grp != 16w0; + } + } } - @id(0x01000010) action set_nexthop_id_and_metadata(@id(1) @refers_to(nexthop_table , nexthop_id) nexthop_id_t nexthop_id, route_metadata_t route_metadata) { - nexthop_id_valid = true; - nexthop_id_value = nexthop_id; - local_metadata.route_metadata = route_metadata; +} + +control routing_resolution(in headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { + @name("tunnel_id_valid") bool tunnel_id_valid_0 = false; + @name("tunnel_id_value") tunnel_id_t tunnel_id_value_0; + @name("router_interface_id_valid") bool router_interface_id_valid_0 = false; + @name("router_interface_id_value") router_interface_id_t router_interface_id_value_0; + @name("neighbor_id_valid") bool neighbor_id_valid_0 = false; + @name("neighbor_id_value") ipv6_addr_t neighbor_id_value_0; + @id(0x01000001) @name("set_dst_mac") action set_dst_mac_0(@id(1) @format(MAC_ADDRESS) ethernet_addr_t dst_mac) { + local_metadata.packet_rewrites.dst_mac = dst_mac; } - @max_group_size(256) action_selector(HashAlgorithm.identity, 32w65536, 32w16) wcmp_group_selector; - @p4runtime_role("sdn_controller") @id(0x02000043) @oneshot table wcmp_group_table { + @p4runtime_role("sdn_controller") @id(0x02000040) @name("neighbor_table") table neighbor_table_0 { key = { - wcmp_group_id_value : exact @id(1) @name("wcmp_group_id"); - local_metadata.wcmp_selector_input: selector @name("local_metadata.wcmp_selector_input"); + router_interface_id_value_0: exact @id(1) @name("router_interface_id") @refers_to(router_interface_table , router_interface_id); + neighbor_id_value_0 : exact @id(2) @format(IPV6_ADDRESS) @name("neighbor_id"); } actions = { - @proto_id(1) set_nexthop_id(); + @proto_id(1) set_dst_mac_0(); @defaultonly NoAction(); } const default_action = NoAction(); - @id(0x11DC4EC8) implementation = wcmp_group_selector; - size = 3968; + size = 1024; } - action no_action() { + @id(0x0100001B) @unsupported @action_restriction(" + // Disallow reserved VLAN IDs with implementation-defined semantics. + vlan_id != 0 && vlan_id != 4095") @name("set_port_and_src_mac_and_vlan_id") action set_port_and_src_mac_and_vlan_id_0(@id(1) port_id_t port, @id(2) @format(MAC_ADDRESS) ethernet_addr_t src_mac, @id(3) vlan_id_t vlan_id) { + standard_metadata.egress_spec = (bit<9>)port; + local_metadata.packet_rewrites.src_mac = src_mac; + local_metadata.packet_rewrites.vlan_id = vlan_id; } - @entry_restriction(" - // The VRF ID 0 (or '' in P4Runtime) encodes the default VRF, which cannot - // be read or written via this table, but is always present implicitly. - // TODO: This constraint should read `vrf_id != ''` (since - // constraints are a control plane (P4Runtime) concept), but - // p4-constraints does not currently support strings. - vrf_id != 0; - ") @p4runtime_role("sdn_controller") @id(0x0200004A) table vrf_table { + @id(0x01000002) @name("set_port_and_src_mac") action set_port_and_src_mac_0(@id(1) port_id_t port, @id(2) @format(MAC_ADDRESS) ethernet_addr_t src_mac) { + set_port_and_src_mac_and_vlan_id_0(port, src_mac, 12w0xfff); + } + @p4runtime_role("sdn_controller") @id(0x02000041) @name("router_interface_table") table router_interface_table_0 { key = { - local_metadata.vrf_id: exact @id(1) @name("vrf_id"); + router_interface_id_value_0: exact @id(1) @name("router_interface_id"); } actions = { - @proto_id(1) no_action(); + @proto_id(1) set_port_and_src_mac_0(); + @proto_id(2) set_port_and_src_mac_and_vlan_id_0(); + @defaultonly NoAction(); } - const default_action = no_action(); - size = 64; + const default_action = NoAction(); + size = 256; } - @id(0x01000006) action drop() { - mark_to_drop(standard_metadata); + @id(0x01000017) @name("set_ip_nexthop_and_disable_rewrites") action set_ip_nexthop_and_disable_rewrites_0(@id(1) @refers_to(router_interface_table , router_interface_id) @refers_to(neighbor_table , router_interface_id) router_interface_id_t router_interface_id, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) ipv6_addr_t neighbor_id, @id(3) bit<1> disable_decrement_ttl, @id(4) bit<1> disable_src_mac_rewrite, @id(5) bit<1> disable_dst_mac_rewrite, @id(6) bit<1> disable_vlan_rewrite) { + router_interface_id_valid_0 = true; + router_interface_id_value_0 = router_interface_id; + neighbor_id_valid_0 = true; + neighbor_id_value_0 = neighbor_id; + local_metadata.enable_decrement_ttl = !(bool)disable_decrement_ttl; + local_metadata.enable_src_mac_rewrite = !(bool)disable_src_mac_rewrite; + local_metadata.enable_dst_mac_rewrite = !(bool)disable_dst_mac_rewrite; + local_metadata.enable_vlan_rewrite = !(bool)disable_vlan_rewrite; } - @id(0x01000004) action set_wcmp_group_id(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) wcmp_group_id_t wcmp_group_id) { - wcmp_group_id_valid = true; - wcmp_group_id_value = wcmp_group_id; + @id(0x01000014) @name("set_ip_nexthop") action set_ip_nexthop_0(@id(1) @refers_to(router_interface_table , router_interface_id) @refers_to(neighbor_table , router_interface_id) router_interface_id_t router_interface_id, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) ipv6_addr_t neighbor_id) { + set_ip_nexthop_and_disable_rewrites_0(router_interface_id, neighbor_id, 1w0x0, 1w0x0, 1w0x0, 1w0x0); } - @id(0x01000011) action set_wcmp_group_id_and_metadata(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) wcmp_group_id_t wcmp_group_id, route_metadata_t route_metadata) { - set_wcmp_group_id(wcmp_group_id); - local_metadata.route_metadata = route_metadata; + @id(0x01000003) @deprecated("Use set_ip_nexthop instead.") @name("set_nexthop") action set_nexthop_0(@id(1) @refers_to(router_interface_table , router_interface_id) @refers_to(neighbor_table , router_interface_id) router_interface_id_t router_interface_id, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) ipv6_addr_t neighbor_id) { + set_ip_nexthop_0(router_interface_id, neighbor_id); } - @id(0x0100000F) action trap() { - clone(CloneType.I2E, 32w1024); - mark_to_drop(standard_metadata); + @id(0x01000012) @name("set_p2p_tunnel_encap_nexthop") action set_p2p_tunnel_encap_nexthop_0(@id(1) @refers_to(tunnel_table , tunnel_id) tunnel_id_t tunnel_id) { + tunnel_id_valid_0 = true; + tunnel_id_value_0 = tunnel_id; } - @p4runtime_role("sdn_controller") @id(0x02000044) table ipv4_table { + @p4runtime_role("sdn_controller") @id(0x02000042) @name("nexthop_table") table nexthop_table_0 { key = { - local_metadata.vrf_id: exact @id(1) @name("vrf_id") @refers_to(vrf_table , vrf_id); - headers.ipv4.dst_addr: lpm @format(IPV4_ADDRESS) @id(2) @name("ipv4_dst"); + local_metadata.nexthop_id_value: exact @id(1) @name("nexthop_id"); } actions = { - @proto_id(1) drop(); - @proto_id(2) set_nexthop_id(); - @proto_id(3) set_wcmp_group_id(); - @proto_id(4) trap(); - @proto_id(5) set_nexthop_id_and_metadata(); - @proto_id(6) set_wcmp_group_id_and_metadata(); + @proto_id(1) set_nexthop_0(); + @proto_id(2) set_p2p_tunnel_encap_nexthop_0(); + @proto_id(3) set_ip_nexthop_0(); + @proto_id(4) set_ip_nexthop_and_disable_rewrites_0(); + @defaultonly NoAction(); } - const default_action = drop(); - size = 32768; + const default_action = NoAction(); + size = 1024; } - @p4runtime_role("sdn_controller") @id(0x02000045) table ipv6_table { + @id(0x01000013) @name("mark_for_p2p_tunnel_encap") action mark_for_p2p_tunnel_encap_0(@id(1) @format(IPV6_ADDRESS) ipv6_addr_t encap_src_ip, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) ipv6_addr_t encap_dst_ip, @id(3) @refers_to(neighbor_table , router_interface_id) @refers_to(router_interface_table , router_interface_id) router_interface_id_t router_interface_id) { + local_metadata.tunnel_encap_src_ipv6 = encap_src_ip; + local_metadata.tunnel_encap_dst_ipv6 = encap_dst_ip; + local_metadata.apply_tunnel_encap_at_egress = true; + set_ip_nexthop_0(router_interface_id, encap_dst_ip); + } + @p4runtime_role("sdn_controller") @id(0x02000050) @name("tunnel_table") table tunnel_table_0 { key = { - local_metadata.vrf_id: exact @id(1) @name("vrf_id") @refers_to(vrf_table , vrf_id); - headers.ipv6.dst_addr: lpm @format(IPV6_ADDRESS) @id(2) @name("ipv6_dst"); + tunnel_id_value_0: exact @id(1) @name("tunnel_id"); } actions = { - @proto_id(1) drop(); - @proto_id(2) set_nexthop_id(); - @proto_id(3) set_wcmp_group_id(); - @proto_id(4) trap(); - @proto_id(5) set_nexthop_id_and_metadata(); - @proto_id(6) set_wcmp_group_id_and_metadata(); + @proto_id(1) mark_for_p2p_tunnel_encap_0(); + @defaultonly NoAction(); } - const default_action = drop(); - size = 4096; + const default_action = NoAction(); + size = 2048; + } + @max_group_size(512) @id(0x11DC4EC8) @name("wcmp_group_selector") action_selector(HashAlgorithm.identity, 32w49152, 32w8) wcmp_group_selector_0; + @p4runtime_role("sdn_controller") @id(0x02000043) @oneshot @name("wcmp_group_table") table wcmp_group_table_0 { + key = { + local_metadata.wcmp_group_id_value: exact @id(1) @name("wcmp_group_id"); + local_metadata.wcmp_selector_input: selector @name("local_metadata.wcmp_selector_input"); + } + actions = { + @proto_id(1) set_nexthop_id(local_metadata); + @defaultonly NoAction(); + } + const default_action = NoAction(); + implementation = wcmp_group_selector_0; + size = 3968; } apply { - mark_to_drop(standard_metadata); - vrf_table.apply(); if (local_metadata.admit_to_l3) { - if (headers.ipv4.isValid()) { - ipv4_table.apply(); - } else if (headers.ipv6.isValid()) { - ipv6_table.apply(); - } - if (wcmp_group_id_valid) { - wcmp_group_table.apply(); + if (local_metadata.wcmp_group_id_valid) { + wcmp_group_table_0.apply(); } - if (nexthop_id_valid) { - nexthop_table.apply(); - if (router_interface_id_valid && neighbor_id_valid) { - router_interface_table.apply(); - neighbor_table.apply(); + if (local_metadata.nexthop_id_valid) { + nexthop_table_0.apply(); + if (tunnel_id_valid_0) { + tunnel_table_0.apply(); + } + if (router_interface_id_valid_0 && neighbor_id_valid_0) { + router_interface_table_0.apply(); + neighbor_table_0.apply(); } } } + local_metadata.packet_in_target_egress_port = standard_metadata.egress_spec; + local_metadata.packet_in_ingress_port = standard_metadata.ingress_port; + if (local_metadata.acl_drop) { + mark_to_drop(standard_metadata); + } } } @@ -438,197 +689,515 @@ control verify_ipv4_checksum(inout headers_t headers, inout local_metadata_t loc control compute_ipv4_checksum(inout headers_t headers, inout local_metadata_t local_metadata) { apply { - update_checksum, bit<4>, bit<6>, bit<2>, bit<16>, bit<16>, bit<1>, bit<1>, bit<1>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>, bit<16>>(headers.erspan_ipv4.isValid(), { headers.erspan_ipv4.version, headers.erspan_ipv4.ihl, headers.erspan_ipv4.dscp, headers.erspan_ipv4.ecn, headers.erspan_ipv4.total_len, headers.erspan_ipv4.identification, headers.erspan_ipv4.reserved, headers.erspan_ipv4.do_not_fragment, headers.erspan_ipv4.more_fragments, headers.erspan_ipv4.frag_offset, headers.erspan_ipv4.ttl, headers.erspan_ipv4.protocol, headers.erspan_ipv4.src_addr, headers.erspan_ipv4.dst_addr }, headers.erspan_ipv4.header_checksum, HashAlgorithm.csum16); update_checksum, bit<4>, bit<6>, bit<2>, bit<16>, bit<16>, bit<1>, bit<1>, bit<1>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>, bit<16>>(headers.ipv4.isValid(), { headers.ipv4.version, headers.ipv4.ihl, headers.ipv4.dscp, headers.ipv4.ecn, headers.ipv4.total_len, headers.ipv4.identification, headers.ipv4.reserved, headers.ipv4.do_not_fragment, headers.ipv4.more_fragments, headers.ipv4.frag_offset, headers.ipv4.ttl, headers.ipv4.protocol, headers.ipv4.src_addr, headers.ipv4.dst_addr }, headers.ipv4.header_checksum, HashAlgorithm.csum16); } } -control mirroring_encap(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { - apply { - if (standard_metadata.instance_type == 32w1) { - headers.erspan_ethernet.setValid(); - headers.erspan_ethernet.src_addr = local_metadata.mirroring_src_mac; - headers.erspan_ethernet.dst_addr = local_metadata.mirroring_dst_mac; - headers.erspan_ethernet.ether_type = 16w0x800; - headers.erspan_ipv4.setValid(); - headers.erspan_ipv4.src_addr = local_metadata.mirroring_src_ip; - headers.erspan_ipv4.dst_addr = local_metadata.mirroring_dst_ip; - headers.erspan_ipv4.version = 4w4; - headers.erspan_ipv4.ihl = 4w5; - headers.erspan_ipv4.protocol = 8w0x2f; - headers.erspan_ipv4.ttl = local_metadata.mirroring_ttl; - headers.erspan_ipv4.dscp = local_metadata.mirroring_tos[7:2]; - headers.erspan_ipv4.ecn = local_metadata.mirroring_tos[1:0]; - headers.erspan_ipv4.total_len = 16w24 + (bit<16>)standard_metadata.packet_length; - headers.erspan_ipv4.identification = 16w0; - headers.erspan_ipv4.reserved = 1w0; - headers.erspan_ipv4.do_not_fragment = 1w1; - headers.erspan_ipv4.more_fragments = 1w0; - headers.erspan_ipv4.frag_offset = 13w0; - headers.erspan_ipv4.header_checksum = 16w0; - headers.erspan_gre.setValid(); - headers.erspan_gre.checksum_present = 1w0; - headers.erspan_gre.routing_present = 1w0; - headers.erspan_gre.key_present = 1w0; - headers.erspan_gre.sequence_present = 1w0; - headers.erspan_gre.strict_source_route = 1w0; - headers.erspan_gre.recursion_control = 3w0; - headers.erspan_gre.acknowledgement_present = 1w0; - headers.erspan_gre.flags = 4w0; - headers.erspan_gre.version = 3w0; - headers.erspan_gre.protocol = 16w0x88be; - } - } -} - -control mirroring_clone(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { - port_id_t mirror_port; - bit<32> pre_session; - @id(0x01000007) action mirror_as_ipv4_erspan(@id(1) port_id_t port, @id(2) @format(IPV4_ADDRESS) ipv4_addr_t src_ip, @id(3) @format(IPV4_ADDRESS) ipv4_addr_t dst_ip, @id(4) @format(MAC_ADDRESS) ethernet_addr_t src_mac, @id(5) @format(MAC_ADDRESS) ethernet_addr_t dst_mac, @id(6) bit<8> ttl, @id(7) bit<8> tos) { - mirror_port = port; - local_metadata.mirroring_src_ip = src_ip; - local_metadata.mirroring_dst_ip = dst_ip; - local_metadata.mirroring_src_mac = src_mac; - local_metadata.mirroring_dst_mac = dst_mac; - local_metadata.mirroring_ttl = ttl; - local_metadata.mirroring_tos = tos; - } - @p4runtime_role("sdn_controller") @id(0x02000046) table mirror_session_table { +control ingress_cloning(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { + @id(0x0100001C) @name("ingress_clone") action ingress_clone_0(@id(1) bit<32> clone_session) { + clone_preserving_field_list(CloneType.I2E, clone_session, PreservedFieldList.MIRROR_AND_PACKET_IN_COPY); + } + @unsupported @p4runtime_role("packet_replication_engine_manager") @id(0x02000051) @entry_restriction(" + // mirror_egress_port is present iff marked_to_mirror is true. + // Exact match indicating presence of mirror_egress_port. + marked_to_mirror == 1 -> mirror_egress_port::mask == -1; + // Wildcard match indicating abscence of mirror_egress_port. + marked_to_mirror == 0 -> mirror_egress_port::mask == 0; + ") @name("ingress_clone_table") table ingress_clone_table_0 { key = { - local_metadata.mirror_session_id_value: exact @id(1) @name("mirror_session_id"); + local_metadata.marked_to_copy : exact @id(1) @name("marked_to_copy"); + local_metadata.marked_to_mirror : exact @id(2) @name("marked_to_mirror"); + local_metadata.mirror_egress_port: optional @id(3) @name("mirror_egress_port"); } actions = { - @proto_id(1) mirror_as_ipv4_erspan(); + @proto_id(1) ingress_clone_0(); @defaultonly NoAction(); } - const default_action = NoAction(); - size = 2; + default_action = NoAction(); + } + apply { + ingress_clone_table_0.apply(); + } +} + +control mirror_session_lookup(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { + @id(0x01000007) @name("mirror_as_ipv4_erspan") action mirror_as_ipv4_erspan_0(@id(1) port_id_t port, @id(2) @format(IPV4_ADDRESS) ipv4_addr_t src_ip, @id(3) @format(IPV4_ADDRESS) ipv4_addr_t dst_ip, @id(4) @format(MAC_ADDRESS) ethernet_addr_t src_mac, @id(5) @format(MAC_ADDRESS) ethernet_addr_t dst_mac, @id(6) bit<8> ttl, @id(7) bit<8> tos) { } - @id(0x01000009) action set_pre_session(bit<32> id) { - pre_session = id; + @id(0x0100001D) @unsupported @name("mirror_with_vlan_tag_and_ipfix_encapsulation") action mirror_with_vlan_tag_and_ipfix_encapsulation_0(@id(1) port_id_t monitor_port, @id(2) port_id_t monitor_failover_port, @id(3) @format(MAC_ADDRESS) ethernet_addr_t mirror_encap_src_mac, @id(4) @format(MAC_ADDRESS) ethernet_addr_t mirror_encap_dst_mac, @id(6) vlan_id_t mirror_encap_vlan_id, @id(7) @format(IPV6_ADDRESS) ipv6_addr_t mirror_encap_dst_ip, @id(8) @format(IPV6_ADDRESS) ipv6_addr_t mirror_encap_src_ip, @id(9) bit<16> mirror_encap_udp_src_port, @id(10) bit<16> mirror_encap_udp_dst_port) { + local_metadata.mirror_egress_port = monitor_port; + local_metadata.mirror_encap_src_mac = mirror_encap_src_mac; + local_metadata.mirror_encap_dst_mac = mirror_encap_dst_mac; + local_metadata.mirror_encap_vlan_id = mirror_encap_vlan_id; + local_metadata.mirror_encap_src_ip = mirror_encap_src_ip; + local_metadata.mirror_encap_dst_ip = mirror_encap_dst_ip; + local_metadata.mirror_encap_udp_src_port = mirror_encap_udp_src_port; + local_metadata.mirror_encap_udp_dst_port = mirror_encap_udp_dst_port; } - @p4runtime_role("packet_replication_engine_manager") @id(0x02000048) table mirror_port_to_pre_session_table { + @p4runtime_role("sdn_controller") @id(0x02000046) @name("mirror_session_table") table mirror_session_table_0 { key = { - mirror_port: exact @id(1) @name("mirror_port"); + local_metadata.mirror_session_id: exact @id(1) @name("mirror_session_id"); } actions = { - @proto_id(1) set_pre_session(); + @proto_id(1) mirror_as_ipv4_erspan_0(); + @proto_id(2) mirror_with_vlan_tag_and_ipfix_encapsulation_0(); @defaultonly NoAction(); } const default_action = NoAction(); + size = 4; } apply { - if (local_metadata.mirror_session_id_valid) { - if (mirror_session_table.apply().hit) { - if (mirror_port_to_pre_session_table.apply().hit) { - clone_preserving_field_list(CloneType.I2E, pre_session, 8w1); - } - } + if (local_metadata.marked_to_mirror) { + mirror_session_table_0.apply(); + } + } +} + +control mirroring_encap(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { + apply { + if (standard_metadata.instance_type == 32w1 && standard_metadata.egress_rid == 16w2) { + headers.mirror_encap_ethernet.setValid(); + headers.mirror_encap_ethernet.src_addr = local_metadata.mirror_encap_src_mac; + headers.mirror_encap_ethernet.dst_addr = local_metadata.mirror_encap_dst_mac; + headers.mirror_encap_ethernet.ether_type = 16w0x8100; + headers.mirror_encap_vlan.setValid(); + headers.mirror_encap_vlan.ether_type = 16w0x86dd; + headers.mirror_encap_vlan.vlan_id = local_metadata.mirror_encap_vlan_id; + headers.mirror_encap_ipv6.setValid(); + headers.mirror_encap_ipv6.version = 4w6; + headers.mirror_encap_ipv6.dscp = 6w0; + headers.mirror_encap_ipv6.ecn = 2w0; + headers.mirror_encap_ipv6.hop_limit = 8w16; + headers.mirror_encap_ipv6.flow_label = 20w0; + headers.mirror_encap_ipv6.payload_length = (bit<16>)standard_metadata.packet_length + 16w52; + headers.mirror_encap_ipv6.next_header = 8w0x11; + headers.mirror_encap_ipv6.src_addr = local_metadata.mirror_encap_src_ip; + headers.mirror_encap_ipv6.dst_addr = local_metadata.mirror_encap_dst_ip; + headers.mirror_encap_udp.setValid(); + headers.mirror_encap_udp.src_port = local_metadata.mirror_encap_udp_src_port; + headers.mirror_encap_udp.dst_port = local_metadata.mirror_encap_udp_dst_port; + headers.mirror_encap_udp.hdr_length = headers.mirror_encap_ipv6.payload_length; + headers.mirror_encap_udp.checksum = 16w0; + headers.ipfix.setValid(); + headers.psamp_extended.setValid(); } } } control l3_admit(in headers_t headers, inout local_metadata_t local_metadata, in standard_metadata_t standard_metadata) { - @id(0x01000008) action admit_to_l3() { + @id(0x01000008) @name("admit_to_l3") action admit_to_l3_0() { local_metadata.admit_to_l3 = true; } - @p4runtime_role("sdn_controller") @id(0x02000047) table l3_admit_table { + @p4runtime_role("sdn_controller") @id(0x02000047) @name("l3_admit_table") table l3_admit_table_0 { key = { headers.ethernet.dst_addr : ternary @name("dst_mac") @id(1) @format(MAC_ADDRESS); local_metadata.ingress_port: optional @name("in_port") @id(2); } actions = { - @proto_id(1) admit_to_l3(); + @proto_id(1) admit_to_l3_0(); @defaultonly NoAction(); } const default_action = NoAction(); - size = 128; + size = 64; } apply { - l3_admit_table.apply(); + if (local_metadata.enable_vlan_checks && !(local_metadata.vlan_id == 12w0x0 || local_metadata.vlan_id == 12w0xfff)) { + local_metadata.admit_to_l3 = false; + } else { + l3_admit_table_0.apply(); + } } } -control ttl(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { +control gre_tunnel_encap(inout headers_t headers, in local_metadata_t local_metadata, in standard_metadata_t standard_metadata) { apply { - if (local_metadata.admit_to_l3) { + if (local_metadata.apply_tunnel_encap_at_egress) { + headers.tunnel_encap_gre.setValid(); + headers.tunnel_encap_gre.checksum_present = 1w0; + headers.tunnel_encap_gre.routing_present = 1w0; + headers.tunnel_encap_gre.key_present = 1w0; + headers.tunnel_encap_gre.sequence_present = 1w0; + headers.tunnel_encap_gre.strict_source_route = 1w0; + headers.tunnel_encap_gre.recursion_control = 3w0; + headers.tunnel_encap_gre.flags = 4w0; + headers.tunnel_encap_gre.version = 3w0; + headers.tunnel_encap_gre.protocol = headers.ethernet.ether_type; + headers.ethernet.ether_type = 16w0x86dd; + headers.tunnel_encap_ipv6.setValid(); + headers.tunnel_encap_ipv6.version = 4w6; + headers.tunnel_encap_ipv6.src_addr = local_metadata.tunnel_encap_src_ipv6; + headers.tunnel_encap_ipv6.dst_addr = local_metadata.tunnel_encap_dst_ipv6; + headers.tunnel_encap_ipv6.payload_length = (bit<16>)standard_metadata.packet_length + 16w65526; + headers.tunnel_encap_ipv6.next_header = 8w0x2f; if (headers.ipv4.isValid()) { - if (headers.ipv4.ttl <= 8w1) { - mark_to_drop(standard_metadata); - } else { - headers.ipv4.ttl = headers.ipv4.ttl + 8w255; - } + headers.tunnel_encap_ipv6.dscp = headers.ipv4.dscp; + headers.tunnel_encap_ipv6.ecn = headers.ipv4.ecn; + headers.tunnel_encap_ipv6.hop_limit = headers.ipv4.ttl; + } else if (headers.ipv6.isValid()) { + headers.tunnel_encap_ipv6.dscp = headers.ipv6.dscp; + headers.tunnel_encap_ipv6.ecn = headers.ipv6.ecn; + headers.tunnel_encap_ipv6.hop_limit = headers.ipv6.hop_limit; } - if (headers.ipv6.isValid()) { - if (headers.ipv6.hop_limit <= 8w1) { - mark_to_drop(standard_metadata); - } else { - headers.ipv6.hop_limit = headers.ipv6.hop_limit + 8w255; - } + } + } +} + +control vlan_untag(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { + @id(0x0100001A) @name("disable_vlan_checks") action disable_vlan_checks_0() { + local_metadata.enable_vlan_checks = false; + } + @p4runtime_role("sdn_controller") @id(0x0200004D) @entry_restriction(" + // Force the dummy_match to be wildcard. + dummy_match::mask == 0; + ") @name("disable_vlan_checks_table") table disable_vlan_checks_table_0 { + key = { + 1w1: ternary @id(1) @name("dummy_match"); + } + actions = { + @proto_id(1) disable_vlan_checks_0(); + @defaultonly NoAction(); + } + size = 1; + default_action = NoAction(); + } + apply { + if (headers.vlan.isValid()) { + local_metadata.vlan_id = headers.vlan.vlan_id; + headers.ethernet.ether_type = headers.vlan.ether_type; + headers.vlan.setInvalid(); + } else { + local_metadata.vlan_id = 12w0xfff; + } + local_metadata.enable_vlan_checks = true; + disable_vlan_checks_table_0.apply(); + } +} + +control ingress_vlan_checks(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { + apply { + if (local_metadata.enable_vlan_checks && !(local_metadata.vlan_id == 12w0x0 || local_metadata.vlan_id == 12w0xfff)) { + mark_to_drop(standard_metadata); + } + } +} + +control egress_vlan_checks(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { + apply { + if (local_metadata.enable_vlan_checks) { + if (standard_metadata.instance_type == 32w1 && standard_metadata.egress_rid == 16w2 && !(local_metadata.mirror_encap_vlan_id == 12w0x0 || local_metadata.mirror_encap_vlan_id == 12w0xfff)) { + mark_to_drop(standard_metadata); + } else if (!(standard_metadata.instance_type == 32w1 && standard_metadata.egress_rid == 16w1) && !(local_metadata.vlan_id == 12w0x0 || local_metadata.vlan_id == 12w0xfff)) { + mark_to_drop(standard_metadata); } } } } -control packet_rewrites(inout headers_t headers, in local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { +control vlan_tag(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { apply { - if (local_metadata.admit_to_l3) { + if (!(local_metadata.vlan_id == 12w0x0 || local_metadata.vlan_id == 12w0xfff) && !(standard_metadata.instance_type == 32w1 && standard_metadata.egress_rid == 16w2)) { + headers.vlan.setValid(); + headers.vlan.priority_code_point = 3w0; + headers.vlan.drop_eligible_indicator = 1w0; + headers.vlan.vlan_id = local_metadata.vlan_id; + headers.vlan.ether_type = headers.ethernet.ether_type; + headers.ethernet.ether_type = 16w0x8100; + } + } +} + +const ipv6_addr_t IPV6_MULTICAST_MASK_0 = 128w0xff000000000000000000000000000000; +const ipv6_addr_t IPV6_MULTICAST_VALUE_0 = 128w0xff000000000000000000000000000000; +const ipv6_addr_t IPV6_LOOPBACK_MASK_0 = 128w0xffffffffffffffffffffffffffffffff; +const ipv6_addr_t IPV6_LOOPBACK_VALUE_0 = 128w0x1; +const ipv4_addr_t IPV4_MULTICAST_MASK_0 = 32w0xf0000000; +const ipv4_addr_t IPV4_MULTICAST_VALUE_0 = 32w0xe0000000; +const ipv4_addr_t IPV4_BROADCAST_VALUE_0 = 32w0xffffffff; +const ipv4_addr_t IPV4_LOOPBACK_MASK_0 = 32w0xff000000; +const ipv4_addr_t IPV4_LOOPBACK_VALUE_0 = 32w0x7f000000; +const ethernet_addr_t MAC_MULTICAST_MASK_0 = 48w0x10000000000; +const ethernet_addr_t MAC_MULTICAST_VALUE_0 = 48w0x10000000000; +control drop_martians(in headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { + apply { + if (headers.ipv6.isValid() && (headers.ipv6.src_addr & 128w0xff000000000000000000000000000000 == 128w0xff000000000000000000000000000000 || headers.ipv6.dst_addr & 128w0xff000000000000000000000000000000 == 128w0xff000000000000000000000000000000 || headers.ipv6.src_addr == 128w0x1 || headers.ipv6.dst_addr == 128w0x1) || headers.ipv4.isValid() && (headers.ipv4.src_addr & 32w0xf0000000 == 32w0xe0000000 || headers.ipv4.src_addr == 32w0xffffffff || (headers.ipv4.dst_addr & 32w0xf0000000 == 32w0xe0000000 || headers.ipv4.dst_addr == 32w0xffffffff) || headers.ipv4.src_addr & 32w0xff000000 == 32w0x7f000000 || headers.ipv4.dst_addr & 32w0xff000000 == 32w0x7f000000) || headers.ethernet.isValid() && headers.ethernet.dst_addr & 48w0x10000000000 == 48w0x10000000000) { + mark_to_drop(standard_metadata); + } + } +} + +control multicast_rewrites(inout local_metadata_t local_metadata, in standard_metadata_t standard_metadata) { + @name("multicast_replica_port") port_id_t multicast_replica_port_0 = (port_id_t)standard_metadata.egress_port; + @name("multicast_replica_instance") replica_instance_t multicast_replica_instance_0 = standard_metadata.egress_rid; + @id(0x01000019) @name("set_multicast_src_mac") action set_multicast_src_mac_0(@id(1) @format(MAC_ADDRESS) ethernet_addr_t src_mac) { + local_metadata.enable_src_mac_rewrite = true; + local_metadata.packet_rewrites.src_mac = src_mac; + } + @p4runtime_role("sdn_controller") @id(0x0200004C) @name("multicast_router_interface_table") table multicast_router_interface_table_0 { + key = { + multicast_replica_port_0 : exact @referenced_by(builtin : : multicast_group_table , replica . port) @id(1) @name("multicast_replica_port"); + multicast_replica_instance_0: exact @referenced_by(builtin : : multicast_group_table , replica . instance) @id(2) @name("multicast_replica_instance"); + } + actions = { + @proto_id(1) set_multicast_src_mac_0(); + @defaultonly NoAction(); + } + size = 110; + default_action = NoAction(); + } + apply { + multicast_router_interface_table_0.apply(); + } +} + +control packet_rewrites(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { + @name("multicast_rewrites") multicast_rewrites() multicast_rewrites_inst_0; + apply { + if (standard_metadata.instance_type == 32w5) { + local_metadata.enable_decrement_ttl = true; + multicast_rewrites_inst_0.apply(local_metadata, standard_metadata); + } + if (local_metadata.enable_src_mac_rewrite) { headers.ethernet.src_addr = local_metadata.packet_rewrites.src_mac; + } + if (local_metadata.enable_dst_mac_rewrite) { headers.ethernet.dst_addr = local_metadata.packet_rewrites.dst_mac; } + if (local_metadata.enable_vlan_rewrite) { + local_metadata.vlan_id = local_metadata.packet_rewrites.vlan_id; + } + if (headers.ipv4.isValid()) { + if (headers.ipv4.ttl > 8w0 && local_metadata.enable_decrement_ttl) { + headers.ipv4.ttl = headers.ipv4.ttl + 8w255; + } + if (headers.ipv4.ttl == 8w0) { + mark_to_drop(standard_metadata); + } + } + if (headers.ipv6.isValid()) { + if (headers.ipv6.hop_limit > 8w0 && local_metadata.enable_decrement_ttl) { + headers.ipv6.hop_limit = headers.ipv6.hop_limit + 8w255; + } + if (headers.ipv6.hop_limit == 8w0) { + mark_to_drop(standard_metadata); + } + } } } -@id(0x01000109) @sai_action(SAI_PACKET_ACTION_DROP) action acl_drop(inout standard_metadata_t standard_metadata) { - mark_to_drop(standard_metadata); +control tunnel_termination_lookup(in headers_t headers, inout local_metadata_t local_metadata) { + @id(0x01000016) @name("mark_for_tunnel_decap_and_set_vrf") action mark_for_tunnel_decap_and_set_vrf_0(@refers_to(vrf_table , vrf_id) vrf_id_t vrf_id) { + local_metadata.apply_tunnel_decap_at_end_of_pre_ingress = true; + local_metadata.vrf_id = vrf_id; + } + @unsupported @p4runtime_role("sdn_controller") @id(0x0200004B) @name("ipv6_tunnel_termination_table") table ipv6_tunnel_termination_table_0 { + key = { + headers.ipv6.dst_addr: ternary @id(1) @name("dst_ipv6") @format(IPV6_ADDRESS); + headers.ipv6.src_addr: ternary @id(2) @name("src_ipv6") @format(IPV6_ADDRESS); + } + actions = { + @proto_id(1) mark_for_tunnel_decap_and_set_vrf_0(); + @defaultonly NoAction(); + } + size = 126; + default_action = NoAction(); + } + apply { + if (headers.ipv6.isValid()) { + if (headers.ipv6.next_header == 8w0x4 || headers.ipv6.next_header == 8w0x29) { + ipv6_tunnel_termination_table_0.apply(); + } + } + } } + +control tunnel_termination_decap(inout headers_t headers, in local_metadata_t local_metadata) { + apply { + if (local_metadata.apply_tunnel_decap_at_end_of_pre_ingress) { + assert(headers.ipv6.isValid()); + assert(headers.inner_ipv4.isValid() && !headers.inner_ipv6.isValid() || !headers.inner_ipv4.isValid() && headers.inner_ipv6.isValid()); + headers.ipv6.setInvalid(); + if (headers.inner_ipv4.isValid()) { + headers.ethernet.ether_type = 16w0x800; + headers.ipv4 = headers.inner_ipv4; + headers.inner_ipv4.setInvalid(); + } + if (headers.inner_ipv6.isValid()) { + headers.ethernet.ether_type = 16w0x86dd; + headers.ipv6 = headers.inner_ipv6; + headers.inner_ipv6.setInvalid(); + } + } + } +} + +@id(0x01000109) @sai_action(SAI_PACKET_ACTION_DROP) action acl_drop(inout local_metadata_t local_metadata) { + local_metadata.acl_drop = true; +} +control acl_egress(in headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { + @name("dscp") bit<6> dscp_0 = 6w0; + @name("ip_protocol") bit<8> ip_protocol_0 = 8w0; + @id(0x13000104) @name("acl_egress_counter") direct_counter(CounterType.packets_and_bytes) acl_egress_counter_0; + @id(0x13000108) @name("acl_egress_dhcp_to_host_counter") direct_counter(CounterType.packets_and_bytes) acl_egress_dhcp_to_host_counter_0; + @id(0x0100010D) @sai_action(SAI_PACKET_ACTION_FORWARD) @name("acl_egress_forward") action acl_egress_forward_0() { + acl_egress_counter_0.count(); + } + @p4runtime_role("sdn_controller") @id(0x02000104) @sai_acl(EGRESS) @entry_restriction(" + + + + + + // Only allow IP field matches for IP packets. + ip_protocol::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + + + + + + + + // Forbid illegal combinations of IP_TYPE fields. + is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0); + is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0); + is_ipv6::mask != 0 -> (is_ip::mask == 0 && is_ipv4::mask == 0); + // Forbid unsupported combinations of IP_TYPE fields. + is_ipv4::mask != 0 -> (is_ipv4 == 1); + is_ipv6::mask != 0 -> (is_ipv6 == 1); + ") @name("acl_egress_table") table acl_egress_table_0 { + key = { + ip_protocol_0 : ternary @id(2) @name("ip_protocol") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IP_PROTOCOL); + (port_id_t)standard_metadata.egress_port : optional @id(4) @name("out_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_OUT_PORT); + headers.ipv4.isValid() || headers.ipv6.isValid(): optional @id(5) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(6) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(7) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + headers.ethernet.src_addr : ternary @id(10) @name("src_mac") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_SRC_MAC) @format(MAC_ADDRESS); + } + actions = { + @proto_id(1) acl_drop(local_metadata); + @defaultonly NoAction(); + } + const default_action = NoAction(); + counters = acl_egress_counter_0; + size = 127; + } + @id(0x02000108) @sai_acl(EGRESS) @p4runtime_role("sdn_controller") @entry_restriction(" + // Only allow IP field matches for IP packets. + ip_protocol::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + // Only allow l4_dst_port matches for TCP/UDP packets. + l4_dst_port::mask != 0 -> (ip_protocol == 6 || ip_protocol == 17); + // Forbid illegal combinations of IP_TYPE fields. + is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0); + is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0); + is_ipv6::mask != 0 -> (is_ip::mask == 0 && is_ipv4::mask == 0); + // Forbid unsupported combinations of IP_TYPE fields. + is_ipv4::mask != 0 -> (is_ipv4 == 1); + is_ipv6::mask != 0 -> (is_ipv6 == 1); + ") @name("acl_egress_dhcp_to_host_table") table acl_egress_dhcp_to_host_table_0 { + key = { + headers.ipv4.isValid() || headers.ipv6.isValid(): optional @id(1) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(2) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(3) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + ip_protocol_0 : ternary @id(5) @name("ip_protocol") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IP_PROTOCOL); + local_metadata.l4_dst_port : ternary @id(6) @name("l4_dst_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_L4_DST_PORT); + (port_id_t)standard_metadata.egress_port : optional @id(7) @name("out_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_OUT_PORT); + } + actions = { + @proto_id(1) acl_drop(local_metadata); + @defaultonly NoAction(); + } + const default_action = NoAction(); + counters = acl_egress_dhcp_to_host_counter_0; + size = 127; + } + apply { + if (headers.ipv4.isValid()) { + dscp_0 = headers.ipv4.dscp; + ip_protocol_0 = headers.ipv4.protocol; + } else if (headers.ipv6.isValid()) { + dscp_0 = headers.ipv6.dscp; + ip_protocol_0 = headers.ipv6.next_header; + } else { + ip_protocol_0 = 8w0; + } + acl_egress_table_0.apply(); + if (local_metadata.acl_drop) { + mark_to_drop(standard_metadata); + } + } +} + control acl_ingress(in headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { - bit<8> ttl = 8w0; - bit<6> dscp = 6w0; - bit<2> ecn = 2w0; - bit<8> ip_protocol = 8w0; - @id(0x15000100) direct_meter(MeterType.bytes) acl_ingress_meter; - @id(0x13000102) direct_counter(CounterType.packets_and_bytes) acl_ingress_counter; - @id(0x01000101) @sai_action(SAI_PACKET_ACTION_COPY , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_YELLOW) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_RED) action acl_copy(@sai_action_param(QOS_QUEUE) @id(1) qos_queue_t qos_queue) { - acl_ingress_counter.count(); - acl_ingress_meter.read(local_metadata.color); - clone(CloneType.I2E, 32w1024); - } - @id(0x01000102) @sai_action(SAI_PACKET_ACTION_TRAP , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_YELLOW) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED) action acl_trap(@sai_action_param(QOS_QUEUE) @id(1) qos_queue_t qos_queue) { - acl_copy(qos_queue); - mark_to_drop(standard_metadata); + @name("ttl") bit<8> ttl_0 = 8w0; + @name("dscp") bit<6> dscp_1 = 6w0; + @name("ecn") bit<2> ecn_0 = 2w0; + @name("ip_protocol") bit<8> ip_protocol_1 = 8w0; + @name("cancel_copy") bool cancel_copy_0 = false; + @id(0x15000100) @mode(single_rate_two_color) @name("acl_ingress_meter") direct_meter(MeterType.bytes) acl_ingress_meter_0; + @id(0x15000102) @mode(single_rate_two_color) @name("acl_ingress_qos_meter") direct_meter(MeterType.bytes) acl_ingress_qos_meter_0; + @id(0x13000102) @name("acl_ingress_counter") direct_counter(CounterType.packets_and_bytes) acl_ingress_counter_0; + @id(0x13000107) @name("acl_ingress_qos_counter") direct_counter(CounterType.packets_and_bytes) acl_ingress_qos_counter_0; + @id(0x13000109) @name("acl_ingress_counting_counter") direct_counter(CounterType.packets_and_bytes) acl_ingress_counting_counter_0; + @id(0x1300010A) @name("acl_ingress_security_counter") direct_counter(CounterType.packets_and_bytes) acl_ingress_security_counter_0; + @id(0x01000101) @sai_action(SAI_PACKET_ACTION_COPY , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_RED) @name("acl_copy") action acl_copy_0(@sai_action_param(QOS_QUEUE) @id(1) qos_queue_t qos_queue) { + acl_ingress_counter_0.count(); + acl_ingress_meter_0.read(local_metadata.color); + local_metadata.marked_to_copy = true; + } + @id(0x01000102) @sai_action(SAI_PACKET_ACTION_TRAP , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED) @name("acl_trap") action acl_trap_0(@sai_action_param(QOS_QUEUE) @id(1) qos_queue_t qos_queue) { + acl_copy_0(qos_queue); + local_metadata.acl_drop = true; } - @id(0x01000199) @sai_action(SAI_PACKET_ACTION_TRAP , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_YELLOW) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED) action acl_experimental_trap(@sai_action_param(QOS_QUEUE) @id(1) qos_queue_t qos_queue) { - acl_ingress_meter.read(local_metadata.color); - acl_trap(qos_queue); + @id(0x01000103) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED) @name("acl_forward") action acl_forward_0() { + acl_ingress_meter_0.read(local_metadata.color); } - @id(0x01000103) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_YELLOW) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED) action acl_forward() { - acl_ingress_counter.count(); - acl_ingress_meter.read(local_metadata.color); + @id(0x01000105) @sai_action(SAI_PACKET_ACTION_FORWARD) @name("acl_count") action acl_count_0() { + acl_ingress_counting_counter_0.count(); } - @id(0x01000104) @sai_action(SAI_PACKET_ACTION_FORWARD) action acl_mirror(@id(1) @refers_to(mirror_session_table , mirror_session_id) @sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_MIRROR_INGRESS) mirror_session_id_t mirror_session_id) { - acl_ingress_counter.count(); - local_metadata.mirror_session_id_valid = true; - local_metadata.mirror_session_id_value = mirror_session_id; + @id(0x01000104) @sai_action(SAI_PACKET_ACTION_FORWARD) @name("acl_mirror") action acl_mirror_0(@id(1) @refers_to(mirror_session_table , mirror_session_id) @sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_MIRROR_INGRESS) mirror_session_id_t mirror_session_id) { + acl_ingress_counter_0.count(); + local_metadata.marked_to_mirror = true; + local_metadata.mirror_session_id = mirror_session_id; } - @p4runtime_role("sdn_controller") @id(0x02000100) @sai_acl(INGRESS) @entry_restriction(" + @id(0x0100010C) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_COPY_CANCEL , SAI_PACKET_COLOR_RED) @name("set_qos_queue_and_cancel_copy_above_rate_limit") action set_qos_queue_and_cancel_copy_above_rate_limit_0(@id(1) @sai_action_param(QOS_QUEUE) qos_queue_t qos_queue) { + acl_ingress_qos_meter_0.read(local_metadata.color); + } + @id(0x01000111) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DENY , SAI_PACKET_COLOR_RED) @unsupported @name("set_cpu_and_multicast_queues_and_deny_above_rate_limit") action set_cpu_and_multicast_queues_and_deny_above_rate_limit_0(@id(1) @sai_action_param(QOS_QUEUE) qos_queue_t cpu_queue, @id(2) @sai_action_param(MULTICAST_QOS_QUEUE , SAI_PACKET_COLOR_GREEN) qos_queue_t green_multicast_queue, @id(3) @sai_action_param(MULTICAST_QOS_QUEUE , SAI_PACKET_COLOR_RED) qos_queue_t red_multicast_queue) { + acl_ingress_qos_meter_0.read(local_metadata.color); + } + @id(0x0100010E) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DENY , SAI_PACKET_COLOR_RED) @name("set_cpu_queue_and_deny_above_rate_limit") action set_cpu_queue_and_deny_above_rate_limit_0(@id(1) @sai_action_param(QOS_QUEUE) qos_queue_t cpu_queue) { + acl_ingress_qos_meter_0.read(local_metadata.color); + } + @id(0x01000110) @sai_action(SAI_PACKET_ACTION_FORWARD) @name("set_cpu_queue") action set_cpu_queue_0(@id(1) @sai_action_param(QOS_QUEUE) qos_queue_t cpu_queue) { + } + @id(0x0100010F) @sai_action(SAI_PACKET_ACTION_DENY) @name("acl_deny") action acl_deny_0() { + cancel_copy_0 = true; + local_metadata.acl_drop = true; + } + @p4runtime_role("sdn_controller") @id(0x02000100) @sai_acl(INGRESS) @sai_acl_priority(5) @entry_restriction(" // Forbid using ether_type for IP packets (by convention, use is_ip* instead). ether_type != 0x0800 && ether_type != 0x86dd; // Only allow IP field matches for IP packets. dst_ip::mask != 0 -> is_ipv4 == 1; + + src_ip::mask != 0 -> is_ipv4 == 1; + dst_ipv6::mask != 0 -> is_ipv6 == 1; + src_ipv6::mask != 0 -> is_ipv6 == 1; ttl::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + dscp::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); ecn::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + ip_protocol::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); // Only allow l4_dst_port and l4_src_port matches for TCP/UDP packets. + l4_src_port::mask != 0 -> (ip_protocol == 6 || ip_protocol == 17); + l4_dst_port::mask != 0 -> (ip_protocol == 6 || ip_protocol == 17); // Only allow arp_tpa matches for ARP packets. arp_tpa::mask != 0 -> ether_type == 0x0806; - // Only allow icmp_type matches for ICMP packets + @@ -640,66 +1209,242 @@ control acl_ingress(in headers_t headers, inout local_metadata_t local_metadata, // Forbid unsupported combinations of IP_TYPE fields. is_ipv4::mask != 0 -> (is_ipv4 == 1); is_ipv6::mask != 0 -> (is_ipv6 == 1); - ") table acl_ingress_table { + ") @name("acl_ingress_table") table acl_ingress_table_0 { key = { - headers.ipv4.isValid() || headers.ipv6.isValid(): optional @name("is_ip") @id(1) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); - headers.ipv4.isValid() : optional @name("is_ipv4") @id(2) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); - headers.ipv6.isValid() : optional @name("is_ipv6") @id(3) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); - headers.ethernet.ether_type : ternary @name("ether_type") @id(4) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ETHER_TYPE); - headers.ethernet.dst_addr : ternary @name("dst_mac") @id(5) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_MAC) @format(MAC_ADDRESS); - headers.ipv4.src_addr : ternary @name("src_ip") @id(6) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_SRC_IP) @format(IPV4_ADDRESS); - headers.ipv4.dst_addr : ternary @name("dst_ip") @id(7) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_IP) @format(IPV4_ADDRESS); - headers.ipv6.src_addr[127:64] : ternary @name("src_ipv6") @id(8) @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_SRC_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_SRC_IPV6_WORD2 )) @format(IPV6_ADDRESS); - headers.ipv6.dst_addr[127:64] : ternary @name("dst_ipv6") @id(9) @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD2 )) @format(IPV6_ADDRESS); - ttl : ternary @name("ttl") @id(10) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_TTL); - dscp : ternary @name("dscp") @id(11) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DSCP); - ecn : ternary @name("ecn") @id(12) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ECN); - ip_protocol : ternary @name("ip_protocol") @id(13) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IP_PROTOCOL); - headers.icmp.type : ternary @name("icmpv6_type") @id(14) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ICMPV6_TYPE); - local_metadata.l4_src_port : ternary @name("l4_src_port") @id(20) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_L4_SRC_PORT); - local_metadata.l4_dst_port : ternary @name("l4_dst_port") @id(15) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_L4_DST_PORT); - headers.arp.target_proto_addr : ternary @name("arp_tpa") @id(16) @composite_field(@ sai_udf ( base = SAI_UDF_BASE_L3 , offset = 24 , length = 2 ) , @ sai_udf ( base = SAI_UDF_BASE_L3 , offset = 26 , length = 2 )) @format(IPV4_ADDRESS); + headers.ipv4.isValid() || headers.ipv6.isValid(): optional @id(1) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(2) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(3) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + headers.ethernet.ether_type : ternary @id(4) @name("ether_type") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ETHER_TYPE); + headers.ethernet.dst_addr : ternary @id(5) @name("dst_mac") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_MAC) @format(MAC_ADDRESS); + headers.ipv4.src_addr : ternary @id(6) @name("src_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_SRC_IP) @format(IPV4_ADDRESS); + headers.ipv4.dst_addr : ternary @id(7) @name("dst_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_IP) @format(IPV4_ADDRESS); + headers.ipv6.src_addr[127:64] : ternary @id(8) @name("src_ipv6") @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_SRC_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_SRC_IPV6_WORD2 )) @format(IPV6_ADDRESS); + headers.ipv6.dst_addr[127:64] : ternary @id(9) @name("dst_ipv6") @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD2 )) @format(IPV6_ADDRESS); + ttl_0 : ternary @id(10) @name("ttl") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_TTL); + dscp_1 : ternary @id(11) @name("dscp") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DSCP); + ecn_0 : ternary @id(12) @name("ecn") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ECN); + ip_protocol_1 : ternary @id(13) @name("ip_protocol") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IP_PROTOCOL); + headers.icmp.type : ternary @id(14) @name("icmpv6_type") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ICMPV6_TYPE); + local_metadata.l4_src_port : ternary @id(20) @name("l4_src_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_L4_SRC_PORT); + local_metadata.l4_dst_port : ternary @id(15) @name("l4_dst_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_L4_DST_PORT); + headers.arp.target_proto_addr : ternary @id(16) @name("arp_tpa") @composite_field(@ sai_udf ( base = SAI_UDF_BASE_L3 , offset = 24 , length = 2 ) , @ sai_udf ( base = SAI_UDF_BASE_L3 , offset = 26 , length = 2 )) @format(IPV4_ADDRESS); } actions = { - @proto_id(1) acl_copy(); - @proto_id(2) acl_trap(); - @proto_id(3) acl_forward(); - @proto_id(4) acl_mirror(); - @proto_id(5) acl_drop(standard_metadata); - @proto_id(99) acl_experimental_trap(); + @proto_id(1) acl_copy_0(); + @proto_id(2) acl_trap_0(); + @proto_id(3) acl_forward_0(); + @proto_id(4) acl_mirror_0(); + @proto_id(5) acl_drop(local_metadata); @defaultonly NoAction(); } const default_action = NoAction(); - meters = acl_ingress_meter; - counters = acl_ingress_counter; - size = 128; + meters = acl_ingress_meter_0; + counters = acl_ingress_counter_0; + size = 255; + } + @id(0x02000107) @sai_acl(INGRESS) @sai_acl_priority(10) @p4runtime_role("sdn_controller") @entry_restriction(" + // Forbid using ether_type for IP packets (by convention, use is_ip* instead). + ether_type != 0x0800 && ether_type != 0x86dd; + // Only allow IP field matches for IP packets. + ttl::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + ip_protocol::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + // Only allow l4_dst_port matches for TCP/UDP packets. + l4_dst_port::mask != 0 -> (ip_protocol == 6 || ip_protocol == 17); + // Forbid illegal combinations of IP_TYPE fields. + is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0); + is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0); + is_ipv6::mask != 0 -> (is_ip::mask == 0 && is_ipv4::mask == 0); + // Forbid unsupported combinations of IP_TYPE fields. + is_ipv4::mask != 0 -> (is_ipv4 == 1); + is_ipv6::mask != 0 -> (is_ipv6 == 1); + // Only allow icmp_type matches for ICMP packets + icmpv6_type::mask != 0 -> ip_protocol == 58; +# 369 " .. / .. / .. / .. / pins - infra / sai_p4 / instantiations / google / acl_ingress . p4 " + ") @name("acl_ingress_qos_table") table acl_ingress_qos_table_0 { + key = { + headers.ipv4.isValid() || headers.ipv6.isValid(): optional @id(1) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(2) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(3) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + headers.ethernet.ether_type : ternary @id(4) @name("ether_type") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ETHER_TYPE); + ttl_0 : ternary @id(7) @name("ttl") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_TTL); + ip_protocol_1 : ternary @id(8) @name("ip_protocol") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IP_PROTOCOL); + headers.icmp.type : ternary @id(9) @name("icmpv6_type") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ICMPV6_TYPE); + local_metadata.l4_dst_port : ternary @id(10) @name("l4_dst_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_L4_DST_PORT); + } + actions = { + @proto_id(1) set_qos_queue_and_cancel_copy_above_rate_limit_0(); + @proto_id(2) set_cpu_queue_and_deny_above_rate_limit_0(); + @proto_id(3) acl_forward_0(); + @proto_id(4) acl_drop(local_metadata); + @proto_id(5) set_cpu_queue_0(); + @proto_id(6) set_cpu_and_multicast_queues_and_deny_above_rate_limit_0(); + @defaultonly NoAction(); + } + const default_action = NoAction(); + meters = acl_ingress_qos_meter_0; + counters = acl_ingress_qos_counter_0; + size = 511; + } + @p4runtime_role("sdn_controller") @id(0x02000109) @sai_acl_priority(7) @sai_acl(INGRESS) @entry_restriction(" + // Only allow IP field matches for IP packets. + dscp::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + // Forbid illegal combinations of IP_TYPE fields. + is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0); + is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0); + is_ipv6::mask != 0 -> (is_ip::mask == 0 && is_ipv4::mask == 0); + // Forbid unsupported combinations of IP_TYPE fields. + is_ipv4::mask != 0 -> (is_ipv4 == 1); + is_ipv6::mask != 0 -> (is_ipv6 == 1); + ") @name("acl_ingress_counting_table") table acl_ingress_counting_table_0 { + key = { + headers.ipv4.isValid() || headers.ipv6.isValid(): optional @id(1) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(2) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(3) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + dscp_1 : ternary @id(11) @name("dscp") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DSCP); + local_metadata.route_metadata : ternary @id(18) @name("route_metadata") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ROUTE_DST_USER_META); + } + actions = { + @proto_id(3) acl_count_0(); + @defaultonly NoAction(); + } + const default_action = NoAction(); + counters = acl_ingress_counting_counter_0; + size = 255; + } + @id(0x01000112) @name("redirect_to_nexthop") action redirect_to_nexthop_0(@sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_REDIRECT) @sai_action_param_object_type(SAI_OBJECT_TYPE_NEXT_HOP) @refers_to(nexthop_table , nexthop_id) nexthop_id_t nexthop_id) { + local_metadata.nexthop_id_valid = true; + local_metadata.nexthop_id_value = nexthop_id; + local_metadata.wcmp_group_id_valid = false; + standard_metadata.mcast_grp = 16w0; + } + @id(0x01000113) @action_restriction(" + // Disallow 0 since it encodes 'no multicast' in V1Model. + multicast_group_id != 0; + ") @name("redirect_to_ipmc_group") action redirect_to_ipmc_group_0(@sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_REDIRECT) @sai_action_param_object_type(SAI_OBJECT_TYPE_IPMC_GROUP) @refers_to(builtin : : multicast_group_table , multicast_group_id) multicast_group_id_t multicast_group_id) { + standard_metadata.mcast_grp = multicast_group_id; + local_metadata.nexthop_id_valid = false; + local_metadata.wcmp_group_id_valid = false; + } + @id(0x0200010B) @sai_acl(INGRESS) @sai_acl_priority(15) @p4runtime_role("sdn_controller") @entry_restriction(" + // Only allow IP field matches for IP packets. + dst_ip::mask != 0 -> is_ipv4 == 1; + dst_ipv6::mask != 0 -> is_ipv6 == 1; + // Forbid illegal combinations of IP_TYPE fields. + is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0); + is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0); + is_ipv6::mask != 0 -> (is_ip::mask == 0 && is_ipv4::mask == 0); + // Forbid unsupported combinations of IP_TYPE fields. + is_ipv4::mask != 0 -> (is_ipv4 == 1); + is_ipv6::mask != 0 -> (is_ipv6 == 1); + ") @name("acl_ingress_mirror_and_redirect_table") table acl_ingress_mirror_and_redirect_table_0 { + key = { + headers.ipv4.isValid() || headers.ipv6.isValid(): optional @id(2) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(3) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(4) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + headers.ipv4.dst_addr : ternary @id(10) @name("dst_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_IP) @format(IPV4_ADDRESS); + headers.ipv6.dst_addr[127:64] : ternary @id(5) @name("dst_ipv6") @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD2 )) @format(IPV6_ADDRESS); + local_metadata.vrf_id : optional @id(8) @name("vrf_id") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_VRF_ID); + local_metadata.ipmc_table_hit : optional @id(9) @name("ipmc_table_hit") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IPMC_NPU_META_DST_HIT); + } + actions = { + @proto_id(4) acl_forward_0(); + @proto_id(1) acl_mirror_0(); + @proto_id(2) redirect_to_nexthop_0(); + @proto_id(3) redirect_to_ipmc_group_0(); + @defaultonly NoAction(); + } + const default_action = NoAction(); + size = 255; + } + @id(0x0200010A) @sai_acl(INGRESS) @sai_acl_priority(20) @p4runtime_role("sdn_controller") @entry_restriction(" + // Forbid using ether_type for IP packets (by convention, use is_ip* instead). + ether_type != 0x0800 && ether_type != 0x86dd; + + // Only allow IP field matches for IP packets. + dst_ip::mask != 0 -> is_ipv4 == 1; + src_ip::mask != 0 -> is_ipv4 == 1; + src_ipv6::mask != 0 -> is_ipv6 == 1; + + // TODO: This comment is required for the preprocessor to not + // spit out nonsense. + + + + + + + + // Forbid illegal combinations of IP_TYPE fields. + is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0); + is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0); + is_ipv6::mask != 0 -> (is_ip::mask == 0 && is_ipv4::mask == 0); + // Forbid unsupported combinations of IP_TYPE fields. + is_ipv4::mask != 0 -> (is_ipv4 == 1); + is_ipv6::mask != 0 -> (is_ipv6 == 1); + ") @name("acl_ingress_security_table") table acl_ingress_security_table_0 { + key = { + headers.ipv4.isValid() || headers.ipv6.isValid(): optional @id(1) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(2) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(3) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + headers.ethernet.ether_type : ternary @id(4) @name("ether_type") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ETHER_TYPE); + headers.ipv4.src_addr : ternary @id(5) @name("src_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_SRC_IP) @format(IPV4_ADDRESS); + headers.ipv4.dst_addr : ternary @id(6) @name("dst_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_IP) @format(IPV4_ADDRESS); + headers.ipv6.src_addr[127:64] : ternary @id(7) @name("src_ipv6") @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_SRC_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_SRC_IPV6_WORD2 )) @format(IPV6_ADDRESS); + } + actions = { + @proto_id(1) acl_forward_0(); + @proto_id(2) acl_drop(local_metadata); + @proto_id(3) acl_deny_0(); + @defaultonly NoAction(); + } + const default_action = NoAction(); + counters = acl_ingress_security_counter_0; + size = 255; } apply { if (headers.ipv4.isValid()) { - ttl = headers.ipv4.ttl; - dscp = headers.ipv4.dscp; - ecn = headers.ipv4.ecn; - ip_protocol = headers.ipv4.protocol; + ttl_0 = headers.ipv4.ttl; + dscp_1 = headers.ipv4.dscp; + ecn_0 = headers.ipv4.ecn; + ip_protocol_1 = headers.ipv4.protocol; } else if (headers.ipv6.isValid()) { - ttl = headers.ipv6.hop_limit; - dscp = headers.ipv6.dscp; - ecn = headers.ipv6.ecn; - ip_protocol = headers.ipv6.next_header; + ttl_0 = headers.ipv6.hop_limit; + dscp_1 = headers.ipv6.dscp; + ecn_0 = headers.ipv6.ecn; + ip_protocol_1 = headers.ipv6.next_header; + } + acl_ingress_table_0.apply(); + acl_ingress_mirror_and_redirect_table_0.apply(); + acl_ingress_security_table_0.apply(); + if (cancel_copy_0) { + local_metadata.marked_to_copy = false; } - acl_ingress_table.apply(); } } control acl_pre_ingress(in headers_t headers, inout local_metadata_t local_metadata, in standard_metadata_t standard_metadata) { - bit<6> dscp = 6w0; - @id(0x13000101) direct_counter(CounterType.packets_and_bytes) acl_pre_ingress_counter; - @id(0x01000100) @sai_action(SAI_PACKET_ACTION_FORWARD) action set_vrf(@sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_SET_VRF) @refers_to(vrf_table , vrf_id) @id(1) vrf_id_t vrf_id) { + @name("dscp") bit<6> dscp_2 = 6w0; + @name("ecn") bit<2> ecn_1 = 2w0; + @name("ip_protocol") bit<8> ip_protocol_2 = 8w0; + @id(0x13000101) @name("acl_pre_ingress_counter") direct_counter(CounterType.packets_and_bytes) acl_pre_ingress_counter_0; + @id(0x13000106) @name("acl_pre_ingress_vlan_counter") direct_counter(CounterType.packets_and_bytes) acl_pre_ingress_vlan_counter_0; + @id(0x13000105) @name("acl_pre_ingress_metadata_counter") direct_counter(CounterType.packets_and_bytes) acl_pre_ingress_metadata_counter_0; + @id(0x01000100) @sai_action(SAI_PACKET_ACTION_FORWARD) @name("set_vrf") action set_vrf_0(@sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_SET_VRF) @refers_to(vrf_table , vrf_id) @id(1) vrf_id_t vrf_id) { local_metadata.vrf_id = vrf_id; - acl_pre_ingress_counter.count(); + acl_pre_ingress_counter_0.count(); + } + @id(0x0100010A) @sai_action(SAI_PACKET_ACTION_FORWARD) @name("set_outer_vlan_id") action set_outer_vlan_id_0(@id(1) @sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_SET_OUTER_VLAN_ID) vlan_id_t vlan_id) { + local_metadata.vlan_id = vlan_id; + acl_pre_ingress_vlan_counter_0.count(); } - @p4runtime_role("sdn_controller") @id(0x02000101) @sai_acl(PRE_INGRESS) @entry_restriction(" + @id(0x0100010B) @sai_action(SAI_PACKET_ACTION_FORWARD) @name("set_acl_metadata") action set_acl_metadata_0(@id(1) @sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_SET_ACL_META_DATA) acl_metadata_t acl_metadata) { + local_metadata.acl_metadata = acl_metadata; + acl_pre_ingress_metadata_counter_0.count(); + } + @p4runtime_role("sdn_controller") @id(0x02000101) @sai_acl(PRE_INGRESS) @sai_acl_priority(11) @entry_restriction(" // Only allow IP field matches for IP packets. dscp::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + ecn::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); dst_ip::mask != 0 -> is_ipv4 == 1; dst_ipv6::mask != 0 -> is_ipv6 == 1; // Forbid illegal combinations of IP_TYPE fields. @@ -709,71 +1454,218 @@ control acl_pre_ingress(in headers_t headers, inout local_metadata_t local_metad // Forbid unsupported combinations of IP_TYPE fields. is_ipv4::mask != 0 -> (is_ipv4 == 1); is_ipv6::mask != 0 -> (is_ipv6 == 1); + + + + // Reserve high priorities for switch-internal use. // TODO: Remove once inband workaround is obsolete. ::priority < 0x7fffffff; - ") table acl_pre_ingress_table { + ") @name("acl_pre_ingress_table") table acl_pre_ingress_table_0 { key = { - headers.ipv4.isValid() || headers.ipv6.isValid(): optional @name("is_ip") @id(1) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); - headers.ipv4.isValid() : optional @name("is_ipv4") @id(2) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); - headers.ipv6.isValid() : optional @name("is_ipv6") @id(3) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); - headers.ethernet.src_addr : ternary @name("src_mac") @id(4) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_SRC_MAC) @format(MAC_ADDRESS); - headers.ipv4.dst_addr : ternary @name("dst_ip") @id(5) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_IP) @format(IPV4_ADDRESS); - headers.ipv6.dst_addr[127:64] : ternary @name("dst_ipv6") @id(6) @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD2 )) @format(IPV6_ADDRESS); - dscp : ternary @name("dscp") @id(7) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DSCP); - local_metadata.ingress_port : optional @name("in_port") @id(8) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IN_PORT); + headers.ipv4.isValid() || headers.ipv6.isValid(): optional @id(1) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(2) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(3) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + headers.ethernet.src_addr : ternary @id(4) @name("src_mac") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_SRC_MAC) @format(MAC_ADDRESS); + headers.ipv4.dst_addr : ternary @id(5) @name("dst_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_IP) @format(IPV4_ADDRESS); + headers.ipv6.dst_addr[127:64] : ternary @id(6) @name("dst_ipv6") @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD2 )) @format(IPV6_ADDRESS); + dscp_2 : ternary @id(7) @name("dscp") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DSCP); + ecn_1 : ternary @id(10) @name("ecn") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ECN); + local_metadata.ingress_port : optional @id(8) @name("in_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IN_PORT); } actions = { - @proto_id(1) set_vrf(); + @proto_id(1) set_vrf_0(); @defaultonly NoAction(); } const default_action = NoAction(); - counters = acl_pre_ingress_counter; - size = 255; + counters = acl_pre_ingress_counter_0; + size = 254; + } + @id(0x02000105) @sai_acl(PRE_INGRESS) @p4runtime_role("sdn_controller") @sai_acl_priority(1) @entry_restriction(" + // Forbid using ether_type for IP packets (by convention, use is_ip* instead). + ether_type != 0x0800 && ether_type != 0x86dd; + // Forbid illegal combinations of IP_TYPE fields. + is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0); + is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0); + is_ipv6::mask != 0 -> (is_ip::mask == 0 && is_ipv4::mask == 0); + // Forbid unsupported combinations of IP_TYPE fields. + is_ipv4::mask != 0 -> (is_ipv4 == 1); + is_ipv6::mask != 0 -> (is_ipv6 == 1); + // Disallow match on reserved VLAN IDs to rule out vendor specific behavior. + vlan_id::mask != 0 -> (vlan_id != 4095 && vlan_id != 0); + // TODO: Disallow setting to reserved VLAN IDs when supported. + ") @name("acl_pre_ingress_vlan_table") table acl_pre_ingress_vlan_table_0 { + key = { + headers.ipv4.isValid() || headers.ipv6.isValid(): optional @id(1) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(2) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(3) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + headers.ethernet.ether_type : ternary @id(4) @name("ether_type") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ETHER_TYPE); + local_metadata.vlan_id : ternary @id(5) @name("vlan_id") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_OUTER_VLAN_ID); + } + actions = { + @proto_id(1) set_outer_vlan_id_0(); + @defaultonly NoAction(); + } + const default_action = NoAction(); + counters = acl_pre_ingress_vlan_counter_0; + size = 254; + } + @id(0x02000106) @sai_acl(PRE_INGRESS) @p4runtime_role("sdn_controller") @sai_acl_priority(5) @entry_restriction(" + // Forbid illegal combinations of IP_TYPE fields. + is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0); + is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0); + is_ipv6::mask != 0 -> (is_ip::mask == 0 && is_ipv4::mask == 0); + // DSCP is only allowed on IP traffic. + dscp::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + ecn::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + // Forbid unsupported combinations of IP_TYPE fields. + is_ipv4::mask != 0 -> (is_ipv4 == 1); + is_ipv6::mask != 0 -> (is_ipv6 == 1); + // Only allow icmp_type matches for ICMP packets + icmpv6_type::mask != 0 -> ip_protocol == 58; + ") @name("acl_pre_ingress_metadata_table") table acl_pre_ingress_metadata_table_0 { + key = { + headers.ipv4.isValid() || headers.ipv6.isValid(): optional @id(1) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(2) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(3) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + ip_protocol_2 : ternary @id(4) @name("ip_protocol") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IP_PROTOCOL); + headers.icmp.type : ternary @id(5) @name("icmpv6_type") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ICMPV6_TYPE); + dscp_2 : ternary @id(6) @name("dscp") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DSCP); + ecn_1 : ternary @id(7) @name("ecn") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ECN); + } + actions = { + @proto_id(1) set_acl_metadata_0(); + @defaultonly NoAction(); + } + const default_action = NoAction(); + counters = acl_pre_ingress_metadata_counter_0; + size = 254; } apply { if (headers.ipv4.isValid()) { - dscp = headers.ipv4.dscp; + dscp_2 = headers.ipv4.dscp; + ecn_1 = headers.ipv4.ecn; + ip_protocol_2 = headers.ipv4.protocol; } else if (headers.ipv6.isValid()) { - dscp = headers.ipv6.dscp; + dscp_2 = headers.ipv6.dscp; + ecn_1 = headers.ipv6.ecn; + ip_protocol_2 = headers.ipv6.next_header; } - local_metadata.vrf_id = (vrf_id_t)10w0; - acl_pre_ingress_table.apply(); + acl_pre_ingress_table_0.apply(); } } control admit_google_system_mac(in headers_t headers, inout local_metadata_t local_metadata) { apply { - local_metadata.admit_to_l3 = headers.ethernet.dst_addr & 48w0x10000000000 == 48w0; + local_metadata.admit_to_l3 = headers.ethernet.dst_addr == 48w0x1a11175f80; + } +} + +control hashing(in headers_t headers, inout local_metadata_t local_metadata, in standard_metadata_t standard_metadata) { + @name("seed") bit<32> seed_0 = 32w0; + @name("offset") bit<8> offset_0 = 8w0; + @sai_hash_seed(0) @id(0x010000A) @name("select_ecmp_hash_algorithm") action select_ecmp_hash_algorithm_0() { + seed_0 = 32w0; + } + @sai_ecmp_hash(SAI_SWITCH_ATTR_ECMP_HASH_IPV4) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_SRC_IPV4) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_DST_IPV4) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_SRC_PORT) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_DST_PORT) @id(0x0100000B) @name("compute_ecmp_hash_ipv4") action compute_ecmp_hash_ipv4_0() { + hash, bit<1>, tuple, bit<32>, bit<32>, bit<16>, bit<16>>, bit<17>>(local_metadata.wcmp_selector_input, HashAlgorithm.crc32, 1w0, { seed_0, headers.ipv4.src_addr, headers.ipv4.dst_addr, local_metadata.l4_src_port, local_metadata.l4_dst_port }, 17w0x10000); + local_metadata.wcmp_selector_input = local_metadata.wcmp_selector_input >> offset_0 | local_metadata.wcmp_selector_input << 8w8 - offset_0; + } + @sai_ecmp_hash(SAI_SWITCH_ATTR_ECMP_HASH_IPV6) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_SRC_IPV6) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_DST_IPV6) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_SRC_PORT) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_DST_PORT) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_IPV6_FLOW_LABEL) @id(0x0100000C) @name("compute_ecmp_hash_ipv6") action compute_ecmp_hash_ipv6_0() { + hash, bit<1>, tuple, bit<20>, bit<128>, bit<128>, bit<16>, bit<16>>, bit<17>>(local_metadata.wcmp_selector_input, HashAlgorithm.crc32, 1w0, { seed_0, headers.ipv6.flow_label, headers.ipv6.src_addr, headers.ipv6.dst_addr, local_metadata.l4_src_port, local_metadata.l4_dst_port }, 17w0x10000); + local_metadata.wcmp_selector_input = local_metadata.wcmp_selector_input >> offset_0 | local_metadata.wcmp_selector_input << 8w8 - offset_0; + } + apply { + select_ecmp_hash_algorithm_0(); + if (headers.ipv4.isValid()) { + compute_ecmp_hash_ipv4_0(); + } else if (headers.ipv6.isValid()) { + compute_ecmp_hash_ipv6_0(); + } + } +} + +control lag_hashing_config(in headers_t headers) { + @name("lag_seed") bit<32> lag_seed_0 = 32w0; + @name("lag_offset") bit<4> lag_offset_0 = 4w0; + @sai_hash_algorithm(SAI_HASH_ALGORITHM_CRC) @sai_hash_seed(0) @sai_hash_offset(0) @name("select_lag_hash_algorithm") action select_lag_hash_algorithm_0() { + lag_seed_0 = 32w0; + lag_offset_0 = 4w0; + } + @sai_lag_hash(SAI_SWITCH_ATTR_LAG_HASH_IPV4) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_SRC_IPV4) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_DST_IPV4) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_SRC_PORT) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_DST_PORT) @id(0x0100000D) @name("compute_lag_hash_ipv4") action compute_lag_hash_ipv4_0() { + } + @sai_lag_hash(SAI_SWITCH_ATTR_LAG_HASH_IPV6) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_SRC_IPV6) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_DST_IPV6) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_SRC_PORT) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_DST_PORT) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_IPV6_FLOW_LABEL) @id(0x0100000E) @name("compute_lag_hash_ipv6") action compute_lag_hash_ipv6_0() { + } + apply { + select_lag_hash_algorithm_0(); + if (headers.ipv4.isValid()) { + compute_lag_hash_ipv4_0(); + } else if (headers.ipv6.isValid()) { + compute_lag_hash_ipv6_0(); + } } } control ingress(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { - @name("acl_pre_ingress") acl_pre_ingress() acl_pre_ingress_inst; - @name("admit_google_system_mac") admit_google_system_mac() admit_google_system_mac_inst; - @name("l3_admit") l3_admit() l3_admit_inst; - @name("routing") routing() routing_inst; - @name("acl_ingress") acl_ingress() acl_ingress_inst; - @name("ttl") ttl() ttl_inst; - @name("mirroring_clone") mirroring_clone() mirroring_clone_inst; + @name("packet_out_decap") packet_out_decap() packet_out_decap_inst_0; + @name("tunnel_termination_lookup") tunnel_termination_lookup() tunnel_termination_lookup_inst_0; + @name("vlan_untag") vlan_untag() vlan_untag_inst_0; + @name("acl_pre_ingress") acl_pre_ingress() acl_pre_ingress_inst_0; + @name("ingress_vlan_checks") ingress_vlan_checks() ingress_vlan_checks_inst_0; + @name("tunnel_termination_decap") tunnel_termination_decap() tunnel_termination_decap_inst_0; + @name("admit_google_system_mac") admit_google_system_mac() admit_google_system_mac_inst_0; + @name("l3_admit") l3_admit() l3_admit_inst_0; + @name("hashing") hashing() hashing_inst_0; + @name("routing_lookup") routing_lookup() routing_lookup_inst_0; + @name("acl_ingress") acl_ingress() acl_ingress_inst_0; + @name("routing_resolution") routing_resolution() routing_resolution_inst_0; + @name("mirror_session_lookup") mirror_session_lookup() mirror_session_lookup_inst_0; + @name("ingress_cloning") ingress_cloning() ingress_cloning_inst_0; + @name("drop_martians") drop_martians() drop_martians_inst_0; apply { - acl_pre_ingress_inst.apply(headers, local_metadata, standard_metadata); - admit_google_system_mac_inst.apply(headers, local_metadata); - l3_admit_inst.apply(headers, local_metadata, standard_metadata); - routing_inst.apply(headers, local_metadata, standard_metadata); - acl_ingress_inst.apply(headers, local_metadata, standard_metadata); - ttl_inst.apply(headers, local_metadata, standard_metadata); - mirroring_clone_inst.apply(headers, local_metadata, standard_metadata); + packet_out_decap_inst_0.apply(headers, local_metadata, standard_metadata); + if (local_metadata.bypass_ingress) { + ; + } else { + tunnel_termination_lookup_inst_0.apply(headers, local_metadata); + vlan_untag_inst_0.apply(headers, local_metadata, standard_metadata); + acl_pre_ingress_inst_0.apply(headers, local_metadata, standard_metadata); + ingress_vlan_checks_inst_0.apply(headers, local_metadata, standard_metadata); + tunnel_termination_decap_inst_0.apply(headers, local_metadata); + admit_google_system_mac_inst_0.apply(headers, local_metadata); + l3_admit_inst_0.apply(headers, local_metadata, standard_metadata); + hashing_inst_0.apply(headers, local_metadata, standard_metadata); + routing_lookup_inst_0.apply(headers, local_metadata, standard_metadata); + acl_ingress_inst_0.apply(headers, local_metadata, standard_metadata); + routing_resolution_inst_0.apply(headers, local_metadata, standard_metadata); + mirror_session_lookup_inst_0.apply(headers, local_metadata, standard_metadata); + ingress_cloning_inst_0.apply(headers, local_metadata, standard_metadata); + drop_martians_inst_0.apply(headers, local_metadata, standard_metadata); + } } } control egress(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { - @name("packet_rewrites") packet_rewrites() packet_rewrites_inst; - @name("mirroring_encap") mirroring_encap() mirroring_encap_inst; + @name("packet_in_encap") packet_in_encap() packet_in_encap_inst_0; + @name("packet_rewrites") packet_rewrites() packet_rewrites_inst_0; + @name("gre_tunnel_encap") gre_tunnel_encap() gre_tunnel_encap_inst_0; + @name("mirroring_encap") mirroring_encap() mirroring_encap_inst_0; + @name("egress_vlan_checks") egress_vlan_checks() egress_vlan_checks_inst_0; + @name("vlan_tag") vlan_tag() vlan_tag_inst_0; + @name("acl_egress") acl_egress() acl_egress_inst_0; apply { - packet_rewrites_inst.apply(headers, local_metadata, standard_metadata); - mirroring_encap_inst.apply(headers, local_metadata, standard_metadata); + packet_in_encap_inst_0.apply(headers, local_metadata, standard_metadata); + if (standard_metadata.instance_type == 32w1 && standard_metadata.egress_rid == 16w1) { + ; + } else { + packet_rewrites_inst_0.apply(headers, local_metadata, standard_metadata); + gre_tunnel_encap_inst_0.apply(headers, local_metadata, standard_metadata); + mirroring_encap_inst_0.apply(headers, local_metadata, standard_metadata); + egress_vlan_checks_inst_0.apply(headers, local_metadata, standard_metadata); + vlan_tag_inst_0.apply(headers, local_metadata, standard_metadata); + acl_egress_inst_0.apply(headers, local_metadata, standard_metadata); + } } } -@pkginfo(name="middleblock.p4", organization="Google") V1Switch(packet_parser(), verify_ipv4_checksum(), ingress(), egress(), compute_ipv4_checksum(), packet_deparser()) main; +@pkginfo(name="middleblock.p4", organization="Google", version="1.6.1") V1Switch(packet_parser(), verify_ipv4_checksum(), ingress(), egress(), compute_ipv4_checksum(), packet_deparser()) main; diff --git a/testdata/p4_16_samples_outputs/pins/pins_middleblock-frontend.p4 b/testdata/p4_16_samples_outputs/pins/pins_middleblock-frontend.p4 index 820baae538..66f962fb00 100644 --- a/testdata/p4_16_samples_outputs/pins/pins_middleblock-frontend.p4 +++ b/testdata/p4_16_samples_outputs/pins/pins_middleblock-frontend.p4 @@ -5,10 +5,19 @@ typedef bit<48> ethernet_addr_t; typedef bit<32> ipv4_addr_t; typedef bit<128> ipv6_addr_t; +typedef bit<12> vlan_id_t; +typedef bit<16> ether_type_t; header ethernet_t { ethernet_addr_t dst_addr; ethernet_addr_t src_addr; - bit<16> ether_type; + ether_type_t ether_type; +} + +header vlan_t { + bit<3> priority_code_point; + bit<1> drop_eligible_indicator; + vlan_id_t vlan_id; + ether_type_t ether_type; } header ipv4_t { @@ -65,6 +74,7 @@ header icmp_t { bit<8> type; bit<8> code; bit<16> checksum; + bit<32> rest_of_header; } header arp_t { @@ -92,104 +102,219 @@ header gre_t { bit<16> protocol; } +header ipfix_t { + bit<16> version_number; + bit<16> length; + bit<32> export_time; + bit<32> sequence_number; + bit<32> observation_domain_id; +} + +header psamp_extended_t { + bit<16> template_id; + bit<16> length; + bit<64> observation_time; + bit<16> flowset; + bit<16> next_hop_index; + bit<16> epoch; + bit<16> ingress_port; + bit<16> egress_port; + bit<16> user_meta_field; + bit<8> dlb_id; + bit<8> variable_length; + bit<16> packet_sampled_length; +} + enum bit<8> PreservedFieldList { - CLONE_I2E = 8w1 + MIRROR_AND_PACKET_IN_COPY = 8w1, + RECIRCULATE = 8w2 } type bit<10> nexthop_id_t; +type bit<10> tunnel_id_t; type bit<12> wcmp_group_id_t; -type bit<10> vrf_id_t; +@p4runtime_translation_mappings({ { "" , 0 } , }) type bit<10> vrf_id_t; type bit<10> router_interface_id_t; type bit<9> port_id_t; type bit<10> mirror_session_id_t; type bit<8> qos_queue_t; typedef bit<6> route_metadata_t; +typedef bit<8> acl_metadata_t; +typedef bit<16> multicast_group_id_t; +typedef bit<16> replica_instance_t; enum bit<2> MeterColor_t { GREEN = 2w0, YELLOW = 2w1, RED = 2w2 } +@controller_header("packet_in") header packet_in_header_t { + @id(1) + port_id_t ingress_port; + @id(2) + port_id_t target_egress_port; +} + +@controller_header("packet_out") header packet_out_header_t { + @id(1) + port_id_t egress_port; + @id(2) + bit<1> submit_to_ingress; + @id(3) @padding + bit<6> unused_pad; +} + struct headers_t { - ethernet_t erspan_ethernet; - ipv4_t erspan_ipv4; - gre_t erspan_gre; - ethernet_t ethernet; - ipv6_t tunnel_encap_ipv6; - gre_t tunnel_encap_gre; - ipv4_t ipv4; - ipv6_t ipv6; - icmp_t icmp; - tcp_t tcp; - udp_t udp; - arp_t arp; + packet_out_header_t packet_out_header; + ethernet_t mirror_encap_ethernet; + vlan_t mirror_encap_vlan; + ipv6_t mirror_encap_ipv6; + udp_t mirror_encap_udp; + ipfix_t ipfix; + psamp_extended_t psamp_extended; + ethernet_t ethernet; + vlan_t vlan; + ipv6_t tunnel_encap_ipv6; + gre_t tunnel_encap_gre; + ipv4_t ipv4; + ipv6_t ipv6; + ipv4_t inner_ipv4; + ipv6_t inner_ipv6; + icmp_t icmp; + tcp_t tcp; + udp_t udp; + arp_t arp; } struct packet_rewrites_t { ethernet_addr_t src_mac; ethernet_addr_t dst_mac; + vlan_id_t vlan_id; } struct local_metadata_t { + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + bool enable_vlan_checks; + vlan_id_t vlan_id; bool admit_to_l3; vrf_id_t vrf_id; + bool enable_decrement_ttl; + bool enable_src_mac_rewrite; + bool enable_dst_mac_rewrite; + bool enable_vlan_rewrite; packet_rewrites_t packet_rewrites; bit<16> l4_src_port; bit<16> l4_dst_port; - bit<16> wcmp_selector_input; + bit<8> wcmp_selector_input; + bool apply_tunnel_decap_at_end_of_pre_ingress; bool apply_tunnel_encap_at_egress; ipv6_addr_t tunnel_encap_src_ipv6; ipv6_addr_t tunnel_encap_dst_ipv6; - bool mirror_session_id_valid; - mirror_session_id_t mirror_session_id_value; - @field_list(PreservedFieldList.CLONE_I2E) - ipv4_addr_t mirroring_src_ip; - @field_list(PreservedFieldList.CLONE_I2E) - ipv4_addr_t mirroring_dst_ip; - @field_list(PreservedFieldList.CLONE_I2E) - ethernet_addr_t mirroring_src_mac; - @field_list(PreservedFieldList.CLONE_I2E) - ethernet_addr_t mirroring_dst_mac; - @field_list(PreservedFieldList.CLONE_I2E) - bit<8> mirroring_ttl; - @field_list(PreservedFieldList.CLONE_I2E) - bit<8> mirroring_tos; + bool marked_to_copy; + bool marked_to_mirror; + mirror_session_id_t mirror_session_id; + port_id_t mirror_egress_port; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + ethernet_addr_t mirror_encap_src_mac; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + ethernet_addr_t mirror_encap_dst_mac; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + vlan_id_t mirror_encap_vlan_id; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + ipv6_addr_t mirror_encap_src_ip; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + ipv6_addr_t mirror_encap_dst_ip; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + bit<16> mirror_encap_udp_src_port; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + bit<16> mirror_encap_udp_dst_port; + @field_list(PreservedFieldList.RECIRCULATE) + bit<9> loopback_port; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + bit<9> packet_in_ingress_port; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + bit<9> packet_in_target_egress_port; MeterColor_t color; port_id_t ingress_port; route_metadata_t route_metadata; -} - -@controller_header("packet_in") header packet_in_header_t { - @id(1) - port_id_t ingress_port; - @id(2) - port_id_t target_egress_port; -} - -@controller_header("packet_out") header packet_out_header_t { - @id(1) - port_id_t egress_port; - @id(2) - bit<1> submit_to_ingress; - @id(3) - bit<7> unused_pad; + acl_metadata_t acl_metadata; + bool bypass_ingress; + bool wcmp_group_id_valid; + wcmp_group_id_t wcmp_group_id_value; + bool nexthop_id_valid; + nexthop_id_t nexthop_id_value; + bool ipmc_table_hit; + bool acl_drop; } parser packet_parser(packet_in packet, out headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { state start { + local_metadata.enable_vlan_checks = false; + local_metadata.vlan_id = 12w0; local_metadata.admit_to_l3 = false; local_metadata.vrf_id = (vrf_id_t)10w0; + local_metadata.enable_decrement_ttl = false; + local_metadata.enable_src_mac_rewrite = false; + local_metadata.enable_dst_mac_rewrite = false; + local_metadata.enable_vlan_rewrite = false; local_metadata.packet_rewrites.src_mac = 48w0; local_metadata.packet_rewrites.dst_mac = 48w0; local_metadata.l4_src_port = 16w0; local_metadata.l4_dst_port = 16w0; - local_metadata.wcmp_selector_input = 16w0; - local_metadata.mirror_session_id_valid = false; + local_metadata.wcmp_selector_input = 8w0; + local_metadata.apply_tunnel_decap_at_end_of_pre_ingress = false; + local_metadata.apply_tunnel_encap_at_egress = false; + local_metadata.tunnel_encap_src_ipv6 = 128w0; + local_metadata.tunnel_encap_dst_ipv6 = 128w0; + local_metadata.marked_to_copy = false; + local_metadata.marked_to_mirror = false; + local_metadata.mirror_session_id = (mirror_session_id_t)10w0; + local_metadata.mirror_egress_port = (port_id_t)9w0; local_metadata.color = MeterColor_t.GREEN; - local_metadata.ingress_port = (port_id_t)standard_metadata.ingress_port; local_metadata.route_metadata = 6w0; + local_metadata.bypass_ingress = false; + local_metadata.wcmp_group_id_valid = false; + local_metadata.wcmp_group_id_value = (wcmp_group_id_t)12w0; + local_metadata.nexthop_id_valid = false; + local_metadata.nexthop_id_value = (nexthop_id_t)10w0; + local_metadata.ipmc_table_hit = false; + local_metadata.acl_drop = false; + transition select(standard_metadata.instance_type == 32w4) { + true: start_true; + false: start_false; + } + } + state start_true { + local_metadata.ingress_port = (port_id_t)local_metadata.loopback_port; + transition start_join; + } + state start_false { + local_metadata.ingress_port = (port_id_t)standard_metadata.ingress_port; + transition start_join; + } + state start_join { + transition select(standard_metadata.ingress_port) { + 9w510: parse_packet_out_header; + default: parse_ethernet; + } + } + state parse_packet_out_header { + packet.extract(headers.packet_out_header); + transition parse_ethernet; + } + state parse_ethernet { packet.extract(headers.ethernet); transition select(headers.ethernet.ether_type) { + 16w0x800: parse_ipv4; + 16w0x86dd: parse_ipv6; + 16w0x806: parse_arp; + 16w0x8100: parse_8021q_vlan; + default: accept; + } + } + state parse_8021q_vlan { + packet.extract(headers.vlan); + transition select(headers.vlan.ether_type) { 16w0x800: parse_ipv4; 16w0x86dd: parse_ipv6; 16w0x806: parse_arp; @@ -199,6 +324,17 @@ parser packet_parser(packet_in packet, out headers_t headers, inout local_metada state parse_ipv4 { packet.extract(headers.ipv4); transition select(headers.ipv4.protocol) { + 8w0x4: parse_ipv4_in_ip; + 8w0x29: parse_ipv6_in_ip; + 8w0x1: parse_icmp; + 8w0x6: parse_tcp; + 8w0x11: parse_udp; + default: accept; + } + } + state parse_ipv4_in_ip { + packet.extract(headers.inner_ipv4); + transition select(headers.inner_ipv4.protocol) { 8w0x1: parse_icmp; 8w0x6: parse_tcp; 8w0x11: parse_udp; @@ -208,6 +344,17 @@ parser packet_parser(packet_in packet, out headers_t headers, inout local_metada state parse_ipv6 { packet.extract(headers.ipv6); transition select(headers.ipv6.next_header) { + 8w0x4: parse_ipv4_in_ip; + 8w0x29: parse_ipv6_in_ip; + 8w0x3a: parse_icmp; + 8w0x6: parse_tcp; + 8w0x11: parse_udp; + default: accept; + } + } + state parse_ipv6_in_ip { + packet.extract(headers.inner_ipv6); + transition select(headers.inner_ipv6.next_header) { 8w0x3a: parse_icmp; 8w0x6: parse_tcp; 8w0x11: parse_udp; @@ -238,14 +385,21 @@ parser packet_parser(packet_in packet, out headers_t headers, inout local_metada control packet_deparser(packet_out packet, in headers_t headers) { apply { - packet.emit(headers.erspan_ethernet); - packet.emit(headers.erspan_ipv4); - packet.emit(headers.erspan_gre); + packet.emit(headers.packet_out_header); + packet.emit(headers.mirror_encap_ethernet); + packet.emit(headers.mirror_encap_vlan); + packet.emit(headers.mirror_encap_ipv6); + packet.emit(headers.mirror_encap_udp); + packet.emit(headers.ipfix); + packet.emit(headers.psamp_extended); packet.emit(headers.ethernet); + packet.emit(headers.vlan); packet.emit(headers.tunnel_encap_ipv6); packet.emit(headers.tunnel_encap_gre); packet.emit(headers.ipv4); packet.emit(headers.ipv6); + packet.emit(headers.inner_ipv4); + packet.emit(headers.inner_ipv6); packet.emit(headers.arp); packet.emit(headers.icmp); packet.emit(headers.tcp); @@ -261,30 +415,31 @@ control verify_ipv4_checksum(inout headers_t headers, inout local_metadata_t loc control compute_ipv4_checksum(inout headers_t headers, inout local_metadata_t local_metadata) { apply { - update_checksum, bit<4>, bit<6>, bit<2>, bit<16>, bit<16>, bit<1>, bit<1>, bit<1>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>, bit<16>>(headers.erspan_ipv4.isValid(), { headers.erspan_ipv4.version, headers.erspan_ipv4.ihl, headers.erspan_ipv4.dscp, headers.erspan_ipv4.ecn, headers.erspan_ipv4.total_len, headers.erspan_ipv4.identification, headers.erspan_ipv4.reserved, headers.erspan_ipv4.do_not_fragment, headers.erspan_ipv4.more_fragments, headers.erspan_ipv4.frag_offset, headers.erspan_ipv4.ttl, headers.erspan_ipv4.protocol, headers.erspan_ipv4.src_addr, headers.erspan_ipv4.dst_addr }, headers.erspan_ipv4.header_checksum, HashAlgorithm.csum16); update_checksum, bit<4>, bit<6>, bit<2>, bit<16>, bit<16>, bit<1>, bit<1>, bit<1>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>, bit<16>>(headers.ipv4.isValid(), { headers.ipv4.version, headers.ipv4.ihl, headers.ipv4.dscp, headers.ipv4.ecn, headers.ipv4.total_len, headers.ipv4.identification, headers.ipv4.reserved, headers.ipv4.do_not_fragment, headers.ipv4.more_fragments, headers.ipv4.frag_offset, headers.ipv4.ttl, headers.ipv4.protocol, headers.ipv4.src_addr, headers.ipv4.dst_addr }, headers.ipv4.header_checksum, HashAlgorithm.csum16); } } control ingress(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { @name("ingress.acl_pre_ingress.dscp") bit<6> acl_pre_ingress_dscp; - @name("ingress.routing.wcmp_group_id_valid") bool routing_wcmp_group_id_valid; - @name("ingress.routing.wcmp_group_id_value") wcmp_group_id_t routing_wcmp_group_id_value; - @name("ingress.routing.nexthop_id_valid") bool routing_nexthop_id_valid; - @name("ingress.routing.nexthop_id_value") nexthop_id_t routing_nexthop_id_value; - @name("ingress.routing.router_interface_id_valid") bool routing_router_interface_id_valid; - @name("ingress.routing.router_interface_id_value") router_interface_id_t routing_router_interface_id_value; - @name("ingress.routing.neighbor_id_valid") bool routing_neighbor_id_valid; - @name("ingress.routing.neighbor_id_value") ipv6_addr_t routing_neighbor_id_value; + @name("ingress.acl_pre_ingress.ecn") bit<2> acl_pre_ingress_ecn; + @name("ingress.hashing.seed") bit<32> hashing_seed; + @name("ingress.hashing.offset") bit<8> hashing_offset; @name("ingress.acl_ingress.ttl") bit<8> acl_ingress_ttl; @name("ingress.acl_ingress.dscp") bit<6> acl_ingress_dscp; @name("ingress.acl_ingress.ecn") bit<2> acl_ingress_ecn; @name("ingress.acl_ingress.ip_protocol") bit<8> acl_ingress_ip_protocol; - @name("ingress.mirroring_clone.mirror_port") port_id_t mirroring_clone_mirror_port; - @name("ingress.mirroring_clone.pre_session") bit<32> mirroring_clone_pre_session; - @name("ingress.standard_metadata") standard_metadata_t standard_metadata_0; - @noWarn("unused") @name(".NoAction") action NoAction_1() { - } + @name("ingress.acl_ingress.cancel_copy") bool acl_ingress_cancel_copy; + @name("ingress.routing_resolution.tunnel_id_valid") bool routing_resolution_tunnel_id_valid; + @name("ingress.routing_resolution.tunnel_id_value") tunnel_id_t routing_resolution_tunnel_id_value; + @name("ingress.routing_resolution.router_interface_id_valid") bool routing_resolution_router_interface_id_valid; + @name("ingress.routing_resolution.router_interface_id_value") router_interface_id_t routing_resolution_router_interface_id_value; + @name("ingress.routing_resolution.neighbor_id_valid") bool routing_resolution_neighbor_id_valid; + @name("ingress.routing_resolution.neighbor_id_value") ipv6_addr_t routing_resolution_neighbor_id_value; + @name("ingress.local_metadata") local_metadata_t local_metadata_0; + @name("ingress.local_metadata") local_metadata_t local_metadata_1; + @name("ingress.local_metadata") local_metadata_t local_metadata_8; + @name("ingress.local_metadata") local_metadata_t local_metadata_9; + @name("ingress.local_metadata") local_metadata_t local_metadata_10; @noWarn("unused") @name(".NoAction") action NoAction_2() { } @noWarn("unused") @name(".NoAction") action NoAction_3() { @@ -301,19 +456,94 @@ control ingress(inout headers_t headers, inout local_metadata_t local_metadata, } @noWarn("unused") @name(".NoAction") action NoAction_9() { } - @id(0x01000109) @sai_action(SAI_PACKET_ACTION_DROP) @name(".acl_drop") action acl_drop_0() { - standard_metadata_0 = standard_metadata; - mark_to_drop(standard_metadata_0); - standard_metadata = standard_metadata_0; + @noWarn("unused") @name(".NoAction") action NoAction_10() { + } + @noWarn("unused") @name(".NoAction") action NoAction_11() { + } + @noWarn("unused") @name(".NoAction") action NoAction_12() { + } + @noWarn("unused") @name(".NoAction") action NoAction_13() { + } + @noWarn("unused") @name(".NoAction") action NoAction_14() { + } + @noWarn("unused") @name(".NoAction") action NoAction_15() { + } + @noWarn("unused") @name(".NoAction") action NoAction_16() { + } + @noWarn("unused") @name(".NoAction") action NoAction_17() { + } + @id(0x01000005) @name(".set_nexthop_id") action set_nexthop_id_1(@id(1) @refers_to(nexthop_table , nexthop_id) @name("nexthop_id") nexthop_id_t nexthop_id) { + local_metadata_0 = local_metadata; + local_metadata_0.nexthop_id_valid = true; + local_metadata_0.nexthop_id_value = nexthop_id; + local_metadata = local_metadata_0; + } + @id(0x01000005) @name(".set_nexthop_id") action set_nexthop_id_2(@id(1) @refers_to(nexthop_table , nexthop_id) @name("nexthop_id") nexthop_id_t nexthop_id_3) { + local_metadata_1 = local_metadata; + local_metadata_1.nexthop_id_valid = true; + local_metadata_1.nexthop_id_value = nexthop_id_3; + local_metadata = local_metadata_1; + } + @id(0x01000005) @name(".set_nexthop_id") action set_nexthop_id_3(@id(1) @refers_to(nexthop_table , nexthop_id) @name("nexthop_id") nexthop_id_t nexthop_id_4) { + local_metadata_8 = local_metadata; + local_metadata_8.nexthop_id_valid = true; + local_metadata_8.nexthop_id_value = nexthop_id_4; + local_metadata = local_metadata_8; + } + @id(0x01000109) @sai_action(SAI_PACKET_ACTION_DROP) @name(".acl_drop") action acl_drop_2() { + local_metadata_9 = local_metadata; + local_metadata_9.acl_drop = true; + local_metadata = local_metadata_9; + } + @id(0x01000109) @sai_action(SAI_PACKET_ACTION_DROP) @name(".acl_drop") action acl_drop_3() { + local_metadata_10 = local_metadata; + local_metadata_10.acl_drop = true; + local_metadata = local_metadata_10; + } + @id(0x01000016) @name("ingress.tunnel_termination_lookup.mark_for_tunnel_decap_and_set_vrf") action tunnel_termination_lookup_mark_for_tunnel_decap_and_set_vrf_0(@refers_to(vrf_table , vrf_id) @name("vrf_id") vrf_id_t vrf_id_2) { + local_metadata.apply_tunnel_decap_at_end_of_pre_ingress = true; + local_metadata.vrf_id = vrf_id_2; + } + @unsupported @p4runtime_role("sdn_controller") @id(0x0200004B) @name("ingress.tunnel_termination_lookup.ipv6_tunnel_termination_table") table tunnel_termination_lookup_ipv6_tunnel_termination_table { + key = { + headers.ipv6.dst_addr: ternary @id(1) @name("dst_ipv6") @format(IPV6_ADDRESS); + headers.ipv6.src_addr: ternary @id(2) @name("src_ipv6") @format(IPV6_ADDRESS); + } + actions = { + @proto_id(1) tunnel_termination_lookup_mark_for_tunnel_decap_and_set_vrf_0(); + @defaultonly NoAction_2(); + } + size = 126; + default_action = NoAction_2(); + } + @id(0x0100001A) @name("ingress.vlan_untag.disable_vlan_checks") action vlan_untag_disable_vlan_checks_0() { + local_metadata.enable_vlan_checks = false; + } + @p4runtime_role("sdn_controller") @id(0x0200004D) @entry_restriction(" + // Force the dummy_match to be wildcard. + dummy_match::mask == 0; + ") @name("ingress.vlan_untag.disable_vlan_checks_table") table vlan_untag_disable_vlan_checks_table { + key = { + 1w1: ternary @id(1) @name("dummy_match"); + } + actions = { + @proto_id(1) vlan_untag_disable_vlan_checks_0(); + @defaultonly NoAction_3(); + } + size = 1; + default_action = NoAction_3(); } @id(0x13000101) @name("ingress.acl_pre_ingress.acl_pre_ingress_counter") direct_counter(CounterType.packets_and_bytes) acl_pre_ingress_acl_pre_ingress_counter; - @id(0x01000100) @sai_action(SAI_PACKET_ACTION_FORWARD) @name("ingress.acl_pre_ingress.set_vrf") action acl_pre_ingress_set_vrf_0(@sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_SET_VRF) @refers_to(vrf_table , vrf_id) @id(1) @name("vrf_id") vrf_id_t vrf_id_1) { - local_metadata.vrf_id = vrf_id_1; + @id(0x13000106) @name("ingress.acl_pre_ingress.acl_pre_ingress_vlan_counter") direct_counter(CounterType.packets_and_bytes) acl_pre_ingress_acl_pre_ingress_vlan_counter; + @id(0x13000105) @name("ingress.acl_pre_ingress.acl_pre_ingress_metadata_counter") direct_counter(CounterType.packets_and_bytes) acl_pre_ingress_acl_pre_ingress_metadata_counter; + @id(0x01000100) @sai_action(SAI_PACKET_ACTION_FORWARD) @name("ingress.acl_pre_ingress.set_vrf") action acl_pre_ingress_set_vrf_0(@sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_SET_VRF) @refers_to(vrf_table , vrf_id) @id(1) @name("vrf_id") vrf_id_t vrf_id_3) { + local_metadata.vrf_id = vrf_id_3; acl_pre_ingress_acl_pre_ingress_counter.count(); } - @p4runtime_role("sdn_controller") @id(0x02000101) @sai_acl(PRE_INGRESS) @entry_restriction(" + @p4runtime_role("sdn_controller") @id(0x02000101) @sai_acl(PRE_INGRESS) @sai_acl_priority(11) @entry_restriction(" // Only allow IP field matches for IP packets. dscp::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + ecn::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); dst_ip::mask != 0 -> is_ipv4 == 1; dst_ipv6::mask != 0 -> is_ipv6 == 1; // Forbid illegal combinations of IP_TYPE fields. @@ -323,27 +553,32 @@ control ingress(inout headers_t headers, inout local_metadata_t local_metadata, // Forbid unsupported combinations of IP_TYPE fields. is_ipv4::mask != 0 -> (is_ipv4 == 1); is_ipv6::mask != 0 -> (is_ipv6 == 1); + + + + // Reserve high priorities for switch-internal use. // TODO: Remove once inband workaround is obsolete. ::priority < 0x7fffffff; ") @name("ingress.acl_pre_ingress.acl_pre_ingress_table") table acl_pre_ingress_acl_pre_ingress_table { key = { - headers.ipv4.isValid() || headers.ipv6.isValid(): optional @name("is_ip") @id(1) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); - headers.ipv4.isValid() : optional @name("is_ipv4") @id(2) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); - headers.ipv6.isValid() : optional @name("is_ipv6") @id(3) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); - headers.ethernet.src_addr : ternary @name("src_mac") @id(4) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_SRC_MAC) @format(MAC_ADDRESS); - headers.ipv4.dst_addr : ternary @name("dst_ip") @id(5) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_IP) @format(IPV4_ADDRESS); - headers.ipv6.dst_addr[127:64] : ternary @name("dst_ipv6") @id(6) @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD2 )) @format(IPV6_ADDRESS); - acl_pre_ingress_dscp : ternary @name("dscp") @id(7) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DSCP); - local_metadata.ingress_port : optional @name("in_port") @id(8) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IN_PORT); + headers.ipv4.isValid() || headers.ipv6.isValid(): optional @id(1) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(2) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(3) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + headers.ethernet.src_addr : ternary @id(4) @name("src_mac") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_SRC_MAC) @format(MAC_ADDRESS); + headers.ipv4.dst_addr : ternary @id(5) @name("dst_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_IP) @format(IPV4_ADDRESS); + headers.ipv6.dst_addr[127:64] : ternary @id(6) @name("dst_ipv6") @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD2 )) @format(IPV6_ADDRESS); + acl_pre_ingress_dscp : ternary @id(7) @name("dscp") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DSCP); + acl_pre_ingress_ecn : ternary @id(10) @name("ecn") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ECN); + local_metadata.ingress_port : optional @id(8) @name("in_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IN_PORT); } actions = { @proto_id(1) acl_pre_ingress_set_vrf_0(); - @defaultonly NoAction_1(); + @defaultonly NoAction_4(); } - const default_action = NoAction_1(); + const default_action = NoAction_4(); counters = acl_pre_ingress_acl_pre_ingress_counter; - size = 255; + size = 254; } @id(0x01000008) @name("ingress.l3_admit.admit_to_l3") action l3_admit_admit_to_l3_0() { local_metadata.admit_to_l3 = true; @@ -355,104 +590,23 @@ control ingress(inout headers_t headers, inout local_metadata_t local_metadata, } actions = { @proto_id(1) l3_admit_admit_to_l3_0(); - @defaultonly NoAction_2(); - } - const default_action = NoAction_2(); - size = 128; - } - @id(0x01000001) @name("ingress.routing.set_dst_mac") action routing_set_dst_mac_0(@id(1) @format(MAC_ADDRESS) @name("dst_mac") ethernet_addr_t dst_mac_2) { - local_metadata.packet_rewrites.dst_mac = dst_mac_2; - } - @p4runtime_role("sdn_controller") @id(0x02000040) @name("ingress.routing.neighbor_table") table routing_neighbor_table { - key = { - routing_router_interface_id_value: exact @id(1) @name("router_interface_id") @refers_to(router_interface_table , router_interface_id); - routing_neighbor_id_value : exact @id(2) @format(IPV6_ADDRESS) @name("neighbor_id"); - } - actions = { - @proto_id(1) routing_set_dst_mac_0(); - @defaultonly NoAction_3(); - } - const default_action = NoAction_3(); - size = 1024; - } - @id(0x01000002) @name("ingress.routing.set_port_and_src_mac") action routing_set_port_and_src_mac_0(@id(1) @name("port") port_id_t port, @id(2) @format(MAC_ADDRESS) @name("src_mac") ethernet_addr_t src_mac_2) { - standard_metadata.egress_spec = (bit<9>)port; - local_metadata.packet_rewrites.src_mac = src_mac_2; - } - @p4runtime_role("sdn_controller") @id(0x02000041) @name("ingress.routing.router_interface_table") table routing_router_interface_table { - key = { - routing_router_interface_id_value: exact @id(1) @name("router_interface_id"); - } - actions = { - @proto_id(1) routing_set_port_and_src_mac_0(); - @defaultonly NoAction_4(); - } - const default_action = NoAction_4(); - size = 256; - } - @id(0x01000014) @name("ingress.routing.set_ip_nexthop") action routing_set_ip_nexthop_0(@id(1) @refers_to(router_interface_table , router_interface_id) @refers_to(neighbor_table , router_interface_id) @name("router_interface_id") router_interface_id_t router_interface_id, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) @name("neighbor_id") ipv6_addr_t neighbor_id) { - routing_router_interface_id_valid = true; - routing_router_interface_id_value = router_interface_id; - routing_neighbor_id_valid = true; - routing_neighbor_id_value = neighbor_id; - } - @id(0x01000003) @deprecated("Use set_ip_nexthop instead.") @name("ingress.routing.set_nexthop") action routing_set_nexthop_0(@id(1) @refers_to(router_interface_table , router_interface_id) @refers_to(neighbor_table , router_interface_id) @name("router_interface_id") router_interface_id_t router_interface_id_2, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) @name("neighbor_id") ipv6_addr_t neighbor_id_2) { - @id(0x01000014) { - routing_router_interface_id_valid = true; - routing_router_interface_id_value = router_interface_id_2; - routing_neighbor_id_valid = true; - routing_neighbor_id_value = neighbor_id_2; - } - } - @p4runtime_role("sdn_controller") @id(0x02000042) @name("ingress.routing.nexthop_table") table routing_nexthop_table { - key = { - routing_nexthop_id_value: exact @id(1) @name("nexthop_id"); - } - actions = { - @proto_id(1) routing_set_nexthop_0(); - @proto_id(3) routing_set_ip_nexthop_0(); @defaultonly NoAction_5(); } const default_action = NoAction_5(); - size = 1024; - } - @id(0x01000005) @name("ingress.routing.set_nexthop_id") action routing_set_nexthop_id_0(@id(1) @refers_to(nexthop_table , nexthop_id) @name("nexthop_id") nexthop_id_t nexthop_id) { - routing_nexthop_id_valid = true; - routing_nexthop_id_value = nexthop_id; - } - @id(0x01000005) @name("ingress.routing.set_nexthop_id") action routing_set_nexthop_id_1(@id(1) @refers_to(nexthop_table , nexthop_id) @name("nexthop_id") nexthop_id_t nexthop_id_2) { - routing_nexthop_id_valid = true; - routing_nexthop_id_value = nexthop_id_2; - } - @id(0x01000005) @name("ingress.routing.set_nexthop_id") action routing_set_nexthop_id_2(@id(1) @refers_to(nexthop_table , nexthop_id) @name("nexthop_id") nexthop_id_t nexthop_id_3) { - routing_nexthop_id_valid = true; - routing_nexthop_id_value = nexthop_id_3; + size = 64; } - @id(0x01000010) @name("ingress.routing.set_nexthop_id_and_metadata") action routing_set_nexthop_id_and_metadata_0(@id(1) @refers_to(nexthop_table , nexthop_id) @name("nexthop_id") nexthop_id_t nexthop_id_4, @name("route_metadata") route_metadata_t route_metadata_2) { - routing_nexthop_id_valid = true; - routing_nexthop_id_value = nexthop_id_4; - local_metadata.route_metadata = route_metadata_2; + @sai_hash_seed(0) @id(0x010000A) @name("ingress.hashing.select_ecmp_hash_algorithm") action hashing_select_ecmp_hash_algorithm_0() { + hashing_seed = 32w0; } - @id(0x01000010) @name("ingress.routing.set_nexthop_id_and_metadata") action routing_set_nexthop_id_and_metadata_1(@id(1) @refers_to(nexthop_table , nexthop_id) @name("nexthop_id") nexthop_id_t nexthop_id_5, @name("route_metadata") route_metadata_t route_metadata_3) { - routing_nexthop_id_valid = true; - routing_nexthop_id_value = nexthop_id_5; - local_metadata.route_metadata = route_metadata_3; + @sai_ecmp_hash(SAI_SWITCH_ATTR_ECMP_HASH_IPV4) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_SRC_IPV4) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_DST_IPV4) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_SRC_PORT) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_DST_PORT) @id(0x0100000B) @name("ingress.hashing.compute_ecmp_hash_ipv4") action hashing_compute_ecmp_hash_ipv4_0() { + hash, bit<1>, tuple, bit<32>, bit<32>, bit<16>, bit<16>>, bit<17>>(local_metadata.wcmp_selector_input, HashAlgorithm.crc32, 1w0, { hashing_seed, headers.ipv4.src_addr, headers.ipv4.dst_addr, local_metadata.l4_src_port, local_metadata.l4_dst_port }, 17w0x10000); + local_metadata.wcmp_selector_input = local_metadata.wcmp_selector_input >> hashing_offset | local_metadata.wcmp_selector_input << 8w8 - hashing_offset; } - @max_group_size(256) @name("ingress.routing.wcmp_group_selector") action_selector(HashAlgorithm.identity, 32w65536, 32w16) routing_wcmp_group_selector; - @p4runtime_role("sdn_controller") @id(0x02000043) @oneshot @name("ingress.routing.wcmp_group_table") table routing_wcmp_group_table { - key = { - routing_wcmp_group_id_value : exact @id(1) @name("wcmp_group_id"); - local_metadata.wcmp_selector_input: selector @name("local_metadata.wcmp_selector_input"); - } - actions = { - @proto_id(1) routing_set_nexthop_id_0(); - @defaultonly NoAction_6(); - } - const default_action = NoAction_6(); - @id(0x11DC4EC8) implementation = routing_wcmp_group_selector; - size = 3968; + @sai_ecmp_hash(SAI_SWITCH_ATTR_ECMP_HASH_IPV6) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_SRC_IPV6) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_DST_IPV6) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_SRC_PORT) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_DST_PORT) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_IPV6_FLOW_LABEL) @id(0x0100000C) @name("ingress.hashing.compute_ecmp_hash_ipv6") action hashing_compute_ecmp_hash_ipv6_0() { + hash, bit<1>, tuple, bit<20>, bit<128>, bit<128>, bit<16>, bit<16>>, bit<17>>(local_metadata.wcmp_selector_input, HashAlgorithm.crc32, 1w0, { hashing_seed, headers.ipv6.flow_label, headers.ipv6.src_addr, headers.ipv6.dst_addr, local_metadata.l4_src_port, local_metadata.l4_dst_port }, 17w0x10000); + local_metadata.wcmp_selector_input = local_metadata.wcmp_selector_input >> hashing_offset | local_metadata.wcmp_selector_input << 8w8 - hashing_offset; } - @name("ingress.routing.no_action") action routing_no_action_0() { + @id(0x01798B9E) @name("ingress.routing_lookup.no_action") action routing_lookup_no_action_0() { } @entry_restriction(" // The VRF ID 0 (or '' in P4Runtime) encodes the default VRF, which cannot @@ -461,137 +615,198 @@ control ingress(inout headers_t headers, inout local_metadata_t local_metadata, // constraints are a control plane (P4Runtime) concept), but // p4-constraints does not currently support strings. vrf_id != 0; - ") @p4runtime_role("sdn_controller") @id(0x0200004A) @name("ingress.routing.vrf_table") table routing_vrf_table { + ") @p4runtime_role("sdn_controller") @id(0x0200004A) @name("ingress.routing_lookup.vrf_table") table routing_lookup_vrf_table { key = { local_metadata.vrf_id: exact @id(1) @name("vrf_id"); } actions = { - @proto_id(1) routing_no_action_0(); + @proto_id(1) routing_lookup_no_action_0(); } - const default_action = routing_no_action_0(); + const default_action = routing_lookup_no_action_0(); size = 64; } - @id(0x01000006) @name("ingress.routing.drop") action routing_drop_0() { + @id(0x01000006) @name("ingress.routing_lookup.drop") action routing_lookup_drop_0() { mark_to_drop(standard_metadata); } - @id(0x01000006) @name("ingress.routing.drop") action routing_drop_1() { + @id(0x01000006) @name("ingress.routing_lookup.drop") action routing_lookup_drop_1() { mark_to_drop(standard_metadata); } - @id(0x01000004) @name("ingress.routing.set_wcmp_group_id") action routing_set_wcmp_group_id_0(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) @name("wcmp_group_id") wcmp_group_id_t wcmp_group_id) { - routing_wcmp_group_id_valid = true; - routing_wcmp_group_id_value = wcmp_group_id; + @id(0x01000004) @name("ingress.routing_lookup.set_wcmp_group_id") action routing_lookup_set_wcmp_group_id_0(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) @name("wcmp_group_id") wcmp_group_id_t wcmp_group_id) { + local_metadata.wcmp_group_id_valid = true; + local_metadata.wcmp_group_id_value = wcmp_group_id; } - @id(0x01000004) @name("ingress.routing.set_wcmp_group_id") action routing_set_wcmp_group_id_1(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) @name("wcmp_group_id") wcmp_group_id_t wcmp_group_id_2) { - routing_wcmp_group_id_valid = true; - routing_wcmp_group_id_value = wcmp_group_id_2; + @id(0x01000004) @name("ingress.routing_lookup.set_wcmp_group_id") action routing_lookup_set_wcmp_group_id_1(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) @name("wcmp_group_id") wcmp_group_id_t wcmp_group_id_2) { + local_metadata.wcmp_group_id_valid = true; + local_metadata.wcmp_group_id_value = wcmp_group_id_2; } - @id(0x01000011) @name("ingress.routing.set_wcmp_group_id_and_metadata") action routing_set_wcmp_group_id_and_metadata_0(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) @name("wcmp_group_id") wcmp_group_id_t wcmp_group_id_3, @name("route_metadata") route_metadata_t route_metadata_4) { + @id(0x01000011) @name("ingress.routing_lookup.set_wcmp_group_id_and_metadata") action routing_lookup_set_wcmp_group_id_and_metadata_0(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) @name("wcmp_group_id") wcmp_group_id_t wcmp_group_id_3, @name("route_metadata") route_metadata_t route_metadata_3) { @id(0x01000004) { - routing_wcmp_group_id_valid = true; - routing_wcmp_group_id_value = wcmp_group_id_3; + local_metadata.wcmp_group_id_valid = true; + local_metadata.wcmp_group_id_value = wcmp_group_id_3; } - local_metadata.route_metadata = route_metadata_4; + local_metadata.route_metadata = route_metadata_3; } - @id(0x01000011) @name("ingress.routing.set_wcmp_group_id_and_metadata") action routing_set_wcmp_group_id_and_metadata_1(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) @name("wcmp_group_id") wcmp_group_id_t wcmp_group_id_4, @name("route_metadata") route_metadata_t route_metadata_5) { + @id(0x01000011) @name("ingress.routing_lookup.set_wcmp_group_id_and_metadata") action routing_lookup_set_wcmp_group_id_and_metadata_1(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) @name("wcmp_group_id") wcmp_group_id_t wcmp_group_id_4, @name("route_metadata") route_metadata_t route_metadata_4) { @id(0x01000004) { - routing_wcmp_group_id_valid = true; - routing_wcmp_group_id_value = wcmp_group_id_4; + local_metadata.wcmp_group_id_valid = true; + local_metadata.wcmp_group_id_value = wcmp_group_id_4; } - local_metadata.route_metadata = route_metadata_5; + local_metadata.route_metadata = route_metadata_4; } - @id(0x0100000F) @name("ingress.routing.trap") action routing_trap_0() { - clone(CloneType.I2E, 32w1024); + @id(0x01000015) @name("ingress.routing_lookup.set_metadata_and_drop") action routing_lookup_set_metadata_and_drop_0(@id(1) @name("route_metadata") route_metadata_t route_metadata_5) { + local_metadata.route_metadata = route_metadata_5; mark_to_drop(standard_metadata); } - @id(0x0100000F) @name("ingress.routing.trap") action routing_trap_1() { - clone(CloneType.I2E, 32w1024); + @id(0x01000015) @name("ingress.routing_lookup.set_metadata_and_drop") action routing_lookup_set_metadata_and_drop_1(@id(1) @name("route_metadata") route_metadata_t route_metadata_6) { + local_metadata.route_metadata = route_metadata_6; mark_to_drop(standard_metadata); } - @p4runtime_role("sdn_controller") @id(0x02000044) @name("ingress.routing.ipv4_table") table routing_ipv4_table { + @id(0x01000010) @name("ingress.routing_lookup.set_nexthop_id_and_metadata") action routing_lookup_set_nexthop_id_and_metadata_0(@id(1) @refers_to(nexthop_table , nexthop_id) @name("nexthop_id") nexthop_id_t nexthop_id_5, @name("route_metadata") route_metadata_t route_metadata_7) { + local_metadata.nexthop_id_valid = true; + local_metadata.nexthop_id_value = nexthop_id_5; + local_metadata.route_metadata = route_metadata_7; + } + @id(0x01000010) @name("ingress.routing_lookup.set_nexthop_id_and_metadata") action routing_lookup_set_nexthop_id_and_metadata_1(@id(1) @refers_to(nexthop_table , nexthop_id) @name("nexthop_id") nexthop_id_t nexthop_id_6, @name("route_metadata") route_metadata_t route_metadata_8) { + local_metadata.nexthop_id_valid = true; + local_metadata.nexthop_id_value = nexthop_id_6; + local_metadata.route_metadata = route_metadata_8; + } + @id(0x01000018) @action_restriction(" + // Disallow 0 since it encodes 'no multicast' in V1Model. + multicast_group_id != 0; + ") @name("ingress.routing_lookup.set_multicast_group_id") action routing_lookup_set_multicast_group_id_0(@id(1) @refers_to(builtin : : multicast_group_table , multicast_group_id) @name("multicast_group_id") multicast_group_id_t multicast_group_id) { + standard_metadata.mcast_grp = multicast_group_id; + } + @id(0x01000018) @action_restriction(" + // Disallow 0 since it encodes 'no multicast' in V1Model. + multicast_group_id != 0; + ") @name("ingress.routing_lookup.set_multicast_group_id") action routing_lookup_set_multicast_group_id_1(@id(1) @refers_to(builtin : : multicast_group_table , multicast_group_id) @name("multicast_group_id") multicast_group_id_t multicast_group_id_2) { + standard_metadata.mcast_grp = multicast_group_id_2; + } + @p4runtime_role("sdn_controller") @id(0x02000044) @name("ingress.routing_lookup.ipv4_table") table routing_lookup_ipv4_table { key = { local_metadata.vrf_id: exact @id(1) @name("vrf_id") @refers_to(vrf_table , vrf_id); - headers.ipv4.dst_addr: lpm @format(IPV4_ADDRESS) @id(2) @name("ipv4_dst"); + headers.ipv4.dst_addr: lpm @id(2) @name("ipv4_dst") @format(IPV4_ADDRESS); } actions = { - @proto_id(1) routing_drop_0(); - @proto_id(2) routing_set_nexthop_id_1(); - @proto_id(3) routing_set_wcmp_group_id_0(); - @proto_id(4) routing_trap_0(); - @proto_id(5) routing_set_nexthop_id_and_metadata_0(); - @proto_id(6) routing_set_wcmp_group_id_and_metadata_0(); + @proto_id(1) routing_lookup_drop_0(); + @proto_id(2) set_nexthop_id_1(); + @proto_id(3) routing_lookup_set_wcmp_group_id_0(); + @proto_id(5) routing_lookup_set_nexthop_id_and_metadata_0(); + @proto_id(6) routing_lookup_set_wcmp_group_id_and_metadata_0(); + @proto_id(7) routing_lookup_set_metadata_and_drop_0(); } - const default_action = routing_drop_0(); - size = 32768; + const default_action = routing_lookup_drop_0(); + size = 131072; } - @p4runtime_role("sdn_controller") @id(0x02000045) @name("ingress.routing.ipv6_table") table routing_ipv6_table { + @p4runtime_role("sdn_controller") @id(0x02000045) @name("ingress.routing_lookup.ipv6_table") table routing_lookup_ipv6_table { key = { local_metadata.vrf_id: exact @id(1) @name("vrf_id") @refers_to(vrf_table , vrf_id); - headers.ipv6.dst_addr: lpm @format(IPV6_ADDRESS) @id(2) @name("ipv6_dst"); + headers.ipv6.dst_addr: lpm @id(2) @name("ipv6_dst") @format(IPV6_ADDRESS); } actions = { - @proto_id(1) routing_drop_1(); - @proto_id(2) routing_set_nexthop_id_2(); - @proto_id(3) routing_set_wcmp_group_id_1(); - @proto_id(4) routing_trap_1(); - @proto_id(5) routing_set_nexthop_id_and_metadata_1(); - @proto_id(6) routing_set_wcmp_group_id_and_metadata_1(); + @proto_id(1) routing_lookup_drop_1(); + @proto_id(2) set_nexthop_id_2(); + @proto_id(3) routing_lookup_set_wcmp_group_id_1(); + @proto_id(5) routing_lookup_set_nexthop_id_and_metadata_1(); + @proto_id(6) routing_lookup_set_wcmp_group_id_and_metadata_1(); + @proto_id(7) routing_lookup_set_metadata_and_drop_1(); } - const default_action = routing_drop_1(); - size = 4096; + const default_action = routing_lookup_drop_1(); + size = 17000; } - @id(0x15000100) @name("ingress.acl_ingress.acl_ingress_meter") direct_meter(MeterType.bytes) acl_ingress_acl_ingress_meter; + @p4runtime_role("sdn_controller") @id(0x0200004E) @name("ingress.routing_lookup.ipv4_multicast_table") table routing_lookup_ipv4_multicast_table { + key = { + local_metadata.vrf_id: exact @id(1) @name("vrf_id") @refers_to(vrf_table , vrf_id); + headers.ipv4.dst_addr: exact @id(2) @name("ipv4_dst") @format(IPV4_ADDRESS); + } + actions = { + @proto_id(1) routing_lookup_set_multicast_group_id_0(); + @defaultonly NoAction_6(); + } + size = 1600; + default_action = NoAction_6(); + } + @p4runtime_role("sdn_controller") @id(0x0200004F) @name("ingress.routing_lookup.ipv6_multicast_table") table routing_lookup_ipv6_multicast_table { + key = { + local_metadata.vrf_id: exact @id(1) @name("vrf_id") @refers_to(vrf_table , vrf_id); + headers.ipv6.dst_addr: exact @id(2) @name("ipv6_dst") @format(IPV6_ADDRESS); + } + actions = { + @proto_id(1) routing_lookup_set_multicast_group_id_1(); + @defaultonly NoAction_7(); + } + size = 1600; + default_action = NoAction_7(); + } + @id(0x15000100) @mode(single_rate_two_color) @name("ingress.acl_ingress.acl_ingress_meter") direct_meter(MeterType.bytes) acl_ingress_acl_ingress_meter; + @id(0x15000102) @mode(single_rate_two_color) @name("ingress.acl_ingress.acl_ingress_qos_meter") direct_meter(MeterType.bytes) acl_ingress_acl_ingress_qos_meter; @id(0x13000102) @name("ingress.acl_ingress.acl_ingress_counter") direct_counter(CounterType.packets_and_bytes) acl_ingress_acl_ingress_counter; - @id(0x01000101) @sai_action(SAI_PACKET_ACTION_COPY , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_YELLOW) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_RED) @name("ingress.acl_ingress.acl_copy") action acl_ingress_acl_copy_0(@sai_action_param(QOS_QUEUE) @id(1) @name("qos_queue") qos_queue_t qos_queue) { + @id(0x13000107) @name("ingress.acl_ingress.acl_ingress_qos_counter") direct_counter(CounterType.packets_and_bytes) acl_ingress_acl_ingress_qos_counter; + @id(0x13000109) @name("ingress.acl_ingress.acl_ingress_counting_counter") direct_counter(CounterType.packets_and_bytes) acl_ingress_acl_ingress_counting_counter; + @id(0x1300010A) @name("ingress.acl_ingress.acl_ingress_security_counter") direct_counter(CounterType.packets_and_bytes) acl_ingress_acl_ingress_security_counter; + @id(0x01000101) @sai_action(SAI_PACKET_ACTION_COPY , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_RED) @name("ingress.acl_ingress.acl_copy") action acl_ingress_acl_copy_0(@sai_action_param(QOS_QUEUE) @id(1) @name("qos_queue") qos_queue_t qos_queue) { acl_ingress_acl_ingress_counter.count(); acl_ingress_acl_ingress_meter.read(local_metadata.color); - clone(CloneType.I2E, 32w1024); + local_metadata.marked_to_copy = true; } - @id(0x01000102) @sai_action(SAI_PACKET_ACTION_TRAP , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_YELLOW) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED) @name("ingress.acl_ingress.acl_trap") action acl_ingress_acl_trap_0(@sai_action_param(QOS_QUEUE) @id(1) @name("qos_queue") qos_queue_t qos_queue_3) { - @id(0x01000101) @sai_action(SAI_PACKET_ACTION_COPY , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_YELLOW) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_RED) { + @id(0x01000102) @sai_action(SAI_PACKET_ACTION_TRAP , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED) @name("ingress.acl_ingress.acl_trap") action acl_ingress_acl_trap_0(@sai_action_param(QOS_QUEUE) @id(1) @name("qos_queue") qos_queue_t qos_queue_2) { + @id(0x01000101) @sai_action(SAI_PACKET_ACTION_COPY , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_RED) { acl_ingress_acl_ingress_counter.count(); acl_ingress_acl_ingress_meter.read(local_metadata.color); - clone(CloneType.I2E, 32w1024); + local_metadata.marked_to_copy = true; } - mark_to_drop(standard_metadata); + local_metadata.acl_drop = true; } - @id(0x01000199) @sai_action(SAI_PACKET_ACTION_TRAP , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_YELLOW) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED) @name("ingress.acl_ingress.acl_experimental_trap") action acl_ingress_acl_experimental_trap_0(@sai_action_param(QOS_QUEUE) @id(1) @name("qos_queue") qos_queue_t qos_queue_4) { + @id(0x01000103) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED) @name("ingress.acl_ingress.acl_forward") action acl_ingress_acl_forward_0() { acl_ingress_acl_ingress_meter.read(local_metadata.color); - @id(0x01000102) @sai_action(SAI_PACKET_ACTION_TRAP , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_YELLOW) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED) { - @id(0x01000101) @sai_action(SAI_PACKET_ACTION_COPY , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_YELLOW) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_RED) { - acl_ingress_acl_ingress_counter.count(); - acl_ingress_acl_ingress_meter.read(local_metadata.color); - clone(CloneType.I2E, 32w1024); - } - mark_to_drop(standard_metadata); - } } - @id(0x01000103) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_YELLOW) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED) @name("ingress.acl_ingress.acl_forward") action acl_ingress_acl_forward_0() { - acl_ingress_acl_ingress_counter.count(); + @id(0x01000103) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED) @name("ingress.acl_ingress.acl_forward") action acl_ingress_acl_forward_1() { acl_ingress_acl_ingress_meter.read(local_metadata.color); } - @id(0x01000104) @sai_action(SAI_PACKET_ACTION_FORWARD) @name("ingress.acl_ingress.acl_mirror") action acl_ingress_acl_mirror_0(@id(1) @refers_to(mirror_session_table , mirror_session_id) @sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_MIRROR_INGRESS) @name("mirror_session_id") mirror_session_id_t mirror_session_id) { + @id(0x01000103) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED) @name("ingress.acl_ingress.acl_forward") action acl_ingress_acl_forward_2() { + acl_ingress_acl_ingress_meter.read(local_metadata.color); + } + @id(0x01000104) @sai_action(SAI_PACKET_ACTION_FORWARD) @name("ingress.acl_ingress.acl_mirror") action acl_ingress_acl_mirror_0(@id(1) @refers_to(mirror_session_table , mirror_session_id) @sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_MIRROR_INGRESS) @name("mirror_session_id") mirror_session_id_t mirror_session_id_1) { + acl_ingress_acl_ingress_counter.count(); + local_metadata.marked_to_mirror = true; + local_metadata.mirror_session_id = mirror_session_id_1; + } + @id(0x01000104) @sai_action(SAI_PACKET_ACTION_FORWARD) @name("ingress.acl_ingress.acl_mirror") action acl_ingress_acl_mirror_1(@id(1) @refers_to(mirror_session_table , mirror_session_id) @sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_MIRROR_INGRESS) @name("mirror_session_id") mirror_session_id_t mirror_session_id_2) { acl_ingress_acl_ingress_counter.count(); - local_metadata.mirror_session_id_valid = true; - local_metadata.mirror_session_id_value = mirror_session_id; + local_metadata.marked_to_mirror = true; + local_metadata.mirror_session_id = mirror_session_id_2; + } + @id(0x0100010F) @sai_action(SAI_PACKET_ACTION_DENY) @name("ingress.acl_ingress.acl_deny") action acl_ingress_acl_deny_0() { + acl_ingress_cancel_copy = true; + local_metadata.acl_drop = true; } - @p4runtime_role("sdn_controller") @id(0x02000100) @sai_acl(INGRESS) @entry_restriction(" + @p4runtime_role("sdn_controller") @id(0x02000100) @sai_acl(INGRESS) @sai_acl_priority(5) @entry_restriction(" // Forbid using ether_type for IP packets (by convention, use is_ip* instead). ether_type != 0x0800 && ether_type != 0x86dd; // Only allow IP field matches for IP packets. dst_ip::mask != 0 -> is_ipv4 == 1; + + src_ip::mask != 0 -> is_ipv4 == 1; + dst_ipv6::mask != 0 -> is_ipv6 == 1; + src_ipv6::mask != 0 -> is_ipv6 == 1; ttl::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + dscp::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); ecn::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + ip_protocol::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); // Only allow l4_dst_port and l4_src_port matches for TCP/UDP packets. + l4_src_port::mask != 0 -> (ip_protocol == 6 || ip_protocol == 17); + l4_dst_port::mask != 0 -> (ip_protocol == 6 || ip_protocol == 17); // Only allow arp_tpa matches for ARP packets. arp_tpa::mask != 0 -> ether_type == 0x0806; - // Only allow icmp_type matches for ICMP packets + @@ -605,187 +820,632 @@ control ingress(inout headers_t headers, inout local_metadata_t local_metadata, is_ipv6::mask != 0 -> (is_ipv6 == 1); ") @name("ingress.acl_ingress.acl_ingress_table") table acl_ingress_acl_ingress_table { key = { - headers.ipv4.isValid() || headers.ipv6.isValid(): optional @name("is_ip") @id(1) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); - headers.ipv4.isValid() : optional @name("is_ipv4") @id(2) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); - headers.ipv6.isValid() : optional @name("is_ipv6") @id(3) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); - headers.ethernet.ether_type : ternary @name("ether_type") @id(4) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ETHER_TYPE); - headers.ethernet.dst_addr : ternary @name("dst_mac") @id(5) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_MAC) @format(MAC_ADDRESS); - headers.ipv4.src_addr : ternary @name("src_ip") @id(6) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_SRC_IP) @format(IPV4_ADDRESS); - headers.ipv4.dst_addr : ternary @name("dst_ip") @id(7) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_IP) @format(IPV4_ADDRESS); - headers.ipv6.src_addr[127:64] : ternary @name("src_ipv6") @id(8) @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_SRC_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_SRC_IPV6_WORD2 )) @format(IPV6_ADDRESS); - headers.ipv6.dst_addr[127:64] : ternary @name("dst_ipv6") @id(9) @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD2 )) @format(IPV6_ADDRESS); - acl_ingress_ttl : ternary @name("ttl") @id(10) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_TTL); - acl_ingress_dscp : ternary @name("dscp") @id(11) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DSCP); - acl_ingress_ecn : ternary @name("ecn") @id(12) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ECN); - acl_ingress_ip_protocol : ternary @name("ip_protocol") @id(13) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IP_PROTOCOL); - headers.icmp.type : ternary @name("icmpv6_type") @id(14) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ICMPV6_TYPE); - local_metadata.l4_src_port : ternary @name("l4_src_port") @id(20) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_L4_SRC_PORT); - local_metadata.l4_dst_port : ternary @name("l4_dst_port") @id(15) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_L4_DST_PORT); - headers.arp.target_proto_addr : ternary @name("arp_tpa") @id(16) @composite_field(@ sai_udf ( base = SAI_UDF_BASE_L3 , offset = 24 , length = 2 ) , @ sai_udf ( base = SAI_UDF_BASE_L3 , offset = 26 , length = 2 )) @format(IPV4_ADDRESS); + headers.ipv4.isValid() || headers.ipv6.isValid(): optional @id(1) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(2) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(3) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + headers.ethernet.ether_type : ternary @id(4) @name("ether_type") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ETHER_TYPE); + headers.ethernet.dst_addr : ternary @id(5) @name("dst_mac") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_MAC) @format(MAC_ADDRESS); + headers.ipv4.src_addr : ternary @id(6) @name("src_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_SRC_IP) @format(IPV4_ADDRESS); + headers.ipv4.dst_addr : ternary @id(7) @name("dst_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_IP) @format(IPV4_ADDRESS); + headers.ipv6.src_addr[127:64] : ternary @id(8) @name("src_ipv6") @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_SRC_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_SRC_IPV6_WORD2 )) @format(IPV6_ADDRESS); + headers.ipv6.dst_addr[127:64] : ternary @id(9) @name("dst_ipv6") @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD2 )) @format(IPV6_ADDRESS); + acl_ingress_ttl : ternary @id(10) @name("ttl") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_TTL); + acl_ingress_dscp : ternary @id(11) @name("dscp") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DSCP); + acl_ingress_ecn : ternary @id(12) @name("ecn") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ECN); + acl_ingress_ip_protocol : ternary @id(13) @name("ip_protocol") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IP_PROTOCOL); + headers.icmp.type : ternary @id(14) @name("icmpv6_type") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ICMPV6_TYPE); + local_metadata.l4_src_port : ternary @id(20) @name("l4_src_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_L4_SRC_PORT); + local_metadata.l4_dst_port : ternary @id(15) @name("l4_dst_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_L4_DST_PORT); + headers.arp.target_proto_addr : ternary @id(16) @name("arp_tpa") @composite_field(@ sai_udf ( base = SAI_UDF_BASE_L3 , offset = 24 , length = 2 ) , @ sai_udf ( base = SAI_UDF_BASE_L3 , offset = 26 , length = 2 )) @format(IPV4_ADDRESS); } actions = { @proto_id(1) acl_ingress_acl_copy_0(); @proto_id(2) acl_ingress_acl_trap_0(); @proto_id(3) acl_ingress_acl_forward_0(); @proto_id(4) acl_ingress_acl_mirror_0(); - @proto_id(5) acl_drop_0(); - @proto_id(99) acl_ingress_acl_experimental_trap_0(); - @defaultonly NoAction_7(); + @proto_id(5) acl_drop_2(); + @defaultonly NoAction_8(); } - const default_action = NoAction_7(); + const default_action = NoAction_8(); meters = acl_ingress_acl_ingress_meter; counters = acl_ingress_acl_ingress_counter; - size = 128; - } - @id(0x01000007) @name("ingress.mirroring_clone.mirror_as_ipv4_erspan") action mirroring_clone_mirror_as_ipv4_erspan_0(@id(1) @name("port") port_id_t port_2, @id(2) @format(IPV4_ADDRESS) @name("src_ip") ipv4_addr_t src_ip, @id(3) @format(IPV4_ADDRESS) @name("dst_ip") ipv4_addr_t dst_ip, @id(4) @format(MAC_ADDRESS) @name("src_mac") ethernet_addr_t src_mac_3, @id(5) @format(MAC_ADDRESS) @name("dst_mac") ethernet_addr_t dst_mac_3, @id(6) @name("ttl") bit<8> ttl_0, @id(7) @name("tos") bit<8> tos) { - mirroring_clone_mirror_port = port_2; - local_metadata.mirroring_src_ip = src_ip; - local_metadata.mirroring_dst_ip = dst_ip; - local_metadata.mirroring_src_mac = src_mac_3; - local_metadata.mirroring_dst_mac = dst_mac_3; - local_metadata.mirroring_ttl = ttl_0; - local_metadata.mirroring_tos = tos; - } - @p4runtime_role("sdn_controller") @id(0x02000046) @name("ingress.mirroring_clone.mirror_session_table") table mirroring_clone_mirror_session_table { + size = 255; + } + @id(0x01000112) @name("ingress.acl_ingress.redirect_to_nexthop") action acl_ingress_redirect_to_nexthop_0(@sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_REDIRECT) @sai_action_param_object_type(SAI_OBJECT_TYPE_NEXT_HOP) @refers_to(nexthop_table , nexthop_id) @name("nexthop_id") nexthop_id_t nexthop_id_7) { + local_metadata.nexthop_id_valid = true; + local_metadata.nexthop_id_value = nexthop_id_7; + local_metadata.wcmp_group_id_valid = false; + standard_metadata.mcast_grp = 16w0; + } + @id(0x01000113) @action_restriction(" + // Disallow 0 since it encodes 'no multicast' in V1Model. + multicast_group_id != 0; + ") @name("ingress.acl_ingress.redirect_to_ipmc_group") action acl_ingress_redirect_to_ipmc_group_0(@sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_REDIRECT) @sai_action_param_object_type(SAI_OBJECT_TYPE_IPMC_GROUP) @refers_to(builtin : : multicast_group_table , multicast_group_id) @name("multicast_group_id") multicast_group_id_t multicast_group_id_3) { + standard_metadata.mcast_grp = multicast_group_id_3; + local_metadata.nexthop_id_valid = false; + local_metadata.wcmp_group_id_valid = false; + } + @id(0x0200010B) @sai_acl(INGRESS) @sai_acl_priority(15) @p4runtime_role("sdn_controller") @entry_restriction(" + // Only allow IP field matches for IP packets. + dst_ip::mask != 0 -> is_ipv4 == 1; + dst_ipv6::mask != 0 -> is_ipv6 == 1; + // Forbid illegal combinations of IP_TYPE fields. + is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0); + is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0); + is_ipv6::mask != 0 -> (is_ip::mask == 0 && is_ipv4::mask == 0); + // Forbid unsupported combinations of IP_TYPE fields. + is_ipv4::mask != 0 -> (is_ipv4 == 1); + is_ipv6::mask != 0 -> (is_ipv6 == 1); + ") @name("ingress.acl_ingress.acl_ingress_mirror_and_redirect_table") table acl_ingress_acl_ingress_mirror_and_redirect_table { key = { - local_metadata.mirror_session_id_value: exact @id(1) @name("mirror_session_id"); + headers.ipv4.isValid() || headers.ipv6.isValid(): optional @id(2) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(3) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(4) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + headers.ipv4.dst_addr : ternary @id(10) @name("dst_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_IP) @format(IPV4_ADDRESS); + headers.ipv6.dst_addr[127:64] : ternary @id(5) @name("dst_ipv6") @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD2 )) @format(IPV6_ADDRESS); + local_metadata.vrf_id : optional @id(8) @name("vrf_id") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_VRF_ID); + local_metadata.ipmc_table_hit : optional @id(9) @name("ipmc_table_hit") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IPMC_NPU_META_DST_HIT); } actions = { - @proto_id(1) mirroring_clone_mirror_as_ipv4_erspan_0(); - @defaultonly NoAction_8(); + @proto_id(4) acl_ingress_acl_forward_1(); + @proto_id(1) acl_ingress_acl_mirror_1(); + @proto_id(2) acl_ingress_redirect_to_nexthop_0(); + @proto_id(3) acl_ingress_redirect_to_ipmc_group_0(); + @defaultonly NoAction_9(); } - const default_action = NoAction_8(); - size = 2; + const default_action = NoAction_9(); + size = 255; } - @id(0x01000009) @name("ingress.mirroring_clone.set_pre_session") action mirroring_clone_set_pre_session_0(@name("id") bit<32> id) { - mirroring_clone_pre_session = id; + @id(0x0200010A) @sai_acl(INGRESS) @sai_acl_priority(20) @p4runtime_role("sdn_controller") @entry_restriction(" + // Forbid using ether_type for IP packets (by convention, use is_ip* instead). + ether_type != 0x0800 && ether_type != 0x86dd; + + // Only allow IP field matches for IP packets. + dst_ip::mask != 0 -> is_ipv4 == 1; + src_ip::mask != 0 -> is_ipv4 == 1; + src_ipv6::mask != 0 -> is_ipv6 == 1; + + // TODO: This comment is required for the preprocessor to not + // spit out nonsense. + + + + + + + + // Forbid illegal combinations of IP_TYPE fields. + is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0); + is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0); + is_ipv6::mask != 0 -> (is_ip::mask == 0 && is_ipv4::mask == 0); + // Forbid unsupported combinations of IP_TYPE fields. + is_ipv4::mask != 0 -> (is_ipv4 == 1); + is_ipv6::mask != 0 -> (is_ipv6 == 1); + ") @name("ingress.acl_ingress.acl_ingress_security_table") table acl_ingress_acl_ingress_security_table { + key = { + headers.ipv4.isValid() || headers.ipv6.isValid(): optional @id(1) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(2) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(3) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + headers.ethernet.ether_type : ternary @id(4) @name("ether_type") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ETHER_TYPE); + headers.ipv4.src_addr : ternary @id(5) @name("src_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_SRC_IP) @format(IPV4_ADDRESS); + headers.ipv4.dst_addr : ternary @id(6) @name("dst_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_IP) @format(IPV4_ADDRESS); + headers.ipv6.src_addr[127:64] : ternary @id(7) @name("src_ipv6") @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_SRC_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_SRC_IPV6_WORD2 )) @format(IPV6_ADDRESS); + } + actions = { + @proto_id(1) acl_ingress_acl_forward_2(); + @proto_id(2) acl_drop_3(); + @proto_id(3) acl_ingress_acl_deny_0(); + @defaultonly NoAction_10(); + } + const default_action = NoAction_10(); + counters = acl_ingress_acl_ingress_security_counter; + size = 255; } - @p4runtime_role("packet_replication_engine_manager") @id(0x02000048) @name("ingress.mirroring_clone.mirror_port_to_pre_session_table") table mirroring_clone_mirror_port_to_pre_session_table { + @id(0x01000001) @name("ingress.routing_resolution.set_dst_mac") action routing_resolution_set_dst_mac_0(@id(1) @format(MAC_ADDRESS) @name("dst_mac") ethernet_addr_t dst_mac_2) { + local_metadata.packet_rewrites.dst_mac = dst_mac_2; + } + @p4runtime_role("sdn_controller") @id(0x02000040) @name("ingress.routing_resolution.neighbor_table") table routing_resolution_neighbor_table { key = { - mirroring_clone_mirror_port: exact @id(1) @name("mirror_port"); + routing_resolution_router_interface_id_value: exact @id(1) @name("router_interface_id") @refers_to(router_interface_table , router_interface_id); + routing_resolution_neighbor_id_value : exact @id(2) @format(IPV6_ADDRESS) @name("neighbor_id"); } actions = { - @proto_id(1) mirroring_clone_set_pre_session_0(); - @defaultonly NoAction_9(); + @proto_id(1) routing_resolution_set_dst_mac_0(); + @defaultonly NoAction_11(); } - const default_action = NoAction_9(); + const default_action = NoAction_11(); + size = 1024; + } + @id(0x0100001B) @unsupported @action_restriction(" + // Disallow reserved VLAN IDs with implementation-defined semantics. + vlan_id != 0 && vlan_id != 4095") @name("ingress.routing_resolution.set_port_and_src_mac_and_vlan_id") action routing_resolution_set_port_and_src_mac_and_vlan_id_0(@id(1) @name("port") port_id_t port, @id(2) @format(MAC_ADDRESS) @name("src_mac") ethernet_addr_t src_mac_4, @id(3) @name("vlan_id") vlan_id_t vlan_id_1) { + standard_metadata.egress_spec = (bit<9>)port; + local_metadata.packet_rewrites.src_mac = src_mac_4; + local_metadata.packet_rewrites.vlan_id = vlan_id_1; + } + @id(0x01000002) @name("ingress.routing_resolution.set_port_and_src_mac") action routing_resolution_set_port_and_src_mac_0(@id(1) @name("port") port_id_t port_3, @id(2) @format(MAC_ADDRESS) @name("src_mac") ethernet_addr_t src_mac_5) { + @id(0x0100001B) @unsupported @action_restriction(" + // Disallow reserved VLAN IDs with implementation-defined semantics. + vlan_id != 0 && vlan_id != 4095") { + standard_metadata.egress_spec = (bit<9>)port_3; + local_metadata.packet_rewrites.src_mac = src_mac_5; + local_metadata.packet_rewrites.vlan_id = 12w0xfff; + } + } + @p4runtime_role("sdn_controller") @id(0x02000041) @name("ingress.routing_resolution.router_interface_table") table routing_resolution_router_interface_table { + key = { + routing_resolution_router_interface_id_value: exact @id(1) @name("router_interface_id"); + } + actions = { + @proto_id(1) routing_resolution_set_port_and_src_mac_0(); + @proto_id(2) routing_resolution_set_port_and_src_mac_and_vlan_id_0(); + @defaultonly NoAction_12(); + } + const default_action = NoAction_12(); + size = 256; + } + @id(0x01000017) @name("ingress.routing_resolution.set_ip_nexthop_and_disable_rewrites") action routing_resolution_set_ip_nexthop_and_disable_rewrites_0(@id(1) @refers_to(router_interface_table , router_interface_id) @refers_to(neighbor_table , router_interface_id) @name("router_interface_id") router_interface_id_t router_interface_id, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) @name("neighbor_id") ipv6_addr_t neighbor_id, @id(3) @name("disable_decrement_ttl") bit<1> disable_decrement_ttl, @id(4) @name("disable_src_mac_rewrite") bit<1> disable_src_mac_rewrite, @id(5) @name("disable_dst_mac_rewrite") bit<1> disable_dst_mac_rewrite, @id(6) @name("disable_vlan_rewrite") bit<1> disable_vlan_rewrite) { + routing_resolution_router_interface_id_valid = true; + routing_resolution_router_interface_id_value = router_interface_id; + routing_resolution_neighbor_id_valid = true; + routing_resolution_neighbor_id_value = neighbor_id; + local_metadata.enable_decrement_ttl = !(bool)disable_decrement_ttl; + local_metadata.enable_src_mac_rewrite = !(bool)disable_src_mac_rewrite; + local_metadata.enable_dst_mac_rewrite = !(bool)disable_dst_mac_rewrite; + local_metadata.enable_vlan_rewrite = !(bool)disable_vlan_rewrite; + } + @id(0x01000014) @name("ingress.routing_resolution.set_ip_nexthop") action routing_resolution_set_ip_nexthop_0(@id(1) @refers_to(router_interface_table , router_interface_id) @refers_to(neighbor_table , router_interface_id) @name("router_interface_id") router_interface_id_t router_interface_id_4, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) @name("neighbor_id") ipv6_addr_t neighbor_id_3) { + @id(0x01000017) { + routing_resolution_router_interface_id_valid = true; + routing_resolution_router_interface_id_value = router_interface_id_4; + routing_resolution_neighbor_id_valid = true; + routing_resolution_neighbor_id_value = neighbor_id_3; + local_metadata.enable_decrement_ttl = true; + local_metadata.enable_src_mac_rewrite = true; + local_metadata.enable_dst_mac_rewrite = true; + local_metadata.enable_vlan_rewrite = true; + } + } + @id(0x01000003) @deprecated("Use set_ip_nexthop instead.") @name("ingress.routing_resolution.set_nexthop") action routing_resolution_set_nexthop_0(@id(1) @refers_to(router_interface_table , router_interface_id) @refers_to(neighbor_table , router_interface_id) @name("router_interface_id") router_interface_id_t router_interface_id_5, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) @name("neighbor_id") ipv6_addr_t neighbor_id_4) { + @id(0x01000014) { + @id(0x01000017) { + routing_resolution_router_interface_id_valid = true; + routing_resolution_router_interface_id_value = router_interface_id_5; + routing_resolution_neighbor_id_valid = true; + routing_resolution_neighbor_id_value = neighbor_id_4; + local_metadata.enable_decrement_ttl = true; + local_metadata.enable_src_mac_rewrite = true; + local_metadata.enable_dst_mac_rewrite = true; + local_metadata.enable_vlan_rewrite = true; + } + } + } + @id(0x01000012) @name("ingress.routing_resolution.set_p2p_tunnel_encap_nexthop") action routing_resolution_set_p2p_tunnel_encap_nexthop_0(@id(1) @refers_to(tunnel_table , tunnel_id) @name("tunnel_id") tunnel_id_t tunnel_id) { + routing_resolution_tunnel_id_valid = true; + routing_resolution_tunnel_id_value = tunnel_id; + } + @p4runtime_role("sdn_controller") @id(0x02000042) @name("ingress.routing_resolution.nexthop_table") table routing_resolution_nexthop_table { + key = { + local_metadata.nexthop_id_value: exact @id(1) @name("nexthop_id"); + } + actions = { + @proto_id(1) routing_resolution_set_nexthop_0(); + @proto_id(2) routing_resolution_set_p2p_tunnel_encap_nexthop_0(); + @proto_id(3) routing_resolution_set_ip_nexthop_0(); + @proto_id(4) routing_resolution_set_ip_nexthop_and_disable_rewrites_0(); + @defaultonly NoAction_13(); + } + const default_action = NoAction_13(); + size = 1024; + } + @id(0x01000013) @name("ingress.routing_resolution.mark_for_p2p_tunnel_encap") action routing_resolution_mark_for_p2p_tunnel_encap_0(@id(1) @format(IPV6_ADDRESS) @name("encap_src_ip") ipv6_addr_t encap_src_ip, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) @name("encap_dst_ip") ipv6_addr_t encap_dst_ip, @id(3) @refers_to(neighbor_table , router_interface_id) @refers_to(router_interface_table , router_interface_id) @name("router_interface_id") router_interface_id_t router_interface_id_6) { + local_metadata.tunnel_encap_src_ipv6 = encap_src_ip; + local_metadata.tunnel_encap_dst_ipv6 = encap_dst_ip; + local_metadata.apply_tunnel_encap_at_egress = true; + @id(0x01000014) { + @id(0x01000017) { + routing_resolution_router_interface_id_valid = true; + routing_resolution_router_interface_id_value = router_interface_id_6; + routing_resolution_neighbor_id_valid = true; + routing_resolution_neighbor_id_value = encap_dst_ip; + local_metadata.enable_decrement_ttl = true; + local_metadata.enable_src_mac_rewrite = true; + local_metadata.enable_dst_mac_rewrite = true; + local_metadata.enable_vlan_rewrite = true; + } + } + } + @p4runtime_role("sdn_controller") @id(0x02000050) @name("ingress.routing_resolution.tunnel_table") table routing_resolution_tunnel_table { + key = { + routing_resolution_tunnel_id_value: exact @id(1) @name("tunnel_id"); + } + actions = { + @proto_id(1) routing_resolution_mark_for_p2p_tunnel_encap_0(); + @defaultonly NoAction_14(); + } + const default_action = NoAction_14(); + size = 2048; + } + @max_group_size(512) @id(0x11DC4EC8) @name("ingress.routing_resolution.wcmp_group_selector") action_selector(HashAlgorithm.identity, 32w49152, 32w8) routing_resolution_wcmp_group_selector; + @p4runtime_role("sdn_controller") @id(0x02000043) @oneshot @name("ingress.routing_resolution.wcmp_group_table") table routing_resolution_wcmp_group_table { + key = { + local_metadata.wcmp_group_id_value: exact @id(1) @name("wcmp_group_id"); + local_metadata.wcmp_selector_input: selector @name("local_metadata.wcmp_selector_input"); + } + actions = { + @proto_id(1) set_nexthop_id_3(); + @defaultonly NoAction_15(); + } + const default_action = NoAction_15(); + implementation = routing_resolution_wcmp_group_selector; + size = 3968; + } + @id(0x01000007) @name("ingress.mirror_session_lookup.mirror_as_ipv4_erspan") action mirror_session_lookup_mirror_as_ipv4_erspan_0(@id(1) @name("port") port_id_t port_4, @id(2) @format(IPV4_ADDRESS) @name("src_ip") ipv4_addr_t src_ip, @id(3) @format(IPV4_ADDRESS) @name("dst_ip") ipv4_addr_t dst_ip, @id(4) @format(MAC_ADDRESS) @name("src_mac") ethernet_addr_t src_mac_6, @id(5) @format(MAC_ADDRESS) @name("dst_mac") ethernet_addr_t dst_mac_3, @id(6) @name("ttl") bit<8> ttl_1, @id(7) @name("tos") bit<8> tos) { + } + @id(0x0100001D) @unsupported @name("ingress.mirror_session_lookup.mirror_with_vlan_tag_and_ipfix_encapsulation") action mirror_session_lookup_mirror_with_vlan_tag_and_ipfix_encapsulation_0(@id(1) @name("monitor_port") port_id_t monitor_port, @id(2) @name("monitor_failover_port") port_id_t monitor_failover_port, @id(3) @format(MAC_ADDRESS) @name("mirror_encap_src_mac") ethernet_addr_t mirror_encap_src_mac_1, @id(4) @format(MAC_ADDRESS) @name("mirror_encap_dst_mac") ethernet_addr_t mirror_encap_dst_mac_1, @id(6) @name("mirror_encap_vlan_id") vlan_id_t mirror_encap_vlan_id_1, @id(7) @format(IPV6_ADDRESS) @name("mirror_encap_dst_ip") ipv6_addr_t mirror_encap_dst_ip_1, @id(8) @format(IPV6_ADDRESS) @name("mirror_encap_src_ip") ipv6_addr_t mirror_encap_src_ip_1, @id(9) @name("mirror_encap_udp_src_port") bit<16> mirror_encap_udp_src_port_1, @id(10) @name("mirror_encap_udp_dst_port") bit<16> mirror_encap_udp_dst_port_1) { + local_metadata.mirror_egress_port = monitor_port; + local_metadata.mirror_encap_src_mac = mirror_encap_src_mac_1; + local_metadata.mirror_encap_dst_mac = mirror_encap_dst_mac_1; + local_metadata.mirror_encap_vlan_id = mirror_encap_vlan_id_1; + local_metadata.mirror_encap_src_ip = mirror_encap_src_ip_1; + local_metadata.mirror_encap_dst_ip = mirror_encap_dst_ip_1; + local_metadata.mirror_encap_udp_src_port = mirror_encap_udp_src_port_1; + local_metadata.mirror_encap_udp_dst_port = mirror_encap_udp_dst_port_1; + } + @p4runtime_role("sdn_controller") @id(0x02000046) @name("ingress.mirror_session_lookup.mirror_session_table") table mirror_session_lookup_mirror_session_table { + key = { + local_metadata.mirror_session_id: exact @id(1) @name("mirror_session_id"); + } + actions = { + @proto_id(1) mirror_session_lookup_mirror_as_ipv4_erspan_0(); + @proto_id(2) mirror_session_lookup_mirror_with_vlan_tag_and_ipfix_encapsulation_0(); + @defaultonly NoAction_16(); + } + const default_action = NoAction_16(); + size = 4; + } + @id(0x0100001C) @name("ingress.ingress_cloning.ingress_clone") action ingress_cloning_ingress_clone_0(@id(1) @name("clone_session") bit<32> clone_session) { + clone_preserving_field_list(CloneType.I2E, clone_session, PreservedFieldList.MIRROR_AND_PACKET_IN_COPY); + } + @unsupported @p4runtime_role("packet_replication_engine_manager") @id(0x02000051) @entry_restriction(" + // mirror_egress_port is present iff marked_to_mirror is true. + // Exact match indicating presence of mirror_egress_port. + marked_to_mirror == 1 -> mirror_egress_port::mask == -1; + // Wildcard match indicating abscence of mirror_egress_port. + marked_to_mirror == 0 -> mirror_egress_port::mask == 0; + ") @name("ingress.ingress_cloning.ingress_clone_table") table ingress_cloning_ingress_clone_table { + key = { + local_metadata.marked_to_copy : exact @id(1) @name("marked_to_copy"); + local_metadata.marked_to_mirror : exact @id(2) @name("marked_to_mirror"); + local_metadata.mirror_egress_port: optional @id(3) @name("mirror_egress_port"); + } + actions = { + @proto_id(1) ingress_cloning_ingress_clone_0(); + @defaultonly NoAction_17(); + } + default_action = NoAction_17(); } apply { - acl_pre_ingress_dscp = 6w0; - if (headers.ipv4.isValid()) { - acl_pre_ingress_dscp = headers.ipv4.dscp; - } else if (headers.ipv6.isValid()) { - acl_pre_ingress_dscp = headers.ipv6.dscp; + if (headers.packet_out_header.isValid() && headers.packet_out_header.submit_to_ingress == 1w0) { + standard_metadata.egress_spec = (bit<9>)headers.packet_out_header.egress_port; + local_metadata.bypass_ingress = true; } - local_metadata.vrf_id = (vrf_id_t)10w0; - acl_pre_ingress_acl_pre_ingress_table.apply(); - local_metadata.admit_to_l3 = headers.ethernet.dst_addr & 48w0x10000000000 == 48w0; - l3_admit_l3_admit_table.apply(); - routing_wcmp_group_id_valid = false; - routing_nexthop_id_valid = false; - routing_router_interface_id_valid = false; - routing_neighbor_id_valid = false; - mark_to_drop(standard_metadata); - routing_vrf_table.apply(); - if (local_metadata.admit_to_l3) { + headers.packet_out_header.setInvalid(); + if (local_metadata.bypass_ingress) { + ; + } else { + if (headers.ipv6.isValid()) { + if (headers.ipv6.next_header == 8w0x4 || headers.ipv6.next_header == 8w0x29) { + tunnel_termination_lookup_ipv6_tunnel_termination_table.apply(); + } + } + if (headers.vlan.isValid()) { + local_metadata.vlan_id = headers.vlan.vlan_id; + headers.ethernet.ether_type = headers.vlan.ether_type; + headers.vlan.setInvalid(); + } else { + local_metadata.vlan_id = 12w0xfff; + } + local_metadata.enable_vlan_checks = true; + vlan_untag_disable_vlan_checks_table.apply(); + acl_pre_ingress_dscp = 6w0; + acl_pre_ingress_ecn = 2w0; if (headers.ipv4.isValid()) { - routing_ipv4_table.apply(); + acl_pre_ingress_dscp = headers.ipv4.dscp; + acl_pre_ingress_ecn = headers.ipv4.ecn; } else if (headers.ipv6.isValid()) { - routing_ipv6_table.apply(); + acl_pre_ingress_dscp = headers.ipv6.dscp; + acl_pre_ingress_ecn = headers.ipv6.ecn; } - if (routing_wcmp_group_id_valid) { - routing_wcmp_group_table.apply(); + acl_pre_ingress_acl_pre_ingress_table.apply(); + if (local_metadata.enable_vlan_checks && !(local_metadata.vlan_id == 12w0x0 || local_metadata.vlan_id == 12w0xfff)) { + mark_to_drop(standard_metadata); } - if (routing_nexthop_id_valid) { - routing_nexthop_table.apply(); - if (routing_router_interface_id_valid && routing_neighbor_id_valid) { - routing_router_interface_table.apply(); - routing_neighbor_table.apply(); + if (local_metadata.apply_tunnel_decap_at_end_of_pre_ingress) { + assert(headers.ipv6.isValid()); + assert(headers.inner_ipv4.isValid() && !headers.inner_ipv6.isValid() || !headers.inner_ipv4.isValid() && headers.inner_ipv6.isValid()); + headers.ipv6.setInvalid(); + if (headers.inner_ipv4.isValid()) { + headers.ethernet.ether_type = 16w0x800; + headers.ipv4 = headers.inner_ipv4; + headers.inner_ipv4.setInvalid(); + } + if (headers.inner_ipv6.isValid()) { + headers.ethernet.ether_type = 16w0x86dd; + headers.ipv6 = headers.inner_ipv6; + headers.inner_ipv6.setInvalid(); } } - } - acl_ingress_ttl = 8w0; - acl_ingress_dscp = 6w0; - acl_ingress_ecn = 2w0; - acl_ingress_ip_protocol = 8w0; - if (headers.ipv4.isValid()) { - acl_ingress_ttl = headers.ipv4.ttl; - acl_ingress_dscp = headers.ipv4.dscp; - acl_ingress_ecn = headers.ipv4.ecn; - acl_ingress_ip_protocol = headers.ipv4.protocol; - } else if (headers.ipv6.isValid()) { - acl_ingress_ttl = headers.ipv6.hop_limit; - acl_ingress_dscp = headers.ipv6.dscp; - acl_ingress_ecn = headers.ipv6.ecn; - acl_ingress_ip_protocol = headers.ipv6.next_header; - } - acl_ingress_acl_ingress_table.apply(); - if (local_metadata.admit_to_l3) { + local_metadata.admit_to_l3 = headers.ethernet.dst_addr == 48w0x1a11175f80; + if (local_metadata.enable_vlan_checks && !(local_metadata.vlan_id == 12w0x0 || local_metadata.vlan_id == 12w0xfff)) { + local_metadata.admit_to_l3 = false; + } else { + l3_admit_l3_admit_table.apply(); + } + hashing_offset = 8w0; + hashing_select_ecmp_hash_algorithm_0(); if (headers.ipv4.isValid()) { - if (headers.ipv4.ttl <= 8w1) { - mark_to_drop(standard_metadata); - } else { - headers.ipv4.ttl = headers.ipv4.ttl + 8w255; - } + hashing_compute_ecmp_hash_ipv4_0(); + } else if (headers.ipv6.isValid()) { + hashing_compute_ecmp_hash_ipv6_0(); } - if (headers.ipv6.isValid()) { - if (headers.ipv6.hop_limit <= 8w1) { - mark_to_drop(standard_metadata); - } else { - headers.ipv6.hop_limit = headers.ipv6.hop_limit + 8w255; + mark_to_drop(standard_metadata); + routing_lookup_vrf_table.apply(); + if (local_metadata.admit_to_l3) { + if (headers.ipv4.isValid()) { + routing_lookup_ipv4_table.apply(); + routing_lookup_ipv4_multicast_table.apply(); + local_metadata.ipmc_table_hit = standard_metadata.mcast_grp != 16w0; + } else if (headers.ipv6.isValid()) { + routing_lookup_ipv6_table.apply(); + routing_lookup_ipv6_multicast_table.apply(); + local_metadata.ipmc_table_hit = standard_metadata.mcast_grp != 16w0; } } - } - if (local_metadata.mirror_session_id_valid) { - if (mirroring_clone_mirror_session_table.apply().hit) { - if (mirroring_clone_mirror_port_to_pre_session_table.apply().hit) { - clone_preserving_field_list(CloneType.I2E, mirroring_clone_pre_session, 8w1); + acl_ingress_ttl = 8w0; + acl_ingress_dscp = 6w0; + acl_ingress_ecn = 2w0; + acl_ingress_ip_protocol = 8w0; + acl_ingress_cancel_copy = false; + if (headers.ipv4.isValid()) { + acl_ingress_ttl = headers.ipv4.ttl; + acl_ingress_dscp = headers.ipv4.dscp; + acl_ingress_ecn = headers.ipv4.ecn; + acl_ingress_ip_protocol = headers.ipv4.protocol; + } else if (headers.ipv6.isValid()) { + acl_ingress_ttl = headers.ipv6.hop_limit; + acl_ingress_dscp = headers.ipv6.dscp; + acl_ingress_ecn = headers.ipv6.ecn; + acl_ingress_ip_protocol = headers.ipv6.next_header; + } + acl_ingress_acl_ingress_table.apply(); + acl_ingress_acl_ingress_mirror_and_redirect_table.apply(); + acl_ingress_acl_ingress_security_table.apply(); + if (acl_ingress_cancel_copy) { + local_metadata.marked_to_copy = false; + } + routing_resolution_tunnel_id_valid = false; + routing_resolution_router_interface_id_valid = false; + routing_resolution_neighbor_id_valid = false; + if (local_metadata.admit_to_l3) { + if (local_metadata.wcmp_group_id_valid) { + routing_resolution_wcmp_group_table.apply(); + } + if (local_metadata.nexthop_id_valid) { + routing_resolution_nexthop_table.apply(); + if (routing_resolution_tunnel_id_valid) { + routing_resolution_tunnel_table.apply(); + } + if (routing_resolution_router_interface_id_valid && routing_resolution_neighbor_id_valid) { + routing_resolution_router_interface_table.apply(); + routing_resolution_neighbor_table.apply(); + } } } + local_metadata.packet_in_target_egress_port = standard_metadata.egress_spec; + local_metadata.packet_in_ingress_port = standard_metadata.ingress_port; + if (local_metadata.acl_drop) { + mark_to_drop(standard_metadata); + } + if (local_metadata.marked_to_mirror) { + mirror_session_lookup_mirror_session_table.apply(); + } + ingress_cloning_ingress_clone_table.apply(); + if (headers.ipv6.isValid() && (headers.ipv6.src_addr & 128w0xff000000000000000000000000000000 == 128w0xff000000000000000000000000000000 || headers.ipv6.dst_addr & 128w0xff000000000000000000000000000000 == 128w0xff000000000000000000000000000000 || headers.ipv6.src_addr == 128w0x1 || headers.ipv6.dst_addr == 128w0x1) || headers.ipv4.isValid() && (headers.ipv4.src_addr & 32w0xf0000000 == 32w0xe0000000 || headers.ipv4.src_addr == 32w0xffffffff || (headers.ipv4.dst_addr & 32w0xf0000000 == 32w0xe0000000 || headers.ipv4.dst_addr == 32w0xffffffff) || headers.ipv4.src_addr & 32w0xff000000 == 32w0x7f000000 || headers.ipv4.dst_addr & 32w0xff000000 == 32w0x7f000000) || headers.ethernet.isValid() && headers.ethernet.dst_addr & 48w0x10000000000 == 48w0x10000000000) { + mark_to_drop(standard_metadata); + } } } } control egress(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { + @name("egress.packet_rewrites.multicast_rewrites.multicast_replica_port") port_id_t packet_rewrites_multicast_rewrites_multicast_replica_port; + @name("egress.packet_rewrites.multicast_rewrites.multicast_replica_instance") replica_instance_t packet_rewrites_multicast_rewrites_multicast_replica_instance; + @name("egress.acl_egress.ip_protocol") bit<8> acl_egress_ip_protocol; + @name("egress.local_metadata") local_metadata_t local_metadata_11; + @noWarn("unused") @name(".NoAction") action NoAction_18() { + } + @noWarn("unused") @name(".NoAction") action NoAction_19() { + } + @id(0x01000109) @sai_action(SAI_PACKET_ACTION_DROP) @name(".acl_drop") action acl_drop_4() { + local_metadata_11 = local_metadata; + local_metadata_11.acl_drop = true; + local_metadata = local_metadata_11; + } + @id(0x01000019) @name("egress.packet_rewrites.multicast_rewrites.set_multicast_src_mac") action packet_rewrites_multicast_rewrites_set_multicast_src_mac_0(@id(1) @format(MAC_ADDRESS) @name("src_mac") ethernet_addr_t src_mac_7) { + local_metadata.enable_src_mac_rewrite = true; + local_metadata.packet_rewrites.src_mac = src_mac_7; + } + @p4runtime_role("sdn_controller") @id(0x0200004C) @name("egress.packet_rewrites.multicast_rewrites.multicast_router_interface_table") table packet_rewrites_multicast_rewrites_multicast_router_interface_table { + key = { + packet_rewrites_multicast_rewrites_multicast_replica_port : exact @referenced_by(builtin : : multicast_group_table , replica . port) @id(1) @name("multicast_replica_port"); + packet_rewrites_multicast_rewrites_multicast_replica_instance: exact @referenced_by(builtin : : multicast_group_table , replica . instance) @id(2) @name("multicast_replica_instance"); + } + actions = { + @proto_id(1) packet_rewrites_multicast_rewrites_set_multicast_src_mac_0(); + @defaultonly NoAction_18(); + } + size = 110; + default_action = NoAction_18(); + } + @id(0x13000104) @name("egress.acl_egress.acl_egress_counter") direct_counter(CounterType.packets_and_bytes) acl_egress_acl_egress_counter; + @id(0x13000108) @name("egress.acl_egress.acl_egress_dhcp_to_host_counter") direct_counter(CounterType.packets_and_bytes) acl_egress_acl_egress_dhcp_to_host_counter; + @p4runtime_role("sdn_controller") @id(0x02000104) @sai_acl(EGRESS) @entry_restriction(" + + + + + + // Only allow IP field matches for IP packets. + ip_protocol::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + + + + + + + + // Forbid illegal combinations of IP_TYPE fields. + is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0); + is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0); + is_ipv6::mask != 0 -> (is_ip::mask == 0 && is_ipv4::mask == 0); + // Forbid unsupported combinations of IP_TYPE fields. + is_ipv4::mask != 0 -> (is_ipv4 == 1); + is_ipv6::mask != 0 -> (is_ipv6 == 1); + ") @name("egress.acl_egress.acl_egress_table") table acl_egress_acl_egress_table { + key = { + acl_egress_ip_protocol : ternary @id(2) @name("ip_protocol") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IP_PROTOCOL); + (port_id_t)standard_metadata.egress_port : optional @id(4) @name("out_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_OUT_PORT); + headers.ipv4.isValid() || headers.ipv6.isValid(): optional @id(5) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(6) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(7) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + headers.ethernet.src_addr : ternary @id(10) @name("src_mac") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_SRC_MAC) @format(MAC_ADDRESS); + } + actions = { + @proto_id(1) acl_drop_4(); + @defaultonly NoAction_19(); + } + const default_action = NoAction_19(); + counters = acl_egress_acl_egress_counter; + size = 127; + } apply { - if (local_metadata.admit_to_l3) { - headers.ethernet.src_addr = local_metadata.packet_rewrites.src_mac; - headers.ethernet.dst_addr = local_metadata.packet_rewrites.dst_mac; - } - if (standard_metadata.instance_type == 32w1) { - headers.erspan_ethernet.setValid(); - headers.erspan_ethernet.src_addr = local_metadata.mirroring_src_mac; - headers.erspan_ethernet.dst_addr = local_metadata.mirroring_dst_mac; - headers.erspan_ethernet.ether_type = 16w0x800; - headers.erspan_ipv4.setValid(); - headers.erspan_ipv4.src_addr = local_metadata.mirroring_src_ip; - headers.erspan_ipv4.dst_addr = local_metadata.mirroring_dst_ip; - headers.erspan_ipv4.version = 4w4; - headers.erspan_ipv4.ihl = 4w5; - headers.erspan_ipv4.protocol = 8w0x2f; - headers.erspan_ipv4.ttl = local_metadata.mirroring_ttl; - headers.erspan_ipv4.dscp = local_metadata.mirroring_tos[7:2]; - headers.erspan_ipv4.ecn = local_metadata.mirroring_tos[1:0]; - headers.erspan_ipv4.total_len = 16w24 + (bit<16>)standard_metadata.packet_length; - headers.erspan_ipv4.identification = 16w0; - headers.erspan_ipv4.reserved = 1w0; - headers.erspan_ipv4.do_not_fragment = 1w1; - headers.erspan_ipv4.more_fragments = 1w0; - headers.erspan_ipv4.frag_offset = 13w0; - headers.erspan_ipv4.header_checksum = 16w0; - headers.erspan_gre.setValid(); - headers.erspan_gre.checksum_present = 1w0; - headers.erspan_gre.routing_present = 1w0; - headers.erspan_gre.key_present = 1w0; - headers.erspan_gre.sequence_present = 1w0; - headers.erspan_gre.strict_source_route = 1w0; - headers.erspan_gre.recursion_control = 3w0; - headers.erspan_gre.acknowledgement_present = 1w0; - headers.erspan_gre.flags = 4w0; - headers.erspan_gre.version = 3w0; - headers.erspan_gre.protocol = 16w0x88be; + if (standard_metadata.instance_type == 32w1 && standard_metadata.egress_rid == 16w1) { + ; + } else { + if (standard_metadata.instance_type == 32w5) { + local_metadata.enable_decrement_ttl = true; + packet_rewrites_multicast_rewrites_multicast_replica_port = (port_id_t)standard_metadata.egress_port; + packet_rewrites_multicast_rewrites_multicast_replica_instance = standard_metadata.egress_rid; + packet_rewrites_multicast_rewrites_multicast_router_interface_table.apply(); + } + if (local_metadata.enable_src_mac_rewrite) { + headers.ethernet.src_addr = local_metadata.packet_rewrites.src_mac; + } + if (local_metadata.enable_dst_mac_rewrite) { + headers.ethernet.dst_addr = local_metadata.packet_rewrites.dst_mac; + } + if (local_metadata.enable_vlan_rewrite) { + local_metadata.vlan_id = local_metadata.packet_rewrites.vlan_id; + } + if (headers.ipv4.isValid()) { + if (headers.ipv4.ttl > 8w0 && local_metadata.enable_decrement_ttl) { + headers.ipv4.ttl = headers.ipv4.ttl + 8w255; + } + if (headers.ipv4.ttl == 8w0) { + mark_to_drop(standard_metadata); + } + } + if (headers.ipv6.isValid()) { + if (headers.ipv6.hop_limit > 8w0 && local_metadata.enable_decrement_ttl) { + headers.ipv6.hop_limit = headers.ipv6.hop_limit + 8w255; + } + if (headers.ipv6.hop_limit == 8w0) { + mark_to_drop(standard_metadata); + } + } + if (local_metadata.apply_tunnel_encap_at_egress) { + headers.tunnel_encap_gre.setValid(); + headers.tunnel_encap_gre.checksum_present = 1w0; + headers.tunnel_encap_gre.routing_present = 1w0; + headers.tunnel_encap_gre.key_present = 1w0; + headers.tunnel_encap_gre.sequence_present = 1w0; + headers.tunnel_encap_gre.strict_source_route = 1w0; + headers.tunnel_encap_gre.recursion_control = 3w0; + headers.tunnel_encap_gre.flags = 4w0; + headers.tunnel_encap_gre.version = 3w0; + headers.tunnel_encap_gre.protocol = headers.ethernet.ether_type; + headers.ethernet.ether_type = 16w0x86dd; + headers.tunnel_encap_ipv6.setValid(); + headers.tunnel_encap_ipv6.version = 4w6; + headers.tunnel_encap_ipv6.src_addr = local_metadata.tunnel_encap_src_ipv6; + headers.tunnel_encap_ipv6.dst_addr = local_metadata.tunnel_encap_dst_ipv6; + headers.tunnel_encap_ipv6.payload_length = (bit<16>)standard_metadata.packet_length + 16w65526; + headers.tunnel_encap_ipv6.next_header = 8w0x2f; + if (headers.ipv4.isValid()) { + headers.tunnel_encap_ipv6.dscp = headers.ipv4.dscp; + headers.tunnel_encap_ipv6.ecn = headers.ipv4.ecn; + headers.tunnel_encap_ipv6.hop_limit = headers.ipv4.ttl; + } else if (headers.ipv6.isValid()) { + headers.tunnel_encap_ipv6.dscp = headers.ipv6.dscp; + headers.tunnel_encap_ipv6.ecn = headers.ipv6.ecn; + headers.tunnel_encap_ipv6.hop_limit = headers.ipv6.hop_limit; + } + } + if (standard_metadata.instance_type == 32w1 && standard_metadata.egress_rid == 16w2) { + headers.mirror_encap_ethernet.setValid(); + headers.mirror_encap_ethernet.src_addr = local_metadata.mirror_encap_src_mac; + headers.mirror_encap_ethernet.dst_addr = local_metadata.mirror_encap_dst_mac; + headers.mirror_encap_ethernet.ether_type = 16w0x8100; + headers.mirror_encap_vlan.setValid(); + headers.mirror_encap_vlan.ether_type = 16w0x86dd; + headers.mirror_encap_vlan.vlan_id = local_metadata.mirror_encap_vlan_id; + headers.mirror_encap_ipv6.setValid(); + headers.mirror_encap_ipv6.version = 4w6; + headers.mirror_encap_ipv6.dscp = 6w0; + headers.mirror_encap_ipv6.ecn = 2w0; + headers.mirror_encap_ipv6.hop_limit = 8w16; + headers.mirror_encap_ipv6.flow_label = 20w0; + headers.mirror_encap_ipv6.payload_length = (bit<16>)standard_metadata.packet_length + 16w52; + headers.mirror_encap_ipv6.next_header = 8w0x11; + headers.mirror_encap_ipv6.src_addr = local_metadata.mirror_encap_src_ip; + headers.mirror_encap_ipv6.dst_addr = local_metadata.mirror_encap_dst_ip; + headers.mirror_encap_udp.setValid(); + headers.mirror_encap_udp.src_port = local_metadata.mirror_encap_udp_src_port; + headers.mirror_encap_udp.dst_port = local_metadata.mirror_encap_udp_dst_port; + headers.mirror_encap_udp.hdr_length = headers.mirror_encap_ipv6.payload_length; + headers.mirror_encap_udp.checksum = 16w0; + headers.ipfix.setValid(); + headers.psamp_extended.setValid(); + } + if (local_metadata.enable_vlan_checks) { + if (standard_metadata.instance_type == 32w1 && standard_metadata.egress_rid == 16w2 && !(local_metadata.mirror_encap_vlan_id == 12w0x0 || local_metadata.mirror_encap_vlan_id == 12w0xfff)) { + mark_to_drop(standard_metadata); + } else if (!(standard_metadata.instance_type == 32w1 && standard_metadata.egress_rid == 16w1) && !(local_metadata.vlan_id == 12w0x0 || local_metadata.vlan_id == 12w0xfff)) { + mark_to_drop(standard_metadata); + } + } + if (!(local_metadata.vlan_id == 12w0x0 || local_metadata.vlan_id == 12w0xfff) && !(standard_metadata.instance_type == 32w1 && standard_metadata.egress_rid == 16w2)) { + headers.vlan.setValid(); + headers.vlan.priority_code_point = 3w0; + headers.vlan.drop_eligible_indicator = 1w0; + headers.vlan.vlan_id = local_metadata.vlan_id; + headers.vlan.ether_type = headers.ethernet.ether_type; + headers.ethernet.ether_type = 16w0x8100; + } + if (headers.ipv4.isValid()) { + acl_egress_ip_protocol = headers.ipv4.protocol; + } else if (headers.ipv6.isValid()) { + acl_egress_ip_protocol = headers.ipv6.next_header; + } else { + acl_egress_ip_protocol = 8w0; + } + acl_egress_acl_egress_table.apply(); + if (local_metadata.acl_drop) { + mark_to_drop(standard_metadata); + } } } } -@pkginfo(name="middleblock.p4", organization="Google") V1Switch(packet_parser(), verify_ipv4_checksum(), ingress(), egress(), compute_ipv4_checksum(), packet_deparser()) main; +@pkginfo(name="middleblock.p4", organization="Google", version="1.6.1") V1Switch(packet_parser(), verify_ipv4_checksum(), ingress(), egress(), compute_ipv4_checksum(), packet_deparser()) main; diff --git a/testdata/p4_16_samples_outputs/pins/pins_middleblock-midend.p4 b/testdata/p4_16_samples_outputs/pins/pins_middleblock-midend.p4 index 4bf3634ba2..10d236ba4d 100644 --- a/testdata/p4_16_samples_outputs/pins/pins_middleblock-midend.p4 +++ b/testdata/p4_16_samples_outputs/pins/pins_middleblock-midend.p4 @@ -8,6 +8,13 @@ header ethernet_t { bit<16> ether_type; } +header vlan_t { + bit<3> priority_code_point; + bit<1> drop_eligible_indicator; + bit<12> vlan_id; + bit<16> ether_type; +} + header ipv4_t { bit<4> version; bit<4> ihl; @@ -62,6 +69,7 @@ header icmp_t { bit<8> type; bit<8> code; bit<16> checksum; + bit<32> rest_of_header; } header arp_t { @@ -89,54 +97,27 @@ header gre_t { bit<16> protocol; } -struct headers_t { - ethernet_t erspan_ethernet; - ipv4_t erspan_ipv4; - gre_t erspan_gre; - ethernet_t ethernet; - ipv6_t tunnel_encap_ipv6; - gre_t tunnel_encap_gre; - ipv4_t ipv4; - ipv6_t ipv6; - icmp_t icmp; - tcp_t tcp; - udp_t udp; - arp_t arp; -} - -struct packet_rewrites_t { - bit<48> src_mac; - bit<48> dst_mac; +header ipfix_t { + bit<16> version_number; + bit<16> length; + bit<32> export_time; + bit<32> sequence_number; + bit<32> observation_domain_id; } -struct local_metadata_t { - bool _admit_to_l30; - bit<10> _vrf_id1; - bit<48> _packet_rewrites_src_mac2; - bit<48> _packet_rewrites_dst_mac3; - bit<16> _l4_src_port4; - bit<16> _l4_dst_port5; - bit<16> _wcmp_selector_input6; - bool _apply_tunnel_encap_at_egress7; - bit<128> _tunnel_encap_src_ipv68; - bit<128> _tunnel_encap_dst_ipv69; - bool _mirror_session_id_valid10; - bit<10> _mirror_session_id_value11; - @field_list(8w1) - bit<32> _mirroring_src_ip12; - @field_list(8w1) - bit<32> _mirroring_dst_ip13; - @field_list(8w1) - bit<48> _mirroring_src_mac14; - @field_list(8w1) - bit<48> _mirroring_dst_mac15; - @field_list(8w1) - bit<8> _mirroring_ttl16; - @field_list(8w1) - bit<8> _mirroring_tos17; - bit<2> _color18; - bit<9> _ingress_port19; - bit<6> _route_metadata20; +header psamp_extended_t { + bit<16> template_id; + bit<16> length; + bit<64> observation_time; + bit<16> flowset; + bit<16> next_hop_index; + bit<16> epoch; + bit<16> ingress_port; + bit<16> egress_port; + bit<16> user_meta_field; + bit<8> dlb_id; + bit<8> variable_length; + bit<16> packet_sampled_length; } @controller_header("packet_in") header packet_in_header_t { @@ -151,25 +132,164 @@ struct local_metadata_t { bit<9> egress_port; @id(2) bit<1> submit_to_ingress; - @id(3) - bit<7> unused_pad; + @id(3) @padding + bit<6> unused_pad; +} + +struct headers_t { + packet_out_header_t packet_out_header; + ethernet_t mirror_encap_ethernet; + vlan_t mirror_encap_vlan; + ipv6_t mirror_encap_ipv6; + udp_t mirror_encap_udp; + ipfix_t ipfix; + psamp_extended_t psamp_extended; + ethernet_t ethernet; + vlan_t vlan; + ipv6_t tunnel_encap_ipv6; + gre_t tunnel_encap_gre; + ipv4_t ipv4; + ipv6_t ipv6; + ipv4_t inner_ipv4; + ipv6_t inner_ipv6; + icmp_t icmp; + tcp_t tcp; + udp_t udp; + arp_t arp; +} + +struct packet_rewrites_t { + bit<48> src_mac; + bit<48> dst_mac; + bit<12> vlan_id; +} + +struct local_metadata_t { + @field_list(8w1) + bool _enable_vlan_checks0; + bit<12> _vlan_id1; + bool _admit_to_l32; + bit<10> _vrf_id3; + bool _enable_decrement_ttl4; + bool _enable_src_mac_rewrite5; + bool _enable_dst_mac_rewrite6; + bool _enable_vlan_rewrite7; + bit<48> _packet_rewrites_src_mac8; + bit<48> _packet_rewrites_dst_mac9; + bit<12> _packet_rewrites_vlan_id10; + bit<16> _l4_src_port11; + bit<16> _l4_dst_port12; + bit<8> _wcmp_selector_input13; + bool _apply_tunnel_decap_at_end_of_pre_ingress14; + bool _apply_tunnel_encap_at_egress15; + bit<128> _tunnel_encap_src_ipv616; + bit<128> _tunnel_encap_dst_ipv617; + bool _marked_to_copy18; + bool _marked_to_mirror19; + bit<10> _mirror_session_id20; + bit<9> _mirror_egress_port21; + @field_list(8w1) + bit<48> _mirror_encap_src_mac22; + @field_list(8w1) + bit<48> _mirror_encap_dst_mac23; + @field_list(8w1) + bit<12> _mirror_encap_vlan_id24; + @field_list(8w1) + bit<128> _mirror_encap_src_ip25; + @field_list(8w1) + bit<128> _mirror_encap_dst_ip26; + @field_list(8w1) + bit<16> _mirror_encap_udp_src_port27; + @field_list(8w1) + bit<16> _mirror_encap_udp_dst_port28; + @field_list(8w2) + bit<9> _loopback_port29; + @field_list(8w1) + bit<9> _packet_in_ingress_port30; + @field_list(8w1) + bit<9> _packet_in_target_egress_port31; + bit<2> _color32; + bit<9> _ingress_port33; + bit<6> _route_metadata34; + bit<8> _acl_metadata35; + bool _bypass_ingress36; + bool _wcmp_group_id_valid37; + bit<12> _wcmp_group_id_value38; + bool _nexthop_id_valid39; + bit<10> _nexthop_id_value40; + bool _ipmc_table_hit41; + bool _acl_drop42; } parser packet_parser(packet_in packet, out headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { state start { - local_metadata._admit_to_l30 = false; - local_metadata._vrf_id1 = 10w0; - local_metadata._packet_rewrites_src_mac2 = 48w0; - local_metadata._packet_rewrites_dst_mac3 = 48w0; - local_metadata._l4_src_port4 = 16w0; - local_metadata._l4_dst_port5 = 16w0; - local_metadata._wcmp_selector_input6 = 16w0; - local_metadata._mirror_session_id_valid10 = false; - local_metadata._color18 = 2w0; - local_metadata._ingress_port19 = standard_metadata.ingress_port; - local_metadata._route_metadata20 = 6w0; + local_metadata._enable_vlan_checks0 = false; + local_metadata._vlan_id1 = 12w0; + local_metadata._admit_to_l32 = false; + local_metadata._vrf_id3 = 10w0; + local_metadata._enable_decrement_ttl4 = false; + local_metadata._enable_src_mac_rewrite5 = false; + local_metadata._enable_dst_mac_rewrite6 = false; + local_metadata._enable_vlan_rewrite7 = false; + local_metadata._packet_rewrites_src_mac8 = 48w0; + local_metadata._packet_rewrites_dst_mac9 = 48w0; + local_metadata._l4_src_port11 = 16w0; + local_metadata._l4_dst_port12 = 16w0; + local_metadata._wcmp_selector_input13 = 8w0; + local_metadata._apply_tunnel_decap_at_end_of_pre_ingress14 = false; + local_metadata._apply_tunnel_encap_at_egress15 = false; + local_metadata._tunnel_encap_src_ipv616 = 128w0; + local_metadata._tunnel_encap_dst_ipv617 = 128w0; + local_metadata._marked_to_copy18 = false; + local_metadata._marked_to_mirror19 = false; + local_metadata._mirror_session_id20 = 10w0; + local_metadata._mirror_egress_port21 = 9w0; + local_metadata._color32 = 2w0; + local_metadata._route_metadata34 = 6w0; + local_metadata._bypass_ingress36 = false; + local_metadata._wcmp_group_id_valid37 = false; + local_metadata._wcmp_group_id_value38 = 12w0; + local_metadata._nexthop_id_valid39 = false; + local_metadata._nexthop_id_value40 = 10w0; + local_metadata._ipmc_table_hit41 = false; + local_metadata._acl_drop42 = false; + transition select((bit<1>)(standard_metadata.instance_type == 32w4)) { + 1w1: start_true; + 1w0: start_false; + default: noMatch; + } + } + state start_true { + local_metadata._ingress_port33 = local_metadata._loopback_port29; + transition start_join; + } + state start_false { + local_metadata._ingress_port33 = standard_metadata.ingress_port; + transition start_join; + } + state start_join { + transition select(standard_metadata.ingress_port) { + 9w510: parse_packet_out_header; + default: parse_ethernet; + } + } + state parse_packet_out_header { + packet.extract(headers.packet_out_header); + transition parse_ethernet; + } + state parse_ethernet { packet.extract(headers.ethernet); transition select(headers.ethernet.ether_type) { + 16w0x800: parse_ipv4; + 16w0x86dd: parse_ipv6; + 16w0x806: parse_arp; + 16w0x8100: parse_8021q_vlan; + default: accept; + } + } + state parse_8021q_vlan { + packet.extract(headers.vlan); + transition select(headers.vlan.ether_type) { 16w0x800: parse_ipv4; 16w0x86dd: parse_ipv6; 16w0x806: parse_arp; @@ -179,6 +299,17 @@ parser packet_parser(packet_in packet, out headers_t headers, inout local_metada state parse_ipv4 { packet.extract(headers.ipv4); transition select(headers.ipv4.protocol) { + 8w0x4: parse_ipv4_in_ip; + 8w0x29: parse_ipv6_in_ip; + 8w0x1: parse_icmp; + 8w0x6: parse_tcp; + 8w0x11: parse_udp; + default: accept; + } + } + state parse_ipv4_in_ip { + packet.extract(headers.inner_ipv4); + transition select(headers.inner_ipv4.protocol) { 8w0x1: parse_icmp; 8w0x6: parse_tcp; 8w0x11: parse_udp; @@ -188,6 +319,17 @@ parser packet_parser(packet_in packet, out headers_t headers, inout local_metada state parse_ipv6 { packet.extract(headers.ipv6); transition select(headers.ipv6.next_header) { + 8w0x4: parse_ipv4_in_ip; + 8w0x29: parse_ipv6_in_ip; + 8w0x3a: parse_icmp; + 8w0x6: parse_tcp; + 8w0x11: parse_udp; + default: accept; + } + } + state parse_ipv6_in_ip { + packet.extract(headers.inner_ipv6); + transition select(headers.inner_ipv6.next_header) { 8w0x3a: parse_icmp; 8w0x6: parse_tcp; 8w0x11: parse_udp; @@ -196,14 +338,14 @@ parser packet_parser(packet_in packet, out headers_t headers, inout local_metada } state parse_tcp { packet.extract(headers.tcp); - local_metadata._l4_src_port4 = headers.tcp.src_port; - local_metadata._l4_dst_port5 = headers.tcp.dst_port; + local_metadata._l4_src_port11 = headers.tcp.src_port; + local_metadata._l4_dst_port12 = headers.tcp.dst_port; transition accept; } state parse_udp { packet.extract(headers.udp); - local_metadata._l4_src_port4 = headers.udp.src_port; - local_metadata._l4_dst_port5 = headers.udp.dst_port; + local_metadata._l4_src_port11 = headers.udp.src_port; + local_metadata._l4_dst_port12 = headers.udp.dst_port; transition accept; } state parse_icmp { @@ -214,18 +356,29 @@ parser packet_parser(packet_in packet, out headers_t headers, inout local_metada packet.extract(headers.arp); transition accept; } + state noMatch { + verify(false, error.NoMatch); + transition reject; + } } control packet_deparser(packet_out packet, in headers_t headers) { apply { - packet.emit(headers.erspan_ethernet); - packet.emit(headers.erspan_ipv4); - packet.emit(headers.erspan_gre); + packet.emit(headers.packet_out_header); + packet.emit(headers.mirror_encap_ethernet); + packet.emit(headers.mirror_encap_vlan); + packet.emit(headers.mirror_encap_ipv6); + packet.emit(headers.mirror_encap_udp); + packet.emit(headers.ipfix); + packet.emit(headers.psamp_extended); packet.emit(headers.ethernet); + packet.emit(headers.vlan); packet.emit(headers.tunnel_encap_ipv6); packet.emit(headers.tunnel_encap_gre); packet.emit(headers.ipv4); packet.emit(headers.ipv6); + packet.emit(headers.inner_ipv4); + packet.emit(headers.inner_ipv6); packet.emit(headers.arp); packet.emit(headers.icmp); packet.emit(headers.tcp); @@ -258,32 +411,46 @@ control verify_ipv4_checksum(inout headers_t headers, inout local_metadata_t loc control compute_ipv4_checksum(inout headers_t headers, inout local_metadata_t local_metadata) { apply { - update_checksum>(headers.erspan_ipv4.isValid(), (tuple_0){f0 = headers.erspan_ipv4.version,f1 = headers.erspan_ipv4.ihl,f2 = headers.erspan_ipv4.dscp,f3 = headers.erspan_ipv4.ecn,f4 = headers.erspan_ipv4.total_len,f5 = headers.erspan_ipv4.identification,f6 = headers.erspan_ipv4.reserved,f7 = headers.erspan_ipv4.do_not_fragment,f8 = headers.erspan_ipv4.more_fragments,f9 = headers.erspan_ipv4.frag_offset,f10 = headers.erspan_ipv4.ttl,f11 = headers.erspan_ipv4.protocol,f12 = headers.erspan_ipv4.src_addr,f13 = headers.erspan_ipv4.dst_addr}, headers.erspan_ipv4.header_checksum, HashAlgorithm.csum16); update_checksum>(headers.ipv4.isValid(), (tuple_0){f0 = headers.ipv4.version,f1 = headers.ipv4.ihl,f2 = headers.ipv4.dscp,f3 = headers.ipv4.ecn,f4 = headers.ipv4.total_len,f5 = headers.ipv4.identification,f6 = headers.ipv4.reserved,f7 = headers.ipv4.do_not_fragment,f8 = headers.ipv4.more_fragments,f9 = headers.ipv4.frag_offset,f10 = headers.ipv4.ttl,f11 = headers.ipv4.protocol,f12 = headers.ipv4.src_addr,f13 = headers.ipv4.dst_addr}, headers.ipv4.header_checksum, HashAlgorithm.csum16); } } +struct tuple_1 { + bit<32> f0; + bit<32> f1; + bit<32> f2; + bit<16> f3; + bit<16> f4; +} + +struct tuple_2 { + bit<32> f0; + bit<20> f1; + bit<128> f2; + bit<128> f3; + bit<16> f4; + bit<16> f5; +} + control ingress(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { @name("ingress.acl_pre_ingress.dscp") bit<6> acl_pre_ingress_dscp; - @name("ingress.routing.wcmp_group_id_valid") bool routing_wcmp_group_id_valid; - @name("ingress.routing.wcmp_group_id_value") bit<12> routing_wcmp_group_id_value; - @name("ingress.routing.nexthop_id_valid") bool routing_nexthop_id_valid; - @name("ingress.routing.nexthop_id_value") bit<10> routing_nexthop_id_value; - @name("ingress.routing.router_interface_id_valid") bool routing_router_interface_id_valid; - @name("ingress.routing.router_interface_id_value") bit<10> routing_router_interface_id_value; - @name("ingress.routing.neighbor_id_valid") bool routing_neighbor_id_valid; - @name("ingress.routing.neighbor_id_value") bit<128> routing_neighbor_id_value; + @name("ingress.acl_pre_ingress.ecn") bit<2> acl_pre_ingress_ecn; @name("ingress.acl_ingress.ttl") bit<8> acl_ingress_ttl; @name("ingress.acl_ingress.dscp") bit<6> acl_ingress_dscp; @name("ingress.acl_ingress.ecn") bit<2> acl_ingress_ecn; @name("ingress.acl_ingress.ip_protocol") bit<8> acl_ingress_ip_protocol; - @name("ingress.mirroring_clone.mirror_port") bit<9> mirroring_clone_mirror_port; - @name("ingress.mirroring_clone.pre_session") bit<32> mirroring_clone_pre_session; - @name("ingress.standard_metadata") standard_metadata_t standard_metadata_0; - bool key_0; - bool key_2; - @noWarn("unused") @name(".NoAction") action NoAction_1() { - } + @name("ingress.acl_ingress.cancel_copy") bool acl_ingress_cancel_copy; + @name("ingress.routing_resolution.tunnel_id_valid") bool routing_resolution_tunnel_id_valid; + @name("ingress.routing_resolution.tunnel_id_value") bit<10> routing_resolution_tunnel_id_value; + @name("ingress.routing_resolution.router_interface_id_valid") bool routing_resolution_router_interface_id_valid; + @name("ingress.routing_resolution.router_interface_id_value") bit<10> routing_resolution_router_interface_id_value; + @name("ingress.routing_resolution.neighbor_id_valid") bool routing_resolution_neighbor_id_valid; + @name("ingress.routing_resolution.neighbor_id_value") bit<128> routing_resolution_neighbor_id_value; + bit<1> key_0; + bool key_1; + bool key_3; + bool key_6; + bool key_8; @noWarn("unused") @name(".NoAction") action NoAction_2() { } @noWarn("unused") @name(".NoAction") action NoAction_3() { @@ -300,49 +467,84 @@ control ingress(inout headers_t headers, inout local_metadata_t local_metadata, } @noWarn("unused") @name(".NoAction") action NoAction_9() { } - @id(0x01000109) @sai_action(SAI_PACKET_ACTION_DROP) @name(".acl_drop") action acl_drop_0() { - standard_metadata_0.ingress_port = standard_metadata.ingress_port; - standard_metadata_0.egress_spec = standard_metadata.egress_spec; - standard_metadata_0.egress_port = standard_metadata.egress_port; - standard_metadata_0.instance_type = standard_metadata.instance_type; - standard_metadata_0.packet_length = standard_metadata.packet_length; - standard_metadata_0.enq_timestamp = standard_metadata.enq_timestamp; - standard_metadata_0.enq_qdepth = standard_metadata.enq_qdepth; - standard_metadata_0.deq_timedelta = standard_metadata.deq_timedelta; - standard_metadata_0.deq_qdepth = standard_metadata.deq_qdepth; - standard_metadata_0.ingress_global_timestamp = standard_metadata.ingress_global_timestamp; - standard_metadata_0.egress_global_timestamp = standard_metadata.egress_global_timestamp; - standard_metadata_0.mcast_grp = standard_metadata.mcast_grp; - standard_metadata_0.egress_rid = standard_metadata.egress_rid; - standard_metadata_0.checksum_error = standard_metadata.checksum_error; - standard_metadata_0.parser_error = standard_metadata.parser_error; - standard_metadata_0.priority = standard_metadata.priority; - mark_to_drop(standard_metadata_0); - standard_metadata.ingress_port = standard_metadata_0.ingress_port; - standard_metadata.egress_spec = standard_metadata_0.egress_spec; - standard_metadata.egress_port = standard_metadata_0.egress_port; - standard_metadata.instance_type = standard_metadata_0.instance_type; - standard_metadata.packet_length = standard_metadata_0.packet_length; - standard_metadata.enq_timestamp = standard_metadata_0.enq_timestamp; - standard_metadata.enq_qdepth = standard_metadata_0.enq_qdepth; - standard_metadata.deq_timedelta = standard_metadata_0.deq_timedelta; - standard_metadata.deq_qdepth = standard_metadata_0.deq_qdepth; - standard_metadata.ingress_global_timestamp = standard_metadata_0.ingress_global_timestamp; - standard_metadata.egress_global_timestamp = standard_metadata_0.egress_global_timestamp; - standard_metadata.mcast_grp = standard_metadata_0.mcast_grp; - standard_metadata.egress_rid = standard_metadata_0.egress_rid; - standard_metadata.checksum_error = standard_metadata_0.checksum_error; - standard_metadata.parser_error = standard_metadata_0.parser_error; - standard_metadata.priority = standard_metadata_0.priority; + @noWarn("unused") @name(".NoAction") action NoAction_10() { + } + @noWarn("unused") @name(".NoAction") action NoAction_11() { + } + @noWarn("unused") @name(".NoAction") action NoAction_12() { + } + @noWarn("unused") @name(".NoAction") action NoAction_13() { + } + @noWarn("unused") @name(".NoAction") action NoAction_14() { + } + @noWarn("unused") @name(".NoAction") action NoAction_15() { + } + @noWarn("unused") @name(".NoAction") action NoAction_16() { + } + @noWarn("unused") @name(".NoAction") action NoAction_17() { + } + @id(0x01000005) @name(".set_nexthop_id") action set_nexthop_id_1(@id(1) @refers_to(nexthop_table , nexthop_id) @name("nexthop_id") bit<10> nexthop_id) { + local_metadata._nexthop_id_valid39 = true; + local_metadata._nexthop_id_value40 = nexthop_id; + } + @id(0x01000005) @name(".set_nexthop_id") action set_nexthop_id_2(@id(1) @refers_to(nexthop_table , nexthop_id) @name("nexthop_id") bit<10> nexthop_id_3) { + local_metadata._nexthop_id_valid39 = true; + local_metadata._nexthop_id_value40 = nexthop_id_3; + } + @id(0x01000005) @name(".set_nexthop_id") action set_nexthop_id_3(@id(1) @refers_to(nexthop_table , nexthop_id) @name("nexthop_id") bit<10> nexthop_id_4) { + local_metadata._nexthop_id_valid39 = true; + local_metadata._nexthop_id_value40 = nexthop_id_4; + } + @id(0x01000109) @sai_action(SAI_PACKET_ACTION_DROP) @name(".acl_drop") action acl_drop_2() { + local_metadata._acl_drop42 = true; + } + @id(0x01000109) @sai_action(SAI_PACKET_ACTION_DROP) @name(".acl_drop") action acl_drop_3() { + local_metadata._acl_drop42 = true; + } + @id(0x01000016) @name("ingress.tunnel_termination_lookup.mark_for_tunnel_decap_and_set_vrf") action tunnel_termination_lookup_mark_for_tunnel_decap_and_set_vrf_0(@refers_to(vrf_table , vrf_id) @name("vrf_id") bit<10> vrf_id_2) { + local_metadata._apply_tunnel_decap_at_end_of_pre_ingress14 = true; + local_metadata._vrf_id3 = vrf_id_2; + } + @unsupported @p4runtime_role("sdn_controller") @id(0x0200004B) @name("ingress.tunnel_termination_lookup.ipv6_tunnel_termination_table") table tunnel_termination_lookup_ipv6_tunnel_termination_table { + key = { + headers.ipv6.dst_addr: ternary @id(1) @name("dst_ipv6") @format(IPV6_ADDRESS); + headers.ipv6.src_addr: ternary @id(2) @name("src_ipv6") @format(IPV6_ADDRESS); + } + actions = { + @proto_id(1) tunnel_termination_lookup_mark_for_tunnel_decap_and_set_vrf_0(); + @defaultonly NoAction_2(); + } + size = 126; + default_action = NoAction_2(); + } + @id(0x0100001A) @name("ingress.vlan_untag.disable_vlan_checks") action vlan_untag_disable_vlan_checks_0() { + local_metadata._enable_vlan_checks0 = false; + } + @p4runtime_role("sdn_controller") @id(0x0200004D) @entry_restriction(" + // Force the dummy_match to be wildcard. + dummy_match::mask == 0; + ") @name("ingress.vlan_untag.disable_vlan_checks_table") table vlan_untag_disable_vlan_checks_table { + key = { + key_0: ternary @id(1) @name("dummy_match"); + } + actions = { + @proto_id(1) vlan_untag_disable_vlan_checks_0(); + @defaultonly NoAction_3(); + } + size = 1; + default_action = NoAction_3(); } @id(0x13000101) @name("ingress.acl_pre_ingress.acl_pre_ingress_counter") direct_counter(CounterType.packets_and_bytes) acl_pre_ingress_acl_pre_ingress_counter; - @id(0x01000100) @sai_action(SAI_PACKET_ACTION_FORWARD) @name("ingress.acl_pre_ingress.set_vrf") action acl_pre_ingress_set_vrf_0(@sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_SET_VRF) @refers_to(vrf_table , vrf_id) @id(1) @name("vrf_id") bit<10> vrf_id_1) { - local_metadata._vrf_id1 = vrf_id_1; + @id(0x13000106) @name("ingress.acl_pre_ingress.acl_pre_ingress_vlan_counter") direct_counter(CounterType.packets_and_bytes) acl_pre_ingress_acl_pre_ingress_vlan_counter; + @id(0x13000105) @name("ingress.acl_pre_ingress.acl_pre_ingress_metadata_counter") direct_counter(CounterType.packets_and_bytes) acl_pre_ingress_acl_pre_ingress_metadata_counter; + @id(0x01000100) @sai_action(SAI_PACKET_ACTION_FORWARD) @name("ingress.acl_pre_ingress.set_vrf") action acl_pre_ingress_set_vrf_0(@sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_SET_VRF) @refers_to(vrf_table , vrf_id) @id(1) @name("vrf_id") bit<10> vrf_id_3) { + local_metadata._vrf_id3 = vrf_id_3; acl_pre_ingress_acl_pre_ingress_counter.count(); } - @p4runtime_role("sdn_controller") @id(0x02000101) @sai_acl(PRE_INGRESS) @entry_restriction(" + @p4runtime_role("sdn_controller") @id(0x02000101) @sai_acl(PRE_INGRESS) @sai_acl_priority(11) @entry_restriction(" // Only allow IP field matches for IP packets. dscp::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + ecn::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); dst_ip::mask != 0 -> is_ipv4 == 1; dst_ipv6::mask != 0 -> is_ipv6 == 1; // Forbid illegal combinations of IP_TYPE fields. @@ -352,136 +554,59 @@ control ingress(inout headers_t headers, inout local_metadata_t local_metadata, // Forbid unsupported combinations of IP_TYPE fields. is_ipv4::mask != 0 -> (is_ipv4 == 1); is_ipv6::mask != 0 -> (is_ipv6 == 1); + + + + // Reserve high priorities for switch-internal use. // TODO: Remove once inband workaround is obsolete. ::priority < 0x7fffffff; ") @name("ingress.acl_pre_ingress.acl_pre_ingress_table") table acl_pre_ingress_acl_pre_ingress_table { key = { - key_0 : optional @name("is_ip") @id(1) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); - headers.ipv4.isValid() : optional @name("is_ipv4") @id(2) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); - headers.ipv6.isValid() : optional @name("is_ipv6") @id(3) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); - headers.ethernet.src_addr : ternary @name("src_mac") @id(4) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_SRC_MAC) @format(MAC_ADDRESS); - headers.ipv4.dst_addr : ternary @name("dst_ip") @id(5) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_IP) @format(IPV4_ADDRESS); - headers.ipv6.dst_addr[127:64] : ternary @name("dst_ipv6") @id(6) @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD2 )) @format(IPV6_ADDRESS); - acl_pre_ingress_dscp : ternary @name("dscp") @id(7) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DSCP); - local_metadata._ingress_port19: optional @name("in_port") @id(8) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IN_PORT); + key_1 : optional @id(1) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(2) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(3) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + headers.ethernet.src_addr : ternary @id(4) @name("src_mac") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_SRC_MAC) @format(MAC_ADDRESS); + headers.ipv4.dst_addr : ternary @id(5) @name("dst_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_IP) @format(IPV4_ADDRESS); + headers.ipv6.dst_addr[127:64] : ternary @id(6) @name("dst_ipv6") @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD2 )) @format(IPV6_ADDRESS); + acl_pre_ingress_dscp : ternary @id(7) @name("dscp") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DSCP); + acl_pre_ingress_ecn : ternary @id(10) @name("ecn") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ECN); + local_metadata._ingress_port33: optional @id(8) @name("in_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IN_PORT); } actions = { @proto_id(1) acl_pre_ingress_set_vrf_0(); - @defaultonly NoAction_1(); + @defaultonly NoAction_4(); } - const default_action = NoAction_1(); + const default_action = NoAction_4(); counters = acl_pre_ingress_acl_pre_ingress_counter; - size = 255; + size = 254; } @id(0x01000008) @name("ingress.l3_admit.admit_to_l3") action l3_admit_admit_to_l3_0() { - local_metadata._admit_to_l30 = true; + local_metadata._admit_to_l32 = true; } @p4runtime_role("sdn_controller") @id(0x02000047) @name("ingress.l3_admit.l3_admit_table") table l3_admit_l3_admit_table { key = { headers.ethernet.dst_addr : ternary @name("dst_mac") @id(1) @format(MAC_ADDRESS); - local_metadata._ingress_port19: optional @name("in_port") @id(2); + local_metadata._ingress_port33: optional @name("in_port") @id(2); } actions = { @proto_id(1) l3_admit_admit_to_l3_0(); - @defaultonly NoAction_2(); - } - const default_action = NoAction_2(); - size = 128; - } - @id(0x01000001) @name("ingress.routing.set_dst_mac") action routing_set_dst_mac_0(@id(1) @format(MAC_ADDRESS) @name("dst_mac") bit<48> dst_mac_2) { - local_metadata._packet_rewrites_dst_mac3 = dst_mac_2; - } - @p4runtime_role("sdn_controller") @id(0x02000040) @name("ingress.routing.neighbor_table") table routing_neighbor_table { - key = { - routing_router_interface_id_value: exact @id(1) @name("router_interface_id") @refers_to(router_interface_table , router_interface_id); - routing_neighbor_id_value : exact @id(2) @format(IPV6_ADDRESS) @name("neighbor_id"); - } - actions = { - @proto_id(1) routing_set_dst_mac_0(); - @defaultonly NoAction_3(); - } - const default_action = NoAction_3(); - size = 1024; - } - @id(0x01000002) @name("ingress.routing.set_port_and_src_mac") action routing_set_port_and_src_mac_0(@id(1) @name("port") bit<9> port, @id(2) @format(MAC_ADDRESS) @name("src_mac") bit<48> src_mac_2) { - standard_metadata.egress_spec = (bit<9>)port; - local_metadata._packet_rewrites_src_mac2 = src_mac_2; - } - @p4runtime_role("sdn_controller") @id(0x02000041) @name("ingress.routing.router_interface_table") table routing_router_interface_table { - key = { - routing_router_interface_id_value: exact @id(1) @name("router_interface_id"); - } - actions = { - @proto_id(1) routing_set_port_and_src_mac_0(); - @defaultonly NoAction_4(); - } - const default_action = NoAction_4(); - size = 256; - } - @id(0x01000014) @name("ingress.routing.set_ip_nexthop") action routing_set_ip_nexthop_0(@id(1) @refers_to(router_interface_table , router_interface_id) @refers_to(neighbor_table , router_interface_id) @name("router_interface_id") bit<10> router_interface_id, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) @name("neighbor_id") bit<128> neighbor_id) { - routing_router_interface_id_valid = true; - routing_router_interface_id_value = router_interface_id; - routing_neighbor_id_valid = true; - routing_neighbor_id_value = neighbor_id; - } - @id(0x01000003) @deprecated("Use set_ip_nexthop instead.") @name("ingress.routing.set_nexthop") action routing_set_nexthop_0(@id(1) @refers_to(router_interface_table , router_interface_id) @refers_to(neighbor_table , router_interface_id) @name("router_interface_id") bit<10> router_interface_id_2, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) @name("neighbor_id") bit<128> neighbor_id_2) { - @id(0x01000014) { - routing_router_interface_id_valid = true; - routing_router_interface_id_value = router_interface_id_2; - routing_neighbor_id_valid = true; - routing_neighbor_id_value = neighbor_id_2; - } - } - @p4runtime_role("sdn_controller") @id(0x02000042) @name("ingress.routing.nexthop_table") table routing_nexthop_table { - key = { - routing_nexthop_id_value: exact @id(1) @name("nexthop_id"); - } - actions = { - @proto_id(1) routing_set_nexthop_0(); - @proto_id(3) routing_set_ip_nexthop_0(); @defaultonly NoAction_5(); } const default_action = NoAction_5(); - size = 1024; - } - @id(0x01000005) @name("ingress.routing.set_nexthop_id") action routing_set_nexthop_id_0(@id(1) @refers_to(nexthop_table , nexthop_id) @name("nexthop_id") bit<10> nexthop_id) { - routing_nexthop_id_valid = true; - routing_nexthop_id_value = nexthop_id; + size = 64; } - @id(0x01000005) @name("ingress.routing.set_nexthop_id") action routing_set_nexthop_id_1(@id(1) @refers_to(nexthop_table , nexthop_id) @name("nexthop_id") bit<10> nexthop_id_2) { - routing_nexthop_id_valid = true; - routing_nexthop_id_value = nexthop_id_2; + @sai_hash_seed(0) @id(0x010000A) @name("ingress.hashing.select_ecmp_hash_algorithm") action hashing_select_ecmp_hash_algorithm_0() { } - @id(0x01000005) @name("ingress.routing.set_nexthop_id") action routing_set_nexthop_id_2(@id(1) @refers_to(nexthop_table , nexthop_id) @name("nexthop_id") bit<10> nexthop_id_3) { - routing_nexthop_id_valid = true; - routing_nexthop_id_value = nexthop_id_3; + @sai_ecmp_hash(SAI_SWITCH_ATTR_ECMP_HASH_IPV4) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_SRC_IPV4) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_DST_IPV4) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_SRC_PORT) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_DST_PORT) @id(0x0100000B) @name("ingress.hashing.compute_ecmp_hash_ipv4") action hashing_compute_ecmp_hash_ipv4_0() { + hash, bit<1>, tuple_1, bit<17>>(local_metadata._wcmp_selector_input13, HashAlgorithm.crc32, 1w0, (tuple_1){f0 = 32w0,f1 = headers.ipv4.src_addr,f2 = headers.ipv4.dst_addr,f3 = local_metadata._l4_src_port11,f4 = local_metadata._l4_dst_port12}, 17w0x10000); + local_metadata._wcmp_selector_input13 = local_metadata._wcmp_selector_input13 | local_metadata._wcmp_selector_input13 << 8w8; } - @id(0x01000010) @name("ingress.routing.set_nexthop_id_and_metadata") action routing_set_nexthop_id_and_metadata_0(@id(1) @refers_to(nexthop_table , nexthop_id) @name("nexthop_id") bit<10> nexthop_id_4, @name("route_metadata") bit<6> route_metadata_2) { - routing_nexthop_id_valid = true; - routing_nexthop_id_value = nexthop_id_4; - local_metadata._route_metadata20 = route_metadata_2; + @sai_ecmp_hash(SAI_SWITCH_ATTR_ECMP_HASH_IPV6) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_SRC_IPV6) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_DST_IPV6) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_SRC_PORT) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_DST_PORT) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_IPV6_FLOW_LABEL) @id(0x0100000C) @name("ingress.hashing.compute_ecmp_hash_ipv6") action hashing_compute_ecmp_hash_ipv6_0() { + hash, bit<1>, tuple_2, bit<17>>(local_metadata._wcmp_selector_input13, HashAlgorithm.crc32, 1w0, (tuple_2){f0 = 32w0,f1 = headers.ipv6.flow_label,f2 = headers.ipv6.src_addr,f3 = headers.ipv6.dst_addr,f4 = local_metadata._l4_src_port11,f5 = local_metadata._l4_dst_port12}, 17w0x10000); + local_metadata._wcmp_selector_input13 = local_metadata._wcmp_selector_input13 | local_metadata._wcmp_selector_input13 << 8w8; } - @id(0x01000010) @name("ingress.routing.set_nexthop_id_and_metadata") action routing_set_nexthop_id_and_metadata_1(@id(1) @refers_to(nexthop_table , nexthop_id) @name("nexthop_id") bit<10> nexthop_id_5, @name("route_metadata") bit<6> route_metadata_3) { - routing_nexthop_id_valid = true; - routing_nexthop_id_value = nexthop_id_5; - local_metadata._route_metadata20 = route_metadata_3; - } - @max_group_size(256) @name("ingress.routing.wcmp_group_selector") action_selector(HashAlgorithm.identity, 32w65536, 32w16) routing_wcmp_group_selector; - @p4runtime_role("sdn_controller") @id(0x02000043) @oneshot @name("ingress.routing.wcmp_group_table") table routing_wcmp_group_table { - key = { - routing_wcmp_group_id_value : exact @id(1) @name("wcmp_group_id"); - local_metadata._wcmp_selector_input6: selector @name("local_metadata.wcmp_selector_input"); - } - actions = { - @proto_id(1) routing_set_nexthop_id_0(); - @defaultonly NoAction_6(); - } - const default_action = NoAction_6(); - @id(0x11DC4EC8) implementation = routing_wcmp_group_selector; - size = 3968; - } - @name("ingress.routing.no_action") action routing_no_action_0() { + @id(0x01798B9E) @name("ingress.routing_lookup.no_action") action routing_lookup_no_action_0() { } @entry_restriction(" // The VRF ID 0 (or '' in P4Runtime) encodes the default VRF, which cannot @@ -490,137 +615,198 @@ control ingress(inout headers_t headers, inout local_metadata_t local_metadata, // constraints are a control plane (P4Runtime) concept), but // p4-constraints does not currently support strings. vrf_id != 0; - ") @p4runtime_role("sdn_controller") @id(0x0200004A) @name("ingress.routing.vrf_table") table routing_vrf_table { + ") @p4runtime_role("sdn_controller") @id(0x0200004A) @name("ingress.routing_lookup.vrf_table") table routing_lookup_vrf_table { key = { - local_metadata._vrf_id1: exact @id(1) @name("vrf_id"); + local_metadata._vrf_id3: exact @id(1) @name("vrf_id"); } actions = { - @proto_id(1) routing_no_action_0(); + @proto_id(1) routing_lookup_no_action_0(); } - const default_action = routing_no_action_0(); + const default_action = routing_lookup_no_action_0(); size = 64; } - @id(0x01000006) @name("ingress.routing.drop") action routing_drop_0() { + @id(0x01000006) @name("ingress.routing_lookup.drop") action routing_lookup_drop_0() { mark_to_drop(standard_metadata); } - @id(0x01000006) @name("ingress.routing.drop") action routing_drop_1() { + @id(0x01000006) @name("ingress.routing_lookup.drop") action routing_lookup_drop_1() { mark_to_drop(standard_metadata); } - @id(0x01000004) @name("ingress.routing.set_wcmp_group_id") action routing_set_wcmp_group_id_0(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) @name("wcmp_group_id") bit<12> wcmp_group_id) { - routing_wcmp_group_id_valid = true; - routing_wcmp_group_id_value = wcmp_group_id; + @id(0x01000004) @name("ingress.routing_lookup.set_wcmp_group_id") action routing_lookup_set_wcmp_group_id_0(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) @name("wcmp_group_id") bit<12> wcmp_group_id) { + local_metadata._wcmp_group_id_valid37 = true; + local_metadata._wcmp_group_id_value38 = wcmp_group_id; } - @id(0x01000004) @name("ingress.routing.set_wcmp_group_id") action routing_set_wcmp_group_id_1(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) @name("wcmp_group_id") bit<12> wcmp_group_id_2) { - routing_wcmp_group_id_valid = true; - routing_wcmp_group_id_value = wcmp_group_id_2; + @id(0x01000004) @name("ingress.routing_lookup.set_wcmp_group_id") action routing_lookup_set_wcmp_group_id_1(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) @name("wcmp_group_id") bit<12> wcmp_group_id_2) { + local_metadata._wcmp_group_id_valid37 = true; + local_metadata._wcmp_group_id_value38 = wcmp_group_id_2; } - @id(0x01000011) @name("ingress.routing.set_wcmp_group_id_and_metadata") action routing_set_wcmp_group_id_and_metadata_0(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) @name("wcmp_group_id") bit<12> wcmp_group_id_3, @name("route_metadata") bit<6> route_metadata_4) { + @id(0x01000011) @name("ingress.routing_lookup.set_wcmp_group_id_and_metadata") action routing_lookup_set_wcmp_group_id_and_metadata_0(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) @name("wcmp_group_id") bit<12> wcmp_group_id_3, @name("route_metadata") bit<6> route_metadata_3) { @id(0x01000004) { - routing_wcmp_group_id_valid = true; - routing_wcmp_group_id_value = wcmp_group_id_3; + local_metadata._wcmp_group_id_valid37 = true; + local_metadata._wcmp_group_id_value38 = wcmp_group_id_3; } - local_metadata._route_metadata20 = route_metadata_4; + local_metadata._route_metadata34 = route_metadata_3; } - @id(0x01000011) @name("ingress.routing.set_wcmp_group_id_and_metadata") action routing_set_wcmp_group_id_and_metadata_1(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) @name("wcmp_group_id") bit<12> wcmp_group_id_4, @name("route_metadata") bit<6> route_metadata_5) { + @id(0x01000011) @name("ingress.routing_lookup.set_wcmp_group_id_and_metadata") action routing_lookup_set_wcmp_group_id_and_metadata_1(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) @name("wcmp_group_id") bit<12> wcmp_group_id_4, @name("route_metadata") bit<6> route_metadata_4) { @id(0x01000004) { - routing_wcmp_group_id_valid = true; - routing_wcmp_group_id_value = wcmp_group_id_4; + local_metadata._wcmp_group_id_valid37 = true; + local_metadata._wcmp_group_id_value38 = wcmp_group_id_4; } - local_metadata._route_metadata20 = route_metadata_5; + local_metadata._route_metadata34 = route_metadata_4; } - @id(0x0100000F) @name("ingress.routing.trap") action routing_trap_0() { - clone(CloneType.I2E, 32w1024); + @id(0x01000015) @name("ingress.routing_lookup.set_metadata_and_drop") action routing_lookup_set_metadata_and_drop_0(@id(1) @name("route_metadata") bit<6> route_metadata_5) { + local_metadata._route_metadata34 = route_metadata_5; mark_to_drop(standard_metadata); } - @id(0x0100000F) @name("ingress.routing.trap") action routing_trap_1() { - clone(CloneType.I2E, 32w1024); + @id(0x01000015) @name("ingress.routing_lookup.set_metadata_and_drop") action routing_lookup_set_metadata_and_drop_1(@id(1) @name("route_metadata") bit<6> route_metadata_6) { + local_metadata._route_metadata34 = route_metadata_6; mark_to_drop(standard_metadata); } - @p4runtime_role("sdn_controller") @id(0x02000044) @name("ingress.routing.ipv4_table") table routing_ipv4_table { + @id(0x01000010) @name("ingress.routing_lookup.set_nexthop_id_and_metadata") action routing_lookup_set_nexthop_id_and_metadata_0(@id(1) @refers_to(nexthop_table , nexthop_id) @name("nexthop_id") bit<10> nexthop_id_5, @name("route_metadata") bit<6> route_metadata_7) { + local_metadata._nexthop_id_valid39 = true; + local_metadata._nexthop_id_value40 = nexthop_id_5; + local_metadata._route_metadata34 = route_metadata_7; + } + @id(0x01000010) @name("ingress.routing_lookup.set_nexthop_id_and_metadata") action routing_lookup_set_nexthop_id_and_metadata_1(@id(1) @refers_to(nexthop_table , nexthop_id) @name("nexthop_id") bit<10> nexthop_id_6, @name("route_metadata") bit<6> route_metadata_8) { + local_metadata._nexthop_id_valid39 = true; + local_metadata._nexthop_id_value40 = nexthop_id_6; + local_metadata._route_metadata34 = route_metadata_8; + } + @id(0x01000018) @action_restriction(" + // Disallow 0 since it encodes 'no multicast' in V1Model. + multicast_group_id != 0; + ") @name("ingress.routing_lookup.set_multicast_group_id") action routing_lookup_set_multicast_group_id_0(@id(1) @refers_to(builtin : : multicast_group_table , multicast_group_id) @name("multicast_group_id") bit<16> multicast_group_id) { + standard_metadata.mcast_grp = multicast_group_id; + } + @id(0x01000018) @action_restriction(" + // Disallow 0 since it encodes 'no multicast' in V1Model. + multicast_group_id != 0; + ") @name("ingress.routing_lookup.set_multicast_group_id") action routing_lookup_set_multicast_group_id_1(@id(1) @refers_to(builtin : : multicast_group_table , multicast_group_id) @name("multicast_group_id") bit<16> multicast_group_id_2) { + standard_metadata.mcast_grp = multicast_group_id_2; + } + @p4runtime_role("sdn_controller") @id(0x02000044) @name("ingress.routing_lookup.ipv4_table") table routing_lookup_ipv4_table { + key = { + local_metadata._vrf_id3: exact @id(1) @name("vrf_id") @refers_to(vrf_table , vrf_id); + headers.ipv4.dst_addr : lpm @id(2) @name("ipv4_dst") @format(IPV4_ADDRESS); + } + actions = { + @proto_id(1) routing_lookup_drop_0(); + @proto_id(2) set_nexthop_id_1(); + @proto_id(3) routing_lookup_set_wcmp_group_id_0(); + @proto_id(5) routing_lookup_set_nexthop_id_and_metadata_0(); + @proto_id(6) routing_lookup_set_wcmp_group_id_and_metadata_0(); + @proto_id(7) routing_lookup_set_metadata_and_drop_0(); + } + const default_action = routing_lookup_drop_0(); + size = 131072; + } + @p4runtime_role("sdn_controller") @id(0x02000045) @name("ingress.routing_lookup.ipv6_table") table routing_lookup_ipv6_table { key = { - local_metadata._vrf_id1: exact @id(1) @name("vrf_id") @refers_to(vrf_table , vrf_id); - headers.ipv4.dst_addr : lpm @format(IPV4_ADDRESS) @id(2) @name("ipv4_dst"); + local_metadata._vrf_id3: exact @id(1) @name("vrf_id") @refers_to(vrf_table , vrf_id); + headers.ipv6.dst_addr : lpm @id(2) @name("ipv6_dst") @format(IPV6_ADDRESS); } actions = { - @proto_id(1) routing_drop_0(); - @proto_id(2) routing_set_nexthop_id_1(); - @proto_id(3) routing_set_wcmp_group_id_0(); - @proto_id(4) routing_trap_0(); - @proto_id(5) routing_set_nexthop_id_and_metadata_0(); - @proto_id(6) routing_set_wcmp_group_id_and_metadata_0(); + @proto_id(1) routing_lookup_drop_1(); + @proto_id(2) set_nexthop_id_2(); + @proto_id(3) routing_lookup_set_wcmp_group_id_1(); + @proto_id(5) routing_lookup_set_nexthop_id_and_metadata_1(); + @proto_id(6) routing_lookup_set_wcmp_group_id_and_metadata_1(); + @proto_id(7) routing_lookup_set_metadata_and_drop_1(); } - const default_action = routing_drop_0(); - size = 32768; + const default_action = routing_lookup_drop_1(); + size = 17000; } - @p4runtime_role("sdn_controller") @id(0x02000045) @name("ingress.routing.ipv6_table") table routing_ipv6_table { + @p4runtime_role("sdn_controller") @id(0x0200004E) @name("ingress.routing_lookup.ipv4_multicast_table") table routing_lookup_ipv4_multicast_table { key = { - local_metadata._vrf_id1: exact @id(1) @name("vrf_id") @refers_to(vrf_table , vrf_id); - headers.ipv6.dst_addr : lpm @format(IPV6_ADDRESS) @id(2) @name("ipv6_dst"); + local_metadata._vrf_id3: exact @id(1) @name("vrf_id") @refers_to(vrf_table , vrf_id); + headers.ipv4.dst_addr : exact @id(2) @name("ipv4_dst") @format(IPV4_ADDRESS); } actions = { - @proto_id(1) routing_drop_1(); - @proto_id(2) routing_set_nexthop_id_2(); - @proto_id(3) routing_set_wcmp_group_id_1(); - @proto_id(4) routing_trap_1(); - @proto_id(5) routing_set_nexthop_id_and_metadata_1(); - @proto_id(6) routing_set_wcmp_group_id_and_metadata_1(); + @proto_id(1) routing_lookup_set_multicast_group_id_0(); + @defaultonly NoAction_6(); } - const default_action = routing_drop_1(); - size = 4096; + size = 1600; + default_action = NoAction_6(); } - @id(0x15000100) @name("ingress.acl_ingress.acl_ingress_meter") direct_meter>(MeterType.bytes) acl_ingress_acl_ingress_meter; + @p4runtime_role("sdn_controller") @id(0x0200004F) @name("ingress.routing_lookup.ipv6_multicast_table") table routing_lookup_ipv6_multicast_table { + key = { + local_metadata._vrf_id3: exact @id(1) @name("vrf_id") @refers_to(vrf_table , vrf_id); + headers.ipv6.dst_addr : exact @id(2) @name("ipv6_dst") @format(IPV6_ADDRESS); + } + actions = { + @proto_id(1) routing_lookup_set_multicast_group_id_1(); + @defaultonly NoAction_7(); + } + size = 1600; + default_action = NoAction_7(); + } + @id(0x15000100) @mode(single_rate_two_color) @name("ingress.acl_ingress.acl_ingress_meter") direct_meter>(MeterType.bytes) acl_ingress_acl_ingress_meter; + @id(0x15000102) @mode(single_rate_two_color) @name("ingress.acl_ingress.acl_ingress_qos_meter") direct_meter>(MeterType.bytes) acl_ingress_acl_ingress_qos_meter; @id(0x13000102) @name("ingress.acl_ingress.acl_ingress_counter") direct_counter(CounterType.packets_and_bytes) acl_ingress_acl_ingress_counter; - @id(0x01000101) @sai_action(SAI_PACKET_ACTION_COPY , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_YELLOW) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_RED) @name("ingress.acl_ingress.acl_copy") action acl_ingress_acl_copy_0(@sai_action_param(QOS_QUEUE) @id(1) @name("qos_queue") bit<8> qos_queue) { + @id(0x13000107) @name("ingress.acl_ingress.acl_ingress_qos_counter") direct_counter(CounterType.packets_and_bytes) acl_ingress_acl_ingress_qos_counter; + @id(0x13000109) @name("ingress.acl_ingress.acl_ingress_counting_counter") direct_counter(CounterType.packets_and_bytes) acl_ingress_acl_ingress_counting_counter; + @id(0x1300010A) @name("ingress.acl_ingress.acl_ingress_security_counter") direct_counter(CounterType.packets_and_bytes) acl_ingress_acl_ingress_security_counter; + @id(0x01000101) @sai_action(SAI_PACKET_ACTION_COPY , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_RED) @name("ingress.acl_ingress.acl_copy") action acl_ingress_acl_copy_0(@sai_action_param(QOS_QUEUE) @id(1) @name("qos_queue") bit<8> qos_queue) { acl_ingress_acl_ingress_counter.count(); - acl_ingress_acl_ingress_meter.read(local_metadata._color18); - clone(CloneType.I2E, 32w1024); + acl_ingress_acl_ingress_meter.read(local_metadata._color32); + local_metadata._marked_to_copy18 = true; } - @id(0x01000102) @sai_action(SAI_PACKET_ACTION_TRAP , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_YELLOW) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED) @name("ingress.acl_ingress.acl_trap") action acl_ingress_acl_trap_0(@sai_action_param(QOS_QUEUE) @id(1) @name("qos_queue") bit<8> qos_queue_3) { - @id(0x01000101) @sai_action(SAI_PACKET_ACTION_COPY , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_YELLOW) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_RED) { + @id(0x01000102) @sai_action(SAI_PACKET_ACTION_TRAP , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED) @name("ingress.acl_ingress.acl_trap") action acl_ingress_acl_trap_0(@sai_action_param(QOS_QUEUE) @id(1) @name("qos_queue") bit<8> qos_queue_2) { + @id(0x01000101) @sai_action(SAI_PACKET_ACTION_COPY , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_RED) { acl_ingress_acl_ingress_counter.count(); - acl_ingress_acl_ingress_meter.read(local_metadata._color18); - clone(CloneType.I2E, 32w1024); + acl_ingress_acl_ingress_meter.read(local_metadata._color32); + local_metadata._marked_to_copy18 = true; } - mark_to_drop(standard_metadata); + local_metadata._acl_drop42 = true; } - @id(0x01000199) @sai_action(SAI_PACKET_ACTION_TRAP , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_YELLOW) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED) @name("ingress.acl_ingress.acl_experimental_trap") action acl_ingress_acl_experimental_trap_0(@sai_action_param(QOS_QUEUE) @id(1) @name("qos_queue") bit<8> qos_queue_4) { - acl_ingress_acl_ingress_meter.read(local_metadata._color18); - @id(0x01000102) @sai_action(SAI_PACKET_ACTION_TRAP , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_YELLOW) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED) { - @id(0x01000101) @sai_action(SAI_PACKET_ACTION_COPY , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_YELLOW) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_RED) { - acl_ingress_acl_ingress_counter.count(); - acl_ingress_acl_ingress_meter.read(local_metadata._color18); - clone(CloneType.I2E, 32w1024); - } - mark_to_drop(standard_metadata); - } + @id(0x01000103) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED) @name("ingress.acl_ingress.acl_forward") action acl_ingress_acl_forward_0() { + acl_ingress_acl_ingress_meter.read(local_metadata._color32); + } + @id(0x01000103) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED) @name("ingress.acl_ingress.acl_forward") action acl_ingress_acl_forward_1() { + acl_ingress_acl_ingress_meter.read(local_metadata._color32); + } + @id(0x01000103) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED) @name("ingress.acl_ingress.acl_forward") action acl_ingress_acl_forward_2() { + acl_ingress_acl_ingress_meter.read(local_metadata._color32); } - @id(0x01000103) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_YELLOW) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED) @name("ingress.acl_ingress.acl_forward") action acl_ingress_acl_forward_0() { + @id(0x01000104) @sai_action(SAI_PACKET_ACTION_FORWARD) @name("ingress.acl_ingress.acl_mirror") action acl_ingress_acl_mirror_0(@id(1) @refers_to(mirror_session_table , mirror_session_id) @sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_MIRROR_INGRESS) @name("mirror_session_id") bit<10> mirror_session_id_1) { acl_ingress_acl_ingress_counter.count(); - acl_ingress_acl_ingress_meter.read(local_metadata._color18); + local_metadata._marked_to_mirror19 = true; + local_metadata._mirror_session_id20 = mirror_session_id_1; } - @id(0x01000104) @sai_action(SAI_PACKET_ACTION_FORWARD) @name("ingress.acl_ingress.acl_mirror") action acl_ingress_acl_mirror_0(@id(1) @refers_to(mirror_session_table , mirror_session_id) @sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_MIRROR_INGRESS) @name("mirror_session_id") bit<10> mirror_session_id) { + @id(0x01000104) @sai_action(SAI_PACKET_ACTION_FORWARD) @name("ingress.acl_ingress.acl_mirror") action acl_ingress_acl_mirror_1(@id(1) @refers_to(mirror_session_table , mirror_session_id) @sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_MIRROR_INGRESS) @name("mirror_session_id") bit<10> mirror_session_id_2) { acl_ingress_acl_ingress_counter.count(); - local_metadata._mirror_session_id_valid10 = true; - local_metadata._mirror_session_id_value11 = mirror_session_id; + local_metadata._marked_to_mirror19 = true; + local_metadata._mirror_session_id20 = mirror_session_id_2; } - @p4runtime_role("sdn_controller") @id(0x02000100) @sai_acl(INGRESS) @entry_restriction(" + @id(0x0100010F) @sai_action(SAI_PACKET_ACTION_DENY) @name("ingress.acl_ingress.acl_deny") action acl_ingress_acl_deny_0() { + acl_ingress_cancel_copy = true; + local_metadata._acl_drop42 = true; + } + @p4runtime_role("sdn_controller") @id(0x02000100) @sai_acl(INGRESS) @sai_acl_priority(5) @entry_restriction(" // Forbid using ether_type for IP packets (by convention, use is_ip* instead). ether_type != 0x0800 && ether_type != 0x86dd; // Only allow IP field matches for IP packets. dst_ip::mask != 0 -> is_ipv4 == 1; + + src_ip::mask != 0 -> is_ipv4 == 1; + dst_ipv6::mask != 0 -> is_ipv6 == 1; + src_ipv6::mask != 0 -> is_ipv6 == 1; ttl::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + dscp::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); ecn::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + ip_protocol::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); // Only allow l4_dst_port and l4_src_port matches for TCP/UDP packets. + l4_src_port::mask != 0 -> (ip_protocol == 6 || ip_protocol == 17); + l4_dst_port::mask != 0 -> (ip_protocol == 6 || ip_protocol == 17); // Only allow arp_tpa matches for ARP packets. arp_tpa::mask != 0 -> ether_type == 0x0806; - // Only allow icmp_type matches for ICMP packets + @@ -634,342 +820,1090 @@ control ingress(inout headers_t headers, inout local_metadata_t local_metadata, is_ipv6::mask != 0 -> (is_ipv6 == 1); ") @name("ingress.acl_ingress.acl_ingress_table") table acl_ingress_acl_ingress_table { key = { - key_2 : optional @name("is_ip") @id(1) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); - headers.ipv4.isValid() : optional @name("is_ipv4") @id(2) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); - headers.ipv6.isValid() : optional @name("is_ipv6") @id(3) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); - headers.ethernet.ether_type : ternary @name("ether_type") @id(4) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ETHER_TYPE); - headers.ethernet.dst_addr : ternary @name("dst_mac") @id(5) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_MAC) @format(MAC_ADDRESS); - headers.ipv4.src_addr : ternary @name("src_ip") @id(6) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_SRC_IP) @format(IPV4_ADDRESS); - headers.ipv4.dst_addr : ternary @name("dst_ip") @id(7) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_IP) @format(IPV4_ADDRESS); - headers.ipv6.src_addr[127:64]: ternary @name("src_ipv6") @id(8) @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_SRC_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_SRC_IPV6_WORD2 )) @format(IPV6_ADDRESS); - headers.ipv6.dst_addr[127:64]: ternary @name("dst_ipv6") @id(9) @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD2 )) @format(IPV6_ADDRESS); - acl_ingress_ttl : ternary @name("ttl") @id(10) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_TTL); - acl_ingress_dscp : ternary @name("dscp") @id(11) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DSCP); - acl_ingress_ecn : ternary @name("ecn") @id(12) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ECN); - acl_ingress_ip_protocol : ternary @name("ip_protocol") @id(13) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IP_PROTOCOL); - headers.icmp.type : ternary @name("icmpv6_type") @id(14) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ICMPV6_TYPE); - local_metadata._l4_src_port4 : ternary @name("l4_src_port") @id(20) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_L4_SRC_PORT); - local_metadata._l4_dst_port5 : ternary @name("l4_dst_port") @id(15) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_L4_DST_PORT); - headers.arp.target_proto_addr: ternary @name("arp_tpa") @id(16) @composite_field(@ sai_udf ( base = SAI_UDF_BASE_L3 , offset = 24 , length = 2 ) , @ sai_udf ( base = SAI_UDF_BASE_L3 , offset = 26 , length = 2 )) @format(IPV4_ADDRESS); + key_3 : optional @id(1) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(2) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(3) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + headers.ethernet.ether_type : ternary @id(4) @name("ether_type") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ETHER_TYPE); + headers.ethernet.dst_addr : ternary @id(5) @name("dst_mac") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_MAC) @format(MAC_ADDRESS); + headers.ipv4.src_addr : ternary @id(6) @name("src_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_SRC_IP) @format(IPV4_ADDRESS); + headers.ipv4.dst_addr : ternary @id(7) @name("dst_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_IP) @format(IPV4_ADDRESS); + headers.ipv6.src_addr[127:64]: ternary @id(8) @name("src_ipv6") @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_SRC_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_SRC_IPV6_WORD2 )) @format(IPV6_ADDRESS); + headers.ipv6.dst_addr[127:64]: ternary @id(9) @name("dst_ipv6") @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD2 )) @format(IPV6_ADDRESS); + acl_ingress_ttl : ternary @id(10) @name("ttl") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_TTL); + acl_ingress_dscp : ternary @id(11) @name("dscp") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DSCP); + acl_ingress_ecn : ternary @id(12) @name("ecn") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ECN); + acl_ingress_ip_protocol : ternary @id(13) @name("ip_protocol") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IP_PROTOCOL); + headers.icmp.type : ternary @id(14) @name("icmpv6_type") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ICMPV6_TYPE); + local_metadata._l4_src_port11: ternary @id(20) @name("l4_src_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_L4_SRC_PORT); + local_metadata._l4_dst_port12: ternary @id(15) @name("l4_dst_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_L4_DST_PORT); + headers.arp.target_proto_addr: ternary @id(16) @name("arp_tpa") @composite_field(@ sai_udf ( base = SAI_UDF_BASE_L3 , offset = 24 , length = 2 ) , @ sai_udf ( base = SAI_UDF_BASE_L3 , offset = 26 , length = 2 )) @format(IPV4_ADDRESS); } actions = { @proto_id(1) acl_ingress_acl_copy_0(); @proto_id(2) acl_ingress_acl_trap_0(); @proto_id(3) acl_ingress_acl_forward_0(); @proto_id(4) acl_ingress_acl_mirror_0(); - @proto_id(5) acl_drop_0(); - @proto_id(99) acl_ingress_acl_experimental_trap_0(); - @defaultonly NoAction_7(); + @proto_id(5) acl_drop_2(); + @defaultonly NoAction_8(); } - const default_action = NoAction_7(); + const default_action = NoAction_8(); meters = acl_ingress_acl_ingress_meter; counters = acl_ingress_acl_ingress_counter; - size = 128; - } - @id(0x01000007) @name("ingress.mirroring_clone.mirror_as_ipv4_erspan") action mirroring_clone_mirror_as_ipv4_erspan_0(@id(1) @name("port") bit<9> port_2, @id(2) @format(IPV4_ADDRESS) @name("src_ip") bit<32> src_ip, @id(3) @format(IPV4_ADDRESS) @name("dst_ip") bit<32> dst_ip, @id(4) @format(MAC_ADDRESS) @name("src_mac") bit<48> src_mac_3, @id(5) @format(MAC_ADDRESS) @name("dst_mac") bit<48> dst_mac_3, @id(6) @name("ttl") bit<8> ttl_0, @id(7) @name("tos") bit<8> tos) { - mirroring_clone_mirror_port = port_2; - local_metadata._mirroring_src_ip12 = src_ip; - local_metadata._mirroring_dst_ip13 = dst_ip; - local_metadata._mirroring_src_mac14 = src_mac_3; - local_metadata._mirroring_dst_mac15 = dst_mac_3; - local_metadata._mirroring_ttl16 = ttl_0; - local_metadata._mirroring_tos17 = tos; - } - @p4runtime_role("sdn_controller") @id(0x02000046) @name("ingress.mirroring_clone.mirror_session_table") table mirroring_clone_mirror_session_table { + size = 255; + } + @id(0x01000112) @name("ingress.acl_ingress.redirect_to_nexthop") action acl_ingress_redirect_to_nexthop_0(@sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_REDIRECT) @sai_action_param_object_type(SAI_OBJECT_TYPE_NEXT_HOP) @refers_to(nexthop_table , nexthop_id) @name("nexthop_id") bit<10> nexthop_id_7) { + local_metadata._nexthop_id_valid39 = true; + local_metadata._nexthop_id_value40 = nexthop_id_7; + local_metadata._wcmp_group_id_valid37 = false; + standard_metadata.mcast_grp = 16w0; + } + @id(0x01000113) @action_restriction(" + // Disallow 0 since it encodes 'no multicast' in V1Model. + multicast_group_id != 0; + ") @name("ingress.acl_ingress.redirect_to_ipmc_group") action acl_ingress_redirect_to_ipmc_group_0(@sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_REDIRECT) @sai_action_param_object_type(SAI_OBJECT_TYPE_IPMC_GROUP) @refers_to(builtin : : multicast_group_table , multicast_group_id) @name("multicast_group_id") bit<16> multicast_group_id_3) { + standard_metadata.mcast_grp = multicast_group_id_3; + local_metadata._nexthop_id_valid39 = false; + local_metadata._wcmp_group_id_valid37 = false; + } + @id(0x0200010B) @sai_acl(INGRESS) @sai_acl_priority(15) @p4runtime_role("sdn_controller") @entry_restriction(" + // Only allow IP field matches for IP packets. + dst_ip::mask != 0 -> is_ipv4 == 1; + dst_ipv6::mask != 0 -> is_ipv6 == 1; + // Forbid illegal combinations of IP_TYPE fields. + is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0); + is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0); + is_ipv6::mask != 0 -> (is_ip::mask == 0 && is_ipv4::mask == 0); + // Forbid unsupported combinations of IP_TYPE fields. + is_ipv4::mask != 0 -> (is_ipv4 == 1); + is_ipv6::mask != 0 -> (is_ipv6 == 1); + ") @name("ingress.acl_ingress.acl_ingress_mirror_and_redirect_table") table acl_ingress_acl_ingress_mirror_and_redirect_table { key = { - local_metadata._mirror_session_id_value11: exact @id(1) @name("mirror_session_id"); + key_6 : optional @id(2) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(3) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(4) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + headers.ipv4.dst_addr : ternary @id(10) @name("dst_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_IP) @format(IPV4_ADDRESS); + headers.ipv6.dst_addr[127:64] : ternary @id(5) @name("dst_ipv6") @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD2 )) @format(IPV6_ADDRESS); + local_metadata._vrf_id3 : optional @id(8) @name("vrf_id") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_VRF_ID); + local_metadata._ipmc_table_hit41: optional @id(9) @name("ipmc_table_hit") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IPMC_NPU_META_DST_HIT); } actions = { - @proto_id(1) mirroring_clone_mirror_as_ipv4_erspan_0(); - @defaultonly NoAction_8(); + @proto_id(4) acl_ingress_acl_forward_1(); + @proto_id(1) acl_ingress_acl_mirror_1(); + @proto_id(2) acl_ingress_redirect_to_nexthop_0(); + @proto_id(3) acl_ingress_redirect_to_ipmc_group_0(); + @defaultonly NoAction_9(); } - const default_action = NoAction_8(); - size = 2; + const default_action = NoAction_9(); + size = 255; } - @id(0x01000009) @name("ingress.mirroring_clone.set_pre_session") action mirroring_clone_set_pre_session_0(@name("id") bit<32> id) { - mirroring_clone_pre_session = id; + @id(0x0200010A) @sai_acl(INGRESS) @sai_acl_priority(20) @p4runtime_role("sdn_controller") @entry_restriction(" + // Forbid using ether_type for IP packets (by convention, use is_ip* instead). + ether_type != 0x0800 && ether_type != 0x86dd; + + // Only allow IP field matches for IP packets. + dst_ip::mask != 0 -> is_ipv4 == 1; + src_ip::mask != 0 -> is_ipv4 == 1; + src_ipv6::mask != 0 -> is_ipv6 == 1; + + // TODO: This comment is required for the preprocessor to not + // spit out nonsense. + + + + + + + + // Forbid illegal combinations of IP_TYPE fields. + is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0); + is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0); + is_ipv6::mask != 0 -> (is_ip::mask == 0 && is_ipv4::mask == 0); + // Forbid unsupported combinations of IP_TYPE fields. + is_ipv4::mask != 0 -> (is_ipv4 == 1); + is_ipv6::mask != 0 -> (is_ipv6 == 1); + ") @name("ingress.acl_ingress.acl_ingress_security_table") table acl_ingress_acl_ingress_security_table { + key = { + key_8 : optional @id(1) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(2) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(3) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + headers.ethernet.ether_type : ternary @id(4) @name("ether_type") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ETHER_TYPE); + headers.ipv4.src_addr : ternary @id(5) @name("src_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_SRC_IP) @format(IPV4_ADDRESS); + headers.ipv4.dst_addr : ternary @id(6) @name("dst_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_IP) @format(IPV4_ADDRESS); + headers.ipv6.src_addr[127:64]: ternary @id(7) @name("src_ipv6") @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_SRC_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_SRC_IPV6_WORD2 )) @format(IPV6_ADDRESS); + } + actions = { + @proto_id(1) acl_ingress_acl_forward_2(); + @proto_id(2) acl_drop_3(); + @proto_id(3) acl_ingress_acl_deny_0(); + @defaultonly NoAction_10(); + } + const default_action = NoAction_10(); + counters = acl_ingress_acl_ingress_security_counter; + size = 255; } - @p4runtime_role("packet_replication_engine_manager") @id(0x02000048) @name("ingress.mirroring_clone.mirror_port_to_pre_session_table") table mirroring_clone_mirror_port_to_pre_session_table { + @id(0x01000001) @name("ingress.routing_resolution.set_dst_mac") action routing_resolution_set_dst_mac_0(@id(1) @format(MAC_ADDRESS) @name("dst_mac") bit<48> dst_mac_2) { + local_metadata._packet_rewrites_dst_mac9 = dst_mac_2; + } + @p4runtime_role("sdn_controller") @id(0x02000040) @name("ingress.routing_resolution.neighbor_table") table routing_resolution_neighbor_table { key = { - mirroring_clone_mirror_port: exact @id(1) @name("mirror_port"); + routing_resolution_router_interface_id_value: exact @id(1) @name("router_interface_id") @refers_to(router_interface_table , router_interface_id); + routing_resolution_neighbor_id_value : exact @id(2) @format(IPV6_ADDRESS) @name("neighbor_id"); } actions = { - @proto_id(1) mirroring_clone_set_pre_session_0(); - @defaultonly NoAction_9(); + @proto_id(1) routing_resolution_set_dst_mac_0(); + @defaultonly NoAction_11(); } - const default_action = NoAction_9(); + const default_action = NoAction_11(); + size = 1024; + } + @id(0x0100001B) @unsupported @action_restriction(" + // Disallow reserved VLAN IDs with implementation-defined semantics. + vlan_id != 0 && vlan_id != 4095") @name("ingress.routing_resolution.set_port_and_src_mac_and_vlan_id") action routing_resolution_set_port_and_src_mac_and_vlan_id_0(@id(1) @name("port") bit<9> port, @id(2) @format(MAC_ADDRESS) @name("src_mac") bit<48> src_mac_4, @id(3) @name("vlan_id") bit<12> vlan_id_1) { + standard_metadata.egress_spec = (bit<9>)port; + local_metadata._packet_rewrites_src_mac8 = src_mac_4; + local_metadata._packet_rewrites_vlan_id10 = vlan_id_1; + } + @id(0x01000002) @name("ingress.routing_resolution.set_port_and_src_mac") action routing_resolution_set_port_and_src_mac_0(@id(1) @name("port") bit<9> port_3, @id(2) @format(MAC_ADDRESS) @name("src_mac") bit<48> src_mac_5) { + @id(0x0100001B) @unsupported @action_restriction(" + // Disallow reserved VLAN IDs with implementation-defined semantics. + vlan_id != 0 && vlan_id != 4095") { + standard_metadata.egress_spec = (bit<9>)port_3; + local_metadata._packet_rewrites_src_mac8 = src_mac_5; + local_metadata._packet_rewrites_vlan_id10 = 12w0xfff; + } + } + @p4runtime_role("sdn_controller") @id(0x02000041) @name("ingress.routing_resolution.router_interface_table") table routing_resolution_router_interface_table { + key = { + routing_resolution_router_interface_id_value: exact @id(1) @name("router_interface_id"); + } + actions = { + @proto_id(1) routing_resolution_set_port_and_src_mac_0(); + @proto_id(2) routing_resolution_set_port_and_src_mac_and_vlan_id_0(); + @defaultonly NoAction_12(); + } + const default_action = NoAction_12(); + size = 256; + } + @id(0x01000017) @name("ingress.routing_resolution.set_ip_nexthop_and_disable_rewrites") action routing_resolution_set_ip_nexthop_and_disable_rewrites_0(@id(1) @refers_to(router_interface_table , router_interface_id) @refers_to(neighbor_table , router_interface_id) @name("router_interface_id") bit<10> router_interface_id, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) @name("neighbor_id") bit<128> neighbor_id, @id(3) @name("disable_decrement_ttl") bit<1> disable_decrement_ttl, @id(4) @name("disable_src_mac_rewrite") bit<1> disable_src_mac_rewrite, @id(5) @name("disable_dst_mac_rewrite") bit<1> disable_dst_mac_rewrite, @id(6) @name("disable_vlan_rewrite") bit<1> disable_vlan_rewrite) { + routing_resolution_router_interface_id_valid = true; + routing_resolution_router_interface_id_value = router_interface_id; + routing_resolution_neighbor_id_valid = true; + routing_resolution_neighbor_id_value = neighbor_id; + local_metadata._enable_decrement_ttl4 = !(bool)disable_decrement_ttl; + local_metadata._enable_src_mac_rewrite5 = !(bool)disable_src_mac_rewrite; + local_metadata._enable_dst_mac_rewrite6 = !(bool)disable_dst_mac_rewrite; + local_metadata._enable_vlan_rewrite7 = !(bool)disable_vlan_rewrite; + } + @id(0x01000014) @name("ingress.routing_resolution.set_ip_nexthop") action routing_resolution_set_ip_nexthop_0(@id(1) @refers_to(router_interface_table , router_interface_id) @refers_to(neighbor_table , router_interface_id) @name("router_interface_id") bit<10> router_interface_id_4, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) @name("neighbor_id") bit<128> neighbor_id_3) { + @id(0x01000017) { + routing_resolution_router_interface_id_valid = true; + routing_resolution_router_interface_id_value = router_interface_id_4; + routing_resolution_neighbor_id_valid = true; + routing_resolution_neighbor_id_value = neighbor_id_3; + local_metadata._enable_decrement_ttl4 = true; + local_metadata._enable_src_mac_rewrite5 = true; + local_metadata._enable_dst_mac_rewrite6 = true; + local_metadata._enable_vlan_rewrite7 = true; + } + } + @id(0x01000003) @deprecated("Use set_ip_nexthop instead.") @name("ingress.routing_resolution.set_nexthop") action routing_resolution_set_nexthop_0(@id(1) @refers_to(router_interface_table , router_interface_id) @refers_to(neighbor_table , router_interface_id) @name("router_interface_id") bit<10> router_interface_id_5, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) @name("neighbor_id") bit<128> neighbor_id_4) { + @id(0x01000014) { + @id(0x01000017) { + routing_resolution_router_interface_id_valid = true; + routing_resolution_router_interface_id_value = router_interface_id_5; + routing_resolution_neighbor_id_valid = true; + routing_resolution_neighbor_id_value = neighbor_id_4; + local_metadata._enable_decrement_ttl4 = true; + local_metadata._enable_src_mac_rewrite5 = true; + local_metadata._enable_dst_mac_rewrite6 = true; + local_metadata._enable_vlan_rewrite7 = true; + } + } + } + @id(0x01000012) @name("ingress.routing_resolution.set_p2p_tunnel_encap_nexthop") action routing_resolution_set_p2p_tunnel_encap_nexthop_0(@id(1) @refers_to(tunnel_table , tunnel_id) @name("tunnel_id") bit<10> tunnel_id) { + routing_resolution_tunnel_id_valid = true; + routing_resolution_tunnel_id_value = tunnel_id; + } + @p4runtime_role("sdn_controller") @id(0x02000042) @name("ingress.routing_resolution.nexthop_table") table routing_resolution_nexthop_table { + key = { + local_metadata._nexthop_id_value40: exact @id(1) @name("nexthop_id"); + } + actions = { + @proto_id(1) routing_resolution_set_nexthop_0(); + @proto_id(2) routing_resolution_set_p2p_tunnel_encap_nexthop_0(); + @proto_id(3) routing_resolution_set_ip_nexthop_0(); + @proto_id(4) routing_resolution_set_ip_nexthop_and_disable_rewrites_0(); + @defaultonly NoAction_13(); + } + const default_action = NoAction_13(); + size = 1024; + } + @id(0x01000013) @name("ingress.routing_resolution.mark_for_p2p_tunnel_encap") action routing_resolution_mark_for_p2p_tunnel_encap_0(@id(1) @format(IPV6_ADDRESS) @name("encap_src_ip") bit<128> encap_src_ip, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) @name("encap_dst_ip") bit<128> encap_dst_ip, @id(3) @refers_to(neighbor_table , router_interface_id) @refers_to(router_interface_table , router_interface_id) @name("router_interface_id") bit<10> router_interface_id_6) { + local_metadata._tunnel_encap_src_ipv616 = encap_src_ip; + local_metadata._tunnel_encap_dst_ipv617 = encap_dst_ip; + local_metadata._apply_tunnel_encap_at_egress15 = true; + @id(0x01000014) { + @id(0x01000017) { + routing_resolution_router_interface_id_valid = true; + routing_resolution_router_interface_id_value = router_interface_id_6; + routing_resolution_neighbor_id_valid = true; + routing_resolution_neighbor_id_value = encap_dst_ip; + local_metadata._enable_decrement_ttl4 = true; + local_metadata._enable_src_mac_rewrite5 = true; + local_metadata._enable_dst_mac_rewrite6 = true; + local_metadata._enable_vlan_rewrite7 = true; + } + } + } + @p4runtime_role("sdn_controller") @id(0x02000050) @name("ingress.routing_resolution.tunnel_table") table routing_resolution_tunnel_table { + key = { + routing_resolution_tunnel_id_value: exact @id(1) @name("tunnel_id"); + } + actions = { + @proto_id(1) routing_resolution_mark_for_p2p_tunnel_encap_0(); + @defaultonly NoAction_14(); + } + const default_action = NoAction_14(); + size = 2048; } - @hidden action pins_middleblock736() { + @max_group_size(512) @id(0x11DC4EC8) @name("ingress.routing_resolution.wcmp_group_selector") action_selector(HashAlgorithm.identity, 32w49152, 32w8) routing_resolution_wcmp_group_selector; + @p4runtime_role("sdn_controller") @id(0x02000043) @oneshot @name("ingress.routing_resolution.wcmp_group_table") table routing_resolution_wcmp_group_table { + key = { + local_metadata._wcmp_group_id_value38: exact @id(1) @name("wcmp_group_id"); + local_metadata._wcmp_selector_input13: selector @name("local_metadata.wcmp_selector_input"); + } + actions = { + @proto_id(1) set_nexthop_id_3(); + @defaultonly NoAction_15(); + } + const default_action = NoAction_15(); + implementation = routing_resolution_wcmp_group_selector; + size = 3968; + } + @id(0x01000007) @name("ingress.mirror_session_lookup.mirror_as_ipv4_erspan") action mirror_session_lookup_mirror_as_ipv4_erspan_0(@id(1) @name("port") bit<9> port_4, @id(2) @format(IPV4_ADDRESS) @name("src_ip") bit<32> src_ip, @id(3) @format(IPV4_ADDRESS) @name("dst_ip") bit<32> dst_ip, @id(4) @format(MAC_ADDRESS) @name("src_mac") bit<48> src_mac_6, @id(5) @format(MAC_ADDRESS) @name("dst_mac") bit<48> dst_mac_3, @id(6) @name("ttl") bit<8> ttl_1, @id(7) @name("tos") bit<8> tos) { + } + @id(0x0100001D) @unsupported @name("ingress.mirror_session_lookup.mirror_with_vlan_tag_and_ipfix_encapsulation") action mirror_session_lookup_mirror_with_vlan_tag_and_ipfix_encapsulation_0(@id(1) @name("monitor_port") bit<9> monitor_port, @id(2) @name("monitor_failover_port") bit<9> monitor_failover_port, @id(3) @format(MAC_ADDRESS) @name("mirror_encap_src_mac") bit<48> mirror_encap_src_mac_1, @id(4) @format(MAC_ADDRESS) @name("mirror_encap_dst_mac") bit<48> mirror_encap_dst_mac_1, @id(6) @name("mirror_encap_vlan_id") bit<12> mirror_encap_vlan_id_1, @id(7) @format(IPV6_ADDRESS) @name("mirror_encap_dst_ip") bit<128> mirror_encap_dst_ip_1, @id(8) @format(IPV6_ADDRESS) @name("mirror_encap_src_ip") bit<128> mirror_encap_src_ip_1, @id(9) @name("mirror_encap_udp_src_port") bit<16> mirror_encap_udp_src_port_1, @id(10) @name("mirror_encap_udp_dst_port") bit<16> mirror_encap_udp_dst_port_1) { + local_metadata._mirror_egress_port21 = monitor_port; + local_metadata._mirror_encap_src_mac22 = mirror_encap_src_mac_1; + local_metadata._mirror_encap_dst_mac23 = mirror_encap_dst_mac_1; + local_metadata._mirror_encap_vlan_id24 = mirror_encap_vlan_id_1; + local_metadata._mirror_encap_src_ip25 = mirror_encap_src_ip_1; + local_metadata._mirror_encap_dst_ip26 = mirror_encap_dst_ip_1; + local_metadata._mirror_encap_udp_src_port27 = mirror_encap_udp_src_port_1; + local_metadata._mirror_encap_udp_dst_port28 = mirror_encap_udp_dst_port_1; + } + @p4runtime_role("sdn_controller") @id(0x02000046) @name("ingress.mirror_session_lookup.mirror_session_table") table mirror_session_lookup_mirror_session_table { + key = { + local_metadata._mirror_session_id20: exact @id(1) @name("mirror_session_id"); + } + actions = { + @proto_id(1) mirror_session_lookup_mirror_as_ipv4_erspan_0(); + @proto_id(2) mirror_session_lookup_mirror_with_vlan_tag_and_ipfix_encapsulation_0(); + @defaultonly NoAction_16(); + } + const default_action = NoAction_16(); + size = 4; + } + @id(0x0100001C) @name("ingress.ingress_cloning.ingress_clone") action ingress_cloning_ingress_clone_0(@id(1) @name("clone_session") bit<32> clone_session) { + clone_preserving_field_list(CloneType.I2E, clone_session, 8w1); + } + @unsupported @p4runtime_role("packet_replication_engine_manager") @id(0x02000051) @entry_restriction(" + // mirror_egress_port is present iff marked_to_mirror is true. + // Exact match indicating presence of mirror_egress_port. + marked_to_mirror == 1 -> mirror_egress_port::mask == -1; + // Wildcard match indicating abscence of mirror_egress_port. + marked_to_mirror == 0 -> mirror_egress_port::mask == 0; + ") @name("ingress.ingress_cloning.ingress_clone_table") table ingress_cloning_ingress_clone_table { + key = { + local_metadata._marked_to_copy18 : exact @id(1) @name("marked_to_copy"); + local_metadata._marked_to_mirror19 : exact @id(2) @name("marked_to_mirror"); + local_metadata._mirror_egress_port21: optional @id(3) @name("mirror_egress_port"); + } + actions = { + @proto_id(1) ingress_cloning_ingress_clone_0(); + @defaultonly NoAction_17(); + } + default_action = NoAction_17(); + } + @hidden action pins_middleblock420() { + standard_metadata.egress_spec = (bit<9>)headers.packet_out_header.egress_port; + local_metadata._bypass_ingress36 = true; + } + @hidden action pins_middleblock855() { + local_metadata._vlan_id1 = headers.vlan.vlan_id; + headers.ethernet.ether_type = headers.vlan.ether_type; + headers.vlan.setInvalid(); + } + @hidden action pins_middleblock859() { + local_metadata._vlan_id1 = 12w0xfff; + } + @hidden action pins_middleblock846() { + local_metadata._enable_vlan_checks0 = true; + key_0 = 1w1; + } + @hidden action pins_middleblock1532() { acl_pre_ingress_dscp = headers.ipv4.dscp; + acl_pre_ingress_ecn = headers.ipv4.ecn; } - @hidden action pins_middleblock738() { + @hidden action pins_middleblock1536() { acl_pre_ingress_dscp = headers.ipv6.dscp; + acl_pre_ingress_ecn = headers.ipv6.ecn; } - @hidden action pins_middleblock694() { + @hidden action pins_middleblock1412() { acl_pre_ingress_dscp = 6w0; + acl_pre_ingress_ecn = 2w0; + } + @hidden action pins_middleblock1452() { + key_1 = headers.ipv4.isValid() || headers.ipv6.isValid(); + } + @hidden action pins_middleblock869() { + mark_to_drop(standard_metadata); } - @hidden action pins_middleblock717() { - local_metadata._vrf_id1 = 10w0; - key_0 = headers.ipv4.isValid() || headers.ipv6.isValid(); + @hidden action pins_middleblock1005() { + headers.ethernet.ether_type = 16w0x800; + headers.ipv4 = headers.inner_ipv4; + headers.inner_ipv4.setInvalid(); } - @hidden action pins_middleblock747() { - local_metadata._admit_to_l30 = headers.ethernet.dst_addr & 48w0x10000000000 == 48w0; + @hidden action pins_middleblock1001() { + assert(headers.ipv6.isValid()); + assert(headers.inner_ipv4.isValid() && !headers.inner_ipv6.isValid() || !headers.inner_ipv4.isValid() && headers.inner_ipv6.isValid()); + headers.ipv6.setInvalid(); } - @hidden action pins_middleblock262() { - routing_wcmp_group_id_valid = false; - routing_nexthop_id_valid = false; - routing_router_interface_id_valid = false; - routing_neighbor_id_valid = false; + @hidden action pins_middleblock1010() { + headers.ethernet.ether_type = 16w0x86dd; + headers.ipv6 = headers.inner_ipv6; + headers.inner_ipv6.setInvalid(); + } + @hidden action pins_middleblock797() { + local_metadata._admit_to_l32 = false; + } + @hidden action pins_middleblock1546() { + local_metadata._admit_to_l32 = headers.ethernet.dst_addr == 48w0x1a11175f80; + } + @hidden action pins_middleblock530() { mark_to_drop(standard_metadata); } - @hidden action pins_middleblock679() { + @hidden action pins_middleblock536() { + local_metadata._ipmc_table_hit41 = standard_metadata.mcast_grp != 16w0; + } + @hidden action pins_middleblock540() { + local_metadata._ipmc_table_hit41 = standard_metadata.mcast_grp != 16w0; + } + @hidden action pins_middleblock1392() { acl_ingress_ttl = headers.ipv4.ttl; acl_ingress_dscp = headers.ipv4.dscp; acl_ingress_ecn = headers.ipv4.ecn; acl_ingress_ip_protocol = headers.ipv4.protocol; } - @hidden action pins_middleblock684() { + @hidden action pins_middleblock1397() { acl_ingress_ttl = headers.ipv6.hop_limit; acl_ingress_dscp = headers.ipv6.dscp; acl_ingress_ecn = headers.ipv6.ecn; acl_ingress_ip_protocol = headers.ipv6.next_header; } - @hidden action pins_middleblock586() { + @hidden action pins_middleblock1115() { acl_ingress_ttl = 8w0; acl_ingress_dscp = 6w0; acl_ingress_ecn = 2w0; acl_ingress_ip_protocol = 8w0; + acl_ingress_cancel_copy = false; + } + @hidden action pins_middleblock1200() { + key_3 = headers.ipv4.isValid() || headers.ipv6.isValid(); + } + @hidden action pins_middleblock1327() { + key_6 = headers.ipv4.isValid() || headers.ipv6.isValid(); } - @hidden action pins_middleblock645() { - key_2 = headers.ipv4.isValid() || headers.ipv6.isValid(); + @hidden action pins_middleblock1372() { + key_8 = headers.ipv4.isValid() || headers.ipv6.isValid(); } - @hidden action pins_middleblock557() { + @hidden action pins_middleblock1406() { + local_metadata._marked_to_copy18 = false; + } + @hidden action pins_middleblock547() { + routing_resolution_tunnel_id_valid = false; + routing_resolution_router_interface_id_valid = false; + routing_resolution_neighbor_id_valid = false; + } + @hidden action pins_middleblock674() { mark_to_drop(standard_metadata); } - @hidden action pins_middleblock559() { - headers.ipv4.ttl = headers.ipv4.ttl + 8w255; + @hidden action pins_middleblock671() { + local_metadata._packet_in_target_egress_port31 = standard_metadata.egress_spec; + local_metadata._packet_in_ingress_port30 = standard_metadata.ingress_port; } - @hidden action pins_middleblock564() { + @hidden action pins_middleblock913() { mark_to_drop(standard_metadata); } - @hidden action pins_middleblock566() { - headers.ipv6.hop_limit = headers.ipv6.hop_limit + 8w255; + @hidden action pins_middleblock423() { + headers.packet_out_header.setInvalid(); + } + @hidden table tbl_pins_middleblock420 { + actions = { + pins_middleblock420(); + } + const default_action = pins_middleblock420(); + } + @hidden table tbl_pins_middleblock423 { + actions = { + pins_middleblock423(); + } + const default_action = pins_middleblock423(); + } + @hidden table tbl_pins_middleblock855 { + actions = { + pins_middleblock855(); + } + const default_action = pins_middleblock855(); } - @hidden action pins_middleblock524() { - clone_preserving_field_list(CloneType.I2E, mirroring_clone_pre_session, 8w1); + @hidden table tbl_pins_middleblock859 { + actions = { + pins_middleblock859(); + } + const default_action = pins_middleblock859(); } - @hidden table tbl_pins_middleblock694 { + @hidden table tbl_pins_middleblock846 { actions = { - pins_middleblock694(); + pins_middleblock846(); } - const default_action = pins_middleblock694(); + const default_action = pins_middleblock846(); } - @hidden table tbl_pins_middleblock736 { + @hidden table tbl_pins_middleblock1412 { actions = { - pins_middleblock736(); + pins_middleblock1412(); } - const default_action = pins_middleblock736(); + const default_action = pins_middleblock1412(); } - @hidden table tbl_pins_middleblock738 { + @hidden table tbl_pins_middleblock1532 { actions = { - pins_middleblock738(); + pins_middleblock1532(); } - const default_action = pins_middleblock738(); + const default_action = pins_middleblock1532(); } - @hidden table tbl_pins_middleblock717 { + @hidden table tbl_pins_middleblock1536 { actions = { - pins_middleblock717(); + pins_middleblock1536(); } - const default_action = pins_middleblock717(); + const default_action = pins_middleblock1536(); } - @hidden table tbl_pins_middleblock747 { + @hidden table tbl_pins_middleblock1452 { actions = { - pins_middleblock747(); + pins_middleblock1452(); } - const default_action = pins_middleblock747(); + const default_action = pins_middleblock1452(); } - @hidden table tbl_pins_middleblock262 { + @hidden table tbl_pins_middleblock869 { actions = { - pins_middleblock262(); + pins_middleblock869(); } - const default_action = pins_middleblock262(); + const default_action = pins_middleblock869(); } - @hidden table tbl_pins_middleblock586 { + @hidden table tbl_pins_middleblock1001 { actions = { - pins_middleblock586(); + pins_middleblock1001(); } - const default_action = pins_middleblock586(); + const default_action = pins_middleblock1001(); } - @hidden table tbl_pins_middleblock679 { + @hidden table tbl_pins_middleblock1005 { actions = { - pins_middleblock679(); + pins_middleblock1005(); } - const default_action = pins_middleblock679(); + const default_action = pins_middleblock1005(); } - @hidden table tbl_pins_middleblock684 { + @hidden table tbl_pins_middleblock1010 { actions = { - pins_middleblock684(); + pins_middleblock1010(); } - const default_action = pins_middleblock684(); + const default_action = pins_middleblock1010(); } - @hidden table tbl_pins_middleblock645 { + @hidden table tbl_pins_middleblock1546 { actions = { - pins_middleblock645(); + pins_middleblock1546(); } - const default_action = pins_middleblock645(); + const default_action = pins_middleblock1546(); } - @hidden table tbl_pins_middleblock557 { + @hidden table tbl_pins_middleblock797 { actions = { - pins_middleblock557(); + pins_middleblock797(); } - const default_action = pins_middleblock557(); + const default_action = pins_middleblock797(); } - @hidden table tbl_pins_middleblock559 { + @hidden table tbl_hashing_select_ecmp_hash_algorithm { actions = { - pins_middleblock559(); + hashing_select_ecmp_hash_algorithm_0(); } - const default_action = pins_middleblock559(); + const default_action = hashing_select_ecmp_hash_algorithm_0(); } - @hidden table tbl_pins_middleblock564 { + @hidden table tbl_hashing_compute_ecmp_hash_ipv4 { actions = { - pins_middleblock564(); + hashing_compute_ecmp_hash_ipv4_0(); } - const default_action = pins_middleblock564(); + const default_action = hashing_compute_ecmp_hash_ipv4_0(); } - @hidden table tbl_pins_middleblock566 { + @hidden table tbl_hashing_compute_ecmp_hash_ipv6 { actions = { - pins_middleblock566(); + hashing_compute_ecmp_hash_ipv6_0(); } - const default_action = pins_middleblock566(); + const default_action = hashing_compute_ecmp_hash_ipv6_0(); } - @hidden table tbl_pins_middleblock524 { + @hidden table tbl_pins_middleblock530 { actions = { - pins_middleblock524(); + pins_middleblock530(); } - const default_action = pins_middleblock524(); + const default_action = pins_middleblock530(); + } + @hidden table tbl_pins_middleblock536 { + actions = { + pins_middleblock536(); + } + const default_action = pins_middleblock536(); + } + @hidden table tbl_pins_middleblock540 { + actions = { + pins_middleblock540(); + } + const default_action = pins_middleblock540(); + } + @hidden table tbl_pins_middleblock1115 { + actions = { + pins_middleblock1115(); + } + const default_action = pins_middleblock1115(); + } + @hidden table tbl_pins_middleblock1392 { + actions = { + pins_middleblock1392(); + } + const default_action = pins_middleblock1392(); + } + @hidden table tbl_pins_middleblock1397 { + actions = { + pins_middleblock1397(); + } + const default_action = pins_middleblock1397(); + } + @hidden table tbl_pins_middleblock1200 { + actions = { + pins_middleblock1200(); + } + const default_action = pins_middleblock1200(); + } + @hidden table tbl_pins_middleblock1327 { + actions = { + pins_middleblock1327(); + } + const default_action = pins_middleblock1327(); + } + @hidden table tbl_pins_middleblock1372 { + actions = { + pins_middleblock1372(); + } + const default_action = pins_middleblock1372(); + } + @hidden table tbl_pins_middleblock1406 { + actions = { + pins_middleblock1406(); + } + const default_action = pins_middleblock1406(); + } + @hidden table tbl_pins_middleblock547 { + actions = { + pins_middleblock547(); + } + const default_action = pins_middleblock547(); + } + @hidden table tbl_pins_middleblock671 { + actions = { + pins_middleblock671(); + } + const default_action = pins_middleblock671(); + } + @hidden table tbl_pins_middleblock674 { + actions = { + pins_middleblock674(); + } + const default_action = pins_middleblock674(); + } + @hidden table tbl_pins_middleblock913 { + actions = { + pins_middleblock913(); + } + const default_action = pins_middleblock913(); } apply { - tbl_pins_middleblock694.apply(); - if (headers.ipv4.isValid()) { - tbl_pins_middleblock736.apply(); - } else if (headers.ipv6.isValid()) { - tbl_pins_middleblock738.apply(); - } - tbl_pins_middleblock717.apply(); - acl_pre_ingress_acl_pre_ingress_table.apply(); - tbl_pins_middleblock747.apply(); - l3_admit_l3_admit_table.apply(); - tbl_pins_middleblock262.apply(); - routing_vrf_table.apply(); - if (local_metadata._admit_to_l30) { + if (headers.packet_out_header.isValid() && headers.packet_out_header.submit_to_ingress == 1w0) { + tbl_pins_middleblock420.apply(); + } + tbl_pins_middleblock423.apply(); + if (local_metadata._bypass_ingress36) { + ; + } else { + if (headers.ipv6.isValid()) { + if (headers.ipv6.next_header == 8w0x4 || headers.ipv6.next_header == 8w0x29) { + tunnel_termination_lookup_ipv6_tunnel_termination_table.apply(); + } + } + if (headers.vlan.isValid()) { + tbl_pins_middleblock855.apply(); + } else { + tbl_pins_middleblock859.apply(); + } + tbl_pins_middleblock846.apply(); + vlan_untag_disable_vlan_checks_table.apply(); + tbl_pins_middleblock1412.apply(); if (headers.ipv4.isValid()) { - routing_ipv4_table.apply(); + tbl_pins_middleblock1532.apply(); } else if (headers.ipv6.isValid()) { - routing_ipv6_table.apply(); + tbl_pins_middleblock1536.apply(); } - if (routing_wcmp_group_id_valid) { - routing_wcmp_group_table.apply(); + tbl_pins_middleblock1452.apply(); + acl_pre_ingress_acl_pre_ingress_table.apply(); + if (local_metadata._enable_vlan_checks0 && !(local_metadata._vlan_id1 == 12w0x0 || local_metadata._vlan_id1 == 12w0xfff)) { + tbl_pins_middleblock869.apply(); } - if (routing_nexthop_id_valid) { - routing_nexthop_table.apply(); - if (routing_router_interface_id_valid && routing_neighbor_id_valid) { - routing_router_interface_table.apply(); - routing_neighbor_table.apply(); + if (local_metadata._apply_tunnel_decap_at_end_of_pre_ingress14) { + tbl_pins_middleblock1001.apply(); + if (headers.inner_ipv4.isValid()) { + tbl_pins_middleblock1005.apply(); + } + if (headers.inner_ipv6.isValid()) { + tbl_pins_middleblock1010.apply(); } } - } - tbl_pins_middleblock586.apply(); - if (headers.ipv4.isValid()) { - tbl_pins_middleblock679.apply(); - } else if (headers.ipv6.isValid()) { - tbl_pins_middleblock684.apply(); - } - tbl_pins_middleblock645.apply(); - acl_ingress_acl_ingress_table.apply(); - if (local_metadata._admit_to_l30) { + tbl_pins_middleblock1546.apply(); + if (local_metadata._enable_vlan_checks0 && !(local_metadata._vlan_id1 == 12w0x0 || local_metadata._vlan_id1 == 12w0xfff)) { + tbl_pins_middleblock797.apply(); + } else { + l3_admit_l3_admit_table.apply(); + } + tbl_hashing_select_ecmp_hash_algorithm.apply(); if (headers.ipv4.isValid()) { - if (headers.ipv4.ttl <= 8w1) { - tbl_pins_middleblock557.apply(); - } else { - tbl_pins_middleblock559.apply(); - } + tbl_hashing_compute_ecmp_hash_ipv4.apply(); + } else if (headers.ipv6.isValid()) { + tbl_hashing_compute_ecmp_hash_ipv6.apply(); } - if (headers.ipv6.isValid()) { - if (headers.ipv6.hop_limit <= 8w1) { - tbl_pins_middleblock564.apply(); - } else { - tbl_pins_middleblock566.apply(); + tbl_pins_middleblock530.apply(); + routing_lookup_vrf_table.apply(); + if (local_metadata._admit_to_l32) { + if (headers.ipv4.isValid()) { + routing_lookup_ipv4_table.apply(); + routing_lookup_ipv4_multicast_table.apply(); + tbl_pins_middleblock536.apply(); + } else if (headers.ipv6.isValid()) { + routing_lookup_ipv6_table.apply(); + routing_lookup_ipv6_multicast_table.apply(); + tbl_pins_middleblock540.apply(); } } - } - if (local_metadata._mirror_session_id_valid10) { - if (mirroring_clone_mirror_session_table.apply().hit) { - if (mirroring_clone_mirror_port_to_pre_session_table.apply().hit) { - tbl_pins_middleblock524.apply(); + tbl_pins_middleblock1115.apply(); + if (headers.ipv4.isValid()) { + tbl_pins_middleblock1392.apply(); + } else if (headers.ipv6.isValid()) { + tbl_pins_middleblock1397.apply(); + } + tbl_pins_middleblock1200.apply(); + acl_ingress_acl_ingress_table.apply(); + tbl_pins_middleblock1327.apply(); + acl_ingress_acl_ingress_mirror_and_redirect_table.apply(); + tbl_pins_middleblock1372.apply(); + acl_ingress_acl_ingress_security_table.apply(); + if (acl_ingress_cancel_copy) { + tbl_pins_middleblock1406.apply(); + } + tbl_pins_middleblock547.apply(); + if (local_metadata._admit_to_l32) { + if (local_metadata._wcmp_group_id_valid37) { + routing_resolution_wcmp_group_table.apply(); + } + if (local_metadata._nexthop_id_valid39) { + routing_resolution_nexthop_table.apply(); + if (routing_resolution_tunnel_id_valid) { + routing_resolution_tunnel_table.apply(); + } + if (routing_resolution_router_interface_id_valid && routing_resolution_neighbor_id_valid) { + routing_resolution_router_interface_table.apply(); + routing_resolution_neighbor_table.apply(); + } } } + tbl_pins_middleblock671.apply(); + if (local_metadata._acl_drop42) { + tbl_pins_middleblock674.apply(); + } + if (local_metadata._marked_to_mirror19) { + mirror_session_lookup_mirror_session_table.apply(); + } + ingress_cloning_ingress_clone_table.apply(); + if (headers.ipv6.isValid() && (headers.ipv6.src_addr & 128w0xff000000000000000000000000000000 == 128w0xff000000000000000000000000000000 || headers.ipv6.dst_addr & 128w0xff000000000000000000000000000000 == 128w0xff000000000000000000000000000000 || headers.ipv6.src_addr == 128w0x1 || headers.ipv6.dst_addr == 128w0x1) || headers.ipv4.isValid() && (headers.ipv4.src_addr & 32w0xf0000000 == 32w0xe0000000 || headers.ipv4.src_addr == 32w0xffffffff || (headers.ipv4.dst_addr & 32w0xf0000000 == 32w0xe0000000 || headers.ipv4.dst_addr == 32w0xffffffff) || headers.ipv4.src_addr & 32w0xff000000 == 32w0x7f000000 || headers.ipv4.dst_addr & 32w0xff000000 == 32w0x7f000000) || headers.ethernet.isValid() && headers.ethernet.dst_addr & 48w0x10000000000 == 48w0x10000000000) { + tbl_pins_middleblock913.apply(); + } } } } control egress(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { - @hidden action pins_middleblock576() { - headers.ethernet.src_addr = local_metadata._packet_rewrites_src_mac2; - headers.ethernet.dst_addr = local_metadata._packet_rewrites_dst_mac3; - } - @hidden action pins_middleblock449() { - headers.erspan_ethernet.setValid(); - headers.erspan_ethernet.src_addr = local_metadata._mirroring_src_mac14; - headers.erspan_ethernet.dst_addr = local_metadata._mirroring_dst_mac15; - headers.erspan_ethernet.ether_type = 16w0x800; - headers.erspan_ipv4.setValid(); - headers.erspan_ipv4.src_addr = local_metadata._mirroring_src_ip12; - headers.erspan_ipv4.dst_addr = local_metadata._mirroring_dst_ip13; - headers.erspan_ipv4.version = 4w4; - headers.erspan_ipv4.ihl = 4w5; - headers.erspan_ipv4.protocol = 8w0x2f; - headers.erspan_ipv4.ttl = local_metadata._mirroring_ttl16; - headers.erspan_ipv4.dscp = local_metadata._mirroring_tos17[7:2]; - headers.erspan_ipv4.ecn = local_metadata._mirroring_tos17[1:0]; - headers.erspan_ipv4.total_len = 16w24 + (bit<16>)standard_metadata.packet_length; - headers.erspan_ipv4.identification = 16w0; - headers.erspan_ipv4.reserved = 1w0; - headers.erspan_ipv4.do_not_fragment = 1w1; - headers.erspan_ipv4.more_fragments = 1w0; - headers.erspan_ipv4.frag_offset = 13w0; - headers.erspan_ipv4.header_checksum = 16w0; - headers.erspan_gre.setValid(); - headers.erspan_gre.checksum_present = 1w0; - headers.erspan_gre.routing_present = 1w0; - headers.erspan_gre.key_present = 1w0; - headers.erspan_gre.sequence_present = 1w0; - headers.erspan_gre.strict_source_route = 1w0; - headers.erspan_gre.recursion_control = 3w0; - headers.erspan_gre.acknowledgement_present = 1w0; - headers.erspan_gre.flags = 4w0; - headers.erspan_gre.version = 3w0; - headers.erspan_gre.protocol = 16w0x88be; - } - @hidden table tbl_pins_middleblock576 { - actions = { - pins_middleblock576(); - } - const default_action = pins_middleblock576(); - } - @hidden table tbl_pins_middleblock449 { - actions = { - pins_middleblock449(); - } - const default_action = pins_middleblock449(); + @name("egress.acl_egress.ip_protocol") bit<8> acl_egress_ip_protocol; + bool key_10; + @noWarn("unused") @name(".NoAction") action NoAction_18() { } - apply { - if (local_metadata._admit_to_l30) { - tbl_pins_middleblock576.apply(); + @noWarn("unused") @name(".NoAction") action NoAction_19() { + } + @id(0x01000109) @sai_action(SAI_PACKET_ACTION_DROP) @name(".acl_drop") action acl_drop_4() { + local_metadata._acl_drop42 = true; + } + @id(0x01000019) @name("egress.packet_rewrites.multicast_rewrites.set_multicast_src_mac") action packet_rewrites_multicast_rewrites_set_multicast_src_mac_0(@id(1) @format(MAC_ADDRESS) @name("src_mac") bit<48> src_mac_7) { + local_metadata._enable_src_mac_rewrite5 = true; + local_metadata._packet_rewrites_src_mac8 = src_mac_7; + } + @p4runtime_role("sdn_controller") @id(0x0200004C) @name("egress.packet_rewrites.multicast_rewrites.multicast_router_interface_table") table packet_rewrites_multicast_rewrites_multicast_router_interface_table { + key = { + standard_metadata.egress_port: exact @referenced_by(builtin : : multicast_group_table , replica . port) @id(1) @name("multicast_replica_port"); + standard_metadata.egress_rid : exact @referenced_by(builtin : : multicast_group_table , replica . instance) @id(2) @name("multicast_replica_instance"); + } + actions = { + @proto_id(1) packet_rewrites_multicast_rewrites_set_multicast_src_mac_0(); + @defaultonly NoAction_18(); + } + size = 110; + default_action = NoAction_18(); + } + @id(0x13000104) @name("egress.acl_egress.acl_egress_counter") direct_counter(CounterType.packets_and_bytes) acl_egress_acl_egress_counter; + @id(0x13000108) @name("egress.acl_egress.acl_egress_dhcp_to_host_counter") direct_counter(CounterType.packets_and_bytes) acl_egress_acl_egress_dhcp_to_host_counter; + @p4runtime_role("sdn_controller") @id(0x02000104) @sai_acl(EGRESS) @entry_restriction(" + + + + + + // Only allow IP field matches for IP packets. + ip_protocol::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + + + + + + + + // Forbid illegal combinations of IP_TYPE fields. + is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0); + is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0); + is_ipv6::mask != 0 -> (is_ip::mask == 0 && is_ipv4::mask == 0); + // Forbid unsupported combinations of IP_TYPE fields. + is_ipv4::mask != 0 -> (is_ipv4 == 1); + is_ipv6::mask != 0 -> (is_ipv6 == 1); + ") @name("egress.acl_egress.acl_egress_table") table acl_egress_acl_egress_table { + key = { + acl_egress_ip_protocol : ternary @id(2) @name("ip_protocol") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IP_PROTOCOL); + standard_metadata.egress_port: optional @id(4) @name("out_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_OUT_PORT); + key_10 : optional @id(5) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(6) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(7) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + headers.ethernet.src_addr : ternary @id(10) @name("src_mac") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_SRC_MAC) @format(MAC_ADDRESS); + } + actions = { + @proto_id(1) acl_drop_4(); + @defaultonly NoAction_19(); + } + const default_action = NoAction_19(); + counters = acl_egress_acl_egress_counter; + size = 127; + } + @hidden action pins_middleblock943() { + local_metadata._enable_decrement_ttl4 = true; + } + @hidden action pins_middleblock947() { + headers.ethernet.src_addr = local_metadata._packet_rewrites_src_mac8; + } + @hidden action pins_middleblock950() { + headers.ethernet.dst_addr = local_metadata._packet_rewrites_dst_mac9; + } + @hidden action pins_middleblock953() { + local_metadata._vlan_id1 = local_metadata._packet_rewrites_vlan_id10; + } + @hidden action pins_middleblock957() { + headers.ipv4.ttl = headers.ipv4.ttl + 8w255; + } + @hidden action pins_middleblock960() { + mark_to_drop(standard_metadata); + } + @hidden action pins_middleblock965() { + headers.ipv6.hop_limit = headers.ipv6.hop_limit + 8w255; + } + @hidden action pins_middleblock968() { + mark_to_drop(standard_metadata); + } + @hidden action pins_middleblock825() { + headers.tunnel_encap_ipv6.dscp = headers.ipv4.dscp; + headers.tunnel_encap_ipv6.ecn = headers.ipv4.ecn; + headers.tunnel_encap_ipv6.hop_limit = headers.ipv4.ttl; + } + @hidden action pins_middleblock829() { + headers.tunnel_encap_ipv6.dscp = headers.ipv6.dscp; + headers.tunnel_encap_ipv6.ecn = headers.ipv6.ecn; + headers.tunnel_encap_ipv6.hop_limit = headers.ipv6.hop_limit; + } + @hidden action pins_middleblock807() { + headers.tunnel_encap_gre.setValid(); + headers.tunnel_encap_gre.checksum_present = 1w0; + headers.tunnel_encap_gre.routing_present = 1w0; + headers.tunnel_encap_gre.key_present = 1w0; + headers.tunnel_encap_gre.sequence_present = 1w0; + headers.tunnel_encap_gre.strict_source_route = 1w0; + headers.tunnel_encap_gre.recursion_control = 3w0; + headers.tunnel_encap_gre.flags = 4w0; + headers.tunnel_encap_gre.version = 3w0; + headers.tunnel_encap_gre.protocol = headers.ethernet.ether_type; + headers.ethernet.ether_type = 16w0x86dd; + headers.tunnel_encap_ipv6.setValid(); + headers.tunnel_encap_ipv6.version = 4w6; + headers.tunnel_encap_ipv6.src_addr = local_metadata._tunnel_encap_src_ipv616; + headers.tunnel_encap_ipv6.dst_addr = local_metadata._tunnel_encap_dst_ipv617; + headers.tunnel_encap_ipv6.payload_length = (bit<16>)standard_metadata.packet_length + 16w65526; + headers.tunnel_encap_ipv6.next_header = 8w0x2f; + } + @hidden action pins_middleblock751() { + headers.mirror_encap_ethernet.setValid(); + headers.mirror_encap_ethernet.src_addr = local_metadata._mirror_encap_src_mac22; + headers.mirror_encap_ethernet.dst_addr = local_metadata._mirror_encap_dst_mac23; + headers.mirror_encap_ethernet.ether_type = 16w0x8100; + headers.mirror_encap_vlan.setValid(); + headers.mirror_encap_vlan.ether_type = 16w0x86dd; + headers.mirror_encap_vlan.vlan_id = local_metadata._mirror_encap_vlan_id24; + headers.mirror_encap_ipv6.setValid(); + headers.mirror_encap_ipv6.version = 4w6; + headers.mirror_encap_ipv6.dscp = 6w0; + headers.mirror_encap_ipv6.ecn = 2w0; + headers.mirror_encap_ipv6.hop_limit = 8w16; + headers.mirror_encap_ipv6.flow_label = 20w0; + headers.mirror_encap_ipv6.payload_length = (bit<16>)standard_metadata.packet_length + 16w52; + headers.mirror_encap_ipv6.next_header = 8w0x11; + headers.mirror_encap_ipv6.src_addr = local_metadata._mirror_encap_src_ip25; + headers.mirror_encap_ipv6.dst_addr = local_metadata._mirror_encap_dst_ip26; + headers.mirror_encap_udp.setValid(); + headers.mirror_encap_udp.src_port = local_metadata._mirror_encap_udp_src_port27; + headers.mirror_encap_udp.dst_port = local_metadata._mirror_encap_udp_dst_port28; + headers.mirror_encap_udp.hdr_length = (bit<16>)standard_metadata.packet_length + 16w52; + headers.mirror_encap_udp.checksum = 16w0; + headers.ipfix.setValid(); + headers.psamp_extended.setValid(); + } + @hidden action pins_middleblock878() { + mark_to_drop(standard_metadata); + } + @hidden action pins_middleblock880() { + mark_to_drop(standard_metadata); + } + @hidden action pins_middleblock889() { + headers.vlan.setValid(); + headers.vlan.priority_code_point = 3w0; + headers.vlan.drop_eligible_indicator = 1w0; + headers.vlan.vlan_id = local_metadata._vlan_id1; + headers.vlan.ether_type = headers.ethernet.ether_type; + headers.ethernet.ether_type = 16w0x8100; + } + @hidden action pins_middleblock1100() { + acl_egress_ip_protocol = headers.ipv4.protocol; + } + @hidden action pins_middleblock1103() { + acl_egress_ip_protocol = headers.ipv6.next_header; + } + @hidden action pins_middleblock1105() { + acl_egress_ip_protocol = 8w0; + } + @hidden action pins_middleblock1055() { + key_10 = headers.ipv4.isValid() || headers.ipv6.isValid(); + } + @hidden action pins_middleblock1109() { + mark_to_drop(standard_metadata); + } + @hidden table tbl_pins_middleblock943 { + actions = { + pins_middleblock943(); + } + const default_action = pins_middleblock943(); + } + @hidden table tbl_pins_middleblock947 { + actions = { + pins_middleblock947(); } - if (standard_metadata.instance_type == 32w1) { - tbl_pins_middleblock449.apply(); + const default_action = pins_middleblock947(); + } + @hidden table tbl_pins_middleblock950 { + actions = { + pins_middleblock950(); + } + const default_action = pins_middleblock950(); + } + @hidden table tbl_pins_middleblock953 { + actions = { + pins_middleblock953(); + } + const default_action = pins_middleblock953(); + } + @hidden table tbl_pins_middleblock957 { + actions = { + pins_middleblock957(); + } + const default_action = pins_middleblock957(); + } + @hidden table tbl_pins_middleblock960 { + actions = { + pins_middleblock960(); + } + const default_action = pins_middleblock960(); + } + @hidden table tbl_pins_middleblock965 { + actions = { + pins_middleblock965(); + } + const default_action = pins_middleblock965(); + } + @hidden table tbl_pins_middleblock968 { + actions = { + pins_middleblock968(); + } + const default_action = pins_middleblock968(); + } + @hidden table tbl_pins_middleblock807 { + actions = { + pins_middleblock807(); + } + const default_action = pins_middleblock807(); + } + @hidden table tbl_pins_middleblock825 { + actions = { + pins_middleblock825(); + } + const default_action = pins_middleblock825(); + } + @hidden table tbl_pins_middleblock829 { + actions = { + pins_middleblock829(); + } + const default_action = pins_middleblock829(); + } + @hidden table tbl_pins_middleblock751 { + actions = { + pins_middleblock751(); + } + const default_action = pins_middleblock751(); + } + @hidden table tbl_pins_middleblock878 { + actions = { + pins_middleblock878(); + } + const default_action = pins_middleblock878(); + } + @hidden table tbl_pins_middleblock880 { + actions = { + pins_middleblock880(); + } + const default_action = pins_middleblock880(); + } + @hidden table tbl_pins_middleblock889 { + actions = { + pins_middleblock889(); + } + const default_action = pins_middleblock889(); + } + @hidden table tbl_pins_middleblock1100 { + actions = { + pins_middleblock1100(); + } + const default_action = pins_middleblock1100(); + } + @hidden table tbl_pins_middleblock1103 { + actions = { + pins_middleblock1103(); + } + const default_action = pins_middleblock1103(); + } + @hidden table tbl_pins_middleblock1105 { + actions = { + pins_middleblock1105(); + } + const default_action = pins_middleblock1105(); + } + @hidden table tbl_pins_middleblock1055 { + actions = { + pins_middleblock1055(); + } + const default_action = pins_middleblock1055(); + } + @hidden table tbl_pins_middleblock1109 { + actions = { + pins_middleblock1109(); + } + const default_action = pins_middleblock1109(); + } + apply { + if (standard_metadata.instance_type == 32w1 && standard_metadata.egress_rid == 16w1) { + ; + } else { + if (standard_metadata.instance_type == 32w5) { + tbl_pins_middleblock943.apply(); + packet_rewrites_multicast_rewrites_multicast_router_interface_table.apply(); + } + if (local_metadata._enable_src_mac_rewrite5) { + tbl_pins_middleblock947.apply(); + } + if (local_metadata._enable_dst_mac_rewrite6) { + tbl_pins_middleblock950.apply(); + } + if (local_metadata._enable_vlan_rewrite7) { + tbl_pins_middleblock953.apply(); + } + if (headers.ipv4.isValid()) { + if (headers.ipv4.ttl > 8w0 && local_metadata._enable_decrement_ttl4) { + tbl_pins_middleblock957.apply(); + } + if (headers.ipv4.ttl == 8w0) { + tbl_pins_middleblock960.apply(); + } + } + if (headers.ipv6.isValid()) { + if (headers.ipv6.hop_limit > 8w0 && local_metadata._enable_decrement_ttl4) { + tbl_pins_middleblock965.apply(); + } + if (headers.ipv6.hop_limit == 8w0) { + tbl_pins_middleblock968.apply(); + } + } + if (local_metadata._apply_tunnel_encap_at_egress15) { + tbl_pins_middleblock807.apply(); + if (headers.ipv4.isValid()) { + tbl_pins_middleblock825.apply(); + } else if (headers.ipv6.isValid()) { + tbl_pins_middleblock829.apply(); + } + } + if (standard_metadata.instance_type == 32w1 && standard_metadata.egress_rid == 16w2) { + tbl_pins_middleblock751.apply(); + } + if (local_metadata._enable_vlan_checks0) { + if (standard_metadata.instance_type == 32w1 && standard_metadata.egress_rid == 16w2 && !(local_metadata._mirror_encap_vlan_id24 == 12w0x0 || local_metadata._mirror_encap_vlan_id24 == 12w0xfff)) { + tbl_pins_middleblock878.apply(); + } else if (!(standard_metadata.instance_type == 32w1 && standard_metadata.egress_rid == 16w1) && !(local_metadata._vlan_id1 == 12w0x0 || local_metadata._vlan_id1 == 12w0xfff)) { + tbl_pins_middleblock880.apply(); + } + } + if (!(local_metadata._vlan_id1 == 12w0x0 || local_metadata._vlan_id1 == 12w0xfff) && !(standard_metadata.instance_type == 32w1 && standard_metadata.egress_rid == 16w2)) { + tbl_pins_middleblock889.apply(); + } + if (headers.ipv4.isValid()) { + tbl_pins_middleblock1100.apply(); + } else if (headers.ipv6.isValid()) { + tbl_pins_middleblock1103.apply(); + } else { + tbl_pins_middleblock1105.apply(); + } + tbl_pins_middleblock1055.apply(); + acl_egress_acl_egress_table.apply(); + if (local_metadata._acl_drop42) { + tbl_pins_middleblock1109.apply(); + } } } } -@pkginfo(name="middleblock.p4", organization="Google") V1Switch(packet_parser(), verify_ipv4_checksum(), ingress(), egress(), compute_ipv4_checksum(), packet_deparser()) main; +@pkginfo(name="middleblock.p4", organization="Google", version="1.6.1") V1Switch(packet_parser(), verify_ipv4_checksum(), ingress(), egress(), compute_ipv4_checksum(), packet_deparser()) main; diff --git a/testdata/p4_16_samples_outputs/pins/pins_middleblock.p4 b/testdata/p4_16_samples_outputs/pins/pins_middleblock.p4 index 0b936b3cb4..cc8fe4e435 100644 --- a/testdata/p4_16_samples_outputs/pins/pins_middleblock.p4 +++ b/testdata/p4_16_samples_outputs/pins/pins_middleblock.p4 @@ -5,10 +5,21 @@ typedef bit<48> ethernet_addr_t; typedef bit<32> ipv4_addr_t; typedef bit<128> ipv6_addr_t; +typedef bit<12> vlan_id_t; +typedef bit<16> ether_type_t; +const vlan_id_t INTERNAL_VLAN_ID = 0xfff; +const vlan_id_t NO_VLAN_ID = 0x0; header ethernet_t { ethernet_addr_t dst_addr; ethernet_addr_t src_addr; - bit<16> ether_type; + ether_type_t ether_type; +} + +header vlan_t { + bit<3> priority_code_point; + bit<1> drop_eligible_indicator; + vlan_id_t vlan_id; + ether_type_t ether_type; } header ipv4_t { @@ -65,6 +76,7 @@ header icmp_t { bit<8> type; bit<8> code; bit<16> checksum; + bit<32> rest_of_header; } header arp_t { @@ -92,109 +104,211 @@ header gre_t { bit<16> protocol; } +header ipfix_t { + bit<16> version_number; + bit<16> length; + bit<32> export_time; + bit<32> sequence_number; + bit<32> observation_domain_id; +} + +header psamp_extended_t { + bit<16> template_id; + bit<16> length; + bit<64> observation_time; + bit<16> flowset; + bit<16> next_hop_index; + bit<16> epoch; + bit<16> ingress_port; + bit<16> egress_port; + bit<16> user_meta_field; + bit<8> dlb_id; + bit<8> variable_length; + bit<16> packet_sampled_length; +} + enum bit<8> PreservedFieldList { - CLONE_I2E = 8w1 + MIRROR_AND_PACKET_IN_COPY = 8w1, + RECIRCULATE = 8w2 } type bit<10> nexthop_id_t; type bit<10> tunnel_id_t; type bit<12> wcmp_group_id_t; -type bit<10> vrf_id_t; +@p4runtime_translation_mappings({ { "" , 0 } , }) type bit<10> vrf_id_t; const vrf_id_t kDefaultVrf = 0; type bit<10> router_interface_id_t; type bit<9> port_id_t; type bit<10> mirror_session_id_t; type bit<8> qos_queue_t; typedef bit<6> route_metadata_t; +typedef bit<8> acl_metadata_t; +typedef bit<16> multicast_group_id_t; +typedef bit<16> replica_instance_t; enum bit<2> MeterColor_t { GREEN = 0, YELLOW = 1, RED = 2 } +@controller_header("packet_in") header packet_in_header_t { + @id(1) + port_id_t ingress_port; + @id(2) + port_id_t target_egress_port; +} + +@controller_header("packet_out") header packet_out_header_t { + @id(1) + port_id_t egress_port; + @id(2) + bit<1> submit_to_ingress; + @id(3) @padding + bit<6> unused_pad; +} + struct headers_t { - ethernet_t erspan_ethernet; - ipv4_t erspan_ipv4; - gre_t erspan_gre; - ethernet_t ethernet; - ipv6_t tunnel_encap_ipv6; - gre_t tunnel_encap_gre; - ipv4_t ipv4; - ipv6_t ipv6; - icmp_t icmp; - tcp_t tcp; - udp_t udp; - arp_t arp; + packet_out_header_t packet_out_header; + ethernet_t mirror_encap_ethernet; + vlan_t mirror_encap_vlan; + ipv6_t mirror_encap_ipv6; + udp_t mirror_encap_udp; + ipfix_t ipfix; + psamp_extended_t psamp_extended; + ethernet_t ethernet; + vlan_t vlan; + ipv6_t tunnel_encap_ipv6; + gre_t tunnel_encap_gre; + ipv4_t ipv4; + ipv6_t ipv6; + ipv4_t inner_ipv4; + ipv6_t inner_ipv6; + icmp_t icmp; + tcp_t tcp; + udp_t udp; + arp_t arp; } struct packet_rewrites_t { ethernet_addr_t src_mac; ethernet_addr_t dst_mac; + vlan_id_t vlan_id; } struct local_metadata_t { + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + bool enable_vlan_checks; + vlan_id_t vlan_id; bool admit_to_l3; vrf_id_t vrf_id; + bool enable_decrement_ttl; + bool enable_src_mac_rewrite; + bool enable_dst_mac_rewrite; + bool enable_vlan_rewrite; packet_rewrites_t packet_rewrites; bit<16> l4_src_port; bit<16> l4_dst_port; - bit<16> wcmp_selector_input; + bit<8> wcmp_selector_input; + bool apply_tunnel_decap_at_end_of_pre_ingress; bool apply_tunnel_encap_at_egress; ipv6_addr_t tunnel_encap_src_ipv6; ipv6_addr_t tunnel_encap_dst_ipv6; - bool mirror_session_id_valid; - mirror_session_id_t mirror_session_id_value; - @field_list(PreservedFieldList.CLONE_I2E) - ipv4_addr_t mirroring_src_ip; - @field_list(PreservedFieldList.CLONE_I2E) - ipv4_addr_t mirroring_dst_ip; - @field_list(PreservedFieldList.CLONE_I2E) - ethernet_addr_t mirroring_src_mac; - @field_list(PreservedFieldList.CLONE_I2E) - ethernet_addr_t mirroring_dst_mac; - @field_list(PreservedFieldList.CLONE_I2E) - bit<8> mirroring_ttl; - @field_list(PreservedFieldList.CLONE_I2E) - bit<8> mirroring_tos; + bool marked_to_copy; + bool marked_to_mirror; + mirror_session_id_t mirror_session_id; + port_id_t mirror_egress_port; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + ethernet_addr_t mirror_encap_src_mac; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + ethernet_addr_t mirror_encap_dst_mac; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + vlan_id_t mirror_encap_vlan_id; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + ipv6_addr_t mirror_encap_src_ip; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + ipv6_addr_t mirror_encap_dst_ip; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + bit<16> mirror_encap_udp_src_port; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + bit<16> mirror_encap_udp_dst_port; + @field_list(PreservedFieldList.RECIRCULATE) + bit<9> loopback_port; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + bit<9> packet_in_ingress_port; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + bit<9> packet_in_target_egress_port; MeterColor_t color; port_id_t ingress_port; route_metadata_t route_metadata; -} - -@controller_header("packet_in") header packet_in_header_t { - @id(1) - port_id_t ingress_port; - @id(2) - port_id_t target_egress_port; -} - -@controller_header("packet_out") header packet_out_header_t { - @id(1) - port_id_t egress_port; - @id(2) - bit<1> submit_to_ingress; - @id(3) - bit<7> unused_pad; + acl_metadata_t acl_metadata; + bool bypass_ingress; + bool wcmp_group_id_valid; + wcmp_group_id_t wcmp_group_id_value; + bool nexthop_id_valid; + nexthop_id_t nexthop_id_value; + bool ipmc_table_hit; + bool acl_drop; } parser packet_parser(packet_in packet, out headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { state start { + local_metadata.enable_vlan_checks = false; + local_metadata.vlan_id = 0; local_metadata.admit_to_l3 = false; local_metadata.vrf_id = kDefaultVrf; + local_metadata.enable_decrement_ttl = false; + local_metadata.enable_src_mac_rewrite = false; + local_metadata.enable_dst_mac_rewrite = false; + local_metadata.enable_vlan_rewrite = false; local_metadata.packet_rewrites.src_mac = 0; local_metadata.packet_rewrites.dst_mac = 0; local_metadata.l4_src_port = 0; local_metadata.l4_dst_port = 0; local_metadata.wcmp_selector_input = 0; - local_metadata.mirror_session_id_valid = false; + local_metadata.apply_tunnel_decap_at_end_of_pre_ingress = false; + local_metadata.apply_tunnel_encap_at_egress = false; + local_metadata.tunnel_encap_src_ipv6 = 0; + local_metadata.tunnel_encap_dst_ipv6 = 0; + local_metadata.marked_to_copy = false; + local_metadata.marked_to_mirror = false; + local_metadata.mirror_session_id = 0; + local_metadata.mirror_egress_port = 0; local_metadata.color = MeterColor_t.GREEN; - local_metadata.ingress_port = (port_id_t)standard_metadata.ingress_port; local_metadata.route_metadata = 0; + local_metadata.bypass_ingress = false; + local_metadata.wcmp_group_id_valid = false; + local_metadata.wcmp_group_id_value = 0; + local_metadata.nexthop_id_valid = false; + local_metadata.nexthop_id_value = 0; + local_metadata.ipmc_table_hit = false; + local_metadata.acl_drop = false; + if (standard_metadata.instance_type == 4) { + local_metadata.ingress_port = (port_id_t)local_metadata.loopback_port; + } else { + local_metadata.ingress_port = (port_id_t)standard_metadata.ingress_port; + } + transition select(standard_metadata.ingress_port) { + 510: parse_packet_out_header; + default: parse_ethernet; + } + } + state parse_packet_out_header { + packet.extract(headers.packet_out_header); transition parse_ethernet; } state parse_ethernet { packet.extract(headers.ethernet); transition select(headers.ethernet.ether_type) { + 0x800: parse_ipv4; + 0x86dd: parse_ipv6; + 0x806: parse_arp; + 0x8100: parse_8021q_vlan; + default: accept; + } + } + state parse_8021q_vlan { + packet.extract(headers.vlan); + transition select(headers.vlan.ether_type) { 0x800: parse_ipv4; 0x86dd: parse_ipv6; 0x806: parse_arp; @@ -204,6 +318,17 @@ parser packet_parser(packet_in packet, out headers_t headers, inout local_metada state parse_ipv4 { packet.extract(headers.ipv4); transition select(headers.ipv4.protocol) { + 0x4: parse_ipv4_in_ip; + 0x29: parse_ipv6_in_ip; + 0x1: parse_icmp; + 0x6: parse_tcp; + 0x11: parse_udp; + default: accept; + } + } + state parse_ipv4_in_ip { + packet.extract(headers.inner_ipv4); + transition select(headers.inner_ipv4.protocol) { 0x1: parse_icmp; 0x6: parse_tcp; 0x11: parse_udp; @@ -213,6 +338,17 @@ parser packet_parser(packet_in packet, out headers_t headers, inout local_metada state parse_ipv6 { packet.extract(headers.ipv6); transition select(headers.ipv6.next_header) { + 0x4: parse_ipv4_in_ip; + 0x29: parse_ipv6_in_ip; + 0x3a: parse_icmp; + 0x6: parse_tcp; + 0x11: parse_udp; + default: accept; + } + } + state parse_ipv6_in_ip { + packet.extract(headers.inner_ipv6); + transition select(headers.inner_ipv6.next_header) { 0x3a: parse_icmp; 0x6: parse_tcp; 0x11: parse_udp; @@ -243,14 +379,21 @@ parser packet_parser(packet_in packet, out headers_t headers, inout local_metada control packet_deparser(packet_out packet, in headers_t headers) { apply { - packet.emit(headers.erspan_ethernet); - packet.emit(headers.erspan_ipv4); - packet.emit(headers.erspan_gre); + packet.emit(headers.packet_out_header); + packet.emit(headers.mirror_encap_ethernet); + packet.emit(headers.mirror_encap_vlan); + packet.emit(headers.mirror_encap_ipv6); + packet.emit(headers.mirror_encap_udp); + packet.emit(headers.ipfix); + packet.emit(headers.psamp_extended); packet.emit(headers.ethernet); + packet.emit(headers.vlan); packet.emit(headers.tunnel_encap_ipv6); packet.emit(headers.tunnel_encap_gre); packet.emit(headers.ipv4); packet.emit(headers.ipv6); + packet.emit(headers.inner_ipv4); + packet.emit(headers.inner_ipv6); packet.emit(headers.arp); packet.emit(headers.icmp); packet.emit(headers.tcp); @@ -258,11 +401,143 @@ control packet_deparser(packet_out packet, in headers_t headers) { } } -control routing(in headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { - bool wcmp_group_id_valid = false; - wcmp_group_id_t wcmp_group_id_value; - bool nexthop_id_valid = false; - nexthop_id_t nexthop_id_value; +control packet_in_encap(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { + apply { + } +} + +control packet_out_decap(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { + apply { + if (headers.packet_out_header.isValid() && headers.packet_out_header.submit_to_ingress == 0) { + standard_metadata.egress_spec = (bit<9>)headers.packet_out_header.egress_port; + local_metadata.bypass_ingress = true; + } + headers.packet_out_header.setInvalid(); + } +} + +@id(0x01000005) action set_nexthop_id(inout local_metadata_t local_metadata, @id(1) @refers_to(nexthop_table , nexthop_id) nexthop_id_t nexthop_id) { + local_metadata.nexthop_id_valid = true; + local_metadata.nexthop_id_value = nexthop_id; +} +control routing_lookup(in headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { + @id(0x01798B9E) action no_action() { + } + @entry_restriction(" + // The VRF ID 0 (or '' in P4Runtime) encodes the default VRF, which cannot + // be read or written via this table, but is always present implicitly. + // TODO: This constraint should read `vrf_id != ''` (since + // constraints are a control plane (P4Runtime) concept), but + // p4-constraints does not currently support strings. + vrf_id != 0; + ") @p4runtime_role("sdn_controller") @id(0x0200004A) table vrf_table { + key = { + local_metadata.vrf_id: exact @id(1) @name("vrf_id"); + } + actions = { + @proto_id(1) no_action; + } + const default_action = no_action; + size = 64; + } + @id(0x01000006) action drop() { + mark_to_drop(standard_metadata); + } + @id(0x01000004) action set_wcmp_group_id(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) wcmp_group_id_t wcmp_group_id) { + local_metadata.wcmp_group_id_valid = true; + local_metadata.wcmp_group_id_value = wcmp_group_id; + } + @id(0x01000011) action set_wcmp_group_id_and_metadata(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) wcmp_group_id_t wcmp_group_id, route_metadata_t route_metadata) { + set_wcmp_group_id(wcmp_group_id); + local_metadata.route_metadata = route_metadata; + } + @id(0x01000015) action set_metadata_and_drop(@id(1) route_metadata_t route_metadata) { + local_metadata.route_metadata = route_metadata; + mark_to_drop(standard_metadata); + } + @id(0x01000010) action set_nexthop_id_and_metadata(@id(1) @refers_to(nexthop_table , nexthop_id) nexthop_id_t nexthop_id, route_metadata_t route_metadata) { + local_metadata.nexthop_id_valid = true; + local_metadata.nexthop_id_value = nexthop_id; + local_metadata.route_metadata = route_metadata; + } + @id(0x01000018) @action_restriction(" + // Disallow 0 since it encodes 'no multicast' in V1Model. + multicast_group_id != 0; + ") action set_multicast_group_id(@id(1) @refers_to(builtin : : multicast_group_table , multicast_group_id) multicast_group_id_t multicast_group_id) { + standard_metadata.mcast_grp = multicast_group_id; + } + @p4runtime_role("sdn_controller") @id(0x02000044) table ipv4_table { + key = { + local_metadata.vrf_id: exact @id(1) @name("vrf_id") @refers_to(vrf_table , vrf_id); + headers.ipv4.dst_addr: lpm @id(2) @name("ipv4_dst") @format(IPV4_ADDRESS); + } + actions = { + @proto_id(1) drop; + @proto_id(2) set_nexthop_id(local_metadata); + @proto_id(3) set_wcmp_group_id; + @proto_id(5) set_nexthop_id_and_metadata; + @proto_id(6) set_wcmp_group_id_and_metadata; + @proto_id(7) set_metadata_and_drop; + } + const default_action = drop; + size = 131072; + } + @p4runtime_role("sdn_controller") @id(0x02000045) table ipv6_table { + key = { + local_metadata.vrf_id: exact @id(1) @name("vrf_id") @refers_to(vrf_table , vrf_id); + headers.ipv6.dst_addr: lpm @id(2) @name("ipv6_dst") @format(IPV6_ADDRESS); + } + actions = { + @proto_id(1) drop; + @proto_id(2) set_nexthop_id(local_metadata); + @proto_id(3) set_wcmp_group_id; + @proto_id(5) set_nexthop_id_and_metadata; + @proto_id(6) set_wcmp_group_id_and_metadata; + @proto_id(7) set_metadata_and_drop; + } + const default_action = drop; + size = 17000; + } + @p4runtime_role("sdn_controller") @id(0x0200004E) table ipv4_multicast_table { + key = { + local_metadata.vrf_id: exact @id(1) @name("vrf_id") @refers_to(vrf_table , vrf_id); + headers.ipv4.dst_addr: exact @id(2) @name("ipv4_dst") @format(IPV4_ADDRESS); + } + actions = { + @proto_id(1) set_multicast_group_id; + } + size = 1600; + } + @p4runtime_role("sdn_controller") @id(0x0200004F) table ipv6_multicast_table { + key = { + local_metadata.vrf_id: exact @id(1) @name("vrf_id") @refers_to(vrf_table , vrf_id); + headers.ipv6.dst_addr: exact @id(2) @name("ipv6_dst") @format(IPV6_ADDRESS); + } + actions = { + @proto_id(1) set_multicast_group_id; + } + size = 1600; + } + apply { + mark_to_drop(standard_metadata); + vrf_table.apply(); + if (local_metadata.admit_to_l3) { + if (headers.ipv4.isValid()) { + ipv4_table.apply(); + ipv4_multicast_table.apply(); + local_metadata.ipmc_table_hit = standard_metadata.mcast_grp != 0; + } else if (headers.ipv6.isValid()) { + ipv6_table.apply(); + ipv6_multicast_table.apply(); + local_metadata.ipmc_table_hit = standard_metadata.mcast_grp != 0; + } + } + } +} + +control routing_resolution(in headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { + bool tunnel_id_valid = false; + tunnel_id_t tunnel_id_value; bool router_interface_id_valid = false; router_interface_id_t router_interface_id_value; bool neighbor_id_valid = false; @@ -282,9 +557,15 @@ control routing(in headers_t headers, inout local_metadata_t local_metadata, ino const default_action = NoAction; size = 1024; } - @id(0x01000002) action set_port_and_src_mac(@id(1) port_id_t port, @id(2) @format(MAC_ADDRESS) ethernet_addr_t src_mac) { + @id(0x0100001B) @unsupported @action_restriction(" + // Disallow reserved VLAN IDs with implementation-defined semantics. + vlan_id != 0 && vlan_id != 4095") action set_port_and_src_mac_and_vlan_id(@id(1) port_id_t port, @id(2) @format(MAC_ADDRESS) ethernet_addr_t src_mac, @id(3) vlan_id_t vlan_id) { standard_metadata.egress_spec = (bit<9>)port; local_metadata.packet_rewrites.src_mac = src_mac; + local_metadata.packet_rewrites.vlan_id = vlan_id; + } + @id(0x01000002) action set_port_and_src_mac(@id(1) port_id_t port, @id(2) @format(MAC_ADDRESS) ethernet_addr_t src_mac) { + set_port_and_src_mac_and_vlan_id(port, src_mac, INTERNAL_VLAN_ID); } @p4runtime_role("sdn_controller") @id(0x02000041) table router_interface_table { key = { @@ -292,141 +573,98 @@ control routing(in headers_t headers, inout local_metadata_t local_metadata, ino } actions = { @proto_id(1) set_port_and_src_mac; + @proto_id(2) set_port_and_src_mac_and_vlan_id; @defaultonly NoAction; } const default_action = NoAction; size = 256; } - @id(0x01000014) action set_ip_nexthop(@id(1) @refers_to(router_interface_table , router_interface_id) @refers_to(neighbor_table , router_interface_id) router_interface_id_t router_interface_id, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) ipv6_addr_t neighbor_id) { + @id(0x01000017) action set_ip_nexthop_and_disable_rewrites(@id(1) @refers_to(router_interface_table , router_interface_id) @refers_to(neighbor_table , router_interface_id) router_interface_id_t router_interface_id, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) ipv6_addr_t neighbor_id, @id(3) bit<1> disable_decrement_ttl, @id(4) bit<1> disable_src_mac_rewrite, @id(5) bit<1> disable_dst_mac_rewrite, @id(6) bit<1> disable_vlan_rewrite) { router_interface_id_valid = true; router_interface_id_value = router_interface_id; neighbor_id_valid = true; neighbor_id_value = neighbor_id; + local_metadata.enable_decrement_ttl = !(bool)disable_decrement_ttl; + local_metadata.enable_src_mac_rewrite = !(bool)disable_src_mac_rewrite; + local_metadata.enable_dst_mac_rewrite = !(bool)disable_dst_mac_rewrite; + local_metadata.enable_vlan_rewrite = !(bool)disable_vlan_rewrite; + } + @id(0x01000014) action set_ip_nexthop(@id(1) @refers_to(router_interface_table , router_interface_id) @refers_to(neighbor_table , router_interface_id) router_interface_id_t router_interface_id, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) ipv6_addr_t neighbor_id) { + set_ip_nexthop_and_disable_rewrites(router_interface_id, neighbor_id, 0x0, 0x0, 0x0, 0x0); } @id(0x01000003) @deprecated("Use set_ip_nexthop instead.") action set_nexthop(@id(1) @refers_to(router_interface_table , router_interface_id) @refers_to(neighbor_table , router_interface_id) router_interface_id_t router_interface_id, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) ipv6_addr_t neighbor_id) { set_ip_nexthop(router_interface_id, neighbor_id); } + @id(0x01000012) action set_p2p_tunnel_encap_nexthop(@id(1) @refers_to(tunnel_table , tunnel_id) tunnel_id_t tunnel_id) { + tunnel_id_valid = true; + tunnel_id_value = tunnel_id; + } @p4runtime_role("sdn_controller") @id(0x02000042) table nexthop_table { key = { - nexthop_id_value: exact @id(1) @name("nexthop_id"); + local_metadata.nexthop_id_value: exact @id(1) @name("nexthop_id"); } actions = { @proto_id(1) set_nexthop; + @proto_id(2) set_p2p_tunnel_encap_nexthop; @proto_id(3) set_ip_nexthop; + @proto_id(4) set_ip_nexthop_and_disable_rewrites; @defaultonly NoAction; } const default_action = NoAction; size = 1024; } - @id(0x01000005) action set_nexthop_id(@id(1) @refers_to(nexthop_table , nexthop_id) nexthop_id_t nexthop_id) { - nexthop_id_valid = true; - nexthop_id_value = nexthop_id; - } - @id(0x01000010) action set_nexthop_id_and_metadata(@id(1) @refers_to(nexthop_table , nexthop_id) nexthop_id_t nexthop_id, route_metadata_t route_metadata) { - nexthop_id_valid = true; - nexthop_id_value = nexthop_id; - local_metadata.route_metadata = route_metadata; + @id(0x01000013) action mark_for_p2p_tunnel_encap(@id(1) @format(IPV6_ADDRESS) ipv6_addr_t encap_src_ip, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) ipv6_addr_t encap_dst_ip, @id(3) @refers_to(neighbor_table , router_interface_id) @refers_to(router_interface_table , router_interface_id) router_interface_id_t router_interface_id) { + local_metadata.tunnel_encap_src_ipv6 = encap_src_ip; + local_metadata.tunnel_encap_dst_ipv6 = encap_dst_ip; + local_metadata.apply_tunnel_encap_at_egress = true; + set_ip_nexthop(router_interface_id, encap_dst_ip); } - @max_group_size(256) action_selector(HashAlgorithm.identity, 65536, 16) wcmp_group_selector; - @p4runtime_role("sdn_controller") @id(0x02000043) @oneshot table wcmp_group_table { + @p4runtime_role("sdn_controller") @id(0x02000050) table tunnel_table { key = { - wcmp_group_id_value : exact @id(1) @name("wcmp_group_id"); - local_metadata.wcmp_selector_input: selector; + tunnel_id_value: exact @id(1) @name("tunnel_id"); } actions = { - @proto_id(1) set_nexthop_id; + @proto_id(1) mark_for_p2p_tunnel_encap; @defaultonly NoAction; } const default_action = NoAction; - @id(0x11DC4EC8) implementation = wcmp_group_selector; - size = 3968; - } - action no_action() { - } - @entry_restriction(" - // The VRF ID 0 (or '' in P4Runtime) encodes the default VRF, which cannot - // be read or written via this table, but is always present implicitly. - // TODO: This constraint should read `vrf_id != ''` (since - // constraints are a control plane (P4Runtime) concept), but - // p4-constraints does not currently support strings. - vrf_id != 0; - ") @p4runtime_role("sdn_controller") @id(0x0200004A) table vrf_table { - key = { - local_metadata.vrf_id: exact @id(1) @name("vrf_id"); - } - actions = { - @proto_id(1) no_action; - } - const default_action = no_action; - size = 64; - } - @id(0x01000006) action drop() { - mark_to_drop(standard_metadata); - } - @id(0x01000004) action set_wcmp_group_id(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) wcmp_group_id_t wcmp_group_id) { - wcmp_group_id_valid = true; - wcmp_group_id_value = wcmp_group_id; - } - @id(0x01000011) action set_wcmp_group_id_and_metadata(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) wcmp_group_id_t wcmp_group_id, route_metadata_t route_metadata) { - set_wcmp_group_id(wcmp_group_id); - local_metadata.route_metadata = route_metadata; - } - @id(0x0100000F) action trap() { - clone(CloneType.I2E, 1024); - mark_to_drop(standard_metadata); - } - @p4runtime_role("sdn_controller") @id(0x02000044) table ipv4_table { - key = { - local_metadata.vrf_id: exact @id(1) @name("vrf_id") @refers_to(vrf_table , vrf_id); - headers.ipv4.dst_addr: lpm @format(IPV4_ADDRESS) @id(2) @name("ipv4_dst"); - } - actions = { - @proto_id(1) drop; - @proto_id(2) set_nexthop_id; - @proto_id(3) set_wcmp_group_id; - @proto_id(4) trap; - @proto_id(5) set_nexthop_id_and_metadata; - @proto_id(6) set_wcmp_group_id_and_metadata; - } - const default_action = drop; - size = 32768; + size = 2048; } - @p4runtime_role("sdn_controller") @id(0x02000045) table ipv6_table { + @max_group_size(512) @id(0x11DC4EC8) action_selector(HashAlgorithm.identity, 49152, 8) wcmp_group_selector; + @p4runtime_role("sdn_controller") @id(0x02000043) @oneshot table wcmp_group_table { key = { - local_metadata.vrf_id: exact @id(1) @name("vrf_id") @refers_to(vrf_table , vrf_id); - headers.ipv6.dst_addr: lpm @format(IPV6_ADDRESS) @id(2) @name("ipv6_dst"); + local_metadata.wcmp_group_id_value: exact @id(1) @name("wcmp_group_id"); + local_metadata.wcmp_selector_input: selector; } actions = { - @proto_id(1) drop; - @proto_id(2) set_nexthop_id; - @proto_id(3) set_wcmp_group_id; - @proto_id(4) trap; - @proto_id(5) set_nexthop_id_and_metadata; - @proto_id(6) set_wcmp_group_id_and_metadata; + @proto_id(1) set_nexthop_id(local_metadata); + @defaultonly NoAction; } - const default_action = drop; - size = 4096; + const default_action = NoAction; + implementation = wcmp_group_selector; + size = 3968; } apply { - mark_to_drop(standard_metadata); - vrf_table.apply(); if (local_metadata.admit_to_l3) { - if (headers.ipv4.isValid()) { - ipv4_table.apply(); - } else if (headers.ipv6.isValid()) { - ipv6_table.apply(); - } - if (wcmp_group_id_valid) { + if (local_metadata.wcmp_group_id_valid) { wcmp_group_table.apply(); } - if (nexthop_id_valid) { + if (local_metadata.nexthop_id_valid) { nexthop_table.apply(); + if (tunnel_id_valid) { + tunnel_table.apply(); + } if (router_interface_id_valid && neighbor_id_valid) { router_interface_table.apply(); neighbor_table.apply(); } } } + local_metadata.packet_in_target_egress_port = standard_metadata.egress_spec; + local_metadata.packet_in_ingress_port = standard_metadata.ingress_port; + if (local_metadata.acl_drop) { + mark_to_drop(standard_metadata); + } } } @@ -438,92 +676,94 @@ control verify_ipv4_checksum(inout headers_t headers, inout local_metadata_t loc control compute_ipv4_checksum(inout headers_t headers, inout local_metadata_t local_metadata) { apply { - update_checksum(headers.erspan_ipv4.isValid(), { headers.erspan_ipv4.version, headers.erspan_ipv4.ihl, headers.erspan_ipv4.dscp, headers.erspan_ipv4.ecn, headers.erspan_ipv4.total_len, headers.erspan_ipv4.identification, headers.erspan_ipv4.reserved, headers.erspan_ipv4.do_not_fragment, headers.erspan_ipv4.more_fragments, headers.erspan_ipv4.frag_offset, headers.erspan_ipv4.ttl, headers.erspan_ipv4.protocol, headers.erspan_ipv4.src_addr, headers.erspan_ipv4.dst_addr }, headers.erspan_ipv4.header_checksum, HashAlgorithm.csum16); update_checksum(headers.ipv4.isValid(), { headers.ipv4.version, headers.ipv4.ihl, headers.ipv4.dscp, headers.ipv4.ecn, headers.ipv4.total_len, headers.ipv4.identification, headers.ipv4.reserved, headers.ipv4.do_not_fragment, headers.ipv4.more_fragments, headers.ipv4.frag_offset, headers.ipv4.ttl, headers.ipv4.protocol, headers.ipv4.src_addr, headers.ipv4.dst_addr }, headers.ipv4.header_checksum, HashAlgorithm.csum16); } } -control mirroring_encap(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { - apply { - if (standard_metadata.instance_type == 1) { - headers.erspan_ethernet.setValid(); - headers.erspan_ethernet.src_addr = local_metadata.mirroring_src_mac; - headers.erspan_ethernet.dst_addr = local_metadata.mirroring_dst_mac; - headers.erspan_ethernet.ether_type = 0x800; - headers.erspan_ipv4.setValid(); - headers.erspan_ipv4.src_addr = local_metadata.mirroring_src_ip; - headers.erspan_ipv4.dst_addr = local_metadata.mirroring_dst_ip; - headers.erspan_ipv4.version = 4w4; - headers.erspan_ipv4.ihl = 4w5; - headers.erspan_ipv4.protocol = 0x2f; - headers.erspan_ipv4.ttl = local_metadata.mirroring_ttl; - headers.erspan_ipv4.dscp = local_metadata.mirroring_tos[7:2]; - headers.erspan_ipv4.ecn = local_metadata.mirroring_tos[1:0]; - headers.erspan_ipv4.total_len = 20 + 4 + (bit<16>)standard_metadata.packet_length; - headers.erspan_ipv4.identification = 0; - headers.erspan_ipv4.reserved = 0; - headers.erspan_ipv4.do_not_fragment = 1; - headers.erspan_ipv4.more_fragments = 0; - headers.erspan_ipv4.frag_offset = 0; - headers.erspan_ipv4.header_checksum = 0; - headers.erspan_gre.setValid(); - headers.erspan_gre.checksum_present = 0; - headers.erspan_gre.routing_present = 0; - headers.erspan_gre.key_present = 0; - headers.erspan_gre.sequence_present = 0; - headers.erspan_gre.strict_source_route = 0; - headers.erspan_gre.recursion_control = 0; - headers.erspan_gre.acknowledgement_present = 0; - headers.erspan_gre.flags = 0; - headers.erspan_gre.version = 0; - headers.erspan_gre.protocol = 0x88be; - } - } -} - -control mirroring_clone(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { - port_id_t mirror_port; - bit<32> pre_session; - @id(0x01000007) action mirror_as_ipv4_erspan(@id(1) port_id_t port, @id(2) @format(IPV4_ADDRESS) ipv4_addr_t src_ip, @id(3) @format(IPV4_ADDRESS) ipv4_addr_t dst_ip, @id(4) @format(MAC_ADDRESS) ethernet_addr_t src_mac, @id(5) @format(MAC_ADDRESS) ethernet_addr_t dst_mac, @id(6) bit<8> ttl, @id(7) bit<8> tos) { - mirror_port = port; - local_metadata.mirroring_src_ip = src_ip; - local_metadata.mirroring_dst_ip = dst_ip; - local_metadata.mirroring_src_mac = src_mac; - local_metadata.mirroring_dst_mac = dst_mac; - local_metadata.mirroring_ttl = ttl; - local_metadata.mirroring_tos = tos; +control ingress_cloning(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { + @id(0x0100001C) action ingress_clone(@id(1) bit<32> clone_session) { + clone_preserving_field_list(CloneType.I2E, clone_session, PreservedFieldList.MIRROR_AND_PACKET_IN_COPY); } - @p4runtime_role("sdn_controller") @id(0x02000046) table mirror_session_table { + @unsupported @p4runtime_role("packet_replication_engine_manager") @id(0x02000051) @entry_restriction(" + // mirror_egress_port is present iff marked_to_mirror is true. + // Exact match indicating presence of mirror_egress_port. + marked_to_mirror == 1 -> mirror_egress_port::mask == -1; + // Wildcard match indicating abscence of mirror_egress_port. + marked_to_mirror == 0 -> mirror_egress_port::mask == 0; + ") table ingress_clone_table { key = { - local_metadata.mirror_session_id_value: exact @id(1) @name("mirror_session_id"); + local_metadata.marked_to_copy : exact @id(1) @name("marked_to_copy"); + local_metadata.marked_to_mirror : exact @id(2) @name("marked_to_mirror"); + local_metadata.mirror_egress_port: optional @id(3) @name("mirror_egress_port"); } actions = { - @proto_id(1) mirror_as_ipv4_erspan; - @defaultonly NoAction; + @proto_id(1) ingress_clone; } - const default_action = NoAction; - size = 2; } - @id(0x01000009) action set_pre_session(bit<32> id) { - pre_session = id; + apply { + ingress_clone_table.apply(); + } +} + +control mirror_session_lookup(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { + @id(0x01000007) action mirror_as_ipv4_erspan(@id(1) port_id_t port, @id(2) @format(IPV4_ADDRESS) ipv4_addr_t src_ip, @id(3) @format(IPV4_ADDRESS) ipv4_addr_t dst_ip, @id(4) @format(MAC_ADDRESS) ethernet_addr_t src_mac, @id(5) @format(MAC_ADDRESS) ethernet_addr_t dst_mac, @id(6) bit<8> ttl, @id(7) bit<8> tos) { + } + @id(0x0100001D) @unsupported action mirror_with_vlan_tag_and_ipfix_encapsulation(@id(1) port_id_t monitor_port, @id(2) port_id_t monitor_failover_port, @id(3) @format(MAC_ADDRESS) ethernet_addr_t mirror_encap_src_mac, @id(4) @format(MAC_ADDRESS) ethernet_addr_t mirror_encap_dst_mac, @id(6) vlan_id_t mirror_encap_vlan_id, @id(7) @format(IPV6_ADDRESS) ipv6_addr_t mirror_encap_dst_ip, @id(8) @format(IPV6_ADDRESS) ipv6_addr_t mirror_encap_src_ip, @id(9) bit<16> mirror_encap_udp_src_port, @id(10) bit<16> mirror_encap_udp_dst_port) { + local_metadata.mirror_egress_port = monitor_port; + local_metadata.mirror_encap_src_mac = mirror_encap_src_mac; + local_metadata.mirror_encap_dst_mac = mirror_encap_dst_mac; + local_metadata.mirror_encap_vlan_id = mirror_encap_vlan_id; + local_metadata.mirror_encap_src_ip = mirror_encap_src_ip; + local_metadata.mirror_encap_dst_ip = mirror_encap_dst_ip; + local_metadata.mirror_encap_udp_src_port = mirror_encap_udp_src_port; + local_metadata.mirror_encap_udp_dst_port = mirror_encap_udp_dst_port; } - @p4runtime_role("packet_replication_engine_manager") @id(0x02000048) table mirror_port_to_pre_session_table { + @p4runtime_role("sdn_controller") @id(0x02000046) table mirror_session_table { key = { - mirror_port: exact @id(1); + local_metadata.mirror_session_id: exact @id(1) @name("mirror_session_id"); } actions = { - @proto_id(1) set_pre_session; + @proto_id(1) mirror_as_ipv4_erspan; + @proto_id(2) mirror_with_vlan_tag_and_ipfix_encapsulation; @defaultonly NoAction; } const default_action = NoAction; + size = 4; } apply { - if (local_metadata.mirror_session_id_valid) { - if (mirror_session_table.apply().hit) { - if (mirror_port_to_pre_session_table.apply().hit) { - clone_preserving_field_list(CloneType.I2E, pre_session, (bit<8>)PreservedFieldList.CLONE_I2E); - } - } + if (local_metadata.marked_to_mirror) { + mirror_session_table.apply(); + } + } +} + +control mirroring_encap(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { + apply { + if (standard_metadata.instance_type == 1 && standard_metadata.egress_rid == 2) { + headers.mirror_encap_ethernet.setValid(); + headers.mirror_encap_ethernet.src_addr = local_metadata.mirror_encap_src_mac; + headers.mirror_encap_ethernet.dst_addr = local_metadata.mirror_encap_dst_mac; + headers.mirror_encap_ethernet.ether_type = 0x8100; + headers.mirror_encap_vlan.setValid(); + headers.mirror_encap_vlan.ether_type = 0x86dd; + headers.mirror_encap_vlan.vlan_id = local_metadata.mirror_encap_vlan_id; + headers.mirror_encap_ipv6.setValid(); + headers.mirror_encap_ipv6.version = 4w6; + headers.mirror_encap_ipv6.dscp = 0; + headers.mirror_encap_ipv6.ecn = 0; + headers.mirror_encap_ipv6.hop_limit = 16; + headers.mirror_encap_ipv6.flow_label = 0; + headers.mirror_encap_ipv6.payload_length = (bit<16>)standard_metadata.packet_length + 8 + 16 + 28; + headers.mirror_encap_ipv6.next_header = 0x11; + headers.mirror_encap_ipv6.src_addr = local_metadata.mirror_encap_src_ip; + headers.mirror_encap_ipv6.dst_addr = local_metadata.mirror_encap_dst_ip; + headers.mirror_encap_udp.setValid(); + headers.mirror_encap_udp.src_port = local_metadata.mirror_encap_udp_src_port; + headers.mirror_encap_udp.dst_port = local_metadata.mirror_encap_udp_dst_port; + headers.mirror_encap_udp.hdr_length = headers.mirror_encap_ipv6.payload_length; + headers.mirror_encap_udp.checksum = 0; + headers.ipfix.setValid(); + headers.psamp_extended.setValid(); } } } @@ -542,93 +782,400 @@ control l3_admit(in headers_t headers, inout local_metadata_t local_metadata, in @defaultonly NoAction; } const default_action = NoAction; - size = 128; + size = 64; } apply { - l3_admit_table.apply(); + if (local_metadata.enable_vlan_checks && !(local_metadata.vlan_id == NO_VLAN_ID || local_metadata.vlan_id == INTERNAL_VLAN_ID)) { + local_metadata.admit_to_l3 = false; + } else { + l3_admit_table.apply(); + } } } -control ttl(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { +control gre_tunnel_encap(inout headers_t headers, in local_metadata_t local_metadata, in standard_metadata_t standard_metadata) { apply { - if (local_metadata.admit_to_l3) { + if (local_metadata.apply_tunnel_encap_at_egress) { + headers.tunnel_encap_gre.setValid(); + headers.tunnel_encap_gre.checksum_present = 0; + headers.tunnel_encap_gre.routing_present = 0; + headers.tunnel_encap_gre.key_present = 0; + headers.tunnel_encap_gre.sequence_present = 0; + headers.tunnel_encap_gre.strict_source_route = 0; + headers.tunnel_encap_gre.recursion_control = 0; + headers.tunnel_encap_gre.flags = 0; + headers.tunnel_encap_gre.version = 0; + headers.tunnel_encap_gre.protocol = headers.ethernet.ether_type; + headers.ethernet.ether_type = 0x86dd; + headers.tunnel_encap_ipv6.setValid(); + headers.tunnel_encap_ipv6.version = 4w6; + headers.tunnel_encap_ipv6.src_addr = local_metadata.tunnel_encap_src_ipv6; + headers.tunnel_encap_ipv6.dst_addr = local_metadata.tunnel_encap_dst_ipv6; + headers.tunnel_encap_ipv6.payload_length = (bit<16>)standard_metadata.packet_length + 4 - 14; + headers.tunnel_encap_ipv6.next_header = 0x2f; if (headers.ipv4.isValid()) { - if (headers.ipv4.ttl <= 1) { - mark_to_drop(standard_metadata); - } else { - headers.ipv4.ttl = headers.ipv4.ttl - 1; - } - } - if (headers.ipv6.isValid()) { - if (headers.ipv6.hop_limit <= 1) { - mark_to_drop(standard_metadata); - } else { - headers.ipv6.hop_limit = headers.ipv6.hop_limit - 1; - } + headers.tunnel_encap_ipv6.dscp = headers.ipv4.dscp; + headers.tunnel_encap_ipv6.ecn = headers.ipv4.ecn; + headers.tunnel_encap_ipv6.hop_limit = headers.ipv4.ttl; + } else if (headers.ipv6.isValid()) { + headers.tunnel_encap_ipv6.dscp = headers.ipv6.dscp; + headers.tunnel_encap_ipv6.ecn = headers.ipv6.ecn; + headers.tunnel_encap_ipv6.hop_limit = headers.ipv6.hop_limit; } } } } -control packet_rewrites(inout headers_t headers, in local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { - apply { - if (local_metadata.admit_to_l3) { - headers.ethernet.src_addr = local_metadata.packet_rewrites.src_mac; +control vlan_untag(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { + @id(0x0100001A) action disable_vlan_checks() { + local_metadata.enable_vlan_checks = false; + } + @p4runtime_role("sdn_controller") @id(0x0200004D) @entry_restriction(" + // Force the dummy_match to be wildcard. + dummy_match::mask == 0; + ") table disable_vlan_checks_table { + key = { + 1w1: ternary @id(1) @name("dummy_match"); + } + actions = { + @proto_id(1) disable_vlan_checks; + } + size = 1; + } + apply { + if (headers.vlan.isValid()) { + local_metadata.vlan_id = headers.vlan.vlan_id; + headers.ethernet.ether_type = headers.vlan.ether_type; + headers.vlan.setInvalid(); + } else { + local_metadata.vlan_id = INTERNAL_VLAN_ID; + } + local_metadata.enable_vlan_checks = true; + disable_vlan_checks_table.apply(); + } +} + +control ingress_vlan_checks(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { + apply { + if (local_metadata.enable_vlan_checks && !(local_metadata.vlan_id == NO_VLAN_ID || local_metadata.vlan_id == INTERNAL_VLAN_ID)) { + mark_to_drop(standard_metadata); + } + } +} + +control egress_vlan_checks(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { + apply { + if (local_metadata.enable_vlan_checks) { + if (standard_metadata.instance_type == 1 && standard_metadata.egress_rid == 2 && !(local_metadata.mirror_encap_vlan_id == NO_VLAN_ID || local_metadata.mirror_encap_vlan_id == INTERNAL_VLAN_ID)) { + mark_to_drop(standard_metadata); + } else if (!(standard_metadata.instance_type == 1 && standard_metadata.egress_rid == 1) && !(local_metadata.vlan_id == NO_VLAN_ID || local_metadata.vlan_id == INTERNAL_VLAN_ID)) { + mark_to_drop(standard_metadata); + } + } + } +} + +control vlan_tag(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { + apply { + if (!(local_metadata.vlan_id == NO_VLAN_ID || local_metadata.vlan_id == INTERNAL_VLAN_ID) && !(standard_metadata.instance_type == 1 && standard_metadata.egress_rid == 2)) { + headers.vlan.setValid(); + headers.vlan.priority_code_point = 0; + headers.vlan.drop_eligible_indicator = 0; + headers.vlan.vlan_id = local_metadata.vlan_id; + headers.vlan.ether_type = headers.ethernet.ether_type; + headers.ethernet.ether_type = 0x8100; + } + } +} + +const ipv6_addr_t IPV6_MULTICAST_MASK = 0xff000000000000000000000000000000; +const ipv6_addr_t IPV6_MULTICAST_VALUE = 0xff000000000000000000000000000000; +const ipv6_addr_t IPV6_LOOPBACK_MASK = 0xffffffffffffffffffffffffffffffff; +const ipv6_addr_t IPV6_LOOPBACK_VALUE = 0x1; +const ipv4_addr_t IPV4_MULTICAST_MASK = 0xf0000000; +const ipv4_addr_t IPV4_MULTICAST_VALUE = 0xe0000000; +const ipv4_addr_t IPV4_BROADCAST_VALUE = 0xffffffff; +const ipv4_addr_t IPV4_LOOPBACK_MASK = 0xff000000; +const ipv4_addr_t IPV4_LOOPBACK_VALUE = 0x7f000000; +const ethernet_addr_t MAC_MULTICAST_MASK = 0x10000000000; +const ethernet_addr_t MAC_MULTICAST_VALUE = 0x10000000000; +control drop_martians(in headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { + apply { + if (headers.ipv6.isValid() && (headers.ipv6.src_addr & IPV6_MULTICAST_MASK == IPV6_MULTICAST_VALUE || headers.ipv6.dst_addr & IPV6_MULTICAST_MASK == IPV6_MULTICAST_VALUE || headers.ipv6.src_addr & IPV6_LOOPBACK_MASK == IPV6_LOOPBACK_VALUE || headers.ipv6.dst_addr & IPV6_LOOPBACK_MASK == IPV6_LOOPBACK_VALUE) || headers.ipv4.isValid() && (headers.ipv4.src_addr & IPV4_MULTICAST_MASK == IPV4_MULTICAST_VALUE || headers.ipv4.src_addr == IPV4_BROADCAST_VALUE || (headers.ipv4.dst_addr & IPV4_MULTICAST_MASK == IPV4_MULTICAST_VALUE || headers.ipv4.dst_addr == IPV4_BROADCAST_VALUE) || headers.ipv4.src_addr & IPV4_LOOPBACK_MASK == IPV4_LOOPBACK_VALUE || headers.ipv4.dst_addr & IPV4_LOOPBACK_MASK == IPV4_LOOPBACK_VALUE) || headers.ethernet.isValid() && headers.ethernet.dst_addr & MAC_MULTICAST_MASK == MAC_MULTICAST_VALUE) { + mark_to_drop(standard_metadata); + } + } +} + +control multicast_rewrites(inout local_metadata_t local_metadata, in standard_metadata_t standard_metadata) { + port_id_t multicast_replica_port = (port_id_t)standard_metadata.egress_port; + replica_instance_t multicast_replica_instance = standard_metadata.egress_rid; + @id(0x01000019) action set_multicast_src_mac(@id(1) @format(MAC_ADDRESS) ethernet_addr_t src_mac) { + local_metadata.enable_src_mac_rewrite = true; + local_metadata.packet_rewrites.src_mac = src_mac; + } + @p4runtime_role("sdn_controller") @id(0x0200004C) table multicast_router_interface_table { + key = { + multicast_replica_port : exact @referenced_by(builtin : : multicast_group_table , replica . port) @id(1); + multicast_replica_instance: exact @referenced_by(builtin : : multicast_group_table , replica . instance) @id(2); + } + actions = { + @proto_id(1) set_multicast_src_mac; + } + size = 110; + } + apply { + multicast_router_interface_table.apply(); + } +} + +control packet_rewrites(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { + apply { + if (standard_metadata.instance_type == 5) { + local_metadata.enable_decrement_ttl = true; + multicast_rewrites.apply(local_metadata, standard_metadata); + } + if (local_metadata.enable_src_mac_rewrite) { + headers.ethernet.src_addr = local_metadata.packet_rewrites.src_mac; + } + if (local_metadata.enable_dst_mac_rewrite) { headers.ethernet.dst_addr = local_metadata.packet_rewrites.dst_mac; } + if (local_metadata.enable_vlan_rewrite) { + local_metadata.vlan_id = local_metadata.packet_rewrites.vlan_id; + } + if (headers.ipv4.isValid()) { + if (headers.ipv4.ttl > 0 && local_metadata.enable_decrement_ttl) { + headers.ipv4.ttl = headers.ipv4.ttl - 1; + } + if (headers.ipv4.ttl == 0) { + mark_to_drop(standard_metadata); + } + } + if (headers.ipv6.isValid()) { + if (headers.ipv6.hop_limit > 0 && local_metadata.enable_decrement_ttl) { + headers.ipv6.hop_limit = headers.ipv6.hop_limit - 1; + } + if (headers.ipv6.hop_limit == 0) { + mark_to_drop(standard_metadata); + } + } } } -@id(0x01000109) @sai_action(SAI_PACKET_ACTION_DROP) action acl_drop(inout standard_metadata_t standard_metadata) { - mark_to_drop(standard_metadata); +control tunnel_termination_lookup(in headers_t headers, inout local_metadata_t local_metadata) { + @id(0x01000016) action mark_for_tunnel_decap_and_set_vrf(@refers_to(vrf_table , vrf_id) vrf_id_t vrf_id) { + local_metadata.apply_tunnel_decap_at_end_of_pre_ingress = true; + local_metadata.vrf_id = vrf_id; + } + @unsupported @p4runtime_role("sdn_controller") @id(0x0200004B) table ipv6_tunnel_termination_table { + key = { + headers.ipv6.dst_addr: ternary @id(1) @name("dst_ipv6") @format(IPV6_ADDRESS); + headers.ipv6.src_addr: ternary @id(2) @name("src_ipv6") @format(IPV6_ADDRESS); + } + actions = { + @proto_id(1) mark_for_tunnel_decap_and_set_vrf; + } + size = 126; + } + apply { + if (headers.ipv6.isValid()) { + if (headers.ipv6.next_header == 0x4 || headers.ipv6.next_header == 0x29) { + ipv6_tunnel_termination_table.apply(); + } + } + } +} + +control tunnel_termination_decap(inout headers_t headers, in local_metadata_t local_metadata) { + apply { + if (local_metadata.apply_tunnel_decap_at_end_of_pre_ingress) { + assert(headers.ipv6.isValid()); + assert(headers.inner_ipv4.isValid() && !headers.inner_ipv6.isValid() || !headers.inner_ipv4.isValid() && headers.inner_ipv6.isValid()); + headers.ipv6.setInvalid(); + if (headers.inner_ipv4.isValid()) { + headers.ethernet.ether_type = 0x800; + headers.ipv4 = headers.inner_ipv4; + headers.inner_ipv4.setInvalid(); + } + if (headers.inner_ipv6.isValid()) { + headers.ethernet.ether_type = 0x86dd; + headers.ipv6 = headers.inner_ipv6; + headers.inner_ipv6.setInvalid(); + } + } + } +} + +@id(0x01000109) @sai_action(SAI_PACKET_ACTION_DROP) action acl_drop(inout local_metadata_t local_metadata) { + local_metadata.acl_drop = true; +} +control acl_egress(in headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { + bit<6> dscp = 0; + bit<8> ip_protocol = 0; + @id(0x13000104) direct_counter(CounterType.packets_and_bytes) acl_egress_counter; + @id(0x13000108) direct_counter(CounterType.packets_and_bytes) acl_egress_dhcp_to_host_counter; + @id(0x0100010D) @sai_action(SAI_PACKET_ACTION_FORWARD) action acl_egress_forward() { + acl_egress_counter.count(); + } + @p4runtime_role("sdn_controller") @id(0x02000104) @sai_acl(EGRESS) @entry_restriction(" + + + + + + // Only allow IP field matches for IP packets. + ip_protocol::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + + + + + + + + // Forbid illegal combinations of IP_TYPE fields. + is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0); + is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0); + is_ipv6::mask != 0 -> (is_ip::mask == 0 && is_ipv4::mask == 0); + // Forbid unsupported combinations of IP_TYPE fields. + is_ipv4::mask != 0 -> (is_ipv4 == 1); + is_ipv6::mask != 0 -> (is_ipv6 == 1); + ") table acl_egress_table { + key = { + ip_protocol : ternary @id(2) @name("ip_protocol") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IP_PROTOCOL); + (port_id_t)standard_metadata.egress_port : optional @id(4) @name("out_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_OUT_PORT); + headers.ipv4.isValid() || headers.ipv6.isValid(): optional @id(5) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(6) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(7) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + headers.ethernet.src_addr : ternary @id(10) @name("src_mac") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_SRC_MAC) @format(MAC_ADDRESS); + } + actions = { + @proto_id(1) acl_drop(local_metadata); + @defaultonly NoAction; + } + const default_action = NoAction; + counters = acl_egress_counter; + size = 127; + } + @id(0x02000108) @sai_acl(EGRESS) @p4runtime_role("sdn_controller") @entry_restriction(" + // Only allow IP field matches for IP packets. + ip_protocol::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + // Only allow l4_dst_port matches for TCP/UDP packets. + l4_dst_port::mask != 0 -> (ip_protocol == 6 || ip_protocol == 17); + // Forbid illegal combinations of IP_TYPE fields. + is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0); + is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0); + is_ipv6::mask != 0 -> (is_ip::mask == 0 && is_ipv4::mask == 0); + // Forbid unsupported combinations of IP_TYPE fields. + is_ipv4::mask != 0 -> (is_ipv4 == 1); + is_ipv6::mask != 0 -> (is_ipv6 == 1); + ") table acl_egress_dhcp_to_host_table { + key = { + headers.ipv4.isValid() || headers.ipv6.isValid(): optional @id(1) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(2) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(3) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + ip_protocol : ternary @id(5) @name("ip_protocol") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IP_PROTOCOL); + local_metadata.l4_dst_port : ternary @id(6) @name("l4_dst_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_L4_DST_PORT); + (port_id_t)standard_metadata.egress_port : optional @id(7) @name("out_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_OUT_PORT); + } + actions = { + @proto_id(1) acl_drop(local_metadata); + @defaultonly NoAction; + } + const default_action = NoAction; + counters = acl_egress_dhcp_to_host_counter; + size = 127; + } + apply { + if (headers.ipv4.isValid()) { + dscp = headers.ipv4.dscp; + ip_protocol = headers.ipv4.protocol; + } else if (headers.ipv6.isValid()) { + dscp = headers.ipv6.dscp; + ip_protocol = headers.ipv6.next_header; + } else { + ip_protocol = 0; + } + acl_egress_table.apply(); + if (local_metadata.acl_drop) { + mark_to_drop(standard_metadata); + } + } } + control acl_ingress(in headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { bit<8> ttl = 0; bit<6> dscp = 0; bit<2> ecn = 0; bit<8> ip_protocol = 0; - @id(0x15000100) direct_meter(MeterType.bytes) acl_ingress_meter; + bool cancel_copy = false; + @id(0x15000100) @mode(single_rate_two_color) direct_meter(MeterType.bytes) acl_ingress_meter; + @id(0x15000102) @mode(single_rate_two_color) direct_meter(MeterType.bytes) acl_ingress_qos_meter; @id(0x13000102) direct_counter(CounterType.packets_and_bytes) acl_ingress_counter; - @id(0x01000101) @sai_action(SAI_PACKET_ACTION_COPY , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_YELLOW) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_RED) action acl_copy(@sai_action_param(QOS_QUEUE) @id(1) qos_queue_t qos_queue) { + @id(0x13000107) direct_counter(CounterType.packets_and_bytes) acl_ingress_qos_counter; + @id(0x13000109) direct_counter(CounterType.packets_and_bytes) acl_ingress_counting_counter; + @id(0x1300010A) direct_counter(CounterType.packets_and_bytes) acl_ingress_security_counter; + @id(0x01000101) @sai_action(SAI_PACKET_ACTION_COPY , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_RED) action acl_copy(@sai_action_param(QOS_QUEUE) @id(1) qos_queue_t qos_queue) { acl_ingress_counter.count(); acl_ingress_meter.read(local_metadata.color); - clone(CloneType.I2E, 1024); + local_metadata.marked_to_copy = true; } - @id(0x01000102) @sai_action(SAI_PACKET_ACTION_TRAP , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_YELLOW) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED) action acl_trap(@sai_action_param(QOS_QUEUE) @id(1) qos_queue_t qos_queue) { + @id(0x01000102) @sai_action(SAI_PACKET_ACTION_TRAP , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED) action acl_trap(@sai_action_param(QOS_QUEUE) @id(1) qos_queue_t qos_queue) { acl_copy(qos_queue); - mark_to_drop(standard_metadata); + local_metadata.acl_drop = true; } - @id(0x01000199) @sai_action(SAI_PACKET_ACTION_TRAP , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_YELLOW) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED) action acl_experimental_trap(@sai_action_param(QOS_QUEUE) @id(1) qos_queue_t qos_queue) { + @id(0x01000103) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED) action acl_forward() { acl_ingress_meter.read(local_metadata.color); - acl_trap(qos_queue); } - @id(0x01000103) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_YELLOW) @sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED) action acl_forward() { - acl_ingress_counter.count(); - acl_ingress_meter.read(local_metadata.color); + @id(0x01000105) @sai_action(SAI_PACKET_ACTION_FORWARD) action acl_count() { + acl_ingress_counting_counter.count(); } @id(0x01000104) @sai_action(SAI_PACKET_ACTION_FORWARD) action acl_mirror(@id(1) @refers_to(mirror_session_table , mirror_session_id) @sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_MIRROR_INGRESS) mirror_session_id_t mirror_session_id) { acl_ingress_counter.count(); - local_metadata.mirror_session_id_valid = true; - local_metadata.mirror_session_id_value = mirror_session_id; + local_metadata.marked_to_mirror = true; + local_metadata.mirror_session_id = mirror_session_id; + } + @id(0x0100010C) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_COPY_CANCEL , SAI_PACKET_COLOR_RED) action set_qos_queue_and_cancel_copy_above_rate_limit(@id(1) @sai_action_param(QOS_QUEUE) qos_queue_t qos_queue) { + acl_ingress_qos_meter.read(local_metadata.color); + } + @id(0x01000111) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DENY , SAI_PACKET_COLOR_RED) @unsupported action set_cpu_and_multicast_queues_and_deny_above_rate_limit(@id(1) @sai_action_param(QOS_QUEUE) qos_queue_t cpu_queue, @id(2) @sai_action_param(MULTICAST_QOS_QUEUE , SAI_PACKET_COLOR_GREEN) qos_queue_t green_multicast_queue, @id(3) @sai_action_param(MULTICAST_QOS_QUEUE , SAI_PACKET_COLOR_RED) qos_queue_t red_multicast_queue) { + acl_ingress_qos_meter.read(local_metadata.color); + } + @id(0x0100010E) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DENY , SAI_PACKET_COLOR_RED) action set_cpu_queue_and_deny_above_rate_limit(@id(1) @sai_action_param(QOS_QUEUE) qos_queue_t cpu_queue) { + acl_ingress_qos_meter.read(local_metadata.color); + } + @id(0x01000110) @sai_action(SAI_PACKET_ACTION_FORWARD) action set_cpu_queue(@id(1) @sai_action_param(QOS_QUEUE) qos_queue_t cpu_queue) { } - @p4runtime_role("sdn_controller") @id(0x02000100) @sai_acl(INGRESS) @entry_restriction(" + @id(0x0100010F) @sai_action(SAI_PACKET_ACTION_DENY) action acl_deny() { + cancel_copy = true; + local_metadata.acl_drop = true; + } + @p4runtime_role("sdn_controller") @id(0x02000100) @sai_acl(INGRESS) @sai_acl_priority(5) @entry_restriction(" // Forbid using ether_type for IP packets (by convention, use is_ip* instead). ether_type != 0x0800 && ether_type != 0x86dd; // Only allow IP field matches for IP packets. dst_ip::mask != 0 -> is_ipv4 == 1; + + src_ip::mask != 0 -> is_ipv4 == 1; + dst_ipv6::mask != 0 -> is_ipv6 == 1; + src_ipv6::mask != 0 -> is_ipv6 == 1; ttl::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + dscp::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); ecn::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + ip_protocol::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); // Only allow l4_dst_port and l4_src_port matches for TCP/UDP packets. + l4_src_port::mask != 0 -> (ip_protocol == 6 || ip_protocol == 17); + l4_dst_port::mask != 0 -> (ip_protocol == 6 || ip_protocol == 17); // Only allow arp_tpa matches for ARP packets. arp_tpa::mask != 0 -> ether_type == 0x0806; - // Only allow icmp_type matches for ICMP packets + @@ -642,37 +1189,195 @@ control acl_ingress(in headers_t headers, inout local_metadata_t local_metadata, is_ipv6::mask != 0 -> (is_ipv6 == 1); ") table acl_ingress_table { key = { - headers.ipv4.isValid() || headers.ipv6.isValid(): optional @name("is_ip") @id(1) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); - headers.ipv4.isValid() : optional @name("is_ipv4") @id(2) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); - headers.ipv6.isValid() : optional @name("is_ipv6") @id(3) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); - headers.ethernet.ether_type : ternary @name("ether_type") @id(4) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ETHER_TYPE); - headers.ethernet.dst_addr : ternary @name("dst_mac") @id(5) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_MAC) @format(MAC_ADDRESS); - headers.ipv4.src_addr : ternary @name("src_ip") @id(6) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_SRC_IP) @format(IPV4_ADDRESS); - headers.ipv4.dst_addr : ternary @name("dst_ip") @id(7) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_IP) @format(IPV4_ADDRESS); - headers.ipv6.src_addr[127:64] : ternary @name("src_ipv6") @id(8) @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_SRC_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_SRC_IPV6_WORD2 )) @format(IPV6_ADDRESS); - headers.ipv6.dst_addr[127:64] : ternary @name("dst_ipv6") @id(9) @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD2 )) @format(IPV6_ADDRESS); - ttl : ternary @name("ttl") @id(10) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_TTL); - dscp : ternary @name("dscp") @id(11) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DSCP); - ecn : ternary @name("ecn") @id(12) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ECN); - ip_protocol : ternary @name("ip_protocol") @id(13) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IP_PROTOCOL); - headers.icmp.type : ternary @name("icmpv6_type") @id(14) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ICMPV6_TYPE); - local_metadata.l4_src_port : ternary @name("l4_src_port") @id(20) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_L4_SRC_PORT); - local_metadata.l4_dst_port : ternary @name("l4_dst_port") @id(15) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_L4_DST_PORT); - headers.arp.target_proto_addr : ternary @name("arp_tpa") @id(16) @composite_field(@ sai_udf ( base = SAI_UDF_BASE_L3 , offset = 24 , length = 2 ) , @ sai_udf ( base = SAI_UDF_BASE_L3 , offset = 26 , length = 2 )) @format(IPV4_ADDRESS); + headers.ipv4.isValid() || headers.ipv6.isValid(): optional @id(1) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(2) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(3) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + headers.ethernet.ether_type : ternary @id(4) @name("ether_type") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ETHER_TYPE); + headers.ethernet.dst_addr : ternary @id(5) @name("dst_mac") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_MAC) @format(MAC_ADDRESS); + headers.ipv4.src_addr : ternary @id(6) @name("src_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_SRC_IP) @format(IPV4_ADDRESS); + headers.ipv4.dst_addr : ternary @id(7) @name("dst_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_IP) @format(IPV4_ADDRESS); + headers.ipv6.src_addr[127:64] : ternary @id(8) @name("src_ipv6") @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_SRC_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_SRC_IPV6_WORD2 )) @format(IPV6_ADDRESS); + headers.ipv6.dst_addr[127:64] : ternary @id(9) @name("dst_ipv6") @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD2 )) @format(IPV6_ADDRESS); + ttl : ternary @id(10) @name("ttl") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_TTL); + dscp : ternary @id(11) @name("dscp") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DSCP); + ecn : ternary @id(12) @name("ecn") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ECN); + ip_protocol : ternary @id(13) @name("ip_protocol") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IP_PROTOCOL); + headers.icmp.type : ternary @id(14) @name("icmpv6_type") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ICMPV6_TYPE); + local_metadata.l4_src_port : ternary @id(20) @name("l4_src_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_L4_SRC_PORT); + local_metadata.l4_dst_port : ternary @id(15) @name("l4_dst_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_L4_DST_PORT); + headers.arp.target_proto_addr : ternary @id(16) @name("arp_tpa") @composite_field(@ sai_udf ( base = SAI_UDF_BASE_L3 , offset = 24 , length = 2 ) , @ sai_udf ( base = SAI_UDF_BASE_L3 , offset = 26 , length = 2 )) @format(IPV4_ADDRESS); } actions = { @proto_id(1) acl_copy(); @proto_id(2) acl_trap(); @proto_id(3) acl_forward(); @proto_id(4) acl_mirror(); - @proto_id(5) acl_drop(standard_metadata); - @proto_id(99) acl_experimental_trap(); + @proto_id(5) acl_drop(local_metadata); @defaultonly NoAction; } const default_action = NoAction; meters = acl_ingress_meter; counters = acl_ingress_counter; - size = 128; + size = 255; + } + @id(0x02000107) @sai_acl(INGRESS) @sai_acl_priority(10) @p4runtime_role("sdn_controller") @entry_restriction(" + // Forbid using ether_type for IP packets (by convention, use is_ip* instead). + ether_type != 0x0800 && ether_type != 0x86dd; + // Only allow IP field matches for IP packets. + ttl::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + ip_protocol::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + // Only allow l4_dst_port matches for TCP/UDP packets. + l4_dst_port::mask != 0 -> (ip_protocol == 6 || ip_protocol == 17); + // Forbid illegal combinations of IP_TYPE fields. + is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0); + is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0); + is_ipv6::mask != 0 -> (is_ip::mask == 0 && is_ipv4::mask == 0); + // Forbid unsupported combinations of IP_TYPE fields. + is_ipv4::mask != 0 -> (is_ipv4 == 1); + is_ipv6::mask != 0 -> (is_ipv6 == 1); + // Only allow icmp_type matches for ICMP packets + icmpv6_type::mask != 0 -> ip_protocol == 58; +# 369 " .. / .. / .. / .. / pins - infra / sai_p4 / instantiations / google / acl_ingress . p4 " + ") table acl_ingress_qos_table { + key = { + headers.ipv4.isValid() || headers.ipv6.isValid(): optional @id(1) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(2) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(3) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + headers.ethernet.ether_type : ternary @id(4) @name("ether_type") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ETHER_TYPE); + ttl : ternary @id(7) @name("ttl") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_TTL); + ip_protocol : ternary @id(8) @name("ip_protocol") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IP_PROTOCOL); + headers.icmp.type : ternary @id(9) @name("icmpv6_type") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ICMPV6_TYPE); + local_metadata.l4_dst_port : ternary @id(10) @name("l4_dst_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_L4_DST_PORT); + } + actions = { + @proto_id(1) set_qos_queue_and_cancel_copy_above_rate_limit(); + @proto_id(2) set_cpu_queue_and_deny_above_rate_limit(); + @proto_id(3) acl_forward(); + @proto_id(4) acl_drop(local_metadata); + @proto_id(5) set_cpu_queue(); + @proto_id(6) set_cpu_and_multicast_queues_and_deny_above_rate_limit(); + @defaultonly NoAction; + } + const default_action = NoAction; + meters = acl_ingress_qos_meter; + counters = acl_ingress_qos_counter; + size = 511; + } + @p4runtime_role("sdn_controller") @id(0x02000109) @sai_acl_priority(7) @sai_acl(INGRESS) @entry_restriction(" + // Only allow IP field matches for IP packets. + dscp::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + // Forbid illegal combinations of IP_TYPE fields. + is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0); + is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0); + is_ipv6::mask != 0 -> (is_ip::mask == 0 && is_ipv4::mask == 0); + // Forbid unsupported combinations of IP_TYPE fields. + is_ipv4::mask != 0 -> (is_ipv4 == 1); + is_ipv6::mask != 0 -> (is_ipv6 == 1); + ") table acl_ingress_counting_table { + key = { + headers.ipv4.isValid() || headers.ipv6.isValid(): optional @id(1) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(2) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(3) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + dscp : ternary @id(11) @name("dscp") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DSCP); + local_metadata.route_metadata : ternary @id(18) @name("route_metadata") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ROUTE_DST_USER_META); + } + actions = { + @proto_id(3) acl_count(); + @defaultonly NoAction; + } + const default_action = NoAction; + counters = acl_ingress_counting_counter; + size = 255; + } + @id(0x01000112) action redirect_to_nexthop(@sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_REDIRECT) @sai_action_param_object_type(SAI_OBJECT_TYPE_NEXT_HOP) @refers_to(nexthop_table , nexthop_id) nexthop_id_t nexthop_id) { + local_metadata.nexthop_id_valid = true; + local_metadata.nexthop_id_value = nexthop_id; + local_metadata.wcmp_group_id_valid = false; + standard_metadata.mcast_grp = 0; + } + @id(0x01000113) @action_restriction(" + // Disallow 0 since it encodes 'no multicast' in V1Model. + multicast_group_id != 0; + ") action redirect_to_ipmc_group(@sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_REDIRECT) @sai_action_param_object_type(SAI_OBJECT_TYPE_IPMC_GROUP) @refers_to(builtin : : multicast_group_table , multicast_group_id) multicast_group_id_t multicast_group_id) { + standard_metadata.mcast_grp = multicast_group_id; + local_metadata.nexthop_id_valid = false; + local_metadata.wcmp_group_id_valid = false; + } + @id(0x0200010B) @sai_acl(INGRESS) @sai_acl_priority(15) @p4runtime_role("sdn_controller") @entry_restriction(" + // Only allow IP field matches for IP packets. + dst_ip::mask != 0 -> is_ipv4 == 1; + dst_ipv6::mask != 0 -> is_ipv6 == 1; + // Forbid illegal combinations of IP_TYPE fields. + is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0); + is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0); + is_ipv6::mask != 0 -> (is_ip::mask == 0 && is_ipv4::mask == 0); + // Forbid unsupported combinations of IP_TYPE fields. + is_ipv4::mask != 0 -> (is_ipv4 == 1); + is_ipv6::mask != 0 -> (is_ipv6 == 1); + ") table acl_ingress_mirror_and_redirect_table { + key = { + headers.ipv4.isValid() || headers.ipv6.isValid(): optional @id(2) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(3) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(4) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + headers.ipv4.dst_addr : ternary @id(10) @name("dst_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_IP) @format(IPV4_ADDRESS); + headers.ipv6.dst_addr[127:64] : ternary @id(5) @name("dst_ipv6") @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD2 )) @format(IPV6_ADDRESS); + local_metadata.vrf_id : optional @id(8) @name("vrf_id") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_VRF_ID); + local_metadata.ipmc_table_hit : optional @id(9) @name("ipmc_table_hit") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IPMC_NPU_META_DST_HIT); + } + actions = { + @proto_id(4) acl_forward(); + @proto_id(1) acl_mirror(); + @proto_id(2) redirect_to_nexthop(); + @proto_id(3) redirect_to_ipmc_group(); + @defaultonly NoAction; + } + const default_action = NoAction; + size = 255; + } + @id(0x0200010A) @sai_acl(INGRESS) @sai_acl_priority(20) @p4runtime_role("sdn_controller") @entry_restriction(" + // Forbid using ether_type for IP packets (by convention, use is_ip* instead). + ether_type != 0x0800 && ether_type != 0x86dd; + + // Only allow IP field matches for IP packets. + dst_ip::mask != 0 -> is_ipv4 == 1; + src_ip::mask != 0 -> is_ipv4 == 1; + src_ipv6::mask != 0 -> is_ipv6 == 1; + + // TODO: This comment is required for the preprocessor to not + // spit out nonsense. + + + + + + + + // Forbid illegal combinations of IP_TYPE fields. + is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0); + is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0); + is_ipv6::mask != 0 -> (is_ip::mask == 0 && is_ipv4::mask == 0); + // Forbid unsupported combinations of IP_TYPE fields. + is_ipv4::mask != 0 -> (is_ipv4 == 1); + is_ipv6::mask != 0 -> (is_ipv6 == 1); + ") table acl_ingress_security_table { + key = { + headers.ipv4.isValid() || headers.ipv6.isValid(): optional @id(1) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(2) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(3) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + headers.ethernet.ether_type : ternary @id(4) @name("ether_type") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ETHER_TYPE); + headers.ipv4.src_addr : ternary @id(5) @name("src_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_SRC_IP) @format(IPV4_ADDRESS); + headers.ipv4.dst_addr : ternary @id(6) @name("dst_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_IP) @format(IPV4_ADDRESS); + headers.ipv6.src_addr[127:64] : ternary @id(7) @name("src_ipv6") @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_SRC_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_SRC_IPV6_WORD2 )) @format(IPV6_ADDRESS); + } + actions = { + @proto_id(1) acl_forward(); + @proto_id(2) acl_drop(local_metadata); + @proto_id(3) acl_deny(); + @defaultonly NoAction; + } + const default_action = NoAction; + counters = acl_ingress_security_counter; + size = 255; } apply { if (headers.ipv4.isValid()) { @@ -687,19 +1392,37 @@ control acl_ingress(in headers_t headers, inout local_metadata_t local_metadata, ip_protocol = headers.ipv6.next_header; } acl_ingress_table.apply(); + acl_ingress_mirror_and_redirect_table.apply(); + acl_ingress_security_table.apply(); + if (cancel_copy) { + local_metadata.marked_to_copy = false; + } } } control acl_pre_ingress(in headers_t headers, inout local_metadata_t local_metadata, in standard_metadata_t standard_metadata) { bit<6> dscp = 0; + bit<2> ecn = 0; + bit<8> ip_protocol = 0; @id(0x13000101) direct_counter(CounterType.packets_and_bytes) acl_pre_ingress_counter; + @id(0x13000106) direct_counter(CounterType.packets_and_bytes) acl_pre_ingress_vlan_counter; + @id(0x13000105) direct_counter(CounterType.packets_and_bytes) acl_pre_ingress_metadata_counter; @id(0x01000100) @sai_action(SAI_PACKET_ACTION_FORWARD) action set_vrf(@sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_SET_VRF) @refers_to(vrf_table , vrf_id) @id(1) vrf_id_t vrf_id) { local_metadata.vrf_id = vrf_id; acl_pre_ingress_counter.count(); } - @p4runtime_role("sdn_controller") @id(0x02000101) @sai_acl(PRE_INGRESS) @entry_restriction(" + @id(0x0100010A) @sai_action(SAI_PACKET_ACTION_FORWARD) action set_outer_vlan_id(@id(1) @sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_SET_OUTER_VLAN_ID) vlan_id_t vlan_id) { + local_metadata.vlan_id = vlan_id; + acl_pre_ingress_vlan_counter.count(); + } + @id(0x0100010B) @sai_action(SAI_PACKET_ACTION_FORWARD) action set_acl_metadata(@id(1) @sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_SET_ACL_META_DATA) acl_metadata_t acl_metadata) { + local_metadata.acl_metadata = acl_metadata; + acl_pre_ingress_metadata_counter.count(); + } + @p4runtime_role("sdn_controller") @id(0x02000101) @sai_acl(PRE_INGRESS) @sai_acl_priority(11) @entry_restriction(" // Only allow IP field matches for IP packets. dscp::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + ecn::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); dst_ip::mask != 0 -> is_ipv4 == 1; dst_ipv6::mask != 0 -> is_ipv6 == 1; // Forbid illegal combinations of IP_TYPE fields. @@ -709,19 +1432,24 @@ control acl_pre_ingress(in headers_t headers, inout local_metadata_t local_metad // Forbid unsupported combinations of IP_TYPE fields. is_ipv4::mask != 0 -> (is_ipv4 == 1); is_ipv6::mask != 0 -> (is_ipv6 == 1); + + + + // Reserve high priorities for switch-internal use. // TODO: Remove once inband workaround is obsolete. ::priority < 0x7fffffff; ") table acl_pre_ingress_table { key = { - headers.ipv4.isValid() || headers.ipv6.isValid(): optional @name("is_ip") @id(1) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); - headers.ipv4.isValid() : optional @name("is_ipv4") @id(2) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); - headers.ipv6.isValid() : optional @name("is_ipv6") @id(3) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); - headers.ethernet.src_addr : ternary @name("src_mac") @id(4) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_SRC_MAC) @format(MAC_ADDRESS); - headers.ipv4.dst_addr : ternary @name("dst_ip") @id(5) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_IP) @format(IPV4_ADDRESS); - headers.ipv6.dst_addr[127:64] : ternary @name("dst_ipv6") @id(6) @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD2 )) @format(IPV6_ADDRESS); - dscp : ternary @name("dscp") @id(7) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DSCP); - local_metadata.ingress_port : optional @name("in_port") @id(8) @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IN_PORT); + headers.ipv4.isValid() || headers.ipv6.isValid(): optional @id(1) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(2) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(3) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + headers.ethernet.src_addr : ternary @id(4) @name("src_mac") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_SRC_MAC) @format(MAC_ADDRESS); + headers.ipv4.dst_addr : ternary @id(5) @name("dst_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_IP) @format(IPV4_ADDRESS); + headers.ipv6.dst_addr[127:64] : ternary @id(6) @name("dst_ipv6") @composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD2 )) @format(IPV6_ADDRESS); + dscp : ternary @id(7) @name("dscp") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DSCP); + ecn : ternary @id(10) @name("ecn") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ECN); + local_metadata.ingress_port : optional @id(8) @name("in_port") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IN_PORT); } actions = { @proto_id(1) set_vrf; @@ -729,42 +1457,167 @@ control acl_pre_ingress(in headers_t headers, inout local_metadata_t local_metad } const default_action = NoAction; counters = acl_pre_ingress_counter; - size = 255; + size = 254; + } + @id(0x02000105) @sai_acl(PRE_INGRESS) @p4runtime_role("sdn_controller") @sai_acl_priority(1) @entry_restriction(" + // Forbid using ether_type for IP packets (by convention, use is_ip* instead). + ether_type != 0x0800 && ether_type != 0x86dd; + // Forbid illegal combinations of IP_TYPE fields. + is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0); + is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0); + is_ipv6::mask != 0 -> (is_ip::mask == 0 && is_ipv4::mask == 0); + // Forbid unsupported combinations of IP_TYPE fields. + is_ipv4::mask != 0 -> (is_ipv4 == 1); + is_ipv6::mask != 0 -> (is_ipv6 == 1); + // Disallow match on reserved VLAN IDs to rule out vendor specific behavior. + vlan_id::mask != 0 -> (vlan_id != 4095 && vlan_id != 0); + // TODO: Disallow setting to reserved VLAN IDs when supported. + ") table acl_pre_ingress_vlan_table { + key = { + headers.ipv4.isValid() || headers.ipv6.isValid(): optional @id(1) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(2) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(3) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + headers.ethernet.ether_type : ternary @id(4) @name("ether_type") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ETHER_TYPE); + local_metadata.vlan_id : ternary @id(5) @name("vlan_id") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_OUTER_VLAN_ID); + } + actions = { + @proto_id(1) set_outer_vlan_id; + @defaultonly NoAction; + } + const default_action = NoAction; + counters = acl_pre_ingress_vlan_counter; + size = 254; + } + @id(0x02000106) @sai_acl(PRE_INGRESS) @p4runtime_role("sdn_controller") @sai_acl_priority(5) @entry_restriction(" + // Forbid illegal combinations of IP_TYPE fields. + is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0); + is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0); + is_ipv6::mask != 0 -> (is_ip::mask == 0 && is_ipv4::mask == 0); + // DSCP is only allowed on IP traffic. + dscp::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + ecn::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1); + // Forbid unsupported combinations of IP_TYPE fields. + is_ipv4::mask != 0 -> (is_ipv4 == 1); + is_ipv6::mask != 0 -> (is_ipv6 == 1); + // Only allow icmp_type matches for ICMP packets + icmpv6_type::mask != 0 -> ip_protocol == 58; + ") table acl_pre_ingress_metadata_table { + key = { + headers.ipv4.isValid() || headers.ipv6.isValid(): optional @id(1) @name("is_ip") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP); + headers.ipv4.isValid() : optional @id(2) @name("is_ipv4") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY); + headers.ipv6.isValid() : optional @id(3) @name("is_ipv6") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY); + ip_protocol : ternary @id(4) @name("ip_protocol") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_IP_PROTOCOL); + headers.icmp.type : ternary @id(5) @name("icmpv6_type") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ICMPV6_TYPE); + dscp : ternary @id(6) @name("dscp") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_DSCP); + ecn : ternary @id(7) @name("ecn") @sai_field(SAI_ACL_TABLE_ATTR_FIELD_ECN); + } + actions = { + @proto_id(1) set_acl_metadata; + @defaultonly NoAction; + } + const default_action = NoAction; + counters = acl_pre_ingress_metadata_counter; + size = 254; } apply { if (headers.ipv4.isValid()) { dscp = headers.ipv4.dscp; + ecn = headers.ipv4.ecn; + ip_protocol = headers.ipv4.protocol; } else if (headers.ipv6.isValid()) { dscp = headers.ipv6.dscp; + ecn = headers.ipv6.ecn; + ip_protocol = headers.ipv6.next_header; } - local_metadata.vrf_id = kDefaultVrf; acl_pre_ingress_table.apply(); } } control admit_google_system_mac(in headers_t headers, inout local_metadata_t local_metadata) { apply { - local_metadata.admit_to_l3 = headers.ethernet.dst_addr & 0x10000000000 == 0; + local_metadata.admit_to_l3 = headers.ethernet.dst_addr == 0x1a11175f80; + } +} + +control hashing(in headers_t headers, inout local_metadata_t local_metadata, in standard_metadata_t standard_metadata) { + bit<32> seed = 0; + bit<8> offset = 0; + @sai_hash_seed(0) @id(0x010000A) action select_ecmp_hash_algorithm() { + seed = 0; + } + @sai_ecmp_hash(SAI_SWITCH_ATTR_ECMP_HASH_IPV4) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_SRC_IPV4) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_DST_IPV4) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_SRC_PORT) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_DST_PORT) @id(0x0100000B) action compute_ecmp_hash_ipv4() { + hash(local_metadata.wcmp_selector_input, HashAlgorithm.crc32, 1w0, { seed, headers.ipv4.src_addr, headers.ipv4.dst_addr, local_metadata.l4_src_port, local_metadata.l4_dst_port }, 17w0x10000); + local_metadata.wcmp_selector_input = local_metadata.wcmp_selector_input >> offset | local_metadata.wcmp_selector_input << 8 - offset; + } + @sai_ecmp_hash(SAI_SWITCH_ATTR_ECMP_HASH_IPV6) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_SRC_IPV6) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_DST_IPV6) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_SRC_PORT) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_DST_PORT) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_IPV6_FLOW_LABEL) @id(0x0100000C) action compute_ecmp_hash_ipv6() { + hash(local_metadata.wcmp_selector_input, HashAlgorithm.crc32, 1w0, { seed, headers.ipv6.flow_label, headers.ipv6.src_addr, headers.ipv6.dst_addr, local_metadata.l4_src_port, local_metadata.l4_dst_port }, 17w0x10000); + local_metadata.wcmp_selector_input = local_metadata.wcmp_selector_input >> offset | local_metadata.wcmp_selector_input << 8 - offset; + } + apply { + select_ecmp_hash_algorithm(); + if (headers.ipv4.isValid()) { + compute_ecmp_hash_ipv4(); + } else if (headers.ipv6.isValid()) { + compute_ecmp_hash_ipv6(); + } + } +} + +control lag_hashing_config(in headers_t headers) { + bit<32> lag_seed = 0; + bit<4> lag_offset = 0; + @sai_hash_algorithm(SAI_HASH_ALGORITHM_CRC) @sai_hash_seed(0) @sai_hash_offset(0) action select_lag_hash_algorithm() { + lag_seed = 0; + lag_offset = 0; + } + @sai_lag_hash(SAI_SWITCH_ATTR_LAG_HASH_IPV4) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_SRC_IPV4) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_DST_IPV4) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_SRC_PORT) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_DST_PORT) @id(0x0100000D) action compute_lag_hash_ipv4() { + } + @sai_lag_hash(SAI_SWITCH_ATTR_LAG_HASH_IPV6) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_SRC_IPV6) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_DST_IPV6) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_SRC_PORT) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_DST_PORT) @sai_native_hash_field(SAI_NATIVE_HASH_FIELD_IPV6_FLOW_LABEL) @id(0x0100000E) action compute_lag_hash_ipv6() { + } + apply { + select_lag_hash_algorithm(); + if (headers.ipv4.isValid()) { + compute_lag_hash_ipv4(); + } else if (headers.ipv6.isValid()) { + compute_lag_hash_ipv6(); + } } } control ingress(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { apply { - acl_pre_ingress.apply(headers, local_metadata, standard_metadata); - admit_google_system_mac.apply(headers, local_metadata); - l3_admit.apply(headers, local_metadata, standard_metadata); - routing.apply(headers, local_metadata, standard_metadata); - acl_ingress.apply(headers, local_metadata, standard_metadata); - ttl.apply(headers, local_metadata, standard_metadata); - mirroring_clone.apply(headers, local_metadata, standard_metadata); + packet_out_decap.apply(headers, local_metadata, standard_metadata); + if (!local_metadata.bypass_ingress) { + tunnel_termination_lookup.apply(headers, local_metadata); + vlan_untag.apply(headers, local_metadata, standard_metadata); + acl_pre_ingress.apply(headers, local_metadata, standard_metadata); + ingress_vlan_checks.apply(headers, local_metadata, standard_metadata); + tunnel_termination_decap.apply(headers, local_metadata); + admit_google_system_mac.apply(headers, local_metadata); + l3_admit.apply(headers, local_metadata, standard_metadata); + hashing.apply(headers, local_metadata, standard_metadata); + routing_lookup.apply(headers, local_metadata, standard_metadata); + acl_ingress.apply(headers, local_metadata, standard_metadata); + routing_resolution.apply(headers, local_metadata, standard_metadata); + mirror_session_lookup.apply(headers, local_metadata, standard_metadata); + ingress_cloning.apply(headers, local_metadata, standard_metadata); + drop_martians.apply(headers, local_metadata, standard_metadata); + } } } control egress(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { apply { - packet_rewrites.apply(headers, local_metadata, standard_metadata); - mirroring_encap.apply(headers, local_metadata, standard_metadata); + packet_in_encap.apply(headers, local_metadata, standard_metadata); + if (!(standard_metadata.instance_type == 1 && standard_metadata.egress_rid == 1)) { + packet_rewrites.apply(headers, local_metadata, standard_metadata); + gre_tunnel_encap.apply(headers, local_metadata, standard_metadata); + mirroring_encap.apply(headers, local_metadata, standard_metadata); + egress_vlan_checks.apply(headers, local_metadata, standard_metadata); + vlan_tag.apply(headers, local_metadata, standard_metadata); + acl_egress.apply(headers, local_metadata, standard_metadata); + } } } -@pkginfo(name="middleblock.p4", organization="Google") V1Switch(packet_parser(), verify_ipv4_checksum(), ingress(), egress(), compute_ipv4_checksum(), packet_deparser()) main; +@pkginfo(name="middleblock.p4", organization="Google", version="1.6.1") V1Switch(packet_parser(), verify_ipv4_checksum(), ingress(), egress(), compute_ipv4_checksum(), packet_deparser()) main; diff --git a/testdata/p4_16_samples_outputs/pins/pins_middleblock.p4-stderr b/testdata/p4_16_samples_outputs/pins/pins_middleblock.p4-stderr index 49c4e8c20d..1ca0b16dbb 100644 --- a/testdata/p4_16_samples_outputs/pins/pins_middleblock.p4-stderr +++ b/testdata/p4_16_samples_outputs/pins/pins_middleblock.p4-stderr @@ -1,36 +1,111 @@ -pins_middleblock.p4(586): [--Wwarn=shadow] warning: 'ttl' shadows 'control ttl' - bit<8> ttl = 0; - ^^^^^^^^^^^^^^ -pins_middleblock.p4(552) -control ttl(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { - ^^^ -pins_middleblock.p4(314): [--Wwarn=deprecated] warning: set_nexthop: Using deprecated feature set_nexthop. Use set_ip_nexthop instead. +pins_middleblock.p4(615): [--Wwarn=deprecated] warning: set_nexthop: Using deprecated feature set_nexthop. Use set_ip_nexthop instead. @proto_id(1) set_nexthop; ^^^^^^^^^^^ -pins_middleblock.p4(306) +pins_middleblock.p4(603) @id(0x01000003) @deprecated("Use set_ip_nexthop instead.") action set_nexthop(@id(1) @refers_to(router_interface_table , router_interface_id) @refers_to(neighbor_table , router_interface_id) router_interface_id_t router_interface_id, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) ipv6_addr_t neighbor_id) { ^^^^^^^^^^^ -pins_middleblock.p4(592): [--Wwarn=unused] warning: 'qos_queue' is unused - @id(0x01000101) @sai_action(SAI_PACKET_ACTION_COPY , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_YELLOW) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_RED) action acl_copy(@sai_action_param(QOS_QUEUE) @id(1) qos_queue_t qos_queue) { - ^^^^^^^^^ -pins_middleblock.p4(333): [--Wwarn=uninitialized_use] warning: wcmp_group_id_value may not be completely initialized - wcmp_group_id_value : exact @id(1) @name("wcmp_group_id"); - ^^^^^^^^^^^^^^^^^^^ -pins_middleblock.p4(311): [--Wwarn=uninitialized_use] warning: nexthop_id_value may not be completely initialized - nexthop_id_value: exact @id(1) @name("nexthop_id"); - ^^^^^^^^^^^^^^^^ -pins_middleblock.p4(291): [--Wwarn=uninitialized_use] warning: router_interface_id_value may not be completely initialized +pins_middleblock.p4(846): [--Wwarn=ignore-prop] warning: KeyElement: constant key element + 1w1: ternary @id(1) @name("dummy_match"); + ^^^ +pins_middleblock.p4(717): [--Wwarn=unused] warning: 'port' is unused + @id(0x01000007) action mirror_as_ipv4_erspan(@id(1) port_id_t port, @id(2) @format(IPV4_ADDRESS) ipv4_addr_t src_ip, @id(3) @format(IPV4_ADDRESS) ipv4_addr_t dst_ip, @id(4) @format(MAC_ADDRESS) ethernet_addr_t src_mac, @id(5) @format(MAC_ADDRESS) ethernet_addr_t dst_mac, @id(6) bit<8> ttl, @id(7) bit<8> tos) { + ^^^^ +pins_middleblock.p4(717): [--Wwarn=unused] warning: 'src_ip' is unused + @id(0x01000007) action mirror_as_ipv4_erspan(@id(1) port_id_t port, @id(2) @format(IPV4_ADDRESS) ipv4_addr_t src_ip, @id(3) @format(IPV4_ADDRESS) ipv4_addr_t dst_ip, @id(4) @format(MAC_ADDRESS) ethernet_addr_t src_mac, @id(5) @format(MAC_ADDRESS) ethernet_addr_t dst_mac, @id(6) bit<8> ttl, @id(7) bit<8> tos) { + ^^^^^^ +pins_middleblock.p4(717): [--Wwarn=unused] warning: 'dst_ip' is unused + @id(0x01000007) action mirror_as_ipv4_erspan(@id(1) port_id_t port, @id(2) @format(IPV4_ADDRESS) ipv4_addr_t src_ip, @id(3) @format(IPV4_ADDRESS) ipv4_addr_t dst_ip, @id(4) @format(MAC_ADDRESS) ethernet_addr_t src_mac, @id(5) @format(MAC_ADDRESS) ethernet_addr_t dst_mac, @id(6) bit<8> ttl, @id(7) bit<8> tos) { + ^^^^^^ +pins_middleblock.p4(717): [--Wwarn=unused] warning: 'src_mac' is unused + @id(0x01000007) action mirror_as_ipv4_erspan(@id(1) port_id_t port, @id(2) @format(IPV4_ADDRESS) ipv4_addr_t src_ip, @id(3) @format(IPV4_ADDRESS) ipv4_addr_t dst_ip, @id(4) @format(MAC_ADDRESS) ethernet_addr_t src_mac, @id(5) @format(MAC_ADDRESS) ethernet_addr_t dst_mac, @id(6) bit<8> ttl, @id(7) bit<8> tos) { + ^^^^^^^ +pins_middleblock.p4(717): [--Wwarn=unused] warning: 'dst_mac' is unused + @id(0x01000007) action mirror_as_ipv4_erspan(@id(1) port_id_t port, @id(2) @format(IPV4_ADDRESS) ipv4_addr_t src_ip, @id(3) @format(IPV4_ADDRESS) ipv4_addr_t dst_ip, @id(4) @format(MAC_ADDRESS) ethernet_addr_t src_mac, @id(5) @format(MAC_ADDRESS) ethernet_addr_t dst_mac, @id(6) bit<8> ttl, @id(7) bit<8> tos) { + ^^^^^^^ +pins_middleblock.p4(717): [--Wwarn=unused] warning: 'ttl' is unused + @id(0x01000007) action mirror_as_ipv4_erspan(@id(1) port_id_t port, @id(2) @format(IPV4_ADDRESS) ipv4_addr_t src_ip, @id(3) @format(IPV4_ADDRESS) ipv4_addr_t dst_ip, @id(4) @format(MAC_ADDRESS) ethernet_addr_t src_mac, @id(5) @format(MAC_ADDRESS) ethernet_addr_t dst_mac, @id(6) bit<8> ttl, @id(7) bit<8> tos) { + ^^^ +pins_middleblock.p4(717): [--Wwarn=unused] warning: 'tos' is unused + @id(0x01000007) action mirror_as_ipv4_erspan(@id(1) port_id_t port, @id(2) @format(IPV4_ADDRESS) ipv4_addr_t src_ip, @id(3) @format(IPV4_ADDRESS) ipv4_addr_t dst_ip, @id(4) @format(MAC_ADDRESS) ethernet_addr_t src_mac, @id(5) @format(MAC_ADDRESS) ethernet_addr_t dst_mac, @id(6) bit<8> ttl, @id(7) bit<8> tos) { + ^^^ +pins_middleblock.p4(719): [--Wwarn=unused] warning: 'monitor_failover_port' is unused + @id(0x0100001D) @unsupported action mirror_with_vlan_tag_and_ipfix_encapsulation(@id(1) port_id_t monitor_port, @id(2) port_id_t monitor_failover_port, @id(3) @format(MAC_ADDRESS) ethernet_addr_t mirror_encap_src_mac, @id(4) @format(MAC_ADDRESS) ethernet_addr_t mirror_encap_dst_mac, @id(6) vlan_id_t mirror_encap_vlan_id, @id(7) @format(IPV6_ADDRESS) ipv6_addr_t mirror_encap_dst_ip, @id(8) @format(IPV6_ADDRESS) ipv6_addr_t mirror_encap_src_ip, @id(9) bit<16> mirror_encap_udp_src_port, @id(10) bit<16> mirror_encap_udp_dst_port) { + ^^^^^^^^^^^^^^^^^^^^^ +pins_middleblock.p4(1080): [--Wwarn=unused] warning: Table acl_egress_dhcp_to_host_table is not used; removing + ") table acl_egress_dhcp_to_host_table { + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +pins_middleblock.p4(1126): [--Wwarn=unused] warning: 'qos_queue' is unused + @id(0x01000101) @sai_action(SAI_PACKET_ACTION_COPY , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_RED) action acl_copy(@sai_action_param(QOS_QUEUE) @id(1) qos_queue_t qos_queue) { + ^^^^^^^^^ +pins_middleblock.p4(1146): [--Wwarn=unused] warning: 'qos_queue' is unused + @id(0x0100010C) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_COPY_CANCEL , SAI_PACKET_COLOR_RED) action set_qos_queue_and_cancel_copy_above_rate_limit(@id(1) @sai_action_param(QOS_QUEUE) qos_queue_t qos_queue) { + ^^^^^^^^^ +pins_middleblock.p4(1149): [--Wwarn=unused] warning: 'cpu_queue' is unused + @id(0x01000111) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DENY , SAI_PACKET_COLOR_RED) @unsupported action set_cpu_and_multicast_queues_and_deny_above_rate_limit(@id(1) @sai_action_param(QOS_QUEUE) qos_queue_t cpu_queue, @id(2) @sai_action_param(MULTICAST_QOS_QUEUE , SAI_PACKET_COLOR_GREEN) qos_queue_t green_multicast_queue, @id(3) @sai_action_param(MULTICAST_QOS_QUEUE , SAI_PACKET_COLOR_RED) qos_queue_t red_multicast_queue) { + ^^^^^^^^^ +pins_middleblock.p4(1149): [--Wwarn=unused] warning: 'green_multicast_queue' is unused + @id(0x01000111) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DENY , SAI_PACKET_COLOR_RED) @unsupported action set_cpu_and_multicast_queues_and_deny_above_rate_limit(@id(1) @sai_action_param(QOS_QUEUE) qos_queue_t cpu_queue, @id(2) @sai_action_param(MULTICAST_QOS_QUEUE , SAI_PACKET_COLOR_GREEN) qos_queue_t green_multicast_queue, @id(3) @sai_action_param(MULTICAST_QOS_QUEUE , SAI_PACKET_COLOR_RED) qos_queue_t red_multicast_queue) { + ^^^^^^^^^^^^^^^^^^^^^ +pins_middleblock.p4(1149): [--Wwarn=unused] warning: 'red_multicast_queue' is unused + @id(0x01000111) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DENY , SAI_PACKET_COLOR_RED) @unsupported action set_cpu_and_multicast_queues_and_deny_above_rate_limit(@id(1) @sai_action_param(QOS_QUEUE) qos_queue_t cpu_queue, @id(2) @sai_action_param(MULTICAST_QOS_QUEUE , SAI_PACKET_COLOR_GREEN) qos_queue_t green_multicast_queue, @id(3) @sai_action_param(MULTICAST_QOS_QUEUE , SAI_PACKET_COLOR_RED) qos_queue_t red_multicast_queue) { + ^^^^^^^^^^^^^^^^^^^ +pins_middleblock.p4(1152): [--Wwarn=unused] warning: 'cpu_queue' is unused + @id(0x0100010E) @sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_GREEN) @sai_action(SAI_PACKET_ACTION_DENY , SAI_PACKET_COLOR_RED) action set_cpu_queue_and_deny_above_rate_limit(@id(1) @sai_action_param(QOS_QUEUE) qos_queue_t cpu_queue) { + ^^^^^^^^^ +pins_middleblock.p4(1155): [--Wwarn=unused] warning: 'cpu_queue' is unused + @id(0x01000110) @sai_action(SAI_PACKET_ACTION_FORWARD) action set_cpu_queue(@id(1) @sai_action_param(QOS_QUEUE) qos_queue_t cpu_queue) { + ^^^^^^^^^ +pins_middleblock.p4(1249): [--Wwarn=unused] warning: Table acl_ingress_qos_table is not used; removing + ") table acl_ingress_qos_table { + ^^^^^^^^^^^^^^^^^^^^^ +pins_middleblock.p4(1284): [--Wwarn=unused] warning: Table acl_ingress_counting_table is not used; removing + ") table acl_ingress_counting_table { + ^^^^^^^^^^^^^^^^^^^^^^^^^^ +pins_middleblock.p4(1483): [--Wwarn=unused] warning: Table acl_pre_ingress_vlan_table is not used; removing + ") table acl_pre_ingress_vlan_table { + ^^^^^^^^^^^^^^^^^^^^^^^^^^ +pins_middleblock.p4(1512): [--Wwarn=unused] warning: Table acl_pre_ingress_metadata_table is not used; removing + ") table acl_pre_ingress_metadata_table { + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +pins_middleblock.p4(1574): [--Wwarn=unused] warning: Control lag_hashing_config is not used; removing +control lag_hashing_config(in headers_t headers) { + ^^^^^^^^^^^^^^^^^^ +pins_middleblock.p4(1025): [--Wwarn=unused] warning: acl_egress_dhcp_to_host_counter: unused instance + @id(0x13000108) direct_counter(CounterType.packets_and_bytes) acl_egress_dhcp_to_host_counter; + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +pins_middleblock.p4(1123): [--Wwarn=unused] warning: acl_ingress_qos_counter: unused instance + @id(0x13000107) direct_counter(CounterType.packets_and_bytes) acl_ingress_qos_counter; + ^^^^^^^^^^^^^^^^^^^^^^^ +pins_middleblock.p4(1121): [--Wwarn=unused] warning: acl_ingress_qos_meter: unused instance + @id(0x15000102) @mode(single_rate_two_color) direct_meter(MeterType.bytes) acl_ingress_qos_meter; + ^^^^^^^^^^^^^^^^^^^^^ +pins_middleblock.p4(1124): [--Wwarn=unused] warning: acl_ingress_counting_counter: unused instance + @id(0x13000109) direct_counter(CounterType.packets_and_bytes) acl_ingress_counting_counter; + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +pins_middleblock.p4(1416): [--Wwarn=unused] warning: acl_pre_ingress_vlan_counter: unused instance + @id(0x13000106) direct_counter(CounterType.packets_and_bytes) acl_pre_ingress_vlan_counter; + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +pins_middleblock.p4(1417): [--Wwarn=unused] warning: acl_pre_ingress_metadata_counter: unused instance + @id(0x13000105) direct_counter(CounterType.packets_and_bytes) acl_pre_ingress_metadata_counter; + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +pins_middleblock.p4(632): [--Wwarn=uninitialized_use] warning: tunnel_id_value may not be completely initialized + tunnel_id_value: exact @id(1) @name("tunnel_id"); + ^^^^^^^^^^^^^^^ +pins_middleblock.p4(580): [--Wwarn=uninitialized_use] warning: router_interface_id_value may not be completely initialized router_interface_id_value: exact @id(1) @name("router_interface_id"); ^^^^^^^^^^^^^^^^^^^^^^^^^ -pins_middleblock.p4(275): [--Wwarn=uninitialized_use] warning: router_interface_id_value may not be completely initialized +pins_middleblock.p4(558): [--Wwarn=uninitialized_use] warning: router_interface_id_value may not be completely initialized router_interface_id_value: exact @id(1) @name("router_interface_id") @refers_to(router_interface_table , router_interface_id); ^^^^^^^^^^^^^^^^^^^^^^^^^ -pins_middleblock.p4(276): [--Wwarn=uninitialized_use] warning: neighbor_id_value may be uninitialized +pins_middleblock.p4(559): [--Wwarn=uninitialized_use] warning: neighbor_id_value may be uninitialized neighbor_id_value : exact @id(2) @format(IPV6_ADDRESS) @name("neighbor_id"); ^^^^^^^^^^^^^^^^^ -pins_middleblock.p4(512): [--Wwarn=uninitialized_use] warning: mirror_port may not be completely initialized - mirror_port: exact @id(1); - ^^^^^^^^^^^ -pins_middleblock.p4(524): [--Wwarn=uninitialized_use] warning: pre_session may be uninitialized - clone_preserving_field_list(CloneType.I2E, pre_session, (bit<8>)PreservedFieldList.CLONE_I2E); - ^^^^^^^^^^^ +pins_middleblock.p4(846): [--Wwarn=mismatch] warning: 1w1: Constant key field + 1w1: ternary @id(1) @name("dummy_match"); + ^^^ +pins_middleblock.p4(1558): [--Wwarn=overflow] warning: local_metadata._wcmp_selector_input13 << 8: shifting value with 8 bits by 8 + local_metadata.wcmp_selector_input = local_metadata.wcmp_selector_input >> offset | local_metadata.wcmp_selector_input << 8 - offset; + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +pins_middleblock.p4(1562): [--Wwarn=overflow] warning: local_metadata._wcmp_selector_input13 << 8: shifting value with 8 bits by 8 + local_metadata.wcmp_selector_input = local_metadata.wcmp_selector_input >> offset | local_metadata.wcmp_selector_input << 8 - offset; + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/testdata/p4_16_samples_outputs/pins/pins_middleblock.p4.p4info.txtpb b/testdata/p4_16_samples_outputs/pins/pins_middleblock.p4.p4info.txtpb index a2742d05d6..a874de55c5 100644 --- a/testdata/p4_16_samples_outputs/pins/pins_middleblock.p4.p4info.txtpb +++ b/testdata/p4_16_samples_outputs/pins/pins_middleblock.p4.p4info.txtpb @@ -3,9 +3,68 @@ pkg_info { name: "middleblock.p4" + version: "1.6.1" arch: "v1model" organization: "Google" } +tables { + preamble { + id: 33554507 + name: "ingress.tunnel_termination_lookup.ipv6_tunnel_termination_table" + alias: "ipv6_tunnel_termination_table" + annotations: "@unsupported" + annotations: "@p4runtime_role(\"sdn_controller\")" + } + match_fields { + id: 1 + name: "dst_ipv6" + annotations: "@format(IPV6_ADDRESS)" + bitwidth: 128 + match_type: TERNARY + } + match_fields { + id: 2 + name: "src_ipv6" + annotations: "@format(IPV6_ADDRESS)" + bitwidth: 128 + match_type: TERNARY + } + action_refs { + id: 16777238 + annotations: "@proto_id(1)" + } + action_refs { + id: 21257015 + annotations: "@defaultonly" + scope: DEFAULT_ONLY + } + size: 126 +} +tables { + preamble { + id: 33554509 + name: "ingress.vlan_untag.disable_vlan_checks_table" + alias: "disable_vlan_checks_table" + annotations: "@p4runtime_role(\"sdn_controller\")" + annotations: "@entry_restriction(\"\n // Force the dummy_match to be wildcard.\n dummy_match::mask == 0;\n \")" + } + match_fields { + id: 1 + name: "dummy_match" + bitwidth: 1 + match_type: TERNARY + } + action_refs { + id: 16777242 + annotations: "@proto_id(1)" + } + action_refs { + id: 21257015 + annotations: "@defaultonly" + scope: DEFAULT_ONLY + } + size: 1 +} tables { preamble { id: 33554689 @@ -13,7 +72,8 @@ tables { alias: "acl_pre_ingress_table" annotations: "@p4runtime_role(\"sdn_controller\")" annotations: "@sai_acl(PRE_INGRESS)" - annotations: "@entry_restriction(\"\n // Only allow IP field matches for IP packets.\n dscp::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1);\n dst_ip::mask != 0 -> is_ipv4 == 1;\n dst_ipv6::mask != 0 -> is_ipv6 == 1;\n // Forbid illegal combinations of IP_TYPE fields.\n is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0);\n is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0);\n is_ipv6::mask != 0 -> (is_ip::mask == 0 && is_ipv4::mask == 0);\n // Forbid unsupported combinations of IP_TYPE fields.\n is_ipv4::mask != 0 -> (is_ipv4 == 1);\n is_ipv6::mask != 0 -> (is_ipv6 == 1);\n // Reserve high priorities for switch-internal use.\n // TODO: Remove once inband workaround is obsolete.\n ::priority < 0x7fffffff;\n \")" + annotations: "@sai_acl_priority(11)" + annotations: "@entry_restriction(\"\n // Only allow IP field matches for IP packets.\n dscp::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1);\n ecn::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1);\n dst_ip::mask != 0 -> is_ipv4 == 1;\n dst_ipv6::mask != 0 -> is_ipv6 == 1;\n // Forbid illegal combinations of IP_TYPE fields.\n is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0);\n is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0);\n is_ipv6::mask != 0 -> (is_ip::mask == 0 && is_ipv4::mask == 0);\n // Forbid unsupported combinations of IP_TYPE fields.\n is_ipv4::mask != 0 -> (is_ipv4 == 1);\n is_ipv6::mask != 0 -> (is_ipv6 == 1);\n\n\n\n\n // Reserve high priorities for switch-internal use.\n // TODO: Remove once inband workaround is obsolete.\n ::priority < 0x7fffffff;\n \")" } match_fields { id: 1 @@ -67,6 +127,13 @@ tables { bitwidth: 6 match_type: TERNARY } + match_fields { + id: 10 + name: "ecn" + annotations: "@sai_field(SAI_ACL_TABLE_ATTR_FIELD_ECN)" + bitwidth: 2 + match_type: TERNARY + } match_fields { id: 8 name: "in_port" @@ -88,7 +155,7 @@ tables { } const_default_action_id: 21257015 direct_resource_ids: 318767361 - size: 255 + size: 254 } tables { preamble { @@ -123,138 +190,12 @@ tables { scope: DEFAULT_ONLY } const_default_action_id: 21257015 - size: 128 -} -tables { - preamble { - id: 33554496 - name: "ingress.routing.neighbor_table" - alias: "neighbor_table" - annotations: "@p4runtime_role(\"sdn_controller\")" - } - match_fields { - id: 1 - name: "router_interface_id" - annotations: "@refers_to(router_interface_table , router_interface_id)" - bitwidth: 10 - match_type: EXACT - type_name { - name: "router_interface_id_t" - } - } - match_fields { - id: 2 - name: "neighbor_id" - annotations: "@format(IPV6_ADDRESS)" - bitwidth: 128 - match_type: EXACT - } - action_refs { - id: 16777217 - annotations: "@proto_id(1)" - } - action_refs { - id: 21257015 - annotations: "@defaultonly" - scope: DEFAULT_ONLY - } - const_default_action_id: 21257015 - size: 1024 -} -tables { - preamble { - id: 33554497 - name: "ingress.routing.router_interface_table" - alias: "router_interface_table" - annotations: "@p4runtime_role(\"sdn_controller\")" - } - match_fields { - id: 1 - name: "router_interface_id" - bitwidth: 10 - match_type: EXACT - type_name { - name: "router_interface_id_t" - } - } - action_refs { - id: 16777218 - annotations: "@proto_id(1)" - } - action_refs { - id: 21257015 - annotations: "@defaultonly" - scope: DEFAULT_ONLY - } - const_default_action_id: 21257015 - size: 256 -} -tables { - preamble { - id: 33554498 - name: "ingress.routing.nexthop_table" - alias: "nexthop_table" - annotations: "@p4runtime_role(\"sdn_controller\")" - } - match_fields { - id: 1 - name: "nexthop_id" - bitwidth: 10 - match_type: EXACT - type_name { - name: "nexthop_id_t" - } - } - action_refs { - id: 16777219 - annotations: "@proto_id(1)" - } - action_refs { - id: 16777236 - annotations: "@proto_id(3)" - } - action_refs { - id: 21257015 - annotations: "@defaultonly" - scope: DEFAULT_ONLY - } - const_default_action_id: 21257015 - size: 1024 -} -tables { - preamble { - id: 33554499 - name: "ingress.routing.wcmp_group_table" - alias: "wcmp_group_table" - annotations: "@p4runtime_role(\"sdn_controller\")" - annotations: "@oneshot" - } - match_fields { - id: 1 - name: "wcmp_group_id" - bitwidth: 12 - match_type: EXACT - type_name { - name: "wcmp_group_id_t" - } - } - action_refs { - id: 16777221 - annotations: "@proto_id(1)" - } - action_refs { - id: 21257015 - annotations: "@defaultonly" - scope: DEFAULT_ONLY - } - const_default_action_id: 21257015 - implementation_id: 299650760 - size: 3968 + size: 64 } tables { preamble { id: 33554506 - name: "ingress.routing.vrf_table" + name: "ingress.routing_lookup.vrf_table" alias: "vrf_table" annotations: "@entry_restriction(\"\n // The VRF ID 0 (or \'\' in P4Runtime) encodes the default VRF, which cannot\n // be read or written via this table, but is always present implicitly.\n // TODO: This constraint should read `vrf_id != \'\'` (since\n // constraints are a control plane (P4Runtime) concept), but\n // p4-constraints does not currently support strings.\n vrf_id != 0;\n \")" annotations: "@p4runtime_role(\"sdn_controller\")" @@ -278,7 +219,7 @@ tables { tables { preamble { id: 33554500 - name: "ingress.routing.ipv4_table" + name: "ingress.routing_lookup.ipv4_table" alias: "ipv4_table" annotations: "@p4runtime_role(\"sdn_controller\")" } @@ -311,10 +252,6 @@ tables { id: 16777220 annotations: "@proto_id(3)" } - action_refs { - id: 16777231 - annotations: "@proto_id(4)" - } action_refs { id: 16777232 annotations: "@proto_id(5)" @@ -323,13 +260,17 @@ tables { id: 16777233 annotations: "@proto_id(6)" } + action_refs { + id: 16777237 + annotations: "@proto_id(7)" + } const_default_action_id: 16777222 - size: 32768 + size: 131072 } tables { preamble { id: 33554501 - name: "ingress.routing.ipv6_table" + name: "ingress.routing_lookup.ipv6_table" alias: "ipv6_table" annotations: "@p4runtime_role(\"sdn_controller\")" } @@ -362,10 +303,6 @@ tables { id: 16777220 annotations: "@proto_id(3)" } - action_refs { - id: 16777231 - annotations: "@proto_id(4)" - } action_refs { id: 16777232 annotations: "@proto_id(5)" @@ -374,8 +311,82 @@ tables { id: 16777233 annotations: "@proto_id(6)" } + action_refs { + id: 16777237 + annotations: "@proto_id(7)" + } const_default_action_id: 16777222 - size: 4096 + size: 17000 +} +tables { + preamble { + id: 33554510 + name: "ingress.routing_lookup.ipv4_multicast_table" + alias: "ipv4_multicast_table" + annotations: "@p4runtime_role(\"sdn_controller\")" + } + match_fields { + id: 1 + name: "vrf_id" + annotations: "@refers_to(vrf_table , vrf_id)" + bitwidth: 10 + match_type: EXACT + type_name { + name: "vrf_id_t" + } + } + match_fields { + id: 2 + name: "ipv4_dst" + annotations: "@format(IPV4_ADDRESS)" + bitwidth: 32 + match_type: EXACT + } + action_refs { + id: 16777240 + annotations: "@proto_id(1)" + } + action_refs { + id: 21257015 + annotations: "@defaultonly" + scope: DEFAULT_ONLY + } + size: 1600 +} +tables { + preamble { + id: 33554511 + name: "ingress.routing_lookup.ipv6_multicast_table" + alias: "ipv6_multicast_table" + annotations: "@p4runtime_role(\"sdn_controller\")" + } + match_fields { + id: 1 + name: "vrf_id" + annotations: "@refers_to(vrf_table , vrf_id)" + bitwidth: 10 + match_type: EXACT + type_name { + name: "vrf_id_t" + } + } + match_fields { + id: 2 + name: "ipv6_dst" + annotations: "@format(IPV6_ADDRESS)" + bitwidth: 128 + match_type: EXACT + } + action_refs { + id: 16777240 + annotations: "@proto_id(1)" + } + action_refs { + id: 21257015 + annotations: "@defaultonly" + scope: DEFAULT_ONLY + } + size: 1600 } tables { preamble { @@ -384,7 +395,8 @@ tables { alias: "acl_ingress_table" annotations: "@p4runtime_role(\"sdn_controller\")" annotations: "@sai_acl(INGRESS)" - annotations: "@entry_restriction(\"\n // Forbid using ether_type for IP packets (by convention, use is_ip* instead).\n ether_type != 0x0800 && ether_type != 0x86dd;\n // Only allow IP field matches for IP packets.\n dst_ip::mask != 0 -> is_ipv4 == 1;\n dst_ipv6::mask != 0 -> is_ipv6 == 1;\n ttl::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1);\n dscp::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1);\n ecn::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1);\n ip_protocol::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1);\n // Only allow l4_dst_port and l4_src_port matches for TCP/UDP packets.\n l4_src_port::mask != 0 -> (ip_protocol == 6 || ip_protocol == 17);\n l4_dst_port::mask != 0 -> (ip_protocol == 6 || ip_protocol == 17);\n\n // Only allow arp_tpa matches for ARP packets.\n arp_tpa::mask != 0 -> ether_type == 0x0806;\n\n // Only allow icmp_type matches for ICMP packets\n\n\n\n icmpv6_type::mask != 0 -> ip_protocol == 58;\n // Forbid illegal combinations of IP_TYPE fields.\n is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0);\n is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0);\n is_ipv6::mask != 0 -> (is_ip::mask == 0 && is_ipv4::mask == 0);\n // Forbid unsupported combinations of IP_TYPE fields.\n is_ipv4::mask != 0 -> (is_ipv4 == 1);\n is_ipv6::mask != 0 -> (is_ipv6 == 1);\n \")" + annotations: "@sai_acl_priority(5)" + annotations: "@entry_restriction(\"\n // Forbid using ether_type for IP packets (by convention, use is_ip* instead).\n ether_type != 0x0800 && ether_type != 0x86dd;\n // Only allow IP field matches for IP packets.\n dst_ip::mask != 0 -> is_ipv4 == 1;\n\n src_ip::mask != 0 -> is_ipv4 == 1;\n\n dst_ipv6::mask != 0 -> is_ipv6 == 1;\n src_ipv6::mask != 0 -> is_ipv6 == 1;\n ttl::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1);\n\n dscp::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1);\n ecn::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1);\n\n ip_protocol::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1);\n // Only allow l4_dst_port and l4_src_port matches for TCP/UDP packets.\n\n l4_src_port::mask != 0 -> (ip_protocol == 6 || ip_protocol == 17);\n\n l4_dst_port::mask != 0 -> (ip_protocol == 6 || ip_protocol == 17);\n\n // Only allow arp_tpa matches for ARP packets.\n arp_tpa::mask != 0 -> ether_type == 0x0806;\n\n\n\n\n\n icmpv6_type::mask != 0 -> ip_protocol == 58;\n // Forbid illegal combinations of IP_TYPE fields.\n is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0);\n is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0);\n is_ipv6::mask != 0 -> (is_ip::mask == 0 && is_ipv4::mask == 0);\n // Forbid unsupported combinations of IP_TYPE fields.\n is_ipv4::mask != 0 -> (is_ipv4 == 1);\n is_ipv6::mask != 0 -> (is_ipv6 == 1);\n \")" } match_fields { id: 1 @@ -531,10 +543,6 @@ tables { id: 16777481 annotations: "@proto_id(5)" } - action_refs { - id: 16777625 - annotations: "@proto_id(99)" - } action_refs { id: 21257015 annotations: "@defaultonly" @@ -543,54 +551,205 @@ tables { const_default_action_id: 21257015 direct_resource_ids: 318767362 direct_resource_ids: 352321792 - size: 128 + size: 255 } tables { preamble { - id: 33554502 - name: "ingress.mirroring_clone.mirror_session_table" - alias: "mirror_session_table" + id: 33554699 + name: "ingress.acl_ingress.acl_ingress_mirror_and_redirect_table" + alias: "acl_ingress_mirror_and_redirect_table" + annotations: "@sai_acl(INGRESS)" + annotations: "@sai_acl_priority(15)" annotations: "@p4runtime_role(\"sdn_controller\")" + annotations: "@entry_restriction(\"\n // Only allow IP field matches for IP packets.\n dst_ip::mask != 0 -> is_ipv4 == 1;\n dst_ipv6::mask != 0 -> is_ipv6 == 1;\n // Forbid illegal combinations of IP_TYPE fields.\n is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0);\n is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0);\n is_ipv6::mask != 0 -> (is_ip::mask == 0 && is_ipv4::mask == 0);\n // Forbid unsupported combinations of IP_TYPE fields.\n is_ipv4::mask != 0 -> (is_ipv4 == 1);\n is_ipv6::mask != 0 -> (is_ipv6 == 1);\n \")" } match_fields { - id: 1 - name: "mirror_session_id" - bitwidth: 10 - match_type: EXACT + id: 2 + name: "is_ip" + annotations: "@sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP)" + bitwidth: 1 + match_type: OPTIONAL + } + match_fields { + id: 3 + name: "is_ipv4" + annotations: "@sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY)" + bitwidth: 1 + match_type: OPTIONAL + } + match_fields { + id: 4 + name: "is_ipv6" + annotations: "@sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY)" + bitwidth: 1 + match_type: OPTIONAL + } + match_fields { + id: 10 + name: "dst_ip" + annotations: "@sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_IP)" + annotations: "@format(IPV4_ADDRESS)" + bitwidth: 32 + match_type: TERNARY + } + match_fields { + id: 5 + name: "dst_ipv6" + annotations: "@composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_DST_IPV6_WORD2 ))" + annotations: "@format(IPV6_ADDRESS)" + bitwidth: 64 + match_type: TERNARY + } + match_fields { + id: 8 + name: "vrf_id" + annotations: "@sai_field(SAI_ACL_TABLE_ATTR_FIELD_VRF_ID)" + bitwidth: 10 + match_type: OPTIONAL type_name { - name: "mirror_session_id_t" + name: "vrf_id_t" } } + match_fields { + id: 9 + name: "ipmc_table_hit" + annotations: "@sai_field(SAI_ACL_TABLE_ATTR_FIELD_IPMC_NPU_META_DST_HIT)" + bitwidth: 1 + match_type: OPTIONAL + } action_refs { - id: 16777223 + id: 16777475 + annotations: "@proto_id(4)" + } + action_refs { + id: 16777476 annotations: "@proto_id(1)" } + action_refs { + id: 16777490 + annotations: "@proto_id(2)" + } + action_refs { + id: 16777491 + annotations: "@proto_id(3)" + } action_refs { id: 21257015 annotations: "@defaultonly" scope: DEFAULT_ONLY } const_default_action_id: 21257015 - size: 2 + size: 255 } tables { preamble { - id: 33554504 - name: "ingress.mirroring_clone.mirror_port_to_pre_session_table" - alias: "mirror_port_to_pre_session_table" - annotations: "@p4runtime_role(\"packet_replication_engine_manager\")" + id: 33554698 + name: "ingress.acl_ingress.acl_ingress_security_table" + alias: "acl_ingress_security_table" + annotations: "@sai_acl(INGRESS)" + annotations: "@sai_acl_priority(20)" + annotations: "@p4runtime_role(\"sdn_controller\")" + annotations: "@entry_restriction(\"\n // Forbid using ether_type for IP packets (by convention, use is_ip* instead).\n ether_type != 0x0800 && ether_type != 0x86dd;\n\n // Only allow IP field matches for IP packets.\n dst_ip::mask != 0 -> is_ipv4 == 1;\n src_ip::mask != 0 -> is_ipv4 == 1;\n src_ipv6::mask != 0 -> is_ipv6 == 1;\n\n // TODO: This comment is required for the preprocessor to not\n // spit out nonsense.\n\n\n\n\n\n\n\n // Forbid illegal combinations of IP_TYPE fields.\n is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0);\n is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0);\n is_ipv6::mask != 0 -> (is_ip::mask == 0 && is_ipv4::mask == 0);\n // Forbid unsupported combinations of IP_TYPE fields.\n is_ipv4::mask != 0 -> (is_ipv4 == 1);\n is_ipv6::mask != 0 -> (is_ipv6 == 1);\n \")" } match_fields { id: 1 - name: "mirror_port" - bitwidth: 9 + name: "is_ip" + annotations: "@sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP)" + bitwidth: 1 + match_type: OPTIONAL + } + match_fields { + id: 2 + name: "is_ipv4" + annotations: "@sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY)" + bitwidth: 1 + match_type: OPTIONAL + } + match_fields { + id: 3 + name: "is_ipv6" + annotations: "@sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY)" + bitwidth: 1 + match_type: OPTIONAL + } + match_fields { + id: 4 + name: "ether_type" + annotations: "@sai_field(SAI_ACL_TABLE_ATTR_FIELD_ETHER_TYPE)" + bitwidth: 16 + match_type: TERNARY + } + match_fields { + id: 5 + name: "src_ip" + annotations: "@sai_field(SAI_ACL_TABLE_ATTR_FIELD_SRC_IP)" + annotations: "@format(IPV4_ADDRESS)" + bitwidth: 32 + match_type: TERNARY + } + match_fields { + id: 6 + name: "dst_ip" + annotations: "@sai_field(SAI_ACL_TABLE_ATTR_FIELD_DST_IP)" + annotations: "@format(IPV4_ADDRESS)" + bitwidth: 32 + match_type: TERNARY + } + match_fields { + id: 7 + name: "src_ipv6" + annotations: "@composite_field(@ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_SRC_IPV6_WORD3 ) , @ sai_field ( SAI_ACL_TABLE_ATTR_FIELD_SRC_IPV6_WORD2 ))" + annotations: "@format(IPV6_ADDRESS)" + bitwidth: 64 + match_type: TERNARY + } + action_refs { + id: 16777475 + annotations: "@proto_id(1)" + } + action_refs { + id: 16777481 + annotations: "@proto_id(2)" + } + action_refs { + id: 16777487 + annotations: "@proto_id(3)" + } + action_refs { + id: 21257015 + annotations: "@defaultonly" + scope: DEFAULT_ONLY + } + const_default_action_id: 21257015 + direct_resource_ids: 318767370 + size: 255 +} +tables { + preamble { + id: 33554496 + name: "ingress.routing_resolution.neighbor_table" + alias: "neighbor_table" + annotations: "@p4runtime_role(\"sdn_controller\")" + } + match_fields { + id: 1 + name: "router_interface_id" + annotations: "@refers_to(router_interface_table , router_interface_id)" + bitwidth: 10 match_type: EXACT type_name { - name: "port_id_t" + name: "router_interface_id_t" } } + match_fields { + id: 2 + name: "neighbor_id" + annotations: "@format(IPV6_ADDRESS)" + bitwidth: 128 + match_type: EXACT + } action_refs { - id: 16777225 + id: 16777217 annotations: "@proto_id(1)" } action_refs { @@ -601,85 +760,738 @@ tables { const_default_action_id: 21257015 size: 1024 } -actions { +tables { preamble { + id: 33554497 + name: "ingress.routing_resolution.router_interface_table" + alias: "router_interface_table" + annotations: "@p4runtime_role(\"sdn_controller\")" + } + match_fields { + id: 1 + name: "router_interface_id" + bitwidth: 10 + match_type: EXACT + type_name { + name: "router_interface_id_t" + } + } + action_refs { + id: 16777218 + annotations: "@proto_id(1)" + } + action_refs { + id: 16777243 + annotations: "@proto_id(2)" + } + action_refs { id: 21257015 - name: "NoAction" - alias: "NoAction" - annotations: "@noWarn(\"unused\")" + annotations: "@defaultonly" + scope: DEFAULT_ONLY } + const_default_action_id: 21257015 + size: 256 } -actions { +tables { preamble { - id: 16777481 - name: "acl_drop" - alias: "acl_drop" - annotations: "@sai_action(SAI_PACKET_ACTION_DROP)" + id: 33554498 + name: "ingress.routing_resolution.nexthop_table" + alias: "nexthop_table" + annotations: "@p4runtime_role(\"sdn_controller\")" + } + match_fields { + id: 1 + name: "nexthop_id" + bitwidth: 10 + match_type: EXACT + type_name { + name: "nexthop_id_t" + } + } + action_refs { + id: 16777219 + annotations: "@proto_id(1)" + } + action_refs { + id: 16777234 + annotations: "@proto_id(2)" + } + action_refs { + id: 16777236 + annotations: "@proto_id(3)" + } + action_refs { + id: 16777239 + annotations: "@proto_id(4)" + } + action_refs { + id: 21257015 + annotations: "@defaultonly" + scope: DEFAULT_ONLY } + const_default_action_id: 21257015 + size: 1024 } -actions { +tables { preamble { - id: 16777472 - name: "ingress.acl_pre_ingress.set_vrf" - alias: "set_vrf" - annotations: "@sai_action(SAI_PACKET_ACTION_FORWARD)" + id: 33554512 + name: "ingress.routing_resolution.tunnel_table" + alias: "tunnel_table" + annotations: "@p4runtime_role(\"sdn_controller\")" } - params { + match_fields { id: 1 - name: "vrf_id" - annotations: "@sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_SET_VRF)" - annotations: "@refers_to(vrf_table , vrf_id)" + name: "tunnel_id" bitwidth: 10 + match_type: EXACT type_name { - name: "vrf_id_t" + name: "tunnel_id_t" } } -} -actions { - preamble { - id: 16777224 - name: "ingress.l3_admit.admit_to_l3" - alias: "admit_to_l3" + action_refs { + id: 16777235 + annotations: "@proto_id(1)" + } + action_refs { + id: 21257015 + annotations: "@defaultonly" + scope: DEFAULT_ONLY } + const_default_action_id: 21257015 + size: 2048 } -actions { +tables { preamble { - id: 16777217 - name: "ingress.routing.set_dst_mac" - alias: "set_dst_mac" + id: 33554499 + name: "ingress.routing_resolution.wcmp_group_table" + alias: "wcmp_group_table" + annotations: "@p4runtime_role(\"sdn_controller\")" + annotations: "@oneshot" + } + match_fields { + id: 1 + name: "wcmp_group_id" + bitwidth: 12 + match_type: EXACT + type_name { + name: "wcmp_group_id_t" + } + } + action_refs { + id: 16777221 + annotations: "@proto_id(1)" + } + action_refs { + id: 21257015 + annotations: "@defaultonly" + scope: DEFAULT_ONLY + } + const_default_action_id: 21257015 + implementation_id: 299650760 + size: 3968 +} +tables { + preamble { + id: 33554502 + name: "ingress.mirror_session_lookup.mirror_session_table" + alias: "mirror_session_table" + annotations: "@p4runtime_role(\"sdn_controller\")" + } + match_fields { + id: 1 + name: "mirror_session_id" + bitwidth: 10 + match_type: EXACT + type_name { + name: "mirror_session_id_t" + } + } + action_refs { + id: 16777223 + annotations: "@proto_id(1)" + } + action_refs { + id: 16777245 + annotations: "@proto_id(2)" + } + action_refs { + id: 21257015 + annotations: "@defaultonly" + scope: DEFAULT_ONLY + } + const_default_action_id: 21257015 + size: 4 +} +tables { + preamble { + id: 33554513 + name: "ingress.ingress_cloning.ingress_clone_table" + alias: "ingress_clone_table" + annotations: "@unsupported" + annotations: "@p4runtime_role(\"packet_replication_engine_manager\")" + annotations: "@entry_restriction(\"\n // mirror_egress_port is present iff marked_to_mirror is true.\n // Exact match indicating presence of mirror_egress_port.\n marked_to_mirror == 1 -> mirror_egress_port::mask == -1;\n // Wildcard match indicating abscence of mirror_egress_port.\n marked_to_mirror == 0 -> mirror_egress_port::mask == 0;\n \")" + } + match_fields { + id: 1 + name: "marked_to_copy" + bitwidth: 1 + match_type: EXACT + } + match_fields { + id: 2 + name: "marked_to_mirror" + bitwidth: 1 + match_type: EXACT + } + match_fields { + id: 3 + name: "mirror_egress_port" + bitwidth: 9 + match_type: OPTIONAL + type_name { + name: "port_id_t" + } + } + action_refs { + id: 16777244 + annotations: "@proto_id(1)" + } + action_refs { + id: 21257015 + annotations: "@defaultonly" + scope: DEFAULT_ONLY + } + size: 1024 +} +tables { + preamble { + id: 33554508 + name: "egress.packet_rewrites.multicast_rewrites.multicast_router_interface_table" + alias: "multicast_router_interface_table" + annotations: "@p4runtime_role(\"sdn_controller\")" + } + match_fields { + id: 1 + name: "multicast_replica_port" + annotations: "@referenced_by(builtin : : multicast_group_table , replica . port)" + bitwidth: 9 + match_type: EXACT + type_name { + name: "port_id_t" + } + } + match_fields { + id: 2 + name: "multicast_replica_instance" + annotations: "@referenced_by(builtin : : multicast_group_table , replica . instance)" + bitwidth: 16 + match_type: EXACT + } + action_refs { + id: 16777241 + annotations: "@proto_id(1)" + } + action_refs { + id: 21257015 + annotations: "@defaultonly" + scope: DEFAULT_ONLY + } + size: 110 +} +tables { + preamble { + id: 33554692 + name: "egress.acl_egress.acl_egress_table" + alias: "acl_egress_table" + annotations: "@p4runtime_role(\"sdn_controller\")" + annotations: "@sai_acl(EGRESS)" + annotations: "@entry_restriction(\"\n\n\n\n\n\n // Only allow IP field matches for IP packets.\n ip_protocol::mask != 0 -> (is_ip == 1 || is_ipv4 == 1 || is_ipv6 == 1);\n\n\n\n\n\n\n\n // Forbid illegal combinations of IP_TYPE fields.\n is_ip::mask != 0 -> (is_ipv4::mask == 0 && is_ipv6::mask == 0);\n is_ipv4::mask != 0 -> (is_ip::mask == 0 && is_ipv6::mask == 0);\n is_ipv6::mask != 0 -> (is_ip::mask == 0 && is_ipv4::mask == 0);\n // Forbid unsupported combinations of IP_TYPE fields.\n is_ipv4::mask != 0 -> (is_ipv4 == 1);\n is_ipv6::mask != 0 -> (is_ipv6 == 1);\n \")" + } + match_fields { + id: 2 + name: "ip_protocol" + annotations: "@sai_field(SAI_ACL_TABLE_ATTR_FIELD_IP_PROTOCOL)" + bitwidth: 8 + match_type: TERNARY + } + match_fields { + id: 4 + name: "out_port" + annotations: "@sai_field(SAI_ACL_TABLE_ATTR_FIELD_OUT_PORT)" + bitwidth: 9 + match_type: OPTIONAL + type_name { + name: "port_id_t" + } + } + match_fields { + id: 5 + name: "is_ip" + annotations: "@sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IP)" + bitwidth: 1 + match_type: OPTIONAL + } + match_fields { + id: 6 + name: "is_ipv4" + annotations: "@sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV4ANY)" + bitwidth: 1 + match_type: OPTIONAL + } + match_fields { + id: 7 + name: "is_ipv6" + annotations: "@sai_field(SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE / IPV6ANY)" + bitwidth: 1 + match_type: OPTIONAL + } + match_fields { + id: 10 + name: "src_mac" + annotations: "@sai_field(SAI_ACL_TABLE_ATTR_FIELD_SRC_MAC)" + annotations: "@format(MAC_ADDRESS)" + bitwidth: 48 + match_type: TERNARY + } + action_refs { + id: 16777481 + annotations: "@proto_id(1)" + } + action_refs { + id: 21257015 + annotations: "@defaultonly" + scope: DEFAULT_ONLY + } + const_default_action_id: 21257015 + direct_resource_ids: 318767364 + size: 127 +} +actions { + preamble { + id: 21257015 + name: "NoAction" + alias: "NoAction" + annotations: "@noWarn(\"unused\")" + } +} +actions { + preamble { + id: 16777221 + name: "set_nexthop_id" + alias: "set_nexthop_id" + } + params { + id: 1 + name: "nexthop_id" + annotations: "@refers_to(nexthop_table , nexthop_id)" + bitwidth: 10 + type_name { + name: "nexthop_id_t" + } + } +} +actions { + preamble { + id: 16777481 + name: "acl_drop" + alias: "acl_drop" + annotations: "@sai_action(SAI_PACKET_ACTION_DROP)" + } +} +actions { + preamble { + id: 16777238 + name: "ingress.tunnel_termination_lookup.mark_for_tunnel_decap_and_set_vrf" + alias: "mark_for_tunnel_decap_and_set_vrf" + } + params { + id: 1 + name: "vrf_id" + annotations: "@refers_to(vrf_table , vrf_id)" + bitwidth: 10 + type_name { + name: "vrf_id_t" + } + } +} +actions { + preamble { + id: 16777242 + name: "ingress.vlan_untag.disable_vlan_checks" + alias: "disable_vlan_checks" + } +} +actions { + preamble { + id: 16777472 + name: "ingress.acl_pre_ingress.set_vrf" + alias: "set_vrf" + annotations: "@sai_action(SAI_PACKET_ACTION_FORWARD)" + } + params { + id: 1 + name: "vrf_id" + annotations: "@sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_SET_VRF)" + annotations: "@refers_to(vrf_table , vrf_id)" + bitwidth: 10 + type_name { + name: "vrf_id_t" + } + } +} +actions { + preamble { + id: 16777224 + name: "ingress.l3_admit.admit_to_l3" + alias: "admit_to_l3" + } +} +actions { + preamble { + id: 17825802 + name: "ingress.hashing.select_ecmp_hash_algorithm" + alias: "select_ecmp_hash_algorithm" + annotations: "@sai_hash_seed(0)" + } +} +actions { + preamble { + id: 16777227 + name: "ingress.hashing.compute_ecmp_hash_ipv4" + alias: "compute_ecmp_hash_ipv4" + annotations: "@sai_ecmp_hash(SAI_SWITCH_ATTR_ECMP_HASH_IPV4)" + annotations: "@sai_native_hash_field(SAI_NATIVE_HASH_FIELD_SRC_IPV4)" + annotations: "@sai_native_hash_field(SAI_NATIVE_HASH_FIELD_DST_IPV4)" + annotations: "@sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_SRC_PORT)" + annotations: "@sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_DST_PORT)" + } +} +actions { + preamble { + id: 16777228 + name: "ingress.hashing.compute_ecmp_hash_ipv6" + alias: "compute_ecmp_hash_ipv6" + annotations: "@sai_ecmp_hash(SAI_SWITCH_ATTR_ECMP_HASH_IPV6)" + annotations: "@sai_native_hash_field(SAI_NATIVE_HASH_FIELD_SRC_IPV6)" + annotations: "@sai_native_hash_field(SAI_NATIVE_HASH_FIELD_DST_IPV6)" + annotations: "@sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_SRC_PORT)" + annotations: "@sai_native_hash_field(SAI_NATIVE_HASH_FIELD_L4_DST_PORT)" + annotations: "@sai_native_hash_field(SAI_NATIVE_HASH_FIELD_IPV6_FLOW_LABEL)" + } +} +actions { + preamble { + id: 24742814 + name: "ingress.routing_lookup.no_action" + alias: "no_action" + } +} +actions { + preamble { + id: 16777222 + name: "ingress.routing_lookup.drop" + alias: "drop" + } +} +actions { + preamble { + id: 16777220 + name: "ingress.routing_lookup.set_wcmp_group_id" + alias: "set_wcmp_group_id" + } + params { + id: 1 + name: "wcmp_group_id" + annotations: "@refers_to(wcmp_group_table , wcmp_group_id)" + bitwidth: 12 + type_name { + name: "wcmp_group_id_t" + } + } +} +actions { + preamble { + id: 16777233 + name: "ingress.routing_lookup.set_wcmp_group_id_and_metadata" + alias: "set_wcmp_group_id_and_metadata" + } + params { + id: 1 + name: "wcmp_group_id" + annotations: "@refers_to(wcmp_group_table , wcmp_group_id)" + bitwidth: 12 + type_name { + name: "wcmp_group_id_t" + } + } + params { + id: 2 + name: "route_metadata" + bitwidth: 6 + } +} +actions { + preamble { + id: 16777237 + name: "ingress.routing_lookup.set_metadata_and_drop" + alias: "set_metadata_and_drop" + } + params { + id: 1 + name: "route_metadata" + bitwidth: 6 + } +} +actions { + preamble { + id: 16777232 + name: "ingress.routing_lookup.set_nexthop_id_and_metadata" + alias: "set_nexthop_id_and_metadata" + } + params { + id: 1 + name: "nexthop_id" + annotations: "@refers_to(nexthop_table , nexthop_id)" + bitwidth: 10 + type_name { + name: "nexthop_id_t" + } + } + params { + id: 2 + name: "route_metadata" + bitwidth: 6 + } +} +actions { + preamble { + id: 16777240 + name: "ingress.routing_lookup.set_multicast_group_id" + alias: "set_multicast_group_id" + annotations: "@action_restriction(\"\n // Disallow 0 since it encodes \'no multicast\' in V1Model.\n multicast_group_id != 0;\n \")" + } + params { + id: 1 + name: "multicast_group_id" + annotations: "@refers_to(builtin : : multicast_group_table , multicast_group_id)" + bitwidth: 16 + } +} +actions { + preamble { + id: 16777473 + name: "ingress.acl_ingress.acl_copy" + alias: "acl_copy" + annotations: "@sai_action(SAI_PACKET_ACTION_COPY , SAI_PACKET_COLOR_GREEN)" + annotations: "@sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_RED)" + } + params { + id: 1 + name: "qos_queue" + annotations: "@sai_action_param(QOS_QUEUE)" + bitwidth: 8 + type_name { + name: "qos_queue_t" + } + } +} +actions { + preamble { + id: 16777474 + name: "ingress.acl_ingress.acl_trap" + alias: "acl_trap" + annotations: "@sai_action(SAI_PACKET_ACTION_TRAP , SAI_PACKET_COLOR_GREEN)" + annotations: "@sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED)" + } + params { + id: 1 + name: "qos_queue" + annotations: "@sai_action_param(QOS_QUEUE)" + bitwidth: 8 + type_name { + name: "qos_queue_t" + } + } +} +actions { + preamble { + id: 16777475 + name: "ingress.acl_ingress.acl_forward" + alias: "acl_forward" + annotations: "@sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_GREEN)" + annotations: "@sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED)" + } +} +actions { + preamble { + id: 16777476 + name: "ingress.acl_ingress.acl_mirror" + alias: "acl_mirror" + annotations: "@sai_action(SAI_PACKET_ACTION_FORWARD)" + } + params { + id: 1 + name: "mirror_session_id" + annotations: "@refers_to(mirror_session_table , mirror_session_id)" + annotations: "@sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_MIRROR_INGRESS)" + bitwidth: 10 + type_name { + name: "mirror_session_id_t" + } + } +} +actions { + preamble { + id: 16777487 + name: "ingress.acl_ingress.acl_deny" + alias: "acl_deny" + annotations: "@sai_action(SAI_PACKET_ACTION_DENY)" + } +} +actions { + preamble { + id: 16777490 + name: "ingress.acl_ingress.redirect_to_nexthop" + alias: "redirect_to_nexthop" + } + params { + id: 1 + name: "nexthop_id" + annotations: "@sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_REDIRECT)" + annotations: "@sai_action_param_object_type(SAI_OBJECT_TYPE_NEXT_HOP)" + annotations: "@refers_to(nexthop_table , nexthop_id)" + bitwidth: 10 + type_name { + name: "nexthop_id_t" + } + } +} +actions { + preamble { + id: 16777491 + name: "ingress.acl_ingress.redirect_to_ipmc_group" + alias: "redirect_to_ipmc_group" + annotations: "@action_restriction(\"\n // Disallow 0 since it encodes \'no multicast\' in V1Model.\n multicast_group_id != 0;\n \")" + } + params { + id: 1 + name: "multicast_group_id" + annotations: "@sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_REDIRECT)" + annotations: "@sai_action_param_object_type(SAI_OBJECT_TYPE_IPMC_GROUP)" + annotations: "@refers_to(builtin : : multicast_group_table , multicast_group_id)" + bitwidth: 16 + } +} +actions { + preamble { + id: 16777217 + name: "ingress.routing_resolution.set_dst_mac" + alias: "set_dst_mac" + } + params { + id: 1 + name: "dst_mac" + annotations: "@format(MAC_ADDRESS)" + bitwidth: 48 + } +} +actions { + preamble { + id: 16777243 + name: "ingress.routing_resolution.set_port_and_src_mac_and_vlan_id" + alias: "set_port_and_src_mac_and_vlan_id" + annotations: "@unsupported" + annotations: "@action_restriction(\"\n // Disallow reserved VLAN IDs with implementation-defined semantics.\n vlan_id != 0 && vlan_id != 4095\")" + } + params { + id: 1 + name: "port" + bitwidth: 9 + type_name { + name: "port_id_t" + } + } + params { + id: 2 + name: "src_mac" + annotations: "@format(MAC_ADDRESS)" + bitwidth: 48 + } + params { + id: 3 + name: "vlan_id" + bitwidth: 12 + } +} +actions { + preamble { + id: 16777218 + name: "ingress.routing_resolution.set_port_and_src_mac" + alias: "set_port_and_src_mac" + } + params { + id: 1 + name: "port" + bitwidth: 9 + type_name { + name: "port_id_t" + } + } + params { + id: 2 + name: "src_mac" + annotations: "@format(MAC_ADDRESS)" + bitwidth: 48 + } +} +actions { + preamble { + id: 16777239 + name: "ingress.routing_resolution.set_ip_nexthop_and_disable_rewrites" + alias: "set_ip_nexthop_and_disable_rewrites" + } + params { + id: 1 + name: "router_interface_id" + annotations: "@refers_to(router_interface_table , router_interface_id)" + annotations: "@refers_to(neighbor_table , router_interface_id)" + bitwidth: 10 + type_name { + name: "router_interface_id_t" + } + } + params { + id: 2 + name: "neighbor_id" + annotations: "@format(IPV6_ADDRESS)" + annotations: "@refers_to(neighbor_table , neighbor_id)" + bitwidth: 128 + } + params { + id: 3 + name: "disable_decrement_ttl" + bitwidth: 1 } params { - id: 1 - name: "dst_mac" - annotations: "@format(MAC_ADDRESS)" - bitwidth: 48 - } -} -actions { - preamble { - id: 16777218 - name: "ingress.routing.set_port_and_src_mac" - alias: "set_port_and_src_mac" + id: 4 + name: "disable_src_mac_rewrite" + bitwidth: 1 } params { - id: 1 - name: "port" - bitwidth: 9 - type_name { - name: "port_id_t" - } + id: 5 + name: "disable_dst_mac_rewrite" + bitwidth: 1 } params { - id: 2 - name: "src_mac" - annotations: "@format(MAC_ADDRESS)" - bitwidth: 48 + id: 6 + name: "disable_vlan_rewrite" + bitwidth: 1 } } actions { preamble { id: 16777236 - name: "ingress.routing.set_ip_nexthop" + name: "ingress.routing_resolution.set_ip_nexthop" alias: "set_ip_nexthop" } params { @@ -703,7 +1515,7 @@ actions { actions { preamble { id: 16777219 - name: "ingress.routing.set_nexthop" + name: "ingress.routing_resolution.set_nexthop" alias: "set_nexthop" annotations: "@deprecated(\"Use set_ip_nexthop instead.\")" } @@ -727,255 +1539,197 @@ actions { } actions { preamble { - id: 16777221 - name: "ingress.routing.set_nexthop_id" - alias: "set_nexthop_id" + id: 16777234 + name: "ingress.routing_resolution.set_p2p_tunnel_encap_nexthop" + alias: "set_p2p_tunnel_encap_nexthop" } params { id: 1 - name: "nexthop_id" - annotations: "@refers_to(nexthop_table , nexthop_id)" + name: "tunnel_id" + annotations: "@refers_to(tunnel_table , tunnel_id)" bitwidth: 10 type_name { - name: "nexthop_id_t" + name: "tunnel_id_t" } } } actions { preamble { - id: 16777232 - name: "ingress.routing.set_nexthop_id_and_metadata" - alias: "set_nexthop_id_and_metadata" + id: 16777235 + name: "ingress.routing_resolution.mark_for_p2p_tunnel_encap" + alias: "mark_for_p2p_tunnel_encap" } params { id: 1 - name: "nexthop_id" - annotations: "@refers_to(nexthop_table , nexthop_id)" - bitwidth: 10 - type_name { - name: "nexthop_id_t" - } + name: "encap_src_ip" + annotations: "@format(IPV6_ADDRESS)" + bitwidth: 128 } params { id: 2 - name: "route_metadata" - bitwidth: 6 - } -} -actions { - preamble { - id: 24742814 - name: "ingress.routing.no_action" - alias: "no_action" - } -} -actions { - preamble { - id: 16777222 - name: "ingress.routing.drop" - alias: "drop" - } -} -actions { - preamble { - id: 16777220 - name: "ingress.routing.set_wcmp_group_id" - alias: "set_wcmp_group_id" + name: "encap_dst_ip" + annotations: "@format(IPV6_ADDRESS)" + annotations: "@refers_to(neighbor_table , neighbor_id)" + bitwidth: 128 } params { - id: 1 - name: "wcmp_group_id" - annotations: "@refers_to(wcmp_group_table , wcmp_group_id)" - bitwidth: 12 + id: 3 + name: "router_interface_id" + annotations: "@refers_to(neighbor_table , router_interface_id)" + annotations: "@refers_to(router_interface_table , router_interface_id)" + bitwidth: 10 type_name { - name: "wcmp_group_id_t" + name: "router_interface_id_t" } } } actions { preamble { - id: 16777233 - name: "ingress.routing.set_wcmp_group_id_and_metadata" - alias: "set_wcmp_group_id_and_metadata" + id: 16777223 + name: "ingress.mirror_session_lookup.mirror_as_ipv4_erspan" + alias: "mirror_as_ipv4_erspan" } params { id: 1 - name: "wcmp_group_id" - annotations: "@refers_to(wcmp_group_table , wcmp_group_id)" - bitwidth: 12 + name: "port" + bitwidth: 9 type_name { - name: "wcmp_group_id_t" + name: "port_id_t" } } params { id: 2 - name: "route_metadata" - bitwidth: 6 - } -} -actions { - preamble { - id: 16777231 - name: "ingress.routing.trap" - alias: "trap" + name: "src_ip" + annotations: "@format(IPV4_ADDRESS)" + bitwidth: 32 } -} -actions { - preamble { - id: 16777473 - name: "ingress.acl_ingress.acl_copy" - alias: "acl_copy" - annotations: "@sai_action(SAI_PACKET_ACTION_COPY , SAI_PACKET_COLOR_GREEN)" - annotations: "@sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_YELLOW)" - annotations: "@sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_RED)" + params { + id: 3 + name: "dst_ip" + annotations: "@format(IPV4_ADDRESS)" + bitwidth: 32 } params { - id: 1 - name: "qos_queue" - annotations: "@sai_action_param(QOS_QUEUE)" - bitwidth: 8 - type_name { - name: "qos_queue_t" - } + id: 4 + name: "src_mac" + annotations: "@format(MAC_ADDRESS)" + bitwidth: 48 } -} -actions { - preamble { - id: 16777474 - name: "ingress.acl_ingress.acl_trap" - alias: "acl_trap" - annotations: "@sai_action(SAI_PACKET_ACTION_TRAP , SAI_PACKET_COLOR_GREEN)" - annotations: "@sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_YELLOW)" - annotations: "@sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED)" + params { + id: 5 + name: "dst_mac" + annotations: "@format(MAC_ADDRESS)" + bitwidth: 48 } params { - id: 1 - name: "qos_queue" - annotations: "@sai_action_param(QOS_QUEUE)" + id: 6 + name: "ttl" bitwidth: 8 - type_name { - name: "qos_queue_t" - } - } -} -actions { - preamble { - id: 16777625 - name: "ingress.acl_ingress.acl_experimental_trap" - alias: "acl_experimental_trap" - annotations: "@sai_action(SAI_PACKET_ACTION_TRAP , SAI_PACKET_COLOR_GREEN)" - annotations: "@sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_YELLOW)" - annotations: "@sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED)" } params { - id: 1 - name: "qos_queue" - annotations: "@sai_action_param(QOS_QUEUE)" + id: 7 + name: "tos" bitwidth: 8 - type_name { - name: "qos_queue_t" - } - } -} -actions { - preamble { - id: 16777475 - name: "ingress.acl_ingress.acl_forward" - alias: "acl_forward" - annotations: "@sai_action(SAI_PACKET_ACTION_FORWARD , SAI_PACKET_COLOR_GREEN)" - annotations: "@sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_YELLOW)" - annotations: "@sai_action(SAI_PACKET_ACTION_DROP , SAI_PACKET_COLOR_RED)" } } actions { preamble { - id: 16777476 - name: "ingress.acl_ingress.acl_mirror" - alias: "acl_mirror" - annotations: "@sai_action(SAI_PACKET_ACTION_FORWARD)" + id: 16777245 + name: "ingress.mirror_session_lookup.mirror_with_vlan_tag_and_ipfix_encapsulation" + alias: "mirror_with_vlan_tag_and_ipfix_encapsulation" + annotations: "@unsupported" } params { id: 1 - name: "mirror_session_id" - annotations: "@refers_to(mirror_session_table , mirror_session_id)" - annotations: "@sai_action_param(SAI_ACL_ENTRY_ATTR_ACTION_MIRROR_INGRESS)" - bitwidth: 10 + name: "monitor_port" + bitwidth: 9 type_name { - name: "mirror_session_id_t" + name: "port_id_t" } } -} -actions { - preamble { - id: 16777223 - name: "ingress.mirroring_clone.mirror_as_ipv4_erspan" - alias: "mirror_as_ipv4_erspan" - } params { - id: 1 - name: "port" + id: 2 + name: "monitor_failover_port" bitwidth: 9 type_name { name: "port_id_t" } } - params { - id: 2 - name: "src_ip" - annotations: "@format(IPV4_ADDRESS)" - bitwidth: 32 - } params { id: 3 - name: "dst_ip" - annotations: "@format(IPV4_ADDRESS)" - bitwidth: 32 - } - params { - id: 4 - name: "src_mac" + name: "mirror_encap_src_mac" annotations: "@format(MAC_ADDRESS)" bitwidth: 48 } params { - id: 5 - name: "dst_mac" + id: 4 + name: "mirror_encap_dst_mac" annotations: "@format(MAC_ADDRESS)" bitwidth: 48 } params { id: 6 - name: "ttl" - bitwidth: 8 + name: "mirror_encap_vlan_id" + bitwidth: 12 } params { id: 7 - name: "tos" - bitwidth: 8 + name: "mirror_encap_dst_ip" + annotations: "@format(IPV6_ADDRESS)" + bitwidth: 128 + } + params { + id: 8 + name: "mirror_encap_src_ip" + annotations: "@format(IPV6_ADDRESS)" + bitwidth: 128 + } + params { + id: 9 + name: "mirror_encap_udp_src_port" + bitwidth: 16 + } + params { + id: 10 + name: "mirror_encap_udp_dst_port" + bitwidth: 16 } } actions { preamble { - id: 16777225 - name: "ingress.mirroring_clone.set_pre_session" - alias: "set_pre_session" + id: 16777244 + name: "ingress.ingress_cloning.ingress_clone" + alias: "ingress_clone" } params { id: 1 - name: "id" + name: "clone_session" bitwidth: 32 } } +actions { + preamble { + id: 16777241 + name: "egress.packet_rewrites.multicast_rewrites.set_multicast_src_mac" + alias: "set_multicast_src_mac" + } + params { + id: 1 + name: "src_mac" + annotations: "@format(MAC_ADDRESS)" + bitwidth: 48 + } +} action_profiles { preamble { id: 299650760 - name: "ingress.routing.wcmp_group_selector" + name: "ingress.routing_resolution.wcmp_group_selector" alias: "wcmp_group_selector" } table_ids: 33554499 with_selector: true - size: 65536 - max_group_size: 256 + size: 49152 + max_group_size: 512 } direct_counters { preamble { @@ -999,11 +1753,34 @@ direct_counters { } direct_table_id: 33554688 } +direct_counters { + preamble { + id: 318767370 + name: "ingress.acl_ingress.acl_ingress_security_counter" + alias: "acl_ingress_security_counter" + } + spec { + unit: BOTH + } + direct_table_id: 33554698 +} +direct_counters { + preamble { + id: 318767364 + name: "egress.acl_egress.acl_egress_counter" + alias: "acl_egress_counter" + } + spec { + unit: BOTH + } + direct_table_id: 33554692 +} direct_meters { preamble { id: 352321792 name: "ingress.acl_ingress.acl_ingress_meter" alias: "acl_ingress_meter" + annotations: "@mode(single_rate_two_color)" } spec { unit: BYTES @@ -1057,7 +1834,8 @@ controller_packet_metadata { metadata { id: 3 name: "unused_pad" - bitwidth: 7 + annotations: "@padding" + bitwidth: 6 } } type_info { @@ -1121,6 +1899,18 @@ type_info { } } } + new_types { + key: "tunnel_id_t" + value { + original_type { + bitstring { + bit { + bitwidth: 10 + } + } + } + } + } new_types { key: "vrf_id_t" value { @@ -1131,6 +1921,7 @@ type_info { } } } + annotations: "@p4runtime_translation_mappings({ { \"\" , 0 } , })" } } new_types { diff --git a/testdata/p4_16_samples_outputs/pins/pins_wbb-first.p4 b/testdata/p4_16_samples_outputs/pins/pins_wbb-first.p4 index da5d14aecd..95cc8da4bb 100644 --- a/testdata/p4_16_samples_outputs/pins/pins_wbb-first.p4 +++ b/testdata/p4_16_samples_outputs/pins/pins_wbb-first.p4 @@ -5,10 +5,21 @@ typedef bit<48> ethernet_addr_t; typedef bit<32> ipv4_addr_t; typedef bit<128> ipv6_addr_t; +typedef bit<12> vlan_id_t; +typedef bit<16> ether_type_t; +const vlan_id_t INTERNAL_VLAN_ID = 12w0xfff; +const vlan_id_t NO_VLAN_ID = 12w0x0; header ethernet_t { ethernet_addr_t dst_addr; ethernet_addr_t src_addr; - bit<16> ether_type; + ether_type_t ether_type; +} + +header vlan_t { + bit<3> priority_code_point; + bit<1> drop_eligible_indicator; + vlan_id_t vlan_id; + ether_type_t ether_type; } header ipv4_t { @@ -65,6 +76,7 @@ header icmp_t { bit<8> type; bit<8> code; bit<16> checksum; + bit<32> rest_of_header; } header arp_t { @@ -92,453 +104,150 @@ header gre_t { bit<16> protocol; } +header ipfix_t { + bit<16> version_number; + bit<16> length; + bit<32> export_time; + bit<32> sequence_number; + bit<32> observation_domain_id; +} + +header psamp_extended_t { + bit<16> template_id; + bit<16> length; + bit<64> observation_time; + bit<16> flowset; + bit<16> next_hop_index; + bit<16> epoch; + bit<16> ingress_port; + bit<16> egress_port; + bit<16> user_meta_field; + bit<8> dlb_id; + bit<8> variable_length; + bit<16> packet_sampled_length; +} + enum bit<8> PreservedFieldList { - CLONE_I2E = 8w1 + MIRROR_AND_PACKET_IN_COPY = 8w1, + RECIRCULATE = 8w2 } type bit<10> nexthop_id_t; type bit<10> tunnel_id_t; type bit<12> wcmp_group_id_t; -type bit<10> vrf_id_t; +@p4runtime_translation_mappings({ { "" , 0 } , }) type bit<10> vrf_id_t; const vrf_id_t kDefaultVrf = (vrf_id_t)10w0; type bit<10> router_interface_id_t; type bit<9> port_id_t; type bit<10> mirror_session_id_t; type bit<8> qos_queue_t; typedef bit<6> route_metadata_t; +typedef bit<8> acl_metadata_t; +typedef bit<16> multicast_group_id_t; +typedef bit<16> replica_instance_t; enum bit<2> MeterColor_t { GREEN = 2w0, YELLOW = 2w1, RED = 2w2 } +@controller_header("packet_in") header packet_in_header_t { + @id(1) + port_id_t ingress_port; + @id(2) + port_id_t target_egress_port; +} + +@controller_header("packet_out") header packet_out_header_t { + @id(1) + port_id_t egress_port; + @id(2) + bit<1> submit_to_ingress; + @id(3) @padding + bit<6> unused_pad; +} + struct headers_t { - ethernet_t erspan_ethernet; - ipv4_t erspan_ipv4; - gre_t erspan_gre; - ethernet_t ethernet; - ipv6_t tunnel_encap_ipv6; - gre_t tunnel_encap_gre; - ipv4_t ipv4; - ipv6_t ipv6; - icmp_t icmp; - tcp_t tcp; - udp_t udp; - arp_t arp; + packet_out_header_t packet_out_header; + ethernet_t mirror_encap_ethernet; + vlan_t mirror_encap_vlan; + ipv6_t mirror_encap_ipv6; + udp_t mirror_encap_udp; + ipfix_t ipfix; + psamp_extended_t psamp_extended; + ethernet_t ethernet; + vlan_t vlan; + ipv6_t tunnel_encap_ipv6; + gre_t tunnel_encap_gre; + ipv4_t ipv4; + ipv6_t ipv6; + ipv4_t inner_ipv4; + ipv6_t inner_ipv6; + icmp_t icmp; + tcp_t tcp; + udp_t udp; + arp_t arp; } struct packet_rewrites_t { ethernet_addr_t src_mac; ethernet_addr_t dst_mac; + vlan_id_t vlan_id; } struct local_metadata_t { + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + bool enable_vlan_checks; + vlan_id_t vlan_id; bool admit_to_l3; vrf_id_t vrf_id; + bool enable_decrement_ttl; + bool enable_src_mac_rewrite; + bool enable_dst_mac_rewrite; + bool enable_vlan_rewrite; packet_rewrites_t packet_rewrites; bit<16> l4_src_port; bit<16> l4_dst_port; - bit<16> wcmp_selector_input; + bit<8> wcmp_selector_input; + bool apply_tunnel_decap_at_end_of_pre_ingress; bool apply_tunnel_encap_at_egress; ipv6_addr_t tunnel_encap_src_ipv6; ipv6_addr_t tunnel_encap_dst_ipv6; - bool mirror_session_id_valid; - mirror_session_id_t mirror_session_id_value; - @field_list(PreservedFieldList.CLONE_I2E) - ipv4_addr_t mirroring_src_ip; - @field_list(PreservedFieldList.CLONE_I2E) - ipv4_addr_t mirroring_dst_ip; - @field_list(PreservedFieldList.CLONE_I2E) - ethernet_addr_t mirroring_src_mac; - @field_list(PreservedFieldList.CLONE_I2E) - ethernet_addr_t mirroring_dst_mac; - @field_list(PreservedFieldList.CLONE_I2E) - bit<8> mirroring_ttl; - @field_list(PreservedFieldList.CLONE_I2E) - bit<8> mirroring_tos; + bool marked_to_copy; + bool marked_to_mirror; + mirror_session_id_t mirror_session_id; + port_id_t mirror_egress_port; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + ethernet_addr_t mirror_encap_src_mac; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + ethernet_addr_t mirror_encap_dst_mac; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + vlan_id_t mirror_encap_vlan_id; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + ipv6_addr_t mirror_encap_src_ip; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + ipv6_addr_t mirror_encap_dst_ip; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + bit<16> mirror_encap_udp_src_port; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + bit<16> mirror_encap_udp_dst_port; + @field_list(PreservedFieldList.RECIRCULATE) + bit<9> loopback_port; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + bit<9> packet_in_ingress_port; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + bit<9> packet_in_target_egress_port; MeterColor_t color; port_id_t ingress_port; route_metadata_t route_metadata; -} - -@controller_header("packet_in") header packet_in_header_t { - @id(1) - port_id_t ingress_port; - @id(2) - port_id_t target_egress_port; -} - -@controller_header("packet_out") header packet_out_header_t { - @id(1) - port_id_t egress_port; - @id(2) - bit<1> submit_to_ingress; - @id(3) - bit<7> unused_pad; -} - -parser packet_parser(packet_in packet, out headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { - state start { - local_metadata.admit_to_l3 = false; - local_metadata.vrf_id = (vrf_id_t)10w0; - local_metadata.packet_rewrites.src_mac = 48w0; - local_metadata.packet_rewrites.dst_mac = 48w0; - local_metadata.l4_src_port = 16w0; - local_metadata.l4_dst_port = 16w0; - local_metadata.wcmp_selector_input = 16w0; - local_metadata.mirror_session_id_valid = false; - local_metadata.color = MeterColor_t.GREEN; - local_metadata.ingress_port = (port_id_t)standard_metadata.ingress_port; - local_metadata.route_metadata = 6w0; - transition parse_ethernet; - } - state parse_ethernet { - packet.extract(headers.ethernet); - transition select(headers.ethernet.ether_type) { - 16w0x800: parse_ipv4; - 16w0x86dd: parse_ipv6; - 16w0x806: parse_arp; - default: accept; - } - } - state parse_ipv4 { - packet.extract(headers.ipv4); - transition select(headers.ipv4.protocol) { - 8w0x1: parse_icmp; - 8w0x6: parse_tcp; - 8w0x11: parse_udp; - default: accept; - } - } - state parse_ipv6 { - packet.extract(headers.ipv6); - transition select(headers.ipv6.next_header) { - 8w0x3a: parse_icmp; - 8w0x6: parse_tcp; - 8w0x11: parse_udp; - default: accept; - } - } - state parse_tcp { - packet.extract(headers.tcp); - local_metadata.l4_src_port = headers.tcp.src_port; - local_metadata.l4_dst_port = headers.tcp.dst_port; - transition accept; - } - state parse_udp { - packet.extract(headers.udp); - local_metadata.l4_src_port = headers.udp.src_port; - local_metadata.l4_dst_port = headers.udp.dst_port; - transition accept; - } - state parse_icmp { - packet.extract(headers.icmp); - transition accept; - } - state parse_arp { - packet.extract(headers.arp); - transition accept; - } -} - -control packet_deparser(packet_out packet, in headers_t headers) { - apply { - packet.emit(headers.erspan_ethernet); - packet.emit(headers.erspan_ipv4); - packet.emit(headers.erspan_gre); - packet.emit(headers.ethernet); - packet.emit(headers.tunnel_encap_ipv6); - packet.emit(headers.tunnel_encap_gre); - packet.emit(headers.ipv4); - packet.emit(headers.ipv6); - packet.emit(headers.arp); - packet.emit(headers.icmp); - packet.emit(headers.tcp); - packet.emit(headers.udp); - } -} - -control routing(in headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { - bool wcmp_group_id_valid = false; - wcmp_group_id_t wcmp_group_id_value; - bool nexthop_id_valid = false; - nexthop_id_t nexthop_id_value; - bool router_interface_id_valid = false; - router_interface_id_t router_interface_id_value; - bool neighbor_id_valid = false; - ipv6_addr_t neighbor_id_value; - @id(0x01000001) action set_dst_mac(@id(1) @format(MAC_ADDRESS) ethernet_addr_t dst_mac) { - local_metadata.packet_rewrites.dst_mac = dst_mac; - } - @p4runtime_role("sdn_controller") @id(0x02000040) table neighbor_table { - key = { - router_interface_id_value: exact @id(1) @name("router_interface_id") @refers_to(router_interface_table , router_interface_id); - neighbor_id_value : exact @id(2) @format(IPV6_ADDRESS) @name("neighbor_id"); - } - actions = { - @proto_id(1) set_dst_mac(); - @defaultonly NoAction(); - } - const default_action = NoAction(); - size = 1024; - } - @id(0x01000002) action set_port_and_src_mac(@id(1) port_id_t port, @id(2) @format(MAC_ADDRESS) ethernet_addr_t src_mac) { - standard_metadata.egress_spec = (bit<9>)port; - local_metadata.packet_rewrites.src_mac = src_mac; - } - @p4runtime_role("sdn_controller") @id(0x02000041) table router_interface_table { - key = { - router_interface_id_value: exact @id(1) @name("router_interface_id"); - } - actions = { - @proto_id(1) set_port_and_src_mac(); - @defaultonly NoAction(); - } - const default_action = NoAction(); - size = 256; - } - @id(0x01000014) action set_ip_nexthop(@id(1) @refers_to(router_interface_table , router_interface_id) @refers_to(neighbor_table , router_interface_id) router_interface_id_t router_interface_id, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) ipv6_addr_t neighbor_id) { - router_interface_id_valid = true; - router_interface_id_value = router_interface_id; - neighbor_id_valid = true; - neighbor_id_value = neighbor_id; - } - @id(0x01000003) @deprecated("Use set_ip_nexthop instead.") action set_nexthop(@id(1) @refers_to(router_interface_table , router_interface_id) @refers_to(neighbor_table , router_interface_id) router_interface_id_t router_interface_id, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) ipv6_addr_t neighbor_id) { - set_ip_nexthop(router_interface_id, neighbor_id); - } - @p4runtime_role("sdn_controller") @id(0x02000042) table nexthop_table { - key = { - nexthop_id_value: exact @id(1) @name("nexthop_id"); - } - actions = { - @proto_id(1) set_nexthop(); - @proto_id(3) set_ip_nexthop(); - @defaultonly NoAction(); - } - const default_action = NoAction(); - size = 1024; - } - @id(0x01000005) action set_nexthop_id(@id(1) @refers_to(nexthop_table , nexthop_id) nexthop_id_t nexthop_id) { - nexthop_id_valid = true; - nexthop_id_value = nexthop_id; - } - @id(0x01000010) action set_nexthop_id_and_metadata(@id(1) @refers_to(nexthop_table , nexthop_id) nexthop_id_t nexthop_id, route_metadata_t route_metadata) { - nexthop_id_valid = true; - nexthop_id_value = nexthop_id; - local_metadata.route_metadata = route_metadata; - } - @max_group_size(256) action_selector(HashAlgorithm.identity, 32w65536, 32w16) wcmp_group_selector; - @p4runtime_role("sdn_controller") @id(0x02000043) @oneshot table wcmp_group_table { - key = { - wcmp_group_id_value : exact @id(1) @name("wcmp_group_id"); - local_metadata.wcmp_selector_input: selector @name("local_metadata.wcmp_selector_input"); - } - actions = { - @proto_id(1) set_nexthop_id(); - @defaultonly NoAction(); - } - const default_action = NoAction(); - @id(0x11DC4EC8) implementation = wcmp_group_selector; - size = 3968; - } - action no_action() { - } - @entry_restriction(" - // The VRF ID 0 (or '' in P4Runtime) encodes the default VRF, which cannot - // be read or written via this table, but is always present implicitly. - // TODO: This constraint should read `vrf_id != ''` (since - // constraints are a control plane (P4Runtime) concept), but - // p4-constraints does not currently support strings. - vrf_id != 0; - ") @p4runtime_role("sdn_controller") @id(0x0200004A) table vrf_table { - key = { - local_metadata.vrf_id: exact @id(1) @name("vrf_id"); - } - actions = { - @proto_id(1) no_action(); - } - const default_action = no_action(); - size = 64; - } - @id(0x01000006) action drop() { - mark_to_drop(standard_metadata); - } - @id(0x01000004) action set_wcmp_group_id(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) wcmp_group_id_t wcmp_group_id) { - wcmp_group_id_valid = true; - wcmp_group_id_value = wcmp_group_id; - } - @id(0x01000011) action set_wcmp_group_id_and_metadata(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) wcmp_group_id_t wcmp_group_id, route_metadata_t route_metadata) { - set_wcmp_group_id(wcmp_group_id); - local_metadata.route_metadata = route_metadata; - } - @id(0x0100000F) action trap() { - clone(CloneType.I2E, 32w1024); - mark_to_drop(standard_metadata); - } - @p4runtime_role("sdn_controller") @id(0x02000044) table ipv4_table { - key = { - local_metadata.vrf_id: exact @id(1) @name("vrf_id") @refers_to(vrf_table , vrf_id); - headers.ipv4.dst_addr: lpm @format(IPV4_ADDRESS) @id(2) @name("ipv4_dst"); - } - actions = { - @proto_id(1) drop(); - @proto_id(2) set_nexthop_id(); - @proto_id(3) set_wcmp_group_id(); - @proto_id(4) trap(); - @proto_id(5) set_nexthop_id_and_metadata(); - @proto_id(6) set_wcmp_group_id_and_metadata(); - } - const default_action = drop(); - size = 32768; - } - @p4runtime_role("sdn_controller") @id(0x02000045) table ipv6_table { - key = { - local_metadata.vrf_id: exact @id(1) @name("vrf_id") @refers_to(vrf_table , vrf_id); - headers.ipv6.dst_addr: lpm @format(IPV6_ADDRESS) @id(2) @name("ipv6_dst"); - } - actions = { - @proto_id(1) drop(); - @proto_id(2) set_nexthop_id(); - @proto_id(3) set_wcmp_group_id(); - @proto_id(4) trap(); - @proto_id(5) set_nexthop_id_and_metadata(); - @proto_id(6) set_wcmp_group_id_and_metadata(); - } - const default_action = drop(); - size = 4096; - } - apply { - mark_to_drop(standard_metadata); - vrf_table.apply(); - if (local_metadata.admit_to_l3) { - if (headers.ipv4.isValid()) { - ipv4_table.apply(); - } else if (headers.ipv6.isValid()) { - ipv6_table.apply(); - } - if (wcmp_group_id_valid) { - wcmp_group_table.apply(); - } - if (nexthop_id_valid) { - nexthop_table.apply(); - if (router_interface_id_valid && neighbor_id_valid) { - router_interface_table.apply(); - neighbor_table.apply(); - } - } - } - } -} - -control verify_ipv4_checksum(inout headers_t headers, inout local_metadata_t local_metadata) { - apply { - verify_checksum, bit<4>, bit<6>, bit<2>, bit<16>, bit<16>, bit<1>, bit<1>, bit<1>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>, bit<16>>(headers.ipv4.isValid(), { headers.ipv4.version, headers.ipv4.ihl, headers.ipv4.dscp, headers.ipv4.ecn, headers.ipv4.total_len, headers.ipv4.identification, headers.ipv4.reserved, headers.ipv4.do_not_fragment, headers.ipv4.more_fragments, headers.ipv4.frag_offset, headers.ipv4.ttl, headers.ipv4.protocol, headers.ipv4.src_addr, headers.ipv4.dst_addr }, headers.ipv4.header_checksum, HashAlgorithm.csum16); - } -} - -control compute_ipv4_checksum(inout headers_t headers, inout local_metadata_t local_metadata) { - apply { - update_checksum, bit<4>, bit<6>, bit<2>, bit<16>, bit<16>, bit<1>, bit<1>, bit<1>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>, bit<16>>(headers.erspan_ipv4.isValid(), { headers.erspan_ipv4.version, headers.erspan_ipv4.ihl, headers.erspan_ipv4.dscp, headers.erspan_ipv4.ecn, headers.erspan_ipv4.total_len, headers.erspan_ipv4.identification, headers.erspan_ipv4.reserved, headers.erspan_ipv4.do_not_fragment, headers.erspan_ipv4.more_fragments, headers.erspan_ipv4.frag_offset, headers.erspan_ipv4.ttl, headers.erspan_ipv4.protocol, headers.erspan_ipv4.src_addr, headers.erspan_ipv4.dst_addr }, headers.erspan_ipv4.header_checksum, HashAlgorithm.csum16); - update_checksum, bit<4>, bit<6>, bit<2>, bit<16>, bit<16>, bit<1>, bit<1>, bit<1>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>, bit<16>>(headers.ipv4.isValid(), { headers.ipv4.version, headers.ipv4.ihl, headers.ipv4.dscp, headers.ipv4.ecn, headers.ipv4.total_len, headers.ipv4.identification, headers.ipv4.reserved, headers.ipv4.do_not_fragment, headers.ipv4.more_fragments, headers.ipv4.frag_offset, headers.ipv4.ttl, headers.ipv4.protocol, headers.ipv4.src_addr, headers.ipv4.dst_addr }, headers.ipv4.header_checksum, HashAlgorithm.csum16); - } -} - -control mirroring_clone(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { - port_id_t mirror_port; - bit<32> pre_session; - @id(0x01000007) action mirror_as_ipv4_erspan(@id(1) port_id_t port, @id(2) @format(IPV4_ADDRESS) ipv4_addr_t src_ip, @id(3) @format(IPV4_ADDRESS) ipv4_addr_t dst_ip, @id(4) @format(MAC_ADDRESS) ethernet_addr_t src_mac, @id(5) @format(MAC_ADDRESS) ethernet_addr_t dst_mac, @id(6) bit<8> ttl, @id(7) bit<8> tos) { - mirror_port = port; - local_metadata.mirroring_src_ip = src_ip; - local_metadata.mirroring_dst_ip = dst_ip; - local_metadata.mirroring_src_mac = src_mac; - local_metadata.mirroring_dst_mac = dst_mac; - local_metadata.mirroring_ttl = ttl; - local_metadata.mirroring_tos = tos; - } - @p4runtime_role("sdn_controller") @id(0x02000046) table mirror_session_table { - key = { - local_metadata.mirror_session_id_value: exact @id(1) @name("mirror_session_id"); - } - actions = { - @proto_id(1) mirror_as_ipv4_erspan(); - @defaultonly NoAction(); - } - const default_action = NoAction(); - size = 2; - } - @id(0x01000009) action set_pre_session(bit<32> id) { - pre_session = id; - } - @p4runtime_role("packet_replication_engine_manager") @id(0x02000048) table mirror_port_to_pre_session_table { - key = { - mirror_port: exact @id(1) @name("mirror_port"); - } - actions = { - @proto_id(1) set_pre_session(); - @defaultonly NoAction(); - } - const default_action = NoAction(); - } - apply { - if (local_metadata.mirror_session_id_valid) { - if (mirror_session_table.apply().hit) { - if (mirror_port_to_pre_session_table.apply().hit) { - clone_preserving_field_list(CloneType.I2E, pre_session, 8w1); - } - } - } - } -} - -control l3_admit(in headers_t headers, inout local_metadata_t local_metadata, in standard_metadata_t standard_metadata) { - @id(0x01000008) action admit_to_l3() { - local_metadata.admit_to_l3 = true; - } - @p4runtime_role("sdn_controller") @id(0x02000047) table l3_admit_table { - key = { - headers.ethernet.dst_addr : ternary @name("dst_mac") @id(1) @format(MAC_ADDRESS); - local_metadata.ingress_port: optional @name("in_port") @id(2); - } - actions = { - @proto_id(1) admit_to_l3(); - @defaultonly NoAction(); - } - const default_action = NoAction(); - size = 128; - } - apply { - l3_admit_table.apply(); - } -} - -control ttl(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { - apply { - if (local_metadata.admit_to_l3) { - if (headers.ipv4.isValid()) { - if (headers.ipv4.ttl <= 8w1) { - mark_to_drop(standard_metadata); - } else { - headers.ipv4.ttl = headers.ipv4.ttl + 8w255; - } - } - if (headers.ipv6.isValid()) { - if (headers.ipv6.hop_limit <= 8w1) { - mark_to_drop(standard_metadata); - } else { - headers.ipv6.hop_limit = headers.ipv6.hop_limit + 8w255; - } - } - } - } -} - -control packet_rewrites(inout headers_t headers, in local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { - apply { - if (local_metadata.admit_to_l3) { - headers.ethernet.src_addr = local_metadata.packet_rewrites.src_mac; - headers.ethernet.dst_addr = local_metadata.packet_rewrites.dst_mac; - } - } + acl_metadata_t acl_metadata; + bool bypass_ingress; + bool wcmp_group_id_valid; + wcmp_group_id_t wcmp_group_id_value; + bool nexthop_id_valid; + nexthop_id_t nexthop_id_value; + bool ipmc_table_hit; + bool acl_drop; } control acl_wbb_ingress(in headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { @@ -547,12 +256,12 @@ control acl_wbb_ingress(in headers_t headers, inout local_metadata_t local_metad @id(0x13000103) direct_counter(CounterType.packets_and_bytes) acl_wbb_ingress_counter; @id(0x01000107) @sai_action(SAI_PACKET_ACTION_COPY) action acl_wbb_ingress_copy() { acl_wbb_ingress_meter.read(local_metadata.color); - clone(CloneType.I2E, 32w1024); + clone(CloneType.I2E, 32w255); acl_wbb_ingress_counter.count(); } @id(0x01000108) @sai_action(SAI_PACKET_ACTION_TRAP) action acl_wbb_ingress_trap() { acl_wbb_ingress_meter.read(local_metadata.color); - clone(CloneType.I2E, 32w1024); + clone(CloneType.I2E, 32w255); mark_to_drop(standard_metadata); acl_wbb_ingress_counter.count(); } @@ -614,25 +323,36 @@ control acl_wbb_ingress(in headers_t headers, inout local_metadata_t local_metad } control ingress(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { - @name("l3_admit") l3_admit() l3_admit_inst; - @name("routing") routing() routing_inst; @name("acl_wbb_ingress") acl_wbb_ingress() acl_wbb_ingress_inst; - @name("ttl") ttl() ttl_inst; - @name("mirroring_clone") mirroring_clone() mirroring_clone_inst; apply { - l3_admit_inst.apply(headers, local_metadata, standard_metadata); - routing_inst.apply(headers, local_metadata, standard_metadata); acl_wbb_ingress_inst.apply(headers, local_metadata, standard_metadata); - ttl_inst.apply(headers, local_metadata, standard_metadata); - mirroring_clone_inst.apply(headers, local_metadata, standard_metadata); } } control egress(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { - @name("packet_rewrites") packet_rewrites() packet_rewrites_inst; apply { - packet_rewrites_inst.apply(headers, local_metadata, standard_metadata); } } -@pkginfo(name="wbb.p4", organization="Google") V1Switch(packet_parser(), verify_ipv4_checksum(), ingress(), egress(), compute_ipv4_checksum(), packet_deparser()) main; +parser packet_parser(packet_in packet, out headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { + state start { + transition accept; + } +} + +control packet_deparser(packet_out packet, in headers_t headers) { + apply { + } +} + +control verify_ipv4_checksum(inout headers_t headers, inout local_metadata_t local_metadata) { + apply { + } +} + +control compute_ipv4_checksum(inout headers_t headers, inout local_metadata_t local_metadata) { + apply { + } +} + +@pkginfo(name="wbb.p4", organization="Google", version="0.0.0") V1Switch(packet_parser(), verify_ipv4_checksum(), ingress(), egress(), compute_ipv4_checksum(), packet_deparser()) main; diff --git a/testdata/p4_16_samples_outputs/pins/pins_wbb-frontend.p4 b/testdata/p4_16_samples_outputs/pins/pins_wbb-frontend.p4 index 21d40c1e1b..0378050d23 100644 --- a/testdata/p4_16_samples_outputs/pins/pins_wbb-frontend.p4 +++ b/testdata/p4_16_samples_outputs/pins/pins_wbb-frontend.p4 @@ -5,10 +5,19 @@ typedef bit<48> ethernet_addr_t; typedef bit<32> ipv4_addr_t; typedef bit<128> ipv6_addr_t; +typedef bit<12> vlan_id_t; +typedef bit<16> ether_type_t; header ethernet_t { ethernet_addr_t dst_addr; ethernet_addr_t src_addr; - bit<16> ether_type; + ether_type_t ether_type; +} + +header vlan_t { + bit<3> priority_code_point; + bit<1> drop_eligible_indicator; + vlan_id_t vlan_id; + ether_type_t ether_type; } header ipv4_t { @@ -65,6 +74,7 @@ header icmp_t { bit<8> type; bit<8> code; bit<16> checksum; + bit<32> rest_of_header; } header arp_t { @@ -92,411 +102,160 @@ header gre_t { bit<16> protocol; } +header ipfix_t { + bit<16> version_number; + bit<16> length; + bit<32> export_time; + bit<32> sequence_number; + bit<32> observation_domain_id; +} + +header psamp_extended_t { + bit<16> template_id; + bit<16> length; + bit<64> observation_time; + bit<16> flowset; + bit<16> next_hop_index; + bit<16> epoch; + bit<16> ingress_port; + bit<16> egress_port; + bit<16> user_meta_field; + bit<8> dlb_id; + bit<8> variable_length; + bit<16> packet_sampled_length; +} + enum bit<8> PreservedFieldList { - CLONE_I2E = 8w1 + MIRROR_AND_PACKET_IN_COPY = 8w1, + RECIRCULATE = 8w2 } type bit<10> nexthop_id_t; type bit<12> wcmp_group_id_t; -type bit<10> vrf_id_t; -type bit<10> router_interface_id_t; +@p4runtime_translation_mappings({ { "" , 0 } , }) type bit<10> vrf_id_t; type bit<9> port_id_t; type bit<10> mirror_session_id_t; typedef bit<6> route_metadata_t; +typedef bit<8> acl_metadata_t; enum bit<2> MeterColor_t { GREEN = 2w0, YELLOW = 2w1, RED = 2w2 } +@controller_header("packet_in") header packet_in_header_t { + @id(1) + port_id_t ingress_port; + @id(2) + port_id_t target_egress_port; +} + +@controller_header("packet_out") header packet_out_header_t { + @id(1) + port_id_t egress_port; + @id(2) + bit<1> submit_to_ingress; + @id(3) @padding + bit<6> unused_pad; +} + struct headers_t { - ethernet_t erspan_ethernet; - ipv4_t erspan_ipv4; - gre_t erspan_gre; - ethernet_t ethernet; - ipv6_t tunnel_encap_ipv6; - gre_t tunnel_encap_gre; - ipv4_t ipv4; - ipv6_t ipv6; - icmp_t icmp; - tcp_t tcp; - udp_t udp; - arp_t arp; + packet_out_header_t packet_out_header; + ethernet_t mirror_encap_ethernet; + vlan_t mirror_encap_vlan; + ipv6_t mirror_encap_ipv6; + udp_t mirror_encap_udp; + ipfix_t ipfix; + psamp_extended_t psamp_extended; + ethernet_t ethernet; + vlan_t vlan; + ipv6_t tunnel_encap_ipv6; + gre_t tunnel_encap_gre; + ipv4_t ipv4; + ipv6_t ipv6; + ipv4_t inner_ipv4; + ipv6_t inner_ipv6; + icmp_t icmp; + tcp_t tcp; + udp_t udp; + arp_t arp; } struct packet_rewrites_t { ethernet_addr_t src_mac; ethernet_addr_t dst_mac; + vlan_id_t vlan_id; } struct local_metadata_t { + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + bool enable_vlan_checks; + vlan_id_t vlan_id; bool admit_to_l3; vrf_id_t vrf_id; + bool enable_decrement_ttl; + bool enable_src_mac_rewrite; + bool enable_dst_mac_rewrite; + bool enable_vlan_rewrite; packet_rewrites_t packet_rewrites; bit<16> l4_src_port; bit<16> l4_dst_port; - bit<16> wcmp_selector_input; + bit<8> wcmp_selector_input; + bool apply_tunnel_decap_at_end_of_pre_ingress; bool apply_tunnel_encap_at_egress; ipv6_addr_t tunnel_encap_src_ipv6; ipv6_addr_t tunnel_encap_dst_ipv6; - bool mirror_session_id_valid; - mirror_session_id_t mirror_session_id_value; - @field_list(PreservedFieldList.CLONE_I2E) - ipv4_addr_t mirroring_src_ip; - @field_list(PreservedFieldList.CLONE_I2E) - ipv4_addr_t mirroring_dst_ip; - @field_list(PreservedFieldList.CLONE_I2E) - ethernet_addr_t mirroring_src_mac; - @field_list(PreservedFieldList.CLONE_I2E) - ethernet_addr_t mirroring_dst_mac; - @field_list(PreservedFieldList.CLONE_I2E) - bit<8> mirroring_ttl; - @field_list(PreservedFieldList.CLONE_I2E) - bit<8> mirroring_tos; + bool marked_to_copy; + bool marked_to_mirror; + mirror_session_id_t mirror_session_id; + port_id_t mirror_egress_port; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + ethernet_addr_t mirror_encap_src_mac; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + ethernet_addr_t mirror_encap_dst_mac; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + vlan_id_t mirror_encap_vlan_id; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + ipv6_addr_t mirror_encap_src_ip; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + ipv6_addr_t mirror_encap_dst_ip; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + bit<16> mirror_encap_udp_src_port; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + bit<16> mirror_encap_udp_dst_port; + @field_list(PreservedFieldList.RECIRCULATE) + bit<9> loopback_port; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + bit<9> packet_in_ingress_port; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + bit<9> packet_in_target_egress_port; MeterColor_t color; port_id_t ingress_port; route_metadata_t route_metadata; -} - -@controller_header("packet_in") header packet_in_header_t { - @id(1) - port_id_t ingress_port; - @id(2) - port_id_t target_egress_port; -} - -@controller_header("packet_out") header packet_out_header_t { - @id(1) - port_id_t egress_port; - @id(2) - bit<1> submit_to_ingress; - @id(3) - bit<7> unused_pad; -} - -parser packet_parser(packet_in packet, out headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { - state start { - local_metadata.admit_to_l3 = false; - local_metadata.vrf_id = (vrf_id_t)10w0; - local_metadata.packet_rewrites.src_mac = 48w0; - local_metadata.packet_rewrites.dst_mac = 48w0; - local_metadata.l4_src_port = 16w0; - local_metadata.l4_dst_port = 16w0; - local_metadata.wcmp_selector_input = 16w0; - local_metadata.mirror_session_id_valid = false; - local_metadata.color = MeterColor_t.GREEN; - local_metadata.ingress_port = (port_id_t)standard_metadata.ingress_port; - local_metadata.route_metadata = 6w0; - packet.extract(headers.ethernet); - transition select(headers.ethernet.ether_type) { - 16w0x800: parse_ipv4; - 16w0x86dd: parse_ipv6; - 16w0x806: parse_arp; - default: accept; - } - } - state parse_ipv4 { - packet.extract(headers.ipv4); - transition select(headers.ipv4.protocol) { - 8w0x1: parse_icmp; - 8w0x6: parse_tcp; - 8w0x11: parse_udp; - default: accept; - } - } - state parse_ipv6 { - packet.extract(headers.ipv6); - transition select(headers.ipv6.next_header) { - 8w0x3a: parse_icmp; - 8w0x6: parse_tcp; - 8w0x11: parse_udp; - default: accept; - } - } - state parse_tcp { - packet.extract(headers.tcp); - local_metadata.l4_src_port = headers.tcp.src_port; - local_metadata.l4_dst_port = headers.tcp.dst_port; - transition accept; - } - state parse_udp { - packet.extract(headers.udp); - local_metadata.l4_src_port = headers.udp.src_port; - local_metadata.l4_dst_port = headers.udp.dst_port; - transition accept; - } - state parse_icmp { - packet.extract(headers.icmp); - transition accept; - } - state parse_arp { - packet.extract(headers.arp); - transition accept; - } -} - -control packet_deparser(packet_out packet, in headers_t headers) { - apply { - packet.emit(headers.erspan_ethernet); - packet.emit(headers.erspan_ipv4); - packet.emit(headers.erspan_gre); - packet.emit(headers.ethernet); - packet.emit(headers.tunnel_encap_ipv6); - packet.emit(headers.tunnel_encap_gre); - packet.emit(headers.ipv4); - packet.emit(headers.ipv6); - packet.emit(headers.arp); - packet.emit(headers.icmp); - packet.emit(headers.tcp); - packet.emit(headers.udp); - } -} - -control verify_ipv4_checksum(inout headers_t headers, inout local_metadata_t local_metadata) { - apply { - verify_checksum, bit<4>, bit<6>, bit<2>, bit<16>, bit<16>, bit<1>, bit<1>, bit<1>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>, bit<16>>(headers.ipv4.isValid(), { headers.ipv4.version, headers.ipv4.ihl, headers.ipv4.dscp, headers.ipv4.ecn, headers.ipv4.total_len, headers.ipv4.identification, headers.ipv4.reserved, headers.ipv4.do_not_fragment, headers.ipv4.more_fragments, headers.ipv4.frag_offset, headers.ipv4.ttl, headers.ipv4.protocol, headers.ipv4.src_addr, headers.ipv4.dst_addr }, headers.ipv4.header_checksum, HashAlgorithm.csum16); - } -} - -control compute_ipv4_checksum(inout headers_t headers, inout local_metadata_t local_metadata) { - apply { - update_checksum, bit<4>, bit<6>, bit<2>, bit<16>, bit<16>, bit<1>, bit<1>, bit<1>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>, bit<16>>(headers.erspan_ipv4.isValid(), { headers.erspan_ipv4.version, headers.erspan_ipv4.ihl, headers.erspan_ipv4.dscp, headers.erspan_ipv4.ecn, headers.erspan_ipv4.total_len, headers.erspan_ipv4.identification, headers.erspan_ipv4.reserved, headers.erspan_ipv4.do_not_fragment, headers.erspan_ipv4.more_fragments, headers.erspan_ipv4.frag_offset, headers.erspan_ipv4.ttl, headers.erspan_ipv4.protocol, headers.erspan_ipv4.src_addr, headers.erspan_ipv4.dst_addr }, headers.erspan_ipv4.header_checksum, HashAlgorithm.csum16); - update_checksum, bit<4>, bit<6>, bit<2>, bit<16>, bit<16>, bit<1>, bit<1>, bit<1>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>, bit<16>>(headers.ipv4.isValid(), { headers.ipv4.version, headers.ipv4.ihl, headers.ipv4.dscp, headers.ipv4.ecn, headers.ipv4.total_len, headers.ipv4.identification, headers.ipv4.reserved, headers.ipv4.do_not_fragment, headers.ipv4.more_fragments, headers.ipv4.frag_offset, headers.ipv4.ttl, headers.ipv4.protocol, headers.ipv4.src_addr, headers.ipv4.dst_addr }, headers.ipv4.header_checksum, HashAlgorithm.csum16); - } + acl_metadata_t acl_metadata; + bool bypass_ingress; + bool wcmp_group_id_valid; + wcmp_group_id_t wcmp_group_id_value; + bool nexthop_id_valid; + nexthop_id_t nexthop_id_value; + bool ipmc_table_hit; + bool acl_drop; } control ingress(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { - @name("ingress.routing.wcmp_group_id_valid") bool routing_wcmp_group_id_valid; - @name("ingress.routing.wcmp_group_id_value") wcmp_group_id_t routing_wcmp_group_id_value; - @name("ingress.routing.nexthop_id_valid") bool routing_nexthop_id_valid; - @name("ingress.routing.nexthop_id_value") nexthop_id_t routing_nexthop_id_value; - @name("ingress.routing.router_interface_id_valid") bool routing_router_interface_id_valid; - @name("ingress.routing.router_interface_id_value") router_interface_id_t routing_router_interface_id_value; - @name("ingress.routing.neighbor_id_valid") bool routing_neighbor_id_valid; - @name("ingress.routing.neighbor_id_value") ipv6_addr_t routing_neighbor_id_value; @name("ingress.acl_wbb_ingress.ttl") bit<8> acl_wbb_ingress_ttl; - @name("ingress.mirroring_clone.mirror_port") port_id_t mirroring_clone_mirror_port; - @name("ingress.mirroring_clone.pre_session") bit<32> mirroring_clone_pre_session; @noWarn("unused") @name(".NoAction") action NoAction_1() { } - @noWarn("unused") @name(".NoAction") action NoAction_2() { - } - @noWarn("unused") @name(".NoAction") action NoAction_3() { - } - @noWarn("unused") @name(".NoAction") action NoAction_4() { - } - @noWarn("unused") @name(".NoAction") action NoAction_5() { - } - @noWarn("unused") @name(".NoAction") action NoAction_6() { - } - @noWarn("unused") @name(".NoAction") action NoAction_7() { - } - @noWarn("unused") @name(".NoAction") action NoAction_8() { - } - @id(0x01000008) @name("ingress.l3_admit.admit_to_l3") action l3_admit_admit_to_l3_0() { - local_metadata.admit_to_l3 = true; - } - @p4runtime_role("sdn_controller") @id(0x02000047) @name("ingress.l3_admit.l3_admit_table") table l3_admit_l3_admit_table { - key = { - headers.ethernet.dst_addr : ternary @name("dst_mac") @id(1) @format(MAC_ADDRESS); - local_metadata.ingress_port: optional @name("in_port") @id(2); - } - actions = { - @proto_id(1) l3_admit_admit_to_l3_0(); - @defaultonly NoAction_1(); - } - const default_action = NoAction_1(); - size = 128; - } - @id(0x01000001) @name("ingress.routing.set_dst_mac") action routing_set_dst_mac_0(@id(1) @format(MAC_ADDRESS) @name("dst_mac") ethernet_addr_t dst_mac_2) { - local_metadata.packet_rewrites.dst_mac = dst_mac_2; - } - @p4runtime_role("sdn_controller") @id(0x02000040) @name("ingress.routing.neighbor_table") table routing_neighbor_table { - key = { - routing_router_interface_id_value: exact @id(1) @name("router_interface_id") @refers_to(router_interface_table , router_interface_id); - routing_neighbor_id_value : exact @id(2) @format(IPV6_ADDRESS) @name("neighbor_id"); - } - actions = { - @proto_id(1) routing_set_dst_mac_0(); - @defaultonly NoAction_2(); - } - const default_action = NoAction_2(); - size = 1024; - } - @id(0x01000002) @name("ingress.routing.set_port_and_src_mac") action routing_set_port_and_src_mac_0(@id(1) @name("port") port_id_t port, @id(2) @format(MAC_ADDRESS) @name("src_mac") ethernet_addr_t src_mac_2) { - standard_metadata.egress_spec = (bit<9>)port; - local_metadata.packet_rewrites.src_mac = src_mac_2; - } - @p4runtime_role("sdn_controller") @id(0x02000041) @name("ingress.routing.router_interface_table") table routing_router_interface_table { - key = { - routing_router_interface_id_value: exact @id(1) @name("router_interface_id"); - } - actions = { - @proto_id(1) routing_set_port_and_src_mac_0(); - @defaultonly NoAction_3(); - } - const default_action = NoAction_3(); - size = 256; - } - @id(0x01000014) @name("ingress.routing.set_ip_nexthop") action routing_set_ip_nexthop_0(@id(1) @refers_to(router_interface_table , router_interface_id) @refers_to(neighbor_table , router_interface_id) @name("router_interface_id") router_interface_id_t router_interface_id, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) @name("neighbor_id") ipv6_addr_t neighbor_id) { - routing_router_interface_id_valid = true; - routing_router_interface_id_value = router_interface_id; - routing_neighbor_id_valid = true; - routing_neighbor_id_value = neighbor_id; - } - @id(0x01000003) @deprecated("Use set_ip_nexthop instead.") @name("ingress.routing.set_nexthop") action routing_set_nexthop_0(@id(1) @refers_to(router_interface_table , router_interface_id) @refers_to(neighbor_table , router_interface_id) @name("router_interface_id") router_interface_id_t router_interface_id_2, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) @name("neighbor_id") ipv6_addr_t neighbor_id_2) { - @id(0x01000014) { - routing_router_interface_id_valid = true; - routing_router_interface_id_value = router_interface_id_2; - routing_neighbor_id_valid = true; - routing_neighbor_id_value = neighbor_id_2; - } - } - @p4runtime_role("sdn_controller") @id(0x02000042) @name("ingress.routing.nexthop_table") table routing_nexthop_table { - key = { - routing_nexthop_id_value: exact @id(1) @name("nexthop_id"); - } - actions = { - @proto_id(1) routing_set_nexthop_0(); - @proto_id(3) routing_set_ip_nexthop_0(); - @defaultonly NoAction_4(); - } - const default_action = NoAction_4(); - size = 1024; - } - @id(0x01000005) @name("ingress.routing.set_nexthop_id") action routing_set_nexthop_id_0(@id(1) @refers_to(nexthop_table , nexthop_id) @name("nexthop_id") nexthop_id_t nexthop_id) { - routing_nexthop_id_valid = true; - routing_nexthop_id_value = nexthop_id; - } - @id(0x01000005) @name("ingress.routing.set_nexthop_id") action routing_set_nexthop_id_1(@id(1) @refers_to(nexthop_table , nexthop_id) @name("nexthop_id") nexthop_id_t nexthop_id_2) { - routing_nexthop_id_valid = true; - routing_nexthop_id_value = nexthop_id_2; - } - @id(0x01000005) @name("ingress.routing.set_nexthop_id") action routing_set_nexthop_id_2(@id(1) @refers_to(nexthop_table , nexthop_id) @name("nexthop_id") nexthop_id_t nexthop_id_3) { - routing_nexthop_id_valid = true; - routing_nexthop_id_value = nexthop_id_3; - } - @id(0x01000010) @name("ingress.routing.set_nexthop_id_and_metadata") action routing_set_nexthop_id_and_metadata_0(@id(1) @refers_to(nexthop_table , nexthop_id) @name("nexthop_id") nexthop_id_t nexthop_id_4, @name("route_metadata") route_metadata_t route_metadata_2) { - routing_nexthop_id_valid = true; - routing_nexthop_id_value = nexthop_id_4; - local_metadata.route_metadata = route_metadata_2; - } - @id(0x01000010) @name("ingress.routing.set_nexthop_id_and_metadata") action routing_set_nexthop_id_and_metadata_1(@id(1) @refers_to(nexthop_table , nexthop_id) @name("nexthop_id") nexthop_id_t nexthop_id_5, @name("route_metadata") route_metadata_t route_metadata_3) { - routing_nexthop_id_valid = true; - routing_nexthop_id_value = nexthop_id_5; - local_metadata.route_metadata = route_metadata_3; - } - @max_group_size(256) @name("ingress.routing.wcmp_group_selector") action_selector(HashAlgorithm.identity, 32w65536, 32w16) routing_wcmp_group_selector; - @p4runtime_role("sdn_controller") @id(0x02000043) @oneshot @name("ingress.routing.wcmp_group_table") table routing_wcmp_group_table { - key = { - routing_wcmp_group_id_value : exact @id(1) @name("wcmp_group_id"); - local_metadata.wcmp_selector_input: selector @name("local_metadata.wcmp_selector_input"); - } - actions = { - @proto_id(1) routing_set_nexthop_id_0(); - @defaultonly NoAction_5(); - } - const default_action = NoAction_5(); - @id(0x11DC4EC8) implementation = routing_wcmp_group_selector; - size = 3968; - } - @name("ingress.routing.no_action") action routing_no_action_0() { - } - @entry_restriction(" - // The VRF ID 0 (or '' in P4Runtime) encodes the default VRF, which cannot - // be read or written via this table, but is always present implicitly. - // TODO: This constraint should read `vrf_id != ''` (since - // constraints are a control plane (P4Runtime) concept), but - // p4-constraints does not currently support strings. - vrf_id != 0; - ") @p4runtime_role("sdn_controller") @id(0x0200004A) @name("ingress.routing.vrf_table") table routing_vrf_table { - key = { - local_metadata.vrf_id: exact @id(1) @name("vrf_id"); - } - actions = { - @proto_id(1) routing_no_action_0(); - } - const default_action = routing_no_action_0(); - size = 64; - } - @id(0x01000006) @name("ingress.routing.drop") action routing_drop_0() { - mark_to_drop(standard_metadata); - } - @id(0x01000006) @name("ingress.routing.drop") action routing_drop_1() { - mark_to_drop(standard_metadata); - } - @id(0x01000004) @name("ingress.routing.set_wcmp_group_id") action routing_set_wcmp_group_id_0(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) @name("wcmp_group_id") wcmp_group_id_t wcmp_group_id) { - routing_wcmp_group_id_valid = true; - routing_wcmp_group_id_value = wcmp_group_id; - } - @id(0x01000004) @name("ingress.routing.set_wcmp_group_id") action routing_set_wcmp_group_id_1(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) @name("wcmp_group_id") wcmp_group_id_t wcmp_group_id_2) { - routing_wcmp_group_id_valid = true; - routing_wcmp_group_id_value = wcmp_group_id_2; - } - @id(0x01000011) @name("ingress.routing.set_wcmp_group_id_and_metadata") action routing_set_wcmp_group_id_and_metadata_0(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) @name("wcmp_group_id") wcmp_group_id_t wcmp_group_id_3, @name("route_metadata") route_metadata_t route_metadata_4) { - @id(0x01000004) { - routing_wcmp_group_id_valid = true; - routing_wcmp_group_id_value = wcmp_group_id_3; - } - local_metadata.route_metadata = route_metadata_4; - } - @id(0x01000011) @name("ingress.routing.set_wcmp_group_id_and_metadata") action routing_set_wcmp_group_id_and_metadata_1(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) @name("wcmp_group_id") wcmp_group_id_t wcmp_group_id_4, @name("route_metadata") route_metadata_t route_metadata_5) { - @id(0x01000004) { - routing_wcmp_group_id_valid = true; - routing_wcmp_group_id_value = wcmp_group_id_4; - } - local_metadata.route_metadata = route_metadata_5; - } - @id(0x0100000F) @name("ingress.routing.trap") action routing_trap_0() { - clone(CloneType.I2E, 32w1024); - mark_to_drop(standard_metadata); - } - @id(0x0100000F) @name("ingress.routing.trap") action routing_trap_1() { - clone(CloneType.I2E, 32w1024); - mark_to_drop(standard_metadata); - } - @p4runtime_role("sdn_controller") @id(0x02000044) @name("ingress.routing.ipv4_table") table routing_ipv4_table { - key = { - local_metadata.vrf_id: exact @id(1) @name("vrf_id") @refers_to(vrf_table , vrf_id); - headers.ipv4.dst_addr: lpm @format(IPV4_ADDRESS) @id(2) @name("ipv4_dst"); - } - actions = { - @proto_id(1) routing_drop_0(); - @proto_id(2) routing_set_nexthop_id_1(); - @proto_id(3) routing_set_wcmp_group_id_0(); - @proto_id(4) routing_trap_0(); - @proto_id(5) routing_set_nexthop_id_and_metadata_0(); - @proto_id(6) routing_set_wcmp_group_id_and_metadata_0(); - } - const default_action = routing_drop_0(); - size = 32768; - } - @p4runtime_role("sdn_controller") @id(0x02000045) @name("ingress.routing.ipv6_table") table routing_ipv6_table { - key = { - local_metadata.vrf_id: exact @id(1) @name("vrf_id") @refers_to(vrf_table , vrf_id); - headers.ipv6.dst_addr: lpm @format(IPV6_ADDRESS) @id(2) @name("ipv6_dst"); - } - actions = { - @proto_id(1) routing_drop_1(); - @proto_id(2) routing_set_nexthop_id_2(); - @proto_id(3) routing_set_wcmp_group_id_1(); - @proto_id(4) routing_trap_1(); - @proto_id(5) routing_set_nexthop_id_and_metadata_1(); - @proto_id(6) routing_set_wcmp_group_id_and_metadata_1(); - } - const default_action = routing_drop_1(); - size = 4096; - } @id(0x15000101) @name("ingress.acl_wbb_ingress.acl_wbb_ingress_meter") direct_meter(MeterType.bytes) acl_wbb_ingress_acl_wbb_ingress_meter; @id(0x13000103) @name("ingress.acl_wbb_ingress.acl_wbb_ingress_counter") direct_counter(CounterType.packets_and_bytes) acl_wbb_ingress_acl_wbb_ingress_counter; @id(0x01000107) @sai_action(SAI_PACKET_ACTION_COPY) @name("ingress.acl_wbb_ingress.acl_wbb_ingress_copy") action acl_wbb_ingress_acl_wbb_ingress_copy_0() { acl_wbb_ingress_acl_wbb_ingress_meter.read(local_metadata.color); - clone(CloneType.I2E, 32w1024); + clone(CloneType.I2E, 32w255); acl_wbb_ingress_acl_wbb_ingress_counter.count(); } @id(0x01000108) @sai_action(SAI_PACKET_ACTION_TRAP) @name("ingress.acl_wbb_ingress.acl_wbb_ingress_trap") action acl_wbb_ingress_acl_wbb_ingress_trap_0() { acl_wbb_ingress_acl_wbb_ingress_meter.read(local_metadata.color); - clone(CloneType.I2E, 32w1024); + clone(CloneType.I2E, 32w255); mark_to_drop(standard_metadata); acl_wbb_ingress_acl_wbb_ingress_counter.count(); } @@ -540,71 +299,14 @@ control ingress(inout headers_t headers, inout local_metadata_t local_metadata, actions = { @proto_id(1) acl_wbb_ingress_acl_wbb_ingress_copy_0(); @proto_id(2) acl_wbb_ingress_acl_wbb_ingress_trap_0(); - @defaultonly NoAction_6(); + @defaultonly NoAction_1(); } - const default_action = NoAction_6(); + const default_action = NoAction_1(); meters = acl_wbb_ingress_acl_wbb_ingress_meter; counters = acl_wbb_ingress_acl_wbb_ingress_counter; size = 8; } - @id(0x01000007) @name("ingress.mirroring_clone.mirror_as_ipv4_erspan") action mirroring_clone_mirror_as_ipv4_erspan_0(@id(1) @name("port") port_id_t port_2, @id(2) @format(IPV4_ADDRESS) @name("src_ip") ipv4_addr_t src_ip, @id(3) @format(IPV4_ADDRESS) @name("dst_ip") ipv4_addr_t dst_ip, @id(4) @format(MAC_ADDRESS) @name("src_mac") ethernet_addr_t src_mac_3, @id(5) @format(MAC_ADDRESS) @name("dst_mac") ethernet_addr_t dst_mac_3, @id(6) @name("ttl") bit<8> ttl_0, @id(7) @name("tos") bit<8> tos) { - mirroring_clone_mirror_port = port_2; - local_metadata.mirroring_src_ip = src_ip; - local_metadata.mirroring_dst_ip = dst_ip; - local_metadata.mirroring_src_mac = src_mac_3; - local_metadata.mirroring_dst_mac = dst_mac_3; - local_metadata.mirroring_ttl = ttl_0; - local_metadata.mirroring_tos = tos; - } - @p4runtime_role("sdn_controller") @id(0x02000046) @name("ingress.mirroring_clone.mirror_session_table") table mirroring_clone_mirror_session_table { - key = { - local_metadata.mirror_session_id_value: exact @id(1) @name("mirror_session_id"); - } - actions = { - @proto_id(1) mirroring_clone_mirror_as_ipv4_erspan_0(); - @defaultonly NoAction_7(); - } - const default_action = NoAction_7(); - size = 2; - } - @id(0x01000009) @name("ingress.mirroring_clone.set_pre_session") action mirroring_clone_set_pre_session_0(@name("id") bit<32> id) { - mirroring_clone_pre_session = id; - } - @p4runtime_role("packet_replication_engine_manager") @id(0x02000048) @name("ingress.mirroring_clone.mirror_port_to_pre_session_table") table mirroring_clone_mirror_port_to_pre_session_table { - key = { - mirroring_clone_mirror_port: exact @id(1) @name("mirror_port"); - } - actions = { - @proto_id(1) mirroring_clone_set_pre_session_0(); - @defaultonly NoAction_8(); - } - const default_action = NoAction_8(); - } apply { - l3_admit_l3_admit_table.apply(); - routing_wcmp_group_id_valid = false; - routing_nexthop_id_valid = false; - routing_router_interface_id_valid = false; - routing_neighbor_id_valid = false; - mark_to_drop(standard_metadata); - routing_vrf_table.apply(); - if (local_metadata.admit_to_l3) { - if (headers.ipv4.isValid()) { - routing_ipv4_table.apply(); - } else if (headers.ipv6.isValid()) { - routing_ipv6_table.apply(); - } - if (routing_wcmp_group_id_valid) { - routing_wcmp_group_table.apply(); - } - if (routing_nexthop_id_valid) { - routing_nexthop_table.apply(); - if (routing_router_interface_id_valid && routing_neighbor_id_valid) { - routing_router_interface_table.apply(); - routing_neighbor_table.apply(); - } - } - } acl_wbb_ingress_ttl = 8w0; if (headers.ipv4.isValid()) { acl_wbb_ingress_ttl = headers.ipv4.ttl; @@ -612,39 +314,33 @@ control ingress(inout headers_t headers, inout local_metadata_t local_metadata, acl_wbb_ingress_ttl = headers.ipv6.hop_limit; } acl_wbb_ingress_acl_wbb_ingress_table.apply(); - if (local_metadata.admit_to_l3) { - if (headers.ipv4.isValid()) { - if (headers.ipv4.ttl <= 8w1) { - mark_to_drop(standard_metadata); - } else { - headers.ipv4.ttl = headers.ipv4.ttl + 8w255; - } - } - if (headers.ipv6.isValid()) { - if (headers.ipv6.hop_limit <= 8w1) { - mark_to_drop(standard_metadata); - } else { - headers.ipv6.hop_limit = headers.ipv6.hop_limit + 8w255; - } - } - } - if (local_metadata.mirror_session_id_valid) { - if (mirroring_clone_mirror_session_table.apply().hit) { - if (mirroring_clone_mirror_port_to_pre_session_table.apply().hit) { - clone_preserving_field_list(CloneType.I2E, mirroring_clone_pre_session, 8w1); - } - } - } } } control egress(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { apply { - if (local_metadata.admit_to_l3) { - headers.ethernet.src_addr = local_metadata.packet_rewrites.src_mac; - headers.ethernet.dst_addr = local_metadata.packet_rewrites.dst_mac; - } } } -@pkginfo(name="wbb.p4", organization="Google") V1Switch(packet_parser(), verify_ipv4_checksum(), ingress(), egress(), compute_ipv4_checksum(), packet_deparser()) main; +parser packet_parser(packet_in packet, out headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { + state start { + transition accept; + } +} + +control packet_deparser(packet_out packet, in headers_t headers) { + apply { + } +} + +control verify_ipv4_checksum(inout headers_t headers, inout local_metadata_t local_metadata) { + apply { + } +} + +control compute_ipv4_checksum(inout headers_t headers, inout local_metadata_t local_metadata) { + apply { + } +} + +@pkginfo(name="wbb.p4", organization="Google", version="0.0.0") V1Switch(packet_parser(), verify_ipv4_checksum(), ingress(), egress(), compute_ipv4_checksum(), packet_deparser()) main; diff --git a/testdata/p4_16_samples_outputs/pins/pins_wbb-midend.p4 b/testdata/p4_16_samples_outputs/pins/pins_wbb-midend.p4 index 9835624e65..217aa3f448 100644 --- a/testdata/p4_16_samples_outputs/pins/pins_wbb-midend.p4 +++ b/testdata/p4_16_samples_outputs/pins/pins_wbb-midend.p4 @@ -8,6 +8,13 @@ header ethernet_t { bit<16> ether_type; } +header vlan_t { + bit<3> priority_code_point; + bit<1> drop_eligible_indicator; + bit<12> vlan_id; + bit<16> ether_type; +} + header ipv4_t { bit<4> version; bit<4> ihl; @@ -62,6 +69,7 @@ header icmp_t { bit<8> type; bit<8> code; bit<16> checksum; + bit<32> rest_of_header; } header arp_t { @@ -89,54 +97,27 @@ header gre_t { bit<16> protocol; } -struct headers_t { - ethernet_t erspan_ethernet; - ipv4_t erspan_ipv4; - gre_t erspan_gre; - ethernet_t ethernet; - ipv6_t tunnel_encap_ipv6; - gre_t tunnel_encap_gre; - ipv4_t ipv4; - ipv6_t ipv6; - icmp_t icmp; - tcp_t tcp; - udp_t udp; - arp_t arp; +header ipfix_t { + bit<16> version_number; + bit<16> length; + bit<32> export_time; + bit<32> sequence_number; + bit<32> observation_domain_id; } -struct packet_rewrites_t { - bit<48> src_mac; - bit<48> dst_mac; -} - -struct local_metadata_t { - bool _admit_to_l30; - bit<10> _vrf_id1; - bit<48> _packet_rewrites_src_mac2; - bit<48> _packet_rewrites_dst_mac3; - bit<16> _l4_src_port4; - bit<16> _l4_dst_port5; - bit<16> _wcmp_selector_input6; - bool _apply_tunnel_encap_at_egress7; - bit<128> _tunnel_encap_src_ipv68; - bit<128> _tunnel_encap_dst_ipv69; - bool _mirror_session_id_valid10; - bit<10> _mirror_session_id_value11; - @field_list(8w1) - bit<32> _mirroring_src_ip12; - @field_list(8w1) - bit<32> _mirroring_dst_ip13; - @field_list(8w1) - bit<48> _mirroring_src_mac14; - @field_list(8w1) - bit<48> _mirroring_dst_mac15; - @field_list(8w1) - bit<8> _mirroring_ttl16; - @field_list(8w1) - bit<8> _mirroring_tos17; - bit<2> _color18; - bit<9> _ingress_port19; - bit<6> _route_metadata20; +header psamp_extended_t { + bit<16> template_id; + bit<16> length; + bit<64> observation_time; + bit<16> flowset; + bit<16> next_hop_index; + bit<16> epoch; + bit<16> ingress_port; + bit<16> egress_port; + bit<16> user_meta_field; + bit<8> dlb_id; + bit<8> variable_length; + bit<16> packet_sampled_length; } @controller_header("packet_in") header packet_in_header_t { @@ -151,350 +132,109 @@ struct local_metadata_t { bit<9> egress_port; @id(2) bit<1> submit_to_ingress; - @id(3) - bit<7> unused_pad; + @id(3) @padding + bit<6> unused_pad; } -parser packet_parser(packet_in packet, out headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { - state start { - local_metadata._admit_to_l30 = false; - local_metadata._vrf_id1 = 10w0; - local_metadata._packet_rewrites_src_mac2 = 48w0; - local_metadata._packet_rewrites_dst_mac3 = 48w0; - local_metadata._l4_src_port4 = 16w0; - local_metadata._l4_dst_port5 = 16w0; - local_metadata._wcmp_selector_input6 = 16w0; - local_metadata._mirror_session_id_valid10 = false; - local_metadata._color18 = 2w0; - local_metadata._ingress_port19 = standard_metadata.ingress_port; - local_metadata._route_metadata20 = 6w0; - packet.extract(headers.ethernet); - transition select(headers.ethernet.ether_type) { - 16w0x800: parse_ipv4; - 16w0x86dd: parse_ipv6; - 16w0x806: parse_arp; - default: accept; - } - } - state parse_ipv4 { - packet.extract(headers.ipv4); - transition select(headers.ipv4.protocol) { - 8w0x1: parse_icmp; - 8w0x6: parse_tcp; - 8w0x11: parse_udp; - default: accept; - } - } - state parse_ipv6 { - packet.extract(headers.ipv6); - transition select(headers.ipv6.next_header) { - 8w0x3a: parse_icmp; - 8w0x6: parse_tcp; - 8w0x11: parse_udp; - default: accept; - } - } - state parse_tcp { - packet.extract(headers.tcp); - local_metadata._l4_src_port4 = headers.tcp.src_port; - local_metadata._l4_dst_port5 = headers.tcp.dst_port; - transition accept; - } - state parse_udp { - packet.extract(headers.udp); - local_metadata._l4_src_port4 = headers.udp.src_port; - local_metadata._l4_dst_port5 = headers.udp.dst_port; - transition accept; - } - state parse_icmp { - packet.extract(headers.icmp); - transition accept; - } - state parse_arp { - packet.extract(headers.arp); - transition accept; - } -} - -control packet_deparser(packet_out packet, in headers_t headers) { - apply { - packet.emit(headers.erspan_ethernet); - packet.emit(headers.erspan_ipv4); - packet.emit(headers.erspan_gre); - packet.emit(headers.ethernet); - packet.emit(headers.tunnel_encap_ipv6); - packet.emit(headers.tunnel_encap_gre); - packet.emit(headers.ipv4); - packet.emit(headers.ipv6); - packet.emit(headers.arp); - packet.emit(headers.icmp); - packet.emit(headers.tcp); - packet.emit(headers.udp); - } -} - -struct tuple_0 { - bit<4> f0; - bit<4> f1; - bit<6> f2; - bit<2> f3; - bit<16> f4; - bit<16> f5; - bit<1> f6; - bit<1> f7; - bit<1> f8; - bit<13> f9; - bit<8> f10; - bit<8> f11; - bit<32> f12; - bit<32> f13; +struct headers_t { + packet_out_header_t packet_out_header; + ethernet_t mirror_encap_ethernet; + vlan_t mirror_encap_vlan; + ipv6_t mirror_encap_ipv6; + udp_t mirror_encap_udp; + ipfix_t ipfix; + psamp_extended_t psamp_extended; + ethernet_t ethernet; + vlan_t vlan; + ipv6_t tunnel_encap_ipv6; + gre_t tunnel_encap_gre; + ipv4_t ipv4; + ipv6_t ipv6; + ipv4_t inner_ipv4; + ipv6_t inner_ipv6; + icmp_t icmp; + tcp_t tcp; + udp_t udp; + arp_t arp; } -control verify_ipv4_checksum(inout headers_t headers, inout local_metadata_t local_metadata) { - apply { - verify_checksum>(headers.ipv4.isValid(), (tuple_0){f0 = headers.ipv4.version,f1 = headers.ipv4.ihl,f2 = headers.ipv4.dscp,f3 = headers.ipv4.ecn,f4 = headers.ipv4.total_len,f5 = headers.ipv4.identification,f6 = headers.ipv4.reserved,f7 = headers.ipv4.do_not_fragment,f8 = headers.ipv4.more_fragments,f9 = headers.ipv4.frag_offset,f10 = headers.ipv4.ttl,f11 = headers.ipv4.protocol,f12 = headers.ipv4.src_addr,f13 = headers.ipv4.dst_addr}, headers.ipv4.header_checksum, HashAlgorithm.csum16); - } +struct packet_rewrites_t { + bit<48> src_mac; + bit<48> dst_mac; + bit<12> vlan_id; } -control compute_ipv4_checksum(inout headers_t headers, inout local_metadata_t local_metadata) { - apply { - update_checksum>(headers.erspan_ipv4.isValid(), (tuple_0){f0 = headers.erspan_ipv4.version,f1 = headers.erspan_ipv4.ihl,f2 = headers.erspan_ipv4.dscp,f3 = headers.erspan_ipv4.ecn,f4 = headers.erspan_ipv4.total_len,f5 = headers.erspan_ipv4.identification,f6 = headers.erspan_ipv4.reserved,f7 = headers.erspan_ipv4.do_not_fragment,f8 = headers.erspan_ipv4.more_fragments,f9 = headers.erspan_ipv4.frag_offset,f10 = headers.erspan_ipv4.ttl,f11 = headers.erspan_ipv4.protocol,f12 = headers.erspan_ipv4.src_addr,f13 = headers.erspan_ipv4.dst_addr}, headers.erspan_ipv4.header_checksum, HashAlgorithm.csum16); - update_checksum>(headers.ipv4.isValid(), (tuple_0){f0 = headers.ipv4.version,f1 = headers.ipv4.ihl,f2 = headers.ipv4.dscp,f3 = headers.ipv4.ecn,f4 = headers.ipv4.total_len,f5 = headers.ipv4.identification,f6 = headers.ipv4.reserved,f7 = headers.ipv4.do_not_fragment,f8 = headers.ipv4.more_fragments,f9 = headers.ipv4.frag_offset,f10 = headers.ipv4.ttl,f11 = headers.ipv4.protocol,f12 = headers.ipv4.src_addr,f13 = headers.ipv4.dst_addr}, headers.ipv4.header_checksum, HashAlgorithm.csum16); - } +struct local_metadata_t { + @field_list(8w1) + bool _enable_vlan_checks0; + bit<12> _vlan_id1; + bool _admit_to_l32; + bit<10> _vrf_id3; + bool _enable_decrement_ttl4; + bool _enable_src_mac_rewrite5; + bool _enable_dst_mac_rewrite6; + bool _enable_vlan_rewrite7; + bit<48> _packet_rewrites_src_mac8; + bit<48> _packet_rewrites_dst_mac9; + bit<12> _packet_rewrites_vlan_id10; + bit<16> _l4_src_port11; + bit<16> _l4_dst_port12; + bit<8> _wcmp_selector_input13; + bool _apply_tunnel_decap_at_end_of_pre_ingress14; + bool _apply_tunnel_encap_at_egress15; + bit<128> _tunnel_encap_src_ipv616; + bit<128> _tunnel_encap_dst_ipv617; + bool _marked_to_copy18; + bool _marked_to_mirror19; + bit<10> _mirror_session_id20; + bit<9> _mirror_egress_port21; + @field_list(8w1) + bit<48> _mirror_encap_src_mac22; + @field_list(8w1) + bit<48> _mirror_encap_dst_mac23; + @field_list(8w1) + bit<12> _mirror_encap_vlan_id24; + @field_list(8w1) + bit<128> _mirror_encap_src_ip25; + @field_list(8w1) + bit<128> _mirror_encap_dst_ip26; + @field_list(8w1) + bit<16> _mirror_encap_udp_src_port27; + @field_list(8w1) + bit<16> _mirror_encap_udp_dst_port28; + @field_list(8w2) + bit<9> _loopback_port29; + @field_list(8w1) + bit<9> _packet_in_ingress_port30; + @field_list(8w1) + bit<9> _packet_in_target_egress_port31; + bit<2> _color32; + bit<9> _ingress_port33; + bit<6> _route_metadata34; + bit<8> _acl_metadata35; + bool _bypass_ingress36; + bool _wcmp_group_id_valid37; + bit<12> _wcmp_group_id_value38; + bool _nexthop_id_valid39; + bit<10> _nexthop_id_value40; + bool _ipmc_table_hit41; + bool _acl_drop42; } control ingress(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { - @name("ingress.routing.wcmp_group_id_valid") bool routing_wcmp_group_id_valid; - @name("ingress.routing.wcmp_group_id_value") bit<12> routing_wcmp_group_id_value; - @name("ingress.routing.nexthop_id_valid") bool routing_nexthop_id_valid; - @name("ingress.routing.nexthop_id_value") bit<10> routing_nexthop_id_value; - @name("ingress.routing.router_interface_id_valid") bool routing_router_interface_id_valid; - @name("ingress.routing.router_interface_id_value") bit<10> routing_router_interface_id_value; - @name("ingress.routing.neighbor_id_valid") bool routing_neighbor_id_valid; - @name("ingress.routing.neighbor_id_value") bit<128> routing_neighbor_id_value; @name("ingress.acl_wbb_ingress.ttl") bit<8> acl_wbb_ingress_ttl; - @name("ingress.mirroring_clone.mirror_port") bit<9> mirroring_clone_mirror_port; - @name("ingress.mirroring_clone.pre_session") bit<32> mirroring_clone_pre_session; @noWarn("unused") @name(".NoAction") action NoAction_1() { } - @noWarn("unused") @name(".NoAction") action NoAction_2() { - } - @noWarn("unused") @name(".NoAction") action NoAction_3() { - } - @noWarn("unused") @name(".NoAction") action NoAction_4() { - } - @noWarn("unused") @name(".NoAction") action NoAction_5() { - } - @noWarn("unused") @name(".NoAction") action NoAction_6() { - } - @noWarn("unused") @name(".NoAction") action NoAction_7() { - } - @noWarn("unused") @name(".NoAction") action NoAction_8() { - } - @id(0x01000008) @name("ingress.l3_admit.admit_to_l3") action l3_admit_admit_to_l3_0() { - local_metadata._admit_to_l30 = true; - } - @p4runtime_role("sdn_controller") @id(0x02000047) @name("ingress.l3_admit.l3_admit_table") table l3_admit_l3_admit_table { - key = { - headers.ethernet.dst_addr : ternary @name("dst_mac") @id(1) @format(MAC_ADDRESS); - local_metadata._ingress_port19: optional @name("in_port") @id(2); - } - actions = { - @proto_id(1) l3_admit_admit_to_l3_0(); - @defaultonly NoAction_1(); - } - const default_action = NoAction_1(); - size = 128; - } - @id(0x01000001) @name("ingress.routing.set_dst_mac") action routing_set_dst_mac_0(@id(1) @format(MAC_ADDRESS) @name("dst_mac") bit<48> dst_mac_2) { - local_metadata._packet_rewrites_dst_mac3 = dst_mac_2; - } - @p4runtime_role("sdn_controller") @id(0x02000040) @name("ingress.routing.neighbor_table") table routing_neighbor_table { - key = { - routing_router_interface_id_value: exact @id(1) @name("router_interface_id") @refers_to(router_interface_table , router_interface_id); - routing_neighbor_id_value : exact @id(2) @format(IPV6_ADDRESS) @name("neighbor_id"); - } - actions = { - @proto_id(1) routing_set_dst_mac_0(); - @defaultonly NoAction_2(); - } - const default_action = NoAction_2(); - size = 1024; - } - @id(0x01000002) @name("ingress.routing.set_port_and_src_mac") action routing_set_port_and_src_mac_0(@id(1) @name("port") bit<9> port, @id(2) @format(MAC_ADDRESS) @name("src_mac") bit<48> src_mac_2) { - standard_metadata.egress_spec = (bit<9>)port; - local_metadata._packet_rewrites_src_mac2 = src_mac_2; - } - @p4runtime_role("sdn_controller") @id(0x02000041) @name("ingress.routing.router_interface_table") table routing_router_interface_table { - key = { - routing_router_interface_id_value: exact @id(1) @name("router_interface_id"); - } - actions = { - @proto_id(1) routing_set_port_and_src_mac_0(); - @defaultonly NoAction_3(); - } - const default_action = NoAction_3(); - size = 256; - } - @id(0x01000014) @name("ingress.routing.set_ip_nexthop") action routing_set_ip_nexthop_0(@id(1) @refers_to(router_interface_table , router_interface_id) @refers_to(neighbor_table , router_interface_id) @name("router_interface_id") bit<10> router_interface_id, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) @name("neighbor_id") bit<128> neighbor_id) { - routing_router_interface_id_valid = true; - routing_router_interface_id_value = router_interface_id; - routing_neighbor_id_valid = true; - routing_neighbor_id_value = neighbor_id; - } - @id(0x01000003) @deprecated("Use set_ip_nexthop instead.") @name("ingress.routing.set_nexthop") action routing_set_nexthop_0(@id(1) @refers_to(router_interface_table , router_interface_id) @refers_to(neighbor_table , router_interface_id) @name("router_interface_id") bit<10> router_interface_id_2, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) @name("neighbor_id") bit<128> neighbor_id_2) { - @id(0x01000014) { - routing_router_interface_id_valid = true; - routing_router_interface_id_value = router_interface_id_2; - routing_neighbor_id_valid = true; - routing_neighbor_id_value = neighbor_id_2; - } - } - @p4runtime_role("sdn_controller") @id(0x02000042) @name("ingress.routing.nexthop_table") table routing_nexthop_table { - key = { - routing_nexthop_id_value: exact @id(1) @name("nexthop_id"); - } - actions = { - @proto_id(1) routing_set_nexthop_0(); - @proto_id(3) routing_set_ip_nexthop_0(); - @defaultonly NoAction_4(); - } - const default_action = NoAction_4(); - size = 1024; - } - @id(0x01000005) @name("ingress.routing.set_nexthop_id") action routing_set_nexthop_id_0(@id(1) @refers_to(nexthop_table , nexthop_id) @name("nexthop_id") bit<10> nexthop_id) { - routing_nexthop_id_valid = true; - routing_nexthop_id_value = nexthop_id; - } - @id(0x01000005) @name("ingress.routing.set_nexthop_id") action routing_set_nexthop_id_1(@id(1) @refers_to(nexthop_table , nexthop_id) @name("nexthop_id") bit<10> nexthop_id_2) { - routing_nexthop_id_valid = true; - routing_nexthop_id_value = nexthop_id_2; - } - @id(0x01000005) @name("ingress.routing.set_nexthop_id") action routing_set_nexthop_id_2(@id(1) @refers_to(nexthop_table , nexthop_id) @name("nexthop_id") bit<10> nexthop_id_3) { - routing_nexthop_id_valid = true; - routing_nexthop_id_value = nexthop_id_3; - } - @id(0x01000010) @name("ingress.routing.set_nexthop_id_and_metadata") action routing_set_nexthop_id_and_metadata_0(@id(1) @refers_to(nexthop_table , nexthop_id) @name("nexthop_id") bit<10> nexthop_id_4, @name("route_metadata") bit<6> route_metadata_2) { - routing_nexthop_id_valid = true; - routing_nexthop_id_value = nexthop_id_4; - local_metadata._route_metadata20 = route_metadata_2; - } - @id(0x01000010) @name("ingress.routing.set_nexthop_id_and_metadata") action routing_set_nexthop_id_and_metadata_1(@id(1) @refers_to(nexthop_table , nexthop_id) @name("nexthop_id") bit<10> nexthop_id_5, @name("route_metadata") bit<6> route_metadata_3) { - routing_nexthop_id_valid = true; - routing_nexthop_id_value = nexthop_id_5; - local_metadata._route_metadata20 = route_metadata_3; - } - @max_group_size(256) @name("ingress.routing.wcmp_group_selector") action_selector(HashAlgorithm.identity, 32w65536, 32w16) routing_wcmp_group_selector; - @p4runtime_role("sdn_controller") @id(0x02000043) @oneshot @name("ingress.routing.wcmp_group_table") table routing_wcmp_group_table { - key = { - routing_wcmp_group_id_value : exact @id(1) @name("wcmp_group_id"); - local_metadata._wcmp_selector_input6: selector @name("local_metadata.wcmp_selector_input"); - } - actions = { - @proto_id(1) routing_set_nexthop_id_0(); - @defaultonly NoAction_5(); - } - const default_action = NoAction_5(); - @id(0x11DC4EC8) implementation = routing_wcmp_group_selector; - size = 3968; - } - @name("ingress.routing.no_action") action routing_no_action_0() { - } - @entry_restriction(" - // The VRF ID 0 (or '' in P4Runtime) encodes the default VRF, which cannot - // be read or written via this table, but is always present implicitly. - // TODO: This constraint should read `vrf_id != ''` (since - // constraints are a control plane (P4Runtime) concept), but - // p4-constraints does not currently support strings. - vrf_id != 0; - ") @p4runtime_role("sdn_controller") @id(0x0200004A) @name("ingress.routing.vrf_table") table routing_vrf_table { - key = { - local_metadata._vrf_id1: exact @id(1) @name("vrf_id"); - } - actions = { - @proto_id(1) routing_no_action_0(); - } - const default_action = routing_no_action_0(); - size = 64; - } - @id(0x01000006) @name("ingress.routing.drop") action routing_drop_0() { - mark_to_drop(standard_metadata); - } - @id(0x01000006) @name("ingress.routing.drop") action routing_drop_1() { - mark_to_drop(standard_metadata); - } - @id(0x01000004) @name("ingress.routing.set_wcmp_group_id") action routing_set_wcmp_group_id_0(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) @name("wcmp_group_id") bit<12> wcmp_group_id) { - routing_wcmp_group_id_valid = true; - routing_wcmp_group_id_value = wcmp_group_id; - } - @id(0x01000004) @name("ingress.routing.set_wcmp_group_id") action routing_set_wcmp_group_id_1(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) @name("wcmp_group_id") bit<12> wcmp_group_id_2) { - routing_wcmp_group_id_valid = true; - routing_wcmp_group_id_value = wcmp_group_id_2; - } - @id(0x01000011) @name("ingress.routing.set_wcmp_group_id_and_metadata") action routing_set_wcmp_group_id_and_metadata_0(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) @name("wcmp_group_id") bit<12> wcmp_group_id_3, @name("route_metadata") bit<6> route_metadata_4) { - @id(0x01000004) { - routing_wcmp_group_id_valid = true; - routing_wcmp_group_id_value = wcmp_group_id_3; - } - local_metadata._route_metadata20 = route_metadata_4; - } - @id(0x01000011) @name("ingress.routing.set_wcmp_group_id_and_metadata") action routing_set_wcmp_group_id_and_metadata_1(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) @name("wcmp_group_id") bit<12> wcmp_group_id_4, @name("route_metadata") bit<6> route_metadata_5) { - @id(0x01000004) { - routing_wcmp_group_id_valid = true; - routing_wcmp_group_id_value = wcmp_group_id_4; - } - local_metadata._route_metadata20 = route_metadata_5; - } - @id(0x0100000F) @name("ingress.routing.trap") action routing_trap_0() { - clone(CloneType.I2E, 32w1024); - mark_to_drop(standard_metadata); - } - @id(0x0100000F) @name("ingress.routing.trap") action routing_trap_1() { - clone(CloneType.I2E, 32w1024); - mark_to_drop(standard_metadata); - } - @p4runtime_role("sdn_controller") @id(0x02000044) @name("ingress.routing.ipv4_table") table routing_ipv4_table { - key = { - local_metadata._vrf_id1: exact @id(1) @name("vrf_id") @refers_to(vrf_table , vrf_id); - headers.ipv4.dst_addr : lpm @format(IPV4_ADDRESS) @id(2) @name("ipv4_dst"); - } - actions = { - @proto_id(1) routing_drop_0(); - @proto_id(2) routing_set_nexthop_id_1(); - @proto_id(3) routing_set_wcmp_group_id_0(); - @proto_id(4) routing_trap_0(); - @proto_id(5) routing_set_nexthop_id_and_metadata_0(); - @proto_id(6) routing_set_wcmp_group_id_and_metadata_0(); - } - const default_action = routing_drop_0(); - size = 32768; - } - @p4runtime_role("sdn_controller") @id(0x02000045) @name("ingress.routing.ipv6_table") table routing_ipv6_table { - key = { - local_metadata._vrf_id1: exact @id(1) @name("vrf_id") @refers_to(vrf_table , vrf_id); - headers.ipv6.dst_addr : lpm @format(IPV6_ADDRESS) @id(2) @name("ipv6_dst"); - } - actions = { - @proto_id(1) routing_drop_1(); - @proto_id(2) routing_set_nexthop_id_2(); - @proto_id(3) routing_set_wcmp_group_id_1(); - @proto_id(4) routing_trap_1(); - @proto_id(5) routing_set_nexthop_id_and_metadata_1(); - @proto_id(6) routing_set_wcmp_group_id_and_metadata_1(); - } - const default_action = routing_drop_1(); - size = 4096; - } @id(0x15000101) @name("ingress.acl_wbb_ingress.acl_wbb_ingress_meter") direct_meter>(MeterType.bytes) acl_wbb_ingress_acl_wbb_ingress_meter; @id(0x13000103) @name("ingress.acl_wbb_ingress.acl_wbb_ingress_counter") direct_counter(CounterType.packets_and_bytes) acl_wbb_ingress_acl_wbb_ingress_counter; @id(0x01000107) @sai_action(SAI_PACKET_ACTION_COPY) @name("ingress.acl_wbb_ingress.acl_wbb_ingress_copy") action acl_wbb_ingress_acl_wbb_ingress_copy_0() { - acl_wbb_ingress_acl_wbb_ingress_meter.read(local_metadata._color18); - clone(CloneType.I2E, 32w1024); + acl_wbb_ingress_acl_wbb_ingress_meter.read(local_metadata._color32); + clone(CloneType.I2E, 32w255); acl_wbb_ingress_acl_wbb_ingress_counter.count(); } @id(0x01000108) @sai_action(SAI_PACKET_ACTION_TRAP) @name("ingress.acl_wbb_ingress.acl_wbb_ingress_trap") action acl_wbb_ingress_acl_wbb_ingress_trap_0() { - acl_wbb_ingress_acl_wbb_ingress_meter.read(local_metadata._color18); - clone(CloneType.I2E, 32w1024); + acl_wbb_ingress_acl_wbb_ingress_meter.read(local_metadata._color32); + clone(CloneType.I2E, 32w255); mark_to_drop(standard_metadata); acl_wbb_ingress_acl_wbb_ingress_counter.count(); } @@ -538,201 +278,75 @@ control ingress(inout headers_t headers, inout local_metadata_t local_metadata, actions = { @proto_id(1) acl_wbb_ingress_acl_wbb_ingress_copy_0(); @proto_id(2) acl_wbb_ingress_acl_wbb_ingress_trap_0(); - @defaultonly NoAction_6(); + @defaultonly NoAction_1(); } - const default_action = NoAction_6(); + const default_action = NoAction_1(); meters = acl_wbb_ingress_acl_wbb_ingress_meter; counters = acl_wbb_ingress_acl_wbb_ingress_counter; size = 8; } - @id(0x01000007) @name("ingress.mirroring_clone.mirror_as_ipv4_erspan") action mirroring_clone_mirror_as_ipv4_erspan_0(@id(1) @name("port") bit<9> port_2, @id(2) @format(IPV4_ADDRESS) @name("src_ip") bit<32> src_ip, @id(3) @format(IPV4_ADDRESS) @name("dst_ip") bit<32> dst_ip, @id(4) @format(MAC_ADDRESS) @name("src_mac") bit<48> src_mac_3, @id(5) @format(MAC_ADDRESS) @name("dst_mac") bit<48> dst_mac_3, @id(6) @name("ttl") bit<8> ttl_0, @id(7) @name("tos") bit<8> tos) { - mirroring_clone_mirror_port = port_2; - local_metadata._mirroring_src_ip12 = src_ip; - local_metadata._mirroring_dst_ip13 = dst_ip; - local_metadata._mirroring_src_mac14 = src_mac_3; - local_metadata._mirroring_dst_mac15 = dst_mac_3; - local_metadata._mirroring_ttl16 = ttl_0; - local_metadata._mirroring_tos17 = tos; - } - @p4runtime_role("sdn_controller") @id(0x02000046) @name("ingress.mirroring_clone.mirror_session_table") table mirroring_clone_mirror_session_table { - key = { - local_metadata._mirror_session_id_value11: exact @id(1) @name("mirror_session_id"); - } - actions = { - @proto_id(1) mirroring_clone_mirror_as_ipv4_erspan_0(); - @defaultonly NoAction_7(); - } - const default_action = NoAction_7(); - size = 2; - } - @id(0x01000009) @name("ingress.mirroring_clone.set_pre_session") action mirroring_clone_set_pre_session_0(@name("id") bit<32> id) { - mirroring_clone_pre_session = id; - } - @p4runtime_role("packet_replication_engine_manager") @id(0x02000048) @name("ingress.mirroring_clone.mirror_port_to_pre_session_table") table mirroring_clone_mirror_port_to_pre_session_table { - key = { - mirroring_clone_mirror_port: exact @id(1) @name("mirror_port"); - } - actions = { - @proto_id(1) mirroring_clone_set_pre_session_0(); - @defaultonly NoAction_8(); - } - const default_action = NoAction_8(); - } - @hidden action pins_wbb262() { - routing_wcmp_group_id_valid = false; - routing_nexthop_id_valid = false; - routing_router_interface_id_valid = false; - routing_neighbor_id_valid = false; - mark_to_drop(standard_metadata); - } - @hidden action pins_wbb608() { + @hidden action pins_wbb325() { acl_wbb_ingress_ttl = headers.ipv4.ttl; } - @hidden action pins_wbb610() { + @hidden action pins_wbb327() { acl_wbb_ingress_ttl = headers.ipv6.hop_limit; } - @hidden action pins_wbb545() { + @hidden action pins_wbb262() { acl_wbb_ingress_ttl = 8w0; } - @hidden action pins_wbb519() { - mark_to_drop(standard_metadata); - } - @hidden action pins_wbb521() { - headers.ipv4.ttl = headers.ipv4.ttl + 8w255; - } - @hidden action pins_wbb526() { - mark_to_drop(standard_metadata); - } - @hidden action pins_wbb528() { - headers.ipv6.hop_limit = headers.ipv6.hop_limit + 8w255; - } - @hidden action pins_wbb486() { - clone_preserving_field_list(CloneType.I2E, mirroring_clone_pre_session, 8w1); - } @hidden table tbl_pins_wbb262 { actions = { pins_wbb262(); } const default_action = pins_wbb262(); } - @hidden table tbl_pins_wbb545 { - actions = { - pins_wbb545(); - } - const default_action = pins_wbb545(); - } - @hidden table tbl_pins_wbb608 { - actions = { - pins_wbb608(); - } - const default_action = pins_wbb608(); - } - @hidden table tbl_pins_wbb610 { - actions = { - pins_wbb610(); - } - const default_action = pins_wbb610(); - } - @hidden table tbl_pins_wbb519 { - actions = { - pins_wbb519(); - } - const default_action = pins_wbb519(); - } - @hidden table tbl_pins_wbb521 { - actions = { - pins_wbb521(); - } - const default_action = pins_wbb521(); - } - @hidden table tbl_pins_wbb526 { - actions = { - pins_wbb526(); - } - const default_action = pins_wbb526(); - } - @hidden table tbl_pins_wbb528 { + @hidden table tbl_pins_wbb325 { actions = { - pins_wbb528(); + pins_wbb325(); } - const default_action = pins_wbb528(); + const default_action = pins_wbb325(); } - @hidden table tbl_pins_wbb486 { + @hidden table tbl_pins_wbb327 { actions = { - pins_wbb486(); + pins_wbb327(); } - const default_action = pins_wbb486(); + const default_action = pins_wbb327(); } apply { - l3_admit_l3_admit_table.apply(); tbl_pins_wbb262.apply(); - routing_vrf_table.apply(); - if (local_metadata._admit_to_l30) { - if (headers.ipv4.isValid()) { - routing_ipv4_table.apply(); - } else if (headers.ipv6.isValid()) { - routing_ipv6_table.apply(); - } - if (routing_wcmp_group_id_valid) { - routing_wcmp_group_table.apply(); - } - if (routing_nexthop_id_valid) { - routing_nexthop_table.apply(); - if (routing_router_interface_id_valid && routing_neighbor_id_valid) { - routing_router_interface_table.apply(); - routing_neighbor_table.apply(); - } - } - } - tbl_pins_wbb545.apply(); if (headers.ipv4.isValid()) { - tbl_pins_wbb608.apply(); + tbl_pins_wbb325.apply(); } else if (headers.ipv6.isValid()) { - tbl_pins_wbb610.apply(); + tbl_pins_wbb327.apply(); } acl_wbb_ingress_acl_wbb_ingress_table.apply(); - if (local_metadata._admit_to_l30) { - if (headers.ipv4.isValid()) { - if (headers.ipv4.ttl <= 8w1) { - tbl_pins_wbb519.apply(); - } else { - tbl_pins_wbb521.apply(); - } - } - if (headers.ipv6.isValid()) { - if (headers.ipv6.hop_limit <= 8w1) { - tbl_pins_wbb526.apply(); - } else { - tbl_pins_wbb528.apply(); - } - } - } - if (local_metadata._mirror_session_id_valid10) { - if (mirroring_clone_mirror_session_table.apply().hit) { - if (mirroring_clone_mirror_port_to_pre_session_table.apply().hit) { - tbl_pins_wbb486.apply(); - } - } - } } } control egress(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { - @hidden action pins_wbb538() { - headers.ethernet.src_addr = local_metadata._packet_rewrites_src_mac2; - headers.ethernet.dst_addr = local_metadata._packet_rewrites_dst_mac3; + apply { } - @hidden table tbl_pins_wbb538 { - actions = { - pins_wbb538(); - } - const default_action = pins_wbb538(); +} + +parser packet_parser(packet_in packet, out headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { + state start { + transition accept; } +} + +control packet_deparser(packet_out packet, in headers_t headers) { + apply { + } +} + +control verify_ipv4_checksum(inout headers_t headers, inout local_metadata_t local_metadata) { + apply { + } +} + +control compute_ipv4_checksum(inout headers_t headers, inout local_metadata_t local_metadata) { apply { - if (local_metadata._admit_to_l30) { - tbl_pins_wbb538.apply(); - } } } -@pkginfo(name="wbb.p4", organization="Google") V1Switch(packet_parser(), verify_ipv4_checksum(), ingress(), egress(), compute_ipv4_checksum(), packet_deparser()) main; +@pkginfo(name="wbb.p4", organization="Google", version="0.0.0") V1Switch(packet_parser(), verify_ipv4_checksum(), ingress(), egress(), compute_ipv4_checksum(), packet_deparser()) main; diff --git a/testdata/p4_16_samples_outputs/pins/pins_wbb.p4 b/testdata/p4_16_samples_outputs/pins/pins_wbb.p4 index 52326aaaae..0c2e3413fe 100644 --- a/testdata/p4_16_samples_outputs/pins/pins_wbb.p4 +++ b/testdata/p4_16_samples_outputs/pins/pins_wbb.p4 @@ -5,10 +5,21 @@ typedef bit<48> ethernet_addr_t; typedef bit<32> ipv4_addr_t; typedef bit<128> ipv6_addr_t; +typedef bit<12> vlan_id_t; +typedef bit<16> ether_type_t; +const vlan_id_t INTERNAL_VLAN_ID = 0xfff; +const vlan_id_t NO_VLAN_ID = 0x0; header ethernet_t { ethernet_addr_t dst_addr; ethernet_addr_t src_addr; - bit<16> ether_type; + ether_type_t ether_type; +} + +header vlan_t { + bit<3> priority_code_point; + bit<1> drop_eligible_indicator; + vlan_id_t vlan_id; + ether_type_t ether_type; } header ipv4_t { @@ -65,6 +76,7 @@ header icmp_t { bit<8> type; bit<8> code; bit<16> checksum; + bit<32> rest_of_header; } header arp_t { @@ -92,453 +104,150 @@ header gre_t { bit<16> protocol; } +header ipfix_t { + bit<16> version_number; + bit<16> length; + bit<32> export_time; + bit<32> sequence_number; + bit<32> observation_domain_id; +} + +header psamp_extended_t { + bit<16> template_id; + bit<16> length; + bit<64> observation_time; + bit<16> flowset; + bit<16> next_hop_index; + bit<16> epoch; + bit<16> ingress_port; + bit<16> egress_port; + bit<16> user_meta_field; + bit<8> dlb_id; + bit<8> variable_length; + bit<16> packet_sampled_length; +} + enum bit<8> PreservedFieldList { - CLONE_I2E = 8w1 + MIRROR_AND_PACKET_IN_COPY = 8w1, + RECIRCULATE = 8w2 } type bit<10> nexthop_id_t; type bit<10> tunnel_id_t; type bit<12> wcmp_group_id_t; -type bit<10> vrf_id_t; +@p4runtime_translation_mappings({ { "" , 0 } , }) type bit<10> vrf_id_t; const vrf_id_t kDefaultVrf = 0; type bit<10> router_interface_id_t; type bit<9> port_id_t; type bit<10> mirror_session_id_t; type bit<8> qos_queue_t; typedef bit<6> route_metadata_t; +typedef bit<8> acl_metadata_t; +typedef bit<16> multicast_group_id_t; +typedef bit<16> replica_instance_t; enum bit<2> MeterColor_t { GREEN = 0, YELLOW = 1, RED = 2 } +@controller_header("packet_in") header packet_in_header_t { + @id(1) + port_id_t ingress_port; + @id(2) + port_id_t target_egress_port; +} + +@controller_header("packet_out") header packet_out_header_t { + @id(1) + port_id_t egress_port; + @id(2) + bit<1> submit_to_ingress; + @id(3) @padding + bit<6> unused_pad; +} + struct headers_t { - ethernet_t erspan_ethernet; - ipv4_t erspan_ipv4; - gre_t erspan_gre; - ethernet_t ethernet; - ipv6_t tunnel_encap_ipv6; - gre_t tunnel_encap_gre; - ipv4_t ipv4; - ipv6_t ipv6; - icmp_t icmp; - tcp_t tcp; - udp_t udp; - arp_t arp; + packet_out_header_t packet_out_header; + ethernet_t mirror_encap_ethernet; + vlan_t mirror_encap_vlan; + ipv6_t mirror_encap_ipv6; + udp_t mirror_encap_udp; + ipfix_t ipfix; + psamp_extended_t psamp_extended; + ethernet_t ethernet; + vlan_t vlan; + ipv6_t tunnel_encap_ipv6; + gre_t tunnel_encap_gre; + ipv4_t ipv4; + ipv6_t ipv6; + ipv4_t inner_ipv4; + ipv6_t inner_ipv6; + icmp_t icmp; + tcp_t tcp; + udp_t udp; + arp_t arp; } struct packet_rewrites_t { ethernet_addr_t src_mac; ethernet_addr_t dst_mac; + vlan_id_t vlan_id; } struct local_metadata_t { + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + bool enable_vlan_checks; + vlan_id_t vlan_id; bool admit_to_l3; vrf_id_t vrf_id; + bool enable_decrement_ttl; + bool enable_src_mac_rewrite; + bool enable_dst_mac_rewrite; + bool enable_vlan_rewrite; packet_rewrites_t packet_rewrites; bit<16> l4_src_port; bit<16> l4_dst_port; - bit<16> wcmp_selector_input; + bit<8> wcmp_selector_input; + bool apply_tunnel_decap_at_end_of_pre_ingress; bool apply_tunnel_encap_at_egress; ipv6_addr_t tunnel_encap_src_ipv6; ipv6_addr_t tunnel_encap_dst_ipv6; - bool mirror_session_id_valid; - mirror_session_id_t mirror_session_id_value; - @field_list(PreservedFieldList.CLONE_I2E) - ipv4_addr_t mirroring_src_ip; - @field_list(PreservedFieldList.CLONE_I2E) - ipv4_addr_t mirroring_dst_ip; - @field_list(PreservedFieldList.CLONE_I2E) - ethernet_addr_t mirroring_src_mac; - @field_list(PreservedFieldList.CLONE_I2E) - ethernet_addr_t mirroring_dst_mac; - @field_list(PreservedFieldList.CLONE_I2E) - bit<8> mirroring_ttl; - @field_list(PreservedFieldList.CLONE_I2E) - bit<8> mirroring_tos; + bool marked_to_copy; + bool marked_to_mirror; + mirror_session_id_t mirror_session_id; + port_id_t mirror_egress_port; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + ethernet_addr_t mirror_encap_src_mac; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + ethernet_addr_t mirror_encap_dst_mac; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + vlan_id_t mirror_encap_vlan_id; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + ipv6_addr_t mirror_encap_src_ip; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + ipv6_addr_t mirror_encap_dst_ip; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + bit<16> mirror_encap_udp_src_port; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + bit<16> mirror_encap_udp_dst_port; + @field_list(PreservedFieldList.RECIRCULATE) + bit<9> loopback_port; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + bit<9> packet_in_ingress_port; + @field_list(PreservedFieldList.MIRROR_AND_PACKET_IN_COPY) + bit<9> packet_in_target_egress_port; MeterColor_t color; port_id_t ingress_port; route_metadata_t route_metadata; -} - -@controller_header("packet_in") header packet_in_header_t { - @id(1) - port_id_t ingress_port; - @id(2) - port_id_t target_egress_port; -} - -@controller_header("packet_out") header packet_out_header_t { - @id(1) - port_id_t egress_port; - @id(2) - bit<1> submit_to_ingress; - @id(3) - bit<7> unused_pad; -} - -parser packet_parser(packet_in packet, out headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { - state start { - local_metadata.admit_to_l3 = false; - local_metadata.vrf_id = kDefaultVrf; - local_metadata.packet_rewrites.src_mac = 0; - local_metadata.packet_rewrites.dst_mac = 0; - local_metadata.l4_src_port = 0; - local_metadata.l4_dst_port = 0; - local_metadata.wcmp_selector_input = 0; - local_metadata.mirror_session_id_valid = false; - local_metadata.color = MeterColor_t.GREEN; - local_metadata.ingress_port = (port_id_t)standard_metadata.ingress_port; - local_metadata.route_metadata = 0; - transition parse_ethernet; - } - state parse_ethernet { - packet.extract(headers.ethernet); - transition select(headers.ethernet.ether_type) { - 0x800: parse_ipv4; - 0x86dd: parse_ipv6; - 0x806: parse_arp; - default: accept; - } - } - state parse_ipv4 { - packet.extract(headers.ipv4); - transition select(headers.ipv4.protocol) { - 0x1: parse_icmp; - 0x6: parse_tcp; - 0x11: parse_udp; - default: accept; - } - } - state parse_ipv6 { - packet.extract(headers.ipv6); - transition select(headers.ipv6.next_header) { - 0x3a: parse_icmp; - 0x6: parse_tcp; - 0x11: parse_udp; - default: accept; - } - } - state parse_tcp { - packet.extract(headers.tcp); - local_metadata.l4_src_port = headers.tcp.src_port; - local_metadata.l4_dst_port = headers.tcp.dst_port; - transition accept; - } - state parse_udp { - packet.extract(headers.udp); - local_metadata.l4_src_port = headers.udp.src_port; - local_metadata.l4_dst_port = headers.udp.dst_port; - transition accept; - } - state parse_icmp { - packet.extract(headers.icmp); - transition accept; - } - state parse_arp { - packet.extract(headers.arp); - transition accept; - } -} - -control packet_deparser(packet_out packet, in headers_t headers) { - apply { - packet.emit(headers.erspan_ethernet); - packet.emit(headers.erspan_ipv4); - packet.emit(headers.erspan_gre); - packet.emit(headers.ethernet); - packet.emit(headers.tunnel_encap_ipv6); - packet.emit(headers.tunnel_encap_gre); - packet.emit(headers.ipv4); - packet.emit(headers.ipv6); - packet.emit(headers.arp); - packet.emit(headers.icmp); - packet.emit(headers.tcp); - packet.emit(headers.udp); - } -} - -control routing(in headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { - bool wcmp_group_id_valid = false; - wcmp_group_id_t wcmp_group_id_value; - bool nexthop_id_valid = false; - nexthop_id_t nexthop_id_value; - bool router_interface_id_valid = false; - router_interface_id_t router_interface_id_value; - bool neighbor_id_valid = false; - ipv6_addr_t neighbor_id_value; - @id(0x01000001) action set_dst_mac(@id(1) @format(MAC_ADDRESS) ethernet_addr_t dst_mac) { - local_metadata.packet_rewrites.dst_mac = dst_mac; - } - @p4runtime_role("sdn_controller") @id(0x02000040) table neighbor_table { - key = { - router_interface_id_value: exact @id(1) @name("router_interface_id") @refers_to(router_interface_table , router_interface_id); - neighbor_id_value : exact @id(2) @format(IPV6_ADDRESS) @name("neighbor_id"); - } - actions = { - @proto_id(1) set_dst_mac; - @defaultonly NoAction; - } - const default_action = NoAction; - size = 1024; - } - @id(0x01000002) action set_port_and_src_mac(@id(1) port_id_t port, @id(2) @format(MAC_ADDRESS) ethernet_addr_t src_mac) { - standard_metadata.egress_spec = (bit<9>)port; - local_metadata.packet_rewrites.src_mac = src_mac; - } - @p4runtime_role("sdn_controller") @id(0x02000041) table router_interface_table { - key = { - router_interface_id_value: exact @id(1) @name("router_interface_id"); - } - actions = { - @proto_id(1) set_port_and_src_mac; - @defaultonly NoAction; - } - const default_action = NoAction; - size = 256; - } - @id(0x01000014) action set_ip_nexthop(@id(1) @refers_to(router_interface_table , router_interface_id) @refers_to(neighbor_table , router_interface_id) router_interface_id_t router_interface_id, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) ipv6_addr_t neighbor_id) { - router_interface_id_valid = true; - router_interface_id_value = router_interface_id; - neighbor_id_valid = true; - neighbor_id_value = neighbor_id; - } - @id(0x01000003) @deprecated("Use set_ip_nexthop instead.") action set_nexthop(@id(1) @refers_to(router_interface_table , router_interface_id) @refers_to(neighbor_table , router_interface_id) router_interface_id_t router_interface_id, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) ipv6_addr_t neighbor_id) { - set_ip_nexthop(router_interface_id, neighbor_id); - } - @p4runtime_role("sdn_controller") @id(0x02000042) table nexthop_table { - key = { - nexthop_id_value: exact @id(1) @name("nexthop_id"); - } - actions = { - @proto_id(1) set_nexthop; - @proto_id(3) set_ip_nexthop; - @defaultonly NoAction; - } - const default_action = NoAction; - size = 1024; - } - @id(0x01000005) action set_nexthop_id(@id(1) @refers_to(nexthop_table , nexthop_id) nexthop_id_t nexthop_id) { - nexthop_id_valid = true; - nexthop_id_value = nexthop_id; - } - @id(0x01000010) action set_nexthop_id_and_metadata(@id(1) @refers_to(nexthop_table , nexthop_id) nexthop_id_t nexthop_id, route_metadata_t route_metadata) { - nexthop_id_valid = true; - nexthop_id_value = nexthop_id; - local_metadata.route_metadata = route_metadata; - } - @max_group_size(256) action_selector(HashAlgorithm.identity, 65536, 16) wcmp_group_selector; - @p4runtime_role("sdn_controller") @id(0x02000043) @oneshot table wcmp_group_table { - key = { - wcmp_group_id_value : exact @id(1) @name("wcmp_group_id"); - local_metadata.wcmp_selector_input: selector; - } - actions = { - @proto_id(1) set_nexthop_id; - @defaultonly NoAction; - } - const default_action = NoAction; - @id(0x11DC4EC8) implementation = wcmp_group_selector; - size = 3968; - } - action no_action() { - } - @entry_restriction(" - // The VRF ID 0 (or '' in P4Runtime) encodes the default VRF, which cannot - // be read or written via this table, but is always present implicitly. - // TODO: This constraint should read `vrf_id != ''` (since - // constraints are a control plane (P4Runtime) concept), but - // p4-constraints does not currently support strings. - vrf_id != 0; - ") @p4runtime_role("sdn_controller") @id(0x0200004A) table vrf_table { - key = { - local_metadata.vrf_id: exact @id(1) @name("vrf_id"); - } - actions = { - @proto_id(1) no_action; - } - const default_action = no_action; - size = 64; - } - @id(0x01000006) action drop() { - mark_to_drop(standard_metadata); - } - @id(0x01000004) action set_wcmp_group_id(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) wcmp_group_id_t wcmp_group_id) { - wcmp_group_id_valid = true; - wcmp_group_id_value = wcmp_group_id; - } - @id(0x01000011) action set_wcmp_group_id_and_metadata(@id(1) @refers_to(wcmp_group_table , wcmp_group_id) wcmp_group_id_t wcmp_group_id, route_metadata_t route_metadata) { - set_wcmp_group_id(wcmp_group_id); - local_metadata.route_metadata = route_metadata; - } - @id(0x0100000F) action trap() { - clone(CloneType.I2E, 1024); - mark_to_drop(standard_metadata); - } - @p4runtime_role("sdn_controller") @id(0x02000044) table ipv4_table { - key = { - local_metadata.vrf_id: exact @id(1) @name("vrf_id") @refers_to(vrf_table , vrf_id); - headers.ipv4.dst_addr: lpm @format(IPV4_ADDRESS) @id(2) @name("ipv4_dst"); - } - actions = { - @proto_id(1) drop; - @proto_id(2) set_nexthop_id; - @proto_id(3) set_wcmp_group_id; - @proto_id(4) trap; - @proto_id(5) set_nexthop_id_and_metadata; - @proto_id(6) set_wcmp_group_id_and_metadata; - } - const default_action = drop; - size = 32768; - } - @p4runtime_role("sdn_controller") @id(0x02000045) table ipv6_table { - key = { - local_metadata.vrf_id: exact @id(1) @name("vrf_id") @refers_to(vrf_table , vrf_id); - headers.ipv6.dst_addr: lpm @format(IPV6_ADDRESS) @id(2) @name("ipv6_dst"); - } - actions = { - @proto_id(1) drop; - @proto_id(2) set_nexthop_id; - @proto_id(3) set_wcmp_group_id; - @proto_id(4) trap; - @proto_id(5) set_nexthop_id_and_metadata; - @proto_id(6) set_wcmp_group_id_and_metadata; - } - const default_action = drop; - size = 4096; - } - apply { - mark_to_drop(standard_metadata); - vrf_table.apply(); - if (local_metadata.admit_to_l3) { - if (headers.ipv4.isValid()) { - ipv4_table.apply(); - } else if (headers.ipv6.isValid()) { - ipv6_table.apply(); - } - if (wcmp_group_id_valid) { - wcmp_group_table.apply(); - } - if (nexthop_id_valid) { - nexthop_table.apply(); - if (router_interface_id_valid && neighbor_id_valid) { - router_interface_table.apply(); - neighbor_table.apply(); - } - } - } - } -} - -control verify_ipv4_checksum(inout headers_t headers, inout local_metadata_t local_metadata) { - apply { - verify_checksum(headers.ipv4.isValid(), { headers.ipv4.version, headers.ipv4.ihl, headers.ipv4.dscp, headers.ipv4.ecn, headers.ipv4.total_len, headers.ipv4.identification, headers.ipv4.reserved, headers.ipv4.do_not_fragment, headers.ipv4.more_fragments, headers.ipv4.frag_offset, headers.ipv4.ttl, headers.ipv4.protocol, headers.ipv4.src_addr, headers.ipv4.dst_addr }, headers.ipv4.header_checksum, HashAlgorithm.csum16); - } -} - -control compute_ipv4_checksum(inout headers_t headers, inout local_metadata_t local_metadata) { - apply { - update_checksum(headers.erspan_ipv4.isValid(), { headers.erspan_ipv4.version, headers.erspan_ipv4.ihl, headers.erspan_ipv4.dscp, headers.erspan_ipv4.ecn, headers.erspan_ipv4.total_len, headers.erspan_ipv4.identification, headers.erspan_ipv4.reserved, headers.erspan_ipv4.do_not_fragment, headers.erspan_ipv4.more_fragments, headers.erspan_ipv4.frag_offset, headers.erspan_ipv4.ttl, headers.erspan_ipv4.protocol, headers.erspan_ipv4.src_addr, headers.erspan_ipv4.dst_addr }, headers.erspan_ipv4.header_checksum, HashAlgorithm.csum16); - update_checksum(headers.ipv4.isValid(), { headers.ipv4.version, headers.ipv4.ihl, headers.ipv4.dscp, headers.ipv4.ecn, headers.ipv4.total_len, headers.ipv4.identification, headers.ipv4.reserved, headers.ipv4.do_not_fragment, headers.ipv4.more_fragments, headers.ipv4.frag_offset, headers.ipv4.ttl, headers.ipv4.protocol, headers.ipv4.src_addr, headers.ipv4.dst_addr }, headers.ipv4.header_checksum, HashAlgorithm.csum16); - } -} - -control mirroring_clone(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { - port_id_t mirror_port; - bit<32> pre_session; - @id(0x01000007) action mirror_as_ipv4_erspan(@id(1) port_id_t port, @id(2) @format(IPV4_ADDRESS) ipv4_addr_t src_ip, @id(3) @format(IPV4_ADDRESS) ipv4_addr_t dst_ip, @id(4) @format(MAC_ADDRESS) ethernet_addr_t src_mac, @id(5) @format(MAC_ADDRESS) ethernet_addr_t dst_mac, @id(6) bit<8> ttl, @id(7) bit<8> tos) { - mirror_port = port; - local_metadata.mirroring_src_ip = src_ip; - local_metadata.mirroring_dst_ip = dst_ip; - local_metadata.mirroring_src_mac = src_mac; - local_metadata.mirroring_dst_mac = dst_mac; - local_metadata.mirroring_ttl = ttl; - local_metadata.mirroring_tos = tos; - } - @p4runtime_role("sdn_controller") @id(0x02000046) table mirror_session_table { - key = { - local_metadata.mirror_session_id_value: exact @id(1) @name("mirror_session_id"); - } - actions = { - @proto_id(1) mirror_as_ipv4_erspan; - @defaultonly NoAction; - } - const default_action = NoAction; - size = 2; - } - @id(0x01000009) action set_pre_session(bit<32> id) { - pre_session = id; - } - @p4runtime_role("packet_replication_engine_manager") @id(0x02000048) table mirror_port_to_pre_session_table { - key = { - mirror_port: exact @id(1); - } - actions = { - @proto_id(1) set_pre_session; - @defaultonly NoAction; - } - const default_action = NoAction; - } - apply { - if (local_metadata.mirror_session_id_valid) { - if (mirror_session_table.apply().hit) { - if (mirror_port_to_pre_session_table.apply().hit) { - clone_preserving_field_list(CloneType.I2E, pre_session, (bit<8>)PreservedFieldList.CLONE_I2E); - } - } - } - } -} - -control l3_admit(in headers_t headers, inout local_metadata_t local_metadata, in standard_metadata_t standard_metadata) { - @id(0x01000008) action admit_to_l3() { - local_metadata.admit_to_l3 = true; - } - @p4runtime_role("sdn_controller") @id(0x02000047) table l3_admit_table { - key = { - headers.ethernet.dst_addr : ternary @name("dst_mac") @id(1) @format(MAC_ADDRESS); - local_metadata.ingress_port: optional @name("in_port") @id(2); - } - actions = { - @proto_id(1) admit_to_l3; - @defaultonly NoAction; - } - const default_action = NoAction; - size = 128; - } - apply { - l3_admit_table.apply(); - } -} - -control ttl(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { - apply { - if (local_metadata.admit_to_l3) { - if (headers.ipv4.isValid()) { - if (headers.ipv4.ttl <= 1) { - mark_to_drop(standard_metadata); - } else { - headers.ipv4.ttl = headers.ipv4.ttl - 1; - } - } - if (headers.ipv6.isValid()) { - if (headers.ipv6.hop_limit <= 1) { - mark_to_drop(standard_metadata); - } else { - headers.ipv6.hop_limit = headers.ipv6.hop_limit - 1; - } - } - } - } -} - -control packet_rewrites(inout headers_t headers, in local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { - apply { - if (local_metadata.admit_to_l3) { - headers.ethernet.src_addr = local_metadata.packet_rewrites.src_mac; - headers.ethernet.dst_addr = local_metadata.packet_rewrites.dst_mac; - } - } + acl_metadata_t acl_metadata; + bool bypass_ingress; + bool wcmp_group_id_valid; + wcmp_group_id_t wcmp_group_id_value; + bool nexthop_id_valid; + nexthop_id_t nexthop_id_value; + bool ipmc_table_hit; + bool acl_drop; } control acl_wbb_ingress(in headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { @@ -547,12 +256,12 @@ control acl_wbb_ingress(in headers_t headers, inout local_metadata_t local_metad @id(0x13000103) direct_counter(CounterType.packets_and_bytes) acl_wbb_ingress_counter; @id(0x01000107) @sai_action(SAI_PACKET_ACTION_COPY) action acl_wbb_ingress_copy() { acl_wbb_ingress_meter.read(local_metadata.color); - clone(CloneType.I2E, 1024); + clone(CloneType.I2E, 255); acl_wbb_ingress_counter.count(); } @id(0x01000108) @sai_action(SAI_PACKET_ACTION_TRAP) action acl_wbb_ingress_trap() { acl_wbb_ingress_meter.read(local_metadata.color); - clone(CloneType.I2E, 1024); + clone(CloneType.I2E, 255); mark_to_drop(standard_metadata); acl_wbb_ingress_counter.count(); } @@ -615,18 +324,34 @@ control acl_wbb_ingress(in headers_t headers, inout local_metadata_t local_metad control ingress(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { apply { - l3_admit.apply(headers, local_metadata, standard_metadata); - routing.apply(headers, local_metadata, standard_metadata); acl_wbb_ingress.apply(headers, local_metadata, standard_metadata); - ttl.apply(headers, local_metadata, standard_metadata); - mirroring_clone.apply(headers, local_metadata, standard_metadata); } } control egress(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { apply { - packet_rewrites.apply(headers, local_metadata, standard_metadata); } } -@pkginfo(name="wbb.p4", organization="Google") V1Switch(packet_parser(), verify_ipv4_checksum(), ingress(), egress(), compute_ipv4_checksum(), packet_deparser()) main; +parser packet_parser(packet_in packet, out headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { + state start { + transition accept; + } +} + +control packet_deparser(packet_out packet, in headers_t headers) { + apply { + } +} + +control verify_ipv4_checksum(inout headers_t headers, inout local_metadata_t local_metadata) { + apply { + } +} + +control compute_ipv4_checksum(inout headers_t headers, inout local_metadata_t local_metadata) { + apply { + } +} + +@pkginfo(name="wbb.p4", organization="Google", version="0.0.0") V1Switch(packet_parser(), verify_ipv4_checksum(), ingress(), egress(), compute_ipv4_checksum(), packet_deparser()) main; diff --git a/testdata/p4_16_samples_outputs/pins/pins_wbb.p4-stderr b/testdata/p4_16_samples_outputs/pins/pins_wbb.p4-stderr index 804ed768c6..e69de29bb2 100644 --- a/testdata/p4_16_samples_outputs/pins/pins_wbb.p4-stderr +++ b/testdata/p4_16_samples_outputs/pins/pins_wbb.p4-stderr @@ -1,33 +0,0 @@ -pins_wbb.p4(545): [--Wwarn=shadow] warning: 'ttl' shadows 'control ttl' - bit<8> ttl = 0; - ^^^^^^^^^^^^^^ -pins_wbb.p4(514) -control ttl(inout headers_t headers, inout local_metadata_t local_metadata, inout standard_metadata_t standard_metadata) { - ^^^ -pins_wbb.p4(314): [--Wwarn=deprecated] warning: set_nexthop: Using deprecated feature set_nexthop. Use set_ip_nexthop instead. - @proto_id(1) set_nexthop; - ^^^^^^^^^^^ -pins_wbb.p4(306) - @id(0x01000003) @deprecated("Use set_ip_nexthop instead.") action set_nexthop(@id(1) @refers_to(router_interface_table , router_interface_id) @refers_to(neighbor_table , router_interface_id) router_interface_id_t router_interface_id, @id(2) @format(IPV6_ADDRESS) @refers_to(neighbor_table , neighbor_id) ipv6_addr_t neighbor_id) { - ^^^^^^^^^^^ -pins_wbb.p4(333): [--Wwarn=uninitialized_use] warning: wcmp_group_id_value may not be completely initialized - wcmp_group_id_value : exact @id(1) @name("wcmp_group_id"); - ^^^^^^^^^^^^^^^^^^^ -pins_wbb.p4(311): [--Wwarn=uninitialized_use] warning: nexthop_id_value may not be completely initialized - nexthop_id_value: exact @id(1) @name("nexthop_id"); - ^^^^^^^^^^^^^^^^ -pins_wbb.p4(291): [--Wwarn=uninitialized_use] warning: router_interface_id_value may not be completely initialized - router_interface_id_value: exact @id(1) @name("router_interface_id"); - ^^^^^^^^^^^^^^^^^^^^^^^^^ -pins_wbb.p4(275): [--Wwarn=uninitialized_use] warning: router_interface_id_value may not be completely initialized - router_interface_id_value: exact @id(1) @name("router_interface_id") @refers_to(router_interface_table , router_interface_id); - ^^^^^^^^^^^^^^^^^^^^^^^^^ -pins_wbb.p4(276): [--Wwarn=uninitialized_use] warning: neighbor_id_value may be uninitialized - neighbor_id_value : exact @id(2) @format(IPV6_ADDRESS) @name("neighbor_id"); - ^^^^^^^^^^^^^^^^^ -pins_wbb.p4(474): [--Wwarn=uninitialized_use] warning: mirror_port may not be completely initialized - mirror_port: exact @id(1); - ^^^^^^^^^^^ -pins_wbb.p4(486): [--Wwarn=uninitialized_use] warning: pre_session may be uninitialized - clone_preserving_field_list(CloneType.I2E, pre_session, (bit<8>)PreservedFieldList.CLONE_I2E); - ^^^^^^^^^^^ diff --git a/testdata/p4_16_samples_outputs/pins/pins_wbb.p4.p4info.txtpb b/testdata/p4_16_samples_outputs/pins/pins_wbb.p4.p4info.txtpb index 380996cec3..cccb2bd1c2 100644 --- a/testdata/p4_16_samples_outputs/pins/pins_wbb.p4.p4info.txtpb +++ b/testdata/p4_16_samples_outputs/pins/pins_wbb.p4.p4info.txtpb @@ -3,296 +3,10 @@ pkg_info { name: "wbb.p4" + version: "0.0.0" arch: "v1model" organization: "Google" } -tables { - preamble { - id: 33554503 - name: "ingress.l3_admit.l3_admit_table" - alias: "l3_admit_table" - annotations: "@p4runtime_role(\"sdn_controller\")" - } - match_fields { - id: 1 - name: "dst_mac" - annotations: "@format(MAC_ADDRESS)" - bitwidth: 48 - match_type: TERNARY - } - match_fields { - id: 2 - name: "in_port" - bitwidth: 9 - match_type: OPTIONAL - type_name { - name: "port_id_t" - } - } - action_refs { - id: 16777224 - annotations: "@proto_id(1)" - } - action_refs { - id: 21257015 - annotations: "@defaultonly" - scope: DEFAULT_ONLY - } - const_default_action_id: 21257015 - size: 128 -} -tables { - preamble { - id: 33554496 - name: "ingress.routing.neighbor_table" - alias: "neighbor_table" - annotations: "@p4runtime_role(\"sdn_controller\")" - } - match_fields { - id: 1 - name: "router_interface_id" - annotations: "@refers_to(router_interface_table , router_interface_id)" - bitwidth: 10 - match_type: EXACT - type_name { - name: "router_interface_id_t" - } - } - match_fields { - id: 2 - name: "neighbor_id" - annotations: "@format(IPV6_ADDRESS)" - bitwidth: 128 - match_type: EXACT - } - action_refs { - id: 16777217 - annotations: "@proto_id(1)" - } - action_refs { - id: 21257015 - annotations: "@defaultonly" - scope: DEFAULT_ONLY - } - const_default_action_id: 21257015 - size: 1024 -} -tables { - preamble { - id: 33554497 - name: "ingress.routing.router_interface_table" - alias: "router_interface_table" - annotations: "@p4runtime_role(\"sdn_controller\")" - } - match_fields { - id: 1 - name: "router_interface_id" - bitwidth: 10 - match_type: EXACT - type_name { - name: "router_interface_id_t" - } - } - action_refs { - id: 16777218 - annotations: "@proto_id(1)" - } - action_refs { - id: 21257015 - annotations: "@defaultonly" - scope: DEFAULT_ONLY - } - const_default_action_id: 21257015 - size: 256 -} -tables { - preamble { - id: 33554498 - name: "ingress.routing.nexthop_table" - alias: "nexthop_table" - annotations: "@p4runtime_role(\"sdn_controller\")" - } - match_fields { - id: 1 - name: "nexthop_id" - bitwidth: 10 - match_type: EXACT - type_name { - name: "nexthop_id_t" - } - } - action_refs { - id: 16777219 - annotations: "@proto_id(1)" - } - action_refs { - id: 16777236 - annotations: "@proto_id(3)" - } - action_refs { - id: 21257015 - annotations: "@defaultonly" - scope: DEFAULT_ONLY - } - const_default_action_id: 21257015 - size: 1024 -} -tables { - preamble { - id: 33554499 - name: "ingress.routing.wcmp_group_table" - alias: "wcmp_group_table" - annotations: "@p4runtime_role(\"sdn_controller\")" - annotations: "@oneshot" - } - match_fields { - id: 1 - name: "wcmp_group_id" - bitwidth: 12 - match_type: EXACT - type_name { - name: "wcmp_group_id_t" - } - } - action_refs { - id: 16777221 - annotations: "@proto_id(1)" - } - action_refs { - id: 21257015 - annotations: "@defaultonly" - scope: DEFAULT_ONLY - } - const_default_action_id: 21257015 - implementation_id: 299650760 - size: 3968 -} -tables { - preamble { - id: 33554506 - name: "ingress.routing.vrf_table" - alias: "vrf_table" - annotations: "@entry_restriction(\"\n // The VRF ID 0 (or \'\' in P4Runtime) encodes the default VRF, which cannot\n // be read or written via this table, but is always present implicitly.\n // TODO: This constraint should read `vrf_id != \'\'` (since\n // constraints are a control plane (P4Runtime) concept), but\n // p4-constraints does not currently support strings.\n vrf_id != 0;\n \")" - annotations: "@p4runtime_role(\"sdn_controller\")" - } - match_fields { - id: 1 - name: "vrf_id" - bitwidth: 10 - match_type: EXACT - type_name { - name: "vrf_id_t" - } - } - action_refs { - id: 24742814 - annotations: "@proto_id(1)" - } - const_default_action_id: 24742814 - size: 64 -} -tables { - preamble { - id: 33554500 - name: "ingress.routing.ipv4_table" - alias: "ipv4_table" - annotations: "@p4runtime_role(\"sdn_controller\")" - } - match_fields { - id: 1 - name: "vrf_id" - annotations: "@refers_to(vrf_table , vrf_id)" - bitwidth: 10 - match_type: EXACT - type_name { - name: "vrf_id_t" - } - } - match_fields { - id: 2 - name: "ipv4_dst" - annotations: "@format(IPV4_ADDRESS)" - bitwidth: 32 - match_type: LPM - } - action_refs { - id: 16777222 - annotations: "@proto_id(1)" - } - action_refs { - id: 16777221 - annotations: "@proto_id(2)" - } - action_refs { - id: 16777220 - annotations: "@proto_id(3)" - } - action_refs { - id: 16777231 - annotations: "@proto_id(4)" - } - action_refs { - id: 16777232 - annotations: "@proto_id(5)" - } - action_refs { - id: 16777233 - annotations: "@proto_id(6)" - } - const_default_action_id: 16777222 - size: 32768 -} -tables { - preamble { - id: 33554501 - name: "ingress.routing.ipv6_table" - alias: "ipv6_table" - annotations: "@p4runtime_role(\"sdn_controller\")" - } - match_fields { - id: 1 - name: "vrf_id" - annotations: "@refers_to(vrf_table , vrf_id)" - bitwidth: 10 - match_type: EXACT - type_name { - name: "vrf_id_t" - } - } - match_fields { - id: 2 - name: "ipv6_dst" - annotations: "@format(IPV6_ADDRESS)" - bitwidth: 128 - match_type: LPM - } - action_refs { - id: 16777222 - annotations: "@proto_id(1)" - } - action_refs { - id: 16777221 - annotations: "@proto_id(2)" - } - action_refs { - id: 16777220 - annotations: "@proto_id(3)" - } - action_refs { - id: 16777231 - annotations: "@proto_id(4)" - } - action_refs { - id: 16777232 - annotations: "@proto_id(5)" - } - action_refs { - id: 16777233 - annotations: "@proto_id(6)" - } - const_default_action_id: 16777222 - size: 4096 -} tables { preamble { id: 33554691 @@ -355,62 +69,6 @@ tables { direct_resource_ids: 352321793 size: 8 } -tables { - preamble { - id: 33554502 - name: "ingress.mirroring_clone.mirror_session_table" - alias: "mirror_session_table" - annotations: "@p4runtime_role(\"sdn_controller\")" - } - match_fields { - id: 1 - name: "mirror_session_id" - bitwidth: 10 - match_type: EXACT - type_name { - name: "mirror_session_id_t" - } - } - action_refs { - id: 16777223 - annotations: "@proto_id(1)" - } - action_refs { - id: 21257015 - annotations: "@defaultonly" - scope: DEFAULT_ONLY - } - const_default_action_id: 21257015 - size: 2 -} -tables { - preamble { - id: 33554504 - name: "ingress.mirroring_clone.mirror_port_to_pre_session_table" - alias: "mirror_port_to_pre_session_table" - annotations: "@p4runtime_role(\"packet_replication_engine_manager\")" - } - match_fields { - id: 1 - name: "mirror_port" - bitwidth: 9 - match_type: EXACT - type_name { - name: "port_id_t" - } - } - action_refs { - id: 16777225 - annotations: "@proto_id(1)" - } - action_refs { - id: 21257015 - annotations: "@defaultonly" - scope: DEFAULT_ONLY - } - const_default_action_id: 21257015 - size: 1024 -} actions { preamble { id: 21257015 @@ -419,191 +77,6 @@ actions { annotations: "@noWarn(\"unused\")" } } -actions { - preamble { - id: 16777224 - name: "ingress.l3_admit.admit_to_l3" - alias: "admit_to_l3" - } -} -actions { - preamble { - id: 16777217 - name: "ingress.routing.set_dst_mac" - alias: "set_dst_mac" - } - params { - id: 1 - name: "dst_mac" - annotations: "@format(MAC_ADDRESS)" - bitwidth: 48 - } -} -actions { - preamble { - id: 16777218 - name: "ingress.routing.set_port_and_src_mac" - alias: "set_port_and_src_mac" - } - params { - id: 1 - name: "port" - bitwidth: 9 - type_name { - name: "port_id_t" - } - } - params { - id: 2 - name: "src_mac" - annotations: "@format(MAC_ADDRESS)" - bitwidth: 48 - } -} -actions { - preamble { - id: 16777236 - name: "ingress.routing.set_ip_nexthop" - alias: "set_ip_nexthop" - } - params { - id: 1 - name: "router_interface_id" - annotations: "@refers_to(router_interface_table , router_interface_id)" - annotations: "@refers_to(neighbor_table , router_interface_id)" - bitwidth: 10 - type_name { - name: "router_interface_id_t" - } - } - params { - id: 2 - name: "neighbor_id" - annotations: "@format(IPV6_ADDRESS)" - annotations: "@refers_to(neighbor_table , neighbor_id)" - bitwidth: 128 - } -} -actions { - preamble { - id: 16777219 - name: "ingress.routing.set_nexthop" - alias: "set_nexthop" - annotations: "@deprecated(\"Use set_ip_nexthop instead.\")" - } - params { - id: 1 - name: "router_interface_id" - annotations: "@refers_to(router_interface_table , router_interface_id)" - annotations: "@refers_to(neighbor_table , router_interface_id)" - bitwidth: 10 - type_name { - name: "router_interface_id_t" - } - } - params { - id: 2 - name: "neighbor_id" - annotations: "@format(IPV6_ADDRESS)" - annotations: "@refers_to(neighbor_table , neighbor_id)" - bitwidth: 128 - } -} -actions { - preamble { - id: 16777221 - name: "ingress.routing.set_nexthop_id" - alias: "set_nexthop_id" - } - params { - id: 1 - name: "nexthop_id" - annotations: "@refers_to(nexthop_table , nexthop_id)" - bitwidth: 10 - type_name { - name: "nexthop_id_t" - } - } -} -actions { - preamble { - id: 16777232 - name: "ingress.routing.set_nexthop_id_and_metadata" - alias: "set_nexthop_id_and_metadata" - } - params { - id: 1 - name: "nexthop_id" - annotations: "@refers_to(nexthop_table , nexthop_id)" - bitwidth: 10 - type_name { - name: "nexthop_id_t" - } - } - params { - id: 2 - name: "route_metadata" - bitwidth: 6 - } -} -actions { - preamble { - id: 24742814 - name: "ingress.routing.no_action" - alias: "no_action" - } -} -actions { - preamble { - id: 16777222 - name: "ingress.routing.drop" - alias: "drop" - } -} -actions { - preamble { - id: 16777220 - name: "ingress.routing.set_wcmp_group_id" - alias: "set_wcmp_group_id" - } - params { - id: 1 - name: "wcmp_group_id" - annotations: "@refers_to(wcmp_group_table , wcmp_group_id)" - bitwidth: 12 - type_name { - name: "wcmp_group_id_t" - } - } -} -actions { - preamble { - id: 16777233 - name: "ingress.routing.set_wcmp_group_id_and_metadata" - alias: "set_wcmp_group_id_and_metadata" - } - params { - id: 1 - name: "wcmp_group_id" - annotations: "@refers_to(wcmp_group_table , wcmp_group_id)" - bitwidth: 12 - type_name { - name: "wcmp_group_id_t" - } - } - params { - id: 2 - name: "route_metadata" - bitwidth: 6 - } -} -actions { - preamble { - id: 16777231 - name: "ingress.routing.trap" - alias: "trap" - } -} actions { preamble { id: 16777479 @@ -620,78 +93,6 @@ actions { annotations: "@sai_action(SAI_PACKET_ACTION_TRAP)" } } -actions { - preamble { - id: 16777223 - name: "ingress.mirroring_clone.mirror_as_ipv4_erspan" - alias: "mirror_as_ipv4_erspan" - } - params { - id: 1 - name: "port" - bitwidth: 9 - type_name { - name: "port_id_t" - } - } - params { - id: 2 - name: "src_ip" - annotations: "@format(IPV4_ADDRESS)" - bitwidth: 32 - } - params { - id: 3 - name: "dst_ip" - annotations: "@format(IPV4_ADDRESS)" - bitwidth: 32 - } - params { - id: 4 - name: "src_mac" - annotations: "@format(MAC_ADDRESS)" - bitwidth: 48 - } - params { - id: 5 - name: "dst_mac" - annotations: "@format(MAC_ADDRESS)" - bitwidth: 48 - } - params { - id: 6 - name: "ttl" - bitwidth: 8 - } - params { - id: 7 - name: "tos" - bitwidth: 8 - } -} -actions { - preamble { - id: 16777225 - name: "ingress.mirroring_clone.set_pre_session" - alias: "set_pre_session" - } - params { - id: 1 - name: "id" - bitwidth: 32 - } -} -action_profiles { - preamble { - id: 299650760 - name: "ingress.routing.wcmp_group_selector" - alias: "wcmp_group_selector" - } - table_ids: 33554499 - with_selector: true - size: 65536 - max_group_size: 256 -} direct_counters { preamble { id: 318767363 @@ -761,34 +162,11 @@ controller_packet_metadata { metadata { id: 3 name: "unused_pad" - bitwidth: 7 + annotations: "@padding" + bitwidth: 6 } } type_info { - new_types { - key: "mirror_session_id_t" - value { - original_type { - bitstring { - bit { - bitwidth: 10 - } - } - } - } - } - new_types { - key: "nexthop_id_t" - value { - original_type { - bitstring { - bit { - bitwidth: 10 - } - } - } - } - } new_types { key: "port_id_t" value { @@ -801,40 +179,4 @@ type_info { } } } - new_types { - key: "router_interface_id_t" - value { - original_type { - bitstring { - bit { - bitwidth: 10 - } - } - } - } - } - new_types { - key: "vrf_id_t" - value { - original_type { - bitstring { - bit { - bitwidth: 10 - } - } - } - } - } - new_types { - key: "wcmp_group_id_t" - value { - original_type { - bitstring { - bit { - bitwidth: 12 - } - } - } - } - } }