From patchwork Sat Dec 29 19:55:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Slava Ovsiienko X-Patchwork-Id: 49361 X-Patchwork-Delegate: shahafs@mellanox.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 562D55F22; Sat, 29 Dec 2018 20:55:54 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 655255F22 for ; Sat, 29 Dec 2018 20:55:52 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from viacheslavo@mellanox.com) with ESMTPS (AES256-SHA encrypted); 29 Dec 2018 21:55:49 +0200 Received: from pegasus12.mtr.labs.mlnx. (pegasus12.mtr.labs.mlnx [10.210.17.40]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id wBTJtkdV002527; Sat, 29 Dec 2018 21:55:49 +0200 From: Viacheslav Ovsiienko To: shahafs@mellanox.com Cc: dev@dpdk.org Date: Sat, 29 Dec 2018 19:55:36 +0000 Message-Id: <1546113340-30356-2-git-send-email-viacheslavo@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1546113340-30356-1-git-send-email-viacheslavo@mellanox.com> References: <1546113340-30356-1-git-send-email-viacheslavo@mellanox.com> Subject: [dpdk-dev] [PATCH 1/5] net/mlx5: optimize neigh and local encap rules search X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" This patch removes unnecessary local varialbles and optimizes local and neigh encapsulation rules search. Signed-off-by: Viacheslav Ovsiienko --- drivers/net/mlx5/mlx5_flow_tcf.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow_tcf.c b/drivers/net/mlx5/mlx5_flow_tcf.c index 33ebddd..b4734a0 100644 --- a/drivers/net/mlx5/mlx5_flow_tcf.c +++ b/drivers/net/mlx5/mlx5_flow_tcf.c @@ -4781,8 +4781,7 @@ struct tcf_nlcb_context { struct rte_flow_error *error) { const struct flow_tcf_vxlan_encap *encap = dev_flow->tcf.vxlan_encap; - struct tcf_local_rule *rule; - bool found = false; + struct tcf_local_rule *rule = NULL; int ret; assert(encap); @@ -4793,7 +4792,6 @@ struct tcf_nlcb_context { if (rule->mask & FLOW_TCF_ENCAP_IPV4_SRC && encap->ipv4.src == rule->ipv4.src && encap->ipv4.dst == rule->ipv4.dst) { - found = true; break; } } @@ -4806,12 +4804,11 @@ struct tcf_nlcb_context { sizeof(encap->ipv6.src)) && !memcmp(&encap->ipv6.dst, &rule->ipv6.dst, sizeof(encap->ipv6.dst))) { - found = true; break; } } } - if (found) { + if (rule) { if (enable) { rule->refcnt++; return 0; @@ -4890,8 +4887,7 @@ struct tcf_nlcb_context { struct rte_flow_error *error) { const struct flow_tcf_vxlan_encap *encap = dev_flow->tcf.vxlan_encap; - struct tcf_neigh_rule *rule; - bool found = false; + struct tcf_neigh_rule *rule = NULL; int ret; assert(encap); @@ -4901,7 +4897,6 @@ struct tcf_nlcb_context { LIST_FOREACH(rule, &vtep->neigh, next) { if (rule->mask & FLOW_TCF_ENCAP_IPV4_DST && encap->ipv4.dst == rule->ipv4.dst) { - found = true; break; } } @@ -4912,12 +4907,11 @@ struct tcf_nlcb_context { if (rule->mask & FLOW_TCF_ENCAP_IPV6_DST && !memcmp(&encap->ipv6.dst, &rule->ipv6.dst, sizeof(encap->ipv6.dst))) { - found = true; break; } } } - if (found) { + if (rule) { if (memcmp(&encap->eth.dst, &rule->eth, sizeof(encap->eth.dst))) { DRV_LOG(WARNING, "Destination MAC differs"