[v3,17/30] baseband: replace use of fixed size rte_memcpy

Message ID 20240402215502.278838-18-stephen@networkplumber.org (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series replace rte_memcpy of fixed size with memcpy |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Stephen Hemminger April 2, 2024, 9:50 p.m. UTC
Automatically generated by devtools/cocci/rte_memcpy.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/baseband/acc/rte_acc100_pmd.c  | 17 ++++++++---------
 drivers/baseband/acc/rte_vrb_pmd.c     | 21 ++++++++++-----------
 drivers/baseband/la12xx/bbdev_la12xx.c |  4 ++--
 3 files changed, 20 insertions(+), 22 deletions(-)
  

Comments

Chautru, Nicolas April 5, 2024, 1:22 a.m. UTC | #1
Hi Stephen, 

Your script is causing some odd line split which are not required I believe. Also doing mix of space and tabs. 

-		rte_memcpy(&desc->req.fcw_ld, &desc_first->req.fcw_ld, ACC_FCW_LD_BLEN);
+		memcpy(&desc->req.fcw_ld, &desc_first->req.fcw_ld,
+		       ACC_FCW_LD_BLEN);

> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Tuesday, April 2, 2024 2:51 PM
> To: dev@dpdk.org
> Cc: Stephen Hemminger <stephen@networkplumber.org>; Chautru, Nicolas
> <nicolas.chautru@intel.com>; Gagandeep Singh <g.singh@nxp.com>; Hemant
> Agrawal <hemant.agrawal@nxp.com>
> Subject: [PATCH v3 17/30] baseband: replace use of fixed size rte_memcpy
> 
> Automatically generated by devtools/cocci/rte_memcpy.cocci
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>  drivers/baseband/acc/rte_acc100_pmd.c  | 17 ++++++++---------
>  drivers/baseband/acc/rte_vrb_pmd.c     | 21 ++++++++++-----------
>  drivers/baseband/la12xx/bbdev_la12xx.c |  4 ++--
>  3 files changed, 20 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/baseband/acc/rte_acc100_pmd.c
> b/drivers/baseband/acc/rte_acc100_pmd.c
> index 4f666e514b..6a6212f3de 100644
> --- a/drivers/baseband/acc/rte_acc100_pmd.c
> +++ b/drivers/baseband/acc/rte_acc100_pmd.c
> @@ -2975,15 +2975,13 @@ enqueue_ldpc_dec_one_op_cb(struct acc_queue
> *q, struct rte_bbdev_dec_op *op,
>  		uint8_t *prev_ptr = (uint8_t *) prev_desc;
>  		uint8_t *new_ptr = (uint8_t *) desc;
>  		/* Copy first 4 words and BDESCs */
> -		rte_memcpy(new_ptr, prev_ptr, ACC_5GUL_SIZE_0);
> -		rte_memcpy(new_ptr + ACC_5GUL_OFFSET_0,
> -				prev_ptr + ACC_5GUL_OFFSET_0,
> -				ACC_5GUL_SIZE_1);
> +		memcpy(new_ptr, prev_ptr, ACC_5GUL_SIZE_0);
> +		memcpy(new_ptr + ACC_5GUL_OFFSET_0,
> +		       prev_ptr + ACC_5GUL_OFFSET_0, ACC_5GUL_SIZE_1);
>  		desc->req.op_addr = prev_desc->req.op_addr;
>  		/* Copy FCW */
> -		rte_memcpy(new_ptr + ACC_DESC_FCW_OFFSET,
> -				prev_ptr + ACC_DESC_FCW_OFFSET,
> -				ACC_FCW_LD_BLEN);
> +		memcpy(new_ptr + ACC_DESC_FCW_OFFSET,
> +		       prev_ptr + ACC_DESC_FCW_OFFSET, ACC_FCW_LD_BLEN);
>  		acc100_dma_desc_ld_update(op, &desc->req, input,
> h_output,
>  				&in_offset, &h_out_offset,
>  				&h_out_length, harq_layout);
> @@ -3130,7 +3128,8 @@ enqueue_ldpc_dec_one_op_tb(struct acc_queue
> *q, struct rte_bbdev_dec_op *op,
>  		desc = acc_desc(q, total_enqueued_cbs);
>  		desc->req.data_ptrs[0].address = q->ring_addr_iova +
> fcw_offset;
>  		desc->req.data_ptrs[0].blen = ACC_FCW_LD_BLEN;
> -		rte_memcpy(&desc->req.fcw_ld, &desc_first->req.fcw_ld,
> ACC_FCW_LD_BLEN);
> +		memcpy(&desc->req.fcw_ld, &desc_first->req.fcw_ld,
> +		       ACC_FCW_LD_BLEN);
>  		ret = acc100_dma_desc_ld_fill(op, &desc->req, &input,
>  				h_output, &in_offset, &h_out_offset,
>  				&h_out_length,
> @@ -4430,7 +4429,7 @@ acc100_configure(const char *dev_name, struct
> rte_acc_conf *conf)
>  	struct acc_device *d = bbdev->data->dev_private;
> 
>  	/* Store configuration */
> -	rte_memcpy(&d->acc_conf, conf, sizeof(d->acc_conf));
> +	memcpy(&d->acc_conf, conf, sizeof(d->acc_conf));
> 
>  	value = acc_reg_read(d, HwPfPcieGpexBridgeControl);
>  	bool firstCfg = (value != ACC100_CFG_PCI_BRIDGE); diff --git
> a/drivers/baseband/acc/rte_vrb_pmd.c
> b/drivers/baseband/acc/rte_vrb_pmd.c
> index 88b1104fab..3e5376a12e 100644
> --- a/drivers/baseband/acc/rte_vrb_pmd.c
> +++ b/drivers/baseband/acc/rte_vrb_pmd.c
> @@ -2450,15 +2450,13 @@ vrb_enqueue_ldpc_dec_one_op_cb(struct
> acc_queue *q, struct rte_bbdev_dec_op *op,
>  		uint8_t *prev_ptr = (uint8_t *) prev_desc;
>  		uint8_t *new_ptr = (uint8_t *) desc;
>  		/* Copy first 4 words and BDESCs. */
> -		rte_memcpy(new_ptr, prev_ptr, ACC_5GUL_SIZE_0);
> -		rte_memcpy(new_ptr + ACC_5GUL_OFFSET_0,
> -				prev_ptr + ACC_5GUL_OFFSET_0,
> -				ACC_5GUL_SIZE_1);
> +		memcpy(new_ptr, prev_ptr, ACC_5GUL_SIZE_0);
> +		memcpy(new_ptr + ACC_5GUL_OFFSET_0,
> +		       prev_ptr + ACC_5GUL_OFFSET_0, ACC_5GUL_SIZE_1);
>  		desc->req.op_addr = prev_desc->req.op_addr;
>  		/* Copy FCW. */
> -		rte_memcpy(new_ptr + ACC_DESC_FCW_OFFSET,
> -				prev_ptr + ACC_DESC_FCW_OFFSET,
> -				ACC_FCW_LD_BLEN);
> +		memcpy(new_ptr + ACC_DESC_FCW_OFFSET,
> +		       prev_ptr + ACC_DESC_FCW_OFFSET, ACC_FCW_LD_BLEN);
>  		vrb_dma_desc_ld_update(op, &desc->req, input, h_output,
>  				&in_offset, &h_out_offset,
>  				&h_out_length, harq_layout);
> @@ -2566,7 +2564,8 @@ vrb_enqueue_ldpc_dec_one_op_tb(struct
> acc_queue *q, struct rte_bbdev_dec_op *op,
>  		fcw_offset = (desc_idx << 8) + ACC_DESC_FCW_OFFSET;
>  		desc->req.data_ptrs[0].address = q->ring_addr_iova +
> fcw_offset;
>  		desc->req.data_ptrs[0].blen = ACC_FCW_LD_BLEN;
> -		rte_memcpy(&desc->req.fcw_ld, &desc_first->req.fcw_ld,
> ACC_FCW_LD_BLEN);
> +		memcpy(&desc->req.fcw_ld, &desc_first->req.fcw_ld,
> +		       ACC_FCW_LD_BLEN);
>  		desc->req.fcw_ld.tb_trailer_size = (c - r - 1) * trail_len;
>  		ret = vrb_dma_desc_ld_fill(op, &desc->req, &input,
>  				h_output, &in_offset, &h_out_offset, @@ -
> 3991,7 +3990,7 @@ enqueue_mldts_split_op(struct acc_queue *q, struct
> rte_bbdev_mldts_op *op,
>  		if (symb == 0)
>  			desc->req.cbs_in_tb = num_syms;
>  		else
> -			rte_memcpy(&desc->req.fcw_mldts, fcw,
> ACC_FCW_MLDTS_BLEN);
> +			memcpy(&desc->req.fcw_mldts, fcw,
> ACC_FCW_MLDTS_BLEN);
>  		desc->req.data_ptrs[1].address =
> rte_pktmbuf_iova_offset(input_q, in_offset);
>  		desc->req.data_ptrs[1].blen = q_size;
>  		in_offset += q_size;
> @@ -4337,7 +4336,7 @@ vrb1_configure(const char *dev_name, struct
> rte_acc_conf *conf)
>  	struct acc_device *d = bbdev->data->dev_private;
> 
>  	/* Store configuration. */
> -	rte_memcpy(&d->acc_conf, conf, sizeof(d->acc_conf));
> +	memcpy(&d->acc_conf, conf, sizeof(d->acc_conf));
> 
>  	/* Check we are already out of PG. */
>  	status = acc_reg_read(d, VRB1_PfHiSectionPowerGatingAck); @@ -
> 4744,7 +4743,7 @@ vrb2_configure(const char *dev_name, struct
> rte_acc_conf *conf)
>  	struct acc_device *d = bbdev->data->dev_private;
> 
>  	/* Store configuration. */
> -	rte_memcpy(&d->acc_conf, conf, sizeof(d->acc_conf));
> +	memcpy(&d->acc_conf, conf, sizeof(d->acc_conf));
> 
>  	/* Explicitly releasing AXI as this may be stopped after PF FLR/BME. */
>  	address = VRB2_PfDmaAxiControl;
> diff --git a/drivers/baseband/la12xx/bbdev_la12xx.c
> b/drivers/baseband/la12xx/bbdev_la12xx.c
> index bb754a5395..23e2fdb811 100644
> --- a/drivers/baseband/la12xx/bbdev_la12xx.c
> +++ b/drivers/baseband/la12xx/bbdev_la12xx.c
> @@ -597,8 +597,8 @@ dequeue_single_op(struct bbdev_la12xx_q_priv
> *q_priv, void *dst)
> 
>  	op = q_priv->bbdev_op[ci];
> 
> -	rte_memcpy(dst, q_priv->msg_ch_vaddr[ci],
> -		sizeof(struct bbdev_ipc_enqueue_op));
> +	memcpy(dst, q_priv->msg_ch_vaddr[ci],
> +	       sizeof(struct bbdev_ipc_enqueue_op));
> 
>  	/* Move Consumer Index forward */
>  	ci++;
> --
> 2.43.0
  
Stephen Hemminger April 5, 2024, 3:02 p.m. UTC | #2
On Fri, 5 Apr 2024 01:22:59 +0000
"Chautru, Nicolas" <nicolas.chautru@intel.com> wrote:

> Hi Stephen, 
> 
> Your script is causing some odd line split which are not required I believe. Also doing mix of space and tabs. 
> 
> -		rte_memcpy(&desc->req.fcw_ld, &desc_first->req.fcw_ld, ACC_FCW_LD_BLEN);
> +		memcpy(&desc->req.fcw_ld, &desc_first->req.fcw_ld,
> +		       ACC_FCW_LD_BLEN);

The coccinelle spatch tool seems to still think that max line length should be 80.
Will fix these manually.
  

Patch

diff --git a/drivers/baseband/acc/rte_acc100_pmd.c b/drivers/baseband/acc/rte_acc100_pmd.c
index 4f666e514b..6a6212f3de 100644
--- a/drivers/baseband/acc/rte_acc100_pmd.c
+++ b/drivers/baseband/acc/rte_acc100_pmd.c
@@ -2975,15 +2975,13 @@  enqueue_ldpc_dec_one_op_cb(struct acc_queue *q, struct rte_bbdev_dec_op *op,
 		uint8_t *prev_ptr = (uint8_t *) prev_desc;
 		uint8_t *new_ptr = (uint8_t *) desc;
 		/* Copy first 4 words and BDESCs */
-		rte_memcpy(new_ptr, prev_ptr, ACC_5GUL_SIZE_0);
-		rte_memcpy(new_ptr + ACC_5GUL_OFFSET_0,
-				prev_ptr + ACC_5GUL_OFFSET_0,
-				ACC_5GUL_SIZE_1);
+		memcpy(new_ptr, prev_ptr, ACC_5GUL_SIZE_0);
+		memcpy(new_ptr + ACC_5GUL_OFFSET_0,
+		       prev_ptr + ACC_5GUL_OFFSET_0, ACC_5GUL_SIZE_1);
 		desc->req.op_addr = prev_desc->req.op_addr;
 		/* Copy FCW */
-		rte_memcpy(new_ptr + ACC_DESC_FCW_OFFSET,
-				prev_ptr + ACC_DESC_FCW_OFFSET,
-				ACC_FCW_LD_BLEN);
+		memcpy(new_ptr + ACC_DESC_FCW_OFFSET,
+		       prev_ptr + ACC_DESC_FCW_OFFSET, ACC_FCW_LD_BLEN);
 		acc100_dma_desc_ld_update(op, &desc->req, input, h_output,
 				&in_offset, &h_out_offset,
 				&h_out_length, harq_layout);
@@ -3130,7 +3128,8 @@  enqueue_ldpc_dec_one_op_tb(struct acc_queue *q, struct rte_bbdev_dec_op *op,
 		desc = acc_desc(q, total_enqueued_cbs);
 		desc->req.data_ptrs[0].address = q->ring_addr_iova + fcw_offset;
 		desc->req.data_ptrs[0].blen = ACC_FCW_LD_BLEN;
-		rte_memcpy(&desc->req.fcw_ld, &desc_first->req.fcw_ld, ACC_FCW_LD_BLEN);
+		memcpy(&desc->req.fcw_ld, &desc_first->req.fcw_ld,
+		       ACC_FCW_LD_BLEN);
 		ret = acc100_dma_desc_ld_fill(op, &desc->req, &input,
 				h_output, &in_offset, &h_out_offset,
 				&h_out_length,
@@ -4430,7 +4429,7 @@  acc100_configure(const char *dev_name, struct rte_acc_conf *conf)
 	struct acc_device *d = bbdev->data->dev_private;
 
 	/* Store configuration */
-	rte_memcpy(&d->acc_conf, conf, sizeof(d->acc_conf));
+	memcpy(&d->acc_conf, conf, sizeof(d->acc_conf));
 
 	value = acc_reg_read(d, HwPfPcieGpexBridgeControl);
 	bool firstCfg = (value != ACC100_CFG_PCI_BRIDGE);
diff --git a/drivers/baseband/acc/rte_vrb_pmd.c b/drivers/baseband/acc/rte_vrb_pmd.c
index 88b1104fab..3e5376a12e 100644
--- a/drivers/baseband/acc/rte_vrb_pmd.c
+++ b/drivers/baseband/acc/rte_vrb_pmd.c
@@ -2450,15 +2450,13 @@  vrb_enqueue_ldpc_dec_one_op_cb(struct acc_queue *q, struct rte_bbdev_dec_op *op,
 		uint8_t *prev_ptr = (uint8_t *) prev_desc;
 		uint8_t *new_ptr = (uint8_t *) desc;
 		/* Copy first 4 words and BDESCs. */
-		rte_memcpy(new_ptr, prev_ptr, ACC_5GUL_SIZE_0);
-		rte_memcpy(new_ptr + ACC_5GUL_OFFSET_0,
-				prev_ptr + ACC_5GUL_OFFSET_0,
-				ACC_5GUL_SIZE_1);
+		memcpy(new_ptr, prev_ptr, ACC_5GUL_SIZE_0);
+		memcpy(new_ptr + ACC_5GUL_OFFSET_0,
+		       prev_ptr + ACC_5GUL_OFFSET_0, ACC_5GUL_SIZE_1);
 		desc->req.op_addr = prev_desc->req.op_addr;
 		/* Copy FCW. */
-		rte_memcpy(new_ptr + ACC_DESC_FCW_OFFSET,
-				prev_ptr + ACC_DESC_FCW_OFFSET,
-				ACC_FCW_LD_BLEN);
+		memcpy(new_ptr + ACC_DESC_FCW_OFFSET,
+		       prev_ptr + ACC_DESC_FCW_OFFSET, ACC_FCW_LD_BLEN);
 		vrb_dma_desc_ld_update(op, &desc->req, input, h_output,
 				&in_offset, &h_out_offset,
 				&h_out_length, harq_layout);
@@ -2566,7 +2564,8 @@  vrb_enqueue_ldpc_dec_one_op_tb(struct acc_queue *q, struct rte_bbdev_dec_op *op,
 		fcw_offset = (desc_idx << 8) + ACC_DESC_FCW_OFFSET;
 		desc->req.data_ptrs[0].address = q->ring_addr_iova + fcw_offset;
 		desc->req.data_ptrs[0].blen = ACC_FCW_LD_BLEN;
-		rte_memcpy(&desc->req.fcw_ld, &desc_first->req.fcw_ld, ACC_FCW_LD_BLEN);
+		memcpy(&desc->req.fcw_ld, &desc_first->req.fcw_ld,
+		       ACC_FCW_LD_BLEN);
 		desc->req.fcw_ld.tb_trailer_size = (c - r - 1) * trail_len;
 		ret = vrb_dma_desc_ld_fill(op, &desc->req, &input,
 				h_output, &in_offset, &h_out_offset,
@@ -3991,7 +3990,7 @@  enqueue_mldts_split_op(struct acc_queue *q, struct rte_bbdev_mldts_op *op,
 		if (symb == 0)
 			desc->req.cbs_in_tb = num_syms;
 		else
-			rte_memcpy(&desc->req.fcw_mldts, fcw, ACC_FCW_MLDTS_BLEN);
+			memcpy(&desc->req.fcw_mldts, fcw, ACC_FCW_MLDTS_BLEN);
 		desc->req.data_ptrs[1].address = rte_pktmbuf_iova_offset(input_q, in_offset);
 		desc->req.data_ptrs[1].blen = q_size;
 		in_offset += q_size;
@@ -4337,7 +4336,7 @@  vrb1_configure(const char *dev_name, struct rte_acc_conf *conf)
 	struct acc_device *d = bbdev->data->dev_private;
 
 	/* Store configuration. */
-	rte_memcpy(&d->acc_conf, conf, sizeof(d->acc_conf));
+	memcpy(&d->acc_conf, conf, sizeof(d->acc_conf));
 
 	/* Check we are already out of PG. */
 	status = acc_reg_read(d, VRB1_PfHiSectionPowerGatingAck);
@@ -4744,7 +4743,7 @@  vrb2_configure(const char *dev_name, struct rte_acc_conf *conf)
 	struct acc_device *d = bbdev->data->dev_private;
 
 	/* Store configuration. */
-	rte_memcpy(&d->acc_conf, conf, sizeof(d->acc_conf));
+	memcpy(&d->acc_conf, conf, sizeof(d->acc_conf));
 
 	/* Explicitly releasing AXI as this may be stopped after PF FLR/BME. */
 	address = VRB2_PfDmaAxiControl;
diff --git a/drivers/baseband/la12xx/bbdev_la12xx.c b/drivers/baseband/la12xx/bbdev_la12xx.c
index bb754a5395..23e2fdb811 100644
--- a/drivers/baseband/la12xx/bbdev_la12xx.c
+++ b/drivers/baseband/la12xx/bbdev_la12xx.c
@@ -597,8 +597,8 @@  dequeue_single_op(struct bbdev_la12xx_q_priv *q_priv, void *dst)
 
 	op = q_priv->bbdev_op[ci];
 
-	rte_memcpy(dst, q_priv->msg_ch_vaddr[ci],
-		sizeof(struct bbdev_ipc_enqueue_op));
+	memcpy(dst, q_priv->msg_ch_vaddr[ci],
+	       sizeof(struct bbdev_ipc_enqueue_op));
 
 	/* Move Consumer Index forward */
 	ci++;