From patchwork Tue Feb 2 07:07:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saeed Mahameed X-Patchwork-Id: 12060881 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB851C433E9 for ; Tue, 2 Feb 2021 07:08:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 647B164ED4 for ; Tue, 2 Feb 2021 07:08:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232432AbhBBHIE (ORCPT ); Tue, 2 Feb 2021 02:08:04 -0500 Received: from mail.kernel.org ([198.145.29.99]:52260 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232498AbhBBHHw (ORCPT ); Tue, 2 Feb 2021 02:07:52 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6A85B64EE2; Tue, 2 Feb 2021 07:07:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612249632; bh=dlWT559v6/SM8gkDJZjd8wFyDba9OMs/E59puJpfQnA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lIt0G7y0zL3brx+QwctzmxodPZeNznHzhpr5uCsn1nt3u/HuAE6YZEER8ZuY2TQEd DJVJ3iATESQEuqWNwJZtINQuduWByQQCD/MKL6SUQe+kLrIz9y0l+52mekfJPUmxBa VU9NhL2/9/VfnkovSNi2VStDdedIEMU9IBg3RxQnHGT9O6Q/p1j4GH/L+AI5XLd4cj g30uK+jgV8nnBEgo/BAndBA9rEoY9/pdjAW/OQ/UkvMBKaSNU1r0aWFd9r5ql+6NxX xrWk1K2QXtqD+C57J7TEFtxiHknNgEecwjhACTWrx98aYkmp/aHaGkiRlT0+zFjKWc RcwYtiON/2VeQ== From: Saeed Mahameed To: Jakub Kicinski Cc: "David S. Miller" , netdev@vger.kernel.org, Daniel Jurgens , Colin Ian King , Saeed Mahameed Subject: [net 1/4] net/mlx5: Fix function calculation for page trees Date: Mon, 1 Feb 2021 23:07:00 -0800 Message-Id: <20210202070703.617251-2-saeed@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210202070703.617251-1-saeed@kernel.org> References: <20210202070703.617251-1-saeed@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Daniel Jurgens The function calculation always results in a value of 0. This works generally, but when the release all pages feature is enabled it will result in crashes. Fixes: 0aa128475d33 ("net/mlx5: Maintain separate page trees for ECPF and PF functions") Signed-off-by: Daniel Jurgens Reported-by: Colin Ian King Signed-off-by: Saeed Mahameed --- drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c b/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c index eaa8958e24d7..c0656d4782e1 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c @@ -76,7 +76,7 @@ enum { static u32 get_function(u16 func_id, bool ec_function) { - return func_id & (ec_function << 16); + return (u32)func_id | (ec_function << 16); } static struct rb_root *page_root_per_function(struct mlx5_core_dev *dev, u32 function) From patchwork Tue Feb 2 07:07:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saeed Mahameed X-Patchwork-Id: 12060879 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CB478C433E6 for ; Tue, 2 Feb 2021 07:08:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 871EA64EED for ; Tue, 2 Feb 2021 07:08:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232504AbhBBHIN (ORCPT ); Tue, 2 Feb 2021 02:08:13 -0500 Received: from mail.kernel.org ([198.145.29.99]:52268 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231509AbhBBHHx (ORCPT ); Tue, 2 Feb 2021 02:07:53 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 545ED64EE5; Tue, 2 Feb 2021 07:07:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612249632; bh=QUH8SUTpfgcF7e/+AMqZO4NpD0O/qomD8Siyr0KTosg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j+KYAliWdMxTtGD4GtigcTsfa+B6F64pp48684hlXdu7UJrdyxwsLXwTqyXMxMtWx OgZymm//bGKHRIrdPnfwXbh1vFhl6MEEMxV4Pws9xOShnRcDuXjOfHSODUTfvYJYxL ZbeNa5YLIczP/WOR2VE0XSDnUBdfn3eCuBo16gLAxDMj7D3D4mZ42+nISVeszcfH78 ixA8s5zrjWZ88Llq7CTnlUHWk9dHn3QsNTCIfFcngpZqK0GkjDdYs06UQsmcg7PT3e I7Nax7ceZIftOZxUxwGj5UnF+VIKfmkYEEDp86RAwB92JIvDL2azSckX7/BMfjY4fk m2aWnMw/EbWfw== From: Saeed Mahameed To: Jakub Kicinski Cc: "David S. Miller" , netdev@vger.kernel.org, Maor Gottlieb , Alaa Hleihel , Mark Bloch , Saeed Mahameed Subject: [net 2/4] net/mlx5: Fix leak upon failure of rule creation Date: Mon, 1 Feb 2021 23:07:01 -0800 Message-Id: <20210202070703.617251-3-saeed@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210202070703.617251-1-saeed@kernel.org> References: <20210202070703.617251-1-saeed@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Maor Gottlieb When creation of a new rule that requires allocation of an FTE fails, need to call to tree_put_node on the FTE in order to release its' resource. Fixes: cefc23554fc2 ("net/mlx5: Fix FTE cleanup") Signed-off-by: Maor Gottlieb Reviewed-by: Alaa Hleihel Reviewed-by: Mark Bloch Signed-off-by: Saeed Mahameed --- drivers/net/ethernet/mellanox/mlx5/core/fs_core.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c index 0fcee702b808..ee4d86c1f436 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c @@ -1760,6 +1760,7 @@ try_add_to_existing_fg(struct mlx5_flow_table *ft, if (!fte_tmp) continue; rule = add_rule_fg(g, spec, flow_act, dest, dest_num, fte_tmp); + /* No error check needed here, because insert_fte() is not called */ up_write_ref_node(&fte_tmp->node, false); tree_put_node(&fte_tmp->node, false); kmem_cache_free(steering->ftes_cache, fte); @@ -1812,6 +1813,8 @@ try_add_to_existing_fg(struct mlx5_flow_table *ft, up_write_ref_node(&g->node, false); rule = add_rule_fg(g, spec, flow_act, dest, dest_num, fte); up_write_ref_node(&fte->node, false); + if (IS_ERR(rule)) + tree_put_node(&fte->node, false); return rule; } rule = ERR_PTR(-ENOENT); @@ -1910,6 +1913,8 @@ _mlx5_add_flow_rules(struct mlx5_flow_table *ft, up_write_ref_node(&g->node, false); rule = add_rule_fg(g, spec, flow_act, dest, dest_num, fte); up_write_ref_node(&fte->node, false); + if (IS_ERR(rule)) + tree_put_node(&fte->node, false); tree_put_node(&g->node, false); return rule; From patchwork Tue Feb 2 07:07:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saeed Mahameed X-Patchwork-Id: 12060883 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2EB5C433E0 for ; Tue, 2 Feb 2021 07:08:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 54D2964EDF for ; Tue, 2 Feb 2021 07:08:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232516AbhBBHIa (ORCPT ); Tue, 2 Feb 2021 02:08:30 -0500 Received: from mail.kernel.org ([198.145.29.99]:52280 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232502AbhBBHHy (ORCPT ); Tue, 2 Feb 2021 02:07:54 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 15B1264EE6; Tue, 2 Feb 2021 07:07:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612249633; bh=VtjsyGeWH7k1gH7aSe59CuNAwUz00/GcQsmlRLS7eh4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=umGgLXyhnpJWC6IvVfoav6DzPA+l9R92O7U0WaNgUTM9fcXRvmAl2GTMi58n/64AG SbexRhlQvTH6LdETwC7YmOX1x/+5Ajxt7D7o6yqVEpvWYiX9w5ItF49P0ccQlqZsyT HkI5Hk58u4Yl1EmiiMz0daSfrluYGu/5YGFYZ+HUkxcPZvL/F+V1+hOHsd3b5K8Kyj v55HgdNP3FDzsfeXk+mVZXE/pZO+deDYHrwoIsd9LdY136FzlpZGke0/pnOUYzxz6W zAqT5PGHRFdOqbJ8LSRgYXQYfpq1iIRaVNp5wRGA7/7KMNbTKC+rP2R2i/p9Qgmr3h 7b4aZfvYahmoA== From: Saeed Mahameed To: Jakub Kicinski Cc: "David S. Miller" , netdev@vger.kernel.org, Maxim Mikityanskiy , Tariq Toukan , Saeed Mahameed Subject: [net 3/4] net/mlx5e: Update max_opened_tc also when channels are closed Date: Mon, 1 Feb 2021 23:07:02 -0800 Message-Id: <20210202070703.617251-4-saeed@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210202070703.617251-1-saeed@kernel.org> References: <20210202070703.617251-1-saeed@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Maxim Mikityanskiy max_opened_tc is used for stats, so that potentially non-zero stats won't disappear when num_tc decreases. However, mlx5e_setup_tc_mqprio fails to update it in the flow where channels are closed. This commit fixes it. The new value of priv->channels.params.num_tc is always checked on exit. In case of errors it will just be the old value, and in case of success it will be the updated value. Fixes: 05909babce53 ("net/mlx5e: Avoid reset netdev stats on configuration changes") Signed-off-by: Maxim Mikityanskiy Reviewed-by: Tariq Toukan Signed-off-by: Saeed Mahameed --- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c index a9d824a9cb05..3fc7d18ac868 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -3627,12 +3627,10 @@ static int mlx5e_setup_tc_mqprio(struct mlx5e_priv *priv, err = mlx5e_safe_switch_channels(priv, &new_channels, mlx5e_num_channels_changed_ctx, NULL); - if (err) - goto out; - priv->max_opened_tc = max_t(u8, priv->max_opened_tc, - new_channels.params.num_tc); out: + priv->max_opened_tc = max_t(u8, priv->max_opened_tc, + priv->channels.params.num_tc); mutex_unlock(&priv->state_lock); return err; } From patchwork Tue Feb 2 07:07:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saeed Mahameed X-Patchwork-Id: 12060885 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4DABC433E0 for ; Tue, 2 Feb 2021 07:08:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 57A2264EDF for ; Tue, 2 Feb 2021 07:08:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232539AbhBBHIw (ORCPT ); Tue, 2 Feb 2021 02:08:52 -0500 Received: from mail.kernel.org ([198.145.29.99]:52290 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230135AbhBBHHz (ORCPT ); Tue, 2 Feb 2021 02:07:55 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id A5E0964EE8; Tue, 2 Feb 2021 07:07:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612249634; bh=kZbPJ6B7sPM1Z+PThnJwxki9PhKg1yLJLSxqGLaduG0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hWDcCl2uMZ76nIUCOFTpRNpIhX5TnNGBEAw2mUlI0spT6v7MfErSV2rsvF4HqAOzA ilx08vNMqwR25qnuASz7Gy6BXUgNP2rlPLFlx9ex3rbA+gf+yR1OBrZLWRyXwP46iD VMA18OOPBGSw0JNds1ho4eKx+Qy4QdsGZtjJkX5T+dGyvJwA8WQFCZPyRVDYN5L9uj cjiQaNFh1/th3KoGTZvgYxNyXDgYUxtYIHPL1QggQvJbPIdPhvcfrPOae4RuxwCXnO RWp2FAIXaHJ74AqFBmOpF/6dYf8bcH0KIZM5tyyS0cTRjNFU9KCl9LAhDV5zPaIqjX 38byHKQPYoceg== From: Saeed Mahameed To: Jakub Kicinski Cc: "David S. Miller" , netdev@vger.kernel.org, Maor Dickman , Roi Dayan , Saeed Mahameed Subject: [net 4/4] net/mlx5e: Release skb in case of failure in tc update skb Date: Mon, 1 Feb 2021 23:07:03 -0800 Message-Id: <20210202070703.617251-5-saeed@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210202070703.617251-1-saeed@kernel.org> References: <20210202070703.617251-1-saeed@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Maor Dickman In case of failure in tc update skb the packet is dropped without freeing the skb. Fixed by freeing the skb in case failure in tc update skb. Fixes: d6d27782864f ("net/mlx5: E-Switch, Restore chain id on miss") Fixes: c75690972228 ("net/mlx5e: Add tc chains offload support for nic flows") Signed-off-by: Maor Dickman Reviewed-by: Roi Dayan Signed-off-by: Saeed Mahameed --- drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c index 7f5851c61218..ca4b55839a8a 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c @@ -1262,8 +1262,10 @@ static void mlx5e_handle_rx_cqe(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe) mlx5e_complete_rx_cqe(rq, cqe, cqe_bcnt, skb); if (mlx5e_cqe_regb_chain(cqe)) - if (!mlx5e_tc_update_skb(cqe, skb)) + if (!mlx5e_tc_update_skb(cqe, skb)) { + dev_kfree_skb_any(skb); goto free_wqe; + } napi_gro_receive(rq->cq.napi, skb); @@ -1316,8 +1318,10 @@ static void mlx5e_handle_rx_cqe_rep(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe) if (rep->vlan && skb_vlan_tag_present(skb)) skb_vlan_pop(skb); - if (!mlx5e_rep_tc_update_skb(cqe, skb, &tc_priv)) + if (!mlx5e_rep_tc_update_skb(cqe, skb, &tc_priv)) { + dev_kfree_skb_any(skb); goto free_wqe; + } napi_gro_receive(rq->cq.napi, skb); @@ -1371,8 +1375,10 @@ static void mlx5e_handle_rx_cqe_mpwrq_rep(struct mlx5e_rq *rq, struct mlx5_cqe64 mlx5e_complete_rx_cqe(rq, cqe, cqe_bcnt, skb); - if (!mlx5e_rep_tc_update_skb(cqe, skb, &tc_priv)) + if (!mlx5e_rep_tc_update_skb(cqe, skb, &tc_priv)) { + dev_kfree_skb_any(skb); goto mpwrq_cqe_out; + } napi_gro_receive(rq->cq.napi, skb); @@ -1528,8 +1534,10 @@ static void mlx5e_handle_rx_cqe_mpwrq(struct mlx5e_rq *rq, struct mlx5_cqe64 *cq mlx5e_complete_rx_cqe(rq, cqe, cqe_bcnt, skb); if (mlx5e_cqe_regb_chain(cqe)) - if (!mlx5e_tc_update_skb(cqe, skb)) + if (!mlx5e_tc_update_skb(cqe, skb)) { + dev_kfree_skb_any(skb); goto mpwrq_cqe_out; + } napi_gro_receive(rq->cq.napi, skb);