1)For a given entry in table, I have more than 1 ranges. The example you gave is about 1 range so how will I handle more than 1 ranges is action part because the packet will only lie in one of these ranges.
Do I need to pass all the min_vals and max_vals to action function or is there some other way of doing this available.
Andy replies: Yes, you can pass all min_vals and max_vals to a single action, and have multiple range checks performed within the same action. I am sure there are other ways, but that way is straightforward and should do what you want.
Is there any functionality like array available in P4.
Andy replies: There are currently no arrays available in P4, except in the form of header stacks, which are like arrays, but each element is a value with the same header type.
2)How will I pass these values action function from table, do I need to specify them in json file or is there any other way possible to pass the values to action function.
Andy replies: Every parameter of an action that is an action of some table, that doesn’t have a direction like in/out/inout, must have the value of that action parameter specified by the control plane software when it adds an entry to the table that uses the action.
Any json file you are describing, e.g. like used in the p4lang/tutorials repository, is a special custom-crafted json schema for those examples, and are basically always implemented by having some control plane software read the json file, and then make the necessary control plane calls to add the desired table entries to the data plane. They typically only let you specify the initial table entries to add when the control plane software starts up, but after that they will never change. You can write whatever control plane software you want, that could read from a json or any other file format you want to describe initial table entries, if you wish, or you can write control plane software that never reads from any files at all, and uses other mechanisms to decide what table entries to add. Control plane software is a program you can write, and do whatever you want it to do.
3)Is it possible to implement dynamic ranges in action function like if the values of ranges changes , I don’t need to modify code ?
Andy replies: If the min and max values are parameters of actions that are installed as table entries, then without changing any P4 code, you can change the action parameters by modifying the entries currently installed in a table, deleting entries in a table, adding new entries to a table, etc. from the control plane software.