vmware-archive / p4c-xdp

Backend for the P4 compiler targeting XDP
Apache License 2.0
171 stars 26 forks source link

Compiler support for htons, htonl, htonll #118

Open maharishib opened 5 years ago

maharishib commented 5 years ago

These functions(htons,htonl,htonll) are defined in "ebf_common.h". Can we include compiler support for them, so that we can use this functionality from p4 program?

mihaibudiu commented 5 years ago

In general it is not sustainable to add special support to the compiler for whatever functions may be needed. One thing we can do, though, is to define a calling convention in C and to allow the users to implement any functions that are declared as "extern" and not known by the model. The bmv2 back-end already does this.

Also, please note that there is a long-standing bug related to the (internal) use of htonll in p4c-ebpf and p4c-xdp: https://github.com/p4lang/p4c/issues/1122, which no one had time to fix so far.

mihaibudiu commented 5 years ago

BTW: if we do this we will probably do it in the ebpf back-end rather than in the xdp back-end, because the xdp back-end automatically inherits all the features of the ebpf back-end.