-
Notifications
You must be signed in to change notification settings - Fork 472
DPDK: Add support for "mirror_packet" PNA extern #3128
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
Conversation
@@ -765,6 +765,33 @@ bool ConvertStatementToDpdk::preorder(const IR::MethodCallStatement *s) { | |||
} else { | |||
::error("%1%: unhandled function", s); | |||
} | |||
} else if (a->method->name == "mirror_packet") { | |||
auto slot_id = a->expr->arguments->at(0)->expression; |
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.
first you should check that there are exactly 2 arguments and give an error otherwise (probably a modelError).
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.
No of arguments mismatch is caught by the frontend, I also added a test for that.
I can add the check to be on the safer side.
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.
Added a check.
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.
That is true, but you are assuming the users have loaded the correct pna file. But users can modify the pna file or load by mistake v1model.p4 instead of pna. Also, pna may change as time goes on. In these cases the compiler should not crash.
backends/dpdk/dpdkHelpers.cpp
Outdated
const IR::Expression *session_idexpr = session_id; | ||
// mirror instruction supports only metadata as operands, move any constant arguments | ||
// to metadata fields | ||
if (slot_id->is<IR::Constant>()){ |
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.
no space before {
backends/dpdk/dpdkHelpers.cpp
Outdated
auto tmpMember = new IR::Member(new IR::PathExpression("m"), tmpName); | ||
add_instr(new IR::DpdkMovStatement(tmpMember, slot_id)); | ||
slot_idexpr = tmpMember; | ||
} |
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.
are you sure that anything that is not a constant will work?
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.
Frontend rejects the program if the arguments to mirror_packet are not compile-time constants. Updated the code to assert on this condition.
@mbudiu-vmw I have updated the code as per you comments. Please let me know if anything else is required. |
This PR adds support for PNA extern "mirror_packet"
This translates to mirror instruction in dpdk
mirror <SLOT_ID> <SESSON_ID>
If the arguments are constants, they should be moved to Metadata as the mirror instruction in dpdk does not support immediate values as operands.
Added a valid test and a few negative tests.
Negative tests are added for the following: