summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTariq Toukan <tariqt@nvidia.com>2021-07-21 15:23:57 +0300
committerSaeed Mahameed <saeedm@nvidia.com>2021-08-16 16:17:26 -0700
commitfc651ff9105adb44261774482380ee5f86ac24d9 (patch)
treee0538a658c6e6ae21d3402b86e396fd1faea6943
parent6e5fea51961e60ffd45a480dce23c4dd567fc5ec (diff)
net/mlx5e: Introduce TIR create/destroy API in rx_res
Take TIR control operations in rx_res into functions. This is in preparation to supporting on-demand TIR operations in downstream patches. Signed-off-by: Tariq Toukan <tariqt@nvidia.com> Reviewed-by: Maxim Mikityanskiy <maximmi@nvidia.com> Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en/rx_res.c140
1 files changed, 83 insertions, 57 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/rx_res.c b/drivers/net/ethernet/mellanox/mlx5/core/en/rx_res.c
index 2d0e8c809936..dfa492a14928 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/rx_res.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/rx_res.c
@@ -117,84 +117,114 @@ static void mlx5e_rx_res_rss_params_init(struct mlx5e_rx_res *res, unsigned int
mlx5e_rss_get_default_tt_config(tt).rx_hash_fields;
}
-static int mlx5e_rx_res_rss_init(struct mlx5e_rx_res *res,
- const struct mlx5e_lro_param *init_lro_param)
+static void mlx5e_rx_res_rss_destroy_tir(struct mlx5e_rx_res *res,
+ enum mlx5_traffic_types tt,
+ bool inner)
+{
+ struct mlx5e_tir *tir;
+
+ tir = inner ? &res->rss[tt].inner_indir_tir : &res->rss[tt].indir_tir;
+ mlx5e_tir_destroy(tir);
+}
+
+static int mlx5e_rx_res_rss_create_tir(struct mlx5e_rx_res *res,
+ struct mlx5e_tir_builder *builder,
+ enum mlx5_traffic_types tt,
+ const struct mlx5e_lro_param *init_lro_param,
+ bool inner)
{
bool inner_ft_support = res->features & MLX5E_RX_RES_FEATURE_INNER_FT;
+ struct mlx5e_rss_params_traffic_type rss_tt;
+ struct mlx5e_tir *tir;
+ u32 rqtn;
+ int err;
+
+ tir = inner ? &res->rss[tt].inner_indir_tir : &res->rss[tt].indir_tir;
+
+ rqtn = mlx5e_rqt_get_rqtn(&res->indir_rqt);
+ mlx5e_tir_builder_build_rqt(builder, res->mdev->mlx5e_res.hw_objs.td.tdn,
+ rqtn, inner_ft_support);
+ mlx5e_tir_builder_build_lro(builder, init_lro_param);
+ rss_tt = mlx5e_rx_res_rss_get_current_tt_config(res, tt);
+ mlx5e_tir_builder_build_rss(builder, &res->rss_params.hash, &rss_tt, inner);
+
+ err = mlx5e_tir_init(tir, builder, res->mdev, true);
+ if (err) {
+ mlx5_core_warn(res->mdev, "Failed to create %sindirect TIR: err = %d, tt = %d\n",
+ inner ? "inner " : "", err, tt);
+ return err;
+ }
+
+ return 0;
+}
+
+static int mlx5e_rx_res_rss_create_tirs(struct mlx5e_rx_res *res,
+ const struct mlx5e_lro_param *init_lro_param,
+ bool inner)
+{
enum mlx5_traffic_types tt, max_tt;
struct mlx5e_tir_builder *builder;
- u32 indir_rqtn;
int err;
builder = mlx5e_tir_builder_alloc(false);
if (!builder)
return -ENOMEM;
- err = mlx5e_rqt_init_direct(&res->indir_rqt, res->mdev, true, res->drop_rqn);
- if (err)
- goto out;
-
- indir_rqtn = mlx5e_rqt_get_rqtn(&res->indir_rqt);
-
for (tt = 0; tt < MLX5E_NUM_INDIR_TIRS; tt++) {
- struct mlx5e_rss_params_traffic_type rss_tt;
-
- mlx5e_tir_builder_build_rqt(builder, res->mdev->mlx5e_res.hw_objs.td.tdn,
- indir_rqtn, inner_ft_support);
- mlx5e_tir_builder_build_lro(builder, init_lro_param);
- rss_tt = mlx5e_rx_res_rss_get_current_tt_config(res, tt);
- mlx5e_tir_builder_build_rss(builder, &res->rss_params.hash, &rss_tt, false);
-
- err = mlx5e_tir_init(&res->rss[tt].indir_tir, builder, res->mdev, true);
- if (err) {
- mlx5_core_warn(res->mdev, "Failed to create an indirect TIR: err = %d, tt = %d\n",
- err, tt);
+ err = mlx5e_rx_res_rss_create_tir(res, builder, tt, init_lro_param, inner);
+ if (err)
goto err_destroy_tirs;
- }
mlx5e_tir_builder_clear(builder);
}
- if (!inner_ft_support)
- goto out;
+out:
+ mlx5e_tir_builder_free(builder);
+ return err;
- for (tt = 0; tt < MLX5E_NUM_INDIR_TIRS; tt++) {
- struct mlx5e_rss_params_traffic_type rss_tt;
+err_destroy_tirs:
+ max_tt = tt;
+ for (tt = 0; tt < max_tt; tt++)
+ mlx5e_rx_res_rss_destroy_tir(res, tt, inner);
+ goto out;
+}
- mlx5e_tir_builder_build_rqt(builder, res->mdev->mlx5e_res.hw_objs.td.tdn,
- indir_rqtn, inner_ft_support);
- mlx5e_tir_builder_build_lro(builder, init_lro_param);
- rss_tt = mlx5e_rx_res_rss_get_current_tt_config(res, tt);
- mlx5e_tir_builder_build_rss(builder, &res->rss_params.hash, &rss_tt, true);
+static void mlx5e_rx_res_rss_destroy_tirs(struct mlx5e_rx_res *res, bool inner)
+{
+ enum mlx5_traffic_types tt;
- err = mlx5e_tir_init(&res->rss[tt].inner_indir_tir, builder, res->mdev, true);
- if (err) {
- mlx5_core_warn(res->mdev, "Failed to create an inner indirect TIR: err = %d, tt = %d\n",
- err, tt);
- goto err_destroy_inner_tirs;
- }
+ for (tt = 0; tt < MLX5E_NUM_INDIR_TIRS; tt++)
+ mlx5e_rx_res_rss_destroy_tir(res, tt, inner);
+}
- mlx5e_tir_builder_clear(builder);
- }
+static int mlx5e_rx_res_rss_init(struct mlx5e_rx_res *res,
+ const struct mlx5e_lro_param *init_lro_param)
+{
+ bool inner_ft_support = res->features & MLX5E_RX_RES_FEATURE_INNER_FT;
+ int err;
- goto out;
+ err = mlx5e_rqt_init_direct(&res->indir_rqt, res->mdev, true, res->drop_rqn);
+ if (err)
+ return err;
-err_destroy_inner_tirs:
- max_tt = tt;
- for (tt = 0; tt < max_tt; tt++)
- mlx5e_tir_destroy(&res->rss[tt].inner_indir_tir);
+ err = mlx5e_rx_res_rss_create_tirs(res, init_lro_param, false);
+ if (err)
+ goto err_destroy_rqt;
+
+ if (inner_ft_support) {
+ err = mlx5e_rx_res_rss_create_tirs(res, init_lro_param, true);
+ if (err)
+ goto err_destroy_tirs;
+ }
+
+ return 0;
- tt = MLX5E_NUM_INDIR_TIRS;
err_destroy_tirs:
- max_tt = tt;
- for (tt = 0; tt < max_tt; tt++)
- mlx5e_tir_destroy(&res->rss[tt].indir_tir);
+ mlx5e_rx_res_rss_destroy_tirs(res, false);
+err_destroy_rqt:
mlx5e_rqt_destroy(&res->indir_rqt);
-out:
- mlx5e_tir_builder_free(builder);
-
return err;
}
@@ -337,14 +367,10 @@ out:
static void mlx5e_rx_res_rss_destroy(struct mlx5e_rx_res *res)
{
- enum mlx5_traffic_types tt;
-
- for (tt = 0; tt < MLX5E_NUM_INDIR_TIRS; tt++)
- mlx5e_tir_destroy(&res->rss[tt].indir_tir);
+ mlx5e_rx_res_rss_destroy_tirs(res, false);
if (res->features & MLX5E_RX_RES_FEATURE_INNER_FT)
- for (tt = 0; tt < MLX5E_NUM_INDIR_TIRS; tt++)
- mlx5e_tir_destroy(&res->rss[tt].inner_indir_tir);
+ mlx5e_rx_res_rss_destroy_tirs(res, true);
mlx5e_rqt_destroy(&res->indir_rqt);
}