Open marsontti opened 1 day ago
The last time I checked several years ago, there were still quite a few simple P4 programs that the PSA architecture implementation in BMv2 does not support, or has bugs. I can double-check those issues to see if anything has changed since then, but assuming it is the same as it was then, it is very easy to find P4 programs that are not implemented correctly by the PSA implementation for BMv2. We had a volunteer actively working on improving it several years ago, but no one has decided to work on it after that yet, unfortunately.
I am trying to implement a P4 program using PSA for bmv2. In the program, I wanted to use registers where a structure representing a flow would serve as the index. In the program, I'm trying to read the contents of the register using the 'flow' structure. The program compiles; however, when loading the program onto the psa_switch, I get an error: "Invalid reference to object of type 'header' with name 'flow_0'." Additionally, I've noticed that when I try to write a program where the flow is not the index but instead the value stored by the register, I get a compilation error: "functions or methods returning structures are not supported on this target."
So my question is: is this an error, or does the p4c-bm2-psa compiler simply not support structures in registers, both as indexes and as values?
Structure:
struct flow_t { ip4Addr_t srcAddr; ip4Addr_t dstAddr; bit<8> protocol; port_t srcPort; port_t dstPort; }
Read using structure: assignedPort = pat_send_reg.read(flow);
Read structure using port (from https://github.com/p4lang/p4-spec/blob/main/p4-16/psa/examples/psa-example-register1.p4): tmp = port_pkt_ip_bytes_in.read(istd.ingress_port);