Checksum Extern - 2025.1 English - UG1308

Vitis Networking P4 User Guide (UG1308)

Document ID
UG1308
Release Date
2025-05-29
Version
2025.1 English

The architecture-specific implementation of the Checksum Extern closely follows the PSA/PNA specification (refer to References). It performs a checksum calculation across some specified header/metadata fields, based on a given Hash algorithm. The supported algorithms are:

  • CRC32
  • CRC16
  • ONES_COMPLEMENT16 (One's complement 16-bit sum used for IPv4 headers)

A custom data input type can be provided (scalars, headers, tuples, structs, etc.). All of the input data must be passed to the Checksum Extern in a single “apply” method call and the result of the checksum calculation is then returned. The input data must be in multiples of 16-bits (32-bits for CRC32) and no greater than 1024 bits, or else the compiler will trigger a warning.

There can be multiple instances of the Checksum Extern in a P4 program. The Checksum Extern is only supported within the Match_Action Engine ‘control’ block of a P4 program. There is no AXI4-Lite control-plane associated with the Checksum Extern.
Note: Checksum calculations over the packet payload is not currently supported.

The Checksum Extern is defined in xsa.p4 as -

extern Checksum<H>{
/// Constructor
Checksum(HashAlgorithm_t hash);

void apply<T, W>(in T data, out W result);
}

An example of a Checksum Extern being used in an example P4 program is provided in Forward Example Design.