P4: specifying data planes http://P4.org Intel Hillsboro, OR

P4: specifying data planes http://P4.org Intel  Hillsboro, OR

P4: specifying data planes http://P4.org Intel Hillsboro, OR July 10, 2018 Mihai Budiu VMware Research Group My Background Ph.D. from CMU (computer architecture, compilers) Microsoft Research (security, big data, machine learning) Barefoot Networks (P4 design and implementation) VMware Research (P4, SDNs, big data)

Note: I am not a networking person 2 My involvement with P4 Hired at to work on the design and implementation of P4 In Barefoot led the group that created the first P416 draft document Started (with Chris Dodd) the C++ reference compiler implementation Main contributor to the open-source P4 compiler front-end, mid-end and several back-ends Pushed P416 through standardization process Currently co-chair of the P4 language design working group 3

What I can talk about today P416 programming language Language design Language/architecture separation Portability vs. extensibility P416 reference compiler architecture How to extend the compiler for a new target Compiling P4->eBPF Compiling to eBPF (packet filters) Compiling to XDP (packet switching) Comparing P4 and eBPF These are organized as 3 separate PPTX presentations 4

What I dont plan to cover P414 (the old version of P4) Run the P4 tutorials (given at P4 developer days) Demonstrate P4-related tools (compilers, simulators, IDEs) The P4 control-plane API (P4Runtime) The P4 Portable Switch Architecture Various applications written in P4 5 Presentation outline P4 & Programmable networks Why should you care? An introduction to P416 P4 limitations

Conclusions 6 Networking 101 Data packets switches/ routers 7 Switch Control and Data Planes Switch architecture Control plane

packets Data plane Interfaces 8 Traditional switch architecture Control-plane CPU Control plane Data plane Table management Switch ASIC

Look-up tables (policies) 9 Software-Defined Networking Policies/signaling Controller Dumb control plane Data plane 10 The P4 world Upload program Policies/signaling

Dumb control plane SW: P4 Programmable data plane 11 Not just for switches! Control plane SW: P4 Programmable switches FPGA switches Programmable network cards Software switches Hypervisor switches

You name it Programmable data plane 12 How is this possible? Hello ? Most useful if you have your own network playground Datacenter 13

Data-planes From now on in this presentation we only talk about the data-plane We expect that SDN will continue to evolve the control-plane Control plane Data plane 14 WHY SHOULD YOU CARE? 15 P4.org Consortium

Carriers, cloud operators, chip cos, networking, systems, universities, start-ups 16 Isnt Open-Flow Enough? Headers 36 12 1 40 41

1.3 1.4 15 1.1 1.2 Open-Flow version Open-flow has never been enough: it keeps changing to describe new protocols Very fragmented 17

Protocols = programs VxLAN: 175 lines of P4 Took 4 years from proposal to wide availability NVGRE: 183 lines of P4 M. Shahbaz, S. Choi, B. Pfaff, C. Kim, N. Feamster, N. McKeown, J. Rexford, PISCES: A Programmable, Protocol-Independent Software Switch SIGCOMM 2016 40 times reduction in the size of the OvS parser Much easier to add new protocols Same performance 18 Use only what you need

IETF has issued thousands of RFCs Switch RAM and CPU is very expensive Network operators can remove protocols Simpler troubleshooting 19 Network monitoring measurements (custom headers)

Monitoring agent ork Telemetry (INT) work Monitoring and Managementwith Programmable Data Planes a & LJ Wobker 20 Optimize your network Push application functionality in the network High speed Paxos Made Switch-y Huynh Tu Dang, Marco Canini, Fernando Pedone, Robert Soul CCR April 2016

21 Network = software Use software engineering principles and tools Upgrade your network at any time Protocols = intellectual property 22 AN INTRODUCTION TO P416 23 Language evolution P4: Programming Protocol-Independent Packet Processors Pat Bosshart, Dan Daly, Glen Gibb, Martin Izzard, Nick McKeown, Jennifer Rexford, Cole Schlesinger, Dan Talayco, Amin Vahdat,

George Varghese, David Walker ACM SIGCOMM Computer Communications Review (CCR). Volume 44, Issue #3 (July 2014) P4 v1.0 spec, reference implementation and tools released in Spring 2015 (mostly by Barefoot Networks), Apache 2 license, http://github.com/p4lang. P416 spec, draft reference implementation and tools released in December 2016; spec finalized May 2017; v1.1 in June 2018 http://github.com/p4lang/p4-spec 24 P4 Community http://github.com/p4lang http://p4.org Free membership! Mailing lists Workshops P4 developer days

Academic papers (SIGCOMM, SOSR) 25 P4 working groups Language design: evolves P4 Control-plane API: defines API between control-plane and P4 program (P4Runtime) Applications: defines interoperable applications (e.g. In-band Network Telemetry) Architecture (Portable Switch Architecture): standardizes portable architecture models Education 26 Available Software Tools Compilers for various back-ends Netronome chip, Barefoot chip, eBPF, Xilinx FPGA

(open-source and proprietary) Multiple control-plane implementations SAI, OpenFlow, P4Runtime Simulators Testing tools Sample P4 programs IntelliJ plugin IDE, editor modes Tutorials 27

P4 software workflow User-supplied P4 program P4 architecture model P4 compiler Dataplane runtime API Control-plane

LOAD LOAD API Tables control signals extern objects Data plane target Manufacturer supplied

28 P416 Most recent revision of P4 C-like syntax; strongly typed No loops, pointers, recursion, dynamic allocation Spec: http://github.com/p4lang/p4-spec Reference compiler implementation (Apache 2 license): http://github.com/p4lang/p4c 29 P416 Language Overview

Suitable for L2 & 3 High-level, type, memory-safe (no pointers) Bounded execution (no loops) Statically allocated (no malloc, no recursion) Sub-languages: Parsing headers Packet header rewriting Target architecture description 30 P416 data plane model Programmable blocks

Data plane P4 Fixed function P4 P4 Interfaces 31 Example packet processing pipeline Programmable parser eth vlan ipv4 Headers

Payload Packet (byte[]) Programmable match-action units eth ipv4 port mtag err bcast Metadata

Queueing/ switching Not programmable Headers eth mtag ipv4 Programmable reassembly Packet 32 Language elements Programmable parser

State-machine; bitfield extraction Programmable match-action units Table lookup; bitfield manipulation; control flow Programmable reassembly Bitfield packing Data-types

Target description External libraries Bitstrings, headers, structures, arrays user target Interfaces of programmable blocks Support for custom accelerators 33 Basic data types bit, int

e.g., bit<128>, int<1024> int is twos complement varbit<13> Container up to specified size; dynamic size is shorter Only operation is copying bool enum, error, match_kind error { PacketTooShort, ParseError } error.PacketTooShort Only string constants supported typedef 34

Structures, headers typedef bit<32> IPv4Address; header IPv4_h { bit<4> version; bit<4> ihl; bit<8> tos; bit<16> totalLen; bit<16> identification; bit<3>

flags; bit<13> fragOffset; bit<8> ttl; bit<8> protocol; bit<16> hdrChecksum; IPv4Address srcAddr; IPv4Address dstAddr; } // List of all recognized headers struct Parsed_packet { Ethernet_h ethernet; IPv4_h

ip; header = struct + valid bit 35 Other derived types Array of headers H[6] arr; Fixed size Unions of headers header_union IP { ipv4 v4header; ipv6 v6header; }

Tuples tuple, bit<16>> set, bit<16>> - implicit only No recursive types 36 Expression language Standard arithmetic/logic on arbitrary bitstrings But no funky undefined cases like in C

2s complement for signed values No division/modulo Bit-slicing, bit concatenation Integers are not Booleans No implicit casts 37 Extern objects Model hardware accelerators or behaviors not expressible in P4 Generic type extern Register { Register(bit<32> size); constructor T read(in bit<32> index);

void write(in bit<32> index, in T value); } instantiation Register>(1024) reg; Method calls using copy-in, copy-out Like Java interfaces 38 Packets = byte streams extern packet_in { void extract(out T headerLvalue); void extract(out T varSizeHdr, in bit<32> varFieldSizeBits);

T lookahead(); bit<32> length(); void advance(in bit<32> bits); } extern packet_out { void emit(in T hdr); void emit(in bool condition, in T data); } 39 Parsing = State machines dst src type

ethernet header IP header IP payload parser Parser(packet_in b, out Parsed_packet p) { state start { start b.extract(p.ethernet); transition select(p.ethernet.type) { 0x0800: parse_ipv4; default: reject; parse_ipv4 } }

state parse_ipv4 { accept reject b.extract(p.ip); transition accept; } } Parser states can contain cycles => loops bounded by packet size 40 Value Sets parser p(packet_in pk, out Headers h) { value_set>(4) vs; state start { pk.extract(h); transition select(h.f) {

vs: next; default: reject; } } } A set of 32-bit values changed dynamically by the control plane. 41 Actions ~ Objects with a single method. Straight-line code. Reside in tables; invoked automatically on table match. Action data; from control plane action Set_nhop(IPv4Address ipv4_dest, PortId port) { nextHop = ipv4_dest; outCtrl.outputPort = port;

} class Set_nhop { } IPv4Address ipv4_dest; PortId port; void run() { nextHop = ipv4_dest; outCtrl.outputPort = port } Java/C++ equivalent code. 42 Tables

Map table ipv4_match { key = { headers.ip.dstAddr: exact; } actions = { drop; Set_nhop; } default_action = drop; } Populated by the control plane dstAddr action drop Set_nhop(, 4) drop 00 drop

Set_nhop(, 6) 43 headers & metadata Table = Match-Action Processing Control plane Lookup Key Lookup key

Action action code & data hit action code action data Action Lookup table Default action

Execute Data headers & metadata 44 Control-Flow Ipv4_match control Pipe(inout Parsed_packet headers, in InControl inCtrl,// input port out OutControl outCtrl) { // output port IPv4Address nextHop; // local variable action Drop_action() { }

action Set_nhop() { } table ipv4_match() { } apply { // body of the pipeline ipv4_match.apply(); if (outCtrl.outputPort == DROP_PORT) return; dmac.apply(nextHop); if (outCtrl.outputPort == DROP_PORT) return; smac.apply(); } } dmac smac

45 Packet Construction Convert headers back into a byte stream. Only valid headers are emitted. control Deparser(in Parsed_packet p, packet_out b) { apply { b.emit(p.ethernet); b.emit(p.ip); } } 46 P4 Program structure

#include #include #include #include // core library // target description "library.p4" // library functions "user.p4" // user program 47 Architecture declaration Provided by the target manufacturer struct input_metadata { bit<12> inputPort; } struct output_metadata { bit<12> outputPort; } parser Parser(packet_in b, out H headers);

H = user-specified header type control Pipeline(inout H headers, in input_metadata input, out output_metadata output); control Deparser(in H headers, packet_out p); package Switch(Parser p, Pipeline p, DeparserSwitch d); Parser Pipeline Deparser 48 Support for custom accelerators

extern bit<32> random(); External function extern Checksum16 { void clear(); // prepare unit for computation void update(in T data); // add data to checksum void remove(in T data); // remove data from checksum bit<16> get(); // get the checksum for data added External object with methods. Methods can be invoked like functions. } Some external objects can be accessed from the control-plane. 49

Execution model When a block is invoked (parser, control) it executes to completion on a separate thread All local variables are thread-local Only inter-thread communication possible through extern objects and functions Execution triggered by outside event (e.g., packet arrival) Actions execute atomically @atomic annotation 50 P4 LIMITATIONS 51

Limitations of P416 The core P4 language is very small Highly portable among many targets But very limited in expressivity Accelerators can provide additional functionality May not be portable between different targets Standard architectures to ensure portability Portable switch architecture (PSA) Library of standard accelerators (counters, meters, etc) No standard smart NIC architecture exists! 52 What is missing

Floating point Pointers, references Data structures, recursive data types Dynamic memory management Loops, iterators (except the parser state-machine) Recursion Threads => Constant work/byte of header 53

What cannot be done in (pure) P4 Multicast or broadcast Queueing, scheduling, multiplexing Payload processing: e.g., encryption Packet trailers Persistent state across packets Communication to control-plane Inter-packet operations

(fragmentation and reassembly) Packet generation Timers 54 How are these done? Multicast, broadcast, queueing, scheduling, multiplexing By target device, controlled by P4 metadata Persistent state across packets (e.g. per-flow state) External objects: registers, counters, meters Communication to control-plane External objects: learning providers Packet generation Control-plane, or external objects

TCP-style reassembly, trailers: Not currently done 55 Why use P4? It is a standardized language: you can specify the data-plane precisely Expressive: express many packet-forwarding policies High-level, type-safe: compiler-managed abstract resources Software: treat network devices like software Killer app: network monitoring

56 Creating a Programming Language Interface in a place where there wasnt one. The P4 ProgrammingLanguage Interface U P L O A D Control plane Data plane

57 References P4: Programming Protocol-Independent Packet Processors Pat Bosshart, Dan Daly, Glen Gibb, Martin Izzard, Nick McKeown, Jennifer Rexford, Cole Schlesinger, Dan Talayco, Amin Vahdat, George Varghese, David Walker ACM SIGCOMM Computer Communications Review (CCR). Volume 44, Issue #3 (July

2014) The P4-16 Programming Language Mihai Budiu and Chris Dodd ACM SIGOPS Operating Systems Review, Vol. 51, no 1, August, 2017, pages 5-14 P4-16 open-source compiler source tree: https://github.com/p4lang/p4c P4-16 language v1.1.0 specification: https://p4.org/p4-spec/docs/P4-16-v1.1.0-draft.pdf Compiler design full presentation: https://github.com/p4lang/p4c/blob/master/docs/compiler-design.pptx P4Runtime draft spec: https://p4lang.github.io/p4-spec/docs/P4Runtime-v1.0.0.pdf 58 BACKUP SLIDES 59

P416 goals Strictly more expressive than P414 Minimally change and simplify P414 Same building-blocks: headers, parsers, match-action, control Well-defined semantics for all constructs Move target-specific constructs from language into libraries Support a variety of targets (ASICs, NICs, FPGAs, etc.) Based on well-understood techniques (no need to invent new language constructs) Strong type system Support for good software engineering practices 60

P414 dataplane model Control-plane 61 P414 to P416 evolution P416 small, Standardized, rarely change core.p4 P4 v1.0 library.p4 arch.p4

Can be large, manufacturer controlled, frequent changes 62

Recently Viewed Presentations

  • We would expect appropriate members of staff to

    We would expect appropriate members of staff to

    The Prevent Strategy 'Extremism' Vocal or active opposition to fundamental British values, including democracy, the rule of law, individual liberty and mutual respect and tolerance of different faiths and beliefs.
  • Union Bank of Nigeria Plc, H1 2012 Facts

    Union Bank of Nigeria Plc, H1 2012 Facts

    branches that caters for both rural and sub-urban regions in Nigeria. ... In order to maintain and grow the customer loyalty and brand recognition enjoyed by the bank, a rebranding drive has been initiated to make the brand more visible.
  • The University of Sheffield: PowerPoint template

    The University of Sheffield: PowerPoint template

    The University of Sheffield, UK Impact fees and exactions in the UK Planning agreements: where do they fit into the UK planning system? The recent growth in the use of planning agreements Case study: the role of agreements in the...
  • Introductory Chemistry Fifth Edition Nivaldo J. Tro Chapter

    Introductory Chemistry Fifth Edition Nivaldo J. Tro Chapter

    Compound: A pure substance composed of two or more elements in fixed definite proportions . Compounds are more common than pure elements. Most elements are chemically reactive and combine with other elements to form compounds. Water, table salt, and sugar...
  • Winter 2014-2015 Florida Standards Assessments English ...

    Winter 2014-2015 Florida Standards Assessments English ...

    School assessment coordinators and test administrators must ensure that students have enough desk space to use their planning sheets. ... Four-function calculators must be provided to students for Grade 8 Science.
  • Constructed Wetlands and Wastewater Treatment

    Constructed Wetlands and Wastewater Treatment

    Constructed Wetlands and Wastewater Treatment Scott Stine SWES 574 Types of Constructed Wetlands Surface Flow Wetlands (SF) similar to natural wetlands free floating, emergent, and submerged plants are used Subsurface Flow Wetlands (SSF) water flows below surface of support media...
  • Over/Under-Reaction of Stock Markets

    Over/Under-Reaction of Stock Markets

    Section VIII: Stock Returns Around Earnings Announcement Dates The stocks are ranked in ascending order on the basis of 6-month lagged returns. The stocks in the lowest past return decile are called the losers group and the stocks in the...
  • Diapositive 1 - mcofch.org

    Diapositive 1 - mcofch.org

    Le nettoyage du bâtiment se fera le 20 mai 2017 de 9h00 à 12h00. Message de Frère Vito. Bienvenue à tous et aux visiteurs dans le précieux nom de notre Seigneur et Sauveur Jésus-Christ à qui nous avons par son...