[P4-dev] VL field bitwidth needs to be a multiple of 8

Antonin Bas antonin at barefootnetworks.com
Wed Jul 19 18:59:46 EDT 2017


Looks like a p4c-bm2-ss compiler bug to me. I opened a Github issue:
https://github.com/p4lang/p4c/issues/781
Your P4 program is correct, but the generated bmv2 JSON is not. As a
workaround (while waiting for the issue to be fixed), you may be able to
replace (ihl << 2) with ((ihl << 2) - 20) * 8. This is no longer correct
P4, but will leverage the p4c-bm2-ss bug to get your program running on
bmv2.

On Wed, Jul 19, 2017 at 3:18 PM, Regis Martins <regisftm at gmail.com> wrote:

> Hello people!
>
> I'm trying to create a variable length field on my ipv4 header, as
> following:
>
> ...
>
> header_type ipv4_t {
>     fields {
>         version     : 4;
>         ihl         : 4;
>         diffserv    : 8;
>         totalLen    : 16;
>         id          : 16;
>         flags       : 3;
>         fragOffset  : 13;
>         ttl         : 8;
>         protocol    : 8;
>         hdrChecksum : 16;
>         srcAddr     : 32;
>         dstAddr     : 32;
>         options_ipv4: *;
>     }
>     length          : (ihl << 2);
>     max_length      : 60;
> }
>
>
> ...
>
>
> The compilation works fine, however the fist packet_in (it is a ping),
> abends the bmv2 with the following message:
>
> [19:05:52.601] [bmv2] [D] [thread 6991] [33.0] [cxt 0] Parser 'parser':
> start
> [19:05:52.601] [bmv2] [D] [thread 6991] [33.0] [cxt 0] Parser state
> 'start' has no switch, going to default next state
> [19:05:52.601] [bmv2] [T] [thread 6991] [33.0] [cxt 0] Bytes parsed: 0
> [19:05:52.601] [bmv2] [D] [thread 6991] [33.0] [cxt 0] Extracting header
> 'eth'
> [19:05:52.601] [bmv2] [D] [thread 6991] [33.0] [cxt 0] Parser state
> 'parse_eth': key is 0800
> [19:05:52.601] [bmv2] [T] [thread 6991] [33.0] [cxt 0] Bytes parsed: 14
> [19:05:52.601] [bmv2] [D] [thread 6991] [33.0] [cxt 0] Extracting header
> 'tmp_hdr'
> [19:05:52.601] [bmv2] [D] [thread 6991] [33.0] [cxt 0] Parser set: setting
> field 'scalars.tmp' from expression, new value is 4
> *[19:05:52.601] [bmv2] [D] [thread 6991] [33.0] [cxt 0] Extracting
> variable-sized header 'tmp_hdr_0'*
> *simple_switch: parser.cpp:288: virtual void
> bm::ParserOpExtractVL::operator()(bm::Packet*, const char*, size_t*) const:
> Assertion `nbits % 8 == 0 && "VL field bitwidth needs to be a multiple of
> 8"' failed.*
>
> Any clue about what is happening?
>
> Please, let me know if there you need further information...
>
> Regards,
>
> *Regis Martins*
>
> _______________________________________________
> 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/20170719/64dbaa08/attachment-0002.html>


More information about the P4-dev mailing list