From patchwork Fri Feb 12 17:17:04 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: 1439945 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.133; helo=hemlock.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DcgDR3Knlz9sVR for ; Sat, 13 Feb 2021 04:17:42 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 0FD7F87626; Fri, 12 Feb 2021 17:17:41 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 05FqeL0Dwd1N; Fri, 12 Feb 2021 17:17:40 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by hemlock.osuosl.org (Postfix) with ESMTP id 1CFE787617; Fri, 12 Feb 2021 17:17:40 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 11485C0891; Fri, 12 Feb 2021 17:17:40 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 56977C0891 for ; Fri, 12 Feb 2021 17:17:38 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 3A6B36F785 for ; Fri, 12 Feb 2021 17:17:38 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5YoiRFZuFtqx for ; Fri, 12 Feb 2021 17:17:36 +0000 (UTC) Received: by smtp3.osuosl.org (Postfix, from userid 1001) id 8571B6F74F; Fri, 12 Feb 2021 17:17:36 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by smtp3.osuosl.org (Postfix) with ESMTPS id 9EA506F74F for ; Fri, 12 Feb 2021 17:17:34 +0000 (UTC) IronPort-SDR: krQX6ZAxgTqigyWjo/veDDem67a3LndjCIUPl+i1jTSHMaa4TJ/RPyjS+yPCItGF+0JFUz3NZB j2C35VU3jD6w== X-IronPort-AV: E=McAfee;i="6000,8403,9893"; a="201595211" X-IronPort-AV: E=Sophos;i="5.81,174,1610438400"; d="scan'208";a="201595211" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2021 09:17:34 -0800 IronPort-SDR: AXdwbh2RyHOEAoNM4wWlo93yeu4AvLbEkRJxw4Mk3OBR+cl53C09rOUOir2JT/YzVw5ew6oWRu 9CB18K36Ocug== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,174,1610438400"; d="scan'208";a="360484869" Received: from silpixa00400633.ir.intel.com ([10.237.213.44]) by orsmga003.jf.intel.com with ESMTP; 12 Feb 2021 09:17:32 -0800 From: Harry van Haaren To: ovs-dev@openvswitch.org Date: Fri, 12 Feb 2021 17:17:04 +0000 Message-Id: <20210212171718.2189798-3-harry.van.haaren@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210212171718.2189798-1-harry.van.haaren@intel.com> References: <20210104163653.2218575-1-harry.van.haaren@intel.com> <20210212171718.2189798-1-harry.van.haaren@intel.com> MIME-Version: 1.0 Cc: i.maximets@ovn.org Subject: [ovs-dev] [PATCH v9 02/16] dpif-netdev: Split HWOL out to own header file. 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 moves the datapath lookup functions required for hardware offload to a seperate file. This allows other DPIF implementations to access the lookup functions, encouraging code reuse. Signed-off-by: Harry van Haaren --- lib/automake.mk | 1 + lib/dpif-netdev-private-hwol.h | 63 ++++++++++++++++++++++++++++++++++ lib/dpif-netdev.c | 39 ++------------------- 3 files changed, 67 insertions(+), 36 deletions(-) create mode 100644 lib/dpif-netdev-private-hwol.h diff --git a/lib/automake.mk b/lib/automake.mk index 0e83145b5..9b3e06db6 100644 --- a/lib/automake.mk +++ b/lib/automake.mk @@ -114,6 +114,7 @@ lib_libopenvswitch_la_SOURCES = \ lib/dpif-netdev-private-dfc.h \ lib/dpif-netdev-private-dpcls.h \ lib/dpif-netdev-private-flow.h \ + lib/dpif-netdev-private-hwol.h \ lib/dpif-netdev-private-thread.h \ lib/dpif-netdev-private.h \ lib/dpif-netdev-perf.c \ diff --git a/lib/dpif-netdev-private-hwol.h b/lib/dpif-netdev-private-hwol.h new file mode 100644 index 000000000..447010ab8 --- /dev/null +++ b/lib/dpif-netdev-private-hwol.h @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2015 Nicira, Inc. + * Copyright (c) 2020 Intel Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef DPIF_NETDEV_PRIVATE_HWOL_H +#define DPIF_NETDEV_PRIVATE_HWOL_H 1 + +#include "dpif-netdev-private-flow.h" + +#define MAX_FLOW_MARK (UINT32_MAX - 1) +#define INVALID_FLOW_MARK 0 +/* Zero flow mark is used to indicate the HW to remove the mark. A packet + * marked with zero mark is received in SW without a mark at all, so it + * cannot be used as a valid mark. + */ + +struct megaflow_to_mark_data { + const struct cmap_node node; + ovs_u128 mega_ufid; + uint32_t mark; +}; + +struct flow_mark { + struct cmap megaflow_to_mark; + struct cmap mark_to_flow; + struct id_pool *pool; +}; + +/* allocated in dpif-netdev.c */ +extern struct flow_mark flow_mark; + +static inline struct dp_netdev_flow * +mark_to_flow_find(const struct dp_netdev_pmd_thread *pmd, + const uint32_t mark) +{ + struct dp_netdev_flow *flow; + + CMAP_FOR_EACH_WITH_HASH (flow, mark_node, hash_int(mark, 0), + &flow_mark.mark_to_flow) { + if (flow->mark == mark && flow->pmd_id == pmd->core_id && + flow->dead == false) { + return flow; + } + } + + return NULL; +} + + +#endif /* dpif-netdev-private-hwol.h */ diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index 395a5c29d..840298f01 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -84,6 +84,8 @@ #include "util.h" #include "uuid.h" +#include "dpif-netdev-private-hwol.h" + VLOG_DEFINE_THIS_MODULE(dpif_netdev); /* Auto Load Balancing Defaults */ @@ -1953,26 +1955,8 @@ dp_netdev_pmd_find_dpcls(struct dp_netdev_pmd_thread *pmd, return cls; } -#define MAX_FLOW_MARK (UINT32_MAX - 1) -#define INVALID_FLOW_MARK 0 -/* Zero flow mark is used to indicate the HW to remove the mark. A packet - * marked with zero mark is received in SW without a mark at all, so it - * cannot be used as a valid mark. - */ - -struct megaflow_to_mark_data { - const struct cmap_node node; - ovs_u128 mega_ufid; - uint32_t mark; -}; - -struct flow_mark { - struct cmap megaflow_to_mark; - struct cmap mark_to_flow; - struct id_pool *pool; -}; -static struct flow_mark flow_mark = { +struct flow_mark flow_mark = { .megaflow_to_mark = CMAP_INITIALIZER, .mark_to_flow = CMAP_INITIALIZER, }; @@ -2141,23 +2125,6 @@ flow_mark_flush(struct dp_netdev_pmd_thread *pmd) } } -static struct dp_netdev_flow * -mark_to_flow_find(const struct dp_netdev_pmd_thread *pmd, - const uint32_t mark) -{ - struct dp_netdev_flow *flow; - - CMAP_FOR_EACH_WITH_HASH (flow, mark_node, hash_int(mark, 0), - &flow_mark.mark_to_flow) { - if (flow->mark == mark && flow->pmd_id == pmd->core_id && - flow->dead == false) { - return flow; - } - } - - return NULL; -} - static struct dp_flow_offload_item * dp_netdev_alloc_flow_offload(struct dp_netdev_pmd_thread *pmd, struct dp_netdev_flow *flow,