diff mbox series

[2/2] mlx5: fix mlx5i_grp_sw_update_stats() stack usage

Message ID 20211108111040.3748899-2-arnd@kernel.org (mailing list archive)
State Awaiting Upstream
Delegated to: Netdev Maintainers
Headers show
Series [1/2] mlx5: fix psample_sample_packet link error | expand

Checks

Context Check Description
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 9 of 9 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch warning WARNING: please, no space before tabs
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/tree_selection success Guessing tree name failed - patch did not apply

Commit Message

Arnd Bergmann Nov. 8, 2021, 11:10 a.m. UTC
From: Arnd Bergmann <arnd@arndb.de>

The mlx5e_sw_stats structure has grown to the point of triggering
a warning when put on the stack of a function:

mlx5/core/ipoib/ipoib.c: In function 'mlx5i_grp_sw_update_stats':
mlx5/core/ipoib/ipoib.c:136:1: error: the frame size of 1028 bytes is larger than 1024 bytes [-Werror=frame-larger-than=]

In this case, only five of the structure members are actually set,
so it's sufficient to have those as separate local variables.
As en_rep.c uses 'struct rtnl_link_stats64' for this, just use
the same one here for consistency.

Fixes: def09e7bbc3d ("net/mlx5e: Add HW_GRO statistics")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 .../net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c    | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

Comments

Saeed Mahameed Nov. 16, 2021, 8:51 p.m. UTC | #1
On Mon, 2021-11-08 at 12:10 +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> The mlx5e_sw_stats structure has grown to the point of triggering
> a warning when put on the stack of a function:
> 
> mlx5/core/ipoib/ipoib.c: In function 'mlx5i_grp_sw_update_stats':
> mlx5/core/ipoib/ipoib.c:136:1: error: the frame size of 1028 bytes is
> larger than 1024 bytes [-Werror=frame-larger-than=]
> 
> In this case, only five of the structure members are actually set,
> so it's sufficient to have those as separate local variables.
> As en_rep.c uses 'struct rtnl_link_stats64' for this, just use
> the same one here for consistency.
> 
> Fixes: def09e7bbc3d ("net/mlx5e: Add HW_GRO statistics")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---

Thanks Arnd, Both patches applied to net-next-mlx5,

Since I will be queuing them up for net-next, I will have to remove the
Fixes tags.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c
index ea1efdecc88c..158958a49743 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c
@@ -110,7 +110,7 @@  void mlx5i_cleanup(struct mlx5e_priv *priv)
 
 static void mlx5i_grp_sw_update_stats(struct mlx5e_priv *priv)
 {
-	struct mlx5e_sw_stats s = { 0 };
+	struct rtnl_link_stats64 s = {};
 	int i, j;
 
 	for (i = 0; i < priv->stats_nch; i++) {
@@ -128,11 +128,17 @@  static void mlx5i_grp_sw_update_stats(struct mlx5e_priv *priv)
 
 			s.tx_packets           += sq_stats->packets;
 			s.tx_bytes             += sq_stats->bytes;
-			s.tx_queue_dropped     += sq_stats->dropped;
+			s.tx_dropped 	       += sq_stats->dropped;
 		}
 	}
 
-	memcpy(&priv->stats.sw, &s, sizeof(s));
+	memset(&priv->stats.sw, 0, sizeof(s));
+
+	priv->stats.sw.rx_packets = s.rx_packets;
+	priv->stats.sw.rx_bytes = s.rx_bytes;
+	priv->stats.sw.tx_packets = s.tx_packets;
+	priv->stats.sw.tx_bytes = s.tx_bytes;
+	priv->stats.sw.tx_queue_dropped = s.tx_dropped;
 }
 
 void mlx5i_get_stats(struct net_device *dev, struct rtnl_link_stats64 *stats)