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

Specify compile-time error to specify explicit priorities in const entries #1259

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 25 additions & 12 deletions p4-16/spec/P4-16-spec.mdk
Original file line number Diff line number Diff line change
Expand Up @@ -6558,12 +6558,12 @@ Some table entries, in particular the ones with at least one `ternary`
field, also require a priority value. A priority is a numeric value
which is used to break ties when a particular key belongs to multiple
sets. When table entries are specified in the P4 program the
priorities are generated by the compiler; when entries are specified
by the control-plane, the priority may need to be explicitly
specified. Entries with higher priority are matched first. This
specification does not mandate whether "higher" priorities are
represented by higher or lower numeric values; this choice is left to
the target implementation.
priorities are specified by the P4 developer or generated by the
compiler; when entries are specified by the control-plane, the
priority may need to be explicitly specified. Entries with higher
priority are matched first. This specification does not mandate
whether "higher" priorities are represented by higher or lower numeric
values; this choice is left to the target implementation.

An example specifying entries for a table is given in Section [#sec-entries].

Expand Down Expand Up @@ -6757,13 +6757,26 @@ element of the set. The `actionRef` component must be an action which
appears in the table actions list (and must not have the
`@defaultonly` annotation), with all its arguments bound.

If no entry priorities are specified in the source code, and
if the runtime API requires a priority for the entries of a
If the runtime API does not require a priority for the entries of a
table---e.g. tables where all key fields have match kind `exact`---
then it is a compile-time error to attempt to specify priority values
for entries in the source code.

If the runtime API requires a priority for the entries of a
table---e.g. when using the P4 Runtime API, tables with at least one
`ternary` search key field---then the entries are matched in program
order, stopping at the first matching entry. Architectures should
define the significance of entry order (if any) for other kinds of
tables.
`ternary` search key field---then there are two cases:

- If the table entries are defined using `const entries`, it is a
compile-time error to attempt to specify priority values for entries
in the source code. The compiler will always assign relative
priorities for the entries such that earlier entries have a higher
match priority than later entries, so that priorities correspond to
the order of the entries in the source code.
- If the table entries are defined using `entries` (without a `const`
qualifier before it), then the source code can optionally specify
priority values for entries, with the compiler assigning priorities
for entries that have none in the source code. See the next section
for details.

Depending on the `match_kind` of the keys, key set expressions may define
one or multiple entries. The compiler will synthesize the correct number of
Expand Down