summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhselasky <hselasky@FreeBSD.org>2016-09-23 08:23:57 +0000
committerhselasky <hselasky@FreeBSD.org>2016-09-23 08:23:57 +0000
commit70914e84195095a8c8ace743ed82cb8b57f1c7a0 (patch)
tree7822a034890e8f0c9e6f5da47e7a00fb5c70ca13
parentb92c3f857abcfb96bc4c61370fb00ceaf7cc9cb5 (diff)
downloadFreeBSD-src-70914e84195095a8c8ace743ed82cb8b57f1c7a0.zip
FreeBSD-src-70914e84195095a8c8ace743ed82cb8b57f1c7a0.tar.gz
MFC r305873:
mlx5en: Factor out common sendqueue code for use with rate limiting SQs. Try to reuse code to setup sendqueues when possible by making some static functions global. Further split the mlx5e_close_sq_wait() function to separate out reusable parts. Sponsored by: Mellanox Technologies
-rw-r--r--sys/dev/mlx5/mlx5_en/en.h6
-rw-r--r--sys/dev/mlx5/mlx5_en/mlx5_en_main.c27
2 files changed, 23 insertions, 10 deletions
diff --git a/sys/dev/mlx5/mlx5_en/en.h b/sys/dev/mlx5/mlx5_en/en.h
index ad23164..ae449c2 100644
--- a/sys/dev/mlx5/mlx5_en/en.h
+++ b/sys/dev/mlx5/mlx5_en/en.h
@@ -812,5 +812,11 @@ int mlx5e_refresh_channel_params(struct mlx5e_priv *);
int mlx5e_open_cq(struct mlx5e_priv *, struct mlx5e_cq_param *,
struct mlx5e_cq *, mlx5e_cq_comp_t *, int eq_ix);
void mlx5e_close_cq(struct mlx5e_cq *);
+void mlx5e_free_sq_db(struct mlx5e_sq *);
+int mlx5e_alloc_sq_db(struct mlx5e_sq *);
+int mlx5e_enable_sq(struct mlx5e_sq *, struct mlx5e_sq_param *, int tis_num);
+int mlx5e_modify_sq(struct mlx5e_sq *, int curr_state, int next_state);
+void mlx5e_disable_sq(struct mlx5e_sq *);
+void mlx5e_drain_sq(struct mlx5e_sq *);
#endif /* _MLX5_EN_H_ */
diff --git a/sys/dev/mlx5/mlx5_en/mlx5_en_main.c b/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
index 8b0e368..28007f3 100644
--- a/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
+++ b/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
@@ -873,7 +873,7 @@ mlx5e_close_rq_wait(struct mlx5e_rq *rq)
mlx5e_destroy_rq(rq);
}
-static void
+void
mlx5e_free_sq_db(struct mlx5e_sq *sq)
{
int wq_sz = mlx5_wq_cyc_get_size(&sq->wq);
@@ -884,7 +884,7 @@ mlx5e_free_sq_db(struct mlx5e_sq *sq)
free(sq->mbuf, M_MLX5EN);
}
-static int
+int
mlx5e_alloc_sq_db(struct mlx5e_sq *sq)
{
int wq_sz = mlx5_wq_cyc_get_size(&sq->wq);
@@ -1033,8 +1033,9 @@ mlx5e_destroy_sq(struct mlx5e_sq *sq)
buf_ring_free(sq->br, M_MLX5EN);
}
-static int
-mlx5e_enable_sq(struct mlx5e_sq *sq, struct mlx5e_sq_param *param)
+int
+mlx5e_enable_sq(struct mlx5e_sq *sq, struct mlx5e_sq_param *param,
+ int tis_num)
{
void *in;
void *sqc;
@@ -1053,7 +1054,7 @@ mlx5e_enable_sq(struct mlx5e_sq *sq, struct mlx5e_sq_param *param)
memcpy(sqc, param->sqc, sizeof(param->sqc));
- MLX5_SET(sqc, sqc, tis_num_0, sq->priv->tisn[sq->tc]);
+ MLX5_SET(sqc, sqc, tis_num_0, tis_num);
MLX5_SET(sqc, sqc, cqn, sq->cq.mcq.cqn);
MLX5_SET(sqc, sqc, state, MLX5_SQC_STATE_RST);
MLX5_SET(sqc, sqc, tis_lst_sz, 1);
@@ -1075,7 +1076,7 @@ mlx5e_enable_sq(struct mlx5e_sq *sq, struct mlx5e_sq_param *param)
return (err);
}
-static int
+int
mlx5e_modify_sq(struct mlx5e_sq *sq, int curr_state, int next_state)
{
void *in;
@@ -1101,7 +1102,7 @@ mlx5e_modify_sq(struct mlx5e_sq *sq, int curr_state, int next_state)
return (err);
}
-static void
+void
mlx5e_disable_sq(struct mlx5e_sq *sq)
{
@@ -1120,7 +1121,7 @@ mlx5e_open_sq(struct mlx5e_channel *c,
if (err)
return (err);
- err = mlx5e_enable_sq(sq, param);
+ err = mlx5e_enable_sq(sq, param, c->priv->tisn[tc]);
if (err)
goto err_destroy_sq;
@@ -1196,8 +1197,8 @@ mlx5e_sq_cev_timeout(void *arg)
callout_reset_curcpu(&sq->cev_callout, hz, mlx5e_sq_cev_timeout, sq);
}
-static void
-mlx5e_close_sq_wait(struct mlx5e_sq *sq)
+void
+mlx5e_drain_sq(struct mlx5e_sq *sq)
{
mtx_lock(&sq->lock);
@@ -1224,7 +1225,13 @@ mlx5e_close_sq_wait(struct mlx5e_sq *sq)
mtx_lock(&sq->lock);
}
mtx_unlock(&sq->lock);
+}
+
+static void
+mlx5e_close_sq_wait(struct mlx5e_sq *sq)
+{
+ mlx5e_drain_sq(sq);
mlx5e_disable_sq(sq);
mlx5e_destroy_sq(sq);
}
OpenPOWER on IntegriCloud