p4-spec icon indicating copy to clipboard operation
p4-spec copied to clipboard

Issue #722: Document restrictions on types IH and EH in PSA

Open jafingerhut opened this issue 2 years ago • 7 comments

jafingerhut avatar Mar 05 '22 19:03 jafingerhut

Intended to address this issue https://github.com/p4lang/p4-spec/issues/722

jafingerhut avatar Mar 05 '22 19:03 jafingerhut

Why does section 7.2.7 of p4-16 working doc does not allow header_union as a member of struct?

hesingh avatar Oct 28 '22 17:10 hesingh

@hesingh If I go to the working draft of the P4_16 specification here: https://p4.org/p4-spec/docs/P4-16-working-spec.html#sec-type-nesting the first table I see has a row labeled "header_union", and in the column labeled "struct or tuple" the table entry says "allow". Do you see something different, or interpret that somehow as not being allowed?

jafingerhut avatar Oct 28 '22 21:10 jafingerhut

I see

struct | allowed2 | error | allowed

7.2.7. Type nesting rules

The table below lists all types that may appear as members of headers, header unions, structs, and tuples. Note that int means an infinite-precision integer, without a width specified.

   

  |   |   |   bit<W> | allowed | error | allowed int<W> | allowed | error | allowed varbit<W> | allowed | error | allowed int | error | error | error void | error | error | error error | error | error | allowed match_kind | error | error | error bool | allowed | error | allowed enum | allowed1 | error | allowed header | error | allowed | allowed header stack | error | error | allowed header_union | error | error | allowed struct | allowed2 | error | allowed tuple | error | error | allowed   |   |   |  

Rationale: int does not have precise storage requirements, un

7.2.7. Type nesting rules The table below lists all types that may appear as members of headers, header unions, structs, and tuples. Note that int means an infinite-precision integer, without a width specified

hesingh avatar Oct 28 '22 21:10 hesingh

This row in that table:

struct | allowed2 | error | allowed

means:

struct is allowed as a member in a header (the column heading of the second column), but see footnote 2. it is an error if you attempt to use a struct as a member of a header_union struct is allowed as a member in a struct or tuple

jafingerhut avatar Oct 28 '22 21:10 jafingerhut

Note something is going on with the draft HTML generation though, see https://github.com/p4lang/p4-spec/issues/1175 . The released spec 1.2.3 is correct.

apinski-cavium avatar Oct 28 '22 21:10 apinski-cavium

@jafingerhut Duh, got it, sorry. Your proposal looks fine.

hesingh avatar Oct 28 '22 21:10 hesingh