P4 spec coverage

What P4-16 language spec constructs P4Py currently supports.

P4Py targets v1model and eBPF. The tables below map supported constructs to their spec sections.

Types

Construct

Supported

Spec section

Notes

bit<W>

Yes

§7.1 Base types

Only numeric type

int<W>

No

§7.1 Base types

varbit

No

§7.1 Base types

bool

Yes

§7.1 Base types

Action params, control output

header

Yes

§7.2 Header types

Flat only, all fields bit<W>

Header stacks

No

§7.2 Header types

struct

Yes

§7.2 Header types

Header, bit<W>, and nested struct members

enum

No

§7.3 Other types

typedef

No

§7.3 Other types

Parser

Construct

Supported

Spec section

Notes

Parser declaration

Yes

§13.1 Parser declaration

Named states

Yes

§13.3 Parser states

First state is implicit start

extract()

Yes

§13.4 Data extraction

Unconditional transition

Yes

§13.6 Transition

transition select

Yes

§13.6 Select

Single field, integer or default cases

lookahead

No

§13.4 Data extraction

Sub-parsers

No

§13.1 Parser declaration

Value sets

No

§13.6 Select

Expressions

Construct

Supported

Spec section

Notes

Integer literals

Yes

§8 Expressions

Decimal, hex, width-annotated

Bool literals

Yes

§8 Expressions

true, false

List expressions

Yes

§8 Expressions

For checksum data args

Field access

Yes

§8 Expressions

hdr.ipv4.dstAddr

+, -

Yes

§8 Expressions

Bitwise (&, |, ^, ~)

No

§8 Expressions

Shifts (<<, >>)

No

§8 Expressions

Comparison (==, !=)

No

§8 Expressions

Only in transition select

Slicing

No

§8 Expressions

Concatenation (++)

No

§8 Expressions

Casts

No

§8 Expressions

.isValid()

Yes

§8 Expressions

In control apply blocks only

.setValid()

No

§8 Expressions

.setInvalid()

No

§8 Expressions

Statements

Construct

Supported

Spec section

Notes

Assignment

Yes

§12 Statements

Method call

Yes

§12 Statements

extract, emit

Function call

Yes

§12 Statements

mark_to_drop

if/else

Yes

§12 Statements

Condition must be .isValid()

switch

Yes

§12 Statements

On action_run only

Block statements

No

§12 Statements

Control blocks

Construct

Supported

Spec section

Notes

Control declaration

Yes

§14 Control blocks

Actions

Yes

§14 Control blocks

Direction-less parameters only

Tables

Yes

§14 Control blocks

exact match

Yes

§14 Control blocks

lpm match

Yes

§14 Control blocks

ternary match

No

§14 Control blocks

range match

No

§14 Control blocks

table.apply()

Yes

§14 Control blocks

const entries

Yes

§14 Control blocks

Deparsing

Construct

Supported

Spec section

Notes

Deparser declaration

Yes

§16 Deparsing

emit()

Yes

§16 Deparsing

See also