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

Discuss adding namespace to P4-16 spec #1193

Closed
hesingh opened this issue Nov 27, 2022 · 3 comments
Closed

Discuss adding namespace to P4-16 spec #1193

hesingh opened this issue Nov 27, 2022 · 3 comments

Comments

@hesingh
Copy link
Contributor

hesingh commented Nov 27, 2022

Problem statement is here.

  1. This would mean, a base headers file must enclose all P4 code in one or more namespace(s).
  2. namespace is added as a new reserved keyword to P4-16. Syntax is same as in C++, namespace M {}
  3. If the compiler processes an include file using namespace M, and processes other P4 code with same namespace, does the compiler raise an error or just adds a new M_1 namespace to reference map?
  4. The compiler find routines will add find object in specific namespace.
@apinski-cavium
Copy link
Contributor

#798
#718
#628
#77
#37
All are related.

@hesingh
Copy link
Contributor Author

hesingh commented Nov 28, 2022

@apinski-cavium thanks,

Andy Fingerhut's doc in this issue has replaced module in #798 by namespace.

P4 already supports #include and all P4 needs to add is namespace to meet the goals in Andy's doc mentioned in this issue. So what use case needs Python import?

@hesingh
Copy link
Contributor Author

hesingh commented Nov 28, 2022

I assumed Andy's doc mentioned in this issue has captured thoughts from any modularity discussion. Since his doc did not include a solution, I filed this issue.

Second, my company has already addressed @vgurevich goals in #798 using two new keywords in P4 - override and super. See the "Quick testing..." section at this link: https://github.com/hesingh/mnkcg/tree/master/p4-ansible

Having read other issues, I am with Andy regarding using namespace which is not the C++ namespace per se. If Name Mangling is used there is no conflict between included code and code in a new P4 program. Right now, with P4-16, I can define several controls in file1.p4 and call the controls in file2.p4 just fine because file2.p4 includes file1.p4. So, why bother with P4 parser and control for Modularity?

So now the only problem to solve is how to use import module in P4?

@hesingh hesingh closed this as not planned Won't fix, can't repro, duplicate, stale Nov 28, 2022
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

No branches or pull requests

2 participants