DPDK patches and discussions
 help / color / mirror / Atom feed
From: Thierry Herbelot <thierry.herbelot@6wind.com>
To: dev@dpdk.org
Cc: Shahaf Shuler <shahafs@mellanox.com>,
	Adrien Mazarguil <adrien.mazarguil@6wind.com>,
	Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
Subject: [dpdk-dev] [PATCH] net/mlx5: cleanup the allocation of the buffer used for the ethtool stats
Date: Fri, 17 Nov 2017 14:51:34 +0100	[thread overview]
Message-ID: <ab5d3d0e8269f0f30759f4b536287b8e03f27147.1510849974.git.thierry.herbelot@6wind.com> (raw)
In-Reply-To: <ab5d3d0e8269f0f30759f4b536287b8e03f27147.1510849974.git.thierry.herbelot@6wind.com>

Simplify the computation for the needed size:
- exact size for the structure header,
- exact size for a number of 64-bit counters.

Fixes: a4193ae3bc4f ('net/mlx5: support extended statistics')

Signed-off-by: Thierry Herbelot <thierry.herbelot@6wind.com>
---
 drivers/net/mlx5/mlx5_stats.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_stats.c b/drivers/net/mlx5/mlx5_stats.c
index 5e225d3740d2..2427585f71ca 100644
--- a/drivers/net/mlx5/mlx5_stats.c
+++ b/drivers/net/mlx5/mlx5_stats.c
@@ -143,11 +143,9 @@ priv_read_dev_counters(struct priv *priv, uint64_t *stats)
 	struct mlx5_xstats_ctrl *xstats_ctrl = &priv->xstats_ctrl;
 	unsigned int i;
 	struct ifreq ifr;
-	unsigned int stats_sz = (xstats_ctrl->stats_n * sizeof(uint64_t)) +
-				 sizeof(struct ethtool_stats);
-	struct ethtool_stats et_stats[(stats_sz + (
-				      sizeof(struct ethtool_stats) - 1)) /
-				      sizeof(struct ethtool_stats)];
+	unsigned int stats_sz = xstats_ctrl->stats_n * sizeof(uint64_t);
+	unsigned char et_stat_buf[sizeof(struct ethtool_stats) + stats_sz];
+	struct ethtool_stats *et_stats = (struct ethtool_stats *)et_stat_buf;
 
 	et_stats->cmd = ETHTOOL_GSTATS;
 	et_stats->n_stats = xstats_ctrl->stats_n;
-- 
2.11.0

       reply	other threads:[~2017-11-17 13:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-17 13:51 Thierry Herbelot [this message]
2017-11-17  7:55 ` Nelio Laranjeiro
2017-11-23 13:00   ` Shahaf Shuler
2017-11-23 13:06     ` Thierry Herbelot
2017-11-23 13:20       ` Shahaf Shuler
2017-11-17 15:08 ` Nelio Laranjeiro

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=ab5d3d0e8269f0f30759f4b536287b8e03f27147.1510849974.git.thierry.herbelot@6wind.com \
    --to=thierry.herbelot@6wind.com \
    --cc=adrien.mazarguil@6wind.com \
    --cc=dev@dpdk.org \
    --cc=nelio.laranjeiro@6wind.com \
    --cc=shahafs@mellanox.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;
as well as URLs for NNTP newsgroup(s).