Hi,
While working with the DASH P4 program, I noticed some differences in how serializable_enums are represented in the generated p4info text format, as well as some missing enum definitions. For example, I see two different encodings for the same enum values:
serializable_enums {
key: "dash_tunnel_dscp_mode_t"
value {
underlying_type { bitwidth: 16 }
members {
name: "PRESERVE_MODEL"
value: "\000\000"
}
members {
name: "PIPE_MODEL"
value: "\000\001"
}
}
}
and alternatively:
"dash_tunnel_dscp_mode_t": {
"underlyingType": {
"bitwidth": 16
},
"members": [
{
"name": "PRESERVE_MODEL",
"value": "AAA="
},
{
"name": "PIPE_MODEL",
"value": "AAE="
}
]
},
Both represent the same underlying values (0x0000 and 0x0001), but the encoding differs — one uses escaped binary (\000\001), the other uses base64 ("AAE="). The first one is form the dash_pipeline_p4rt.txt file and the other one is from the dash_pipeline_p4rt.json
My questions are:
-
What is the difference between these two encodings in practice?
Are both valid according to the P4Runtime spec, or is one preferred forserializable_enumvalues inp4info? -
I’ve noticed that not all
serializable_enumsdefined indash_headers.p4anddash_metadata.p4are emitted into the generateddash_pipeline_p4rt.json/.txtfiles.
Specifically, the following enums are defined in the P4 source but do not appear in theserializable_enumssection of thep4info:dash_pipeline_stage_t dash_eni_mac_type_t dash_packet_source_t dash_packet_subtype_t dash_packet_type_tI’d like to understand why these are omitted. Is this:
-
Because they’re not referenced in any tables, actions, or metadata?
-
A backend/compiler optimization to exclude unused types?
-
A bug or limitation in
p4cor the DASH build flow?
-
From the P4Runtime v1.0.0 Specification §8.5.5:
“Serializable enum types have an underlying fixed-width unsigned integer representation (bit). All named enum members must be assigned an integer value by the P4 programmer, but not all valid numeric values for the underlying type need to have a corresponding name. P4TypeInfo includes the mapping between entry name and entry value…”
However, it’s not clear:
-
Under what circumstances a
serializable_enumdefined in the P4 source is guaranteed to appear in thep4infooutput. -
Whether there’s a way to force inclusion of all defined enums regardless of their usage.
-
Why different generated files sometimes use base64 vs escaped binary for the same values.
-
If different backends or versions of
p4cgenerate escaped vs base64 encodings.
Is there a known rule for when enums appear in p4info, or a flag to force inclusion of all serializable enums regardless of usage?
Thanks!
