Skip to content

To what extent do we check equivalence of table actions? #1388

Description

@jaehyun1ee

P4 tables may specify the default_action property where Section 14.2.1.3. Default action of the official spec states:

If present, the default_action property must appear after the action property. It may be declared as const, indicating that it cannot be changed dynamically by the control-plane. The default action must be one of the actions that appear in the actions list.

The unclear part here is, how we should check the last part, The default action must be one of the actions that appear in the actions list. "one of the actions" is unclear, of whether it means syntactic equivalence or semantic equivalence. Examples are:

action a() {}
control c() {
    table t {
        actions = { .a; }
        default_action = a; /* semantically, a is the same as .a here, but not syntactically */
    }
    apply {}
}
control c()
{
  bit<2> tt;
  action a(in bit v1, in bit v2) { tt = v1++v2; }
  action a1(in s v) { tt = v.f0++v.f1; }
  table t
  {
    actions = { a1({ f0 = ext0(), f1 = ext1()}); }
    default_action = a1({ f1 = ext1(), f0 = ext0()}); /* also, semantically the same arguments, but not syntactically */
  }
  apply {}
}

For the latter case, it may be problematic if ext0() and ext1() is side-effecting, as the order of which they are called affects the program semantics.

It is probably too onerous to precisely state what the same is in the spec, but at least there is an unclear part in the current spec we might want to discuss further.

Below are related tests in the p4c test suite:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions