Header Insertion - 2022.2 English

Vitis Networking P4 User Guide (UG1308)

Document ID
UG1308
Version
2022.2 English
Revision

Where a new header is to be inserted using the setValid() method, it is generally more optimal to include a check for the previous header being valid (assuming that the insertion should only happen under this condition). A simple example of this check is highlighted below for inserting a new VLAN header following an ethernet header.

if (new_vlan_insert == 1 && hdr.eth.isValid())
{  hdr.new_vlan.setValid(); }

This can help the tool narrow down the possible locations in the packet where the header insertion can happen, optimizing the logic resources.