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

Unexpected key field for BMV2 example #3514

Closed
VolodymyrPeschanenkoIntel opened this issue Sep 5, 2022 · 5 comments · Fixed by #4040
Closed

Unexpected key field for BMV2 example #3514

VolodymyrPeschanenkoIntel opened this issue Sep 5, 2022 · 5 comments · Fixed by #4040
Labels
enhancement This topic discusses an improvement to existing compiler code.

Comments

@VolodymyrPeschanenkoIntel
Copy link
Contributor

The match-on-exprs2-bmv2.p4 finished with the messages for attached stf:

OrderedDict([('hdr.ethernet.srcAddr[22:18]', 'exact'), ('hdr.ethernet.dstAddr & 0x10101010101', 'exact'), ('etherType_less_10', 'exact')])
Exception  Unexpected key field hdr.ethernet.dstAddr

match-on-exprs2-bmv2.stf.txt
match-on-exprs2-bmv2-BMV2SimpleSwitchMidEnd_43_MidEndLast.p4.txt
match-on-exprs2-bmv2.json.txt

It looks like p4c-bmv2-ss generated invalid json file for behavioral-model.

@fruffy
Copy link
Collaborator

fruffy commented Sep 5, 2022

It looks like the correct behavior according to https://github.com/p4lang/p4c/blob/main/frontends/p4/tableKeyNames.cpp#L110 but the STF runner can not parse these types of names.

@mihaibudiu
Copy link
Contributor

Can this be solved by adding some @name annotations on the key fields?

@mihaibudiu
Copy link
Contributor

We actually have 2 STF parsers, one is in bmv2stf.py and the other one is in tools. We have never managed to replace the one in bmv2stf with the other one. Each of them has their own limitations.

@mihaibudiu mihaibudiu added the enhancement This topic discusses an improvement to existing compiler code. label Sep 6, 2022
@apinski-cavium
Copy link

But the spec says something different. See https://p4.org/p4-spec/docs/P4-16-working-spec.html#sec-computing-control-names

Which does not list & expressions in the table for keys and generated names.
Should this table be updated with what the reference compiler actually does and allows or is this an extension on top of the specifications. The spec seems to implies that the compiler should reject it if the @name is not supplied in this case even:
"All other kinds of expressions must be annotated with a @name annotation"

@mihaibudiu
Copy link
Contributor

That is correct, the compiler indeed allows this while the spec does not.
I will file a bug with the spec.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This topic discusses an improvement to existing compiler code.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants