main.p4
represents the reference pipeline for Broadcom's fixed-function switches,
but can also be used on Tofino or software switches.
Stratum has integrated Bazel rules to compile included P4 programs as part of the source tree.
To compile main.p4
for all supported platforms, including Broadcom's fixed-function switches,
only a single command is needed:
bazel build //stratum/pipelines/main:main_pipelines
The output tarball can be located by running: bazel aquery //stratum/pipelines/main:main_pipelines | grep Outputs
, but the intermediate files are also available in bazel-bin
.
We also publish the p4c-fpm
compiler as a Docker container. Have a look at the code of our ONF Connect 2019 demo.
If you prefer a native install, there is a Debian package that you can build:
bazel build //stratum/p4c_backends/fpm:p4c_fpm_deb
dpkg -i bazel-bin/stratum/p4c_backends/fpm/p4c_fpm_deb.deb
In a production setup this is the job of a SDN controller like ONOS.
For testing and exploration purposes a tool like p4runtime-shell is useful.
./p4runtime-sh-docker \
--grpc-addr <switch ip>:9339 \
--device-id 1 --election-id 0,1 \
--config <path to main.p4info>,<path to main.pb.bin>
See: p4c-fpm README