diff --git a/p4_pdpi/p4info_union_lib.cc b/p4_pdpi/p4info_union_lib.cc index 2496f45b..d381189c 100644 --- a/p4_pdpi/p4info_union_lib.cc +++ b/p4_pdpi/p4info_union_lib.cc @@ -14,6 +14,7 @@ #include "p4_pdpi/p4info_union_lib.h" +#include #include #include "absl/algorithm/container.h" @@ -120,7 +121,8 @@ absl::Status AssertTableCompatibility(const p4::config::v1::Table& table1, DiffMessages(table1, table2, /*ignored_fields=*/ {"preamble", "match_fields", "action_refs", - "direct_resource_ids", "other_properties"}); + "direct_resource_ids", "other_properties", + "size"}); diff_result.has_value()) { return absl::InvalidArgumentError(absl::StrCat( "tables were incompatible. Relevant differences: ", *diff_result)); @@ -282,6 +284,9 @@ absl::Status UnionFirstFieldIntoSecondAssertingIdenticalId( "incompatible: ", __func__, GetId(table)); + // Use the max size of any table. + unioned_table.set_size(std::max(unioned_table.size(), table.size())); + // For tables, we union their repeated fields and preambles. RETURN_IF_ERROR(UnionFirstPreambleIntoSecondAssertingIdenticalId( table.preamble(), *unioned_table.mutable_preamble())); diff --git a/sai_p4/instantiations/google/acl_pre_ingress.p4 b/sai_p4/instantiations/google/acl_pre_ingress.p4 index 681dbc40..d37c8b3d 100644 --- a/sai_p4/instantiations/google/acl_pre_ingress.p4 +++ b/sai_p4/instantiations/google/acl_pre_ingress.p4 @@ -8,6 +8,14 @@ #include "roles.h" #include "minimum_guaranteed_sizes.p4" +#if defined(SAI_INSTANTIATION_TOR) +#define ACL_PRE_INGRESS_TABLE_MINIMUM_GUARANTEED_SIZE \ + ACL_TOR_PRE_INGRESS_TABLE_MINIMUM_GUARANTEED_SIZE +#else +#define ACL_PRE_INGRESS_TABLE_MINIMUM_GUARANTEED_SIZE \ + ACL_DEFAULT_PRE_INGRESS_TABLE_MINIMUM_GUARANTEED_SIZE +#endif + control acl_pre_ingress(in headers_t headers, inout local_metadata_t local_metadata, in standard_metadata_t standard_metadata) { diff --git a/sai_p4/instantiations/google/fabric_border_router.p4info.pb.txt b/sai_p4/instantiations/google/fabric_border_router.p4info.pb.txt index fa8285fd..28ffbdac 100644 --- a/sai_p4/instantiations/google/fabric_border_router.p4info.pb.txt +++ b/sai_p4/instantiations/google/fabric_border_router.p4info.pb.txt @@ -93,7 +93,7 @@ tables { } const_default_action_id: 21257015 direct_resource_ids: 318767361 - size: 255 + size: 254 } tables { preamble { diff --git a/sai_p4/instantiations/google/middleblock.p4info.pb.txt b/sai_p4/instantiations/google/middleblock.p4info.pb.txt index 20675bbd..0f92833c 100755 --- a/sai_p4/instantiations/google/middleblock.p4info.pb.txt +++ b/sai_p4/instantiations/google/middleblock.p4info.pb.txt @@ -93,7 +93,7 @@ tables { } const_default_action_id: 21257015 direct_resource_ids: 318767361 - size: 255 + size: 254 } tables { preamble { diff --git a/sai_p4/instantiations/google/minimum_guaranteed_sizes.p4 b/sai_p4/instantiations/google/minimum_guaranteed_sizes.p4 index f86d964f..76e06f79 100644 --- a/sai_p4/instantiations/google/minimum_guaranteed_sizes.p4 +++ b/sai_p4/instantiations/google/minimum_guaranteed_sizes.p4 @@ -63,7 +63,8 @@ #define ACL_DEFAULT_PRE_INGRESS_TABLE_MINIMUM_GUARANTEED_SIZE 254 -#define ACL_PRE_INGRESS_TABLE_MINIMUM_GUARANTEED_SIZE 255 + +#define ACL_TOR_PRE_INGRESS_TABLE_MINIMUM_GUARANTEED_SIZE 127 #define ACL_INGRESS_COUNTING_TABLE_MINIMUM_GUARANTEED_SIZE 255 diff --git a/sai_p4/instantiations/google/tor.p4info.pb.txt b/sai_p4/instantiations/google/tor.p4info.pb.txt index 8a460041..a4613885 100644 --- a/sai_p4/instantiations/google/tor.p4info.pb.txt +++ b/sai_p4/instantiations/google/tor.p4info.pb.txt @@ -93,7 +93,7 @@ tables { } const_default_action_id: 21257015 direct_resource_ids: 318767361 - size: 255 + size: 127 } tables { preamble { @@ -136,7 +136,7 @@ tables { } const_default_action_id: 21257015 direct_resource_ids: 318767366 - size: 255 + size: 127 } tables { preamble { @@ -193,7 +193,7 @@ tables { } const_default_action_id: 21257015 direct_resource_ids: 318767365 - size: 255 + size: 127 } tables { preamble { diff --git a/sai_p4/instantiations/google/unioned_p4info.pb.txt b/sai_p4/instantiations/google/unioned_p4info.pb.txt index b2f1a07e..288eb8bd 100644 --- a/sai_p4/instantiations/google/unioned_p4info.pb.txt +++ b/sai_p4/instantiations/google/unioned_p4info.pb.txt @@ -93,7 +93,7 @@ tables { } const_default_action_id: 21257015 direct_resource_ids: 318767361 - size: 255 + size: 254 } tables { preamble { @@ -817,7 +817,7 @@ tables { } const_default_action_id: 21257015 direct_resource_ids: 318767366 - size: 255 + size: 127 } tables { preamble { @@ -874,7 +874,7 @@ tables { } const_default_action_id: 21257015 direct_resource_ids: 318767365 - size: 255 + size: 127 } tables { preamble {