testpmd Commands on Downlink

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 downlink in a UPF test setup.

Commands on downlink

The following testpmd commands can be used on downlink.

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

set raw_decap 1 eth / end_set
set raw_encap 1 eth dst is 12:12:56:78:9a:bc src is 1a:1c:1c:1c:1c:1b /
 ipv4 ttl is 40 dst is 99.99.99.99 / udp dst is 2152 /
 gtp v_pt_rsv_flags is 0x34 msg_type is 0xff / gtp_psc / end_set 

flow create 1 group 0 pattern ipv4 / udp / end actions jump group 2 / end
flow create 1 group 2 pattern end actions rss queues 4 5 6 7 / end 
flow create 1 group 2 pattern ipv4 src is 10.10.10.10 / end actions raw_decap index 1 / raw_encap index 1 /
 modify_field op set dst_type ipv4_dscp dst_level 2 src_type value src_value 0x0c width 1 /
 modify_field op set dst_type ipv4_dst dst_level 2 src_type value src_value 0x12345678 width 4 /
 modify_field op set dst_type udp_port_dst dst_level 2 src_type value src_value 0x2710 width 2 /
 modify_field op set dst_type gtp_teid dst_level 1 src_type value src_value 0x40404040 width 4 /
 modify_field op set dst_type gtp_psc_qfi dst_level 1 src_type value src_value 0xff width 1 /
 port_id id 1 / end

port config mtu 0 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 1
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 ( RTE_MTR_STATS_N_PKTS_GREEN and RTE_MTR_STATS_N_BYTES_GREEN counters). The green color indicates that the traffic rate is within the configured limit.
The following commands configure policing and metering parameters.
add port meter profile trtcm_rfc2698 0 2 125000000 125000000 4194304 4194304 0

add port meter policy 1 13 g_actions void / end y_actions drop / end r_actions drop / end

create port meter 1 14 12 13 yes 0x11 1 g 0
The first command creates a metering profile with ID 12 on port 1.
  • The trtcm_rfc2698 algorithm (a two rate three color marker according to RFC 2698) 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 4000000 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 13 on port 1.
  • 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 14 on port 1.
  • This meter object uses the profile with ID 12 and the meter policy with ID 13.
  • The meter is enabled by setting yes.
  • The statistics mask is set to 0x11 which enables the counters for the number of packets (0x1) 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 14 on port 1 without resetting the counters after reading the statistics.

MAC decapsulation and GTP-U encapsulation

set raw_decap 1 eth / end_set
This command defines decapsulation to remove the Ethernet header from frames on port 0.
  • The set raw_decap command is used to define the decapsulation format to remove the outermost protocol headers from a frame. The index 1 is used.
  • The eth argument specifies that the protocol header to remove is Ethernet.
  • The end_set command is used to signal the end of the configuration option.
The following command defines encapsulation to add new Ethernet, IPv4, UDP and GTP headers to frames on port 0.
set raw_encap 1 eth dst is 12:12:56:78:9a:bc src is 1a:1c:1c:1c:1c:1b / ipv4 ttl is 40 dst is 99.99.99.99 / udp dst is 2152 / gtp v_pt_rsv_flags is 0x34 msg_type is 0xff / gtp_psc / end_set 
  • The set raw_encap 1 command is used to define the encapsulation format to add new protocol headers to a frame. The index 1 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 ipv4 ttl is 40 dst is 99.99.99.99 part specifies the new IPv4 header. The time-to-live (TTL) field is set to 40, and the destination IP address is 99.99.99.99.
  • The udp dst is 2152 part specifies the new UDP header. The destination port for the UDP packet is set to 2152 which is the port number for the GTP-U protocol.
  • The gtp v_pt_rsv_flags is 0x34 msg_type is 0xff / gtp_psc part specifies the new GTP header. The version, protocol type, and reserved flags fields are set to 0x34, and the message type field is set to 0xff. The gtp_psc part specifies the GTP Protocol and service combination (PSC) header.
The resulting frames will have the specified MAC addresses, IP addresses and protocol headers. This command defines a template of the GTP-U header. The GTP TEID and the GTP PSC QFI fields of a flow are configured when a flow rule is created.

Flow rules

The following flow rules defines how frames are received on port 1 will be processed. The first rule jumps to group 2, and the second rule distributes all frames to queue 4, 5, 6 and 7 using RSS.
flow create 1 group 0 pattern end actions jump group 2 / end
flow create 1 group 2 pattern end actions rss queues 4 5 6 7 / end 
The first command creates a flow rule that the jump action to group 2 is applied to all received frames. This means that the frame processing will continue with the flow rule identified by group 2.
The following flow rule defines hairpinning actions to frames with the source IP address of 10.10.10.10 received on port 1. After various actions are applied, frames are transmitted on port 0. The actions include decapsulation, encapsulation and modifying IPv4 and UDP headers of the inner layer. It also modifies the GTP TEID and the GTP PSC QFI fields of the outer layer.
flow create 1 group 2 pattern ipv4 src is 10.10.10.10 / end actions raw_decap index 1 / raw_encap index 1 /
 modify_field op set dst_type ipv4_dscp dst_level 2 src_type value src_value 0x0c width 1 /
 modify_field op set dst_type ipv4_dst dst_level 2 src_type value src_value 0x12345678 width 4 /
 modify_field op set dst_type udp_port_dst dst_level 2 src_type value src_value 0x2710 width 2 /
 modify_field op set dst_type gtp_teid dst_level 1 src_type value src_value 0x40404040 width 4 /
 modify_field op set dst_type gtp_psc_qfi dst_level 1 src_type value src_value 0xff width 1 /
 port_id id 1 / end
The SmartNIC performs the following actions in order by this flow rule.
  1. MAC decapsulation: Decapsulate the frame using the decapsulation format which is defined at index 1.
  2. GTPv1-U encapsulation: Encapsulate the frame using the encapsulation format which is defined at index 1.
  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. GTP-v1-U header modification:
    • Set the GTP TEID to 0x40404040.
    • Set the GTP PSC QFI to 0xff.
  6. port_id id 0: Forward the frames to port 0.
Note: dst_level 2 specifies that the modify_field actions must be performed on the inner layer as the modify_field actions are done after GTPv1-U encapsulation of the in a received frame. dst_level 1 specifies that the modify_field actions must be performed on the outer layer to modify the GTPv1-U header. 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 0 to a value of 600 bytes. The MTU size does not include preamble/SFD, Ethernet header and CRC.
port config mtu 0 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 0.