Skip to content

Enabling T4P4S

signorello edited this page Aug 25, 2022 · 4 revisions

Enabling T4P4S backend

If you use the web interface to launch your P4 program, you only need to select T4P4S as target for the program you want to run. All the following steps can be skipped in that case.

If you use P4Pi from a terminal (either ssh or web terminal), you must be sure to stop and disable the bmv2 service first and then enable t4p4s one with the following commands (as a sudo user):

systemctl stop bmv2.service
systemctl disable bmv2.service
systemctl enable t4p4s.service

Disabling the bmv2 service is required to prevent any conflicts with the t4p4s one.

Afterwards, you can simply start or simply restart the t4p4s.service to run a certain program with T4P4S. Note, however, that the name of the P4 project to be compiled and executed should be placed in the /root/t4p4s-switch file (the same file works for both t4p4s and bmv2 backends). For example, the l2switch example program (located in the folder /root/t4p4s/examples/p4edge/l2switch) can be launched with the following two commands:

echo "l2switch" > /root/t4p4s-switch
systemctl restart t4p4s.service

You can stop any currently running P4 program by simply stopping the T4P4S service like follows:

systemctl stop t4p4s.service

Customizing the parameters of T4P4S

The related service runs the /usr/bin/t4p4s-start script. If you needed different configuration settings, you could modify this script.

Additional tools

P4Pi comes with a preinstalled P4Runtime Shell (p4rtshell) which can be used to leverage the P4Runtime API through port 50051. To make its usage easier, we have created a helper script that fills the required parameters and connect to the target switch. Our helper script can be invoked like follows:

t4p4s-p4rtshell l2switch

The above command hands the .p4info and .json files of the P4 project provided as a cmdline argument (l2switch in this case).

Clone this wiki locally