From patchwork Mon Jan 4 16:36:44 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: 1422169 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=140.211.166.136; helo=silver.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=intel.com Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4D8hCB3FY4z9sVr for ; Tue, 5 Jan 2021 03:38:30 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id BD65522E94; Mon, 4 Jan 2021 16:38:28 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YVCJXL3aYyyE; Mon, 4 Jan 2021 16:38:22 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by silver.osuosl.org (Postfix) with ESMTP id DCE232152A; Mon, 4 Jan 2021 16:37:54 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id BB37FC08A1; Mon, 4 Jan 2021 16:37:54 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 6447EC1E73 for ; Mon, 4 Jan 2021 16:37:53 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 417E8869AC for ; Mon, 4 Jan 2021 16:37:53 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2LR4YqToQTek for ; Mon, 4 Jan 2021 16:37:49 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by whitealder.osuosl.org (Postfix) with ESMTPS id 6719986978 for ; Mon, 4 Jan 2021 16:37:45 +0000 (UTC) IronPort-SDR: QUIp0FDkQ89nThybuIAUQqRnAQXttwNcc1Q5w3r3QbtDu5MQNhk/y8n3udSw4D2rBA6cSf78je A/jWkSHUFLVA== X-IronPort-AV: E=McAfee;i="6000,8403,9854"; a="177130150" X-IronPort-AV: E=Sophos;i="5.78,474,1599548400"; d="scan'208";a="177130150" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jan 2021 08:37:45 -0800 IronPort-SDR: tXW9pkMQeIBntq8AI2EqrmrngciCjQFooAqKi6ptyeACK0XKuI0HKKzBrT+jIv9/KAWhZCr8Jr 38xceFV1fO5w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.78,474,1599548400"; d="scan'208";a="462000403" Received: from silpixa00400633.ir.intel.com ([10.237.213.44]) by fmsmga001.fm.intel.com with ESMTP; 04 Jan 2021 08:37:43 -0800 From: Harry van Haaren To: ovs-dev@openvswitch.org Date: Mon, 4 Jan 2021 16:36:44 +0000 Message-Id: <20210104163653.2218575-8-harry.van.haaren@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210104163653.2218575-1-harry.van.haaren@intel.com> References: <20201216181033.572425-2-harry.van.haaren@intel.com> <20210104163653.2218575-1-harry.van.haaren@intel.com> MIME-Version: 1.0 Cc: i.maximets@ovn.org Subject: [ovs-dev] [PATCH v8 07/16] 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. Usage: $ ovs-appctl dpif-netdev/dpif-get Signed-off-by: Harry van Haaren --- lib/dpif-netdev-private-dpif.c | 7 +++++++ lib/dpif-netdev-private-dpif.h | 6 ++++++ lib/dpif-netdev.c | 24 ++++++++++++++++++++++++ 3 files changed, 37 insertions(+) diff --git a/lib/dpif-netdev-private-dpif.c b/lib/dpif-netdev-private-dpif.c index 9e1f3b8f9..c5021fe9f 100644 --- a/lib/dpif-netdev-private-dpif.c +++ b/lib/dpif-netdev-private-dpif.c @@ -61,6 +61,13 @@ dp_netdev_impl_get_default(void) return func; } +uint32_t +dp_netdev_impl_get(const struct dpif_netdev_impl_info_t **out_impls) +{ + ovs_assert(out_impls); + *out_impls = dpif_impls; + return ARRAY_SIZE(dpif_impls); +} /* 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 a09f90acc..99fbda943 100644 --- a/lib/dpif-netdev-private-dpif.h +++ b/lib/dpif-netdev-private-dpif.h @@ -47,6 +47,12 @@ struct dpif_netdev_impl_info_t { const char *name; }; +/* This function returns all available implementations to the caller. The + * quantity of implementations is returned by the int return value. + */ +uint32_t +dp_netdev_impl_get(const struct dpif_netdev_impl_info_t **out_impls); + /* 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.c b/lib/dpif-netdev.c index 2a0b103c3..4c074995c 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -990,6 +990,27 @@ dpif_netdev_subtable_lookup_set(struct unixctl_conn *conn, int argc, 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) +{ + const struct dpif_netdev_impl_info_t *dpif_impls; + uint32_t count = dp_netdev_impl_get(&dpif_impls); + if (count == 0) { + unixctl_command_reply_error(conn, "error getting dpif names"); + return; + } + + /* Add all dpif functions to reply string. */ + struct ds reply = DS_EMPTY_INITIALIZER; + ds_put_cstr(&reply, "Available DPIF implementations:\n"); + for (uint32_t i = 0; i < count; i++) { + ds_put_format(&reply, " %s\n", dpif_impls[i].name); + } + unixctl_command_reply(conn, ds_cstr(&reply)); + ds_destroy(&reply); +} + static void dpif_netdev_impl_set(struct unixctl_conn *conn, int argc, const char *argv[], void *aux OVS_UNUSED) @@ -1288,6 +1309,9 @@ dpif_netdev_init(void) "[dpif implementation name] [dp]", 1, 2, dpif_netdev_impl_set, NULL); + unixctl_command_register("dpif-netdev/dpif-get", "", + 0, 0, dpif_netdev_impl_get, + NULL); return 0; }