netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Saeed Mahameed <saeed@kernel.org>
To: "David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>
Cc: netdev@vger.kernel.org, Tariq Toukan <tariqt@nvidia.com>,
	Maxim Mikityanskiy <maximmi@nvidia.com>,
	Saeed Mahameed <saeedm@nvidia.com>
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	[thread overview]
Message-ID: <20210726165544.389143-5-saeed@kernel.org> (raw)
In-Reply-To: <20210726165544.389143-1-saeed@kernel.org>

From: Maxim Mikityanskiy <maximmi@nvidia.com>

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 <maximmi@nvidia.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
 .../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, &params->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);
 }
-- 
2.31.1


  parent reply	other threads:[~2021-07-26 16:58 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-26 16:55 [pull request][net-next 00/16] mlx5 updates 2021-07-24 Saeed Mahameed
2021-07-26 16:55 ` [net-next 01/16] net/mlx5e: Prohibit inner indir TIRs in IPoIB Saeed Mahameed
2021-07-26 21:40   ` patchwork-bot+netdevbpf
2021-07-26 16:55 ` [net-next 02/16] net/mlx5e: Block LRO if firmware asks for tunneled LRO Saeed Mahameed
2021-07-26 16:55 ` [net-next 03/16] net/mlx5: Take TIR destruction out of the TIR list lock Saeed Mahameed
2021-07-26 16:55 ` Saeed Mahameed [this message]
2021-07-26 16:55 ` [net-next 05/16] net/mlx5e: Convert RQT to a dedicated object Saeed Mahameed
2021-07-26 16:55 ` [net-next 06/16] net/mlx5e: Move mlx5e_build_rss_params() call to init_rx Saeed Mahameed
2021-07-26 16:55 ` [net-next 07/16] net/mlx5e: Move RX resources to a separate struct Saeed Mahameed
2021-07-26 16:55 ` [net-next 08/16] net/mlx5e: Take RQT out of TIR and group RX resources Saeed Mahameed
2021-07-26 16:55 ` [net-next 09/16] net/mlx5e: Use mlx5e_rqt_get_rqtn to access RQT hardware id Saeed Mahameed
2021-07-26 16:55 ` [net-next 10/16] net/mlx5e: Remove mlx5e_priv usage from mlx5e_build_*tir_ctx*() Saeed Mahameed
2021-07-26 16:55 ` [net-next 11/16] net/mlx5e: Remove lro_param from mlx5e_build_indir_tir_ctx_common() Saeed Mahameed
2021-07-26 16:55 ` [net-next 12/16] net/mlx5e: Remove mdev " Saeed Mahameed
2021-07-26 16:55 ` [net-next 13/16] net/mlx5e: Create struct mlx5e_rss_params_hash Saeed Mahameed
2021-07-26 16:55 ` [net-next 14/16] net/mlx5e: Convert TIR to a dedicated object Saeed Mahameed
2021-07-26 16:55 ` [net-next 15/16] net/mlx5e: Move management of indir traffic types to rx_res Saeed Mahameed
2021-07-26 16:55 ` [net-next 16/16] net/mlx5e: Use the new TIR API for kTLS Saeed Mahameed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210726165544.389143-5-saeed@kernel.org \
    --to=saeed@kernel.org \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=maximmi@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=saeedm@nvidia.com \
    --cc=tariqt@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).