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

p4c-bm2-ss writes incorrect JSON file if there are "Removing unused action parameter" warnings #497

Closed
jafingerhut opened this issue Apr 19, 2017 · 9 comments
Labels
bug This behavior is unintended and should be fixed.

Comments

@jafingerhut
Copy link
Contributor

jafingerhut commented Apr 19, 2017

See attached .p4 and .json files. When compiled there are (correct) warnings about unused parameters for action set_bd_dmac_intf.

If you look at action set_bd_dmac_intf in the JSON file, it has 3 entries for the used arguments under key "runtime_data". However, under the "primitives" key, every time there is a "modify_field" primitive action with source data from a parameter that comes after an unused (and thus removed) parameter, the index is the original index in the parameter list, before the unused ones were removed, which are now wrong.
demo1-variant.p4.txt
demo1-variant.p4.txt

@mihaibudiu mihaibudiu added the bug This behavior is unintended and should be fixed. label Apr 19, 2017
@jafingerhut
Copy link
Contributor Author

And if anyone else hits this issue before it is fixed, it does seem that removing all unused action parameters until those warnings are gone does work around this problem, as one might expect.

@sethfowler
Copy link
Contributor

IMO, we should just stop removing unused action parameters.

We deliberately aren't doing it for P4Runtime.

Is there any reason not to make that change?

@mihaibudiu
Copy link
Contributor

mihaibudiu commented Apr 19, 2017

I was about to work on a fix, but indeed, it would be better if we could keep the unused parameters.
This behavior is inherited from the P4-14 compiler.

@jafingerhut
Copy link
Contributor Author

I think continuing to warn about unused parameters would be useful, even if they are left in the bmv2 JSON file.

@mihaibudiu
Copy link
Contributor

I will attempt to provide a fix for this that uses an #if REMOVE_PARAMETERS. So then we can do it in either way. But, of course, I won't be able to test both cases until BMv2 handles unused parameters.

Note that removing parameters violates the contract that the control-plane API is readable from the program.

@antoninbas
Copy link
Member

There is nothing required from bmv2 AFAIK. If you leave an unused parameter in the JSON, nothing bad will happen, it will just not be used. And as pretty much everyone has mentioned, from a control-plane perspective, it is better to leave unused parameters and simply print a warning.

@mihaibudiu
Copy link
Contributor

OK, then I will just them in. Much simpler.
Note that there seem to be several Travis build failures related to this bug, I don't know why it didn't show up before.

@antoninbas
Copy link
Member

I updated bmv2 to sanitize runtime data indices in action bodies in the JSON. p4c-bmv2-ss outputs invalid JSON every time there is an unused parameter in an action, which is now rejected by bmv2. Unlike my previous sanity check (duplicate names / ids), I did not revert this fix, because I think it is a major bug, yet one "easy" to fix in p4c (a quick workaround may be to remove unused parameters in test programs).

mihaibudiu pushed a commit to mihaibudiu/p4c-clone that referenced this issue Apr 20, 2017
antoninbas pushed a commit that referenced this issue Apr 20, 2017
* Fix for issue #497

* Forgot to change the warning
@antoninbas
Copy link
Member

I merged @mbudiu-vmw's PR, I think we can consider this closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This behavior is unintended and should be fixed.
Projects
None yet
Development

No branches or pull requests

4 participants