From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 92FE41B2E9 for ; Fri, 20 Oct 2017 02:03:56 +0200 (CEST) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Oct 2017 17:03:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.43,404,1503385200"; d="scan'208";a="165254432" Received: from silpixa00372839.ir.intel.com (HELO silpixa00372839.ger.corp.intel.com) ([10.237.222.154]) by fmsmga006.fm.intel.com with ESMTP; 19 Oct 2017 17:03:54 -0700 From: Ferruh Yigit To: Thomas Monjalon Cc: dev@dpdk.org, Ferruh Yigit Date: Fri, 20 Oct 2017 01:03:49 +0100 Message-Id: <20171020000351.57868-1-ferruh.yigit@intel.com> X-Mailer: git-send-email 2.13.6 Subject: [dpdk-dev] [PATCH 1/3] ethdev: extract xstat basic stat count calculation 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, 20 Oct 2017 00:03:57 -0000 Extract into static inline function so that can be used by other functions. Signed-off-by: Ferruh Yigit --- lib/librte_ether/rte_ethdev.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 0b1e92894..798855e15 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -1550,6 +1550,22 @@ rte_eth_stats_reset(uint16_t port_id) return 0; } +static inline int +get_xstats_basic_count(struct rte_eth_dev *dev) +{ + uint16_t nb_rxqs, nb_txqs; + int count; + + nb_rxqs = RTE_MIN(dev->data->nb_rx_queues, RTE_ETHDEV_QUEUE_STAT_CNTRS); + nb_txqs = RTE_MIN(dev->data->nb_tx_queues, RTE_ETHDEV_QUEUE_STAT_CNTRS); + + count = RTE_NB_STATS; + count += nb_rxqs * RTE_NB_RXQ_STATS; + count += nb_txqs * RTE_NB_TXQ_STATS; + + return count; +} + static int get_xstats_count(uint16_t port_id) { @@ -1571,11 +1587,9 @@ get_xstats_count(uint16_t port_id) } else count = 0; - count += RTE_NB_STATS; - count += RTE_MIN(dev->data->nb_rx_queues, RTE_ETHDEV_QUEUE_STAT_CNTRS) * - RTE_NB_RXQ_STATS; - count += RTE_MIN(dev->data->nb_tx_queues, RTE_ETHDEV_QUEUE_STAT_CNTRS) * - RTE_NB_TXQ_STATS; + + count += get_xstats_basic_count(dev); + return count; } -- 2.13.6