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

PSA structs in Registers #5001

Open
marsontti opened this issue Nov 5, 2024 · 1 comment
Open

PSA structs in Registers #5001

marsontti opened this issue Nov 5, 2024 · 1 comment
Labels
psa-bmv2 Topics related to the PSA BMv2 back end

Comments

@marsontti
Copy link

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);

@jafingerhut
Copy link
Contributor

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.

@jafingerhut jafingerhut added the psa-bmv2 Topics related to the PSA BMv2 back end label Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
psa-bmv2 Topics related to the PSA BMv2 back end
Projects
None yet
Development

No branches or pull requests

2 participants