[P4-dev] Loops in p4 action definitions

Andy Fingerhut andy.fingerhut at gmail.com
Thu Jul 13 10:57:12 EDT 2017


P4 does not have variable length loops, by design, to bound the amount of
work done per packet to a fixed amount (or at least a fixed amount per
control block).

I do not know if it would work in your situation, but if the maximum number
of loop iterations is a compile time constant, you can use a
Perl/Python/whatever-language-you-like program to generate an 'unrolled'
version of your loop as a P4 program.  See this earlier message for an
example:

http://lists.p4.org/pipermail/p4-dev_lists.p4.org/2017-April/000908.html

Andy

On Thu, Jul 13, 2017 at 3:49 AM, Hassan Ali Khan <18100116 at lums.edu.pk>
wrote:

> Hi All;
>
> Does anyone know how to add loops in action definition associated with a
> table. We are working on a project which requires us to make seperate
> states depending on the outgoing links. If we have a fixed value for the
> links we want to iterate over that value to maintain the states.
>
> We would really appreciate if someone can suggest any method.
>
>
> Regards,
> Hassan Ali Khan
> 2018-10-0116
>
> _______________________________________________
> 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/20170713/5509a027/attachment-0002.html>


More information about the P4-dev mailing list