From patchwork Tue Jun 14 22:13:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Pattrick X-Patchwork-Id: 1643442 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=T2HK+mE6; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) (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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4LN2lc5rfZz9vGJ for ; Wed, 15 Jun 2022 08:14:04 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id B8C294194D; Tue, 14 Jun 2022 22:14:01 +0000 (UTC) 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 Qr0GckxG9G3a; Tue, 14 Jun 2022 22:13:57 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp4.osuosl.org (Postfix) with ESMTPS id 24048418EC; Tue, 14 Jun 2022 22:13:56 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id B11D5C0083; Tue, 14 Jun 2022 22:13:53 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) by lists.linuxfoundation.org (Postfix) with ESMTP id E1327C0085 for ; Tue, 14 Jun 2022 22:13:45 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id B722C40B83 for ; Tue, 14 Jun 2022 22:13:45 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp2.osuosl.org (amavisd-new); dkim=fail (1024-bit key) reason="fail (body has been altered)" header.d=redhat.com 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 E3fyNxOAEX1B for ; Tue, 14 Jun 2022 22:13:44 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp2.osuosl.org (Postfix) with ESMTPS id ACCF8403AC for ; Tue, 14 Jun 2022 22:13:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655244823; 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=KNOsWQbBkah2NrTcHC6NUIF05DpdT98IWwBLX7gXlgk=; b=T2HK+mE6pzgmMY4Bbkp0+/ZFirt5NqERPLNGbse3tQq2IZ4SgRxN7ZeSbBv905y3mrOq2i EnwFY+2g3aQJ/DHcOJi04nqwN21hHpwK7tea8qvYkz+GqOcC7C9b88POtV0E7QuwEU9/IP q/cTVR0hqkSxBP65DvcjlcVqQ80DtjA= 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-442-FXkBZRQ0O5W1EhIeRZIv1Q-1; Tue, 14 Jun 2022 18:13:40 -0400 X-MC-Unique: FXkBZRQ0O5W1EhIeRZIv1Q-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 09C7485A581; Tue, 14 Jun 2022 22:13:40 +0000 (UTC) Received: from mpattric.remote.csb (unknown [10.22.18.26]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9FA81492C3B; Tue, 14 Jun 2022 22:13:39 +0000 (UTC) From: Mike Pattrick To: dev@openvswitch.org Date: Tue, 14 Jun 2022 18:13:16 -0400 Message-Id: <20220614221317.1028795-9-mkp@redhat.com> In-Reply-To: <20220614221317.1028795-8-mkp@redhat.com> References: <20220614221317.1028795-1-mkp@redhat.com> <20220614221317.1028795-2-mkp@redhat.com> <20220614221317.1028795-3-mkp@redhat.com> <20220614221317.1028795-4-mkp@redhat.com> <20220614221317.1028795-5-mkp@redhat.com> <20220614221317.1028795-6-mkp@redhat.com> <20220614221317.1028795-7-mkp@redhat.com> <20220614221317.1028795-8-mkp@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mkp@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: Flavio Leitner , maxime.coquelin@redhat.com, david.marchand@redhat.com Subject: [ovs-dev] [PATCH 09/10] 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 Add a new command to show the offloading features of each data path port. Signed-off-by: Flavio Leitner Signed-off-by: Mike Pattrick Co-authored-by: Mike Pattrick --- lib/dpif-netdev-unixctl.man | 5 ++++ lib/dpif-netdev.c | 58 +++++++++++++++++++++++++++++++++++++ lib/netdev-provider.h | 3 ++ lib/netdev.c | 35 ++++++++++++++++++++++ tests/dpif-netdev.at | 21 ++++++++++++++ 5 files changed, 122 insertions(+) diff --git a/lib/dpif-netdev-unixctl.man b/lib/dpif-netdev-unixctl.man index 8cd847416..a1bdb2f9a 100644 --- a/lib/dpif-netdev-unixctl.man +++ b/lib/dpif-netdev-unixctl.man @@ -262,3 +262,8 @@ 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/dpif-netdev.c b/lib/dpif-netdev.c index ff57b3961..b3839e948 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -1568,6 +1568,61 @@ dpif_netdev_bond_show(struct unixctl_conn *conn, int argc, ds_destroy(&reply); } +static void +dpif_netdev_offload_show(struct unixctl_conn *conn, int argc, + const char *argv[], void *aux OVS_UNUSED) +{ + struct ds reply = DS_EMPTY_INITIALIZER; + const char *netdev_name = NULL; + struct dp_netdev *dp = NULL; + struct dp_netdev_port *port; + + ovs_mutex_lock(&dp_netdev_mutex); + if (argc == 3) { + dp = shash_find_data(&dp_netdevs, argv[1]); + netdev_name = argv[2]; + } else if (argc == 2) { + dp = shash_find_data(&dp_netdevs, argv[1]); + if (!dp && shash_count(&dp_netdevs) == 1) { + /* There's only one datapath. */ + dp = shash_first(&dp_netdevs)->data; + netdev_name = argv[1]; + } + } else if (shash_count(&dp_netdevs) == 1) { + /* There's only one datapath. */ + dp = shash_first(&dp_netdevs)->data; + } + + if (!dp) { + ovs_mutex_unlock(&dp_netdev_mutex); + unixctl_command_reply_error(conn, + "please specify an existing datapath"); + return; + } + + ovs_rwlock_rdlock(&dp->port_rwlock); + HMAP_FOR_EACH (port, node, &dp->ports) { + if (netdev_name) { + /* find the port and dump the info */ + if (!strcmp(netdev_get_name(port->netdev), netdev_name)) { + ds_put_format(&reply, "%s: ", netdev_get_name(port->netdev)); + netdev_ol_flags_to_string(&reply, port->netdev); + ds_put_format(&reply, "\n"); + break; + } + } else { + ds_put_format(&reply, "%s: ", netdev_get_name(port->netdev)); + netdev_ol_flags_to_string(&reply, port->netdev); + ds_put_format(&reply, "\n"); + } + } + + ovs_rwlock_unlock(&dp->port_rwlock); + ovs_mutex_unlock(&dp_netdev_mutex); + unixctl_command_reply(conn, ds_cstr(&reply)); + ds_destroy(&reply); +} + static int dpif_netdev_init(void) @@ -1624,6 +1679,9 @@ dpif_netdev_init(void) unixctl_command_register("dpif-netdev/miniflow-parser-get", "", 0, 0, dpif_miniflow_extract_impl_get, NULL); + unixctl_command_register("dpif-netdev/offload-show", "[dp] [netdev]", + 0, 2, dpif_netdev_offload_show, + NULL); return 0; } diff --git a/lib/netdev-provider.h b/lib/netdev-provider.h index 0a8538615..5489ebbb8 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_OFFLOAD_TX_IPV4_CSUM = 1 << 0, NETDEV_OFFLOAD_TX_TCP_CSUM = 1 << 1, @@ -45,6 +46,8 @@ enum netdev_ol_flags { NETDEV_OFFLOAD_TX_TCP_TSO = 1 << 4, }; +void netdev_ol_flags_to_string(struct ds *, const struct netdev *); + /* A network device (e.g. an Ethernet device). * * Network device implementations may read these members but should not modify diff --git a/lib/netdev.c b/lib/netdev.c index 1219ddbb9..5eecacd9e 100644 --- a/lib/netdev.c +++ b/lib/netdev.c @@ -2298,3 +2298,38 @@ netdev_free_custom_stats_counters(struct netdev_custom_stats *custom_stats) } } } + +void +netdev_ol_flags_to_string(struct ds *string, const struct netdev *netdev) +{ + /* Sort by dependency, if any. */ + if (netdev->ol_flags & NETDEV_OFFLOAD_TX_IPV4_CSUM) { + ds_put_format(string, "ip_csum: on, "); + } else { + ds_put_format(string, "ip_csum: off, "); + } + + if (netdev->ol_flags & NETDEV_OFFLOAD_TX_TCP_CSUM) { + ds_put_format(string, "tcp_csum: on, "); + } else { + ds_put_format(string, "tcp_csum: off, "); + } + + if (netdev->ol_flags & NETDEV_OFFLOAD_TX_UDP_CSUM) { + ds_put_format(string, "udp_csum: on, "); + } else { + ds_put_format(string, "udp_csum: off, "); + } + + if (netdev->ol_flags & NETDEV_OFFLOAD_TX_SCTP_CSUM) { + ds_put_format(string, "sctp_csum: on, "); + } else { + ds_put_format(string, "sctp_csum: off, "); + } + + if (netdev->ol_flags & NETDEV_OFFLOAD_TX_TCP_TSO) { + ds_put_format(string, "tso: on"); + } else { + ds_put_format(string, "tso: off"); + } +} diff --git a/tests/dpif-netdev.at b/tests/dpif-netdev.at index a79ebdb61..416f15fe6 100644 --- a/tests/dpif-netdev.at +++ b/tests/dpif-netdev.at @@ -636,6 +636,27 @@ OVS_VSWITCHD_STOP(["/flow: in_port is not an exact match/d /failed to put/d"]) 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-appctl dpif-netdev/offload-show | sort], [0], [dnl +br0: ip_csum: off, tcp_csum: off, udp_csum: off, sctp_csum: off, tso: off +ovs-dummy: ip_csum: off, tcp_csum: off, udp_csum: off, sctp_csum: off, tso: off +p1: ip_csum: off, tcp_csum: off, udp_csum: off, sctp_csum: off, tso: off +], []) +AT_CHECK([ovs-appctl dpif-netdev/offload-show p1], [0], [dnl +p1: ip_csum: off, tcp_csum: off, udp_csum: off, sctp_csum: off, tso: off +], []) +AT_CHECK([ovs-appctl dpif-netdev/offload-show ovs-dummy p1], [0], [dnl +p1: ip_csum: off, tcp_csum: off, udp_csum: off, sctp_csum: off, tso: off +], []) +OVS_VSWITCHD_STOP +AT_CLEANUP + # SEND_UDP_PKTS([p_name], [p_ofport]) # # Sends 128 packets to port 'p_name' with different UDP destination ports.