Commit fc651ff9 authored by Tariq Toukan's avatar Tariq Toukan Committed by Saeed Mahameed

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: default avatarTariq Toukan <tariqt@nvidia.com>
Reviewed-by: default avatarMaxim Mikityanskiy <maximmi@nvidia.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
parent 6e5fea51
...@@ -117,84 +117,114 @@ static void mlx5e_rx_res_rss_params_init(struct mlx5e_rx_res *res, unsigned int ...@@ -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; mlx5e_rss_get_default_tt_config(tt).rx_hash_fields;
} }
static int mlx5e_rx_res_rss_init(struct mlx5e_rx_res *res, static void mlx5e_rx_res_rss_destroy_tir(struct mlx5e_rx_res *res,
const struct mlx5e_lro_param *init_lro_param) 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; 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; enum mlx5_traffic_types tt, max_tt;
struct mlx5e_tir_builder *builder; struct mlx5e_tir_builder *builder;
u32 indir_rqtn;
int err; int err;
builder = mlx5e_tir_builder_alloc(false); builder = mlx5e_tir_builder_alloc(false);
if (!builder) if (!builder)
return -ENOMEM; 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++) { for (tt = 0; tt < MLX5E_NUM_INDIR_TIRS; tt++) {
struct mlx5e_rss_params_traffic_type rss_tt; err = mlx5e_rx_res_rss_create_tir(res, builder, tt, init_lro_param, inner);
if (err)
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);
goto err_destroy_tirs; goto err_destroy_tirs;
}
mlx5e_tir_builder_clear(builder); mlx5e_tir_builder_clear(builder);
} }
if (!inner_ft_support) out:
mlx5e_tir_builder_free(builder);
return err;
err_destroy_tirs:
max_tt = tt;
for (tt = 0; tt < max_tt; tt++)
mlx5e_rx_res_rss_destroy_tir(res, tt, inner);
goto out; goto out;
}
for (tt = 0; tt < MLX5E_NUM_INDIR_TIRS; tt++) { static void mlx5e_rx_res_rss_destroy_tirs(struct mlx5e_rx_res *res, bool inner)
struct mlx5e_rss_params_traffic_type rss_tt; {
enum mlx5_traffic_types tt;
mlx5e_tir_builder_build_rqt(builder, res->mdev->mlx5e_res.hw_objs.td.tdn, for (tt = 0; tt < MLX5E_NUM_INDIR_TIRS; tt++)
indir_rqtn, inner_ft_support); mlx5e_rx_res_rss_destroy_tir(res, tt, inner);
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);
err = mlx5e_tir_init(&res->rss[tt].inner_indir_tir, builder, res->mdev, true); static int mlx5e_rx_res_rss_init(struct mlx5e_rx_res *res,
if (err) { const struct mlx5e_lro_param *init_lro_param)
mlx5_core_warn(res->mdev, "Failed to create an inner indirect TIR: err = %d, tt = %d\n", {
err, tt); bool inner_ft_support = res->features & MLX5E_RX_RES_FEATURE_INNER_FT;
goto err_destroy_inner_tirs; int err;
}
mlx5e_tir_builder_clear(builder); err = mlx5e_rqt_init_direct(&res->indir_rqt, res->mdev, true, res->drop_rqn);
} if (err)
return err;
goto out; err = mlx5e_rx_res_rss_create_tirs(res, init_lro_param, false);
if (err)
goto err_destroy_rqt;
err_destroy_inner_tirs: if (inner_ft_support) {
max_tt = tt; err = mlx5e_rx_res_rss_create_tirs(res, init_lro_param, true);
for (tt = 0; tt < max_tt; tt++) if (err)
mlx5e_tir_destroy(&res->rss[tt].inner_indir_tir); goto err_destroy_tirs;
}
return 0;
tt = MLX5E_NUM_INDIR_TIRS;
err_destroy_tirs: err_destroy_tirs:
max_tt = tt; mlx5e_rx_res_rss_destroy_tirs(res, false);
for (tt = 0; tt < max_tt; tt++)
mlx5e_tir_destroy(&res->rss[tt].indir_tir);
err_destroy_rqt:
mlx5e_rqt_destroy(&res->indir_rqt); mlx5e_rqt_destroy(&res->indir_rqt);
out:
mlx5e_tir_builder_free(builder);
return err; return err;
} }
...@@ -337,14 +367,10 @@ static int mlx5e_rx_res_ptp_init(struct mlx5e_rx_res *res) ...@@ -337,14 +367,10 @@ static int mlx5e_rx_res_ptp_init(struct mlx5e_rx_res *res)
static void mlx5e_rx_res_rss_destroy(struct mlx5e_rx_res *res) static void mlx5e_rx_res_rss_destroy(struct mlx5e_rx_res *res)
{ {
enum mlx5_traffic_types tt; mlx5e_rx_res_rss_destroy_tirs(res, false);
for (tt = 0; tt < MLX5E_NUM_INDIR_TIRS; tt++)
mlx5e_tir_destroy(&res->rss[tt].indir_tir);
if (res->features & MLX5E_RX_RES_FEATURE_INNER_FT) if (res->features & MLX5E_RX_RES_FEATURE_INNER_FT)
for (tt = 0; tt < MLX5E_NUM_INDIR_TIRS; tt++) mlx5e_rx_res_rss_destroy_tirs(res, true);
mlx5e_tir_destroy(&res->rss[tt].inner_indir_tir);
mlx5e_rqt_destroy(&res->indir_rqt); mlx5e_rqt_destroy(&res->indir_rqt);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment