This describes how to configure the SmartNIC for the SPAN port configuration.
SPAN port configuration
The SmartNIC receives both upstream and downstream traffic on the same port as illustrated in the following figure.
Inner layer 5 tuple
- Inner layer IPv4 source address
- Inner layer IPv4 destination address
- Inner layer 4 source port number
- Inner layer 4 destination port number
- Inner layer IPv4 protocol number
Sort
The sort feature is used in this configuration to treat upstream traffic and downstream traffic as the same flow. The sort operation is done based on the first two fields extracted from a received frame. If the first field is greater than the second field, the fields will be swapped before the flow lookup. The last two fields are also swapped if the first two fields are swapped as shown in the following figure.
As inner layer IPv4 source and destination addresses of a downstream frame are swapped, inner layer 4 source and destination port numbers are also swapped in the figure.
SPAN port NTPL example
Delete=All Define Port0 = Macro("Port==0 and InnerLayer3Protocol==IPv4") Define KeyTypeProtoSpecs = Macro("(InnerLayer3Header[12]/32, InnerLayer3Header[16]/32, \\ InnerLayer4Header[0]/16, InnerLayer4Header[2]/16)") KeyType[Name=KT_SPAN] = {32, 32, 16, 16} KeyDef[Name=KD_SPAN; KeyType=KT_SPAN; IpProtocolField=Inner; KeySort=Sorted] = KeyTypeProtoSpecs HashMode = HashInner5TupleSorted Assign[StreamId=(0..3); Color=2; Descriptor=DYN4, Offset0=InnerLayer3Header[12], \\ Offset1=InnerLayer4Header[0]] = Port0 and Key(KD_SPAN, KeyID=1) == UNHANDLED Assign[StreamId=(0..3); Color=1; Descriptor=DYN4, Offset0=InnerLayer3Header[12], \\ Offset1=InnerLayer4Header[0]] = Port0 and Key(KD_SPAN, KeyID=1) == MISS Assign[StreamId=(0..3); Color=0; Descriptor=DYN4, ColorBits=FlowID] = Port0 and Key(KD_SPAN, KeyID=1) == 4Save the NTPL example in a file and run the ntpl tool to apply the configuration as shown in the following example.
/opt/napatech/bin/ntpl -f span.ntplAn output example:
ntpl (v. 3.25.2.13-0ebb373f) ============================================================================== NTPL CMD: Delete=All NTPL ID: 0 NTPL CMD: Define Port0 = Macro("Port==0 and InnerLayer3Protocol==IPv4") NTPL ID: 0 NTPL CMD: Define KeyTypeProtoSpecs = Macro("(InnerLayer3Header[12]/32, InnerLayer3Header[16]/32, InnerLayer4Header[0]/16, InnerLayer4Header[2]/16)") NTPL ID: 0 NTPL CMD: KeyType[Name=KT_SPAN] = {32, 32, 16, 16} NTPL ID: 135 NTPL CMD: KeyDef[Name=KD_SPAN; KeyType=KT_SPAN; IpProtocolField=Inner; KeySort=Sorted] = KeyTypeProtoSpecs NTPL ID: 136 NTPL CMD: HashMode = HashInner5TupleSorted NTPL ID: 137 NTPL CMD: Assign[StreamId=(0..3); Color=2; Descriptor=DYN4, Offset0=InnerLayer3Header[12], Offset1=InnerLayer4Header[0]] = Port0 and Key(KD_SPAN, KeyID=1) == UNHANDLED NTPL ID: 138 NTPL CMD: Assign[StreamId=(0..3); Color=1; Descriptor=DYN4, Offset0=InnerLayer3Header[12],Offset1=InnerLayer4Header[0]] = Port0 and Key(KD_SPAN, KeyID=1) == MISS NTPL ID: 139 NTPL CMD: Assign[StreamId=(0..3); Color=0; Descriptor=DYN4, ColorBits=FlowID] = Port0 and Key(KD_SPAN, KeyID=1) == 4 NTPL ID: 140
Macros
- Port0: Filter inner layer IPv4 packets received on port
0.
Define Port0 = Macro("Port==0 and InnerLayer3Protocol==IPv4")
- KeyTypeProtoSpecs: Specify the location of the
fields.
Define KeyTypeProtoSpecs = Macro("(InnerLayer3Header[12]/32, InnerLayer3Header[16]/32, \\ InnerLayer4Header[0]/16, InnerLayer4Header[2]/16)")
The first two fields, InnerLayer3Header[12]/32 and InnerLayer3Header[16]/32 correspond to source and destination IP addresses of a tunneled packet. Two 32 bits are selected on the inner layer 3 header with a 12 byte offset. The last two fields, InnerLayer4Header[0]/16 and InnerLayer4Header[2]/16) correspond to inner layer 4 source and destination port numbers. It indicates that two 16 bits are selected on the inner layer 4 header with a 0 byte offset.
KeyType command
KeyType defines the number of fields and the size of fields. Four fields are specified in this example. The size of the first two fields is 32 bits and the size of the last two fields is 16 bits.KeyType[Name=KT_SPAN] = {32, 32, 16, 16}
KeyDef command
KeyDef[Name=KD_SPAN; KeyType=KT_SPAN; IpProtocolField=Inner; KeySort=Sorted] = KeyTypeProtoSpecsThe inner IP protocol field is specified in addition to inner layer IPv4 source/destination addresses and inner layer 4 source/destination port numbers.
Assign command
HashMode = HashInner5TupleSorted Assign[StreamId=(0..3); Color=0; Descriptor=DYN4, ColorBits=FlowID] = Port0 and Key(KD_SPAN, KeyID=1) == 4This Assign command is applied to handle frames belonging to the flows that are found in the flow table. Actions include the following:
- Frames are distributed to 4 streams using hash mode HashInner5TupleSorted.
- The packet descriptor Dyn4 is selected to specify the ColorBits parameter. ColorBits is set to FlowID which enables the flow ID information of a frame. See Programming Key ID, key set ID and flow ID and User-Defined Flow ID for further information about the flow ID.
- The Color parameter is used to classify flows so that frames can be handled based on the color information in the application. If the flow is found in the flow table, frames are delivered with the Color0 value 0 in dynamic packet descriptor 4. See API: Classify Received Frames for more information about how to classify received frames based on the color information.
- Key ID and Key set ID: See Key set ID and key ID.
Assign[StreamId=(0..3); Color=1; Descriptor=DYN4, Offset0=InnerLayer3Header[12], \\ Offset1=InnerLayer4Header[0]] = Port0 and Key(KD_SPAN, KeyID=1) == MISSThe missed traffic can be classified using the Color0 value 1 of dynamic packet descriptor 4 in the application. The packet descriptor Dyn4 in this example is used to specify Offset0 and Offset1, such that Offset0 points to IPv4 source address and Offset1 points to layer 4 source port number.
Assign[StreamId=(0..3); Color=2; Descriptor=DYN4, Offset0=InnerLayer3Header[12], \\ Offset1=InnerLayer4Header[0]] = Port0 and Key(KD_SPAN, KeyID=1) == UNHANDLEDThe SmartNIC may not be able to look up flows of received frames, for example, in rare situations where the RX rate is faster than the lookup rate of the flow manager in sustained high traffic load. Unhandled frames are delivered to the application. In this example unhandled frames can be classified using the Color0 value 2 of dynamic packet descriptor 4.