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

Huynhtu Dang huynh.tu.dang at usi.ch
Mon Jun 27 11:40:20 EDT 2016


Thanks, David,

My fault. I thought every VAL argument could be an expression. I try your suggestion that supplies the maximum numbers of headers in the stack and it works like a charm. 

Cheers,
Tu Dang

> On Jun 27, 2016, at 4:51 PM, David Hancock <dhancock at cs.utah.edu> wrote:
> 
> 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
> 
> 
> _______________________________________________
> 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