[P4-dev] Multiple table invocation problem

Andy Fingerhut andy.fingerhut at gmail.com
Tue Apr 11 13:29:58 EDT 2017


Ricardo:

Here is a much smaller 'control ingress' block that gives similar errors:

control ingress {

    if (test_metadata.test0 == 1) {

        apply(table7);

        apply(table1);

    } else {

        apply(table7);

    }

}


Antonin Bas has written up an explanation for this limitation here:
https://github.com/p4lang/p4c/issues/457

In your dummy.p4 code, it look like it has this structure:

if (condition1) {

    if (condition2) {

        // lots of code here

        repeated block of code #1

    }

} else {

    repeated block of code #2

}


You could try restructuring it to something like this:


my_metadata.do_it = 0;

if (condition1) {

    if (condition2) {

        // lots of code here

        my_metadata.do_it = 1;

    }

} else {

    my_metadata.do_it = 1;

}

if (my_metadata.do_it == 1) {

    what used to be the repeated block of code, but is now not repeated

}


In P4_16, you could write those assignments in the control block
directly.  In P4_14, I believe it can only be done by requiring little
'dummy tables' that have no search key, and an action that does
nothing but the desired modify_field(my_metadata.do_it, <value>);


Andy



On Tue, Apr 11, 2017 at 5:55 AM, Ricardo Santos <ricardo.santos at kau.se>
wrote:

> Hello,
>
> During the process of compiling a p4 program with some conditions in the
> ingress control code (using p4c-bm), I received some error messages
> referring to tables being invoked multiple times, although I'm not seeing
> any part of my code where that can happen.
>
> I've replicated a simplified version of the control block of my program
> (in attachment) using the same condition ordering and with dummy
> values/tables, which is producing a similar output when using p4c-bm:
>
> ~/p4c-bm/p4c_bm/__main__.py dummy.p4 --json dummy.json
> parsing successful
> semantic checking successful
> Header type standard_metadata_t not byte-aligned, adding padding
> Header type test_metadata_t not byte-aligned, adding padding
> ERROR: Table(s): ['table8', 'table7', 'table6', 'table4'] are invoked
> multiple times and have have next pointers set to:
> [p4_conditional_node._condition_6]
> Error while building HLIR
>
> Could anyone help me understanding what is happening in the attached code
> that is producing these compilation errors, and also how should I fix it?
> Meanwhile I could get rid of the errors by creating copies of the
> conflicting tables (i.e. table4_1, table4_2), but obviously that's not the
> most memory efficient solution.
>
> Thank you.
>
> Best regards,
> Ricardo Santos
>
> --
> Ricardo Santos
> PhD student
> Department of Mathematics and Computer Science
> Karlstad University
> +46 54 700 1073
>
>
> _______________________________________________
> P4-dev mailing list
> P4-dev at lists.p4.org
> http://lists.p4.org/mailman/listinfo/p4-dev_lists.p4.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p4.org/pipermail/p4-dev_lists.p4.org/attachments/20170411/52fda6f4/attachment-0002.html>


More information about the P4-dev mailing list