[P4-dev] Slight Problem with a Boolean Expression

Peter Newman petenewm at cisco.com
Thu Aug 13 15:13:16 EDT 2015


Antonin,

Glad to hear it is not simply my own ignorance.

Top of page 55, section 12 in the spec:
"If the same table is invoked in multiple places from the control
flow, those invocations all refer to the same table instance; that is, 
there is only one set
of statistics, counters, meters, and match+action entries for the table. 
Targets may impose
limitations on these table invocations such as disallowing recursion, 
only allowing
tables to be referenced once, or only allowing control flow functions to 
be referenced
once."

I was attempting a very simple control flow for a trivial test program 
of the form:

if you can route, do ip routing followed by layer 2 forwarding
else just do layer 2 forwarding

--Peter

On 8/13/2015 12:04 PM, Antonin Bas wrote:
> Hi,
>
> I don't think the spec allows this. Could you share the page number 
> with me?
>
> Our compiler only allows applying a given table once.
> So doing this:
> apply(table1);
> apply(table2);
> apply(table1);
> in a control flow is forbidden by the p4lang frontend (for now).
>
> Some cases which should be ok are handled incorrectly by the compiler. 
> For example:
> if(/some_condition/) {
>   apply(table1);
>   apply(table2);
> }
> else {
>   apply(table1);
>   apply(table3);
> }
>
> However most of the times, these cases can easily be rewritten in a 
> form that will be accepted by the compiler. In our example:
> apply(table1);
> if(/some_condition/) {
>   apply(table2);
> }
> else {
>   apply(table3);
> }
>
> On Thu, Aug 13, 2015 at 11:59 AM, Peter Newman <petenewm at cisco.com 
> <mailto:petenewm at cisco.com>> wrote:
>
>     Antonin,
>
>     Thanks. I guess it is time to update my tool set.
>
>     At the risk of sharing my ignorance with the entire community I
>     also get the following compiler error:
>
>     ERROR: Table 'layer2_forwarding' is invoked multiple times.
>
>     The spec specifically states that I can invoke the same table
>     multiple times as long as it is the same identical table. Is this
>     another old compiler version problem? I'm invoking the compiler
>     with the command: 'p4-validate'.
>
>     --Peter
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p4.org/pipermail/p4-dev_lists.p4.org/attachments/20150813/e5874c25/attachment-0001.html>


More information about the P4-dev mailing list