[P4-dev] Pop all headers in a stack?

David Hancock dhancock at cs.utah.edu
Mon Jun 27 10:51:59 EDT 2016


Tu Dang,

In spec v1.0, the count argument for the pop primitive must be a VAL, 
which is a constant or an action parameter.  However, I do not believe 
bmv2 sswitch allows the use of an action parameter for this purpose, so 
if you are using sswitch, you can only use a constant for the count 
argument.  You should verify this.

But you can still remove all headers in a header stack easily enough.  
Just pop using the same value for "count" as you used when you declared 
the header stack.  Popping 100 headers, even if there's only one valid 
header in the stack, should work just fine.

--David

On 06/27/2016 07:35 AM, Huynhtu Dang wrote:
> Dear all,
>
> I try to remove all header stack using pop operation, but hitting a semantic error. I guess POP operation requires integer type for the “count” argument. As I know so far, in P4 v1.0 spec, there is no int type. Is there any way to cast a field to “int” type in P4 v1.0 or other ways to remove all headers in a header stack?
>
> The code snippet to show the problem is pushed here:
> https://gist.github.com/tudang/4ddb635d381332d3b3ecc655d0af7dbf
>
> Best Regards,
> Tu Dang
> _______________________________________________
> P4-dev mailing list
> P4-dev at lists.p4.org
> http://lists.p4.org/mailman/listinfo/p4-dev_lists.p4.org





More information about the P4-dev mailing list