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 D158B1B2AC for ; Fri, 17 Nov 2017 16:08:37 +0100 (CET) Received: by mail-wm0-f68.google.com with SMTP id y82so3742237wmg.1 for ; Fri, 17 Nov 2017 07:08:37 -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=Ntwu8sdMrkiShJz8U3NVm6/nCEu0nWOZGUCZjVCEdyM=; b=acd5nWp/x0TZ7H5fis+5y3Kh/gKasaJi10CqfqIquvTttf82rblFisuWF6tJLd04jW AX5Uz39N1yy/A3YqR2A5LikosdjFSSLaRRQBtCf5kYv6/MEmjN7ttBDLKlD0Xj+UC5XY 21QQ3xpQeqI88k6rVxGhopxeJpcbiIXCOceQ0/UQ4Q5iTC9Du0i0lbNbTNHEYVoyGjOD w4rrd3tnGZDCi4faCcWZRZIsYxZtGFKES1acIziaMQZIDPDD3ts9iX80zqoqSDV9C9Md Q61vbDQ5u1aolNfNybZfDJYoAb0oIrHOBFmDl+nB0EwrxkLpTG1QBnOmZsleIHrtiHy/ lLtQ== 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=Ntwu8sdMrkiShJz8U3NVm6/nCEu0nWOZGUCZjVCEdyM=; b=ihESa2vafoKEXlnIjlha7RX0hGtucskam+NyAMAo7BWko8LW95Qc0tdMZAxAOxhb6Z bZHHnLAlYGlX1AAFfRvUlkZIwN46ulCGSUPk9QYNbLQSm7oIUZNTF3REsCFOGwkglNGU UGqyH3anGM2Cy5IriiljqKKy/6X7QjlR9pC5AUto1+DoquLl8SVui62r5387zZWLiiX2 nQAsOkcQkjLNBK9Ayx0pGZqagBPfLP8yKuDr8QGx3V6tYCh5bvZ53PMD6ny5XmcqmRim ENQV05iy1vFnSzw3Otww1sDEkAVrf97NqreBXDnwSOaPUhOKNq82g9JBwE5ESFss9HiC 2Q6Q== X-Gm-Message-State: AJaThX5ft9xttvSOwR021W0TZSjHbrnnRnQyv82YKt0urjwMDlXPVwC1 64O3DWhocAOO50EzmaK2njxD X-Google-Smtp-Source: AGs4zMYlHyKqf0QXz6JPPvOzxmqWdxxa8XnHc//tysKQh417D3V8RCUmjZa1sHpqs961Z+XAGOlNrA== X-Received: by 10.80.138.136 with SMTP id j8mr7932623edj.111.1510931317708; Fri, 17 Nov 2017 07:08:37 -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 i61sm2923914edc.32.2017.11.17.07.08.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 17 Nov 2017 07:08:36 -0800 (PST) Date: Fri, 17 Nov 2017 16:08:26 +0100 From: Nelio Laranjeiro To: Thierry Herbelot Cc: dev@dpdk.org, Shahaf Shuler , Adrien Mazarguil Message-ID: <20171117150826.ufbo5kjcx6lanajh@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 15:08:39 -0000 On Fri, Nov 17, 2017 at 02:51:34PM +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