[P4-dev] apply() a table more than once in different branches of a conditional

Antonin Bas antonin at barefootnetworks.com
Wed Oct 18 16:51:46 EDT 2017


I can confirm that this example cannot be represented in the bmv2 JSON
profile. If the bmv2 compiler backend lets it through, it's a bug.

On Wed, Oct 18, 2017 at 1:00 PM, Mihai Budiu <mbudiu at vmware.com> wrote:

> This is a restriction of a particular P4 compiler back-end; it models
> limitations of the behavioral model, which in turn models restrictions on
> some kinds of pipelined hardware architectures.
>
> If you are saying that you found a program that at runtime does something
> different than the spec says it should do, then this is a compiler bug;
> please give us more details so we can reproduce this bug.
>
> Mihai
>
> -----Original Message-----
> From: P4-dev [mailto:p4-dev-bounces at lists.p4.org] On Behalf Of edgar
> costa molero
> Sent: Wednesday, October 18, 2017 12:07 PM
> To: p4-dev at lists.p4.org
> Subject: [P4-dev] apply() a table more than once in different branches of
> a conditional
>
> Hi all,
>
>
>
> If you apply the same table in a sequential way i.e:
>
>
>
> table.apply();
>
> table.apply();
>
>
>
> The compiler complains: it says that the program requires a cycle
> containing table.
>
>
>
> However, if you place the calls to apply() in different if branches such
> that only one can be executed, the compiler does not complain….but weird
> things start happening. If we consider the following code:
>
>
>
> if (condition 1){
>
>     if (condition 2){
>
>         tableA.apply();
>
>     }
>
>     else {
>
>        //first call to table B
>
>        tableB.apply();
>
>
>
>        // MORE CODE X
>
>    }
>
>
>
> else {
>
>     //second call to table B
>
>     tableB.apply();
>
>
>
>     //MORE CODE Y
>
> }
>
>
>
> In the code snippet above we can see that tableB can be called if
> (condition 1 and not condition 2), and the second call if (not condition
> 1). You can see also that after this calls there is some code that is
> different: code x and code y. So far, so good. But when you send a packet
> to the switch that will trigger the call to the first tableB.apply() (I
> verified checking the switch’s log), Code Y is executed instead of Code X.
>
>
>
> I understand that for some hardware limitations you don’t allow calls to
> the same table twice. But then, why is the compiler not complaining in the
> scenario above ? And why  is the apply() function returning/jumping to
> “CODE Y” ?
>
>
>
> Kind regards,
>
> Edgar
> _______________________________________________
> P4-dev mailing list
> P4-dev at lists.p4.org
> https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.
> p4.org_mailman_listinfo_p4-2Ddev-5Flists.p4.org&d=DwIGaQ&
> c=uilaK90D4TOVoH58JNXRgQ&r=tGW6TKXajnoXSyy1S1P4DHGPe8sj54GGvw-b21n7aWg&m=
> mFK28FpAj5iB0Tnh2z39PLz6tFPNtKWl0dMjvVW7pSU&s=
> UuonGMhC7HwoZGAnxD_nJU5-AaFGr_x_E_bAoP6SbPk&e=
> _______________________________________________
> P4-dev mailing list
> P4-dev at lists.p4.org
> http://lists.p4.org/mailman/listinfo/p4-dev_lists.p4.org
>



-- 
Antonin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p4.org/pipermail/p4-dev_lists.p4.org/attachments/20171018/d75e072d/attachment-0002.html>


More information about the P4-dev mailing list