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 gives incorrect warning about unused counter #461

Closed
jafingerhut opened this issue Apr 9, 2017 · 6 comments · Fixed by #1018
Closed

p4c-bm2-ss gives incorrect warning about unused counter #461

jafingerhut opened this issue Apr 9, 2017 · 6 comments · Fixed by #1018
Assignees
Labels
bug This behavior is unintended and should be fixed. fixed This topic is considered to be fixed.

Comments

@jafingerhut
Copy link
Contributor

See the first line containing "direct_counter" in the attached P4_16 program. 2017-Apr-08 version of p4c-bm2-ss gives a warning about ipv4_da_lpm_stats being unused. However, if I comment out that line, I get 2 errors, one for each time ipv4_da_lpm_stats.count() is called shortly afterwards.

Also, if I generate a bmv2 JSON file and run simple_switch on it and try to use the command 'counter_read ipv4_da_lpm_stats ' from simple_switch_CLI, it gives this error:

Error: Invalid counter name (ipv4_da_lpm_stats)

A similar P4_14 program works correctly when compiled with p4c-bmv2. I can create a separate issue for this behavior if desired.
bad-warning-of-unused-counter.p4.txt

@mihaibudiu
Copy link
Contributor

This issue was introduced in 2c131b8, when the direct counters had a method count() added. Originally there was no such method in v1model.p4.
I believe that this method should not be present in v1model.p4.

@mihaibudiu
Copy link
Contributor

See all the comments at #421 where this problem was anticipated.

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

There's some confusion as to how direct counters and meters work in the P4_16 standard architecture -- are they properties on tables, or are they externs with methods invoked in actions? The bmv2 backend mostly expecting them to be properties, which is what causes problems with this code. Interally it is buggy and is checking the wrong attribute name (a result of obfuscating the the names of evering behind static const cstring variables rather than just using string literals). With that fixed, the posted code still gives the warning as there are TWO counters, one created in the table and one created in the control. It should be giving an error about the count method being called on a counter not attached to the table, but is not. Fixing that (and the spurious warning requires changing the attribute in the table to be counters = ipv4_da_lpm_stats, attaching the counter created in the control to the table, rather than creating a second counter.

@mihaibudiu
Copy link
Contributor

The standard architecture is one place, but v1model is another one.
It would be very nice if there was some documentation about the way these objects should be used.
Also, if they are to be used differently between PSA and BMv2 we will need special handling for the two cases in the back-end. Also, if the P4-14 to P4-16 translation targets BMv2 or PSA, it may need to be different!

@mihaibudiu
Copy link
Contributor

@ChrisDodd : is this issue fixed with your latest commit?

mihaibudiu pushed a commit to mihaibudiu/p4c-clone that referenced this issue Nov 8, 2017
@mihaibudiu mihaibudiu added the fixed This topic is considered to be fixed. label Nov 8, 2017
mihaibudiu pushed a commit to mihaibudiu/p4c-clone that referenced this issue Nov 8, 2017
@jafingerhut
Copy link
Contributor Author

Thanks for the fixes to avoid the warnings here. Closing this issue is reasonable.

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. fixed This topic is considered to be fixed.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants