Vendor Logo

Open Networking Foundation – p4c

p4c is a reference compiler for the P4 programming language.

p4c is modular; it provides a standard frontend and midend which can be combined with a target-specific backend to create a complete P4 compiler. The goal is to make adding new backends easy. The code contains five sample backends:

  • p4c-bm2-ss: can be used to target the P4 simple_switch written using the BMv2 behavioral model,
  • p4c-dpdk: can be used to target the DPDK software switch (SXS) pipeline
  • p4c-ebpf: can be used to generate C code which can be compiled to eBPF and then loaded in the Linux kernel for packet filtering,
  • p4test: a source-to-source P4 translator which can be used for testing, learning compiler internals and debugging,
  • p4c-graphs: can be used to generate visual representations of a P4 program; for now it only supports generating graphs of top-level control flows, and
  • p4c-ubfp: can be used to generate eBPF code that runs in user-space.

One fact attesting to the level of quality and completeness of p4c’s code is that its front-end code, mid-end code, and p4c-graphs back end are used as the basis for at least one commercially supported P4 compiler.

For more information, visit the p4c repository.

Contact us

Fill out the form below, and we will be in touch shortly.