p4lang / p4c

P4_16 reference compiler
https://p4.org/
Apache License 2.0
683 stars 446 forks source link

PSA bmv2 back end produces incorrect BMv2 JSON file for test program #2506

Open jafingerhut opened 4 years ago

jafingerhut commented 4 years ago

With the versions listed below of p4c and behavioral-model sourcec ode:

commit 373c3c6a681dd46023788604bac05c410d109804
Author: fruffy <5960321+fruffy@users.noreply.github.com>
Date:   Tue Aug 18 21:24:49 2020 +0200

commit 595c1c358555c9800d4eccbfc648f0d1820fd0de
Author: Hemant Singh <32817427+hesingh@users.noreply.github.com>
Date:   Wed Jul 29 16:34:59 2020 -0400

The attached program psa-unicast-or-drop-2-bmv2.p4, which is a small modification of the already-checked-in and working test program psa-unicast-or-drop-bmv2.p4, gives an error not when compiling it, but when psa_switch attempts to read the BMv2 JSON file:

$ p4c-bm2-psa testdata/p4_16_samples/psa-unicast-or-drop-2-bmv2.p4 -o psa-unicast-or-drop-2-bmv2.json

$ psa_switch --log-console psa-unicast-or-drop-2-bmv2.json
Calling target program-options parser
Invalid reference to object of type 'header' with name 'scalars'

I have not dug into exactly what is going wrong, but I suspect that perhaps the BMv2 JSON file is incorrect, and in particular has no fields anywhere to represent the field parser_ingress_port inside of the struct of type metadata_t in the P4 program.

I suspect this is a problem specific to the PSA back end for p4c, since there are very likely v1model architecture test programs that assign values to metadata fields within parsers, and use them in the ingress control.

p4c-psa-issue.zip

jafingerhut commented 3 weeks ago

Just doing a status check on the PSA implementation in BMv2. This issue is still true of the latest version of p4c-bm2-ss and psa_switch executables built from source as of 2024-oct-31.