[P4-discuss] deparsing in P4 1.0.3

Antonin Bas antonin at barefootnetworks.com
Tue Jan 24 11:01:48 EST 2017


Hi Ali,

This has been covered several times on the P4 mailing lists, so I'm sure
you can find some info in the archives.
- If a header instance is valid but is not present in the parse graph, it
will not be serialized as the deparser would not know where to serialize it
(i.e. after which header).
- Your example is not a valid parse graph because it is not a DAG.
Therefore a topological sorting cannot be computed, which is needed to
program the deparser.
- Because we use *a* topological sorting to program the deparser and a
topological sorting may not be unique, a P4 programmer can sometimes
observe funky results, where a specific header is not serialized in the
expected position. See for example the discussion here:
http://lists.p4.org/pipermail/p4-dev_lists.p4.org/2016-June/000373.html.
This is why in P4_14 we sometimes add "dummy transitions" to the graph, as
a way to add edges and constrain the topological sorting.
- Things get a little blurry in the case of header stacks. I can only talk
for my compiler here (p4c-bmv2). If we consider the following P4 parse
state:
mpls_t mpls[3];
parser parse_mpls {
    extract(mpls[next]);
    return select(latest.bos) {
        0 : parse_mpls;
        1 : ingress;
    }
}
The compiler will expand the mpls vertex into 3 vertices: mpls[0] ->
mpls[1] -> mpls[2]. While it is likely that they will be serialized as a
group, it is not guaranteed if I can find a topological sorting where the 3
instances are not contiguous.

Thanks,

Antonin

On Mon, Jan 23, 2017 at 5:27 PM, Ali Kheradmand <a.i.kheradmand at gmail.com>
wrote:

> Hi,
>
> In section 5 of P4 language specification version 1.0.3 it is stated that
> "P4 takes the approach that any format which should be generated on egress
> should be represented by the parser used on ingress." Does that mean that
> if a header instance is valid (e.g an action adds the instance) but is not
> used in the parser, it won't be serialized?
>
> Also regarding cycles in the parse graph, the specification says "In
> general, cycles occur in the parse graph when parsing header stacks or a
> set of optional headers. These may be treated as a single node in the parse
> graph and serialized as a group." Does it mean any permutation of header
> instances in a strongly connected component of parse graph is acceptable as
> an order of serialization?
>
> e.g are both ABC and ACB acceptable in:
>
> parser start {
>    extract(A);
>    return select (A.a) {
>       1: P1;
>       2: P2;
>    }
> }
>
> parser P1 {
>    extract(B);
>    extract(C);
>    return ingress;
> }
>
> parser P2 {
>    extract(C);
>    extract(B);
>    return ingress;
> }
>
> ?
> I see that p4c-bmv2 rejects this program.
>
> Regards,
> Ali
>
>
>
>
> _______________________________________________
> P4-discuss mailing list
> P4-discuss at lists.p4.org
> http://lists.p4.org/mailman/listinfo/p4-discuss_lists.p4.org
>



-- 
Antonin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p4.org/pipermail/p4-discuss_lists.p4.org/attachments/20170124/5c78dec3/attachment-0002.html>


More information about the P4-discuss mailing list