Format String is used to configure the key width, and the position and width of the constant and prefix fields. Format string is only available in LPM Mode. Hardware generation uses this string to generate LPM logic. Software driver uses this string to validate input arguments and build the right data structures.
The format string is composed by VitisNetP4. The information in the format string is extracted from the p4 code. For standalone usage, the format string needs to be created explicitly.
The format string describes the format of all keys. A key consists of several fields, and the format string specifies the location and size of the fields. In the string, fields are separated by a colon (:). The string is read from left to right. The first field corresponds to the least significant bit of the key. The key is specified as little-endian. Each field is specified with a field length and field type. There are no alignment restrictions for the fields.
The following field types and lengths are supported:
- p
- Prefix field - Field length 1 to 128-bit
- c
- Constant field - Field length 4 to 128-bit. The least significant bit of the
constant field has a special meaning. Different tables such as the IPv4
forwarding table and the IPv6 forwarding table can be mixed in the LPM STCAM. To
differentiate the two packet types and to avoid IPv4 lookups to match IPv6
entries and the opposite, it is beneficial to use the least significant bit of
the constant field and not any other means of differentiation. The reason being
two table types might use a different number of prefix masks.
For example, the IPv4 forwarding table uses 32 prefix masks and the IPv6 forwarding table uses 128 prefix masks. The least significant bit of the constant field has dedicated HW associated to it which would only activate the necessary prefix masks. That is, for an IPv4 lookup, only 32 prefix masks would be activated rather than 128 prefix masks. This translates to power savings for IPv4 packets.
The first field must be of p field type. The second field must be of c field type. Exactly two fields must be present.
For example, the format 128p:4c contains one 128-bit wide prefix field
and one 4-bit wide constant field. The 4-bit constant field starts at bit 128 in the
key. The key width is 132 bits.