[v1,7/7] crypto/dpaa2_sec: rework debug code

Message ID 20240806084136.3212615-8-g.singh@nxp.com (mailing list archive)
State Superseded
Delegated to: Thomas Monjalon
Headers
Series DPAA2 crypto changes |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/github-robot: build success github build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-marvell-Functional success Functional Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-unit-arm64-testing pending Testing pending
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-unit-amd64-testing pending Testing pending
ci/iol-compile-amd64-testing pending Testing pending
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-sample-apps-testing success Testing PASS

Commit Message

Gagandeep Singh Aug. 6, 2024, 8:41 a.m. UTC
From: Jun Yang <jun.yang@nxp.com>

Output debug information according to various modes.

Signed-off-by: Jun Yang <jun.yang@nxp.com>
---
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 63 ++++++++++++++++-----
 1 file changed, 48 insertions(+), 15 deletions(-)
  

Comments

Hemant Agrawal Aug. 6, 2024, 8:47 a.m. UTC | #1
Hi Gagan,

On 06-08-2024 14:11, Gagandeep Singh wrote:
> From: Jun Yang <jun.yang@nxp.com>
>
> Output debug information according to various modes.
>
> Signed-off-by: Jun Yang <jun.yang@nxp.com>
> ---
>   drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 63 ++++++++++++++++-----
>   1 file changed, 48 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
> index 1e28c71b53..da3bd871ba 100644
> --- a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
> +++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
> @@ -1095,7 +1095,7 @@ build_auth_fd(dpaa2_sec_session *sess, struct rte_crypto_op *op,
>   
>   static int
>   build_cipher_sg_fd(dpaa2_sec_session *sess, struct rte_crypto_op *op,
> -		struct qbman_fd *fd, __rte_unused uint16_t bpid)
> +		struct qbman_fd *fd, uint16_t bpid)
>   {
>   	struct rte_crypto_sym_op *sym_op = op->sym;
>   	struct qbman_fle *ip_fle, *op_fle, *sge, *fle;
> @@ -1105,6 +1105,10 @@ build_cipher_sg_fd(dpaa2_sec_session *sess, struct rte_crypto_op *op,
>   	struct rte_mbuf *mbuf;
>   	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(op, uint8_t *,
>   			sess->iv.offset);
> +#if (RTE_LOG_DEBUG <= RTE_LOG_DP_LEVEL)
> +	char debug_str[1024];
> +	int offset;
> +#endif
>   
>   	data_len = sym_op->cipher.data.length;
>   	data_offset = sym_op->cipher.data.offset;
> @@ -1210,14 +1214,26 @@ build_cipher_sg_fd(dpaa2_sec_session *sess, struct rte_crypto_op *op,
>   	DPAA2_SET_FD_COMPOUND_FMT(fd);
>   	DPAA2_SET_FD_FLC(fd, DPAA2_VADDR_TO_IOVA(flc));
>   
> -	DPAA2_SEC_DP_DEBUG(
> -		"CIPHER SG: fdaddr =%" PRIx64 " bpid =%d meta =%d"
> -		" off =%d, len =%d\n",
> +#if (RTE_LOG_DEBUG <= RTE_LOG_DP_LEVEL)
> +	offset = sprintf(debug_str,
> +		"CIPHER SG: fdaddr =%" PRIx64 ", from %s pool ",
>   		DPAA2_GET_FD_ADDR(fd),
> -		DPAA2_GET_FD_BPID(fd),
> -		rte_dpaa2_bpid_info[bpid].meta_data_size,
> -		DPAA2_GET_FD_OFFSET(fd),
> -		DPAA2_GET_FD_LEN(fd));
> +		bpid < MAX_BPID ? "SW" : "BMAN");
> +	if (bpid < MAX_BPID) {
> +		offset += sprintf(&debug_str[offset],
> +			"bpid = %d ", bpid);
> +	}
> +	offset += sprintf(&debug_str[offset],
> +		"private size = %d ",
> +		mbuf->pool->private_data_size);
> +	offset += sprintf(&debug_str[offset],
> +		"off =%d, len =%d\n",
> +		DPAA2_GET_FD_OFFSET(fd), DPAA2_GET_FD_LEN(fd));
> +		DPAA2_SEC_DP_DEBUG("%s", debug_str);
> +#else
> +	RTE_SET_USED(bpid);
> +#endif
> +
>   	return 0;
>   }
>   
> @@ -1233,6 +1249,10 @@ build_cipher_fd(dpaa2_sec_session *sess, struct rte_crypto_op *op,
>   	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(op, uint8_t *,
>   			sess->iv.offset);
>   	struct rte_mbuf *dst;
> +#if (RTE_LOG_DEBUG <= RTE_LOG_DP_LEVEL)
> +	char debug_str[1024];
> +	int offset;
> +#endif
>   
>   	data_len = sym_op->cipher.data.length;
>   	data_offset = sym_op->cipher.data.offset;
> @@ -1324,14 +1344,23 @@ build_cipher_fd(dpaa2_sec_session *sess, struct rte_crypto_op *op,
>   	DPAA2_SET_FLE_FIN(sge);
>   	DPAA2_SET_FLE_FIN(fle);
>   
> -	DPAA2_SEC_DP_DEBUG(
> -		"CIPHER: fdaddr =%" PRIx64 " bpid =%d meta =%d"
> -		" off =%d, len =%d\n",
> +#if (RTE_LOG_DEBUG <= RTE_LOG_DP_LEVEL)
> +	offset = sprintf(debug_str,
> +		"CIPHER: fdaddr =%" PRIx64 ", from %s pool ",
>   		DPAA2_GET_FD_ADDR(fd),
> -		DPAA2_GET_FD_BPID(fd),
> -		rte_dpaa2_bpid_info[bpid].meta_data_size,
> -		DPAA2_GET_FD_OFFSET(fd),
> -		DPAA2_GET_FD_LEN(fd));
> +		bpid < MAX_BPID ? "SW" : "BMAN");
> +	if (bpid < MAX_BPID) {
> +		offset += sprintf(&debug_str[offset],
> +			"bpid = %d ", bpid);
> +	}
> +	offset += sprintf(&debug_str[offset],
> +			"private size = %d ",
> +			dst->pool->private_data_size);
> +	offset += sprintf(&debug_str[offset],
> +			"off =%d, len =%d\n",
> +			DPAA2_GET_FD_OFFSET(fd), DPAA2_GET_FD_LEN(fd));
> +	DPAA2_SEC_DP_DEBUG("%s", debug_str);
> +#endif
>   
>   	return 0;
>   }
> @@ -1564,6 +1593,10 @@ sec_fd_to_mbuf(const struct qbman_fd *fd, struct dpaa2_sec_qp *qp)
>   	struct qbman_fle *fle;
>   	struct rte_crypto_op *op;
>   	struct rte_mbuf *dst, *src;
> +#if (RTE_LOG_DEBUG <= RTE_LOG_DP_LEVEL)
> +	char debug_str[1024];
> +	int offset;
> +#endif

you have defined these variables but not used?  have you missed 
something in this patch?


>   
>   	if (DPAA2_FD_GET_FORMAT(fd) == qbman_fd_single)
>   		return sec_simple_fd_to_mbuf(fd);
  

Patch

diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
index 1e28c71b53..da3bd871ba 100644
--- a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
+++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
@@ -1095,7 +1095,7 @@  build_auth_fd(dpaa2_sec_session *sess, struct rte_crypto_op *op,
 
 static int
 build_cipher_sg_fd(dpaa2_sec_session *sess, struct rte_crypto_op *op,
-		struct qbman_fd *fd, __rte_unused uint16_t bpid)
+		struct qbman_fd *fd, uint16_t bpid)
 {
 	struct rte_crypto_sym_op *sym_op = op->sym;
 	struct qbman_fle *ip_fle, *op_fle, *sge, *fle;
@@ -1105,6 +1105,10 @@  build_cipher_sg_fd(dpaa2_sec_session *sess, struct rte_crypto_op *op,
 	struct rte_mbuf *mbuf;
 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(op, uint8_t *,
 			sess->iv.offset);
+#if (RTE_LOG_DEBUG <= RTE_LOG_DP_LEVEL)
+	char debug_str[1024];
+	int offset;
+#endif
 
 	data_len = sym_op->cipher.data.length;
 	data_offset = sym_op->cipher.data.offset;
@@ -1210,14 +1214,26 @@  build_cipher_sg_fd(dpaa2_sec_session *sess, struct rte_crypto_op *op,
 	DPAA2_SET_FD_COMPOUND_FMT(fd);
 	DPAA2_SET_FD_FLC(fd, DPAA2_VADDR_TO_IOVA(flc));
 
-	DPAA2_SEC_DP_DEBUG(
-		"CIPHER SG: fdaddr =%" PRIx64 " bpid =%d meta =%d"
-		" off =%d, len =%d\n",
+#if (RTE_LOG_DEBUG <= RTE_LOG_DP_LEVEL)
+	offset = sprintf(debug_str,
+		"CIPHER SG: fdaddr =%" PRIx64 ", from %s pool ",
 		DPAA2_GET_FD_ADDR(fd),
-		DPAA2_GET_FD_BPID(fd),
-		rte_dpaa2_bpid_info[bpid].meta_data_size,
-		DPAA2_GET_FD_OFFSET(fd),
-		DPAA2_GET_FD_LEN(fd));
+		bpid < MAX_BPID ? "SW" : "BMAN");
+	if (bpid < MAX_BPID) {
+		offset += sprintf(&debug_str[offset],
+			"bpid = %d ", bpid);
+	}
+	offset += sprintf(&debug_str[offset],
+		"private size = %d ",
+		mbuf->pool->private_data_size);
+	offset += sprintf(&debug_str[offset],
+		"off =%d, len =%d\n",
+		DPAA2_GET_FD_OFFSET(fd), DPAA2_GET_FD_LEN(fd));
+		DPAA2_SEC_DP_DEBUG("%s", debug_str);
+#else
+	RTE_SET_USED(bpid);
+#endif
+
 	return 0;
 }
 
@@ -1233,6 +1249,10 @@  build_cipher_fd(dpaa2_sec_session *sess, struct rte_crypto_op *op,
 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(op, uint8_t *,
 			sess->iv.offset);
 	struct rte_mbuf *dst;
+#if (RTE_LOG_DEBUG <= RTE_LOG_DP_LEVEL)
+	char debug_str[1024];
+	int offset;
+#endif
 
 	data_len = sym_op->cipher.data.length;
 	data_offset = sym_op->cipher.data.offset;
@@ -1324,14 +1344,23 @@  build_cipher_fd(dpaa2_sec_session *sess, struct rte_crypto_op *op,
 	DPAA2_SET_FLE_FIN(sge);
 	DPAA2_SET_FLE_FIN(fle);
 
-	DPAA2_SEC_DP_DEBUG(
-		"CIPHER: fdaddr =%" PRIx64 " bpid =%d meta =%d"
-		" off =%d, len =%d\n",
+#if (RTE_LOG_DEBUG <= RTE_LOG_DP_LEVEL)
+	offset = sprintf(debug_str,
+		"CIPHER: fdaddr =%" PRIx64 ", from %s pool ",
 		DPAA2_GET_FD_ADDR(fd),
-		DPAA2_GET_FD_BPID(fd),
-		rte_dpaa2_bpid_info[bpid].meta_data_size,
-		DPAA2_GET_FD_OFFSET(fd),
-		DPAA2_GET_FD_LEN(fd));
+		bpid < MAX_BPID ? "SW" : "BMAN");
+	if (bpid < MAX_BPID) {
+		offset += sprintf(&debug_str[offset],
+			"bpid = %d ", bpid);
+	}
+	offset += sprintf(&debug_str[offset],
+			"private size = %d ",
+			dst->pool->private_data_size);
+	offset += sprintf(&debug_str[offset],
+			"off =%d, len =%d\n",
+			DPAA2_GET_FD_OFFSET(fd), DPAA2_GET_FD_LEN(fd));
+	DPAA2_SEC_DP_DEBUG("%s", debug_str);
+#endif
 
 	return 0;
 }
@@ -1564,6 +1593,10 @@  sec_fd_to_mbuf(const struct qbman_fd *fd, struct dpaa2_sec_qp *qp)
 	struct qbman_fle *fle;
 	struct rte_crypto_op *op;
 	struct rte_mbuf *dst, *src;
+#if (RTE_LOG_DEBUG <= RTE_LOG_DP_LEVEL)
+	char debug_str[1024];
+	int offset;
+#endif
 
 	if (DPAA2_FD_GET_FORMAT(fd) == qbman_fd_single)
 		return sec_simple_fd_to_mbuf(fd);