From patchwork Fri Jul 9 15:58:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Van Haaren, Harry" X-Patchwork-Id: 1503263 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GLyYP6XHpz9sRN for ; Sat, 10 Jul 2021 02:00:25 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 37EB54240E; Fri, 9 Jul 2021 16:00:23 +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 J4fHt8TlZw7z; Fri, 9 Jul 2021 16:00:21 +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 C1695423B0; Fri, 9 Jul 2021 16:00:20 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id A62C2C001A; Fri, 9 Jul 2021 16:00:20 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 3D73BC000E for ; Fri, 9 Jul 2021 16:00:19 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 7194241DBD for ; Fri, 9 Jul 2021 15:59:50 +0000 (UTC) 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 1JncyPy9me9B for ; Fri, 9 Jul 2021 15:59:49 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by smtp2.osuosl.org (Postfix) with ESMTPS id 9D7D241DE4 for ; Fri, 9 Jul 2021 15:59:45 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6200,9189,10039"; a="206711720" X-IronPort-AV: E=Sophos;i="5.84,226,1620716400"; d="scan'208";a="206711720" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jul 2021 08:58:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,226,1620716400"; d="scan'208";a="499227711" Received: from silpixa00401089.ir.intel.com ([10.55.129.12]) by fmsmga002.fm.intel.com with ESMTP; 09 Jul 2021 08:58:41 -0700 From: Harry van Haaren To: ovs-dev@openvswitch.org Date: Fri, 9 Jul 2021 15:58:19 +0000 Message-Id: <20210709155824.506447-6-harry.van.haaren@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210709155824.506447-1-harry.van.haaren@intel.com> References: <20210708140240.61172-1-cian.ferriter@intel.com> <20210709155824.506447-1-harry.van.haaren@intel.com> MIME-Version: 1.0 Cc: i.maximets@ovn.org, fbl@sysclose.org Subject: [ovs-dev] [PATCH v16 05/10] dpif-netdev: Add command to get dpif implementations. 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" This commit adds a new command to retrieve the list of available DPIF implementations. This can be used by to check what implementations of the DPIF are available in any given OVS binary. It also returns which implementations are in use by the OVS PMD threads. Usage: $ ovs-appctl dpif-netdev/dpif-impl-get Signed-off-by: Harry van Haaren Co-authored-by: Cian Ferriter Signed-off-by: Cian Ferriter Acked-by: Flavio Leitner --- v16: - Include Flavio's Ack from ML v15: - Address Flavio's comments from the v14 review. v14: - Rename command to dpif-impl-get. - Hide more of the dpif impl details from lib/dpif-netdev.c. Pass a dynamic_string to return the dpif-impl-get CMD output. - Add information about which DPIF impl is currently in use by each PMD thread. v13: - Add NEWS item about DPIF get and set commands here rather than in a later commit. - Add documentation items about DPIF set commands here rather than in a later commit. --- Documentation/topics/dpdk/bridge.rst | 8 +++++++ NEWS | 1 + lib/dpif-netdev-private-dpif.c | 31 ++++++++++++++++++++++++++++ lib/dpif-netdev-private-dpif.h | 6 ++++++ lib/dpif-netdev-unixctl.man | 3 +++ lib/dpif-netdev.c | 26 +++++++++++++++++++++++ 6 files changed, 75 insertions(+) diff --git a/Documentation/topics/dpdk/bridge.rst b/Documentation/topics/dpdk/bridge.rst index 06d1f943c1..2d0850836f 100644 --- a/Documentation/topics/dpdk/bridge.rst +++ b/Documentation/topics/dpdk/bridge.rst @@ -226,6 +226,14 @@ stats associated with the datapath. Just like with the SIMD DPCLS feature above, SIMD can be applied to the DPIF to improve performance. +OVS provides multiple implementations of the DPIF. The available +implementations can be listed with the following command :: + + $ ovs-appctl dpif-netdev/dpif-impl-get + Available DPIF implementations: + dpif_scalar (pmds: none) + dpif_avx512 (pmds: 1,2,6,7) + By default, dpif_scalar is used. The DPIF implementation can be selected by name :: diff --git a/NEWS b/NEWS index 2625cabc85..471f3a1a28 100644 --- a/NEWS +++ b/NEWS @@ -23,6 +23,7 @@ Post-v2.15.0 * Refactor lib/dpif-netdev.c to multiple header files. * Add avx512 implementation of dpif which can process non recirculated packets. It supports partial HWOL, EMC, SMC and DPCLS lookups. + * Add commands to get and set the dpif implementations. - ovs-ctl: * New option '--no-record-hostname' to disable hostname configuration in ovsdb on startup. diff --git a/lib/dpif-netdev-private-dpif.c b/lib/dpif-netdev-private-dpif.c index a05a82fa11..84d4ec156e 100644 --- a/lib/dpif-netdev-private-dpif.c +++ b/lib/dpif-netdev-private-dpif.c @@ -79,6 +79,37 @@ dp_netdev_impl_get_default(void) return default_dpif_func; } +void +dp_netdev_impl_get(struct ds *reply, struct dp_netdev_pmd_thread **pmd_list, + size_t n) +{ + /* Add all dpif functions to reply string. */ + ds_put_cstr(reply, "Available DPIF implementations:\n"); + + for (uint32_t i = 0; i < ARRAY_SIZE(dpif_impls); i++) { + ds_put_format(reply, " %s (pmds: ", dpif_impls[i].name); + + for (size_t j = 0; j < n; j++) { + struct dp_netdev_pmd_thread *pmd = pmd_list[j]; + if (pmd->core_id == NON_PMD_CORE_ID) { + continue; + } + + if (pmd->netdev_input_func == dpif_impls[i].input_func) { + ds_put_format(reply, "%u,", pmd->core_id); + } + } + + ds_chomp(reply, ','); + + if (ds_last(reply) == ' ') { + ds_put_cstr(reply, "none"); + } + + ds_put_cstr(reply, ")\n"); + } +} + /* This function checks all available DPIF implementations, and selects the * returns the function pointer to the one requested by "name". */ diff --git a/lib/dpif-netdev-private-dpif.h b/lib/dpif-netdev-private-dpif.h index 7880647ad3..0da639c55a 100644 --- a/lib/dpif-netdev-private-dpif.h +++ b/lib/dpif-netdev-private-dpif.h @@ -22,6 +22,7 @@ /* Forward declarations to avoid including files. */ struct dp_netdev_pmd_thread; struct dp_packet_batch; +struct ds; /* Typedef for DPIF functions. * Returns whether all packets were processed successfully. @@ -48,6 +49,11 @@ struct dpif_netdev_impl_info_t { const char *name; }; +/* This function returns all available implementations to the caller. */ +void +dp_netdev_impl_get(struct ds *reply, struct dp_netdev_pmd_thread **pmd_list, + size_t n); + /* Returns the default DPIF which is first ./configure selected, but can be * overridden at runtime. */ dp_netdev_input_func dp_netdev_impl_get_default(void); diff --git a/lib/dpif-netdev-unixctl.man b/lib/dpif-netdev-unixctl.man index 76cc949f9b..5f92562157 100644 --- a/lib/dpif-netdev-unixctl.man +++ b/lib/dpif-netdev-unixctl.man @@ -227,5 +227,8 @@ When this is the case, the above command prints the load-balancing information of the bonds configured in datapath \fIdp\fR showing the interface associated with each bucket (hash). . +.IP "\fBdpif-netdev/dpif-impl-get\fR +Lists the DPIF implementations that are available. +. .IP "\fBdpif-netdev/dpif-impl-set\fR \fIdpif_impl\fR" Sets the DPIF to be used to \fIdpif_impl\fR. By default "dpif_scalar" is used. diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index 6cdeb93de9..f7b2163bf7 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -965,6 +965,29 @@ dpif_netdev_subtable_lookup_set(struct unixctl_conn *conn, int argc OVS_UNUSED, ds_destroy(&reply); } +static void +dpif_netdev_impl_get(struct unixctl_conn *conn, int argc OVS_UNUSED, + const char *argv[] OVS_UNUSED, void *aux OVS_UNUSED) +{ + struct ds reply = DS_EMPTY_INITIALIZER; + struct shash_node *node; + + ovs_mutex_lock(&dp_netdev_mutex); + SHASH_FOR_EACH (node, &dp_netdevs) { + struct dp_netdev_pmd_thread **pmd_list; + struct dp_netdev *dp = node->data; + size_t n; + + /* Get PMD threads list, required to get the DPIF impl used by each PMD + * thread. */ + sorted_poll_thread_list(dp, &pmd_list, &n); + dp_netdev_impl_get(&reply, pmd_list, n); + } + ovs_mutex_unlock(&dp_netdev_mutex); + unixctl_command_reply(conn, ds_cstr(&reply)); + ds_destroy(&reply); +} + static void dpif_netdev_impl_set(struct unixctl_conn *conn, int argc OVS_UNUSED, const char *argv[], void *aux OVS_UNUSED) @@ -1251,6 +1274,9 @@ dpif_netdev_init(void) "dpif_implementation_name", 1, 1, dpif_netdev_impl_set, NULL); + unixctl_command_register("dpif-netdev/dpif-impl-get", "", + 0, 0, dpif_netdev_impl_get, + NULL); return 0; }