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

create dpdk specific pna.p4 and extend it #3658

Merged
merged 11 commits into from
Nov 11, 2022

Conversation

kamleshbhalui
Copy link
Contributor

@kamleshbhalui kamleshbhalui commented Nov 3, 2022

dpdk target requires packet length in count and execute methods part of Counter and Meter externs.

@usha1830
Copy link
Contributor

usha1830 commented Nov 3, 2022

This is as per p4lang/pna#49 (comment)

@@ -533,7 +533,8 @@ enum PSA_CounterType_t {
@noWarn("unused")
extern Counter<W, S> {
Counter(bit<32> n_counters, PSA_CounterType_t type);
void count(in S index, @optional in bit<32> increment);
void count(in S index);
Copy link
Contributor

Choose a reason for hiding this comment

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

What does DPDK do when a PSA program calls the original count method that does not have a pkt_len parameter? Nothing? It would be good to have a comment here if it does anything other than what PSA defines.

Copy link
Contributor

Choose a reason for hiding this comment

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

And also for the corresponding method in the DirectCounter extern. And for Meter and DirectMeter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added the comments

@@ -1,5 +1,5 @@
#include <core.p4>
#include <pna.p4>
#include <dpdk/pna.p4>
Copy link
Contributor

Choose a reason for hiding this comment

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

For PSA, I thought we had something in the p4c-dpdk front end script that made it automatically look in the dpdk directory for the psa.p4 include file, so that P4 developers could simply write #include <psa.p4> and it would find it in the p4include/dpdk directory. It would be nice to do the same for p4c-dpdk for PNA architecture programs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes it only works for p4c-dpdk but not with p4test. When running tests(make check) every testfiles compiles with p4test and p4c-dpdk.

@@ -33,7 +33,6 @@ struct main_metadata_t {
bit<8> local_metadata_timeout
bit<32> local_metadata_port_out
bit<32> pna_main_output_metadata_output_port
bit<32> table_entry_index
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a valid test for Direct Meter for tables with add_on_miss. These instructions/metadata field shouldn't be removed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@@ -2526,7 +2526,7 @@ bool CollectDirectCounterMeter::preorder(const IR::P4Table* tbl) {
return false;
}
}
if (!ifMethodFound(defaultActionDecl, "execute", meterExternName)) {
if (!ifMethodFound(defaultActionDecl, "dpdk_execute", meterExternName)) {
if (meterInstance) {
::error(ErrorType::ERR_EXPECTED, "Expected default action %1% to have "
"'execute' method call for DirectMeter extern instance %2%",
Copy link
Contributor

Choose a reason for hiding this comment

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

'execute' ->'dpdk_execute'

Copy link
Contributor

Choose a reason for hiding this comment

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

Same name change is required in P4Action preorder

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks fine to me now


IngressPipeline(IngressParserImpl(), ingress(), IngressDeparserImpl()) ip;
EgressPipeline(EgressParserImpl(), egress(), EgressDeparserImpl()) ep;
PSA_Switch(ip, PacketReplicationEngine(), ep, BufferingQueueingEngine()) main;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is the expected output file testdata/p4_16_samples_outputs/psa-example-dpdk-meter-execute-err.p4-stderr empty? I thought these changes claimed to give an error message if you tried to call the execute method without a packet length parameter? Doesn't it?

Copy link
Contributor

Choose a reason for hiding this comment

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

@jafingerhut
Once #3680 is merged, we will move this test to p4_16_dpdk_errors directory and then the error output will also be fixed. Currently, it is added in XFAIL as all other negative tests

Choose a reason for hiding this comment

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

sounds good

@@ -74,6 +74,13 @@ In P4 the second argument of the extract method is the number of bits.
Compiler generates instructions which compute the size in bytes from the value in bits.
If the value in bits is not a multiple of 8, the value is rounded down to the lower
multiple of 8 bits.
- Currently dpdk target does not support standard count and execute methods for Counter and Meter externs as defined in PSA and PNA specifications. It requires packet length as parameter in count and execute methods.
```Meter
Copy link
Contributor

Choose a reason for hiding this comment

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

Does DPDK development have any plans in the future to support the standard count and execute methods, without a packet length parameter?

Copy link
Contributor

Choose a reason for hiding this comment

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

There is no plan in the near future. There was an earlier discussion of providing ethernet frame size as default packet length, however it seems that it wouldn't be correct as DPDK implements trCM which do not work on ethernet frame length.

Choose a reason for hiding this comment

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

"which do not work on ethernet frame length" Meters/policers can work on whatever length in bytes you give for a packet, whether it matches the packet's length or not, so it isn't clear to me what your statement means. If DPDK implements meters by default with ethernet frame length, then I would recommend enabling them to do so, and DOCUMENTING that the methods that do not take a packet length as input, use the ethernet frame length in bytes. If they work as documented, then I'd say that they work :-)

Copy link
Contributor

Choose a reason for hiding this comment

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

I will take this up with the DPDK target team again and see if they can have this in their worklist. We can enable the p4c support when we have the default packet length available from the target side.

Copy link

@jfingerh jfingerh left a comment

Choose a reason for hiding this comment

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

With the future plans for additional changes later mentioned in comments, this looks good to me.

Copy link
Contributor

@jafingerhut jafingerhut left a comment

Choose a reason for hiding this comment

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

LGTM Adding review from my Github account that has write permission this time.

@kamleshbhalui
Copy link
Contributor Author

@jfingerh please merge it.

@jafingerhut jafingerhut merged commit b7f0d13 into p4lang:main Nov 11, 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

Successfully merging this pull request may close these issues.

4 participants