From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id D69BEA046B for ; Thu, 25 Jul 2019 09:36:52 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3C9561C28E; Thu, 25 Jul 2019 09:36:51 +0200 (CEST) Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.196]) by dpdk.org (Postfix) with ESMTP id D65EA1C26A for ; Thu, 25 Jul 2019 09:36:49 +0200 (CEST) Received: by mail-pl1-f196.google.com with SMTP id b3so23076024plr.4 for ; Thu, 25 Jul 2019 00:36:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=5dwthFGM7T3v9wSe6a4XlbaAXVRtLWR5xLOxIOr28mU=; b=GYalh08/i9apyvuGhSp1TdF4M386FFuUIs6ZQ1RZUrV0953SytLVCwk/G6VsQ2zY6g jgfkwu3AzcUixyc6kbWcXxgBewrRA7CLrIUhsm4Rg0qNGiR+ZfJbhwHuInCYKkAC/2XV V84QUoFaQ1079wwbGFoNLMFVoY1CnnumIUES0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=5dwthFGM7T3v9wSe6a4XlbaAXVRtLWR5xLOxIOr28mU=; b=bxVoF2uMskgD6i2f+m2xG4omxKFZRNJA+iLrHT+URxD/kGz0oSQFqn6nlr5m6b48d/ weEARjDDnrrG8wbqr5XhyY/+U2C/I/cQlhrmWK38gysyTMYufAr+U0+I36szKJgEGvXP esFoYrJVyxod1/k8f631bRc0U+oj5NlqxthcmyeQPe25xmLXTe/XOrqgphmZaot8Mdt1 NyWR2YCpf1CGe8dSORewRqGByjo6vtLRBg7zJ4S+9qhRaM6kilJHDzg4X7w47jDPnGty dLQkzNBacCDjp+Q5aLBsHxKX3IoUSiZgTVTVTKL+hVkK57rzEJveLb4snH8r6rGUkI66 j9hw== X-Gm-Message-State: APjAAAXD/k3gEANsBkBcp12BCntDqAVHr3wufXIi0xPxe3EZSoYhowXY iKXS2XWGCcTe1NTNuVkXelxUb9pVORnddSUSskrOuboy X-Google-Smtp-Source: APXvYqybtckzlkg3mcNjXIKoLKPW2UqRMRjBFRPMQxj5JIZn/GrGUzzCKGqG80WgD++LiNtbl2FvY9mf0A486snoVgk= X-Received: by 2002:a17:902:bcc4:: with SMTP id o4mr87970416pls.90.1564040208572; Thu, 25 Jul 2019 00:36:48 -0700 (PDT) MIME-Version: 1.0 References: <20190725045949.27407-1-somnath.kotur@broadcom.com> <20190725045949.27407-2-somnath.kotur@broadcom.com> In-Reply-To: <20190725045949.27407-2-somnath.kotur@broadcom.com> From: Somnath Kotur Date: Thu, 25 Jul 2019 13:07:28 +0530 Message-ID: To: dev , Santoshkumar Karanappa Rastapur Cc: Ferruh Yigit Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [dpdk-dev] [PATCH 1/4] net/bnxt: fix extended port counter statistics 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" +Santoshkumar Karanappa Rastapur On Thu, Jul 25, 2019 at 10:35 AM Somnath Kotur wrote: > From: Santoshkumar Karanappa Rastapur > > We were trying to fill in more rx extended stats than the size allocated > for stats causing segfault. Fixed this by adding an explicit check. > Rearranged the code to return statistic values in xstats_get as per the > names returned in xstats_get_names. > > Fixes: f55e12f33416 ("net/bnxt: support extended port counters") > > Signed-off-by: Rahul Gupta > Signed-off-by: Santoshkumar Karanappa Rastapur < > santosh.rastapur@broadcom.com> > Signed-off-by: Somnath Kotur > --- > drivers/net/bnxt/bnxt_stats.c | 24 ++++++++++++++---------- > 1 file changed, 14 insertions(+), 10 deletions(-) > > diff --git a/drivers/net/bnxt/bnxt_stats.c b/drivers/net/bnxt/bnxt_stats.c > index 4e74f8a..69ac2dd 100644 > --- a/drivers/net/bnxt/bnxt_stats.c > +++ b/drivers/net/bnxt/bnxt_stats.c > @@ -427,8 +427,12 @@ int bnxt_dev_xstats_get_op(struct rte_eth_dev > *eth_dev, > bnxt_hwrm_port_qstats(bp); > bnxt_hwrm_func_qstats_tx_drop(bp, 0xffff, &tx_drop_pkts); > bnxt_hwrm_ext_port_qstats(bp); > - rx_port_stats_ext_cnt = bp->fw_rx_port_stats_ext_size / stat_size; > - tx_port_stats_ext_cnt = bp->fw_tx_port_stats_ext_size / stat_size; > + rx_port_stats_ext_cnt = RTE_MIN(RTE_DIM(bnxt_rx_ext_stats_strings), > + (bp->fw_rx_port_stats_ext_size / > + stat_size)); > + tx_port_stats_ext_cnt = RTE_MIN(RTE_DIM(bnxt_tx_ext_stats_strings), > + (bp->fw_tx_port_stats_ext_size / > + stat_size)); > > count = RTE_DIM(bnxt_rx_stats_strings) + > RTE_DIM(bnxt_tx_stats_strings) + 1/* For tx_drop_pkts */ + > @@ -463,22 +467,22 @@ int bnxt_dev_xstats_get_op(struct rte_eth_dev > *eth_dev, > xstats[count].value = rte_le_to_cpu_64(tx_drop_pkts); > count++; > > - for (i = 0; i < tx_port_stats_ext_cnt; i++) { > - uint64_t *tx_stats_ext = (uint64_t > *)bp->hw_tx_port_stats_ext; > + for (i = 0; i < rx_port_stats_ext_cnt; i++) { > + uint64_t *rx_stats_ext = (uint64_t > *)bp->hw_rx_port_stats_ext; > > xstats[count].value = rte_le_to_cpu_64 > - (*(uint64_t *)((char > *)tx_stats_ext + > - > bnxt_tx_ext_stats_strings[i].offset)); > + (*(uint64_t *)((char > *)rx_stats_ext + > + > bnxt_rx_ext_stats_strings[i].offset)); > > count++; > } > > - for (i = 0; i < rx_port_stats_ext_cnt; i++) { > - uint64_t *rx_stats_ext = (uint64_t > *)bp->hw_rx_port_stats_ext; > + for (i = 0; i < tx_port_stats_ext_cnt; i++) { > + uint64_t *tx_stats_ext = (uint64_t > *)bp->hw_tx_port_stats_ext; > > xstats[count].value = rte_le_to_cpu_64 > - (*(uint64_t *)((char > *)rx_stats_ext + > - > bnxt_rx_ext_stats_strings[i].offset)); > + (*(uint64_t *)((char > *)tx_stats_ext + > + > bnxt_tx_ext_stats_strings[i].offset)); > > count++; > } > -- > 1.8.3.1 > >