[P4-dev] storing metadata while parsing header stacks

Salvatore Signorello salvatore.signorello at uni.lu
Fri Jul 17 12:16:35 EDT 2015


Thank you a lot, Mihai,

This trick works smoothly for the simple MPLS example I've used to
illustrate the issue. I hope I can exploit such workaround into a
different workflow I'm working on too.

Best,
Salvatore
On Fri, 2015-07-17 at 08:24 -0700, Mihai Budiu wrote:
> The valid bits of the header stack can be interpreted as a base 1
> encoding of the number you are looking for. If you want it in base 2
> you can use a table for converting it.
> 
> Mihai
> 
> ______________________________________________________________________
> From: Salvatore Signorello
> Sent: ‎7/‎17/‎2015 0:56
> To: p4-dev at p4.org
> Subject: [P4-dev] storing metadata while parsing header stacks
> 
> 
> 
> Hi all,
> any advice for the following:
> 
> Suppose to have an MPLS stack parsed as follows:
> 
> #define MPLS_DEPTH 5
> header mpls_t mpls[MPLS_DEPTH];
> 
> parser parse_mpls{
>     extract(mpls[next]){
>         return select(latest.bos){
>             0 : parse_mpls;
>             1 : parse_mpls_bos;
>         }
>     }
> }
> 
> and that you would like to know (and to store somewhere, like into a
> metadata block) how many MPLS headers (a number that is likely lower
> than MPLS_DEPTH) have been parsed at the end of the parsing process.
> What to do?
> Could metadata be used like a kind of counter?
> Could register be indexed somehow during the parsing and set through
> the set_metadata?
> 
> Thank you in advance,
> best,
> Salvatore Signorello


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p4.org/pipermail/p4-dev_lists.p4.org/attachments/20150717/0542ab51/attachment-0001.html>


More information about the P4-dev mailing list