Commit 42212d99 authored by Aya Levin's avatar Aya Levin Committed by Saeed Mahameed

net/mlx5e: Generalize direct-TIRs and direct-RQTs API

Add input parameter indicating the size of direct-TIRs/direct-RQTs array
to be created/destroyed. This allows next patches in the patch-set to
handle a single direct-TIR pointing to a direct-RQT with a single entry.
Signed-off-by: default avatarAya Levin <ayal@nvidia.com>
Reviewed-by: default avatarTariq Toukan <tariqt@nvidia.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
parent e078e8df
...@@ -1080,10 +1080,10 @@ int mlx5e_create_indirect_rqt(struct mlx5e_priv *priv); ...@@ -1080,10 +1080,10 @@ int mlx5e_create_indirect_rqt(struct mlx5e_priv *priv);
int mlx5e_create_indirect_tirs(struct mlx5e_priv *priv, bool inner_ttc); int mlx5e_create_indirect_tirs(struct mlx5e_priv *priv, bool inner_ttc);
void mlx5e_destroy_indirect_tirs(struct mlx5e_priv *priv); void mlx5e_destroy_indirect_tirs(struct mlx5e_priv *priv);
int mlx5e_create_direct_rqts(struct mlx5e_priv *priv, struct mlx5e_tir *tirs); 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); 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 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); void mlx5e_destroy_direct_tirs(struct mlx5e_priv *priv, struct mlx5e_tir *tirs, int n);
void mlx5e_destroy_rqt(struct mlx5e_priv *priv, struct mlx5e_rqt *rqt); void mlx5e_destroy_rqt(struct mlx5e_priv *priv, struct mlx5e_rqt *rqt);
int mlx5e_create_tis(struct mlx5_core_dev *mdev, void *in, u32 *tisn); int mlx5e_create_tis(struct mlx5_core_dev *mdev, void *in, u32 *tisn);
......
...@@ -2223,12 +2223,12 @@ int mlx5e_create_indirect_rqt(struct mlx5e_priv *priv) ...@@ -2223,12 +2223,12 @@ int mlx5e_create_indirect_rqt(struct mlx5e_priv *priv)
return err; return err;
} }
int mlx5e_create_direct_rqts(struct mlx5e_priv *priv, struct mlx5e_tir *tirs) int mlx5e_create_direct_rqts(struct mlx5e_priv *priv, struct mlx5e_tir *tirs, int n)
{ {
int err; int err;
int ix; int ix;
for (ix = 0; ix < priv->max_nch; ix++) { for (ix = 0; ix < n; ix++) {
err = mlx5e_create_rqt(priv, 1 /*size */, &tirs[ix].rqt); err = mlx5e_create_rqt(priv, 1 /*size */, &tirs[ix].rqt);
if (unlikely(err)) if (unlikely(err))
goto err_destroy_rqts; goto err_destroy_rqts;
...@@ -2244,11 +2244,11 @@ int mlx5e_create_direct_rqts(struct mlx5e_priv *priv, struct mlx5e_tir *tirs) ...@@ -2244,11 +2244,11 @@ int mlx5e_create_direct_rqts(struct mlx5e_priv *priv, struct mlx5e_tir *tirs)
return err; return err;
} }
void mlx5e_destroy_direct_rqts(struct mlx5e_priv *priv, struct mlx5e_tir *tirs) void mlx5e_destroy_direct_rqts(struct mlx5e_priv *priv, struct mlx5e_tir *tirs, int n)
{ {
int i; int i;
for (i = 0; i < priv->max_nch; i++) for (i = 0; i < n; i++)
mlx5e_destroy_rqt(priv, &tirs[i].rqt); mlx5e_destroy_rqt(priv, &tirs[i].rqt);
} }
...@@ -3249,7 +3249,7 @@ int mlx5e_create_indirect_tirs(struct mlx5e_priv *priv, bool inner_ttc) ...@@ -3249,7 +3249,7 @@ int mlx5e_create_indirect_tirs(struct mlx5e_priv *priv, bool inner_ttc)
return err; return err;
} }
int mlx5e_create_direct_tirs(struct mlx5e_priv *priv, struct mlx5e_tir *tirs) int mlx5e_create_direct_tirs(struct mlx5e_priv *priv, struct mlx5e_tir *tirs, int n)
{ {
struct mlx5e_tir *tir; struct mlx5e_tir *tir;
void *tirc; void *tirc;
...@@ -3263,7 +3263,7 @@ int mlx5e_create_direct_tirs(struct mlx5e_priv *priv, struct mlx5e_tir *tirs) ...@@ -3263,7 +3263,7 @@ int mlx5e_create_direct_tirs(struct mlx5e_priv *priv, struct mlx5e_tir *tirs)
if (!in) if (!in)
return -ENOMEM; return -ENOMEM;
for (ix = 0; ix < priv->max_nch; ix++) { for (ix = 0; ix < n; ix++) {
memset(in, 0, inlen); memset(in, 0, inlen);
tir = &tirs[ix]; tir = &tirs[ix];
tirc = MLX5_ADDR_OF(create_tir_in, in, ctx); tirc = MLX5_ADDR_OF(create_tir_in, in, ctx);
...@@ -3301,11 +3301,11 @@ void mlx5e_destroy_indirect_tirs(struct mlx5e_priv *priv) ...@@ -3301,11 +3301,11 @@ void mlx5e_destroy_indirect_tirs(struct mlx5e_priv *priv)
mlx5e_destroy_tir(priv->mdev, &priv->inner_indir_tir[i]); mlx5e_destroy_tir(priv->mdev, &priv->inner_indir_tir[i]);
} }
void mlx5e_destroy_direct_tirs(struct mlx5e_priv *priv, struct mlx5e_tir *tirs) void mlx5e_destroy_direct_tirs(struct mlx5e_priv *priv, struct mlx5e_tir *tirs, int n)
{ {
int i; int i;
for (i = 0; i < priv->max_nch; i++) for (i = 0; i < n; i++)
mlx5e_destroy_tir(priv->mdev, &tirs[i]); mlx5e_destroy_tir(priv->mdev, &tirs[i]);
} }
...@@ -4901,6 +4901,7 @@ static void mlx5e_nic_cleanup(struct mlx5e_priv *priv) ...@@ -4901,6 +4901,7 @@ static void mlx5e_nic_cleanup(struct mlx5e_priv *priv)
static int mlx5e_init_nic_rx(struct mlx5e_priv *priv) static int mlx5e_init_nic_rx(struct mlx5e_priv *priv)
{ {
struct mlx5_core_dev *mdev = priv->mdev; struct mlx5_core_dev *mdev = priv->mdev;
u16 max_nch = priv->max_nch;
int err; int err;
mlx5e_create_q_counters(priv); mlx5e_create_q_counters(priv);
...@@ -4915,7 +4916,7 @@ static int mlx5e_init_nic_rx(struct mlx5e_priv *priv) ...@@ -4915,7 +4916,7 @@ static int mlx5e_init_nic_rx(struct mlx5e_priv *priv)
if (err) if (err)
goto err_close_drop_rq; goto err_close_drop_rq;
err = mlx5e_create_direct_rqts(priv, priv->direct_tir); err = mlx5e_create_direct_rqts(priv, priv->direct_tir, max_nch);
if (err) if (err)
goto err_destroy_indirect_rqts; goto err_destroy_indirect_rqts;
...@@ -4923,15 +4924,15 @@ static int mlx5e_init_nic_rx(struct mlx5e_priv *priv) ...@@ -4923,15 +4924,15 @@ static int mlx5e_init_nic_rx(struct mlx5e_priv *priv)
if (err) if (err)
goto err_destroy_direct_rqts; goto err_destroy_direct_rqts;
err = mlx5e_create_direct_tirs(priv, priv->direct_tir); err = mlx5e_create_direct_tirs(priv, priv->direct_tir, max_nch);
if (err) if (err)
goto err_destroy_indirect_tirs; goto err_destroy_indirect_tirs;
err = mlx5e_create_direct_rqts(priv, priv->xsk_tir); err = mlx5e_create_direct_rqts(priv, priv->xsk_tir, max_nch);
if (unlikely(err)) if (unlikely(err))
goto err_destroy_direct_tirs; goto err_destroy_direct_tirs;
err = mlx5e_create_direct_tirs(priv, priv->xsk_tir); err = mlx5e_create_direct_tirs(priv, priv->xsk_tir, max_nch);
if (unlikely(err)) if (unlikely(err))
goto err_destroy_xsk_rqts; goto err_destroy_xsk_rqts;
...@@ -4960,15 +4961,15 @@ static int mlx5e_init_nic_rx(struct mlx5e_priv *priv) ...@@ -4960,15 +4961,15 @@ static int mlx5e_init_nic_rx(struct mlx5e_priv *priv)
err_destroy_flow_steering: err_destroy_flow_steering:
mlx5e_destroy_flow_steering(priv); mlx5e_destroy_flow_steering(priv);
err_destroy_xsk_tirs: err_destroy_xsk_tirs:
mlx5e_destroy_direct_tirs(priv, priv->xsk_tir); mlx5e_destroy_direct_tirs(priv, priv->xsk_tir, max_nch);
err_destroy_xsk_rqts: err_destroy_xsk_rqts:
mlx5e_destroy_direct_rqts(priv, priv->xsk_tir); mlx5e_destroy_direct_rqts(priv, priv->xsk_tir, max_nch);
err_destroy_direct_tirs: err_destroy_direct_tirs:
mlx5e_destroy_direct_tirs(priv, priv->direct_tir); mlx5e_destroy_direct_tirs(priv, priv->direct_tir, max_nch);
err_destroy_indirect_tirs: err_destroy_indirect_tirs:
mlx5e_destroy_indirect_tirs(priv); mlx5e_destroy_indirect_tirs(priv);
err_destroy_direct_rqts: err_destroy_direct_rqts:
mlx5e_destroy_direct_rqts(priv, priv->direct_tir); mlx5e_destroy_direct_rqts(priv, priv->direct_tir, max_nch);
err_destroy_indirect_rqts: err_destroy_indirect_rqts:
mlx5e_destroy_rqt(priv, &priv->indir_rqt); mlx5e_destroy_rqt(priv, &priv->indir_rqt);
err_close_drop_rq: err_close_drop_rq:
...@@ -4980,14 +4981,16 @@ static int mlx5e_init_nic_rx(struct mlx5e_priv *priv) ...@@ -4980,14 +4981,16 @@ static int mlx5e_init_nic_rx(struct mlx5e_priv *priv)
static void mlx5e_cleanup_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_accel_cleanup_rx(priv);
mlx5e_tc_nic_cleanup(priv); mlx5e_tc_nic_cleanup(priv);
mlx5e_destroy_flow_steering(priv); mlx5e_destroy_flow_steering(priv);
mlx5e_destroy_direct_tirs(priv, priv->xsk_tir); mlx5e_destroy_direct_tirs(priv, priv->xsk_tir, max_nch);
mlx5e_destroy_direct_rqts(priv, priv->xsk_tir); mlx5e_destroy_direct_rqts(priv, priv->xsk_tir, max_nch);
mlx5e_destroy_direct_tirs(priv, priv->direct_tir); mlx5e_destroy_direct_tirs(priv, priv->direct_tir, max_nch);
mlx5e_destroy_indirect_tirs(priv); mlx5e_destroy_indirect_tirs(priv);
mlx5e_destroy_direct_rqts(priv, priv->direct_tir); mlx5e_destroy_direct_rqts(priv, priv->direct_tir, max_nch);
mlx5e_destroy_rqt(priv, &priv->indir_rqt); mlx5e_destroy_rqt(priv, &priv->indir_rqt);
mlx5e_close_drop_rq(&priv->drop_rq); mlx5e_close_drop_rq(&priv->drop_rq);
mlx5e_destroy_q_counters(priv); mlx5e_destroy_q_counters(priv);
......
...@@ -753,6 +753,7 @@ int mlx5e_rep_bond_update(struct mlx5e_priv *priv, bool cleanup) ...@@ -753,6 +753,7 @@ int mlx5e_rep_bond_update(struct mlx5e_priv *priv, bool cleanup)
static int mlx5e_init_rep_rx(struct mlx5e_priv *priv) static int mlx5e_init_rep_rx(struct mlx5e_priv *priv)
{ {
struct mlx5_core_dev *mdev = priv->mdev; struct mlx5_core_dev *mdev = priv->mdev;
u16 max_nch = priv->max_nch;
int err; int err;
mlx5e_init_l2_addr(priv); mlx5e_init_l2_addr(priv);
...@@ -767,7 +768,7 @@ static int mlx5e_init_rep_rx(struct mlx5e_priv *priv) ...@@ -767,7 +768,7 @@ static int mlx5e_init_rep_rx(struct mlx5e_priv *priv)
if (err) if (err)
goto err_close_drop_rq; goto err_close_drop_rq;
err = mlx5e_create_direct_rqts(priv, priv->direct_tir); err = mlx5e_create_direct_rqts(priv, priv->direct_tir, max_nch);
if (err) if (err)
goto err_destroy_indirect_rqts; goto err_destroy_indirect_rqts;
...@@ -775,7 +776,7 @@ static int mlx5e_init_rep_rx(struct mlx5e_priv *priv) ...@@ -775,7 +776,7 @@ static int mlx5e_init_rep_rx(struct mlx5e_priv *priv)
if (err) if (err)
goto err_destroy_direct_rqts; goto err_destroy_direct_rqts;
err = mlx5e_create_direct_tirs(priv, priv->direct_tir); err = mlx5e_create_direct_tirs(priv, priv->direct_tir, max_nch);
if (err) if (err)
goto err_destroy_indirect_tirs; goto err_destroy_indirect_tirs;
...@@ -800,11 +801,11 @@ static int mlx5e_init_rep_rx(struct mlx5e_priv *priv) ...@@ -800,11 +801,11 @@ static int mlx5e_init_rep_rx(struct mlx5e_priv *priv)
err_destroy_ttc_table: err_destroy_ttc_table:
mlx5e_destroy_ttc_table(priv, &priv->fs.ttc); mlx5e_destroy_ttc_table(priv, &priv->fs.ttc);
err_destroy_direct_tirs: err_destroy_direct_tirs:
mlx5e_destroy_direct_tirs(priv, priv->direct_tir); mlx5e_destroy_direct_tirs(priv, priv->direct_tir, max_nch);
err_destroy_indirect_tirs: err_destroy_indirect_tirs:
mlx5e_destroy_indirect_tirs(priv); mlx5e_destroy_indirect_tirs(priv);
err_destroy_direct_rqts: err_destroy_direct_rqts:
mlx5e_destroy_direct_rqts(priv, priv->direct_tir); mlx5e_destroy_direct_rqts(priv, priv->direct_tir, max_nch);
err_destroy_indirect_rqts: err_destroy_indirect_rqts:
mlx5e_destroy_rqt(priv, &priv->indir_rqt); mlx5e_destroy_rqt(priv, &priv->indir_rqt);
err_close_drop_rq: err_close_drop_rq:
...@@ -814,13 +815,15 @@ static int mlx5e_init_rep_rx(struct mlx5e_priv *priv) ...@@ -814,13 +815,15 @@ static int mlx5e_init_rep_rx(struct mlx5e_priv *priv)
static void mlx5e_cleanup_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); mlx5e_ethtool_cleanup_steering(priv);
rep_vport_rx_rule_destroy(priv); rep_vport_rx_rule_destroy(priv);
mlx5e_destroy_rep_root_ft(priv); mlx5e_destroy_rep_root_ft(priv);
mlx5e_destroy_ttc_table(priv, &priv->fs.ttc); mlx5e_destroy_ttc_table(priv, &priv->fs.ttc);
mlx5e_destroy_direct_tirs(priv, priv->direct_tir); mlx5e_destroy_direct_tirs(priv, priv->direct_tir, max_nch);
mlx5e_destroy_indirect_tirs(priv); mlx5e_destroy_indirect_tirs(priv);
mlx5e_destroy_direct_rqts(priv, priv->direct_tir); mlx5e_destroy_direct_rqts(priv, priv->direct_tir, max_nch);
mlx5e_destroy_rqt(priv, &priv->indir_rqt); mlx5e_destroy_rqt(priv, &priv->indir_rqt);
mlx5e_close_drop_rq(&priv->drop_rq); mlx5e_close_drop_rq(&priv->drop_rq);
} }
......
...@@ -373,6 +373,7 @@ static void mlx5i_destroy_flow_steering(struct mlx5e_priv *priv) ...@@ -373,6 +373,7 @@ static void mlx5i_destroy_flow_steering(struct mlx5e_priv *priv)
static int mlx5i_init_rx(struct mlx5e_priv *priv) static int mlx5i_init_rx(struct mlx5e_priv *priv)
{ {
struct mlx5_core_dev *mdev = priv->mdev; struct mlx5_core_dev *mdev = priv->mdev;
u16 max_nch = priv->max_nch;
int err; int err;
mlx5e_create_q_counters(priv); mlx5e_create_q_counters(priv);
...@@ -387,7 +388,7 @@ static int mlx5i_init_rx(struct mlx5e_priv *priv) ...@@ -387,7 +388,7 @@ static int mlx5i_init_rx(struct mlx5e_priv *priv)
if (err) if (err)
goto err_close_drop_rq; goto err_close_drop_rq;
err = mlx5e_create_direct_rqts(priv, priv->direct_tir); err = mlx5e_create_direct_rqts(priv, priv->direct_tir, max_nch);
if (err) if (err)
goto err_destroy_indirect_rqts; goto err_destroy_indirect_rqts;
...@@ -395,7 +396,7 @@ static int mlx5i_init_rx(struct mlx5e_priv *priv) ...@@ -395,7 +396,7 @@ static int mlx5i_init_rx(struct mlx5e_priv *priv)
if (err) if (err)
goto err_destroy_direct_rqts; goto err_destroy_direct_rqts;
err = mlx5e_create_direct_tirs(priv, priv->direct_tir); err = mlx5e_create_direct_tirs(priv, priv->direct_tir, max_nch);
if (err) if (err)
goto err_destroy_indirect_tirs; goto err_destroy_indirect_tirs;
...@@ -406,11 +407,11 @@ static int mlx5i_init_rx(struct mlx5e_priv *priv) ...@@ -406,11 +407,11 @@ static int mlx5i_init_rx(struct mlx5e_priv *priv)
return 0; return 0;
err_destroy_direct_tirs: err_destroy_direct_tirs:
mlx5e_destroy_direct_tirs(priv, priv->direct_tir); mlx5e_destroy_direct_tirs(priv, priv->direct_tir, max_nch);
err_destroy_indirect_tirs: err_destroy_indirect_tirs:
mlx5e_destroy_indirect_tirs(priv); mlx5e_destroy_indirect_tirs(priv);
err_destroy_direct_rqts: err_destroy_direct_rqts:
mlx5e_destroy_direct_rqts(priv, priv->direct_tir); mlx5e_destroy_direct_rqts(priv, priv->direct_tir, max_nch);
err_destroy_indirect_rqts: err_destroy_indirect_rqts:
mlx5e_destroy_rqt(priv, &priv->indir_rqt); mlx5e_destroy_rqt(priv, &priv->indir_rqt);
err_close_drop_rq: err_close_drop_rq:
...@@ -422,10 +423,12 @@ static int mlx5i_init_rx(struct mlx5e_priv *priv) ...@@ -422,10 +423,12 @@ static int mlx5i_init_rx(struct mlx5e_priv *priv)
static void mlx5i_cleanup_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); mlx5i_destroy_flow_steering(priv);
mlx5e_destroy_direct_tirs(priv, priv->direct_tir); mlx5e_destroy_direct_tirs(priv, priv->direct_tir, max_nch);
mlx5e_destroy_indirect_tirs(priv); mlx5e_destroy_indirect_tirs(priv);
mlx5e_destroy_direct_rqts(priv, priv->direct_tir); mlx5e_destroy_direct_rqts(priv, priv->direct_tir, max_nch);
mlx5e_destroy_rqt(priv, &priv->indir_rqt); mlx5e_destroy_rqt(priv, &priv->indir_rqt);
mlx5e_close_drop_rq(&priv->drop_rq); mlx5e_close_drop_rq(&priv->drop_rq);
mlx5e_destroy_q_counters(priv); mlx5e_destroy_q_counters(priv);
......
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