programming the network data plane in p4

9
SIGCOMM’16 Tutorial Barefoot Networks Aug 2016 1 Programming The Network Data Plane in P4

Upload: others

Post on 06-Jun-2022

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Programming The Network Data Plane in P4

SIGCOMM’16Tutorial

Barefoot NetworksAug 2016

1

Programming The Network Data Plane in P4

Page 2: Programming The Network Data Plane in P4

Switch Pipeline

Protocol-Independent Switch Architecture (PISA)

Prog

ram

mab

lePa

rser

MatchMemory

ActionALU

Page 3: Programming The Network Data Plane in P4

Logical Data-plane View (your P4 program)

Switch Pipeline

Protocol-Independent Switch Architecture (PISA)

8

Queues

Pars

er

Fixe

d Ac

tion

Mat

ch T

able

Mat

ch T

able

Mat

ch T

able

Mat

ch T

able

L2IPv4

IPv6ACL

Actio

n M

acro

Actio

n M

acro

Actio

n M

acro

Actio

n M

acro

Page 4: Programming The Network Data Plane in P4

Mat

ch T

able

Actio

n M

acro

Mapping to Physical Resources

9

Queues

Pars

er

Mat

ch T

able

Mat

ch T

able

Mat

ch T

able

L2 T

able

IPv4

Tab

le

IPv6

Tab

le

ACL

Tabl

e

Actio

n M

acro

Actio

n M

acro

Actio

n M

acro

L2IPv4

IPv6ACL

Logical Data-plane View (P4)

Switch Pipeline

L2

IPv6ACL

IPv4

L2 A

ctio

n M

acro

v4 A

ctio

n M

acro

v6 A

ctio

n

ACL

Actio

n M

acropacket

Page 5: Programming The Network Data Plane in P4

P4: Three Goals

Protocol independence◦ Define a packet parser◦ Define a set of typed match+action tables

Target independence◦ Program without knowledge of packet-processing device details◦ Let compilers configure the target device

In-field Re-configurability◦ Allow the users to change parsing and processing program in the field

11

Page 6: Programming The Network Data Plane in P4

Parser Match+Action TablesQueues/

Scheduling

Packet Metadata

P4-Based Workflow

•Device is not yet programmed◦ Does not know about any packet formats or protocols

14

Page 7: Programming The Network Data Plane in P4

Protocol Authoring

1

Compile2

Control4

Parser Match+Action TablesQueues/

Scheduling

Packet Metadata

IPv4 IPv6

VLANEth

Run-time APIDriver

Switch OSRun!

5P4-Based Workflow

15

L2_L3.p4

Load3

Page 8: Programming The Network Data Plane in P4

Parser

Deparser

The anatomy of a basic pipeline

20

• Parser◦ Converts packet data into a metadata (Parsed Representation)

• Match+Action Tables ◦ Operate on metadata

• Deparser◦ Converts metadata back into a serialized packet

• Metadata Bus◦ Carries the information within the pipeline

All are optional

Metadata Bus

Page 9: Programming The Network Data Plane in P4

P4 Program Sections

24

Parser

Deparser

Header / Metadataparser parse_ethernet {

extract(ethernet);return switch(ethernet.ethertype) {

0x8100 : parse_vlan_tag;0x0800 : parse_ipv4;0x8847 : parse_mpls;default: ingress;

}

table port_table { … }

control ingress {apply(port_table);if (l2_meta.vlan_tags == 0) {

process_assign_vlan();}

}

header_type ethernet_t { … }header_type l2_metadata_t { … }

header ethernet_t ethernet;header vlan_tag_t vlan_tag[2];metadata l2_metadata_t l2_meta;

Data Declarations

Parser Program

Table + Control Flow Program

P4 program defines what each table CAN do