Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SAIP4] Change SAI ACL field name for the ipmc table hit, Enable support for multicast ACL qualifiers and redirect action, Change route_metadata to ternary, Adding src_ipv6 match field to ipv6_tunnel_termination table, Make default src_mac_rewrite NOT be multicast, Remove acl_forward from mirror_and_redirect, Add support for multicast RIF table & fix support for ACL QoS table, Reduce resource limits for QoS table, Build an API to convert P4Testgen tests to Arriba test vectors & Clean up test_entries library and fix bug in AddDefaultRouteForwardingAllPacketsToGivenPort. #639

Merged
merged 8 commits into from
Oct 21, 2024
Merged
2 changes: 1 addition & 1 deletion p4rt_app/p4runtime/p4info_verification_schema_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,7 @@ class GoogleInstantiationTest

// Tests that P4RT app is always "ahead of" our SAI P4 programs, so we don't
// accidentally expose features in the program that are not yet supported by
// P4RT app/GPINS.
// P4RT app/PINS.
TEST_P(GoogleInstantiationTest, SchemaSupportsInstantiation) {
sai::Instantiation instantiation = GetParam();
pdpi::IrP4Info p4info = sai::GetIrP4Info(instantiation);
Expand Down
1 change: 1 addition & 0 deletions sai_p4/fixed/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ filegroup(
srcs = [
"bitwidths.p4",
"bmv2_intrinsics.h",
"common_actions.p4",
"drop_martians.p4",
"headers.p4",
"ids.h",
Expand Down
14 changes: 14 additions & 0 deletions sai_p4/fixed/common_actions.p4
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#ifndef SAI_FIXED_COMMON_ACTIONS_P4_
#define SAI_FIXED_COMMON_ACTIONS_P4_

#include "ids.h"

// This file lists common actions that may be used by multiple control blocks in
// the fixed pipeline.

// Action that does nothing. Like `NoAction` in `core.p4`, but following
// Google's naming conventions.
@id(SHARED_NO_ACTION_ACTION_ID)
action no_action() {}

#endif // SAI_FIXED_COMMON_ACTIONS_P4_
2 changes: 1 addition & 1 deletion sai_p4/fixed/ids.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
// --- Actions -----------------------------------------------------------------

// IDs of fixed SAI actions (8 most significant bits = 0x01).
#define ROUTING_NO_ACTION_ACTION_ID 0x01798B9E // 24742814
#define SHARED_NO_ACTION_ACTION_ID 0x01798B9E // 24742814
#define ROUTING_SET_DST_MAC_ACTION_ID 0x01000001 // 16777217
#define ROUTING_SET_PORT_AND_SRC_MAC_ACTION_ID 0x01000002 // 16777218
#define ROUTING_SET_PORT_AND_SRC_MAC_AND_VLAN_ID_ACTION_ID \
Expand Down
7 changes: 1 addition & 6 deletions sai_p4/fixed/routing.p4
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define SAI_ROUTING_P4_

#include <v1model.p4>
#include "common_actions.p4"
#include "headers.p4"
#include "metadata.p4"
#include "ids.h"
Expand Down Expand Up @@ -65,12 +66,6 @@ action set_nexthop_id(inout local_metadata_t local_metadata,
control routing_lookup(in headers_t headers,
inout local_metadata_t local_metadata,
inout standard_metadata_t standard_metadata) {
// Action that does nothing. Like `NoAction` in `core.p4`, but following
// Google's naming conventions.
// TODO: Add support for CamlCase actions to the PD generator,
// so we can use `NoAction` throughout.
@id(ROUTING_NO_ACTION_ACTION_ID)
action no_action() {}
// Programming this table does not affect packet forwarding directly -- the
// table performs no actions -- but results in the creation/deletion of VRFs.
// This is a prerequisite to using these VRFs, e.g. in the `ipv4_table` and
Expand Down
3 changes: 3 additions & 0 deletions sai_p4/fixed/tunnel_termination.p4
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ control tunnel_termination_lookup(in headers_t headers,
// Sets `SAI_TUNNEL_TERM_TABLE_ENTRY_ATTR_DST_IP[_MASK]`.
headers.ipv6.dst_addr : ternary
@id(1) @name("dst_ipv6") @format(IPV6_ADDRESS);
// Sets `SAI_TUNNEL_TERM_TABLE_ENTRY_ATTR_SRC_IP[_MASK]`.
headers.ipv6.src_addr : ternary
@id(2) @name("src_ipv6") @format(IPV6_ADDRESS);
}
actions = {
@proto_id(1) mark_for_tunnel_decap_and_set_vrf;
Expand Down
4 changes: 4 additions & 0 deletions sai_p4/instantiations/google/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -407,3 +407,7 @@ cc_test(
],
)

filegroup(
name = "sai_p4",
srcs = glob(["**/*.p4"]) + glob(["**/*.h"]),
)
22 changes: 7 additions & 15 deletions sai_p4/instantiations/google/acl_ingress.p4
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ control acl_ingress(in headers_t headers,
headers.icmp.type : ternary
@id(14) @name("icmp_type")
@sai_field(SAI_ACL_TABLE_ATTR_FIELD_ICMP_TYPE);
local_metadata.route_metadata : optional
local_metadata.route_metadata : ternary
@id(15) @name("route_metadata")
@sai_field(SAI_ACL_TABLE_ATTR_FIELD_ROUTE_DST_USER_META);
#endif
Expand Down Expand Up @@ -454,6 +454,7 @@ control acl_ingress(in headers_t headers,
@id(ACL_INGRESS_REDIRECT_TO_NEXTHOP_ACTION_ID)
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) {

Expand All @@ -466,16 +467,14 @@ control acl_ingress(in headers_t headers,
standard_metadata.mcast_grp = 0;
}

// TODO: Remove `@unsupported` annotation once the switch stack
// supports multicast.
@unsupported
@id(ACL_INGRESS_REDIRECT_TO_IPMC_GROUP_ACTION_ID)
@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;
Expand Down Expand Up @@ -552,18 +551,11 @@ control acl_ingress(in headers_t headers,
@id(5);

local_metadata.vrf_id : optional
@name("vrf_id")
@sai_field(SAI_ACL_TABLE_ATTR_FIELD_VRF_ID)
@id(8)
// TODO: Remove once the switch supports this field.
@unsupported;

@id(8) @name("vrf_id")
@sai_field(SAI_ACL_TABLE_ATTR_FIELD_VRF_ID);
local_metadata.ipmc_table_hit : optional
@name("ipmc_table_hit")
@sai_field(SAI_ACL_TABLE_ATTR_FIELD_IPMC_TABLE_HIT)
@id(9)
// TODO: Remove once the switch supports this field.
@unsupported;
@id(9) @name("ipmc_table_hit")
@sai_field(SAI_ACL_TABLE_ATTR_FIELD_IPMC_NPU_META_DST_HIT);
}
actions = {
@proto_id(4) acl_forward();
Expand Down
25 changes: 16 additions & 9 deletions sai_p4/instantiations/google/fabric_border_router.p4info.pb.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ tables {
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)"
Expand Down Expand Up @@ -644,7 +651,7 @@ tables {
name: "route_metadata"
annotations: "@sai_field(SAI_ACL_TABLE_ATTR_FIELD_ROUTE_DST_USER_META)"
bitwidth: 6
match_type: OPTIONAL
match_type: TERNARY
}
action_refs {
id: 16777484
Expand Down Expand Up @@ -678,7 +685,7 @@ tables {
const_default_action_id: 21257015
direct_resource_ids: 318767367
direct_resource_ids: 352321794
size: 511
size: 255
}
tables {
preamble {
Expand Down Expand Up @@ -1088,6 +1095,13 @@ actions {
annotations: "@noWarn(\"unused\")"
}
}
actions {
preamble {
id: 24742814
name: "no_action"
alias: "no_action"
}
}
actions {
preamble {
id: 16777221
Expand Down Expand Up @@ -1156,13 +1170,6 @@ actions {
alias: "admit_to_l3"
}
}
actions {
preamble {
id: 24742814
name: "ingress.routing_lookup.no_action"
alias: "no_action"
}
}
actions {
preamble {
id: 16777222
Expand Down
28 changes: 17 additions & 11 deletions sai_p4/instantiations/google/middleblock.p4info.pb.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ tables {
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)"
Expand Down Expand Up @@ -587,7 +594,6 @@ tables {
id: 8
name: "vrf_id"
annotations: "@sai_field(SAI_ACL_TABLE_ATTR_FIELD_VRF_ID)"
annotations: "@unsupported"
match_type: OPTIONAL
type_name {
name: "vrf_id_t"
Expand All @@ -596,8 +602,7 @@ tables {
match_fields {
id: 9
name: "ipmc_table_hit"
annotations: "@sai_field(SAI_ACL_TABLE_ATTR_FIELD_IPMC_TABLE_HIT)"
annotations: "@unsupported"
annotations: "@sai_field(SAI_ACL_TABLE_ATTR_FIELD_IPMC_NPU_META_DST_HIT)"
bitwidth: 1
match_type: OPTIONAL
}
Expand Down Expand Up @@ -1045,6 +1050,13 @@ actions {
annotations: "@noWarn(\"unused\")"
}
}
actions {
preamble {
id: 24742814
name: "no_action"
alias: "no_action"
}
}
actions {
preamble {
id: 16777221
Expand Down Expand Up @@ -1113,13 +1125,6 @@ actions {
alias: "admit_to_l3"
}
}
actions {
preamble {
id: 24742814
name: "ingress.routing_lookup.no_action"
alias: "no_action"
}
}
actions {
preamble {
id: 16777222
Expand Down Expand Up @@ -1286,6 +1291,7 @@ actions {
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)"
type_name {
name: "nexthop_id_t"
Expand All @@ -1297,13 +1303,13 @@ actions {
id: 16777491
name: "ingress.acl_ingress.redirect_to_ipmc_group"
alias: "redirect_to_ipmc_group"
annotations: "@unsupported"
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
}
Expand Down
2 changes: 1 addition & 1 deletion sai_p4/instantiations/google/minimum_guaranteed_sizes.p4
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@

#define ACL_TOR_PRE_INGRESS_TABLE_MINIMUM_GUARANTEED_SIZE 127

#define ACL_INGRESS_QOS_TABLE_MINIMUM_GUARANTEED_SIZE 511
#define ACL_INGRESS_QOS_TABLE_MINIMUM_GUARANTEED_SIZE 255

#define ACL_INGRESS_COUNTING_TABLE_MINIMUM_GUARANTEED_SIZE 255

Expand Down
10 changes: 3 additions & 7 deletions sai_p4/instantiations/google/sai_pd.proto
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ message VrfTableEntry {
message Ipv6TunnelTerminationTableEntry {
message Match {
Ternary dst_ipv6 = 1; // ternary match / Format::IPV6 / 128 bits
Ternary src_ipv6 = 2; // ternary match / Format::IPV6 / 128 bits
}
Match match = 1;
message Action {
Expand Down Expand Up @@ -592,8 +593,7 @@ message AclIngressQosTableEntry {
Ternary l4_src_port = 12; // ternary match / Format::HEX_STRING / 16 bits
Ternary acl_metadata = 13; // ternary match / Format::HEX_STRING / 8 bits
Ternary icmp_type = 14; // ternary match / Format::HEX_STRING / 8 bits
Optional route_metadata =
15; // optional match / Format::HEX_STRING / 6 bits
Ternary route_metadata = 15; // ternary match / Format::HEX_STRING / 6 bits
}
Match match = 1;
message Action {
Expand Down Expand Up @@ -744,9 +744,7 @@ message AclIngressMirrorAndRedirectTableEntry {
Ternary dst_ipv6 = 5; // ternary match / Format::IPV6 / upper 64 bits
Ternary acl_metadata = 6; // ternary match / Format::HEX_STRING / 8 bits
Ternary vlan_id = 7; // ternary match / Format::HEX_STRING / 12 bits
// CAUTION: This match field is not (yet) supported.
Optional vrf_id = 8; // optional match / Format::STRING
// CAUTION: This match field is not (yet) supported.
Optional vrf_id = 8; // optional match / Format::STRING
Optional ipmc_table_hit =
9; // optional match / Format::HEX_STRING / 1 bits
Ternary dst_ip = 10; // ternary match / Format::IPV4
Expand All @@ -757,7 +755,6 @@ message AclIngressMirrorAndRedirectTableEntry {
AclForwardAction acl_forward = 4;
AclMirrorAction acl_mirror = 1;
RedirectToNexthopAction redirect_to_nexthop = 2;
// CAUTION: This action is not (yet) supported.
RedirectToIpmcGroupAction redirect_to_ipmc_group = 3;
}
}
Expand Down Expand Up @@ -970,7 +967,6 @@ message RedirectToNexthopAction {
string nexthop_id = 1; // Format::STRING
}

// CAUTION: This action is not (yet) supported.
message RedirectToIpmcGroupAction {
string multicast_group_id = 1; // Format::HEX_STRING / 16 bits
}
Expand Down
3 changes: 2 additions & 1 deletion sai_p4/instantiations/google/test_tools/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ cc_library(
":table_entry_generator_helper",
"//gutil:proto",
"//gutil:status",
"//gutil:testing",
"//p4_pdpi:ir_cc_proto",
"@com_github_google_glog//:glog",
"@com_github_p4lang_p4runtime//:p4info_cc_proto",
Expand All @@ -125,7 +126,7 @@ cc_library(
cc_test(
name = "table_entry_generator_test",
srcs = ["table_entry_generator_test.cc"],
shard_count = 5,
shard_count = 50,
deps = [
":table_entry_generator",
"//gutil:status_matchers",
Expand Down
Loading
Loading