[P4-dev] [bmv2] Why does the <H> headers struct forbit nested structs?

Kamila Součková kamila at ksp.sk
Fri Feb 1 12:02:39 EST 2019


> Since around January 7th, 2019, p4c supports a nested bit-vector struct
inside a P4 header. However, since the p4c bmv2 backend does not support
nested structs, a midend pass flattens the header. See the spec changes
that are being made to p4c regarding the code that was checked in.

Ah, okay, so this is a general problem with nested structs, rather than a
specific problem with the `headers_t` struct, correct?

> https://github.com/p4lang/p4-spec/pull/719/files

Is this change already implemented in bmv2, or is it a future thing? Does
it mean that I could change the design to use a "struct > header >
struct"-like wrapping (instead of my current "struct > struct > header")?

For the record, the code I am trying to compile is something along the
lines of:

```
header scion_isdas_h {
    bit<12>   isd;
    bit<20>    as;
}

struct scion_addr_header_t {
    scion_isdas_h dst_isdas;
    // more header-type fields...
}

struct scion_header_t {
    scion_common_h      common;
    scion_addr_header_t addr;
    // more struct-type fields...
}
```

> Off hand, I don’t know of an alternative target that supports nested
structs.

Thanks for the info.

Thanks a lot!

Best,
Kamila
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p4.org/pipermail/p4-dev_lists.p4.org/attachments/20190201/50e895cf/attachment.html>


More information about the P4-dev mailing list