Skip to content

Latest commit

 

History

History
53 lines (34 loc) · 1.78 KB

README.md

File metadata and controls

53 lines (34 loc) · 1.78 KB

Compiling main.p4

main.p4 represents the reference pipeline for Broadcom's fixed-function switches, but can also be used on Tofino or software switches.

Inside Bazel

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.

Docker p4c-fpm

We also publish the p4c-fpm compiler as a Docker container. Have a look at the code of our ONF Connect 2019 demo.

Debian package

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

Pushing the pipeline to a switch

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>

More information on the p4c-fpm compiler

See: p4c-fpm README