From patchwork Fri May 18 01:22:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saeed Mahameed X-Patchwork-Id: 10408023 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 452B1601C8 for ; Fri, 18 May 2018 01:24:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3559728755 for ; Fri, 18 May 2018 01:24:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2A1D828806; Fri, 18 May 2018 01:24:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B254828755 for ; Fri, 18 May 2018 01:24:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752284AbeERBYJ (ORCPT ); Thu, 17 May 2018 21:24:09 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:42899 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752448AbeERBYG (ORCPT ); Thu, 17 May 2018 21:24:06 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from saeedm@mellanox.com) with ESMTPS (AES256-SHA encrypted); 18 May 2018 04:25:53 +0300 Received: from stpd.hsd1.ca.comcast.net ([172.16.5.22]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id w4I1N5aO007096; Fri, 18 May 2018 04:23:58 +0300 From: Saeed Mahameed To: "David S. Miller" , Doug Ledford Cc: Jason Gunthorpe , Leon Romanovsky , Or Gerlitz , netdev@vger.kernel.org, linux-rdma@vger.kernel.org, Jiri Pirko , Saeed Mahameed Subject: [for-next 14/15] net/mlx5e: Ignore attempts to offload multiple times a TC flow Date: Thu, 17 May 2018 18:22:57 -0700 Message-Id: <20180518012258.26968-15-saeedm@mellanox.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180518012258.26968-1-saeedm@mellanox.com> References: <20180518012258.26968-1-saeedm@mellanox.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Or Gerlitz For VF->VF and uplink->VF rules, the TC core (cls_api) attempts to offload the same flow multiple times into the driver, b/c we registered to the egdev callback. Use the flow cookie to ignore attempts to add such flows, we can't reject them (return error), b/c this will fail the offload attempt, so we ignore that. We indentify wrong stat/del calls using the flow ingress/egress flags, here we do return error to the core. Signed-off-by: Or Gerlitz Signed-off-by: Jiri Pirko Reviewed-by: Paul Blakey Signed-off-by: Saeed Mahameed --- .../net/ethernet/mellanox/mlx5/core/en_tc.c | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c index 05c90b4f8a31..674f1d7d2737 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c @@ -2666,6 +2666,12 @@ int mlx5e_configure_flower(struct mlx5e_priv *priv, get_flags(flags, &flow_flags); + flow = rhashtable_lookup_fast(tc_ht, &f->cookie, tc_ht_params); + if (flow) { + netdev_warn_once(priv->netdev, "flow cookie %lx already exists, ignoring\n", f->cookie); + return 0; + } + if (esw && esw->mode == SRIOV_OFFLOADS) { flow_flags |= MLX5E_TC_FLOW_ESWITCH; attr_size = sizeof(struct mlx5_esw_flow_attr); @@ -2728,6 +2734,17 @@ int mlx5e_configure_flower(struct mlx5e_priv *priv, return err; } +#define DIRECTION_MASK (MLX5E_TC_INGRESS | MLX5E_TC_EGRESS) +#define FLOW_DIRECTION_MASK (MLX5E_TC_FLOW_INGRESS | MLX5E_TC_FLOW_EGRESS) + +static bool same_flow_direction(struct mlx5e_tc_flow *flow, int flags) +{ + if ((flow->flags & FLOW_DIRECTION_MASK) == (flags & DIRECTION_MASK)) + return true; + + return false; +} + int mlx5e_delete_flower(struct mlx5e_priv *priv, struct tc_cls_flower_offload *f, int flags) { @@ -2735,7 +2752,7 @@ int mlx5e_delete_flower(struct mlx5e_priv *priv, struct mlx5e_tc_flow *flow; flow = rhashtable_lookup_fast(tc_ht, &f->cookie, tc_ht_params); - if (!flow) + if (!flow || !same_flow_direction(flow, flags)) return -EINVAL; rhashtable_remove_fast(tc_ht, &flow->node, tc_ht_params); @@ -2758,7 +2775,7 @@ int mlx5e_stats_flower(struct mlx5e_priv *priv, u64 lastuse; flow = rhashtable_lookup_fast(tc_ht, &f->cookie, tc_ht_params); - if (!flow) + if (!flow || !same_flow_direction(flow, flags)) return -EINVAL; if (!(flow->flags & MLX5E_TC_FLOW_OFFLOADED))