cloudparts

P4

A programming language for the data plane: it describes which headers a switch, NIC or software switch parses and which match-action tables it applies, so packet processing can be changed by recompiling instead of waiting for new chips.

Linux Foundation project
Type
Open source
Made by
P4 project (Linux Foundation)
Foundation
The Linux Foundation, joined January 2024. Moved from the Open Networking Foundation in 2024; supported by a directed fund with its own governing board
License
Apache 2.0 (specifications, compiler and reference tools)
Facts checked
28 October 2026

What it is

OpenFlow let a controller fill a switch’s tables, but the tables themselves, and the headers they could match, were fixed by the chip. P4 goes one level lower: it is a domain-specific language for describing how a data plane device processes packets. A P4 program declares the headers it knows about, a parser written as a state machine that extracts them, control blocks made of match-action tables (match these fields exactly, by longest prefix or by range, then run one of these actions) and a deparser that writes the headers back out. The language has no built-in idea of Ethernet or IPv4; a program defines whatever protocols it needs. The tables start empty, and the control plane adds and removes entries at run time.

Each target exposes an architecture, a description of its programmable blocks and fixed functions that a program fills in: v1model for the reference software switch, the Portable Switch Architecture (PSA) and the Portable NIC Architecture (PNA), or a vendor’s own. The reference compiler, p4c, has backends for BMv2 (simple_switch, the behavioural model used for learning and testing), for DPDK’s software switch pipeline, and for eBPF and XDP in the Linux kernel. It also emits a P4Info file describing the program’s tables and actions, which P4Runtime, a gRPC API, uses to let a remote controller manage them. The current specifications are P4₁₆ 1.2.5 (October 2024), P4Runtime 1.5.0 (February 2026), PSA 1.2 and PNA 0.7.

The best-known hardware target was Barefoot Networks’ Tofino switch chip, which Intel bought in 2019 and stopped developing in 2023; Intel open-sourced its Tofino P4 software in January 2025, and the community has turned towards SmartNICs, IPUs and software targets. P4 was run by P4.org, then by the Open Networking Foundation from 2019, and became an independent Linux Foundation project in early 2024. The project is active in 2026: p4c ships monthly releases, and the EuroP4 workshop meets in Utrecht in December.

Why teams pick it

  • Defines new headers and forwarding behaviour in software, without waiting for a new chip or a new standard
  • One language and one compiler front end for switches, NICs, software switches and the Linux kernel
  • A standard control-plane API, P4Runtime, generated from the program itself
  • Open specifications and Apache 2.0 tools, with a reference software switch for testing programs before hardware

Watch out for

  • Hardware choice has narrowed: Tofino, the flagship programmable switch chip, is no longer being developed
  • Programs are tied to an architecture, so moving between targets often means rewriting and recompiling, and each target has its own limits on tables and stages
  • Only describes the data plane: you still need a control plane to fill the tables, through P4Runtime or a vendor API
  • A specialist skill: writing P4 well requires knowing both networking protocols and the target pipeline’s resources

Alternatives

What all software-defined networking have in common →Compare side by side →

How it fits with other technologies

Parser and a match-action table from a P4₁₆ program for the v1model architecture (excerpt: checksum, egress and deparser blocks left out) · text

#include <core.p4>
#include <v1model.p4>

header ethernet_t { bit<48> dstAddr; bit<48> srcAddr; bit<16> etherType; }
struct headers_t { ethernet_t ethernet; }
struct metadata_t { }

parser MyParser(packet_in pkt, out headers_t hdr,
                inout metadata_t meta, inout standard_metadata_t std) {
    state start { pkt.extract(hdr.ethernet); transition accept; }
}

control MyIngress(inout headers_t hdr, inout metadata_t meta,
                  inout standard_metadata_t std) {
    action forward(bit<9> port) { std.egress_spec = port; }
    action drop() { mark_to_drop(std); }

    table mac_table {
        key = { hdr.ethernet.dstAddr: exact; }
        actions = { forward; drop; }
        size = 1024;
        default_action = drop();
    }

    apply { mac_table.apply(); }
}

See it in a real stack

No architecture uses P4 yet. Drop it into the playground and wire it up yourself.Open playground →
Where it came from2014–2026

In July 2014 Pat Bosshart, Nick McKeown, Jennifer Rexford, Amin Vahdat, George Varghese and others published “P4: Programming protocol-independent packet processors”. Their argument was that OpenFlow kept adding header fields to a fixed list, and that switches should instead be reconfigurable: the controller should say how packets are parsed and processed. Barefoot Networks, which McKeown and Bosshart had co-founded in 2013, launched Tofino in 2016, a switch chip programmed in P4, and the language was revised into P4₁₆. P4.org, the language consortium, ran the specifications and the p4lang tools on GitHub.

In March 2018 P4.org agreed to join the Open Networking Foundation, completing the move on 9 April 2019. Barefoot had released Tofino 2 in 2018; Intel announced it would buy Barefoot in June 2019, but in January 2023 it stopped developing Tofino, including its third generation, leaving P4 without a new flagship switch chip. In January 2025 Intel open-sourced its Tofino P4 software as open-p4studio.

When the ONF merged its projects into the Linux Foundation, P4 became an independent LF project. ONF announced the move on 4 January 2024: a directed fund seeded by ONF, and a governing board in place of the old advisory board, with technical direction left to the elected Technical Steering Team. In 2026 the project published P4Runtime 1.5.0 and kept monthly p4c releases.

Why it’s built this way

Protocol-independent
Instead of a language that knows Ethernet, IP and so on, P4 makes programs declare their own headers and parsers, so new protocols need a new program, not a new chip or a new version of the language.
Target-independent through architectures
Separating the language from each target’s architecture lets one compiler front end and one language serve ASICs, NICs and software switches, while each vendor describes what its pipeline can do.
Generate the control-plane API from the program
Because the tables are defined in the program, the compiler can describe them for P4Runtime, so a controller can manage any P4 device through the same API.

Timeline

  1. 2014

    P4 paper published in July

  2. 2016

    Barefoot launches Tofino, a P4-programmable switch chip

  3. 2019

    P4.org joins the Open Networking Foundation on 9 April; Intel agrees to buy Barefoot in June

  4. 2023

    Intel stops Tofino development in January

  5. 2024

    Becomes an independent Linux Foundation project; P4₁₆ 1.2.5 in October

  6. 2025

    Intel open-sources its Tofino P4 software in January

  7. 2026

    P4Runtime 1.5.0 in February

Sources10 · facts checked 28 October 2026

Improve this page on GitHub