From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 033F29E5 for ; Wed, 15 Jul 2015 15:11:43 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 15 Jul 2015 06:11:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,480,1432623600"; d="scan'208";a="747772060" Received: from sie-lab-212-170.ir.intel.com (HELO silpixa00378251.ir.intel.com) ([10.237.212.170]) by fmsmga001.fm.intel.com with ESMTP; 15 Jul 2015 06:11:42 -0700 From: Maryam Tahhan To: dev@dpdk.org Date: Wed, 15 Jul 2015 14:11:28 +0100 Message-Id: <1436965894-130019-4-git-send-email-maryam.tahhan@intel.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1436965894-130019-1-git-send-email-maryam.tahhan@intel.com> References: <1436965894-130019-1-git-send-email-maryam.tahhan@intel.com> Subject: [dpdk-dev] [PATCH v6 3/9] ethdev: expose extended error stats X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Jul 2015 13:11:44 -0000 Extend rte_eth_xstats_get to retrieve additional stats from the device driver as well the ethdev generic stats. Signed-off-by: Maryam Tahhan --- lib/librte_ether/rte_ethdev.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) mode change 100644 => 100755 lib/librte_ether/rte_ethdev.c diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c old mode 100644 new mode 100755 index ddf3658..7689328 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -1661,33 +1661,42 @@ rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstats *xstats, { struct rte_eth_stats eth_stats; struct rte_eth_dev *dev; - unsigned count, i, q; + unsigned count = 0, i, q; + signed xcount = 0; uint64_t val, *stats_ptr; VALID_PORTID_OR_ERR_RET(port_id, -EINVAL); dev = &rte_eth_devices[port_id]; - /* implemented by the driver */ - if (dev->dev_ops->xstats_get != NULL) - return (*dev->dev_ops->xstats_get)(dev, xstats, n); - - /* else, return generic statistics */ + /* Return generic statistics */ count = RTE_NB_STATS; count += dev->data->nb_rx_queues * RTE_NB_RXQ_STATS; count += dev->data->nb_tx_queues * RTE_NB_TXQ_STATS; - if (n < count) - return count; - /* now fill the xstats structure */ + /* implemented by the driver */ + if (dev->dev_ops->xstats_get != NULL) { + /* Retrieve the xstats from the driver at the end of the + * xstats struct. + */ + xcount = (*dev->dev_ops->xstats_get)(dev, &xstats[count], + (n > count) ? n - count : 0); + if (xcount < 0) + return xcount; + } + + if (n < count + xcount) + return count + xcount; + + /* now fill the xstats structure */ count = 0; rte_eth_stats_get(port_id, ð_stats); /* global stats */ for (i = 0; i < RTE_NB_STATS; i++) { stats_ptr = RTE_PTR_ADD(ð_stats, - rte_stats_strings[i].offset); + rte_stats_strings[i].offset); val = *stats_ptr; snprintf(xstats[count].name, sizeof(xstats[count].name), "%s", rte_stats_strings[i].name); @@ -1722,7 +1731,7 @@ rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstats *xstats, } } - return count; + return count + xcount; } /* reset ethdev extended statistics */ -- 2.4.3