From: Cheng-Yang Chou <yphbchou0911@gmail.com>
To: yphbchou0911@gmail.com
Cc: charlie910417@gmail.com, jserv@ccns.ncku.edu.tw, leon@kernel.org,
mbloch@nvidia.com, netdev@vger.kernel.org, saeedm@nvidia.com,
tariqt@nvidia.com
Subject: [PATCH v3] net/mlx5/core: Allocate ttc_params on heap
Date: Fri, 27 Feb 2026 01:46:01 +0800 [thread overview]
Message-ID: <20260226174601.2120282-1-yphbchou0911@gmail.com> (raw)
In-Reply-To: <20260226114219.2111793-1-yphbchou0911@gmail.com>
The ttc_params structure is too large to be allocated on the stack,
triggering warnings for exceeding the 1024-byte frame size limit.
Consuming excessive stack space risks causing stack overflows.
Allocate the structure dynamically to maintain safe stack boundaries.
Signed-off-by: Po-Ying Chiu <charlie910417@gmail.com>
Signed-off-by: Cheng-Yang Chou <yphbchou0911@gmail.com>
Suggested-by: Leon Romanovsky <leon@kernel.org>
---
Changes in v3:
- Use tabs instead of spaces for indentation
- Link to v2: https://lore.kernel.org/all/20260226114219.2111793-1-yphbchou0911@gmail.com/
Changes in v2:
- Use kzalloc_obj() instead of kzalloc() to align with the new memory
allocation API introduced in v7.0-rc1 (Leon Romanovsky)
- Link to v1: https://lore.kernel.org/all/20260226092857.1583984-1-yphbchou0911@gmail.com/
.../net/ethernet/mellanox/mlx5/core/en_rep.c | 15 +++++++++----
.../net/ethernet/mellanox/mlx5/core/en_tc.c | 15 ++++++++++---
.../mellanox/mlx5/core/lag/port_sel.c | 22 ++++++++++++++-----
3 files changed, 39 insertions(+), 13 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
index 1db4ecb2356f..c3a4dc2b4a1a 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
@@ -966,27 +966,34 @@ static int mlx5e_create_rep_ttc_table(struct mlx5e_priv *priv)
{
struct mlx5e_rep_priv *rpriv = priv->ppriv;
struct mlx5_eswitch_rep *rep = rpriv->rep;
- struct ttc_params ttc_params = {};
+ struct ttc_params *ttc_params;
int err;
+ ttc_params = kzalloc_obj(*ttc_params);
+ if (!ttc_params)
+ return -ENOMEM;
+
mlx5e_fs_set_ns(priv->fs,
mlx5_get_flow_namespace(priv->mdev,
MLX5_FLOW_NAMESPACE_KERNEL), false);
/* The inner_ttc in the ttc params is intentionally not set */
- mlx5e_set_ttc_params(priv->fs, priv->rx_res, &ttc_params, false, false);
+ mlx5e_set_ttc_params(priv->fs, priv->rx_res, ttc_params, false, false);
if (rep->vport != MLX5_VPORT_UPLINK)
/* To give uplik rep TTC a lower level for chaining from root ft */
- ttc_params.ft_attr.level = MLX5E_TTC_FT_LEVEL + 1;
+ ttc_params->ft_attr.level = MLX5E_TTC_FT_LEVEL + 1;
- mlx5e_fs_set_ttc(priv->fs, mlx5_create_ttc_table(priv->mdev, &ttc_params), false);
+ mlx5e_fs_set_ttc(priv->fs, mlx5_create_ttc_table(priv->mdev, ttc_params), false);
if (IS_ERR(mlx5e_fs_get_ttc(priv->fs, false))) {
err = PTR_ERR(mlx5e_fs_get_ttc(priv->fs, false));
netdev_err(priv->netdev, "Failed to create rep ttc table, err=%d\n",
err);
+ kfree(ttc_params);
return err;
}
+
+ kfree(ttc_params);
return 0;
}
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index 1434b65d4746..b7525da60f92 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -855,7 +855,7 @@ static void mlx5e_hairpin_set_ttc_params(struct mlx5e_hairpin *hp,
static int mlx5e_hairpin_rss_init(struct mlx5e_hairpin *hp)
{
struct mlx5e_priv *priv = hp->func_priv;
- struct ttc_params ttc_params;
+ struct ttc_params *ttc_params;
struct mlx5_ttc_table *ttc;
int err;
@@ -867,8 +867,14 @@ static int mlx5e_hairpin_rss_init(struct mlx5e_hairpin *hp)
if (err)
goto err_create_indirect_tirs;
- mlx5e_hairpin_set_ttc_params(hp, &ttc_params);
- hp->ttc = mlx5_create_ttc_table(priv->mdev, &ttc_params);
+ ttc_params = kzalloc_obj(*ttc_params);
+ if (!ttc_params) {
+ err = -ENOMEM;
+ goto err_alloc_ttc_params;
+ }
+
+ mlx5e_hairpin_set_ttc_params(hp, ttc_params);
+ hp->ttc = mlx5_create_ttc_table(priv->mdev, ttc_params);
if (IS_ERR(hp->ttc)) {
err = PTR_ERR(hp->ttc);
goto err_create_ttc_table;
@@ -879,9 +885,12 @@ static int mlx5e_hairpin_rss_init(struct mlx5e_hairpin *hp)
hp->num_channels,
mlx5_get_ttc_flow_table(ttc)->id);
+ kfree(ttc_params);
return 0;
err_create_ttc_table:
+ kfree(ttc_params);
+err_alloc_ttc_params:
mlx5e_hairpin_destroy_indirect_tirs(hp);
err_create_indirect_tirs:
mlx5e_rqt_destroy(&hp->indir_rqt);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lag/port_sel.c b/drivers/net/ethernet/mellanox/mlx5/core/lag/port_sel.c
index 16c7d16215c4..a8fc1b920e0e 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lag/port_sel.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lag/port_sel.c
@@ -514,15 +514,20 @@ static int mlx5_lag_create_ttc_table(struct mlx5_lag *ldev)
{
int first_idx = mlx5_lag_get_dev_index_by_seq(ldev, MLX5_LAG_P1);
struct mlx5_lag_port_sel *port_sel = &ldev->port_sel;
- struct ttc_params ttc_params = {};
+ struct ttc_params *ttc_params;
struct mlx5_core_dev *dev;
if (first_idx < 0)
return -EINVAL;
+ ttc_params = kzalloc_obj(*ttc_params);
+ if (!ttc_params)
+ return -ENOMEM;
+
dev = ldev->pf[first_idx].dev;
- mlx5_lag_set_outer_ttc_params(ldev, &ttc_params);
- port_sel->outer.ttc = mlx5_create_ttc_table(dev, &ttc_params);
+ mlx5_lag_set_outer_ttc_params(ldev, ttc_params);
+ port_sel->outer.ttc = mlx5_create_ttc_table(dev, ttc_params);
+ kfree(ttc_params);
return PTR_ERR_OR_ZERO(port_sel->outer.ttc);
}
@@ -530,15 +535,20 @@ static int mlx5_lag_create_inner_ttc_table(struct mlx5_lag *ldev)
{
int first_idx = mlx5_lag_get_dev_index_by_seq(ldev, MLX5_LAG_P1);
struct mlx5_lag_port_sel *port_sel = &ldev->port_sel;
- struct ttc_params ttc_params = {};
+ struct ttc_params *ttc_params;
struct mlx5_core_dev *dev;
if (first_idx < 0)
return -EINVAL;
+ ttc_params = kzalloc_obj(*ttc_params);
+ if (!ttc_params)
+ return -ENOMEM;
+
dev = ldev->pf[first_idx].dev;
- mlx5_lag_set_inner_ttc_params(ldev, &ttc_params);
- port_sel->inner.ttc = mlx5_create_inner_ttc_table(dev, &ttc_params);
+ mlx5_lag_set_inner_ttc_params(ldev, ttc_params);
+ port_sel->inner.ttc = mlx5_create_inner_ttc_table(dev, ttc_params);
+ kfree(ttc_params);
return PTR_ERR_OR_ZERO(port_sel->inner.ttc);
}
--
2.48.1
next prev parent reply other threads:[~2026-02-26 17:46 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-26 11:42 [PATCH v2] net/mlx5/core: Allocate ttc_params on heap Cheng-Yang Chou
2026-02-26 17:46 ` Cheng-Yang Chou [this message]
2026-03-03 10:36 ` [PATCH v3] " Cheng-Yang Chou
2026-03-04 7:53 ` Tariq Toukan
2026-03-14 17:30 ` Cheng-Yang Chou
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260226174601.2120282-1-yphbchou0911@gmail.com \
--to=yphbchou0911@gmail.com \
--cc=charlie910417@gmail.com \
--cc=jserv@ccns.ncku.edu.tw \
--cc=leon@kernel.org \
--cc=mbloch@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=saeedm@nvidia.com \
--cc=tariqt@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox