HashMode Command

Reference Documentation

product_line_custom
Intel® PAC
Napatech SmartNIC
category
Reference Information
Napatech Software Suite: HashMode Command

This section specifies the syntax and semantics for the hashmode command.

Supported Options Per Feature Set

Supported Feature Sets
N-ANL4 N-ANL5 - N-ANL12 N-ANL13
X X X
Options Priority X X X
Encapsulation   X X
Layer3Type X X X
Layer4Type X X X
Layer4Port   X X
GTP Hash Modes   X X
Inner Tunnel Hash Modes X X X
InnerLayerXType X X X
TupleSwap   X X
MaskNo   X X
Port X X X
HashModeBasic X X X
HashModeExtended   X X
Toeplitz     X

The syntax for hash key generation is shown below.

<HashModeAction>                  ::= 'HashMode' [ '[' <HashModeOptionList> ']' ] '=' <HashModeBasic> | <HashModeExtended>
<HashModeOptionList>              ::= <HashModeOption> { ';' <HashModeOption> }
<HashModeOption>                  ::= ( 'Priority' '=' <Priority> ) |
                                      ( 'Encapsulation' '=' <HashModeEncapsulationList> ) |
                                      ( 'Layer3Type' '=' <HashModeLayer3TypeList> ) |
                                      ( 'Layer4Type' '=' <HashModeLayer4TypeList> ) |
                                      ( 'Layer4Port' '=' <HashModeLayer4PortList> ) |
                                      ( 'InnerLayer3Type' '=' <HashModeInnerLayer3TypeList> ) |
                                      ( 'InnerLayer4Type' '=' <HashModeInnerLayer4TypeList> ) |
                                      ( 'TupleSwap' '=' <TrueFalseValue> ) |
                                      ( 'MaskNo' '=' <MaskNumber> |
                                      ( 'Port' '=' <PortNumberSpec> ) |
                                      ( 'Algorithm' '=' <HashAlgorithm> ) |
                                      ( 'Key' '=' <HexString> )
                                      ( 'Tag' '=' <Identifier> )
<HashModeEncapsulationList>       ::= <HashModeEncapsulationValue> { ',' <HashModeEncapsulationValue> }
<HashModeEncapsulationValue>      ::= 'VLAN' | 'MPLS'
<HashModeLayer3TypeList>          ::= <HashModeLayer3TypeValue> { ',' <HashModeLayer3TypeValue> }
<HashModeLayer3TypeValue>         ::= 'IP' | 'IPV4' | 'IPV6' | 'Other'
<HashModeLayer4TypeList>          ::= <HashModeLayer4TypeValue> {','  <HashModeLayer4TypeValue> ]
<HashModeLayer4TypeValue>         ::= 'TCP' | 'UDP' | 'ICMP' | 'GREv0' | 'SCTP' | 'Other'
<HashModeLayer4PortList>          ::= <HashModeLayer4PortValue> {','  <HashModeLayer4PortValue> }
<HashModeLayer4PortValue>         ::= 'GTPv0-U' | 'GTPv1-U' | 'GTPv1v2-C'
<HashModeInnerLayer3TypeList>     ::= <HashModeInnerLayer3TypeValue> { ',' <HashModeInnerLayer3TypeValue> }
<HashModeInnerLayer3TypeValue>    ::= 'IP' | 'IPV4' | 'IPV6' | 'Other'
<HashModeInnerLayer4TypeList>     ::= <HashModeInnerLayer4TypeValue> {','  <HashModeInnerLayer4TypeValue> }
<HashModeInnerLayer4TypeValue>    ::= 'TCP' | 'UDP' | 'SCTP' | 'Other'
<HashAlgorithm>                   ::= 'NTH10' | 'TOEPLITZ'
<HashModeBasic>                   ::= 'Hash2Tuple' | 'Hash2TupleSorted' | 'Hash5Tuple' |
                                      'Hash5TupleSorted' | 'HashInner2Tuple' | 'HashInner2TupleSorted' |
                                      'HashInner5Tuple' | 'HashInner5TupleSorted' | 'HashRoundRobin'
<HashModeExtended>                ::= 'None' | 'Hash3TupleGREv0' | 'Hash3TupleGREv0Sorted' |
                                      'Hash3TupleGTPv0' | 'Hash3TupleGTPv0Sorted' | 'Hash3TupleGTPv1v2' |
                                      'Hash3TupleGTPv1v2Sorted' | 'Hash5TupleSCTP' | 'Hash5TupleSCTPSorted' |
                                      'HashLastMPLSLabel' | 'HashAllMPLSLabels' | 'HashLastVLANId' |
                                      'HashAllVLANIds'

Each 'HashMode' command defines the type of the hash key generated by the adapter for a particular type or particular types of frames. For adapters not supporting hash modes, this command is silently ignored.

Overlapping <HashModeAction> commands are prioritized by <Priority>. 0 is the highest priority and 62 is the lowest priority. If two or more overlapping commands are defined with the same priority, it is undefined which commands overrule the other(s). The default priority is 0.

  • Encapsulation specifies VLAN- and/or MPLS-encapsulated frames.
  • Layer3Type specifies IP, IPv4, IPv6 and/or other layer 3 packets.
  • Layer4Type specifies TCP, UDP, ICMP, GREv0, SCTP and/or other layer 4 packets.
  • Layer4Port specifies GTPv0-U, GTPv1-U and/or GTPv1v2-C.
  • InnerLayer3Type specifies IP, IPv4, IPv6 and/or other inner tunnel layer 3 packets.
  • InnerLayer4Type specifies TCP, UDP, SCTP and/or other inner tunnel layer 4 packets.
  • TupleSwap specifies that the hash key tuples should have source and/or destination swapped. Usually used in combination with 'Port'.
  • MaskNo specifies the hash mask number to be used. 'MaskNo' must be specified with the 'HashMask' command.
  • Port specifies the ports 'HashMode' should apply to.
  • Algorithm specifies what algorithm is used to comput the hash. NTH10 is default.
  • Key specifies the key when using the Toeplitz algorithm.

Distribution with the Toeplizt algorithm requires a lookup table that has 2^n entries. Thus if a filter does not distribute to 2^n streams, the driver will round the table size up to the nearest 2^n entries and populate the table by repeating the streams. This can result in a very uneven distribution. The Toeplitz algorithm should therefore preferrably be used together with "Stream Tables" which allow applications to manipulate distribution tables through a c-API (see Stream Tables and TABLE assign parameter)

The Toeplitz key is 40 bytes long and is specified in big-endian order. The specified key can be less than 40 bytes, in which case the rest of the string is treated as zeroes. If an odd number of hex characters are specified the key is prepended with a zero (e.g 0x123 == 0x0123).

<HashModeSpec> specifies the hash key type.

Note: The inner tunnel hash keys are using the first found tunnel in a frame. Hence if a frame contains a tunnel in a tunnel, the tuples from the first found tunnel is used for hashing.

Note: If 'MaskNo' is used, the mask must be defined before the HashMode command is issued.

For a description of the 'Tag' option please refer to Tag Option.

Implicit HashMode Options

When no HashMode options are given, a default set of options is implicitly applied to the NTPL command based on the HashMode chosen. The following table lists all the implicitly applied HashMode options:

HashModeImplicit expression
NoneN/A
HashLastMplsLabelHashMode[Encapsulation=MPLS] = HashLastMplsLabel
HashAllMplsLabelsHashMode[Encapsulation=MPLS] = HashAllMplsLabels
Hash2TupleHashMode[Layer3Type=IP] = Hash2Tuple
Hash2TupleSortedHashMode[Layer3Type=IP] = Hash2TupleSorted
HashLastVlanIdHashMode[Encapsulation=VLAN] = HashLastVlanId
HashAllVlansIdsHashMode[Encapsulation=VLAN] = HashAllVlansIds
Hash5TupleHashMode[Layer3Type=IP;Layer4Type=TCP,UDP,SCTP] = Hash5Tuple
Hash5TupleSortedHashMode[Layer3Type=IP;Layer4Type=TCP,UDP,SCTP] = Hash5TupleSorted
Hash3TupleGREv0HashMode[Layer3Type=IP;Layer4Type=GREv0] = Hash3TupleGREv0
Hash3TupleGREv0SortedHashMode[Layer3Type=IP;Layer4Type=GREv0] = Hash3TupleGREv0Sorted
Hash5TupleSCTPHashMode[Layer3Type=IP;Layer4Type=SCTP] = Hash5TupleSCTP
Hash5TupleSCTPSortedHashMode[Layer3Type=IP;Layer4Type=SCTP] = Hash5TupleSCTPSorted
Hash3TupleGTPv0HashMode[Layer3Type=IP;Layer4Type=TCP,UDP;Layer4Port=GTPv0-U] = Hash3TupleGTPv0
Hash3TupleGTPv0SortedHashMode[Layer3Type=IP;Layer4Type=TCP,UDP;Layer4Port=GTPv0-U] = Hash3TupleGTPv0Sorted
Hash3TupleGTPv1v2HashMode[Layer3Type=IP;Layer4Type=UDP;Layer4Port=GTPv1-U,GTPv1v2-C] = Hash3TupleGTPv1v2
Hash3TupleGTPv1v2SortedHashMode[Layer3Type=IP;Layer4Type=UDP;Layer4Port=GTPv1-U,GTPv1v2-C] = Hash3TupleGTPv1v2Sorted
HashInner2TupleHashMode[InnerLayer3Type=IP] = HashInner2Tuple
HashInner2TupleSortedHashMode[InnerLayer3Type=IP] = HashInner2TupleSorted
HashInner5TupleHashMode[InnerLayer3Type=IP;InnerLayer4Type=TCP,UDP,SCTP] = HashInner5Tuple
HashInner5TupleSortedHashMode[InnerLayer3Type=IP;InnerLayer4Type=TCP,UDP,SCTP] = HashInner5TupleSorted
HashRoundRobinN/A

Valid HashMode Combinations

Some combinations of HashMode options and HashModes lead to invalid scenarios and thus will result in an error when the NTPL command is executed. The general rule is that required fields in the packet must be present to generate a correct hash value. Hence "HashMode[Layer3Type=Other] = Hash2Tuple" will fail as Layer 3 must contain IPv4 or IPv6 to generate a correct 2-tuple hash.

Hash Key Generation Examples

This section describes some examples of multi-CPU buffer splitting.

Sorted 5-Tuple Hash Keys

This section describes an example of specifying a hash key type. The example illustrates how to set up the adapter to generate sorted 5-tuple hash keys.

The hash key NTPL example is shown below.

HashMode = Hash5TupleSorted

Dynamic Hash Key Selection

This section describes an example of specifying dynamic hash key selection. The example illustrates how to set up the adapter to generate 3-tuple GTPv0 sorted hash keys for GTPv0 frames, 3-tuple GTPv1/GTPv2 sorted hash keys for GTPv1 frames, 5-tuple UDP/TCP/SCTP sorted hash keys for all UDP, TCP and SCTP frames, and 2-tuple sorted hash keys for all other IPv4 frames.

The hash key NTPL example is shown below.

HashMode[Priority = 0; Layer4Port = GTPv0-U] = Hash3TupleGTPv0Sorted
HashMode[Priority = 0; Layer4Port = GTPv1-U, GTPv1v2-C] = Hash3TupleGTPv1v2Sorted
HashMode[Priority = 0; Layer4Type = UDP, TCP, SCTP] = Hash5TupleSorted
HashMode[Priority = 1; Layer3Type = IPV4] = Hash2TupleSorted

Setting Up Multi-CPU Distribution

Setting up multi-CPU buffer splitting consists of these steps:

  • Set up the hash key type using a HashMode command
  • Set up multi-CPU buffer splitting using one or more Assign commands

For examples of setting up multi-CPU splitting please refer to the Setting Up Multi-CPU distribution