From: Maryam Tahhan Date: Wed, 15 Jul 2015 13:11:28 +0000 (+0100) Subject: ethdev: expose generic and driver specific stats in xstats X-Git-Tag: spdx-start~8712 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=d4fef8b0d5e5ca4595086c5f78d43f9cb54c4228;p=dpdk.git ethdev: expose generic and driver specific stats in xstats Extend rte_eth_xstats_get to retrieve additional stats from the device driver as well the ethdev generic stats. Signed-off-by: Maryam Tahhan Acked-by: Olivier Matz --- diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index c47b91f015..6e12a9ad6f 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -1661,26 +1661,35 @@ 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); @@ -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 */