p4lang / pna

Portable NIC Architecture
Apache License 2.0
55 stars 21 forks source link

Add assert and assume extern functions to PNA include file? #65

Open jfingerh opened 1 year ago

jfingerh commented 1 year ago

They have recently been added to the PSA include file with this commit: https://github.com/p4lang/p4-spec/blob/main/p4-16/psa/psa.p4#L340-L403

Do we want these added to pna.p4 include file as well? They can be very useful in testing of P4 code on software-based devices, e.g. BMv2 and DPDK. Typically they would be compiled as no-ops on hardware targets.

jfingerh commented 1 year ago

TODO Andy: Discussing this with Cristian Dumitrescu on precisely how these would be implemented on DPDK.

Note that they are already implemented on BMv2 for the v1model architecture. The PSA implementation for BMv2 is only partial as of 2022-Oct, with no one that I know of currently actively working to finish it. Similarly, I do not know of anyone working on BMv2 implementation of PNA architecture at this time.

apinski-cavium commented 1 year ago

+1 from me.

thomascalvert-xlnx commented 1 year ago

Is the architecture include file the right place for defining these methods? It seems to me like they would be better placed in an orthogonal header (e.g. core.p4), as there is really nothing architecture-specific about these 2 methods.

jnfoster commented 1 year ago

@thomascalvert-xlnx in general, we are conservative about adding types and primitives to core.p4 as they must be implemented by every architecture (and therefore every compiler backend). So for assert and assume we first added them to V1Model. The idea was always that if they were useful, and there was a push to use them in more architectures, then we would consider them as candidates for addition to core.p4 instead. Maybe now is the time to have that discussion.