P4C
The P4 Compiler
|
P4Tools is a collection of tools that make testing P4 targets and programs a little easier. So far the platform supports the following tools and projects:
Please see the general installation instructions here. P4Tools can be built using the following CMAKE configuration in the P4C repository.
These dependencies are automatically installed via CMakelist's FetchContent module.
Currently, each C++ source directory has a few subdirectories, including:
core
, containing the core functionality of the submodule; andlib
, containing supporting data structures.The distinction between the two can be fuzzy. Here are some guiding principles for where to find/put what:
core
, it belongs in core
.lib
.P4Tools in general follows the P4C coding style. Some deviations from the Style Guide are highlighted below.
/// An example class demonstrating a documentation comment. class C {};
.h
file, unless providing a library of related classes. Multiple classes may be declared in a .cpp
file.P4Testgen is a test oracle for the P4 language. Given a P4_16 program and a specification of the underlying architecture, it automatically generates a comprehensive set of input/output tests that can be executed to validate a target device.
Jed Liu was the original architect of P4Testgen and designed the abstract machine that allows using P4C's visitors to implement arbitrary traversals of the program IR. Building on Jed's design, Fabian Ruffy completed the symbolic interpreter for P4_16's core features and designed extensions for common open-source architectures. He also developed the model of packets, taint tracking, and concolic execution. Prathima Kotikalapudi developed the extensible test backend, with instantiations for PTF and STF. Vojtěch Havel assisted with the implementation of the symbolic interpreter and the development of P4Testgen extensions for several Intel architectures. Hanneli Tavante added support for strategies that guide the exploration of paths that maximize various notions of coverage. Volodymyr Peschanenko, and Vlad Dubina developed the SMT-LIB interface to Z3, implemented front-end and mid-end passes such as parser unrolling, and completed the back end for the V1Model architecture on the BMv2 simple switch. Nate Foster guided the design of P4Testgen and contributed to various aspects of the symbolic interpreter.