From patchwork Mon Jul 26 16:55:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saeed Mahameed X-Patchwork-Id: 486192 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.7 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 685B6C432BE for ; Mon, 26 Jul 2021 16:58:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4ACE060EB2 for ; Mon, 26 Jul 2021 16:58:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236074AbhGZQRe (ORCPT ); Mon, 26 Jul 2021 12:17:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:49884 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241129AbhGZQPZ (ORCPT ); Mon, 26 Jul 2021 12:15:25 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9BCBA60F57; Mon, 26 Jul 2021 16:55:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1627318553; bh=EevERKxgq8g7N6FFNGl7+xFknPDb6AKUPvnKdbzFUqU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r0zOaDNJMGUSx39WZ4fL36NbJ39sPZKLYHI9KoUUftAPbKJGx3XjeSPvDSWU5QVE9 y/UFzUsJvTLV+nkWEG54VafmJ0VguesX/mWFs0NZiDfN1Pfd1Q2/q6MT35DP+2DQdy D58KqhAausjH/XuPYoe7wPHR5kfSCXeL0rAzGYGV6WW43ATNzEsaUsxW2f64x+O7ws 46uS4ZfK0TDhRNBLgi6lhEzZOiE7wk1N0WEssu7nBrawbYNnUX5iuiTZHXxx4cP8Bv C9ffn87TQHjN3sNZwpZQ5ATJgl8S+PBH04BnXgvSEm5Hekv0t5Uo2w2w1DJGb1iAwa 6dj7+6csFNuXA== From: Saeed Mahameed To: "David S. Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, Tariq Toukan , Maxim Mikityanskiy , Saeed Mahameed Subject: [net-next 02/16] net/mlx5e: Block LRO if firmware asks for tunneled LRO Date: Mon, 26 Jul 2021 09:55:30 -0700 Message-Id: <20210726165544.389143-3-saeed@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210726165544.389143-1-saeed@kernel.org> References: <20210726165544.389143-1-saeed@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Maxim Mikityanskiy This commit does a cleanup in LRO configuration. LRO is a parameter of an RQ, but its state is changed by modifying a TIR related to the RQ. The current status: LRO for tunneled packets is not supported in the driver, inner TIRs may enable LRO on creation, but LRO status of inner TIRs isn't changed in mlx5e_modify_tirs_lro(). This is inconsistent, but as long as the firmware doesn't declare support for tunneled LRO, it works, because the same RQs are shared between the inner and outer TIRs. This commit does two fixes: 1. If the firmware has the tunneled LRO capability, LRO is blocked altogether, because it's not possible to block it for inner TIRs only, when the same RQs are shared between inner and outer TIRs, and the driver won't be able to handle tunneled LRO traffic. 2. mlx5e_modify_tirs_lro() is patched to modify LRO state for all TIRs, including inner ones, because all TIRs related to an RQ should agree on their LRO state. Fixes: 7b3722fa9ef6 ("net/mlx5e: Support RSS for GRE tunneled packets") Signed-off-by: Maxim Mikityanskiy Signed-off-by: Saeed Mahameed --- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 15 +++++++++++++++ include/linux/mlx5/mlx5_ifc.h | 3 ++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c index d09e65557e75..b651134b0f6b 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -2576,6 +2576,14 @@ static int mlx5e_modify_tirs_lro(struct mlx5e_priv *priv) err = mlx5_core_modify_tir(mdev, priv->indir_tir[tt].tirn, in); if (err) goto free_in; + + /* Verify inner tirs resources allocated */ + if (!priv->inner_indir_tir[0].tirn) + continue; + + err = mlx5_core_modify_tir(mdev, priv->inner_indir_tir[tt].tirn, in); + if (err) + goto free_in; } for (ix = 0; ix < priv->max_nch; ix++) { @@ -4808,7 +4816,14 @@ static void mlx5e_build_nic_netdev(struct net_device *netdev) netdev->hw_enc_features |= NETIF_F_HW_VLAN_CTAG_TX; netdev->hw_enc_features |= NETIF_F_HW_VLAN_CTAG_RX; + /* Tunneled LRO is not supported in the driver, and the same RQs are + * shared between inner and outer TIRs, so the driver can't disable LRO + * for inner TIRs while having it enabled for outer TIRs. Due to this, + * block LRO altogether if the firmware declares tunneled LRO support. + */ if (!!MLX5_CAP_ETH(mdev, lro_cap) && + !MLX5_CAP_ETH(mdev, tunnel_lro_vxlan) && + !MLX5_CAP_ETH(mdev, tunnel_lro_gre) && mlx5e_check_fragmented_striding_rq_cap(mdev)) netdev->vlan_features |= NETIF_F_LRO; diff --git a/include/linux/mlx5/mlx5_ifc.h b/include/linux/mlx5/mlx5_ifc.h index b0009aa3647f..6bbae0c3bc0b 100644 --- a/include/linux/mlx5/mlx5_ifc.h +++ b/include/linux/mlx5/mlx5_ifc.h @@ -921,7 +921,8 @@ struct mlx5_ifc_per_protocol_networking_offload_caps_bits { u8 scatter_fcs[0x1]; u8 enhanced_multi_pkt_send_wqe[0x1]; u8 tunnel_lso_const_out_ip_id[0x1]; - u8 reserved_at_1c[0x2]; + u8 tunnel_lro_gre[0x1]; + u8 tunnel_lro_vxlan[0x1]; u8 tunnel_stateless_gre[0x1]; u8 tunnel_stateless_vxlan[0x1]; From patchwork Mon Jul 26 16:55:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saeed Mahameed X-Patchwork-Id: 486191 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.7 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 3013DC4338F for ; Mon, 26 Jul 2021 16:58:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 18FF360E08 for ; Mon, 26 Jul 2021 16:58:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236787AbhGZQRi (ORCPT ); Mon, 26 Jul 2021 12:17:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:49894 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241130AbhGZQP0 (ORCPT ); Mon, 26 Jul 2021 12:15:26 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1AF8E60F6B; Mon, 26 Jul 2021 16:55:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1627318554; bh=KShrqARKA9SqA/+dQldppIu2zDZu5nAEAd3T3jl/AgA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FTcbxHU6ftUGE1o1W2R+aEserkVPLhiTEqBr864VNodbHpn9dFkBiLWYBmqgBHGQt y1Da9WjmeoeSeb/wUVDH1E6fq4rgDE1rgbKaxe/rMowo+W/mH4rW5BnWMfO/LIvHuU m1aUuLXtgbZkjTELIsQFfXkUgx6670+I4+jqj0AbYCrelw2jAWeVSLrVCvrLmi64/6 o/p85NTdM58SugBuEiWJZkjvnyrmWto9MrGpdjjz/dFi6nHpq8jmhwtAeIXJg2OOPH l43YY/MCkaME8NY5IoEy7KEcP7VGitckZEWGyKoH0XYuAw8evf3n10656hj1adK2lr MsfUtIwnm+lKg== From: Saeed Mahameed To: "David S. Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, Tariq Toukan , Maxim Mikityanskiy , Saeed Mahameed Subject: [net-next 03/16] net/mlx5: Take TIR destruction out of the TIR list lock Date: Mon, 26 Jul 2021 09:55:31 -0700 Message-Id: <20210726165544.389143-4-saeed@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210726165544.389143-1-saeed@kernel.org> References: <20210726165544.389143-1-saeed@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Maxim Mikityanskiy res->td.list_lock protects the list of TIRs. There is no point to call mlx5_core_destroy_tir() and invoke a firmware command under this lock. This commit moves this call outside of the lock and puts it after deleting the TIR from the list to ensure that TIRs are always alive while in the list. Signed-off-by: Maxim Mikityanskiy Reviewed-by: Tariq Toukan Signed-off-by: Saeed Mahameed --- drivers/net/ethernet/mellanox/mlx5/core/en_common.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_common.c b/drivers/net/ethernet/mellanox/mlx5/core/en_common.c index 8c166ee56d8b..f3bdd063051a 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_common.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_common.c @@ -58,9 +58,10 @@ void mlx5e_destroy_tir(struct mlx5_core_dev *mdev, struct mlx5e_hw_objs *res = &mdev->mlx5e_res.hw_objs; mutex_lock(&res->td.list_lock); - mlx5_core_destroy_tir(mdev, tir->tirn); list_del(&tir->list); mutex_unlock(&res->td.list_lock); + + mlx5_core_destroy_tir(mdev, tir->tirn); } void mlx5e_mkey_set_relaxed_ordering(struct mlx5_core_dev *mdev, void *mkc) From patchwork Mon Jul 26 16:55:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saeed Mahameed X-Patchwork-Id: 486189 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.7 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 A4C98C432BE for ; Mon, 26 Jul 2021 16:58:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 892B360560 for ; Mon, 26 Jul 2021 16:58:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234494AbhGZQSQ (ORCPT ); Mon, 26 Jul 2021 12:18:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:50088 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241313AbhGZQPs (ORCPT ); Mon, 26 Jul 2021 12:15:48 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 90D8A60F6D; Mon, 26 Jul 2021 16:55:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1627318554; bh=O4/y+5JMftspdi1zUdOeeWKP9myX6PFVSwrLjjAENSU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cbA10ydHBiucUuealfRmX7JemEZADtXciHw35XhzFaLtFQaUwfdWJxQ8Fd3OerQGP lWOts9e/OEQwlyflFMdPYywxvlqoDr79ZjGPp3yViOzYU0tUiQJ0r6Wc353nmQtrYK 2EverqMoFX6yXjECISDEs+deC+f9cd0ITD9DowKHqgVnO8m0F7+dgFMbE53/CO7URg R+n2PofICTkn9GVKuX4cXcVwkQ6tacwP9q5AjJOU5mJf74j0k3z1N0j+9kvMFgoZGG +RtNPbNdCpaWGWiB3BwER8Qj78IC3ljLH4I9/7YDhm9aKWlFaEWfbf0HWIIPYfUKQS QsxKtT/6TLG3w== From: Saeed Mahameed To: "David S. Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, Tariq Toukan , Maxim Mikityanskiy , Saeed Mahameed Subject: [net-next 04/16] net/mlx5e: Check if inner FT is supported outside of create/destroy functions Date: Mon, 26 Jul 2021 09:55:32 -0700 Message-Id: <20210726165544.389143-5-saeed@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210726165544.389143-1-saeed@kernel.org> References: <20210726165544.389143-1-saeed@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Maxim Mikityanskiy Move the mlx5e_tunnel_inner_ft_supported() check for inner flow tables support outside of mlx5e_create_inner_ttc_table() and mlx5e_destroy_inner_ttc_table(). It allows to avoid accessing invalid TIRNs of inner indirect TIRs. In a later commit these accesses will be replaced by getters that will WARN if inner indirect TIRs don't exist. Signed-off-by: Maxim Mikityanskiy Reviewed-by: Tariq Toukan Signed-off-by: Saeed Mahameed --- .../net/ethernet/mellanox/mlx5/core/en_fs.c | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c b/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c index 6464ac3f294e..1a38c527423e 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c @@ -1349,9 +1349,6 @@ static int mlx5e_create_inner_ttc_table(struct mlx5e_priv *priv, struct ttc_para struct mlx5e_flow_table *ft = &ttc->ft; int err; - if (!mlx5e_tunnel_inner_ft_supported(priv->mdev)) - return 0; - ft->t = mlx5_create_flow_table(priv->fs.ns, ¶ms->ft_attr); if (IS_ERR(ft->t)) { err = PTR_ERR(ft->t); @@ -1377,9 +1374,6 @@ static int mlx5e_create_inner_ttc_table(struct mlx5e_priv *priv, struct ttc_para static void mlx5e_destroy_inner_ttc_table(struct mlx5e_priv *priv, struct mlx5e_ttc_table *ttc) { - if (!mlx5e_tunnel_inner_ft_supported(priv->mdev)) - return; - mlx5e_cleanup_ttc_rules(ttc); mlx5e_destroy_flow_table(&ttc->ft); } @@ -1788,15 +1782,18 @@ int mlx5e_create_flow_steering(struct mlx5e_priv *priv) } mlx5e_set_ttc_basic_params(priv, &ttc_params); - mlx5e_set_inner_ttc_ft_params(&ttc_params); - for (tt = 0; tt < MLX5E_NUM_INDIR_TIRS; tt++) - ttc_params.indir_tirn[tt] = priv->inner_indir_tir[tt].tirn; - err = mlx5e_create_inner_ttc_table(priv, &ttc_params, &priv->fs.inner_ttc); - if (err) { - netdev_err(priv->netdev, "Failed to create inner ttc table, err=%d\n", - err); - goto err_destroy_arfs_tables; + if (mlx5e_tunnel_inner_ft_supported(priv->mdev)) { + mlx5e_set_inner_ttc_ft_params(&ttc_params); + for (tt = 0; tt < MLX5E_NUM_INDIR_TIRS; tt++) + ttc_params.indir_tirn[tt] = priv->inner_indir_tir[tt].tirn; + + err = mlx5e_create_inner_ttc_table(priv, &ttc_params, &priv->fs.inner_ttc); + if (err) { + netdev_err(priv->netdev, "Failed to create inner ttc table, err=%d\n", + err); + goto err_destroy_arfs_tables; + } } mlx5e_set_ttc_ft_params(&ttc_params); @@ -1839,7 +1836,8 @@ int mlx5e_create_flow_steering(struct mlx5e_priv *priv) err_destroy_ttc_table: mlx5e_destroy_ttc_table(priv, &priv->fs.ttc); err_destroy_inner_ttc_table: - mlx5e_destroy_inner_ttc_table(priv, &priv->fs.inner_ttc); + if (mlx5e_tunnel_inner_ft_supported(priv->mdev)) + mlx5e_destroy_inner_ttc_table(priv, &priv->fs.inner_ttc); err_destroy_arfs_tables: mlx5e_arfs_destroy_tables(priv); @@ -1852,7 +1850,8 @@ void mlx5e_destroy_flow_steering(struct mlx5e_priv *priv) mlx5e_destroy_vlan_table(priv); mlx5e_destroy_l2_table(priv); mlx5e_destroy_ttc_table(priv, &priv->fs.ttc); - mlx5e_destroy_inner_ttc_table(priv, &priv->fs.inner_ttc); + if (mlx5e_tunnel_inner_ft_supported(priv->mdev)) + mlx5e_destroy_inner_ttc_table(priv, &priv->fs.inner_ttc); mlx5e_arfs_destroy_tables(priv); mlx5e_ethtool_cleanup_steering(priv); } From patchwork Mon Jul 26 16:55:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saeed Mahameed X-Patchwork-Id: 486187 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.7 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 D6FF9C4338F for ; Mon, 26 Jul 2021 16:59:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C037A60EB2 for ; Mon, 26 Jul 2021 16:59:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235658AbhGZQSs (ORCPT ); Mon, 26 Jul 2021 12:18:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:50208 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241827AbhGZQQi (ORCPT ); Mon, 26 Jul 2021 12:16:38 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2000A60F91; Mon, 26 Jul 2021 16:55:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1627318556; bh=Ji8DQYUI+zuiI8TIvK6QkCN2DLckiPk72FeNGeSNLLU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fW311axpbGzQxgCzD8CR/v5Mk5oWo0Vs6VK57Ykp7KEemgpXhalsWjzpYywTRHzx1 VNdM42RiMRuZ08cWVroBOW6WQkKyQmxhyLbIJuaEoZH6mPqXvVtRNTQjEw3WbZnUnn cQGKkeOPAiAuLhYjWshvk5fABMo+bPB8Nan5P8wn1eMizJ2B99ufRyVG6lk7Nr0Oon WMPQYw1b65oasPQSeyF3khbD/OAuZBVhULwqE88RCxT2KScFLALWx1d7TjMO+YvW1v y4mmLcR09CuLxSfZsQYV4dsE6tMFzGtw7o6IJQIcDbFPplAeojlLHSvdbdqbFgYBk5 QHc8YiFPar7iA== From: Saeed Mahameed To: "David S. Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, Tariq Toukan , Maxim Mikityanskiy , Saeed Mahameed Subject: [net-next 07/16] net/mlx5e: Move RX resources to a separate struct Date: Mon, 26 Jul 2021 09:55:35 -0700 Message-Id: <20210726165544.389143-8-saeed@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210726165544.389143-1-saeed@kernel.org> References: <20210726165544.389143-1-saeed@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Maxim Mikityanskiy This commit moves RQTs and TIRs to a separate struct that is allocated dynamically in profiles that support these RX resources (all profiles, except IPoIB PKey). It also allows to remove rqt_enabled flags, as RQTs are always enabled in profiles that support RX resources. Signed-off-by: Maxim Mikityanskiy Reviewed-by: Tariq Toukan Signed-off-by: Saeed Mahameed --- drivers/net/ethernet/mellanox/mlx5/core/en.h | 26 +-- .../net/ethernet/mellanox/mlx5/core/en/fs.h | 2 + .../net/ethernet/mellanox/mlx5/core/en/ptp.c | 2 +- .../ethernet/mellanox/mlx5/core/en/rx_res.h | 36 ++++ .../mellanox/mlx5/core/en/xsk/setup.c | 4 +- .../mellanox/mlx5/core/en_accel/ktls_rx.c | 2 +- .../net/ethernet/mellanox/mlx5/core/en_arfs.c | 6 +- .../ethernet/mellanox/mlx5/core/en_ethtool.c | 13 +- .../net/ethernet/mellanox/mlx5/core/en_fs.c | 6 +- .../mellanox/mlx5/core/en_fs_ethtool.c | 9 +- .../net/ethernet/mellanox/mlx5/core/en_main.c | 169 +++++++++--------- .../net/ethernet/mellanox/mlx5/core/en_rep.c | 33 ++-- .../net/ethernet/mellanox/mlx5/core/en_tc.c | 5 +- .../ethernet/mellanox/mlx5/core/ipoib/ipoib.c | 30 ++-- 14 files changed, 189 insertions(+), 154 deletions(-) create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/rx_res.h diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h index 4ecf77d5f808..2cd2fbf6764d 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h @@ -58,7 +58,7 @@ #include "en/qos.h" #include "lib/hv_vhca.h" #include "lib/clock.h" -#include "en/rqt.h" +#include "en/rx_res.h" extern const struct net_device_ops mlx5e_netdev_ops; struct page_pool; @@ -141,7 +141,6 @@ struct page_pool; #define MLX5E_PARAMS_DEFAULT_MIN_RX_WQES_MPW 0x2 #define MLX5E_MIN_NUM_CHANNELS 0x1 -#define MLX5E_MAX_NUM_CHANNELS (MLX5E_INDIR_RQT_SIZE / 2) #define MLX5E_MAX_NUM_SQS (MLX5E_MAX_NUM_CHANNELS * MLX5E_MAX_NUM_TC) #define MLX5E_TX_CQ_POLL_BUDGET 128 #define MLX5E_TX_XSK_POLL_BUDGET 64 @@ -744,25 +743,11 @@ enum { MLX5E_STATE_XDP_ACTIVE, }; -struct mlx5e_tir { - u32 tirn; - struct mlx5e_rqt rqt; - bool rqt_enabled; - struct list_head list; -}; - enum { MLX5E_TC_PRIO = 0, MLX5E_NIC_PRIO }; -struct mlx5e_rss_params { - struct mlx5e_rss_params_indir indir; - u32 rx_hash_fields[MLX5E_NUM_INDIR_TIRS]; - u8 toeplitz_hash_key[40]; - u8 hfunc; -}; - struct mlx5e_modify_sq_param { int curr_state; int next_state; @@ -832,14 +817,7 @@ struct mlx5e_priv { struct mlx5e_channels channels; u32 tisn[MLX5_MAX_PORTS][MLX5E_MAX_NUM_TC]; - struct mlx5e_rqt indir_rqt; - bool indir_rqt_enabled; - struct mlx5e_tir indir_tir[MLX5E_NUM_INDIR_TIRS]; - struct mlx5e_tir inner_indir_tir[MLX5E_NUM_INDIR_TIRS]; - struct mlx5e_tir direct_tir[MLX5E_MAX_NUM_CHANNELS]; - struct mlx5e_tir xsk_tir[MLX5E_MAX_NUM_CHANNELS]; - struct mlx5e_tir ptp_tir; - struct mlx5e_rss_params rss_params; + struct mlx5e_rx_res *rx_res; u32 tx_rates[MLX5E_MAX_NUM_SQS]; struct mlx5e_flow_steering fs; diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/fs.h b/drivers/net/ethernet/mellanox/mlx5/core/en/fs.h index 43b092f5565a..d764ce8259a1 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/fs.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/fs.h @@ -160,6 +160,8 @@ enum { MLX5E_INNER_TTC_GROUP2_SIZE +\ MLX5E_INNER_TTC_GROUP3_SIZE) +struct mlx5e_priv; + #ifdef CONFIG_MLX5_EN_RXNFC struct mlx5e_ethtool_table { diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c b/drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c index 778e229310a9..c832a3dbdc74 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c @@ -603,8 +603,8 @@ static void mlx5e_ptp_rx_unset_fs(struct mlx5e_priv *priv) static int mlx5e_ptp_rx_set_fs(struct mlx5e_priv *priv) { struct mlx5e_ptp_fs *ptp_fs = priv->fs.ptp_fs; + u32 tirn = priv->rx_res->ptp_tir.tirn; struct mlx5_flow_handle *rule; - u32 tirn = priv->ptp_tir.tirn; int err; if (ptp_fs->valid) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/rx_res.h b/drivers/net/ethernet/mellanox/mlx5/core/en/rx_res.h new file mode 100644 index 000000000000..0520ee39c162 --- /dev/null +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/rx_res.h @@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ +/* Copyright (c) 2021, Mellanox Technologies inc. All rights reserved. */ + +#ifndef __MLX5_EN_RX_RES_H__ +#define __MLX5_EN_RX_RES_H__ + +#include +#include "rqt.h" +#include "fs.h" + +#define MLX5E_MAX_NUM_CHANNELS (MLX5E_INDIR_RQT_SIZE / 2) + +struct mlx5e_rss_params { + struct mlx5e_rss_params_indir indir; + u32 rx_hash_fields[MLX5E_NUM_INDIR_TIRS]; + u8 toeplitz_hash_key[40]; + u8 hfunc; +}; + +struct mlx5e_tir { + u32 tirn; + struct mlx5e_rqt rqt; + struct list_head list; +}; + +struct mlx5e_rx_res { + struct mlx5e_rqt indir_rqt; + struct mlx5e_tir indir_tirs[MLX5E_NUM_INDIR_TIRS]; + struct mlx5e_tir inner_indir_tirs[MLX5E_NUM_INDIR_TIRS]; + struct mlx5e_tir direct_tirs[MLX5E_MAX_NUM_CHANNELS]; + struct mlx5e_tir xsk_tirs[MLX5E_MAX_NUM_CHANNELS]; + struct mlx5e_tir ptp_tir; + struct mlx5e_rss_params rss_params; +}; + +#endif /* __MLX5_EN_RX_RES_H__ */ diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c b/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c index 0772dd324ae2..27dc6336d000 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c @@ -186,12 +186,12 @@ void mlx5e_deactivate_xsk(struct mlx5e_channel *c) int mlx5e_xsk_redirect_rqt_to_channel(struct mlx5e_priv *priv, struct mlx5e_channel *c) { - return mlx5e_rqt_redirect_direct(&priv->xsk_tir[c->ix].rqt, c->xskrq.rqn); + return mlx5e_rqt_redirect_direct(&priv->rx_res->xsk_tirs[c->ix].rqt, c->xskrq.rqn); } int mlx5e_xsk_redirect_rqt_to_drop(struct mlx5e_priv *priv, u16 ix) { - return mlx5e_rqt_redirect_direct(&priv->xsk_tir[ix].rqt, priv->drop_rq.rqn); + return mlx5e_rqt_redirect_direct(&priv->rx_res->xsk_tirs[ix].rqt, priv->drop_rq.rqn); } int mlx5e_xsk_redirect_rqts_to_channels(struct mlx5e_priv *priv, struct mlx5e_channels *chs) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c index 4e58fade7a60..d6b9582e41f6 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c @@ -635,7 +635,7 @@ int mlx5e_ktls_add_rx(struct net_device *netdev, struct sock *sk, priv_rx->sw_stats = &priv->tls->sw_stats; mlx5e_set_ktls_rx_priv_ctx(tls_ctx, priv_rx); - rqtn = priv->direct_tir[rxq].rqt.rqtn; + rqtn = priv->rx_res->direct_tirs[rxq].rqt.rqtn; err = mlx5e_ktls_create_tir(mdev, &priv_rx->tirn, rqtn); if (err) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c b/drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c index 25403af32859..b1efbcbb2573 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c @@ -192,7 +192,7 @@ static int arfs_add_default_rule(struct mlx5e_priv *priv, enum arfs_type type) { struct arfs_table *arfs_t = &priv->fs.arfs->arfs_tables[type]; - struct mlx5e_tir *tir = priv->indir_tir; + struct mlx5e_tir *tir = priv->rx_res->indir_tirs; struct mlx5_flow_destination dest = {}; MLX5_DECLARE_FLOW_ACT(flow_act); enum mlx5e_traffic_types tt; @@ -553,7 +553,7 @@ static struct mlx5_flow_handle *arfs_add_rule(struct mlx5e_priv *priv, 16); } dest.type = MLX5_FLOW_DESTINATION_TYPE_TIR; - dest.tir_num = priv->direct_tir[arfs_rule->rxq].tirn; + dest.tir_num = priv->rx_res->direct_tirs[arfs_rule->rxq].tirn; rule = mlx5_add_flow_rules(ft, spec, &flow_act, &dest, 1); if (IS_ERR(rule)) { err = PTR_ERR(rule); @@ -576,7 +576,7 @@ static void arfs_modify_rule_rq(struct mlx5e_priv *priv, int err = 0; dst.type = MLX5_FLOW_DESTINATION_TYPE_TIR; - dst.tir_num = priv->direct_tir[rxq].tirn; + dst.tir_num = priv->rx_res->direct_tirs[rxq].tirn; err = mlx5_modify_rule_destination(rule, &dst, NULL); if (err) netdev_warn(priv->netdev, diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c index c1f42eade842..8a75b37edcc2 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c @@ -1172,7 +1172,7 @@ static int mlx5e_set_link_ksettings(struct net_device *netdev, u32 mlx5e_ethtool_get_rxfh_key_size(struct mlx5e_priv *priv) { - return sizeof(priv->rss_params.toeplitz_hash_key); + return sizeof(priv->rx_res->rss_params.toeplitz_hash_key); } static u32 mlx5e_get_rxfh_key_size(struct net_device *netdev) @@ -1198,7 +1198,9 @@ int mlx5e_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key, u8 *hfunc) { struct mlx5e_priv *priv = netdev_priv(netdev); - struct mlx5e_rss_params *rss = &priv->rss_params; + struct mlx5e_rss_params *rss; + + rss = &priv->rx_res->rss_params; if (indir) memcpy(indir, rss->indir.table, sizeof(rss->indir.table)); @@ -1217,8 +1219,8 @@ int mlx5e_set_rxfh(struct net_device *dev, const u32 *indir, const u8 *key, const u8 hfunc) { struct mlx5e_priv *priv = netdev_priv(dev); - struct mlx5e_rss_params *rss = &priv->rss_params; int inlen = MLX5_ST_SZ_BYTES(modify_tir_in); + struct mlx5e_rss_params *rss; bool refresh_tirs = false; bool refresh_rqt = false; void *in; @@ -1234,6 +1236,8 @@ int mlx5e_set_rxfh(struct net_device *dev, const u32 *indir, mutex_lock(&priv->state_lock); + rss = &priv->rx_res->rss_params; + if (hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != rss->hfunc) { rss->hfunc = hfunc; refresh_rqt = true; @@ -1261,7 +1265,8 @@ int mlx5e_set_rxfh(struct net_device *dev, const u32 *indir, for (ix = 0; ix < priv->channels.num; ix++) rqns[ix] = priv->channels.c[ix]->rq.rqn; - mlx5e_rqt_redirect_indir(&priv->indir_rqt, rqns, priv->channels.num, + mlx5e_rqt_redirect_indir(&priv->rx_res->indir_rqt, rqns, + priv->channels.num, rss->hfunc, &rss->indir); kvfree(rqns); } diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c b/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c index 1a38c527423e..513a343abfe5 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c @@ -1320,7 +1320,7 @@ static int mlx5e_create_inner_ttc_table_groups(struct mlx5e_ttc_table *ttc) void mlx5e_set_ttc_basic_params(struct mlx5e_priv *priv, struct ttc_params *ttc_params) { - ttc_params->any_tt_tirn = priv->direct_tir[0].tirn; + ttc_params->any_tt_tirn = priv->rx_res->direct_tirs[0].tirn; ttc_params->inner_ttc = &priv->fs.inner_ttc; } @@ -1786,7 +1786,7 @@ int mlx5e_create_flow_steering(struct mlx5e_priv *priv) if (mlx5e_tunnel_inner_ft_supported(priv->mdev)) { mlx5e_set_inner_ttc_ft_params(&ttc_params); for (tt = 0; tt < MLX5E_NUM_INDIR_TIRS; tt++) - ttc_params.indir_tirn[tt] = priv->inner_indir_tir[tt].tirn; + ttc_params.indir_tirn[tt] = priv->rx_res->inner_indir_tirs[tt].tirn; err = mlx5e_create_inner_ttc_table(priv, &ttc_params, &priv->fs.inner_ttc); if (err) { @@ -1798,7 +1798,7 @@ int mlx5e_create_flow_steering(struct mlx5e_priv *priv) mlx5e_set_ttc_ft_params(&ttc_params); for (tt = 0; tt < MLX5E_NUM_INDIR_TIRS; tt++) - ttc_params.indir_tirn[tt] = priv->indir_tir[tt].tirn; + ttc_params.indir_tirn[tt] = priv->rx_res->indir_tirs[tt].tirn; err = mlx5e_create_ttc_table(priv, &ttc_params, &priv->fs.ttc); if (err) { diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c index b416a8ee2eed..b30967a316d1 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c @@ -425,7 +425,8 @@ add_ethtool_flow_rule(struct mlx5e_priv *priv, u16 ix; mlx5e_qid_get_ch_and_group(params, fs->ring_cookie, &ix, &group); - tir = group == MLX5E_RQ_GROUP_XSK ? priv->xsk_tir : priv->direct_tir; + tir = group == MLX5E_RQ_GROUP_XSK ? priv->rx_res->xsk_tirs : + priv->rx_res->direct_tirs; dst = kzalloc(sizeof(*dst), GFP_KERNEL); if (!dst) { @@ -854,10 +855,10 @@ static int mlx5e_set_rss_hash_opt(struct mlx5e_priv *priv, mutex_lock(&priv->state_lock); - if (rx_hash_field == priv->rss_params.rx_hash_fields[tt]) + if (rx_hash_field == priv->rx_res->rss_params.rx_hash_fields[tt]) goto out; - priv->rss_params.rx_hash_fields[tt] = rx_hash_field; + priv->rx_res->rss_params.rx_hash_fields[tt] = rx_hash_field; mlx5e_modify_tirs_hash(priv, in); out: @@ -876,7 +877,7 @@ static int mlx5e_get_rss_hash_opt(struct mlx5e_priv *priv, if (tt == MLX5E_NUM_INDIR_TIRS) return -EINVAL; - hash_field = priv->rss_params.rx_hash_fields[tt]; + hash_field = priv->rx_res->rss_params.rx_hash_fields[tt]; nfc->data = 0; if (hash_field & MLX5_HASH_FIELD_SEL_SRC_IP) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c index 6c495eee82d0..c1ff4bc348bd 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -2198,11 +2198,10 @@ int mlx5e_create_indirect_rqt(struct mlx5e_priv *priv) { int err; - err = mlx5e_rqt_init_direct(&priv->indir_rqt, priv->mdev, true, priv->drop_rq.rqn); + err = mlx5e_rqt_init_direct(&priv->rx_res->indir_rqt, priv->mdev, true, + priv->drop_rq.rqn); if (err) mlx5_core_warn(priv->mdev, "create indirect rqts failed, %d\n", err); - else - priv->indir_rqt_enabled = true; return err; } @@ -2216,17 +2215,14 @@ int mlx5e_create_direct_rqts(struct mlx5e_priv *priv, struct mlx5e_tir *tirs, in priv->drop_rq.rqn); if (unlikely(err)) goto err_destroy_rqts; - tirs[ix].rqt_enabled = true; } return 0; err_destroy_rqts: mlx5_core_warn(priv->mdev, "create rqts failed, %d\n", err); - for (ix--; ix >= 0; ix--) { - tirs[ix].rqt_enabled = false; + for (ix--; ix >= 0; ix--) mlx5e_rqt_destroy(&tirs[ix].rqt); - } return err; } @@ -2235,10 +2231,8 @@ void mlx5e_destroy_direct_rqts(struct mlx5e_priv *priv, struct mlx5e_tir *tirs, { int i; - for (i = 0; i < n; i++) { - tirs[i].rqt_enabled = false; + for (i = 0; i < n; i++) mlx5e_rqt_destroy(&tirs[i].rqt); - } } static int mlx5e_rx_hash_fn(int hfunc) @@ -2251,33 +2245,28 @@ static int mlx5e_rx_hash_fn(int hfunc) static void mlx5e_redirect_rqts_to_channels(struct mlx5e_priv *priv, struct mlx5e_channels *chs) { + struct mlx5e_rx_res *res = priv->rx_res; unsigned int ix; + u32 *rqns; - if (priv->indir_rqt_enabled) { - u32 *rqns; + rqns = kvmalloc_array(chs->num, sizeof(*rqns), GFP_KERNEL); + if (rqns) { + for (ix = 0; ix < chs->num; ix++) + rqns[ix] = chs->c[ix]->rq.rqn; - rqns = kvmalloc_array(chs->num, sizeof(*rqns), GFP_KERNEL); - if (rqns) { - for (ix = 0; ix < chs->num; ix++) - rqns[ix] = chs->c[ix]->rq.rqn; - - mlx5e_rqt_redirect_indir(&priv->indir_rqt, rqns, chs->num, - priv->rss_params.hfunc, - &priv->rss_params.indir); - kvfree(rqns); - } + mlx5e_rqt_redirect_indir(&res->indir_rqt, rqns, chs->num, + res->rss_params.hfunc, + &res->rss_params.indir); + kvfree(rqns); } for (ix = 0; ix < priv->max_nch; ix++) { u32 rqn = priv->drop_rq.rqn; - if (!priv->direct_tir[ix].rqt_enabled) - continue; - if (ix < chs->num) rqn = chs->c[ix]->rq.rqn; - mlx5e_rqt_redirect_direct(&priv->direct_tir[ix].rqt, rqn); + mlx5e_rqt_redirect_direct(&res->direct_tirs[ix].rqt, rqn); } if (priv->profile->rx_ptp_support) { @@ -2286,26 +2275,22 @@ static void mlx5e_redirect_rqts_to_channels(struct mlx5e_priv *priv, if (mlx5e_ptp_get_rqn(priv->channels.ptp, &rqn)) rqn = priv->drop_rq.rqn; - mlx5e_rqt_redirect_direct(&priv->ptp_tir.rqt, rqn); + mlx5e_rqt_redirect_direct(&res->ptp_tir.rqt, rqn); } } static void mlx5e_redirect_rqts_to_drop(struct mlx5e_priv *priv) { + struct mlx5e_rx_res *res = priv->rx_res; unsigned int ix; - if (priv->indir_rqt_enabled) - mlx5e_rqt_redirect_direct(&priv->indir_rqt, priv->drop_rq.rqn); + mlx5e_rqt_redirect_direct(&res->indir_rqt, priv->drop_rq.rqn); - for (ix = 0; ix < priv->max_nch; ix++) { - if (!priv->direct_tir[ix].rqt_enabled) - continue; - - mlx5e_rqt_redirect_direct(&priv->direct_tir[ix].rqt, priv->drop_rq.rqn); - } + for (ix = 0; ix < priv->max_nch; ix++) + mlx5e_rqt_redirect_direct(&res->direct_tirs[ix].rqt, priv->drop_rq.rqn); if (priv->profile->rx_ptp_support) - mlx5e_rqt_redirect_direct(&priv->ptp_tir.rqt, priv->drop_rq.rqn); + mlx5e_rqt_redirect_direct(&res->ptp_tir.rqt, priv->drop_rq.rqn); } static const struct mlx5e_tirc_config tirc_default_config[MLX5E_NUM_INDIR_TIRS] = { @@ -2406,8 +2391,9 @@ static void mlx5e_update_rx_hash_fields(struct mlx5e_tirc_config *ttconfig, void mlx5e_modify_tirs_hash(struct mlx5e_priv *priv, void *in) { + struct mlx5e_rss_params *rss = &priv->rx_res->rss_params; void *tirc = MLX5_ADDR_OF(modify_tir_in, in, ctx); - struct mlx5e_rss_params *rss = &priv->rss_params; + struct mlx5e_rx_res *res = priv->rx_res; struct mlx5_core_dev *mdev = priv->mdev; int ctxlen = MLX5_ST_SZ_BYTES(tirc); struct mlx5e_tirc_config ttconfig; @@ -2420,11 +2406,11 @@ void mlx5e_modify_tirs_hash(struct mlx5e_priv *priv, void *in) mlx5e_update_rx_hash_fields(&ttconfig, tt, rss->rx_hash_fields[tt]); mlx5e_build_indir_tir_ctx_hash(rss, &ttconfig, tirc, false); - mlx5_core_modify_tir(mdev, priv->indir_tir[tt].tirn, in); + mlx5_core_modify_tir(mdev, res->indir_tirs[tt].tirn, in); } /* Verify inner tirs resources allocated */ - if (!priv->inner_indir_tir[0].tirn) + if (!res->inner_indir_tirs[0].tirn) return; for (tt = 0; tt < MLX5E_NUM_INDIR_TIRS; tt++) { @@ -2432,13 +2418,14 @@ void mlx5e_modify_tirs_hash(struct mlx5e_priv *priv, void *in) mlx5e_update_rx_hash_fields(&ttconfig, tt, rss->rx_hash_fields[tt]); mlx5e_build_indir_tir_ctx_hash(rss, &ttconfig, tirc, true); - mlx5_core_modify_tir(mdev, priv->inner_indir_tir[tt].tirn, in); + mlx5_core_modify_tir(mdev, res->inner_indir_tirs[tt].tirn, in); } } static int mlx5e_modify_tirs_lro(struct mlx5e_priv *priv) { struct mlx5_core_dev *mdev = priv->mdev; + struct mlx5e_rx_res *res = priv->rx_res; void *in; void *tirc; @@ -2458,21 +2445,21 @@ static int mlx5e_modify_tirs_lro(struct mlx5e_priv *priv) mlx5e_build_tir_ctx_lro(&priv->channels.params, tirc); for (tt = 0; tt < MLX5E_NUM_INDIR_TIRS; tt++) { - err = mlx5_core_modify_tir(mdev, priv->indir_tir[tt].tirn, in); + err = mlx5_core_modify_tir(mdev, res->indir_tirs[tt].tirn, in); if (err) goto free_in; /* Verify inner tirs resources allocated */ - if (!priv->inner_indir_tir[0].tirn) + if (!res->inner_indir_tirs[0].tirn) continue; - err = mlx5_core_modify_tir(mdev, priv->inner_indir_tir[tt].tirn, in); + err = mlx5_core_modify_tir(mdev, res->inner_indir_tirs[tt].tirn, in); if (err) goto free_in; } for (ix = 0; ix < priv->max_nch; ix++) { - err = mlx5_core_modify_tir(mdev, priv->direct_tir[ix].tirn, in); + err = mlx5_core_modify_tir(mdev, res->direct_tirs[ix].tirn, in); if (err) goto free_in; } @@ -2661,8 +2648,9 @@ int mlx5e_num_channels_changed(struct mlx5e_priv *priv) mlx5e_set_default_xps_cpumasks(priv, &priv->channels.params); - if (!netif_is_rxfh_configured(priv->netdev)) - mlx5e_build_default_indir_rqt(priv->rss_params.indir.table, + /* This function may be called on attach, before priv->rx_res is created. */ + if (!netif_is_rxfh_configured(priv->netdev) && priv->rx_res) + mlx5e_build_default_indir_rqt(priv->rx_res->rss_params.indir.table, MLX5E_INDIR_RQT_SIZE, count); return 0; @@ -2722,16 +2710,19 @@ void mlx5e_activate_priv_channels(struct mlx5e_priv *priv) mlx5e_add_sqs_fwd_rules(priv); mlx5e_wait_channels_min_rx_wqes(&priv->channels); - mlx5e_redirect_rqts_to_channels(priv, &priv->channels); - mlx5e_xsk_redirect_rqts_to_channels(priv, &priv->channels); + if (priv->rx_res) { + mlx5e_redirect_rqts_to_channels(priv, &priv->channels); + mlx5e_xsk_redirect_rqts_to_channels(priv, &priv->channels); + } } void mlx5e_deactivate_priv_channels(struct mlx5e_priv *priv) { - mlx5e_xsk_redirect_rqts_to_drop(priv, &priv->channels); - - mlx5e_redirect_rqts_to_drop(priv); + if (priv->rx_res) { + mlx5e_xsk_redirect_rqts_to_drop(priv, &priv->channels); + mlx5e_redirect_rqts_to_drop(priv); + } if (mlx5e_is_vport_rep(priv)) mlx5e_remove_sqs_fwd_rules(priv); @@ -3122,8 +3113,8 @@ static void mlx5e_build_indir_tir_ctx(struct mlx5e_priv *priv, enum mlx5e_traffic_types tt, u32 *tirc) { - mlx5e_build_indir_tir_ctx_common(priv, priv->indir_rqt.rqtn, tirc); - mlx5e_build_indir_tir_ctx_hash(&priv->rss_params, + mlx5e_build_indir_tir_ctx_common(priv, priv->rx_res->indir_rqt.rqtn, tirc); + mlx5e_build_indir_tir_ctx_hash(&priv->rx_res->rss_params, &tirc_default_config[tt], tirc, false); } @@ -3137,13 +3128,14 @@ static void mlx5e_build_inner_indir_tir_ctx(struct mlx5e_priv *priv, enum mlx5e_traffic_types tt, u32 *tirc) { - mlx5e_build_indir_tir_ctx_common(priv, priv->indir_rqt.rqtn, tirc); - mlx5e_build_indir_tir_ctx_hash(&priv->rss_params, + mlx5e_build_indir_tir_ctx_common(priv, priv->rx_res->indir_rqt.rqtn, tirc); + mlx5e_build_indir_tir_ctx_hash(&priv->rx_res->rss_params, &tirc_default_config[tt], tirc, true); } int mlx5e_create_indirect_tirs(struct mlx5e_priv *priv, bool inner_ttc) { + struct mlx5e_rx_res *res = priv->rx_res; struct mlx5e_tir *tir; void *tirc; int inlen; @@ -3159,7 +3151,7 @@ int mlx5e_create_indirect_tirs(struct mlx5e_priv *priv, bool inner_ttc) for (tt = 0; tt < MLX5E_NUM_INDIR_TIRS; tt++) { memset(in, 0, inlen); - tir = &priv->indir_tir[tt]; + tir = &res->indir_tirs[tt]; tirc = MLX5_ADDR_OF(create_tir_in, in, ctx); mlx5e_build_indir_tir_ctx(priv, tt, tirc); err = mlx5e_create_tir(priv->mdev, tir, in); @@ -3174,7 +3166,7 @@ int mlx5e_create_indirect_tirs(struct mlx5e_priv *priv, bool inner_ttc) for (i = 0; i < MLX5E_NUM_INDIR_TIRS; i++) { memset(in, 0, inlen); - tir = &priv->inner_indir_tir[i]; + tir = &res->inner_indir_tirs[i]; tirc = MLX5_ADDR_OF(create_tir_in, in, ctx); mlx5e_build_inner_indir_tir_ctx(priv, i, tirc); err = mlx5e_create_tir(priv->mdev, tir, in); @@ -3191,10 +3183,10 @@ int mlx5e_create_indirect_tirs(struct mlx5e_priv *priv, bool inner_ttc) err_destroy_inner_tirs: for (i--; i >= 0; i--) - mlx5e_destroy_tir(priv->mdev, &priv->inner_indir_tir[i]); + mlx5e_destroy_tir(priv->mdev, &res->inner_indir_tirs[i]); for (tt--; tt >= 0; tt--) - mlx5e_destroy_tir(priv->mdev, &priv->indir_tir[tt]); + mlx5e_destroy_tir(priv->mdev, &res->indir_tirs[tt]); kvfree(in); @@ -3240,17 +3232,18 @@ int mlx5e_create_direct_tirs(struct mlx5e_priv *priv, struct mlx5e_tir *tirs, in void mlx5e_destroy_indirect_tirs(struct mlx5e_priv *priv) { + struct mlx5e_rx_res *res = priv->rx_res; int i; for (i = 0; i < MLX5E_NUM_INDIR_TIRS; i++) - mlx5e_destroy_tir(priv->mdev, &priv->indir_tir[i]); + mlx5e_destroy_tir(priv->mdev, &res->indir_tirs[i]); /* Verify inner tirs resources allocated */ - if (!priv->inner_indir_tir[0].tirn) + if (!res->inner_indir_tirs[0].tirn) return; for (i = 0; i < MLX5E_NUM_INDIR_TIRS; i++) - mlx5e_destroy_tir(priv->mdev, &priv->inner_indir_tir[i]); + mlx5e_destroy_tir(priv->mdev, &res->inner_indir_tirs[i]); } void mlx5e_destroy_direct_tirs(struct mlx5e_priv *priv, struct mlx5e_tir *tirs, int n) @@ -4869,7 +4862,11 @@ static int mlx5e_init_nic_rx(struct mlx5e_priv *priv) u16 max_nch = priv->max_nch; int err; - mlx5e_build_rss_params(&priv->rss_params, priv->channels.params.num_channels); + priv->rx_res = kvzalloc(sizeof(*priv->rx_res), GFP_KERNEL); + if (!priv->rx_res) + return -ENOMEM; + + mlx5e_build_rss_params(&priv->rx_res->rss_params, priv->channels.params.num_channels); mlx5e_create_q_counters(priv); @@ -4883,7 +4880,7 @@ static int mlx5e_init_nic_rx(struct mlx5e_priv *priv) if (err) goto err_close_drop_rq; - err = mlx5e_create_direct_rqts(priv, priv->direct_tir, max_nch); + err = mlx5e_create_direct_rqts(priv, priv->rx_res->direct_tirs, max_nch); if (err) goto err_destroy_indirect_rqts; @@ -4891,23 +4888,23 @@ static int mlx5e_init_nic_rx(struct mlx5e_priv *priv) if (err) goto err_destroy_direct_rqts; - err = mlx5e_create_direct_tirs(priv, priv->direct_tir, max_nch); + err = mlx5e_create_direct_tirs(priv, priv->rx_res->direct_tirs, max_nch); if (err) goto err_destroy_indirect_tirs; - err = mlx5e_create_direct_rqts(priv, priv->xsk_tir, max_nch); + err = mlx5e_create_direct_rqts(priv, priv->rx_res->xsk_tirs, max_nch); if (unlikely(err)) goto err_destroy_direct_tirs; - err = mlx5e_create_direct_tirs(priv, priv->xsk_tir, max_nch); + err = mlx5e_create_direct_tirs(priv, priv->rx_res->xsk_tirs, max_nch); if (unlikely(err)) goto err_destroy_xsk_rqts; - err = mlx5e_create_direct_rqts(priv, &priv->ptp_tir, 1); + err = mlx5e_create_direct_rqts(priv, &priv->rx_res->ptp_tir, 1); if (err) goto err_destroy_xsk_tirs; - err = mlx5e_create_direct_tirs(priv, &priv->ptp_tir, 1); + err = mlx5e_create_direct_tirs(priv, &priv->rx_res->ptp_tir, 1); if (err) goto err_destroy_ptp_rqt; @@ -4936,26 +4933,27 @@ static int mlx5e_init_nic_rx(struct mlx5e_priv *priv) err_destroy_flow_steering: mlx5e_destroy_flow_steering(priv); err_destroy_ptp_direct_tir: - mlx5e_destroy_direct_tirs(priv, &priv->ptp_tir, 1); + mlx5e_destroy_direct_tirs(priv, &priv->rx_res->ptp_tir, 1); err_destroy_ptp_rqt: - mlx5e_destroy_direct_rqts(priv, &priv->ptp_tir, 1); + mlx5e_destroy_direct_rqts(priv, &priv->rx_res->ptp_tir, 1); err_destroy_xsk_tirs: - mlx5e_destroy_direct_tirs(priv, priv->xsk_tir, max_nch); + mlx5e_destroy_direct_tirs(priv, priv->rx_res->xsk_tirs, max_nch); err_destroy_xsk_rqts: - mlx5e_destroy_direct_rqts(priv, priv->xsk_tir, max_nch); + mlx5e_destroy_direct_rqts(priv, priv->rx_res->xsk_tirs, max_nch); err_destroy_direct_tirs: - mlx5e_destroy_direct_tirs(priv, priv->direct_tir, max_nch); + mlx5e_destroy_direct_tirs(priv, priv->rx_res->direct_tirs, max_nch); err_destroy_indirect_tirs: mlx5e_destroy_indirect_tirs(priv); err_destroy_direct_rqts: - mlx5e_destroy_direct_rqts(priv, priv->direct_tir, max_nch); + mlx5e_destroy_direct_rqts(priv, priv->rx_res->direct_tirs, max_nch); err_destroy_indirect_rqts: - priv->indir_rqt_enabled = false; - mlx5e_rqt_destroy(&priv->indir_rqt); + mlx5e_rqt_destroy(&priv->rx_res->indir_rqt); err_close_drop_rq: mlx5e_close_drop_rq(&priv->drop_rq); err_destroy_q_counters: mlx5e_destroy_q_counters(priv); + kvfree(priv->rx_res); + priv->rx_res = NULL; return err; } @@ -4966,17 +4964,18 @@ static void mlx5e_cleanup_nic_rx(struct mlx5e_priv *priv) mlx5e_accel_cleanup_rx(priv); mlx5e_tc_nic_cleanup(priv); mlx5e_destroy_flow_steering(priv); - mlx5e_destroy_direct_tirs(priv, &priv->ptp_tir, 1); - mlx5e_destroy_direct_rqts(priv, &priv->ptp_tir, 1); - mlx5e_destroy_direct_tirs(priv, priv->xsk_tir, max_nch); - mlx5e_destroy_direct_rqts(priv, priv->xsk_tir, max_nch); - mlx5e_destroy_direct_tirs(priv, priv->direct_tir, max_nch); + mlx5e_destroy_direct_tirs(priv, &priv->rx_res->ptp_tir, 1); + mlx5e_destroy_direct_rqts(priv, &priv->rx_res->ptp_tir, 1); + mlx5e_destroy_direct_tirs(priv, priv->rx_res->xsk_tirs, max_nch); + mlx5e_destroy_direct_rqts(priv, priv->rx_res->xsk_tirs, max_nch); + mlx5e_destroy_direct_tirs(priv, priv->rx_res->direct_tirs, max_nch); mlx5e_destroy_indirect_tirs(priv); - mlx5e_destroy_direct_rqts(priv, priv->direct_tir, max_nch); - priv->indir_rqt_enabled = false; - mlx5e_rqt_destroy(&priv->indir_rqt); + mlx5e_destroy_direct_rqts(priv, priv->rx_res->direct_tirs, max_nch); + mlx5e_rqt_destroy(&priv->rx_res->indir_rqt); mlx5e_close_drop_rq(&priv->drop_rq); mlx5e_destroy_q_counters(priv); + kvfree(priv->rx_res); + priv->rx_res = NULL; } static int mlx5e_init_nic_tx(struct mlx5e_priv *priv) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c index 0df6c6f99820..590a7ae35155 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c @@ -647,6 +647,7 @@ static int mlx5e_create_rep_ttc_table(struct mlx5e_priv *priv) { struct mlx5e_rep_priv *rpriv = priv->ppriv; struct mlx5_eswitch_rep *rep = rpriv->rep; + struct mlx5e_rx_res *res = priv->rx_res; struct ttc_params ttc_params = {}; int tt, err; @@ -654,7 +655,7 @@ static int mlx5e_create_rep_ttc_table(struct mlx5e_priv *priv) MLX5_FLOW_NAMESPACE_KERNEL); /* The inner_ttc in the ttc params is intentionally not set */ - ttc_params.any_tt_tirn = priv->direct_tir[0].tirn; + ttc_params.any_tt_tirn = res->direct_tirs[0].tirn; mlx5e_set_ttc_ft_params(&ttc_params); if (rep->vport != MLX5_VPORT_UPLINK) @@ -662,7 +663,7 @@ static int mlx5e_create_rep_ttc_table(struct mlx5e_priv *priv) ttc_params.ft_attr.level = MLX5E_TTC_FT_LEVEL + 1; for (tt = 0; tt < MLX5E_NUM_INDIR_TIRS; tt++) - ttc_params.indir_tirn[tt] = priv->indir_tir[tt].tirn; + ttc_params.indir_tirn[tt] = res->indir_tirs[tt].tirn; err = mlx5e_create_ttc_table(priv, &ttc_params, &priv->fs.ttc); if (err) { @@ -760,7 +761,11 @@ static int mlx5e_init_rep_rx(struct mlx5e_priv *priv) u16 max_nch = priv->max_nch; int err; - mlx5e_build_rss_params(&priv->rss_params, priv->channels.params.num_channels); + priv->rx_res = kvzalloc(sizeof(*priv->rx_res), GFP_KERNEL); + if (!priv->rx_res) + return -ENOMEM; + + mlx5e_build_rss_params(&priv->rx_res->rss_params, priv->channels.params.num_channels); mlx5e_init_l2_addr(priv); @@ -774,7 +779,7 @@ static int mlx5e_init_rep_rx(struct mlx5e_priv *priv) if (err) goto err_close_drop_rq; - err = mlx5e_create_direct_rqts(priv, priv->direct_tir, max_nch); + err = mlx5e_create_direct_rqts(priv, priv->rx_res->direct_tirs, max_nch); if (err) goto err_destroy_indirect_rqts; @@ -782,7 +787,7 @@ static int mlx5e_init_rep_rx(struct mlx5e_priv *priv) if (err) goto err_destroy_direct_rqts; - err = mlx5e_create_direct_tirs(priv, priv->direct_tir, max_nch); + err = mlx5e_create_direct_tirs(priv, priv->rx_res->direct_tirs, max_nch); if (err) goto err_destroy_indirect_tirs; @@ -807,16 +812,17 @@ static int mlx5e_init_rep_rx(struct mlx5e_priv *priv) err_destroy_ttc_table: mlx5e_destroy_ttc_table(priv, &priv->fs.ttc); err_destroy_direct_tirs: - mlx5e_destroy_direct_tirs(priv, priv->direct_tir, max_nch); + mlx5e_destroy_direct_tirs(priv, priv->rx_res->direct_tirs, max_nch); err_destroy_indirect_tirs: mlx5e_destroy_indirect_tirs(priv); err_destroy_direct_rqts: - mlx5e_destroy_direct_rqts(priv, priv->direct_tir, max_nch); + mlx5e_destroy_direct_rqts(priv, priv->rx_res->direct_tirs, max_nch); err_destroy_indirect_rqts: - priv->indir_rqt_enabled = false; - mlx5e_rqt_destroy(&priv->indir_rqt); + mlx5e_rqt_destroy(&priv->rx_res->indir_rqt); err_close_drop_rq: mlx5e_close_drop_rq(&priv->drop_rq); + kvfree(priv->rx_res); + priv->rx_res = NULL; return err; } @@ -828,12 +834,13 @@ static void mlx5e_cleanup_rep_rx(struct mlx5e_priv *priv) rep_vport_rx_rule_destroy(priv); mlx5e_destroy_rep_root_ft(priv); mlx5e_destroy_ttc_table(priv, &priv->fs.ttc); - mlx5e_destroy_direct_tirs(priv, priv->direct_tir, max_nch); + mlx5e_destroy_direct_tirs(priv, priv->rx_res->direct_tirs, max_nch); mlx5e_destroy_indirect_tirs(priv); - mlx5e_destroy_direct_rqts(priv, priv->direct_tir, max_nch); - priv->indir_rqt_enabled = false; - mlx5e_rqt_destroy(&priv->indir_rqt); + mlx5e_destroy_direct_rqts(priv, priv->rx_res->direct_tirs, max_nch); + mlx5e_rqt_destroy(&priv->rx_res->indir_rqt); mlx5e_close_drop_rq(&priv->drop_rq); + kvfree(priv->rx_res); + priv->rx_res = NULL; } static int mlx5e_init_ul_rep_rx(struct mlx5e_priv *priv) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c index 859f892603e3..4c00abc472be 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c @@ -507,7 +507,7 @@ static int mlx5e_hairpin_create_indirect_rqt(struct mlx5e_hairpin *hp) mlx5e_build_default_indir_rqt(indir->table, MLX5E_INDIR_RQT_SIZE, hp->num_channels); err = mlx5e_rqt_init_indir(&hp->indir_rqt, mdev, hp->pair->rqn, hp->num_channels, - priv->rss_params.hfunc, indir); + priv->rx_res->rss_params.hfunc, indir); kvfree(indir); return err; @@ -529,7 +529,8 @@ static int mlx5e_hairpin_create_indirect_tirs(struct mlx5e_hairpin *hp) MLX5_SET(tirc, tirc, transport_domain, hp->tdn); MLX5_SET(tirc, tirc, disp_type, MLX5_TIRC_DISP_TYPE_INDIRECT); MLX5_SET(tirc, tirc, indirect_table, hp->indir_rqt.rqtn); - mlx5e_build_indir_tir_ctx_hash(&priv->rss_params, &ttconfig, tirc, false); + mlx5e_build_indir_tir_ctx_hash(&priv->rx_res->rss_params, &ttconfig, + tirc, false); err = mlx5_core_create_tir(hp->func_mdev, in, &hp->indir_tirn[tt]); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c index 87c713179c28..685d23e90450 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c @@ -333,7 +333,7 @@ static int mlx5i_create_flow_steering(struct mlx5e_priv *priv) mlx5e_set_ttc_basic_params(priv, &ttc_params); mlx5e_set_ttc_ft_params(&ttc_params); for (tt = 0; tt < MLX5E_NUM_INDIR_TIRS; tt++) - ttc_params.indir_tirn[tt] = priv->indir_tir[tt].tirn; + ttc_params.indir_tirn[tt] = priv->rx_res->indir_tirs[tt].tirn; err = mlx5e_create_ttc_table(priv, &ttc_params, &priv->fs.ttc); if (err) { @@ -362,7 +362,11 @@ static int mlx5i_init_rx(struct mlx5e_priv *priv) u16 max_nch = priv->max_nch; int err; - mlx5e_build_rss_params(&priv->rss_params, priv->channels.params.num_channels); + priv->rx_res = kvzalloc(sizeof(*priv->rx_res), GFP_KERNEL); + if (!priv->rx_res) + return -ENOMEM; + + mlx5e_build_rss_params(&priv->rx_res->rss_params, priv->channels.params.num_channels); mlx5e_create_q_counters(priv); @@ -376,7 +380,7 @@ static int mlx5i_init_rx(struct mlx5e_priv *priv) if (err) goto err_close_drop_rq; - err = mlx5e_create_direct_rqts(priv, priv->direct_tir, max_nch); + err = mlx5e_create_direct_rqts(priv, priv->rx_res->direct_tirs, max_nch); if (err) goto err_destroy_indirect_rqts; @@ -384,7 +388,7 @@ static int mlx5i_init_rx(struct mlx5e_priv *priv) if (err) goto err_destroy_direct_rqts; - err = mlx5e_create_direct_tirs(priv, priv->direct_tir, max_nch); + err = mlx5e_create_direct_tirs(priv, priv->rx_res->direct_tirs, max_nch); if (err) goto err_destroy_indirect_tirs; @@ -395,18 +399,19 @@ static int mlx5i_init_rx(struct mlx5e_priv *priv) return 0; err_destroy_direct_tirs: - mlx5e_destroy_direct_tirs(priv, priv->direct_tir, max_nch); + mlx5e_destroy_direct_tirs(priv, priv->rx_res->direct_tirs, max_nch); err_destroy_indirect_tirs: mlx5e_destroy_indirect_tirs(priv); err_destroy_direct_rqts: - mlx5e_destroy_direct_rqts(priv, priv->direct_tir, max_nch); + mlx5e_destroy_direct_rqts(priv, priv->rx_res->direct_tirs, max_nch); err_destroy_indirect_rqts: - priv->indir_rqt_enabled = false; - mlx5e_rqt_destroy(&priv->indir_rqt); + mlx5e_rqt_destroy(&priv->rx_res->indir_rqt); err_close_drop_rq: mlx5e_close_drop_rq(&priv->drop_rq); err_destroy_q_counters: mlx5e_destroy_q_counters(priv); + kvfree(priv->rx_res); + priv->rx_res = NULL; return err; } @@ -415,13 +420,14 @@ static void mlx5i_cleanup_rx(struct mlx5e_priv *priv) u16 max_nch = priv->max_nch; mlx5i_destroy_flow_steering(priv); - mlx5e_destroy_direct_tirs(priv, priv->direct_tir, max_nch); + mlx5e_destroy_direct_tirs(priv, priv->rx_res->direct_tirs, max_nch); mlx5e_destroy_indirect_tirs(priv); - mlx5e_destroy_direct_rqts(priv, priv->direct_tir, max_nch); - priv->indir_rqt_enabled = false; - mlx5e_rqt_destroy(&priv->indir_rqt); + mlx5e_destroy_direct_rqts(priv, priv->rx_res->direct_tirs, max_nch); + mlx5e_rqt_destroy(&priv->rx_res->indir_rqt); mlx5e_close_drop_rq(&priv->drop_rq); mlx5e_destroy_q_counters(priv); + kvfree(priv->rx_res); + priv->rx_res = NULL; } /* The stats groups order is opposite to the update_stats() order calls */ From patchwork Mon Jul 26 16:55:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saeed Mahameed X-Patchwork-Id: 486184 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.7 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 00620C432BE for ; Mon, 26 Jul 2021 17:00:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CF32660EB2 for ; Mon, 26 Jul 2021 17:00:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240573AbhGZQTT (ORCPT ); Mon, 26 Jul 2021 12:19:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:50210 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241830AbhGZQQi (ORCPT ); Mon, 26 Jul 2021 12:16:38 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A102F60F5E; Mon, 26 Jul 2021 16:55:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1627318557; bh=KeibOd0Q6ISfpIn+i0Wyhen/56nbLoSR/OKDZ4RAeLg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FcqMGqxqv3LRNrxbX/nDLqtZ7EwYbtL9ZCWtULLDsea5X0okQOWRF9h+CS7BUO4gD wc/rlvv13njv+lWxOO7zNNAuUGKovpWjcDwVNqG5NWziwtrUciXqpJWKG3jofdaBTi G+pSg0b0tg8EEAV4MoEz8qdGJYY2iCFOWp75qs7x2Ouq7cKmu32PAZVu3EnyAsCmOw WKQU9hv7Z+DydKA6WEY7YjhUseH7gho8xni4CZ3p3vsKS9O+e9Hxz76aeFluiWq+C8 1enRY5LuA+Kp6hGZyOeJvqh0ADICsSeMLJ2F2/oy30azwsAprp3IpfbyeKBMH1hWTj sn9a2KiyOyWSQ== From: Saeed Mahameed To: "David S. Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, Tariq Toukan , Maxim Mikityanskiy , Saeed Mahameed Subject: [net-next 08/16] net/mlx5e: Take RQT out of TIR and group RX resources Date: Mon, 26 Jul 2021 09:55:36 -0700 Message-Id: <20210726165544.389143-9-saeed@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210726165544.389143-1-saeed@kernel.org> References: <20210726165544.389143-1-saeed@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Maxim Mikityanskiy RQT is not part of TIR, as multiple TIRs may point to the same RQT, as it happens with indir_tir and inner_indir_tir. These instances of a TIR don't use the embedded RQT. This commit takes RQT out of TIR, making them independent. The RQTs are placed into struct mlx5e_rx_res, and items in that struct are regrouped by functionality: RSS, channels and PTP. Signed-off-by: Maxim Mikityanskiy Reviewed-by: Tariq Toukan Signed-off-by: Saeed Mahameed --- drivers/net/ethernet/mellanox/mlx5/core/en.h | 8 +- .../net/ethernet/mellanox/mlx5/core/en/ptp.c | 2 +- .../ethernet/mellanox/mlx5/core/en/rx_res.h | 25 ++- .../mellanox/mlx5/core/en/xsk/setup.c | 4 +- .../mellanox/mlx5/core/en_accel/ktls_rx.c | 2 +- .../net/ethernet/mellanox/mlx5/core/en_arfs.c | 7 +- .../net/ethernet/mellanox/mlx5/core/en_fs.c | 6 +- .../mellanox/mlx5/core/en_fs_ethtool.c | 8 +- .../net/ethernet/mellanox/mlx5/core/en_main.c | 209 ++++++++++++------ .../net/ethernet/mellanox/mlx5/core/en_rep.c | 19 +- .../ethernet/mellanox/mlx5/core/ipoib/ipoib.c | 17 +- 11 files changed, 188 insertions(+), 119 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h index 2cd2fbf6764d..59fc8432202f 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h @@ -1050,10 +1050,10 @@ int mlx5e_create_indirect_rqt(struct mlx5e_priv *priv); int mlx5e_create_indirect_tirs(struct mlx5e_priv *priv, bool inner_ttc); void mlx5e_destroy_indirect_tirs(struct mlx5e_priv *priv); -int mlx5e_create_direct_rqts(struct mlx5e_priv *priv, struct mlx5e_tir *tirs, int n); -void mlx5e_destroy_direct_rqts(struct mlx5e_priv *priv, struct mlx5e_tir *tirs, int n); -int mlx5e_create_direct_tirs(struct mlx5e_priv *priv, struct mlx5e_tir *tirs, int n); -void mlx5e_destroy_direct_tirs(struct mlx5e_priv *priv, struct mlx5e_tir *tirs, int n); +int mlx5e_create_direct_rqts(struct mlx5e_priv *priv); +void mlx5e_destroy_direct_rqts(struct mlx5e_priv *priv); +int mlx5e_create_direct_tirs(struct mlx5e_priv *priv); +void mlx5e_destroy_direct_tirs(struct mlx5e_priv *priv); int mlx5e_create_tis(struct mlx5_core_dev *mdev, void *in, u32 *tisn); void mlx5e_destroy_tis(struct mlx5_core_dev *mdev, u32 tisn); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c b/drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c index c832a3dbdc74..849ee3e147c4 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c @@ -603,7 +603,7 @@ static void mlx5e_ptp_rx_unset_fs(struct mlx5e_priv *priv) static int mlx5e_ptp_rx_set_fs(struct mlx5e_priv *priv) { struct mlx5e_ptp_fs *ptp_fs = priv->fs.ptp_fs; - u32 tirn = priv->rx_res->ptp_tir.tirn; + u32 tirn = priv->rx_res->ptp.tir.tirn; struct mlx5_flow_handle *rule; int err; diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/rx_res.h b/drivers/net/ethernet/mellanox/mlx5/core/en/rx_res.h index 0520ee39c162..b56c5de4828f 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/rx_res.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/rx_res.h @@ -19,18 +19,29 @@ struct mlx5e_rss_params { struct mlx5e_tir { u32 tirn; - struct mlx5e_rqt rqt; struct list_head list; }; struct mlx5e_rx_res { - struct mlx5e_rqt indir_rqt; - struct mlx5e_tir indir_tirs[MLX5E_NUM_INDIR_TIRS]; - struct mlx5e_tir inner_indir_tirs[MLX5E_NUM_INDIR_TIRS]; - struct mlx5e_tir direct_tirs[MLX5E_MAX_NUM_CHANNELS]; - struct mlx5e_tir xsk_tirs[MLX5E_MAX_NUM_CHANNELS]; - struct mlx5e_tir ptp_tir; struct mlx5e_rss_params rss_params; + + struct mlx5e_rqt indir_rqt; + struct { + struct mlx5e_tir indir_tir; + struct mlx5e_tir inner_indir_tir; + } rss[MLX5E_NUM_INDIR_TIRS]; + + struct { + struct mlx5e_rqt direct_rqt; + struct mlx5e_tir direct_tir; + struct mlx5e_rqt xsk_rqt; + struct mlx5e_tir xsk_tir; + } channels[MLX5E_MAX_NUM_CHANNELS]; + + struct { + struct mlx5e_rqt rqt; + struct mlx5e_tir tir; + } ptp; }; #endif /* __MLX5_EN_RX_RES_H__ */ diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c b/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c index 27dc6336d000..ab485d082729 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c @@ -186,12 +186,12 @@ void mlx5e_deactivate_xsk(struct mlx5e_channel *c) int mlx5e_xsk_redirect_rqt_to_channel(struct mlx5e_priv *priv, struct mlx5e_channel *c) { - return mlx5e_rqt_redirect_direct(&priv->rx_res->xsk_tirs[c->ix].rqt, c->xskrq.rqn); + return mlx5e_rqt_redirect_direct(&priv->rx_res->channels[c->ix].xsk_rqt, c->xskrq.rqn); } int mlx5e_xsk_redirect_rqt_to_drop(struct mlx5e_priv *priv, u16 ix) { - return mlx5e_rqt_redirect_direct(&priv->rx_res->xsk_tirs[ix].rqt, priv->drop_rq.rqn); + return mlx5e_rqt_redirect_direct(&priv->rx_res->channels[ix].xsk_rqt, priv->drop_rq.rqn); } int mlx5e_xsk_redirect_rqts_to_channels(struct mlx5e_priv *priv, struct mlx5e_channels *chs) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c index d6b9582e41f6..15153317a083 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c @@ -635,7 +635,7 @@ int mlx5e_ktls_add_rx(struct net_device *netdev, struct sock *sk, priv_rx->sw_stats = &priv->tls->sw_stats; mlx5e_set_ktls_rx_priv_ctx(tls_ctx, priv_rx); - rqtn = priv->rx_res->direct_tirs[rxq].rqt.rqtn; + rqtn = priv->rx_res->channels[rxq].direct_rqt.rqtn; err = mlx5e_ktls_create_tir(mdev, &priv_rx->tirn, rqtn); if (err) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c b/drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c index b1efbcbb2573..db6c6a96a6c9 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c @@ -192,7 +192,6 @@ static int arfs_add_default_rule(struct mlx5e_priv *priv, enum arfs_type type) { struct arfs_table *arfs_t = &priv->fs.arfs->arfs_tables[type]; - struct mlx5e_tir *tir = priv->rx_res->indir_tirs; struct mlx5_flow_destination dest = {}; MLX5_DECLARE_FLOW_ACT(flow_act); enum mlx5e_traffic_types tt; @@ -209,7 +208,7 @@ static int arfs_add_default_rule(struct mlx5e_priv *priv, /* FIXME: Must use mlx5e_ttc_get_default_dest(), * but can't since TTC default is not setup yet ! */ - dest.tir_num = tir[tt].tirn; + dest.tir_num = priv->rx_res->rss[tt].indir_tir.tirn; arfs_t->default_rule = mlx5_add_flow_rules(arfs_t->ft.t, NULL, &flow_act, &dest, 1); @@ -553,7 +552,7 @@ static struct mlx5_flow_handle *arfs_add_rule(struct mlx5e_priv *priv, 16); } dest.type = MLX5_FLOW_DESTINATION_TYPE_TIR; - dest.tir_num = priv->rx_res->direct_tirs[arfs_rule->rxq].tirn; + dest.tir_num = priv->rx_res->channels[arfs_rule->rxq].direct_tir.tirn; rule = mlx5_add_flow_rules(ft, spec, &flow_act, &dest, 1); if (IS_ERR(rule)) { err = PTR_ERR(rule); @@ -576,7 +575,7 @@ static void arfs_modify_rule_rq(struct mlx5e_priv *priv, int err = 0; dst.type = MLX5_FLOW_DESTINATION_TYPE_TIR; - dst.tir_num = priv->rx_res->direct_tirs[rxq].tirn; + dst.tir_num = priv->rx_res->channels[rxq].direct_tir.tirn; err = mlx5_modify_rule_destination(rule, &dst, NULL); if (err) netdev_warn(priv->netdev, diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c b/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c index 513a343abfe5..e79815763edf 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c @@ -1320,7 +1320,7 @@ static int mlx5e_create_inner_ttc_table_groups(struct mlx5e_ttc_table *ttc) void mlx5e_set_ttc_basic_params(struct mlx5e_priv *priv, struct ttc_params *ttc_params) { - ttc_params->any_tt_tirn = priv->rx_res->direct_tirs[0].tirn; + ttc_params->any_tt_tirn = priv->rx_res->channels[0].direct_tir.tirn; ttc_params->inner_ttc = &priv->fs.inner_ttc; } @@ -1786,7 +1786,7 @@ int mlx5e_create_flow_steering(struct mlx5e_priv *priv) if (mlx5e_tunnel_inner_ft_supported(priv->mdev)) { mlx5e_set_inner_ttc_ft_params(&ttc_params); for (tt = 0; tt < MLX5E_NUM_INDIR_TIRS; tt++) - ttc_params.indir_tirn[tt] = priv->rx_res->inner_indir_tirs[tt].tirn; + ttc_params.indir_tirn[tt] = priv->rx_res->rss[tt].inner_indir_tir.tirn; err = mlx5e_create_inner_ttc_table(priv, &ttc_params, &priv->fs.inner_ttc); if (err) { @@ -1798,7 +1798,7 @@ int mlx5e_create_flow_steering(struct mlx5e_priv *priv) mlx5e_set_ttc_ft_params(&ttc_params); for (tt = 0; tt < MLX5E_NUM_INDIR_TIRS; tt++) - ttc_params.indir_tirn[tt] = priv->rx_res->indir_tirs[tt].tirn; + ttc_params.indir_tirn[tt] = priv->rx_res->rss[tt].indir_tir.tirn; err = mlx5e_create_ttc_table(priv, &ttc_params, &priv->fs.ttc); if (err) { diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c index b30967a316d1..32edb9119d38 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c @@ -421,12 +421,9 @@ add_ethtool_flow_rule(struct mlx5e_priv *priv, } else { struct mlx5e_params *params = &priv->channels.params; enum mlx5e_rq_group group; - struct mlx5e_tir *tir; u16 ix; mlx5e_qid_get_ch_and_group(params, fs->ring_cookie, &ix, &group); - tir = group == MLX5E_RQ_GROUP_XSK ? priv->rx_res->xsk_tirs : - priv->rx_res->direct_tirs; dst = kzalloc(sizeof(*dst), GFP_KERNEL); if (!dst) { @@ -435,7 +432,10 @@ add_ethtool_flow_rule(struct mlx5e_priv *priv, } dst->type = MLX5_FLOW_DESTINATION_TYPE_TIR; - dst->tir_num = tir[ix].tirn; + if (group == MLX5E_RQ_GROUP_XSK) + dst->tir_num = priv->rx_res->channels[ix].xsk_tir.tirn; + else + dst->tir_num = priv->rx_res->channels[ix].direct_tir.tirn; flow_act.action = MLX5_FLOW_CONTEXT_ACTION_FWD_DEST; } diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c index c1ff4bc348bd..0e387799ee93 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -2205,14 +2205,14 @@ int mlx5e_create_indirect_rqt(struct mlx5e_priv *priv) return err; } -int mlx5e_create_direct_rqts(struct mlx5e_priv *priv, struct mlx5e_tir *tirs, int n) +int mlx5e_create_direct_rqts(struct mlx5e_priv *priv) { int err; int ix; - for (ix = 0; ix < n; ix++) { - err = mlx5e_rqt_init_direct(&tirs[ix].rqt, priv->mdev, false, - priv->drop_rq.rqn); + for (ix = 0; ix < priv->max_nch; ix++) { + err = mlx5e_rqt_init_direct(&priv->rx_res->channels[ix].direct_rqt, + priv->mdev, false, priv->drop_rq.rqn); if (unlikely(err)) goto err_destroy_rqts; } @@ -2220,19 +2220,49 @@ int mlx5e_create_direct_rqts(struct mlx5e_priv *priv, struct mlx5e_tir *tirs, in return 0; err_destroy_rqts: - mlx5_core_warn(priv->mdev, "create rqts failed, %d\n", err); - for (ix--; ix >= 0; ix--) - mlx5e_rqt_destroy(&tirs[ix].rqt); + mlx5_core_warn(priv->mdev, "create direct rqts failed, %d\n", err); + while (--ix >= 0) + mlx5e_rqt_destroy(&priv->rx_res->channels[ix].direct_rqt); return err; } -void mlx5e_destroy_direct_rqts(struct mlx5e_priv *priv, struct mlx5e_tir *tirs, int n) +static int mlx5e_create_xsk_rqts(struct mlx5e_priv *priv) { - int i; + int err; + int ix; + + for (ix = 0; ix < priv->max_nch; ix++) { + err = mlx5e_rqt_init_direct(&priv->rx_res->channels[ix].xsk_rqt, + priv->mdev, false, priv->drop_rq.rqn); + if (unlikely(err)) + goto err_destroy_rqts; + } + + return 0; + +err_destroy_rqts: + mlx5_core_warn(priv->mdev, "create xsk rqts failed, %d\n", err); + while (--ix >= 0) + mlx5e_rqt_destroy(&priv->rx_res->channels[ix].xsk_rqt); + + return err; +} + +void mlx5e_destroy_direct_rqts(struct mlx5e_priv *priv) +{ + unsigned int ix; - for (i = 0; i < n; i++) - mlx5e_rqt_destroy(&tirs[i].rqt); + for (ix = 0; ix < priv->max_nch; ix++) + mlx5e_rqt_destroy(&priv->rx_res->channels[ix].direct_rqt); +} + +static void mlx5e_destroy_xsk_rqts(struct mlx5e_priv *priv) +{ + unsigned int ix; + + for (ix = 0; ix < priv->max_nch; ix++) + mlx5e_rqt_destroy(&priv->rx_res->channels[ix].xsk_rqt); } static int mlx5e_rx_hash_fn(int hfunc) @@ -2266,7 +2296,7 @@ static void mlx5e_redirect_rqts_to_channels(struct mlx5e_priv *priv, if (ix < chs->num) rqn = chs->c[ix]->rq.rqn; - mlx5e_rqt_redirect_direct(&res->direct_tirs[ix].rqt, rqn); + mlx5e_rqt_redirect_direct(&res->channels[ix].direct_rqt, rqn); } if (priv->profile->rx_ptp_support) { @@ -2275,7 +2305,7 @@ static void mlx5e_redirect_rqts_to_channels(struct mlx5e_priv *priv, if (mlx5e_ptp_get_rqn(priv->channels.ptp, &rqn)) rqn = priv->drop_rq.rqn; - mlx5e_rqt_redirect_direct(&res->ptp_tir.rqt, rqn); + mlx5e_rqt_redirect_direct(&res->ptp.rqt, rqn); } } @@ -2287,10 +2317,10 @@ static void mlx5e_redirect_rqts_to_drop(struct mlx5e_priv *priv) mlx5e_rqt_redirect_direct(&res->indir_rqt, priv->drop_rq.rqn); for (ix = 0; ix < priv->max_nch; ix++) - mlx5e_rqt_redirect_direct(&res->direct_tirs[ix].rqt, priv->drop_rq.rqn); + mlx5e_rqt_redirect_direct(&res->channels[ix].direct_rqt, priv->drop_rq.rqn); if (priv->profile->rx_ptp_support) - mlx5e_rqt_redirect_direct(&res->ptp_tir.rqt, priv->drop_rq.rqn); + mlx5e_rqt_redirect_direct(&res->ptp.rqt, priv->drop_rq.rqn); } static const struct mlx5e_tirc_config tirc_default_config[MLX5E_NUM_INDIR_TIRS] = { @@ -2406,11 +2436,11 @@ void mlx5e_modify_tirs_hash(struct mlx5e_priv *priv, void *in) mlx5e_update_rx_hash_fields(&ttconfig, tt, rss->rx_hash_fields[tt]); mlx5e_build_indir_tir_ctx_hash(rss, &ttconfig, tirc, false); - mlx5_core_modify_tir(mdev, res->indir_tirs[tt].tirn, in); + mlx5_core_modify_tir(mdev, res->rss[tt].indir_tir.tirn, in); } /* Verify inner tirs resources allocated */ - if (!res->inner_indir_tirs[0].tirn) + if (!res->rss[0].inner_indir_tir.tirn) return; for (tt = 0; tt < MLX5E_NUM_INDIR_TIRS; tt++) { @@ -2418,7 +2448,7 @@ void mlx5e_modify_tirs_hash(struct mlx5e_priv *priv, void *in) mlx5e_update_rx_hash_fields(&ttconfig, tt, rss->rx_hash_fields[tt]); mlx5e_build_indir_tir_ctx_hash(rss, &ttconfig, tirc, true); - mlx5_core_modify_tir(mdev, res->inner_indir_tirs[tt].tirn, in); + mlx5_core_modify_tir(mdev, res->rss[tt].inner_indir_tir.tirn, in); } } @@ -2445,21 +2475,21 @@ static int mlx5e_modify_tirs_lro(struct mlx5e_priv *priv) mlx5e_build_tir_ctx_lro(&priv->channels.params, tirc); for (tt = 0; tt < MLX5E_NUM_INDIR_TIRS; tt++) { - err = mlx5_core_modify_tir(mdev, res->indir_tirs[tt].tirn, in); + err = mlx5_core_modify_tir(mdev, res->rss[tt].indir_tir.tirn, in); if (err) goto free_in; /* Verify inner tirs resources allocated */ - if (!res->inner_indir_tirs[0].tirn) + if (!res->rss[0].inner_indir_tir.tirn) continue; - err = mlx5_core_modify_tir(mdev, res->inner_indir_tirs[tt].tirn, in); + err = mlx5_core_modify_tir(mdev, res->rss[tt].inner_indir_tir.tirn, in); if (err) goto free_in; } for (ix = 0; ix < priv->max_nch; ix++) { - err = mlx5_core_modify_tir(mdev, res->direct_tirs[ix].tirn, in); + err = mlx5_core_modify_tir(mdev, res->channels[ix].direct_tir.tirn, in); if (err) goto free_in; } @@ -3151,7 +3181,7 @@ int mlx5e_create_indirect_tirs(struct mlx5e_priv *priv, bool inner_ttc) for (tt = 0; tt < MLX5E_NUM_INDIR_TIRS; tt++) { memset(in, 0, inlen); - tir = &res->indir_tirs[tt]; + tir = &res->rss[tt].indir_tir; tirc = MLX5_ADDR_OF(create_tir_in, in, ctx); mlx5e_build_indir_tir_ctx(priv, tt, tirc); err = mlx5e_create_tir(priv->mdev, tir, in); @@ -3166,7 +3196,7 @@ int mlx5e_create_indirect_tirs(struct mlx5e_priv *priv, bool inner_ttc) for (i = 0; i < MLX5E_NUM_INDIR_TIRS; i++) { memset(in, 0, inlen); - tir = &res->inner_indir_tirs[i]; + tir = &res->rss[i].inner_indir_tir; tirc = MLX5_ADDR_OF(create_tir_in, in, ctx); mlx5e_build_inner_indir_tir_ctx(priv, i, tirc); err = mlx5e_create_tir(priv->mdev, tir, in); @@ -3183,49 +3213,78 @@ int mlx5e_create_indirect_tirs(struct mlx5e_priv *priv, bool inner_ttc) err_destroy_inner_tirs: for (i--; i >= 0; i--) - mlx5e_destroy_tir(priv->mdev, &res->inner_indir_tirs[i]); + mlx5e_destroy_tir(priv->mdev, &res->rss[i].inner_indir_tir); for (tt--; tt >= 0; tt--) - mlx5e_destroy_tir(priv->mdev, &res->indir_tirs[tt]); + mlx5e_destroy_tir(priv->mdev, &res->rss[tt].indir_tir); kvfree(in); return err; } -int mlx5e_create_direct_tirs(struct mlx5e_priv *priv, struct mlx5e_tir *tirs, int n) +static int mlx5e_create_direct_tir(struct mlx5e_priv *priv, struct mlx5e_tir *tir, + struct mlx5e_rqt *rqt) { - struct mlx5e_tir *tir; void *tirc; int inlen; int err = 0; u32 *in; - int ix; inlen = MLX5_ST_SZ_BYTES(create_tir_in); in = kvzalloc(inlen, GFP_KERNEL); if (!in) return -ENOMEM; - for (ix = 0; ix < n; ix++) { - memset(in, 0, inlen); - tir = &tirs[ix]; - tirc = MLX5_ADDR_OF(create_tir_in, in, ctx); - mlx5e_build_direct_tir_ctx(priv, tir->rqt.rqtn, tirc); - err = mlx5e_create_tir(priv->mdev, tir, in); - if (unlikely(err)) - goto err_destroy_ch_tirs; + tirc = MLX5_ADDR_OF(create_tir_in, in, ctx); + mlx5e_build_direct_tir_ctx(priv, rqt->rqtn, tirc); + err = mlx5e_create_tir(priv->mdev, tir, in); + if (unlikely(err)) + mlx5_core_warn(priv->mdev, "create tirs failed, %d\n", err); + + kvfree(in); + + return err; +} + +int mlx5e_create_direct_tirs(struct mlx5e_priv *priv) +{ + int err; + int ix; + + for (ix = 0; ix < priv->max_nch; ix++) { + err = mlx5e_create_direct_tir(priv, &priv->rx_res->channels[ix].direct_tir, + &priv->rx_res->channels[ix].direct_rqt); + if (err) + goto err_destroy_tirs; } - goto out; + return 0; -err_destroy_ch_tirs: - mlx5_core_warn(priv->mdev, "create tirs failed, %d\n", err); - for (ix--; ix >= 0; ix--) - mlx5e_destroy_tir(priv->mdev, &tirs[ix]); +err_destroy_tirs: + while (--ix >= 0) + mlx5e_destroy_tir(priv->mdev, &priv->rx_res->channels[ix].direct_tir); -out: - kvfree(in); + return err; +} + +static int mlx5e_create_xsk_tirs(struct mlx5e_priv *priv) +{ + int err; + int ix; + + for (ix = 0; ix < priv->max_nch; ix++) { + err = mlx5e_create_direct_tir(priv, &priv->rx_res->channels[ix].xsk_tir, + &priv->rx_res->channels[ix].xsk_rqt); + if (err) + goto err_destroy_tirs; + } + + return 0; + +err_destroy_tirs: + while (--ix >= 0) + mlx5e_destroy_tir(priv->mdev, &priv->rx_res->channels[ix].xsk_tir); return err; } @@ -3236,22 +3295,30 @@ void mlx5e_destroy_indirect_tirs(struct mlx5e_priv *priv) int i; for (i = 0; i < MLX5E_NUM_INDIR_TIRS; i++) - mlx5e_destroy_tir(priv->mdev, &res->indir_tirs[i]); + mlx5e_destroy_tir(priv->mdev, &res->rss[i].indir_tir); /* Verify inner tirs resources allocated */ - if (!res->inner_indir_tirs[0].tirn) + if (!res->rss[0].inner_indir_tir.tirn) return; for (i = 0; i < MLX5E_NUM_INDIR_TIRS; i++) - mlx5e_destroy_tir(priv->mdev, &res->inner_indir_tirs[i]); + mlx5e_destroy_tir(priv->mdev, &res->rss[i].inner_indir_tir); } -void mlx5e_destroy_direct_tirs(struct mlx5e_priv *priv, struct mlx5e_tir *tirs, int n) +void mlx5e_destroy_direct_tirs(struct mlx5e_priv *priv) { - int i; + unsigned int ix; - for (i = 0; i < n; i++) - mlx5e_destroy_tir(priv->mdev, &tirs[i]); + for (ix = 0; ix < priv->max_nch; ix++) + mlx5e_destroy_tir(priv->mdev, &priv->rx_res->channels[ix].direct_tir); +} + +static void mlx5e_destroy_xsk_tirs(struct mlx5e_priv *priv) +{ + unsigned int ix; + + for (ix = 0; ix < priv->max_nch; ix++) + mlx5e_destroy_tir(priv->mdev, &priv->rx_res->channels[ix].xsk_tir); } static int mlx5e_modify_channels_scatter_fcs(struct mlx5e_channels *chs, bool enable) @@ -4859,7 +4926,6 @@ static void mlx5e_nic_cleanup(struct mlx5e_priv *priv) static int mlx5e_init_nic_rx(struct mlx5e_priv *priv) { struct mlx5_core_dev *mdev = priv->mdev; - u16 max_nch = priv->max_nch; int err; priv->rx_res = kvzalloc(sizeof(*priv->rx_res), GFP_KERNEL); @@ -4880,7 +4946,7 @@ static int mlx5e_init_nic_rx(struct mlx5e_priv *priv) if (err) goto err_close_drop_rq; - err = mlx5e_create_direct_rqts(priv, priv->rx_res->direct_tirs, max_nch); + err = mlx5e_create_direct_rqts(priv); if (err) goto err_destroy_indirect_rqts; @@ -4888,23 +4954,24 @@ static int mlx5e_init_nic_rx(struct mlx5e_priv *priv) if (err) goto err_destroy_direct_rqts; - err = mlx5e_create_direct_tirs(priv, priv->rx_res->direct_tirs, max_nch); + err = mlx5e_create_direct_tirs(priv); if (err) goto err_destroy_indirect_tirs; - err = mlx5e_create_direct_rqts(priv, priv->rx_res->xsk_tirs, max_nch); + err = mlx5e_create_xsk_rqts(priv); if (unlikely(err)) goto err_destroy_direct_tirs; - err = mlx5e_create_direct_tirs(priv, priv->rx_res->xsk_tirs, max_nch); + err = mlx5e_create_xsk_tirs(priv); if (unlikely(err)) goto err_destroy_xsk_rqts; - err = mlx5e_create_direct_rqts(priv, &priv->rx_res->ptp_tir, 1); + err = mlx5e_rqt_init_direct(&priv->rx_res->ptp.rqt, priv->mdev, false, + priv->drop_rq.rqn); if (err) goto err_destroy_xsk_tirs; - err = mlx5e_create_direct_tirs(priv, &priv->rx_res->ptp_tir, 1); + err = mlx5e_create_direct_tir(priv, &priv->rx_res->ptp.tir, &priv->rx_res->ptp.rqt); if (err) goto err_destroy_ptp_rqt; @@ -4933,19 +5000,19 @@ static int mlx5e_init_nic_rx(struct mlx5e_priv *priv) err_destroy_flow_steering: mlx5e_destroy_flow_steering(priv); err_destroy_ptp_direct_tir: - mlx5e_destroy_direct_tirs(priv, &priv->rx_res->ptp_tir, 1); + mlx5e_destroy_tir(priv->mdev, &priv->rx_res->ptp.tir); err_destroy_ptp_rqt: - mlx5e_destroy_direct_rqts(priv, &priv->rx_res->ptp_tir, 1); + mlx5e_rqt_destroy(&priv->rx_res->ptp.rqt); err_destroy_xsk_tirs: - mlx5e_destroy_direct_tirs(priv, priv->rx_res->xsk_tirs, max_nch); + mlx5e_destroy_xsk_tirs(priv); err_destroy_xsk_rqts: - mlx5e_destroy_direct_rqts(priv, priv->rx_res->xsk_tirs, max_nch); + mlx5e_destroy_xsk_rqts(priv); err_destroy_direct_tirs: - mlx5e_destroy_direct_tirs(priv, priv->rx_res->direct_tirs, max_nch); + mlx5e_destroy_direct_tirs(priv); err_destroy_indirect_tirs: mlx5e_destroy_indirect_tirs(priv); err_destroy_direct_rqts: - mlx5e_destroy_direct_rqts(priv, priv->rx_res->direct_tirs, max_nch); + mlx5e_destroy_direct_rqts(priv); err_destroy_indirect_rqts: mlx5e_rqt_destroy(&priv->rx_res->indir_rqt); err_close_drop_rq: @@ -4959,18 +5026,16 @@ static int mlx5e_init_nic_rx(struct mlx5e_priv *priv) static void mlx5e_cleanup_nic_rx(struct mlx5e_priv *priv) { - u16 max_nch = priv->max_nch; - mlx5e_accel_cleanup_rx(priv); mlx5e_tc_nic_cleanup(priv); mlx5e_destroy_flow_steering(priv); - mlx5e_destroy_direct_tirs(priv, &priv->rx_res->ptp_tir, 1); - mlx5e_destroy_direct_rqts(priv, &priv->rx_res->ptp_tir, 1); - mlx5e_destroy_direct_tirs(priv, priv->rx_res->xsk_tirs, max_nch); - mlx5e_destroy_direct_rqts(priv, priv->rx_res->xsk_tirs, max_nch); - mlx5e_destroy_direct_tirs(priv, priv->rx_res->direct_tirs, max_nch); + mlx5e_destroy_tir(priv->mdev, &priv->rx_res->ptp.tir); + mlx5e_rqt_destroy(&priv->rx_res->ptp.rqt); + mlx5e_destroy_xsk_tirs(priv); + mlx5e_destroy_xsk_rqts(priv); + mlx5e_destroy_direct_tirs(priv); mlx5e_destroy_indirect_tirs(priv); - mlx5e_destroy_direct_rqts(priv, priv->rx_res->direct_tirs, max_nch); + mlx5e_destroy_direct_rqts(priv); mlx5e_rqt_destroy(&priv->rx_res->indir_rqt); mlx5e_close_drop_rq(&priv->drop_rq); mlx5e_destroy_q_counters(priv); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c index 590a7ae35155..2c54951c240d 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c @@ -655,7 +655,7 @@ static int mlx5e_create_rep_ttc_table(struct mlx5e_priv *priv) MLX5_FLOW_NAMESPACE_KERNEL); /* The inner_ttc in the ttc params is intentionally not set */ - ttc_params.any_tt_tirn = res->direct_tirs[0].tirn; + ttc_params.any_tt_tirn = res->channels[0].direct_tir.tirn; mlx5e_set_ttc_ft_params(&ttc_params); if (rep->vport != MLX5_VPORT_UPLINK) @@ -663,7 +663,7 @@ static int mlx5e_create_rep_ttc_table(struct mlx5e_priv *priv) ttc_params.ft_attr.level = MLX5E_TTC_FT_LEVEL + 1; for (tt = 0; tt < MLX5E_NUM_INDIR_TIRS; tt++) - ttc_params.indir_tirn[tt] = res->indir_tirs[tt].tirn; + ttc_params.indir_tirn[tt] = res->rss[tt].indir_tir.tirn; err = mlx5e_create_ttc_table(priv, &ttc_params, &priv->fs.ttc); if (err) { @@ -758,7 +758,6 @@ int mlx5e_rep_bond_update(struct mlx5e_priv *priv, bool cleanup) static int mlx5e_init_rep_rx(struct mlx5e_priv *priv) { struct mlx5_core_dev *mdev = priv->mdev; - u16 max_nch = priv->max_nch; int err; priv->rx_res = kvzalloc(sizeof(*priv->rx_res), GFP_KERNEL); @@ -779,7 +778,7 @@ static int mlx5e_init_rep_rx(struct mlx5e_priv *priv) if (err) goto err_close_drop_rq; - err = mlx5e_create_direct_rqts(priv, priv->rx_res->direct_tirs, max_nch); + err = mlx5e_create_direct_rqts(priv); if (err) goto err_destroy_indirect_rqts; @@ -787,7 +786,7 @@ static int mlx5e_init_rep_rx(struct mlx5e_priv *priv) if (err) goto err_destroy_direct_rqts; - err = mlx5e_create_direct_tirs(priv, priv->rx_res->direct_tirs, max_nch); + err = mlx5e_create_direct_tirs(priv); if (err) goto err_destroy_indirect_tirs; @@ -812,11 +811,11 @@ static int mlx5e_init_rep_rx(struct mlx5e_priv *priv) err_destroy_ttc_table: mlx5e_destroy_ttc_table(priv, &priv->fs.ttc); err_destroy_direct_tirs: - mlx5e_destroy_direct_tirs(priv, priv->rx_res->direct_tirs, max_nch); + mlx5e_destroy_direct_tirs(priv); err_destroy_indirect_tirs: mlx5e_destroy_indirect_tirs(priv); err_destroy_direct_rqts: - mlx5e_destroy_direct_rqts(priv, priv->rx_res->direct_tirs, max_nch); + mlx5e_destroy_direct_rqts(priv); err_destroy_indirect_rqts: mlx5e_rqt_destroy(&priv->rx_res->indir_rqt); err_close_drop_rq: @@ -828,15 +827,13 @@ static int mlx5e_init_rep_rx(struct mlx5e_priv *priv) static void mlx5e_cleanup_rep_rx(struct mlx5e_priv *priv) { - u16 max_nch = priv->max_nch; - mlx5e_ethtool_cleanup_steering(priv); rep_vport_rx_rule_destroy(priv); mlx5e_destroy_rep_root_ft(priv); mlx5e_destroy_ttc_table(priv, &priv->fs.ttc); - mlx5e_destroy_direct_tirs(priv, priv->rx_res->direct_tirs, max_nch); + mlx5e_destroy_direct_tirs(priv); mlx5e_destroy_indirect_tirs(priv); - mlx5e_destroy_direct_rqts(priv, priv->rx_res->direct_tirs, max_nch); + mlx5e_destroy_direct_rqts(priv); mlx5e_rqt_destroy(&priv->rx_res->indir_rqt); mlx5e_close_drop_rq(&priv->drop_rq); kvfree(priv->rx_res); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c index 685d23e90450..6535c636ae22 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c @@ -333,7 +333,7 @@ static int mlx5i_create_flow_steering(struct mlx5e_priv *priv) mlx5e_set_ttc_basic_params(priv, &ttc_params); mlx5e_set_ttc_ft_params(&ttc_params); for (tt = 0; tt < MLX5E_NUM_INDIR_TIRS; tt++) - ttc_params.indir_tirn[tt] = priv->rx_res->indir_tirs[tt].tirn; + ttc_params.indir_tirn[tt] = priv->rx_res->rss[tt].indir_tir.tirn; err = mlx5e_create_ttc_table(priv, &ttc_params, &priv->fs.ttc); if (err) { @@ -359,7 +359,6 @@ static void mlx5i_destroy_flow_steering(struct mlx5e_priv *priv) static int mlx5i_init_rx(struct mlx5e_priv *priv) { struct mlx5_core_dev *mdev = priv->mdev; - u16 max_nch = priv->max_nch; int err; priv->rx_res = kvzalloc(sizeof(*priv->rx_res), GFP_KERNEL); @@ -380,7 +379,7 @@ static int mlx5i_init_rx(struct mlx5e_priv *priv) if (err) goto err_close_drop_rq; - err = mlx5e_create_direct_rqts(priv, priv->rx_res->direct_tirs, max_nch); + err = mlx5e_create_direct_rqts(priv); if (err) goto err_destroy_indirect_rqts; @@ -388,7 +387,7 @@ static int mlx5i_init_rx(struct mlx5e_priv *priv) if (err) goto err_destroy_direct_rqts; - err = mlx5e_create_direct_tirs(priv, priv->rx_res->direct_tirs, max_nch); + err = mlx5e_create_direct_tirs(priv); if (err) goto err_destroy_indirect_tirs; @@ -399,11 +398,11 @@ static int mlx5i_init_rx(struct mlx5e_priv *priv) return 0; err_destroy_direct_tirs: - mlx5e_destroy_direct_tirs(priv, priv->rx_res->direct_tirs, max_nch); + mlx5e_destroy_direct_tirs(priv); err_destroy_indirect_tirs: mlx5e_destroy_indirect_tirs(priv); err_destroy_direct_rqts: - mlx5e_destroy_direct_rqts(priv, priv->rx_res->direct_tirs, max_nch); + mlx5e_destroy_direct_rqts(priv); err_destroy_indirect_rqts: mlx5e_rqt_destroy(&priv->rx_res->indir_rqt); err_close_drop_rq: @@ -417,12 +416,10 @@ static int mlx5i_init_rx(struct mlx5e_priv *priv) static void mlx5i_cleanup_rx(struct mlx5e_priv *priv) { - u16 max_nch = priv->max_nch; - mlx5i_destroy_flow_steering(priv); - mlx5e_destroy_direct_tirs(priv, priv->rx_res->direct_tirs, max_nch); + mlx5e_destroy_direct_tirs(priv); mlx5e_destroy_indirect_tirs(priv); - mlx5e_destroy_direct_rqts(priv, priv->rx_res->direct_tirs, max_nch); + mlx5e_destroy_direct_rqts(priv); mlx5e_rqt_destroy(&priv->rx_res->indir_rqt); mlx5e_close_drop_rq(&priv->drop_rq); mlx5e_destroy_q_counters(priv); From patchwork Mon Jul 26 16:55:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saeed Mahameed X-Patchwork-Id: 486188 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.7 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 AF422C4338F for ; Mon, 26 Jul 2021 16:58:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8A2A460F4F for ; Mon, 26 Jul 2021 16:58:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238850AbhGZQSW (ORCPT ); Mon, 26 Jul 2021 12:18:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:50212 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241831AbhGZQQi (ORCPT ); Mon, 26 Jul 2021 12:16:38 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2DB5060F92; Mon, 26 Jul 2021 16:55:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1627318557; bh=FEga9gDd+3tz8meluN8Siw3+hIW3coc3zRLRF6+ujNo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pWB09V3gaii0QNcLqNg0cZ5qvXUl8g45E176Dqpu6gK9g3nxc+xEikSMtMu8iu+wa Ch1u23hCAWjyMSARZ0XbdPELJsP6eyZBhebewHephYbkU1ViOjawBHRsBFROoyCzOi DrMiMs1lNm8dIHSGem2/vDK1I7P+MME/55AGCr/rkKwAyfo7ySOIypNWRSu24asifo em4JOZRNU41pkqU0t8i/Ycp0I2XDnWFrXGLVpxfevf6VL1Jm31SrTgsP2tF9qxDd6x 8j13/bxzGtbQBb5hf+nGuBjEyH/MhifZpXnT7aVhcd/H7LmkxbsJAWtjkHeYjwIMQW ciAODVVyYuIbQ== From: Saeed Mahameed To: "David S. Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, Tariq Toukan , Maxim Mikityanskiy , Saeed Mahameed Subject: [net-next 09/16] net/mlx5e: Use mlx5e_rqt_get_rqtn to access RQT hardware id Date: Mon, 26 Jul 2021 09:55:37 -0700 Message-Id: <20210726165544.389143-10-saeed@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210726165544.389143-1-saeed@kernel.org> References: <20210726165544.389143-1-saeed@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Maxim Mikityanskiy In order to abstract from implementation details of mlx5e_rqt, use the mlx5e_rqt_get_rqtn getter instead of accessing the field directly. Signed-off-by: Maxim Mikityanskiy Reviewed-by: Tariq Toukan Signed-off-by: Saeed Mahameed --- .../net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 10 +++++++--- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c index 15153317a083..44bc6efd62fd 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c @@ -635,7 +635,7 @@ int mlx5e_ktls_add_rx(struct net_device *netdev, struct sock *sk, priv_rx->sw_stats = &priv->tls->sw_stats; mlx5e_set_ktls_rx_priv_ctx(tls_ctx, priv_rx); - rqtn = priv->rx_res->channels[rxq].direct_rqt.rqtn; + rqtn = mlx5e_rqt_get_rqtn(&priv->rx_res->channels[rxq].direct_rqt); err = mlx5e_ktls_create_tir(mdev, &priv_rx->tirn, rqtn); if (err) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c index 0e387799ee93..a70ada2e7208 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -3143,7 +3143,9 @@ static void mlx5e_build_indir_tir_ctx(struct mlx5e_priv *priv, enum mlx5e_traffic_types tt, u32 *tirc) { - mlx5e_build_indir_tir_ctx_common(priv, priv->rx_res->indir_rqt.rqtn, tirc); + u32 rqtn = mlx5e_rqt_get_rqtn(&priv->rx_res->indir_rqt); + + mlx5e_build_indir_tir_ctx_common(priv, rqtn, tirc); mlx5e_build_indir_tir_ctx_hash(&priv->rx_res->rss_params, &tirc_default_config[tt], tirc, false); } @@ -3158,7 +3160,9 @@ static void mlx5e_build_inner_indir_tir_ctx(struct mlx5e_priv *priv, enum mlx5e_traffic_types tt, u32 *tirc) { - mlx5e_build_indir_tir_ctx_common(priv, priv->rx_res->indir_rqt.rqtn, tirc); + u32 rqtn = mlx5e_rqt_get_rqtn(&priv->rx_res->indir_rqt); + + mlx5e_build_indir_tir_ctx_common(priv, rqtn, tirc); mlx5e_build_indir_tir_ctx_hash(&priv->rx_res->rss_params, &tirc_default_config[tt], tirc, true); } @@ -3237,7 +3241,7 @@ static int mlx5e_create_direct_tir(struct mlx5e_priv *priv, struct mlx5e_tir *ti return -ENOMEM; tirc = MLX5_ADDR_OF(create_tir_in, in, ctx); - mlx5e_build_direct_tir_ctx(priv, rqt->rqtn, tirc); + mlx5e_build_direct_tir_ctx(priv, mlx5e_rqt_get_rqtn(rqt), tirc); err = mlx5e_create_tir(priv->mdev, tir, in); if (unlikely(err)) mlx5_core_warn(priv->mdev, "create tirs failed, %d\n", err); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c index 4c00abc472be..dd5546fb0f42 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c @@ -528,7 +528,7 @@ static int mlx5e_hairpin_create_indirect_tirs(struct mlx5e_hairpin *hp) MLX5_SET(tirc, tirc, transport_domain, hp->tdn); MLX5_SET(tirc, tirc, disp_type, MLX5_TIRC_DISP_TYPE_INDIRECT); - MLX5_SET(tirc, tirc, indirect_table, hp->indir_rqt.rqtn); + MLX5_SET(tirc, tirc, indirect_table, mlx5e_rqt_get_rqtn(&hp->indir_rqt)); mlx5e_build_indir_tir_ctx_hash(&priv->rx_res->rss_params, &ttconfig, tirc, false); From patchwork Mon Jul 26 16:55:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saeed Mahameed X-Patchwork-Id: 486186 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.7 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 C3B77C4338F for ; Mon, 26 Jul 2021 16:59:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AC3E960EB2 for ; Mon, 26 Jul 2021 16:59:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240064AbhGZQSy (ORCPT ); Mon, 26 Jul 2021 12:18:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:50216 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241833AbhGZQQi (ORCPT ); Mon, 26 Jul 2021 12:16:38 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2816960F6E; Mon, 26 Jul 2021 16:55:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1627318558; bh=YgO8KAoqnQlYZnINVZBYLU1GrAO8YmnXbyFhbdgiavc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rXvwis669Fd/xzosRsSGGP0ExU90buy43LmJSG8R5KPHzlmU8EmToFjTdK5tfr4lo F085mTmmAXVqs6SI1wBeU/vyOnCPbD8mRl+VP9mDhiPSjggEQAbQ06W6tyt/UlbkuN f4v6dJiwZdQoIshgElA9Jn8x+BmcBYOmbQY2rJaOdrqJ/L5GnyX4mF56rWDTjaKsWh wCrrlIrOeHqf3oISBuSXgSxSoyvyo6/9s96fmitjIYgnFWbwHbY2UvlQXzRm5WiMSN K6SX6dvcqeU2JFziQbSwlRzLG/F7L9Psrh580D/5s394AdFEOka1X0/kIMddSwwP24 ZjnU1WZDrhoeQ== From: Saeed Mahameed To: "David S. Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, Tariq Toukan , Maxim Mikityanskiy , Saeed Mahameed Subject: [net-next 11/16] net/mlx5e: Remove lro_param from mlx5e_build_indir_tir_ctx_common() Date: Mon, 26 Jul 2021 09:55:39 -0700 Message-Id: <20210726165544.389143-12-saeed@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210726165544.389143-1-saeed@kernel.org> References: <20210726165544.389143-1-saeed@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Maxim Mikityanskiy In order to reduce the list of parameters and to define clearer responsibility for mlx5e_build_indir_tir_ctx_common(), stop passing lro_param and instead call mlx5e_build_tir_ctx_lro() directly where needed. Signed-off-by: Maxim Mikityanskiy Reviewed-by: Tariq Toukan Signed-off-by: Saeed Mahameed --- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c index 72782f0fd5eb..69a4a9336615 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -3130,7 +3130,6 @@ static void mlx5e_cleanup_nic_tx(struct mlx5e_priv *priv) } static void mlx5e_build_indir_tir_ctx_common(struct mlx5_core_dev *mdev, - struct mlx5e_lro_param *lro_param, bool inner_ft_support, u32 rqtn, u32 *tirc) { @@ -3138,8 +3137,6 @@ static void mlx5e_build_indir_tir_ctx_common(struct mlx5_core_dev *mdev, MLX5_SET(tirc, tirc, disp_type, MLX5_TIRC_DISP_TYPE_INDIRECT); MLX5_SET(tirc, tirc, indirect_table, rqtn); MLX5_SET(tirc, tirc, tunneled_offload_en, inner_ft_support); - - mlx5e_build_tir_ctx_lro(lro_param, tirc); } static void mlx5e_build_direct_tir_ctx(struct mlx5_core_dev *mdev, @@ -3147,7 +3144,8 @@ static void mlx5e_build_direct_tir_ctx(struct mlx5_core_dev *mdev, bool inner_ft_support, u32 rqtn, u32 *tirc) { - mlx5e_build_indir_tir_ctx_common(mdev, lro_param, inner_ft_support, rqtn, tirc); + mlx5e_build_indir_tir_ctx_common(mdev, inner_ft_support, rqtn, tirc); + mlx5e_build_tir_ctx_lro(lro_param, tirc); MLX5_SET(tirc, tirc, rx_hash_fn, MLX5_RX_HASH_FN_INVERTED_XOR8); } @@ -3176,9 +3174,10 @@ int mlx5e_create_indirect_tirs(struct mlx5e_priv *priv, bool inner_ttc) memset(in, 0, inlen); tir = &res->rss[tt].indir_tir; tirc = MLX5_ADDR_OF(create_tir_in, in, ctx); - mlx5e_build_indir_tir_ctx_common(priv->mdev, &lro_param, + mlx5e_build_indir_tir_ctx_common(priv->mdev, priv->channels.params.tunneled_offload_en, indir_rqtn, tirc); + mlx5e_build_tir_ctx_lro(&lro_param, tirc); mlx5e_build_indir_tir_ctx_hash(&priv->rx_res->rss_params, &tirc_default_config[tt], tirc, false); @@ -3196,9 +3195,10 @@ int mlx5e_create_indirect_tirs(struct mlx5e_priv *priv, bool inner_ttc) memset(in, 0, inlen); tir = &res->rss[i].inner_indir_tir; tirc = MLX5_ADDR_OF(create_tir_in, in, ctx); - mlx5e_build_indir_tir_ctx_common(priv->mdev, &lro_param, + mlx5e_build_indir_tir_ctx_common(priv->mdev, priv->channels.params.tunneled_offload_en, indir_rqtn, tirc); + mlx5e_build_tir_ctx_lro(&lro_param, tirc); mlx5e_build_indir_tir_ctx_hash(&priv->rx_res->rss_params, &tirc_default_config[i], tirc, true); err = mlx5e_create_tir(priv->mdev, tir, in); From patchwork Mon Jul 26 16:55:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saeed Mahameed X-Patchwork-Id: 486183 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.7 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 E6405C4320A for ; Mon, 26 Jul 2021 17:00:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C27A860F6D for ; Mon, 26 Jul 2021 17:00:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240260AbhGZQTN (ORCPT ); Mon, 26 Jul 2021 12:19:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:50220 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241834AbhGZQQi (ORCPT ); Mon, 26 Jul 2021 12:16:38 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9AB8860F6C; Mon, 26 Jul 2021 16:55:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1627318558; bh=xSWPfZ8GMwHEr7buJUrGU/vrdXW6FuwRJ/pJmdJDraQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k3V76FU9SLSaKsgAsT/fT1yVBD5fs33PaC30veEJsQsR/rycCDfydiDPEOp2nrq1W sJ787YRe4br5+D4g7Lw3MezY6Fur0LHNUgCnoHINmW4b0iTaq8+QjnctgmYNTqnApX W5fUiryhFbNxN5lsWNU0sNqZBxKGydRhDreMMv7HTD+6vxUbKR1owCddosiJx4LbdB gzeTF/c7Gt9gWz1zZ55L7oNi9xE2oootmjMQFa4lo25Ku1dLghS1dyyVusNLXue04A icWP2Id1uvKJyns3Rb0n09Vit7U9YnZ8HImLp735bfO6HKLzRL3y079HlJNfPGRqcc K4qUpXRtEdFbA== From: Saeed Mahameed To: "David S. Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, Tariq Toukan , Maxim Mikityanskiy , Saeed Mahameed Subject: [net-next 12/16] net/mlx5e: Remove mdev from mlx5e_build_indir_tir_ctx_common() Date: Mon, 26 Jul 2021 09:55:40 -0700 Message-Id: <20210726165544.389143-13-saeed@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210726165544.389143-1-saeed@kernel.org> References: <20210726165544.389143-1-saeed@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Maxim Mikityanskiy In order to drop a dependency to mdev and make the function more universal, stop passing mdev to mlx5e_build_indir_tir_ctx_common() and pass transport domain directly instead. It also prepares this function to be used in other contexts that need a custom transport domain, such as hairpin. Signed-off-by: Maxim Mikityanskiy Reviewed-by: Tariq Toukan Signed-off-by: Saeed Mahameed --- .../net/ethernet/mellanox/mlx5/core/en_main.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c index 69a4a9336615..53a51ac86d64 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -3129,22 +3129,20 @@ static void mlx5e_cleanup_nic_tx(struct mlx5e_priv *priv) mlx5e_destroy_tises(priv); } -static void mlx5e_build_indir_tir_ctx_common(struct mlx5_core_dev *mdev, - bool inner_ft_support, +static void mlx5e_build_indir_tir_ctx_common(u32 tdn, bool inner_ft_support, u32 rqtn, u32 *tirc) { - MLX5_SET(tirc, tirc, transport_domain, mdev->mlx5e_res.hw_objs.td.tdn); + MLX5_SET(tirc, tirc, transport_domain, tdn); MLX5_SET(tirc, tirc, disp_type, MLX5_TIRC_DISP_TYPE_INDIRECT); MLX5_SET(tirc, tirc, indirect_table, rqtn); MLX5_SET(tirc, tirc, tunneled_offload_en, inner_ft_support); } -static void mlx5e_build_direct_tir_ctx(struct mlx5_core_dev *mdev, - struct mlx5e_lro_param *lro_param, - bool inner_ft_support, +static void mlx5e_build_direct_tir_ctx(struct mlx5e_lro_param *lro_param, + u32 tdn, bool inner_ft_support, u32 rqtn, u32 *tirc) { - mlx5e_build_indir_tir_ctx_common(mdev, inner_ft_support, rqtn, tirc); + mlx5e_build_indir_tir_ctx_common(tdn, inner_ft_support, rqtn, tirc); mlx5e_build_tir_ctx_lro(lro_param, tirc); MLX5_SET(tirc, tirc, rx_hash_fn, MLX5_RX_HASH_FN_INVERTED_XOR8); } @@ -3174,7 +3172,7 @@ int mlx5e_create_indirect_tirs(struct mlx5e_priv *priv, bool inner_ttc) memset(in, 0, inlen); tir = &res->rss[tt].indir_tir; tirc = MLX5_ADDR_OF(create_tir_in, in, ctx); - mlx5e_build_indir_tir_ctx_common(priv->mdev, + mlx5e_build_indir_tir_ctx_common(priv->mdev->mlx5e_res.hw_objs.td.tdn, priv->channels.params.tunneled_offload_en, indir_rqtn, tirc); mlx5e_build_tir_ctx_lro(&lro_param, tirc); @@ -3195,7 +3193,7 @@ int mlx5e_create_indirect_tirs(struct mlx5e_priv *priv, bool inner_ttc) memset(in, 0, inlen); tir = &res->rss[i].inner_indir_tir; tirc = MLX5_ADDR_OF(create_tir_in, in, ctx); - mlx5e_build_indir_tir_ctx_common(priv->mdev, + mlx5e_build_indir_tir_ctx_common(priv->mdev->mlx5e_res.hw_objs.td.tdn, priv->channels.params.tunneled_offload_en, indir_rqtn, tirc); mlx5e_build_tir_ctx_lro(&lro_param, tirc); @@ -3241,7 +3239,8 @@ static int mlx5e_create_direct_tir(struct mlx5e_priv *priv, struct mlx5e_tir *ti tirc = MLX5_ADDR_OF(create_tir_in, in, ctx); lro_param = mlx5e_get_lro_param(&priv->channels.params); - mlx5e_build_direct_tir_ctx(priv->mdev, &lro_param, + mlx5e_build_direct_tir_ctx(&lro_param, + priv->mdev->mlx5e_res.hw_objs.td.tdn, priv->channels.params.tunneled_offload_en, mlx5e_rqt_get_rqtn(rqt), tirc); err = mlx5e_create_tir(priv->mdev, tir, in); From patchwork Mon Jul 26 16:55:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saeed Mahameed X-Patchwork-Id: 486185 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.7 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 8C676C432BE for ; Mon, 26 Jul 2021 16:59:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6F45960560 for ; Mon, 26 Jul 2021 16:59:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240190AbhGZQTF (ORCPT ); Mon, 26 Jul 2021 12:19:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:50222 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241835AbhGZQQi (ORCPT ); Mon, 26 Jul 2021 12:16:38 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 17BD560F93; Mon, 26 Jul 2021 16:55:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1627318559; bh=HLdfKkZAnj1q3HPKa8nUddK2qGdEQw9QxO1ezSdaiiI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ozsWprsXqc2RZs0gG1wHb2txqppDiiO2LPS6BEeASMMF9cHE/k6qb1ttf49mXDt47 DIT+10vyBg1gYouElwVS1GJkTAUss2vfTosrXTHD05XpDEuF/LlL++ogkP2auZEfuX K8pHVtL7Men19yTwLIu/DTc7vPmzeXcv29Jx7I3GHhIShjLxKsy8IQKkvdBgWJ6qBr MPpFpphKJNQqEK6G+9ZvxUZ1STvKJdao8xg3Vg/vc2047l8b/1z90fK9Grn9nyFtIb I877GTwnhe6y+XNufheceJ20RnPNiubuFHtcr0lLh+irhq1bFMsH5RSYuRgjrWRj1J m0kZhCaY6h9Dg== From: Saeed Mahameed To: "David S. Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, Tariq Toukan , Maxim Mikityanskiy , Saeed Mahameed Subject: [net-next 13/16] net/mlx5e: Create struct mlx5e_rss_params_hash Date: Mon, 26 Jul 2021 09:55:41 -0700 Message-Id: <20210726165544.389143-14-saeed@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210726165544.389143-1-saeed@kernel.org> References: <20210726165544.389143-1-saeed@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Maxim Mikityanskiy This commit introduces a new struct to store RSS hash parameters: hash function and hash key. The existing usages are changed to use the new struct. Signed-off-by: Maxim Mikityanskiy Reviewed-by: Tariq Toukan Signed-off-by: Saeed Mahameed --- .../ethernet/mellanox/mlx5/core/en/rx_res.h | 8 ++++++-- .../ethernet/mellanox/mlx5/core/en_ethtool.c | 18 ++++++++---------- .../net/ethernet/mellanox/mlx5/core/en_main.c | 14 +++++++------- .../net/ethernet/mellanox/mlx5/core/en_tc.c | 2 +- 4 files changed, 22 insertions(+), 20 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/rx_res.h b/drivers/net/ethernet/mellanox/mlx5/core/en/rx_res.h index b56c5de4828f..bdcd0b583e43 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/rx_res.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/rx_res.h @@ -10,11 +10,15 @@ #define MLX5E_MAX_NUM_CHANNELS (MLX5E_INDIR_RQT_SIZE / 2) +struct mlx5e_rss_params_hash { + u8 hfunc; + u8 toeplitz_hash_key[40]; +}; + struct mlx5e_rss_params { + struct mlx5e_rss_params_hash hash; struct mlx5e_rss_params_indir indir; u32 rx_hash_fields[MLX5E_NUM_INDIR_TIRS]; - u8 toeplitz_hash_key[40]; - u8 hfunc; }; struct mlx5e_tir { diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c index 8a75b37edcc2..4167f4e4211e 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c @@ -1172,7 +1172,7 @@ static int mlx5e_set_link_ksettings(struct net_device *netdev, u32 mlx5e_ethtool_get_rxfh_key_size(struct mlx5e_priv *priv) { - return sizeof(priv->rx_res->rss_params.toeplitz_hash_key); + return sizeof(priv->rx_res->rss_params.hash.toeplitz_hash_key); } static u32 mlx5e_get_rxfh_key_size(struct net_device *netdev) @@ -1206,11 +1206,10 @@ int mlx5e_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key, memcpy(indir, rss->indir.table, sizeof(rss->indir.table)); if (key) - memcpy(key, rss->toeplitz_hash_key, - sizeof(rss->toeplitz_hash_key)); + memcpy(key, rss->hash.toeplitz_hash_key, sizeof(rss->hash.toeplitz_hash_key)); if (hfunc) - *hfunc = rss->hfunc; + *hfunc = rss->hash.hfunc; return 0; } @@ -1238,8 +1237,8 @@ int mlx5e_set_rxfh(struct net_device *dev, const u32 *indir, rss = &priv->rx_res->rss_params; - if (hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != rss->hfunc) { - rss->hfunc = hfunc; + if (hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != rss->hash.hfunc) { + rss->hash.hfunc = hfunc; refresh_rqt = true; refresh_tirs = true; } @@ -1250,9 +1249,8 @@ int mlx5e_set_rxfh(struct net_device *dev, const u32 *indir, } if (key) { - memcpy(rss->toeplitz_hash_key, key, - sizeof(rss->toeplitz_hash_key)); - refresh_tirs = refresh_tirs || rss->hfunc == ETH_RSS_HASH_TOP; + memcpy(rss->hash.toeplitz_hash_key, key, sizeof(rss->hash.toeplitz_hash_key)); + refresh_tirs = refresh_tirs || rss->hash.hfunc == ETH_RSS_HASH_TOP; } if (refresh_rqt && test_bit(MLX5E_STATE_OPENED, &priv->state)) { @@ -1267,7 +1265,7 @@ int mlx5e_set_rxfh(struct net_device *dev, const u32 *indir, mlx5e_rqt_redirect_indir(&priv->rx_res->indir_rqt, rqns, priv->channels.num, - rss->hfunc, &rss->indir); + rss->hash.hfunc, &rss->indir); kvfree(rqns); } } diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c index 53a51ac86d64..10e6bebe8c74 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -2285,7 +2285,7 @@ static void mlx5e_redirect_rqts_to_channels(struct mlx5e_priv *priv, rqns[ix] = chs->c[ix]->rq.rqn; mlx5e_rqt_redirect_indir(&res->indir_rqt, rqns, chs->num, - res->rss_params.hfunc, + res->rss_params.hash.hfunc, &res->rss_params.indir); kvfree(rqns); } @@ -2393,15 +2393,15 @@ void mlx5e_build_indir_tir_ctx_hash(struct mlx5e_rss_params *rss_params, void *hfso = inner ? MLX5_ADDR_OF(tirc, tirc, rx_hash_field_selector_inner) : MLX5_ADDR_OF(tirc, tirc, rx_hash_field_selector_outer); - MLX5_SET(tirc, tirc, rx_hash_fn, mlx5e_rx_hash_fn(rss_params->hfunc)); - if (rss_params->hfunc == ETH_RSS_HASH_TOP) { + MLX5_SET(tirc, tirc, rx_hash_fn, mlx5e_rx_hash_fn(rss_params->hash.hfunc)); + if (rss_params->hash.hfunc == ETH_RSS_HASH_TOP) { void *rss_key = MLX5_ADDR_OF(tirc, tirc, rx_hash_toeplitz_key); size_t len = MLX5_FLD_SZ_BYTES(tirc, rx_hash_toeplitz_key); MLX5_SET(tirc, tirc, rx_hash_symmetric, 1); - memcpy(rss_key, rss_params->toeplitz_hash_key, len); + memcpy(rss_key, rss_params->hash.toeplitz_hash_key, len); } MLX5_SET(rx_hash_field_select, hfso, l3_prot_type, ttconfig->l3_prot_type); @@ -4591,9 +4591,9 @@ void mlx5e_build_rss_params(struct mlx5e_rss_params *rss_params, { enum mlx5e_traffic_types tt; - rss_params->hfunc = ETH_RSS_HASH_TOP; - netdev_rss_key_fill(rss_params->toeplitz_hash_key, - sizeof(rss_params->toeplitz_hash_key)); + rss_params->hash.hfunc = ETH_RSS_HASH_TOP; + netdev_rss_key_fill(rss_params->hash.toeplitz_hash_key, + sizeof(rss_params->hash.toeplitz_hash_key)); mlx5e_build_default_indir_rqt(rss_params->indir.table, MLX5E_INDIR_RQT_SIZE, num_channels); for (tt = 0; tt < MLX5E_NUM_INDIR_TIRS; tt++) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c index dd5546fb0f42..b4d58dd5c849 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c @@ -507,7 +507,7 @@ static int mlx5e_hairpin_create_indirect_rqt(struct mlx5e_hairpin *hp) mlx5e_build_default_indir_rqt(indir->table, MLX5E_INDIR_RQT_SIZE, hp->num_channels); err = mlx5e_rqt_init_indir(&hp->indir_rqt, mdev, hp->pair->rqn, hp->num_channels, - priv->rx_res->rss_params.hfunc, indir); + priv->rx_res->rss_params.hash.hfunc, indir); kvfree(indir); return err; From patchwork Mon Jul 26 16:55:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saeed Mahameed X-Patchwork-Id: 486182 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.7 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 9D3B5C43214 for ; Mon, 26 Jul 2021 17:00:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 79C2A60E08 for ; Mon, 26 Jul 2021 17:00:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240762AbhGZQT0 (ORCPT ); Mon, 26 Jul 2021 12:19:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:50238 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241918AbhGZQQr (ORCPT ); Mon, 26 Jul 2021 12:16:47 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9467960F9F; Mon, 26 Jul 2021 16:56:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1627318560; bh=mB63Llru9Z0KEguyfIYyrqUYPQeYPIERidqMBH3p6do=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U9/nwZNB1IHe4ymz65kPXYWLdPZk1+JGwJ57V0kDz8U+D+J0/MY03w5dvMmQocGu9 Fmyr+HW3XsHqfReh1qZ43gXT00/eZ7uzcFYlAttcBG8/0A//uPQyzCjhs9Zmm0LDmk xIUbvgRzMv0MZ4magiOtTYY3rvTmqkOaHnEjCo5klUJh/s9nBFxT5OTr9MYTnnsmnm L22BwXQgkfGSoKTtfkadI1hBeTc+twQaYdgKLdYrYztTusU1+k9TmGtpgrTY3Cwsnz OT6hKZq/LmVl2/tZMnBtzNh15EUaKh9W6I3PmBYUuywyma7nzWo1kzrS5iHNR2l/oq 8EjwdlrbXvhLA== From: Saeed Mahameed To: "David S. Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, Tariq Toukan , Maxim Mikityanskiy , Saeed Mahameed Subject: [net-next 16/16] net/mlx5e: Use the new TIR API for kTLS Date: Mon, 26 Jul 2021 09:55:44 -0700 Message-Id: <20210726165544.389143-17-saeed@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210726165544.389143-1-saeed@kernel.org> References: <20210726165544.389143-1-saeed@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Maxim Mikityanskiy One of the previous commits introduced a dedicated object for a TIR. kTLS code creates a TIR per connection using the low-level mlx5_core API. This commit converts it to the new mlx5e_tir API. Signed-off-by: Maxim Mikityanskiy Reviewed-by: Tariq Toukan Signed-off-by: Saeed Mahameed --- .../net/ethernet/mellanox/mlx5/core/en/tir.c | 12 +++++ .../net/ethernet/mellanox/mlx5/core/en/tir.h | 1 + .../mellanox/mlx5/core/en_accel/ktls_rx.c | 51 ++++++++----------- 3 files changed, 35 insertions(+), 29 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tir.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tir.c index 3ec94da45d36..de936dc4bc48 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/tir.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tir.c @@ -140,6 +140,18 @@ void mlx5e_tir_builder_build_direct(struct mlx5e_tir_builder *builder) MLX5_SET(tirc, tirc, rx_hash_fn, MLX5_RX_HASH_FN_INVERTED_XOR8); } +void mlx5e_tir_builder_build_tls(struct mlx5e_tir_builder *builder) +{ + void *tirc = mlx5e_tir_builder_get_tirc(builder); + + WARN_ON(builder->modify); + + MLX5_SET(tirc, tirc, tls_en, 1); + MLX5_SET(tirc, tirc, self_lb_block, + MLX5_TIRC_SELF_LB_BLOCK_BLOCK_UNICAST | + MLX5_TIRC_SELF_LB_BLOCK_BLOCK_MULTICAST); +} + int mlx5e_tir_init(struct mlx5e_tir *tir, struct mlx5e_tir_builder *builder, struct mlx5_core_dev *mdev, bool reg) { diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tir.h b/drivers/net/ethernet/mellanox/mlx5/core/en/tir.h index 25b8a2edf6cc..e45149a78ed9 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/tir.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tir.h @@ -34,6 +34,7 @@ void mlx5e_tir_builder_build_rss(struct mlx5e_tir_builder *builder, const struct mlx5e_rss_params_traffic_type *rss_tt, bool inner); void mlx5e_tir_builder_build_direct(struct mlx5e_tir_builder *builder); +void mlx5e_tir_builder_build_tls(struct mlx5e_tir_builder *builder); struct mlx5_core_dev; diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c index 44bc6efd62fd..bfdbc3060755 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c @@ -49,7 +49,7 @@ struct mlx5e_ktls_offload_context_rx { struct mlx5e_rq_stats *rq_stats; struct mlx5e_tls_sw_stats *sw_stats; struct completion add_ctx; - u32 tirn; + struct mlx5e_tir tir; u32 key_id; u32 rxq; DECLARE_BITMAP(flags, MLX5E_NUM_PRIV_RX_FLAGS); @@ -99,31 +99,22 @@ mlx5e_ktls_rx_resync_create_resp_list(void) return resp_list; } -static int mlx5e_ktls_create_tir(struct mlx5_core_dev *mdev, u32 *tirn, u32 rqtn) +static int mlx5e_ktls_create_tir(struct mlx5_core_dev *mdev, struct mlx5e_tir *tir, u32 rqtn) { - int err, inlen; - void *tirc; - u32 *in; + struct mlx5e_tir_builder *builder; + int err; - inlen = MLX5_ST_SZ_BYTES(create_tir_in); - in = kvzalloc(inlen, GFP_KERNEL); - if (!in) + builder = mlx5e_tir_builder_alloc(false); + if (!builder) return -ENOMEM; - tirc = MLX5_ADDR_OF(create_tir_in, in, ctx); - - MLX5_SET(tirc, tirc, transport_domain, mdev->mlx5e_res.hw_objs.td.tdn); - MLX5_SET(tirc, tirc, disp_type, MLX5_TIRC_DISP_TYPE_INDIRECT); - MLX5_SET(tirc, tirc, rx_hash_fn, MLX5_RX_HASH_FN_INVERTED_XOR8); - MLX5_SET(tirc, tirc, indirect_table, rqtn); - MLX5_SET(tirc, tirc, tls_en, 1); - MLX5_SET(tirc, tirc, self_lb_block, - MLX5_TIRC_SELF_LB_BLOCK_BLOCK_UNICAST | - MLX5_TIRC_SELF_LB_BLOCK_BLOCK_MULTICAST); + mlx5e_tir_builder_build_rqt(builder, mdev->mlx5e_res.hw_objs.td.tdn, rqtn, false); + mlx5e_tir_builder_build_direct(builder); + mlx5e_tir_builder_build_tls(builder); + err = mlx5e_tir_init(tir, builder, mdev, false); - err = mlx5_core_create_tir(mdev, in, tirn); + mlx5e_tir_builder_free(builder); - kvfree(in); return err; } @@ -139,7 +130,8 @@ static void accel_rule_handle_work(struct work_struct *work) goto out; rule = mlx5e_accel_fs_add_sk(accel_rule->priv, priv_rx->sk, - priv_rx->tirn, MLX5_FS_DEFAULT_FLOW_TAG); + mlx5e_tir_get_tirn(&priv_rx->tir), + MLX5_FS_DEFAULT_FLOW_TAG); if (!IS_ERR_OR_NULL(rule)) accel_rule->rule = rule; out: @@ -173,8 +165,8 @@ post_static_params(struct mlx5e_icosq *sq, pi = mlx5e_icosq_get_next_pi(sq, num_wqebbs); wqe = MLX5E_TLS_FETCH_SET_STATIC_PARAMS_WQE(sq, pi); mlx5e_ktls_build_static_params(wqe, sq->pc, sq->sqn, &priv_rx->crypto_info, - priv_rx->tirn, priv_rx->key_id, - priv_rx->resync.seq, false, + mlx5e_tir_get_tirn(&priv_rx->tir), + priv_rx->key_id, priv_rx->resync.seq, false, TLS_OFFLOAD_CTX_DIR_RX); wi = (struct mlx5e_icosq_wqe_info) { .wqe_type = MLX5E_ICOSQ_WQE_UMR_TLS, @@ -202,8 +194,9 @@ post_progress_params(struct mlx5e_icosq *sq, pi = mlx5e_icosq_get_next_pi(sq, num_wqebbs); wqe = MLX5E_TLS_FETCH_SET_PROGRESS_PARAMS_WQE(sq, pi); - mlx5e_ktls_build_progress_params(wqe, sq->pc, sq->sqn, priv_rx->tirn, false, - next_record_tcp_sn, + mlx5e_ktls_build_progress_params(wqe, sq->pc, sq->sqn, + mlx5e_tir_get_tirn(&priv_rx->tir), + false, next_record_tcp_sn, TLS_OFFLOAD_CTX_DIR_RX); wi = (struct mlx5e_icosq_wqe_info) { .wqe_type = MLX5E_ICOSQ_WQE_SET_PSV_TLS, @@ -325,7 +318,7 @@ resync_post_get_progress_params(struct mlx5e_icosq *sq, psv = &wqe->psv; psv->num_psv = 1 << 4; psv->l_key = sq->channel->mkey_be; - psv->psv_index[0] = cpu_to_be32(priv_rx->tirn); + psv->psv_index[0] = cpu_to_be32(mlx5e_tir_get_tirn(&priv_rx->tir)); psv->va = cpu_to_be64(buf->dma_addr); wi = (struct mlx5e_icosq_wqe_info) { @@ -637,7 +630,7 @@ int mlx5e_ktls_add_rx(struct net_device *netdev, struct sock *sk, rqtn = mlx5e_rqt_get_rqtn(&priv->rx_res->channels[rxq].direct_rqt); - err = mlx5e_ktls_create_tir(mdev, &priv_rx->tirn, rqtn); + err = mlx5e_ktls_create_tir(mdev, &priv_rx->tir, rqtn); if (err) goto err_create_tir; @@ -658,7 +651,7 @@ int mlx5e_ktls_add_rx(struct net_device *netdev, struct sock *sk, return 0; err_post_wqes: - mlx5_core_destroy_tir(mdev, priv_rx->tirn); + mlx5e_tir_destroy(&priv_rx->tir); err_create_tir: mlx5_ktls_destroy_key(mdev, priv_rx->key_id); err_create_key: @@ -693,7 +686,7 @@ void mlx5e_ktls_del_rx(struct net_device *netdev, struct tls_context *tls_ctx) if (priv_rx->rule.rule) mlx5e_accel_fs_del_sk(priv_rx->rule.rule); - mlx5_core_destroy_tir(mdev, priv_rx->tirn); + mlx5e_tir_destroy(&priv_rx->tir); mlx5_ktls_destroy_key(mdev, priv_rx->key_id); /* priv_rx should normally be freed here, but if there is an outstanding * GET_PSV, deallocation will be delayed until the CQE for GET_PSV is