Number of Range Check allowed in any function

Hello guys
My question is, How many range checks are allowed in any function or action in p4-16. Or alternatively, you can tell how many parameters we can pass to any function or action in p4-16.

If any of you worked with p4-14 then please tell the same info about p4-14 also. and what has changed to p4-16 from p4-14 for this range check work.

The P4 language does not impose any constraints on the complexity of the code in a function or action. Various targets may have hardware-induced limitations.
What do you call “range check”?

Is there any limitation on the number of parameters in the function declaration of the action part in P4_16 and P4_14?


The language itself does not limit the number of parameters in an action or a function. However, that does not mean that a particular implementation (especially if we consider high-speed hardware) won’t impose its own limits.

Think about C language. The language itself does not limit the size of the program, but if you are going to compile C for a microcontroller with only few KB of memory and s very small, fixed size stack, the target (that microcontroller) will severely limit what kinds of programs you can write (as well as the number of parameters that can be passed into a function).

Perhaps, it might be better if you describe the problem you are trying to solve first, because right now we can only give you pretty general answers, which are correct, but at the end of the day probably not very helpful to you.

Happy hacking,

The problem I am trying to solve is to create a table and then forward the packet. In my action part, there will be many conditions(IF statement), and based on that I will forward the packet.


  1. How many conditional checks (IF statements), I can have in 1 action.
    2)How many parameters I can pass to a function or action so that I can use more IF statements.

So the answer to the question “How many conditions checks (IF statements), I can have in 1 action.” unfortunately depends upon what target device you are compiling a P4 program to run on. Without knowing a target device, no one can answer that question.

The same applies to your question 2.

I am using BMV2 model.

I believe there is no limit on the number of IF statements in an action for the BMv2 target, but there is a limit on what KIND of if statements are supported. See this documentation for examples of things that are supported and that are not: behavioral-model/ at main · p4lang/behavioral-model · GitHub

I have just created a pull request to update all of the dates in that document for this month, because the limitations mentioned in there are still as true today as they were in 2019 and 2020 when the dates were originally put there.