-
Notifications
You must be signed in to change notification settings - Fork 26
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
PINS Extension tables support #17
Conversation
@kishanps is more familiar with this effort, adding him for review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Shitanshu, happy to see this coming along.
return gutil::NotFoundErrorBuilder() | ||
<< "Table '" << table_name << "' is not a known table."; | ||
// Bypass further checks for extension tables | ||
continue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will have a side effect of bypassing non-ext tables as well, can we strengthen the check here ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change was done at last minute due to latest change that was brought in just before this PR. Based on my understanding this should not bypass checks for any tables supported by schema. However, if there are other ways to handle, I am open for suggestion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suppose a new P4 table (non-ext) is added but does not exist in the supported schema, then this error condition gets ignored now.
I think you need to identify if its an EXT table before looking up into supported_schema_map.tables.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the ones which are not part of supported schema are considered extension tables. We don't want to enforce on naming convention or a specific set of tables as extension tables. It is expected that p4 programmer knows set of sai.p4 tables and thus knows that anything outside of that is considered as an extension table. Thus it is intended that a new table if does not exist in the supported schema, to be considered as extension table.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you Kishan for your inputs. We did not want to restrict the P4 user to make changes to table/object names by adding ext. Current design takes any name the user wants and is more generic.
Any other suggestions you may have that are not blocking for now, we would like to discuss them with you in detail and definitely take it up in the next release itself. Hope this is ok with you.
Thanks,
Reshma
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a short term workaround, can we define a static list of ext tables that can be used to see if this is an allowed table or not ? When ext table verification is supported in the next release, we can remove this static list.
@@ -632,28 +632,6 @@ TEST(IsSupportedBySchemaTest, ReturnsOkWithActionSubset) { | |||
EXPECT_OK(IsSupportedBySchema(schema_p4info, kSupportedSchema)); | |||
} | |||
|
|||
TEST(IsSupportedBySchemaTest, ReturnsErrorForUnknownTable) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe if the IsSupported is strengthened, then this test can be enabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, that is possible.
json_key["context"] = oss.str(); | ||
|
||
std::string key = absl::Substitute("$0:$1", | ||
table::TypeName(table::Type::kTblsDefinitionSet), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this not kExt ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a definition itself. kExt is used for table that holds actual table-entries.
} | ||
// TODO: return status failure. | ||
} | ||
|
||
absl::StatusOr<Type> TypeParse(absl::string_view type_name) { | ||
if (type_name == "ACL") return Type::kAcl; | ||
if (type_name == "FIXED") return Type::kFixed; | ||
if (type_name == APP_P4RT_ACL_TABLE_DEFINITION_NAME) return Type::kDefinition; | ||
if (type_name == "EXT") return Type::kExt; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Related to my other comments in this file, what is the difference between kExt & kTblsDefinitionSet
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hope earlier responses have clarified
p4rt_app/utils/table_utility.cc
Outdated
table_name) != p4rt_app::table::FixedTables.end()) { | ||
return table::Type::kFixed; | ||
} | ||
return table::Type::kExt; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace this logic with substring(table_name) == "EXT" ?
Thank you Kishan for taking time for the review and for review comments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Last set of minor comments, we are almost there.
@@ -35,6 +35,8 @@ TEST(GetTableType, ReturnsAclForSaiAclAnnotation) { | |||
|
|||
TEST(GetTableType, ReturnsFixedForNoAnnotation) { | |||
pdpi::IrTableDefinition ir_table; | |||
google::protobuf::TextFormat::ParseFromString( | |||
R"pb(preamble { alias: "router_interface_table"})pb", &ir_table); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test definition/intent and the addition here is not aligning. The test was meant to ensure that no annotation returns fixed but we are now mandating fixed are part of a defined set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before there were only ACL and FIXED tables. This test had assumed that something that does not have "@sai_acl" annotation would mean Fixed only. With support of extension tables, absence of any annotation can't be assumed as Fixed, and hence using one of the fixed tables explicitly here.
@@ -45,14 +47,23 @@ TEST(GetTableType, ReturnsFixedForNoAnnotation) { | |||
TEST(GetTableType, ReturnsFixedForNoSpecialAnnotation) { | |||
pdpi::IrTableDefinition ir_table; | |||
google::protobuf::TextFormat::ParseFromString( | |||
R"pb(preamble { annotations: "@random()" })pb", &ir_table); | |||
R"pb(preamble { alias: "router_interface_table" annotations: "@random()" })pb", &ir_table); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above comment.
@mint570 can you please help to review this PR? This is required by 202211 release and thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Shitanshu, looks good overall, last set of minor comments.
p4rt_app::table::FixedTables.end(), | ||
table_name) != p4rt_app::table::FixedTables.end()) { | ||
return table::Type::kFixed; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove this logic given that we are using the table id to identify ext vs fixed table.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be required when table id related change is removed. I've kept it so that when extension table validation is added, there will be only one line change that is returning kExt instead of conditionalkExt.
p4rt_app/utils/table_utility.cc
Outdated
// Return kExt table-type conditionally, until extension tables | ||
// validation is in place. Once that is in place, | ||
// return kExt table-type unconditionally | ||
return CONDITIONAL_kExt(ir_table); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a general guideline in this dir, macros are not preferred. Can we inline that check here,
if (id > 0x02000000 & id < 0x03000000)
return kFixed
else if (id > 0x03000000)
return kExt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, will change it to inline
#include "p4_pdpi/utils/annotation_parser.h" | ||
#include "swss/schema.h" | ||
|
||
namespace p4rt_app { | ||
namespace table { | ||
|
||
// This is what orch agent understands as fixed tables | ||
std::vector<std::string> FixedTables { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets get rid of this global var, if at all we need it, lets make it a static list of all the fixed tables we have now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can make it to static. When-ever in future new fixed table is added, we will need to remember to add that entry here. Hope that is okay.
table_name) == p4rt_app::table::FixedTables.end()) { | ||
p4rt_app::table::FixedTables.push_back(table_name); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As in the other comment, remove this logic ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One minor comment inline, thanks Shitanshu for working together on this.
{ | ||
return table::Type::kExt; | ||
} | ||
return table::Type::kFixed; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given we have already checked valid fixed tables just before this, this is not required here.
I would suggest to move this code inline at the caller place and return InvalidArgument if table_id is not greater than 0x030000.
High Level Design: sonic-net/SONiC#1088
This PR is for changes in sonic-pins repo
This changes include,
Not covered in this commit,
Signed-off-by: svshah-intel shitanshu.shah@intel.com