-
Notifications
You must be signed in to change notification settings - Fork 467
DPDK backend: Add support for meter and counter extern #2813
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
Merged
Merged
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
a805208
Fix dpdk regression failure: Duplicates declaration
usha1830 611261b
Fix cpplint errors
usha1830 9c8e6d2
Added checks to ensure parameters exist before accessing them
usha1830 b184e0b
Merge branch 'master' into ushag/fix_duplicates_declaration
usha1830 c03e07d
Merge remote-tracking branch 'upstream/master'
usha1830 c99d261
Merging with p4lang/p4c repo main branch
usha1830 c6a5c12
Merge branch 'p4lang:main' into main
usha1830 4817ea2
Fix PSA extern Register's implementation
usha1830 bfb6f02
Updated spec.cpp as per review comments
usha1830 f5cfb35
Emit a warning if Register instantiation is found outside control block
usha1830 5ca47b1
Fixed a typo
usha1830 f0c7f9c
Remove restriction for instantiation and invocation of register exter…
usha1830 f3ab6ad
Merge branch 'p4lang:main' into ushag_conditional_operator
usha1830 778cd74
Conditional operator support for P4C-DPDK.
usha1830 2b992a4
Merge branch 'p4lang:main' into ushag_conditional_operator
usha1830 61567fd
Changing ternary match to exact in test program, updating the referen…
usha1830 009fd24
Merge branch 'ushag_conditional_operator' of https://github.com/usha1…
usha1830 afa8764
Merge branch 'p4lang:main' into ushag_conditional_operator
usha1830 05a68ba
Added support for range and mask operations in transition select stat…
usha1830 d43963c
Merge branch 'p4lang:main' into origin/ushag/mask_range
usha1830 8b9927f
Support mask operations in dpdk backend (#1)
usha1830 3bde5de
Remove pass for inserting temporary mask variables
usha1830 f7cb04d
Merge branch 'p4lang:main' into origin/ushag/mask_range
usha1830 a3e6ef6
update reference output
usha1830 6b963ce
Merge branch 'p4lang:main' into origin/ushag/mask_range
usha1830 8cf5882
Address review comments
usha1830 00ce76f
Merge branch 'p4lang:main' into origin/ushag/mask_range
usha1830 32d2abe
Merge branch 'p4lang:main' into origin/ushag/mask_range
usha1830 7986213
DPDK backend: Add support for meter and counter PSA externs
usha1830 9648cce
Address review comments for Meter and Counter extern support
usha1830 d663dbb
Merge branch 'p4lang:main' into ushag/Meter_counter
usha1830 76a0557
Cleanup dpdk regression test script to avoid saving error and runtime…
usha1830 402ae06
Updated reference output
usha1830 0013778
Simpilfied the implementation to use vector instead of map
usha1830 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,6 +73,29 @@ bool ConvertStatementToDpdk::preorder(const IR::AssignmentStatement *a) { | |
i = new IR::DpdkGetChecksumStatement( | ||
left, e->object->getName(), intermediate); | ||
} | ||
} else if (e->originalExternType->getName().name == "Meter") { | ||
if (e->method->getName().name == "execute") { | ||
auto argSize = e->expr->arguments->size(); | ||
|
||
// DPDK target needs index and packet length as mandatory parameters | ||
if (argSize < 2) { | ||
::error(ErrorType::ERR_UNEXPECTED, "Expected atleast 2 arguments for %1%", | ||
e->object->getName()); | ||
return false; | ||
} | ||
const IR::Expression *color_in = nullptr; | ||
const IR::Expression *length = nullptr; | ||
auto index = e->expr->arguments->at(0)->expression; | ||
if (argSize == 2) { | ||
length = e->expr->arguments->at(1)->expression; | ||
color_in = new IR::Constant(1); | ||
} else if (argSize == 3) { | ||
length = e->expr->arguments->at(2)->expression; | ||
color_in = e->expr->arguments->at(1)->expression; | ||
} | ||
i = new IR::DpdkMeterExecuteStatement( | ||
e->object->getName(), index, length, color_in, left); | ||
} | ||
} else if (e->originalExternType->getName().name == "Register") { | ||
if (e->method->getName().name == "read") { | ||
auto index = (*e->expr->arguments)[0]->expression; | ||
|
@@ -412,21 +435,46 @@ bool ConvertStatementToDpdk::preorder(const IR::MethodCallStatement *s) { | |
} | ||
} else if (a->originalExternType->getName().name == "Meter") { | ||
if (a->method->getName().name == "execute") { | ||
auto args = a->expr->arguments; | ||
auto index = args->at(0)->expression; | ||
auto color = args->at(1)->expression; | ||
auto meter = a->object->getName(); | ||
add_instr( | ||
new IR::DpdkMeterExecuteStatement(meter, index, color)); | ||
// DPDK target requires the result of meter execute method is assigned to a | ||
// variable of PSA_MeterColor_t type. | ||
::error(ErrorType::ERR_UNSUPPORTED, "LHS of meter execute statement is missing " \ | ||
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. no return here? 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. I don't think so, there is already a return just after the if-else chain. |
||
"Use this format instead : color_out = %1%.execute(index, color_in)", | ||
a->object->getName()); | ||
} else { | ||
BUG("Meter function not implemented."); | ||
} | ||
} else if (a->originalExternType->getName().name == "Counter") { | ||
auto di = a->object->to<IR::Declaration_Instance>(); | ||
auto declArgs = di->arguments; | ||
unsigned value = 0; | ||
auto counter_type = declArgs->at(1)->expression; | ||
if (counter_type->is<IR::Constant>()) | ||
value = counter_type->to<IR::Constant>()->asUnsigned(); | ||
if (a->method->getName().name == "count") { | ||
auto args = a->expr->arguments; | ||
auto index = args->at(0)->expression; | ||
auto counter = a->object->getName(); | ||
add_instr(new IR::DpdkCounterCountStatement(counter, index)); | ||
if (args->size() < 1){ | ||
::error(ErrorType::ERR_UNEXPECTED, "Expected atleast 1 arguments for %1%", | ||
a->object->getName()); | ||
} else { | ||
const IR::Expression *incr = nullptr; | ||
auto index = args->at(0)->expression; | ||
auto counter = a->object->getName(); | ||
if (args->size() == 2) | ||
incr = args->at(1)->expression; | ||
if (value == 2) { | ||
if (incr) { | ||
add_instr(new IR::DpdkCounterCountStatement(counter+"_packets", | ||
index, incr)); | ||
add_instr(new IR::DpdkCounterCountStatement(counter+"_bytes", | ||
index)); | ||
} else { | ||
::error(ErrorType::ERR_UNEXPECTED, | ||
"Expected packet length argument for %1%", a->object->getName()); | ||
} | ||
} else { | ||
add_instr(new IR::DpdkCounterCountStatement(counter, index, incr)); | ||
} | ||
} | ||
} else { | ||
BUG("Counter function not implemented"); | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.