diff mbox series

[RFC,3/3] regex/mlx5: refactor queue creation in mlx5 add support to compress and regex drivers in Bluefield3

Message ID 20210818151441.12400-4-rzidane@nvidia.com (mailing list archive)
State Superseded
Delegated to: Thomas Monjalon
Headers show
Series mlx5: replaced hardware queue object | expand

Checks

Context Check Description
ci/intel-Testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/checkpatch warning coding style issues

Commit Message

Raja Zidane Aug. 18, 2021, 3:14 p.m. UTC
Signed-off-by: Raja Zidane <rzidane@nvidia.com>
---
 drivers/common/mlx5/mlx5_common_devx.c  | 28 ++++++++++++
 drivers/common/mlx5/mlx5_common_devx.h  |  3 ++
 drivers/common/mlx5/version.map         |  1 +
 drivers/compress/mlx5/mlx5_compress.c   | 31 +------------
 drivers/crypto/mlx5/mlx5_crypto.c       | 30 +------------
 drivers/regex/mlx5/mlx5_regex.h         |  6 +--
 drivers/regex/mlx5/mlx5_regex_control.c | 60 ++++++++++++-------------
 7 files changed, 65 insertions(+), 94 deletions(-)
diff mbox series

Patch

diff --git a/drivers/common/mlx5/mlx5_common_devx.c b/drivers/common/mlx5/mlx5_common_devx.c
index 640fe3bbb9..0baf0831e8 100644
--- a/drivers/common/mlx5/mlx5_common_devx.c
+++ b/drivers/common/mlx5/mlx5_common_devx.c
@@ -496,3 +496,31 @@  mlx5_devx_rq_create(void *ctx, struct mlx5_devx_rq *rq_obj, uint32_t wqe_size,
 	return -rte_errno;
 }
 
+int
+mlx5_devx_qp2rts(struct mlx5_devx_qp *qp)
+{
+	/*
+	 * In Order to configure self loopback, when calling these functions the
+	 * remote QP id that is used is the id of the same QP.
+	 */
+	if (mlx5_devx_cmd_modify_qp_state(qp->qp, MLX5_CMD_OP_RST2INIT_QP,
+					  qp->qp->id)) {
+		DRV_LOG(ERR, "Failed to modify QP to INIT state(%u).",
+			rte_errno);
+		return -1;
+	}
+	if (mlx5_devx_cmd_modify_qp_state(qp->qp, MLX5_CMD_OP_INIT2RTR_QP,
+					  qp->qp->id)) {
+		DRV_LOG(ERR, "Failed to modify QP to RTR state(%u).",
+			rte_errno);
+		return -1;
+	}
+	if (mlx5_devx_cmd_modify_qp_state(qp->qp, MLX5_CMD_OP_RTR2RTS_QP,
+					  qp->qp->id)) {
+		DRV_LOG(ERR, "Failed to modify QP to RTS state(%u).",
+			rte_errno);
+		return -1;
+	}
+	return 0;
+}
+
diff --git a/drivers/common/mlx5/mlx5_common_devx.h b/drivers/common/mlx5/mlx5_common_devx.h
index b05260b401..81036f92ff 100644
--- a/drivers/common/mlx5/mlx5_common_devx.h
+++ b/drivers/common/mlx5/mlx5_common_devx.h
@@ -87,4 +87,7 @@  int mlx5_devx_rq_create(void *ctx, struct mlx5_devx_rq *rq_obj,
 			uint32_t wqe_size, uint16_t log_wqbb_n,
 			struct mlx5_devx_create_rq_attr *attr, int socket);
 
+__rte_internal
+int mlx5_devx_qp2rts(struct mlx5_devx_qp *qp);
+
 #endif /* RTE_PMD_MLX5_COMMON_DEVX_H_ */
diff --git a/drivers/common/mlx5/version.map b/drivers/common/mlx5/version.map
index 9487f787b6..e61673dcb0 100644
--- a/drivers/common/mlx5/version.map
+++ b/drivers/common/mlx5/version.map
@@ -73,6 +73,7 @@  INTERNAL {
 	mlx5_devx_sq_destroy;
 	mlx5_devx_qp_create;
 	mlx5_devx_qp_destroy;
+	mlx5_devx_qp2rts;
 
 	mlx5_free;
 
diff --git a/drivers/compress/mlx5/mlx5_compress.c b/drivers/compress/mlx5/mlx5_compress.c
index 05e75adb1c..9cf75a9193 100644
--- a/drivers/compress/mlx5/mlx5_compress.c
+++ b/drivers/compress/mlx5/mlx5_compress.c
@@ -174,35 +174,6 @@  mlx5_compress_init_qp(struct mlx5_compress_qp *qp)
 	}
 }
 
-static int
-mlx5_compress_qp2rts(struct mlx5_compress_qp *qp)
-{
-	/*
-	 * In Order to configure self loopback, when calling these functions the
-	 * remote QP id that is used is the id of the same QP.
-	 */
-	if (mlx5_devx_cmd_modify_qp_state(qp->qp.qp, MLX5_CMD_OP_RST2INIT_QP,
-					  qp->qp.qp->id)) {
-		DRV_LOG(ERR, "Failed to modify QP to INIT state(%u).",
-			rte_errno);
-		return -1;
-	}
-	if (mlx5_devx_cmd_modify_qp_state(qp->qp.qp, MLX5_CMD_OP_INIT2RTR_QP,
-					  qp->qp.qp->id)) {
-		DRV_LOG(ERR, "Failed to modify QP to RTR state(%u).",
-			rte_errno);
-		return -1;
-	}
-	if (mlx5_devx_cmd_modify_qp_state(qp->qp.qp, MLX5_CMD_OP_RTR2RTS_QP,
-					  qp->qp.qp->id)) {
-		DRV_LOG(ERR, "Failed to modify QP to RTS state(%u).",
-			rte_errno);
-		return -1;
-	}
-	return 0;
-}
-
-
 static int
 mlx5_compress_qp_setup(struct rte_compressdev *dev, uint16_t qp_id,
 		       uint32_t max_inflight_ops, int socket_id)
@@ -277,7 +248,7 @@  mlx5_compress_qp_setup(struct rte_compressdev *dev, uint16_t qp_id,
 		DRV_LOG(ERR, "Failed to create QP.");
 		goto err;
 	}
-	ret = mlx5_compress_qp2rts(qp);
+	ret = mlx5_devx_qp2rts(&qp->qp);
 	if(ret) {
 		goto err;
 	}
diff --git a/drivers/crypto/mlx5/mlx5_crypto.c b/drivers/crypto/mlx5/mlx5_crypto.c
index c66a3a7add..94023e4844 100644
--- a/drivers/crypto/mlx5/mlx5_crypto.c
+++ b/drivers/crypto/mlx5/mlx5_crypto.c
@@ -270,34 +270,6 @@  mlx5_crypto_queue_pair_release(struct rte_cryptodev *dev, uint16_t qp_id)
 	return 0;
 }
 
-static int
-mlx5_crypto_qp2rts(struct mlx5_crypto_qp *qp)
-{
-	/*
-	 * In Order to configure self loopback, when calling these functions the
-	 * remote QP id that is used is the id of the same QP.
-	 */
-	if (mlx5_devx_cmd_modify_qp_state(qp->qp_obj.qp, MLX5_CMD_OP_RST2INIT_QP,
-					  qp->qp_obj.qp->id)) {
-		DRV_LOG(ERR, "Failed to modify QP to INIT state(%u).",
-			rte_errno);
-		return -1;
-	}
-	if (mlx5_devx_cmd_modify_qp_state(qp->qp_obj.qp, MLX5_CMD_OP_INIT2RTR_QP,
-					  qp->qp_obj.qp->id)) {
-		DRV_LOG(ERR, "Failed to modify QP to RTR state(%u).",
-			rte_errno);
-		return -1;
-	}
-	if (mlx5_devx_cmd_modify_qp_state(qp->qp_obj.qp, MLX5_CMD_OP_RTR2RTS_QP,
-					  qp->qp_obj.qp->id)) {
-		DRV_LOG(ERR, "Failed to modify QP to RTS state(%u).",
-			rte_errno);
-		return -1;
-	}
-	return 0;
-}
-
 static __rte_noinline uint32_t
 mlx5_crypto_get_block_size(struct rte_crypto_op *op)
 {
@@ -692,7 +664,7 @@  mlx5_crypto_queue_pair_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 		goto error;
 	}
 	qp->mr_ctrl.dev_gen_ptr = &priv->mr_scache.dev_gen;
-	if (mlx5_crypto_qp2rts(qp))
+	if (mlx5_devx_qp2rts(&qp->qp_obj))
 		goto error;
 	qp->mkey = (struct mlx5_devx_obj **)RTE_ALIGN((uintptr_t)(qp + 1),
 							   RTE_CACHE_LINE_SIZE);
diff --git a/drivers/regex/mlx5/mlx5_regex.h b/drivers/regex/mlx5/mlx5_regex.h
index 514f3408f9..41ed58a6af 100644
--- a/drivers/regex/mlx5/mlx5_regex.h
+++ b/drivers/regex/mlx5/mlx5_regex.h
@@ -17,9 +17,9 @@ 
 #include "mlx5_rxp.h"
 #include "mlx5_regex_utils.h"
 
-struct mlx5_regex_sq {
+struct mlx5_regex_inner_qp {
 	uint16_t log_nb_desc; /* Log 2 number of desc for this object. */
-	struct mlx5_devx_sq sq_obj; /* The SQ DevX object. */
+	struct mlx5_devx_qp qp_obj; /* The QP DevX object. */
 	size_t pi, db_pi;
 	size_t ci;
 	uint32_t sqn;
@@ -34,7 +34,7 @@  struct mlx5_regex_cq {
 struct mlx5_regex_qp {
 	uint32_t flags; /* QP user flags. */
 	uint32_t nb_desc; /* Total number of desc for this qp. */
-	struct mlx5_regex_sq *sqs; /* Pointer to sq array. */
+	struct mlx5_regex_inner_qp *qps; /* Pointer to qp array. */
 	uint16_t nb_obj; /* Number of sq objects. */
 	struct mlx5_regex_cq cq; /* CQ struct. */
 	uint32_t free_sqs;
diff --git a/drivers/regex/mlx5/mlx5_regex_control.c b/drivers/regex/mlx5/mlx5_regex_control.c
index 8ce2dabb55..353d6aec97 100644
--- a/drivers/regex/mlx5/mlx5_regex_control.c
+++ b/drivers/regex/mlx5/mlx5_regex_control.c
@@ -106,12 +106,12 @@  regex_ctrl_create_cq(struct mlx5_regex_priv *priv, struct mlx5_regex_cq *cq)
  *   0 on success, a negative errno value otherwise and rte_errno is set.
  */
 static int
-regex_ctrl_destroy_sq(struct mlx5_regex_qp *qp, uint16_t q_ind)
+regex_ctrl_destroy_inner_qp(struct mlx5_regex_qp *qp, uint16_t q_ind)
 {
-	struct mlx5_regex_sq *sq = &qp->sqs[q_ind];
+	struct mlx5_regex_inner_qp *qp_obj = &qp->qps[q_ind];
 
-	mlx5_devx_sq_destroy(&sq->sq_obj);
-	memset(sq, 0, sizeof(*sq));
+	mlx5_devx_qp_destroy(&qp_obj->qp_obj);
+	memset(qp, 0, sizeof(*qp));
 	return 0;
 }
 
@@ -131,45 +131,41 @@  regex_ctrl_destroy_sq(struct mlx5_regex_qp *qp, uint16_t q_ind)
  *   0 on success, a negative errno value otherwise and rte_errno is set.
  */
 static int
-regex_ctrl_create_sq(struct mlx5_regex_priv *priv, struct mlx5_regex_qp *qp,
+regex_ctrl_create_inner_qp(struct mlx5_regex_priv *priv, struct mlx5_regex_qp *qp,
 		     uint16_t q_ind, uint16_t log_nb_desc)
 {
 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
-	struct mlx5_devx_create_sq_attr attr = {
-		.user_index = q_ind,
+	struct mlx5_devx_qp_attr attr = {
 		.cqn = qp->cq.cq_obj.cq->id,
-		.wq_attr = (struct mlx5_devx_wq_attr){
-			.uar_page = priv->uar->page_id,
-		},
+		.uar_index = priv->uar->page_id,
 		.ts_format = mlx5_ts_format_conv(priv->sq_ts_format),
 	};
-	struct mlx5_devx_modify_sq_attr modify_attr = {
-		.state = MLX5_SQC_STATE_RDY,
-	};
-	struct mlx5_regex_sq *sq = &qp->sqs[q_ind];
+	struct mlx5_regex_inner_qp *qp_obj = &qp->qps[q_ind];
 	uint32_t pd_num = 0;
 	int ret;
 
-	sq->log_nb_desc = log_nb_desc;
-	sq->sqn = q_ind;
-	sq->ci = 0;
-	sq->pi = 0;
+	qp_obj->log_nb_desc = log_nb_desc;
+	qp_obj->sqn = q_ind;
+	qp_obj->ci = 0;
+	qp_obj->pi = 0;
 	ret = regex_get_pdn(priv->pd, &pd_num);
 	if (ret)
 		return ret;
-	attr.wq_attr.pd = pd_num;
-	ret = mlx5_devx_sq_create(priv->ctx, &sq->sq_obj,
+	attr.pd = pd_num;
+	attr.rq_size = 0;
+	attr.sq_size = 1 << log_nb_desc;
+	ret = mlx5_devx_qp_create(priv->ctx, &qp_obj->qp_obj,
 			MLX5_REGEX_WQE_LOG_NUM(priv->has_umr, log_nb_desc),
 			&attr, SOCKET_ID_ANY);
 	if (ret) {
-		DRV_LOG(ERR, "Can't create SQ object.");
+		DRV_LOG(ERR, "Can't create QP object.");
 		rte_errno = ENOMEM;
 		return -rte_errno;
 	}
-	ret = mlx5_devx_cmd_modify_sq(sq->sq_obj.sq, &modify_attr);
+	ret = mlx5_devx_qp2rts(&qp_obj->qp_obj);
 	if (ret) {
-		DRV_LOG(ERR, "Can't change SQ state to ready.");
-		regex_ctrl_destroy_sq(qp, q_ind);
+		DRV_LOG(ERR, "Can't change QP state to RTS.");
+		regex_ctrl_destroy_inner_qp(qp, q_ind);
 		rte_errno = ENOMEM;
 		return -rte_errno;
 	}
@@ -224,10 +220,10 @@  mlx5_regex_qp_setup(struct rte_regexdev *dev, uint16_t qp_ind,
 			(1 << MLX5_REGEX_WQE_LOG_NUM(priv->has_umr, log_desc));
 	else
 		qp->nb_obj = 1;
-	qp->sqs = rte_malloc(NULL,
-			     qp->nb_obj * sizeof(struct mlx5_regex_sq), 64);
-	if (!qp->sqs) {
-		DRV_LOG(ERR, "Can't allocate sq array memory.");
+	qp->qps = rte_malloc(NULL,
+			     qp->nb_obj * sizeof(struct mlx5_regex_inner_qp), 64);
+	if (!qp->qps) {
+		DRV_LOG(ERR, "Can't allocate qp array memory.");
 		rte_errno = ENOMEM;
 		return -rte_errno;
 	}
@@ -238,9 +234,9 @@  mlx5_regex_qp_setup(struct rte_regexdev *dev, uint16_t qp_ind,
 		goto err_cq;
 	}
 	for (i = 0; i < qp->nb_obj; i++) {
-		ret = regex_ctrl_create_sq(priv, qp, i, log_desc);
+		ret = regex_ctrl_create_inner_qp(priv, qp, i, log_desc);
 		if (ret) {
-			DRV_LOG(ERR, "Can't create sq.");
+			DRV_LOG(ERR, "Can't create qp object.");
 			goto err_btree;
 		}
 		nb_sq_config++;
@@ -266,9 +262,9 @@  mlx5_regex_qp_setup(struct rte_regexdev *dev, uint16_t qp_ind,
 	mlx5_mr_btree_free(&qp->mr_ctrl.cache_bh);
 err_btree:
 	for (i = 0; i < nb_sq_config; i++)
-		regex_ctrl_destroy_sq(qp, i);
+		regex_ctrl_destroy_inner_qp(qp, i);
 	regex_ctrl_destroy_cq(&qp->cq);
 err_cq:
-	rte_free(qp->sqs);
+	rte_free(qp->qps);
 	return ret;
 }