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

Directionless action arguments provided by the P4 program should behave like in #5042

Open
jaehyun1ee opened this issue Dec 2, 2024 · 0 comments
Labels
bug This behavior is unintended and should be fixed. p4-spec Topics related to the P4 specification (https://github.com/p4lang/p4-spec/).

Comments

@jaehyun1ee
Copy link

The spec mentions in section 6.8. Calling convention that,

For an action, a directionless parameter indicates that it is "action data". See Section 14.1 for the meaning of action data, but its meaning includes the following possibilities:

  • The parameter’s value is provided in the P4 program. In this case, the parameter behaves as if the direction were in. Such an argument expression need not be a compile-time known value.
  • The parameter’s value is provided by the control plane software when an entry is added to a table that uses that action. See Section 14.1.

But test issue473.p4 is categorized under p4_16_errors, expecting the frontend to reject the program with:

control cIngress(inout Parsed_packet hdr,
                 inout mystruct1 meta,
                 inout standard_metadata_t stdmeta) {
    action a1(in bit<32> x) {
        meta.b = meta.b + (bit<4>) x;
        meta.b = (bit<4>) ((bit<32>) meta.b + x);
    }
    action b(inout bit<32> x, bit<8> data) {
        meta.a = meta.a ^ (bit<4>) x ^ (bit<4>) data;
    }
    table t1 {
        key = { hdr.ethernet.srcAddr : exact; }
        actions = {
            a1((bit<32>) meta.a);
            b(meta.c);
        }
        default_action = b(meta.c, (bit<8>) meta.d); // HERE
    }

    apply {
        t1.apply();
    }
}
issue473.p4(70): [--Werror=type-error] error: (bit<8>)meta.d: action argument must be a compile-time constant
        default_action = b(meta.c, (bit<8>) meta.d);
                                   ^^^^^^^^^^^^^^^

I believe this is not in line with the current spec, since b(meta.c, (bit<8>) meta.d) is written within a P4 program (not by the control plane), thus the directionless argument (bit<8>) meta.d need not be a compile-time known value.

@fruffy fruffy added bug This behavior is unintended and should be fixed. p4-spec Topics related to the P4 specification (https://github.com/p4lang/p4-spec/). labels Dec 2, 2024
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. p4-spec Topics related to the P4 specification (https://github.com/p4lang/p4-spec/).
Projects
None yet
Development

No branches or pull requests

2 participants