[v7,3/4] net/mlx5: fix warning about rte_memcpy length

Message ID 20230116130724.50277-3-mb@smartsharesystems.com (mailing list archive)
State Accepted, archived
Delegated to: Raslan Darawsheh
Headers
Series [v7,1/4] net/bnx2x: fix warnings about rte_memcpy lengths |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Morten Brørup Jan. 16, 2023, 1:07 p.m. UTC
  Use RTE_PTR_ADD where copying to the offset of a field in a structure
holding multiple fields, to avoid compiler warnings with decorated
rte_memcpy.

Fixes: 16a7dbc4f69006cc1c96ca2a2c6d3e3c51a2ff50 ("net/mlx5: make flow modify action list thread safe")
Cc: xuemingl@nvidia.com
Cc: matan@nvidia.com
Cc: viacheslavo@nvidia.com

Signed-off-by: Morten Brørup <mb@smartsharesystems.com>
---
v7:
* No changes.
v6:
* Add Fixes to patch description.
v5:
* First patch in series.
---
 drivers/net/mlx5/mlx5_flow_dv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Morten Brørup Feb. 9, 2023, 4:54 p.m. UTC | #1
PING mlx5 maintainers. Care to review this minor improvement, so it can be included in 23.03?

> From: Morten Brørup [mailto:mb@smartsharesystems.com]
> Sent: Monday, 16 January 2023 14.07
> 
> Use RTE_PTR_ADD where copying to the offset of a field in a structure
> holding multiple fields, to avoid compiler warnings with decorated
> rte_memcpy.
> 
> Fixes: 16a7dbc4f69006cc1c96ca2a2c6d3e3c51a2ff50 ("net/mlx5: make flow
> modify action list thread safe")
> Cc: xuemingl@nvidia.com
> Cc: matan@nvidia.com
> Cc: viacheslavo@nvidia.com
> 
> Signed-off-by: Morten Brørup <mb@smartsharesystems.com>
> ---
> v7:
> * No changes.
> v6:
> * Add Fixes to patch description.
> v5:
> * First patch in series.
> ---
>  drivers/net/mlx5/mlx5_flow_dv.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/mlx5/mlx5_flow_dv.c
> b/drivers/net/mlx5/mlx5_flow_dv.c
> index 62c38b87a1..dd9f5fda1a 100644
> --- a/drivers/net/mlx5/mlx5_flow_dv.c
> +++ b/drivers/net/mlx5/mlx5_flow_dv.c
> @@ -5662,7 +5662,7 @@ flow_dv_modify_create_cb(void *tool_ctx, void
> *cb_ctx)
>  				   "cannot allocate resource memory");
>  		return NULL;
>  	}
> -	rte_memcpy(&entry->ft_type,
> +	rte_memcpy(RTE_PTR_ADD(entry, offsetof(typeof(*entry), ft_type)),
>  		   RTE_PTR_ADD(ref, offsetof(typeof(*ref), ft_type)),
>  		   key_len + data_len);
>  	if (entry->ft_type == MLX5DV_FLOW_TABLE_TYPE_FDB)
> --
> 2.17.1
  
Slava Ovsiienko Feb. 10, 2023, 9:13 a.m. UTC | #2
> -----Original Message-----
> From: Morten Brørup <mb@smartsharesystems.com>
> Sent: Thursday, February 9, 2023 6:54 PM
> To: dev@dpdk.org; Matan Azrad <matan@nvidia.com>; Slava Ovsiienko
> <viacheslavo@nvidia.com>; Xueming(Steven) Li <xuemingl@nvidia.com>
> Cc: ruifeng.wang@arm.com; zhoumin@loongson.cn; drc@linux.vnet.ibm.com;
> kda@semihalf.com; bruce.richardson@intel.com;
> konstantin.v.ananyev@yandex.ru; timothy.mcdaniel@intel.com;
> rmody@marvell.com; roretzla@linux.microsoft.com
> Subject: RE: [PATCH v7 3/4] net/mlx5: fix warning about rte_memcpy length
> 
> PING mlx5 maintainers. Care to review this minor improvement, so it can be
> included in 23.03?
> 
> > From: Morten Brørup [mailto:mb@smartsharesystems.com]
> > Sent: Monday, 16 January 2023 14.07
> >
> > Use RTE_PTR_ADD where copying to the offset of a field in a structure
> > holding multiple fields, to avoid compiler warnings with decorated
> > rte_memcpy.
> >
> > Fixes: 16a7dbc4f69006cc1c96ca2a2c6d3e3c51a2ff50 ("net/mlx5: make flow
> > modify action list thread safe")
> > Cc: xuemingl@nvidia.com
> > Cc: matan@nvidia.com
> > Cc: viacheslavo@nvidia.com
> >
> > Signed-off-by: Morten Brørup <mb@smartsharesystems.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
  
Raslan Darawsheh March 13, 2024, 10 a.m. UTC | #3
Hi,
> -----Original Message-----
> From: Morten Brørup <mb@smartsharesystems.com>
> Sent: Monday, January 16, 2023 3:07 PM
> To: dev@dpdk.org; roretzla@linux.microsoft.com; rmody@marvell.com;
> timothy.mcdaniel@intel.com; Matan Azrad <matan@nvidia.com>; Slava
> Ovsiienko <viacheslavo@nvidia.com>
> Cc: ruifeng.wang@arm.com; zhoumin@loongson.cn;
> drc@linux.vnet.ibm.com; kda@semihalf.com; bruce.richardson@intel.com;
> konstantin.v.ananyev@yandex.ru; Morten Brørup
> <mb@smartsharesystems.com>; Xueming(Steven) Li <xuemingl@nvidia.com>
> Subject: [PATCH v7 3/4] net/mlx5: fix warning about rte_memcpy length
> 
> Use RTE_PTR_ADD where copying to the offset of a field in a structure holding
> multiple fields, to avoid compiler warnings with decorated rte_memcpy.
> 
> Fixes: 16a7dbc4f69006cc1c96ca2a2c6d3e3c51a2ff50 ("net/mlx5: make flow
> modify action list thread safe")
> Cc: xuemingl@nvidia.com
> Cc: matan@nvidia.com
> Cc: viacheslavo@nvidia.com
> 
> Signed-off-by: Morten Brørup <mb@smartsharesystems.com>

Patch applied to next-net-mlx,

Kindest regards
Raslan Darawsheh
  

Patch

diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 62c38b87a1..dd9f5fda1a 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -5662,7 +5662,7 @@  flow_dv_modify_create_cb(void *tool_ctx, void *cb_ctx)
 				   "cannot allocate resource memory");
 		return NULL;
 	}
-	rte_memcpy(&entry->ft_type,
+	rte_memcpy(RTE_PTR_ADD(entry, offsetof(typeof(*entry), ft_type)),
 		   RTE_PTR_ADD(ref, offsetof(typeof(*ref), ft_type)),
 		   key_len + data_len);
 	if (entry->ft_type == MLX5DV_FLOW_TABLE_TYPE_FDB)