From patchwork Sun Oct 30 21:22:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saeed Mahameed X-Patchwork-Id: 689065 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3t6VsC2sdqz9t2N for ; Mon, 31 Oct 2016 08:25:35 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932825AbcJ3VZY (ORCPT ); Sun, 30 Oct 2016 17:25:24 -0400 Received: from [193.47.165.129] ([193.47.165.129]:60235 "EHLO mellanox.co.il" rhost-flags-FAIL-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1756482AbcJ3VXn (ORCPT ); Sun, 30 Oct 2016 17:23:43 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from saeedm@mellanox.com) with ESMTPS (AES256-SHA encrypted); 30 Oct 2016 23:22:58 +0200 Received: from reg-l-vrt-045-015.mtl.labs.mlnx (reg-l-vrt-045-015.mtl.labs.mlnx [10.135.45.15]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id u9ULMvlS002060; Sun, 30 Oct 2016 23:22:57 +0200 From: Saeed Mahameed To: "David S. Miller" , Doug Ledford Cc: netdev@vger.kernel.org, linux-rdma@vger.kernel.org, Or Gerlitz , Leon Romanovsky , Tal Alon , Matan Barak , Mark Bloch , Saeed Mahameed , Leon Romanovsky Subject: [PATCH for-next V2 12/15] net/mlx5: Group similer rules under the same fte Date: Sun, 30 Oct 2016 23:22:05 +0200 Message-Id: <1477862528-4328-13-git-send-email-saeedm@mellanox.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1477862528-4328-1-git-send-email-saeedm@mellanox.com> References: <1477862528-4328-1-git-send-email-saeedm@mellanox.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Mark Bloch When adding a new rule, if we can match it with compare_match_value and flow tag we might be able to insert the rule to the same fte. In order to do that, there must be an overlap between the actions of the fte and the new rule. When updating the action of an existing fte, we must tell the firmware we are doing so. Signed-off-by: Mark Bloch Signed-off-by: Saeed Mahameed Signed-off-by: Leon Romanovsky --- drivers/net/ethernet/mellanox/mlx5/core/fs_core.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c index fca6937..43d7052 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c @@ -920,7 +920,8 @@ static struct mlx5_flow_rule *alloc_rule(struct mlx5_flow_destination *dest) /* fte should not be deleted while calling this function */ static struct mlx5_flow_rule *add_rule_fte(struct fs_fte *fte, struct mlx5_flow_group *fg, - struct mlx5_flow_destination *dest) + struct mlx5_flow_destination *dest, + bool update_action) { struct mlx5_flow_table *ft; struct mlx5_flow_rule *rule; @@ -931,6 +932,9 @@ static struct mlx5_flow_rule *add_rule_fte(struct fs_fte *fte, if (!rule) return ERR_PTR(-ENOMEM); + if (update_action) + modify_mask |= BIT(MLX5_SET_FTE_MODIFY_ENABLE_MASK_ACTION); + fs_get_obj(ft, fg->node.parent); /* Add dest to dests list- we need flow tables to be in the * end of the list for forward to next prio rules. @@ -1109,7 +1113,9 @@ static struct mlx5_flow_rule *add_rule_fg(struct mlx5_flow_group *fg, fs_for_each_fte(fte, fg) { nested_lock_ref_node(&fte->node, FS_MUTEX_CHILD); if (compare_match_value(&fg->mask, match_value, &fte->val) && - action == fte->action && flow_tag == fte->flow_tag) { + (action & fte->action) && flow_tag == fte->flow_tag) { + int old_action = fte->action; + rule = find_flow_rule(fte, dest); if (rule) { atomic_inc(&rule->node.refcount); @@ -1117,11 +1123,15 @@ static struct mlx5_flow_rule *add_rule_fg(struct mlx5_flow_group *fg, unlock_ref_node(&fg->node); return rule; } - rule = add_rule_fte(fte, fg, dest); - if (IS_ERR(rule)) + fte->action |= action; + rule = add_rule_fte(fte, fg, dest, + old_action != action); + if (IS_ERR(rule)) { + fte->action = old_action; goto unlock_fte; - else + } else { goto add_rule; + } } unlock_ref_node(&fte->node); } @@ -1138,7 +1148,7 @@ static struct mlx5_flow_rule *add_rule_fg(struct mlx5_flow_group *fg, } tree_init_node(&fte->node, 0, del_fte); nested_lock_ref_node(&fte->node, FS_MUTEX_CHILD); - rule = add_rule_fte(fte, fg, dest); + rule = add_rule_fte(fte, fg, dest, false); if (IS_ERR(rule)) { kfree(fte); goto unlock_fg;