From patchwork Tue Mar 21 18:05:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Pattrick X-Patchwork-Id: 1759546 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) 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=H5b6LnrX; dkim-atps=neutral Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Ph0041Y8Hz247F for ; Wed, 22 Mar 2023 05:05:56 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id EE2FD82095; Tue, 21 Mar 2023 18:05:53 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org EE2FD82095 Authentication-Results: smtp1.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=H5b6LnrX 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 LZ1VYadgBGkp; Tue, 21 Mar 2023 18:05:52 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp1.osuosl.org (Postfix) with ESMTPS id E21AD8203E; Tue, 21 Mar 2023 18:05:50 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org E21AD8203E Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id BC373C0077; Tue, 21 Mar 2023 18:05:50 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 30BA8C008D for ; Tue, 21 Mar 2023 18:05:48 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 460A0418EF for ; Tue, 21 Mar 2023 18:05:47 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 460A0418EF Authentication-Results: smtp4.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=H5b6LnrX X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id igPzAN_-qByb for ; Tue, 21 Mar 2023 18:05:46 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 5B523418DA Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp4.osuosl.org (Postfix) with ESMTPS id 5B523418DA for ; Tue, 21 Mar 2023 18:05:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679421945; 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=uOQR4Ts4t5BZq0IAFw21tLvCQ8i5Nd1rWYLwfhkhiuE=; b=H5b6LnrXpv32ki67TfjjAndVX+EdE1yr/6697lNr1aI0+06tK41aj1p7Lw0pIiu4cHPZYe lSBnZzJyRCQDdf5ttiU/g8aOzVs7fZkLyOh1xqa/HP911J3veBWkO5VJG5dicqYldg85S7 mN584nJhYTR7EJrZiuMhAAEQAWC7x9k= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-478-W6R9K3EMOpWrdMjm0qg0Vg-1; Tue, 21 Mar 2023 14:05:40 -0400 X-MC-Unique: W6R9K3EMOpWrdMjm0qg0Vg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A9D0F85C6E4; Tue, 21 Mar 2023 18:05:39 +0000 (UTC) Received: from mpattric.remote.csb (unknown [10.22.9.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2E56BC15BA0; Tue, 21 Mar 2023 18:05:39 +0000 (UTC) From: Mike Pattrick To: dev@openvswitch.org Date: Tue, 21 Mar 2023 14:05:12 -0400 Message-Id: <20230321180514.121511-2-mkp@redhat.com> In-Reply-To: <20230321180514.121511-1-mkp@redhat.com> References: <20221124053049.1894509-2-mkp@redhat.com> <20230321180514.121511-1-mkp@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: Flavio Leitner , david.marchand@redhat.com, i.maximets@ovn.org Subject: [ovs-dev] [PATCH v10 2/4] dpif-netdev: Show netdev offloading flags. 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" From: Flavio Leitner This patch modifies netdev_get_status to include information about checksum offload status by port, allowing the user to gain insight into where checksum offloading is active. Signed-off-by: Flavio Leitner Co-authored-by: Mike Pattrick Signed-off-by: Mike Pattrick --- Since v9: - Removed entire ovs-appctl dpif-netdev/offload-show command, replaced with a field in the netdev status. - Removed duplicative field tx_tso_offload from netdev-dpdk.c --- lib/dpif-netdev-unixctl.man | 6 ++++++ lib/netdev-dpdk.c | 5 ----- lib/netdev-provider.h | 1 + lib/netdev.c | 29 ++++++++++++++++++++++++++--- tests/dpif-netdev.at | 18 ++++++++++++++++++ 5 files changed, 51 insertions(+), 8 deletions(-) diff --git a/lib/dpif-netdev-unixctl.man b/lib/dpif-netdev-unixctl.man index 8cd847416..2840d462e 100644 --- a/lib/dpif-netdev-unixctl.man +++ b/lib/dpif-netdev-unixctl.man @@ -262,3 +262,9 @@ PMDs in the case where no value is specified. By default "scalar" is used. \fIstudy_cnt\fR defaults to 128 and indicates the number of packets that the "study" miniflow implementation must parse before choosing an optimal implementation. +. +.IP "\fBdpif-netdev/offload-show\fR [\fIdp\fR] [\fInetdev\fR]" +Prints the hardware offloading features enabled in netdev \fInetdev\fR +attached to datapath \fIdp\fR. The datapath \fIdp\fR parameter can be +omitted if there is only one. All netdev ports are printed if the +parameter \fInetdev\fR is omitted. diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index fb0dd43f7..560694dbc 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -1753,11 +1753,6 @@ netdev_dpdk_get_config(const struct netdev *netdev, struct smap *args) } else { smap_add(args, "rx_csum_offload", "false"); } - if (dev->hw_ol_features & NETDEV_TX_TSO_OFFLOAD) { - smap_add(args, "tx_tso_offload", "true"); - } else { - smap_add(args, "tx_tso_offload", "false"); - } smap_add(args, "lsc_interrupt_mode", dev->lsc_interrupt_mode ? "true" : "false"); diff --git a/lib/netdev-provider.h b/lib/netdev-provider.h index b5420947d..fcf52bdd9 100644 --- a/lib/netdev-provider.h +++ b/lib/netdev-provider.h @@ -37,6 +37,7 @@ extern "C" { struct netdev_tnl_build_header_params; #define NETDEV_NUMA_UNSPEC OVS_NUMA_UNSPEC +/* Keep this enum updated with translation to string below. */ enum netdev_ol_flags { NETDEV_TX_OFFLOAD_IPV4_CKSUM = 1 << 0, NETDEV_TX_OFFLOAD_TCP_CKSUM = 1 << 1, diff --git a/lib/netdev.c b/lib/netdev.c index c79778378..818589246 100644 --- a/lib/netdev.c +++ b/lib/netdev.c @@ -43,6 +43,7 @@ #include "netdev-provider.h" #include "netdev-vport.h" #include "odp-netlink.h" +#include "openvswitch/json.h" #include "openflow/openflow.h" #include "packets.h" #include "openvswitch/ofp-print.h" @@ -1373,9 +1374,31 @@ netdev_get_next_hop(const struct netdev *netdev, int netdev_get_status(const struct netdev *netdev, struct smap *smap) { - return (netdev->netdev_class->get_status - ? netdev->netdev_class->get_status(netdev, smap) - : EOPNOTSUPP); + int err = EOPNOTSUPP; + + /* Set offload status only if relevant. */ + if (netdev_get_dpif_type(netdev) && + strcmp(netdev_get_dpif_type(netdev), "system")) { + +#define OL_ADD_STAT(name, bit) \ + smap_add(smap, name "_csum_offload", \ + netdev->ol_flags & bit ? "true" : "false"); + + OL_ADD_STAT("ip", NETDEV_TX_OFFLOAD_IPV4_CKSUM); + OL_ADD_STAT("tcp", NETDEV_TX_OFFLOAD_TCP_CKSUM); + OL_ADD_STAT("udp", NETDEV_TX_OFFLOAD_UDP_CKSUM); + OL_ADD_STAT("sctp", NETDEV_TX_OFFLOAD_SCTP_CKSUM); + OL_ADD_STAT("tso", NETDEV_TX_OFFLOAD_TCP_TSO); +#undef OL_ADD_STAT + + err = 0; + } + + if (!netdev->netdev_class->get_status) { + return err; + } + + return netdev->netdev_class->get_status(netdev, smap); } /* Returns all assigned IP address to 'netdev' and returns 0. diff --git a/tests/dpif-netdev.at b/tests/dpif-netdev.at index baab60a22..8a663a4b6 100644 --- a/tests/dpif-netdev.at +++ b/tests/dpif-netdev.at @@ -650,6 +650,24 @@ AT_CHECK([ovs-appctl revalidator/resume]) OVS_VSWITCHD_STOP AT_CLEANUP +AT_SETUP([dpif-netdev - check dpif-netdev/offload-show]) +OVS_VSWITCHD_START( + [add-port br0 p1 \ + -- set interface p1 type=dummy options:pstream=punix:$OVS_RUNDIR/p0.sock \ + -- set bridge br0 datapath-type=dummy \ + other-config:datapath-id=1234 fail-mode=secure]) + +AT_CHECK([ovs-vsctl list interface p1 | sed -n 's/^status.*{\(.*\).*}$/\1/p'], [0], [dnl +ip_csum_offload="false", sctp_csum_offload="false", tcp_csum_offload="false", tso_csum_offload="false", udp_csum_offload="false" +], []) + +AT_CHECK([ovs-vsctl list interface br0 | sed -n 's/^status.*{\(.*\).*}$/\1/p'], [0], [dnl +ip_csum_offload="false", sctp_csum_offload="false", tcp_csum_offload="false", tso_csum_offload="false", udp_csum_offload="false" +], []) + +OVS_VSWITCHD_STOP +AT_CLEANUP + # SEND_UDP_PKTS([p_name], [p_ofport]) # # Sends 128 packets to port 'p_name' with different UDP destination ports.