From patchwork Tue Dec 19 14:47:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Pattrick X-Patchwork-Id: 1878004 X-Patchwork-Delegate: i.maximets@samsung.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=g5QAsPn+; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SvfgD4Gzzz1ydg for ; Wed, 20 Dec 2023 01:47:36 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 8DEEE418E3; Tue, 19 Dec 2023 14:47:33 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 8DEEE418E3 Authentication-Results: smtp2.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=g5QAsPn+ X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cqYXLSaImUjL; Tue, 19 Dec 2023 14:47:32 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp2.osuosl.org (Postfix) with ESMTPS id 9EF3643577; Tue, 19 Dec 2023 14:47:30 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 9EF3643577 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 866D2C0DD6; Tue, 19 Dec 2023 14:47:28 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) by lists.linuxfoundation.org (Postfix) with ESMTP id A12BAC0037 for ; Tue, 19 Dec 2023 14:47:27 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 8A17682EA2 for ; Tue, 19 Dec 2023 14:47:27 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 8A17682EA2 Authentication-Results: smtp1.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=g5QAsPn+ X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id EDVBjFKpCilj for ; Tue, 19 Dec 2023 14:47:26 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp1.osuosl.org (Postfix) with ESMTPS id 4BC0582E9D for ; Tue, 19 Dec 2023 14:47:26 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 4BC0582E9D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1702997245; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bEj1aSyL7m9qKPdJpKxvsGfxK2TBW9PmU3EUORC1si0=; b=g5QAsPn+CF6zra2D+Ut0MX//U5GPUViPA83ib3dBPlGsPxwMkVfqwVb3GB8JJ2EnpoJH0a tdNcycuI4SdfLem64DxJZRoKC2X7Rd17SIAHfLNOsmW4LqN2yyCoHxCcOZOZ84RW2iqh8D Qn4tHniTGMGmnYz1dbSmgcFFxJv2xfE= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-599-k_J7JpIlOhSKdAw05w0eNw-1; Tue, 19 Dec 2023 09:47:23 -0500 X-MC-Unique: k_J7JpIlOhSKdAw05w0eNw-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 759CE848D60 for ; Tue, 19 Dec 2023 14:47:23 +0000 (UTC) Received: from mpattric.remote.csb (unknown [10.22.8.90]) by smtp.corp.redhat.com (Postfix) with ESMTP id 20CB4492BC6; Tue, 19 Dec 2023 14:47:23 +0000 (UTC) From: Mike Pattrick To: dev@openvswitch.org Date: Tue, 19 Dec 2023 09:47:19 -0500 Message-Id: <20231219144719.1562790-2-mkp@redhat.com> In-Reply-To: <20231219144719.1562790-1-mkp@redhat.com> References: <20231219144719.1562790-1-mkp@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH v4 2/2] netdev-dummy: Add support and test for tso. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Test that netdev-dummy is able to send and receive segment offloaded packets. Signed-off-by: Mike Pattrick Acked-by: Simon Horman --- v2: Fix clang build error: mutex needed to access netdev_dummy members v3: Remove use of tcpdump, hexdump, and otherwise clean up test v4: Wrapped long lines in test --- lib/netdev-dummy.c | 32 +++++++++++- tests/dpif-netdev.at | 122 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 153 insertions(+), 1 deletion(-) diff --git a/lib/netdev-dummy.c b/lib/netdev-dummy.c index 8c6e6d448..9d9a28892 100644 --- a/lib/netdev-dummy.c +++ b/lib/netdev-dummy.c @@ -44,6 +44,7 @@ #include "unaligned.h" #include "timeval.h" #include "unixctl.h" +#include "userspace-tso.h" #include "reconnect.h" VLOG_DEFINE_THIS_MODULE(netdev_dummy); @@ -152,6 +153,8 @@ struct netdev_dummy { bool ol_ip_csum OVS_GUARDED; /* Flag RX packet with good csum. */ bool ol_ip_csum_set_good OVS_GUARDED; + /* Set the segment size for netdev TSO support. */ + int ol_tso_segsz OVS_GUARDED; }; /* Max 'recv_queue_len' in struct netdev_dummy. */ @@ -806,6 +809,10 @@ netdev_dummy_get_config(const struct netdev *dev, struct smap *args) smap_add_format(args, "ol_ip_csum_set_good", "%s", "true"); } + if (netdev->ol_tso_segsz && userspace_tso_enabled()) { + smap_add_format(args, "ol_tso_segsz", "%d", netdev->ol_tso_segsz); + } + /* 'dummy-pmd' specific config. */ if (!netdev_is_pmd(dev)) { goto exit; @@ -937,6 +944,14 @@ netdev_dummy_set_config(struct netdev *netdev_, const struct smap *args, netdev_->ol_flags |= NETDEV_TX_OFFLOAD_IPV4_CKSUM; } + if (userspace_tso_enabled()) { + netdev->ol_tso_segsz = smap_get_int(args, "ol_tso_segsz", 0); + if (netdev->ol_tso_segsz) { + netdev_->ol_flags |= (NETDEV_TX_OFFLOAD_TCP_TSO + | NETDEV_TX_OFFLOAD_TCP_CKSUM); + } + } + netdev_change_seq_changed(netdev_); /* 'dummy-pmd' specific config. */ @@ -1119,6 +1134,15 @@ netdev_dummy_rxq_recv(struct netdev_rxq *rxq_, struct dp_packet_batch *batch, /* The netdev hardware sets the flag when the packet has good csum. */ dp_packet_ol_set_ip_csum_good(packet); } + + if (userspace_tso_enabled() && netdev->ol_tso_segsz) { + dp_packet_set_tso_segsz(packet, netdev->ol_tso_segsz); + dp_packet_hwol_set_tcp_seg(packet); + dp_packet_hwol_set_tx_ip_csum(packet); + dp_packet_hwol_set_tx_ipv4(packet); + dp_packet_hwol_set_csum_tcp(packet); + } + ovs_mutex_unlock(&netdev->mutex); dp_packet_batch_init_packet(batch, packet); @@ -1174,6 +1198,12 @@ netdev_dummy_send(struct netdev *netdev, int qid, DP_PACKET_BATCH_FOR_EACH(i, packet, batch) { const void *buffer = dp_packet_data(packet); size_t size = dp_packet_size(packet); + bool is_tso; + + ovs_mutex_lock(&dev->mutex); + is_tso = userspace_tso_enabled() && dev->ol_tso_segsz && + dp_packet_hwol_is_tso(packet); + ovs_mutex_unlock(&dev->mutex); if (!dp_packet_is_eth(packet)) { error = EPFNOSUPPORT; @@ -1194,7 +1224,7 @@ netdev_dummy_send(struct netdev *netdev, int qid, if (eth->eth_type == htons(ETH_TYPE_VLAN)) { max_size += VLAN_HEADER_LEN; } - if (size > max_size) { + if (size > max_size && !is_tso) { error = EMSGSIZE; break; } diff --git a/tests/dpif-netdev.at b/tests/dpif-netdev.at index d0359b5ea..e0d81e7d4 100644 --- a/tests/dpif-netdev.at +++ b/tests/dpif-netdev.at @@ -810,6 +810,128 @@ AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected} OVS_VSWITCHD_STOP AT_CLEANUP +AT_SETUP([userspace offload - tso]) +OVS_VSWITCHD_START( + [set Open_vSwitch . other_config:userspace-tso-enable=true -- \ + add-br br1 -- set bridge br1 datapath-type=dummy -- \ + add-port br1 p1 -- \ + set Interface p1 type=dummy -- \ + add-port br1 p2 -- \ + set Interface p2 type=dummy]) + +dnl Simple passthrough rule. +AT_CHECK([ovs-ofctl add-flow br1 in_port=p1,actions=output:p2]) + +flow_s="in_port(1),eth(src=8a:bf:7e:2f:05:84,dst=0a:8f:39:4f:e0:73),eth_type(0x0800), \ + ipv4(src=192.168.123.2,dst=192.168.123.1,proto=6,tos=1,ttl=64,frag=no), \ + tcp(src=54392,dst=5201),tcp_flags(ack)" + +dnl Send from tso to no-tso. +AT_CHECK([ovs-vsctl set Interface p2 options:tx_pcap=p2.pcap -- \ + set Interface p1 options:ol_ip_csum=true -- \ + set Interface p1 options:ol_ip_csum_set_good=false -- \ + set Interface p1 options:ol_tso_segsz=500]) + +AT_CHECK([ovs-appctl netdev-dummy/receive p1 "${flow_s}" --len 2054]) + +dnl Send from tso to tso. +AT_CHECK([ovs-vsctl set Interface p2 options:ol_ip_csum=true -- \ + set Interface p2 options:ol_ip_csum_set_good=false -- \ + set Interface p2 options:ol_tso_segsz=500]) + +AT_CHECK([ovs-appctl netdev-dummy/receive p1 "${flow_s}" --len 2054]) + +dnl Check that first we have 4x 500 byte payloads, then one 2000 byte payload. +AT_CHECK([ovs-pcap p2.pcap], [0], [dnl +[0a8f394fe0738abf7e2f058408004501021c0000000040060187c0a87b02c0a87b01d47814510000000000000000501000004dc2]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000] +[0a8f394fe0738abf7e2f058408004501021c0001000040060186c0a87b02c0a87b01d4781451000001f400000000501000004bce]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000] +[0a8f394fe0738abf7e2f058408004501021c0002000040060185c0a87b02c0a87b01d4781451000003e8000000005010000049da]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000] +[0a8f394fe0738abf7e2f058408004501021c0003000040060184c0a87b02c0a87b01d4781451000005dc000000005010000047e6]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000] +[0a8f394fe0738abf7e2f05840800450107f8000000004006fbaac0a87b02c0a87b01d478145100000000000000005010000047e6]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]dnl +[0000000000000000000000000000000000000000000000000000] +]) + +OVS_VSWITCHD_STOP +AT_CLEANUP + AT_SETUP([dpif-netdev - revalidators handle dp modification fail correctly]) OVS_VSWITCHD_START( [add-port br0 p1 \