From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by dpdk.org (Postfix) with ESMTP id 0AF1A1B28F for ; Fri, 17 Nov 2017 14:52:21 +0100 (CET) Received: by mail-wm0-f66.google.com with SMTP id x63so6609867wmf.2 for ; Fri, 17 Nov 2017 05:52:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=nFk0QwV5IRMtVJRvFGimRgt9Fc9QJQnOB6MW5XV16Tc=; b=w0nqHKq9Kr4b1P4Pv2N8nmtMccwvFghXc/9jCa5wvY32ghI8jJIc3KW/N+pu3uLIC8 PMBOOktEhbS/P1Xog1SqraEUbnrFrF6VULaLpBaG4FfC04RVLylqmTeVA1puKI1pFNsS onmyKOmTWpHf9xaF+qQziP6Nkiu28pzMB87Pzz3YtIUG8S6uf1R8DXWA+GeSqFapI6Me uLB1eXXISbLDwkQsCNqeVAOG+uTkrFc6UKPY5eh24T5xFx9AUZj2nIbMDngkHI0nSqie MlH/Alwk8I3zNwfoGyfVCFyNq3y4acBeXdpv1EZ++3wjZyqXquE9nNBbVYeyJ/yAugq8 A7vA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=nFk0QwV5IRMtVJRvFGimRgt9Fc9QJQnOB6MW5XV16Tc=; b=cYeM01f4YdGo9a0VG9qRM7Rq6z52js4shAT3Dk69Hm0NbIjBgDnjAIlM/TKyMQI1LU z85F264AuNlv3x8VSgw6ftYkiMItZfp7qyJNq9XS3fkbhtnhxORnPpvKj3MY8UAFNk0h PvJucGqPCvgXVX1nlC7j9YMtDalgax79RypFZIculBf6jATPH8oEMstp1tsY5Mxpx6yw VXPGyrZN4UdxhN6RBJFjQqdxe2gutHclHyXDL3qo1M324VbObVYQjdu1uxnAQ1jZvoKv pdpVTWK64ktd+4dECdApNfTo6PNb4BYSv/mLXPW+VVsizOHYHSlPcaF0Xmu2KkIbCa36 AuQQ== X-Gm-Message-State: AJaThX7dwGMmgDdytQWo94PVp3XhALvP0tI5nvFBVoMYoV31gXxVHnk1 vOTZ2M/vNo8TNN51I9cetDudO/0= X-Google-Smtp-Source: AGs4zMYXIVnWQTHeBsJBKRDsRdjHdRlgAvSqdRZX2B8MrQgVrjSiNOQ5KPCYeSjtbl8Oee8bv4Js3w== X-Received: by 10.80.148.112 with SMTP id q45mr7449924eda.161.1510926741377; Fri, 17 Nov 2017 05:52:21 -0800 (PST) Received: from ascain.dev.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id f9sm703351edm.83.2017.11.17.05.52.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Nov 2017 05:52:20 -0800 (PST) From: Thierry Herbelot To: dev@dpdk.org Cc: Shahaf Shuler , Adrien Mazarguil , Nelio Laranjeiro Date: Fri, 17 Nov 2017 14:51:34 +0100 Message-Id: X-Mailer: git-send-email 2.11.0 In-Reply-To: References: Subject: [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 13:52:22 -0000 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