[P4-dev] Why do we need header stacks?

hemant at mnkcg.com hemant at mnkcg.com
Thu Dec 27 12:07:34 EST 2018


MPLS and VLAN protocols push/pop labels or add/delete tags respectively.
For example with q-in-q VLAN, one VLAN tag is removed or added.  An array of
headers helps because P4 can uses h[0].setInvalid() to remove a label and
use h[0].isValid() to check for a valid label.  An array is easier than
using a linked list.  You can look for examples of mpls[] and vlan[] in
P4-16 switch code with URL below.

 

https://github.com/jafingerhut/p4lang-tests/blob/master/v1.0.3/switch-2017-0
3-07/out1/switch-translated-to-p4-16.p4

 

Hemant

 

From: P4-dev <p4-dev-bounces at lists.p4.org> On Behalf Of Wu, Xiaoban
Sent: Thursday, December 27, 2018 11:45 AM
To: p4-dev at lists.p4.org
Subject: [P4-dev] Why do we need header stacks?

 

Dear All,

 

Could anyone please tell me in the real-world application, in which scenario
would we consider using an array of header instances with the same header
type?

 

In the P4 spec, it says "MPLS and VLAN tags are examples that might be
treated this way", however I still don't quite understand it. Could anyone
please elaborate on this? Thanks very much.

 

Best wishes,

Xiaoban

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p4.org/pipermail/p4-dev_lists.p4.org/attachments/20181227/9a6224b9/attachment.html>


More information about the P4-dev mailing list