testpmd Commands on Uplink

Link-Inline™ Software User Guide

Platform
Napatech SmartNIC
Content Type
User Guide
Capture Software Version
Link-Inline™ Software 3.2

Use this testpmd command example on uplink in a UPF test setup.

Commands on uplink

The following testpmd commands can be used on uplink, which handles GTPv1-U tunneled traffic. See UPF offload test setup.

add port meter profile trtcm_rfc2698 0 2 125000000 125000000 4194304 4194304 0
add port meter policy 0 3 g_actions void / end y_actions drop / end r_actions drop / end
create port meter 0 4 2 3 yes 0x11 1 g 0

set raw_decap 0 eth / ipv4 / udp / gtp / end_set
set raw_encap 0 eth dst is 12:12:56:78:9a:bc src is 1a:1c:1c:1c:1c:1b / end_set 

flow create 0 group 0 pattern ipv4 / udp / end actions jump group 1 / end
flow create 0 group 1 pattern end actions rss queues 0 1 2 3 end / end

flow create 0 group 1 pattern any num is 3 / ipv4 src is 10.10.10.10 / end actions raw_decap index 0 / 
 raw_encap index 0 /
 modify_field op set dst_type ipv4_dscp dst_level 1 src_type value src_value 0x0c width 1 /
 modify_field op set dst_type ipv4_src dst_level 1 src_type value src_value 0x12345678 width 4 /
 modify_field op set dst_type udp_port_src dst_level 1 src_type value src_value 0x2710 width 2 /
 modify_field op sub dst_type ipv4_ttl dst_level 1 src_type value src_value 1 width 1 / port_id id 1 / end

port config mtu 1 600
Save the commands in a file and run the testpmd command as follows.
testpmd> load upf_test_commands.txt
Read CLI commands from upf_test_commands.txt
Note: Each command must be in a single line without any line breaks.

Traffic metering and policing

You can display the metering capabilities supported on a port using the show port meter cap command. For example:
testpmd> show port meter cap 0
An output example:
****   Port Meter Object Capabilities ****

cap.n_max 16777216
cap.n_shared_max 16777216
cap.identical 0
cap.shared_identical 0
cap.shared_n_flows_per_mtr_max 4294967295
cap.chaining_n_mtrs_per_flow_max 4
cap.chaining_use_prev_mtr_color_supported 0
cap.chaining_use_prev_mtr_color_enforced 0
cap.meter_srtcm_rfc2697_n_max 0
cap.meter_trtcm_rfc2698_n_max 16777216
cap.meter_trtcm_rfc4115_n_max 0
cap.meter_rate_max 147469271040
cap.color_aware_srtcm_rfc2697_supported 0
cap.color_aware_trtcm_rfc2698_supported 0
cap.color_aware_trtcm_rfc4115_supported 0
cap.srtcm_rfc2697_byte_mode_supported 0
cap.srtcm_rfc2697_packet_mode_supported 0
cap.trtcm_rfc2698_byte_mode_supported 1
cap.trtcm_rfc2698_packet_mode_supported 0
cap.trtcm_rfc4115_byte_mode_supported 0
cap.trtcm_rfc4115_packet_mode_supported 0
cap.stats_mask 11
cap.input_color_proto_mask 0x0
cap.separate_input_color_table_per_port 0
  • cap.chaining_n_mtrs_per_flow_max 4 shows that a maximum of four policies can be applied to a single flow.
  • cap.trtcm_rfc2698_byte_mode_supported 1 indicates that the trTCM (two-rate three-color marker) algorithm according to RFC 2698 with byte mode is supported.
  • cap.stats_mask 11 (0x11) means that supported statistics are packets and bytes in green color. The green color indicates that the traffic rate is within the configured limit.
The following commands configure metering parameters.
add port meter profile trtcm_rfc2698 0 2 125000000 125000000 4194304 4194304 0

add port meter policy 0 3 g_actions void / end y_actions drop / end r_actions drop / end

create port meter 0 4 2 3 yes 17 1 g 0
The first command creates a metering profile with ID 2 on port 0.
  • The trtcm_rfc2698 algorithm must be used.
  • This profile specifies the committed information rate (CIR) / the peak information rate (PIR) of 125000000 bytes per second and the committed burst size (CBS) / the peak burst size (PBS) of 4194304 bytes. The CIR and PIR parameters set the maximum bit rate, and the CBS and PBS parameters determine the size of the bucket.
    Note: The CIR and the PIR parameters must be set to the same value, and the CBS and the PBS parameters must be set to the same value.
  • The last parameter must be set to 0 to select the byte mode. The rate and size parameters are specified in bytes per second and bytes respectively.
The second command creates a metering policy with ID 3 on port 0.
  • This policy defines the actions to be taken on frames that exceed PIR defined in the profile.
  • The g_actions (green) parameter specifies that frames within the CIR should be unchanged.
  • The y_actions (yellow) parameter and the r_actions (red) parameter specify that frames exceeding the CIR and the PIR should be dropped.
The third command creates a meter object with ID 4 on port 0.
  • This meter object uses the profile with ID 2 and the meter policy with ID 3.
  • The meter is enabled by setting yes.
  • The statistics mask is set to 0x11 which enables the counters for the number of packets (0x01) and bytes (0x10) passed as green by the policer.
  • The shared parameter is set to 1 which indicates that this meter object can be shared by multiple flows.
  • The default input color is set to g (green).
The metering statistics can be displayed using the following command.
show port meter stats (port_id) (mtr_id) (clear)
For example:
show port meter stats 1 14 no
This command displays the statistics of the metering with ID 4 on port 0 without resetting the counters after reading the statistics.

GTP-U decapsulation and MAC encapsulation

set raw_decap 0 eth / ipv4 / udp / gtp / end_set
This command defines decapsulation to remove the Ethernet, IPv4, UDP and GTP headers from frames.
  • The set raw_decap command defines the decapsulation format to remove the outermost protocol headers from a frame.
  • The index 0 is used.
  • eth / ipv4 / udp / gtp arguments specify that the protocol headers to remove are Ethernet, IPv4, UDP and GTP.
The following command defines encapsulation to add the new Ethernet header to frames.
set raw_encap 0 eth dst is 12:12:56:78:9a:bc src is 1a:1c:1c:1c:1c:1b / end_set
  • The set raw_encap command defines the encapsulation format to add new protocol headers to a frame.
  • The index 0 is used.
  • The eth dst is 12:12:56:78:9a:bc src is 1a:1c:1c:1c:1c:1b part specifies the new Ethernet header. The destination MAC address is 12:12:56:78:9a:bc, and the source MAC address is 1a:1c:1c:1c:1c:1b.
The resulting frames will have the specified MAC addresses.

Flow rules

The following flow rules defines how to process frames received on port 0. The first rule jumps to group 1, and the second rule distributes all frames to queue 0, 1, 2 and 3 using RSS.
flow create 0 group 0 pattern end actions jump group 1 / end
flow create 0 group 1 pattern end actions rss queues 0 1 2 3 end / end
The first command creates a flow rule that the jump action to group 1 is applied to all received frames. This means that the frame processing will continue with the flow rule identified by group 1.
The following flow rule defines HW-offload actions to frames with the inner source IP address of 10.10.10.10 received on port 0. After various actions are applied, frames are transmitted on port 1. The actions include decapsulation, encapsulation and modifying IPv4 and UDP headers.
flow create 0 group 1 pattern any num is 3 / ipv4 src is 10.10.10.10 / end actions raw_decap index 0 / 
 raw_encap index 0 /
 modify_field op set dst_type ipv4_dscp dst_level 1 src_type value src_value 0x0c width 1 /
 modify_field op set dst_type ipv4_src dst_level 1 src_type value src_value 0x12345678 width 4 /
 modify_field op set dst_type udp_port_src dst_level 1 src_type value src_value 0x2710 width 2 /
 modify_field op sub dst_type ipv4_ttl dst_level 1 src_type value src_value 1 width 1 / port_id id 1 / end
In this example, pattern any num is 3 / ipv4 src is 10.10.10.10 is used to match the inner source IP address after any protocols for the first 3 layers. This command is designed to match frames with the following characteristics.
  • The packet can have any protocols in the first three layers, such as Ethernet, IPv4, and UDP or TCP.
  • After these initial layers, the SmartNIC looks for an IPv4 header.
  • Within the IPv4 header, it specifically checks that the source IP address is 10.10.10.10.
The SmartNIC performs the following actions in order by this flow rule.
  1. GTPv1-U decapsulation: Decapsulate the frame using the decapsulation format which is defined at index 0.
  2. MAC encapsulation: Encapsulate the frame using the encapsulation format which is defined at index 0.
  3. DSCP tagging: Set the DSCP field in the IPv4 header to 0x0c.
  4. NAT: Set the source IP address in the IPv4 header to 0x12345678, and set the UDP source port to 0x2710.
  5. Decrementing IPv4 TTL: Subtract 1 from the TTL value.
  6. Forward the frames to port 1.
Note: dst_level 1 specifies the modify_field action should be performed on the outer layer as the modify_field actions are done after decapsulation of the first layer in a received frame. dst_level 1 can be omitted.
Note: Actions must be applied in correct order as shown in this example.

IP fragmentation

This command is used to configure the maximum transmission unit (MTU) for port 1 to a value of 600 bytes. The MTU size does not include preamble/SFD, Ethernet header and CRC.
port config mtu 1 600
The MTU size determines the maximum frame length that can be transmitted without fragmentation. If a frames is larger than 600 bytes, it is fragmented before transmitted on port 1.