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

Mihai Budiu mbudiu at vmware.com
Wed Oct 18 16:00:01 EDT 2017


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=


More information about the P4-dev mailing list