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

PINS Extension tables support #17

Merged
merged 10 commits into from
Jan 9, 2023
Merged

PINS Extension tables support #17

merged 10 commits into from
Jan 9, 2023

Conversation

svshah-intel
Copy link
Contributor

High Level Design: sonic-net/SONiC#1088

This PR is for changes in sonic-pins repo

This changes include,

  • ConfigureAppDbTables() to create and publish Table definitions for all extension tables. Validate response for the success, if failed return failure back to P4RT client
  • A function to insert table definition in json format
  • A function to publish tables definition set into AppDb
  • New table types kTblsDefinitionSet and kExt, modified existing type kDefinition to kAclDefinition
  • Add/update table utility functions around new and modified table types
  • Add list of fixed table definitions, rest any other table definition is considered of EXT type

Not covered in this commit,

  • meter
  • CRM
  • batching

Signed-off-by: svshah-intel shitanshu.shah@intel.com

@rhalstea
Copy link
Collaborator

@kishanps is more familiar with this effort, adding him for review

Copy link
Collaborator

@kishanps kishanps left a 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;
Copy link
Collaborator

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 ?

Copy link
Contributor Author

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.

Copy link
Collaborator

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.

Copy link
Contributor Author

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.

Copy link

@reshmaintel reshmaintel Nov 30, 2022

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

Copy link
Collaborator

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) {
Copy link
Collaborator

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, that is possible.

p4rt_app/sonic/app_db_manager.cc Show resolved Hide resolved
p4rt_app/p4runtime/p4runtime_impl.cc Outdated Show resolved Hide resolved
p4rt_app/p4runtime/p4runtime_impl.cc Outdated Show resolved Hide resolved
json_key["context"] = oss.str();

std::string key = absl::Substitute("$0:$1",
table::TypeName(table::Type::kTblsDefinitionSet),
Copy link
Collaborator

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 ?

Copy link
Contributor Author

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.

p4rt_app/sonic/app_db_manager.cc Outdated Show resolved Hide resolved
p4rt_app/utils/table_utility.cc Show resolved Hide resolved
}
// 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;
Copy link
Collaborator

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

Copy link
Contributor Author

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

table_name) != p4rt_app::table::FixedTables.end()) {
return table::Type::kFixed;
}
return table::Type::kExt;
Copy link
Collaborator

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" ?

@svshah-intel
Copy link
Contributor Author

Thanks Shitanshu, happy to see this coming along.

Thank you Kishan for taking time for the review and for review comments.

@zhangyanzhao zhangyanzhao requested a review from mint570 November 23, 2022 20:05
Copy link
Collaborator

@kishanps kishanps left a 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);
Copy link
Collaborator

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.

Copy link
Contributor Author

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);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above comment.

p4rt_app/utils/table_utility.cc Show resolved Hide resolved
@zhangyanzhao
Copy link

@mint570 can you please help to review this PR? This is required by 202211 release and thanks.

Copy link
Collaborator

@kishanps kishanps left a 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;
}
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

// 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);
Copy link
Collaborator

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

Copy link
Contributor Author

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 {
Copy link
Collaborator

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.

Copy link
Contributor Author

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);
}
}
Copy link
Collaborator

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 ?

Copy link
Collaborator

@kishanps kishanps left a 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;
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants