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

Compiler does not implicitly calculate priorities and does not allow explicit priorities for const entries #4792

Open
kfcripps opened this issue Jul 9, 2024 · 8 comments
Assignees
Labels
control-plane Topics related to the control-plane or P4Runtime. p4-spec Topics related to the P4 specification (https://github.com/p4lang/p4-spec/). question This is a topic requesting clarification.

Comments

@kfcripps
Copy link
Contributor

kfcripps commented Jul 9, 2024

Currently the compiler does not implicitly calculate priorities that are not explicitly provided when the entries are const, and reports an error message when const entries have explicit priorities:

    if (ep->isConstant) {
        if (withPriority)
            ::error(ErrorType::ERR_INVALID,
                    "%1%: Table with 'const' entries cannot have priorities", withPriority);
        return entries;
    }

Why does it do this? Can anyone point me to where in the spec this const entries-specific behavior is described?

@kfcripps kfcripps added question This is a topic requesting clarification. control-plane Topics related to the control-plane or P4Runtime. p4-spec Topics related to the P4 specification (https://github.com/p4lang/p4-spec/). labels Jul 9, 2024
@kfcripps
Copy link
Contributor Author

kfcripps commented Jul 9, 2024

For example:

        const entries = {
            (0x1, 0x2) : a(0, 1, 2);
            (0x3, 0x4) : a(3, 4, 5);
            (0x5, 0x6) : a(6, 7, 8);
            (0x7, _)   : a(9, 10, 11);
            (_, 0x8)   : a(12, 13, 14);
        }

@ChrisDodd
Copy link
Contributor

With const entries, the control plane cannot insert more entries (or remove entries), so the compiler has complete control. The priorities in that case are solely based on the order of the const entries, and there's no need for priorities. The priorities only matter if the control-plane can add entries (which will have priorities), in which case they're needed to determine the relative priorities of the control-plane and static entries.

@jafingerhut
Copy link
Contributor

I have reviewed the sub-section named "Entries" within the section 14.2.1 "Table Properties" of the latest version of the language spec as of 2024-Jul-09, and I did not notice anything there that specifically forbids entry priorities to be specified for a const entries table property.

I agree with Chris Dodd that it does not seem very useful to allow a P4 developer to specify them -- the textual order of entries specifies the relative priority, if that match kind of the keys requires it, and specifying particular numeric values would just be an extra burden on the P4 develeper.

@kfcripps
Copy link
Contributor Author

@ChrisDodd @jafingerhut Thank you for clarifying. Would it make sense to make the spec more explicit regarding priorities of const entries?

@jafingerhut
Copy link
Contributor

It would not bother me if the spec explicitly forbade explicit priority values from being specified inside of const entries, with a brief description of the reason. Are you interested in suggesting a PR for the spec that would do this?

@kfcripps
Copy link
Contributor Author

@jafingerhut I probably won't do it anytime soon, but if you want to open a new issue in the p4-spec repo and assign to me I wouldn't mind trying to do that eventually.

@jafingerhut
Copy link
Contributor

I created this issue, but when I attempt to assign it to you, it does not seem to allow me to specify your Github id: p4lang/p4-spec#1292

@kfcripps
Copy link
Contributor Author

@jafingerhut Thanks. I will just assign this issue to myself instead as a reminder.

@kfcripps kfcripps self-assigned this Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
control-plane Topics related to the control-plane or P4Runtime. p4-spec Topics related to the P4 specification (https://github.com/p4lang/p4-spec/). question This is a topic requesting clarification.
Projects
None yet
Development

No branches or pull requests

3 participants