From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by dpdk.org (Postfix) with ESMTP id ABC1A1B2AF for ; Fri, 17 Nov 2017 08:55:10 +0100 (CET) Received: by mail-wm0-f65.google.com with SMTP id x63so4613341wmf.2 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=q1sfK56VhqGVJ3hslSbmlomRl6k1oUem3yrxDB7zUcwojWvR8x9JMabESZlHgucFUV scyfM1Q0fgn5RXZtGe4aWKkcWkEvzxmv1KIex9NJiAVU+vE6BGMXqix1KfOxuLwIcdYK s25nF5ONWuR651Mb5G6OMzwGLRAR3zNbtuTJUZwvLowdSZZ39auJ42B0h0BHcs3Lcg8o 3zTXufGWSsbBPTJDbQV3LAZgbzoYJfg4QdVTeH/AQBOt0SO0Qww9fmhwZU6q1Te0Yzd0 bGKJ8/dcDF74rhvzr5yybBTVXjv/xrRCqsR0wU/UuSF1pvOyr0FJyBxYTumjw4wpPn5h BO0Q== X-Gm-Message-State: AJaThX621bKTYsR/MUKSDQGXSnDDoaHQo2r8az2PBxF9Cy7MVOvLdCX1 QTPxoXdn8e0R0hQnsY6q8iI8K/ttfg== 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-dev] [PATCH] net/mlx5: cleanup the allocation of the buffer used for the ethtool stats X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions 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