From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by dpdk.org (Postfix) with ESMTP id A99DC1B2AC for ; Fri, 17 Nov 2017 08:55:10 +0100 (CET) Received: by mail-wm0-f68.google.com with SMTP id 9so4580022wme.4 for ; Thu, 16 Nov 2017 23:55:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=odr0euDgHtXQD7UhvnYULwbgpKovvCSOIFtr8waj2kw=; b=uWdxBegkS2HUHeNYkRm5cZCmfaAChA+OoTuq02ZjSqmM6H+57kmJVLpf1O1+jovQRQ A4jOdHMNdfYt2IzmRJP9Sntx3bPRYV0UoP7fmgJXiTd/bFzLVc7dvWPCHfgcWXUz0MN3 Pn7VVzP9jDeAMVYt/Eg2hiED0qE9VET3IOkr0iMYuHEGsDu+FiOYEHRSzTyJ/41HMXg3 bt8STAuwaFx6+LTBY87N4V7Jlbbn1BUiKyozS291or3zo2UVxKk1CWJDGBPJiZLSminw ehhF4RbSCy9bWRrRH9FfYHGRrLKyw++KuKNgWpP21mARr+XFwErlQqyh8hgj+90+GMyO LVYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=odr0euDgHtXQD7UhvnYULwbgpKovvCSOIFtr8waj2kw=; b=Maxq9QrYfOOwBiBSdtTFKnNBoXgFHVGoonHzLb0ond1uhu5SXND3NpG5828KK3aiNQ LOjFStCXQN7N6juUnXTa6ZMcfjnpYrn1jIMAKrvoR9eSMC5OEAuVW61OrQLptDsu0a2f yooWREaEzgjOx0kTbzH61SVUlalkeHXxVK59sfhd60qc54m/dJ9jHr1y91FQj+OQU+9b Ldl8e3vb//xpo8NQLDthpHCFud60Ck585xm6xdvITcT13AGqVyZzhQnyoyYjeWAvwJ8d FBhE4PvmQjZAPMVImlz2CpoR5n3s5ZM+rt/xtyHjFN8skFceG++gumDGLm47ldZF49on H4+g== X-Gm-Message-State: AJaThX74T3r0YrjOUdCeeglEXI7wBgyjQf9GAReH7DptJCf5jGt6HbSk cUGwA/c8hGhK5+7REK/Y2CQ3 X-Google-Smtp-Source: AGs4zMavUvMByUeuRbu4gFgY0LfPWmVKyIDQeFc8eGxJy29JYm3kDoiYkpW9QlNVeQ0X8XDX9LFo9A== X-Received: by 10.28.51.3 with SMTP id z3mr3839883wmz.158.1510905310359; Thu, 16 Nov 2017 23:55:10 -0800 (PST) Received: from laranjeiro-vm.dev.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id o8sm9163310wrc.10.2017.11.16.23.55.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 16 Nov 2017 23:55:09 -0800 (PST) Date: Fri, 17 Nov 2017 08:55:00 +0100 From: Nelio Laranjeiro To: Thierry Herbelot Cc: dev@dpdk.org, Shahaf Shuler , Adrien Mazarguil , stable@dpdk.org Message-ID: <20171117075500.bgusljznteuhwdo2@laranjeiro-vm.dev.6wind.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [dpdk-stable] [PATCH] net/mlx5: cleanup the allocation of the buffer used for the ethtool stats X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Nov 2017 07:55:10 -0000 + stable@dpdk.org On Thu, Nov 16, 2017 at 05:34:47PM +0100, Thierry Herbelot wrote: > 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 > --- > 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 Acked-by: Nelio Laranjeiro Thanks, -- Nélio Laranjeiro 6WIND