Skip to content

Commit

Permalink
Limit ToR ACL pre-ingress table to 127 entries. (sonic-net#281)
Browse files Browse the repository at this point in the history
  • Loading branch information
rkavitha-hcl authored Jul 4, 2024
1 parent dcd6fc3 commit 40bcfde
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 10 deletions.
7 changes: 6 additions & 1 deletion p4_pdpi/p4info_union_lib.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include "p4_pdpi/p4info_union_lib.h"

#include <algorithm>
#include <string>

#include "absl/algorithm/container.h"
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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()));
Expand Down
8 changes: 8 additions & 0 deletions sai_p4/instantiations/google/acl_pre_ingress.p4
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ tables {
}
const_default_action_id: 21257015
direct_resource_ids: 318767361
size: 255
size: 254
}
tables {
preamble {
Expand Down
2 changes: 1 addition & 1 deletion sai_p4/instantiations/google/middleblock.p4info.pb.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ tables {
}
const_default_action_id: 21257015
direct_resource_ids: 318767361
size: 255
size: 254
}
tables {
preamble {
Expand Down
3 changes: 2 additions & 1 deletion sai_p4/instantiations/google/minimum_guaranteed_sizes.p4
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions sai_p4/instantiations/google/tor.p4info.pb.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ tables {
}
const_default_action_id: 21257015
direct_resource_ids: 318767361
size: 255
size: 127
}
tables {
preamble {
Expand Down Expand Up @@ -136,7 +136,7 @@ tables {
}
const_default_action_id: 21257015
direct_resource_ids: 318767366
size: 255
size: 127
}
tables {
preamble {
Expand Down Expand Up @@ -193,7 +193,7 @@ tables {
}
const_default_action_id: 21257015
direct_resource_ids: 318767365
size: 255
size: 127
}
tables {
preamble {
Expand Down
6 changes: 3 additions & 3 deletions sai_p4/instantiations/google/unioned_p4info.pb.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ tables {
}
const_default_action_id: 21257015
direct_resource_ids: 318767361
size: 255
size: 254
}
tables {
preamble {
Expand Down Expand Up @@ -817,7 +817,7 @@ tables {
}
const_default_action_id: 21257015
direct_resource_ids: 318767366
size: 255
size: 127
}
tables {
preamble {
Expand Down Expand Up @@ -874,7 +874,7 @@ tables {
}
const_default_action_id: 21257015
direct_resource_ids: 318767365
size: 255
size: 127
}
tables {
preamble {
Expand Down

0 comments on commit 40bcfde

Please sign in to comment.