[P4-dev] Where to implement if-else apart from control flow to set value

Swaroop Thool swaroopthool1991 at outlook.com
Tue Aug 18 12:41:25 EDT 2015

Hi All,

I am learning p4. I want to know where can steps be written to implement simple operations. 

1)  Where can I put snippet shown below which can set a field of metadata/register means, in control flow or action only? for example: If I want to use if-else statement where comparison between metadata fields are considered and output of it should set one field from that metadata.
I have seen if-else are only used to call "apply(table)" in control part and I also cannot carry out if-else in action definition of that table.

Above example: I didnt find syntax to directly find minimum among three. This is simple snippet to find minimum of three. I get syntax error when I tried to use in control or action part. So I want to use like this without creating new table.
      if ((local_metadata.val1 < local_metadata.val2) and (local_metadata.val1 < local_metadata.val3)){
                 modify_field(local_metadata.minimum, local_metadata.val1)
      else if ((local_metadata.val2 < local_metadata.val3) and (local_metadata.val2 < local_metadata.val1)){
                modify_field(local_metadata.minimum, local_metadata.val2)
              modify_field(local_metadata.minimum, local_metadata.val3) 

How can this be implemented in p4 terms and inside what?

2) I came across serial and parallel semantics. What if I want use value of 1st modify_field() into next modify_field() under same action definition. Is parallel behaviour can be changed?

3) I am unclear with Action Profile part of specification to implement it. Can anyone explain it?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p4.org/pipermail/p4-dev_lists.p4.org/attachments/20150818/a98d8b3d/attachment-0001.html>

More information about the P4-dev mailing list