This patch adds userspace DPDK with rte_flow offload unit tests. It can be run with the 'make check-rte-offloads' command; however, it requires a list of VFs that can be used for offloaded ports. More details on how to set this up can be found in the testing.rst file.
Also note that currently not all tests are passing. This is true for both the old rte_flow offload and the new offload infrastructure. Signed-off-by: Eelco Chaudron <[email protected]> --- v2: - Added multiple offload threads test case. - Fixed ADD_VF cleanup to restore VF original names. - Fixed ADD_VF macro to support client/server names. - Updated test cases below based on previous patches. - Added macro to exclude specific system tests with rte-flow. --- Note that the below tests are failing with the system-traffic.at test-suite on both the main and the rework branch: 20: datapath - ping over ip6gre L2 tunnel FAILED (system-traffic.at:753) This test seems to be failing due to my hardware offload NIC not properly handling checksum offload; i.e., the L4 checksum is not updated and hence the kernel is dropping the packets. 62: mpls - decap header dp-support FAILED (ovs-macros.at:242) 63: mpls - decap header slow-path FAILED (ovs-macros.at:242) These two tests fail because, due to side traffic, an IPv6 drop rule gets installed in hardware. However, this rule also drops MPLS-encapsulated IPv6 traffic. This appears to be a bug specific to the hardware offload NIC I'm using. > Flaky tests (note that their might be more flaky tests which passed the first run): 12: datapath - ping6 between two ports with header modify FAILED (system-traffic.at:260) 27: datapath - flow resume with geneve tun_metadata FAILED (system-traffic.at:1063) 30: datapath - bridging two geneve tunnels FAILED (system-traffic.at:1249) 38: datapath - ping6 over srv6 tunnel FAILED (ovs-macros.at:242) 72: conntrack - IPv6 ping FAILED (ovs-macros.at:242) 105: conntrack - IPv6 fragmentation with ct orig match FAILED (system-traffic.at:5174) 106: conntrack - IPv6 fragmentation expiry FAILED (ovs-macros.at:242) 107: conntrack - IPv6 fragmentation + vlan FAILED (system-traffic.at:5256) 124: conntrack - IPv6 HTTP FAILED (ovs-macros.at:242) 133: conntrack - FTP over IPv6 FAILED (ovs-macros.at:242) --- Documentation/topics/testing.rst | 19 ++ tests/.gitignore | 3 + tests/automake.mk | 24 +++ tests/ofproto-macros.at | 6 +- tests/system-kmod-macros.at | 5 + tests/system-offloads-testsuite-macros.at | 5 + tests/system-rte-offloads-macros.at | 230 ++++++++++++++++++++++ tests/system-rte-offloads-testsuite.at | 28 +++ tests/system-rte-offloads.at | 111 +++++++++++ tests/system-traffic.at | 6 + tests/system-userspace-macros.at | 5 + 11 files changed, 439 insertions(+), 3 deletions(-) create mode 100644 tests/system-rte-offloads-macros.at create mode 100644 tests/system-rte-offloads-testsuite.at create mode 100644 tests/system-rte-offloads.at diff --git a/Documentation/topics/testing.rst b/Documentation/topics/testing.rst index dbeaf2d93..5c45647c2 100644 --- a/Documentation/topics/testing.rst +++ b/Documentation/topics/testing.rst @@ -363,6 +363,25 @@ manual to figure out how to `Configure hugepages`_. All the features documented under `Unit Tests`_ are available for the DPDK testsuite. +Userspace datapath with DPDK and rte_flow offload +''''''''''''''''''''''''''''''''''''''''''''''''' + +To invoke the userspace datapath tests with DPDK and rte_flow offload, the +same prerequisites apply as above. In addition, six Virtual Function (VF) +interfaces must be preconfigured and capable of hardware offloading traffic +between each other. + +These six VFs need to be passed as a list of PF PCI addresses with their +corresponding VF indexes in the OVS_RTE_FLOW_VF_PCI_ADDRS variable. +For example:: + + OVS_RTE_FLOW_VF_PCI_ADDRS="0000:17:00.0,0 0000:17:00.0,1 0000:17:00.0,2 0000:17:00.0,3 0000:17:00.0,4 0000:17:00.0,5" + +To invoke the rte_flow offloads testsuite with the userspace datapath, run:: + + make check-rte-offloads \ + OVS_RTE_FLOW_VF_PCI_ADDRS="0000:17:00.0,0 0000:17:00.0,1 0000:17:00.0,2 0000:17:00.0,3 0000:17:00.0,4 0000:17:00.0,5" + Userspace datapath: Testing and Validation of CPU-specific Optimizations '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' diff --git a/tests/.gitignore b/tests/.gitignore index 3a8c45975..05ffd2533 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -32,6 +32,9 @@ /system-offloads-testsuite /system-offloads-testsuite.dir/ /system-offloads-testsuite.log +/system-rte-offloads-testsuite +/system-rte-offloads-testsuite.dir/ +/system-rte-offloads-testsuite.log /test-aes128 /test-atomic /test-bundle diff --git a/tests/automake.mk b/tests/automake.mk index 59f538761..750bef7a9 100644 --- a/tests/automake.mk +++ b/tests/automake.mk @@ -7,6 +7,7 @@ EXTRA_DIST += \ $(SYSTEM_TSO_TESTSUITE_AT) \ $(SYSTEM_AFXDP_TESTSUITE_AT) \ $(SYSTEM_OFFLOADS_TESTSUITE_AT) \ + $(SYSTEM_RTE_OFFLOADS_TESTSUITE_AT) \ $(SYSTEM_DPDK_TESTSUITE_AT) \ $(OVSDB_CLUSTER_TESTSUITE_AT) \ $(TESTSUITE) \ @@ -15,6 +16,7 @@ EXTRA_DIST += \ $(SYSTEM_TSO_TESTSUITE) \ $(SYSTEM_AFXDP_TESTSUITE) \ $(SYSTEM_OFFLOADS_TESTSUITE) \ + $(SYSTEM_RTE_OFFLOADS_TESTSUITE) \ $(SYSTEM_DPDK_TESTSUITE) \ $(OVSDB_CLUSTER_TESTSUITE) \ tests/atlocal.in \ @@ -186,6 +188,13 @@ SYSTEM_OFFLOADS_TESTSUITE_AT = \ tests/system-offloads-testsuite.at \ tests/system-offloads-testsuite-macros.at +SYSTEM_RTE_OFFLOADS_TESTSUITE_AT = \ + tests/system-common-macros.at \ + tests/system-dpdk-macros.at \ + tests/system-rte-offloads.at \ + tests/system-rte-offloads-macros.at \ + tests/system-rte-offloads-testsuite.at + SYSTEM_DPDK_TESTSUITE_AT = \ tests/system-common-macros.at \ tests/system-dpdk-macros.at \ @@ -202,6 +211,7 @@ SYSTEM_USERSPACE_TESTSUITE = $(srcdir)/tests/system-userspace-testsuite SYSTEM_TSO_TESTSUITE = $(srcdir)/tests/system-tso-testsuite SYSTEM_AFXDP_TESTSUITE = $(srcdir)/tests/system-afxdp-testsuite SYSTEM_OFFLOADS_TESTSUITE = $(srcdir)/tests/system-offloads-testsuite +SYSTEM_RTE_OFFLOADS_TESTSUITE = $(srcdir)/tests/system-rte-offloads-testsuite SYSTEM_DPDK_TESTSUITE = $(srcdir)/tests/system-dpdk-testsuite OVSDB_CLUSTER_TESTSUITE = $(srcdir)/tests/ovsdb-cluster-testsuite DISTCLEANFILES += tests/atconfig tests/atlocal @@ -315,6 +325,12 @@ check-offloads-valgrind: all $(valgrind_wrappers) $(check_DATA) @echo '----------------------------------------------------------------------' @echo 'Valgrind output can be found in tests/system-offloads-testsuite.dir/*/valgrind.*' @echo '----------------------------------------------------------------------' +check-rte-offloads-valgrind: all $(valgrind_wrappers) $(check_DATA) + $(SHELL) '$(SYSTEM_RTE_OFFLOADS_TESTSUITE)' -C tests VALGRIND='$(VALGRIND)' AUTOTEST_PATH='tests/valgrind:$(AUTOTEST_PATH)' -d $(TESTSUITEFLAGS) -j1 + @echo + @echo '----------------------------------------------------------------------' + @echo 'Valgrind output can be found in tests/system-rte-offloads-testsuite.dir/*/valgrind.*' + @echo '----------------------------------------------------------------------' check-tso-valgrind: all $(valgrind_wrappers) $(check_DATA) $(SHELL) '$(SYSTEM_TSO_TESTSUITE)' -C tests VALGRIND='$(VALGRIND)' AUTOTEST_PATH='tests/valgrind:$(AUTOTEST_PATH)' -d $(TESTSUITEFLAGS) -j1 @echo @@ -357,6 +373,10 @@ check-offloads: all set $(SHELL) '$(SYSTEM_OFFLOADS_TESTSUITE)' -C tests AUTOTEST_PATH='$(AUTOTEST_PATH)'; \ "$$@" $(TESTSUITEFLAGS) -j1 || (test X'$(RECHECK)' = Xyes && "$$@" --recheck) +check-rte-offloads: all + set $(SHELL) '$(SYSTEM_RTE_OFFLOADS_TESTSUITE)' -C tests AUTOTEST_PATH='$(AUTOTEST_PATH)'; \ + "$$@" $(TESTSUITEFLAGS) -j1 || (test X'$(RECHECK)' = Xyes && "$$@" --recheck) + check-dpdk: all set $(SHELL) '$(SYSTEM_DPDK_TESTSUITE)' -C tests AUTOTEST_PATH='$(AUTOTEST_PATH)'; \ "$$@" $(TESTSUITEFLAGS) -j1 || (test X'$(RECHECK)' = Xyes && "$$@" --recheck) @@ -402,6 +422,10 @@ $(SYSTEM_OFFLOADS_TESTSUITE): package.m4 $(SYSTEM_TESTSUITE_AT) $(SYSTEM_OFFLOAD $(AM_V_GEN)$(AUTOTEST) -I '$(srcdir)' -o [email protected] [email protected] $(AM_V_at)mv [email protected] $@ +$(SYSTEM_RTE_OFFLOADS_TESTSUITE): package.m4 $(SYSTEM_TESTSUITE_AT) $(SYSTEM_RTE_OFFLOADS_TESTSUITE_AT) $(COMMON_MACROS_AT) + $(AM_V_GEN)$(AUTOTEST) -I '$(srcdir)' -o [email protected] [email protected] + $(AM_V_at)mv [email protected] $@ + $(SYSTEM_DPDK_TESTSUITE): package.m4 $(SYSTEM_TESTSUITE_AT) $(SYSTEM_DPDK_TESTSUITE_AT) $(COMMON_MACROS_AT) $(AM_V_GEN)$(AUTOTEST) -I '$(srcdir)' -o [email protected] [email protected] $(AM_V_at)mv [email protected] $@ diff --git a/tests/ofproto-macros.at b/tests/ofproto-macros.at index 8894dd711..dd4f485f6 100644 --- a/tests/ofproto-macros.at +++ b/tests/ofproto-macros.at @@ -9,9 +9,9 @@ s/ duration=[0-9.]*s,// s/ cookie=0x0,// s/ table=0,// s/ n_packets=0,// -s/ n_offload_packets=0,// +s/ n_offload_packets=[0-9]*,// s/ n_bytes=0,// -s/ n_offload_bytes=0,// +s/ n_offload_bytes=[0-9]*,// s/ idle_age=[0-9]*,// s/ hard_age=[0-9]*,// s/dp_hash=0x[0-9a-f]*\//dp_hash=0x0\// @@ -127,7 +127,7 @@ strip_xids () { # Changes all 'used:...' to say 'used:0.0', to make output easier to compare. strip_used () { - sed 's/used:[[0-9]]\.[[0-9]]*/used:0.0/' + sed -E 's/used:[[0-9]]+\.[[0-9]]*/used:0.0/' } # Removes all 'duration=...' to make output easier to compare. diff --git a/tests/system-kmod-macros.at b/tests/system-kmod-macros.at index 1de0e616b..3e6fd743c 100644 --- a/tests/system-kmod-macros.at +++ b/tests/system-kmod-macros.at @@ -264,6 +264,11 @@ m4_define([VSCTL_ADD_DATAPATH_TABLE], # specific regression. m4_define([CHECK_L3L4_CONNTRACK_REASM]) +# CHECK_NO_RTE_FLOW_OFFLOAD +# +# The kernel module tests do not use RTE_FLOW offload. +m4_define([CHECK_NO_RTE_FLOW_OFFLOAD]) + # CHECK_NO_TC_OFFLOAD # # The kernel module tests do not use TC offload. diff --git a/tests/system-offloads-testsuite-macros.at b/tests/system-offloads-testsuite-macros.at index c80538fd6..16393a06d 100644 --- a/tests/system-offloads-testsuite-macros.at +++ b/tests/system-offloads-testsuite-macros.at @@ -32,6 +32,11 @@ m4_define([OVS_TRAFFIC_VSWITCHD_START], RETIS_CHECK_AND_RUN() ]) +# CHECK_NO_RTE_FLOW_OFFLOAD +# +# The kernel module tests do not use RTE_FLOW offload. +m4_define([CHECK_NO_RTE_FLOW_OFFLOAD]) + # Macro to exclude tests that will fail with TC offload enabled. # We currently have the below tests disabled in system-traffic.at # for the following reasons: diff --git a/tests/system-rte-offloads-macros.at b/tests/system-rte-offloads-macros.at new file mode 100644 index 000000000..20a319eaf --- /dev/null +++ b/tests/system-rte-offloads-macros.at @@ -0,0 +1,230 @@ +AT_COPYRIGHT([Copyright (c) 2025 Red Hat, Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at: + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License.]) + +# Macro to exclude tests that will fail with RTE_FLOW offload enabled. +# We currently have the below tests disabled in system-traffic.at +# for the following reasons: +# +# For RTE_FLOW there is no kernel side of the simulated VETH interface. +# Therefore the following tests are disabled, as they assume kernel ports +# exist since they have dependencies on their behavior. +# - 'datapath - netdev offload software fallback' +# +# RTE_FLOW offload does not update, but replaces the flows when the action +# set changes, which means statistics are reset. Until this changes the +# following test needs to be disabled. +# - 'datapath - simulated flow action update' +# +# The RTE_FLOW test cases use VF interfaces, which are Ethernet devices with +# a minimum frame size of 64 bytes. As a result, received packets appear larger +# than expected. Virtual interfaces, however, report the actual size. To avoid +# adding complex counter adjustments in tests that rely on these values, we +# skip them. +# - 'conntrack - ICMP related' +# - 'conntrack - resubmit to ct multiple times' +# - 'conntrack - ICMP related with NAT' +# - 'conntrack - Multiple ICMP traverse' +# +m4_define([CHECK_NO_RTE_FLOW_OFFLOAD], +[ + AT_SKIP_IF([:]) +]) + +# OVS_RTE_FLOW_PRE_CHECK() +# +# Check prerequisites for DPDK rte_flow tests. Following settings are checked: +# - Existence of at least six VFs and their representors. +# +m4_define([OVS_RTE_FLOW_PRE_CHECK], [ + OVS_DPDK_PRE_CHECK() + AT_SKIP_IF( + [test "$(printf '%s' "$OVS_RTE_FLOW_VF_PCI_ADDRS" | wc -w)" -ne 6]) + + AT_SKIP_IF([! ovs_rte_flow_verify_vf_cfg "$OVS_RTE_FLOW_VF_PCI_ADDRS"]) +]) + +# OVS_TRAFFIC_VSWITCHD_START([vsctl-args], [vsctl-output], [dbinit-aux-args]) +# +# This is a copy from system-dpdk-macro.at with two small changes: +# 1) Use OVS_RTE_FLOW_PRE_CHECK() instead of OVS_DPDK_PRE_CHECK(). +# 2) Start with pci enabled for PF devices. +# +m4_define([OVS_TRAFFIC_VSWITCHD_START], + [ + OVS_RTE_FLOW_PRE_CHECK() + OVS_WAIT_WHILE([ip link show ovs-netdev]) + ALLOW_LIST=$(echo "$OVS_RTE_FLOW_VF_PCI_ADDRS" | awk '{ + for (i=1; i<=NF; i++) { + split($i, parts, ","); + addr = parts[1]; + if (addr != "" && !seen[addr]) { + seen[addr] = 1; + if (result == "") + result = "--allow " addr; + else + result = result " --allow " addr; + } + } + print result; + }') + OVS_DPDK_START([$ALLOW_LIST], [--disable-system], + [-- set Open_vSwitch . other_config:hw-offload=true $3]) + dnl Add bridges, ports, etc. + OVS_WAIT_WHILE([ip link show br0]) + AT_CHECK([ovs-vsctl -- _ADD_BR([br0]) -- $1 m4_if([$2], [], [], + [| uuidfilt])], [0], [$2]) +]) + +# OVS_TRAFFIC_VSWITCHD_STOP([ALLOWLIST], [extra_cmds]) +# +# This is a copy from system-dpdk-macro.at adding some rte_flow specific error +# message exclusion. +# +m4_define([OVS_TRAFFIC_VSWITCHD_STOP], + [OVS_DPDK_STOP_VSWITCHD([dnl +$1";/mlx5_net: Failed to update link status: /d"]) + AT_CHECK([:; $2]) +]) + +# ADD_{VF|VETH}([port], [namespace], [ovs-br], [ip_addr] [mac_addr], [gateway], +# [ip_addr_flags]) +# +# Simulate the ADD_VETH() macro defined in system-common-macros.at, allowing +# us to run the existing system-traffic unit tests without any test-specific +# changes. This is consistent with how DPDK and AF_XDP run the system tests, +# except that we are not using actual veth devices, but VF representer ports. +# +m4_define([ADD_VF], + [ USER_PORT=$1 + case "$USER_PORT" in + client) PORT_NO=0 ;; + server) PORT_NO=1 ;; + *) PORT_NO=${USER_PORT##*[!0-9]} ;; + esac + + AT_CHECK([[[ "$PORT_NO" -ge 0 ]] && [[ "$PORT_NO" -le 6 ]] || return 66]) + PORT_CFG=$(echo $OVS_RTE_FLOW_VF_PCI_ADDRS | cut -d' ' -f$((PORT_NO+1))) + PF_PCI=$(ovs_rte_get_pci_id "$PORT_CFG") + VF_IDX=$(ovs_rte_get_vf_idx "$PORT_CFG") + REP=$(ovs_rte_get_representor_netdev $PF_PCI $VF_IDX) + AT_CHECK([test $? -eq 0]) + + AT_CHECK([ip link set $REP name $1]) + AT_CHECK([ip link set $1 netns $2]) + AT_CHECK([ovs-vsctl add-port $3 ovs-$1 -- \ + set interface ovs-$1 external-ids:iface-id="$1" -- \ + set interface ovs-$1 type=dpdk -- \ + set interface ovs-$1 \ + options:dpdk-devargs=$PF_PCI,representor=vf$VF_IDX]) + NS_CHECK_EXEC([$2], [ip addr add $4 dev $1 $7]) + NS_CHECK_EXEC([$2], [ip link set dev $1 up]) + if test -n "$5"; then + NS_CHECK_EXEC([$2], [ip link set dev $1 address $5]) + else + NS_CHECK_EXEC([$2], + [ip link set dev $1 address 02:00:00:00:EC:0$PORT_NO]) + fi + if test -n "$6"; then + NS_CHECK_EXEC([$2], [ip route add default via $6]) + fi + on_exit "ip netns exec $2 ip link set $1 netns 1; \ + ip link property del dev $1 altname $REP; \ + ip link set $1 name $REP" + ] +) +m4_define([ADD_VETH], [ADD_VF($@)]) + +# DUMP_DP_IP_CLEAN_SORTED() +# +# Clean up and sort the ovs-dpctl dump-flow output for comparing. +# +m4_define([DUMP_DP_IP_CLEAN_SORTED], [dnl + grep 'eth_type(0x0800)' \ + | sed -e 's/eth(src=[[a-z0-9:]]*,dst=[[a-z0-9:]]*)/eth(macs)/;s/recirc_id(0),//' \ + | strip_used | strip_ptype | sort]) + +OVS_START_SHELL_HELPERS + +# ovs_rte_is_valid_pci_vf_addr() +# +# Check if the give PF PCI address and the VF number are valid. +# +ovs_rte_is_valid_pci_vf_addr() { + PCI_ID='[[0-9a-fA-F]]{4}:[[0-9a-fA-F]]{2}:[[0-9a-fA-F]]{2}\.[[0-7]]' + echo "$1" | grep -E -q "^$PCI_ID,[[0-9]]+$" && return 0 || return 1 +} + +# ovs_rte_get_pci_id() +# +ovs_rte_get_pci_id() { + printf '%s\n' "${1%%,*}" +} + +# ovs_rte_get_vf_idx() +# +ovs_rte_get_vf_idx() { + printf '%s\n' "${1##*,}" +} + +# ovr_rte_get_representor_netdev(<PF_PCI>, <VF_INDEX>) +# +# This function tries to find the representor netdev for the give PF's VF. +# +ovs_rte_get_representor_netdev() { + PF_PCI=$1 + VF_IDX=$2 + + VF_NET_DIR="/sys/bus/pci/devices/$PF_PCI/virtfn$VF_IDX/net" + + if [[ ! -d "$VF_NET_DIR" ]]; then + echo "ERROR: VF $VF_IDX for PF $PF_PCI does not exist" >&2 + return 1 + fi + + for iface in "$VF_NET_DIR"/*; do + if [[ -e "$iface" ]]; then + basename "$iface" + return 0 + fi + done + + echo "ERROR: No representor netdev found for VF $VF_IDX on PF $PF_PCI" >&2 + return 1 +} + +# ovs_rte_flow_verify_vf_cfg() +# +# Verify that the given PF PCI addresses and corresponding VF IDs in +# OVS_RTE_FLOW_VF_PCI_ADDRS are valid, exist, and have corresponding +# representor ports. +# +ovs_rte_flow_verify_vf_cfg() { + i=0 + + for addr in $1; do + ovs_rte_is_valid_pci_vf_addr "$addr" || return 1 + + PCI_ID=$(ovs_rte_get_pci_id "$addr") + VF_IDX=$(ovs_rte_get_vf_idx "$addr") + + REP=$(ovs_rte_get_representor_netdev $PCI_ID $VF_IDX) || return 1 + + echo "ovs-p$i: PF PCI $PCI_ID with VF $VF_IDX has representor $REP" + i=$((i + 1)) + done + + return 0 +} + +OVS_END_SHELL_HELPERS \ No newline at end of file diff --git a/tests/system-rte-offloads-testsuite.at b/tests/system-rte-offloads-testsuite.at new file mode 100644 index 000000000..5d64ff68b --- /dev/null +++ b/tests/system-rte-offloads-testsuite.at @@ -0,0 +1,28 @@ +AT_INIT + +AT_COPYRIGHT([Copyright (c) 2025 Red Hat, Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at: + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License.]) + +m4_ifdef([AT_COLOR_TESTS], [AT_COLOR_TESTS]) + +m4_include([tests/ovs-macros.at]) +m4_include([tests/ovsdb-macros.at]) +m4_include([tests/ofproto-macros.at]) +m4_include([tests/system-common-macros.at]) +m4_include([tests/system-userspace-macros.at]) +m4_include([tests/system-dpdk-macros.at]) +m4_include([tests/system-rte-offloads-macros.at]) + +m4_include([tests/system-rte-offloads.at]) +m4_include([tests/system-traffic.at]) diff --git a/tests/system-rte-offloads.at b/tests/system-rte-offloads.at new file mode 100644 index 000000000..0f3391780 --- /dev/null +++ b/tests/system-rte-offloads.at @@ -0,0 +1,111 @@ +AT_COPYRIGHT([Copyright (c) 2025 Red Hat, Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at: + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License.]) + +AT_BANNER([rte_flow offload unit tests]) + +AT_SETUP([rte_flow - ping between two hardware offloaded ports]) +OVS_RTE_FLOW_PRE_CHECK() +OVS_TRAFFIC_VSWITCHD_START() + +AT_CHECK([ovs-ofctl add-flow br0 "actions=normal"]) +ADD_NAMESPACES(at_ns0, at_ns1) +ADD_VF(p0, at_ns0, br0, "10.1.1.1/24") +ADD_VF(p1, at_ns1, br0, "10.1.1.2/24") + +NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -W 2 10.1.1.2 | FORMAT_PING], [0], [dnl +3 packets transmitted, 3 received, 0% packet loss, time 0ms +]) + +OVS_WAIT_UNTIL_EQUAL( + [ovs-appctl dpctl/dump-flows --names type=dpdk,offloaded \ + | DUMP_DP_IP_CLEAN_SORTED], [dnl +in_port(ovs-p0),eth(macs),eth_type(0x0800),ipv4(frag=no), packets:2, bytes:196, used:0.0s, actions:ovs-p1 +in_port(ovs-p1),eth(macs),eth_type(0x0800),ipv4(frag=no), packets:2, bytes:196, used:0.0s, actions:ovs-p0]) + +OVS_TRAFFIC_VSWITCHD_STOP +AT_CLEANUP + +m4_define([RTE_OFFLOAD_SIX_PORT_PING_TEST], [dnl + AT_SETUP($1) + OVS_RTE_FLOW_PRE_CHECK() + OVS_TRAFFIC_VSWITCHD_START($2) + m4_ifval([$2], [CHECK_CPU_DISCOVERED([14])]) + + AT_CHECK([ovs-ofctl add-flow br0 "actions=normal"]) + AT_CHECK([ovs-vsctl set Open_vSwitch . other_config:max-idle=20000]) + ADD_NAMESPACES(at_ns0, at_ns1, at_ns2, at_ns3, at_ns4, at_ns5) + ADD_VF(p0, at_ns0, br0, "10.1.1.1/24") + ADD_VF(p1, at_ns1, br0, "10.1.1.2/24") + ADD_VF(p2, at_ns2, br0, "10.1.1.3/24") + ADD_VF(p3, at_ns3, br0, "10.1.1.4/24") + ADD_VF(p4, at_ns4, br0, "10.1.1.5/24") + ADD_VF(p5, at_ns5, br0, "10.1.1.6/24") + + for NS in $(seq 0 5); do + START=$((NS + 2)) + for IP in $(seq "$START" 6); do + NS_CHECK_EXEC([at_ns$NS], [ping -q -c 3 -i 0.3 -W 2 10.1.1.$IP | FORMAT_PING], [0], [dnl +3 packets transmitted, 3 received, 0% packet loss, time 0ms +]) + done + done + + OVS_WAIT_UNTIL_EQUAL( + [ovs-appctl dpctl/dump-flows --names type=dpdk,offloaded \ + | DUMP_DP_IP_CLEAN_SORTED], [dnl +in_port(ovs-p0),eth(macs),eth_type(0x0800),ipv4(frag=no), packets:2, bytes:196, used:0.0s, actions:ovs-p1 +in_port(ovs-p0),eth(macs),eth_type(0x0800),ipv4(frag=no), packets:2, bytes:196, used:0.0s, actions:ovs-p2 +in_port(ovs-p0),eth(macs),eth_type(0x0800),ipv4(frag=no), packets:2, bytes:196, used:0.0s, actions:ovs-p3 +in_port(ovs-p0),eth(macs),eth_type(0x0800),ipv4(frag=no), packets:2, bytes:196, used:0.0s, actions:ovs-p4 +in_port(ovs-p0),eth(macs),eth_type(0x0800),ipv4(frag=no), packets:2, bytes:196, used:0.0s, actions:ovs-p5 +in_port(ovs-p1),eth(macs),eth_type(0x0800),ipv4(frag=no), packets:2, bytes:196, used:0.0s, actions:ovs-p0 +in_port(ovs-p1),eth(macs),eth_type(0x0800),ipv4(frag=no), packets:2, bytes:196, used:0.0s, actions:ovs-p2 +in_port(ovs-p1),eth(macs),eth_type(0x0800),ipv4(frag=no), packets:2, bytes:196, used:0.0s, actions:ovs-p3 +in_port(ovs-p1),eth(macs),eth_type(0x0800),ipv4(frag=no), packets:2, bytes:196, used:0.0s, actions:ovs-p4 +in_port(ovs-p1),eth(macs),eth_type(0x0800),ipv4(frag=no), packets:2, bytes:196, used:0.0s, actions:ovs-p5 +in_port(ovs-p2),eth(macs),eth_type(0x0800),ipv4(frag=no), packets:2, bytes:196, used:0.0s, actions:ovs-p0 +in_port(ovs-p2),eth(macs),eth_type(0x0800),ipv4(frag=no), packets:2, bytes:196, used:0.0s, actions:ovs-p1 +in_port(ovs-p2),eth(macs),eth_type(0x0800),ipv4(frag=no), packets:2, bytes:196, used:0.0s, actions:ovs-p3 +in_port(ovs-p2),eth(macs),eth_type(0x0800),ipv4(frag=no), packets:2, bytes:196, used:0.0s, actions:ovs-p4 +in_port(ovs-p2),eth(macs),eth_type(0x0800),ipv4(frag=no), packets:2, bytes:196, used:0.0s, actions:ovs-p5 +in_port(ovs-p3),eth(macs),eth_type(0x0800),ipv4(frag=no), packets:2, bytes:196, used:0.0s, actions:ovs-p0 +in_port(ovs-p3),eth(macs),eth_type(0x0800),ipv4(frag=no), packets:2, bytes:196, used:0.0s, actions:ovs-p1 +in_port(ovs-p3),eth(macs),eth_type(0x0800),ipv4(frag=no), packets:2, bytes:196, used:0.0s, actions:ovs-p2 +in_port(ovs-p3),eth(macs),eth_type(0x0800),ipv4(frag=no), packets:2, bytes:196, used:0.0s, actions:ovs-p4 +in_port(ovs-p3),eth(macs),eth_type(0x0800),ipv4(frag=no), packets:2, bytes:196, used:0.0s, actions:ovs-p5 +in_port(ovs-p4),eth(macs),eth_type(0x0800),ipv4(frag=no), packets:2, bytes:196, used:0.0s, actions:ovs-p0 +in_port(ovs-p4),eth(macs),eth_type(0x0800),ipv4(frag=no), packets:2, bytes:196, used:0.0s, actions:ovs-p1 +in_port(ovs-p4),eth(macs),eth_type(0x0800),ipv4(frag=no), packets:2, bytes:196, used:0.0s, actions:ovs-p2 +in_port(ovs-p4),eth(macs),eth_type(0x0800),ipv4(frag=no), packets:2, bytes:196, used:0.0s, actions:ovs-p3 +in_port(ovs-p4),eth(macs),eth_type(0x0800),ipv4(frag=no), packets:2, bytes:196, used:0.0s, actions:ovs-p5 +in_port(ovs-p5),eth(macs),eth_type(0x0800),ipv4(frag=no), packets:2, bytes:196, used:0.0s, actions:ovs-p0 +in_port(ovs-p5),eth(macs),eth_type(0x0800),ipv4(frag=no), packets:2, bytes:196, used:0.0s, actions:ovs-p1 +in_port(ovs-p5),eth(macs),eth_type(0x0800),ipv4(frag=no), packets:2, bytes:196, used:0.0s, actions:ovs-p2 +in_port(ovs-p5),eth(macs),eth_type(0x0800),ipv4(frag=no), packets:2, bytes:196, used:0.0s, actions:ovs-p3 +in_port(ovs-p5),eth(macs),eth_type(0x0800),ipv4(frag=no), packets:2, bytes:196, used:0.0s, actions:ovs-p4]) + + AT_CHECK([ovs-appctl dpctl/offload-stats-show], [0], [ignore], [ignore]) + AT_CHECK([ovs-appctl dpif-netdev/pmd-rxq-show], [0], [ignore], [ignore]) + + OVS_TRAFFIC_VSWITCHD_STOP + AT_CLEANUP +]) + +RTE_OFFLOAD_SIX_PORT_PING_TEST( + [rte_flow - ping between six hardware offloaded ports]) + +RTE_OFFLOAD_SIX_PORT_PING_TEST( + [rte_flow - ping with multiple offload threads], + [-- set Open_vSwitch . other_config:pmd-cpu-mask=0x3ffc \ + -- set Open_vSwitch . other_config:n-offload-threads=10]) diff --git a/tests/system-traffic.at b/tests/system-traffic.at index c613abea6..385fb8440 100644 --- a/tests/system-traffic.at +++ b/tests/system-traffic.at @@ -2456,6 +2456,7 @@ OVS_TRAFFIC_VSWITCHD_STOP(["/WARN/d"]) AT_CLEANUP AT_SETUP([datapath - simulated flow action update]) +CHECK_NO_RTE_FLOW_OFFLOAD() OVS_TRAFFIC_VSWITCHD_START() ADD_NAMESPACES(at_ns0, at_ns1) @@ -2520,6 +2521,7 @@ AT_CLEANUP AT_SETUP([datapath - netdev offload software fallback]) AT_SKIP_IF([test $HAVE_NC = no]) +CHECK_NO_RTE_FLOW_OFFLOAD() OVS_TRAFFIC_VSWITCHD_START() AT_CHECK([ovs-ofctl add-flow br0 "actions=normal"]) @@ -4492,6 +4494,7 @@ AT_CLEANUP AT_SETUP([conntrack - ICMP related]) AT_SKIP_IF([test $HAVE_NC = no]) +CHECK_NO_RTE_FLOW_OFFLOAD() CHECK_CONNTRACK() OVS_TRAFFIC_VSWITCHD_START() @@ -5870,6 +5873,7 @@ OVS_TRAFFIC_VSWITCHD_STOP AT_CLEANUP AT_SETUP([conntrack - resubmit to ct multiple times]) +CHECK_NO_RTE_FLOW_OFFLOAD() CHECK_CONNTRACK() OVS_TRAFFIC_VSWITCHD_START( @@ -7689,6 +7693,7 @@ AT_CLEANUP AT_SETUP([conntrack - ICMP related with NAT]) AT_SKIP_IF([test $HAVE_NC = no]) AT_SKIP_IF([test $HAVE_TCPDUMP = no]) +CHECK_NO_RTE_FLOW_OFFLOAD() CHECK_CONNTRACK() CHECK_CONNTRACK_NAT() OVS_TRAFFIC_VSWITCHD_START() @@ -9215,6 +9220,7 @@ AT_CLEANUP AT_SETUP([conntrack - Multiple ICMP traverse]) dnl This tracks sending ICMP packets via conntrack multiple times for the dnl same packet +CHECK_NO_RTE_FLOW_OFFLOAD() CHECK_CONNTRACK() OVS_TRAFFIC_VSWITCHD_START() OVS_CHECK_CT_CLEAR() diff --git a/tests/system-userspace-macros.at b/tests/system-userspace-macros.at index 49b277a08..71e3bad7b 100644 --- a/tests/system-userspace-macros.at +++ b/tests/system-userspace-macros.at @@ -353,6 +353,11 @@ m4_define([CHECK_L3L4_CONNTRACK_REASM], AT_SKIP_IF([:]) ]) +# CHECK_NO_RTE_FLOW_OFFLOAD +# +# The kernel module tests do not use RTE_FLOW offload. +m4_define([CHECK_NO_RTE_FLOW_OFFLOAD]) + # CHECK_NO_TC_OFFLOAD # # Userspace tests do not use TC offload. -- 2.50.1 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
