[P4-dev] A question about header instances byte aligned

Antonin Bas antonin at barefootnetworks.com
Thu Apr 27 12:08:22 EDT 2017


I agree that there seems to be a contradiction in the spec. Producing an
error should abort compilation, so what would be the point of padding...
As long as the header instance is metadata, padding does not matter as the
header cannot be serialized / deserialized (this is the case in the example
you give). If the header instance is not metadata and is used to store
packet data, the right thing to do would probably be to abort the
compilation with an error to avoid potentially surprising behavior.
I personally think this is a minor issue. I like the approach of P4_16,
which leaves byte-alignment enforcement and padding up to the specific
target you are compiling to.

On Thu, Apr 27, 2017 at 2:30 AM, <ding.rui at zte.com.cn> wrote:

> In the P4 language specification(Version 1.0.3 November 2, 2016), it
> described as blew:
>
> "For header instances, the compiler must produce an error if the total
> length of all
> fields in a header type is not an integral number of bytes. The compiler
> may pad
> the header to be byte aligned."
>
> when I am learning tutorials/SIGCOMM_2015/flowlet_switching(https:/
> /github.com/p4lang/tutorials/tree/master/SIGCOMM_2015/flowlet_switching)
>
> I found the ingress_metadata_t  didn't byte aligned. The total length is
> 171 bits, but the p4c-bmv2 only indicate a warning and compile passed.
>
> I think if  a header type is not an integral number of bytes,the compiler
> must produce an error and compile must stopped.If the compiler can
>
> pad the header to be byte aligned,  the warning is useless.
>
> header_type ingress_metadata_t {
>
>     fields {
>
>         flow_ipg : 48; // inter-packet gap
>
>         flowlet_map_index : FLOWLET_MAP_BITS; // flowlet map index
>
>         flowlet_id : 16; // flowlet id
>
>         flowlet_lasttime : 48; // flowlet's last reference time
>
>         ecmp_offset : 14; // offset into the ecmp table
>
>         nhop_ipv4 : 32;
>
>     }
>
> }
>
> hll at hll:/home/opendaylight/p4lang/tutorials-master/SIGCOMM_2015/flowlet_switching/solution/p4src$
> p4c-bmv2 simple_router.p4  --json simple_router.json
>
> parsing successful
>
> semantic checking successful
>
> Header type standard_metadata_t not byte-aligned, adding padding
>
> Header type ingress_metadata_t not byte-aligned, adding padding
>
> WARNING:p4c_bm.gen_json:The P4 program defines a checksum verification on
> field 'ipv4.hdrChecksum'; as of now bmv2 ignores all checksum
> verifications; checksum updates are processed correctly.
>
> Generating json output to /home/opendaylight/p4lang/
> tutorials-master/SIGCOMM_2015/flowlet_switching/solution/
> p4src/simple_router.json
>
>
>
>
>
> _______________________________________________
> P4-dev mailing list
> P4-dev at lists.p4.org
> http://lists.p4.org/mailman/listinfo/p4-dev_lists.p4.org
>



-- 
Antonin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p4.org/pipermail/p4-dev_lists.p4.org/attachments/20170427/c37bf8a7/attachment-0002.html>


More information about the P4-dev mailing list