From patchwork Wed Jan 12 09:42:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Finn, Emma" X-Patchwork-Id: 1578952 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" (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=FW/HizAA; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4JYjLB5JPpz9s0r for ; Wed, 12 Jan 2022 20:43:30 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id DDF9B428C9; Wed, 12 Jan 2022 09:43:27 +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 zFnh3JpYEILv; Wed, 12 Jan 2022 09:43:26 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTPS id 7FB25428F5; Wed, 12 Jan 2022 09:43:24 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 01C7BC0070; Wed, 12 Jan 2022 09:43:22 +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 43F8AC0070 for ; Wed, 12 Jan 2022 09:43:21 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 236D083F84 for ; Wed, 12 Jan 2022 09:43:21 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp1.osuosl.org (amavisd-new); dkim=pass (2048-bit key) header.d=intel.com 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 Eg2gZB2Zvw_6 for ; Wed, 12 Jan 2022 09:43:20 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by smtp1.osuosl.org (Postfix) with ESMTPS id 5AA7983F7D for ; Wed, 12 Jan 2022 09:43:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1641980600; x=1673516600; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qd2qwdHPFnplsCE4aSh4/VAqxka3wdjBI2y+yW98ef4=; b=FW/HizAAZSXDdhS0qvv/yb9hy+QG5ErU2CMXlxWPNRAiv9adrI9HMcG3 l14Bx8PXODbJg4sPA3NYC1KSE/ANfpjzPfHK3pT8jGTQ0oj4LjfFLSj6L X+QppsG44V5dIB6qv0fs6LwYSAvg7r1z7Fo3cUW9/WmEsEGX7+CpfY2pr ZoreEmwci31TOtmkR2gvWUXwUxkpu4WiFIZjKNRf3NqrOPtsJ4jvsyLkx QSFWPN+UNKAFgD092kdFMyoNWgC9u5M4kQoD0LElWWQFYZ8PyCrXRWNNM MMcrOwf1Bc2uaL0TyRnOsRqiSxoKSo+Wayui1ccPOy4VcoO6hsWePoW+W Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10224"; a="224394766" X-IronPort-AV: E=Sophos;i="5.88,282,1635231600"; d="scan'208";a="224394766" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2022 01:43:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,282,1635231600"; d="scan'208";a="490688322" Received: from silpixa00400899.ir.intel.com ([10.243.23.110]) by orsmga002.jf.intel.com with ESMTP; 12 Jan 2022 01:43:18 -0800 From: Emma Finn To: dev@openvswitch.org, harry.van.haaren@intel.com, kumar.amber@intel.com, ian.stokes@intel.com, i.maximets@ovn.org Date: Wed, 12 Jan 2022 09:42:40 +0000 Message-Id: <20220112094244.81402-5-emma.finn@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220112094244.81402-1-emma.finn@intel.com> References: <20220105165349.3447695-1-emma.finn@intel.com> <20220112094244.81402-1-emma.finn@intel.com> MIME-Version: 1.0 Subject: [ovs-dev] [PATCH v5 4/8] odp-execute: Add command to switch action implementation. 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 allow the user to switch the active action implementation at runtime. A probe function is executed before switching the implementation, to ensure the CPU is capable of running the ISA required. Usage: $ ovs-appctl dpif-netdev/action-impl-set scalar This commit also adds a new command to retrieve the list of available action implementations. This can be used by to check what implementations of actions are available and what implementation is active during runtime. Usage: $ ovs-appctl dpif-netdev/action-impl-get Added separate test-case for ovs-actions get/set commands: 1023: PMD - ovs-actions configuration Signed-off-by: Emma Finn Co-authored-by: Kumar Amber Signed-off-by: Kumar Amber Acked-by: Harry van Haaren --- NEWS | 2 ++ lib/dpif-netdev-unixctl.man | 6 ++++++ lib/dpif-netdev.c | 39 +++++++++++++++++++++++++++++++++++++ lib/odp-execute-private.c | 14 +++++++++++++ lib/odp-execute.h | 3 +++ tests/pmd.at | 21 ++++++++++++++++++++ 6 files changed, 85 insertions(+) diff --git a/NEWS b/NEWS index 26be454df..42bb876da 100644 --- a/NEWS +++ b/NEWS @@ -21,6 +21,8 @@ Post-v2.16.0 * Add support for running threads on cores >= RTE_MAX_LCORE. * Add actions auto-validator function to compare different actions implementations against default implementation. + * Add command line option to switch between different actions + implementations available at run time. - Python: * For SSL support, the use of the pyOpenSSL library has been replaced with the native 'ssl' module. diff --git a/lib/dpif-netdev-unixctl.man b/lib/dpif-netdev-unixctl.man index 8cd847416..500daf4de 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/action-impl-get\fR +Lists the actions implementations that are available. +. +.IP "\fBdpif-netdev/action-impl-set\fR \fIaction_impl\fR" +Sets the action to be used to \fIaction_impl\fR. By default "scalar" is used. diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index eada4fcd7..f6cc779ef 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -60,6 +60,7 @@ #include "netdev-vport.h" #include "netlink.h" #include "odp-execute.h" +#include "odp-execute-private.h" #include "odp-util.h" #include "openvswitch/dynamic-string.h" #include "openvswitch/list.h" @@ -1330,6 +1331,38 @@ error: ds_destroy(&reply); } +static void +action_impl_set(struct unixctl_conn *conn, int argc OVS_UNUSED, + const char *argv[] OVS_UNUSED, void *aux OVS_UNUSED) +{ + struct ds reply = DS_EMPTY_INITIALIZER; + + int32_t err = odp_actions_impl_set(argv[1]); + if (err) { + ds_put_format(&reply, "action implementation %s not found.\n", + argv[1]); + const char *reply_str = ds_cstr(&reply); + unixctl_command_reply_error(conn, reply_str); + VLOG_ERR("%s", reply_str); + ds_destroy(&reply); + return; + } + + ds_put_format(&reply, "action implementation set to %s.\n", argv[1]); + unixctl_command_reply(conn, ds_cstr(&reply)); + ds_destroy(&reply); +} + +static void +action_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; + odp_execute_action_get(&reply); + unixctl_command_reply(conn, ds_cstr(&reply)); + ds_destroy(&reply); +} + static void dpif_netdev_pmd_rebalance(struct unixctl_conn *conn, int argc, const char *argv[], void *aux OVS_UNUSED) @@ -1567,6 +1600,12 @@ 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/action-impl-set", "name", + 1, 1, action_impl_set, + NULL); + unixctl_command_register("dpif-netdev/action-impl-get", "", + 0, 0, action_impl_get, + NULL); return 0; } diff --git a/lib/odp-execute-private.c b/lib/odp-execute-private.c index a4155b5df..c17882a33 100644 --- a/lib/odp-execute-private.c +++ b/lib/odp-execute-private.c @@ -74,6 +74,20 @@ odp_execute_action_set(const char *name, return -1; } +void +odp_execute_action_get(struct ds *string) +{ + uint32_t i; + + ds_put_cstr(string, "Available Actions implementations:\n"); + for (i = 0; i < ACTION_IMPL_MAX; i++) { + ds_put_format(string, " %s (available: %s, active: %s)\n", + action_impls[i].name, + action_impls[i].available ? "True" : "False", + i == active_action_impl_index ? "True" : "False"); + } +} + void odp_execute_action_init(void) { diff --git a/lib/odp-execute.h b/lib/odp-execute.h index 6441392b9..4f4cdc4ac 100644 --- a/lib/odp-execute.h +++ b/lib/odp-execute.h @@ -23,6 +23,7 @@ #include #include "openvswitch/types.h" +struct ds; struct nlattr; struct dp_packet; struct pkt_metadata; @@ -32,6 +33,8 @@ struct dp_packet_batch; /* Called once at initialization time. */ void odp_execute_init(void); +/* Runtime update get/set functionality. */ +int32_t odp_actions_impl_get(struct ds *name); int32_t odp_actions_impl_set(const char *name); typedef void (*odp_execute_cb)(void *dp, struct dp_packet_batch *batch, diff --git a/tests/pmd.at b/tests/pmd.at index a2f9d34a2..df0b3b54c 100644 --- a/tests/pmd.at +++ b/tests/pmd.at @@ -1162,3 +1162,24 @@ ovs-appctl: ovs-vswitchd: server returned an error OVS_VSWITCHD_STOP AT_CLEANUP + +AT_SETUP([PMD - ovs-actions configuration]) +OVS_VSWITCHD_START([], [], [], [--dummy-numa 0,0]) +AT_CHECK([ovs-vsctl add-port br0 p1 -- set Interface p1 type=dummy-pmd]) + +dnl Set the scalar first, so we always have the scalar impl as Active. +AT_CHECK([ovs-appctl dpif-netdev/action-impl-set scalar], [0], [dnl +action implementation set to scalar. +]) + +AT_CHECK([ovs-vsctl show], [], [stdout]) +AT_CHECK([ovs-appctl dpif-netdev/action-impl-get | grep "scalar"], [], [dnl + scalar (available: True, active: True) +]) + +AT_CHECK([ovs-appctl dpif-netdev/action-impl-get | grep "autovalidator"], [], [dnl + autovalidator (available: True, active: False) +]) + +OVS_VSWITCHD_STOP +AT_CLEANUP \ No newline at end of file