Built-in Externs - 2022.2 English

Vitis Networking P4 User Guide (UG1308)

Document ID
UG1308
Version
2022.2 English
Revision

Section 4.3 of the P4 language specification introduces the concept of an extern, which refers to P4 syntax that can be used to define interfaces between P4 programs and architecture-specific functionality that resides outside of those programs.

The P4 language specification describes two varieties of externs:
  • Extern functions, for which the interface between the P4 program and the architecture-specific functionality is described as a function declaration.
  • Extern objects, for which the interface between the P4 program and the architecture-specific functionality is described in terms of an object that provides one or more method declarations, which closely resembles a C++ class declaration.

From the perspective of a P4 program, an extern's implementation is a black box, that is, P4 itself is not concerned with what functionality a given extern declaration implements, nor how it is implemented.

One of the main purposes of P4's extern support is to allow toolchain vendors to provide a "standard library" of functions and features that are useful for many P4 programs (for instance, packet counters) and/or would be very difficult to implement efficiently in P4 code (for instance, checksum calculation).

The Vitis Networking P4 architecture currently supports the following Built-in Externs (with more to be added in the future):

  • Counter Extern