-
Notifications
You must be signed in to change notification settings - Fork 10
03 Lucid tofino compiler
./dptc prog.dpt -o prog_build
compiles the lucid program prog.dpt
into a P4-tofino project in the prog_build
directory. The three most important files in the build directory are:
-
lucid.p4
-- the P4 program. -
lucid.py
-- a python control script used to install compiler-generated multicast rules for event duplication (e.g.,generate_ports
). This script must be run from inside of the tofino'sbfshell
agent, e.g., with$SDE/run_bfshell.sh -b lucid.py
. -
globals.json
-- a json file mapping each global defined in the Lucid program to an object in the resulting P4 program, along with additional type information. This file makes it easier to write custom control programs for Lucid data planes.
The tofino backend has a few additional restrictions on Lucid programs.
-
Each control flow of a handler may only call
generate_port
once andgenerate_ports
once. This is necessary for the Lucid compiler to guarantee thatgenerate_port
andgenerate_ports
can always be implemented without requiring recirculations. In P4, agenerate_port(p, ...)
compiles into setting the unicast output port of the current packet top
, whilegenerate_ports({p1, p2, ..., pn}, ...);
compiles into setting the multicast group of the current packet to a Lucid-created group containing portsp1, p2, ..., pn
. Note that the base generate function, which always sends the event to the local recirculation port, may be used an unlimited number of times in a control flow. -
A handler is only allowed to generate one instance of each event in each control flow.
-
Every event parameter must either start or end on a byte boundary.
The programs in examples/tofino_apps/src
are regularly compiled and tested on the Tofino's ASIC reference model.