What happens when a table with actions defined but without any keys defined?

Hi there,

I found out an example that has some tables with actions defined but without keys defined, such as

  @name(".flowlet") table flowlet {
      actions = {
          lookup_flowlet_map;
      }
  }

When we apply this table, what will happen? It seems that it has no effect? And I ran p4-graphs to get the graph representation, which shows that p4c added a default NoAction to the table.

Does this mean we have to explicitly set lookup_flowlet_map as default such that we will always invoke lookup_flowlet_map action with whatever packets we have? like this:

  @name(".flowlet") table flowlet {
      actions = {
          lookup_flowlet_map;
      }
       @defaultonly default_action = lookup_flowlet_map;
  }

One more question is what the annotation @name means?

regards,

If a P4 table has no key fields, then it is not possible to add any entries to the table.

Thus every .apply() operation on the table will get a miss when it does a lookup.

Thus the table’s default_action will be executed.

If the default_action is explicitly defined in the source code, that is the table’s default_action at the time the P4 program is loaded. If it has const default_action, the control plane is not allowed to change it at run time. Without the const, the control plane is allowed to configure the table’s default_action at run time.

If there is no default_action in the table’s definition, then the language spec and p4c both define that it is the same as if you explicitly wrote default_action = NoAction();, so the default_action is initially a “no op” action, but it can be modified later by the control plane.

Thanks for your detailed explanation!