[v4,20/30] crypto: replace use of fixed size rte_memcpy

Message ID 20240405165518.367503-21-stephen@networkplumber.org (mailing list archive)
State Superseded
Delegated to: Thomas Monjalon
Headers
Series replace use of rte_memcpy with fixed sizes |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Stephen Hemminger April 5, 2024, 4:53 p.m. UTC
  Automatically generated by devtools/cocci/rte_memcpy.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
 drivers/crypto/dpaa_sec/dpaa_sec.c            |  2 +-
 drivers/crypto/ipsec_mb/pmd_snow3g.c          |  4 +-
 drivers/crypto/qat/qat_sym_session.c          | 52 +++++++++----------
 .../scheduler/rte_cryptodev_scheduler.c       |  6 +--
 drivers/crypto/scheduler/scheduler_failover.c | 12 ++---
 5 files changed, 37 insertions(+), 39 deletions(-)
  

Patch

diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.c b/drivers/crypto/dpaa_sec/dpaa_sec.c
index 44528eaf7f..3e7b78656b 100644
--- a/drivers/crypto/dpaa_sec/dpaa_sec.c
+++ b/drivers/crypto/dpaa_sec/dpaa_sec.c
@@ -676,7 +676,7 @@  dpaa_sec_dump(struct dpaa_sec_op_ctx *ctx, struct dpaa_sec_qp *qp)
 	}
 
 	cdb = &sess->cdb;
-	rte_memcpy(&c_cdb, cdb, sizeof(struct sec_cdb));
+	memcpy(&c_cdb, cdb, sizeof(struct sec_cdb));
 #ifdef RTE_LIB_SECURITY
 	printf("\nsession protocol type = %d\n", sess->proto_alg);
 #endif
diff --git a/drivers/crypto/ipsec_mb/pmd_snow3g.c b/drivers/crypto/ipsec_mb/pmd_snow3g.c
index a96779f059..f3f519f2d4 100644
--- a/drivers/crypto/ipsec_mb/pmd_snow3g.c
+++ b/drivers/crypto/ipsec_mb/pmd_snow3g.c
@@ -291,8 +291,8 @@  process_snow3g_hash_op(struct ipsec_mb_qp *qp, struct rte_crypto_op **ops,
 
 			/* Copy back digest from src to auth.digest.data */
 			if (digest_appended)
-				rte_memcpy(ops[i]->sym->auth.digest.data,
-					dst, SNOW3G_DIGEST_LENGTH);
+				memcpy(ops[i]->sym->auth.digest.data, dst,
+				       SNOW3G_DIGEST_LENGTH);
 		}
 		processed_ops++;
 	}
diff --git a/drivers/crypto/qat/qat_sym_session.c b/drivers/crypto/qat/qat_sym_session.c
index 9e2dba5423..a93625b287 100644
--- a/drivers/crypto/qat/qat_sym_session.c
+++ b/drivers/crypto/qat/qat_sym_session.c
@@ -1439,7 +1439,7 @@  static int partial_hash_sha1(uint8_t *data_in, uint8_t *data_out)
 	if (!SHA1_Init(&ctx))
 		return -EFAULT;
 	SHA1_Transform(&ctx, data_in);
-	rte_memcpy(data_out, &ctx, SHA_DIGEST_LENGTH);
+	memcpy(data_out, &ctx, SHA_DIGEST_LENGTH);
 	return 0;
 }
 
@@ -1450,7 +1450,7 @@  static int partial_hash_sha224(uint8_t *data_in, uint8_t *data_out)
 	if (!SHA224_Init(&ctx))
 		return -EFAULT;
 	SHA256_Transform(&ctx, data_in);
-	rte_memcpy(data_out, &ctx, SHA256_DIGEST_LENGTH);
+	memcpy(data_out, &ctx, SHA256_DIGEST_LENGTH);
 	return 0;
 }
 
@@ -1461,7 +1461,7 @@  static int partial_hash_sha256(uint8_t *data_in, uint8_t *data_out)
 	if (!SHA256_Init(&ctx))
 		return -EFAULT;
 	SHA256_Transform(&ctx, data_in);
-	rte_memcpy(data_out, &ctx, SHA256_DIGEST_LENGTH);
+	memcpy(data_out, &ctx, SHA256_DIGEST_LENGTH);
 	return 0;
 }
 
@@ -1472,7 +1472,7 @@  static int partial_hash_sha384(uint8_t *data_in, uint8_t *data_out)
 	if (!SHA384_Init(&ctx))
 		return -EFAULT;
 	SHA512_Transform(&ctx, data_in);
-	rte_memcpy(data_out, &ctx, SHA512_DIGEST_LENGTH);
+	memcpy(data_out, &ctx, SHA512_DIGEST_LENGTH);
 	return 0;
 }
 
@@ -1483,7 +1483,7 @@  static int partial_hash_sha512(uint8_t *data_in, uint8_t *data_out)
 	if (!SHA512_Init(&ctx))
 		return -EFAULT;
 	SHA512_Transform(&ctx, data_in);
-	rte_memcpy(data_out, &ctx, SHA512_DIGEST_LENGTH);
+	memcpy(data_out, &ctx, SHA512_DIGEST_LENGTH);
 	return 0;
 }
 
@@ -1494,7 +1494,7 @@  static int partial_hash_md5(uint8_t *data_in, uint8_t *data_out)
 	if (!MD5_Init(&ctx))
 		return -EFAULT;
 	MD5_Transform(&ctx, data_in);
-	rte_memcpy(data_out, &ctx, MD5_DIGEST_LENGTH);
+	memcpy(data_out, &ctx, MD5_DIGEST_LENGTH);
 
 	return 0;
 }
@@ -1615,8 +1615,7 @@  static int qat_sym_do_precomputes(enum icp_qat_hw_auth_algo hash_alg,
 				return -ENOMEM;
 			}
 
-			rte_memcpy(in, AES_CMAC_SEED,
-				   ICP_QAT_HW_AES_128_KEY_SZ);
+			memcpy(in, AES_CMAC_SEED, ICP_QAT_HW_AES_128_KEY_SZ);
 			rte_memcpy(p_state_buf, auth_key, auth_keylen);
 
 			if (AES_set_encrypt_key(auth_key, auth_keylen << 3,
@@ -1660,8 +1659,8 @@  static int qat_sym_do_precomputes(enum icp_qat_hw_auth_algo hash_alg,
 				return -ENOMEM;
 			}
 
-			rte_memcpy(in, qat_aes_xcbc_key_seed,
-					ICP_QAT_HW_AES_XCBC_MAC_STATE2_SZ);
+			memcpy(in, qat_aes_xcbc_key_seed,
+			       ICP_QAT_HW_AES_XCBC_MAC_STATE2_SZ);
 			for (x = 0; x < HASH_XCBC_PRECOMP_KEY_NUM; x++) {
 				if (AES_set_encrypt_key(auth_key,
 							auth_keylen << 3,
@@ -1924,8 +1923,8 @@  static int qat_sym_do_precomputes_ipsec_mb(enum icp_qat_hw_auth_algo hash_alg,
 
 		uint8_t *input = in;
 		uint8_t *out = p_state_buf;
-		rte_memcpy(input, qat_aes_xcbc_key_seed,
-				ICP_QAT_HW_AES_XCBC_MAC_STATE2_SZ);
+		memcpy(input, qat_aes_xcbc_key_seed,
+		       ICP_QAT_HW_AES_XCBC_MAC_STATE2_SZ);
 		for (i = 0; i < HASH_XCBC_PRECOMP_KEY_NUM; i++) {
 			if (aes_ipsecmb_job(input, out, m, auth_key, auth_keylen)) {
 				memset(input -
@@ -2441,8 +2440,8 @@  int qat_sym_cd_auth_set(struct qat_sym_session *cdesc,
 	cdesc->cd_cur_ptr += sizeof(struct icp_qat_hw_auth_setup);
 	switch (cdesc->qat_hash_alg) {
 	case ICP_QAT_HW_AUTH_ALGO_SM3:
-		rte_memcpy(cdesc->cd_cur_ptr, sm3InitialState,
-				sizeof(sm3InitialState));
+		memcpy(cdesc->cd_cur_ptr, sm3InitialState,
+		       sizeof(sm3InitialState));
 		state1_size = qat_hash_get_state1_size(
 				cdesc->qat_hash_alg);
 		state2_size = ICP_QAT_HW_SM3_STATE2_SZ;
@@ -2453,9 +2452,8 @@  int qat_sym_cd_auth_set(struct qat_sym_session *cdesc,
 		hash_2->auth_config.config =
 			ICP_QAT_HW_AUTH_CONFIG_BUILD(ICP_QAT_HW_AUTH_MODE2,
 				cdesc->qat_hash_alg, digestsize);
-		rte_memcpy(cdesc->cd_cur_ptr + state1_size + state2_size +
-			sizeof(*hash_2), sm3InitialState,
-			sizeof(sm3InitialState));
+		memcpy(cdesc->cd_cur_ptr + state1_size + state2_size + sizeof(*hash_2),
+		       sm3InitialState, sizeof(sm3InitialState));
 		hash_cd_ctrl->inner_state1_sz = state1_size;
 		hash_cd_ctrl->inner_state2_sz  = state2_size;
 		hash_cd_ctrl->inner_state2_offset =
@@ -2493,8 +2491,8 @@  int qat_sym_cd_auth_set(struct qat_sym_session *cdesc,
 	case ICP_QAT_HW_AUTH_ALGO_SHA1:
 		if (cdesc->auth_mode == ICP_QAT_HW_AUTH_MODE0) {
 			/* Plain SHA-1 */
-			rte_memcpy(cdesc->cd_cur_ptr, sha1InitialState,
-					sizeof(sha1InitialState));
+			memcpy(cdesc->cd_cur_ptr, sha1InitialState,
+			       sizeof(sha1InitialState));
 			state1_size = qat_hash_get_state1_size(
 					cdesc->qat_hash_alg);
 			break;
@@ -2520,8 +2518,8 @@  int qat_sym_cd_auth_set(struct qat_sym_session *cdesc,
 	case ICP_QAT_HW_AUTH_ALGO_SHA224:
 		if (cdesc->auth_mode == ICP_QAT_HW_AUTH_MODE0) {
 			/* Plain SHA-224 */
-			rte_memcpy(cdesc->cd_cur_ptr, sha224InitialState,
-					sizeof(sha224InitialState));
+			memcpy(cdesc->cd_cur_ptr, sha224InitialState,
+			       sizeof(sha224InitialState));
 			state1_size = qat_hash_get_state1_size(
 					cdesc->qat_hash_alg);
 			break;
@@ -2545,8 +2543,8 @@  int qat_sym_cd_auth_set(struct qat_sym_session *cdesc,
 	case ICP_QAT_HW_AUTH_ALGO_SHA256:
 		if (cdesc->auth_mode == ICP_QAT_HW_AUTH_MODE0) {
 			/* Plain SHA-256 */
-			rte_memcpy(cdesc->cd_cur_ptr, sha256InitialState,
-					sizeof(sha256InitialState));
+			memcpy(cdesc->cd_cur_ptr, sha256InitialState,
+			       sizeof(sha256InitialState));
 			state1_size = qat_hash_get_state1_size(
 					cdesc->qat_hash_alg);
 			break;
@@ -2570,8 +2568,8 @@  int qat_sym_cd_auth_set(struct qat_sym_session *cdesc,
 	case ICP_QAT_HW_AUTH_ALGO_SHA384:
 		if (cdesc->auth_mode == ICP_QAT_HW_AUTH_MODE0) {
 			/* Plain SHA-384 */
-			rte_memcpy(cdesc->cd_cur_ptr, sha384InitialState,
-					sizeof(sha384InitialState));
+			memcpy(cdesc->cd_cur_ptr, sha384InitialState,
+			       sizeof(sha384InitialState));
 			state1_size = qat_hash_get_state1_size(
 					cdesc->qat_hash_alg);
 			break;
@@ -2595,8 +2593,8 @@  int qat_sym_cd_auth_set(struct qat_sym_session *cdesc,
 	case ICP_QAT_HW_AUTH_ALGO_SHA512:
 		if (cdesc->auth_mode == ICP_QAT_HW_AUTH_MODE0) {
 			/* Plain SHA-512 */
-			rte_memcpy(cdesc->cd_cur_ptr, sha512InitialState,
-					sizeof(sha512InitialState));
+			memcpy(cdesc->cd_cur_ptr, sha512InitialState,
+			       sizeof(sha512InitialState));
 			state1_size = qat_hash_get_state1_size(
 					cdesc->qat_hash_alg);
 			break;
diff --git a/drivers/crypto/scheduler/rte_cryptodev_scheduler.c b/drivers/crypto/scheduler/rte_cryptodev_scheduler.c
index 9a21edd32a..ed1833a7c6 100644
--- a/drivers/crypto/scheduler/rte_cryptodev_scheduler.c
+++ b/drivers/crypto/scheduler/rte_cryptodev_scheduler.c
@@ -79,7 +79,7 @@  sync_caps(struct rte_cryptodev_capabilities *caps,
 
 		/* remove a uncommon cap from the array */
 		for (j = i; j < sync_nb_caps - 1; j++)
-			rte_memcpy(&caps[j], &caps[j+1], sizeof(*cap));
+			memcpy(&caps[j], &caps[j + 1], sizeof(*cap));
 
 		memset(&caps[sync_nb_caps - 1], 0, sizeof(*cap));
 		sync_nb_caps--;
@@ -216,8 +216,8 @@  sync_sec_caps(uint32_t worker_idx,
 		 * caps, from the arrays
 		 */
 		for (j = i; j < nb_sec_caps - 1; j++) {
-			rte_memcpy(&sec_caps[j], &sec_caps[j+1],
-					sizeof(*sec_cap));
+			memcpy(&sec_caps[j], &sec_caps[j + 1],
+			       sizeof(*sec_cap));
 
 			rte_memcpy(&sec_crypto_caps[j][0],
 					&sec_crypto_caps[j+1][0],
diff --git a/drivers/crypto/scheduler/scheduler_failover.c b/drivers/crypto/scheduler/scheduler_failover.c
index 52ff2ffbb7..e7c6d19d25 100644
--- a/drivers/crypto/scheduler/scheduler_failover.c
+++ b/drivers/crypto/scheduler/scheduler_failover.c
@@ -171,12 +171,12 @@  scheduler_start(struct rte_cryptodev *dev)
 		sched_ctx->workers[PRIMARY_WORKER_IDX].qp_id = i;
 		sched_ctx->workers[SECONDARY_WORKER_IDX].qp_id = i;
 
-		rte_memcpy(&qp_ctx->primary_worker,
-				&sched_ctx->workers[PRIMARY_WORKER_IDX],
-				sizeof(struct scheduler_worker));
-		rte_memcpy(&qp_ctx->secondary_worker,
-				&sched_ctx->workers[SECONDARY_WORKER_IDX],
-				sizeof(struct scheduler_worker));
+		memcpy(&qp_ctx->primary_worker,
+		       &sched_ctx->workers[PRIMARY_WORKER_IDX],
+		       sizeof(struct scheduler_worker));
+		memcpy(&qp_ctx->secondary_worker,
+		       &sched_ctx->workers[SECONDARY_WORKER_IDX],
+		       sizeof(struct scheduler_worker));
 	}
 
 	return 0;