p4lang / p4runtime

Specification documents for the P4Runtime control-plane API
Apache License 2.0
146 stars 88 forks source link

OK to restrict P4Runtime v1.0 to serializable enum, but not a 'type' on top of it? #192

Open jafingerhut opened 5 years ago

jafingerhut commented 5 years ago

Right now p4c supports type bit<8> mytypename;, but not this:

enum bit<8> myenum1_t {
    A = 1,
    B = 2
}
type myenum1_t mytypename;

It supports the enum definition, but not the type definition on top of it.

Any thoughts on whether this is a serious issue for P4Runtime v1.0? I would not be surprised if it were straightforward to extend p4c and the P4_16 language spec to say that the case above is explicitly supported, but so far it is not.

jafingerhut commented 5 years ago

Also, if an action parameter, table search key field, etc. has a type that is a serializable enum type (like myenum1_t in my previous comment code snippet), is it expected that the type name myenum1_t should appear as the value of the type_name field describing that thing?

jafingerhut commented 5 years ago

OK, maybe my last comment on this issue, but who knows?

then:

jafingerhut commented 5 years ago

AI for me to think about this a little bit more, and clarify the limitation if there is one.

Agreed that this combination of a serializable enum with a type definition "on top of it" is probably unlikely to be a burning desire for anyone to run out and use in their P4 programs. This questions in this issue are really from someone (me) worrying over what combinations of things to test in the p4c compiler, and which ones will or won't work.