-
Notifications
You must be signed in to change notification settings - Fork 441
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
Improve PNA system library organization with smaller usable components #4752
base: main
Are you sure you want to change the base?
Changes from all commits
61c8723
d0e19ca
78ccd3f
d0449ea
a6fd312
45cdadd
1d26e7b
e2b05eb
afcb06d
87db8a0
7345689
dab46f6
6c8351e
a870a1d
6f28a59
fc41991
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,7 @@ limitations under the License. | |
// Standard include paths for .p4 header files. The values are determined by | ||
// `configure`. | ||
extern const char *p4includePath; | ||
extern const char *p4includeInternalPath; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The discussion in #4742 makes me thing we just should have this be a set. Do not know how difficult this is to implement with all the back ends. |
||
extern const char *p4_14includePath; | ||
|
||
// Base class for compiler options. | ||
|
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -72,6 +72,7 @@ class ToP4 : public Inspector { | |||
listTerminators.pop_back(); | ||||
} | ||||
bool isSystemFile(cstring file); | ||||
bool isSystemInternalFile(cstring file); | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the definition of a system internal file. Any private header include prefixed with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the hacky part. What happened is that in the following loop, p4c/frontends/p4/toP4/toP4.cpp Line 154 in b27702f
My current solution is to define this special |
||||
cstring ifSystemFile(const IR::Node *node); // return file containing node if system file | ||||
// dump node IR tree up to depth - in the form of a comment | ||||
void dump(unsigned depth, const IR::Node *node = nullptr, unsigned adjDepth = 0); | ||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# PNA Standard Libraries | ||
|
||
In this directory, we decompose different versions of the standard `pna.p4` library (as specified in https://github.com/p4lang/pna) into smaller reusable components. Actual backends supporting PNA might modify some of these components in their target-specific `pna.p4` (e.g. `p4include/dpdk/pna.p4`). | ||
|
||
| Version | Release Date | PNA Repo Commit | PNA Spec Link | | ||
| ------- | ------------ | -------------- | ------------- | | ||
| `dev` | N/A | N/A | https://p4.org/p4-spec/docs/pna-working-draft-html-version.html | | ||
| `v0.7` | 2022-12-22 | [9aef684](https://github.com/p4lang/pna/tree/9aef684a8d8e4d1d8ea34b4277bfd329f33e2254) | https://p4.org/p4-spec/docs/PNA-v0.7.html | | ||
| `v0.5` | 2021-05-18 | [e3eb99d](https://github.com/p4lang/pna/tree/e3eb99dc7d59f7a031bc672f8cf6c300f3d166fb) | https://p4.org/p4-spec/docs/PNA-v0.5.0.html | |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* Copyright 2020-present Intel Corporation | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
#ifndef __PNA_P4__ | ||
#define __PNA_P4__ | ||
|
||
#include <core.p4> | ||
|
||
/** | ||
* P4-16 declaration of the Portable NIC Architecture | ||
*/ | ||
|
||
#include <_internal/pna/dev/types_core.p4> | ||
#include <_internal/pna/dev/types_defns.p4> | ||
#include <_internal/pna/dev/types_defns2.p4> | ||
#include <_internal/pna/dev/funcs_int_to_header.p4> | ||
#include <_internal/pna/dev/types_misc.p4> | ||
|
||
#include <_internal/pna/dev/extern_hash.p4> | ||
#include <_internal/pna/dev/extern_checksum.p4> | ||
#include <_internal/pna/dev/extern_counter.p4> | ||
#include <_internal/pna/dev/extern_meter.p4> | ||
#include <_internal/pna/dev/extern_register.p4> | ||
#include <_internal/pna/dev/extern_random.p4> | ||
#include <_internal/pna/dev/extern_action.p4> | ||
#include <_internal/pna/dev/extern_digest.p4> | ||
|
||
#include <_internal/pna/dev/types_metadata.p4> | ||
#include <_internal/pna/dev/extern_funcs.p4> | ||
#include <_internal/pna/dev/blocks.p4> | ||
|
||
#endif // __PNA_P4__ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// BEGIN:Programmable_blocks | ||
parser MainParserT<MH, MM>( | ||
packet_in pkt, | ||
out MH main_hdr, | ||
inout MM main_user_meta, | ||
in pna_main_parser_input_metadata_t istd); | ||
|
||
control MainControlT<MH, MM>( | ||
inout MH main_hdr, | ||
inout MM main_user_meta, | ||
in pna_main_input_metadata_t istd, | ||
inout pna_main_output_metadata_t ostd); | ||
|
||
control MainDeparserT<MH, MM>( | ||
packet_out pkt, | ||
inout MH main_hdr, | ||
in MM main_user_meta, | ||
in pna_main_output_metadata_t ostd); | ||
|
||
package PNA_NIC<MH, MM>( | ||
MainParserT<MH, MM> main_parser, | ||
MainControlT<MH, MM> main_control, | ||
MainDeparserT<MH, MM> main_deparser); | ||
// END:Programmable_blocks |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include <_internal/pna/v0_7/extern_action.p4> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include <_internal/pna/v0_7/extern_checksum.p4> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include <_internal/pna/v0_7/extern_counter.p4> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include <_internal/pna/v0_7/extern_digest.p4> |
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.
It seems like the parser should already determine whether an object is source from a systems file and add this information to the source information.
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.
Agree this will be a better solution.
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.
@ChrisDodd Do you think this could be done in the P4 parser? How much work would it be?