[P4-dev] storing metadata while parsing header stacks

Salvatore Signorello salvatore.signorello at uni.lu
Mon Jul 20 03:11:54 EDT 2015


Hi Mihai,

a follow-up scenario:

we suppose that in the previous example instead of having MPLS headers,
we have another encapsulation protocol, let's call it XYZ. As before, we
may have n chained XYZ headers and we are interested in figuring out how
many of those are included into a parsed packet. However, this time, we
need to figure out such number, because we need to know how many fields
to match into a table like the following:


table xyz{
    reads{
        xyz[0].field : exact;
        xyz[1].field : exact;
                    .
                    .
                    .
        xyz[n].field : exact; // this 'n' has been defined as constant
in parser.p4
    }
    actions{
        performSomething;
    }
}

The above table has to perform an exact match on the fields of the same
type for all the consecutive xyz headers.

Now, we suppose that at we've used the trick you proposed to count the
XYZ headers (base 1 encoding + table to convert in base 2) and we want
to describe the program flow.
I've figured out a very dumb way to describe such workflow, that is:
we define separate table for all the cases (e.g., the first one matching
only a xyz.field, the second one matching two consecutive xyz.fields,
and so on till n fields) and then we use the counter to navigate a chain
of if-else blocks into the main control flow.
Do you see any better ways to describe such scenario?

Caveat: I think that we cannot use ternary matches on a single table,
because the mask we need is defined at run-time by the number of xyz
headers parsed. Please point me wrong, if I'm mistaken.

Thank you in advance,
best,
Salvatore


On Fri, 2015-07-17 at 18:16 +0200, Salvatore Signorello wrote:

> 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
> 
> 
> 
> _______________________________________________
> P4-dev mailing list
> P4-dev at p4.org
> Listinfo - http://mail.p4.org/mailman/listinfo/p4-dev_p4.org
> Archives - http://mail.p4.org/pipermail/p4-dev_p4.org/


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p4.org/pipermail/p4-dev_lists.p4.org/attachments/20150720/5e73df15/attachment-0001.html>


More information about the P4-dev mailing list