* [PATCH] net/mlx5: fix jump ipool entry size
@ 2023-08-25 18:43 Dariusz Sosnowski
2023-09-22 0:20 ` Suanming Mou
2023-10-09 7:50 ` Raslan Darawsheh
0 siblings, 2 replies; 3+ messages in thread
From: Dariusz Sosnowski @ 2023-08-25 18:43 UTC (permalink / raw)
To: Matan Azrad, Viacheslav Ovsiienko, Ori Kam, Suanming Mou; +Cc: dev, stable
In mlx5 PMD, MLX5_IPOOL_JUMP ipool configuration is used to initialize
the ipool containing either:
- flow table entry when DV flow engine is chosen or,
- group table entry when HW steering flow engine is chosen.
Default configuration for MLX5_IPOOL_JUMP ipool specified entry size as
size of mlx5_flow_tbl_data_entry struct, used with DV flow engine.
This could lead to memory corruption when mlx5_flow_group struct
(used with HW steering flow engine) would have bigger size than
mlx5_flow_tbl_data_entry.
This patch fixes that. Entry size for MLX5_IPOOL_JUMP ipool is chosen
dynamically based on device configuration.
Fixes: d1559d66ed2d ("net/mlx5: add table management")
Cc: suanmingm@nvidia.com
Cc: stable@dpdk.org
Signed-off-by: Dariusz Sosnowski <dsosnowski@nvidia.com>
---
drivers/net/mlx5/mlx5.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index b373306f98..7c79cbb7be 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -241,7 +241,12 @@ static const struct mlx5_indexed_pool_config mlx5_ipool_cfg[] = {
.type = "mlx5_port_id_ipool",
},
[MLX5_IPOOL_JUMP] = {
- .size = sizeof(struct mlx5_flow_tbl_data_entry),
+ /*
+ * MLX5_IPOOL_JUMP ipool entry size depends on selected flow engine.
+ * When HW steering is enabled mlx5_flow_group struct is used.
+ * Otherwise mlx5_flow_tbl_data_entry struct is used.
+ */
+ .size = 0,
.trunk_size = 64,
.grow_trunk = 3,
.grow_shift = 2,
@@ -904,6 +909,14 @@ mlx5_flow_ipool_create(struct mlx5_dev_ctx_shared *sh)
sizeof(struct mlx5_flow_handle) :
MLX5_FLOW_HANDLE_VERBS_SIZE;
break;
+#if defined(HAVE_IBV_FLOW_DV_SUPPORT) || !defined(HAVE_INFINIBAND_VERBS_H)
+ /* Set MLX5_IPOOL_JUMP ipool entry size depending on selected flow engine. */
+ case MLX5_IPOOL_JUMP:
+ cfg.size = sh->config.dv_flow_en == 2 ?
+ sizeof(struct mlx5_flow_group) :
+ sizeof(struct mlx5_flow_tbl_data_entry);
+ break;
+#endif
}
if (sh->config.reclaim_mode) {
cfg.release_mem_en = 1;
--
2.25.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH] net/mlx5: fix jump ipool entry size
2023-08-25 18:43 [PATCH] net/mlx5: fix jump ipool entry size Dariusz Sosnowski
@ 2023-09-22 0:20 ` Suanming Mou
2023-10-09 7:50 ` Raslan Darawsheh
1 sibling, 0 replies; 3+ messages in thread
From: Suanming Mou @ 2023-09-22 0:20 UTC (permalink / raw)
To: Dariusz Sosnowski, Matan Azrad, Slava Ovsiienko, Ori Kam; +Cc: dev, stable
Thanks.
> -----Original Message-----
> From: Dariusz Sosnowski <dsosnowski@nvidia.com>
> Sent: Saturday, August 26, 2023 2:44 AM
> To: Matan Azrad <matan@nvidia.com>; Slava Ovsiienko
> <viacheslavo@nvidia.com>; Ori Kam <orika@nvidia.com>; Suanming Mou
> <suanmingm@nvidia.com>
> Cc: dev@dpdk.org; stable@dpdk.org
> Subject: [PATCH] net/mlx5: fix jump ipool entry size
>
> In mlx5 PMD, MLX5_IPOOL_JUMP ipool configuration is used to initialize the ipool
> containing either:
>
> - flow table entry when DV flow engine is chosen or,
> - group table entry when HW steering flow engine is chosen.
>
> Default configuration for MLX5_IPOOL_JUMP ipool specified entry size as size of
> mlx5_flow_tbl_data_entry struct, used with DV flow engine.
> This could lead to memory corruption when mlx5_flow_group struct (used with
> HW steering flow engine) would have bigger size than mlx5_flow_tbl_data_entry.
>
> This patch fixes that. Entry size for MLX5_IPOOL_JUMP ipool is chosen
> dynamically based on device configuration.
>
> Fixes: d1559d66ed2d ("net/mlx5: add table management")
> Cc: suanmingm@nvidia.com
> Cc: stable@dpdk.org
>
> Signed-off-by: Dariusz Sosnowski <dsosnowski@nvidia.com>
Acked-by: Suanming Mou <suanmingm@nvidia.com>
> ---
> drivers/net/mlx5/mlx5.c | 15 ++++++++++++++-
> 1 file changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index
> b373306f98..7c79cbb7be 100644
> --- a/drivers/net/mlx5/mlx5.c
> +++ b/drivers/net/mlx5/mlx5.c
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH] net/mlx5: fix jump ipool entry size
2023-08-25 18:43 [PATCH] net/mlx5: fix jump ipool entry size Dariusz Sosnowski
2023-09-22 0:20 ` Suanming Mou
@ 2023-10-09 7:50 ` Raslan Darawsheh
1 sibling, 0 replies; 3+ messages in thread
From: Raslan Darawsheh @ 2023-10-09 7:50 UTC (permalink / raw)
To: Dariusz Sosnowski, Matan Azrad, Slava Ovsiienko, Ori Kam, Suanming Mou
Cc: dev, stable
Hi,
> -----Original Message-----
> From: Dariusz Sosnowski <dsosnowski@nvidia.com>
> Sent: Friday, August 25, 2023 9:44 PM
> To: Matan Azrad <matan@nvidia.com>; Slava Ovsiienko
> <viacheslavo@nvidia.com>; Ori Kam <orika@nvidia.com>; Suanming Mou
> <suanmingm@nvidia.com>
> Cc: dev@dpdk.org; stable@dpdk.org
> Subject: [PATCH] net/mlx5: fix jump ipool entry size
>
> In mlx5 PMD, MLX5_IPOOL_JUMP ipool configuration is used to initialize the
> ipool containing either:
>
> - flow table entry when DV flow engine is chosen or,
> - group table entry when HW steering flow engine is chosen.
>
> Default configuration for MLX5_IPOOL_JUMP ipool specified entry size as size
> of mlx5_flow_tbl_data_entry struct, used with DV flow engine.
> This could lead to memory corruption when mlx5_flow_group struct (used
> with HW steering flow engine) would have bigger size than
> mlx5_flow_tbl_data_entry.
>
> This patch fixes that. Entry size for MLX5_IPOOL_JUMP ipool is chosen
> dynamically based on device configuration.
>
> Fixes: d1559d66ed2d ("net/mlx5: add table management")
> Cc: suanmingm@nvidia.com
> Cc: stable@dpdk.org
Patch applied to next-net-mlx,
Kindest regards,
Raslan Darawsheh
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-10-09 7:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-25 18:43 [PATCH] net/mlx5: fix jump ipool entry size Dariusz Sosnowski
2023-09-22 0:20 ` Suanming Mou
2023-10-09 7:50 ` Raslan Darawsheh
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).