Intel has launched a toolkit that allows for the creation of custom applications for packet processing in programmable Ethernet switches of the Tofino series. Under the Apache 2.0 license, the source code for the p4c compiler backend and components of the Intel P4 Studio development environment, such as drivers, the switch simulation model, and the server and client for the BF Runtime protocol, has been released. The applications are created using the domain-specific programming language P4 (Programming Protocol-independent Packet Processors), which is designed to define the packet processing logic in network devices such as network interface cards, switches, routers, and firewalls.
The published backend allows for the translation of programs written in P4 into a format suitable for installation on Intel Tofino switches. This enables switch users to create applications that extend the built-in functionality, alter operational logic, or adapt the device to the specific needs of their networks.
Programs written in P4 are compiled into representations for target platforms, which can be either hardware (FPGA, programmable ASIC) or software (x86, BPF). Along with the code for installation on the target systems, the compiler generates runtime for application management using Protobuf/gRPC protocols and the P4Runtime API.
The typical logic of program operation involves classifying packets based on their headers and executing actions on incoming packets, such as redirecting, dropping, modifying TTL, and replacing fields. The language is not tied to network protocols and, instead of built-in support for standard protocols like IP, Ethernet, TCP, and VxLAN, it provides developers with the ability to define any protocols in relation to the compiled applications (the developer attaches a description of header formats and protocol fields).

In addition to the published backend for Intel Tofino switches, the P4 project provides a backend for compiling P4 applications into C code, which can then be compiled into a format suitable for execution in virtual machine eBPF within the Linux kernel. The project also develops an open switch simulator that can be used for experiments in a virtual Mininet network, along with a backend for compiling P4 programs for the simulator.
Source: opennet.ru
